47 lines
138 KiB
JavaScript
47 lines
138 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1485],{87795:e=>{const t=55296,s=127995,i=127999,r=[776,2359,2359,2367,2367,2984,3007,3021,3633,3635,3648,3657,4352,4449,4520];function n(e){if("string"!=typeof e)throw new Error("string cannot be undefined or null");const t=[];let s=0,i=0;for(;s<e.length;)i+=o(s+i,e),c(e[s+i])&&i++,l(e[s+i])&&i++,h(e[s+i])&&i++,u(e[s+i])?i++:(t.push(e.substring(s,s+i)),s+=i,i=0);return t}function o(e,r){const n=r[e];if(!function(e){return e&&p(e[0].charCodeAt(0),t,56319)}(n)||e===r.length-1)return 1;const o=n+r[e+1];let l=r.substring(e+2,e+5);return a(o)&&a(l)||function(e){return p(d(e),s,i)}(l)?4:2}function a(e){return p(d(e),127462,127487)}function l(e){return"string"==typeof e&&p(e.charCodeAt(0),65024,65039)}function h(e){return"string"==typeof e&&p(e.charCodeAt(0),8400,8447)}function c(e){return"string"==typeof e&&-1!==r.indexOf(e.charCodeAt(0))}function u(e){return"string"==typeof e&&8205===e.charCodeAt(0)}function d(e){return(e.charCodeAt(0)-t<<10)+(e.charCodeAt(1)-56320)+65536}function p(e,t,s){return e>=t&&e<=s}e.exports=n,e.exports.substr=function(e,t,s){const i=n(e);if(void 0===t)return e;if(t>=i.length)return"";const r=i.length-t;let o=t+(void 0===s?r:s);return o>t+r&&(o=void 0),i.slice(t,o).join("")}},63002:(e,t,s)=>{s.d(t,{HHistBasedValuesProvider:()=>f});var i=s(50335),r=s(50151),n=s(49483),o=s(5471),a=s(78861),l=s(56265),h=s(99481),c=s(11946),u=s(53660);function d(e,t="",s=""){return{id:t,index:e,orderIndex:e,title:s,value:"",visible:!1}}const p=n.CheckMobile.any(),_=(0,l.getVolumeFormatter)();class f{constructor(e,t,s=!1){this._emptyValues=[],this._study=e,this._model=t,this._emptyTitles=s,void 0!==this._study.metaInfo().graphics.hhists&&this._emptyValues.push(d(0),d(1),d(2))}getItems(){return this._emptyValues}getValues(e){const t=this._emptyValues.map((e=>({...e})));t.forEach((e=>{e.visible=this._study.isVisible(),e.value=u.notAvailable}));const s=this._study.properties().childs().inputs.childs().volume.value();switch(s){case h.HHistVolumeMode.UpDown:this._emptyTitles||(t[0].title="Up",t[1].title="Down",t[2].title="Total");break;case h.HHistVolumeMode.Total:this._emptyTitles||(t[0].title="Total"),t[1].visible=!1,t[2].visible=!1;break;case h.HHistVolumeMode.Delta:this._emptyTitles||(t[0].title="Delta",t[1].title="Max(Up, Down)",t[2].title="Total")}const n=this._study.priceScale(),a=this._model.timeScale();if(null===n||n.isEmpty()||a.isEmpty()||this._hideValues())return t;if(null===e||!isFinite(e)){const s=this._study.data().last();if(null===s)return t;e=s.index}const l=this._model.crosshairSource(),c=l.price;if(!isFinite(l.y)&&null===(e=function(e,t){const s=e.visibleBarsStrictRange()?.lastBar();if(!s)return null;const i=t.data().search(s,o.PlotRowSearchMode.NearestLeft);return i?i.index:null}(this._model.timeScale(),this._model.mainSeries())))return t;const d=function(e,t,s,i){if(0===e.size)return null;if(!s){const e=(0,r.ensureNotNull)(i.data().valueAt(t));s=i.barFunction()(e)}const n=function(e,t){let s=null
|
||
;return e.forEach(((e,i)=>{null!==i&&i<=t&&(null===s||i>s)&&(s=i)})),s}(e,t);if(null===n)return null;const o=e.get(n);if(!o||0===o.size)return null;return function(e,t){let s=null;return e.forEach((e=>{e.priceLow<=t&&t<e.priceHigh&&(s=e)})),s}(o,s)}(this._study.graphics().hhistsByTimePointIndex(),e,c,this._model.mainSeries());if(null===d)return t.forEach((e=>{e.value="0"})),t;const p=this._study.metaInfo().graphics.hhists;if(void 0===p)return t;if(void 0===p[d.styleId])return t;const f=this._study.properties().childs().graphics.childs().hhists?.childs()[d.styleId]?.childs(),m=e=>(0,i.isNumber)(e)?_.format(e):"";if(s!==h.HHistVolumeMode.Delta){if(d.rate.forEach(((e,s)=>{t[s].value=m(e),t[s].color=(0,r.ensureDefined)(f).colors[s].value()})),s===h.HHistVolumeMode.UpDown){const e=d.rate[0]+d.rate[1];t[2].value=m(e),t[2].color=(0,r.ensureDefined)(f).valuesColor.value()}}else{const e=d.rate[0]>d.rate[1]?0:1,s=(0,r.ensureDefined)(f).colors[e].value(),i=d.rate[0]+d.rate[1];[2*d.rate[e]-i,d.rate[e],i].forEach(((e,i)=>{t[i].value=m(e),t[i].color=s}))}return t}_hideValues(){return p&&(null===this._model.crosshairSource().pane||(0,c.isLineToolName)(a.tool.value())||null!==this._model.lineBeingEdited())}}},70954:(e,t,s)=>{s.d(t,{StudyBaseWindowView:()=>n});var i=s(40137),r=s(36313);class n extends i.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new i.DataWindowItem(e.id,e.title,"")))}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}study(){return this._study}_updateImpl(){this._header=this._study.title(r.TitleDisplayTarget.DataWindow),this._title=this._study.title(r.TitleDisplayTarget.DataWindow,!1);const e=this._valueProvider.getValues(this._currentIndex());for(let t=0;t<e.length;++t){const s=e[t],i=this._items[t];i.setValue(s.value),i.setVisible(s.visible),i.setColor(s.color),i.setTitle(s.title)}}_currentIndex(){const e=this._model.crosshairSource().appliedIndex();return isNaN(e)?null:e}}},27909:(e,t,s)=>{s.d(t,{StudyChartFloatingTooltipView:()=>n});var i=s(87465),r=s(36313);class n{constructor(e,t){this._items=[],this._invalidated=!0,this._study=e,this._model=t}destroy(){}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}update(e){this._invalidated=!0}_updateImpl(){const e=this._study.chartFloatingTooltipValuesProvider(),t=this._model.crosshairSource().appliedIndex(),s=e.getValues(t),n=this._study.titleInParts(r.TitleDisplayTarget.StatusLine),o=n[0];let a="";if(n.length>1){const e=n[1];e.length>0&&(a=e.join(" "))}this._items=s.filter(i.notUndefined).filter((e=>e.visible)).map(((e,t)=>({titleText:0===t?o:"",titleInputs:0===t?a:"",value:e.value,valueColor:e.color})))}}},13212:(e,t,s)=>{s.d(t,{StudyDataWindowView:()=>a});var i=s(70954),r=s(71320),n=s(63002);class o{constructor(e,t){this._study=e,this._model=t,
|
||
this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),s=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,2);for(const e of t)e.visible=e.visible&&s(e.id);return t}_createValuesProvider(e,t){return this._hhistBasedStudy?new n.HHistBasedValuesProvider(e,t):new r.StudyValuesProvider(e,t)}}class a extends i.StudyBaseWindowView{canShowItems(){const e=this._model.paneForSource(this._study);return!!e?.maximized().value()||this._model.panes().every((e=>!e.maximized().value()))}_createValuesProvider(e,t){return new o(e,t)}}},12965:(e,t,s)=>{s.d(t,{StudyStatusProvider:()=>n});var i=s(11542),r=(s(86252),s(35990));i.t(null,void 0,s(24077));class n extends r.StudyStatusProviderBase{sourceStatusText(){this._source.status();return super.sourceStatusText()}}},71320:(e,t,s)=>{s.d(t,{StudyValuesProvider:()=>v});var i=s(50335),r=s(49483),n=s(52859),o=s(37103),a=s(5471),l=s(11946),h=s(78861),c=s(4359),u=s(41425),d=s(63903),p=s(50151),_=s(53660),f=s(36313);const m=r.CheckMobile.any(),y=o.enabled("hide_last_na_study_output"),g=o.enabled("always_show_legend_values_on_mobile");class v{constructor(e,t,s,i=!0){this._emptyValues=[],this._colorProviders=new Map,this._study=e,this._model=t,this._searchNearestLeft=i,this._studyMetaInfo=this._study.metaInfo(),this._studyProperties=this._study.properties().childs(),this._isFundamental=!1;const r=this._studyMetaInfo.plots;if(!r)return;let n=0;r.forEach(((e,t)=>{if((0,c.isPlotWithTechnicalValues)(e))return;const i=e.id;this._emptyValues.push(function(e,t,s="",i=""){return{id:s,index:e,orderIndex:t,title:i,value:"",visible:!1}}(t,n++,i,s?"":this._study.guiPlotName(f.TitleDisplayTarget.StatusLine,i)));const r=(0,c.isOhlcPlot)(e)?e.target:i;this._colorProviders.set(r,(0,u.createStudyPlotColorProvider)(this._studyMetaInfo,this._study.properties(),r))}))}getItems(){return this._emptyValues}getPlotColor(e,t){const s=t[e+1];if(!(0,i.isNumber)(s))return"";const r=s>0;let n;const o=this._studyMetaInfo.plots[e];let a=o.id;const l=this._studyProperties;if((0,c.isOhlcPlot)(o))a=o.target||a,n=(0,p.ensureDefined)(l.ohlcPlots.childs()[a].childs().color).value();else if((0,c.isArrowsPlot)(o)){const e=(0,p.ensureDefined)(l.styles.childs()[a]);n=r?e.childs().colorup.value():e.childs().colordown.value()}else n=(0,p.ensureDefined)(l.styles.childs()[a]?.child("color")).value();let h=n;const u=this._colorProviders.get(a),d=u&&u.getPlotPointStyle(t);return d&&((0,c.isArrowsPlot)(o)?(r&&void 0!==d.colors[5]&&(h=d.colors[5]),r||void 0===d.colors[6]||(h=d.colors[6])):void 0!==d.colors[0]&&(h=d.colors[0])),"transparent"===h&&(h=n),h}getValues(e){const t=this._emptyValues.map((e=>({...e})));let s=null;const r=this._study.data().lastIndex(),o=this._studyProperties;if(null!==r){const e=this._searchNearestLeft?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact;for(const i of t){const t=o.styles.childs()[i.id]?.childs().display.value();if(0===t)continue
|
||
;const n=this._study.nearestIndex(r,e,i.index+1);if(void 0===n)continue;const a=n+this._study.offset(i.id);s=null!==s?Math.max(a,s):a}}(null===e||null!==s&&e>s)&&(e=s);const l=this._hideValues(),h=this._study.isVisible()&&!l?_.notAvailable:"";for(const e of t)e.value=h;if(l)return t;y&&t.length&&(t[t.length-1].value="");const u=this._study.priceScale();if(!this._study.isVisible()||null===e||null===u||u.isEmpty()||this._model.timeScale().isEmpty())return t;const f={};for(const s of t){const t=s.id,l=(0,d.getPriceValueFormatterForStudy)(this._study,t),h=(0,p.ensureDefined)(o.styles.childs()[t]),u=h.childs().display.value();if(s.visible=0!==u,!s.visible)continue;const _=h.hasChild("plottype")?h.child("plottype")?.value():null,m=this._searchNearestLeft&&this._isFundamental&&(_===c.LineStudyPlotStyle.StepLine||_===c.LineStudyPlotStyle.StepLineWithDiamonds),y=s.index,g=e-this._study.offset(t),v=m||null!==r&&g>r?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact,S=this._study.nearestIndex(g,v);if(void 0===S)continue;let b=f[t];if(void 0===b&&(b=this._study.getMinFirstBarIndexForPlot(t),Number.isFinite(b)&&(f[t]=b)),b>S)continue;const P=this._study.data().last(),w=this._study.data().valueAt(S)||(null!==P?P.value:null);if(null===w)continue;const I=w[y+1];(0,i.isNumber)(I)&&(s.value=l(I),s.color=(0,n.resetTransparency)(this.getPlotColor(y,w)))}return t}_hideValues(){return g?(0,l.isLineToolName)(h.tool.value())||null!==this._model.lineBeingEdited():m&&(null===this._model.crosshairSource().pane||(0,l.isLineToolName)(h.tool.value())||null!==this._model.lineBeingEdited())}}},11485:(e,t,s)=>{s.r(t),s.d(t,{StudiesChunkName:()=>Yt,Study:()=>us,emptyPrecalculatedAutoscaleInfo:()=>qt,studyFormatter:()=>hs});var i=s(50279),r=s(90054),n=s(16738),o=s(15943);const a=e=>e instanceof Date,l=e=>null!=e&&"object"==typeof e,h=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),c=e=>l(e)&&(e=>0===Object.keys(e).length)(e),u=(e,t)=>{if(e===t)return{};if(!l(e)||!l(t))return t;const s=Object.keys(e).reduce(((e,s)=>(h(t,s)||(e[s]=void 0),e)),Object.create(null));return a(e)||a(t)?e.valueOf()==t.valueOf()?{}:t:Object.keys(t).reduce(((s,i)=>{if(!h(e,i))return s[i]=t[i],s;const r=u(e[i],t[i]);return!c(r)||a(r)||!c(e[i])&&c(t[i])?(s[i]=r,s):s}),s)},d=u;var p=s(50151),_=s(87465),f=s(9343),m=s(11542),y=s(12217),g=s(62312);function v(e){const{name:t,group:s}=e;return t.length>0?`${s?`${s}.`:""}${t}`:void 0}var S=s(10341),b=s(22613),P=s(62773),w=s(48096),I=s(52859),x=s(82130),C=s(29806),V=s(67135),M=(s(2088),s(24062)),T=s(72187),A=s(19844),R=s(45530),O=s(5471),D=s(18330),B=s(70954),N=s(40472),F=s(71320),k=s(63002);class E{constructor(e,t,s,i){this._study=e,this._model=t,this._showStudyValues=i??t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t,s)}getItems(){return this._valuesProvider.getItems()}getValues(e){
|
||
const t=this._valuesProvider.getValues(e),s=this._study.properties(),i=this._showStudyValues.value()&&s.childs().showLegendValues.value(),r=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,8);for(const e of t)e.visible=e.visible&&i&&r(e.id);return t}_createValuesProvider(e,t,s){return this._hhistBasedStudy?new k.HHistBasedValuesProvider(e,t,s):new F.StudyValuesProvider(e,t,s)}}var L=s(4359);class H extends B.StudyBaseWindowView{constructor(e,t){super(e,t),this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,(()=>this.update((0,N.sourceChangeEvent)(e.id()))));const s=this._study.properties();s.childs().showLegendValues.subscribe(this,(()=>this.update((0,N.sourceChangeEvent)(e.id()))));const i=this._study.metaInfo().plots,r=new Set;i.forEach((t=>{if((0,L.isOhlcPlot)(t)){const i=t.target;if(r.has(i))return;r.add(i),s.childs().ohlcPlots.childs()[i].childs().display.subscribe(this,(()=>this.update((0,N.sourceChangeEvent)(e.id()))))}else(0,L.isPlotSupportDisplay)(t)&&s.childs().styles.childs()[t.id]?.childs().display.subscribe(this,(()=>this.update((0,N.sourceChangeEvent)(e.id()))))}))}areValuesVisible(){return this._showStudyValues.value()}additional(){return null}destroy(){this._showStudyValues.unsubscribeAll(this);const e=this._study.properties();e.childs().showLegendValues.unsubscribeAll(this);const t=this._study.metaInfo().plots,s=new Set;t.forEach((t=>{if((0,L.isOhlcPlot)(t)){const i=t.target;if(s.has(i))return;s.add(i),e.childs().ohlcPlots.childs()[i].childs().display.unsubscribeAll(this)}else(0,L.isPlotSupportDisplay)(t)&&e.childs().styles.childs()[t.id]?.childs().display.unsubscribeAll(this)}))}_createValuesProvider(e,t){return new E(e,t)}}var W=s(78861),z=s(80671),U=s(60911),j=s(87163),G=s(98155),$=s(12965);class K{constructor(e,t,s){this._study=e,this._model=t,this._valuesProvider=new F.StudyValuesProvider(e,t,s)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),s=e=>this._study.isPlotVisibleAt(e,8)||this._study.isPlotVisibleAt(e,1);for(const e of t)e.visible=e.visible&&s(e.id);return t}}var Y=s(36313),X=s(67455);function q(e,t){return e.studyId.localeCompare(t.studyId)}function J(e){const t=new Set,s=[];return e.forEach((e=>{t.has(e.studyId)||(t.add(e.studyId),s.push(e))})),s}function Z(e){const t=e.model().mainSeries();return{studyId:(0,p.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>Z(e)))}}var Q=s(69422),ee=s(37103),te=s(94602),se=s(10307);class ie extends se.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){}_drawBackgroundImpl(e){const{context:t,horizontalPixelRatio:s,bitmapSize:i}=e,r=this._data;for(let e=0;e<r.items.length;++e){const n=r.items[e];if(null==n.color)continue;t.fillStyle=n.color;const o=Math.round(n.left*s)+1,a=Math.round(n.right*s);t.fillRect(o,0,a-o+1,i.height)}}}var re=s(41425),ne=s(17631)
|
||
;class oe extends ne.StudyForceOverlayPlotView{constructor(e,t,s,i){super(t,s,i),this._items=[],this._invalidated=!0,this._isMarkersEnabled=ee.enabled("source_selection_markers"),this._study=e;const r=this._study.metaInfo().plots;for(let e=0;e<r.length;e++){const t=r[e];t.id===this._plotName&&(this._plotIndex=e,(0,p.assert)((0,L.isBgColorerPlot)(t),"Plot '"+this._plotName+"' is not a background colorer!"))}this._colorProvider=(0,re.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i)}items(){return this._items}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){if(1&~(0,p.ensureDefined)(this._study.properties().childs().styles.childs()[this._plotName]).childs().display.value())return null;if(!this._scalesReady())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={items:this._items},t=new te.CompositeRenderer;return t.append(new ie(e)),t}_scalesReady(){const e=this._model.timeScale(),t=this._priceScale();return e&&!e.isEmpty()&&null!==t&&!t.isEmpty()}_getTranspValue(){const e=(0,p.ensureDefined)(this._study.properties().childs().styles.childs()[this._plotName]).childs();let t=0;return e.transparency&&(t=e.transparency.value(),t=(0,_.isNumber)(t)?t:40),t}_updateImpl(){this._items=[],(0,p.assert)(this._scalesReady(),"Scales must be ready!");const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return;const t=this._getTranspValue();let s=(0,p.ensureDefined)(this._series.nearestIndex(e.firstBar(),O.PlotRowSearchMode.NearestRight)),i=(0,p.ensureDefined)(this._series.nearestIndex(e.lastBar(),O.PlotRowSearchMode.NearestLeft));const r=this._study.offset(this._plotName);r>0?(s-=r,i+=r):(s+=r,i-=r);const n=this._study.getMinFirstBarIndexForPlot(this._plotName);if(n>i)return;s=Math.max(n,s);const o=this._study.data();for(const e of o.rangeIterator(s,i)){let s=e.index;const i=e.value;s+=r;const n={timePointIndex:Math.floor(s),left:NaN,center:NaN,right:NaN};let o=(0,_.isNumber)(t)?t:50;o=Math.min(o,100),o=Math.max(o,0);const a=this._colorProvider.getPlotPointStyle(i);void 0!==a.colors[1]&&(n.color=(0,I.generateColor)((0,p.ensureDefined)(a.colors[1]),o)),this._items.push(n)}this._model.timeScale().fillBarBorders(this._items)}}var ae,le=s(89323),he=s(45801),ce=s(51752),ue=s(77914),de=s(13173),pe=s(52746),_e=s(26705),fe=s(10555),me=s(6453),ye=s(50335),ge=s(50605),ve=s(2383),Se=s(45720),be=s(49251),Pe=s(27714),we=s(33350);!function(e){e.Left="left",e.Center="center",e.Right="right"}(ae||(ae={}));const Ie=(0,we.createDisconnectedCanvas)(document,(0,Pe.size)({width:0,height:0}),1);class xe{constructor(e,t,s,i,r,n="center",o=0){this._lines=e.split(/[^\S\r\n]*(?:\r\n|\r|\n)/),this._font=function(e,t,s,i){return(0,be.makeFont)(i,s,`${e?"bold ":""}${t?"italic ":""}`)}(t,s,i,r),this._fontSize=r,this._verticalPadding=~~(r/6),this._textAlign=n,this._lineSpacing=o;const a=(0,p.ensureNotNull)(Ie.getContext("2d"));a.font=this._font,a.textBaseline="top";let l=0;for(let e=0;e<this._lines.length;++e){const t=this._lines[e],s=a.measureText(t).width;l=Math.max(l,s)}
|
||
this.textImageWidth=l+1,this.textImageHeight=this._lines.length*r+(this._lines.length-1)*this._lineSpacing+this._verticalPadding}paintTo(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e;s.save();const n=t.location;s.translate(Math.round(function(e,t,s){let i=e;switch(t){case"left":break;case"right":i-=s;break;case"center":i-=s/2}return Math.round(i)}(n.x,n.horzAlign,this.textImageWidth)*i),Math.round(function(e,t,s){let i=e;switch(t){case"top":break;case"bottom":i-=s;break;case"middle":i-=s/2}return Math.round(i)}(n.y,n.vertAlign,this.textImageHeight)*r));const o=t.style;let a;switch(s.textBaseline="top",s.font=this._font,s.lineJoin="round",s.fillStyle=o.fillStyle,o.strokeStyle&&(s.strokeStyle=o.strokeStyle),o.lineWidth&&(s.lineWidth=o.lineWidth),this._textAlign){case"left":a=0,s.textAlign="left";break;case"right":a=this.textImageWidth-1,s.textAlign="right";break;default:a=this.textImageWidth/2,s.textAlign="center"}let l=this._verticalPadding;(0,we.drawScaled)(s,i,r,(()=>{for(const e of this._lines)o.strokeStyle&&s.strokeText(e,a,l),s.fillText(e,a,l),l+=this._fontSize,l+=this._lineSpacing})),s.restore()}}class Ce extends Se.AbstractMapContainer{constructor(e){super(),this._maxSize=e,this._keysQueue=[]}get(e){const{fontSize:t,text:s,align:i,font:r,bold:n,italic:o,lineSpacing:a=0}=e;if(!s||!t||!i)return null;const l=(0,be.makeFont)(t,r,o?"italic":"",n?"bold":""),h=(0,Se.getDefault3)(this._map,a,i,l,new Map);let c=h.get(s);return void 0!==c||(this._size>=this._maxSize?this._deleteFirstKey():++this._size,this._keysQueue.push([l,i,a,s]),c=new xe(s,n,o,r,t,i,a),h.set(s,c)),c}_deleteFirstKey(){const e=this._keysQueue.shift(),[t,s,i,r]=e,n=(0,p.ensureDefined)(this._map.get(i)),o=(0,p.ensureDefined)(n.get(s)),a=(0,p.ensureDefined)(o.get(t));a.delete(r),0===a.size&&o.delete(t),0===o.size&&n.delete(s),0===n.size&&this._map.delete(i)}}var Ve,Me=s(84617),Te=s(49483);!function(e){e.Transparent="rgba(0, 0, 0, 0)"}(Ve||(Ve={}));class Ae extends se.BitmapCoordinatesPaneRenderer{constructor(e,t={skipRenderingOptimizations:!1}){super(),this._items=[],this._barSpacing=0,this._vertOffset=0,this._textCache=t.textCache||new Ce(5e3),this._drawOperation=t.skipRenderingOptimizations?this._drawWithoutOptimizations.bind(this):this._drawWithOptimizations.bind(this),null!==e&&this.setData(e)}hitTest(e){const t=ve.HitTarget.Regular;let s=null;for(const i of this._items){if(!i)continue;const r=this._calcBoundingBox(i);if(r&&(0,me.pointInBox)(e,r)){const e={tooltip:this._getTooltip(i,r)};s=new ve.HitTestResult(t,e)}}return s}setData(e){if(this._height=void 0!==e.height?e.height:e.width,this._width=void 0!==e.width?e.width:e.height,this._color=e.color,this._borderColor=e.borderColor,this._vertOffset=e.vertOffset||0,e.text&&(this._text=e.text,this._fontSize=e.fontSize,this._lineSpacing=e.lineSpacing,this._textColor=e.textColor,this._textAlign=e.textAlign||"center"),void 0!==e.items&&void 0!==e.barSpacing){const t=e.visibleItemsRange?.startItemIndex??0,s=e.visibleItemsRange?.endItemIndex??e.items.length
|
||
;this.setItems(s>t?e.items.slice(t,s):[],e.barSpacing)}}setItems(e,t){this._setBaseData(e,t)}_drawImpl(e){this._preDrawInit(),this._drawOperation(e)}_calcBoundingBox(e){const t=e.vertOffset,s=this._getTextCache(e);if(!s)return;const i=s.textImageWidth,r=s.textImageHeight,n=i/2,o=e.y+t+e.textVertOffset,a=t>0?0:-r,l=t>0?r:0,h=new fe.Point(e.center-n,o+a),c=new fe.Point(e.center+n,o+l);return(0,fe.box)(h,c)}_unionBox(e,t){const s=Math.min(e.min.x,t.min.x),i=Math.max(e.max.x,t.max.x),r=Math.min(e.min.y,t.min.y),n=Math.max(e.max.y,t.max.y),o=new fe.Point(s,r),a=new fe.Point(i,n);return(0,fe.box)(o,a)}_getTooltip(e,t){if(e.tooltip)return{content:{type:"text",data:e.tooltip},tooltipDelay:200,extendMargin:!0,rect:{x:t.min.x,y:t.min.y,w:Math.abs(t.max.x-t.min.x),h:Math.abs(t.max.y-t.min.y)}}}_setBaseData(e,t){this._items.length=0,this._barSpacing=t;for(const t of e){if((0,ye.isNaN)(t.y))continue;const e=void 0===t.width?(0,p.ensureDefined)(this._width):t.width,s=void 0===t.height?(0,p.ensureDefined)(this._height):t.height,i=void 0===t.vertOffset?this._vertOffset:t.vertOffset,r=i>0?s:-s;this._items.push({width:e,height:s,vertOffset:i,textVertOffset:r,shapeWidth:0,shapeHeight:0,stepX:0,stepY:0,...t})}}_drawItemText(e,t){const s=this._getTextCache(t);if(null===s)return;const i=t.center,r=t.vertOffset,n=t.y+r+t.textVertOffset;let o;o=t.style&&void 0!==t.style.textColor?t.style.textColor:this._textColor;const a={style:{fillStyle:o},location:{x:i,y:n,horzAlign:ge.HorizontalAlign.Center,vertAlign:r>0?ge.VerticalAlign.Top:ge.VerticalAlign.Bottom}};s.paintTo(e,a)}_drawWithOptimizations(e){let t,s,i=null,r=!1;for(const n of this._items)(0,ye.isNaN)(n.y)||(n.style&&void 0!==n.style.color?(t=n.style.color||"rgba(0, 0, 0, 0)",s=n.style.borderColor||"rgba(0, 0, 0, 0)"):(t=this._color,s=this._borderColor),(i!==t||Te.isSafari)&&(i=t,r&&this._endPath(e),this._startPath(e,t,s)),this._drawItemShape(e,n),r=!0);r&&this._endPath(e);for(const t of this._items)(0,ye.isNaN)(t.y)||this._drawItemText(e,t)}_drawWithoutOptimizations(e){let t,s;for(const i of this._items){if((0,ye.isNaN)(i.y))continue;const r=(0,p.ensureDefined)(i.style);t=r.color||"rgba(0, 0, 0, 0)",s=r.borderColor||"rgba(0, 0, 0, 0)",this._startPath(e,t,s),this._drawItemShape(e,i),this._endPath(e),this._drawItemText(e,i)}}_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e;(0,we.drawScaled)(s,i,r,(()=>this._drawItemShapeUsingCSSPixels(s,t)))}_drawItemShapeUsingCSSPixels(e,t){}_preDrawInit(){}_startPath(e,t,s){}_endPath(e){}_getTextCache(e){const t=e.text||this._text,s=e.fontSize||this._fontSize,i=e.lineSpacing??this._lineSpacing,r=e.textAlign||this._textAlign,n=e.font??Me.CHART_FONT_FAMILY,o=e.bold??!1,a=e.italic??!1;return this._textCache.get({text:t,bold:o,italic:a,font:n,fontSize:s,lineSpacing:i,align:r})}}class Re extends Ae{_startPath(e,t,s){const i=e.context;i.beginPath(),i.lineWidth=this._lineWidth(e),i.lineCap="butt",i.strokeStyle=t}_endPath(e){e.context.stroke()}_lineWidth(e){return Math.max(1,Math.floor(2*e.horizontalPixelRatio))}}
|
||
class Oe extends Ae{_startPath(e,t,s){const i=e.context;i.beginPath(),i.lineWidth=this._lineWidth(e),i.lineCap="butt",i.fillStyle=t,i.strokeStyle=s}_endPath(e){const t=e.context;t.fill(),t.stroke()}_lineWidth(e){return Math.max(1,Math.floor(e.horizontalPixelRatio))}}class De extends Oe{constructor(){super(...arguments),this._sign=0,this._thinArrow=!1,this._thinArrowLineWidth=0,this._headHeight=0,this._arrowWidth=0}setItems(e,t){this._setBaseData(e,t)}_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=this._lineWidth(e)%2?.5:0,o=this._sign,a=this._arrowWidth,l=this._headHeight,h=Math.abs(t.height),c=Math.round(t.center*i)+n,u=t.vertOffset,d=Math.round((t.y+u+o*h/2)*r)+n,p=(0,ue.ceiledEven)(a*i),_=p/2,f=Math.round(h*r),m=Math.round(l*r);s.translate(c,d),this._thinArrow?(s.moveTo(0,0),s.lineTo(-_,-_*o),s.moveTo(0,0),s.lineTo(_,-_*o),s.moveTo(0,0),s.lineTo(0,-f*o),s.moveTo(-_,-f*o),s.lineTo(_,-f*o)):(s.moveTo(0,0),f<m?(s.lineTo(p,-f*o),s.lineTo(-p,-f*o)):(s.lineTo(p,-m*o),s.lineTo(_,-m*o),s.lineTo(_,-f*o),s.lineTo(-_,-f*o),s.lineTo(-_,-m*o),s.lineTo(-p,-m*o)),s.lineTo(0,0)),s.translate(-c,-d)}_preDrawInit(){const e=this._calculateWidth();this._arrowWidth=e,this._sign=this._isUp()?-1:1,this._thinArrow=e<4,this._thinArrowLineWidth=Math.max(e/2,1),this._headHeight=Math.round(e)}_startPath(e,t,s){const i=e.context;i.beginPath(),i.fillStyle=t,i.strokeStyle=s,i.lineWidth=this._lineWidth(e)}_lineWidth(e){return this._thinArrow?this._thinArrowLineWidth:super._lineWidth(e)}_calcBoundingBox(e){const t=e.vertOffset,s=this._sign,i=this._arrowWidth,r=this._headHeight,n=Math.abs(e.height),o=e.center-i,a=o+2*i,l=e.y+t+s*Math.round(n/2),h=l+(-n-r)*s,c=new fe.Point(o,l),u=new fe.Point(a,h);let d=(0,fe.box)(c,u);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}_calculateWidth(){return Math.round(this._barSpacing/4)}}const Be=2*Math.PI;class Ne extends Oe{setItems(e,t){this._setBaseData(e,t);for(const e of this._items){if(e.fontSize){const t=e.fontSize;e.stepX=Math.round(t/1.5),e.stepY=Math.round(t/2)-1}else{const t=e.height;e.stepX=Math.round(t/2*.65)+.5,e.stepY=e.stepX}e.vertOffset=this._calcVertOffset(e);const t=this._getTextCache(e);if(null===t){e.shapeWidth=2*e.stepX,e.shapeHeight=2.5*e.stepY;continue}const s=t.textImageWidth,i=t.textImageHeight;e.shapeWidth=s+2*e.stepX,e.shapeHeight=i+2*e.stepY,e.vertOffset=this._calcVertOffset(e),e.textHorizOffset=this._getHorizontalTextOffset(e),e.textVertOffset=this._getVerticalTextOffset(e)}}_calcVertOffset(e){return e.vertOffset}_drawCorner(e,t,s,i){const{context:r,horizontalPixelRatio:n}=e,o=Math.max(1,Math.floor(2*n));r.lineTo(t-o*i.prevPointSignX,s-o*i.prevPointSignY),r.arcTo(t,s,t+o*i.nextPointSignX,s+o*i.nextPointSignY,o)}_getArrowSize(e){return e.stepX}_getHorizontalTextOffset(e){return 0}_getVerticalTextOffset(e){return 0}_hasText(e){return Boolean(e.text)||Boolean(this._text)}_drawItemText(e,t){const s=this._getTextCache(t);if(null===s)return
|
||
;const i=t.textHorizOffset||0,r=t.center+i,n=t.vertOffset,o=t.y+n+t.textVertOffset,a=t.style?.textColor||this._textColor,l={style:{fillStyle:(0,p.ensureDefined)(a)},location:{x:r,y:Math.floor(o),horzAlign:ge.HorizontalAlign.Center,vertAlign:ge.VerticalAlign.Middle}};s.paintTo(e,l)}}class Fe{constructor(e,t,s,i){this.prevPointSignX=e,this.prevPointSignY=t,this.nextPointSignX=s,this.nextPointSignY=i}}var ke;!function(e){e.rightUp=new Fe(1,0,0,1),e.rightDown=new Fe(0,1,-1,0),e.leftDown=new Fe(-1,0,0,-1),e.leftUp=new Fe(0,-1,1,0)}(ke||(ke={}));class Ee extends Oe{_calcBoundingBox(e){const t=e.width,s=e.height,i=t/2,r=Math.round(s/3),n=e.center,o=e.vertOffset-2*r,a=e.y+o,l=n-i,h=n+i,c=a,u=a+s,d=new fe.Point(l,c),p=new fe.Point(h,u);let _=(0,fe.box)(d,p);const f=super._calcBoundingBox(e);return f&&(_=this._unionBox(_,f)),_}}var Le=s(41028);const He=new Map;He.set("PaneRendererArrowUp",class extends De{_isUp(){return!0}}),He.set("PaneRendererArrowDown",class extends De{_isUp(){return!1}}),He.set("PaneRendererCircleShape",class extends Oe{_drawItemShapeUsingCSSPixels(e,t){const s=Math.max(t.width,t.height)/2,i=t.center,r=t.vertOffset,n=t.y+r;e.moveTo(i+s,n),e.arc(i,n,s,0,Be,!1)}_calcBoundingBox(e){const t=Math.max(e.width,e.height)/2,s=e.center,i=e.vertOffset,r=e.y+i,n=s-t,o=s+t,a=r-t,l=r+t,h=new fe.Point(n,a),c=new fe.Point(o,l);let u=(0,fe.box)(h,c);const d=super._calcBoundingBox(e);return d&&(u=this._unionBox(u,d)),u}}),He.set("PaneRendererCrossShape",class extends Re{_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=t.width,o=t.height,a=t.center-n/2,l=t.vertOffset,h=t.y-o/2+l,c=this._lineWidth(e),u=c%2?.5:0,d=Math.round(a*i);let p=Math.round((a+n)*i);(p-d)%2!=c%2&&(p+=1);const _=Math.floor((d+p)/2)+u,f=Math.round(h*r);let m=Math.round((h+o)*r);(m-f)%2!=c%2&&(m+=1);const y=Math.floor((f+m)/2)+u;s.moveTo(_,f),s.lineTo(_,m),s.moveTo(d,y),s.lineTo(p,y)}_calcBoundingBox(e){const t=e.width,s=e.height,i=e.center-t/2,r=e.vertOffset,n=e.y-s/2+r,o=i,a=i+t,l=n,h=n+s,c=new fe.Point(o,l),u=new fe.Point(a,h);let d=(0,fe.box)(c,u);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}),He.set("PaneRendererDiamond",class extends Oe{_drawItemShapeUsingCSSPixels(e,t){const s=Math.round(t.height/2),i=t.center,r=t.vertOffset,n=t.y+r;e.moveTo(i,n-s),e.lineTo(i+s,n),e.lineTo(i,n+s),e.lineTo(i-s,n),e.lineTo(i,n-s)}_calcBoundingBox(e){const t=Math.round(e.height/2),s=e.center,i=e.vertOffset,r=e.y+i,n=s-t,o=s+t,a=r-t,l=r+t,h=new fe.Point(n,a),c=new fe.Point(o,l);let u=(0,fe.box)(h,c);const d=super._calcBoundingBox(e);return d&&(u=this._unionBox(u,d)),u}}),He.set("PaneRendererFlagShape",class extends Oe{_drawItemShapeUsingCSSPixels(e,t){const s=t.width,i=t.height,r=i/2,n=(s-3)/3,o=t.center-s/2,a=t.vertOffset,l=t.y-r+a;e.moveTo(o,l),e.lineTo(o+3,l),e.bezierCurveTo(o+n,l-n,o+2*n,l+n,o+s,l),e.lineTo(o+s,l+r),e.bezierCurveTo(o+s-n,l+r+n,o+s-2*n,l+r-n,o+3,l+r),e.lineTo(o+3,l+i),e.lineTo(o,l+i),e.lineTo(o,l)}_calcBoundingBox(e){
|
||
const t=e.width,s=e.height,i=s/2,r=e.center-t/2,n=e.vertOffset,o=e.y-i+n,a=r,l=r+t,h=o,c=o+s,u=new fe.Point(a,h),d=new fe.Point(l,c);let p=(0,fe.box)(u,d);const _=super._calcBoundingBox(e);return _&&(p=this._unionBox(p,_)),p}}),He.set("PaneRendererLabelUp",class extends Ne{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,s=e.center+e.shapeWidth/2,i=e.y+e.vertOffset,r=e.y+e.shapeHeight+e.vertOffset,n=new fe.Point(t,i),o=new fe.Point(s,r);return(0,fe.box)(n,o)}_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=this._lineWidth(e)%2?.5:0,o=Math.max(1,Math.floor(i))%2?.5:0,a=this._getArrowSize(t);let l=Math.round(a*i);(o+l)%1!=n%1&&(l+=.5);let h=Math.round(t.shapeWidth/2*i);(o+h)%1!=n%1&&(h+=.5);const c=Math.round(t.center*i)+o,u=Math.round((t.y+t.vertOffset)*r)+n,d=c-l,p=Math.round((t.y+t.vertOffset+a)*r)+n,_=c+l,f=c+h,m=Math.round((t.y+t.vertOffset+a+t.shapeHeight)*r)+n,y=c-h;s.moveTo(d,p),s.lineTo(c,u),s.lineTo(_,p),t.shapeWidth<=2*a?(s.lineTo(f,p),this._drawCorner(e,f,m,ke.rightDown),this._drawCorner(e,y,m,ke.leftDown),s.lineTo(y,p)):(this._drawCorner(e,f,p,ke.rightUp),this._drawCorner(e,f,m,ke.rightDown),this._drawCorner(e,y,m,ke.leftDown),this._drawCorner(e,y,p,ke.leftUp)),s.lineTo(d,p)}_getVerticalTextOffset(e){return e.shapeHeight/2+this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)>=0?e.vertOffset:e.vertOffset-e.shapeHeight}}),He.set("PaneRendererLabelDown",class extends Ne{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,s=e.center+e.shapeWidth/2,i=e.y-e.shapeHeight+e.vertOffset,r=e.y+e.vertOffset,n=new fe.Point(t,i),o=new fe.Point(s,r);return(0,fe.box)(n,o)}_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=this._lineWidth(e)%2?.5:0,o=Math.max(1,Math.floor(i))%2?.5:0,a=this._getArrowSize(t);let l=Math.round(a*i);(o+l)%1!=n%1&&(l+=.5);let h=Math.round(t.shapeWidth/2*i);(o+h)%1!=n%1&&(h+=.5);const c=Math.round(t.center*i)+o,u=Math.round((t.y+t.vertOffset)*r)+n,d=c+l,p=Math.round((t.y+t.vertOffset-a)*r)+n,_=c-l,f=c+h,m=Math.round((t.y+t.vertOffset-t.shapeHeight-a)*r)+n,y=c-h;s.moveTo(d,p),s.lineTo(c,u),s.lineTo(_,p),t.shapeWidth<=2*a?(s.lineTo(y,p),this._drawCorner(e,y,m,ke.leftUp),this._drawCorner(e,f,m,ke.rightUp),s.lineTo(f,p)):(this._drawCorner(e,y,p,ke.leftDown),this._drawCorner(e,y,m,ke.leftUp),this._drawCorner(e,f,m,ke.rightUp),this._drawCorner(e,f,p,ke.rightDown)),s.lineTo(d,p)}_getVerticalTextOffset(e){return-e.shapeHeight/2-this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)<=0?e.vertOffset:e.vertOffset+e.shapeHeight}}),He.set("PaneRendererSquare",class extends Oe{_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=Math.max(1,Math.floor(i))%2?.5:0,o=this._lineWidth(e)%2?.5:0;let a=Math.round(t.height/2*r);(n+a)%1!=o%1&&(a+=.5);const l=Math.round(t.center*i)+n,h=Math.round((t.y+t.vertOffset)*r)+n,c=l-a,u=h-a,d=l+a,p=h+a;s.rect(c,u,d-c,p-u)}_calcBoundingBox(e){
|
||
const t=e.height,s=Math.round(t/2),i=e.center-s,r=e.vertOffset,n=e.y+r-s,o=i,a=i+t,l=n,h=n+t,c=new fe.Point(o,l),u=new fe.Point(a,h);let d=(0,fe.box)(c,u);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}),He.set("PaneRendererTriangleApexUp",class extends Ee{_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=t.width,o=t.height,a=Math.round(o/3),l=t.vertOffset-2*a,h=this._lineWidth(e)%2?.5:0,c=Math.max(1,Math.floor(i)),u=c%2?.5:0;let d=Math.round(n*i);d%2!=c%2&&(d+=1);const p=Math.round(t.center*i)+u,_=Math.round((t.y+l)*r),f=p+d/2,m=Math.round((t.y+l+o)*r)+h,y=p-d/2;s.moveTo(p,_),s.lineTo(f,m),s.lineTo(y,m),s.lineTo(p,_)}}),He.set("PaneRendererTriangleApexDown",class extends Ee{_drawItemShape(e,t){const{context:s,horizontalPixelRatio:i,verticalPixelRatio:r}=e,n=t.width,o=t.height,a=Math.round(o/3),l=t.vertOffset-a,h=this._lineWidth(e)%2?.5:0,c=Math.max(1,Math.floor(i)),u=c%2?.5:0;let d=Math.round(n*i);d%2!=c%2&&(d+=1);const p=Math.round(t.center*i)+u,_=Math.round((t.y+l)*r)+h,f=p+d/2,m=Math.round((t.y+l+o)*r),y=p-d/2;s.moveTo(y,_),s.lineTo(f,_),s.lineTo(p,m),s.lineTo(y,_)}}),He.set("PaneRendererXCross",class extends Re{_drawItemShapeUsingCSSPixels(e,t){const s=t.width,i=t.height,r=t.center-s/2,n=t.vertOffset,o=t.y-i/2+n;e.moveTo(r,o),e.lineTo(r+s,o+i),e.moveTo(r,o+i),e.lineTo(r+s,o)}_calcBoundingBox(e){const t=e.width,s=e.height,i=e.center-t/2,r=e.vertOffset,n=e.y-s/2+r,o=i,a=i+t,l=n,h=n+s,c=new fe.Point(o,l),u=new fe.Point(a,h);let d=(0,fe.box)(c,u);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}});class We extends Le.StudyPaneViewInplaceUpdatable{constructor(e,t,s,i){super(t,s,i),this._renderer=null,this._shapesRenderer=null,this._selectionRenderer=null,this._isMarkersEnabled=ee.enabled("source_selection_markers"),this._study=e;const r=e.metaInfo().plots;for(let e=0;e<r.length;e++)if(r[e].id===this._plotName){this._plotIndex=e;break}this._plotStyleInfo=(0,p.ensureDefined)(e.metaInfo().styles?.[this._plotName]),this._colorProvider=(0,re.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i),this._selectionIndexer=new de.SelectionIndexes(s.timeScale())}items(){return this._items}renderer(){return this._isPlotVisible()&&this._scalesReady()?(this._makeSureRendererIsValid(),this._renderer):null}_isPlotVisible(){return this._study.isPlotVisibleAt(this._plotName,1)}_scalesReady(){const e=this._model.timeScale(),t=this._priceScale();return e&&null!==t&&!e.isEmpty()&&!t.isEmpty()}_updateImplFull(e){if(this._dataInvalidated?.clearData&&(this._items=[],this._renderer=null),!this._scalesReady())return!1;const t=this._model.timeScale(),s=this._priceScale(),i=t.visibleBarsStrictRange();if(null===i||null===s)return!1;const r=this._study.plots().plottableRange(!1);if(0===r.size())return!1;const n=this._study.offset(this._plotName),o=this._study.firstValue(void 0,this.isForceOverlay());if(null===o)return!1;this._updateAdditionalPrices(s,o)
|
||
;const{hiPlot:a,loPlot:l}=this._hiLoPlots(),h=this._preallocateItems(r,((e,t)=>this._createItem(e,t??null,a,l,n)));let c=this._series.nearestIndex(i.firstBar(),O.PlotRowSearchMode.NearestRight),u=this._series.nearestIndex(i.lastBar(),O.PlotRowSearchMode.NearestLeft);if(void 0===c||void 0===u)return!1;n>0?(c-=n,u+=n):(c+=n,u-=n);const d=this._study.getMinFirstBarIndexForPlot(this._plotName);if(d>u)return!0;c=Math.max(d,c);const _=this._getTranspValue(),f=this._study.properties().childs().styles.childs()[this._plotName].childs(),m=f.color.value(),g=f.textColor?f.textColor.value():void 0,v=m,S=m,b=void 0===g?void 0:g,P=(0,p.ensureNotNull)(this._plotIndex),w=(0,_e.createEmptyStyle)(),I=h??(0,p.ensureNotNull)(r.firstIndex()),x=r.rangeIterator(I,(0,p.ensureNotNull)(r.lastIndex())+1);let C=(0,y.lowerbound)(this._items,I+n,((e,t)=>e.timePointIndex<t));for(const e of x){const t=e.value,s=t[P+1];if(null==s){C++;continue}const i=this._items[C];if(!isNaN(i.origPrices.price)){if(this._colorProvider.isColorDefined()){i.style={color:v,borderColor:S,textColor:b};const e=this._colorProvider.getPlotPointStyle(t,w);this._fillItemWithPointStyle(i,e,_)}}C++}return this._updateImplLight(),!0}_fillItemWithPointStyle(e,t,s){const i=(0,p.ensureDefined)(e.style);if(void 0!==t.colors[0]){i.color=(0,I.generateColor)((0,p.ensureDefined)(t.colors[0]),s);const e=s>9?s-10:0;i.borderColor=(0,I.generateColor)(i.color,e)}void 0!==t.colors[2]&&(i.textColor=(0,I.generateColor)((0,p.ensureDefined)(t.colors[2]),s))}_updateRenderer(e,t){this._makeSureRendererIsValid();const s=this._model.timeScale(),i={},r=this._getTranspValue(),n=s.barSpacing(),o=this._calculateShapeHeight(n),a=this._study.properties().childs().styles.childs()[this._plotName].childs(),l=a.location.value(),h=this._calculateVerticalOffset(l,o+o/2);i.barSpacing=n,i.items=this._items,i.color=(0,I.generateColor)(a.color.value(),r),i.height=o,i.vertOffset=h,i.visibleItemsRange={startItemIndex:e,endItemIndex:t};const c=a.plottype.value(),u=ce.plotShapesData[c],d=new te.CompositeRenderer;u&&(this._shapesRenderer?this._shapesRenderer.setData(i):(this._shapesRenderer=this._createRenderer(u.paneRendererClass,i),d.append(this._shapesRenderer))),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=h,d.append(new he.SelectionRenderer(this._selectionData))),this._renderer=d}_createRenderer(e,t){const s=He.get(e);return new((0,p.ensureDefined)(s))(t)}_getSeriesVal(e,t){const s=(0,pe.barFunction)(e),i=this._series.data().valueAt(t);return null===i?null:s(i)}_getTranspValue(){let e=0;const t=this._study.properties().childs();t.transparency&&(e=t.transparency.value(),e=(0,_.isNumber)(e)?e:50);const s=t.styles.childs()[this._plotName].childs();return s.transparency&&(e=s.transparency.value(),e=(0,_.isNumber)(e)?e:50),(0,ue.clamp)(e,0,100)}_createItem(e,t,s,i,r){const n=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),o={origPrices:{price:NaN},timePointIndex:e+r}
|
||
;if((null===t||0===t)&&n!==D.MarkLocation.Absolute)return o;if(null==t)return o;let a=NaN;switch(n){case D.MarkLocation.AboveBar:{const t=this._getLocationPrice(e,s,r);if(null===t)return o;a=t;break}case D.MarkLocation.BelowBar:{const t=this._getLocationPrice(e,i,r);if(null===t)return o;a=t;break}case D.MarkLocation.Absolute:a=(0,p.ensureNotNull)(t);break;case D.MarkLocation.Top:case D.MarkLocation.Bottom:a=0;break;default:throw new Error("Bad value: "+n)}return{y:NaN,origPrices:{price:a},timePointIndex:e+r}}_dependsOnSeriesData(){const e=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();return e===D.MarkLocation.AboveBar||e===D.MarkLocation.BelowBar}_getValueForUpdating(e){const t=e.value[this._plotIndex+1];if(null==t)return null;const s=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();if(0===t&&s!==D.MarkLocation.Absolute)return null;const i=this._study.offset(this._plotName),{hiPlot:r,loPlot:n}=this._hiLoPlots();switch(s){case D.MarkLocation.AboveBar:return this._getLocationPrice(e.index,r,i);case D.MarkLocation.BelowBar:return this._getLocationPrice(e.index,n,i)}return super._getValueForUpdating(e)}_convertItemsToCoordinates(e,t,s,i){for(let e=s;e<i;e++){const t=this._items[e];t.y=t.origPrices.price}this._model.timeScale().fillBarBorders(this._items);const r=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),n=e.height()*e.topMargin(),o=e.height()*(1-e.bottomMargin()),a=e.isInverted(),l=a?o:n,h=a?n:o,c=e=>{for(let t=s;t<i;t++)isNaN(this._items[t].y)||(this._items[t].y=e)};switch(r){case D.MarkLocation.Top:c(l);break;case D.MarkLocation.Bottom:c(h);break;default:e.pointsArrayToCoordinates(this._items,t,{startItemIndex:s,endItemIndex:i})}}_calculateVerticalOffset(e,t){let s=0;switch(e){case D.MarkLocation.AboveBar:case D.MarkLocation.Bottom:s=-t;break;case D.MarkLocation.BelowBar:case D.MarkLocation.Top:s=t}return(0,p.ensureNotNull)(this._priceScale()).isInverted()&&(s*=-1),s}_calculateShapeHeight(e,t){let s=e;switch(t){case L.PlotSymbolSize.Tiny:s=.3*e;break;case L.PlotSymbolSize.Small:s=.6*e;break;case L.PlotSymbolSize.Normal:s=e;break;case L.PlotSymbolSize.Large:s=1.5*e;break;case L.PlotSymbolSize.Huge:s=2*e}return"number"==typeof t&&t>0&&(s=t),s}_hiLoPlots(){let e,t;let s=null;switch(this._series.properties().childs().style.value()){case 2:s="lineStyle";break;case 14:s="lineWithMarkersStyle";break;case 15:s="steplineStyle";break;case 3:s="areaStyle"}return s?(e=this._series.properties().childs()[s].childs().priceSource.value(),t=e):(e="high",t="low"),{hiPlot:e,loPlot:t}}_getLocationPrice(e,t,s){const i=Math.min(e+s,(0,p.ensureNotNull)(this._series.data().last()).index);return this._getSeriesVal(t,i)}}class ze extends We{_updateRenderer(e,t){const s=this._study.properties().childs().styles.childs()[this._plotName].childs(),i=this._model.timeScale(),r={},n=this._getTranspValue(),o=i.barSpacing();let a
|
||
;a=this._plotStyleInfo.size?this._calculateShapeHeight(25,this._plotStyleInfo.size):Math.round(o/2),a=Math.max(a,1);const l=s.location.value(),h=(0,I.generateColor)(s.color.value(),n),c=n>19?n-10:0,u=this._calculateVerticalOffset(l,Math.round(1.5*a));r.barSpacing=o,r.items=this.items(),r.color=h,r.borderColor=(0,I.generateColor)(s.color.value(),c),r.height=a,r.vertOffset=u,r.visibleItemsRange={startItemIndex:e,endItemIndex:t};const d=s.plottype.value(),p=ce.plotShapesData[d],_=this._plotStyleInfo.text;if(void 0!==_&&""!==_.trim()){let e=_.replace(/\\n/gm,"\n");e=(0,le.cleanButAmpersand)(e,!0),r.text=e,r.fontSize=12;const t=s.textColor?s.textColor.value():void 0;r.textColor=t?(0,I.generateColor)(t,n):h}if(this._renderer&&this._shapesRenderer&&this._selectionRenderer)this._shapesRenderer.setData(r),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?(this._selectionData.vertOffset=u,this._selectionRenderer.setData(this._selectionData)):this._selectionRenderer.setData(null);else{const e=new te.CompositeRenderer;this._shapesRenderer=super._createRenderer(p.paneRendererClass,r),e.append(this._shapesRenderer),this._selectionRenderer=new he.SelectionRenderer(this._selectionData??void 0),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?this._selectionData.vertOffset=u:this._selectionRenderer.setData(null),e.append(this._selectionRenderer),this._renderer=e}}}var Ue,je=s(87795),Ge=s.n(je),$e=s(4539),Ke=s(57658);!function(e){e[e.SimplifiedPaintingMaxFontSize=4]="SimplifiedPaintingMaxFontSize"}(Ue||(Ue={}));class Ye extends Ae{constructor(e,t){super(null,t),this._textWidthCache=new Ke.TextWidthCache,this._fontSizeEnsured=0,this._font="",this._ch="",null!==e&&this.setData(e)}setData(e){super.setData(e),this._fontSizeEnsured=(0,p.ensureDefined)(this._height),this._font=(0,be.makeFont)(this._fontSizeEnsured,e.fontFamily||Me.CHART_FONT_FAMILY);const t=e.char.slice(0,40);this._ch=Ge()(t)[0]||" "}hitTest(e){const t=(0,$e.interactionTolerance)().series+this._fontSizeEnsured/2;for(const s of this._items){if(new fe.Point(s.center,s.y+s.vertOffset).subtract(e).length()<=t)return new ve.HitTestResult(ve.HitTarget.Regular)}return null}_drawItemShape(e,t){const s=t.center,i=t.vertOffset>0?1:-1,r=Math.trunc(this._fontSizeEnsured/6),n=t.y+t.vertOffset-i*Math.round(this._fontSizeEnsured/2)+(i>0?r:-this._fontSizeEnsured);let o;o=t.style&&void 0!==t.style.color?t.style.color:this._color;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:h}=e;a.font!==this._font&&(a.font=this._font);const c=this._textWidthCache.measureText(a,this._ch);if(this._fontSizeEnsured<=4/l){a.save();const e=Math.max(1,Math.floor(l));let i=Math.max(1,Math.floor(c*l));i%2!=e%2&&(i+=i>1?-1:1);const r=Math.round(n*h)+(t.vertOffset>=0?0:-i);return a.fillStyle=o,a.fillRect(Math.round(s*l)+(l%2?.5:0)-i/2,r,i,i),void a.restore()}(0,we.drawScaled)(a,l,h,(()=>{a.fillStyle=o,a.textAlign="center",a.textBaseline="top",a.fillText(this._ch,s,n)}))}_startPath(e,t,s){}_endPath(e){}}
|
||
class Xe extends We{constructor(){super(...arguments),this._charRenderer=new Ye(null)}_updateRenderer(e,t){const s=this._getTranspValue(),i=this._model.timeScale().barSpacing();let r;const n=this._study.properties().childs().styles.childs()[this._plotName].childs();r=this._plotStyleInfo.size?this._calculateShapeHeight(50,this._plotStyleInfo.size):Math.round(i);const o=n.location.value(),a=(0,I.generateColor)(n.color.value(),s),l=this._calculateVerticalOffset(o,r),h={items:this.items(),barSpacing:i,char:(0,p.ensureDefined)(n.char?.value()??this._plotStyleInfo.char),height:r,vertOffset:l,color:a,visibleItemsRange:{startItemIndex:e,endItemIndex:t}},c=this._plotStyleInfo.text;if(void 0!==c&&""!==c.trim()){let e=c.replace(/\\n/gm,"\n");e=(0,le.cleanButAmpersand)(e,!0),h.text=e,h.fontSize=12;const t=n.textColor?n.textColor.value():void 0;h.textColor=t?(0,I.generateColor)(t,s):a}this._charRenderer.setData(h);const u=new te.CompositeRenderer;u.append(this._charRenderer),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=l,u.append(new he.SelectionRenderer(this._selectionData))),this._renderer=u}}var qe=s(24377);class Je{constructor(e,t,s,i,r){this.left=NaN,this.right=NaN,this.height=NaN,this.center=e,this.y=t,this.origHeight=s,this.isUp=i,this.origPrices=r,this.timePointIndex=e,this.style={}}}function Ze(e){return Math.round(e/4)}function Qe(e){return Math.round(e/2)}class et extends se.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=this._data,s=Qe(t.barSpacing),i=Math.round(s/2),r=Math.round(s),n=Ze(t.barSpacing),o=t.visibleItemsRange?.startItemIndex??0,a=t.visibleItemsRange?.endItemIndex??t.items.length;if(o>=a)return null;for(const s of t.items.slice(o,a)){if(!s)continue;if(!Number.isFinite(s.center)||!Number.isFinite(s.y))continue;const t=Math.abs(s.height),o=s.isUp?-1:1,a=t+r,l=s.y-o*n,h=l-o*a,c=s.center-i,u=s.center+i;if(c<e.x&&e.x<u&&(s.isUp?l<e.y&&e.y<h:h<e.y&&e.y<l))return new ve.HitTestResult(ve.HitTarget.Regular)}return null}_drawImpl(e){const{horizontalPixelRatio:t,verticalPixelRatio:s,context:i}=e,r=this._data,n=Qe(r.barSpacing),o=Ze(r.barSpacing),a=n<4,l=Math.max(n/2,1),h=(0,ue.ceiledEven)(n*t),c=h/2,u=Math.round(n*s);i.lineCap="butt",i.lineWidth=Math.max(1,Math.floor(t));const d=i.lineWidth%2?.5:0,p=r.visibleItemsRange?.startItemIndex??0,_=r.visibleItemsRange?.endItemIndex??r.items.length;if(!(p>=_))for(const e of r.items.slice(p,_)){if(!Number.isFinite(e.center)||!Number.isFinite(e.y))continue;const n=e.isUp?-1:1,p=Math.round(Math.abs(e.height)*s),_=Math.round(e.center*t)+d,f=Math.round((e.y-n*o)*s)+d;i.beginPath(),i.translate(_,f);const m=(e.style&&e.style.color)??(e.isUp?r.colorup:r.colordown);a?(i.moveTo(0,0),i.lineTo(-c,-c*n),i.moveTo(0,0),i.lineTo(c,-c*n),i.moveTo(0,0),i.lineTo(0,-p*n),i.moveTo(-c,-p*n),i.lineTo(c,-p*n),i.lineWidth=l,i.strokeStyle=m,i.stroke()):(i.moveTo(0,0),p<u?(i.lineTo(h,-p*n),i.lineTo(-h,-p*n)):(i.lineTo(h,-u*n),i.lineTo(c,-u*n),i.lineTo(c,-p*n),i.lineTo(-c,-p*n),
|
||
i.lineTo(-c,-u*n),i.lineTo(-h,-u*n)),i.lineTo(0,0),i.strokeStyle=e.isUp?r.colorBorderUp:r.colorBorderDown,i.stroke(),i.fillStyle=m,i.fill()),i.translate(-_,-f)}}}class tt extends We{_updateRenderer(e,t){const s=this._study.properties().childs().styles.childs()[this._plotName].childs(),i=(0,ue.clamp)(this._getTranspValue(),0,100),r=this._model.timeScale().barSpacing(),n=(0,I.generateColor)(s.colorup.value(),i),o=(0,I.generateColor)(s.colordown.value(),i),a=(0,qe.parseRgba)(n),l=a?100*(1-a[3]):0,h=(0,qe.parseRgba)(o),c=h?100*(1-h[3]):0,u={items:this._items,barSpacing:r,colorup:n,colordown:o,colorBorderUp:(0,I.generateColor)("#000000",l),colorBorderDown:(0,I.generateColor)("#000000",c),minHeight:this._plotStyleInfo.minHeight,visibleItemsRange:{startItemIndex:e,endItemIndex:t}};this._updateItemsHeights(u);const d=new te.CompositeRenderer;d.append(new et(u)),this._model.selection().isSelected(this._study)&&null!==this._selectionData&&d.append(new he.SelectionRenderer({...this._selectionData,barSpacing:r,withOutline:!1})),this._renderer=d}_fillItemWithPointStyle(e,t,s){const i=(0,p.ensureDefined)(e.style);e.isUp?void 0!==t.colors[5]?i.color=(0,I.generateColor)((0,p.ensureDefined)(t.colors[5]),s):i.color=(0,I.generateColor)(this._study.properties().childs().styles.childs()[this._plotName].childs().colorup.value(),s):void 0!==t.colors[6]?i.color=(0,I.generateColor)((0,p.ensureDefined)(t.colors[6]),s):i.color=(0,I.generateColor)(this._study.properties().childs().styles.childs()[this._plotName].childs().colordown.value(),s)}_getValueForUpdating(e){const t=e.value[this._plotIndex+1];if(!t)return null;const s=e.index,i=t>0,{hiPlot:r,loPlot:n}=this._hiLoPlots(),o=this._study.offset(this._plotName),a=Math.min(s+o,(0,p.ensureNotNull)(this._series.data().last()).index);if(i){const e=this._getSeriesVal(n,a);if(null!==e)return e}else{const e=this._getSeriesVal(r,a);if(null!==e)return e}return null}_updateItem(e,t){const s=this._getValueForUpdating(e),i=e.value[this._plotIndex+1]>0;return this._items[t].origPrices.price=s??NaN,this._items[t].isUp=i,t+1}_createItem(e,t,s,i,r){const n={center:NaN,y:NaN,origPrices:{price:NaN,timePointIndex:NaN},origHeight:NaN,timePointIndex:e+r};if(!t)return n;const o=Math.min(e+r,(0,p.ensureNotNull)(this._series.data().last()).index),a=t>0;let l;if(a){const e=this._getSeriesVal(i,o);if(null===e)return n;l=e}else{const e=this._getSeriesVal(s,o);if(null===e)return n;l=e}return new Je(e+r,l,t,a,{price:l,timePointIndex:e+r})}_dependsOnSeriesData(){return!0}_convertItemsToCoordinates(e,t,s,i){this._convertItemsToCoordinatesImpl(e,t,s,i)}_createSelectionDataPoint(e,t,s,i){const r=this._model.timeScale().barSpacing(),n=Ze(r),o=function(e){return Qe(e)}(r),a=super._createSelectionDataPoint(e,t,s,i),l=this._items[(0,y.lowerbound)(this._items,t,((e,t)=>e.timePointIndex<t))];if(!l)return a;const h=l.isUp?1:-1;return{...a,point:a.point.add((0,fe.point)(0,h*(n+o)))}}_updateItemsHeights(e){const t=this._study.properties().childs().styles.childs();let s=Math.abs((0,
|
||
p.ensureDefined)(t[this._plotName].childs().minHeight?.value()??this._plotStyleInfo.minHeight)),i=Math.abs((0,p.ensureDefined)(t[this._plotName].childs().maxHeight?.value()??this._plotStyleInfo.maxHeight));if(s>i){const e=s;s=i,i=e}const r=this._items,n=e.visibleItemsRange?.startItemIndex??0,o=(e.visibleItemsRange?.endItemIndex??r.length)-1;let a=0;for(let e=n;e<=o;e++){const t=r[e],s=Math.abs(t.origHeight);s>a&&(a=s)}const l=(i-s)/a;for(let e=n;e<=o;e++){const t=r[e],i=Math.abs(t.origHeight);t.height=i*l+s}}}var st=s(64138);class it extends ne.StudyForceOverlayPlotView{constructor(e,t,s,i){super(t,s,i),this._bars=[],this._invalidated=!1,this._isMarkersEnabled=ee.enabled("source_selection_markers"),this._selectionData=null,this._ohlcPlotIndexes=new Map,this._study=e,this._isMarkersEnabled=ee.enabled("source_selection_markers"),this._colorProvider=(0,re.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i),this._selectionIndexer=new de.SelectionIndexes(s.timeScale());const r=this._study.metaInfo().plots;for(let e=0;e<r.length;e++){const t=r[e];"target"in t&&(t.target===this._plotName&&((0,L.isOhlcOpenPlot)(t)&&this._ohlcPlotIndexes.set(1,e),(0,L.isOhlcHighPlot)(t)&&this._ohlcPlotIndexes.set(2,e),(0,L.isOhlcLowPlot)(t)&&this._ohlcPlotIndexes.set(3,e),(0,L.isOhlcClosePlot)(t)&&this._ohlcPlotIndexes.set(4,e)))}}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}items(){return this._bars}_updateImpl(){this._bars.length=0;const e=this._priceScale();if(this._model.timeScale().isEmpty()||null===e||e.isEmpty())return;const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return;let s=this._series.nearestIndex(t.firstBar(),O.PlotRowSearchMode.NearestRight);const i=this._series.nearestIndex(t.lastBar(),O.PlotRowSearchMode.NearestLeft);if(void 0===s||void 0===i)return;const r=this._study.getMinFirstBarIndexForPlot(this._plotName);if(r>i)return;s=Math.max(r,s);const n=this._study.data(),o=this._study.firstValue(void 0,this.isForceOverlay());if(null===o)return;const a=n.rangeIterator(s,i),l=(0,p.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),h=new Map,c=(e,t)=>{const s=e+"@"+t;if(!h.has(s)){const i=(0,I.generateColor)(e,t);return h.set(s,i),i}return h.get(s)},u=(0,_e.createEmptyStyle)();for(const e of a){let t=e.index;const s=e.value;t=Math.floor(t);let i=!0;const r=new Map;for(let e=1;e<=4;++e){const t=this._ohlcPlotIndexes.get(e);if(void 0===t){i=!1;break}const n=s[t+1];if(null==n){i=!1;break}r.set(e,n)}if(!i)continue;const n=(0,p.ensureDefined)(r.get(1)),o=(0,p.ensureDefined)(r.get(4)),a=(0,p.ensureDefined)(r.get(2)),h=(0,p.ensureDefined)(r.get(3)),d=Math.max(n,a,h,o),_=Math.min(n,a,h,o);let f=(0,p.ensureDefined)(c(l.color.value(),0));const m=this._colorProvider.getPlotPointStyle(s,u);void 0!==m.colors[0]&&(f=(0,p.ensureDefined)(m.colors[0]));const y={open:n,high:d,low:_,close:o,color:f,wickColor:m.colors[4],borderColor:m.colors[3],hollow:null,center:NaN,left:NaN,right:NaN,timePointIndex:Math.round(t)};this._bars.push(y)}
|
||
if(e.barPricesToCoordinates(this._bars,o),this._model.timeScale().fillBarBorders(this._bars),this._model.selection().isSelected(this._study)){const t=this._selectionIndexer.indexes();this._selectionData={points:[],hittestResult:ve.HitTarget.Regular,bgColors:[],visible:!0,barSpacing:this._model.timeScale().barSpacing()};const s=(0,p.ensureNotNull)(this._model.paneForSource(this._study)).height(),i=(0,p.ensureDefined)(this._ohlcPlotIndexes.get(4));for(let r=0;r<t.length;r++){const n=t[r],a=this._study.data().valueAt(n);if(null===a)continue;const l=a[i+1];if(null==l)continue;const h=this._model.timeScale().indexToCoordinate(Math.floor(n)),c=e.priceToCoordinate(l,o);this._selectionData.points.push({point:new fe.Point(h,c)}),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(c/s))}}else this._selectionIndexer.clear()}_isOHLCPlotVisible(){return this._study.isPlotVisibleAt(this._plotName,1)}}class rt extends it{renderer(){if(!this._isOHLCPlotVisible())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={bars:this._bars,dontDrawOpen:this._series.properties().childs().barStyle.childs().dontDrawOpen.value(),thinBars:this._series.properties().childs().barStyle.childs().thinBars.value()},t=new te.CompositeRenderer;return t.append(new st.PaneRendererBars(e)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&t.append(new he.SelectionRenderer(this._selectionData)),t}}var nt=s(48227);class ot extends it{renderer(){if(!this._isOHLCPlotVisible())return null;const e=this._priceScale();if(!e||e.isEmpty())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const t=(0,p.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),s=this._model.timeScale().barSpacing(),i={bars:this._bars,barSpacing:s,wickVisible:t.drawWick.value(),bodyVisible:!0,borderVisible:t.drawBorder.value(),barWidth:(0,$e.optimalBarWidth)(s),borderColor:t.borderColor.value(),wickColor:t.wickColor.value(),isPriceScaleInverted:e.isInverted()},r=new te.CompositeRenderer;return r.append(new nt.PaneRendererCandles(i)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&r.append(new he.SelectionRenderer(this._selectionData)),r}}var at=s(69555),lt=s(96025),ht=s(40738),ct=s(69558);class ut extends ht.HorizontalLinePaneView{constructor(e,t){super(),this._lineRendererData.linestyle=ct.LINESTYLE_DOTTED,this._study=e,this._plotName=t}_updateImpl(){this._lineRendererData.visible=!1;const e=this._study.properties().childs().styles.childs()[this._plotName].childs();if(!e.trackPrice.value()||!this._study.isPlotVisibleAt(this._plotName,1))return;const t=this._study.lastValueData(this._plotName,!0);t.noData||(this._lineRendererData.visible=!0,this._lineRendererData.y=t.coordinate,this._lineRendererData.color=t.color,this._lineRendererData.linewidth=e.linewidth.value())}}var dt=s(5605),pt=s(13560),_t=s(18348);const ft={type:0,color:"transparent"}
|
||
;class mt extends _t.AbstractFilledAreaPaneView{constructor(e,t,s,i){super(e,t,s),this._palettesInfo={},this._gradientPropsStateCache=null,this._rgbaFromInteger=(0,pt.rgbaFromIntegerCached)();const r=this._source.metaInfo();this._isRGB=Boolean(r.isRGB),this._isHlineFill="hline_hline"===s.type,(0,p.assert)(this._isHlineFill||"plot_plot"===s.type,"Wrong filledArea type: "+s.type),this._isHlineFill&&this._initBandIndexes(s.objAId,s.objBId),this._fillMetaInfo=s,this._fillStyleProps=i,this._gradientFillType=i.hasChild("fillType")&&"gradient"===i.childs().fillType?.value(),this._gradientStaticState={color1:s.topColor,color2:s.bottomColor,value1:s.topValue,value2:s.bottomValue},this._hasAllGradientRequiredProps=this._gradientFillType&&(void 0!==this._gradientStaticState.color1||i.hasChild("topColor")||void 0!==this._gradientStaticState.color2||i.hasChild("bottomColor"))&&(void 0!==this._gradientStaticState.value1||i.hasChild("topValue"))&&(void 0!==this._gradientStaticState.value2||i.hasChild("bottomValue"));const n=()=>this._colorPlotIndex=this._colorPlotIndex??{type:1};for(let t=0;t<r.plots.length;++t){const i=r.plots[t];if(((0,L.isColorerPlot)(i)||(0,L.isDataPlot)(i))&&i.target===s.id){if((0,L.isColorerPlot)(i)){let s;void 0!==i.targetField?"topColor"===i.targetField?(n().colorIndexOrRgba1=t,s="color1"):"bottomColor"===i.targetField&&(n().colorIndexOrRgba2=t,s="color2"):this._colorPlotIndex={type:0,colorIndexOrRgba:t},(0,L.isPaletteColorerPlot)(i)&&(this._palettesInfo[s??"color"]={map:(0,p.ensureDefined)((0,p.ensureDefined)(r.palettes)[i.palette]?.valToIndex),values:e.properties().palettes[i.palette].colors})}else(0,L.isDataPlot)(i)&&("topValue"===i.targetField?n().valueIndex1=t:"bottomValue"===i.targetField&&(n().valueIndex2=t));if(0===this._colorPlotIndex?.type)break}}}update(e){super.update(e),this._gradientPropsStateCache=null}isForceOverlay(){return!!this._source.metaInfo().isPlotForceOverlay(this._plotAId())}_firstValue(){const e=this.isForceOverlay();return this._source.firstValue(void 0,e)}_minFirstBarIndex(){return this._source.getMinFirstBarIndexForPlot(this._fillMetaInfo.id)}_getColorByPlotValue(e){if(0===e.type){let t;if(null==e.colorIndexOrRgba)return null;if(this._isRGB)t=this._rgbaFromInteger(e.colorIndexOrRgba);else{const s=(0,p.ensureDefined)(this._palettesInfo.color),i=(0,p.ensureDefined)(s.map[e.colorIndexOrRgba]);t=s.values[i]?.childs().color.value()}return{type:0,color:t}}const t=this._gradientColorPropsState();let s,i;if(this._isRGB)null!=e.colorIndexOrRgba1&&(s=this._rgbaFromInteger(e.colorIndexOrRgba1)),null!=e.colorIndexOrRgba2&&(i=this._rgbaFromInteger(e.colorIndexOrRgba2));else{if(null!=e.colorIndexOrRgba1){const t=(0,p.ensureDefined)(this._palettesInfo.color1);s=t.values[(0,p.ensureDefined)(t.map[e.colorIndexOrRgba1])].childs().color.value()}if(null!=e.colorIndexOrRgba2){const t=(0,p.ensureDefined)(this._palettesInfo.color2);i=t.values[(0,p.ensureDefined)(t.map[e.colorIndexOrRgba2])].childs().color.value()}}const r=e.value1??t.value1,n=e.value2??t.value2;return s=s??t.color1,i=i??t.color2,
|
||
void 0===r||void 0===n||void 0===s&&void 0===i?null:{type:1,color1:s,color2:i,value1:r,value2:n,coordinate1:NaN,coordinate2:NaN}}_plotAId(){return this._fillMetaInfo.objAId}_plotBId(){return this._fillMetaInfo.objBId}_commonColor(){const e=this._fillStyleProps.childs();if(this._gradientFillType){if(!this._hasAllGradientRequiredProps)return ft;const e=this._gradientColorPropsState();return{type:1,color1:e.color1,color2:e.color2,value1:e.value1,value2:e.value2,coordinate1:NaN,coordinate2:NaN}}return{type:0,color:e.color.value()}}_transparency(){return this._fillStyleProps.childs().transparency?.value()??0}_visible(){return this._fillStyleProps.childs().visible.value()}_priceScale(){return this.isForceOverlay()?this._model.mainSeries().priceScale():this._source.priceScale()}_initBandIndexes(e,t){this._bandAKey=null,this._bandBKey=null;const s=this._source.metaInfo().bands;if(void 0!==s)for(let i=0;i<s.length;++i){const r=s[i];null!==this._bandAKey||r.id!==e?null===this._bandBKey&&r.id===t&&(this._bandBKey=i):this._bandAKey=i}}_gradientColorPropsState(){if(null===this._gradientPropsStateCache){const e=this._fillStyleProps.state();this._gradientPropsStateCache={color1:this._gradientStaticState.color1??e.topColor,color2:this._gradientStaticState.color2??e.bottomColor,value1:this._gradientStaticState.value1??e.topValue,value2:this._gradientStaticState.value2??e.bottomValue}}return this._gradientPropsStateCache}}var yt=s(13212),gt=s(27909),vt=s(94119);class St{constructor(e,t){this._invalidated=!0,this._lineRenderer=new vt.HorizontalLineRenderer,this._source=t,this._points=[new fe.Point(-1,-1)],this._invalidated=!0,this._properties=e}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={y:this._points[0].y,color:this._properties.childs().color.value(),linewidth:this._properties.childs().linewidth.value(),linestyle:this._properties.childs().linestyle.value()};return this._lineRenderer.setData(e),this._lineRenderer}_updateImpl(){const e=this._source.priceScale();if(!e||e.isEmpty())return void(this._points[0]=new fe.Point(-1,-1));const t=this._properties.childs().value.value(),s=this._source.firstValue(),i=(0,_.isNumber)(t)&&null!==s?e.priceToCoordinate(t,s):NaN;this._points[0]=new fe.Point(-1,i)}}var bt=s(20820);class Pt extends bt.MediaCoordinatesPaneRenderer{constructor(){super(),this._data=null,this._data=null}setData(e=null){this._data=e}hitTest(){return null}_drawImpl(e){if(null===this._data||0===this._data.points.length)return;const t=e.context,s=e.mediaSize.width;if(this._data.gradient){const e=t.createLinearGradient(0,this._data.coordinate1,0,this._data.coordinate2);e.addColorStop(0,this._data.backColor1??"transparent"),e.addColorStop(1,this._data.backColor2??"transparent"),t.fillStyle=e}else t.fillStyle=this._data.backcolor;const i=Math.min(this._data.points[0],this._data.points[1]),r=Math.max(this._data.points[0],this._data.points[1]);t.fillRect(0,i,s,r-i)}}class wt{constructor(e){this._bandBgRenderer=new Pt,this._invalidated=!0,
|
||
this._source=e}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._bandBgRenderer}_updateImpl(){this._bandBgRenderer.setData(null);const e=this._source.properties().childs(),t=e.bands;if(t.childCount()<2)return;const s=e.bandsBackground;if(!s?.childs().fillBackground.value())return;const i=t[0].childs(),r=t[1].childs(),n=this._source.priceScale(),o=this._source.firstValue();if(!n||n.isEmpty()||null===o)return;const a=[n.priceToCoordinate(i.value.value(),o),n.priceToCoordinate(r.value.value(),o)],l=(0,p.ensureDefined)(e.bandsBackground).childs(),h=(0,ue.clamp)(l.transparency?.value()??0,0,100);this._bandBgRenderer.setData({gradient:!1,points:a,backcolor:(0,I.generateColor)(l.backgroundColor.value(),h)})}}class It{constructor(e,t,s){this._bandBgRenderer=new Pt,this._bandAKey=null,this._bandBKey=null,this._invalidated=!0,this._source=e,(0,p.assert)("hline_hline"===t.type,"Wrong filledArea type: "+t.type),this._initBandIndexes(t.objAId,t.objBId),this._fillStyleProps=s,this._bandBgRenderer=new Pt,this._gradientFillType=s.hasChild("fillType")&&"gradient"===s.childs().fillType?.value(),this._gradientStaticState={color1:t.topColor,color2:t.bottomColor,value1:t.topValue,value2:t.bottomValue}}update(){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._bandBgRenderer}_updateImpl(){if(this._bandBgRenderer.setData(null),!this._fillStyleProps.childs().visible.value())return;if(null===this._bandAKey||null===this._bandBKey)return;const e=(0,p.ensureDefined)(this._source.properties().childs().bands),t=e.childs()[this._bandAKey].childs(),s=e.childs()[this._bandBKey].childs(),i=this._source.priceScale(),r=this._source.firstValue();if(!i||i.isEmpty()||null===r)return;const n=[i.priceToCoordinate(t.value.value(),r),i.priceToCoordinate(s.value.value(),r)],o=(0,ue.clamp)(this._fillStyleProps.childs().transparency?.value()??0,0,100);let a;const l=this._fillStyleProps.childs();if(this._gradientFillType){const e=this._gradientStaticState,t=l,s=e.value1??t.topValue?.value(),h=e.value2??t.bottomValue?.value();if(void 0===s||void 0===h)return;const c=e.color1??t.topColor?.value(),u=e.color2??t.bottomColor?.value();if(void 0===c&&void 0===u)return;a={gradient:!0,points:n,backColor1:c&&(0,I.generateColor)(c,o),backColor2:u&&(0,I.generateColor)(u,o),coordinate1:i.priceToCoordinate(s,r),coordinate2:i.priceToCoordinate(h,r)}}else a={gradient:!1,points:n,backcolor:(0,I.generateColor)(l.color.value(),o)};this._bandBgRenderer.setData(a)}_initBandIndexes(e,t){this._bandAKey=null,this._bandBKey=null;(0,p.ensureDefined)(this._source.metaInfo().bands).forEach(((s,i)=>{null===this._bandAKey&&s.id===e&&(this._bandAKey=i),null===this._bandBKey&&s.id===t&&(this._bandBKey=i)}))}}var xt=s(86252),Ct=s(81922),Vt=s(51304),Mt=s(48943),Tt=s(95059),At=s(91106),Rt=s(63670),Ot=s(30693),Dt=s(28477);class Bt extends Dt.AbstractBarColorer{constructor(e,t){super(),this._rgbaFromInteger=(0,pt.rgbaFromIntegerCached)(),this._study=e,
|
||
this._plotIndex=t}applyBarStyle(e,t,s,i){if(t)return s;const r=this._study.properties().childs();if(!r.visible.value())return s;const n=this._study.metaInfo(),o=this._study.data();if(!o||0===o.size())return s;const a=n.plots[this._plotIndex],l=this._getOffset();if(this._study.getMinFirstBarIndexForPlot(a.id)>e+l)return s;if(0===r.styles.childs()[a.id].childs().display.value())return s;const h=o.valueAt(e-l);if(null===h)return s;let c=h[this._plotIndex+1];if(null==c)return s;if(c=Math.round(c),n.isRGB)s.barColor=this._rgbaFromInteger(c),s.upColor=s.barColor,s.downColor=s.barColor;else{const e=n.plots[this._plotIndex];if("palette"in e){const t=e.palette,i=r.palettes.childs()[t],o=(0,p.ensureDefined)(n.palettes?.[t]),a=o.valToIndex?(0,p.ensureDefined)(o.valToIndex[c]):c,l=i.childs().colors.childs()[a].childs().color.value();s.barColor=l,s.upColor=l,s.downColor=l}}return s}firstColoredBar(e){let t=e;for(const s of this._backColorers)t=Math.min(t,s.firstColoredBar(e)??1/0);const s=this._getOffset();t=Math.min(t,e+s);const i=this._getBars().firstIndex(),r=Math.max(t,i??-1/0),n=this._study.metaInfo().plots[this._plotIndex];return Math.max(this._study.getMinFirstBarIndexForPlot(n.id),r)}_getBars(){return this._study.series().bars()}_getOffset(){const e=this._study.metaInfo().plots[this._plotIndex];return this._study.offset(e.id)}}var Nt=s(76422),Ft=s(67563),kt=s(64717);class Et extends at.PanePriceAxisView{constructor(e,t,s,i){super(e,t,s),this._dataSource=t,this._isForceOverlay=t.metaInfo().isPlotForceOverlay(i)}_position(){const e=this._isForceOverlay?this._chartModel.mainPane():this._chartModel.paneForSource(this._dataSource);if(null===e)return null;const t=this._isForceOverlay?this._chartModel.mainSeries().priceScale():this._dataSource.priceScale();if(null===t)return null;let s=e.priceScalePosition(t);return"overlay"===s&&(s=e.priceScalePosition(e.defaultPriceScale())),"overlay"===s?null:s}}var Lt=s(56265);class Ht{constructor(e,t){this._study=e,this._valuesProvider=new F.StudyValuesProvider(e,t,!1,!1)}getItems(){const e=this._study.properties().childs(),t=this._valuesProvider.getItems();for(const s of t){const t=s.id,i=(0,p.ensureDefined)(e.styles.childs()[t]).childs().display.value();s.visible=0!==i}return t}getValues(e){const t=this._valuesProvider.getValues(e),s=this._study.plots().lastIndex(),i=this._study.plots().firstIndex();if(null===s||null===i)return null;for(const r of t){const t=e-this._study.offset(r.id);(t>s||t<i)&&(r.value="")}return t}}var Wt=s(76559),zt=s(72207),Ut=s(3618),jt=s(35727);const Gt=(0,f.getLogger)("Chart.Study"),$t=m.t(null,void 0,s(52969)),Kt=!1;var Yt,Xt;function qt(){return{fields:[],useMainSeriesRange:!1,baseValueMinMax:null}}!function(e){e.PaneViews="study-pane-views"}(Yt||(Yt={})),function(e){e[e.DefaultPriceScale=100]="DefaultPriceScale"}(Xt||(Xt={}));const Jt={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!1,skipFakeInputs:!1,skipBooleanInputs:ee.enabled("dont_show_boolean_study_arguments"),asObject:!0,skippedGroups:[],skippedInputs:[],noExchanges:!1,noResolution:!1,
|
||
keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1},Zt=ee.enabled("study_symbol_ticker_description"),Qt=ee.enabled("hide_main_series_symbol_from_indicator_legend"),es=ee.enabled("datasource_copypaste"),ts=ee.enabled("hide_unresolved_symbols_in_legend");function ss(e,t){const s=e.plots[t];if(!s||!(0,L.isOhlcPlot)(s))return!1;const i=s.target,r=e.defaults.styles&&e.defaults.styles[i],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[i],o=e.ohlcPlots&&e.ohlcPlots[i];return r&&(0,L.isOhlcPlotStyleBars)(r)||n&&(0,L.isOhlcPlotStyleBars)(n)||!!o&&(0,L.isOhlcPlotStyleBars)(o)}function is(e,t){const s=e.plots[t];if(!s||!(0,L.isOhlcPlot)(s))return!1;const i=s.target,r=e.defaults.styles&&e.defaults.styles[i],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[i],o=e.ohlcPlots&&e.ohlcPlots[i];return r&&(0,L.isOhlcPlotStyleCandles)(r)||n&&(0,L.isOhlcPlotStyleCandles)(n)||!!o&&(0,L.isOhlcPlotStyleCandles)(o)}function rs(e,t){(0,p.assert)(void 0!==e,"zOrder must be defined"),(0,p.assert)(!t.has(e),"zOrder must be unique")}function ns(e,t){return e.plots.some((e=>((0,L.isColorerPlot)(e)||(0,L.isDataPlot)(e))&&e.target===t))}function os(e,t,s){let i=0,r=0;return Math.sign(r)-Math.sign(i)}function as(e){const t=(0,Mt.combine)((e=>e.map((e=>as(e.parentSourcesVW().weakReference())))),e);return(0,Mt.accumulate)(((e,t)=>Array.from(new Set(t.concat(e.flat(20))))),t.ownership(),e).ownership()}function ls(e){return"inherit"===e.type&&(e.type="price"),e}function hs(e,t,s,i){{const t=(0,_.isNumber)(i)?i:void 0,r=jt.customFormatters?.studyFormatterFactory?.(e,s,t)??null;if(null!==r)return r}if(null!==t)switch(e.type){case"inherit":case"price":return new Ft.PriceFormatter({priceScale:t});case"volume":return(0,Lt.getVolumeFormatter)(Math.log10(t));case"percent":return(0,Lt.getPercentageFormatter)(Math.log10(t))}if("inherit"===e.type)return null;const r=(0,_.isNumber)(e.precision)?Math.pow(10,e.precision):void 0;switch(e.type){case"price":return new Ft.PriceFormatter({priceScale:r});case"volume":{let t=e.precision;return void 0===t&&(t=s&&(0,_.isNumber)(s.volume_precision)?s.volume_precision:0),(0,Lt.getVolumeFormatter)(t)}case"percent":return(0,Lt.getPercentageFormatter)(void 0===r?void 0:Math.log10(r));default:return Gt.logWarn(`Unsupported format type: ${e.type}`),null}}const cs=new Set(["first_visible_bar_time","last_visible_bar_time","subscribeRealtime"]);class us extends V.PriceDataSource{constructor(e,t,s,i,r,n,o){super(e),this._onStart=new w.Delegate,this._restarting=!1,this._paneViews=[],this._forceOverlaysPaneViews=[],this._legendView=null,this._floatingTooltipView=null,this._priceAxisViews=[],this._forceOverlayPriceAxisViews=[],this._priceAxisViewsBase=[],this._resolvedSymbols={},this._resolvedSymbolsByInput={},this._priceLinesAxisViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[],this._ownFirstValue=null,this._formatter=null,this._defaultFormatter=null,this._dataUpdated=new w.Delegate,this._currencySourceSymbolInputProperty=null,
|
||
this._pineSourceCodeModel=null,this._alertSourceModel=null,this._onHibernationStateChange=new w.Delegate,this._symbolsResolved=new w.Delegate,this._statusChanged=new w.Delegate,this._inputsAnchorsPaneView=null,this._inputsLinesPaneView=null,this._inputsTimeAxisPaneViews=[],this._inputsPriceAxisPaneViews=[],this._sources=new P.WatchedObject([],y.compareTwoCollectionsByIds),this._status=new b.WatchedValue({type:xt.StudyStatusType.Undefined}),this._compileActiveStatus=new P.WatchedObject(null),this._compileErrorStatus=new P.WatchedObject(null),this._wasCompletedBefore=!1,this._isStarted=!1,this._isSubscribedToSessionId=!1,this._titleStrCache={},this._titleInPartsCache={},this._inputsInPartsCache={},this._children=[],this._graphicsPriceAxisViews=[],this._serverPlotOffsets=new P.WatchedObject({}),this._ongoingDataUpdate=Promise.resolve(),this._studyModified=!1,this._tagsChanged=new w.Delegate,this._turnaround="st0",this._pendingResolveSymbols=new Map,this._onIsActualIntervalChange=new w.Delegate,this._childStudyByRebind=new w.Delegate,this._lastNonEmptyPlotRowCache={},this._startMovingPoint=null,this._processHibernateBound=this.processHibernate.bind(this,1),this._maxOffset=new b.WatchedValue(0),this._currencySourceSymbolInfo=null,this._graphicsPriceRangeGroups=null,this._graphicsViewsReady=!1,this._visibleTimeRangeInputs=null,this._turnaroundCounter=0,this._deferredPinePatchProps=!1,this._propertiesPatched=Promise.resolve(),this._resetPropertiesPatched=Promise.resolve(),this._abortPatchPropsController=new AbortController,this._abortResetPatchPropsController=new AbortController,this._aboutToBeDestroyed=new w.Delegate,this._definitionsViewModel=null,this._plotFormatters=new Map,this._showPineVersionInStatusLine=new b.WatchedValue(!1).spawn(),this._onParentSourcesChanges=new w.Delegate,this._statusChangesSubscriber={},this._calculationTime=new b.WatchedValue(0),this._stateForAlertCache=null,this._idForAlertCache=null,this._idForAlertWV=new b.WatchedValue(""),this._chartApi=e.chartApi(),this._properties=t,this._originalMetaInfo=r,this._metaInfo=new b.WatchedValue(i),this._studyName=(0,Mt.combine)((e=>e.useVersionFromMetaInfo?(0,A.getStudyIdWithVersion)(e):this._getStudyIdWithLatestVersion()),this._metaInfo.weakReference()),this._hideMatches=i.inputs.filter((e=>e.hideWhenPlotsHidden)).map((e=>({id:e.id,plotIds:e.hideWhenPlotsHidden||[]}))),this._series=this._model.mainSeries(),this._series.onIntervalChanged().subscribe(this,this._calcIsActualInterval),this._series.alertCreationAvailable().subscribe(this._updateAlertCreationAvailable.bind(this)),this._showStudyArgumentsProperty=(0,X.combineProperty)(((e,t)=>e&&t),e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments.weakReference(),this._properties.childs().showLegendInputs.weakReference()),this._model.symbolAliasService()?.onAliasChanged().subscribe(this,(()=>{this._onFormatterPropsChanged(),this.invalidateTitleCache()})),e.collapsed().subscribe(this._processHibernateBound),this._sources.setValue(s),
|
||
A.StudyMetaInfo.setChildStudyMetaInfoPropertiesSourceId(i,s[0]?.id(),t),s.forEach((e=>{e.setChild(this)})),[this._series,...s].forEach((e=>{e.currencyChanged().subscribe(this,this._onSourceCurrencyChanged),e.unitChanged().subscribe(this,this._onSourceUnitChanged),e.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),e.formatterChanged().subscribe(this,this._onSourceFormatterChanged),e.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged)})),Zt&&this._model.mainSeries().properties().childs().statusViewStyle.childs().symbolTextSource.subscribe(this,(()=>{this.invalidateTitleCache(!0)}));const a=this._properties.childs();for(const e of A.StudyMetaInfo.getSourceInputIds(i))a.inputs.childs()[e]?.subscribe(this,this._onSourceInputChanged);this._plotOffsets=(0,Mt.combine)(((e,t,s,i)=>(i.plots??[]).reduce(((i,r)=>{const n=r.id,o=(e[n]??0)+(s?.childs()[n]?.childs().val.value()??0)+(t?.childs().val.value()??0);return i[n]=o,i}),{})),this._serverPlotOffsets.weakReference(),(0,X.createWVFromGetterAndSubscription)((()=>this.properties().childs().offset),this.properties().childs().offset??new w.Delegate).ownership(),(0,X.createWVFromGetterAndSubscription)((()=>this.properties().childs().offsets),this.properties().childs().offsets??new w.Delegate).ownership(),this._metaInfo.weakReference()),this._properties.subscribe(this,this._onPropertiesChanged),a.visible.subscribe(this,this._visibleChanged),a.visible.subscribe(this,(()=>this.processHibernate())),a.intervalsVisibilities.subscribe(this,this._calcIsActualInterval),a.inputs.subscribe(this,this._updateMaxOffsetValue),void 0!==a.offsets&&a.offsets.subscribe(this,this._updateMaxOffsetValue),void 0!==a.offset&&a.offset.subscribe(this,this._updateMaxOffsetValue),this._initializeCurrencySource(),W.hideAllIndicators().subscribe(this,this._visibleChanged);for(let e=0;e<i.plots.length;e++){const t=i.plots[e],s=t.id,r=a.styles.childs()[s],n=(0,L.isBarColorerPlot)(t);r&&!r.hasChild("display")&&r.merge({display:15}),r?.childs().display.subscribe(this,(()=>{this.processHibernate(),this.invalidateTitleCache(),n&&this._series.invalidateBarColorerCache()}))}for(const e of Object.keys(i.graphics))for(const t of Object.keys(i.graphics[e])){const s=a.graphics.childs()[e]?.childs()[t];s&&s.childs().visible&&(0,p.ensureDefined)(s.childs().visible).subscribe(this,(()=>this.processHibernate()))}this._isActualInterval=(0,Ct.isActualInterval)(this._series.intervalObj().value(),a.intervalsVisibilities),this._initializeStudyInputsPaneViews(),this._handler=e=>this._onData(e),this._valuesProvider=new F.StudyValuesProvider(this,e),this._tableViewValuesProvider=new Ht(this,e),this._graphics=new R.LiveStudyGraphics(i.graphics),this._chartApi=e.chartApi(),this._invalidateLastNonEmptyPlotRowCache(),this._data=new T.PlotList((0,kt.studyPlotFunctionMap)(i),kt.studyEmptyPlotValuePredicate),this._createViews(),this._recreatePriceFormattingDependencies(this._series.symbolInfo()),a.precision.subscribe(this,this._onFormatterPropsChanged),
|
||
this._metaInfo.subscribe((()=>this._onFormatterPropsChanged())),this._showStudyArgumentsProperty.subscribe(this,(()=>this.invalidateTitleCache(!0))),a.inputs.subscribe(this,(()=>this.invalidateTitleCache(!0))),ee.enabled("update_study_formatter_on_symbol_resolve")&&e.mainSeries().dataEvents().symbolResolved().subscribe(this,this._recreatePriceFormattingDependencies),e.mainSeries().dataEvents().symbolResolved().subscribe(this,(()=>this.invalidateTitleCache(!0)));const l=new Set;if(this._simplePlotsCount=i.plots.filter(((e,t)=>{if((0,L.isLinePlot)(e))return!0;if((0,L.isOhlcPlot)(e)){const t=e.target;return!l.has(t)&&(l.add(t),!0)}return!1})).length,this.hasBarColorer()&&a.visible.subscribe(this,(()=>e.mainSeries().invalidateBarStylesCache)),this._definitionsViewModel=null,this._updateMaxOffsetValue(),i.inputs.some((e=>cs.has(e.id)))){this._visibleTimeRangeInputs=e.visibleRangeStudiesInputs().spawn();const t=this._visibleTimeRangeInputs.value();let s=null!==t;this._visibleTimeRangeInputs.subscribe((e=>{const t=()=>{this._onVisibleTimeRangeInputsChanged(e),s!==(null!==e)&&(s=null!==e,!s||this._restarting||this.isStarted()||this.start(!0))};this._statusChanged.unsubscribeAll(this._statusChangesSubscriber),this._status.value().type===xt.StudyStatusType.Loading?this._statusChanged.subscribe(this._statusChangesSubscriber,t,!0):t()})),t&&this._updateVisibleTimeRangeInputs(t,!1)}this._properties.setNameInOwner((0,Wt.propertyPathForSource)(this)),o&&this._pinePatchProps();const h=as(this.parentSourcesVW().weakReference());this._allOwnerSources=(0,Mt.combine)(((e,t)=>{const s=[];for(;null!==t;)s.push(t),t=t.ownerSource();return s}),h,(0,X.createWVFromGetterAndSubscription)((()=>this.ownerSource()),this.ownerSourceChanged()).ownership()),this._symbolSource=(0,Mt.combine)((e=>this._firstSourceOrSeries().symbolSource()),this._allOwnerSources.weakReference())}destroy(){this._signlePerformanceValue?.destroy(),this._aboutToBeDestroyed.fire(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._showStudyArgumentsProperty.unsubscribeAll(this),this._model.mainSeries().dataEvents().symbolResolved().unsubscribeAll(this),this._model.symbolAliasService()?.onAliasChanged().unsubscribeAll(this);this.parentSources().forEach((e=>{e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this),e.priceRangeReadyChanged().unsubscribeAll(this),e.formatterChanged().unsubscribeAll(this),e.priceStepChanged().unsubscribeAll(this)})),this._series.properties().childs().statusViewStyle.childs().symbolTextSource.unsubscribeAll(this),this._series.onIntervalChanged().unsubscribeAll(this),this._series.alertCreationAvailable().unsubscribe(this._updateAlertCreationAvailable),this.formatterChanged().unsubscribe(this,this.invalidateTitleCache),W.hideAllIndicators().unsubscribe(this,this._visibleChanged),this._model.collapsed().unsubscribe(this._processHibernateBound),null!==this._currencySourceSymbolInputProperty&&this._currencySourceSymbolInputProperty.unsubscribeAll(this),
|
||
this._legendView?.destroy(),this._floatingTooltipView?.destroy(),this._pineSourceCodeModel?.get()?.destroy(),this._visibleTimeRangeInputs?.destroy(),this._showPineVersionInStatusLine.destroy(),this._alertStateVersion?.destroy(),this._metaInfo.destroy(),this._studyName.destroy(),this._allOwnerSources.destroy(),this._sources.destroy(),this._symbolSource.destroy(),this._status.destroy(),this._compileActiveStatus.destroy(),this._compileErrorStatus.destroy(),this._plotOffsets.destroy(),this._serverPlotOffsets.destroy(),this._properties.destroy(),super.destroy()}setId(e){super.setId(e),this._properties.setNameInOwner((0,Wt.propertyPathForSource)(this))}properties(){return this._properties}propertiesPatched(){return this._propertiesPatched}isDraggable(){return!this._metaInfo.value().linkedToSeries}logs(){return null}logLevelMask(){const e=this._properties.childs().inputs.childs().__log_level.value();if(!(0,_.isNumber)(e)||e<0||e>7)throw new Error(`Value of log level is unexpected, current value is ${e}, but expected values from 0 to 7`);return{error:Boolean(1&e),warning:Boolean(2&e),info:Boolean(4&e)}}setLogLevelMask(e){const t=(Number(e.error)&&1)|(Number(e.warning)&&2)|(Number(e.info)&&4);this._properties.childs().inputs.childs().__log_level.setValue(t)}performance(){return new b.WatchedValue(null)}profilingEnabled(){return!!this._properties.childs().inputs.childs().__profile?.value()}enableProfiling(e){this._properties.childs().inputs.childs().__profile?.setValue(e)}onAboutToBeDestroyed(){return this._aboutToBeDestroyed}priceScale(e){return e?this._model.mainSeries().priceScale():super.priceScale()}lastValueData(e,t,s){const i={noData:!0},r=this.metaInfo().isPlotForceOverlay(e),n=r?this._model.mainSeries().priceScale():this.priceScale();if(this._model.timeScale().isEmpty()||null===n||n.isEmpty()||this.data().isEmpty())return i;const o=this._model.timeScale().visibleBarsStrictRange(),a=this.firstValue(!0,r);if(null===o||null===a)return i;if(!this._properties.childs().visible.value())return i;const l=this._properties.childs().styles,h=this._properties.childs().ohlcPlots;let c,u;if(l&&l.childs()[e]&&(c=l.childs()[e]),h&&h.childs()[e]&&(c=h.childs()[e]),!c||0===c.childs().display.value())return i;const d=this.metaInfo().plots;for(u=0;u<d.length;u++){const t=d[u];if(t.id===e||(0,L.isOhlcClosePlot)(t)&&t.target===e)break}const p=u+1,f=this.offset(e),m=this.nearestIndex(o.lastBar()-f,O.PlotRowSearchMode.NearestLeft,p);if(void 0===m)return i;const y=this._lastNonEmptyPlotRow(p),g=null!==y&&o.contains(y.index),v=null!==y?y.value:null,S=t||g?v:this.data().valueAt(m);if(!S||!(0,_.isNumber)(S[p]))return i;const b=S[p],P=this._valuesProvider.getPlotColor(u,S),w=n.priceToCoordinate(b,a),I=this.plotFormatter(e).format(b),x={...n.getFormattedValues(b,a,void 0,I),noData:!1,color:P,floatCoordinate:w,coordinate:w};return s&&(x.price=b),x}isFailed(){return this.status().type===xt.StudyStatusType.Error}isLoading(){return this.status().type===xt.StudyStatusType.Loading}isCompleted(){return this.status().type===xt.StudyStatusType.Completed}
|
||
isSymbolInvalid(){const e=this._status.value();return e.type===xt.StudyStatusType.Error&&e.errorDescription.error===$t}series(){return this._series}model(){return this._model}state(e,t){const s=(0,p.ensureNotNull)((0,g.getStudyClassName)(this.constructor)),i=this.metaInfo(),r={type:s,id:this.id(),state:this.properties().state(),zorder:this.zorder(),ownFirstValue:this.isVisible()?null:this._ownFirstValue,metaInfo:this._originalMetaInfo.state()},n=d(r.metaInfo,this._metaInfo.value().state());(0,o.default)(n)||(r.metaInfoPatch=n);const a=this._sources.value().map((e=>e.id()));if(a.length&&(r.parentSources=a),e){let e=this.data();const t=this._model.timeScale(),s=this._seriesDataRangeToSave(e);null!==s&&(e=e.range(s.firstBar(),s.lastBar())),r.data=e.state(),r.data.symbols=this._resolvedSymbols,r.data.graphics=(0,R.saveStudyGraphics)(this.graphics(),t.visibleBarsStrictRange()),r.data.plotOffsets=this._serverPlotOffsets.value()}this.ownerSource()&&(r.ownerSource=this.ownerSource()?.id());for(let e=0;e<i.inputs.length;e++)if("bar_time"===i.inputs[e].type){const t=i.inputs[e].id,s=r.state.inputs[t];if(s<0){const e=this._rightOffsetToUnixTime(-s);r.state.inputs[t]=e&&e>=0?e:0}}if(r.state?.inputs){const e=r.metaInfo.inputs.find((e=>"ILScript"===e.name));e&&delete r.state.inputs[e.id],delete r.state.inputs.__log_level,delete r.state.inputs.__profile}const l=this.stateCustomFields();return l&&(r.customFields=l),r}stateCustomFields(){const e=this._compileErrorStatus.value();if(e)return{compileErrorDescription:e.errorDescription}}restoreStateCustomFields(e){const t=e.compileErrorDescription;t&&this.setErrorCompilation([(0,p.ensureDefined)(t.editorError)])}restoreData(e){this._invalidateLastNonEmptyPlotRowCache(),this.data().restoreState(e),this._resolvedSymbols=e.symbols??{},this._graphics=e.graphics?(0,R.loadStudyGraphics)(e.graphics):(0,R.emptyStudyGraphics)(),this._postProcessGraphics(),this._serverPlotOffsets.setValue(e.plotOffsets??{}),this._setStatus({type:xt.StudyStatusType.Completed},!0)}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}async stateForAlertAsync(){throw new Error("Not implemented")}idForAlert(){return super.idForAlert()}hasBarColorer(){return this._metaInfo.value().plots.some(L.isBarColorerPlot)}barColorer(){const e=this._metaInfo.value().plots;let t=null;for(let s=e.length-1;s>=0;s--)if((0,L.isBarColorerPlot)(e[s])){const e=new Bt(this,s);null===t?t=e:t.pushBackBarColorer(e)}return t}isSavedInStudyTemplates(){return this._metaInfo.value().inputs.every((e=>"bar_time"!==e.type))}restart(e){this._restarting=!0,this.clearData(),(e||ee.enabled("stop_study_on_restart"))&&this.stop(),setTimeout(this.start.bind(this),0)}stop(e,t){if(!0===e&&this._children)for(const e of this._children)e.stop(!0);this._stopStudyOnServer(),this.clearData(),this._unsubscribeToSessionId(),this.recalculate()}disconnect(){this._isStarted=!1,this._model.isSnapshot()||(this._resolvedSymbols={},this._resolvedSymbolsByInput={})}sourceId(){return this._id.value()}parentSources(){return this._sources.value()}
|
||
parentSourcesVW(){return this._sources}symbolSource(){return this._symbolSource.value()}symbolSourceWV(){return this._symbolSource.readonly()}valueAt(e,t){return this.symbolSource().valueAt(e,t)}barsProvider(){return this._firstSourceOrSeries().barsProvider()}ownerSource(){return this.isChildStudy()?this._sources.value()[0]:super.ownerSource()}isChildStudy(){return this._sources.value().length>0}hasChildren(){return this._children.length>0}isStarted(){return this._isStarted}isRestarting(){return this._restarting}isActualInterval(){return this._isActualInterval}onIsActualIntervalChange(){return this._onIsActualIntervalChange}isVisible(){const e=this._properties.childs();if(this._model.collapsed().value()||!e.visible.value()||!this.isActualInterval())return!1;const t=this.metaInfo();if(t.plots.length>0)for(let s=0;s<t.plots.length;s++){const i=t.plots[s].id,r=e.styles.childs()[i];if(void 0===r)continue;if(0!==r.childs().display.value())return!0}if(t.bands)for(let s=0;s<t.bands.length;s++)if(e.bands.childs()[s].childs().visible.value())return!0;for(const s of Object.keys(t.graphics))for(const i of Object.keys(t.graphics[s])){const t=e.graphics.childs()[s]?.childs()[i];if(void 0!==t&&(t.child("visible")?.value()??1))return!0}if(t.filledAreas)for(let s=0;s<t.filledAreas.length;s++)if(e.filledAreasStyle.childs()[t.filledAreas[s].id].childs().visible.value())return!0;return!1}async start(e,t,s){const i=this._model.mainSeries();await i.seriesCreated(),await Promise.all(this._sources.value().filter((e=>e.isHibernated())).map((e=>e.start())));const r=!(this.isHibernationAllowed()&&!this.isVisible())||!0===t;if(this._chartApi&&this._chartApi.isConnected().value()&&r)try{await this._allSymbolsAreResolved(),await this._startAfterSymbolsResolved(e,t)}catch(e){const t=`ERROR: ${this._debugId()} start failed, ${e}`;Gt.logError(t),this._restarting=!1,"TooManyStudies"===e?.cause&&(0,S.showTooManyStudiesNotice)(this._chartApi.getStudyCounter())}r||void 0!==this._inputs||(this._inputs=this._apiInputs())}replaceData(e,t,s){this._invalidateLastNonEmptyPlotRowCache(),this.data().remove(e+1),this.data().addTail(s,t)}inputs(e){const t=(0,n.default)((0,_.clone)(Jt),e||{});t.skipOptionalEmptySymbolInputs&&(t.keepOptionalSymbolsEmpty=!0);return this._buildInputs(t)}data(){return this._data}moveData(e){this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._invalidateLastNonEmptyPlotRowCache(),this._moveData(e),this.data().isEmpty()||this._onIndexDiffsApplied(e)}))}plots(){return this.data()}metaInfo(){return this._metaInfo.value()}status(){return this._compileActiveStatus.value()??this._compileErrorStatus.value()??this._status.value()}name(e){return e?this.metaInfo().shortDescription||"Study":this.metaInfo().description||"Study"}title(e,t,s,i,r,n){i=void 0===i?!this._showStudyArgumentsProperty.value():i;const o=JSON.stringify([e,t,s,i,r,n]);if(this._titleStrCache[o])return this._titleStrCache[o];if(this._titleInPartsCache[o])return this._joinTitlesParts(this._titleInPartsCache[o]);const a=this._title(e,t,s,i,r,n)
|
||
;return this._titleStrCache[o]=a,a}titleInParts(e,t,s,i,r){i=void 0===i?!this._showStudyArgumentsProperty.value():i;const n=JSON.stringify([e,t,s,i,r]);if(this._titleInPartsCache[n])return this._titleInPartsCache[n];const o=this._titleInParts(e,t,s,i,r);return this._titleInPartsCache[n]=o,o}inputsInParts(e,t=!0,s,i,r){const n=!this._showStudyArgumentsProperty.value(),o=ee.enabled("always_show_study_symbol_input_values_in_legend"),a=n&&o;if(n&&!o&&e===Y.TitleDisplayTarget.StatusLine)return null;const l=JSON.stringify([e,t,s,i,r]);if(this._inputsInPartsCache[l])return this._inputsInPartsCache[l];const h=[],c=this.metaInfo(),u=this._titleInputs((0,zt.toInputDisplayFlags)(e),i,!0),d=c.inputs.filter((e=>u.hasOwnProperty(e.id)&&(!a||"symbol"===e.type||e?.isAlwaysShownInLegend))).map((e=>{let t=u[e.id];if("symbol"===e.type){const s=this._properties.childs().inputs.child(e.id)?.value();if(s){const e=this._resolvedSymbolsByInput[s];e&&(t=this._model.symbolAliasService()?.getAliasByProName(e.pro_name)?.aliasName??t)}}return{meta:e,value:t}})),f={};if(d.length>0){if(this.isChildStudy())for(let s=0;s<c.inputs.length;++s){const n=c.inputs[s];if(!A.StudyMetaInfo.isSourceInput(n))continue;const o=n.id,a=(0,p.ensureDefined)(this._properties.childs().inputs.child(o)).value();if(a.indexOf("$")>=0){const s=this.parentSourceForInput(a);if(s instanceof us){const n=s.metaInfo(),o=s.title(e,t,{},!0,i,r);if(1===n.plots.length)f[a]=o;else{const e=a.split("$")[1],t=n.plots[parseInt(e)]?.id,s=n.styles&&n.styles[t],i=s&&s.title||t;f[a]=o+": "+i}}}}d.forEach((({meta:e,value:t})=>{let i;i="time"===e.type?new Date(t).toISOString():(0,_.isNumber)(t)?(0,Lt.getNumericFormatter)().format(t):f&&f[t.toString()]||t.toString(),s&&s[i.toString()]&&(i=s[i.toString()]),h.push({title:(0,Ut.getTranslatedInputTitle)(e.name),value:i})}))}return this._inputsInPartsCache[l]=h,h}invalidateTitleCache(e){if(this._titleStrCache={},this._titleInPartsCache={},this._inputsInPartsCache={},!0===e&&this._children)for(let t=0;t<this._children.length;++t)this._children[t].invalidateTitleCache(e)}graphics(){return this._graphics}graphicsInfo(){return this._metaInfo.value().graphics}priceLabelText(e){const t=this._metaInfo.value(),s=t.styles,i=t.ohlcPlots;let r;s&&s[e]&&(r=s[e]),i&&i[e]&&(r=i[e]);const n=(0,p.ensureDefined)(r).title;return 1!==this._simplePlotsCount||(0,L.isPlotTitleDefined)(n)?t.is_price_study&&n!==t.shortDescription?""===n?t.shortDescription:t.shortDescription+":"+n:n:t.shortDescription}setOwnFirstValue(e){this._ownFirstValue=e}firstValue(e,t){if(t)return this._series.firstValue();const s=this._metaInfo.value();if(!this.isChildStudy()&&"Compare@tv-basicstudies"===s.id||!s.is_price_study){const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return null;const i=this.properties().childs();if(!i.visible.value()||!this.isActualInterval()||null!==this._startMovingPoint)return this._ownFirstValue;const r=t.firstBar(),n=t.lastBar();let o=null;if(null===o){const t=new Set,a=s.filledAreas||[];for(let e=0;e<a.length;e++){const s=a[e]
|
||
;i.filledAreasStyle.childs()[s.id].childs().visible.value()&&(t.add(s.objAId),t.add(s.objBId))}const l=s.plots||[];for(const a of this.data().rangeIterator(r,n)){const r=a.value;for(let n=0;n<l.length;++n){const a=l[n],h=a.id;if((0,L.isColorerPlot)(a)||s.isPlotForceOverlay(h))continue;const c=r[n+1];if(null==c)continue;if((0!==(0,p.ensureDefined)(i.styles.childs()[h]).childs().display.value()||t.has(h))&&!(e&&Math.abs(c)<1e-10)){o=c;break}}if(null!==o)break}}return this._ownFirstValue=o,null!==o?o:this._bandsFirstValue(e)}if(this.isChildStudy()){const e=this._getNonPriceParent();if(e&&this.priceScale()===e.priceScale())return null!==e._ownFirstValue?e._ownFirstValue:e.firstValue()}return this._series.firstValue()}desiredPriceScalePosition(){if(this.metaInfo().isTVScriptStub)return"overlay";if(this.metaInfo().linkedToSeries)return"as-series";switch(this.metaInfo().priceScale){case 1:return"left";case 0:return"right";case 2:return"overlay";default:return null}}offset(e){return this._plotOffsets.value()?.[e]??0}tags(){const e=this._metaInfo.value();return!e.description||e.isTVScriptStub||e.is_hidden_study||e.isTVScript&&"tv-scripting"===e.productId?[]:[e.description]}copiable(){return es&&!this.isChildStudy()}setPriceScale(e){super.setPriceScale(e),(0,Nt.emit)("study_event",this.id(),"price_scale_changed")}priceRange(e,t,s){let i=null;const r=this._metaInfo.value(),n=this._fillPrecalculatedAutoscaleInfo(e,t,s);let o=this.data().minMaxOnRangeCached(e,t,n.fields);if(o=(0,T.mergeMinMax)(n.baseValueMinMax,o),n.useMainSeriesRange){const s=[{name:"low",offset:0},{name:"high",offset:0}],i=this.series().data().bars().minMaxOnRangeCached(e,t,s);o=(0,T.mergeMinMax)(o,i)}if(null!==o&&(i=new M.PriceRange(o.min,o.max)),r.bands&&s.targetPriceScale===this.priceScale())for(let e=0;e<r.bands.length;e++){const t=(0,p.ensureDefined)(this._properties.childs().bands.childs()[e]).childs();if(t.visible.value()){const e=t.value.value();if(!(0,_.isNumber)(e))continue;i?i.apply(e,e):i=new M.PriceRange(e,e)}}return this._postProcessPriceRange(i,s)}autoScaleInfo(e,t,s){const i=this.priceRange(e,t,s),r=(this.priceScale()===this._series.priceScale()||(this.priceScale(),s.targetPriceScale),{topPixelMargin:0,bottomPixelMargin:0});return{range:i,topPixelMargin:r.topPixelMargin,bottomPixelMargin:r.bottomPixelMargin}}formatter(e){return this._formatter??this._firstSourceOrSeries().formatter(!1)}defaultFormatter(){const e=this._firstSourceOrSeries();return this._defaultFormatter??e.defaultFormatter?.()??e.formatter()}plotFormatter(e){return this._plotFormatters.get(e)??this.formatter()}isMultiPaneAvailable(){return this._metaInfo.value().hasForceOverlayPlots()||(0,x.hasForceOverlayPrimitives)(this._metaInfo.value())}isMultiPaneEnabled(){return this._metaInfo.value().hasForceOverlayPlots()}updateAllViews(e){const t=this._model.paneForSource(this),s=this._model.mainPane(),i="viewport-change"===e.type&&e.pane&&e.pane!==s;"viewport-change"===e.type&&e.pane&&e.pane!==t||(this._paneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),
|
||
this._dataWindowView?.update(e),this._legendView?.update(e),this._statusView?.update(e),this._floatingTooltipView?.update(e),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLinesAxisViews.forEach((t=>t.update(e))),this._inputsLinesPaneView?.update(e),this._inputsAnchorsPaneView?.update(e),this._inputsTimeAxisPaneViews.forEach((t=>t.update(e))),this._inputsPriceAxisPaneViews.forEach((t=>t.update(e)))),i||(this._forceOverlaysPaneViews.forEach((t=>t.update(e))),this._forceOverlayLabelPaneViews.forEach((t=>t.update(e))),this._forceOverlayPriceAxisViews.forEach((t=>t.update(e)))),"data-source-change"===e.type&&e.sourceId===this.id()&&e.clearData&&this._children.forEach((e=>e.updateAllViews({type:"data-source-change",sourceId:e.id(),clearData:!0})))}removeByRemoveAllStudies(){return!0}studyName(){return this._studyName}nearestIndex(e,t,s){return this.data().search(e,t,s)?.index}getMinFirstBarIndexForPlot(e){const t=this._properties.childs(),s=this._metaInfo,i=t.styles.childs()[e]?.child("showLast")?.value()??t.filledAreasStyle.childs()[e]?.child("showLast")?.value()??s.value().styles?.[e]?.showLast??t.ohlcPlots.childs()[e]?.child("showLast")?.value()??s.value().ohlcPlots?.[e]?.showLast??null;if(null===i)return-1/0;const r=this.data().lastIndex();return null===r?-1/0:r-i+1}guiPlotName(e,t){const s=this._metaInfo.value(),i=s.plots.find((e=>e.id===t));if(void 0!==i){return((0,L.isOhlcPlot)(i)?s.ohlcPlots?.[i.target]?.title:s.styles?.[t]?.title)??this.title(e)}return this.title(e)}childStudyByRebind(){return this._childStudyByRebind}isPine(){return void 0!==this._metaInfo.value().pine}isStandardPine(){return this.isPine()&&A.StudyMetaInfo.isStandardPine(this._metaInfo.value().id)}isLinkedToSeries(){return!0===this._metaInfo.value().linkedToSeries}preferredZOrder(){return!1===this._metaInfo.value().behind_chart?0:null}defaultPlotIdForAlert(){return this._metaInfo.value().plots?.[0]?.id??null}resolvedSymbolInfoBySymbol(e){return this._resolvedSymbols&&e&&this._resolvedSymbols[this._getSymbolForResolve(e)]||null}hasPendingUnresolvedSymbols(){return this._pendingResolveSymbols.size>0}hasSymbolInputs(){return this._metaInfo.value().inputs.some((e=>"symbol"===e.type))}currency(){if(null!==this._currencySourceSymbolInfo)return(0,Tt.symbolCurrency)(this._currencySourceSymbolInfo);const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().currency():null}currencySourceSymbolInfo(){return this._currencySourceSymbolInfo??this.symbolSource()?.symbolInfo()??null}unit(){const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().unit():null}canOverrideMinTick(){return!1}dataWindowView(){return this._dataWindowView}statusView(){return this._statusView}legendView(){return this._legendView}chartFloatingTooltipView(){return this._floatingTooltipView}pineSourceCodeModel(){return Promise.resolve(null)}alertSourceModel(){return this._alertSourceModel}inputsForAlertState(){return this.inputs()}sessionId(){return this._firstSourceOrSeries().sessionId()}sessionIdChanged(){
|
||
return this._firstSourceOrSeries().sessionIdChanged()}getSymbolString(e){return""===e?"":(0,U.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e))}onStatusChanged(){return this._statusChanged}onDataUpdated(){return this._dataUpdated}symbolsResolved(){return this._symbolsResolved}onHibernationStateChange(){return this._onHibernationStateChange}valuesProvider(){return this._valuesProvider}legendValuesProvider(){return new E(this,this.model())}tableViewValuesProvider(){return this._tableViewValuesProvider}statusProvider(e){return new $.StudyStatusProvider(this)}chartFloatingTooltipValuesProvider(){return new K(this,this.model())}correctScaleMargins(e){if("Volume"===this.metaInfo().shortId){const t=this.model().paneForSource(this);return null!==t&&t.isOverlay(this)&&t.containsMainSeries()?{top:.75,bottom:0}:{top:e.top,bottom:0}}return e}canBeHiddenByGlobalFlag(){return!0}isSourceHidden(){return!this.isVisible()||this.canBeHiddenByGlobalFlag()&&W.hideAllIndicators().value()}wasCompletedBefore(){return this._wasCompletedBefore}paneViews(e){const t=this._model.mainPane();if(this.isSourceHidden())return null;if(!e.hasPriceDataSource(this))return e!==t?null:this._forceOverlaysPaneViews;const s=[];return!this._startMovingPoint&&this._wasCompletedBefore&&s.push(...this._paneViews.filter((e=>!e.isForceOverlay?.()))),this._inputsLinesPaneView&&(this._startMovingPoint||this._model.selection().isSelected(this))&&s.push(this._inputsLinesPaneView),this._inputsAnchorsPaneView&&s.push(this._inputsAnchorsPaneView),e===t&&s.push(...this._forceOverlaysPaneViews),s}labelPaneViews(e){const t=this._model.mainPane();if(this.isSourceHidden()||!e.hasPriceDataSource(this))return this._metaInfo.value().hasForceOverlayPlots()?e!==t?null:this._forceOverlayLabelPaneViews:null;const s=[...this._labelPaneViews];return e===t&&s.push(...this._forceOverlayLabelPaneViews),s}timeAxisViews(){return this._model.selection().isSelected(this)?this._inputsTimeAxisPaneViews:null}priceAxisViews(e,t){if(t!==this.priceScale()&&t===this._model.mainSeries().priceScale()&&!e.hasDataSource(this))return this._forceOverlayPriceAxisViews;const s=this._properties.childs().oldShowLastValue;if(s&&!s.value())return null;let i=this._priceAxisViews.slice();return this._model.selection().isSelected(this)&&(i=i.concat(this._inputsPriceAxisPaneViews)),t===this._model.mainSeries().priceScale()&&(i=i.concat(this._forceOverlayPriceAxisViews)),e.findTargetPriceAxisViews(this,t,i,this._priceLinesAxisViews)}movable(){return null!==this._inputsAnchorsPaneView}startMoving(e,t,s,i){this._startMovingPoint=e}move(e,t,s,i){if(void 0!==e.logical&&null!==this._startMovingPoint){if(Array.isArray(t)){const s=t;this._updateInputValue(e.logical,s[0]),this._updateInputValue(e.logical,s[1])}else this._updateInputValue(e.logical,t);this.updateAllViews((0,N.sourceChangeEvent)(this.id()))}}endMoving(e,t){return this._startMovingPoint=null,{indexesChanged:!1,pricesChanged:!1}}clearData(){this._invalidateLastNonEmptyPlotRowCache(),
|
||
this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._clearData(),this._graphics instanceof R.LiveStudyGraphics&&this._graphics?.clear(),this._serverPlotOffsets.setValue({})})),this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this.updateAllViews((0,N.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))}convertYCoordinateToPriceForMoving(e,t){const s=this.priceScale();if(!t||!s||s.isEmpty())return null;const i=t.firstValue();return null===i?null:s.coordinateToPrice(e,i)}processHibernate(e){const t=this.isVisible();if(!this.isStarted()&&t&&(this._sources.value().forEach((e=>{e.processHibernate()})),this.start(void 0,void 0,e),this._onHibernationStateChange.fire(!1)),this.isHibernationAllowed()&&this.isStarted()&&!t){for(const e of this._children)e.processHibernate();this.stop(void 0,e),this._onHibernationStateChange.fire(!0)}}isHibernationAllowed(){return!this.metaInfo().historyCalculationMayChange&&(!this.hasChildren()||!!this._model.collapsed().value()&&this._children.every((e=>e.isHibernationAllowed())))}isPlotVisibleAt(e,t){let s;const i=this.metaInfo().plots.find((t=>t.id===e));if(s=void 0!==i?(0,L.isOhlcPlot)(i)?this._properties.childs().ohlcPlots.childs()[i.target]:this._properties.childs().styles.childs()[e]:this._properties.childs().ohlcPlots.childs()[e],void 0===s)throw new Error(`Study does not contain ${e} plot`);const r=s.childs().display.value();return null!==r&&(r&t)===t}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,N.sourceChangeEvent)(this.id())),this._model.updateSource(this)}maxOffset(){return this._maxOffset}onStart(){return this._onStart}onParentSourcesChanges(){return this._onParentSourcesChanges}isHibernated(){return!this.isVisible()&&!this.isStarted()}graphicsViewsReady(){return this._graphicsViewsReady}setLoadingCompilationActive(e){0}setErrorCompilation(e){0}hasCompileError(){return null!==this._compileErrorStatus.value()}turnaround(e){if(!e)return this._turnaround;return function(e,t){let s=t.turnaround,i=[t];for(;i.length>0;){let e=[];const t=[];i.forEach((s=>{const i=J(s.sourceStudies).sort(q);if(i.length>0){e=e.concat(i);const s=i.map((e=>e.turnaround)).join("_");t.push(s)}})),t.length&&(s=t.join("_")+"_"+s),i=e}return e+"_"+s}(this._series.seriesSource().turnaround(),Z(this))}canHaveChildren(){return this._canHaveChildren=this._canHaveChildren??A.StudyMetaInfo.canHaveChildren(this._metaInfo.value()),this._canHaveChildren}setChild(e){-1===this._children.indexOf(e)&&this._children.push(e)}unsetChild(e){const t=this._children.indexOf(e);~t&&this._children.splice(t,1)}getAllChildren(){const e=this._children.slice();for(let t=0;t<e.length;++t){const s=e[t].getAllChildren();for(let t=0;t<s.length;++t)~e.indexOf(s[t])||e.push(s[t])}return e}parentSourceForInput(e){if(e.includes("$")){const t=e.split("$")[0];return this._sources.value().find((e=>e.id()===t))??null}return this._series}priceStep(){return this._priceStep||this._firstSourceOrSeries().priceStep(!1)}recreatePriceFormatter(){
|
||
this._recreatePriceFormattingDependencies()}setOwnerSource(e){super.setOwnerSource(e),this._recreatePriceFormattingDependencies()}onTagsChanged(){return this._tagsChanged}getPropertyDefinitionsViewModel(){return null===this._definitionsViewModel?this._getPropertyDefinitionsViewModelClass().then((e=>null===e||this._isDestroyed?null:(null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this._model.undoModel(),this)),this._definitionsViewModel))):Promise.resolve(this._definitionsViewModel)}calculationTime(){return this._calculationTime.readonly()}contextMenuStatName(){return"IndicatorContextMenu"}metaInfoWV(){return this._metaInfo.readonly()}async patchPropertiesAfterResetDefaults(){throw new Error("Not implemented")}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_alertMetaInfo(){return this.metaInfo()}_createStudyOnServer(){if(this._isDestroyed)return!1;this._isStarted=!0,this._incrementTurnaround();const e=(0,p.ensureDefined)(this._inputs);let t;return t=this._chartApi.createStudy(this.sourceId(),this._turnaround,this.isChildStudy()?(0,p.ensureNotNull)(this._sources.value()[0].sourceId()):(0,p.ensureNotNull)(this._series.seriesSource().instanceId()),this._studyName.value(),e,this._handler,this._studySpec()),t?(performance.mark(`calculate_study_${this._id.value()}`),!0):(this._isStarted=!1,t)}_stopStudyOnServer(){this._chartApi&&this._chartApi.isConnected().value()&&this.isStarted()&&(this._chartApi.removeStudy(this.sourceId()),this._setStatus({type:xt.StudyStatusType.Undefined})),performance.clearMarks(`calculate_study_${this.sourceId()}`),this._isStarted=!1}_modifyStudyOnServer(e,t){this._chartApi.modifyStudy(this.sourceId(),this._turnaround,e,this._handler,t),performance.mark(`calculate_study_${this.sourceId()}`)}_sendNotifyCommand(e,t){this._chartApi.notifyStudy(this.sourceId(),e,t)}_transformData(e){}_plotsDataRange(){const e=this.plots().firstIndex(),t=this.plots().lastIndex();return null!==e&&null!==t?[e,t]:null}_invalidateLastNonEmptyPlotRowCache(){this._lastNonEmptyPlotRowCache={}}_collectDepsForAlert(){throw new Error("Not implemented")}_allInputsAreValid(){if(null===this._visibleTimeRangeInputs?.value())return!1;for(const e of this._metaInfo.value().inputs)if("bar_time"===e.type){const t=e.id;if(null==this._properties.childs().inputs.childs()[t].value())return!1}return!0}async _startAfterSymbolsResolved(e,t){await Promise.all(this._sources.value().map((e=>!e.isStarted()||e.isRestarting()?new Promise((t=>{e.onStart().subscribe(this,t,!0)})):Promise.resolve()))),this.isStarted()&&!this._restarting||(this._restarting=!1,this._allInputsAreValid()&&!this.metaInfo().isTVScriptStub&&(this._inputs=this._apiInputs(),this._createStudyOnServer()&&(this._subscribeToSessionId(),this._onStart.fire(),!0===e&&this._children&&await this._children.map((e=>e.start(!0,t))))))}async _changeInputsImpl(e,t){const i=this._calcSources(),r=this._metaInfo.value(),n=os(),o=()=>{for(const s of r.inputs){if("source"!==s.type)continue;const i=e[s.id].v,r=t[s.id].v;if(i!==r){(0,
|
||
p.ensureDefined)(this._properties.childs().inputs.child(s.id)).setValue(r)}}};if(this.isStarted()&&this._chartApi.isConnected().value()&&n>0&&!this._chartApi.canCreateStudy(this._studySpec(!0),!0).success){const e=window.user.pro_plan,t="pro_premium_expert"===e||"pro_premium_expert_trial"===e;return createGoProDialog({feature:"studyOnStudy",hideLimitTable:t,actions:e&&t?[{text:m.t(null,void 0,s(15462)),action:PredefinedAction.Close}]:void 0}),void o()}this._inputs=e;let a=!1;const l=Object.values(Q.RangeDependentStudyInputNames);for(const s of Object.keys(e))if(JSON.stringify(e[s])!==JSON.stringify(t[s])&&!l.includes(s)){a=!0;break}this._incrementTurnaround(),a&&this.disablePriceRangeReady();try{await this._updateParentSources(i,n,!0),this._modifyStudyOnServer(e,n),this._studyModified=!0}catch(e){Gt.logError(`Error applying parent sources: ${e}`),o()}this.invalidateTitleCache()}_createPriceAxisView(e){return new Rt.StudyPriceAxisView(this,{plotIndex:e})}_createPriceLineAxisView(e){return new Ot.StudyPriceLineAxisView(this,e)}_createStudyPlotPaneView(e){return new lt.StudyPlotPaneView(this,this._series,this._model,e)}_createViews(){this._priceAxisViewsBase=[],this._forceOverlayPriceAxisViews=[],this._priceLinesAxisViews=[],this._paneViews=[],this._forceOverlaysPaneViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[];const e=new Set,t=this.metaInfo(),s=Boolean(t.usePlotsZOrder),i=new Map,r=this._properties.childs();if(r.filledAreasStyle&&t.filledAreas)for(let e=0;e<t.filledAreas.length;++e){const n=t.filledAreas[e],o=(0,p.ensureDefined)(r.filledAreasStyle.childs()[n.id]),a=ns(t,n.id);let l;if("plot_plot"===n.type||a?l=new mt(this,this.model(),n,o):"hline_hline"===n.type?l=new It(this,n,o):Gt.logWarn("Unsupported filledArea type: "+n.type),void 0!==l){let e=!1;if("plot_plot"===n.type&&(e=t.isPlotForceOverlay(n.objAId)),e)this._forceOverlaysPaneViews.push(l);else{const e=s?(0,p.ensureDefined)(n.zorder):i.size;rs(e,i),i.set(e,{paneViews:[l]})}}}{let r=-1e5;for(let n=0;n<t.plots.length;n++){const o=t.plots[n];let a,l,h,c,u,d=t.isPlotForceOverlay(o.id);if((0,L.isNonVisualPlot)(o))continue;let _=o.id,f=t.styles;const m=(0,L.isBgColorerPlot)(o);if(m)a=new oe(this,this._series,this._model,_);else if((0,L.isShapesPlot)(o))a=new ze(this,this._series,this._model,_);else if((0,L.isCharsPlot)(o))a=new Xe(this,this._series,this._model,_);else if((0,L.isArrowsPlot)(o))a=new tt(this,this._series,this._model,_);else if((0,L.isOhlcPlot)(o)){const s=o.target;if(e.has(s))continue;if(d=t.isPlotForceOverlay(s),e.add(s),ss(t,n))a=new rt(this,this._series,this._model,s);else{if(!is(t,n)){Gt.logError(`plot ${o.id} looks to be invalid`);continue}a=new ot(this,this._series,this._model,s)}c=this._createPriceAxisView(s),h=new at.PanePriceAxisView(c,this,this._model),_=s,f=t.ohlcPlots}else(0,L.isDataPlot)(o)||(c=this._createPriceAxisView(_),u=this._createPriceLineAxisView(_),a=this._createStudyPlotPaneView(_),this._properties.childs().styles.childs()[_]?.child("trackPrice")?.value()&&(l=new ut(this,_)),
|
||
h=new Et(c,this,this._model,_));const y=s?m?r++:(0,p.ensureDefined)(f?.[_]?.zorder):i.size;if(rs(y,i),d)c&&this._forceOverlayPriceAxisViews.push(c),a&&this._forceOverlaysPaneViews.push(a),h&&this._forceOverlayLabelPaneViews.push(h);else{const e={paneViews:void 0!==a?[a]:[],labelView:h,priceAxisView:c,priceLineAxisView:u};void 0!==l&&e.paneViews.push(l),i.set(y,e)}}}(this._metaInfo.value().bands??[]).forEach(((e,t)=>{const n=r.bands.childs()[t];if(n&&n.childs().visible.value()){const t=new St(n,this),r=s?(0,p.ensureDefined)(e.zorder):i.size;rs(r,i),i.set(r,{paneViews:[t]})}})),r.bandsBackground&&((0,p.assert)(!s,"'usePlotsZOrder' flag does not supported"),i.set(i.size,{paneViews:[new wt(this)]}));const n=this._paneViews,o=this._forceOverlaysPaneViews;this._createGraphicsPaneViews().then((e=>{for(let t=0;t<e.regularPaneViews.length;t++)n.push(e.regularPaneViews[t]);for(let t=0;t<e.forceOverlayPaneViews.length;t++)o.push(e.forceOverlayPaneViews[t]);this._model.lightUpdate(),this._graphicsViewsReady=!0})),r.areaBackground&&((0,p.assert)(!s,"'usePlotsZOrder' flag does not supported"),i.set(i.size,{paneViews:[new dt.AreaBackgroundPaneView(this,this.model())]}));const a=Array.from(i.keys()).sort(((e,t)=>e-t));for(let e=0;e<a.length;e++){const t=(0,p.ensureDefined)(i.get(a[e]));this._paneViews.push(...t.paneViews),t.labelView&&this._labelPaneViews.push(t.labelView),t.priceAxisView&&this._priceAxisViewsBase.push(t.priceAxisView),t.priceLineAxisView&&this._priceLinesAxisViews.push(t.priceLineAxisView)}this._dataWindowView||(this._dataWindowView=new yt.StudyDataWindowView(this,this._model)),this._legendView||(this._legendView=new H(this,this._model)),this._statusView||(this._statusView=new z.StudyStatusView(this)),this._floatingTooltipView||(this._floatingTooltipView=new gt.StudyChartFloatingTooltipView(this,this._model)),this._concatPriceAxisViews()}_onData(e){switch(e.method){case"study_loading":this._onStudyLoading(e.time);break;case"study_error":this._onStudyError(e.params[2]);break;case"study_completed":if(!this._checkTurnaround(e.params[1]))return;this._onStudyCompleted(e.time);break;case"data_update":if(e.params.customId!==this.sourceId()||!this._checkTurnaround(e.params.turnaround))return;(0,p.assert)(!!e.params.nonseries,"data.params.nonseries is missing"),this._onDataUpdate(e.params.plots,(0,p.ensureDefined)(e.params.nonseries),e.params.lastBar);break;case"clear_data":this._checkTurnaround(e.params.turnaround)&&this.clearData()}}_getTelemetryObjectName(){return"study"}_onDataUpdated(e,t,s,i){if(this.hasBarColorer()&&e.length>0){const t=(0,p.ensureNotNull)(this.barColorer()).firstColoredBar(e[0].index);null!==t&&this._model.mainSeries().invalidateBarStylesCache(t)}null!==t&&this._postProcessGraphics();const r=this._model.paneForSource(this);if(this._model.recalculatePane(r,(0,N.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:i??void 0,nonSeriesOnly:0===e.length})),this._updateSources(),e.length){const t=e[e.length-1].index,s=e[0].index;this._dataRangeUpdated.fire({type:"partial",startIndex:s,
|
||
endIndex:t})}else this.data().isEmpty()&&this._dataRangeUpdated.fire({type:"full"})}_titleInputs(e,t,s){return this.inputs(this._titleInputsOptions(e,t,s))}_titleInputsOptions(e,t,s){return{symbolsForDisplay:!0,skipHiddenInputs:!0,skipFakeInputs:!1,fakeInputsForDisplay:!0,asObject:!0,skippedGroups:[],skippedInputs:this._skippedTitleInputs(),noExchanges:t,noResolution:s,priceInputsForDisplay:!0,skipOptionalEmptySymbolInputs:Qt,displayMask:e}}_postProcessGraphics(){this._graphicsPriceAxisViews=this._createGraphicsPriceAxisViews(),this._concatPriceAxisViews()}async _createGraphicsPaneViews(){return(0,R.createGraphicsPaneViews)(this,this.model())}_createGraphicsPriceAxisViews(){return(0,R.createGraphicsPriceAxisViews)(this)}_subscribeToSessionId(){!this._isSubscribedToSessionId&&this.hasSymbolInputs()&&(this.sessionIdChanged().subscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!0)}_recreateFormatter(e){let t=e;if(t){const e=this._model.symbolAliasService()?.getAliasByProName(t.pro_name);e&&(t=(0,r.default)(t),(0,n.default)(t,e.formattingOptions??{}))}this._recreatePlotsFormatters(t),this._formatter=this._tryCreateFormatter(t),this._defaultFormatter=this._tryCreateDefaultFormatter(t),this._formatterChanged.fire();const s=this.priceScale();null!==s&&s.updateFormatter(),this.getAllChildren().forEach((e=>{e.recreatePriceFormatter()})),this._model.fullUpdate()}_recreatePriceFormattingDependencies(e){this._recreateFormatter(e),this._recreatePriceStep()}_title(e,t,s,i,r,n){const o=this._titleInParts(e,t,s,i,r,n);return this._joinTitlesParts(o)}_postProcessPriceRange(e,t){if(e&&e.minValue()===e.maxValue()&&!this.metaInfo().is_price_study){const t=.005*e.minValue();e=new M.PriceRange(e.minValue()-t,e.maxValue()+t)}const s=t.targetPriceScale;return s&&s.isLog()&&e?new M.PriceRange(s.priceToLogical(e.minValue()),s.priceToLogical(e.maxValue())):e}_titleInParts(e,t=!0,i,r,n,o){const a=[m.t(this.name(t),{context:"study"},s(83477))];let l=[];if(!r||ee.enabled("always_show_study_symbol_input_values_in_legend")){const s=this._getMTFResolutionInputTitle();null!==s&&s.length>0&&a.push(s);l=(this.inputsInParts(e,t,i,n,o)??[]).map((e=>e.value))}return[a.join(" · "),l]}_seriesDataRangeToSave(e){return this._model.timeScale().visibleExtendedDataRange(e,0)}_getSymbolForResolve(e){return this.getSymbolString(this._getSymbolForApi(e))}_getSymbolForApi(e){return e}_getSymbolObject(e){const t={symbol:e},s=this.currency();return null!==this._currencySourceSymbolInputProperty&&null!==this._currencySourceSymbolInfo&&this._getSymbolForApi(this._currencySourceSymbolInputProperty.value())===e&&(t["currency-id"]=s),t.session=this.sessionId(),t}_onSymbolResolved(e,t,s){this._onCurrencyMayChange()}_onSymbolResolvingStart(e,t){}_onSymbolError(){}_setStatus(e,t){const s=this.isFailed();this._status.setValue(e),e.type===xt.StudyStatusType.Completed?this._wasCompletedBefore=!0:e.type!==xt.StudyStatusType.Error&&e.type!==xt.StudyStatusType.Undefined||(this._wasCompletedBefore=!1),t||(this._statusView?.update((0,
|
||
N.sourceChangeEvent)(this.id())),this._model.updateSource(this),this._statusChanged.fire(this.status())),s!==this.isFailed()&&this._updateAlertCreationAvailable()}_onPropertiesChanged(){this._restarting||(this._inputs?this._tryChangeInputs():this._chartApi&&this._chartApi.isConnected().value()&&this.restart());this._metaInfo.value();this._recreatePaneViews(),(0,Nt.emit)("study_properties_changed",this._id.value())}_lastNonEmptyPlotRow(e){if(!(0,_.isInteger)(e))return Gt.logDebug("_lastNonEmptyPlotRow: incorrect plotIndex"),null;let t=this._lastNonEmptyPlotRowCache[e]??null;if(null!==t)return t;return t=this.data().findLast(((t,s)=>void 0!==s[e]),1e3),null===t?null:(this._lastNonEmptyPlotRowCache[e]=t,t)}_onCurrencyChanged(){"alwaysOff"!==(0,At.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),this.isStarted()&&this._tryChangeInputs(),this._currencyChanged.fire()}_apiInputs(){return this.inputs({keepOptionalSymbolsEmpty:!0})}async _tryChangeInputs(){const e=this.isStarted()&&this._chartApi.isConnected().value(),t=this._allInputsAreValid(),s=((0,p.ensureDefined)((0,_.clone)(this._inputs)),this._apiInputs()),i=JSON.stringify(s),r=i!==JSON.stringify(this._inputs);if(e&&t)try{if(await this._allSymbolsAreResolved(),i!==JSON.stringify(this._apiInputs()))return this._tryChangeInputs();if(this._isStopped())return void(r&&this.disablePriceRangeReady());r&&await this._changeInputsImpl(s,(0,p.ensureDefined)((0,_.clone)(this._inputs)))}catch(e){Gt.logError(`ERROR: ${this._debugId()} _tryChangeInputs: cannot modify study, ${e}`)}else if(e&&!t&&this.stop(!0),!e&&t&&this.start(!0),r){const e=this._calcSources(),t=os(this._metaInfo.value());this._updateParentSources(e,t,!0),this._inputs=s}this._tagsChanged.fire()}_onCurrencyMayChange(){if(null!==this._currencySourceSymbolInputProperty){const e=this.currency();this._updateCurrencySourceSymbolInfo(),e!==this.currency()&&this._onCurrencyChanged()}}_fillPrecalculatedAutoscaleInfo(e,t,s){const i=this._metaInfo.value(),r=this.properties().childs(),n=new Set,o=i.filledAreas||[];for(let e=0;e<o.length;e++){const t=o[e];r.filledAreasStyle.childs()[t.id].childs().visible.value()&&(n.add(t.objAId),n.add(t.objBId))}return i.plots.filter((e=>!(0,L.isPlotWithTechnicalValues)(e))).filter((e=>i.isPlotForceOverlay(e.id)?s.targetPriceScale===this._model.mainSeries().priceScale():s.targetPriceScale===this.priceScale()&&!s.forceOverlayOnly)).filter((e=>n.has(e.id)||this.isPlotVisibleAt(e.id,1))).reduce(((s,i)=>this._applyPlotToPrecalculatedAutoscaleInfo(e,t,s,i)),{fields:[],useMainSeriesRange:!1,baseValueMinMax:null})}_firstSourceOrSeries(){return this._sources.value()[0]??this._series}_skipHistogramBaseOnAutoScale(){return!1}_tryCreateFormatter(e){const t=void 0===e?this.symbolSource().symbolInfo():e;return hs(this._metaInfo.value().format,this._priceScaleByProperties(),t,this.properties().childs().precision.value())}_tryCreateDefaultFormatter(e){return this._tryCreateFormatter(e)}_mergeData(e){return this._invalidateLastNonEmptyPlotRowCache(),this.data().merge(e)}
|
||
_skippedTitleInputs(){return this._hideMatches.filter((e=>e.plotIds.every((e=>0===this._getPlotDisplayValue(e))))).map((e=>e.id))}_getPlotDisplayValue(e){return this.properties()?.childs()?.styles?.childs()?.[e]?.childs()?.display?.value()}_onStudyError(e){performance.clearMarks(`calculate_study_${this.sourceId()}`),this._handleStudyError(this._createStudyError(e)),this._enablePriceRangeReady()}_onStudyCompleted(e){if(performance.getEntriesByName(`calculate_study_${this.sourceId()}`).length){try{const e=performance.measure(`measure_study_${this.sourceId()}`,`calculate_study_${this.sourceId()}`);this._calculationTime.setValue(e.duration)}catch(e){Gt.logError("Error during measuring study calculation time")}performance.clearMarks(`calculate_study_${this.sourceId()}`),performance.clearMeasures(`measure_study_${this.sourceId()}`)}this._studyModified&&(this.clearData(),this._studyModified=!1),this._setStatus({type:xt.StudyStatusType.Completed}),this._statusView?.update((0,N.sourceChangeEvent)(this.id()));const t=this._model.paneForSource(this);this._model.recalculatePane(t,(0,N.sourceChangeEvent)(this.id())),this._updateSources();const s=Vt.InvalidationMask.full();null!==this._model.appliedTimeFrame().value()&&s.lockVisibleTimeRangeOnResize(),this._model.invalidate(s)}_clearData(){this._data.clear(),this._dataRangeUpdated.fire({type:"full"})}_moveData(e){this.data().move(e)}_defaultErrorTitle(){return"Runtime error"}_incrementTurnaround(){this._turnaround="st"+ ++this._turnaroundCounter}_checkTurnaround(e){return e===this._turnaround||e===this._model.mainSeries().seriesSource().turnaround()||e===this.turnaround(!0)}_updateMaxOffsetValue(){let e=-1/0;for(const t of this._metaInfo.value().plots)e=Math.max(this.offset(t.id),e);this._maxOffset.setValue(e)}_rightOffsetToUnixTime(e){if(this._series.bars().size()>=e){const t=(0,p.ensureNotNull)(this._series.bars().lastIndex())-e;return(0,p.ensureNotNull)(this._series.bars().valueAt(t))[0]}return null}_concatPriceAxisViews(){this._priceAxisViews=[...this._priceAxisViewsBase,...this._graphicsPriceAxisViews]}_onStudyLoading(e){this._setStatus({type:xt.StudyStatusType.Loading,startTime:Date.now()}),this._statusView?.update((0,N.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_handleStudyError(e){this.clearData(),this._setStatus(e),this._statusView?.update((0,N.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_createStudyError(e){let t;return t=(0,_.isString)(e)?{error:this._getStudyErrorText(e),title:e.includes("study_not_auth")?"Access error":this._defaultErrorTitle()}:{...e,title:e.title??this._defaultErrorTitle()},(0,xt.createStudyError)(t,this.symbolSource().symbolInfo()?.exchange)}_updateSources(){this._model.updateSource(this),this.hasBarColorer()&&this._model.updateSource(this._model.mainSeries())}_unsubscribeToSessionId(){this._isSubscribedToSessionId&&(this.sessionIdChanged().unsubscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!1)}_onSessionIdChanged(){this.restart(!0)}_recreatePriceStep(){let e=null
|
||
;const t=this._priceScaleByProperties()??this._priceScaleByMetaInfo();null!==t&&(e=1/t),this._priceStep!==e&&(this._priceStep=e,this._priceStepChanged.fire())}_recreatePlotsFormatters(e){this._plotFormatters.clear();const t=this._metaInfo.value(),s=t.format,i=this._priceScaleByProperties(),r=void 0===e?this.symbolSource().symbolInfo():e;for(const[e,n]of Object.entries(t.ohlcPlots??{}))if(n?.format){const t=hs(ls({...s,...n?.format}),i,r,this.properties().childs().precision.value());t&&this._plotFormatters.set(e,t)}for(const[e,n]of Object.entries(t.styles??{}))if(n?.format){const t=hs(ls({...s,...n?.format}),i,r,this.properties().childs().precision.value());t&&this._plotFormatters.set(e,t)}for(const e of t.plots)if((0,L.isOhlcPlot)(e)){const t=this._plotFormatters.get(e.target);t&&this._plotFormatters.set(e.id,t)}}_joinTitlesParts(e){const t=e[1]?e[1].join(", "):"";return e[0]+(t.length>0?" ("+t+")":"")}_getMTFResolutionInputTitle(){const e=this.metaInfo();for(let t=0;t<e.inputs.length;t++){const s=e.inputs[t];if("resolution"===s.type&&s.isMTFResolution)return(0,p.ensureDefined)(this._properties.childs().inputs.child(s.id)).value()}return null}_onDataUpdate(e,t,s){this._studyModified&&(this.clearData(),this._studyModified=!1);const i=(0,C.unpackNonSeriesData)(t.d);return this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>i),(()=>i)).then(this._onDataUnpacked.bind(this,e,t.indexes,s)),this._ongoingDataUpdate}_allSymbolsAreResolved(){const e=this._inputSymbols(),t=[];let s=!1;for(const i of e){const e=this._getSymbolForResolve(i);if(""!==e)if(this._resolvedSymbols[e])s=!0;else{const s=this._resolveSymbol(e,i);t.push(s)}}if(0===t.length){const e=Promise.resolve();return s?e.then((()=>this._symbolsResolved.fire())):e}return Promise.all(t).catch((e=>(this._inputSymbols().includes(e)&&this.stop(!0),this._setStatus({type:xt.StudyStatusType.Error,errorDescription:{error:$t}}),this._model.updateSource(this),Promise.reject("Invalid symbol, "+e)))).then((()=>{this._symbolsResolved.fire(),this._recheckLineToolsActuality()}))}_resolveSymbol(e,t){if(""===e)return Promise.resolve();let s=this._pendingResolveSymbols.get(e);return void 0!==s||(s=new Promise(((s,i)=>{this._onSymbolResolvingStart(e,t),this._chartApi.resolveSymbol((0,j.makeNextSymbolId)(),e,(r=>{switch(this._pendingResolveSymbols.delete(e),r.method){case"symbol_resolved":{this._setStatus({type:xt.StudyStatusType.Undefined});const i=r.params[1];this._resolvedSymbols[e]=i,this._resolvedSymbolsByInput[t]=i,this.invalidateTitleCache(!0),this._onSymbolResolved(e,t,i),s();break}case"symbol_error":if(this._setStatus({type:xt.StudyStatusType.Error,errorDescription:{error:r.params[1]}}),this._onSymbolError(),r.params[1]===G.permissionDenied&&r.params[2]){if(r.params[2]!==G.SymbolErrorPermissionDeniedReason.Symbol)return void this._resolveSymbol(r.params[2],t).then(s);if(r.params[3])return void this._resolveSymbol(r.params[3],t).then(s)}0,i(t)}}))})),this._pendingResolveSymbols.set(e,s)),s}_recheckLineToolsActuality(){const e=this._model.paneForSource(this)
|
||
;null!==e&&e.sourcesByGroup().lineSourcesForAllSymbols().forEach((e=>{e.ownerSource()===this&&e.calcIsActualSymbol()}))}_sendTelemetryCounter(e,t){void 0===t&&(t=this._getTelemetryAdditionalData());const s={count:1,additional:t};telemetry.sendChartReport(e,s)}_getTelemetryAdditionalData(){let e="";const t=this._metaInfo.value();return t.pine&&t.pine.version&&t.shortId.indexOf("USER")>=0&&(e="_v"+t.pine.version),{symbol:this.series().actualSymbol(),resolution:this.series().interval(),study:t.shortId+e}}_onSourceFormatterChanged(){null===this._formatter&&(null!==this._priceScale&&this._priceScale.updateFormatter(),this._formatterChanged.fire())}_onSourcePriceStepChanged(){null===this._priceStep&&this._priceStepChanged.fire()}_bandsFirstValue(e){const t=this._metaInfo.value();if(!t.bands)return null;for(let s=0;s<t.bands.length;s++){const t=(0,p.ensureDefined)(this._properties.childs().bands).childs()[s];if(t.childs().visible.value()){const s=t.childs().value.value();if(e&&0===s)continue;if(null!==s)return s}}return null}_prepareInputs(e){(0,p.assert)(!!e,"options not set");const t=this.metaInfo(),s={},i=e.allowedInputTypes?new Set(e.allowedInputTypes):null,r=!(!e.asObject||!e.useNameAndGroupAsKey);for(let n=0;n<t.inputs.length;n++){const o=t.inputs[n];if(null!==i&&!i.has(o.type))continue;if(o.isFake&&e.skipFakeInputs)continue;if(o.isMTFResolution&&e.noResolution)continue;if(void 0!==e.displayMask&&!((0,p.ensureDefined)(o.display)&e.displayMask))continue;if(e.skipHiddenInputs&&(!e.doNotSkipHiddenWithMigrate||!o.migrate)){let t=!1;switch(o.type){case"bool":t=e.skipBooleanInputs;break;case"color":t=e.skipColorInputs;break;case"time":t=e.skipTimeInputs;break;case"text_area":t=e.skipTextareaInputs;break;default:t=Boolean(o.isHidden)}if(t)continue}if(void 0!==o.groupId&&-1!==e.skippedGroups.indexOf(o.groupId))continue;if(-1!==e.skippedInputs.indexOf(o.id))continue;const a=this._prepareInput(o,e);if("symbol"===o.type&&e.skipOptionalEmptySymbolInputs&&""===a)continue;let l;r&&(l=v(o),void 0!==l&&l in s&&(l=void 0)),s[l||o.id]=(0,_.clone)(a)}return s}_prepareInputValue(e,t){const s=e.id,i=this._properties.childs();if(t.valuesAsIsFromProperties)return i.inputs.childs()[s].value();const r=this._metaInfo.value();if("symbol"===e.type){const r=t&&t.symbolsForDisplay,n=i.inputs.childs()[s].value();let o=r?n:this._getSymbolForApi(n),a=this._resolvedSymbols?.[this._getSymbolForResolve(o)]??null;if(""===o&&e.optional){if(t&&t.keepOptionalSymbolsEmpty)return o;o=this._model.mainSeries().symbol(),a=this._model.mainSeries().symbolInfo()}if(r)if(a)if(Zt){switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":o=a.description;break;case"ticker-and-description":o=`${a.name}, ${a.description}`;break;case"ticker":o=a.name}}else o=(0,Tt.symbolTitle)(a,t.noExchanges);else ts&&(o="");else a&&(o=a.ticker||a.full_name),!this.isPine()&&t&&t.symbolsForChartApi&&(o=this.getSymbolString(o));return o}if("bar_time"===e.type){let e=i.inputs.childs()[s].value();if(e<0){const t=this._rightOffsetToUnixTime(-e);e=t&&t>=0?t:e}
|
||
return e}if(r.isTVScript||r.pine){if("text"===s)return r.defaults.inputs?.text??"";if("pineId"===s)return r.scriptIdPart;if("pineVersion"===s)return r.pine?r.pine.version:"-1";if("color"===e.type&&r.isRGB){const e=i.inputs.childs()[s].value();return(0,I.colorToInteger)(e)}if("price"===e.type){const e=i.inputs.childs()[s].value();return t.priceInputsForDisplay?this.formatter().format(e):e}}return i.inputs.childs()[s].value()}_getStudyIdWithLatestVersion(){return A.StudyMetaInfo.getStudyIdWithLatestVersion(this.metaInfo())}_debugId(){const e=[];e.push(this._id.value());const t=this._metaInfo.value();return e.push(t.fullId),e.push(t.description),JSON.stringify({study:e})}_hasAvailableAlertPlots(){return!1}_hasAlertConditions(){return!1}_hasAlertFunction(){return!1}async _updateParentSources(e,t,s){if(this._sources.value().forEach((e=>e.unsetChild(this))),s&&await Promise.all(e.map((e=>e.isStarted()?Promise.resolve():e.start(!1,!0)))),e.forEach((e=>e.setChild(this))),this._setSources(e),this._recreatePriceFormattingDependencies(),0!==t&&this._sources.value().length<=1){const e=this._firstSourceOrSeries(),t=this._priceScale,s=(0,p.ensureNotNull)(e.priceScale());if(t!==s){const t=this._model.paneForSource(this),i=(0,p.ensureNotNull)(this._model.paneForSource(e));t===i&&i.move(this,s,!0)}}}_calcSources(){const e=this._properties.childs().inputs.state();return A.StudyMetaInfo.getSourceIdsByInputs(this._metaInfo.value().inputs,e).map((e=>{if("high"===e||"open"===e||"low"===e||"close"===e||"hl2"===e||"ohl3"===e||"ohlc4"===e)return null;return this._model.allStudies().find((t=>t.canHaveChildren()&&t.id()===e))??null})).filter(_.notNull)}_isStopped(){return!this.isStarted()}_onDataUnpacked(e,t,s,i){if(this._isDestroyed)return;"nochange"!==t&&this._processPlotOffsets(i),this._transformData(e);const r=this._mergeData(e);null!==i&&(i.indexes_replace?((0,p.assert)("nochange"!==t),this._graphics.replaceIndexesTo(t)):("nochange"!==t&&this._graphics.replaceIndexesTo(t),void 0!==i.graphicsCmds&&this._graphics.processCommands(i.graphicsCmds))),this._onDataUpdated(e,i,t,r&&r.index),this.priceRangeReady()||this._enablePriceRangeReady()}_processPlotOffsets(e){if(e&&e.indexes_replace)return;const t=this._serverPlotOffsets.value();this._serverPlotOffsets.setValue(e&&e.offsets||{}),(0,i.default)(t,this._serverPlotOffsets.value())||this.updateAllViews((0,N.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._updateMaxOffsetValue()}_applyPlotToPrecalculatedAutoscaleInfo(e,t,s,i){const r=i.id,n=this._properties.childs().styles.childs()[r],o=(0,L.isShapesPlot)(i)||(0,L.isCharsPlot)(i);s.useMainSeriesRange=s.useMainSeriesRange||(0,L.isArrowsPlot)(i);let a=(0,L.isLinePlot)(i)||(0,L.isOhlcPlot)(i);if(o){const e=(0,p.ensureDefined)(n).childs().location.value(),t=[D.MarkLocation.Absolute,D.MarkLocation.Top,D.MarkLocation.Bottom].indexOf(e)<0;s.useMainSeriesRange=s.useMainSeriesRange||o&&t,a=a||e===D.MarkLocation.Absolute}if(!a)return s;const l={name:r,offset:this.offset(r)},h=n.childs().plottype.value()
|
||
;if(!this._skipHistogramBaseOnAutoScale()&&[L.LineStudyPlotStyle.Histogram,L.LineStudyPlotStyle.Columns,L.LineStudyPlotStyle.Area].indexOf(h)>=0){const i=(this._metaInfo.value().styles??{})?.[r]?.histogramBase;if(void 0===i)return s;const n=this.data().minMaxOnRangeCached(e,t,[l]);return(0,_.isNumber)(i)&&null!==n&&(s.baseValueMinMax=(0,T.mergeMinMax)(s.baseValueMinMax,{min:i,max:i}),s.baseValueMinMax=(0,T.mergeMinMax)(s.baseValueMinMax,n)),s}return s.fields.push(l),s}async _onSourceInputChanged(){if(!this.isStarted()){this._calcSources();Kt}}_buildInputs(e){(0,p.assert)(!!e,"options not set");let t={};try{t=this._prepareInputs(e)}catch(e){Gt.logWarn("Failed to prepare study inputs: "+e)}if(e.asObject){const e={};return Object.keys(t).forEach((s=>{null!=t[s]&&(e[s]=t[s])})),e}{const e=[];return Object.keys(t).forEach((s=>{null!=t[s]&&e.push(t[s])})),e}}_prepareInput(e,t){const s=this._prepareInputValue(e,t);return!e.isFake||t.fakeInputsForDisplay||t.onlyAtomValues?s:{v:s,f:!0,t:e.type}}_plotsForAlert(){return[]}_formatterStateForAlert(){try{const e=this.formatter();return FormattersSerializer.isSerializable(e)?FormattersSerializer.serialize(e):null}catch{return null}}_calcIsActualInterval(){const e=this._isActualInterval;this._isActualInterval=(0,Ct.isActualInterval)(this._series.intervalObj().value(),this._properties.childs().intervalsVisibilities),e!==this._isActualInterval&&(this._onIsActualIntervalChange.fire(),this._visibleChanged(),this.processHibernate())}_visibleChanged(){this._series.invalidateBarColorerCache()}_getNonPriceParent(){const e=this._sources.value();for(const t of e)if(t instanceof us){const e=t.metaInfo();return e.is_price_study&&"Compare@tv-basicstudies"!==e.id?t._getNonPriceParent():t}return null}_updateInputValue(e,t){const s=this._properties.childs().inputs.childs();if(s[t.id])if("price"===t.type)s[t.id].setValue(e.price);else if("time"===t.type){const i=this._model.timeScale().indexToTimePoint(e.index);null!==i&&s[t.id].setValue(1e3*i)}}_initializeStudyInputsPaneViews(){}_updateCurrencySourceSymbolInfo(){null!==this._currencySourceSymbolInputProperty&&(this._currencySourceSymbolInfo=this._resolvedSymbolsByInput[this._currencySourceSymbolInputProperty.value()]??null)}_initializeCurrencySource(){const e=this.metaInfo(),t="symbolInputSymbolSource"===e.symbolSource?.type&&e.symbolSource?.inputId,s=e.inputs.find((e=>e.id===t));if("string"==typeof t&&"symbol"===s?.type&&e.is_price_study){const e=this._properties.childs().inputs.childs()[t];void 0!==e&&(e.subscribe(this,this._onCurrencyMayChange),this._currencySourceSymbolInputProperty=e)}}_recreatePaneViews(){this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this._createViews(),this.recalculate(),this.updateAllViews((0,N.sourceChangeEvent)(this.id()))}async _pinePatchProps(){throw new Error("Not implemented")}_areStudyInputsModified(e){if(0===Object.keys(e).length)return!1;if(void 0===this._oldStudyInputs)return!0;const t=Object.keys(this._oldStudyInputs);(0,
|
||
p.assert)(t.length===Object.keys(e).length,"keys quantity should be equal");for(const s of t)if((0,p.assert)(e.hasOwnProperty(s),`key '${s}' should exist in study inputs`),(0,p.ensureDefined)(this._oldStudyInputs)[s]!==e[s])return!0;return!1}_onVisibleTimeRangeInputsChanged(e){null!==e?this._updateVisibleTimeRangeInputs(e):this.isStarted()&&this._chartApi.isConnected().value()&&this.stop(!0)}_updateVisibleTimeRangeInputs(e,t=!0){const s={first_visible_bar_time:e.firstVisibleBarTime,last_visible_bar_time:e.lastVisibleBarTime,subscribeRealtime:e.subscribeRealtime},i=this.metaInfo().inputs,r=[];for(const e of i)s.hasOwnProperty(e.id)&&r.push(e.id);const n=this.properties().childs().inputs;for(const e of r)n.childs()[e].setValueSilently(s[e]);t&&r.length>0&&n.fireChanged()}_getStudyErrorText(e){const t=e.split(":",2)[0];return decodeURIComponent(t)}_priceScaleByProperties(){if("default"===this.properties().childs().precision.value())return null;const e=parseInt(this.properties().childs().precision.value());return isFinite(e)?Math.pow(10,e):null}_priceScaleByMetaInfo(){const e=this.metaInfo().format,t="inherit"!==e.type?e.precision:void 0,s=(0,_.isNumber)(t)?Math.pow(10,t):void 0;if("price"===e.type||"percent"===e.type)return s||100;if("volume"===e.type){if(void 0===e.precision){const e=this.series().symbolInfo();if(null!==e&&(0,_.isNumber)(e.volume_precision))return Math.pow(10,e.volume_precision)}return 1}return"inherit"===e.type||Gt.logWarn("Unsupported format type: "+e.type),null}_inputSymbols(){return this.metaInfo().inputs.filter((e=>"symbol"===e.type)).map((e=>(0,p.ensureDefined)(this._properties.childs().inputs.child(e.id)).value()))}_studySpec(e){return{id:this._metaInfo.value().id,child:e??this.isChildStudy(),fundamental:!1}}_onFormatterPropsChanged(){this._recreatePriceFormattingDependencies()}_setSources(e){this.invalidateTitleCache(),this._sources.setValue(e),this._onParentSourcesChanges.fire()}async _awaitForMetaInfo(){const e={resolver:()=>{}},t=()=>e.resolver();try{await Promise.race([new Promise(((e,t)=>{setTimeout((()=>t(new Error("Timeout"))),3e3)})),await new Promise((s=>{e.resolver=s,this.metaInfoWV().subscribe(t)}))])}catch(e){throw e}finally{this.metaInfoWV().unsubscribe(t)}}}},51752:(e,t,s)=>{s.d(t,{plotShapesData:()=>r});var i=s(11542);const r={shape_arrow_down:{guiName:i.t(null,void 0,s(34247)),id:"shape_arrow_down",paneRendererClass:"PaneRendererArrowDown",pineName:"shape.arrowdown",icon:"arrow_down"},shape_arrow_up:{guiName:i.t(null,void 0,s(45523)),id:"shape_arrow_up",paneRendererClass:"PaneRendererArrowUp",pineName:"shape.arrowup",icon:"arrow_up"},shape_circle:{guiName:i.t(null,void 0,s(91944)),id:"shape_circle",paneRendererClass:"PaneRendererCircleShape",pineName:"shape.circle",icon:"circle"},shape_cross:{guiName:i.t(null,void 0,s(6969)),id:"shape_cross",paneRendererClass:"PaneRendererCrossShape",pineName:"shape.cross",icon:"cross"},shape_diamond:{guiName:i.t(null,void 0,s(15179)),id:"shape_diamond",paneRendererClass:"PaneRendererDiamond",pineName:"shape.diamond",icon:"diamond"},shape_flag:{
|
||
guiName:i.t(null,void 0,s(33885)),id:"shape_flag",paneRendererClass:"PaneRendererFlagShape",pineName:"shape.flag",icon:"flag"},shape_label_down:{guiName:i.t(null,void 0,s(85924)),id:"shape_label_down",paneRendererClass:"PaneRendererLabelDown",pineName:"shape.labeldown",icon:"label_down"},shape_label_up:{guiName:i.t(null,void 0,s(49857)),id:"shape_label_up",paneRendererClass:"PaneRendererLabelUp",pineName:"shape.labelup",icon:"label_up"},shape_square:{guiName:i.t(null,void 0,s(66205)),id:"shape_square",paneRendererClass:"PaneRendererSquare",pineName:"shape.square",icon:"square"},shape_triangle_down:{guiName:i.t(null,void 0,s(76152)),id:"shape_triangle_down",paneRendererClass:"PaneRendererTriangleApexDown",pineName:"shape.triangledown",icon:"triangle_down"},shape_triangle_up:{guiName:i.t(null,void 0,s(21236)),id:"shape_triangle_up",paneRendererClass:"PaneRendererTriangleApexUp",pineName:"shape.triangleup",icon:"triangle_up"},shape_xcross:{guiName:i.t(null,void 0,s(11316)),id:"shape_xcross",paneRendererClass:"PaneRendererXCross",pineName:"shape.xcross",icon:"x_cross"}}}}]); |