"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[83687,58722],{226722:(t,e,s)=>{s.d(e,{TVXWindowEvents:()=>a});s(466281);var i=s(338619),n=s(49437);const r=(0,i.getLogger)("XWindowEvents");var a;!function(t){const e="tvxwevents.",s={};let i;window.BroadcastChannel?(i=new BroadcastChannel("tvxwevents"),i.addEventListener("message",(function(t){const{data:{event:e,value:i}}=t;s[e]&&s[e].forEach((t=>{t(i)}))})),function(){const t=[],s=performance.now();for(let s=0;s{e(t.newValue)}));n.TVLocalStorage.removeItem(r)})),t.on=function(t,e){s[t]||(s[t]=[]),s[t].push(e)},t.off=function(t,e){if(!s[t])return;const i=s[t].indexOf(e);-1!==i&&(1===s[t].length?delete s[t]:s[t].splice(i,1))},t.emit=function(t,s=Date.now()){try{i?i.postMessage({event:t,value:s}):n.TVLocalStorage.setItem(e+t,s.toString())}catch(t){r.logError(t.message)}}}(a||(a={}))},828473:(t,e,s)=>{s.d(e,{lowerbound:()=>i,upperbound:()=>n});s(650151);function i(t,e,s,i=0,n=t.length){return function(t,e,s,i,n){let r=n-i;for(;0>1,a=i+n;s(t(a),e)?(i=a+1,r-=n+1):r=n}return i}((e=>t[e]),e,s,i,n)}function n(t,e,s,i=0,n=t.length){let r=n-i;for(;0>1,a=i+n;s(e,t[a])?r=n:(i=a+1,r-=n+1)}return i}},643322:(t,e,s)=>{s.d(e,{combine:()=>r});var i=s(375397);function n(t,e,...s){let n=null;const r=(...e)=>t(...e.map((t=>t.value())),null==n?void 0:n.value()),a=n=new i.WatchedValue(r(...s)),o=()=>{e(...s.map((t=>t.value())))&&a.setValue(r(...s))},l=s.map((t=>t.spawn()));for(const t of l)t.subscribe(o);return a.readonly().spawn((()=>{l.forEach((t=>t.destroy())),s.forEach((t=>t.release()))}))}function r(t,...e){return n(t,(()=>!0),...e)}},339709:(t,e,s)=>{s.d(e,{customFormatters:()=>i});const i={dateFormatter:null,timeFormatter:null,tickMarkFormatter:null,priceFormatterFactory:null,studyFormatterFactory:null}},378975:(t,e,s)=>{s.d(e,{Interval:()=>u,ResolutionKind:()=>r});const i=/^(\d*)([TSHDWMR])$/,n=/^(\d+)$/;var r,a;!function(t){t.Ticks="ticks",t.Seconds="seconds",t.Minutes="minutes",t.Days="days",t.Weeks="weeks",t.Months="months",t.Range="range",t.Invalid="invalid"}(r||(r={})),function(t){t.Hours="hours"}(a||(a={}));const o={};o[r.Ticks]=1e3,o[r.Seconds]=1e3,o[r.Minutes]=60*o[r.Seconds],o[r.Days]=1440*o[r.Minutes],o[r.Weeks]=7*o[r.Days];const l={T:r.Ticks,S:r.Seconds,D:r.Days,W:r.Weeks,M:r.Months,R:r.Range},h=new Set([r.Ticks,r.Seconds,r.Minutes]);class u{constructor(t,e){ this._kind=r.Invalid,this._multiplier=0,t!==r.Invalid&&e>0&&(this._kind=t,this._multiplier=e)}kind(){return this._kind}guiKind(){return this.isMinuteHours()?a.Hours:this._kind}multiplier(){return this._multiplier}isValid(){return this.kind()!==r.Invalid&&this.multiplier()>0}isDWM(){return this.isValid()&&!this.isRange()&&!this.isIntraday()&&!this.isTicks()}isIntraday(){const t=h.has(this.kind());return this.isValid()&&t}isSeconds(){return this.kind()===r.Seconds}isMinutes(){return this.kind()===r.Minutes}isMinuteHours(){return this.kind()===r.Minutes&&((t=this.multiplier())>=60&&!(t%60));var t}isDays(){return this.kind()===r.Days}isWeeks(){return this.kind()===r.Weeks}isMonths(){return this.kind()===r.Months}isRange(){return this.kind()===r.Range}isTicks(){return this.kind()===r.Ticks}is1Tick(){return this.isTicks()&&1===this.multiplier()}isTimeBased(){return!this.isRange()}letter(){return this.isValid()&&this.kind()!==r.Minutes?this.kind()[0].toUpperCase():""}value(){return this.isValid()?this.kind()===r.Minutes?this.multiplier()+"":this.multiplier()+this.letter():""}isEqualTo(t){if(!(t instanceof u))throw new Error("Argument is not an Interval");return!(!this.isValid()||!t.isValid())&&(this.kind()===t.kind()&&this.multiplier()===t.multiplier())}inMilliseconds(t=Date.now()){if(!this.isValid()||this.isRange())return NaN;if(this.isMonths()){const e=new Date(t);e.setUTCMonth(e.getUTCMonth()+(this.multiplier()||1));return+e-t}const e=this.multiplier();return o[this.kind()]*e}static isEqual(t,e){return t===e||u.parse(t).isEqualTo(u.parse(e))}static parseExt(t){t=(t+"").toUpperCase().split(",")[0];let e=i.exec(t);return null!==e?"H"===e[2]?{interval:new u(r.Minutes,60*d(e[1])),guiResolutionKind:a.Hours}:{interval:new u(l[e[2]],d(e[1])),guiResolutionKind:l[e[2]]}:(e=n.exec(t),null!==e?{interval:new u(r.Minutes,d(e[1])),guiResolutionKind:r.Minutes}:{interval:new u(r.Invalid,0),guiResolutionKind:r.Invalid})}static parse(t){return u.parseExt(t).interval}static kind(t){return u.parse(t).kind()}static isValid(t){return u.parse(t).isValid()}static isDWM(t){return u.parse(t).isDWM()}static isIntraday(t){return u.parse(t).isIntraday()}static isSeconds(t){return u.parse(t).isSeconds()}static isMinutes(t){return u.parse(t).isMinutes()}static isMinuteHours(t){return u.parse(t).isMinuteHours()}static isDays(t){return u.parse(t).isDays()}static isWeeks(t){return u.parse(t).isWeeks()}static isMonths(t){return u.parse(t).isMonths()}static isRange(t){return u.parse(t).isRange()}static isTicks(t){return u.parse(t).isTicks()}static isTimeBased(t){return u.parse(t).isTimeBased()}static normalize(t){const e=u.parse(t);return e.isValid()?e.value():null}}function d(t){return 0===t.length?1:parseInt(t,10)}},518439:(t,e,s)=>{var i;s.d(e,{PlotRowSearchMode:()=>i}),function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.Exact=0]="Exact",t[t.NearestRight=1]="NearestRight"}(i||(i={}))},979351:(t,e,s)=>{s.d(e,{unpackNonSeriesData:()=>o});var i=s(130551),n=s(650151);function r(t){if(!(0, i.isObject)(t))throw new Error("Graphics commands should be wrapped in an object");if((0,i.hasProperty)(t,"create"),(0,i.hasProperty)(t,"erase")){const e=t.erase;(0,n.assert)(Array.isArray(e),"Collection of erase commands should be array");for(const t of e){if(!(0,i.isObject)(t)||!(0,i.hasProperty)(t,"action"))throw new Error("Command should be an object with 'action' property");(0,n.assert)("all"===t.action||"one"===t.action,"Erase command action should be 'all' or 'one'")}}return t}async function a(t){{const[{inflateZlib:e,inflateRaw:i},{unpackImpl:n}]=await Promise.all(["function"==typeof DecompressionStream?s.e(95465).then(s.bind(s,23536)):Promise.all([s.e(84069),s.e(82170)]).then(s.bind(s,458140)),s.e(95465).then(s.bind(s,532152))]);return n(e,i,t)}}async function o(t){if(""===t)return null;const e=JSON.parse(t);if(!(0,i.isObject)(e)||"function"==typeof e)throw new Error("Non-object content in the non-series envelope");if((0,i.hasProperty)(e,"indexes_replace"))return{indexes_replace:!0};const s={indexes_replace:!1};if((0,i.hasProperty)(e,"offsets")&&(s.offsets=e.offsets),(0,i.hasProperty)(e,"isUpdate")){if("boolean"!=typeof e.isUpdate)throw new Error('Invalid type of "isUpdate" field');s.isUpdate=e.isUpdate}return(0,i.hasProperty)(e,"data")&&(s.data=e.data),(0,i.hasProperty)(e,"graphicsCmds")&&(s.graphicsCmds=r(e.graphicsCmds)),(0,i.hasProperty)(e,"dataCompressed")&&(s.data=await a(e.dataCompressed)),(0,i.hasProperty)(e,"graphicsCmdsCompressed")&&(s.graphicsCmds=r(await a(e.graphicsCmdsCompressed))),s}},55243:(t,e,s)=>{s.d(e,{PlotList:()=>c});var i=s(650151),n=s(828473),r=s(501571),a=s(338619),o=s(518439);const l=(0,a.getLogger)("Chart.PlotList"),h=30;function u(t){return t.index}function d(t){return t.value[0]}class c{constructor(t=null,e=null){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache=new Map,this._rowSearchCacheByIndex=new Map,this._rowSearchCacheByIndexWithoutEmptyValues=new Map,this._rowSearchCacheByTime=new Map,this._rowSearchCacheByTimeWithoutEmptyValues=new Map,this._plotFunctions=t||new Map,this._emptyValuePredicate=e}clear(){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache.clear(),this._invalidateSearchCaches()}first(){return this.size()>0?this._items[this._start]:null}last(){return this.size()>0?this._items[this._end-1]:null}firstIndex(){return this.size()>0?this._indexAt(this._start):null}lastIndex(){return this.size()>0?this._indexAt(this._end-1):null}clone(){const t=this.firstIndex(),e=this.lastIndex();return null===t||null===e?new c:this.range(t,e)}size(){return this._end-this._start}isEmpty(){return 0===this.size()}contains(t){return null!==this.search(t,o.PlotRowSearchMode.Exact)}valueAt(t){const e=this.search(t);return null!==e?e.value:null}add(t,e){if(this._shareRead)return l.logDebug("add: readonly collection modification attempt"),!1;const s={index:t,value:e},i=this._nonCachedSearch(t,o.PlotRowSearchMode.Exact,u);return this._invalidateSearchCaches(),null===i?(this._items.splice(this._lowerbound(t,u),0,s),this._start=0, this._end=this._items.length,!0):(this._items[i]=s,!1)}search(t,e=o.PlotRowSearchMode.Exact,s){return this._searchImpl(t,e,this._rowSearchCacheByIndex,this._rowSearchCacheByIndexWithoutEmptyValues,u,s)}searchByTime(t,e=o.PlotRowSearchMode.Exact,s){return this._searchImpl(t,e,this._rowSearchCacheByTime,this._rowSearchCacheByTimeWithoutEmptyValues,d,s)}fold(t,e){let s=e;for(let e=this._start;e=s;--e){const s=this._indexAt(e),i=this._valueAt(e);if(t(s,i))return{index:s,value:i}}return null}each(t){for(let e=this._start;ethis._start&&(e._start-=1),e}rangeCountback(t,e){if(null===this.firstIndex())return new c;const s=new c(this._plotFunctions,this._emptyValuePredicate);return s._items=this._items,s._end=this._upperbound(t),s._start=Math.max(this._start,s._end-e),s._shareRead=!0,s}rangeIterator(t,e){const s=this._lowerbound(t,u),i=this._upperbound(e);return this._rangeIteratorImpl(s,i)}fullRangeIterator(){return this._rangeIteratorImpl(this._start,this._end)}minMaxOnRangeCached(t,e,s){if(this.isEmpty())return null;let i=null;for(const n of s){i=_(i,this._minMaxOnRangeCachedImpl(t-n.offset,e-n.offset,n.name))}return i}minMaxOnRange(t,e,s){if(this.isEmpty())return null;let i=null;for(const n of s){i=_(i,this._minMaxOnRange(t-n.offset,e-n.offset,n.name))}return i}merge(t){return this._shareRead?(l.logDebug("merge: readonly collection modification attempt"),null):0===t.length?null:this.isEmpty()||t[t.length-1].indexthis._items[this._items.length-1].index?this._append(t):1===t.length&&t[0].index===this._items[this._items.length-1].index?(this._updateLast(t[0]),t[0]):this._merge(t)}addTail(t,e=!1){if(0===t.length)return;let s=0;e&&this._end-this._start>0&&(s=1,this._items[this._end-this._start-1].value=t[0].value);for(let e=s;evoid 0!==t)).sort(((t,e)=>t.index-e.index)),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._start=0,this._end=this._items.length}remove(t){if(this._shareRead)return l.logDebug("remove: readonly collection modification attempt"),null;const e=this._nonCachedSearch(t,o.PlotRowSearchMode.NearestRight,u);if(null===e)return null;const s=this._items.splice(e);return this._end=this._items.length,this._minMaxCache.clear(),this._invalidateSearchCaches(),s.length>0?s[0]:null}state(){const t=this._items.slice(this._start,this._end);return{start:0,end:t.length,data:t}}restoreState(t){t?(this._start=t.start,this._end=t.end,this._shareRead=!1,this._items=t.data,this._minMaxCache.clear(),this._invalidateSearchCaches()):this.clear()}_indexAt(t){return this._items[t].index}_valueAt(t){return this._items[t].value}_length(){return this._items.length}_searchImpl(t,e,s,i,n,r){const a=void 0!==r?s:i,o=void 0!==r?1e4*(e+1)+r:e;let l=a.get(t);if(void 0!==l){const t=l.get(o);if(void 0!==t)return t}const h=this._nonCachedSearch(t,e,n,r);if(null===h)return null;const u={index:this._indexAt(h),value:this._valueAt(h)};return void 0===l&&(l=new Map,a.set(t,l)),l.set(o,u),u}_nonCachedSearch(t,e,s,i){const n=this._lowerbound(t,s),r=n===this._end||t!==s(this._items[n]);if(r&&e!==o.PlotRowSearchMode.Exact)switch(e){case o.PlotRowSearchMode.NearestLeft:return this._searchNearestLeft(n,i);case o.PlotRowSearchMode.NearestRight:return this._searchNearestRight(n,i);default:throw new TypeError("Unknown search mode")}if(void 0===i||r||e===o.PlotRowSearchMode.Exact)return r?null:n;switch(e){case o.PlotRowSearchMode.NearestLeft:return this._nonEmptyNearestLeft(n,i);case o.PlotRowSearchMode.NearestRight:return this._nonEmptyNearestRight(n,i);default:throw new TypeError("Unknown search mode")}}_nonEmptyNearestRight(t,e){const s=(0,i.ensure)(this._emptyValuePredicate),n=(0,i.ensure)(e);for(;t=this._start&&s(this._valueAt(t),n);)t-=1;return te(t)e.index>t),this._start,this._end)}_plotMinMax(t,e,s){let i=null;const n=this._plotFunctions.get(s) ;if(void 0===n)throw new Error(`Plot "${s}" is not registered`);for(let s=t;si.max&&(i.max=t)))}return i}_invalidateCacheForRow(t){const e=Math.floor(t.index/h);this._minMaxCache.forEach((t=>t.delete(e)))}_prepend(t){return(0,i.assert)(!this._shareRead,"collection should not be readonly"),(0,i.assert)(0!==t.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=t.concat(this._items),this._start=0,this._end=this._items.length,t[0]}_append(t){return(0,i.assert)(!this._shareRead,"collection should not be readonly"),(0,i.assert)(0!==t.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=this._items.concat(t),this._start=0,this._end=this._items.length,t[0]}_updateLast(t){(0,i.assert)(!this.isEmpty(),"plot list should not be empty");const e=this._items[this._end-1];(0,i.assert)(e.index===t.index,"last row index should match new row index"),this._invalidateCacheForRow(t),this._invalidateSearchCaches(),this._items[this._end-1]=t}_merge(t){return(0,i.assert)(0!==t.length,"plot rows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=function(t,e){const s=function(t,e){const s=t.length,i=e.length;let n=s+i,r=0,a=0;for(;re[a].index?a++:(r++,a++,n--);return n}(t,e),i=new Array(s);let n=0,r=0;const a=t.length,o=e.length;let l=0;for(;ne[r].index?(i[l]=e[r],r++):(i[l]=e[r],n++,r++),l++;for(;n(s+=1,s>=e?{done:!0,value:void 0}:{done:!1,value:this._items[s]})}}_invalidateSearchCaches(){this._rowSearchCacheByIndex.clear(),this._rowSearchCacheByIndexWithoutEmptyValues.clear(),this._rowSearchCacheByTime.clear(),this._rowSearchCacheByTimeWithoutEmptyValues.clear()}}function _(t,e){if(null===t)return e;if(null===e)return t;return{min:Math.min(t.min,e.min),max:Math.max(t.max,e.max)}}},998418:(t,e,s)=>{s(658843)},848292:(t,e,s)=>{s(998418)},660961:(t,e,s)=>{s(523965),s(203918);s(998418);s(848292)},523965:(t,e,s)=>{s(375397) },203918:(t,e,s)=>{s(375397)},658843:(t,e,s)=>{s(650151),s(942634)},368628:(t,e,s)=>{s.d(e,{SeriesData:()=>c});var i,n=s(650151),r=s(55243),a=s(828473);!function(t){t[t.FromLeft=-1]="FromLeft",t[t.FromRight=1]="FromRight"}(i||(i={}));const o={open:t=>t[1],high:t=>t[2],low:t=>t[3],close:t=>t[4],hl2:t=>(t[2]+t[3])/2,hlc3:t=>(t[2]+t[3]+t[4])/3,ohlc4:t=>(t[1]+t[2]+t[3]+t[4])/4},l=["open","high","low","close","hl2","hlc3","ohlc4"];function h(){const t=new Map;return l.forEach(((e,s)=>{t.set(e,function(t,e,s){const i=o[null!=e?e:t],n=o[t],r=o[null!=s?s:t];return(t,e)=>{switch(e){case 0:return i(t);case 2:return r(t);default:return n(t)}}}(e))})),t}function u(t,e){return null==t[e]}const d=[{barsToMerge:10,forBarspacingLargerThen:.03},{barsToMerge:30,forBarspacingLargerThen:.01},{barsToMerge:100,forBarspacingLargerThen:.003},{barsToMerge:500,forBarspacingLargerThen:0}];class c{constructor(){this._pressedChunks={chunks:new Map,priceSource:"uninitialized"},this.m_bars=new r.PlotList(h(),u),this.m_nsBars=new r.PlotList(h(),u),this._clearPressedChunks()}bars(){return this.m_bars}nsBars(){return this.m_nsBars}pressedChunks(t,e){if(e!==this._pressedChunks.priceSource){this._pressedChunks.priceSource=e;const t=this.m_bars.first();t&&(this._clearPressedChunks(),this._rebuildPressedChunks(t))}const s=(0,n.ensureDefined)(d.find((e=>e.forBarspacingLargerThen<=t)));return(0,n.ensureDefined)(this._pressedChunks.chunks.get(s.barsToMerge))}mergeRegularBars(t){const e=this.m_bars.size(),s=this.m_bars.merge(t);return s&&"uninitialized"!==this._pressedChunks.priceSource&&(e===this.m_bars.size()&&s.index===this.m_bars.lastIndex()?this._updateLatestChunks():this._rebuildPressedChunks(s)),s}size(){return this.m_bars.size()+this.m_nsBars.size()}each(t){this.m_bars.each(t),this.m_nsBars.each(t)}clear(){this.m_bars.clear(),this.m_nsBars.clear(),this.lastProjectionPrice=void 0,this._clearPressedChunks()}clone(){const t=new c;return t.lastProjectionPrice=this.lastProjectionPrice,t.boxSize=this.boxSize,t.reversalAmount=this.reversalAmount,t.m_bars=this.m_bars.clone(),t.m_nsBars=this.m_bars.clone(),t}isEmpty(){return this.m_bars.isEmpty()&&this.m_nsBars.isEmpty()}first(){return this.m_bars.isEmpty()?this.m_nsBars.first():this.m_bars.first()}last(){return this.m_nsBars.isEmpty()?this.m_bars.last():this.m_nsBars.last()}search(t,e,s){return this.nsBars().isEmpty()?this.bars().search(t,e,s):this.bars().isEmpty()||(0,n.ensureNotNull)(this.nsBars().firstIndex())<=t?this.nsBars().search(t,e,s):this.bars().search(t,e,s)}valueAt(t){const e=this.search(t);return null!==e?e.value:null}plotValueToTimePointIndex(t,e,s){if(s===i.FromRight){const s=(s,i)=>{const n=i[e];return null!=n&&t>=n},i=this.m_bars.findLast(s);if(null!==i)return i.index;const n=this.m_nsBars.findLast(s);return null!==n?n.index:this.m_bars.firstIndex()}if(s===i.FromLeft){const s=(s,i)=>{const n=i[e];return null!=n&&t<=n},i=this.m_bars.findFirst(s);if(null!==i)return i.index;const n=this.m_nsBars.findFirst(s);return null!==n?n.index:this.m_bars.lastIndex()} throw new Error("plotValueToTimePointIndex: unsupported search mode")}moveData(t){this.m_bars.move(t),this.m_nsBars.move(t),this.m_bars.size()>0&&this._rebuildPressedChunks((0,n.ensureNotNull)(this.m_bars.first()))}_rebuildPressedChunks(t){const e=this._pressedChunks.priceSource;if("uninitialized"===e)return;const s=t.index,i=o[e],r=(t,e,s)=>{let n=null;for(const r of t){const t=i(r.value);n&&r.index-n.startTime>=s.barsToMerge&&(e.push(n),n=null),n?(n.endTime=r.index,n.high=Math.max(n.high,t),n.low=Math.min(n.low,t),n.close=t):n={startTime:r.index,endTime:r.index,open:t,high:t,low:t,close:t}}n&&e.push(n)};d.forEach((t=>{const e=(0,n.ensureDefined)(this._pressedChunks.chunks.get(t.barsToMerge)),i=(0,a.lowerbound)(e,s,((t,e)=>t.endTime0){const s=e[0].startTime-1,i=(0,n.ensureNotNull)(this.m_bars.firstIndex()),a=this.m_bars.rangeIterator(i,s),o=[];r(a,o,t);const l=o.concat(e);this._pressedChunks.chunks.set(t.barsToMerge,l)}else{const s=(0,n.ensureNotNull)(this.m_bars.lastIndex());e.splice(i);let a=(0,n.ensureNotNull)(this.m_bars.firstIndex());e.length&&(a=e[e.length-1].endTime+1);const o=this.m_bars.rangeIterator(a,s);r(o,e,t)}}))}_updateLatestChunks(){const t=(0,n.ensureNotNull)(this.m_bars.last());d.forEach((e=>{const s=(0,n.ensureDefined)(this._pressedChunks.chunks.get(e.barsToMerge)),i=t.value[4],r=s[s.length-1];r.high=Math.max(r.high,i),r.low=Math.min(r.low,i),r.close=i,r.endTime=t.index}))}_clearPressedChunks(){d.forEach((t=>this._pressedChunks.chunks.set(t.barsToMerge,[])))}}},975179:(t,e,s)=>{s.d(e,{createSeriesFormatter:()=>d,extractSymbolNameFromSymbolInfo:()=>c});s(444372),s(62802),s(638456),s(540519),s(378975);var i=s(735211),n=s(764829),r=s(957365),a=s(142567);s(643322),s(660961);const o=n.enabled("pay_attention_to_ticker_not_symbol"),l=n.enabled("uppercase_instrument_names"),h=n.enabled("charting_library_single_symbol_request"),u=n.enabled("use_ticker_on_symbol_info_update");n.enabled("hide_object_tree_and_price_scale_exchange_label");function d(t,e,s=!1){const{priceScale:n,minMove:o,fractional:l,minMove2:h,variableMinTick:u}=function(t,e="default",s=!1){let i,n,r,a=100,o=1;if("default"===e)null!=t&&(({pricescale:a,minmov:o,minmove2:n,fractional:i}=t),r=t.variable_tick_size||void 0);else{let t=e.split(",");3!==t.length&&(t=["100","1","false"]),a=parseInt(t[0]),o=parseInt(t[1]),i="true"===t[2]}return s&&(o=1),{priceScale:a,minMove:o,fractional:i,minMove2:n,variableMinTick:r,ignoreMinMove:s}}(t,e,s);if(null!=t){const i=t.format;if("default"===e&&"volume"===i)return new r.VolumeFormatter({precision:2});if("percent"===i)return new a.PercentageFormatter({priceScale:n,minMove:o,fractional:l,minMove2:h,variableMinTick:u,ignoreMinMove:s})}return new i.PriceFormatter({priceScale:n,minMove:o,fractional:l,minMove2:h,variableMinTick:u,ignoreMinMove:s})}function c(t,e,s,i){let n=t&&(s&&t.pro_name||t.full_name||t.name);return h&&e?n=e:(u||!i&&o)&&t&&t.ticker&&(n=t.ticker),l&&n&&(n=n.toUpperCase()),n}},501372:(t,e,s)=>{s.d(e,{SeriesDataSource:()=>S}) ;var i=s(650151),n=s(124829),r=s(882782),a=s(378975),o=s(368628),l=s(979351),h=s(124066),u=s(320771),d=s(338619),c=s(975179),_=s(61625);const m=(0,d.getLogger)("Chart.SeriesDataSource");var p;!function(t){t[t.Idle=0]="Idle",t[t.AwaitingConnection=1]="AwaitingConnection",t[t.AwaitingFirstDataUpdate=2]="AwaitingFirstDataUpdate",t[t.Active=3]="Active"}(p||(p={}));let f=1;let g=1;function b(t){return t.startDate?t.endDate||t.count?t.endDate?["from_to",t.startDate,t.endDate]:["bar_count",t.startDate,(0,i.ensure)(t.count)]:["from_to",t.startDate]:t.count||300}function y(t){return(0,n.isString)(t.symbol)?t.symbol:t.symbol.symbol}function v(t,e){(0,n.isString)(t.symbol)?t.symbol=e:t.symbol.symbol=e}class S{constructor(t,e,s,i){this._extSymbol=null,this._lastResolvedSymbol="",this._createSeriesOverriddenParams=0,this._instanceId=null,this._symbolInstanceId=null,this._resolution=null,this._timeFrame=null,this._data=new o.SeriesData,this._dataEvents=new u.SeriesDataEvents,this._status=p.Idle,this._turnaroundCounter=1,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=t,this._turnaroundPrefix=e,this._createSeriesParams=b(null!=s?s:{count:300}),this._timeFrame=i||null,this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged)}modifySeries(t,e,s=null,r=!1,o=null){r&&(m.logNormal("Due to force flag clearing symbol & resolution to force re-requesting data."),this._extSymbol=null,this._resolution=null);const l=y(t),h=!this.symbolSameAsResolved(l);if(h&&(this._lastResolvedSymbol=""),this._extSymbol&&!h){v(t,y(this._extSymbol))}const u=this._extSymbol,d=this._resolution;if(this._extSymbol=t,this._resolution=e,null===this._instanceId)return void(this._timeFrame=s);const c=!(0,n.deepEquals)(u,t)[0];c&&v(this._extSymbol,l);const _=null===d||!a.Interval.isEqual(d,e);(c||_||null!==s)&&(this._timeFrame=null,(c||_)&&this._turnaroundCounter++,c&&this._resolveSymbol(),this._gateway.modifySeries(this._instanceId,this.turnaround(),(0,i.ensureNotNull)(this._symbolInstanceId),this._resolution,o,s,this._onMessage.bind(this)),this._dataEvents.fireModified())}requestMoreData(t){null!==this._instanceId&&this._gateway.requestMoreData(this._instanceId,t,this._onMessage.bind(this))}requestMoreTickmarks(t){null!==this._instanceId&&this._gateway.requestMoreTickmarks(this._instanceId,t,this._onMessage.bind(this))}setFutureTickmarksMode(t){null!==this._instanceId&&this._gateway.setFutureTickmarksMode(t)}isStarted(){return this._status!==p.Idle}isActive(){return this._status===p.Active}resolution(){return this._resolution}start(){this.isStarted()?m.logNormal("start: data source is already started, nothing to do"):((0,i.assert)(null!==this._extSymbol,"symbol must be set before start"),(0,i.assert)(null!==this._resolution,"resolution must be set before start"), this._gateway.isConnected().value()?this._createSeries():this._changeStatusTo(p.AwaitingConnection))}stop(){this.isStarted()?(null!==this._instanceId&&(this._gateway.removeSeries(this._instanceId),this._instanceId=null),this._symbolInstanceId=null,this._changeStatusTo(p.Idle)):m.logNormal("stop: data source is already stopped, nothing to do")}instanceId(){return this._instanceId}data(){return this._data}setData(t){this._data=t}clearData(){this.isStarted()?this._enqueueUpdate((()=>this._clearDataImpl())):this._clearDataImpl()}dataEvents(){return this._dataEvents}turnaround(){return`${this._turnaroundPrefix}${this._turnaroundCounter}`}symbolInstanceId(){return this._symbolInstanceId}symbol(){return this._extSymbol}moveData(t){this._enqueueUpdate((()=>this._data.moveData(t)))}setInitialRequestOptions(t){this._createSeriesOverriddenParams=b(t)}symbolSameAsResolved(t){return null!==this._extSymbol&&(0,_.symbolSameAsResolved)(t,y(this._extSymbol),this._lastResolvedSymbol)}resolvedSymbol(){return null===this._extSymbol?null:y(this._extSymbol)}_resolveSymbol(){null!==this._extSymbol&&(this._symbolInstanceId=this._gateway.resolveSymbol("sds_sym_"+f++,(0,r.encodeExtendedSymbolOrGetSimpleSymbolString)(this._extSymbol),this._onMessage.bind(this)))}_clearDataImpl(){this._data.clear()}_changeStatusTo(t){(0,i.assert)(this._status!==t,"Source and destination status should be distinct"),m.logNormal(`Status changed from ${p[this._status]} to ${p[t]}`),this._status=t}_createSeries(){(0,i.assert)(this._status!==p.Active,'Status should not be "Active" when creating a study'),this._instanceId="sds_"+g++,this._resolveSymbol();const t=this._createSeriesOverriddenParams||this._createSeriesParams;this._createSeriesOverriddenParams&&(this._createSeriesOverriddenParams=0),this._gateway.createSeries(this._instanceId,this.turnaround(),(0,i.ensureNotNull)(this._symbolInstanceId),(0,i.ensureNotNull)(this._resolution),t,this._timeFrame,this._onMessage.bind(this)),this._timeFrame=null,this._changeStatusTo(p.AwaitingFirstDataUpdate),this._dataEvents.fireCreated(this._instanceId)}_onGatewayIsConnectedChanged(t){t?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===p.AwaitingConnection&&this._createSeries()}_onGatewayDisconnected(){this._status!==p.Idle&&this._status!==p.AwaitingConnection&&(this._instanceId=null,this._changeStatusTo(p.AwaitingConnection)),this._turnaroundCounter=1}_onMessage(t){this._enqueueUpdate((()=>this._onMessageImpl(t)))}async _onMessageImpl(t){switch(t.method){case"symbol_resolved":{const[e,s]=t.params;if(e!==this._symbolInstanceId){null!==this._symbolInstanceId&&m.logNormal(`Resolve for old symbol, expected: ${this._symbolInstanceId}, actual ${t.params[0]}`);break}this._onSymbolResolved(s);break}case"symbol_error":if(t.params[0]!==this._symbolInstanceId){null!==this._symbolInstanceId&&m.logNormal(`Symbol error for old symbol, expected: ${this._symbolInstanceId}, actual ${t.params[0]}`);break}this._onSymbolError(t);break;case"series_timeframe":{const[e,s,i,n,r,a,o]=t.params ;if(!this._checkTurnaround(e,s)){m.logNormal(`Time frame for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e} (${s})`);break}this._onSeriesTimeFrame(i,n,r,a,o);break}case"series_error":{const[e,s]=t.params;if(!this._checkTurnaround(e,s)){m.logNormal(`Series error for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e} (${s})`);break}this._onSeriesError(t.params[2]);break}case"series_loading":{const[e,s]=t.params;if(!this._checkTurnaround(e,s))break;this._onSeriesLoading(t.time);break}case"series_completed":{const[e,s,i,n]=t.params;if(!this._checkTurnaround(e,i)){m.logNormal(`Series completed for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e} (${i})`);break}this._onSeriesCompleted(s,t.time,n);break}case"data_update":if(!this._checkTurnaround(t.params.customId,t.params.turnaround)){m.logNormal(`Data update for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t.params.customId} (${t.params.turnaround})`);break}await this._onDataUpdate(t.params.plots,t.params.nonseries,t.params.lastBar);break;case"clear_data":if(t.params.turnaround!==this.turnaround()){m.logNormal(`Clear data for old data, expected: ${this.turnaround()}, actual ${t.params.turnaround}`);break}this._clearDataImpl(),this._dataEvents.fireDataUpdated(void 0,!1,null,!1)}}_onSeriesError(t){let e,s;if("string"==typeof t)s={error:t},e=t;else if(s=t,t.ctx){const s={};Object.entries(t.ctx).forEach((([t,e])=>{s[t]=e.toString()})),e=t.error.format(s)}else e=t.error;if(e.startsWith("study_not_auth:")){const t=e.split(":",2)[1].split("@",2)[0];if(["BarSetRenko","BarSetPriceBreak","BarSetKagi","BarSetPnF"].includes(t))this._dataEvents.fireChartTypeNotPermitted(t);else if("BarSetSpread"===t)this._dataEvents.fireIntradaySpreadNotPermitted();else if("BarSetRange"===t){const t=`${(0,i.ensureNotNull)(this._extSymbol).inputs.range}R`;this._dataEvents.fireCustomIntervalNotPermitted(t)}}else{if(e.startsWith("unsupported"))return void this._dataEvents.fireUnsupportedResolutionRequested();"resolution_not_entitled"===e?this._dataEvents.fireIntradayExchangeNotPermitted():"custom_resolution"===e?this._dataEvents.fireCustomIntervalNotPermitted((0,i.ensureNotNull)(this._resolution)):"seconds_not_entitled"===e?this._dataEvents.fireSecondsIntervalNotPermitted():"ticks_not_entitled"===e&&this._dataEvents.fireTicksIntervalNotPermitted()}this._dataEvents.fireSeriesError(s)}_onSeriesTimeFrame(t,e,s,i,n){this._dataEvents.fireSeriesTimeFrame(t,e,s,null==i||i,n)}_onSymbolError(t){if(t.params[1]===h.permissionDenied)switch(t.params[2]){case h.SymbolErrorPermissionDeniedReason.Symbol:this._dataEvents.fireSymbolNotPermitted(t.params[3]);break;case h.SymbolErrorPermissionDeniedReason.GroupPermission:this._dataEvents.fireSymbolGroupNotPermitted(t.params[3]);break;default:this._dataEvents.fireSymbolNotPermitted(t.params[2])}else t.params[1]===h.invalidSymbol&&this._dataEvents.fireSymbolInvalid();this._dataEvents.fireSymbolError(t.params[1])}_onSymbolResolved(t){ this._lastResolvedSymbol=(0,i.ensureNotNull)((0,c.extractSymbolNameFromSymbolInfo)(t,"")),this._dataEvents.fireSymbolResolved(t)}async _onDataUpdate(t,e,s){this._onDataUnpacked(t,s,await async function(t){if(void 0===t)return{projectionPlots:[],boxSize:null};if(""===t.d||"nochange"===t.indexes)return null;const e=await(0,l.unpackNonSeriesData)(t.d);if(null===e||e.indexes_replace)return null;const s=t.indexes,{bars:i,price:n,boxSize:r,reversalAmount:a}=e.data,o=(i||[]).map((t=>{let e;return"factor"in t?e=t.factor:"additionalPrice"in t&&(e=t.additionalPrice),{index:s[t.time],value:[0,t.open,t.high,t.low,t.close,t.volume,e]}}));return{lastPrice:n,projectionPlots:o,reversalAmount:a,boxSize:r}}(e))}_enqueueUpdate(t){return this._ongoingDataUpdate=this._ongoingDataUpdate.then(t,t),this._ongoingDataUpdate}_onDataUnpacked(t,e,s){if(this._status===p.Idle)return;this._status===p.AwaitingFirstDataUpdate&&(this._changeStatusTo(p.Active),this._clearDataImpl());const i=this._data.bars().size(),n=this._data.bars().firstIndex(),r=this._data.mergeRegularBars(t);null!==s&&(this._data.nsBars().clear(),this._data.nsBars().merge(s.projectionPlots),this._data.lastProjectionPrice=s.lastPrice,null!==s.boxSize&&(this._data.boxSize=s.boxSize),this._data.reversalAmount=s.reversalAmount);const a=null===n,o=a||null!==r&&r.index