bitbank-lab-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +388 -0
- package/assets/lightweight-charts.standalone.js +7 -0
- package/bin/bitbank-lab-mcp.js +20 -0
- package/lib/cache.ts +70 -0
- package/lib/candle-utils.ts +48 -0
- package/lib/candle-validate.ts +434 -0
- package/lib/conversions.ts +25 -0
- package/lib/datetime.ts +157 -0
- package/lib/depth-analysis.ts +51 -0
- package/lib/error.ts +15 -0
- package/lib/formatter.ts +296 -0
- package/lib/get-depth.ts +111 -0
- package/lib/http.ts +132 -0
- package/lib/indicator-config.ts +39 -0
- package/lib/indicator_buffer.ts +41 -0
- package/lib/indicators.ts +579 -0
- package/lib/logger.ts +120 -0
- package/lib/ma-snapshot-utils.ts +277 -0
- package/lib/math.ts +89 -0
- package/lib/pattern-diagrams.ts +562 -0
- package/lib/result.ts +104 -0
- package/lib/validate.ts +154 -0
- package/lib/volatility.ts +132 -0
- package/package.json +79 -0
- package/src/env.ts +4 -0
- package/src/handlers/analyzeCandlePatternsHandler.ts +383 -0
- package/src/handlers/analyzeFibonacciHandler.ts +54 -0
- package/src/handlers/analyzeIndicatorsHandler.ts +682 -0
- package/src/handlers/analyzeMarketSignalHandler.ts +272 -0
- package/src/handlers/analyzeMyPortfolioHandler.ts +800 -0
- package/src/handlers/detectPatternsHandler.ts +77 -0
- package/src/handlers/detectPatternsViewsHandler.ts +518 -0
- package/src/handlers/getTickersJpyHandler.ts +145 -0
- package/src/handlers/getVolatilityMetricsHandler.ts +234 -0
- package/src/handlers/portfolio/calc.ts +549 -0
- package/src/handlers/portfolio/fetch.ts +318 -0
- package/src/handlers/portfolio/types.ts +170 -0
- package/src/handlers/renderChartSvgHandler.ts +69 -0
- package/src/handlers/runBacktestHandler.ts +70 -0
- package/src/http.ts +107 -0
- package/src/private/auth.ts +104 -0
- package/src/private/client.ts +298 -0
- package/src/private/config.ts +25 -0
- package/src/private/confirmation.ts +185 -0
- package/src/private/schemas.ts +866 -0
- package/src/prompts.ts +2296 -0
- package/src/resources/app-resources.ts +79 -0
- package/src/schema/analysis.ts +942 -0
- package/src/schema/backtest.ts +100 -0
- package/src/schema/base.ts +88 -0
- package/src/schema/candle-validate.ts +135 -0
- package/src/schema/chart.ts +399 -0
- package/src/schema/index.ts +11 -0
- package/src/schema/indicators.ts +125 -0
- package/src/schema/market-data.ts +298 -0
- package/src/schema/patterns.ts +382 -0
- package/src/schema/types.ts +97 -0
- package/src/schemas.d.ts +37 -0
- package/src/schemas.ts +7 -0
- package/src/server.ts +405 -0
- package/src/tool-definition.ts +44 -0
- package/src/tool-registry.ts +174 -0
- package/src/types/express-shim.d.ts +9 -0
- package/src/types/schemas.generated.d.ts +23 -0
- package/tools/analyze_bb_snapshot.ts +385 -0
- package/tools/analyze_candle_patterns.ts +810 -0
- package/tools/analyze_currency_strength.ts +273 -0
- package/tools/analyze_ema_snapshot.ts +183 -0
- package/tools/analyze_fibonacci.ts +530 -0
- package/tools/analyze_ichimoku_snapshot.ts +606 -0
- package/tools/analyze_indicators.ts +691 -0
- package/tools/analyze_market_signal.ts +665 -0
- package/tools/analyze_mtf_fibonacci.ts +273 -0
- package/tools/analyze_mtf_sma.ts +175 -0
- package/tools/analyze_sma_snapshot.ts +146 -0
- package/tools/analyze_stoch_snapshot.ts +276 -0
- package/tools/analyze_support_resistance.ts +817 -0
- package/tools/analyze_volume_profile.ts +546 -0
- package/tools/chart/ichimoku-cloud.ts +113 -0
- package/tools/chart/render-depth.ts +139 -0
- package/tools/chart/render-sub-panels.ts +208 -0
- package/tools/chart/svg-utils.ts +102 -0
- package/tools/detect_macd_cross.ts +691 -0
- package/tools/detect_patterns.ts +424 -0
- package/tools/detect_whale_events.ts +181 -0
- package/tools/get_candles.ts +487 -0
- package/tools/get_flow_metrics.ts +596 -0
- package/tools/get_orderbook.ts +540 -0
- package/tools/get_ticker.ts +132 -0
- package/tools/get_tickers_jpy.ts +240 -0
- package/tools/get_transactions.ts +209 -0
- package/tools/get_volatility_metrics.ts +302 -0
- package/tools/patterns/aftermath.ts +212 -0
- package/tools/patterns/config.ts +151 -0
- package/tools/patterns/detect_doubles.ts +650 -0
- package/tools/patterns/detect_hs.ts +635 -0
- package/tools/patterns/detect_pennants.ts +373 -0
- package/tools/patterns/detect_triangles.ts +820 -0
- package/tools/patterns/detect_triples.ts +633 -0
- package/tools/patterns/detect_wedges.ts +1072 -0
- package/tools/patterns/helpers.ts +517 -0
- package/tools/patterns/index.ts +40 -0
- package/tools/patterns/regression.ts +153 -0
- package/tools/patterns/smoothing.ts +168 -0
- package/tools/patterns/swing.ts +91 -0
- package/tools/patterns/types.ts +193 -0
- package/tools/prepare_chart_data.ts +294 -0
- package/tools/prepare_depth_data.ts +189 -0
- package/tools/private/analyze_my_portfolio.ts +21 -0
- package/tools/private/cancel_order.ts +127 -0
- package/tools/private/cancel_orders.ts +121 -0
- package/tools/private/create_order.ts +236 -0
- package/tools/private/get_margin_positions.ts +134 -0
- package/tools/private/get_margin_status.ts +155 -0
- package/tools/private/get_margin_trade_history.ts +156 -0
- package/tools/private/get_my_assets.ts +207 -0
- package/tools/private/get_my_deposit_withdrawal.ts +500 -0
- package/tools/private/get_my_orders.ts +157 -0
- package/tools/private/get_my_trade_history.ts +229 -0
- package/tools/private/get_order.ts +95 -0
- package/tools/private/get_orders_info.ts +90 -0
- package/tools/private/preview_cancel_order.ts +172 -0
- package/tools/private/preview_cancel_orders.ts +137 -0
- package/tools/private/preview_order.ts +292 -0
- package/tools/render_candle_pattern_diagram.ts +389 -0
- package/tools/render_chart_svg.ts +799 -0
- package/tools/render_depth_svg.ts +274 -0
- package/tools/trading_process/index.ts +7 -0
- package/tools/trading_process/lib/backtest_engine.ts +252 -0
- package/tools/trading_process/lib/equity.ts +131 -0
- package/tools/trading_process/lib/fetch_candles.ts +181 -0
- package/tools/trading_process/lib/sma.ts +62 -0
- package/tools/trading_process/lib/strategies/bb_breakout.ts +141 -0
- package/tools/trading_process/lib/strategies/index.ts +52 -0
- package/tools/trading_process/lib/strategies/macd_cross.ts +256 -0
- package/tools/trading_process/lib/strategies/rsi.ts +133 -0
- package/tools/trading_process/lib/strategies/sma_cross.ts +214 -0
- package/tools/trading_process/lib/strategies/types.ts +118 -0
- package/tools/trading_process/lib/svg_to_png.ts +64 -0
- package/tools/trading_process/render_backtest_chart_generic.ts +729 -0
- package/tools/trading_process/run_backtest.ts +243 -0
- package/tools/trading_process/types.ts +85 -0
- package/tools/validate_candle_data.ts +260 -0
- package/tsconfig.json +17 -0
- package/ui/cancel-confirm/dist/cancel-confirm.html +99 -0
- package/ui/order-confirm/dist/order-confirm.html +99 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license
|
|
3
|
+
* TradingView Lightweight Charts™ v5.1.0
|
|
4
|
+
* Copyright (c) 2025 TradingView, Inc.
|
|
5
|
+
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
!function(){"use strict";const t={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 i,n;function s(t,i){const n={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(n)}function e(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(n,i+e),t.lineTo(s,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function a(t){if(null===t)throw new Error("Value is null");return t}function l(t){return a(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(n||(n={}));class o{constructor(){this.t=[]}i(t,i,n){const s={h:t,l:i,o:!0===n};this.t.push(s)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,n){const s=[...this.t];this.t=this.t.filter((t=>!t.o)),s.forEach((s=>s.h(t,i,n)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const n of i)for(const i in n)void 0!==n[i]&&Object.prototype.hasOwnProperty.call(n,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof n[i]||void 0===t[i]||Array.isArray(n[i])?t[i]=n[i]:_(t[i],n[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let n,s,e;for(s in n=Array.isArray(i)?[]:{},i)i.hasOwnProperty(s)&&(e=i[s],n[s]=e&&"object"==typeof e?p(e):e);return n}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,n){return void 0===i&&(i=w),`${n=void 0!==n?`${n} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,i=this.F(),n=this.W();return t.P===i&&t.T===n||(t.P=i,t.T=n,t.k=g(i,n),t.A=2.5/12*i,t.I=t.A,t.V=i/12*t.C,t.B=i/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function b(t){return t<0?0:t>255?255:Math.round(t)||0}function x(t){return.199*t[0]+.687*t[1]+.114*t[2]}class S{constructor(t,i){this.j=new Map,this.q=t,i&&(this.j=i)}Y(t,i){if("transparent"===t)return t;const n=this.K(t),s=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${i*s})`}Z(t){const i=this.K(t);return{G:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,X:x(i)>160?"black":"white"}}J(t){return x(this.K(t))}tt(t,i,n){const[s,e,r,h]=this.K(t),[a,l,o,_]=this.K(i),u=[b(s+n*(a-s)),b(e+n*(l-e)),b(r+n*(o-r)),(c=h+n*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}K(t){const i=this.j.get(t);if(i)return i;const n=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const n=window.getComputedStyle(i).color;return document.body.removeChild(i),n}(t),s=n.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!s){if(this.q.length)for(const i of this.q){const n=i(t);if(n)return this.j.set(t,n),n}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(s[1],10),parseInt(s[2],10),parseInt(s[3],10),s[4]?parseFloat(s[4]):1];return this.j.set(t,e),e}}class C{constructor(){this.it=[]}nt(t){this.it=t}st(t,i,n){this.it.forEach((s=>{s.st(t,i,n)}))}}class y{st(t,i,n){t.useBitmapCoordinateSpace((t=>this.et(t,i,n)))}}class P extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.rt||null===this.rt.lt)return;const s=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=s.to-1;a>=s.from;--a){const s=e.ot[a],l=Math.round(s._t*i)+r,o=s.ut*n,_=h*n+r;t.moveTo(l,o),t.arc(l,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function k(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const T={from:0,to:1};class R{constructor(t,i,n){this.Mt=new C,this.bt=[],this.xt=[],this.St=!0,this.O=t,this.Ct=i,this.yt=n,this.Mt.nt(this.bt)}Pt(t){this.kt(),this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Mt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.xt=t.map(k),this.bt=this.xt.map((t=>{const i=new P;return i.ht(t),i})),this.Mt.nt(this.bt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.It(),i=this.yt.Et(),n=this.Ct.Vt(),s=this.O.Bt();this.kt(),i.forEach(((i,e)=>{const r=this.xt[e],h=i.At(n),a=i.zt();!t&&null!==h&&i.It()&&null!==a?(r.vt=h.Lt,r.ft=h.ft,r.ct=h.Ot,r.ot[0].gt=h.gt,r.ot[0].ut=i.Ft().Nt(h.gt,a.Wt),r.dt=h.Ht??this.O.Ut(r.ot[0].ut/i.Ft().$t()),r.ot[0].wt=n,r.ot[0]._t=s.jt(n),r.lt=T):r.lt=null}))}}class D extends y{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;const h=this.qt.Yt.It,a=this.qt.Kt.It;if(!h&&!a)return;const l=Math.round(this.qt._t*n),o=Math.round(this.qt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*n),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,s(t,this.qt.Yt.Zt),function(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,n),t.lineTo(i+e,s),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*r),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,s(t,this.qt.Kt.Zt),e(t,o,0,i.width))}}class I{constructor(t,i){this.St=!0,this.Gt={Yt:{ct:1,Zt:0,R:"",It:!1},Kt:{ct:1,Zt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new D(this.Gt),this.Jt=t,this.yt=i}Pt(){this.St=!0}Tt(t){return this.St&&(this.Rt(),this.St=!1),this.Xt}Rt(){const t=this.Jt.It(),i=this.yt.Qt().N().crosshair,n=this.Gt;if(2===i.mode)return n.Kt.It=!1,void(n.Yt.It=!1);n.Kt.It=t&&this.Jt.ti(this.yt),n.Yt.It=t&&this.Jt.ii(),n.Kt.ct=i.horzLine.width,n.Kt.Zt=i.horzLine.style,n.Kt.R=i.horzLine.color,n.Yt.ct=i.vertLine.width,n.Yt.Zt=i.vertLine.style,n.Yt.R=i.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}}function E(t,i,n,s,e,r){t.fillRect(i+r,n,s-2*r,r),t.fillRect(i+r,n+e-r,s-2*r,r),t.fillRect(i,n,r,e),t.fillRect(i+s-r,n,r,e)}function V(t,i,n,s,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,s,e),t.restore()}function B(t,i,n,s,e,r){t.beginPath(),t.roundRect?t.roundRect(i,n,s,e,r):(t.lineTo(i+s-r[1],n),0!==r[1]&&t.arcTo(i+s,n,i+s,n+r[1],r[1]),t.lineTo(i+s,n+e-r[2]),0!==r[2]&&t.arcTo(i+s,n+e,i+s-r[2],n+e,r[2]),t.lineTo(i+r[3],n+e),0!==r[3]&&t.arcTo(i,n+e,i,n+e-r[3],r[3]),t.lineTo(i,n+r[0]),0!==r[0]&&t.arcTo(i,n,i+r[0],n,r[0]))}function A(t,i,n,s,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return B(t,i,n,s,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;B(t,i+o,n+o,s-h,e-h,(_=-o,a.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=h,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function z(t,i,n,s,e,r,h){t.save(),t.globalCompositeOperation="copy";const a=t.createLinearGradient(0,0,0,e);a.addColorStop(0,r),a.addColorStop(1,h),t.fillStyle=a,t.fillRect(i,n,s,e),t.restore()}class L{constructor(t,i){this.ht(t,i)}ht(t,i){this.qt=t,this.ei=i}$t(t,i){return this.qt.It?t.P+t.A+t.I:0}st(t,i,n,s){if(!this.qt.It||0===this.qt.ri.length)return;const e=this.qt.R,r=this.ei.G,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.k;const a=this.hi(t,i,n,s),l=a.ai;return a.li?A(h,l.oi,l._i,l.ui,l.ci,r,l.di,[l.ft,0,0,l.ft],r):A(h,l.fi,l._i,l.ui,l.ci,r,l.di,[0,l.ft,l.ft,0],r),this.qt.pi&&(h.fillStyle=e,h.fillRect(l.fi,l.mi,l.wi-l.fi,l.gi)),this.qt.Mi&&(h.fillStyle=i.D,h.fillRect(a.li?l.bi-l.di:0,l._i,l.di,l.xi-l._i)),a}));t.useMediaCoordinateSpace((({context:t})=>{const n=h.Si;t.font=i.k,t.textAlign=h.li?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.qt.ri,n.Ci,(n._i+n.xi)/2+n.yi)}))}hi(t,i,n,s){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.qt.pi||!this.qt.Pi?i.C:0,_=this.qt.ki?i.S:0,u=i.A+this.ei.Ti,c=i.I+this.ei.Ri,d=i.V,f=i.B,p=this.qt.ri,v=i.P,m=n.Di(e,p),w=Math.ceil(n.Ii(e,p)),g=v+u+c,M=i.S+d+f+w+o,b=Math.max(1,Math.floor(l));let x=Math.round(g*l);x%2!=b%2&&(x+=1);const S=_>0?Math.max(1,Math.floor(_*a)):0,C=Math.round(M*a),y=Math.round(o*a),P=this.ei.Ei??this.ei.Vi??this.ei.Bi,k=Math.round(P*l)-Math.floor(.5*l),T=Math.floor(k+b/2-x/2),R=T+x,D="right"===s,I=D?h.width-_:_,E=D?r.width-S:S;let V,B,A;return D?(V=E-C,B=E-y,A=I-o-d-_):(V=E+C,B=E+y,A=I+o+d),{li:D,ai:{_i:T,mi:k,xi:R,ui:C,ci:x,ft:2*a,di:S,oi:V,fi:E,wi:B,gi:b,bi:r.width},Si:{_i:T/l,xi:R/l,Ci:A,yi:m}}}}class O{constructor(t){this.Ai={Bi:0,G:"#000",Ri:0,Ti:0},this.zi={ri:"",It:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",Mi:!1,ki:!1},this.Li={ri:"",It:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",Mi:!0,ki:!0},this.St=!0,this.Oi=new(t||L)(this.zi,this.Ai),this.Ni=new(t||L)(this.Li,this.Ai)}ri(){return this.Fi(),this.zi.ri}Bi(){return this.Fi(),this.Ai.Bi}Pt(){this.St=!0}$t(t,i=!1){return Math.max(this.Oi.$t(t,i),this.Ni.$t(t,i))}Wi(){return this.Ai.Ei??null}Hi(){return this.Ai.Ei??this.Ai.Vi??this.Bi()}Ui(t){this.Ai.Vi=t??void 0}$i(){return this.Fi(),this.zi.It||this.Li.It}ji(){return this.Fi(),this.zi.It}Tt(t){return this.Fi(),this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.Oi.ht(this.zi,this.Ai),this.Ni.ht(this.Li,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.zi,this.Ai),this.Ni.ht(this.Li,this.Ai),this.Ni}Fi(){this.St&&(this.zi.pi=!0,this.Li.pi=!1,this.Yi(this.zi,this.Li,this.Ai))}}class N extends O{constructor(t,i,n){super(),this.Jt=t,this.Ki=i,this.Zi=n}Yi(t,i,n){if(t.It=!1,2===this.Jt.N().mode)return;const s=this.Jt.N().horzLine;if(!s.labelVisible)return;const e=this.Ki.zt();if(!this.Jt.It()||this.Ki.Gi()||null===e)return;const r=this.Ki.Xi().Z(s.labelBackgroundColor);n.G=r.G,t.R=r.X;const h=2/12*this.Ki.P();n.Ti=h,n.Ri=h;const a=this.Zi(this.Ki);n.Bi=a.Bi,t.ri=this.Ki.Ji(a.gt,e),t.It=!0}}const F=/[1-9]/g;class W{constructor(){this.qt=null}ht(t){this.qt=t}st(t,i){if(null===this.qt||!1===this.qt.It||0===this.qt.ri.length)return;const n=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.k,Math.round(i.Qi.Ii(t,a(this.qt).ri,F)))));if(n<=0)return;const s=i.tn,e=n+2*s,r=e/2,h=this.qt.nn;let l=this.qt.Bi,o=Math.floor(l-r)+.5;o<0?(l+=Math.abs(0-o),o=Math.floor(l-r)+.5):o+e>h&&(l-=Math.abs(h-(o+e)),o=Math.floor(l-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.C+i.A+i.P+i.I);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:n,verticalPixelRatio:s})=>{const e=a(this.qt);t.fillStyle=e.G;const r=Math.round(o*n),h=Math.round(0*s),l=Math.round(_*n),c=Math.round(u*s),d=Math.round(2*n);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(l-d,c),t.arcTo(l,c,l,c-d,d),t.lineTo(l,h),t.fill(),e.pi){const r=Math.round(e.Bi*n),a=h,l=Math.round((a+i.C)*s);t.fillStyle=e.R;const o=Math.max(1,Math.floor(n)),_=Math.floor(.5*n);t.fillRect(r-_,a,o,l-a)}})),t.useMediaCoordinateSpace((({context:t})=>{const n=a(this.qt),e=0+i.S+i.C+i.A+i.P/2;t.font=i.k,t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.R;const r=i.Qi.Di(t,"Apr0");t.translate(o+s,e+r),t.fillText(n.ri,0,0)}))}}class H{constructor(t,i,n){this.St=!0,this.Xt=new W,this.Gt={It:!1,G:"#4c525e",R:"white",ri:"",nn:0,Bi:NaN,pi:!0},this.Ct=t,this.sn=i,this.Zi=n}Pt(){this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Xt.ht(this.Gt),this.Xt}Rt(){const t=this.Gt;if(t.It=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const n=this.sn.Bt();if(n.Gi())return;t.nn=n.nn();const s=this.Zi();if(null===s)return;t.Bi=s.Bi;const e=n.en(this.Ct.Vt());t.ri=n.rn(a(e)),t.It=!0;const r=this.sn.Xi().Z(i.labelBackgroundColor);t.G=r.G,t.R=r.X,t.pi=n.N().ticksVisible}}class U{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}($||($={}));class j extends U{constructor(t,i){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.gn=new WeakMap,this.Mn=new WeakMap,this.bn=NaN,this.xn=NaN,this.Sn=NaN,this.Cn=NaN,this.sn=t,this.yn=i;this.Pn=((t,i)=>n=>{const s=i(),e=t();if(n===a(this.yt).kn())return{gt:e,Bi:s};{const t=a(n.zt());return{gt:n.Tn(s,t),Bi:s}}})((()=>this.fn),(()=>this.xn));const n=((t,i)=>()=>{const n=this.sn.Bt().Rn(t()),s=i();return n&&Number.isFinite(s)?{wt:n,Bi:s}:null})((()=>this.pn),(()=>this.ni()));this.Dn=new H(this,t,n)}N(){return this.yn}In(t,i){this.Sn=t,this.Cn=i}En(){this.Sn=NaN,this.Cn=NaN}Vn(){return this.Sn}Bn(){return this.Cn}An(t,i,n){this.wn||(this.wn=!0),this.vn=!0,this.zn(t,i,n)}Vt(){return this.pn}ni(){return this.bn}si(){return this.xn}It(){return this.vn}Ln(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.xn=NaN,this.yt=null,this.En(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const i=this.sn,n=i.Bt();let s=null,e=null;for(const n of i.Wn()){const i=n.Un().Hn(t,-1);if(i){if(i.$n===t)return t;(null===s||i.$n>s)&&(s=i.$n)}const r=n.Un().Hn(t,1);if(r){if(r.$n===t)return t;(null===e||r.$n<e)&&(e=r.$n)}}const r=[s,e].filter(v);if(0===r.length)return t;const h=n.jt(t),a=r.map((t=>Math.abs(h-n.jt(t))));return r[a.indexOf(Math.min(...a))]}jn(t){let i=this.gn.get(t);i||(i=new I(this,t),this.gn.set(t,i));let n=this.Mn.get(t);return n||(n=new R(this.sn,this,t),this.Mn.set(t,n)),[i,n]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,i){this.vn&&this.yt===t||this.mn.clear();const n=[];return this.yt===t&&n.push(this.Yn(this.mn,i,this.Pn)),n}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Zn().forEach((t=>{this.gn.get(t)?.Pt(),this.Mn.get(t)?.Pt()})),this.mn.forEach((t=>t.Pt())),this.Dn.Pt()}Gn(t){return t&&!t.kn().Gi()?t.kn():null}zn(t,i,n){this.Xn(t,i,n)&&this.Nn()}Xn(t,i,n){const s=this.bn,e=this.xn,r=this.fn,h=this.pn,a=this.yt,l=this.Gn(n);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Bt().jt(t),this.yt=n;const o=null!==l?l.zt():null;return null!==l&&null!==o?(this.fn=i,this.xn=l.Nt(i,o)):(this.fn=NaN,this.xn=NaN),s!==this.bn||e!==this.xn||h!==this.pn||r!==this.fn||a!==this.yt}On(){const t=this.sn.Jn().map((t=>t.Un().Qn())).filter(v),i=0===t.length?null:Math.max(...t);this.pn=null!==i?i:NaN}Yn(t,i,n){let s=t.get(i);return void 0===s&&(s=new N(this,i,n),t.set(i,s)),s}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,i){const n=function(t,i){return void 0===t?i:{rs:Math.max(t.rs,i.rs),hs:t.hs||i.hs}}(this.ts.get(t),i);this.ts.set(t,n)}ls(){return this.ss}_s(t){const i=this.ts.get(t);return void 0===i?{rs:this.ss}:{rs:Math.max(this.ss,i.rs),hs:i.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}gs(t){this.cs(),this.ns.push({ds:2,Wt:t})}Ms(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}xs(t){for(const i of t.ns)this.Ss(i);this.ss=Math.max(this.ss,t.ss),t.ts.forEach(((t,i)=>{this.es(i,t)}))}static Cs(){return new Y(2)}static ys(){return new Y(3)}Ss(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.gs(t.Wt);break;case 3:this.Ms(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex((t=>5===t.ds));-1!==t&&this.ns.splice(t,1)}}class K{formatTickmarks(t){return t.map((t=>this.format(t)))}}const Z=".";function G(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class X extends K{constructor(t,i){if(super(),i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.Ps=i,this.ks()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Ts(t)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const i=this.Ki/this.Ps;let n=Math.floor(t),s="";const e=void 0!==this.Rs?this.Rs:NaN;if(i>1){let r=+(Math.round(t*i)-n*i).toFixed(this.Rs);r>=i&&(r-=i,n+=1),s=Z+G(+r.toFixed(this.Rs)*this.Ps,e)}else n=Math.round(n*i)/i,e>0&&(s=Z+G(0,e));return n.toFixed(0)+s}}class J extends X{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Q extends K{constructor(t){super(),this.Ds=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.Is(t):t<999995?i+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Is(t/1e9)+"B")}Is(t){let i;const n=Math.pow(10,this.Ds);return i=(t=Math.round(t*n)/n)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const tt=/[2-9]/g;class it{constructor(t=50){this.Es=0,this.Vs=1,this.Bs=1,this.As={},this.zs=new Map,this.Ls=t}Os(){this.Es=0,this.zs.clear(),this.Vs=1,this.Bs=1,this.As={}}Ii(t,i,n){return this.Ns(t,i,n).width}Di(t,i,n){const s=this.Ns(t,i,n);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}Ns(t,i,n){const s=n||tt,e=String(i).replace(s,"0");if(this.zs.has(e))return h(this.zs.get(e)).Fs;if(this.Es===this.Ls){const t=this.As[this.Bs];delete this.As[this.Bs],this.zs.delete(t),this.Bs++,this.Es--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.zs.set(e,{Fs:r,Ws:this.Vs}),this.As[this.Vs]=e,this.Es++,this.Vs++),r}}class nt{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,i,n){this.Hs=t,this.M=i,this.Us=n}st(t){null!==this.M&&null!==this.Hs&&this.Hs.st(t,this.M,this.$s,this.Us)}}class st{constructor(t,i,n){this.qs=t,this.$s=new it(50),this.Ys=i,this.O=n,this.F=-1,this.Xt=new nt(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(null===t)return null;const i=t.Zs(this.Ys)?t.Gs():this.Ys.Ft();if(null===i)return null;const n=t.Xs(i);if("overlay"===n)return null;const s=this.O.Js();return s.P!==this.F&&(this.F=s.P,this.$s.Os()),this.Xt.js(this.qs.qi(),s,n),this.Xt}}class et extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,i){if(!this.qt?.It)return null;const{ut:n,ct:s,te:e}=this.qt;return i>=n-s-7&&i<=n+s+7?{ie:this.qt,te:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;if(!1===this.qt.It)return;const h=Math.round(this.qt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*n),s(t,this.qt.Zt),e(t,h,0,i.width))}}class rt{constructor(t){this.ne={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Zt:0,It:!1},this.se=new et,this.St=!0,this.ee=t,this.re=t.Qt(),this.se.ht(this.ne)}Pt(){this.St=!0}Tt(){return this.ee.It()?(this.St&&(this.he(),this.St=!1),this.se):null}}class ht extends rt{constructor(t){super(t)}he(){this.ne.It=!1;const t=this.ee.Ft(),i=t.ae().ae;if(2!==i&&3!==i)return;const n=this.ee.N();if(!n.baseLineVisible||!this.ee.It())return;const s=this.ee.zt();null!==s&&(this.ne.It=!0,this.ne.ut=t.Nt(s.Wt,s.Wt),this.ne.R=n.baseLineColor,this.ne.ct=n.baseLineWidth,this.ne.Zt=n.baseLineStyle)}}class at extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}le(){return this.qt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){const s=this.qt;if(null===s)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(s.oe.x*i)+r,a=s.oe.y*n;t.fillStyle=s._e,t.beginPath();const l=Math.max(2,1.5*s.ue)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.ce,t.beginPath(),t.arc(h,a,s.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=s.de,t.beginPath(),t.arc(h,a,s.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{fe:0,pe:.25,ve:4,me:10,we:.25,ge:0,Me:.4,be:.8},{fe:.25,pe:.525,ve:10,me:14,we:0,ge:0,Me:.8,be:0},{fe:.525,pe:1,ve:14,me:14,we:0,ge:0,Me:0,be:0}];class ot{constructor(t){this.Xt=new at,this.St=!0,this.xe=!0,this.Se=performance.now(),this.Ce=this.Se-1,this.ye=t}Pe(){this.Ce=this.Se-1,this.Pt()}ke(){if(this.Pt(),2===this.ye.N().lastPriceAnimation){const t=performance.now(),i=this.Ce-t;if(i>0)return void(i<650&&(this.Ce+=2600));this.Se=t,this.Ce=t+2600}}Pt(){this.St=!0}Te(){this.xe=!0}It(){return 0!==this.ye.N().lastPriceAnimation}Re(){switch(this.ye.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Ce}}Tt(){return this.St?(this.Rt(),this.St=!1,this.xe=!1):this.xe&&(this.De(),this.xe=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.ye.Qt().Bt(),i=t.Ie(),n=this.ye.zt();if(null===i||null===n)return;const s=this.ye.Ee(!0);if(s.Ve||!i.Be(s.$n))return;const e={x:t.jt(s.$n),y:this.ye.Ft().Nt(s.gt,n.Wt)},r=s.R,h=this.ye.N().lineWidth,a=this.Ae(this.ze(),r);this.Xt.ht({_e:r,ue:h,ce:a.ce,de:a.de,ft:a.ft,oe:e})}De(){const t=this.Xt.le();if(null!==t){const i=this.Ae(this.ze(),t._e);t.ce=i.ce,t.de=i.de,t.ft=i.ft}}ze(){return this.Re()?performance.now()-this.Se:2599}Le(t,i,n,s){const e=n+(s-n)*i;return this.ye.Qt().Xi().Y(t,e)}Ae(t,i){const n=t%2600/2600;let s;for(const t of lt)if(n>=t.fe&&n<=t.pe){s=t;break}r(void 0!==s,"Last price animation internal logic error");const e=(n-s.fe)/(s.pe-s.fe);return{ce:this.Le(i,e,s.we,s.ge),de:this.Le(i,e,s.Me,s.be),ft:(h=e,a=s.ve,l=s.me,a+(l-a)*h)};var h,a,l}}class _t extends rt{constructor(t){super(t)}he(){const t=this.ne;t.It=!1;const i=this.ee.N();if(!i.priceLineVisible||!this.ee.It())return;const n=this.ee.Ee(0===i.priceLineSource);n.Ve||(t.It=!0,t.ut=n.Bi,t.R=this.ee.Oe(n.R),t.ct=i.priceLineWidth,t.Zt=i.priceLineStyle)}}class ut extends O{constructor(t){super(),this.Jt=t}Yi(t,i,n){t.It=!1,i.It=!1;const s=this.Jt;if(!s.It())return;const e=s.N(),r=e.lastValueVisible,h=""!==s.Ne(),a=0===e.seriesLastValueMode,l=s.Ee(!1);if(l.Ve)return;r&&(t.ri=this.Fe(l,r,a),t.It=0!==t.ri.length),(h||a)&&(i.ri=this.We(l,r,h,a),i.It=i.ri.length>0);const o=s.Oe(l.R),_=this.Jt.Qt().Xi().Z(o);n.G=_.G,n.Bi=l.Bi,i.Ht=s.Qt().Ut(l.Bi/s.Ft().$t()),t.Ht=o,t.R=_.X,i.R=_.X}We(t,i,n,s){let e="";const r=this.Jt.Ne();return n&&0!==r.length&&(e+=`${r} `),i&&s&&(e+=this.Jt.Ft().He()?t.Ue:t.$e),e.trim()}Fe(t,i,n){return i?n?this.Jt.Ft().He()?t.$e:t.Ue:t.ri:""}}function ct(t,i,n,s){const e=Number.isFinite(i),r=Number.isFinite(n);return e&&r?t(i,n):e||r?e?i:n:s}class dt{constructor(t,i){this.je=t,this.qe=i}Ye(t){return null!==t&&(this.je===t.je&&this.qe===t.qe)}Ke(){return new dt(this.je,this.qe)}Ze(){return this.je}Ge(){return this.qe}Xe(){return this.qe-this.je}Gi(){return this.qe===this.je||Number.isNaN(this.qe)||Number.isNaN(this.je)}xs(t){return null===t?this:new dt(ct(Math.min,this.Ze(),t.Ze(),-1/0),ct(Math.max,this.Ge(),t.Ge(),1/0))}Je(t){if(!u(t))return;if(0===this.qe-this.je)return;const i=.5*(this.qe+this.je);let n=this.qe-i,s=this.je-i;n*=t,s*=t,this.qe=i+n,this.je=i+s}Qe(t){u(t)&&(this.qe+=t,this.je+=t)}tr(){return{minValue:this.je,maxValue:this.qe}}static ir(t){return null===t?null:new dt(t.minValue,t.maxValue)}}class ft{constructor(t,i){this.nr=t,this.sr=i||null}er(){return this.nr}rr(){return this.sr}tr(){return{priceRange:null===this.nr?null:this.nr.tr(),margins:this.sr||void 0}}static ir(t){return null===t?null:new ft(dt.ir(t.priceRange),t.margins)}}const pt=[2,4,8,16,32,64,128,256,512],vt="Custom series with conflation reducer must have a priceValueBuilder method";class mt extends rt{constructor(t,i){super(t),this.hr=i}he(){const t=this.ne;t.It=!1;const i=this.hr.N();if(!this.ee.It()||!i.lineVisible)return;const n=this.hr.ar();null!==n&&(t.It=!0,t.ut=n,t.R=i.color,t.ct=i.lineWidth,t.Zt=i.lineStyle,t.te=this.hr.N().id)}}class wt extends O{constructor(t,i){super(),this.ye=t,this.hr=i}Yi(t,i,n){t.It=!1,i.It=!1;const s=this.hr.N(),e=s.axisLabelVisible,r=""!==s.title,h=this.ye;if(!e||!h.It())return;const a=this.hr.ar();if(null===a)return;r&&(i.ri=s.title,i.It=!0),i.Ht=h.Qt().Ut(a/h.Ft().$t()),t.ri=this.lr(s.price),t.It=!0;const l=this.ye.Qt().Xi().Z(s.axisLabelColor||s.color);n.G=l.G;const o=s.axisLabelTextColor||l.X;t.R=o,i.R=o,n.Bi=a}lr(t){const i=this.ye.zt();return null===i?"":this.ye.Ft().Ji(t,i.Wt)}}class gt{constructor(t,i){this.ye=t,this.yn=i,this._r=new mt(t,this),this.qs=new wt(t,this),this.ur=new st(this.qs,t,t.Qt())}cr(t){_(this.yn,t),this.Pt(),this.ye.Qt().dr()}N(){return this.yn}pr(){return this._r}vr(){return this.ur}mr(){return this.qs}Pt(){this._r.Pt(),this.qs.Pt()}ar(){const t=this.ye,i=t.Ft();if(t.Qt().Bt().Gi()||i.Gi())return null;const n=t.zt();return null===n?null:i.Nt(this.yn.price,n.Wt)}}class Mt{constructor(){this.wr=new WeakMap}gr(t,i,n){const s=1/i*n;if(t>=s)return 1;const e=s/t,r=Math.pow(2,Math.floor(Math.log2(e)));return Math.min(r,512)}Mr(t,i,n,s=!1,e){if(0===t.length||i<=1)return t;const r=this.br(i);if(r<=1)return t;const h=this.Sr(t);let a=h.Cr.get(r);return void 0!==a||(a=this.yr(t,r,n,s,e,h.Cr),h.Cr.set(r,a)),a}Pr(t,i,n,s,e=!1,r){if(n<1||0===t.length)return t;const h=this.Sr(t),a=h.Cr.get(n);if(!a)return this.Mr(t,n,s,e,r);const l=this.kr(t,i,n,a,e,s,r);return h.Cr.set(n,l),l}br(t){if(t<=2)return 2;for(const i of pt)if(t<=i)return i;return 512}Tr(t){if(0===t.length)return 0;const i=t[0],n=t[t.length-1];return 31*t.length+17*i.$n+13*n.$n}yr(t,i,n,s=!1,e,r=new Map){if(2===i)return this.Rr(t,2,n,s,e);const h=i/2;let a=r.get(h);return a||(a=this.yr(t,h,n,s,e,r),r.set(h,a)),this.Dr(a,n,s,e)}Rr(t,i,n,s=!1,e){const r=this.Ir(t,i,n,s,e);return this.Er(r,s)}Dr(t,i,n=!1,s){const e=this.Ir(t,2,i,n,s);return this.Er(e,n)}Ir(t,i,n,s=!1,e){const r=[];for(let h=0;h<t.length;h+=i){if(t.length-h>=i){const i=this.Vr(t[h],t[h+1],n,s,e);i.Br=!1,r.push(i)}else if(0===r.length)r.push(this.Ar(t[h],!0));else{const i=r[r.length-1];r[r.length-1]=this.zr(i,t[h],n,s,e)}}return r}Lr(t,i){return(t??1)+(i??1)}Vr(t,i,n,s=!1,e){if(!s||!n||!e){const n=t.Wt[1]>i.Wt[1]?t.Wt[1]:i.Wt[1],s=t.Wt[2]<i.Wt[2]?t.Wt[2]:i.Wt[2];return{Or:t.$n,Nr:i.$n,Fr:t.wt,Wr:i.wt,Hr:t.Wt[0],Ur:n,$r:s,jr:i.Wt[3],qr:this.Lr(t.qr,i.qr),Yr:void 0,Br:!1}}const r=n(this.Kr(t,e),this.Kr(i,e)),h=e(r),a=h.length?h[h.length-1]:0;return{Or:t.$n,Nr:i.$n,Fr:t.wt,Wr:i.wt,Hr:t.Wt[0],Ur:Math.max(t.Wt[1],a),$r:Math.min(t.Wt[2],a),jr:a,qr:this.Lr(t.qr,i.qr),Yr:r,Br:!1}}zr(t,i,n,s=!1,e){if(!s||!n||!e)return{Or:t.Or,Nr:i.$n,Fr:t.Fr,Wr:i.wt,Hr:t.Hr,Ur:t.Ur>i.Wt[1]?t.Ur:i.Wt[1],$r:t.$r<i.Wt[2]?t.$r:i.Wt[2],jr:i.Wt[3],qr:t.qr+(i.qr??1),Yr:t.Yr,Br:!1};const r=t.Yr,h=this.Kr(i,e),a=r?{data:r,index:t.Or,originalTime:t.Fr,time:t.Fr,priceValues:e(r)}:null,l=a?n(a,h):h.data,o=a?e(l):h.priceValues,_=o.length?o[o.length-1]:0;return{Or:t.Or,Nr:i.$n,Fr:t.Fr,Wr:i.wt,Hr:t.Hr,Ur:Math.max(t.Ur,_),$r:Math.min(t.$r,_),jr:_,qr:t.qr+(i.qr??1),Yr:l,Br:!1}}Zr(t,i,n,s,e,r,h=!1,a){const l=i===s?e:t[i];if(n-i==1)return this.Ar(l,!0);const o=i+1===s?e:t[i+1];let _=this.Vr(l,o,r,h,a);for(let l=i+2;l<n;l++){const i=l===s?e:t[l];_=this.zr(_,i,r,h,a)}return _}Kr(t,i){const n=t.le??{};return{data:t.le,index:t.$n,originalTime:t.Gr,time:t.wt,priceValues:i(n)}}Xr(t,i=!1){const n=!0===i,s=!!t.Yr;return{...{$n:t.Or,wt:t.Fr,Gr:t.Fr,Wt:[n?t.jr:t.Hr,t.Ur,t.$r,t.jr],qr:t.qr},le:n?s?t.Yr:{wt:t.Fr}:void 0}}Er(t,i=!1){return t.map((t=>this.Xr(t,i)))}kr(t,i,n,s,e=!1,r,h){if(0===s.length)return s;const a=t.length-1,l=Math.floor(a/n)*n;if(Math.min(l+n,t.length)-l<n&&t.length>n){const s=t.slice();return s[s.length-1]=i,this.Mr(s,n,r,e,h)}if(Math.floor((a-1)/n)===Math.floor(a/n)||1===s.length){const o=Math.min(l+n,t.length),_=o-l;if(_<=0)return s;const u=1===_?this.Ar(l===a?i:t[l],!0):this.Zr(t,l,o,a,i,r,e,h);return s[s.length-1]=this.Xr(u,e),s}{const s=t.slice();return s[s.length-1]=i,this.Mr(s,n,r,e,h)}}Ar(t,i=!1){return{Or:t.$n,Nr:t.$n,Fr:t.wt,Wr:t.wt,Hr:t.Wt[0],Ur:t.Wt[1],$r:t.Wt[2],jr:t.Wt[3],qr:t.qr??1,Yr:t.le,Br:i}}Sr(t){const i=this.Jr(t),n=this.Tr(t);return i.Qr!==n&&(i.Cr.clear(),i.Qr=n),i}Jr(t){let i=this.wr.get(t);return void 0===i&&(i={Qr:this.Tr(t),Cr:new Map},this.wr.set(t,i)),i}}class bt extends U{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const xt={Bar:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=a(t(n,s)),o=l(h.Wt[0])<=l(h.Wt[3]);return{th:h.R??(o?e:r)}},Candlestick:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=a(t(n,s)),d=l(c.Wt[0])<=l(c.Wt[3]);return{th:c.R??(d?e:r),ih:c.Ht??(d?h:o),nh:c.sh??(d?_:u)}},Custom:(t,i,n,s)=>({th:a(t(n,s)).R??i.color}),Area:(t,i,n,s)=>{const e=a(t(n,s));return{th:e.vt??i.lineColor,vt:e.vt??i.lineColor,eh:e.eh??i.topColor,rh:e.rh??i.bottomColor}},Baseline:(t,i,n,s)=>{const e=a(t(n,s));return{th:e.Wt[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,hh:e.hh??i.topLineColor,ah:e.ah??i.bottomLineColor,oh:e.oh??i.topFillColor1,_h:e._h??i.topFillColor2,uh:e.uh??i.bottomFillColor1,dh:e.dh??i.bottomFillColor2}},Line:(t,i,n,s)=>{const e=a(t(n,s));return{th:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,n,s)=>({th:a(t(n,s)).R??i.color})};class St{constructor(t){this.fh=(t,i)=>void 0!==i?i.Wt:this.ye.Un().ph(t),this.ye=t,this.mh=xt[t.wh()]}gh(t,i){return this.mh(this.fh,this.ye.N(),t,i)}}function Ct(t,i,n,s,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;s(i[a],n)===t?(e=a+1,h-=r+1):h=r}return e}const yt=Ct.bind(null,!0),Pt=Ct.bind(null,!1);var kt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(kt||(kt={}));const Tt=30;class Rt{constructor(){this.Mh=[],this.bh=new Map,this.xh=new Map,this.Sh=[]}Ch(){return this.yh()>0?this.Mh[this.Mh.length-1]:null}Ph(){return this.yh()>0?this.kh(0):null}Qn(){return this.yh()>0?this.kh(this.Mh.length-1):null}yh(){return this.Mh.length}Gi(){return 0===this.yh()}Be(t){return null!==this.Th(t,0)}ph(t){return this.Hn(t)}Hn(t,i=0){const n=this.Th(t,i);return null===n?null:{...this.Rh(n),$n:this.kh(n)}}Dh(){return this.Mh}Ih(t,i,n){if(this.Gi())return null;let s=null;for(const e of n){s=Dt(s,this.Eh(t,i,e))}return s}ht(t){this.xh.clear(),this.bh.clear(),this.Mh=t,this.Sh=t.map((t=>t.$n))}Vh(){return this.Sh}kh(t){return this.Mh[t].$n}Rh(t){return this.Mh[t]}Th(t,i){const n=this.Bh(t);if(null===n&&0!==i)switch(i){case-1:return this.Ah(t);case 1:return this.zh(t);default:throw new TypeError("Unknown search mode")}return n}Ah(t){let i=this.Lh(t);return i>0&&(i-=1),i!==this.Mh.length&&this.kh(i)<t?i:null}zh(t){const i=this.Oh(t);return i!==this.Mh.length&&t<this.kh(i)?i:null}Bh(t){const i=this.Lh(t);return i===this.Mh.length||t<this.Mh[i].$n?null:i}Lh(t){return yt(this.Mh,t,((t,i)=>t.$n<i))}Oh(t){return Pt(this.Mh,t,((t,i)=>t.$n>i))}Nh(t,i,n){let s=null;for(let e=t;e<i;e++){const t=this.Mh[e].Wt[n];Number.isNaN(t)||(null===s?s={Fh:t,Wh:t}:(t<s.Fh&&(s.Fh=t),t>s.Wh&&(s.Wh=t)))}return s}Eh(t,i,n){if(this.Gi())return null;let s=null;const e=a(this.Ph()),r=a(this.Qn()),h=Math.max(t,e),l=Math.min(i,r),o=Math.ceil(h/Tt)*Tt,_=Math.max(o,Math.floor(l/Tt)*Tt);{const t=this.Lh(h),e=this.Oh(Math.min(l,o,i));s=Dt(s,this.Nh(t,e,n))}let u=this.bh.get(n);void 0===u&&(u=new Map,this.bh.set(n,u));for(let t=Math.max(o+1,h);t<_;t+=Tt){const i=Math.floor(t/Tt);let e=u.get(i);if(void 0===e){const t=this.Lh(i*Tt),s=this.Oh((i+1)*Tt-1);e=this.Nh(t,s,n),u.set(i,e)}s=Dt(s,e)}{const t=this.Lh(_),i=this.Oh(l);s=Dt(s,this.Nh(t,i,n))}return s}}function Dt(t,i){if(null===t)return i;if(null===i)return t;return{Fh:Math.min(t.Fh,i.Fh),Wh:Math.max(t.Wh,i.Wh)}}function It(){return new Rt}const Et={setLineStyle:s};class Vt{constructor(t){this.Hh=t}st(t,i,n){this.Hh.draw(t,Et)}Uh(t,i,n){this.Hh.drawBackground?.(t,Et)}}class Bt{constructor(t){this.zs=null,this.$h=t}Tt(){const t=this.$h.renderer();if(null===t)return null;if(this.zs?.jh===t)return this.zs.qh;const i=new Vt(t);return this.zs={jh:t,qh:i},i}Yh(){return this.$h.zOrder?.()??"normal"}}class At{constructor(t){this.Kh=null,this.Zh=t}Gh(){return this.Zh}Nn(){this.Zh.updateAllViews?.()}jn(){const t=this.Zh.paneViews?.()??[];if(this.Kh?.jh===t)return this.Kh.qh;const i=t.map((t=>new Bt(t)));return this.Kh={jh:t,qh:i},i}Qs(t,i){return this.Zh.hitTest?.(t,i)??null}}let zt=class extends At{cn(){return[]}};class Lt{constructor(t){this.Hh=t}st(t,i,n){this.Hh.draw(t,Et)}Uh(t,i,n){this.Hh.drawBackground?.(t,Et)}}class Ot{constructor(t){this.zs=null,this.$h=t}Tt(){const t=this.$h.renderer();if(null===t)return null;if(this.zs?.jh===t)return this.zs.qh;const i=new Lt(t);return this.zs={jh:t,qh:i},i}Yh(){return this.$h.zOrder?.()??"normal"}}function Nt(t){return{ri:t.text(),Bi:t.coordinate(),Ei:t.fixedCoordinate?.(),R:t.textColor(),G:t.backColor(),It:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class Ft{constructor(t,i){this.Xt=new W,this.Xh=t,this.Jh=i}Tt(){return this.Xt.ht({nn:this.Jh.nn(),...Nt(this.Xh)}),this.Xt}}class Wt extends O{constructor(t,i){super(),this.Xh=t,this.Ki=i}Yi(t,i,n){const s=Nt(this.Xh);n.G=s.G,t.R=s.R;const e=2/12*this.Ki.P();n.Ti=e,n.Ri=e,n.Bi=s.Bi,n.Ei=s.Ei,t.ri=s.ri,t.It=s.It,t.pi=s.pi}}class Ht extends At{constructor(t,i){super(t),this.Qh=null,this.ta=null,this.ia=null,this.na=null,this.ye=i}dn(){const t=this.Zh.timeAxisViews?.()??[];if(this.Qh?.jh===t)return this.Qh.qh;const i=this.ye.Qt().Bt(),n=t.map((t=>new Ft(t,i)));return this.Qh={jh:t,qh:n},n}qn(){const t=this.Zh.priceAxisViews?.()??[];if(this.ta?.jh===t)return this.ta.qh;const i=this.ye.Ft(),n=t.map((t=>new Wt(t,i)));return this.ta={jh:t,qh:n},n}sa(){const t=this.Zh.priceAxisPaneViews?.()??[];if(this.ia?.jh===t)return this.ia.qh;const i=t.map((t=>new Ot(t)));return this.ia={jh:t,qh:i},i}ea(){const t=this.Zh.timeAxisPaneViews?.()??[];if(this.na?.jh===t)return this.na.qh;const i=t.map((t=>new Ot(t)));return this.na={jh:t,qh:i},i}ra(t,i){return this.Zh.autoscaleInfo?.(t,i)??null}}function Ut(t,i,n,s){t.forEach((t=>{i(t).forEach((t=>{t.Yh()===n&&s.push(t)}))}))}function $t(t){return t.jn()}function jt(t){return t.sa()}function qt(t){return t.ea()}const Yt=["Area","Line","Baseline"];class Kt extends bt{constructor(t,i,n,s,e){super(t),this.qt=It(),this._r=new _t(this),this.ha=[],this.aa=new ht(this),this.la=null,this.oa=null,this._a=null,this.ua=[],this.ca=new Mt,this.da=new Map,this.fa=null,this.yn=n,this.pa=i;const r=new ut(this);if(this.mn=[r],this.ur=new st(r,this,t),Yt.includes(this.pa)&&(this.la=new ot(this)),this.va(),this.$h=s(this,this.Qt(),e),"Custom"===this.pa){const t=this.$h;t.ma&&this.wa(t.ma)}}m(){null!==this._a&&clearTimeout(this._a)}Oe(t){return this.yn.priceLineColor||t}Ee(t){const i={Ve:!0},n=this.Ft();if(this.Qt().Bt().Gi()||n.Gi()||this.qt.Gi())return i;const s=this.Qt().Bt().Ie(),e=this.zt();if(null===s||null===e)return i;let r,h;if(t){const t=this.qt.Ch();if(null===t)return i;r=t,h=t.$n}else{const t=this.qt.Hn(s.bi(),-1);if(null===t)return i;if(r=this.qt.ph(t.$n),null===r)return i;h=t.$n}const a=r.Wt[3],l=this.ga().gh(h,{Wt:r}),o=n.Nt(a,e.Wt);return{Ve:!1,gt:a,ri:n.Ji(a,e.Wt),Ue:n.Ma(a),$e:n.ba(a,e.Wt),R:l.th,Bi:o,$n:h}}ga(){return null!==this.oa||(this.oa=new St(this)),this.oa}N(){return this.yn}cr(t){const i=this.Qt(),{priceScaleId:n,visible:s,priceFormat:e}=t;void 0!==n&&n!==this.yn.priceScaleId&&i.xa(this,n),void 0!==s&&s!==this.yn.visible&&i.Sa();const r=void 0!==t.conflationThresholdFactor;_(this.yn,t),r&&(this.da.clear(),this.Qt().dr()),void 0!==e&&(this.va(),i.Ca()),i.ya(this),i.Pa(),this.$h.Pt("options")}ht(t,i){this.qt.ht(t),this.da.clear();const n=this.Qt().Bt().N();n.enableConflation&&n.precomputeConflationOnInit&&this.ka(n.precomputeConflationPriority),this.$h.Pt("data"),null!==this.la&&(i&&i.Ta?this.la.ke():0===t.length&&this.la.Pe());const s=this.Qt().Ks(this);this.Qt().Ra(s),this.Qt().ya(this),this.Qt().Pa(),this.Qt().dr()}Da(t){const i=new gt(this,t);return this.ha.push(i),this.Qt().ya(this),i}Ia(t){const i=this.ha.indexOf(t);-1!==i&&this.ha.splice(i,1),this.Qt().ya(this)}Ea(){return this.ha}wh(){return this.pa}zt(){const t=this.Va();return null===t?null:{Wt:t.Wt[3],Ba:t.wt}}Va(){const t=this.Qt().Bt().Ie();if(null===t)return null;const i=t.Aa();return this.qt.Hn(i,1)}Un(){return this.qt}wa(t){this.fa=t,this.da.clear()}za(){return!!this.Qt().Bt().N().enableConflation&&this.La()>1}Pr(t){if(!this.za())return;const i=this.La();if(!this.da.has(i))return;const n="Custom"===this.pa,s=n&&this.fa||void 0,e=n&&this.$h.Oa?t=>{const i=t,n=this.$h.Oa(i);return Array.isArray(n)?n:["number"==typeof n?n:0]}:void 0,r=this.ca.Pr(this.qt.Dh(),t,i,s,n,e),h=It();h.ht(r),this.da.set(i,h)}Na(){const t=this.Qt().Bt().N().enableConflation;if("Custom"===this.pa&&null===this.fa)return this.qt;if(!t)return this.qt;const i=this.La(),n=this.da.get(i);if(n)return n;this.Fa(i);return this.da.get(i)??this.qt}Wa(t){const i=this.qt.ph(t);return null===i?null:"Bar"===this.pa||"Candlestick"===this.pa||"Custom"===this.pa?{Hr:i.Wt[0],Ur:i.Wt[1],$r:i.Wt[2],jr:i.Wt[3]}:i.Wt[3]}Ha(t){const i=[];Ut(this.ua,$t,"top",i);const n=this.la;return null!==n&&n.It()?(null===this._a&&n.Re()&&(this._a=setTimeout((()=>{this._a=null,this.Qt().Ua()}),0)),n.Te(),i.unshift(n),i):i}jn(){const t=[];this.$a()||t.push(this.aa),t.push(this.$h,this._r);const i=this.ha.map((t=>t.pr()));return t.push(...i),Ut(this.ua,$t,"normal",t),t}ja(){return this.qa($t,"bottom")}Ya(t){return this.qa(jt,t)}Ka(t){return this.qa(qt,t)}Za(t,i){return this.ua.map((n=>n.Qs(t,i))).filter((t=>null!==t))}cn(){return[this.ur,...this.ha.map((t=>t.vr()))]}qn(t,i){if(i!==this.hn&&!this.$a())return[];const n=[...this.mn];for(const t of this.ha)n.push(t.mr());return this.ua.forEach((t=>{n.push(...t.qn())})),n}dn(){const t=[];return this.ua.forEach((i=>{t.push(...i.dn())})),t}ra(t,i){if(void 0!==this.yn.autoscaleInfoProvider){const n=this.yn.autoscaleInfoProvider((()=>{const n=this.Ga(t,i);return null===n?null:n.tr()}));return ft.ir(n)}return this.Ga(t,i)}jh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}Xa(){return this.Ja}Nn(){this.$h.Pt();for(const t of this.mn)t.Pt();for(const t of this.ha)t.Pt();this._r.Pt(),this.aa.Pt(),this.la?.Pt(),this.ua.forEach((t=>t.Nn()))}Ft(){return a(super.Ft())}At(t){if(!(("Line"===this.pa||"Area"===this.pa||"Baseline"===this.pa)&&this.yn.crosshairMarkerVisible))return null;const i=this.qt.ph(t);if(null===i)return null;return{gt:i.Wt[3],ft:this.Qa(),Ht:this.tl(),Ot:this.il(),Lt:this.nl(t)}}Ne(){return this.yn.title}It(){return this.yn.visible}sl(t){this.ua.push(new Ht(t,this))}el(t){this.ua=this.ua.filter((i=>i.Gh()!==t))}rl(){if("Custom"===this.pa)return t=>this.$h.Oa(t)}hl(){if("Custom"===this.pa)return t=>this.$h.al(t)}ll(){return this.qt.Vh()}$a(){return!q(this.Ft().ol())}Ga(t,i){if(!c(t)||!c(i)||this.qt.Gi())return null;const n="Line"===this.pa||"Area"===this.pa||"Baseline"===this.pa||"Histogram"===this.pa?[3]:[2,1],s=this.qt.Ih(t,i,n);let e=null!==s?new dt(s.Fh,s.Wh):null,r=null;if("Histogram"===this.wh()){const t=this.yn.base,i=new dt(t,t);e=null!==e?e.xs(i):i}return this.ua.forEach((n=>{const s=n.ra(t,i);if(s?.priceRange){const t=new dt(s.priceRange.minValue,s.priceRange.maxValue);e=null!==e?e.xs(t):t}s?.margins&&(r=s.margins)})),new ft(e,r)}Qa(){switch(this.pa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}tl(){switch(this.pa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}il(){switch(this.pa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}nl(t){switch(this.pa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.ga().gh(t).th}va(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.Ja={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(i=>i.map(t))};break}case"volume":this.Ja=new Q(this.yn.priceFormat.precision);break;case"percent":this.Ja=new J(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.Ja=new X(t,this.yn.priceFormat.minMove*t)}}null!==this.hn&&this.hn._l()}qa(t,i){const n=[];return Ut(this.ua,t,i,n),n}La(){const{ul:t,cl:i,dl:n}=this.fl();return this.ca.gr(t,i,n)}fl(){const t=this.Qt().Bt(),i=t.ul(),n=window.devicePixelRatio||1,s=t.N().conflationThresholdFactor;return{ul:i,cl:n,dl:this.yn.conflationThresholdFactor??s??1}}pl(t){const i=this.qt.Dh();let n;if("Custom"===this.pa&&null!==this.fa){const s=this.rl();if(!s)throw new Error(vt);n=this.ca.Mr(i,t,this.fa,!0,(t=>s(t)))}else n=this.ca.Mr(i,t);const s=It();return s.ht(n),s}Fa(t){const i=this.pl(t);this.da.set(t,i)}ka(t){if("Custom"===this.pa&&(null===this.fa||!this.rl()))return;this.da.clear();const i=this.Qt().Bt().vl();for(const n of i){const i=()=>{this.ml(n)},s="object"==typeof window&&window||"object"==typeof self&&self;s?.gl?.wl?s.gl.wl((()=>{i()}),{Ml:t}):Promise.resolve().then((()=>i()))}}ml(t){if(this.da.has(t))return;if(0===this.qt.Dh().length)return;const i=this.pl(t);this.da.set(t,i)}}const Zt=[3],Gt=[0,1,2,3];class Xt{constructor(t){this.yn=t}bl(t,i,n){let s=t;if(0===this.yn.mode)return s;const e=n.kn(),r=e.zt();if(null===r)return s;const h=e.Nt(t,r),a=n.xl().filter((t=>t instanceof Kt)).reduce(((t,s)=>{if(n.Zs(s)||!s.It())return t;const e=s.Ft(),r=s.Un();if(e.Gi()||!r.Be(i))return t;const h=r.ph(i);if(null===h)return t;const a=l(s.zt()),o=3===this.yn.mode?Gt:Zt;return t.concat(o.map((t=>e.Nt(h.Wt[t],a.Wt))))}),[]);if(0===a.length)return s;a.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=a[0];return s=e.Tn(o,r),s}}function Jt(t,i,n){return Math.min(Math.max(t,i),n)}function Qt(t,i,n){return i-t<=n}function ti(t){const i=Math.ceil(t);return i%2==0?i-1:i}class ii extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:e}){if(null===this.qt)return;const r=Math.max(1,Math.floor(n));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=a(this.qt);if(h.Sl){t.strokeStyle=h.Cl,s(t,h.yl),t.beginPath();for(const s of h.Pl){const e=Math.round(s.kl*n);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Tl){t.strokeStyle=h.Rl,s(t,h.Dl),t.beginPath();for(const n of h.Il){const s=Math.round(n.kl*e);t.moveTo(-r,s),t.lineTo(i.width+r,s)}t.stroke()}}))}}class ni{constructor(t){this.Xt=new ii,this.St=!0,this.yt=t}Pt(){this.St=!0}Tt(){if(this.St){const t=this.yt.Qt().N().grid,i={Tl:t.horzLines.visible,Sl:t.vertLines.visible,Rl:t.horzLines.color,Cl:t.vertLines.color,Dl:t.horzLines.style,yl:t.vertLines.style,Il:this.yt.kn().El(),Pl:(this.yt.Qt().Bt().El()||[]).map((t=>({kl:t.coord})))};this.Xt.ht(i),this.St=!1}return this.Xt}}class si{constructor(t){this.$h=new ni(t)}pr(){return this.$h}}const ei={Vl:4,Bl:1e-4};function ri(t,i){const n=100*(t-i)/i;return i<0?-n:n}function hi(t,i){const n=ri(t.Ze(),i),s=ri(t.Ge(),i);return new dt(n,s)}function ai(t,i){const n=100*(t-i)/i+100;return i<0?-n:n}function li(t,i){const n=ai(t.Ze(),i),s=ai(t.Ge(),i);return new dt(n,s)}function oi(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.log10(n+i.Bl)+i.Vl;return t<0?-s:s}function _i(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.pow(10,n-i.Vl)-i.Bl;return t<0?-s:s}function ui(t,i){if(null===t)return null;const n=oi(t.Ze(),i),s=oi(t.Ge(),i);return new dt(n,s)}function ci(t,i){if(null===t)return null;const n=_i(t.Ze(),i),s=_i(t.Ge(),i);return new dt(n,s)}function di(t){if(null===t)return ei;const i=Math.abs(t.Ge()-t.Ze());if(i>=1||i<1e-15)return ei;const n=Math.ceil(Math.abs(Math.log10(i))),s=ei.Vl+n;return{Vl:s,Bl:1/Math.pow(10,s)}}class fi{constructor(t,i){if(this.Al=t,this.zl=i,function(t){if(t<0)return!1;if(t>1e18)return!0;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Al))this.Ll=[2,2.5,2];else{this.Ll=[];for(let t=this.Al;1!==t;){if(t%2==0)this.Ll.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Ll.push(2,2.5),t/=5}if(this.Ll.length>100)throw new Error("something wrong with base")}}}Ol(t,i,n){const s=0===this.Al?0:1/this.Al;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.zl[0];for(;;){const t=Qt(e,s,1e-14)&&e>s+1e-14,i=Qt(e,n*h,1e-14),a=Qt(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.zl[++r%this.zl.length]}if(e<=s+1e-14&&(e=s),e=Math.max(1,e),this.Ll.length>0&&(a=e,l=1,o=1e-14,Math.abs(a-l)<o))for(r=0,h=this.Ll[0];Qt(e,n*h,1e-14)&&e>s+1e-14;)e/=h,h=this.Ll[++r%this.Ll.length];var a,l,o;return e}}class pi{constructor(t,i,n,s){this.Nl=[],this.Ki=t,this.Al=i,this.Fl=n,this.Wl=s}Ol(t,i){if(t<i)throw new Error("high < low");const n=this.Ki.$t(),s=(t-i)*this.Hl()/n,e=new fi(this.Al,[2,2.5,2]),r=new fi(this.Al,[2,2,2.5]),h=new fi(this.Al,[2.5,2,2]),a=[];return a.push(e.Ol(t,i,s),r.Ol(t,i,s),h.Ol(t,i,s)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(a)}Ul(){const t=this.Ki,i=t.zt();if(null===i)return void(this.Nl=[]);const n=t.$t(),s=this.Fl(n-1,i),e=this.Fl(0,i),r=this.Ki.N().entireTextOnly?this.$l()/2:0,h=r,a=n-1-r,l=Math.max(s,e),o=Math.min(s,e);if(l===o)return void(this.Nl=[]);const _=this.Ol(l,o);if(this.jl(i,_,l,o,h,a),t.ql()&&this.Yl(_,o,l)){const t=this.Ki.Kl();this.Zl(i,_,h,a,t,2*t)}const u=this.Nl.map((t=>t.Gl)),c=this.Ki.Xl(u);for(let t=0;t<this.Nl.length;t++)this.Nl[t].Jl=c[t]}El(){return this.Nl}$l(){return this.Ki.P()}Hl(){return Math.ceil(2.5*this.$l())}jl(t,i,n,s,e,r){const h=this.Nl,a=this.Ki;let l=n%i;l+=l<0?i:0;const o=n>=s?1:-1;let _=null,u=0;for(let c=n-l;c>s;c-=i){const n=this.Wl(c,t,!0);null!==_&&Math.abs(n-_)<this.Hl()||(n<e||n>r||(u<h.length?(h[u].kl=n,h[u].Jl=a.Ql(c),h[u].Gl=c):h.push({kl:n,Jl:a.Ql(c),Gl:c}),u++,_=n,a.io()&&(i=this.Ol(c*o,s))))}h.length=u}Zl(t,i,n,s,e,r){const h=this.Nl,a=this.no(t,n,e,r),l=this.no(t,s,-r,-e),o=this.Wl(0,t,!0)-this.Wl(i,t,!0);h.length>0&&h[0].kl-a.kl<o/2&&h.shift(),h.length>0&&l.kl-h[h.length-1].kl<o/2&&h.pop(),h.unshift(a),h.push(l)}no(t,i,n,s){const e=(n+s)/2,r=this.Fl(i+n,t),h=this.Fl(i+s,t),a=Math.min(r,h),l=Math.max(r,h),o=Math.max(.1,this.Ol(l,a)),_=this.Fl(i+e,t),u=_-_%o,c=this.Wl(u,t,!0);return{Jl:this.Ki.Ql(u),kl:c,Gl:u}}Yl(t,i,n){let s=l(this.Ki.er());return this.Ki.io()&&(s=ci(s,this.Ki.so())),s.Ze()-i<t&&n-s.Ge()<t}}function vi(t){return t.slice().sort(((t,i)=>a(t.ln())-a(i.ln())))}var mi;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(mi||(mi={}));const wi=new J,gi=new X(100,1);class Mi{constructor(t,i,n,s,e){this.eo=0,this.ro=null,this.nr=null,this.ho=null,this.ao={lo:!1,oo:null},this._o=!1,this.uo=0,this.co=0,this.do=new o,this.fo=new o,this.po=[],this.vo=null,this.mo=null,this.wo=null,this.Mo=null,this.bo=null,this.Ja=gi,this.xo=di(null),this.So=t,this.yn=i,this.Co=n,this.yo=s,this.Po=e,this.ko=new pi(this,100,this.To.bind(this),this.Ro.bind(this))}ol(){return this.So}N(){return this.yn}cr(t){if(_(this.yn,t),this._l(),void 0!==t.mode&&this.Do({ae:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),n=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(n<0||n>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(i+n>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+n}`);this.Io(),this.wo=null}}Eo(){return this.yn.autoScale}Vo(){return this._o}io(){return 1===this.yn.mode}He(){return 2===this.yn.mode}Bo(){return 3===this.yn.mode}so(){return this.xo}ae(){return{hs:this.yn.autoScale,Ao:this.yn.invertScale,ae:this.yn.mode}}Do(t){const i=this.ae();let n=null;void 0!==t.hs&&(this.yn.autoScale=t.hs),void 0!==t.ae&&(this.yn.mode=t.ae,2!==t.ae&&3!==t.ae||(this.yn.autoScale=!0),this.ao.lo=!1),1===i.ae&&t.ae!==i.ae&&(!function(t,i){if(null===t)return!1;const n=_i(t.Ze(),i),s=_i(t.Ge(),i);return isFinite(n)&&isFinite(s)}(this.nr,this.xo)?this.yn.autoScale=!0:(n=ci(this.nr,this.xo),null!==n&&this.zo(n))),1===t.ae&&t.ae!==i.ae&&(n=ui(this.nr,this.xo),null!==n&&this.zo(n));const s=i.ae!==this.yn.mode;s&&(2===i.ae||this.He())&&this._l(),s&&(3===i.ae||this.Bo())&&this._l(),void 0!==t.Ao&&i.Ao!==t.Ao&&(this.yn.invertScale=t.Ao,this.Lo()),this.fo.p(i,this.ae())}Oo(){return this.fo}P(){return this.Co.fontSize}$t(){return this.eo}No(t){this.eo!==t&&(this.eo=t,this.Io(),this.wo=null)}Fo(){if(this.ro)return this.ro;const t=this.$t()-this.Wo()-this.Ho();return this.ro=t,t}er(){return this.Uo(),this.nr}zo(t,i){const n=this.nr;(i||null===n&&null!==t||null!==n&&!n.Ye(t))&&(this.wo=null,this.nr=t)}$o(t){this.zo(t),this.jo(null!==t)}Gi(){return this.Uo(),0===this.eo||!this.nr||this.nr.Gi()}qo(t){return this.Ao()?t:this.$t()-1-t}Nt(t,i){return this.He()?t=ri(t,i):this.Bo()&&(t=ai(t,i)),this.Ro(t,i)}Yo(t,i,n){this.Uo();const s=this.Ho(),e=a(this.er()),r=e.Ze(),h=e.Ge(),l=this.Fo()-1,o=this.Ao(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Ko();for(let n=u;n<c;n++){const e=t[n],h=e.gt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.gt,i));const l=s+_*(a-r),u=o?l:this.eo-1-l;e.ut=u}}Zo(t,i,n){this.Uo();const s=this.Ho(),e=a(this.er()),r=e.Ze(),h=e.Ge(),l=this.Fo()-1,o=this.Ao(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Ko();for(let n=u;n<c;n++){const e=t[n];let h=e.Hr,a=e.Ur,l=e.$r,u=e.jr;null!==d&&(h=d(e.Hr,i),a=d(e.Ur,i),l=d(e.$r,i),u=d(e.jr,i));let c=s+_*(h-r),f=o?c:this.eo-1-c;e.Go=f,c=s+_*(a-r),f=o?c:this.eo-1-c,e.Xo=f,c=s+_*(l-r),f=o?c:this.eo-1-c,e.Jo=f,c=s+_*(u-r),f=o?c:this.eo-1-c,e.Qo=f}}Tn(t,i){const n=this.To(t,i);return this.t_(n,i)}t_(t,i){let n=t;return this.He()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this.Bo()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n}xl(){return this.po}Dt(){return this.mo||(this.mo=vi(this.po)),this.mo}i_(t){-1===this.po.indexOf(t)&&(this.po.push(t),this._l(),this.n_())}s_(t){const i=this.po.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.po.splice(i,1),0===this.po.length&&(this.Do({hs:!0}),this.zo(null)),this._l(),this.n_()}zt(){let t=null;for(const i of this.po){const n=i.zt();null!==n&&((null===t||n.Ba<t.Ba)&&(t=n))}return null===t?null:t.Wt}Ao(){return this.yn.invertScale}El(){const t=null===this.zt();if(null!==this.wo&&(t||this.wo.e_===t))return this.wo.El;this.ko.Ul();const i=this.ko.El();return this.wo={El:i,e_:t},this.do.p(),i}r_(){return this.do}h_(t){this.He()||this.Bo()||null===this.Mo&&null===this.ho&&(this.Gi()||(this.Mo=this.eo-t,this.ho=a(this.er()).Ke()))}a_(t){if(this.He()||this.Bo())return;if(null===this.Mo)return;this.Do({hs:!1}),(t=this.eo-t)<0&&(t=0);let i=(this.Mo+.2*(this.eo-1))/(t+.2*(this.eo-1));const n=a(this.ho).Ke();i=Math.max(i,.1),n.Je(i),this.zo(n)}l_(){this.He()||this.Bo()||(this.Mo=null,this.ho=null)}o_(t){this.Eo()||null===this.bo&&null===this.ho&&(this.Gi()||(this.bo=t,this.ho=a(this.er()).Ke()))}__(t){if(this.Eo())return;if(null===this.bo)return;const i=a(this.er()).Xe()/(this.Fo()-1);let n=t-this.bo;this.Ao()&&(n*=-1);const s=n*i,e=a(this.ho).Ke();e.Qe(s),this.zo(e,!0),this.wo=null}u_(){this.Eo()||null!==this.bo&&(this.bo=null,this.ho=null)}Xa(){return this.Ja||this._l(),this.Ja}Ji(t,i){switch(this.yn.mode){case 2:return this.c_(ri(t,i));case 3:return this.Xa().format(ai(t,i));default:return this.lr(t)}}Ql(t){switch(this.yn.mode){case 2:return this.c_(t);case 3:return this.Xa().format(t);default:return this.lr(t)}}Xl(t){switch(this.yn.mode){case 2:return this.d_(t);case 3:return this.Xa().formatTickmarks(t);default:return this.f_(t)}}Ma(t){return this.lr(t,a(this.vo).Xa())}ba(t,i){return t=ri(t,i),this.c_(t,wi)}p_(){return this.po}v_(t){this.ao={oo:t,lo:!1}}Nn(){this.po.forEach((t=>t.Nn()))}ql(){return this.yn.ensureEdgeTickMarksVisible&&this.Eo()}Kl(){return this.P()/2}_l(){this.wo=null;let t=1/0;this.vo=null;for(const i of this.po)i.ln()<t&&(t=i.ln(),this.vo=i);let i=100;null!==this.vo&&(i=Math.round(this.vo.jh())),this.Ja=gi,this.He()?(this.Ja=wi,i=100):this.Bo()?(this.Ja=new X(100,1),i=100):null!==this.vo&&(this.Ja=this.vo.Xa()),this.ko=new pi(this,i,this.To.bind(this),this.Ro.bind(this)),this.ko.Ul()}n_(){this.mo=null}m_(){return null===this.vo||this.He()||this.Bo()?1:1/this.vo.jh()}Xi(){return this.Po}jo(t){this._o=t}Wo(){return this.Ao()?this.yn.scaleMargins.bottom*this.$t()+this.co:this.yn.scaleMargins.top*this.$t()+this.uo}Ho(){return this.Ao()?this.yn.scaleMargins.top*this.$t()+this.uo:this.yn.scaleMargins.bottom*this.$t()+this.co}Uo(){this.ao.lo||(this.ao.lo=!0,this.w_())}Io(){this.ro=null}Ro(t,i){if(this.Uo(),this.Gi())return 0;t=this.io()&&t?oi(t,this.xo):t;const n=a(this.er()),s=this.Ho()+(this.Fo()-1)*(t-n.Ze())/n.Xe();return this.qo(s)}To(t,i){if(this.Uo(),this.Gi())return 0;const n=this.qo(t),s=a(this.er()),e=s.Ze()+s.Xe()*((n-this.Ho())/(this.Fo()-1));return this.io()?_i(e,this.xo):e}Lo(){this.wo=null,this.ko.Ul()}w_(){if(this.Vo()&&!this.Eo())return;const t=this.ao.oo;if(null===t)return;let i=null;const n=this.p_();let s=0,e=0;for(const r of n){if(!r.It())continue;const n=r.zt();if(null===n)continue;const h=r.ra(t.Aa(),t.bi());let l=h&&h.er();if(null!==l){switch(this.yn.mode){case 1:l=ui(l,this.xo);break;case 2:l=hi(l,n.Wt);break;case 3:l=li(l,n.Wt)}if(i=null===i?l:i.xs(a(l)),null!==h){const t=h.rr();null!==t&&(s=Math.max(s,t.above),e=Math.max(e,t.below))}}}if(this.ql()&&(s=Math.max(s,this.Kl()),e=Math.max(e,this.Kl())),s===this.uo&&e===this.co||(this.uo=s,this.co=e,this.wo=null,this.Io()),null!==i){if(i.Ze()===i.Ge()){const t=5*this.m_();this.io()&&(i=ci(i,this.xo)),i=new dt(i.Ze()-t,i.Ge()+t),this.io()&&(i=ui(i,this.xo))}if(this.io()){const t=ci(i,this.xo),n=di(t);if(r=n,h=this.xo,r.Vl!==h.Vl||r.Bl!==h.Bl){const s=null!==this.ho?ci(this.ho,this.xo):null;this.xo=n,i=ui(t,n),null!==s&&(this.ho=ui(s,n))}}this.zo(i)}else null===this.nr&&(this.zo(new dt(-.5,.5)),this.xo=di(null));var r,h}Ko(){return this.He()?ri:this.Bo()?ai:this.io()?t=>oi(t,this.xo):null}g_(t,i,n){return void 0===i?(void 0===n&&(n=this.Xa()),n.format(t)):i(t)}M_(t,i,n){return void 0===i?(void 0===n&&(n=this.Xa()),n.formatTickmarks(t)):i(t)}lr(t,i){return this.g_(t,this.yo.priceFormatter,i)}f_(t,i){const n=this.yo.priceFormatter;return this.M_(t,this.yo.tickmarksPriceFormatter??(n?t=>t.map(n):void 0),i)}c_(t,i){return this.g_(t,this.yo.percentageFormatter,i)}d_(t,i){const n=this.yo.percentageFormatter;return this.M_(t,this.yo.tickmarksPercentageFormatter??(n?t=>t.map(n):void 0),i)}}function bi(t){return t instanceof Kt}class xi{constructor(t,i){this.po=[],this.b_=new Map,this.eo=0,this.x_=0,this.S_=1,this.mo=null,this.C_=!1,this.y_=new o,this.ua=[],this.Jh=t,this.sn=i,this.P_=new si(this);const n=i.N();this.k_=this.T_("left",n.leftPriceScale),this.R_=this.T_("right",n.rightPriceScale),this.k_.Oo().i(this.D_.bind(this,this.k_),this),this.R_.Oo().i(this.D_.bind(this,this.R_),this),this.I_(n)}I_(t){if(t.leftPriceScale&&this.k_.cr(t.leftPriceScale),t.rightPriceScale&&this.R_.cr(t.rightPriceScale),t.localization&&(this.k_._l(),this.R_._l()),t.overlayPriceScales){const i=Array.from(this.b_.values());for(const n of i){const i=a(n[0].Ft());i.cr(t.overlayPriceScales),t.localization&&i._l()}}}E_(t){switch(t){case"left":return this.k_;case"right":return this.R_}return this.b_.has(t)?h(this.b_.get(t))[0].Ft():null}m(){this.Qt().V_().u(this),this.k_.Oo().u(this),this.R_.Oo().u(this),this.po.forEach((t=>{t.m&&t.m()})),this.ua=this.ua.filter((t=>{const i=t.Gh();return i.detached&&i.detached(),!1})),this.y_.p()}B_(){return this.S_}A_(t){this.S_=t}Qt(){return this.sn}nn(){return this.x_}$t(){return this.eo}z_(t){this.x_=t,this.L_()}No(t){this.eo=t,this.k_.No(t),this.R_.No(t),this.po.forEach((i=>{if(this.Zs(i)){const n=i.Ft();null!==n&&n.No(t)}})),this.L_()}O_(t){this.C_=t}N_(){return this.C_}F_(){return this.po.filter(bi)}xl(){return this.po}Zs(t){const i=t.Ft();return null===i||this.k_!==i&&this.R_!==i}i_(t,i,n){this.W_(t,i,n?t.ln():this.po.length)}s_(t,i){const n=this.po.indexOf(t);r(-1!==n,"removeDataSource: invalid data source"),this.po.splice(n,1),i||this.po.forEach(((t,i)=>t._n(i)));const s=a(t.Ft()).ol();if(this.b_.has(s)){const i=h(this.b_.get(s)),n=i.indexOf(t);-1!==n&&(i.splice(n,1),0===i.length&&this.b_.delete(s))}const e=t.Ft();e&&e.xl().indexOf(t)>=0&&(e.s_(t),this.H_(e)),this.mo=null}Xs(t){return t===this.k_?"left":t===this.R_?"right":"overlay"}U_(){return this.k_}j_(){return this.R_}q_(t,i){t.h_(i)}Y_(t,i){t.a_(i),this.L_()}K_(t){t.l_()}Z_(t,i){t.o_(i)}G_(t,i){t.__(i),this.L_()}X_(t){t.u_()}L_(){this.po.forEach((t=>{t.Nn()}))}kn(){let t=null;return this.sn.N().rightPriceScale.visible&&0!==this.R_.xl().length?t=this.R_:this.sn.N().leftPriceScale.visible&&0!==this.k_.xl().length?t=this.k_:0!==this.po.length&&(t=this.po[0].Ft()),null===t&&(t=this.R_),t}Gs(){let t=null;return this.sn.N().rightPriceScale.visible?t=this.R_:this.sn.N().leftPriceScale.visible&&(t=this.k_),t}H_(t){null!==t&&t.Eo()&&this.J_(t)}Q_(t){const i=this.Jh.Ie();t.Do({hs:!0}),null!==i&&t.v_(i),this.L_()}tu(){this.J_(this.k_),this.J_(this.R_)}iu(){this.H_(this.k_),this.H_(this.R_),this.po.forEach((t=>{this.Zs(t)&&this.H_(t.Ft())})),this.L_(),this.sn.dr()}Dt(){return null===this.mo&&(this.mo=vi(this.po)),this.mo}nu(t,i){i=Jt(i,0,this.po.length-1);const n=this.po.indexOf(t);r(-1!==n,"setSeriesOrder: invalid data source"),this.po.splice(n,1),this.po.splice(i,0,t),this.po.forEach(((t,i)=>t._n(i))),this.mo=null;for(const t of[this.k_,this.R_])t.n_(),t._l();this.sn.dr()}Et(){return this.Dt().filter(bi)}su(){return this.y_}eu(){return this.P_}sl(t){this.ua.push(new zt(t))}el(t){this.ua=this.ua.filter((i=>i.Gh()!==t)),t.detached&&t.detached(),this.sn.dr()}ru(){return this.ua}Za(t,i){return this.ua.map((n=>n.Qs(t,i))).filter((t=>null!==t))}J_(t){const i=t.p_();if(i&&i.length>0&&!this.Jh.Gi()){const i=this.Jh.Ie();null!==i&&t.v_(i)}t.Nn()}W_(t,i,n){let s=this.E_(i);if(null===s&&(s=this.T_(i,this.sn.N().overlayPriceScales)),this.po.splice(n,0,t),!q(i)){const n=this.b_.get(i)||[];n.push(t),this.b_.set(i,n)}t._n(n),s.i_(t),t.un(s),this.H_(s),this.mo=null}D_(t,i,n){i.ae!==n.ae&&this.J_(t)}T_(t,i){const n={visible:!0,autoScale:!0,...p(i)},s=new Mi(t,n,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return s.No(this.$t()),s}}function Si(t){return{hu:t.hu,au:{te:t.lu.externalId},ou:t.lu.cursorStyle}}function Ci(t,i,n,s){for(const e of t){const t=e.Tt(s);if(null!==t&&t.Qs){const s=t.Qs(i,n);if(null!==s)return{_u:e,au:s}}}return null}function yi(t){return void 0!==t.jn}function Pi(t,i,n){const s=[t,...t.Dt()],e=function(t,i,n){let s,e;for(const a of t){const t=a.Za?.(i,n)??[];for(const i of t)r=i.zOrder,h=s?.zOrder,(!h||"top"===r&&"top"!==h||"normal"===r&&"bottom"===h)&&(s=i,e=a)}var r,h;return s&&e?{lu:s,hu:e}:null}(s,i,n);if("top"===e?.lu.zOrder)return Si(e);for(const r of s){if(e&&e.hu===r&&"bottom"!==e.lu.zOrder&&!e.lu.isBackground)return Si(e);if(yi(r)){const s=Ci(r.jn(t),i,n,t);if(null!==s)return{hu:r,_u:s._u,au:s.au}}if(e&&e.hu===r&&"bottom"!==e.lu.zOrder&&e.lu.isBackground)return Si(e)}return e?.lu?Si(e):null}class ki{constructor(t,i,n=50){this.Es=0,this.Vs=1,this.Bs=1,this.zs=new Map,this.As=new Map,this.uu=t,this.cu=i,this.Ls=n}du(t){const i=t.time,n=this.cu.cacheKey(i),s=this.zs.get(n);if(void 0!==s)return s.fu;if(this.Es===this.Ls){const t=this.As.get(this.Bs);this.As.delete(this.Bs),this.zs.delete(h(t)),this.Bs++,this.Es--}const e=this.uu(t);return this.zs.set(n,{fu:e,Ws:this.Vs}),this.As.set(this.Vs,n),this.Es++,this.Vs++,e}}class Ti{constructor(t,i){r(t<=i,"right should be >= left"),this.pu=t,this.vu=i}Aa(){return this.pu}bi(){return this.vu}mu(){return this.vu-this.pu+1}Be(t){return this.pu<=t&&t<=this.vu}Ye(t){return this.pu===t.Aa()&&this.vu===t.bi()}}function Ri(t,i){return null===t||null===i?t===i:t.Ye(i)}class Di{constructor(){this.wu=new Map,this.zs=null,this.gu=!1}Mu(t){this.gu=t,this.zs=null}bu(t,i){this.xu(i),this.zs=null;for(let n=i;n<t.length;++n){const i=t[n];let s=this.wu.get(i.timeWeight);void 0===s&&(s=[],this.wu.set(i.timeWeight,s)),s.push({index:n,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}Su(t,i,n,s,e){const r=Math.ceil(i/t);return null!==this.zs&&this.zs.Cu===r&&e===this.zs.yu&&n===this.zs.Pu||(this.zs={yu:e,Pu:n,El:this.ku(r,n,s),Cu:r}),this.zs.El}xu(t){if(0===t)return void this.wu.clear();const i=[];this.wu.forEach(((n,s)=>{t<=n[0].index?i.push(s):n.splice(yt(n,t,(i=>i.index<t)),1/0)}));for(const t of i)this.wu.delete(t)}ku(t,i,n){let s=[];const e=t=>!i||n.has(t.index);for(const i of Array.from(this.wu.keys()).sort(((t,i)=>i-t))){if(!this.wu.get(i))continue;const n=s;s=[];const r=n.length;let a=0;const l=h(this.wu.get(i)),o=l.length;let _=1/0,u=-1/0;for(let i=0;i<o;i++){const h=l[i],o=h.index;for(;a<r;){const t=n[a],i=t.index;if(!(i<o&&e(t))){_=i;break}a++,s.push(t),u=i,_=1/0}if(_-o>=t&&o-u>=t&&e(h))s.push(h),u=o;else if(this.gu)return n}for(;a<r;a++)e(n[a])&&s.push(n[a])}return s}}class Ii{constructor(t){this.Tu=t}Ru(){return null===this.Tu?null:new Ti(Math.floor(this.Tu.Aa()),Math.ceil(this.Tu.bi()))}Du(){return this.Tu}static Iu(){return new Ii(null)}}function Ei(t,i){return t.weight>i.weight?t:i}class Vi{constructor(t,i,n,s){this.x_=0,this.Eu=null,this.Vu=[],this.bo=null,this.Mo=null,this.Bu=new Di,this.Au=new Map,this.zu=Ii.Iu(),this.Lu=!0,this.Ou=new o,this.Nu=new o,this.Fu=new o,this.Wu=null,this.Hu=null,this.Uu=new Map,this.$u=-1,this.ju=[],this.qu=1,this.yn=i,this.yo=n,this.Yu=i.rightOffset,this.Ku=i.barSpacing,this.sn=t,this.Zu(i),this.cu=s,this.Gu(),this.Bu.Mu(i.uniformDistribution),this.Xu(),this.Ju()}N(){return this.yn}Qu(t){_(this.yo,t),this.tc(),this.Gu()}cr(t,i){_(this.yn,t),this.yn.fixLeftEdge&&this.nc(),this.yn.fixRightEdge&&this.sc(),void 0!==t.barSpacing&&this.sn.gs(t.barSpacing),void 0!==t.rightOffset&&this.sn.Ms(t.rightOffset),this.Zu(t),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.sn.gs(t.barSpacing??this.Ku),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.Ju(),this.tc(),this.Gu(),void 0===t.enableConflation&&void 0===t.conflationThresholdFactor||this.Xu(),this.Fu.p()}Rn(t){return this.Vu[t]?.time??null}en(t){return this.Vu[t]??null}ec(t,i){if(this.Vu.length<1)return null;if(this.cu.key(t)>this.cu.key(this.Vu[this.Vu.length-1].time))return i?this.Vu.length-1:null;const n=yt(this.Vu,this.cu.key(t),((t,i)=>this.cu.key(t.time)<i));return this.cu.key(t)<this.cu.key(this.Vu[n].time)?i?n:null:n}Gi(){return 0===this.x_||0===this.Vu.length||null===this.Eu}rc(){return this.Vu.length>0}Ie(){return this.hc(),this.zu.Ru()}ac(){return this.hc(),this.zu.Du()}lc(){const t=this.Ie();if(null===t)return null;const i={from:t.Aa(),to:t.bi()};return this.oc(i)}oc(t){const i=Math.round(t.from),n=Math.round(t.to),s=a(this._c()),e=a(this.uc());return{from:a(this.en(Math.max(s,i))),to:a(this.en(Math.min(e,n)))}}cc(t){return{from:a(this.ec(t.from,!0)),to:a(this.ec(t.to,!0))}}nn(){return this.x_}z_(t){if(!isFinite(t)||t<=0)return;if(this.x_===t)return;const i=this.ac(),n=this.x_;if(this.x_=t,this.Lu=!0,this.yn.lockVisibleTimeRangeOnResize&&0!==n){const i=this.Ku*t/n;this.Ku=i}if(this.yn.fixLeftEdge&&null!==i&&i.Aa()<=0){const i=n-t;this.Yu-=Math.round(i/this.Ku)+1,this.Lu=!0}this.dc(),this.fc()}jt(t){if(this.Gi()||!c(t))return 0;const i=this.vc()+this.Yu-t;return this.x_-(i+.5)*this.Ku-1}mc(t,i){const n=this.vc(),s=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=s;i<e;i++){const s=t[i].wt,e=n+this.Yu-s,r=this.x_-(e+.5)*this.Ku-1;t[i]._t=r}}wc(t,i){const n=Math.ceil(this.gc(t));return i&&this.yn.ignoreWhitespaceIndices&&!this.Mc(n)?this.bc(n):n}Ms(t){this.Lu=!0,this.Yu=t,this.fc(),this.sn.xc(),this.sn.dr()}ul(){return this.Ku}gs(t){const i=this.Ku;if(this.Sc(t),void 0!==this.yn.rightOffsetPixels&&0!==i){const t=this.Yu*i/this.Ku;this.Yu=t}this.fc(),this.sn.xc(),this.sn.dr()}Cc(){return this.Yu}El(){if(this.Gi())return null;if(null!==this.Hu)return this.Hu;const t=this.Ku,i=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),n=Math.round(i/t),s=a(this.Ie()),e=Math.max(s.Aa(),s.Aa()-n),r=Math.max(s.bi(),s.bi()-n),h=this.Bu.Su(t,i,this.yn.ignoreWhitespaceIndices,this.Uu,this.$u),l=this._c()+n,o=this.uc()-n,_=this.yc(),u=this.yn.fixLeftEdge||_,c=this.yn.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.index&&t.index<=r))continue;let n;d<this.ju.length?(n=this.ju[d],n.coord=this.jt(t.index),n.label=this.Pc(t),n.weight=t.weight):(n={needAlignCoordinate:!1,coord:this.jt(t.index),label:this.Pc(t),weight:t.weight},this.ju.push(n)),this.Ku>i/2&&!_?n.needAlignCoordinate=!1:n.needAlignCoordinate=u&&t.index<=l||c&&t.index>=o,d++}return this.ju.length=d,this.Hu=this.ju,this.ju}kc(){let t;this.Lu=!0,this.gs(this.yn.barSpacing),t=void 0!==this.yn.rightOffsetPixels?this.yn.rightOffsetPixels/this.ul():this.yn.rightOffset,this.Ms(t)}Tc(t){this.Lu=!0,this.Eu=t,this.fc(),this.nc()}Rc(t,i){const n=this.gc(t),s=this.ul(),e=s+i*(s/10);this.gs(e),this.yn.rightBarStaysOnScroll||this.Ms(this.Cc()+(n-this.gc(t)))}h_(t){this.bo&&this.u_(),null===this.Mo&&null===this.Wu&&(this.Gi()||(this.Mo=t,this.Dc()))}a_(t){if(null===this.Wu)return;const i=Jt(this.x_-t,0,this.x_),n=Jt(this.x_-a(this.Mo),0,this.x_);0!==i&&0!==n&&this.gs(this.Wu.ul*i/n)}l_(){null!==this.Mo&&(this.Mo=null,this.Ic())}o_(t){null===this.bo&&null===this.Wu&&(this.Gi()||(this.bo=t,this.Dc()))}__(t){if(null===this.bo)return;const i=(this.bo-t)/this.ul();this.Yu=a(this.Wu).Cc+i,this.Lu=!0,this.fc()}u_(){null!==this.bo&&(this.bo=null,this.Ic())}Ec(){this.Vc(this.yn.rightOffset)}Vc(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const n=this.Yu,s=performance.now();this.sn.ps({Bc:t=>(t-s)/i>=1,Ac:e=>{const r=(e-s)/i;return r>=1?t:n+(t-n)*r}})}Pt(t,i){this.Lu=!0,this.Vu=t,this.Bu.bu(t,i),this.fc()}zc(){return this.Ou}Lc(){return this.Nu}Oc(){return this.Fu}vc(){return this.Eu||0}Nc(t,i){const n=t.mu(),s=i&&this.yn.rightOffsetPixels||0;this.Sc((this.x_-s)/n),this.Yu=t.bi()-this.vc(),i&&(this.Yu=s?s/this.ul():this.yn.rightOffset),this.fc(),this.Lu=!0,this.sn.xc(),this.sn.dr()}Fc(){const t=this._c(),i=this.uc();if(null===t||null===i)return;const n=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Nc(new Ti(t,i+n),!0)}Wc(t){const i=new Ti(t.from,t.to);this.Nc(i)}rn(t){return void 0!==this.yo.timeFormatter?this.yo.timeFormatter(t.originalTime):this.cu.formatHorzItem(t.time)}Ju(){if(!this.yn.ignoreWhitespaceIndices)return;this.Uu.clear();const t=this.sn.Jn();for(const i of t)for(const t of i.ll())this.Uu.set(t,!0);this.$u++}Hc(){return this.qu}vl(){const t=1/(window.devicePixelRatio||1),i=this.yn.minBarSpacing;if(i>=t)return[1];const n=[1];let s=2;for(;s<=512;){i<t/s&&n.push(s),s*=2}return n}yc(){const t=this.sn.N().handleScroll,i=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}_c(){return 0===this.Vu.length?null:0}uc(){return 0===this.Vu.length?null:this.Vu.length-1}Uc(t){return(this.x_-1-t)/this.Ku}gc(t){const i=this.Uc(t),n=this.vc()+this.Yu-i;return Math.round(1e6*n)/1e6}Sc(t){const i=this.Ku;this.Ku=t,this.dc(),i!==this.Ku&&(this.Lu=!0,this.$c(),this.Xu())}hc(){if(!this.Lu)return;if(this.Lu=!1,this.Gi())return void this.jc(Ii.Iu());const t=this.vc(),i=this.x_/this.Ku,n=this.Yu+t,s=new Ti(n-i+1,n);this.jc(new Ii(s))}dc(){const t=Jt(this.Ku,this.qc(),this.Yc());this.Ku!==t&&(this.Ku=t,this.Lu=!0)}Yc(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.x_}qc(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&0!==this.Vu.length?this.x_/this.Vu.length:this.yn.minBarSpacing}Xu(){if(!this.yn.enableConflation)return void(this.qu=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.Ku>=t)return void(this.qu=1);const i=t/this.Ku,n=Math.pow(2,Math.floor(Math.log2(i)));this.qu=Math.min(n,512)}fc(){const t=this.Kc();null!==t&&this.Yu<t&&(this.Yu=t,this.Lu=!0);const i=this.Zc();this.Yu>i&&(this.Yu=i,this.Lu=!0)}Kc(){const t=this._c(),i=this.Eu;if(null===t||null===i)return null;return t-i-1+(this.yn.fixLeftEdge?this.x_/this.Ku:Math.min(2,this.Vu.length))}Zc(){return this.yn.fixRightEdge?0:this.x_/this.Ku-Math.min(2,this.Vu.length)}Dc(){this.Wu={ul:this.ul(),Cc:this.Cc()}}Ic(){this.Wu=null}Pc(t){let i=this.Au.get(t.weight);return void 0===i&&(i=new ki((t=>this.Gc(t)),this.cu),this.Au.set(t.weight,i)),i.du(t)}Gc(t){return this.cu.formatTickmark(t,this.yo)}jc(t){const i=this.zu;this.zu=t,Ri(i.Ru(),this.zu.Ru())||this.Ou.p(),Ri(i.Du(),this.zu.Du())||this.Nu.p(),this.$c()}$c(){this.Hu=null}tc(){this.$c(),this.Au.clear()}Gu(){this.cu.updateFormatter(this.yo)}nc(){if(!this.yn.fixLeftEdge)return;const t=this._c();if(null===t)return;const i=this.Ie();if(null===i)return;const n=i.Aa()-t;if(n<0){const t=this.Yu-n-1;this.Ms(t)}this.dc()}sc(){this.fc(),this.dc()}Mc(t){return!this.yn.ignoreWhitespaceIndices||(this.Uu.get(t)||!1)}bc(t){const i=function*(t){const i=Math.round(t),n=i<t;let s=1;for(;;)n?(yield i+s,yield i-s):(yield i-s,yield i+s),s++}(t),n=this.uc();for(;n;){const t=i.next().value;if(this.Uu.get(t))return t;if(t<0||t>n)break}return t}Zu(t){if(void 0!==t.rightOffsetPixels){const i=t.rightOffsetPixels/(t.barSpacing||this.Ku);this.sn.Ms(i)}}}var Bi,Ai,zi,Li,Oi;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Bi||(Bi={}));class Ni{constructor(t,i,n){this.Xc=[],this.Jc=[],this.Qc=null,this.x_=0,this.td=null,this.nd=new o,this.sd=new o,this.ed=null,this.rd=t,this.yn=i,this.cu=n,this.Po=new S(this.yn.layout.colorParsers),this.hd=new M(this),this.Jh=new Vi(this,i.timeScale,this.yn.localization,n),this.Ct=new j(this,i.crosshair),this.ad=new Xt(i.crosshair),i.addDefaultPane&&(this.ld(0),this.Xc[0].A_(2)),this.od=this._d(0),this.ud=this._d(1)}Ca(){this.dd(Y.ys())}dr(){this.dd(Y.Cs())}Ua(){this.dd(new Y(1))}ya(t){const i=this.fd(t);this.dd(i)}pd(){return this.td}vd(t){if(this.td?.hu===t?.hu&&this.td?.au?.te===t?.au?.te)return;const i=this.td;this.td=t,null!==i&&this.ya(i.hu),null!==t&&t.hu!==i?.hu&&this.ya(t.hu)}N(){return this.yn}cr(t){_(this.yn,t),this.Xc.forEach((i=>i.I_(t))),void 0!==t.timeScale&&this.Jh.cr(t.timeScale),void 0!==t.localization&&this.Jh.Qu(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.nd.p(),this.od=this._d(0),this.ud=this._d(1),this.Ca()}md(t,i,n=0){const s=this.Xc[n];if(void 0===s)return;if("left"===t)return _(this.yn,{leftPriceScale:i}),s.I_({leftPriceScale:i}),this.nd.p(),void this.Ca();if("right"===t)return _(this.yn,{rightPriceScale:i}),s.I_({rightPriceScale:i}),this.nd.p(),void this.Ca();const e=this.wd(t,n);null!==e&&(e.Ft.cr(i),this.nd.p())}wd(t,i){const n=this.Xc[i];if(void 0===n)return null;const s=n.E_(t);return null!==s?{Kn:n,Ft:s}:null}Bt(){return this.Jh}Zn(){return this.Xc}gd(){return this.Ct}Md(){return this.sd}bd(t,i){t.No(i),this.xc()}z_(t){this.x_=t,this.Jh.z_(this.x_),this.Xc.forEach((i=>i.z_(t))),this.xc()}xd(t){1!==this.Xc.length&&(r(t>=0&&t<this.Xc.length,"Invalid pane index"),this.Xc.splice(t,1),this.Ca())}Sd(t,i){if(this.Xc.length<2)return;r(t>=0&&t<this.Xc.length,"Invalid pane index");const n=this.Xc[t],s=this.Xc.reduce(((t,i)=>t+i.B_()),0),e=this.Xc.reduce(((t,i)=>t+i.$t()),0),h=e-30*(this.Xc.length-1);i=Math.min(h,Math.max(30,i));const a=s/e,l=n.$t();n.A_(i*a);let o=i-l,_=this.Xc.length-1;for(const t of this.Xc)if(t!==n){const i=Math.min(h,Math.max(30,t.$t()-o/_));o-=t.$t()-i,_-=1;const n=i*a;t.A_(n)}this.Ca()}Cd(t,i){r(t>=0&&t<this.Xc.length&&i>=0&&i<this.Xc.length,"Invalid pane index");const n=this.Xc[t],s=this.Xc[i];this.Xc[t]=s,this.Xc[i]=n,this.Ca()}yd(t,i){if(r(t>=0&&t<this.Xc.length&&i>=0&&i<this.Xc.length,"Invalid pane index"),t===i)return;const[n]=this.Xc.splice(t,1);this.Xc.splice(i,0,n),this.Ca()}q_(t,i,n){t.q_(i,n)}Y_(t,i,n){t.Y_(i,n),this.Pa(),this.dd(this.Pd(t,2))}K_(t,i){t.K_(i),this.dd(this.Pd(t,2))}Z_(t,i,n){i.Eo()||t.Z_(i,n)}G_(t,i,n){i.Eo()||(t.G_(i,n),this.Pa(),this.dd(this.Pd(t,2)))}X_(t,i){i.Eo()||(t.X_(i),this.dd(this.Pd(t,2)))}Q_(t,i){t.Q_(i),this.dd(this.Pd(t,2))}kd(t){this.Jh.h_(t)}Td(t,i){const n=this.Bt();if(n.Gi()||0===i)return;const s=n.nn();t=Math.max(1,Math.min(t,s)),n.Rc(t,i),this.xc()}Rd(t){this.Dd(0),this.Id(t),this.Ed()}Vd(t){this.Jh.a_(t),this.xc()}Bd(){this.Jh.l_(),this.dr()}Dd(t){this.Jh.o_(t)}Id(t){this.Jh.__(t),this.xc()}Ed(){this.Jh.u_(),this.dr()}Jn(){return this.Jc}Wn(){return null===this.Qc&&(this.Qc=this.Jc.filter((t=>t.It()))),this.Qc}Sa(){this.Qc=null}Ad(t,i,n,s,e){this.Ct.In(t,i);let r=NaN,h=this.Jh.wc(t,!0);const a=this.Jh.Ie();null!==a&&(h=Math.min(Math.max(a.Aa(),h),a.bi())),h=this.Ct.Fn(h);const l=s.kn(),o=l.zt();if(null!==o&&(r=l.Tn(i,o)),r=this.ad.bl(r,h,s),this.Ct.An(h,r,s),this.Ua(),!e){const e=Pi(s,t,i);this.vd(e&&{hu:e.hu,au:e.au,ou:e.ou||null}),this.sd.p(this.Ct.Vt(),{x:t,y:i},n)}}zd(t,i,n){const s=n.kn(),e=s.zt(),r=s.Nt(t,a(e)),h=this.Jh.ec(i,!0),l=this.Jh.jt(a(h));this.Ad(l,r,null,n,!0)}Ld(t){this.gd().Ln(),this.Ua(),t||this.sd.p(null,null,null)}Pa(){const t=this.Ct.Kn();if(null!==t){const i=this.Ct.Vn(),n=this.Ct.Bn();this.Ad(i,n,null,t)}this.Ct.Nn()}Od(t,i,n){const s=this.Jh.Rn(0);void 0!==i&&void 0!==n&&this.Jh.Pt(i,n);const e=this.Jh.Rn(0),r=this.Jh.vc(),h=this.Jh.Ie();if(null!==h&&null!==s&&null!==e){const i=h.Be(r),a=this.cu.key(s)>this.cu.key(e),l=null!==t&&t>r&&!a,o=this.Jh.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===n)||o)&&this.Jh.N().shiftVisibleRangeOnNewBar;if(l&&!_){const i=t-r;this.Jh.Ms(this.Jh.Cc()-i)}}this.Jh.Tc(t)}Ra(t){null!==t&&t.iu()}Ks(t){if(function(t){return t instanceof xi}(t))return t;const i=this.Xc.find((i=>i.Dt().includes(t)));return void 0===i?null:i}xc(){this.Xc.forEach((t=>t.iu())),this.Pa()}m(){this.Xc.forEach((t=>t.m())),this.Xc.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Nd(){return this.hd}Js(){return this.hd.N()}V_(){return this.nd}Fd(t,i){const n=this.ld(i);this.Wd(t,n),this.Jc.push(t),this.Sa(),1===this.Jc.length?this.Ca():this.dr()}Hd(t){const i=this.Ks(t),n=this.Jc.indexOf(t);r(-1!==n,"Series not found");const s=a(i);this.Jc.splice(n,1),s.s_(t),t.m&&t.m(),this.Sa(),this.Jh.Ju(),this.Ud(s)}xa(t,i){const n=a(this.Ks(t));n.s_(t,!0),n.i_(t,i,!0)}Fc(){const t=Y.Cs();t.us(),this.dd(t)}$d(t){const i=Y.Cs();i.fs(t),this.dd(i)}ws(){const t=Y.Cs();t.ws(),this.dd(t)}gs(t){const i=Y.Cs();i.gs(t),this.dd(i)}Ms(t){const i=Y.Cs();i.Ms(t),this.dd(i)}ps(t){const i=Y.Cs();i.ps(t),this.dd(i)}cs(){const t=Y.Cs();t.cs(),this.dd(t)}jd(){return this.yn.rightPriceScale.visible?"right":"left"}qd(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.Yd(t))return;const n=a(this.Ks(t));n.s_(t);const s=this.ld(i);this.Wd(t,s),0===n.xl().length&&this.Ud(n),this.Ca()}Kd(){return this.ud}$(){return this.od}Ut(t){const i=this.ud,n=this.od;if(i===n)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.ed||this.ed.eh!==n||this.ed.rh!==i)this.ed={eh:n,rh:i,Zd:new Map};else{const i=this.ed.Zd.get(t);if(void 0!==i)return i}const s=this.Po.tt(n,i,t/100);return this.ed.Zd.set(t,s),s}Gd(t){return this.Xc.indexOf(t)}Xi(){return this.Po}Xd(){return this.Jd()}Jd(t){const i=new xi(this.Jh,this);this.Xc.push(i);const n=t??this.Xc.length-1,s=Y.ys();return s.es(n,{rs:0,hs:!0}),this.dd(s),i}ld(t){return r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.Xc.length,t))<this.Xc.length?this.Xc[t]:this.Jd(t)}Yd(t){return this.Xc.findIndex((i=>i.F_().includes(t)))}Pd(t,i){const n=new Y(i);if(null!==t){const s=this.Xc.indexOf(t);n.es(s,{rs:i})}return n}fd(t,i){return void 0===i&&(i=2),this.Pd(this.Ks(t),i)}dd(t){this.rd&&this.rd(t),this.Xc.forEach((t=>t.eu().pr().Pt()))}Wd(t,i){const n=t.N().priceScaleId,s=void 0!==n?n:this.jd();i.i_(t,s),q(s)||t.cr(t.N())}_d(t){const i=this.yn.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}Ud(t){!t.N_()&&0===t.xl().length&&this.Xc.length>1&&this.Xc.splice(this.Gd(t),1)}}function Fi(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const n=Math.round(t);if(Math.abs(n-t)<1e-8)return i;t*=10}return i}function Wi(t){return!u(t)&&!d(t)}function Hi(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Ai||(Ai={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(zi||(zi={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Li||(Li={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Oi||(Oi={}));const Ui=t=>t.getUTCFullYear();function $i(t,i,n){return i.replace(/yyyy/g,(t=>G(Ui(t),4))(t)).replace(/yy/g,(t=>G(Ui(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,n)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,n)).replace(/MM/g,(t=>G((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>G((t=>t.getUTCDate())(t),2))(t))}class ji{constructor(t="yyyy-MM-dd",i="default"){this.Qd=t,this.tf=i}du(t){return $i(t,this.Qd,this.tf)}}class qi{constructor(t){this.if=t||"%h:%m:%s"}du(t){return this.if.replace("%h",G(t.getUTCHours(),2)).replace("%m",G(t.getUTCMinutes(),2)).replace("%s",G(t.getUTCSeconds(),2))}}const Yi={nf:"yyyy-MM-dd",sf:"%h:%m:%s",ef:" ",rf:"default"};class Ki{constructor(t={}){const i={...Yi,...t};this.hf=new ji(i.nf,i.rf),this.af=new qi(i.sf),this.lf=i.ef}du(t){return`${this.hf.du(t)}${this.lf}${this.af.du(t)}`}}function Zi(t){return 60*t*60*1e3}function Gi(t){return 60*t*1e3}const Xi=[{_f:(Ji=1,1e3*Ji),uf:10},{_f:Gi(1),uf:20},{_f:Gi(5),uf:21},{_f:Gi(30),uf:22},{_f:Zi(1),uf:30},{_f:Zi(3),uf:31},{_f:Zi(6),uf:32},{_f:Zi(12),uf:33}];var Ji;function Qi(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let n=Xi.length-1;n>=0;--n)if(Math.floor(i.getTime()/Xi[n]._f)!==Math.floor(t.getTime()/Xi[n]._f))return Xi[n].uf;return 0}function tn(t){let i=t;if(d(t)&&(i=sn(t)),!Wi(i))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{cf:Math.round(n.getTime()/1e3),df:i}}function nn(t){if(!Hi(t))throw new Error("time must be of type isUTCTimestamp");return{cf:t}}function sn(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function en(t){d(t.time)&&(t.time=sn(t.time))}class rn{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(en)}(t):en(t)}createConverterToInternalObj(t){return a(function(t){return 0===t.length?null:Wi(t[0].time)||d(t[0].time)?tn:nn}(t))}key(t){return"object"==typeof t&&"cf"in t?t.cf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.df?new Date(1e3*i.cf).getTime():new Date(Date.UTC(i.df.year,i.df.month-1,i.df.day)).getTime()}convertHorzItemToInternal(t){return Hi(i=t)?nn(i):Wi(i)?tn(i):tn(sn(i));var i}updateFormatter(t){if(!this.yn)return;const i=t.dateFormat;this.yn.timeScale.timeVisible?this.ff=new Ki({nf:i,sf:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",ef:" ",rf:t.locale}):this.ff=new ji(i,t.locale)}formatHorzItem(t){const i=t;return this.ff.du(new Date(1e3*i.cf))}formatTickmark(t,i){const n=function(t,i,n){switch(t){case 0:case 10:return i?n?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),s=this.yn.timeScale;if(void 0!==s.tickMarkFormatter){const e=s.tickMarkFormatter(t.originalTime,n,i.locale);if(null!==e)return e}return function(t,i,n){const s={};switch(i){case 0:s.year="numeric";break;case 1:s.month="short";break;case 2:s.day="numeric";break;case 3:s.hour12=!1,s.hour="2-digit",s.minute="2-digit";break;case 4:s.hour12=!1,s.hour="2-digit",s.minute="2-digit",s.second="2-digit"}const e=void 0===t.df?new Date(1e3*t.cf):new Date(Date.UTC(t.df.year,t.df.month-1,t.df.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(n,s)}(t.time,n,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Ei,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let n=0===i?null:t[i-1].time.cf,s=null!==n?new Date(1e3*n):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*i.time.cf);null!==s&&(i.timeWeight=Qi(h,s)),e+=i.time.cf-(n||i.time.cf),n=i.time.cf,s=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),n=new Date(1e3*(t[0].time.cf-i));t[0].timeWeight=Qi(new Date(1e3*t[0].time.cf),n)}}(t,i)}static pf(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function hn(t){var i=t.width,n=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:n}}function an(t,i){return t.width===i.width&&t.height===i.height}var ln=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,n={next:t};return this._observers.push(n),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==n}))}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)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)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach((function(i){return i.next(t._window.devicePixelRatio)})),this._reinstallResolutionListener()},t}();var on=function(){function t(t,i,n){var s;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=hn({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(s=null==n?void 0:n.allowResizeObserver)||void 0===s||s,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return hn({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=hn(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;an(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var n=this;this._bitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,n=hn(this._transformBitmapSize(t,this._canvasElementClientSize)),s=an(this.bitmapSize,n)?null:n;null===i&&null===s||null!==i&&null!==s&&an(i,s)||(this._suggestedBitmapSize=s,this._emitSuggestedBitmapSizeChanged(i,s))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var n=this;this._suggestedBitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(n){t(n.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=_n(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new ln(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var n=_n(this._canvasElement);if(null!==n){var s=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:n.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return hn({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],s):hn({width:this._canvasElementClientSize.width*s,height:this._canvasElementClientSize.height*s});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var n=i.find((function(i){return i.target===t._canvasElement}));if(n&&n.devicePixelContentBoxSize&&n.devicePixelContentBoxSize[0]){var s=n.devicePixelContentBoxSize[0],e=hn({width:s.inlineSize,height:s.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function _n(t){return t.ownerDocument.defaultView}var un=function(){function t(t,i,n){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===n.width||0===n.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=n,this._context=t}return t.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()}},t.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(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function cn(t,i){var n=t.canvasElementClientSize;if(0===n.width||0===n.height)return null;var s=t.bitmapSize;if(0===s.width||0===s.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new un(e,n,s)}const dn="undefined"!=typeof window;function fn(){return!!dn&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function pn(){return!!dn&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function vn(t){return t+t%2}function mn(t){dn&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class wn{constructor(t,i,n){this.vf=0,this.mf=null,this.wf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.gf=0,this.Mf=null,this.bf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.xf=null,this.Sf=!1,this.Cf=null,this.yf=null,this.Pf=!1,this.kf=!1,this.Tf=!1,this.Rf=null,this.Df=null,this.If=null,this.Ef=null,this.Vf=null,this.Bf=null,this.Af=null,this.zf=0,this.Lf=!1,this.Of=!1,this.Nf=!1,this.Ff=0,this.Wf=null,this.Hf=!pn(),this.Uf=t=>{this.$f(t)},this.jf=t=>{if(this.qf(t)){const i=this.Yf(t);if(++this.gf,this.Mf&&this.gf>1){const{Kf:n}=this.Zf(bn(t),this.bf);n<30&&!this.Tf&&this.Gf(i,this.Jf.Xf),this.Qf()}}else{const i=this.Yf(t);if(++this.vf,this.mf&&this.vf>1){const{Kf:n}=this.Zf(bn(t),this.wf);n<5&&!this.kf&&this.tp(i,this.Jf.ip),this.np()}}},this.sp=t,this.Jf=i,this.yn=n,this.ep()}m(){null!==this.Rf&&(this.Rf(),this.Rf=null),null!==this.Df&&(this.Df(),this.Df=null),null!==this.Ef&&(this.Ef(),this.Ef=null),null!==this.Vf&&(this.Vf(),this.Vf=null),null!==this.Bf&&(this.Bf(),this.Bf=null),null!==this.If&&(this.If(),this.If=null),this.rp(),this.np()}hp(t){this.Ef&&this.Ef();const i=this.ap.bind(this);if(this.Ef=()=>{this.sp.removeEventListener("mousemove",i)},this.sp.addEventListener("mousemove",i),this.qf(t))return;const n=this.Yf(t);this.tp(n,this.Jf.lp),this.Hf=!0}np(){null!==this.mf&&clearTimeout(this.mf),this.vf=0,this.mf=null,this.wf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Qf(){null!==this.Mf&&clearTimeout(this.Mf),this.gf=0,this.Mf=null,this.bf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}ap(t){if(this.Nf||null!==this.yf)return;if(this.qf(t))return;const i=this.Yf(t);this.tp(i,this.Jf.op),this.Hf=!0}_p(t){const i=Sn(t.changedTouches,a(this.Wf));if(null===i)return;if(this.Ff=xn(t),null!==this.Af)return;if(this.Of)return;this.Lf=!0;const n=this.Zf(bn(i),a(this.yf)),{up:s,cp:e,Kf:r}=n;if(this.Pf||!(r<5)){if(!this.Pf){const t=.5*s,i=e>=t&&!this.yn.dp(),n=t>e&&!this.yn.fp();i||n||(this.Of=!0),this.Pf=!0,this.Tf=!0,this.rp(),this.Qf()}if(!this.Of){const n=this.Yf(t,i);this.Gf(n,this.Jf.pp),Mn(t)}}}vp(t){if(0!==t.button)return;const i=this.Zf(bn(t),a(this.Cf)),{Kf:n}=i;if(n>=5&&(this.kf=!0,this.np()),this.kf){const i=this.Yf(t);this.tp(i,this.Jf.mp)}}Zf(t,i){const n=Math.abs(i._t-t._t),s=Math.abs(i.ut-t.ut);return{up:n,cp:s,Kf:n+s}}wp(t){let i=Sn(t.changedTouches,a(this.Wf));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.Wf=null,this.Ff=xn(t),this.rp(),this.yf=null,this.Bf&&(this.Bf(),this.Bf=null);const n=this.Yf(t,i);if(this.Gf(n,this.Jf.gp),++this.gf,this.Mf&&this.gf>1){const{Kf:t}=this.Zf(bn(i),this.bf);t<30&&!this.Tf&&this.Gf(n,this.Jf.Xf),this.Qf()}else this.Tf||(this.Gf(n,this.Jf.Mp),this.Jf.Mp&&Mn(t));0===this.gf&&Mn(t),0===t.touches.length&&this.Sf&&(this.Sf=!1,Mn(t))}$f(t){if(0!==t.button)return;const i=this.Yf(t);if(this.Cf=null,this.Nf=!1,this.Vf&&(this.Vf(),this.Vf=null),fn()){this.sp.ownerDocument.documentElement.removeEventListener("mouseleave",this.Uf)}if(!this.qf(t))if(this.tp(i,this.Jf.bp),++this.vf,this.mf&&this.vf>1){const{Kf:n}=this.Zf(bn(t),this.wf);n<5&&!this.kf&&this.tp(i,this.Jf.ip),this.np()}else this.kf||this.tp(i,this.Jf.xp)}rp(){null!==this.xf&&(clearTimeout(this.xf),this.xf=null)}Sp(t){if(null!==this.Wf)return;const i=t.changedTouches[0];this.Wf=i.identifier,this.Ff=xn(t);const n=this.sp.ownerDocument.documentElement;this.Tf=!1,this.Pf=!1,this.Of=!1,this.yf=bn(i),this.Bf&&(this.Bf(),this.Bf=null);{const i=this._p.bind(this),s=this.wp.bind(this);this.Bf=()=>{n.removeEventListener("touchmove",i),n.removeEventListener("touchend",s)},n.addEventListener("touchmove",i,{passive:!1}),n.addEventListener("touchend",s,{passive:!1}),this.rp(),this.xf=setTimeout(this.Cp.bind(this,t),240)}const s=this.Yf(t,i);this.Gf(s,this.Jf.yp),this.Mf||(this.gf=0,this.Mf=setTimeout(this.Qf.bind(this),500),this.bf=bn(i))}Pp(t){if(0!==t.button)return;const i=this.sp.ownerDocument.documentElement;fn()&&i.addEventListener("mouseleave",this.Uf),this.kf=!1,this.Cf=bn(t),this.Vf&&(this.Vf(),this.Vf=null);{const t=this.vp.bind(this),n=this.$f.bind(this);this.Vf=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",n)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",n)}if(this.Nf=!0,this.qf(t))return;const n=this.Yf(t);this.tp(n,this.Jf.kp),this.mf||(this.vf=0,this.mf=setTimeout(this.np.bind(this),500),this.wf=bn(t))}ep(){this.sp.addEventListener("mouseenter",this.hp.bind(this)),this.sp.addEventListener("touchcancel",this.rp.bind(this));{const t=this.sp.ownerDocument,i=t=>{this.Jf.Tp&&(t.composed&&this.sp.contains(t.composedPath()[0])||t.target&&this.sp.contains(t.target)||this.Jf.Tp())};this.Df=()=>{t.removeEventListener("touchstart",i)},this.Rf=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}pn()&&(this.If=()=>{this.sp.removeEventListener("dblclick",this.jf)},this.sp.addEventListener("dblclick",this.jf)),this.sp.addEventListener("mouseleave",this.Rp.bind(this)),this.sp.addEventListener("touchstart",this.Sp.bind(this),{passive:!0}),mn(this.sp),this.sp.addEventListener("mousedown",this.Pp.bind(this)),this.Dp(),this.sp.addEventListener("touchmove",(()=>{}),{passive:!1})}Dp(){void 0===this.Jf.Ip&&void 0===this.Jf.Ep&&void 0===this.Jf.Vp||(this.sp.addEventListener("touchstart",(t=>this.Bp(t.touches)),{passive:!0}),this.sp.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.Af&&void 0!==this.Jf.Ep){const i=gn(t.touches[0],t.touches[1])/this.zf;this.Jf.Ep(this.Af,i),Mn(t)}}),{passive:!1}),this.sp.addEventListener("touchend",(t=>{this.Bp(t.touches)})))}Bp(t){1===t.length&&(this.Lf=!1),2!==t.length||this.Lf||this.Sf?this.Ap():this.zp(t)}zp(t){const i=this.sp.getBoundingClientRect()||{left:0,top:0};this.Af={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.zf=gn(t[0],t[1]),void 0!==this.Jf.Ip&&this.Jf.Ip(),this.rp()}Ap(){null!==this.Af&&(this.Af=null,void 0!==this.Jf.Vp&&this.Jf.Vp())}Rp(t){if(this.Ef&&this.Ef(),this.qf(t))return;if(!this.Hf)return;const i=this.Yf(t);this.tp(i,this.Jf.Lp),this.Hf=!pn()}Cp(t){const i=Sn(t.touches,a(this.Wf));if(null===i)return;const n=this.Yf(t,i);this.Gf(n,this.Jf.Op),this.Tf=!0,this.Sf=!0}qf(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:xn(t)<this.Ff+500}Gf(t,i){i&&i.call(this.Jf,t)}tp(t,i){i&&i.call(this.Jf,t)}Yf(t,i){const n=i||t,s=this.sp.getBoundingClientRect()||{left:0,top:0};return{clientX:n.clientX,clientY:n.clientY,pageX:n.pageX,pageY:n.pageY,screenX:n.screenX,screenY:n.screenY,localX:n.clientX-s.left,localY:n.clientY-s.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Np:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,Fp:t.type,Wp:n.target,_u:t.view,Hp:()=>{"touchstart"!==t.type&&Mn(t)}}}}function gn(t,i){const n=t.clientX-i.clientX,s=t.clientY-i.clientY;return Math.sqrt(n*n+s*s)}function Mn(t){t.cancelable&&t.preventDefault()}function bn(t){return{_t:t.pageX,ut:t.pageY}}function xn(t){return t.timeStamp||performance.now()}function Sn(t,i){for(let n=0;n<t.length;++n)if(t[n].identifier===i)return t[n];return null}class Cn{constructor(t,i,n){this.Up=null,this.$p=null,this.jp=!0,this.qp=null,this.Yp=t,this.Kp=t.Zp()[i],this.Gp=t.Zp()[n],this.Xp=document.createElement("tr"),this.Xp.style.height="1px",this.Jp=document.createElement("td"),this.Jp.style.position="relative",this.Jp.style.padding="0",this.Jp.style.margin="0",this.Jp.setAttribute("colspan","3"),this.Qp(),this.Xp.appendChild(this.Jp),this.jp=this.Yp.N().layout.panes.enableResize,this.jp?this.tv():(this.Up=null,this.$p=null)}m(){null!==this.$p&&this.$p.m()}iv(){return this.Xp}nv(){return hn({width:this.Kp.nv().width,height:1})}sv(){return hn({width:this.Kp.sv().width,height:1*window.devicePixelRatio})}ev(t,i,n){const s=this.sv();t.fillStyle=this.Yp.N().layout.panes.separatorColor,t.fillRect(i,n,s.width,s.height)}Pt(){this.Qp(),this.Yp.N().layout.panes.enableResize!==this.jp&&(this.jp=this.Yp.N().layout.panes.enableResize,this.jp?this.tv():(null!==this.Up&&(this.Jp.removeChild(this.Up.rv),this.Jp.removeChild(this.Up.hv),this.Up=null),null!==this.$p&&(this.$p.m(),this.$p=null)))}tv(){const t=document.createElement("div"),i=t.style;i.position="fixed",i.display="none",i.zIndex="49",i.top="0",i.left="0",i.width="100%",i.height="100%",i.cursor="row-resize",this.Jp.appendChild(t);const n=document.createElement("div"),s=n.style;s.position="absolute",s.zIndex="50",s.top="-4px",s.height="9px",s.width="100%",s.backgroundColor="",s.cursor="row-resize",this.Jp.appendChild(n);const e={lp:this.av.bind(this),Lp:this.lv.bind(this),kp:this.ov.bind(this),yp:this.ov.bind(this),mp:this._v.bind(this),pp:this._v.bind(this),bp:this.uv.bind(this),gp:this.uv.bind(this)};this.$p=new wn(n,e,{dp:()=>!1,fp:()=>!0}),this.Up={hv:n,rv:t}}Qp(){this.Jp.style.background=this.Yp.N().layout.panes.separatorColor}av(t){null!==this.Up&&(this.Up.hv.style.backgroundColor=this.Yp.N().layout.panes.separatorHoverColor)}lv(t){null!==this.Up&&null===this.qp&&(this.Up.hv.style.backgroundColor="")}ov(t){if(null===this.Up)return;const i=this.Kp.cv().B_()+this.Gp.cv().B_(),n=i/(this.Kp.nv().height+this.Gp.nv().height),s=30*n;i<=2*s||(this.qp={dv:t.pageY,fv:this.Kp.cv().B_(),pv:i-s,vv:i,mv:n,wv:s},this.Up.rv.style.display="block")}_v(t){const i=this.qp;if(null===i)return;const n=(t.pageY-i.dv)*i.mv,s=Jt(i.fv+n,i.wv,i.pv);this.Kp.cv().A_(s),this.Gp.cv().A_(i.vv-s),this.Yp.Qt().Ca()}uv(t){null!==this.qp&&null!==this.Up&&(this.qp=null,this.Up.rv.style.display="none")}}function yn(t,i){return t.gv-i.gv}function Pn(t,i,n){const s=(t.gv-i.gv)/(t.wt-i.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class kn{constructor(t,i,n,s){this.Mv=null,this.bv=null,this.xv=null,this.Sv=null,this.Cv=null,this.yv=0,this.Pv=0,this.kv=t,this.Tv=i,this.Rv=n,this.Ps=s}Dv(t,i){if(null!==this.Mv){if(this.Mv.wt===i)return void(this.Mv.gv=t);if(Math.abs(this.Mv.gv-t)<this.Ps)return}this.Sv=this.xv,this.xv=this.bv,this.bv=this.Mv,this.Mv={wt:i,gv:t}}fe(t,i){if(null===this.Mv||null===this.bv)return;if(i-this.Mv.wt>50)return;let n=0;const s=Pn(this.Mv,this.bv,this.Tv),e=yn(this.Mv,this.bv),r=[s],h=[e];if(n+=e,null!==this.xv){const t=Pn(this.bv,this.xv,this.Tv);if(Math.sign(t)===Math.sign(s)){const i=yn(this.bv,this.xv);if(r.push(t),h.push(i),n+=i,null!==this.Sv){const t=Pn(this.xv,this.Sv,this.Tv);if(Math.sign(t)===Math.sign(s)){const i=yn(this.xv,this.Sv);r.push(t),h.push(i),n+=i}}}}let a=0;for(let t=0;t<r.length;++t)a+=h[t]/n*r[t];Math.abs(a)<this.kv||(this.Cv={gv:t,wt:i},this.Pv=a,this.yv=function(t,i){const n=Math.log(i);return Math.log(1*n/-t)/n}(Math.abs(a),this.Rv))}Ac(t){const i=a(this.Cv),n=t-i.wt;return i.gv+this.Pv*(Math.pow(this.Rv,n)-1)/Math.log(this.Rv)}Bc(t){return null===this.Cv||this.Iv(t)===this.yv}Iv(t){const i=t-a(this.Cv).wt;return Math.min(i,this.yv)}}class Tn{constructor(t,i){this.Ev=void 0,this.Vv=void 0,this.Bv=void 0,this.vn=!1,this.Av=t,this.zv=i,this.Lv()}Pt(){this.Lv()}Ov(){this.Ev&&this.Av.removeChild(this.Ev),this.Vv&&this.Av.removeChild(this.Vv),this.Ev=void 0,this.Vv=void 0}Nv(){return this.vn!==this.Fv()||this.Bv!==this.Wv()}Wv(){return this.zv.Qt().Xi().J(this.zv.N().layout.textColor)>160?"dark":"light"}Fv(){return this.zv.N().layout.attributionLogo}Hv(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Lv(){this.Nv()&&(this.Ov(),this.vn=this.Fv(),this.vn&&(this.Bv=this.Wv(),this.Vv=document.createElement("style"),this.Vv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.Ev=document.createElement("a"),this.Ev.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.Hv()}`,this.Ev.title="Charting by TradingView",this.Ev.id="tv-attr-logo",this.Ev.target="_blank",this.Ev.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.Ev.toggleAttribute("data-dark","dark"===this.Bv),this.Av.appendChild(this.Vv),this.Av.appendChild(this.Ev)))}}function Rn(t,i){const n=a(t.ownerDocument).createElement("canvas");t.appendChild(n);const s=new on(n,(e={options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})}).transform,e.options);var e;return s.resizeCanvasElement(i),s}function Dn(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function In(t,i,n,s){t.Uh&&t.Uh(i,n,s)}function En(t,i,n,s){t.st(i,n,s)}function Vn(t,i,n,s){const e=t(n,s);for(const t of e){const n=t.Tt(s);null!==n&&i(n)}}function Bn(t,i){return n=>{if(!function(t){return void 0!==t.Ft}(n))return[];return(n.Ft()?.ol()??"")!==i?[]:n.Ya?.(t)??[]}}function An(t,i,n,s){if(!t.length)return;let e=0;const r=t[0].$t(s,!0);let h=1===i?n/2-(t[0].Hi()-r/2):t[0].Hi()-r/2-n/2;h=Math.max(0,h);for(let r=1;r<t.length;r++){const a=t[r],l=t[r-1],o=l.$t(s,!1),_=a.Hi(),u=l.Hi();if(1===i?_>u-o:_<u+o){const s=u-o*i;a.Ui(s);const r=s-i*o/2;if((1===i?r<0:r>n)&&h>0){const s=1===i?-1-r:r-n,a=Math.min(s,h);for(let n=e;n<t.length;n++)t[n].Ui(t[n].Hi()+i*a);h-=a}}else e=r,h=1===i?u-o-_:_-(u+o)}}class zn{constructor(t,i,n,s){this.Ki=null,this.Uv=null,this.$v=!1,this.jv=new it(200),this.qv=null,this.Yv=0,this.Kv=!1,this.Zv=()=>{this.Kv||this.yt.Gv().Qt().dr()},this.Xv=()=>{this.Kv||this.yt.Gv().Qt().dr()},this.yt=t,this.yn=i,this.Co=i.layout,this.hd=n,this.Jv="left"===s,this.Qv=Bn("normal",s),this.tm=Bn("top",s),this.im=Bn("bottom",s),this.Jp=document.createElement("div"),this.Jp.style.height="100%",this.Jp.style.overflow="hidden",this.Jp.style.width="25px",this.Jp.style.left="0",this.Jp.style.position="relative",this.nm=Rn(this.Jp,hn({width:16,height:16})),this.nm.subscribeSuggestedBitmapSizeChanged(this.Zv);const e=this.nm.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.sm=Rn(this.Jp,hn({width:16,height:16})),this.sm.subscribeSuggestedBitmapSizeChanged(this.Xv);const r=this.sm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={kp:this.ov.bind(this),yp:this.ov.bind(this),mp:this._v.bind(this),pp:this._v.bind(this),Tp:this.rm.bind(this),bp:this.uv.bind(this),gp:this.uv.bind(this),ip:this.hm.bind(this),Xf:this.hm.bind(this),lp:this.am.bind(this),Lp:this.lv.bind(this)};this.$p=new wn(this.sm.canvasElement,h,{dp:()=>!this.yn.handleScroll.vertTouchDrag,fp:()=>!0})}m(){this.$p.m(),this.sm.unsubscribeSuggestedBitmapSizeChanged(this.Xv),Dn(this.sm.canvasElement),this.sm.dispose(),this.nm.unsubscribeSuggestedBitmapSizeChanged(this.Zv),Dn(this.nm.canvasElement),this.nm.dispose(),null!==this.Ki&&this.Ki.r_().u(this),this.Ki=null}iv(){return this.Jp}P(){return this.Co.fontSize}lm(){const t=this.hd.N();return this.qv!==t.k&&(this.jv.Os(),this.qv=t.k),t}om(){if(null===this.Ki)return 0;let t=0;const i=this.lm(),n=a(this.nm.canvasElement.getContext("2d",{colorSpace:this.yt.Gv().N().layout.colorSpace}));n.save();const s=this.Ki.El();n.font=this._m(),s.length>0&&(t=Math.max(this.jv.Ii(n,s[0].Jl),this.jv.Ii(n,s[s.length-1].Jl)));const e=this.um();for(let i=e.length;i--;){const s=this.jv.Ii(n,e[i].ri());s>t&&(t=s)}const r=this.Ki.zt();if(null!==r&&null!==this.Uv&&(2!==(h=this.yn.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Ki.Tn(1,r),s=this.Ki.Tn(this.Uv.height-2,r);t=Math.max(t,this.jv.Ii(n,this.Ki.Ji(Math.floor(Math.min(i,s))+.11111111111111,r)),this.jv.Ii(n,this.Ki.Ji(Math.ceil(Math.max(i,s))-.11111111111111,r)))}var h;n.restore();const l=t||34;return vn(Math.ceil(i.S+i.C+i.V+i.B+5+l))}dm(t){null!==this.Uv&&an(this.Uv,t)||(this.Uv=t,this.Kv=!0,this.nm.resizeCanvasElement(t),this.sm.resizeCanvasElement(t),this.Kv=!1,this.Jp.style.width=`${t.width}px`,this.Jp.style.height=`${t.height}px`)}fm(){return a(this.Uv).width}un(t){this.Ki!==t&&(null!==this.Ki&&this.Ki.r_().u(this),this.Ki=t,t.r_().i(this.do.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.cv();this.yt.Gv().Qt().Q_(t,a(this.Ft()))}pm(t){if(null===this.Uv)return;const i={colorSpace:this.yt.Gv().N().layout.colorSpace};if(1!==t){this.vm(),this.nm.applySuggestedBitmapSize();const t=cn(this.nm,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.wm(t),this.gm(t)})),this.yt.Mm(t,this.im),this.bm(t),this.yt.Mm(t,this.Qv),this.xm(t))}this.sm.applySuggestedBitmapSize();const n=cn(this.sm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Sm(n),this.yt.Mm(n,this.tm))}sv(){return this.nm.bitmapSize}ev(t,i,n,s){const e=this.sv();if(e.width>0&&e.height>0&&(t.drawImage(this.nm.canvasElement,i,n),s)){const s=this.sm.canvasElement;t.drawImage(s,i,n)}}Pt(){this.Ki?.El()}ov(t){if(null===this.Ki||this.Ki.Gi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Gv().Qt(),n=this.yt.cv();this.$v=!0,i.q_(n,this.Ki,t.localY)}_v(t){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Gv().Qt(),n=this.yt.cv(),s=this.Ki;i.Y_(n,s,t.localY)}rm(){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt.Gv().Qt(),i=this.yt.cv(),n=this.Ki;this.$v&&(this.$v=!1,t.K_(i,n))}uv(t){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Gv().Qt(),n=this.yt.cv();this.$v=!1,i.K_(n,this.Ki)}hm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}am(t){if(null===this.Ki)return;!this.yt.Gv().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.He()||this.Ki.Bo()||this.Cm(1)}lv(t){this.Cm(0)}um(){const t=[],i=null===this.Ki?void 0:this.Ki;return(n=>{for(let s=0;s<n.length;++s){const e=n[s].qn(this.yt.cv(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.yt.cv().Dt()),t}wm({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.yt.cv().Qt(),r=e.$(),h=e.Kd();r===h?V(t,0,0,n,s,r):z(t,0,0,n,s,r,h)}gm({context:t,bitmapSize:i,horizontalPixelRatio:n}){if(null===this.Uv||null===this.Ki||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const s=Math.max(1,Math.floor(this.lm().S*n));let e;e=this.Jv?i.width-s:0,t.fillRect(e,0,s,i.height)}bm(t){if(null===this.Uv||null===this.Ki)return;const i=this.Ki.El(),n=this.Ki.N(),s=this.lm(),e=this.Jv?this.Uv.width-s.C:0;n.borderVisible&&n.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=n.borderColor;const a=Math.max(1,Math.floor(h)),l=Math.floor(.5*h),o=Math.round(s.C*r);t.beginPath();for(const n of i)t.rect(Math.floor(e*r),Math.round(n.kl*h)-l,o,a);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this._m(),t.fillStyle=n.textColor??this.Co.textColor,t.textAlign=this.Jv?"right":"left",t.textBaseline="middle";const r=this.Jv?Math.round(e-s.V):Math.round(e+s.C+s.V),h=i.map((i=>this.jv.Di(t,i.Jl)));for(let n=i.length;n--;){const s=i[n];t.fillText(s.Jl,r,s.kl+h[n])}}))}vm(){if(null===this.Uv||null===this.Ki)return;let t=this.Uv.height/2;const i=[],n=this.Ki.Dt().slice(),s=this.yt.cv(),e=this.lm();this.Ki===s.Gs()&&this.yt.cv().Dt().forEach((t=>{s.Zs(t)&&n.push(t)}));const r=this.Ki.xl()[0],h=this.Ki;n.forEach((n=>{const e=n.qn(s,h);e.forEach((t=>{t.$i()&&null===t.Wi()&&(t.Ui(null),i.push(t))})),r===n&&e.length>0&&(t=e[0].Bi())}));this.Ki.N().alignLabels&&this.ym(i,e,t)}ym(t,i,n){if(null===this.Uv)return;const s=t.filter((t=>t.Bi()<=n)),e=t.filter((t=>t.Bi()>n));s.sort(((t,i)=>i.Bi()-t.Bi())),s.length&&e.length&&e.push(s[0]),e.sort(((t,i)=>t.Bi()-i.Bi()));for(const n of t){const t=Math.floor(n.$t(i)/2),s=n.Bi();s>-t&&s<t&&n.Ui(t),s>this.Uv.height-t&&s<this.Uv.height+t&&n.Ui(this.Uv.height-t)}An(s,1,this.Uv.height,i),An(e,-1,this.Uv.height,i)}xm(t){if(null===this.Uv)return;const i=this.um(),n=this.lm(),s=this.Jv?"right":"left";i.forEach((i=>{if(i.ji()){i.Tt(a(this.Ki)).st(t,n,this.jv,s)}}))}Sm(t){if(null===this.Uv||null===this.Ki)return;const i=this.yt.Gv().Qt(),n=[],s=this.yt.cv(),e=i.gd().qn(s,this.Ki);e.length&&n.push(e);const r=this.lm(),h=this.Jv?"right":"left";n.forEach((i=>{i.forEach((i=>{i.Tt(a(this.Ki)).st(t,r,this.jv,h)}))}))}Cm(t){this.Jp.style.cursor=1===t?"ns-resize":"default"}do(){const t=this.om();this.Yv<t&&this.yt.Gv().Qt().Ca(),this.Yv=t}_m(){return g(this.Co.fontSize,this.Co.fontFamily)}}function Ln(t,i){return t.ja?.(i)??[]}function On(t,i){return t.jn?.(i)??[]}function Nn(t,i){return t.cn?.(i)??[]}function Fn(t,i){return t.Ha?.(i)??[]}class Wn{constructor(t,i){this.Uv=hn({width:0,height:0}),this.Pm=null,this.km=null,this.Tm=null,this.Rm=null,this.Dm=!1,this.Im=new o,this.Em=new o,this.Vm=0,this.Bm=!1,this.Am=null,this.zm=!1,this.Lm=null,this.Om=null,this.Kv=!1,this.Zv=()=>{this.Kv||null===this.Nm||this.sn().dr()},this.Xv=()=>{this.Kv||null===this.Nm||this.sn().dr()},this.zv=t,this.Nm=i,this.Nm.su().i(this.Fm.bind(this),this,!0),this.Wm=document.createElement("td"),this.Wm.style.padding="0",this.Wm.style.position="relative";const n=document.createElement("div");n.style.width="100%",n.style.height="100%",n.style.position="relative",n.style.overflow="hidden",this.Hm=document.createElement("td"),this.Hm.style.padding="0",this.Um=document.createElement("td"),this.Um.style.padding="0",this.Wm.appendChild(n),this.nm=Rn(n,hn({width:16,height:16})),this.nm.subscribeSuggestedBitmapSizeChanged(this.Zv);const s=this.nm.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.sm=Rn(n,hn({width:16,height:16})),this.sm.subscribeSuggestedBitmapSizeChanged(this.Xv);const e=this.sm.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.Xp=document.createElement("tr"),this.Xp.appendChild(this.Hm),this.Xp.appendChild(this.Wm),this.Xp.appendChild(this.Um),this.$m(),this.$p=new wn(this.sm.canvasElement,this,{dp:()=>null===this.Am&&!this.zv.N().handleScroll.vertTouchDrag,fp:()=>null===this.Am&&!this.zv.N().handleScroll.horzTouchDrag})}m(){null!==this.Pm&&this.Pm.m(),null!==this.km&&this.km.m(),this.Tm=null,this.sm.unsubscribeSuggestedBitmapSizeChanged(this.Xv),Dn(this.sm.canvasElement),this.sm.dispose(),this.nm.unsubscribeSuggestedBitmapSizeChanged(this.Zv),Dn(this.nm.canvasElement),this.nm.dispose(),null!==this.Nm&&(this.Nm.su().u(this),this.Nm.m()),this.$p.m()}cv(){return a(this.Nm)}jm(t){null!==this.Nm&&this.Nm.su().u(this),this.Nm=t,null!==this.Nm&&this.Nm.su().i(Wn.prototype.Fm.bind(this),this,!0),this.$m(),this.zv.Zp().indexOf(this)===this.zv.Zp().length-1?(this.Tm=this.Tm??new Tn(this.Wm,this.zv),this.Tm.Pt()):(this.Tm?.Ov(),this.Tm=null)}Gv(){return this.zv}iv(){return this.Xp}$m(){if(null!==this.Nm&&(this.qm(),0!==this.sn().Jn().length)){if(null!==this.Pm){const t=this.Nm.U_();this.Pm.un(a(t))}if(null!==this.km){const t=this.Nm.j_();this.km.un(a(t))}}}Ym(){null!==this.Pm&&this.Pm.Pt(),null!==this.km&&this.km.Pt()}B_(){return null!==this.Nm?this.Nm.B_():0}A_(t){this.Nm&&this.Nm.A_(t)}lp(t){if(!this.Nm)return;this.Km();const i=t.localX,n=t.localY;this.Zm(i,n,t)}kp(t){this.Km(),this.Gm(),this.Zm(t.localX,t.localY,t)}op(t){if(!this.Nm)return;this.Km();const i=t.localX,n=t.localY;this.Zm(i,n,t)}xp(t){null!==this.Nm&&(this.Km(),this.Xm(t))}ip(t){null!==this.Nm&&this.Jm(this.Em,t)}Xf(t){this.ip(t)}mp(t){this.Km(),this.Qm(t),this.Zm(t.localX,t.localY,t)}bp(t){null!==this.Nm&&(this.Km(),this.Bm=!1,this.tw(t))}Mp(t){null!==this.Nm&&this.Xm(t)}Op(t){if(this.Bm=!0,null===this.Am){const i={x:t.localX,y:t.localY};this.iw(i,i,t)}}Lp(t){null!==this.Nm&&(this.Km(),this.Nm.Qt().vd(null),this.nw())}sw(){return this.Im}ew(){return this.Em}Ip(){this.Vm=1,this.sn().cs()}Ep(t,i){if(!this.zv.N().handleScale.pinch)return;const n=5*(i-this.Vm);this.Vm=i,this.sn().Td(t._t,n)}yp(t){this.Bm=!1,this.zm=null!==this.Am,this.Gm();const i=this.sn().gd();null!==this.Am&&i.It()&&(this.Lm={x:i.ni(),y:i.si()},this.Am={x:t.localX,y:t.localY})}pp(t){if(null===this.Nm)return;const i=t.localX,n=t.localY;if(null===this.Am)this.Qm(t);else{this.zm=!1;const s=a(this.Lm),e=s.x+(i-this.Am.x),r=s.y+(n-this.Am.y);this.Zm(e,r,t)}}gp(t){0===this.Gv().N().trackingMode.exitMode&&(this.zm=!0),this.rw(),this.tw(t)}Qs(t,i){const n=this.Nm;return null===n?null:Pi(n,t,i)}hw(t,i){a("left"===i?this.Pm:this.km).dm(hn({width:t,height:this.Uv.height}))}nv(){return this.Uv}dm(t){an(this.Uv,t)||(this.Uv=t,this.Kv=!0,this.nm.resizeCanvasElement(t),this.sm.resizeCanvasElement(t),this.Kv=!1,this.Wm.style.width=t.width+"px",this.Wm.style.height=t.height+"px")}aw(){const t=a(this.Nm);t.H_(t.U_()),t.H_(t.j_());for(const i of t.xl())if(t.Zs(i)){const n=i.Ft();null!==n&&t.H_(n),i.Nn()}for(const i of t.ru())i.Nn()}sv(){return this.nm.bitmapSize}ev(t,i,n,s){const e=this.sv();if(e.width>0&&e.height>0&&(t.drawImage(this.nm.canvasElement,i,n),s)){const s=this.sm.canvasElement;null!==t&&t.drawImage(s,i,n)}}pm(t){if(0===t)return;if(null===this.Nm)return;t>1&&this.aw(),null!==this.Pm&&this.Pm.pm(t),null!==this.km&&this.km.pm(t);const i={colorSpace:this.zv.N().layout.colorSpace};if(1!==t){this.nm.applySuggestedBitmapSize();const t=cn(this.nm,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.wm(t)})),this.Nm&&(this.lw(t,Ln),this.ow(t),this.lw(t,On),this.lw(t,Nn)))}this.sm.applySuggestedBitmapSize();const n=cn(this.sm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this._w(n),this.lw(n,Fn),this.lw(n,Nn))}uw(){return this.Pm}cw(){return this.km}Mm(t,i){this.lw(t,i)}Fm(){null!==this.Nm&&this.Nm.su().u(this),this.Nm=null}Xm(t){this.Jm(this.Im,t)}Jm(t,i){const n=i.localX,s=i.localY;t.v()&&t.p(this.sn().Bt().wc(n),{x:n,y:s},i)}wm({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.sn(),r=e.$(),h=e.Kd();r===h?V(t,0,0,n,s,h):z(t,0,0,n,s,r,h)}ow(t){const i=a(this.Nm),n=i.eu().pr().Tt(i);null!==n&&n.st(t,!1)}_w(t){this.dw(t,On,En,this.sn().gd())}lw(t,i){const n=a(this.Nm),s=n.Dt(),e=n.ru();for(const n of e)this.dw(t,i,In,n);for(const n of s)this.dw(t,i,In,n);for(const n of e)this.dw(t,i,En,n);for(const n of s)this.dw(t,i,En,n)}dw(t,i,n,s){const e=a(this.Nm),r=e.Qt().pd(),h=null!==r&&r.hu===s,l=null!==r&&h&&void 0!==r.au?r.au.ie:void 0;Vn(i,(i=>n(i,t,h,l)),s,e)}qm(){if(null===this.Nm)return;const t=this.zv,i=this.Nm.U_().N().visible,n=this.Nm.j_().N().visible;i||null===this.Pm||(this.Hm.removeChild(this.Pm.iv()),this.Pm.m(),this.Pm=null),n||null===this.km||(this.Um.removeChild(this.km.iv()),this.km.m(),this.km=null);const s=t.Qt().Nd();i&&null===this.Pm&&(this.Pm=new zn(this,t.N(),s,"left"),this.Hm.appendChild(this.Pm.iv())),n&&null===this.km&&(this.km=new zn(this,t.N(),s,"right"),this.Um.appendChild(this.km.iv()))}fw(t){return t.Np&&this.Bm||null!==this.Am}Zm(t,i,n){t=Math.max(0,Math.min(t,this.Uv.width-1)),i=Math.max(0,Math.min(i,this.Uv.height-1)),this.sn().Ad(t,i,n,a(this.Nm))}nw(){this.sn().Ld()}rw(){this.zm&&(this.Am=null,this.nw())}iw(t,i,n){this.Am=t,this.zm=!1,this.Zm(i.x,i.y,n);const s=this.sn().gd();this.Lm={x:s.ni(),y:s.si()}}sn(){return this.zv.Qt()}tw(t){if(!this.Dm)return;const i=this.sn(),n=this.cv();if(i.X_(n,n.kn()),this.Rm=null,this.Dm=!1,i.Ed(),null!==this.Om){const t=performance.now(),n=i.Bt();this.Om.fe(n.Cc(),t),this.Om.Bc(t)||i.ps(this.Om)}}Km(){this.Am=null}Gm(){if(!this.Nm)return;if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)a(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Nm.kn().Gi()&&this.sn().Bt().Gi()}Qm(t){if(null===this.Nm)return;const i=this.sn(),n=i.Bt();if(n.Gi())return;const s=this.zv.N(),e=s.handleScroll,r=s.kineticScroll;if((!e.pressedMouseMove||t.Np)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.Np))return;const h=this.Nm.kn(),a=performance.now();if(null!==this.Rm||this.fw(t)||(this.Rm={x:t.clientX,y:t.clientY,cf:a,pw:t.localX,mw:t.localY}),null!==this.Rm&&!this.Dm&&(this.Rm.x!==t.clientX||this.Rm.y!==t.clientY)){if(t.Np&&r.touch||!t.Np&&r.mouse){const t=n.ul();this.Om=new kn(.2/t,7/t,.997,15/t),this.Om.Dv(n.Cc(),this.Rm.cf)}else this.Om=null;h.Gi()||i.Z_(this.Nm,h,t.localY),i.Dd(t.localX),this.Dm=!0}this.Dm&&(h.Gi()||i.G_(this.Nm,h,t.localY),i.Id(t.localX),null!==this.Om&&this.Om.Dv(n.Cc(),a))}}class Hn{constructor(t,i,n,s,e){this.St=!0,this.Uv=hn({width:0,height:0}),this.Zv=()=>this.pm(3),this.Jv="left"===t,this.hd=n.Nd,this.yn=i,this.ww=s,this.gw=e,this.Jp=document.createElement("div"),this.Jp.style.width="25px",this.Jp.style.height="100%",this.Jp.style.overflow="hidden",this.nm=Rn(this.Jp,hn({width:16,height:16})),this.nm.subscribeSuggestedBitmapSizeChanged(this.Zv)}m(){this.nm.unsubscribeSuggestedBitmapSizeChanged(this.Zv),Dn(this.nm.canvasElement),this.nm.dispose()}iv(){return this.Jp}nv(){return this.Uv}dm(t){an(this.Uv,t)||(this.Uv=t,this.nm.resizeCanvasElement(t),this.Jp.style.width=`${t.width}px`,this.Jp.style.height=`${t.height}px`,this.St=!0)}pm(t){if(t<3&&!this.St)return;if(0===this.Uv.width||0===this.Uv.height)return;this.St=!1,this.nm.applySuggestedBitmapSize();const i=cn(this.nm,{colorSpace:this.yn.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.wm(t),this.gm(t)}))}sv(){return this.nm.bitmapSize}ev(t,i,n){const s=this.sv();s.width>0&&s.height>0&&t.drawImage(this.nm.canvasElement,i,n)}gm({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:s}){if(!this.ww())return;t.fillStyle=this.yn.timeScale.borderColor;const e=Math.floor(this.hd.N().S*n),r=Math.floor(this.hd.N().S*s),h=this.Jv?i.width-e:0;t.fillRect(h,0,e,r)}wm({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.gw())}}function Un(t){return i=>i.Ka?.(t)??[]}const $n=Un("normal"),jn=Un("top"),qn=Un("bottom");class Yn{constructor(t,i){this.Mw=null,this.bw=null,this.M=null,this.xw=!1,this.Uv=hn({width:0,height:0}),this.Sw=new o,this.jv=new it(5),this.Kv=!1,this.Zv=()=>{this.Kv||this.zv.Qt().dr()},this.Xv=()=>{this.Kv||this.zv.Qt().dr()},this.zv=t,this.cu=i,this.yn=t.N().layout,this.Ev=document.createElement("tr"),this.Cw=document.createElement("td"),this.Cw.style.padding="0",this.yw=document.createElement("td"),this.yw.style.padding="0",this.Jp=document.createElement("td"),this.Jp.style.height="25px",this.Jp.style.padding="0",this.Pw=document.createElement("div"),this.Pw.style.width="100%",this.Pw.style.height="100%",this.Pw.style.position="relative",this.Pw.style.overflow="hidden",this.Jp.appendChild(this.Pw),this.nm=Rn(this.Pw,hn({width:16,height:16})),this.nm.subscribeSuggestedBitmapSizeChanged(this.Zv);const n=this.nm.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.sm=Rn(this.Pw,hn({width:16,height:16})),this.sm.subscribeSuggestedBitmapSizeChanged(this.Xv);const s=this.sm.canvasElement;s.style.position="absolute",s.style.zIndex="2",s.style.left="0",s.style.top="0",this.Ev.appendChild(this.Cw),this.Ev.appendChild(this.Jp),this.Ev.appendChild(this.yw),this.kw(),this.zv.Qt().V_().i(this.kw.bind(this),this),this.$p=new wn(this.sm.canvasElement,this,{dp:()=>!0,fp:()=>!this.zv.N().handleScroll.horzTouchDrag})}m(){this.$p.m(),null!==this.Mw&&this.Mw.m(),null!==this.bw&&this.bw.m(),this.sm.unsubscribeSuggestedBitmapSizeChanged(this.Xv),Dn(this.sm.canvasElement),this.sm.dispose(),this.nm.unsubscribeSuggestedBitmapSizeChanged(this.Zv),Dn(this.nm.canvasElement),this.nm.dispose()}iv(){return this.Ev}Tw(){return this.Mw}Rw(){return this.bw}kp(t){if(this.xw)return;this.xw=!0;const i=this.zv.Qt();!i.Bt().Gi()&&this.zv.N().handleScale.axisPressedMouseMove.time&&i.kd(t.localX)}yp(t){this.kp(t)}Tp(){const t=this.zv.Qt();!t.Bt().Gi()&&this.xw&&(this.xw=!1,this.zv.N().handleScale.axisPressedMouseMove.time&&t.Bd())}mp(t){const i=this.zv.Qt();!i.Bt().Gi()&&this.zv.N().handleScale.axisPressedMouseMove.time&&i.Vd(t.localX)}pp(t){this.mp(t)}bp(){this.xw=!1;const t=this.zv.Qt();t.Bt().Gi()&&!this.zv.N().handleScale.axisPressedMouseMove.time||t.Bd()}gp(){this.bp()}ip(){this.zv.N().handleScale.axisDoubleClickReset.time&&this.zv.Qt().ws()}Xf(){this.ip()}lp(){this.zv.Qt().N().handleScale.axisPressedMouseMove.time&&this.Cm(1)}Lp(){this.Cm(0)}nv(){return this.Uv}Dw(){return this.Sw}Iw(t,i,n){an(this.Uv,t)||(this.Uv=t,this.Kv=!0,this.nm.resizeCanvasElement(t),this.sm.resizeCanvasElement(t),this.Kv=!1,this.Jp.style.width=`${t.width}px`,this.Jp.style.height=`${t.height}px`,this.Sw.p(t)),null!==this.Mw&&this.Mw.dm(hn({width:i,height:t.height})),null!==this.bw&&this.bw.dm(hn({width:n,height:t.height}))}Ew(){const t=this.Vw();return Math.ceil(t.S+t.C+t.P+t.A+t.I+t.Bw)}Pt(){this.zv.Qt().Bt().El()}sv(){return this.nm.bitmapSize}ev(t,i,n,s){const e=this.sv();if(e.width>0&&e.height>0&&(t.drawImage(this.nm.canvasElement,i,n),s)){const s=this.sm.canvasElement;t.drawImage(s,i,n)}}pm(t){if(0===t)return;const i={colorSpace:this.yn.colorSpace};if(1!==t){this.nm.applySuggestedBitmapSize();const n=cn(this.nm,i);null!==n&&(n.useBitmapCoordinateSpace((t=>{this.wm(t),this.gm(t),this.Aw(n,qn)})),this.bm(n),this.Aw(n,$n)),null!==this.Mw&&this.Mw.pm(t),null!==this.bw&&this.bw.pm(t)}this.sm.applySuggestedBitmapSize();const n=cn(this.sm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.zw([...this.zv.Qt().Jn(),this.zv.Qt().gd()],n),this.Aw(n,jn))}Aw(t,i){const n=this.zv.Qt().Jn();for(const s of n)Vn(i,(i=>In(i,t,!1,void 0)),s,void 0);for(const s of n)Vn(i,(i=>En(i,t,!1,void 0)),s,void 0)}wm({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.zv.Qt().Kd())}gm({context:t,bitmapSize:i,verticalPixelRatio:n}){if(this.zv.N().timeScale.borderVisible){t.fillStyle=this.Lw();const s=Math.max(1,Math.floor(this.Vw().S*n));t.fillRect(0,0,i.width,s)}}bm(t){const i=this.zv.Qt().Bt(),n=i.El();if(!n||0===n.length)return;const s=this.cu.maxTickMarkWeight(n),e=this.Vw(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:s})=>{t.strokeStyle=this.Lw(),t.fillStyle=this.Lw();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const a=Math.round(e.C*s);for(let s=n.length;s--;){const e=Math.round(n[s].coord*i);t.rect(e-h,0,r,a)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.S+e.C+e.A+e.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this._m();for(const e of n)if(e.weight<s){const n=e.needAlignCoordinate?this.Ow(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}this.zv.N().timeScale.allowBoldLabels&&(t.font=this.Nw());for(const e of n)if(e.weight>=s){const n=e.needAlignCoordinate?this.Ow(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}}))}Ow(t,i,n){const s=this.jv.Ii(t,n),e=s/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+s>this.Uv.width&&(i-=Math.abs(this.Uv.width-(r+s))),i}zw(t,i){const n=this.Vw();for(const s of t)for(const t of s.dn())t.Tt().st(i,n)}Lw(){return this.zv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}_m(){return g(this.F(),this.yn.fontFamily)}Nw(){return g(this.F(),this.yn.fontFamily,"bold")}Vw(){null===this.M&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:"",Qi:new it,Bw:0});const t=this.M,i=this._m();if(t.k!==i){const n=this.F();t.P=n,t.k=i,t.A=3*n/12,t.I=3*n/12,t.tn=9*n/12,t.L=0,t.Bw=4*n/12,t.Qi.Os()}return this.M}Cm(t){this.Jp.style.cursor=1===t?"ew-resize":"default"}kw(){const t=this.zv.Qt(),i=t.N();i.leftPriceScale.visible||null===this.Mw||(this.Cw.removeChild(this.Mw.iv()),this.Mw.m(),this.Mw=null),i.rightPriceScale.visible||null===this.bw||(this.yw.removeChild(this.bw.iv()),this.bw.m(),this.bw=null);const n={Nd:this.zv.Qt().Nd()},s=()=>i.leftPriceScale.borderVisible&&t.Bt().N().borderVisible,e=()=>t.Kd();i.leftPriceScale.visible&&null===this.Mw&&(this.Mw=new Hn("left",i,n,s,e),this.Cw.appendChild(this.Mw.iv())),i.rightPriceScale.visible&&null===this.bw&&(this.bw=new Hn("right",i,n,s,e),this.yw.appendChild(this.bw.iv()))}}const Kn=!!dn&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!dn&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Zn{constructor(t,i,n){var s;this.Fw=[],this.Ww=[],this.Hw=0,this.eo=0,this.x_=0,this.Uw=0,this.$w=0,this.jw=null,this.qw=!1,this.Im=new o,this.Em=new o,this.sd=new o,this.Yw=null,this.Kw=null,this.Av=t,this.yn=i,this.cu=n,this.Ev=document.createElement("div"),this.Ev.classList.add("tv-lightweight-charts"),this.Ev.style.overflow="hidden",this.Ev.style.direction="ltr",this.Ev.style.width="100%",this.Ev.style.height="100%",(s=this.Ev).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.Zw=document.createElement("table"),this.Zw.setAttribute("cellspacing","0"),this.Ev.appendChild(this.Zw),this.Gw=this.Xw.bind(this),Gn(this.yn)&&this.Jw(!0),this.sn=new Ni(this.rd.bind(this),this.yn,n),this.Qt().Md().i(this.Qw.bind(this),this),this.tg=new Yn(this,this.cu),this.Zw.appendChild(this.tg.iv());const e=i.autoSize&&this.ig();let r=this.yn.width,h=this.yn.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.ng(r,h),this.sg(),t.appendChild(this.Ev),this.eg(),this.sn.Bt().Oc().i(this.sn.Ca.bind(this.sn),this),this.sn.V_().i(this.sn.Ca.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}Zp(){return this.Fw}rg(){return this.tg}m(){this.Jw(!1),0!==this.Hw&&window.cancelAnimationFrame(this.Hw),this.sn.Md().u(this),this.sn.Bt().Oc().u(this),this.sn.V_().u(this),this.sn.m();for(const t of this.Fw)this.Zw.removeChild(t.iv()),t.sw().u(this),t.ew().u(this),t.m();this.Fw=[];for(const t of this.Ww)this.hg(t);this.Ww=[],a(this.tg).m(),null!==this.Ev.parentElement&&this.Ev.parentElement.removeChild(this.Ev),this.sd.m(),this.Im.m(),this.Em.m(),this.ag()}ng(t,i,n=!1){if(this.eo===i&&this.x_===t)return;const s=function(t){const i=Math.floor(t.width),n=Math.floor(t.height);return hn({width:i-i%2,height:n-n%2})}(hn({width:t,height:i}));this.eo=s.height,this.x_=s.width;const e=this.eo+"px",r=this.x_+"px";a(this.Ev).style.height=e,a(this.Ev).style.width=r,this.Zw.style.height=e,this.Zw.style.width=r,n?this.lg(Y.ys(),performance.now()):this.sn.Ca()}pm(t){void 0===t&&(t=Y.ys());for(let i=0;i<this.Fw.length;i++)this.Fw[i].pm(t._s(i).rs);this.yn.timeScale.visible&&this.tg.pm(t.ls())}cr(t){const i=Gn(this.yn);this.sn.cr(t);const n=Gn(this.yn);n!==i&&this.Jw(n),t.layout?.panes&&this.og(),this.eg(),this._g(t)}sw(){return this.Im}ew(){return this.Em}Md(){return this.sd}ug(t=!1){null!==this.jw&&(this.lg(this.jw,performance.now()),this.jw=null);const i=this.cg(null),n=document.createElement("canvas");n.width=i.width,n.height=i.height;const s=a(n.getContext("2d"));return this.cg(s,t),n}dg(t){if("left"===t&&!this.fg())return 0;if("right"===t&&!this.pg())return 0;if(0===this.Fw.length)return 0;return a("left"===t?this.Fw[0].uw():this.Fw[0].cw()).fm()}vg(){return this.yn.autoSize&&null!==this.Yw}hv(){return this.Ev}mg(t){this.Kw=t,this.Kw?this.hv().style.setProperty("cursor",t):this.hv().style.removeProperty("cursor")}wg(){return this.Kw}gg(t){return h(this.Fw[t]).nv()}og(){this.Ww.forEach((t=>{t.Pt()}))}_g(t){(void 0!==t.autoSize||!this.Yw||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.Yw&&this.ig(),!1===t.autoSize&&null!==this.Yw&&this.ag(),t.autoSize||void 0===t.width&&void 0===t.height||this.ng(t.width||this.x_,t.height||this.eo))}cg(t,i){let n=0,s=0;const e=this.Fw[0],r=(n,s)=>{let e=0;for(let r=0;r<this.Fw.length;r++){const h=this.Fw[r],l=a("left"===n?h.uw():h.cw()),o=l.sv();if(null!==t&&l.ev(t,s,e,i),e+=o.height,r<this.Fw.length-1){const i=this.Ww[r],n=i.sv();null!==t&&i.ev(t,s,e),e+=n.height}}};if(this.fg()){r("left",0);n+=a(e.uw()).sv().width}for(let e=0;e<this.Fw.length;e++){const r=this.Fw[e],h=r.sv();if(null!==t&&r.ev(t,n,s,i),s+=h.height,e<this.Fw.length-1){const i=this.Ww[e],r=i.sv();null!==t&&i.ev(t,n,s),s+=r.height}}if(n+=e.sv().width,this.pg()){r("right",n);n+=a(e.cw()).sv().width}const h=(i,n,s)=>{a("left"===i?this.tg.Tw():this.tg.Rw()).ev(a(t),n,s)};if(this.yn.timeScale.visible){const n=this.tg.sv();if(null!==t){let r=0;this.fg()&&(h("left",r,s),r=a(e.uw()).sv().width),this.tg.ev(t,r,s,i),r+=n.width,this.pg()&&h("right",r,s)}s+=n.height}return hn({width:n,height:s})}Mg(){let t=0,i=0,n=0;for(const s of this.Fw)this.fg()&&(i=Math.max(i,a(s.uw()).om(),this.yn.leftPriceScale.minimumWidth)),this.pg()&&(n=Math.max(n,a(s.cw()).om(),this.yn.rightPriceScale.minimumWidth)),t+=s.B_();i=vn(i),n=vn(n);const s=this.x_,e=this.eo,r=Math.max(s-i-n,0),h=1*this.Ww.length,l=this.yn.timeScale.visible;let o=l?Math.max(this.tg.Ew(),this.yn.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e<u?0:e-u,d=c/t;let f=0;const p=window.devicePixelRatio||1;for(let t=0;t<this.Fw.length;++t){const s=this.Fw[t];s.jm(this.sn.Zn()[t]);let e=0,h=0;h=t===this.Fw.length-1?Math.ceil((c-f)*p)/p:Math.round(s.B_()*d*p)/p,e=Math.max(h,2),f+=e,s.dm(hn({width:r,height:e})),this.fg()&&s.hw(i,"left"),this.pg()&&s.hw(n,"right"),s.cv()&&this.sn.bd(s.cv(),e)}this.tg.Iw(hn({width:l?r:0,height:o}),l?i:0,l?n:0),this.sn.z_(r),this.Uw!==i&&(this.Uw=i),this.$w!==n&&(this.$w=n)}Jw(t){t?this.Ev.addEventListener("wheel",this.Gw,{passive:!1}):this.Ev.removeEventListener("wheel",this.Gw)}bg(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Kn?1/window.devicePixelRatio:1}Xw(t){if(!(0!==t.deltaX&&this.yn.handleScroll.mouseWheel||0!==t.deltaY&&this.yn.handleScale.mouseWheel))return;const i=this.bg(t),n=i*t.deltaX/100,s=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==s&&this.yn.handleScale.mouseWheel){const i=Math.sign(s)*Math.min(1,Math.abs(s)),n=t.clientX-this.Ev.getBoundingClientRect().left;this.Qt().Td(n,i)}0!==n&&this.yn.handleScroll.mouseWheel&&this.Qt().Rd(-80*n)}lg(t,i){const n=t.ls();3===n&&this.xg(),3!==n&&2!==n||(this.Sg(t),this.Cg(t,i),this.tg.Pt(),this.Fw.forEach((t=>{t.Ym()})),3===this.jw?.ls()&&(this.jw.xs(t),this.xg(),this.Sg(this.jw),this.Cg(this.jw,i),t=this.jw,this.jw=null)),this.pm(t)}Cg(t,i){for(const n of t.bs())this.Ss(n,i)}Sg(t){const i=this.sn.Zn();for(let n=0;n<i.length;n++)t._s(n).hs&&i[n].tu()}Ss(t,i){const n=this.sn.Bt();switch(t.ds){case 0:n.Fc();break;case 1:n.Wc(t.Wt);break;case 2:n.gs(t.Wt);break;case 3:n.Ms(t.Wt);break;case 4:n.kc();break;case 5:t.Wt.Bc(i)||n.Ms(t.Wt.Ac(i))}}rd(t){null!==this.jw?this.jw.xs(t):this.jw=t,this.qw||(this.qw=!0,this.Hw=window.requestAnimationFrame((t=>{if(this.qw=!1,this.Hw=0,null!==this.jw){const i=this.jw;this.jw=null,this.lg(i,t);for(const n of i.bs())if(5===n.ds&&!n.Wt.Bc(t)){this.Qt().ps(n.Wt);break}}})))}xg(){this.sg()}hg(t){this.Zw.removeChild(t.iv()),t.m()}sg(){const t=this.sn.Zn(),i=t.length,n=this.Fw.length;for(let t=i;t<n;t++){const t=h(this.Fw.pop());this.Zw.removeChild(t.iv()),t.sw().u(this),t.ew().u(this),t.m();const i=this.Ww.pop();void 0!==i&&this.hg(i)}for(let s=n;s<i;s++){const i=new Wn(this,t[s]);if(i.sw().i(this.yg.bind(this,i),this),i.ew().i(this.Pg.bind(this,i),this),this.Fw.push(i),s>0){const t=new Cn(this,s-1,s);this.Ww.push(t),this.Zw.insertBefore(t.iv(),this.tg.iv())}this.Zw.insertBefore(i.iv(),this.tg.iv())}for(let n=0;n<i;n++){const i=t[n],s=this.Fw[n];s.cv()!==i?s.jm(i):s.$m()}this.eg(),this.Mg()}kg(t,i,n,s){const e=new Map;if(null!==t){this.sn.Jn().forEach((i=>{const n=i.Un().Hn(t);null!==n&&e.set(i,n)}))}let r;if(null!==t){const i=this.sn.Bt().en(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().pd(),a=null!==h&&h.hu instanceof Kt?h.hu:void 0,l=null!==h&&void 0!==h.au?h.au.te:void 0,o=this.Tg(s);return{Gr:r,$n:t??void 0,Rg:i??void 0,Dg:-1!==o?o:void 0,Ig:a,Eg:e,Vg:l,Bg:n??void 0}}Tg(t){let i=-1;if(t)i=this.Fw.indexOf(t);else{const t=this.Qt().gd().Kn();null!==t&&(i=this.Qt().Zn().indexOf(t))}return i}yg(t,i,n,s){this.Im.p((()=>this.kg(i,n,s,t)))}Pg(t,i,n,s){this.Em.p((()=>this.kg(i,n,s,t)))}Qw(t,i,n){this.mg(this.Qt().pd()?.ou??null),this.sd.p((()=>this.kg(t,i,n)))}eg(){const t=this.yn.timeScale.visible?"":"none";this.tg.iv().style.display=t}fg(){return this.Fw[0].cv().U_().N().visible}pg(){return this.Fw[0].cv().j_().N().visible}ig(){return"ResizeObserver"in window&&(this.Yw=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.ng(i.contentRect.width,i.contentRect.height)})),this.Yw.observe(this.Av,{box:"border-box"}),!0)}ag(){null!==this.Yw&&this.Yw.disconnect(),this.Yw=null}}function Gn(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Xn(t){return void 0===t.open&&void 0===t.value}function Jn(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function Qn(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Gr:s};return void 0!==n.color&&(r.R=n.color),r}function ts(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Gr:s};return void 0!==n.lineColor&&(r.vt=n.lineColor),void 0!==n.topColor&&(r.eh=n.topColor),void 0!==n.bottomColor&&(r.rh=n.bottomColor),r}function is(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Gr:s};return void 0!==n.topLineColor&&(r.hh=n.topLineColor),void 0!==n.bottomLineColor&&(r.ah=n.bottomLineColor),void 0!==n.topFillColor1&&(r.oh=n.topFillColor1),void 0!==n.topFillColor2&&(r._h=n.topFillColor2),void 0!==n.bottomFillColor1&&(r.uh=n.bottomFillColor1),void 0!==n.bottomFillColor2&&(r.dh=n.bottomFillColor2),r}function ns(t,i,n,s){const e={$n:i,wt:t,Wt:[n.open,n.high,n.low,n.close],Gr:s};return void 0!==n.color&&(e.R=n.color),e}function ss(t,i,n,s){const e={$n:i,wt:t,Wt:[n.open,n.high,n.low,n.close],Gr:s};return void 0!==n.color&&(e.R=n.color),void 0!==n.borderColor&&(e.Ht=n.borderColor),void 0!==n.wickColor&&(e.sh=n.wickColor),e}function es(t,i,n,s,e){const r=h(e)(n),a=Math.max(...r),l=Math.min(...r),o=r[r.length-1],_=[o,a,l,o],{time:u,color:c,...d}=n;return{$n:i,wt:t,Wt:_,Gr:s,le:d,R:c}}function rs(t){return void 0!==t.Wt}function hs(t,i){return void 0!==i.customValues&&(t.Ag=i.customValues),t}function as(t){return(i,n,s,e,r,h)=>function(t,i){return i?i(t):Xn(t)}(s,h)?hs({wt:i,$n:n,Gr:e},s):hs(t(i,n,s,e,r),s)}function ls(t){return{Candlestick:as(ss),Bar:as(ns),Area:as(ts),Baseline:as(is),Histogram:as(Qn),Line:as(Qn),Custom:as(es)}[t]}function os(t){return{$n:0,zg:new Map,Ba:t}}function _s(t,i){if(void 0!==t&&0!==t.length)return{Lg:i.key(t[0].wt),Og:i.key(t[t.length-1].wt)}}function us(t){let i;return t.forEach((t=>{void 0===i&&(i=t.Gr)})),h(i)}class cs{constructor(t){this.Ng=new Map,this.Fg=new Map,this.Wg=new Map,this.Hg=[],this.cu=t}m(){this.Ng.clear(),this.Fg.clear(),this.Wg.clear(),this.Hg=[]}Ug(t,i){let n=0!==this.Ng.size,s=!1;const e=this.Fg.get(t);if(void 0!==e)if(1===this.Fg.size)n=!1,s=!0,this.Ng.clear();else for(const i of this.Hg)i.pointData.zg.delete(t)&&(s=!0);let r=[];if(0!==i.length){const n=i.map((t=>t.time)),e=this.cu.createConverterToInternalObj(i),h=ls(t.wh()),a=t.rl(),l=t.hl();r=i.map(((i,r)=>{const o=e(i.time),_=this.cu.key(o);let u=this.Ng.get(_);void 0===u&&(u=os(o),this.Ng.set(_,u),s=!0);const c=h(o,u.$n,i,n[r],a,l);return u.zg.set(t,c),c}))}n&&this.$g(),this.jg(t,r);let h=-1;if(s){const t=[];this.Ng.forEach((i=>{t.push({timeWeight:0,time:i.Ba,pointData:i,originalTime:us(i.zg)})})),t.sort(((t,i)=>this.cu.key(t.time)-this.cu.key(i.time))),h=this.qg(t)}return this.Yg(t,h,function(t,i,n){const s=_s(t,n),e=_s(i,n);if(void 0!==s&&void 0!==e)return{Kg:!1,Ta:s.Og>=e.Og&&s.Lg>=e.Lg}}(this.Fg.get(t),e,this.cu))}Hd(t){return this.Ug(t,[])}Zg(t,i,n){if(n&&t.za())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const s=i;!function(t){void 0===t.Gr&&(t.Gr=t.time)}(s),this.cu.preprocessData(i);const e=this.cu.createConverterToInternalObj([i])(i.time),r=this.Wg.get(t);if(!n&&void 0!==r&&this.cu.key(e)<this.cu.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${e}`);let h=this.Ng.get(this.cu.key(e));if(n&&void 0===h)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const a=void 0===h;void 0===h&&(h=os(e),this.Ng.set(this.cu.key(e),h));const l=ls(t.wh()),o=t.rl(),_=t.hl(),u=l(e,h.$n,i,s.Gr,o,_),c=!n&&!a&&void 0!==r&&this.cu.key(e)===this.cu.key(r);h.zg.set(t,u),n?this.Gg(t,u,h.$n):c&&t.za()&&rs(u)?(t.Pr(u),this.Xg(t,u)):this.Xg(t,u);const d={Ta:rs(u),Kg:n};if(!a)return this.Yg(t,-1,d);const f={timeWeight:0,time:h.Ba,pointData:h,originalTime:us(h.zg)},p=yt(this.Hg,this.cu.key(f.time),((t,i)=>this.cu.key(t.time)<i));this.Hg.splice(p,0,f);for(let t=p;t<this.Hg.length;++t)ds(this.Hg[t].pointData,t);return this.cu.fillWeightsForPoints(this.Hg,p),this.Yg(t,p,d)}Jg(t,i){const n=this.Fg.get(t);if(void 0===n||i<=0)return[[],this.Qg()];i=Math.min(i,n.length);const s=n.splice(-i).reverse();0===n.length?this.Wg.delete(t):this.Wg.set(t,n[n.length-1].wt);for(const i of s){const n=this.Ng.get(this.cu.key(i.wt));if(n&&(n.zg.delete(t),0===n.zg.size)){this.Ng.delete(this.cu.key(n.Ba)),this.Hg.splice(n.$n,1);for(let t=n.$n;t<this.Hg.length;++t)ds(this.Hg[t].pointData,t)}}return[s,this.Yg(t,this.Hg.length-1,{Kg:!1,Ta:!1})]}Xg(t,i){let n=this.Fg.get(t);void 0===n&&(n=[],this.Fg.set(t,n));const s=0!==n.length?n[n.length-1]:null;null===s||this.cu.key(i.wt)>this.cu.key(s.wt)?rs(i)&&n.push(i):rs(i)?n[n.length-1]=i:n.splice(-1,1),this.Wg.set(t,i.wt)}Gg(t,i,n){const s=this.Fg.get(t);if(void 0===s)return;const e=yt(s,n,((t,i)=>t.$n<i));rs(i)?s[e]=i:s.splice(e,1)}jg(t,i){0!==i.length?(this.Fg.set(t,i.filter(rs)),this.Wg.set(t,i[i.length-1].wt)):(this.Fg.delete(t),this.Wg.delete(t))}$g(){for(const t of this.Hg)0===t.pointData.zg.size&&this.Ng.delete(this.cu.key(t.time))}qg(t){let i=-1;for(let n=0;n<this.Hg.length&&n<t.length;++n){const s=this.Hg[n],e=t[n];if(this.cu.key(s.time)!==this.cu.key(e.time)){i=n;break}e.timeWeight=s.timeWeight,ds(e.pointData,n)}if(-1===i&&this.Hg.length!==t.length&&(i=Math.min(this.Hg.length,t.length)),-1===i)return-1;for(let n=i;n<t.length;++n)ds(t[n].pointData,n);return this.cu.fillWeightsForPoints(t,i),this.Hg=t,i}tM(){if(0===this.Fg.size)return null;let t=0;return this.Fg.forEach((i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].$n))})),t}Yg(t,i,n){const s=this.Qg();if(-1!==i)this.Fg.forEach(((i,e)=>{s.F_.set(e,{le:i,iM:e===t?n:void 0})})),this.Fg.has(t)||s.F_.set(t,{le:[],iM:n}),s.Bt.nM=this.Hg,s.Bt.sM=i;else{const i=this.Fg.get(t);s.F_.set(t,{le:i||[],iM:n})}return s}Qg(){return{F_:new Map,Bt:{vc:this.tM()}}}}function ds(t,i){t.$n=i,t.zg.forEach((t=>{t.$n=i}))}function fs(t,i){return t.wt<i}function ps(t,i){return i<t.wt}function vs(t,i,n){const s=i.Aa(),e=i.bi(),r=yt(t,s,fs),h=Pt(t,e,ps);if(!n)return{from:r,to:h};let a=r,l=h;return r>0&&r<t.length&&t[r].wt>=s&&(a=r-1),h>0&&h<t.length&&t[h-1].wt<=e&&(l=h+1),{from:a,to:l}}class ms{constructor(t,i,n){this.eM=!0,this.rM=!0,this.hM=!0,this.aM=[],this.lM=null,this.oM=-1,this.ee=t,this.re=i,this._M=n}Pt(t){this.eM=!0,"data"===t&&(this.rM=!0),"options"===t&&(this.hM=!0)}Tt(){return this.ee.It()?(this.uM(),null===this.lM?null:this.cM):null}dM(){this.aM=this.aM.map((t=>({...t,...this.ee.ga().gh(t.wt)})))}fM(){this.lM=null}uM(){const t=this.re.Bt(),i=t.N().enableConflation?t.Hc():0;i!==this.oM&&(this.rM=!0,this.oM=i),this.rM&&(this.pM(),this.rM=!1),this.hM&&(this.dM(),this.hM=!1),this.eM&&(this.vM(),this.eM=!1)}vM(){const t=this.ee.Ft(),i=this.re.Bt();if(this.fM(),i.Gi()||t.Gi())return;const n=i.Ie();if(null===n)return;if(0===this.ee.Un().yh())return;const s=this.ee.zt();null!==s&&(this.lM=vs(this.aM,n,this._M),this.mM(t,i,s.Wt),this.wM())}}class ws{constructor(t,i){this.gM=t,this.Ki=i}st(t,i,n){this.gM.draw(t,this.Ki,i,n)}}class gs extends ms{constructor(t,i,n){super(t,i,!1),this.$h=n,this.cM=new ws(this.$h.renderer(),(i=>{const n=t.zt();return null===n?null:t.Ft().Nt(i,n.Wt)}))}get ma(){return this.$h.conflationReducer}Oa(t){return this.$h.priceValueBuilder(t)}al(t){return this.$h.isWhitespace(t)}pM(){const t=this.ee.ga();this.aM=this.ee.Na().Dh().map((i=>({wt:i.$n,_t:NaN,...t.gh(i.$n),MM:i.le})))}mM(t,i){i.mc(this.aM,m(this.lM))}wM(){this.$h.update({bars:this.aM.map(Ms),barSpacing:this.re.Bt().ul(),visibleRange:this.lM,conflationFactor:this.re.Bt().Hc()},this.ee.N())}}function Ms(t){return{x:t._t,time:t.wt,originalData:t.MM,barColor:t.th}}const bs={color:"#2196f3"},xs=(t,i,n)=>{const s=l(n);return new gs(t,i,s)};function Ss(t){const i={value:t.Wt[3],time:t.Gr};return void 0!==t.Ag&&(i.customValues=t.Ag),i}function Cs(t){const i=Ss(t);return void 0!==t.R&&(i.color=t.R),i}function ys(t){const i=Ss(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.eh&&(i.topColor=t.eh),void 0!==t.rh&&(i.bottomColor=t.rh),i}function Ps(t){const i=Ss(t);return void 0!==t.hh&&(i.topLineColor=t.hh),void 0!==t.ah&&(i.bottomLineColor=t.ah),void 0!==t.oh&&(i.topFillColor1=t.oh),void 0!==t._h&&(i.topFillColor2=t._h),void 0!==t.uh&&(i.bottomFillColor1=t.uh),void 0!==t.dh&&(i.bottomFillColor2=t.dh),i}function ks(t){const i={open:t.Wt[0],high:t.Wt[1],low:t.Wt[2],close:t.Wt[3],time:t.Gr};return void 0!==t.Ag&&(i.customValues=t.Ag),i}function Ts(t){const i=ks(t);return void 0!==t.R&&(i.color=t.R),i}function Rs(t){const i=ks(t),{R:n,Ht:s,sh:e}=t;return void 0!==n&&(i.color=n),void 0!==s&&(i.borderColor=s),void 0!==e&&(i.wickColor=e),i}function Ds(t){return{Area:ys,Line:Cs,Baseline:Ps,Histogram:Cs,Bar:Ts,Candlestick:Rs,Custom:Is}[t]}function Is(t){const i=t.Gr;return{...t.le,time:i}}const Es={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,doNotSnapToHiddenSeriesIndices:!1},Vs={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Bs={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:w,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},As={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,ensureEdgeTickMarksVisible:!1},zs={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function Ls(){return{addDefaultPane:!0,width:0,height:0,autoSize:!1,layout:Bs,crosshair:Es,grid:Vs,overlayPriceScales:{...As},leftPriceScale:{...As,visible:!1},rightPriceScale:{...As,visible:!0},timeScale:zs,localization:{locale:dn?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 Os{constructor(t,i,n){this.Yp=t,this.bM=i,this.xM=n??0}applyOptions(t){this.Yp.Qt().md(this.bM,t,this.xM)}options(){return this.Ki().N()}width(){return q(this.bM)?this.Yp.dg(this.bM):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().$o(new dt(t.from,t.to))}getVisibleRange(){let t,i,n=this.Ki().er();if(null===n)return null;if(this.Ki().io()){const s=this.Ki().m_(),e=Fi(s);n=ci(n,this.Ki().so()),t=Number((Math.round(n.Ze()/s)*s).toFixed(e)),i=Number((Math.round(n.Ge()/s)*s).toFixed(e))}else t=n.Ze(),i=n.Ge();return{from:t,to:i}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return a(this.Yp.Qt().wd(this.bM,this.xM)).Ft}}class Ns{constructor(t,i,n,s){this.Yp=t,this.yt=n,this.SM=i,this.CM=s}getHeight(){return this.yt.$t()}setHeight(t){const i=this.Yp.Qt(),n=i.Gd(this.yt);i.Sd(n,t)}getStretchFactor(){return this.yt.B_()}setStretchFactor(t){this.yt.A_(t),this.Yp.Qt().Ca()}paneIndex(){return this.Yp.Qt().Gd(this.yt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&t<this.Yp.Zp().length,"Invalid pane index"),this.Yp.Qt().yd(i,t))}getSeries(){return this.yt.F_().map((t=>this.SM(t)))??[]}getHTMLElement(){const t=this.Yp.Zp();return t&&0!==t.length&&t[this.paneIndex()]?t[this.paneIndex()].iv():null}attachPrimitive(t){this.yt.sl(t),t.attached&&t.attached({chart:this.CM,requestUpdate:()=>this.yt.Qt().Ca()})}detachPrimitive(t){this.yt.el(t)}priceScale(t){if(null===this.yt.E_(t))throw new Error(`Cannot find price scale with id: ${t}`);return new Os(this.Yp,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.O_(t)}preserveEmptyPane(){return this.yt.N_()}addCustomSeries(t,i={},n=0){return this.CM.addCustomSeries(t,i,n)}addSeries(t,i={}){return this.CM.addSeries(t,i,this.paneIndex())}}const Fs={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Ws{constructor(t){this.hr=t}applyOptions(t){this.hr.cr(t)}options(){return this.hr.N()}yM(){return this.hr}}class Hs{constructor(t,i,n,s,e,r){this.PM=new o,this.ee=t,this.kM=i,this.TM=n,this.cu=e,this.CM=s,this.RM=r}m(){this.PM.m()}priceFormatter(){return this.ee.Xa()}priceToCoordinate(t){const i=this.ee.zt();return null===i?null:this.ee.Ft().Nt(t,i.Wt)}coordinateToPrice(t){const i=this.ee.zt();return null===i?null:this.ee.Ft().Tn(t,i.Wt)}barsInLogicalRange(t){if(null===t)return null;const i=new Ii(new Ti(t.from,t.to)).Ru(),n=this.ee.Un();if(n.Gi())return null;const s=n.Hn(i.Aa(),1),e=n.Hn(i.bi(),-1),r=a(n.Ph()),h=a(n.Qn());if(null!==s&&null!==e&&s.$n>e.$n)return{barsBefore:t.from-r,barsAfter:h-t.to};const l={barsBefore:null===s||s.$n===r?t.from-r:s.$n-r,barsAfter:null===e||e.$n===h?h-t.to:h-e.$n};return null!==s&&null!==e&&(l.from=s.Gr,l.to=e.Gr),l}setData(t){this.cu,this.ee.wh(),this.kM.DM(this.ee,t),this.IM("full")}update(t,i=!1){this.ee.wh(),this.kM.EM(this.ee,t,i),this.IM("update")}pop(t=1){const i=this.kM.VM(this.ee,t);0!==i.length&&this.IM("update");const n=Ds(this.seriesType());return i.map((t=>n(t)))}dataByIndex(t,i){const n=this.ee.Un().Hn(t,i);if(null===n)return null;return Ds(this.seriesType())(n)}data(){const t=Ds(this.seriesType());return this.ee.Un().Dh().map((i=>t(i)))}subscribeDataChanged(t){this.PM.i(t)}unsubscribeDataChanged(t){this.PM._(t)}applyOptions(t){this.ee.cr(t)}options(){return p(this.ee.N())}priceScale(){return this.TM.priceScale(this.ee.Ft().ol(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(Fs),t),n=this.ee.Da(i);return new Ws(n)}removePriceLine(t){this.ee.Ia(t.yM())}priceLines(){return this.ee.Ea().map((t=>new Ws(t)))}seriesType(){return this.ee.wh()}lastValueData(t){const i=this.ee.Ee(t);return i.Ve?{noData:!0}:{noData:!1,price:i.gt,color:i.R}}attachPrimitive(t){this.ee.sl(t),t.attached&&t.attached({chart:this.CM,series:this,requestUpdate:()=>this.ee.Qt().Ca(),horzScaleBehavior:this.cu})}detachPrimitive(t){this.ee.el(t),t.detached&&t.detached(),this.ee.Qt().Ca()}getPane(){const t=this.ee,i=a(this.ee.Qt().Ks(t));return this.RM(i)}moveToPane(t){this.ee.Qt().qd(this.ee,t)}seriesOrder(){const t=this.ee.Qt().Ks(this.ee);return null===t?-1:t.F_().indexOf(this.ee)}setSeriesOrder(t){const i=this.ee.Qt().Ks(this.ee);null!==i&&i.nu(this.ee,t)}IM(t){this.PM.v()&&this.PM.p(t)}}class Us{constructor(t,i,n){this.BM=new o,this.Nu=new o,this.Sw=new o,this.sn=t,this.Jh=t.Bt(),this.tg=i,this.Jh.zc().i(this.AM.bind(this)),this.Jh.Lc().i(this.zM.bind(this)),this.tg.Dw().i(this.LM.bind(this)),this.cu=n}m(){this.Jh.zc().u(this),this.Jh.Lc().u(this),this.tg.Dw().u(this),this.BM.m(),this.Nu.m(),this.Sw.m()}scrollPosition(){return this.Jh.Cc()}scrollToPosition(t,i){i?this.Jh.Vc(t,1e3):this.sn.Ms(t)}scrollToRealTime(){this.Jh.Ec()}getVisibleRange(){const t=this.Jh.lc();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.cu.convertHorzItemToInternal(t.from),to:this.cu.convertHorzItemToInternal(t.to)},n=this.Jh.cc(i);this.sn.$d(n)}getVisibleLogicalRange(){const t=this.Jh.ac();return null===t?null:{from:t.Aa(),to:t.bi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.sn.$d(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.Fc()}logicalToCoordinate(t){const i=this.sn.Bt();return i.Gi()?null:i.jt(t)}coordinateToLogical(t){return this.Jh.Gi()?null:this.Jh.wc(t)}timeToIndex(t,i){const n=this.cu.convertHorzItemToInternal(t);return this.Jh.ec(n,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.Jh.jt(i)}coordinateToTime(t){const i=this.sn.Bt(),n=i.wc(t),s=i.en(n);return null===s?null:s.originalTime}width(){return this.tg.nv().width}height(){return this.tg.nv().height}subscribeVisibleTimeRangeChange(t){this.BM.i(t)}unsubscribeVisibleTimeRangeChange(t){this.BM._(t)}subscribeVisibleLogicalRangeChange(t){this.Nu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Nu._(t)}subscribeSizeChange(t){this.Sw.i(t)}unsubscribeSizeChange(t){this.Sw._(t)}applyOptions(t){this.Jh.cr(t)}options(){return{...p(this.Jh.N()),barSpacing:this.Jh.ul()}}AM(){this.BM.v()&&this.BM.p(this.getVisibleRange())}zM(){this.Nu.v()&&this.Nu.p(this.getVisibleLogicalRange())}LM(t){this.Sw.p(t.width,t.height)}}function $s(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:n}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class js{constructor(t,i,n){this.OM=new Map,this.NM=new Map,this.FM=new o,this.WM=new o,this.HM=new o,this.Xc=new WeakMap,this.UM=new cs(i);const s=void 0===n?p(Ls()):_(p(Ls()),$s(n));this.$M=i,this.Yp=new Zn(t,s,i),this.Yp.sw().i((t=>{this.FM.v()&&this.FM.p(this.jM(t()))}),this),this.Yp.ew().i((t=>{this.WM.v()&&this.WM.p(this.jM(t()))}),this),this.Yp.Md().i((t=>{this.HM.v()&&this.HM.p(this.jM(t()))}),this);const e=this.Yp.Qt();this.qM=new Us(e,this.Yp.rg(),this.$M)}remove(){this.Yp.sw().u(this),this.Yp.ew().u(this),this.Yp.Md().u(this),this.qM.m(),this.Yp.m(),this.OM.clear(),this.NM.clear(),this.FM.m(),this.WM.m(),this.HM.m(),this.UM.m()}resize(t,i,n){this.autoSizeActive()||this.Yp.ng(t,i,n)}addCustomSeries(t,i={},n=0){const s=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...bs,...t.defaultOptions()},YM:xs,KM:t}))(l(t));return this.ZM(s,i,n)}addSeries(t,i={},n=0){return this.ZM(t,i,n)}removeSeries(t){const i=h(this.OM.get(t)),n=this.UM.Hd(i);this.Yp.Qt().Hd(i),this.GM(n),this.OM.delete(t),this.NM.delete(i)}DM(t,i){this.GM(this.UM.Ug(t,i))}EM(t,i,n){this.GM(this.UM.Zg(t,i,n))}VM(t,i){const[n,s]=this.UM.Jg(t,i);return 0!==n.length&&this.GM(s),n}subscribeClick(t){this.FM.i(t)}unsubscribeClick(t){this.FM._(t)}subscribeCrosshairMove(t){this.HM.i(t)}unsubscribeCrosshairMove(t){this.HM._(t)}subscribeDblClick(t){this.WM.i(t)}unsubscribeDblClick(t){this.WM._(t)}priceScale(t,i=0){return new Os(this.Yp,t,i)}timeScale(){return this.qM}applyOptions(t){this.Yp.cr($s(t))}options(){return this.Yp.N()}takeScreenshot(t=!1,i=!1){let n,s;try{i||(n=this.Yp.Qt().N().crosshair.mode,this.Yp.cr({crosshair:{mode:2}})),s=this.Yp.ug(t)}finally{i||void 0===n||this.Yp.Qt().cr({crosshair:{mode:n}})}return s}addPane(t=!1){const i=this.Yp.Qt().Xd();return i.O_(t),this.XM(i)}removePane(t){this.Yp.Qt().xd(t)}swapPanes(t,i){this.Yp.Qt().Cd(t,i)}autoSizeActive(){return this.Yp.vg()}chartElement(){return this.Yp.hv()}panes(){return this.Yp.Qt().Zn().map((t=>this.XM(t)))}paneSize(t=0){const i=this.Yp.gg(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,n){const s=this.OM.get(n);if(void 0===s)return;const e=this.Yp.Qt().Ks(s);null!==e&&this.Yp.Qt().zd(t,i,e)}clearCrosshairPosition(){this.Yp.Qt().Ld(!0)}horzBehaviour(){return this.$M}ZM(i,n={},s=0){r(void 0!==i.YM),function(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=Fi(i.minMove))}(n.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(n);const e=_(p(t),p(i.defaultOptions),n),h=i.YM,a=new Kt(this.Yp.Qt(),i.type,e,h,i.KM);this.Yp.Qt().Fd(a,s);const l=new Hs(a,this,this,this,this.$M,(t=>this.XM(t)));return this.OM.set(l,a),this.NM.set(a,l),l}GM(t){const i=this.Yp.Qt();i.Od(t.Bt.vc,t.Bt.nM,t.Bt.sM),t.F_.forEach(((t,i)=>i.ht(t.le,t.iM))),i.Bt().Ju(),i.xc()}JM(t){return h(this.NM.get(t))}jM(t){const i=new Map;t.Eg.forEach(((t,n)=>{const s=n.wh(),e=Ds(s)(t);if("Custom"!==s)r(Jn(e));else{const t=n.hl();r(!t||!1===t(e))}i.set(this.JM(n),e)}));const n=void 0!==t.Ig&&this.NM.has(t.Ig)?this.JM(t.Ig):void 0;return{time:t.Gr,logical:t.$n,point:t.Rg,paneIndex:t.Dg,hoveredSeries:n,hoveredObjectId:t.Vg,seriesData:i,sourceEvent:t.Bg}}XM(t){let i=this.Xc.get(t);return i||(i=new Ns(this.Yp,(t=>this.JM(t)),t,this),this.Xc.set(t,i)),i}}function qs(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function Ys(t,i,n){const s=qs(t),e=new js(s,i,n);return i.setOptions(e.options()),e}class Ks extends ms{constructor(t,i){super(t,i,!0)}mM(t,i,n){i.mc(this.aM,m(this.lM)),t.Yo(this.aM,n,m(this.lM))}QM(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}pM(){const t=this.ee.ga();this.aM=this.ee.Na().Dh().map((i=>{let n;if((i.qr??1)>1){const t=i.Wt[1],s=i.Wt[2],e=i.Wt[3];n=Math.abs(t-e)>Math.abs(s-e)?t:s}else n=i.Wt[3];return this.tb(i.$n,n,t)}))}}function Zs(t,i,n,s,e,r,h){if(0===i.length||s.from>=i.length||s.to<=0)return;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:o}=t,_=i[s.from];let u=r(t,_),c=_;if(s.to-s.from<2){const i=e/2;a.beginPath();const n={_t:_._t-i,ut:_.ut},s={_t:_._t+i,ut:_.ut};a.moveTo(n._t*l,n.ut*o),a.lineTo(s._t*l,s.ut*o),h(t,u,n,s)}else{const e=(i,n)=>{h(t,u,c,n),a.beginPath(),u=i,c=n};let d=c;a.beginPath(),a.moveTo(_._t*l,_.ut*o);for(let h=s.from+1;h<s.to;++h){d=i[h];const s=r(t,d);switch(n){case 0:a.lineTo(d._t*l,d.ut*o);break;case 1:a.lineTo(d._t*l,i[h-1].ut*o),s!==u&&(e(s,d),a.lineTo(d._t*l,i[h-1].ut*o)),a.lineTo(d._t*l,d.ut*o);break;case 2:{const[t,n]=Qs(i,h-1,h);a.bezierCurveTo(t._t*l,t.ut*o,n._t*l,n.ut*o,d._t*l,d.ut*o);break}}1!==n&&s!==u&&(e(s,d),a.moveTo(d._t*l,d.ut*o))}(c!==d||c===d&&1===n)&&h(t,u,c,d)}}const Gs=6;function Xs(t,i){return{_t:t._t-i._t,ut:t.ut-i.ut}}function Js(t,i){return{_t:t._t/i,ut:t.ut/i}}function Qs(t,i,n){const s=Math.max(0,i-1),e=Math.min(t.length-1,n+1);var r,h;return[(r=t[i],h=Js(Xs(t[n],t[s]),Gs),{_t:r._t+h._t,ut:r.ut+h.ut}),Xs(t[n],Js(Xs(t[e],t[i]),Gs))]}function te(t,i){const n=t.context;n.strokeStyle=i,n.stroke()}class ie extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,ib:e,nb:r,ct:h,Zt:a,sb:l}=this.rt;if(null===n)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,s(o,a),o.lineJoin="round";const _=this.eb.bind(this);void 0!==r&&Zs(t,i,r,n,e,_,te),l&&function(t,i,n,s,e){if(s.to-s.from<=0)return;const{horizontalPixelRatio:r,verticalPixelRatio:h,context:a}=t;let l=null;const o=Math.max(1,Math.floor(r))%2/2,_=n*h+o;for(let n=s.to-1;n>=s.from;--n){const s=i[n];if(s){const i=e(t,s);i!==l&&(a.beginPath(),null!==l&&a.fill(),a.fillStyle=i,l=i);const n=Math.round(s._t*r)+o,u=s.ut*h;a.moveTo(n,u),a.arc(n,u,_,0,2*Math.PI)}}a.fill()}(t,i,l,n,_)}}class ne extends ie{eb(t,i){return i.vt}}class se extends Ks{constructor(){super(...arguments),this.cM=new ne}tb(t,i,n){return{...this.QM(t,i),...n.gh(t)}}wM(){const t=this.ee.N(),i={ot:this.aM,Zt:t.lineStyle,nb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,sb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.lM,ib:this.re.Bt().ul()};this.cM.ht(i)}}const ee={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},YM:(t,i)=>new se(t,i)};function re(t,i){return t.weight>i.weight?t:i}class he{constructor(){this.rb=new o,this.hb=function(t){let i=!1;return function(...n){i||(i=!0,queueMicrotask((()=>{t(...n),i=!1})))}}((()=>this.rb.p(this.ab))),this.ab=0}lb(){return this.rb}m(){this.rb.m()}options(){return this.yn}setOptions(t){this.yn=t}preprocessData(t){}updateFormatter(t){this.yn&&(this.yn.localization=t)}createConverterToInternalObj(t){return this.hb(),t=>(t>this.ab&&(this.ab=t),t)}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return this.ob(t)}formatTickmark(t){return this.ob(t.time)}maxTickMarkWeight(t){return t.reduce(re,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)%120==0?10:n%60==0?9:n%36==0?8:n%12==0?7:n%6==0?6:n%3==0?5:n%1==0?4:0;var n;this.ab=t[t.length-1].time,this.hb()}ob(t){if(this.yn.localization?.timeFormatter)return this.yn.localization.timeFormatter(t);if(t<12)return`${t}M`;const i=Math.floor(t/12),n=t%12;return 0===n?`${i}Y`:`${i}Y${n}M`}}const ae={yieldCurve:{baseResolution:1,minimumTimeRange:120,startTimeRange:0},timeScale:{ignoreWhitespaceIndices:!0},leftPriceScale:{visible:!0},rightPriceScale:{visible:!1},localization:{priceFormatter:t=>t.toFixed(3)+"%"}},le={lastValueVisible:!1,priceLineVisible:!1};class oe extends js{constructor(t,i){const n=_(ae,i||{}),s=new he;super(t,s,n),s.setOptions(this.options()),this._initWhitespaceSeries()}addSeries(t,i={},n=0){if(t.isBuiltIn&&!1===["Area","Line"].includes(t.type))throw new Error("Yield curve only support Area and Line series");const s={...le,...i};return super.addSeries(t,s,n)}_initWhitespaceSeries(){const t=this.horzBehaviour(),i=this.addSeries(ee);let n;function s(s){const e=function(t,i){return{fe:Math.max(0,t.startTimeRange),pe:Math.max(0,t.minimumTimeRange,i||0),_b:Math.max(1,t.baseResolution)}}(t.options().yieldCurve,s),r=(({fe:t,pe:i,_b:n})=>`${t}~${i}~${n}`)(e);r!==n&&(n=r,i.setData(function({fe:t,pe:i,_b:n}){return Array.from({length:Math.floor((i-t)/n)+1},((i,s)=>({time:t+s*n})))}(e)))}s(0),t.lb().i(s)}}function _e(t,i){return t.weight>i.weight?t:i}class ue{options(){return this.yn}setOptions(t){this.yn=t}preprocessData(t){}updateFormatter(t){this.yn&&(this.yn.localization=t)}createConverterToInternalObj(t){return t=>t}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return t.toFixed(this.Ds())}formatTickmark(t,i){return t.time.toFixed(this.Ds())}maxTickMarkWeight(t){return t.reduce(_e,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)===100*Math.ceil(n/100)?8:n===50*Math.ceil(n/50)?7:n===25*Math.ceil(n/25)?6:n===10*Math.ceil(n/10)?5:n===5*Math.ceil(n/5)?4:n===Math.ceil(n)?3:2*n===Math.ceil(2*n)?1:0;var n}Ds(){return this.yn.localization.precision}}function ce(t,i,n,s,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:a}=i;r.lineTo(e._t*h,t*a),r.lineTo(s._t*h,t*a),r.closePath(),r.fillStyle=n,r.fill()}class de extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,ib:e,ct:r,Zt:h,nb:a}=this.rt,l=this.rt.ub??(this.rt.cb?0:t.mediaSize.height);if(null===n)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,s(o,h),o.lineWidth=1,Zs(t,i,a,n,e,this.fb.bind(this),ce.bind(null,l))}}class fe{pb(t,i){const n=this.mb,{wb:s,gb:e,Mb:r,bb:h,ub:a,xb:l,Sb:o}=i;if(void 0===this.Cb||void 0===n||n.wb!==s||n.gb!==e||n.Mb!==r||n.bb!==h||n.ub!==a||n.xb!==l||n.Sb!==o){const{verticalPixelRatio:n}=t,_=a||l>0?n:1,u=l*_,c=o===t.bitmapSize.height?o:o*_,d=(a??0)*_,f=t.context.createLinearGradient(0,u,0,c);if(f.addColorStop(0,s),null!=a){const t=Jt((d-u)/(c-u),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.Cb=f,this.mb=i}return this.Cb}}class pe extends de{constructor(){super(...arguments),this.yb=new fe}fb(t,i){const n=this.rt;return this.yb.pb(t,{wb:i.oh,gb:i._h,Mb:i.uh,bb:i.dh,ub:n.ub,xb:n.xb??0,Sb:n.Sb??t.bitmapSize.height})}}class ve extends ie{constructor(){super(...arguments),this.Pb=new fe}eb(t,i){const n=this.rt;return this.Pb.pb(t,{wb:i.hh,gb:i.hh,Mb:i.ah,bb:i.ah,ub:n.ub,xb:n.xb??0,Sb:n.Sb??t.bitmapSize.height})}}class me extends Ks{constructor(t,i){super(t,i),this.cM=new C,this.kb=new pe,this.Tb=new ve,this.cM.nt([this.kb,this.Tb])}tb(t,i,n){return{...this.QM(t,i),...n.gh(t)}}wM(){const t=this.ee.zt();if(null===t)return;const i=this.ee.N(),n=this.ee.Ft().Nt(i.baseValue.price,t.Wt),s=this.re.Bt().ul();if(null===this.lM||0===this.aM.length)return;let e,r;if(i.relativeGradient){e=this.aM[this.lM.from].ut,r=this.aM[this.lM.from].ut;for(let t=this.lM.from;t<this.lM.to;t++){const i=this.aM[t];i.ut<e&&(e=i.ut),i.ut>r&&(r=i.ut)}}this.kb.ht({ot:this.aM,ct:i.lineWidth,Zt:i.lineStyle,nb:i.lineType,ub:n,xb:e,Sb:r,cb:!1,lt:this.lM,ib:s}),this.Tb.ht({ot:this.aM,ct:i.lineWidth,Zt:i.lineStyle,nb:i.lineVisible?i.lineType:void 0,sb:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,ub:n,xb:e,Sb:r,lt:this.lM,ib:s})}}const we={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,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},YM:(t,i)=>new me(t,i)};class ge extends de{constructor(){super(...arguments),this.yb=new fe}fb(t,i){return this.yb.pb(t,{wb:i.eh,gb:"",Mb:"",bb:i.rh,xb:this.rt?.xb??0,Sb:t.bitmapSize.height})}}class Me extends Ks{constructor(t,i){super(t,i),this.cM=new C,this.Rb=new ge,this.Db=new ne,this.cM.nt([this.Rb,this.Db])}tb(t,i,n){return{...this.QM(t,i),...n.gh(t)}}wM(){const t=this.ee.N();if(null===this.lM||0===this.aM.length)return;let i;if(t.relativeGradient){i=this.aM[this.lM.from].ut;for(let t=this.lM.from;t<this.lM.to;t++){const n=this.aM[t];n.ut<i&&(i=n.ut)}}this.Rb.ht({nb:t.lineType,ot:this.aM,Zt:t.lineStyle,ct:t.lineWidth,ub:null,xb:i,cb:t.invertFilledArea,lt:this.lM,ib:this.re.Bt().ul()}),this.Db.ht({nb:t.lineVisible?t.lineType:void 0,ot:this.aM,Zt:t.lineStyle,ct:t.lineWidth,lt:this.lM,ib:this.re.Bt().ul(),sb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}const be={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},YM:(t,i)=>new Me(t,i)};class xe extends y{constructor(){super(...arguments),this.qt=null,this.Ib=0,this.Eb=0}ht(t){this.qt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.Un.length||null===this.qt.lt)return;if(this.Ib=this.Vb(i),this.Ib>=2){Math.max(1,Math.floor(i))%2!=this.Ib%2&&this.Ib--}this.Eb=this.qt.Bb?Math.min(this.Ib,Math.floor(i)):this.Ib;let s=null;const e=this.Eb<=this.Ib&&this.qt.ul>=Math.floor(1.5*i);for(let r=this.qt.lt.from;r<this.qt.lt.to;++r){const h=this.qt.Un[r];s!==h.th&&(t.fillStyle=h.th,s=h.th);const a=Math.floor(.5*this.Eb),l=Math.round(h._t*i),o=l-a,_=this.Eb,u=o+_-1,c=Math.min(h.Xo,h.Jo),d=Math.max(h.Xo,h.Jo),f=Math.round(c*n)-a,p=Math.round(d*n)+a,v=Math.max(p-f,this.Eb);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.Ib);if(e){if(this.qt.Ab){const i=l-m;let s=Math.max(f,Math.round(h.Go*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(i,s,o-i,e-s+1)}const i=l+m;let s=Math.max(f,Math.round(h.Qo*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(u+1,s,i-u,e-s+1)}}}Vb(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(a(this.qt).ul,t)))}}class Se extends ms{constructor(t,i){super(t,i,!1)}mM(t,i,n){i.mc(this.aM,m(this.lM)),t.Zo(this.aM,n,m(this.lM))}zb(t,i,n){return{wt:t,Hr:i.Wt[0],Ur:i.Wt[1],$r:i.Wt[2],jr:i.Wt[3],_t:NaN,Go:NaN,Xo:NaN,Jo:NaN,Qo:NaN}}pM(){const t=this.ee.ga();this.aM=this.ee.Na().Dh().map((i=>this.tb(i.$n,i,t)))}}class Ce extends Se{constructor(){super(...arguments),this.cM=new xe}tb(t,i,n){return{...this.zb(t,i,n),...n.gh(t)}}wM(){const t=this.ee.N();this.cM.ht({Un:this.aM,ul:this.re.Bt().ul(),Ab:t.openVisible,Bb:t.thinBars,lt:this.lM})}}const ye={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},YM:(t,i)=>new Ce(t,i)};class Pe extends y{constructor(){super(...arguments),this.qt=null,this.Ib=0}ht(t){this.qt=t}et(t){if(null===this.qt||0===this.qt.Un.length||null===this.qt.lt)return;const{horizontalPixelRatio:i}=t;if(this.Ib=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const n=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),s=Math.floor(t*n*i),e=Math.floor(t*i),r=Math.min(s,e);return Math.max(Math.floor(i),r)}(this.qt.ul,i),this.Ib>=2){Math.floor(i)%2!=this.Ib%2&&this.Ib--}const n=this.qt.Un;this.qt.Lb&&this.Ob(t,n,this.qt.lt),this.qt.Mi&&this.gm(t,n,this.qt.lt);const s=this.Nb(i);(!this.qt.Mi||this.Ib>2*s)&&this.Fb(t,n,this.qt.lt)}Ob(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",a=Math.min(Math.floor(e),Math.floor(this.qt.ul*e));a=Math.max(Math.floor(e),Math.min(a,this.Ib));const l=Math.floor(.5*a);let o=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.nh!==h&&(s.fillStyle=n.nh,h=n.nh);const _=Math.round(Math.min(n.Go,n.Qo)*r),u=Math.round(Math.max(n.Go,n.Qo)*r),c=Math.round(n.Xo*r),d=Math.round(n.Jo*r);let f=Math.round(e*n._t)-l;const p=f+a-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;s.fillRect(f,c,v,_-c),s.fillRect(f,u+1,v,d-u),o=p}}Nb(t){let i=Math.floor(1*t);this.Ib<=2*i&&(i=Math.floor(.5*(this.Ib-1)));const n=Math.max(Math.floor(t),i);return this.Ib<=2*n?Math.max(Math.floor(t),Math.floor(1*t)):n}gm(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.Nb(e);let l=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.ih!==h&&(s.fillStyle=n.ih,h=n.ih);let o=Math.round(n._t*e)-Math.floor(.5*this.Ib);const _=o+this.Ib-1,u=Math.round(Math.min(n.Go,n.Qo)*r),c=Math.round(Math.max(n.Go,n.Qo)*r);if(null!==l&&(o=Math.max(l+1,o),o=Math.min(o,_)),this.qt.ul*e>2*a)E(s,o,u,_-o+1,c-u+1,a);else{const t=_-o+1;s.fillRect(o,u,t,c-u+1)}l=_}}Fb(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.Nb(e);for(let t=n.from;t<n.to;t++){const n=i[t];let l=Math.round(Math.min(n.Go,n.Qo)*r),o=Math.round(Math.max(n.Go,n.Qo)*r),_=Math.round(n._t*e)-Math.floor(.5*this.Ib),u=_+this.Ib-1;if(n.th!==h){const t=n.th;s.fillStyle=t,h=t}this.qt.Mi&&(_+=a,l+=a,u-=a,o-=a),l>o||s.fillRect(_,l,u-_+1,o-l+1)}}}class ke extends Se{constructor(){super(...arguments),this.cM=new Pe}tb(t,i,n){return{...this.zb(t,i,n),...n.gh(t)}}wM(){const t=this.ee.N();this.cM.ht({Un:this.aM,ul:this.re.Bt().ul(),Lb:t.wickVisible,Mi:t.borderVisible,lt:this.lM})}}const Te={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},YM:(t,i)=>new ke(t,i)};class Re extends y{constructor(){super(...arguments),this.qt=null,this.Wb=[]}ht(t){this.qt=t,this.Wb=[]}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return;this.Wb.length||this.Hb(i);const s=Math.max(1,Math.floor(n)),e=Math.round(this.qt.Ub*n)-Math.floor(s/2),r=e+s;for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const h=this.qt.ot[i],a=this.Wb[i-this.qt.lt.from],l=Math.round(h.ut*n);let o,_;t.fillStyle=h.th,l<=e?(o=l,_=r):(o=e,_=l-Math.floor(s/2)+s),t.fillRect(a.Aa,o,a.bi-a.Aa+1,_-o)}}Hb(t){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return void(this.Wb=[]);const i=Math.ceil(this.qt.ul*t)<=1?0:Math.max(1,Math.floor(t)),n=Math.round(this.qt.ul*t)-i;this.Wb=new Array(this.qt.lt.to-this.qt.lt.from);for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const s=this.qt.ot[i],e=Math.round(s._t*t);let r,h;if(n%2){const t=(n-1)/2;r=e-t,h=e+t}else{const t=n/2;r=e-t,h=e+t-1}this.Wb[i-this.qt.lt.from]={Aa:r,bi:h,$b:e,oe:s._t*t,wt:s.wt}}for(let t=this.qt.lt.from+1;t<this.qt.lt.to;t++){const n=this.Wb[t-this.qt.lt.from],s=this.Wb[t-this.qt.lt.from-1];n.wt===s.wt+1&&(n.Aa-s.bi!==i+1&&(s.$b>s.oe?s.bi=n.Aa-i-1:n.Aa=s.bi+i+1))}let s=Math.ceil(this.qt.ul*t);for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.Wb[t-this.qt.lt.from];i.bi<i.Aa&&(i.bi=i.Aa);const n=i.bi-i.Aa+1;s=Math.min(n,s)}if(i>0&&s<4)for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.Wb[t-this.qt.lt.from];i.bi-i.Aa+1>s&&(i.$b>i.oe?i.bi-=1:i.Aa+=1)}}}class De extends Ks{constructor(){super(...arguments),this.cM=new Re}tb(t,i,n){return{...this.QM(t,i),...n.gh(t)}}wM(){const t={ot:this.aM,ul:this.re.Bt().ul(),lt:this.lM,Ub:this.ee.Ft().Nt(this.ee.N().base,a(this.ee.zt()).Wt)};this.cM.ht(t)}}const Ie={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},YM:(t,i)=>new De(t,i)};class Ee{constructor(t,i){this.yt=t,this.jb=i,this.qb()}detach(){this.yt.detachPrimitive(this.jb)}getPane(){return this.yt}applyOptions(t){this.jb.cr?.(t)}qb(){this.yt.attachPrimitive(this.jb)}}const Ve={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},Be={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:w,fontStyle:"",text:""};class Ae{constructor(t){this.Yb=new Map,this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{if(!this.qt.visible)return;const{context:i,mediaSize:n}=t;let s=0;for(const t of this.qt.lines){if(0===t.text.length)continue;i.font=t.k;const e=this.Kb(i,t.text);e>n.width?t.Rc=n.width/e:t.Rc=1,s+=t.lineHeight*t.Rc}let e=0;switch(this.qt.vertAlign){case"top":e=0;break;case"center":e=Math.max((n.height-s)/2,0);break;case"bottom":e=Math.max(n.height-s,0)}for(const t of this.qt.lines){i.save(),i.fillStyle=t.color;let s=0;switch(this.qt.horzAlign){case"left":i.textAlign="left",s=t.lineHeight/2;break;case"center":i.textAlign="center",s=n.width/2;break;case"right":i.textAlign="right",s=n.width-1-t.lineHeight/2}i.translate(s,e),i.textBaseline="top",i.font=t.k,i.scale(t.Rc,t.Rc),i.fillText(t.text,0,t.Zb),i.restore(),e+=t.lineHeight*t.Rc}}))}Kb(t,i){const n=this.Gb(t.font);let s=n.get(i);return void 0===s&&(s=t.measureText(i).width,n.set(i,s)),s}Gb(t){let i=this.Yb.get(t);return void 0===i&&(i=new Map,this.Yb.set(t,i)),i}}class ze{constructor(t){this.yn=Oe(t)}Pt(t){this.yn=Oe(t)}renderer(){return new Ae(this.yn)}}function Le(t){return{...t,k:g(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,Zb:0,Rc:0}}function Oe(t){return{...t,lines:t.lines.map(Le)}}function Ne(t){return{...Be,...t}}function Fe(t){return{...Ve,...t,lines:t.lines?.map(Ne)??[]}}class We{constructor(t){this.yn=Fe(t),this.Xb=[new ze(this.yn)]}updateAllViews(){this.Xb.forEach((t=>t.Pt(this.yn)))}paneViews(){return this.Xb}attached({requestUpdate:t}){this.Jb=t}detached(){this.Jb=void 0}cr(t){this.yn=Fe({...this.yn,...t}),this.Jb&&this.Jb()}}const He={alpha:1,padding:0};class Ue{constructor(t){this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{const i=t.context,n=this.Qb(this.qt,t.mediaSize);n&&this.qt.tx&&(i.globalAlpha=this.qt.alpha??1,i.drawImage(this.qt.tx,n._t,n.ut,n.nn,n.$t))}))}Qb(t,i){const{maxHeight:n,maxWidth:s,ix:e,nx:r,padding:h}=t,a=Math.round(i.width/2),l=Math.round(i.height/2),o=h??0;let _=i.width-2*o,u=i.height-2*o;n&&(u=Math.min(u,n)),s&&(_=Math.min(_,s));const c=_/r,d=u/e,f=Math.min(c,d),p=r*f,v=e*f;return{_t:a-.5*p,ut:l-.5*v,$t:v,nn:p}}}class $e{constructor(t){this.sx=null,this.hx=0,this.lx=0,this.yn=t,this.M=je(this.yn,this.sx,this.hx,this.lx)}ox(t){void 0!==t._x&&(this.hx=t._x),void 0!==t.ux&&(this.lx=t.ux),void 0!==t.vx&&(this.sx=t.vx),this.Pt()}mx(t){this.yn=t,this.Pt()}zOrder(){return"bottom"}Pt(){this.M=je(this.yn,this.sx,this.hx,this.lx)}renderer(){return new Ue(this.M)}}function je(t,i,n,s){return{...t,tx:i,nx:n,ix:s}}function qe(t){return{...He,...t}}class Ye{constructor(t,i){this.wx=null,this.gx=t,this.yn=qe(i),this.Xb=[new $e(this.yn)]}updateAllViews(){this.Xb.forEach((t=>t.Pt()))}paneViews(){return this.Xb}attached(t){const{requestUpdate:i}=t;this.Mx=i,this.wx=new Image,this.wx.onload=()=>{const t=this.wx?.naturalHeight??1,i=this.wx?.naturalWidth??1;this.Xb.forEach((n=>n.ox({ux:t,_x:i,vx:this.wx}))),this.Mx&&this.Mx()},this.wx.src=this.gx}detached(){this.Mx=void 0,this.wx=null}cr(t){this.yn=qe({...this.yn,...t}),this.bx(),this.Jb&&this.Jb()}Jb(){this.Mx&&this.Mx()}bx(){this.Xb.forEach((t=>t.mx(this.yn)))}}class Ke{constructor(t,i){this.ee=t,this.Zh=i,this.qb()}detach(){this.ee.detachPrimitive(this.Zh)}getSeries(){return this.ee}applyOptions(t){this.Zh&&this.Zh.cr&&this.Zh.cr(t)}qb(){this.ee.attachPrimitive(this.Zh)}}const Ze={autoScale:!0,zOrder:"normal"};function Ge(t,i){return ti(Math.min(Math.max(t,12),30)*i)}function Xe(t,i){switch(t){case"arrowDown":case"arrowUp":return Ge(i,1);case"circle":return Ge(i,.8);case"square":return Ge(i,.7)}}function Je(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(Ge(t,1))}function Qe(t){return Math.max(Ge(t,.1),3)}function tr(t,i,n){return i?t:n?Math.ceil(t/2):0}function ir(t,i,n,s){const e=(Xe("arrowUp",s)-1)/2*n.xx,r=(ti(s/2)-1)/2*n.xx;i.beginPath(),t?(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut-e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut+e),i.lineTo(n._t-r,n.ut+e),i.lineTo(n._t-r,n.ut)):(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut+e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut-e),i.lineTo(n._t-r,n.ut-e),i.lineTo(n._t-r,n.ut)),i.fill()}function nr(t,i,n,s,e,r){const h=(Xe("arrowUp",s)-1)/2,a=(ti(s/2)-1)/2;if(e>=i-a-2&&e<=i+a+2&&r>=(t?n:n-h)-2&&r<=(t?n+h:n)+2)return!0;return(()=>{if(e<i-h-3||e>i+h+3||r<(t?n-h-3:n)||r>(t?n:n+h+3))return!1;const s=Math.abs(e-i);return Math.abs(r-n)+3>=s/2})()}class sr{constructor(){this.qt=null,this.$s=new it,this.F=-1,this.W="",this.qv="",this.Sx="normal"}ht(t){this.qt=t}js(t,i,n){this.F===t&&this.W===i||(this.F=t,this.W=i,this.qv=g(t,i),this.$s.Os()),this.Sx=n}Qs(t,i){if(null===this.qt||null===this.qt.lt)return null;for(let n=this.qt.lt.from;n<this.qt.lt.to;n++){const s=this.qt.ot[n];if(s&&rr(s,t,i))return{zOrder:"normal",externalId:s.te??""}}return null}draw(t){"aboveSeries"!==this.Sx&&t.useBitmapCoordinateSpace((t=>{this.et(t)}))}drawBackground(t){"aboveSeries"===this.Sx&&t.useBitmapCoordinateSpace((t=>{this.et(t)}))}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null!==this.qt&&null!==this.qt.lt){t.textBaseline="middle",t.font=this.qv;for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=this.qt.ot[s];void 0!==e.ri&&(e.ri.nn=this.$s.Ii(t,e.ri.Cx),e.ri.$t=this.F,e.ri._t=e._t-e.ri.nn/2),er(e,t,i,n)}}}}function er(t,i,n,s){i.fillStyle=t.R,void 0!==t.ri&&function(t,i,n,s,e,r){t.save(),t.scale(e,r),t.fillText(i,n,s),t.restore()}(i,t.ri.Cx,t.ri._t,t.ri.ut,n,s),function(t,i,n){if(0===t.yh)return;switch(t.yx){case"arrowDown":return void ir(!1,i,n,t.yh);case"arrowUp":return void ir(!0,i,n,t.yh);case"circle":return void function(t,i,n){const s=(Xe("circle",n)-1)/2;t.beginPath(),t.arc(i._t,i.ut,s*i.xx,0,2*Math.PI,!1),t.fill()}(i,n,t.yh);case"square":return void function(t,i,n){const s=Xe("square",n),e=(s-1)*i.xx/2,r=i._t-e,h=i.ut-e;t.fillRect(r,h,s*i.xx,s*i.xx)}(i,n,t.yh)}t.yx}(t,i,function(t,i,n){const s=Math.max(1,Math.floor(i))%2/2;return{_t:Math.round(t._t*i)+s,ut:t.ut*n,xx:i}}(t,n,s))}function rr(t,i,n){return!(void 0===t.ri||!function(t,i,n,s,e,r){const h=s/2;return e>=t&&e<=t+n&&r>=i-h&&r<=i+h}(t.ri._t,t.ri.ut,t.ri.nn,t.ri.$t,i,n))||function(t,i,n){if(0===t.yh)return!1;switch(t.yx){case"arrowDown":return nr(!0,t._t,t.ut,t.yh,i,n);case"arrowUp":return nr(!1,t._t,t.ut,t.yh,i,n);case"circle":return function(t,i,n,s,e){const r=2+Xe("circle",n)/2,h=t-s,a=i-e;return Math.sqrt(h*h+a*a)<=r}(t._t,t.ut,t.yh,i,n);case"square":return function(t,i,n,s,e){const r=Xe("square",n),h=(r-1)/2,a=t-h,l=i-h;return s>=a&&s<=a+r&&e>=l&&e<=l+r}(t._t,t.ut,t.yh,i,n)}}(t,i,n)}function hr(t){return"atPriceTop"===t||"atPriceBottom"===t||"atPriceMiddle"===t}function ar(t,i,n,s,e,r,h,l){const o=function(t,i,n){if(hr(i.position)&&void 0!==i.price)return i.price;if("value"in(s=t)&&"number"==typeof s.value)return t.value;var s;if(function(t){return"open"in t&&"high"in t&&"low"in t&&"close"in t}(t)){if("inBar"===i.position)return t.close;if("aboveBar"===i.position)return n?t.low:t.high;if("belowBar"===i.position)return n?t.high:t.low}}(n,i,h.priceScale().options().invertScale);if(void 0===o)return;const _=hr(i.position),c=l.timeScale(),d=u(i.size)?Math.max(i.size,0):1,f=Je(c.options().barSpacing)*d,p=f/2;t.yh=f;switch(i.position){case"inBar":case"atPriceMiddle":return t.ut=a(h.priceToCoordinate(o)),void(void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e));case"aboveBar":case"atPriceTop":{const i=_?0:s.Px;return t.ut=a(h.priceToCoordinate(o))-p-i,void 0!==t.ri&&(t.ri.ut=t.ut-p-.6*e,s.Px+=1.2*e),void(_||(s.Px+=f+r))}case"belowBar":case"atPriceBottom":{const i=_?0:s.kx;return t.ut=a(h.priceToCoordinate(o))+p+i,void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e,s.kx+=1.2*e),void(_||(s.kx+=f+r))}}}class lr{constructor(t,i,n){this.Tx=[],this.St=!0,this.Rx=!0,this.Xt=new sr,this.ye=t,this.zv=i,this.qt={ot:[],lt:null},this.yn=n}renderer(){if(!this.ye.options().visible)return null;this.St&&this.Dx();const t=this.zv.options().layout;return this.Xt.js(t.fontSize,t.fontFamily,this.yn.zOrder),this.Xt.ht(this.qt),this.Xt}Ix(t){this.Tx=t,this.Pt("data")}Pt(t){this.St=!0,"data"===t&&(this.Rx=!0)}Ex(t){this.St=!0,this.yn=t}zOrder(){return"aboveSeries"===this.yn.zOrder?"top":this.yn.zOrder}Dx(){const t=this.zv.timeScale(),i=this.Tx;this.Rx&&(this.qt.ot=i.map((t=>({wt:t.time,_t:0,ut:0,yh:0,yx:t.shape,R:t.color,te:t.id,Vx:t.Vx,ri:void 0}))),this.Rx=!1);const n=this.zv.options().layout;this.qt.lt=null;const s=t.getVisibleLogicalRange();if(null===s)return;const e=new Ti(Math.floor(s.from),Math.ceil(s.to));if(null===this.ye.data()[0])return;if(0===this.qt.ot.length)return;let r=NaN;const h=Qe(t.options().barSpacing),l={Px:h,kx:h};this.qt.lt=vs(this.qt.ot,e,!0);for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=i[s];e.time!==r&&(l.Px=h,l.kx=h,r=e.time);const o=this.qt.ot[s];o._t=a(t.logicalToCoordinate(e.time)),void 0!==e.text&&e.text.length>0&&(o.ri={Cx:e.text,_t:0,ut:0,nn:0,$t:0});const _=this.ye.dataByIndex(e.time,0);null!==_&&ar(o,e,_,l,n.fontSize,h,this.ye,this.zv)}this.St=!1}}function or(t){return{...Ze,...t}}class _r{constructor(t){this.$h=null,this.Tx=[],this.Bx=[],this.Ax=null,this.ye=null,this.zv=null,this.zx=!0,this.Lx=null,this.Ox=null,this.Nx=null,this.Fx=!0,this.yn=or(t)}attached(t){this.Wx(),this.zv=t.chart,this.ye=t.series,this.$h=new lr(this.ye,a(this.zv),this.yn),this.Mx=t.requestUpdate,this.ye.subscribeDataChanged((t=>this.IM(t))),this.Fx=!0,this.Jb()}Jb(){this.Mx&&this.Mx()}detached(){this.ye&&this.Ax&&this.ye.unsubscribeDataChanged(this.Ax),this.zv=null,this.ye=null,this.$h=null,this.Ax=null}Ix(t){this.Fx=!0,this.Tx=t,this.Wx(),this.zx=!0,this.Ox=null,this.Jb()}Hx(){return this.Tx}paneViews(){return this.$h?[this.$h]:[]}updateAllViews(){this.Ux()}hitTest(t,i){return this.$h?this.$h.renderer()?.Qs(t,i)??null:null}autoscaleInfo(t,i){if(this.yn.autoScale&&this.$h){const t=this.$x();if(t)return{priceRange:null,margins:t}}return null}cr(t){this.yn=or({...this.yn,...t}),this.Jb&&this.Jb()}$x(){const t=a(this.zv).timeScale().options().barSpacing;if(this.zx||t!==this.Nx){if(this.Nx=t,this.Tx.length>0){const i=Qe(t),n=1.5*Je(t)+2*i,s=this.jx();this.Lx={above:tr(n,s.aboveBar,s.inBar),below:tr(n,s.belowBar,s.inBar)}}else this.Lx=null;this.zx=!1}return this.Lx}jx(){return null===this.Ox&&(this.Ox=this.Tx.reduce(((t,i)=>(t[i.position]||(t[i.position]=!0),t)),{inBar:!1,aboveBar:!1,belowBar:!1,atPriceTop:!1,atPriceBottom:!1,atPriceMiddle:!1})),this.Ox}Wx(){if(!this.Fx||!this.zv||!this.ye)return;const t=this.zv.timeScale(),i=this.ye?.data();if(null==t.getVisibleLogicalRange()||!this.ye||0===i.length)return void(this.Bx=[]);const n=t.timeToIndex(a(i[0].time),!0);this.Bx=this.Tx.map(((i,s)=>{const e=t.timeToIndex(i.time,!0),r=e<n?1:-1,h=a(this.ye).dataByIndex(e,r),l={time:t.timeToIndex(a(h).time,!1),position:i.position,shape:i.shape,color:i.color,id:i.id,Vx:s,text:i.text,size:i.size,price:i.price,Gr:i.time};if("atPriceTop"===i.position||"atPriceBottom"===i.position||"atPriceMiddle"===i.position){if(void 0===i.price)throw new Error(`Price is required for position ${i.position}`);return{...l,position:i.position,price:i.price}}return{...l,position:i.position,price:i.price}})),this.Fx=!1}Ux(t){this.$h&&(this.Wx(),this.$h.Ix(this.Bx),this.$h.Ex(this.yn),this.$h.Pt(t))}IM(t){this.Fx=!0,this.Jb()}}class ur extends Ke{constructor(t,i,n){super(t,i),n&&this.setMarkers(n)}setMarkers(t){this.Zh.Ix(t)}markers(){return this.Zh.Hx()}}class cr{constructor(t){this.Tx=new Map,this.qx=t}Yx(t,i,n){if(this.Kx(i),void 0!==n){const s=window.setTimeout((()=>{this.Tx.delete(i),this.Zx()}),n),e={...t,Gx:s,Xx:Date.now()+n};this.Tx.set(i,e)}else this.Tx.set(i,{...t,Gx:void 0,Xx:void 0});this.Zx()}Kx(t){const i=this.Tx.get(t);i&&void 0!==i.Gx&&window.clearTimeout(i.Gx),this.Tx.delete(t),this.Zx()}Jx(){for(const[t]of this.Tx)this.Kx(t)}Qx(){const t=Date.now(),i=[];for(const[n,s]of this.Tx)!s.Xx||s.Xx>t?i.push({time:s.time,sign:s.sign,value:s.value}):this.Kx(n);return i}tS(t){this.qx=t}Zx(){this.qx&&this.qx()}}const dr={positiveColor:"#22AB94",negativeColor:"#F7525F",updateVisibilityDuration:5e3};class fr{constructor(t,i,n,s){this.qt=t,this.iS=i,this.nS=n,this.sS=s}draw(t){t.useBitmapCoordinateSpace((t=>{const i=t.context,n=Math.max(1,Math.floor(t.horizontalPixelRatio))%2/2,s=4*t.verticalPixelRatio+n;this.qt.forEach((e=>{const r=Math.round(e._t*t.horizontalPixelRatio)+n;i.beginPath();const h=this.eS(e.rS);i.fillStyle=h,i.arc(r,e.ut*t.verticalPixelRatio,s,0,2*Math.PI,!1),i.fill(),e.rS&&(i.strokeStyle=h,i.lineWidth=Math.floor(2*t.horizontalPixelRatio),i.beginPath(),i.moveTo((e._t-4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.rS)*t.verticalPixelRatio),i.lineTo(e._t*t.horizontalPixelRatio+n,(e.ut-7*e.rS-7*e.rS*.5)*t.verticalPixelRatio),i.lineTo((e._t+4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.rS)*t.verticalPixelRatio),i.stroke())}))}))}eS(t){return 0===t?this.iS:t>0?this.sS:this.nS}}class pr{constructor(t,i,n){this.qt=[],this.ye=t,this.Jh=i,this.yn=n}Pt(t){this.qt=t.map((t=>{const i=this.ye.priceToCoordinate(t.value);if(null===i)return null;return{_t:a(this.Jh.timeToCoordinate(t.time)),ut:i,rS:t.sign}})).filter(v)}renderer(){const t=function(t,i){return function(t,i){return"Area"===i}(0,i)?t.lineColor:t.color}(this.ye.options(),this.ye.seriesType());return new fr(this.qt,t,this.yn.negativeColor,this.yn.positiveColor)}}function vr(t,i){return"Line"===i||"Area"===i}class mr{constructor(t){this.zv=void 0,this.ye=void 0,this.Xb=[],this.cu=null,this.hS=new Map,this.aS=new cr((()=>this.Jb())),this.yn={...dr,...t}}cr(t){this.yn={...this.yn,...t},this.Jb()}Ix(t){this.aS.Jx();const i=this.cu;i&&t.forEach((t=>{this.aS.Yx(t,i.key(t.time))}))}Hx(){return this.aS.Qx()}Jb(){this.Mx?.()}attached(t){const{chart:i,series:n,requestUpdate:s,horzScaleBehavior:e}=t;this.zv=i,this.ye=n,this.cu=e;const r=this.ye.seriesType();if("Area"!==r&&"Line"!==r)throw new Error("UpDownMarkersPrimitive is only supported for Area and Line series types");this.Xb=[new pr(this.ye,this.zv.timeScale(),this.yn)],this.Mx=s,this.Jb()}detached(){this.zv=void 0,this.ye=void 0,this.Mx=void 0}Gv(){return h(this.zv)}F_(){return h(this.ye)}updateAllViews(){this.Xb.forEach((t=>t.Pt(this.Hx())))}paneViews(){return this.Xb}ht(t){if(!this.ye)throw new Error("Primitive not attached to series");const i=this.ye.seriesType();this.hS.clear();const n=this.cu;n&&t.forEach((t=>{Jn(t)&&vr(0,i)&&this.hS.set(n.key(t.time),t.value)})),h(this.ye).setData(t)}Pt(t,i){if(!this.ye||!this.cu)throw new Error("Primitive not attached to series");const n=this.ye.seriesType(),s=this.cu.key(t.time);if(Xn(t)&&this.hS.delete(s),Jn(t)&&vr(0,n)){const i=this.hS.get(s);i&&this.aS.Yx({time:t.time,value:t.value,sign:wr(t.value,i)},s,this.yn.updateVisibilityDuration)}h(this.ye).update(t,i)}lS(){this.aS.Jx()}}function wr(t,i){return t===i?0:t-i>0?1:-1}class gr extends Ke{setData(t){return this.Zh.ht(t)}update(t,i){return this.Zh.Pt(t,i)}markers(){return this.Zh.Hx()}setMarkers(t){return this.Zh.Ix(t)}clearMarkers(){return this.Zh.lS()}}const Mr={...t,color:"#2196f3"};var br=Object.freeze({__proto__:null,AreaSeries:be,BarSeries:ye,BaselineSeries:we,CandlestickSeries:Te,get ColorType(){return Li},get CrosshairMode(){return $},HistogramSeries:Ie,get LastPriceAnimationMode(){return Ai},LineSeries:ee,get LineStyle(){return n},get LineType(){return i},get MismatchDirection(){return kt},get PriceLineSource(){return zi},get PriceScaleMode(){return mi},get TickMarkType(){return Oi},get TrackingModeExitMode(){return Bi},createChart:function(t,i){return Ys(t,new rn,rn.pf(i))},createChartEx:Ys,createImageWatermark:function(t,i,n){return new Ee(t,new Ye(i,n))},createOptionsChart:function(t,i){return Ys(t,new ue,i)},createSeriesMarkers:function(t,i,n){const s=new ur(t,new _r(n??{}));return i&&s.setMarkers(i),s},createTextWatermark:function(t,i){return new Ee(t,new We(i))},createUpDownMarkers:function(t,i={}){return new gr(t,new mr(i))},createYieldCurveChart:function(t,i){const n=qs(t);return new oe(n,i)},customSeriesDefaultOptions:Mr,defaultHorzScaleBehavior:function(){return rn},isBusinessDay:Wi,isUTCTimestamp:Hi,version:function(){return"5.1.0"}});window.LightweightCharts=br}();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const serverPath = resolve(__dirname, '..', 'src', 'server.ts');
|
|
8
|
+
|
|
9
|
+
const child = spawn(process.execPath, ['--import', 'tsx', serverPath], {
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
14
|
+
process.on(sig, () => child.kill(sig));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
child.on('exit', (code, signal) => {
|
|
18
|
+
if (signal) process.kill(process.pid, signal);
|
|
19
|
+
else process.exit(code ?? 1);
|
|
20
|
+
});
|
package/lib/cache.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared in-memory TTL cache with optional max-entry eviction (FIFO).
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const c = new TtlCache<MyData>({ ttlMs: 30_000, maxEntries: 20 });
|
|
6
|
+
* c.set('key', data);
|
|
7
|
+
* const hit = c.get('key'); // undefined if expired or absent
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface TtlCacheOptions {
|
|
11
|
+
/** Time-to-live in milliseconds. */
|
|
12
|
+
ttlMs: number;
|
|
13
|
+
/** Maximum number of entries. Oldest entry is evicted when exceeded. Default: no limit. */
|
|
14
|
+
maxEntries?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Entry<V> {
|
|
18
|
+
value: V;
|
|
19
|
+
ts: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class TtlCache<V> {
|
|
23
|
+
private readonly ttlMs: number;
|
|
24
|
+
private readonly maxEntries: number;
|
|
25
|
+
private readonly store = new Map<string, Entry<V>>();
|
|
26
|
+
|
|
27
|
+
constructor(opts: TtlCacheOptions) {
|
|
28
|
+
this.ttlMs = opts.ttlMs;
|
|
29
|
+
this.maxEntries = opts.maxEntries ?? Infinity;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Return cached value if present and not expired, otherwise `undefined`. */
|
|
33
|
+
get(key: string): V | undefined {
|
|
34
|
+
const entry = this.store.get(key);
|
|
35
|
+
if (!entry) return undefined;
|
|
36
|
+
if (Date.now() - entry.ts > this.ttlMs) {
|
|
37
|
+
this.store.delete(key);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return entry.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Store a value. Evicts the oldest entry when `maxEntries` is reached. */
|
|
44
|
+
set(key: string, value: V): void {
|
|
45
|
+
if (this.store.size >= this.maxEntries && !this.store.has(key)) {
|
|
46
|
+
const oldest = this.store.keys().next().value;
|
|
47
|
+
if (oldest != null) this.store.delete(oldest);
|
|
48
|
+
}
|
|
49
|
+
// Re-insert to refresh insertion order (relevant for FIFO eviction)
|
|
50
|
+
this.store.delete(key);
|
|
51
|
+
this.store.set(key, { value, ts: Date.now() });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Check existence without returning the value. */
|
|
55
|
+
has(key: string): boolean {
|
|
56
|
+
return this.get(key) !== undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
delete(key: string): boolean {
|
|
60
|
+
return this.store.delete(key);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
clear(): void {
|
|
64
|
+
this.store.clear();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get size(): number {
|
|
68
|
+
return this.store.size;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ローソク足ヘルパー関数
|
|
3
|
+
*
|
|
4
|
+
* isBullish / isBearish / bodySize / bodyTop / bodyBottom を提供。
|
|
5
|
+
* analyze_candle_patterns.ts から抽出。他ツールでも再利用可能。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Candle } from '../src/schemas.js';
|
|
9
|
+
|
|
10
|
+
/** ローソク足が陽線かどうか */
|
|
11
|
+
export function isBullish(c: Candle): boolean {
|
|
12
|
+
return c.close > c.open;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** ローソク足が陰線かどうか */
|
|
16
|
+
export function isBearish(c: Candle): boolean {
|
|
17
|
+
return c.close < c.open;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 実体の大きさを取得 */
|
|
21
|
+
export function bodySize(c: Candle): number {
|
|
22
|
+
return Math.abs(c.close - c.open);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 実体の上端 */
|
|
26
|
+
export function bodyTop(c: Candle): number {
|
|
27
|
+
return Math.max(c.open, c.close);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 実体の下端 */
|
|
31
|
+
export function bodyBottom(c: Candle): number {
|
|
32
|
+
return Math.min(c.open, c.close);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 上ヒゲの長さ */
|
|
36
|
+
export function upperShadow(c: Candle): number {
|
|
37
|
+
return c.high - bodyTop(c);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 下ヒゲの長さ */
|
|
41
|
+
export function lowerShadow(c: Candle): number {
|
|
42
|
+
return bodyBottom(c) - c.low;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** ローソク足全体のレンジ(高値 - 安値) */
|
|
46
|
+
export function totalRange(c: Candle): number {
|
|
47
|
+
return c.high - c.low;
|
|
48
|
+
}
|