"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[98031],{246255:(e,t,s)=>{s.d(t,{ChartSession:()=>d});var r=s(942634),i=s(650151),o=s(375397),n=s(79342);const a=(0,s(338619).getLogger)("ChartApi.AbstractSession");class h{constructor(e,t,s){this._isConnected=new o.WatchedValue(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new r.Delegate,this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=s}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,i.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,n.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,i.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile((()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()})))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),s=String(e.params[1]);return void this._onCriticalError(t,s)}this._onMessage(e)}serverTime(){return this._chartApi.serverTime()}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,i.assert)(1===this._state,"Session is not registered"),this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){a.logNormal(this._generateLogMessage(e))}_logError(e){a.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),this._isConnectForbidden=!1}}class d extends h{ constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new r.Delegate,this._symbolResolveMap=new Map,this._lastSymbolResolveInfoMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}switchTimezone(e){return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}availablePriceSources(e){return this._getChartApi().availablePriceSources(e)}resolveSymbol(e,t,s){if(this._symbolResolveMap.has(t)){const[e,r]=this._symbolResolveMap.get(t);return Array.isArray(r)?r.push(s):r.then(s),e}{const r=[s];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,(s=>{if("symbol_error"===s.method)this._symbolResolveMap.delete(t);else{this._symbolResolveMap.set(t,[e,Promise.resolve(s)]);const[,r]=s.params,i={pro_name:r.pro_name,ticker:r.ticker};this._lastSymbolResolveInfoMap.set(t,i),i.pro_name&&this._lastSymbolResolveInfoMap.set(i.pro_name,i),r.full_name&&this._lastSymbolResolveInfoMap.set(r.full_name,i),i.ticker&&this._lastSymbolResolveInfoMap.set(i.ticker,i)}r.forEach((e=>e(s)))})),this._symbolResolveMap.set(t,[e,r]),e}}requestFirstBarTime(e,t,s){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,s)}lastSymbolResolveInfo(e){return this._lastSymbolResolveInfoMap.get(e)??null}createSeries(e,t,s,r,i,o,n){return this._getChartApi().createSeries(this.sessionId(),e,t,s,r,i,o,n)}modifySeries(e,t,s,r,i,o,n){return this._getChartApi().modifySeries(this.sessionId(),e,t,s,r,i,o,n)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,s){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,s)}requestMoreTickmarks(e,t,s){return this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,s)}setFutureTickmarksMode(e){return this._getChartApi().setFutureTickmarksMode(this.sessionId(),e)}canCreateStudy(e,t){return this._getChartApi().canCreateStudy(this.sessionId(),e,t)}getStudyCounter(){return this._getChartApi().getStudyCounter(this.sessionId())}getFundamentalCounter(){return this._getChartApi().getFundamentalCounter(this.sessionId())}createStudy(e,t,s,r,i,o,n){return this._getChartApi().createStudy(this.sessionId(),e,t,s,r,i,o,n)}modifyStudy(e,t,s,r,i){return this._getChartApi().modifyStudy(this.sessionId(),e,t,s,r,i)}notifyStudy(e,t,s){return this._getChartApi().notifyStudy(this.sessionId(),e,t,s)}removeStudy(e){return this._getChartApi().removeStudy(this.sessionId(),e)}createPointset(e,t,s,r,i,o){return this._getChartApi().createPointset(this.sessionId(),e,t,s,r,i,o)}modifyPointset(e,t,s,r){return this._getChartApi().modifyPointset(this.sessionId(),e,t,s,r)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)} setVisibleTimeRange(e,t,s,r,i,o){0}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach((e=>{/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]})),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())}_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}},264552:(e,t,s)=>{s.d(t,{getServerInterval:()=>i});var r=s(378975);function i(e){return r.Interval.isRange(e)?"1":e}},319448:(e,t,s)=>{s.d(t,{DateTimeFormatter:()=>n});var r=s(300484),i=s(553220);const o={dateFormat:"yyyy-MM-dd",withWeekday:!1,timeFormat:r.hourMinuteSecondFormat,dateTimeSeparator:" "};class n{constructor(e={}){const t=Object.assign({},o,e);this._dateFormatter=new i.DateFormatter(t.dateFormat,t.withWeekday),this._timeFormatter=new r.TimeFormatter(t.timeFormat),this._separator=t.dateTimeSeparator}format(e,t){const s=t?.dateTimeSeparator??this._separator;return`${this._dateFormatter.format(e)}${s}${this._timeFormatter.format(e)}`}formatLocal(e,t){const s=t?.dateTimeSeparator??this._separator;return`${this._dateFormatter.formatLocal(e)}${s}${this._timeFormatter.formatLocal(e)}`}}},320771:(e,t,s)=>{s.d(t,{SeriesDataEvents:()=>i});var r=s(942634);class i{constructor(){this._created=new r.Delegate,this._modified=new r.Delegate,this._loading=new r.Delegate,this._completed=new r.Delegate,this._error=new r.Delegate,this._symbolError=new r.Delegate,this._symbolResolved=new r.Delegate,this._seriesError=new r.Delegate,this._symbolNotPermitted=new r.Delegate,this._symbolInvalid=new r.Delegate,this._symbolGroupNotPermitted=new r.Delegate,this._chartTypeNotPermitted=new r.Delegate,this._intradaySpreadNotPermitted=new r.Delegate,this._intradayExchangeNotPermitted=new r.Delegate,this._customIntervalNotPermitted=new r.Delegate,this._secondsIntervalNotPermitted=new r.Delegate,this._ticksIntervalNotPermitted=new r.Delegate,this._barReceived=new r.Delegate,this._seriesTimeFrame=new r.Delegate,this._dataUpdated=new r.Delegate,this._unsupportedResolutionRequested=new r.Delegate}destroy(){this._created.destroy(),this._modified.destroy(),this._loading.destroy(),this._completed.destroy(),this._error.destroy(),this._symbolError.destroy(),this._symbolResolved.destroy(),this._seriesError.destroy(),this._symbolInvalid.destroy(),this._symbolNotPermitted.destroy(),this._symbolGroupNotPermitted.destroy(),this._chartTypeNotPermitted.destroy(),this._intradaySpreadNotPermitted.destroy(),this._intradayExchangeNotPermitted.destroy(),this._customIntervalNotPermitted.destroy(),this._secondsIntervalNotPermitted.destroy(),this._ticksIntervalNotPermitted.destroy(),this._barReceived.destroy(),this._seriesTimeFrame.destroy(), this._dataUpdated.destroy(),this._unsupportedResolutionRequested.destroy()}created(){return this._created}modified(){return this._modified}loading(){return this._loading}completed(){return this._completed}error(){return this._error}symbolError(){return this._symbolError}symbolResolved(){return this._symbolResolved}seriesError(){return this._seriesError}symbolInvalid(){return this._symbolInvalid}symbolNotPermitted(){return this._symbolNotPermitted}symbolGroupNotPermitted(){return this._symbolGroupNotPermitted}chartTypeNotPermitted(){return this._chartTypeNotPermitted}intradaySpreadNotPermitted(){return this._intradaySpreadNotPermitted}intradayExchangeNotPermitted(){return this._intradayExchangeNotPermitted}customIntervalNotPermitted(){return this._customIntervalNotPermitted}secondsIntervalNotPermitted(){return this._secondsIntervalNotPermitted}ticksIntervalNotPermitted(){return this._ticksIntervalNotPermitted}barReceived(){return this._barReceived}seriesTimeFrame(){return this._seriesTimeFrame}dataUpdated(){return this._dataUpdated}unsupportedResolutionRequested(){return this._unsupportedResolutionRequested}fireCompleted(e){this._completed.fire(e)}fireCreated(e){this._created.fire(e)}fireModified(){this._modified.fire()}fireLoading(e){this._loading.fire(e)}fireError(){this._error.fire()}fireSymbolError(e){this._symbolError.fire(e),this.fireError()}fireSymbolResolved(e){this._symbolResolved.fire(e)}fireSeriesError(e){this._seriesError.fire(e),this.fireError()}fireSymbolInvalid(){this._symbolInvalid.fire()}fireSymbolNotPermitted(e){this._symbolNotPermitted.fire(e)}fireSymbolGroupNotPermitted(e){this._symbolGroupNotPermitted.fire(e)}fireChartTypeNotPermitted(e){this._chartTypeNotPermitted.fire(e),this.fireError()}fireIntradaySpreadNotPermitted(){this._intradaySpreadNotPermitted.fire(),this.fireError()}fireIntradayExchangeNotPermitted(){this._intradayExchangeNotPermitted.fire(),this.fireError()}fireCustomIntervalNotPermitted(e){this._customIntervalNotPermitted.fire(e),this.fireError()}fireSecondsIntervalNotPermitted(){this._secondsIntervalNotPermitted.fire(),this.fireError()}fireTicksIntervalNotPermitted(){this._ticksIntervalNotPermitted.fire(),this.fireError()}fireBarReceived(e){this._barReceived.fire(e)}fireSeriesTimeFrame(e,t,s,r,i){this._seriesTimeFrame.fire(e,t,s,r,i)}fireDataUpdated(e,t,s,r){this._dataUpdated.fire(e,t,s,r)}fireUnsupportedResolutionRequested(){this._unsupportedResolutionRequested.fire()}}},61625:(e,t,s)=>{function r(e,t,s){return e===t||e===s}s.d(t,{symbolSameAsResolved:()=>r})},501571:(e,t,s)=>{s.d(t,{INVALID_TIME_POINT_INDEX:()=>r,UNPLOTTABLE_TIME_POINT_INDEX:()=>i});const r=-2e6,i=-1e6}}]);