48 lines
141 KiB
JavaScript
48 lines
141 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[7670],{53660: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),u(e[s+i])&&i++,l(e[s+i])&&i++,h(e[s+i])&&i++,c(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 u(e){return"string"==typeof e&&-1!==r.indexOf(e.charCodeAt(0))}function c(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("")}},93700:(e,t,s)=>{s.d(t,{HHistBasedValuesProvider:()=>f});var i=s(97486),r=s(85842),n=s(45958),o=s(44850),a=s(54951),l=s(34192),h=s(78795),u=s(62116),c=s(62950);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=c.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(),u=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,u,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,u.isLineToolName)(a.tool.value())||null!==this._model.lineBeingEdited())}}},3405:(e,t,s)=>{s.d(t,{StudyBaseWindowView:()=>n});var i=s(88990),r=s(65366);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}}},41252:(e,t,s)=>{s.d(t,{StudyChartFloatingTooltipView:()=>n});var i=s(7321),r=s(65366);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})))}}},59217:(e,t,s)=>{s.d(t,{StudyDataWindowView:()=>a});var i=s(3405),r=s(53416),n=s(93700);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)}}},49695:(e,t,s)=>{s.d(t,{StudyStatusProvider:()=>n});var i=s(91599),r=(s(32137),s(79925));i.t(null,void 0,s(37966));class n extends r.StudyStatusProviderBase{sourceStatusText(){this._source.status();return super.sourceStatusText()}}},53416:(e,t,s)=>{s.d(t,{StudyValuesProvider:()=>v});var i=s(97486),r=s(16905),n=s(45958),o=s(82347),a=s(44850),l=s(62116),h=s(54951),u=s(65164),c=s(49545),d=s(3774),p=s(85842),_=s(62950),f=s(65366);const m=n.CheckMobile.any(),y=(0,r.isFeaturesetEnabled)("hide_last_na_study_output"),g=(0,r.isFeaturesetEnabled)("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,u.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,u.isOhlcPlot)(e)?e.target:i;this._colorProviders.set(r,(0,c.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,u.isOhlcPlot)(o))a=o.target||a,n=(0,p.ensureDefined)(l.ohlcPlots.childs()[a].childs().color).value();else if((0,u.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 c=this._colorProviders.get(a),d=c&&c.getPlotPointStyle(t);return d&&((0,u.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(),n=this._studyProperties;if(null!==r){const e=this._searchNearestLeft?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact;for(const i of t){
|
||
const t=n.styles.childs()[i.id]?.childs().display.value();if(0===t)continue;const o=this._study.nearestIndex(r,e,i.index+1);if(void 0===o)continue;const a=o+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 c=this._study.priceScale();if(!this._study.isVisible()||null===e||null===c||c.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)(n.styles.childs()[t]),c=h.childs().display.value();if(s.visible=0!==c,!s.visible)continue;const _=h.hasChild("plottype")?h.child("plottype")?.value():null,m=this._searchNearestLeft&&this._isFundamental&&(_===u.LineStudyPlotStyle.StepLine||_===u.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,o.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())}}},67670:(e,t,s)=>{s.r(t),s.d(t,{StudiesChunkName:()=>es,Study:()=>ys,emptyPrecalculatedAutoscaleInfo:()=>ss,studyFormatter:()=>fs});var i=s(83991),r=s(57600),n=s(35558),o=s(90570),a=s(16905);const l=e=>e instanceof Date,h=e=>null!=e&&"object"==typeof e,u=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),c=e=>h(e)&&(e=>0===Object.keys(e).length)(e),d=(e,t)=>{if(e===t)return{};if(!h(e)||!h(t))return t;const s=Object.keys(e).reduce(((e,s)=>(u(t,s)||(e[s]=void 0),e)),Object.create(null));return l(e)||l(t)?e.valueOf()==t.valueOf()?{}:t:Object.keys(t).reduce(((s,i)=>{if(!u(e,i))return s[i]=t[i],s;const r=d(e[i],t[i]);return!c(r)||l(r)||!c(e[i])&&c(t[i])?(s[i]=r,s):s}),s)},p=d;var _=s(85842),f=s(7321),m=s(73775),y=s(42897),g=s(91599),v=s(21515),S=s(35313);function b(e){const{name:t,group:s}=e;return t.length>0?`${s?`${s}.`:""}${t}`:void 0}var P=s(22872);var w=s(70397),I=s(89659),x=s(89772),C=s(36870),V=s(82347),M=s(95168),T=s(14520),R=s(46675),A=(s(62352),s(43459)),O=s(33578),D=s(55531),N=s(4865),B=s(6620),F=s(95359),k=s(44850),E=s(62565),L=s(3405),H=s(9840),W=s(53416),z=s(93700);class U{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 z.HHistBasedValuesProvider(e,t,s):new W.StudyValuesProvider(e,t,s)}}var j=s(65164);class G extends L.StudyBaseWindowView{constructor(e,t){super(e,t),this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,(()=>this.update((0,H.sourceChangeEvent)(e.id()))));const s=this._study.properties();s.childs().showLegendValues.subscribe(this,(()=>this.update((0,H.sourceChangeEvent)(e.id()))));const i=this._study.metaInfo().plots,r=new Set;i.forEach((t=>{if((0,j.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,H.sourceChangeEvent)(e.id()))))}else(0,j.isPlotSupportDisplay)(t)&&s.childs().styles.childs()[t.id]?.childs().display.subscribe(this,(()=>this.update((0,H.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,j.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,j.isPlotSupportDisplay)(t)&&e.childs().styles.childs()[t.id]?.childs().display.unsubscribeAll(this)}))}_createValuesProvider(e,t){return new U(e,t)}}var $=s(54951),K=s(3811),Y=s(66085),X=s(95847),q=s(36637),J=s(49695);class Z{constructor(e,t,s){this._study=e,this._model=t,this._valuesProvider=new W.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 Q=s(65366),ee=s(20707);function te(e,t){return e.studyId.localeCompare(t.studyId)}function se(e){const t=new Set,s=[];return e.forEach((e=>{t.has(e.studyId)||(t.add(e.studyId),s.push(e))})),s}function ie(e){const t=e.model().mainSeries();return{studyId:(0,_.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>ie(e)))}}var re=s(16570),ne=s(99680),oe=s(57507);class ae extends oe.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 le=s(49545),he=s(93299);class ue extends he.StudyForceOverlayPlotView{constructor(e,t,s,i){super(t,s,i),this._items=[],this._invalidated=!0,this._isMarkersEnabled=(0,a.isFeaturesetEnabled)("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,_.assert)((0,j.isBgColorerPlot)(t),"Plot '"+this._plotName+"' is not a background colorer!"))}this._colorProvider=(0,le.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i)}items(){return this._items}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){if(1&~(0,_.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 ne.CompositeRenderer;return t.append(new ae(e)),t}_scalesReady(){const e=this._model.timeScale(),t=this._priceScale();return!e.isEmpty()&&null!==t&&!t.isEmpty()}_getTranspValue(){const e=(0,_.ensureDefined)(this._study.properties().childs().styles.childs()[this._plotName]).childs();let t=0;return e.transparency&&(t=e.transparency.value(),t=(0,f.isNumber)(t)?t:40),t}_updateImpl(){this._items=[],(0,_.assert)(this._scalesReady(),"Scales must be ready!");const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return;const t=this._getTranspValue();let s=(0,_.ensureDefined)(this._series.nearestIndex(e.firstBar(),k.PlotRowSearchMode.NearestRight)),i=(0,_.ensureDefined)(this._series.nearestIndex(e.lastBar(),k.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,f.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,V.generateColor)((0,_.ensureDefined)(a.colors[1]),o)),this._items.push(n)}this._model.timeScale().fillBarBorders(this._items)}}var ce,de=s(59793),pe=s(71367),_e=s(30220),fe=s(85728),me=s(88858),ye=s(95953),ge=s(53598),ve=s(57415),Se=s(91069),be=s(97486),Pe=s(95385),we=s(83077),Ie=s(30598),xe=s(31048),Ce=s(35433),Ve=s(91903);!function(e){e.Left="left",e.Center="center",e.Right="right"}(ce||(ce={}));const Me=(0,Ve.createDisconnectedCanvas)(document,(0,Ce.size)({width:0,height:0}),1);class Te{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,xe.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,_.ensureNotNull)(Me.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,Ve.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 Re extends Ie.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,xe.makeFont)(t,r,o?"italic":"",n?"bold":""),h=(0,Ie.getDefault3)(this._map,a,i,l,new Map);let u=h.get(s);return void 0!==u||(this._size>=this._maxSize?this._deleteFirstKey():++this._size,this._keysQueue.push([l,i,a,s]),u=new Te(s,n,o,r,t,i,a),h.set(s,u)),u}_deleteFirstKey(){const e=this._keysQueue.shift(),[t,s,i,r]=e,n=(0,_.ensureDefined)(this._map.get(i)),o=(0,_.ensureDefined)(n.get(s)),a=(0,_.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 Ae,Oe=s(14491),De=s(45958);!function(e){e.Transparent="rgba(0, 0, 0, 0)"}(Ae||(Ae={}));class Ne extends oe.BitmapCoordinatesPaneRenderer{constructor(e,t={skipRenderingOptimizations:!1}){super(),this._items=[],this._barSpacing=0,this._vertOffset=0,this._textCache=t.textCache||new Re(5e3),this._drawOperation=t.skipRenderingOptimizations?this._drawWithoutOptimizations.bind(this):this._drawWithOptimizations.bind(this),null!==e&&this.setData(e)}hitTest(e){const t=we.HitTarget.Regular;let s=null;for(const i of this._items){if(!i)continue;const r=this._calcBoundingBox(i);if(r&&(0,Se.pointInBox)(e,r)){const e={tooltip:this._getTooltip(i,r)};s=new we.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 ve.Point(e.center-n,o+a),u=new ve.Point(e.center+n,o+l);return(0,ve.box)(h,u)}_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 ve.Point(s,r),a=new ve.Point(i,n);return(0,ve.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,be.isNaN)(t.y))continue;const e=void 0===t.width?(0,_.ensureDefined)(this._width):t.width,s=void 0===t.height?(0,_.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:Pe.HorizontalAlign.Center,vertAlign:r>0?Pe.VerticalAlign.Top:Pe.VerticalAlign.Bottom}};s.paintTo(e,a)}_drawWithOptimizations(e){let t,s,i=null,r=!1;for(const n of this._items)(0,be.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||De.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,be.isNaN)(t.y)||this._drawItemText(e,t)}_drawWithoutOptimizations(e){let t,s;for(const i of this._items){if((0,be.isNaN)(i.y))continue;const r=(0,_.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,Ve.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??Oe.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 Be extends Ne{_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 Fe extends Ne{_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 ke extends Fe{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),u=Math.round(t.center*i)+n,c=t.vertOffset,d=Math.round((t.y+c+o*h/2)*r)+n,p=(0,fe.ceiledEven)(a*i),_=p/2,f=Math.round(h*r),m=Math.round(l*r);s.translate(u,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(-u,-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,u=new ve.Point(o,l),c=new ve.Point(a,h);let d=(0,ve.box)(u,c);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}_calculateWidth(){return Math.round(this._barSpacing/4)}}const Ee=2*Math.PI;class Le extends Fe{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,_.ensureDefined)(a)},location:{x:r,y:Math.floor(o),horzAlign:Pe.HorizontalAlign.Center,vertAlign:Pe.VerticalAlign.Middle}};s.paintTo(e,l)}}class He{constructor(e,t,s,i){this.prevPointSignX=e,this.prevPointSignY=t,this.nextPointSignX=s,this.nextPointSignY=i}}var We;!function(e){e.rightUp=new He(1,0,0,1),e.rightDown=new He(0,1,-1,0),e.leftDown=new He(-1,0,0,-1),e.leftUp=new He(0,-1,1,0)}(We||(We={}));class ze extends Fe{_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,u=a,c=a+s,d=new ve.Point(l,u),p=new ve.Point(h,c);let _=(0,ve.box)(d,p);const f=super._calcBoundingBox(e);return f&&(_=this._unionBox(_,f)),_}}var Ue=s(93976);const je=new Map;je.set("PaneRendererArrowUp",class extends ke{_isUp(){return!0}}),je.set("PaneRendererArrowDown",class extends ke{_isUp(){return!1}}),je.set("PaneRendererCircleShape",class extends Fe{_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,Ee,!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 ve.Point(n,a),u=new ve.Point(o,l);let c=(0,ve.box)(h,u);const d=super._calcBoundingBox(e);return d&&(c=this._unionBox(c,d)),c}}),je.set("PaneRendererCrossShape",class extends Be{_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,u=this._lineWidth(e),c=u%2?.5:0,d=Math.round(a*i);let p=Math.round((a+n)*i);(p-d)%2!=u%2&&(p+=1);const _=Math.floor((d+p)/2)+c,f=Math.round(h*r);let m=Math.round((h+o)*r);(m-f)%2!=u%2&&(m+=1);const y=Math.floor((f+m)/2)+c;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,u=new ve.Point(o,l),c=new ve.Point(a,h);let d=(0,ve.box)(u,c);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}),je.set("PaneRendererDiamond",class extends Fe{_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 ve.Point(n,a),u=new ve.Point(o,l);let c=(0,ve.box)(h,u);const d=super._calcBoundingBox(e);return d&&(c=this._unionBox(c,d)),c}}),je.set("PaneRendererFlagShape",class extends Fe{_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,u=o+s,c=new ve.Point(a,h),d=new ve.Point(l,u);let p=(0,ve.box)(c,d);const _=super._calcBoundingBox(e);return _&&(p=this._unionBox(p,_)),p}}),je.set("PaneRendererLabelUp",class extends Le{_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 ve.Point(t,i),o=new ve.Point(s,r);return(0,ve.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 u=Math.round(t.center*i)+o,c=Math.round((t.y+t.vertOffset)*r)+n,d=u-l,p=Math.round((t.y+t.vertOffset+a)*r)+n,_=u+l,f=u+h,m=Math.round((t.y+t.vertOffset+a+t.shapeHeight)*r)+n,y=u-h;s.moveTo(d,p),s.lineTo(u,c),s.lineTo(_,p),t.shapeWidth<=2*a?(s.lineTo(f,p),this._drawCorner(e,f,m,We.rightDown),this._drawCorner(e,y,m,We.leftDown),s.lineTo(y,p)):(this._drawCorner(e,f,p,We.rightUp),this._drawCorner(e,f,m,We.rightDown),this._drawCorner(e,y,m,We.leftDown),this._drawCorner(e,y,p,We.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}}),je.set("PaneRendererLabelDown",class extends Le{_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 ve.Point(t,i),o=new ve.Point(s,r);return(0,ve.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 u=Math.round(t.center*i)+o,c=Math.round((t.y+t.vertOffset)*r)+n,d=u+l,p=Math.round((t.y+t.vertOffset-a)*r)+n,_=u-l,f=u+h,m=Math.round((t.y+t.vertOffset-t.shapeHeight-a)*r)+n,y=u-h;s.moveTo(d,p),s.lineTo(u,c),s.lineTo(_,p),t.shapeWidth<=2*a?(s.lineTo(y,p),this._drawCorner(e,y,m,We.leftUp),this._drawCorner(e,f,m,We.rightUp),s.lineTo(f,p)):(this._drawCorner(e,y,p,We.leftDown),this._drawCorner(e,y,m,We.leftUp),this._drawCorner(e,f,m,We.rightUp),this._drawCorner(e,f,p,We.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}}),je.set("PaneRendererSquare",class extends Fe{_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,u=l-a,c=h-a,d=l+a,p=h+a;s.rect(u,c,d-u,p-c)}_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,u=new ve.Point(o,l),c=new ve.Point(a,h);let d=(0,ve.box)(u,c);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}),je.set("PaneRendererTriangleApexUp",class extends ze{_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,u=Math.max(1,Math.floor(i)),c=u%2?.5:0;let d=Math.round(n*i);d%2!=u%2&&(d+=1);const p=Math.round(t.center*i)+c,_=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,_)}}),je.set("PaneRendererTriangleApexDown",class extends ze{_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,u=Math.max(1,Math.floor(i)),c=u%2?.5:0;let d=Math.round(n*i);d%2!=u%2&&(d+=1);const p=Math.round(t.center*i)+c,_=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,_)}}),je.set("PaneRendererXCross",class extends Be{_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,u=new ve.Point(o,l),c=new ve.Point(a,h);let d=(0,ve.box)(u,c);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}});class Ge extends Ue.StudyPaneViewInplaceUpdatable{constructor(e,t,s,i){super(t,s,i),this._renderer=null,this._shapesRenderer=null,this._selectionRenderer=null,this._isMarkersEnabled=(0,a.isFeaturesetEnabled)("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,_.ensureDefined)(e.metaInfo().styles?.[this._plotName]),this._colorProvider=(0,le.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i),this._selectionIndexer=new me.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 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 u=this._series.nearestIndex(i.firstBar(),k.PlotRowSearchMode.NearestRight),c=this._series.nearestIndex(i.lastBar(),k.PlotRowSearchMode.NearestLeft);if(void 0===u||void 0===c)return!1;n>0?(u-=n,c+=n):(u+=n,c-=n);const d=this._study.getMinFirstBarIndexForPlot(this._plotName);if(d>c)return!0;u=Math.max(d,u);const p=this._getTranspValue(),f=this._study.properties().childs().styles.childs()[this._plotName].childs(),m=f.color.value(),y=f.textColor?f.textColor.value():void 0,g=m,S=m,b=void 0===y?void 0:y,P=(0,_.ensureNotNull)(this._plotIndex),w=(0,ge.createEmptyStyle)(),I=h??(0,_.ensureNotNull)(r.firstIndex()),x=r.rangeIterator(I,(0,_.ensureNotNull)(r.lastIndex())+1);let C=(0,v.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.price)){if(this._colorProvider.isColorDefined()){i.style={color:g,borderColor:S,textColor:b};const e=this._colorProvider.getPlotPointStyle(t,w);this._fillItemWithPointStyle(i,e,p)}}C++}return this._updateImplLight(),!0}_fillItemWithPointStyle(e,t,s){const i=(0,_.ensureDefined)(e.style);if(void 0!==t.colors[0]){i.color=(0,V.generateColor)((0,_.ensureDefined)(t.colors[0]),s);const e=s>9?s-10:0;i.borderColor=(0,V.generateColor)(i.color,e)}void 0!==t.colors[2]&&(i.textColor=(0,V.generateColor)((0,_.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,V.generateColor)(a.color.value(),r),i.height=o,i.vertOffset=h,i.visibleItemsRange={startItemIndex:e,endItemIndex:t};const u=a.plottype.value(),c=_e.plotShapesData[u],d=new ne.CompositeRenderer;c&&(this._shapesRenderer?this._shapesRenderer.setData(i):(this._shapesRenderer=this._createRenderer(c.paneRendererClass,i),d.append(this._shapesRenderer))),this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=h,d.append(new pe.SelectionRenderer(this._selectionData))),this._renderer=d}_createRenderer(e,t){const s=je.get(e);return new((0,_.ensureDefined)(s))(t)}_getSeriesVal(e,t){const s=(0,ye.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,f.isNumber)(e)?e:50);const s=t.styles.childs()[this._plotName].childs();return s.transparency&&(e=s.transparency.value(),e=(0,f.isNumber)(e)?e:50),(0,fe.clamp)(e,0,100)}_createItem(e,t,s,i,r){const n=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),o={price:NaN,timePointIndex:e+r};if((null===t||0===t)&&n!==E.MarkLocation.Absolute)return o;if(null==t)return o;let a=NaN
|
||
;switch(n){case E.MarkLocation.AboveBar:{const t=this._getLocationPrice(e,s,r);if(null===t)return o;a=t;break}case E.MarkLocation.BelowBar:{const t=this._getLocationPrice(e,i,r);if(null===t)return o;a=t;break}case E.MarkLocation.Absolute:a=(0,_.ensureNotNull)(t);break;case E.MarkLocation.Top:case E.MarkLocation.Bottom:a=0;break;default:throw new Error("Bad value: "+n)}return{y:NaN,price:a,timePointIndex:e+r}}_dependsOnSeriesData(){const e=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();return e===E.MarkLocation.AboveBar||e===E.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!==E.MarkLocation.Absolute)return null;const i=this._study.offset(this._plotName),{hiPlot:r,loPlot:n}=this._hiLoPlots();switch(s){case E.MarkLocation.AboveBar:return this._getLocationPrice(e.index,r,i);case E.MarkLocation.BelowBar:return this._getLocationPrice(e.index,n,i)}return super._getValueForUpdating(e)}_convertItemsToCoordinates(e,t,s,i){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,u=e=>{for(let t=s;t<i;t++)isNaN(this._items[t].price)||(this._items[t].y=e)};switch(r){case E.MarkLocation.Top:u(l);break;case E.MarkLocation.Bottom:u(h);break;default:e.fillYCoordinates(this._items,t,{startItemIndex:s,endItemIndex:i})}}_calculateVerticalOffset(e,t){let s=0;switch(e){case E.MarkLocation.AboveBar:case E.MarkLocation.Bottom:s=-t;break;case E.MarkLocation.BelowBar:case E.MarkLocation.Top:s=t}return(0,_.ensureNotNull)(this._priceScale()).isInverted()&&(s*=-1),s}_calculateShapeHeight(e,t){let s=e;switch(t){case j.PlotSymbolSize.Tiny:s=.3*e;break;case j.PlotSymbolSize.Small:s=.6*e;break;case j.PlotSymbolSize.Normal:s=e;break;case j.PlotSymbolSize.Large:s=1.5*e;break;case j.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,_.ensureNotNull)(this._series.data().last()).index);return this._getSeriesVal(t,i)}}class $e extends Ge{_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,V.generateColor)(s.color.value(),n),u=n>19?n-10:0,c=this._calculateVerticalOffset(l,Math.round(1.5*a))
|
||
;r.barSpacing=o,r.items=this.items(),r.color=h,r.borderColor=(0,V.generateColor)(s.color.value(),u),r.height=a,r.vertOffset=c,r.visibleItemsRange={startItemIndex:e,endItemIndex:t};const d=s.plottype.value(),p=_e.plotShapesData[d],_=this._plotStyleInfo.text;if(void 0!==_&&""!==_.trim()){let e=_.replace(/\\n/gm,"\n");e=(0,de.cleanButAmpersand)(e,!0),r.text=e,r.fontSize=12;const t=s.textColor?s.textColor.value():void 0;r.textColor=t?(0,V.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=c,this._selectionRenderer.setData(this._selectionData)):this._selectionRenderer.setData(null);else{const e=new ne.CompositeRenderer;this._shapesRenderer=super._createRenderer(p.paneRendererClass,r),e.append(this._shapesRenderer),this._selectionRenderer=new pe.SelectionRenderer(this._selectionData??void 0),this._isMarkersEnabled&&null!==this._selectionData?this._selectionData.vertOffset=c:this._selectionRenderer.setData(null),e.append(this._selectionRenderer),this._renderer=e}}}var Ke,Ye=s(53660),Xe=s.n(Ye),qe=s(72244),Je=s(57268);!function(e){e[e.SimplifiedPaintingMaxFontSize=4]="SimplifiedPaintingMaxFontSize"}(Ke||(Ke={}));class Ze extends Ne{constructor(e,t){super(null,t),this._textWidthCache=new Je.TextWidthCache,this._fontSizeEnsured=0,this._font="",this._ch="",null!==e&&this.setData(e)}setData(e){super.setData(e),this._fontSizeEnsured=(0,_.ensureDefined)(this._height),this._font=(0,xe.makeFont)(this._fontSizeEnsured,e.fontFamily||Oe.CHART_FONT_FAMILY);const t=e.char.slice(0,40);this._ch=Xe()(t)[0]||" "}hitTest(e){const t=(0,qe.interactionTolerance)().series+this._fontSizeEnsured/2;for(const s of this._items){if(new ve.Point(s.center,s.y+s.vertOffset).subtract(e).length()<=t)return new we.HitTestResult(we.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 u=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(u*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,Ve.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 Qe extends Ge{constructor(){super(...arguments),this._charRenderer=new Ze(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,V.generateColor)(n.color.value(),s),l=this._calculateVerticalOffset(o,r),h={items:this.items(),barSpacing:i,char:(0,_.ensureDefined)(n.char?.value()??this._plotStyleInfo.char),height:r,vertOffset:l,color:a,visibleItemsRange:{startItemIndex:e,endItemIndex:t}},u=this._plotStyleInfo.text;if(void 0!==u&&""!==u.trim()){let e=u.replace(/\\n/gm,"\n");e=(0,de.cleanButAmpersand)(e,!0),h.text=e,h.fontSize=12;const t=n.textColor?n.textColor.value():void 0;h.textColor=t?(0,V.generateColor)(t,s):a}this._charRenderer.setData(h);const c=new ne.CompositeRenderer;c.append(this._charRenderer),this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=l,c.append(new pe.SelectionRenderer(this._selectionData))),this._renderer=c}}var et=s(55482);class tt{constructor(e,t,s,i){this.left=NaN,this.center=NaN,this.right=NaN,this.y=NaN,this.height=NaN,this.timePointIndex=e,this.price=t,this.origHeight=s,this.isUp=i,this.style={}}}function st(e){return Math.round(e/4)}function it(e){return Math.round(e/2)}class rt extends oe.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=this._data,s=it(t.barSpacing),i=Math.round(s/2),r=Math.round(s),n=st(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,u=s.center-i,c=s.center+i;if(u<e.x&&e.x<c&&(s.isUp?l<e.y&&e.y<h:h<e.y&&e.y<l))return new we.HitTestResult(we.HitTarget.Regular)}return null}_drawImpl(e){const{horizontalPixelRatio:t,verticalPixelRatio:s,context:i}=e,r=this._data,n=it(r.barSpacing),o=st(r.barSpacing),a=n<4,l=Math.max(n/2,1),h=(0,fe.ceiledEven)(n*t),u=h/2,c=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(-u,-u*n),i.moveTo(0,0),i.lineTo(u,-u*n),i.moveTo(0,0),i.lineTo(0,-p*n),i.moveTo(-u,-p*n),i.lineTo(u,-p*n),i.lineWidth=l,i.strokeStyle=m,i.stroke()):(i.moveTo(0,0),p<c?(i.lineTo(h,-p*n),i.lineTo(-h,-p*n)):(i.lineTo(h,-c*n),i.lineTo(u,-c*n),i.lineTo(u,-p*n),i.lineTo(-u,-p*n),i.lineTo(-u,-c*n),i.lineTo(-h,-c*n)),i.lineTo(0,0),i.strokeStyle=e.isUp?r.colorBorderUp:r.colorBorderDown,i.stroke(),i.fillStyle=m,i.fill()),i.translate(-_,-f)}}}class nt extends Ge{_updateRenderer(e,t){const s=this._study.properties().childs().styles.childs()[this._plotName].childs(),i=(0,
|
||
fe.clamp)(this._getTranspValue(),0,100),r=this._model.timeScale().barSpacing(),n=(0,V.generateColor)(s.colorup.value(),i),o=(0,V.generateColor)(s.colordown.value(),i),a=(0,et.parseRgba)(n),l=a?100*(1-a[3]):0,h=(0,et.parseRgba)(o),u=h?100*(1-h[3]):0,c={items:this._items,barSpacing:r,colorup:n,colordown:o,colorBorderUp:(0,V.generateColor)("#000000",l),colorBorderDown:(0,V.generateColor)("#000000",u),minHeight:this._plotStyleInfo.minHeight,visibleItemsRange:{startItemIndex:e,endItemIndex:t}};this._updateItemsHeights(c);const d=new ne.CompositeRenderer;d.append(new rt(c)),this._isMarkersEnabled&&null!==this._selectionData&&d.append(new pe.SelectionRenderer({...this._selectionData,barSpacing:r,withOutline:!1})),this._renderer=d}_fillItemWithPointStyle(e,t,s){const i=(0,_.ensureDefined)(e.style);e.isUp?void 0!==t.colors[5]?i.color=(0,V.generateColor)((0,_.ensureDefined)(t.colors[5]),s):i.color=(0,V.generateColor)(this._study.properties().childs().styles.childs()[this._plotName].childs().colorup.value(),s):void 0!==t.colors[6]?i.color=(0,V.generateColor)((0,_.ensureDefined)(t.colors[6]),s):i.color=(0,V.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,_.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].price=s??NaN,this._items[t].isUp=i,t+1}_createItem(e,t,s,i,r){const n={center:NaN,origHeight:NaN,timePointIndex:e+r,isUp:!0,height:NaN,price:NaN,left:NaN,right:NaN,y:NaN};if(!t)return n;const o=Math.min(e+r,(0,_.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 tt(e+r,l,t,a)}_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=st(r),o=function(e){return it(e)}(r),a=super._createSelectionDataPoint(e,t,s,i),l=this._items[(0,v.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,ve.point)(0,h*(n+o)))}}_updateItemsHeights(e){const t=this._study.properties().childs().styles.childs();let s=Math.abs((0,_.ensureDefined)(t[this._plotName].childs().minHeight?.value()??this._plotStyleInfo.minHeight)),i=Math.abs((0,_.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 ot=s(60848);class at extends he.StudyForceOverlayPlotView{constructor(e,t,s,i){super(t,s,i),this._bars=[],this._invalidated=!1,this._isMarkersEnabled=(0,a.isFeaturesetEnabled)("source_selection_markers"),this._selectionData=null,this._ohlcPlotIndexes=new Map,this._study=e,this._colorProvider=(0,le.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),i),this._selectionIndexer=new me.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,j.isOhlcOpenPlot)(t)&&this._ohlcPlotIndexes.set(1,e),(0,j.isOhlcHighPlot)(t)&&this._ohlcPlotIndexes.set(2,e),(0,j.isOhlcLowPlot)(t)&&this._ohlcPlotIndexes.set(3,e),(0,j.isOhlcClosePlot)(t)&&this._ohlcPlotIndexes.set(4,e)))}}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}items(){return this._bars}isPlotHighlighted(){if(!this._study.hasHighlightedPlots())return!1;const e=this._study.metaInfo().plots.filter((e=>"target"in e&&e.target===this._plotName));return Boolean(e.find((e=>(0,_.ensureNotNull)(this._model.highlightedPlotInfo()).plotId===e.id)))}_updateImpl(){this._bars.length=0;const e=this._priceScale(),t=this._model.timeScale();if(t.isEmpty()||null===e||e.isEmpty())return;const s=t.visibleBarsStrictRange();if(null===s)return;let i=this._series.nearestIndex(s.firstBar(),k.PlotRowSearchMode.NearestRight);const r=this._series.nearestIndex(s.lastBar(),k.PlotRowSearchMode.NearestLeft);if(void 0===i||void 0===r)return;const n=this._study.getMinFirstBarIndexForPlot(this._plotName);if(n>r)return;i=Math.max(n,i);const o=this._study.data(),a=this._study.firstValue(void 0,this.isForceOverlay());if(null===a)return;const l=o.rangeIterator(i,r),h=(0,_.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),u=new Map,c=(e,t)=>{const s=e+"@"+t;if(!u.has(s)){const i=(0,V.generateColor)(e,t);return u.set(s,i),i}return u.get(s)},d=(0,ge.createEmptyStyle)();for(const e of l){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,_.ensureDefined)(r.get(1)),o=(0,_.ensureDefined)(r.get(4)),a=(0,_.ensureDefined)(r.get(2)),l=(0,_.ensureDefined)(r.get(3)),u=Math.max(n,a,l,o),p=Math.min(n,a,l,o);let f=(0,_.ensureDefined)(c(h.color.value(),0));const m=this._colorProvider.getPlotPointStyle(s,d);void 0!==m.colors[0]&&(f=(0,_.ensureDefined)(m.colors[0]));const y={open:n,high:u,low:p,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)}e.barPricesToCoordinates(this._bars,a),t.fillBarBorders(this._bars),this._createSelection(a,t)}_createSelection(e,t){const s=this._priceScale();if(null===s)return;if(this._selectionData={points:[],bgColors:[],
|
||
visible:!0,hittestResult:we.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()},!this.isPlotHighlighted()&&(!this._model.selection().isSelected(this._study)||this._study.hasHighlightedPlots()))return void this._selectionIndexer.clear();const i=(0,_.ensureNotNull)(this._model.paneForSource(this._study)).height(),r=(0,_.ensureDefined)(this._ohlcPlotIndexes.get(4)),n=this._selectionIndexer.indexes();for(let o=0;o<n.length;o++){const a=n[o],l=this._study.data().valueAt(a);if(null===l)continue;const h=l[r+1];if(null==h)continue;const u=t.indexToCoordinate(Math.floor(a)),c=s.priceToCoordinate(h,e);this._selectionData.points.push({point:new ve.Point(u,c)}),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(c/i))}}_isOHLCPlotVisible(){return this._study.isPlotVisibleAt(this._plotName,1)}}class lt extends at{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 ne.CompositeRenderer;return t.append(new ot.PaneRendererBars(e)),this._isMarkersEnabled&&this._selectionData&&t.append(new pe.SelectionRenderer(this._selectionData)),t}}var ht=s(10514);class ut extends at{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,_.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,qe.optimalBarWidth)(s),borderColor:t.borderColor.value(),wickColor:t.wickColor.value(),isPriceScaleInverted:e.isInverted()},r=new ne.CompositeRenderer;return r.append(new ht.PaneRendererCandles(i)),this._isMarkersEnabled&&this._selectionData&&r.append(new pe.SelectionRenderer(this._selectionData)),r}}var ct=s(95655),dt=s(24561),pt=s(95429),_t=s(80140);class ft extends pt.HorizontalLinePaneView{constructor(e,t){super(),this._lineRendererData.linestyle=_t.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 mt=s(61874),yt=s(17785),gt=s(97411);const vt={type:0,color:"transparent"};class St extends gt.AbstractFilledAreaPaneView{constructor(e,t,s,i){super(e,t,s),this._palettesInfo={},this._gradientPropsStateCache=null,this._rgbaFromInteger=(0,yt.rgbaFromIntegerCached)();const r=this._source.metaInfo()
|
||
;this._isRGB=Boolean(r.isRGB),this._isHlineFill="hline_hline"===s.type,(0,_.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,j.isColorerPlot)(i)||(0,j.isDataPlot)(i))&&i.target===s.id){if((0,j.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,j.isPaletteColorerPlot)(i)&&(this._palettesInfo[s??"color"]={map:(0,_.ensureDefined)((0,_.ensureDefined)(r.palettes)[i.palette]?.valToIndex),values:e.properties().palettes[i.palette].colors})}else(0,j.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,_.ensureDefined)(this._palettesInfo.color),i=(0,_.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,_.ensureDefined)(this._palettesInfo.color1);s=t.values[(0,_.ensureDefined)(t.map[e.colorIndexOrRgba1])].childs().color.value()}if(null!=e.colorIndexOrRgba2){const t=(0,_.ensureDefined)(this._palettesInfo.color2);i=t.values[(0,_.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 vt;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 bt=s(59217),Pt=s(41252),wt=s(87378);class It{constructor(e,t){this._invalidated=!0,this._lineRenderer=new wt.HorizontalLineRenderer,this._source=t,this._points=[new ve.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 ve.Point(-1,-1));const t=this._properties.childs().value.value(),s=this._source.firstValue(),i=(0,f.isNumber)(t)&&null!==s?e.priceToCoordinate(t,s):NaN;this._points[0]=new ve.Point(-1,i)}}var xt=s(56568);class Ct extends xt.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 Vt{constructor(e){this._bandBgRenderer=new Ct,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,_.ensureDefined)(e.bandsBackground).childs(),h=(0,fe.clamp)(l.transparency?.value()??0,0,100);this._bandBgRenderer.setData({gradient:!1,points:a,backcolor:(0,V.generateColor)(l.backgroundColor.value(),h)})}}class Mt{constructor(e,t,s){this._bandBgRenderer=new Ct,this._bandAKey=null,this._bandBKey=null,this._invalidated=!0,this._source=e,(0,_.assert)("hline_hline"===t.type,"Wrong filledArea type: "+t.type),this._initBandIndexes(t.objAId,t.objBId),this._fillStyleProps=s,this._bandBgRenderer=new Ct,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,_.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,fe.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 u=e.color1??t.topColor?.value(),c=e.color2??t.bottomColor?.value();if(void 0===u&&void 0===c)return;a={gradient:!0,points:n,backColor1:u&&(0,V.generateColor)(u,o),backColor2:c&&(0,V.generateColor)(c,o),coordinate1:i.priceToCoordinate(s,r),coordinate2:i.priceToCoordinate(h,r)}}else a={gradient:!1,points:n,backcolor:(0,V.generateColor)(l.color.value(),o)};this._bandBgRenderer.setData(a)}_initBandIndexes(e,t){this._bandAKey=null,this._bandBKey=null;(0,_.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 Tt=s(32137),Rt=s(96532),At=s(40394),Ot=s(68657),Dt=s(37032),Nt=s(82708),Bt=s(40180);class Ft extends Bt.StudyPriceAxisView{isPlotHighlighted(){if(!this._source.hasHighlightedPlots())return!1;const e=this._source.metaInfo().plots.filter((e=>"target"in e&&e.target===this._data?.plotName));return Boolean(e.find((e=>(0,_.ensureNotNull)(this._model.highlightedPlotInfo()).plotId===e.id)))}}var kt=s(46396),Et=s(83014);class Lt extends Et.AbstractBarColorer{
|
||
constructor(e,t){super(),this._rgbaFromInteger=(0,yt.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 u=h[this._plotIndex+1];if(null==u)return s;if(u=Math.round(u),n.isRGB)s.barColor=this._rgbaFromInteger(u),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,_.ensureDefined)(n.palettes?.[t]),a=o.valToIndex?(0,_.ensureDefined)(o.valToIndex[u]):u,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 Ht=s(96375),Wt=s(58456),zt=s(66235);class Ut extends ct.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 jt=s(34192),Gt=s(34969);class $t{constructor(e,t){this._study=e,this._valuesProvider=new W.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,_.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 Kt=s(68061),Yt=s(75323),Xt=s(82372),qt=s(55744);const Jt=(0,m.getLogger)("Chart.Study"),Zt=g.t(null,{context:"study status description"},s(29066)),Qt=!1;var es,ts;function ss(){return{fields:[],useMainSeriesRange:!1,baseValueMinMax:null}}!function(e){e.PaneViews="study-pane-views"}(es||(es={})),function(e){e[e.DefaultPriceScale=100]="DefaultPriceScale"}(ts||(ts={}));const is={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!1,skipFakeInputs:!1,
|
||
skipBooleanInputs:(0,a.isFeaturesetEnabled)("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},rs=(0,a.isFeaturesetEnabled)("study_symbol_ticker_description"),ns=(0,a.isFeaturesetEnabled)("hide_main_series_symbol_from_indicator_legend"),os=(0,a.isFeaturesetEnabled)("datasource_copypaste"),as=(0,a.isFeaturesetEnabled)("hide_unresolved_symbols_in_legend");function ls(e,t){const s=e.plots[t];if(!s||!(0,j.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,j.isOhlcPlotStyleBars)(r)||n&&(0,j.isOhlcPlotStyleBars)(n)||!!o&&(0,j.isOhlcPlotStyleBars)(o)}function hs(e,t){const s=e.plots[t];if(!s||!(0,j.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,j.isOhlcPlotStyleCandles)(r)||n&&(0,j.isOhlcPlotStyleCandles)(n)||!!o&&(0,j.isOhlcPlotStyleCandles)(o)}function us(e,t){(0,_.assert)(void 0!==e,"zOrder must be defined"),(0,_.assert)(!t.has(e),"zOrder must be unique")}function cs(e,t){return e.plots.some((e=>((0,j.isColorerPlot)(e)||(0,j.isDataPlot)(e))&&e.target===t))}function ds(e,t,s){let i=0,r=0;return Math.sign(r)-Math.sign(i)}function ps(e){const t=(0,Ot.combine)((e=>e.map((e=>ps(e.parentSourcesVW().weakReference())))),e);return(0,Ot.accumulate)(((e,t)=>Array.from(new Set(t.concat(e.flat(20))))),t.ownership(),e).ownership()}function _s(e){return"inherit"===e.type&&(e.type="price"),e}function fs(e,t,s,i){{const t=(0,f.isNumber)(i)?i:void 0,r=qt.customFormatters?.studyFormatterFactory?.(e,s,t)??null;if(null!==r)return r}if(null!==t)switch(e.type){case"inherit":case"price":return new Wt.PriceFormatter({priceScale:t});case"volume":return(0,jt.getVolumeFormatter)(Math.log10(t));case"percent":return(0,jt.getPercentageFormatter)(Math.log10(t))}if("inherit"===e.type)return null;const r=(0,f.isNumber)(e.precision)?Math.pow(10,e.precision):void 0;switch(e.type){case"price":return new Wt.PriceFormatter({priceScale:r});case"volume":{let t=e.precision;return void 0===t&&(t=s&&(0,f.isNumber)(s.volume_precision)?s.volume_precision:0),(0,jt.getVolumeFormatter)(t)}case"percent":return(0,jt.getPercentageFormatter)(void 0===r?void 0:Math.log10(r));default:return Jt.logWarn(`Unsupported format type: ${e.type}`),null}}const ms=new Set(["first_visible_bar_time","last_visible_bar_time","subscribeRealtime"]);class ys extends R.PriceDataSource{constructor(e,t,s,i,r,n,o){super(e),this._onStart=new C.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 C.Delegate,this._currencySourceSymbolInputProperty=null,this._pineSourceCodeModel=null,this._alertSourceModel=null,this._onHibernationStateChange=new C.Delegate,this._symbolsResolved=new C.Delegate,this._statusChanged=new C.Delegate,this._inputsAnchorsPaneView=null,this._inputsLinesPaneView=null,this._inputsTimeAxisPaneViews=[],this._inputsPriceAxisPaneViews=[],this._sources=new x.WatchedObject([],v.compareTwoCollectionsByIds),this._status=new I.WatchedValue({type:Tt.StudyStatusType.Undefined}),this._compileActiveStatus=new x.WatchedObject(null),this._compileErrorStatus=new x.WatchedObject(null),this._wasCompletedBefore=!1,this._isStarted=!1,this._isSubscribedToSessionId=!1,this._titleStrCache={},this._titleInPartsCache={},this._inputsInPartsCache={},this._children=[],this._graphicsPriceAxisViews=[],this._serverPlotOffsets=new x.WatchedObject({}),this._ongoingDataUpdate=Promise.resolve(),this._studyModified=!1,this._tagsChanged=new C.Delegate,this._turnaround="st0",this._pendingResolveSymbols=new Map,this._onIsActualIntervalChange=new C.Delegate,this._childStudyByRebind=new C.Delegate,this._lastNonEmptyPlotRowCache={},this._startMovingPoint=null,this._processHibernateBound=this.processHibernate.bind(this,1),this._maxOffset=new I.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 C.Delegate,this._definitionsViewModel=null,this._plotFormatters=new Map,this._showPineVersionInStatusLine=new I.WatchedValue(!1).spawn(),this._onParentSourcesChanges=new C.Delegate,this._statusChangesSubscriber={},this._calculationTime=new I.WatchedValue(0),this._stateForAlertCache=null,this._idForAlertCache=null,this._idForAlertWV=new I.WatchedValue(""),this._chartApi=e.chartApi(),this._properties=t,this._originalMetaInfo=r,this._metaInfo=new I.WatchedValue(i),this._studyName=(0,Ot.combine)((e=>e.useVersionFromMetaInfo?(0,B.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,ee.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),B.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.metricChanged().subscribe(this,this._onSourceMetricChanged),e.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),e.formatterChanged().subscribe(this,this._onSourceFormatterChanged),e.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged)})),rs&&this._model.mainSeries().properties().childs().statusViewStyle.childs().symbolTextSource.subscribe(this,(()=>{this.invalidateTitleCache(!0)}));const l=this._properties.childs();for(const e of B.StudyMetaInfo.getSourceInputIds(i))l.inputs.childs()[e]?.subscribe(this,this._onSourceInputChanged);this._plotOffsets=(0,Ot.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??0);return i[n]=o,i}),{})),this._serverPlotOffsets.weakReference(),(0,ee.createWVFromGetterAndSubscription)((()=>this.properties().childs().offset?.childs().val.value()),this.properties().childs().offset??new C.Delegate).ownership(),(0,ee.createWVFromGetterAndSubscription)((()=>this.properties().childs().offsets),this.properties().childs().offsets??new C.Delegate).ownership(),this._metaInfo.weakReference()),this._properties.subscribe(this,this._onPropertiesChanged),l.visible.subscribe(this,this._visibleChanged),l.visible.subscribe(this,(()=>this.processHibernate())),l.intervalsVisibilities.subscribe(this,this._calcIsActualInterval),l.inputs.subscribe(this,this._updateMaxOffsetValue),void 0!==l.offsets&&l.offsets.subscribe(this,this._updateMaxOffsetValue),void 0!==l.offset&&l.offset.subscribe(this,this._updateMaxOffsetValue),this._initializeCurrencySource(),$.hideAllIndicators().subscribe(this,this._visibleChanged);for(let e=0;e<i.plots.length;e++){const t=i.plots[e],s=t.id,r=l.styles.childs()[s],n=(0,j.isBarColorerPlot)(t);r&&!r.hasChild("display")&&r.merge({display:4294967295}),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=l.graphics.childs()[e]?.childs()[t];s&&s.childs().visible&&(0,_.ensureDefined)(s.childs().visible).subscribe(this,(()=>this.processHibernate()))}this._isActualInterval=(0,Rt.isActualInterval)(this._series.intervalObj().value(),l.intervalsVisibilities),this._initializeStudyInputsPaneViews(),this._handler=e=>this._onData(e),this._valuesProvider=new W.StudyValuesProvider(this,e),this._tableViewValuesProvider=new $t(this,e),this._graphics=new F.LiveStudyGraphics(i.graphics),this._chartApi=e.chartApi(),
|
||
this._invalidateLastNonEmptyPlotRowCache(),this._data=new D.PlotList((0,zt.studyPlotFunctionMap)(i),zt.studyEmptyPlotValuePredicate),this._createViews(),this._recreatePriceFormattingDependencies(this._series.symbolInfo()),l.precision.subscribe(this,this._onFormatterPropsChanged),this._metaInfo.subscribe((()=>this._onFormatterPropsChanged())),this._showStudyArgumentsProperty.subscribe(this,(()=>this.invalidateTitleCache(!0))),l.inputs.subscribe(this,(()=>this.invalidateTitleCache(!0))),(0,a.isFeaturesetEnabled)("update_study_formatter_on_symbol_resolve")&&e.mainSeries().dataEvents().symbolResolved().subscribe(this,this._recreatePriceFormattingDependencies),e.mainSeries().dataEvents().symbolResolved().subscribe(this,(()=>this.invalidateTitleCache(!0)));const h=new Set;if(this._simplePlotsCount=i.plots.filter(((e,t)=>{if((0,j.isLinePlot)(e))return!0;if((0,j.isOhlcPlot)(e)){const t=e.target;return!h.has(t)&&(h.add(t),!0)}return!1})).length,this.hasBarColorer()&&l.visible.subscribe(this,(()=>e.mainSeries().invalidateBarStylesCache)),this._definitionsViewModel=null,this._updateMaxOffsetValue(),i.inputs.some((e=>ms.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===Tt.StudyStatusType.Loading?this._statusChanged.subscribe(this._statusChangesSubscriber,t,!0):t()})),t&&this._updateVisibleTimeRangeInputs(t,!1)}this._properties.setNameInOwner((0,Kt.propertyPathForSource)(this)),o&&this._pinePatchProps();const u=ps(this.parentSourcesVW().weakReference());this._allOwnerSources=(0,Ot.combine)(((e,t)=>{const s=[];for(;null!==t;)s.push(t),t=t.ownerSource();return s}),u,(0,ee.createWVFromGetterAndSubscription)((()=>this.ownerSource()),this.ownerSourceChanged()).ownership()),this._symbolSource=(0,Ot.combine)((e=>this._firstSourceOrSeries().symbolSource()),this._allOwnerSources.weakReference()),this._properties.onRestoreFactoryDefaults().subscribe(this,this._handleRestoringFactoryDefaults)}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.metricChanged().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),$.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.onRestoreFactoryDefaults().unsubscribe(this,this._handleRestoringFactoryDefaults),this._properties.destroy(),super.destroy()}setId(e){super.setId(e),this._properties.setNameInOwner((0,Kt.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,f.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 I.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 u,c;if(l&&l.childs()[e]&&(u=l.childs()[e]),h&&h.childs()[e]&&(u=h.childs()[e]),!u||0===u.childs().display.value())return i;const d=this.metaInfo().plots;for(c=0;c<d.length;c++){const t=d[c];if(t.id===e||(0,j.isOhlcClosePlot)(t)&&t.target===e)break}const p=c+1,_=this.offset(e),m=this.nearestIndex(o.lastBar()-_,k.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,f.isNumber)(S[p]))return i;const b=S[p],P=this._valuesProvider.getPlotColor(c,S),w=n.priceToCoordinate(b,a),I=this.plotFormatter(e).format(b),x={...n.getFormattedValues(b,a,void 0,I),noData:!1,color:P,coordinate:w};return s&&(x.price=b),x}isFailed(){return this.status().type===Tt.StudyStatusType.Error}isLoading(){return this.status().type===Tt.StudyStatusType.Loading}isCompleted(){return this.status().type===Tt.StudyStatusType.Completed}isSymbolInvalid(){const e=this._status.value();return e.type===Tt.StudyStatusType.Error&&e.errorDescription.error===Zt}series(){return this._series}model(){return this._model}state(e,t){const s=(0,_.ensureNotNull)((0,S.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=p(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,F.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,_.ensureDefined)(t.editorError)])}restoreData(e){this._invalidateLastNonEmptyPlotRowCache(),this.data().restoreState(e),this._resolvedSymbols=e.symbols??{},this._graphics=e.graphics?(0,F.loadStudyGraphics)(e.graphics):(0,F.emptyStudyGraphics)(),this._postProcessGraphics(),this._serverPlotOffsets.setValue(e.plotOffsets??{}),this._setStatus({type:Tt.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(j.isBarColorerPlot)}barColorer(){const e=this._metaInfo.value().plots;let t=null;for(let s=e.length-1;s>=0;s--)if((0,j.isBarColorerPlot)(e[s])){const e=new Lt(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||(0,a.isFeaturesetEnabled)("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}`;Jt.logError(t),this._restarting=!1,"TooManyStudies"===e?.cause&&(0,w.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,f.clone)(is),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){const t=this.metaInfo();return e?t.shortDescription?(0,y.decodeHTMLEntities)(t.shortDescription):"Study":t.description?(0,y.decodeHTMLEntities)(t.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=(0,a.isFeaturesetEnabled)("always_show_study_symbol_input_values_in_legend"),l=n&&o;if(n&&!o&&e===Q.TitleDisplayTarget.StatusLine)return null;const h=JSON.stringify([e,t,s,i,r]);if(this._inputsInPartsCache[h])return this._inputsInPartsCache[h];const u=[],c=this.metaInfo(),d=this._titleInputs((0,Yt.toInputDisplayFlags)(e),i,!0),p=c.inputs.filter((e=>d.hasOwnProperty(e.id)&&(!l||"symbol"===e.type||e?.isAlwaysShownInLegend))).map((e=>{let t=d[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}})),m={};if(p.length>0){if(this.isChildStudy())for(let s=0;s<c.inputs.length;++s){const n=c.inputs[s];if(!B.StudyMetaInfo.isSourceInput(n))continue;const o=n.id,a=(0,_.ensureDefined)(this._properties.childs().inputs.child(o)).value();if(a.indexOf("$")>=0){const s=this.parentSourceForInput(a);if(s instanceof ys){const n=s.metaInfo(),o=s.title(e,t,{},!0,i,r);if(1===n.plots.length)m[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;m[a]=o+": "+i}}}}p.forEach((({meta:e,value:t})=>{let i;i="time"===e.type?new Date(t).toISOString():(0,f.isNumber)(t)?(0,jt.getNumericFormatter)().format(t):m&&m[t.toString()]||t.toString(),s&&s[i.toString()]&&(i=s[i.toString()]),u.push({title:(0,Xt.getTranslatedInputTitle)(e.name),value:i})}))}return this._inputsInPartsCache[h]=u,u}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,_.ensureDefined)(r).title;let o;return o=1!==this._simplePlotsCount||(0,
|
||
j.isPlotTitleDefined)(n)?t.is_price_study&&n!==t.shortDescription?""===n?t.shortDescription:t.shortDescription+":"+n:n:t.shortDescription,(0,y.decodeHTMLEntities)(o)}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||[],h=[],u=[];for(let e=0;e<l.length;++e){const r=l[e],n=r.id;if((0,j.isColorerPlot)(r)||s.isPlotForceOverlay(n))continue;if(0!==(0,_.ensureDefined)(i.styles.childs()[n]).childs().display.value()||t.has(n)){if((0,j.isLinePlot)(r)){const t=i.styles.childs()[n].childs().plottype.value();(0,j.doesLinePlotStyleSupportFillBreaks)(t)&&u.push(e)}h.push(e)}}if(u.length){const t=(0,_.ensureNotNull)(this._model.timeScale().logicalRange()),s=Math.floor(t.left());for(let t=0;t<u.length;t++){const i=u[t],r=this._getFirstValForPlotThatSupportFillBreaks(i,s);if(!(null===r||e&&Math.abs(r)<1e-10)){o=r;break}}}if(null===o&&0!==h.length)for(const t of this.data().rangeIterator(r,n)){const s=t.value;for(let t=0;t<h.length;++t){const i=s[h[t]+1];if(!(null==i||e&&Math.abs(i)<1e-10)){o=i;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 os&&!this.isChildStudy()}setPriceScale(e){super.setPriceScale(e),(0,Ht.emit)("study_event",this.id(),"price_scale_changed")}priceRange(e){let t=null;const s=this._metaInfo.value(),{startTimePoint:i,endTimePoint:r}=e,n=this._fillPrecalculatedAutoscaleInfo(e);let o=this.data().minMaxOnRangeCached(i,r,n.fields);if(o=(0,D.mergeMinMax)(n.baseValueMinMax,o),n.useMainSeriesRange){const e=[{name:"low",offset:0},{name:"high",offset:0}],t=this.series().data().bars().minMaxOnRangeCached(i,r,e);o=(0,D.mergeMinMax)(o,t)}if(null!==o&&(t=new A.PriceRange(o.min,o.max)),s.bands&&e.targetPriceScale===this.priceScale())for(let e=0;e<s.bands.length;e++){const s=(0,
|
||
_.ensureDefined)(this._properties.childs().bands.childs()[e]).childs();if(s.visible.value()){const e=s.value.value();if(!(0,f.isNumber)(e))continue;t?t.apply(e,e):t=new A.PriceRange(e,e)}}return this._postProcessPriceRange(t,e)}autoScaleInfo(e){const t=this.priceRange(e),s=(this.priceScale()===this._series.priceScale()||(this.priceScale(),e.targetPriceScale),{topPixelMargin:0,bottomPixelMargin:0});return{range:t,topPixelMargin:s.topPixelMargin,bottomPixelMargin:s.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,M.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){const r=(0,j.isOhlcPlot)(i)?s.ohlcPlots?.[i.target]?.title:s.styles?.[t]?.title;return r?(0,y.decodeHTMLEntities)(r):this.title(e)}return this.title(e)}childStudyByRebind(){return this._childStudyByRebind}isPine(){return this._metaInfo.value().isPine()}isStandardPine(){return this._metaInfo.value().isStandardPine()}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,Dt.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({forceTreatSourceInputsAsFake:!0})}sessionId(){return this._firstSourceOrSeries().sessionId()}sessionIdChanged(){return this._firstSourceOrSeries().sessionIdChanged()}getSymbolString(e,t){return""===e?"":(0,Y.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e,t))}onStatusChanged(){return this._statusChanged}onDataUpdated(){return this._dataUpdated}symbolsResolved(){return this._symbolsResolved}onHibernationStateChange(){return this._onHibernationStateChange}valuesProvider(){return this._valuesProvider}legendValuesProvider(){return new U(this,this.model())}tableViewValuesProvider(){return this._tableViewValuesProvider}statusProvider(e){return new J.StudyStatusProvider(this)}chartFloatingTooltipValuesProvider(){return new Z(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()&&$.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=[],i=this._paneViews.find((e=>{return t=e,(0,P.isObject)(t)&&"isPlotHighlighted"in t&&e.isPlotHighlighted();var t}))??null;return!this._startMovingPoint&&this._wasCompletedBefore&&s.push(...this._paneViews.filter((e=>!e.isForceOverlay?.()&&e!==i))),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),i&&s.push(i),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,H.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 F.LiveStudyGraphics&&this._graphics?.clear(),this._serverPlotOffsets.setValue({})})),this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this.updateAllViews((0,H.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.properties().childs().visible.value())&&(!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,j.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&&(0,O.isPlotVisible)(r,t)}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,H.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=se(s.sourceStudies).sort(te);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(),ie(this))}canHaveChildren(){return this._canHaveChildren=this._canHaveChildren??B.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)}children(){return this._children}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}hasHighlightedPlots(){return(0,N.highlightContainsSource)(this._model.highlightedPlotInfo(),this.id())}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,_.ensureDefined)(this._inputs);let t;return t=this._chartApi.createStudy(this.sourceId(),this._turnaround,this.isChildStudy()?(0,_.ensureNotNull)(this._sources.value()[0].sourceId()):(0,_.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:Tt.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 s=this._calcSources(),i=this._metaInfo.value(),r=ds(),n=()=>{for(const s of i.inputs){if("source"!==s.type)continue;const i=e[s.id].v,r=t[s.id].v;if(i!==r){(0,_.ensureDefined)(this._properties.childs().inputs.child(s.id)).setValue(r)}}};if(this.isStarted()&&this._chartApi.isConnected().value()&&r>0&&!this._chartApi.canCreateStudy(this._studySpec(!0),!0).success){const e=window.user.pro_plan;return openPaywall({feature:"studyOnStudy",isMaxPlan:"pro_premium_expert"===e||"pro_premium_expert_trial"===e}),void n()}this._inputs=e;let o=!1;const a=Object.values(re.RangeDependentStudyInputNames);for(const s of Object.keys(e))if(JSON.stringify(e[s])!==JSON.stringify(t[s])&&!a.includes(s)){o=!0;break}this._incrementTurnaround(),o&&this.disablePriceRangeReady();try{await this._updateParentSources(s,r,!0),this._modifyStudyOnServer(e,r),this._studyModified=!0}catch(e){Jt.logError(`Error applying parent sources: ${e}`),n()}this.invalidateTitleCache()}_createPriceAxisView(e){const t=this.metaInfo().plots.find((t=>"target"in t&&t.target===e));return void 0!==t&&(0,j.isOhlcPlot)(t)?new Ft(this,{plotName:e}):new Bt.StudyPriceAxisView(this,{plotName:e})}_createPriceLineAxisView(e){return new kt.StudyPriceLineAxisView(this,e)}_createStudyPlotPaneView(e){return new dt.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,_.ensureDefined)(r.filledAreasStyle.childs()[n.id]),a=cs(t,n.id);let l;if("plot_plot"===n.type||a?l=new St(this,this.model(),n,o):"hline_hline"===n.type?l=new Mt(this,n,o):Jt.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,_.ensureDefined)(n.zorder):i.size;us(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,u,c,d=t.isPlotForceOverlay(o.id);if((0,j.isNonVisualPlot)(o))continue;let p=o.id,f=t.styles;const m=(0,j.isBgColorerPlot)(o);if(m)a=new ue(this,this._series,this._model,p);else if((0,j.isShapesPlot)(o))a=new $e(this,this._series,this._model,p);else if((0,j.isCharsPlot)(o))a=new Qe(this,this._series,this._model,p);else if((0,j.isArrowsPlot)(o))a=new nt(this,this._series,this._model,p);else if((0,j.isOhlcPlot)(o)){const s=o.target;if(e.has(s))continue;if(d=t.isPlotForceOverlay(s),e.add(s),ls(t,n))a=new lt(this,this._series,this._model,s);else{if(!hs(t,n)){Jt.logError(`plot ${o.id} looks to be invalid`);continue}a=new ut(this,this._series,this._model,s)}u=this._createPriceAxisView(s),h=new ct.PanePriceAxisView(u,this,this._model),p=s,f=t.ohlcPlots}else(0,j.isDataPlot)(o)||(u=this._createPriceAxisView(p),c=this._createPriceLineAxisView(p),a=this._createStudyPlotPaneView(p),this._properties.childs().styles.childs()[p]?.child("trackPrice")?.value()&&(l=new ft(this,p)),h=new Ut(u,this,this._model,p));const y=s?m?r++:(0,_.ensureDefined)(f?.[p]?.zorder):i.size;if(us(y,i),d)u&&this._forceOverlayPriceAxisViews.push(u),a&&this._forceOverlaysPaneViews.push(a),h&&this._forceOverlayLabelPaneViews.push(h);else{const e={paneViews:void 0!==a?[a]:[],labelView:h,priceAxisView:u,priceLineAxisView:c};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 It(n,this),r=s?(0,_.ensureDefined)(e.zorder):i.size;us(r,i),i.set(r,{paneViews:[t]})}})),r.bandsBackground&&((0,_.assert)(!s,"'usePlotsZOrder' flag does not supported"),i.set(i.size,{paneViews:[new Vt(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,_.assert)(!s,"'usePlotsZOrder' flag does not supported"),i.set(i.size,{paneViews:[new mt.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,_.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 bt.StudyDataWindowView(this,this._model)),this._legendView||(this._legendView=new G(this,this._model)),this._statusView||(this._statusView=new K.StudyStatusView(this)),this._floatingTooltipView||(this._floatingTooltipView=new Pt.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,_.assert)(!!e.params.nonseries,"data.params.nonseries is missing"),this._onDataUpdate(e.params.plots,(0,_.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,_.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,H.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:ns,displayMask:e}}_postProcessGraphics(){this._graphicsPriceAxisViews=this._createGraphicsPriceAxisViews(),this._concatPriceAxisViews()}async _createGraphicsPaneViews(){return(0,F.createGraphicsPaneViews)(this,this.model())}_createGraphicsPriceAxisViews(){return(0,F.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 A.PriceRange(e.minValue()-t,e.maxValue()+t)}const s=t.targetPriceScale;return s&&s.isLog()&&e?new A.PriceRange(s.priceToLogical(e.minValue()),s.priceToLogical(e.maxValue())):e}_titleInParts(e,t=!0,i,r,n,o){const l=[g.t(this.name(t),{context:"study"},s(84693))];let h=[];if(!r||(0,a.isFeaturesetEnabled)("always_show_study_symbol_input_values_in_legend")){const s=this._getMTFResolutionInputTitle();null!==s&&s.length>0&&l.push(s);h=(this.inputsInParts(e,t,i,n,o)??[]).map((e=>e.value))}return[l.join(" · "),h]}_seriesDataRangeToSave(e){return this._model.timeScale().visibleExtendedDataRange(e,0)}_getSymbolForResolve(e){return this.getSymbolString(this._getSymbolForApi(e))}_getSymbolForApi(e){return e}_getSymbolObject(e,t){const s={symbol:e},i=this.currency();return null!==this._currencySourceSymbolInputProperty&&null!==this._currencySourceSymbolInfo&&this._getSymbolForApi(this._currencySourceSymbolInputProperty.value())===e&&(s["currency-id"]=i),s.session=this.sessionId(),s}_onSymbolResolved(e,t,s){this._onCurrencyMayChange()}_onSymbolResolvingStart(e,t){}_onSymbolError(){}_setStatus(e,t){const s=this.isFailed();this._status.setValue(e),e.type===Tt.StudyStatusType.Completed?this._wasCompletedBefore=!0:e.type!==Tt.StudyStatusType.Error&&e.type!==Tt.StudyStatusType.Undefined||(this._wasCompletedBefore=!1),t||(this._statusView?.update((0,H.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,Ht.emit)("study_properties_changed",this._id.value())}_lastNonEmptyPlotRow(e){if(!(0,f.isInteger)(e))return Jt.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,Nt.currencyUnitMetricVisibilityProperty)().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,_.ensureDefined)((0,f.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,_.ensureDefined)((0,
|
||
f.clone)(this._inputs)))}catch(e){Jt.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=ds(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){const t=this._metaInfo.value(),s=this.properties().childs(),i=new Set,r=t.filledAreas||[];for(let e=0;e<r.length;e++){const t=r[e];s.filledAreasStyle.childs()[t.id].childs().visible.value()&&(i.add(t.objAId),i.add(t.objBId))}return t.plots.filter((e=>!(0,j.isPlotWithTechnicalValues)(e))).filter((s=>t.isPlotForceOverlay(s.id)?e.targetPriceScale===this._model.mainSeries().priceScale():e.targetPriceScale===this.priceScale()&&!e.forceOverlayOnly)).filter((e=>i.has(e.id)||this.isPlotVisibleAt(e.id,1))).reduce(((t,s)=>this._applyPlotToPrecalculatedAutoscaleInfo(e,t,s)),{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 fs(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){Jt.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:Tt.StudyStatusType.Completed}),this._statusView?.update((0,H.sourceChangeEvent)(this.id()));const t=this._model.paneForSource(this);this._model.recalculatePane(t,(0,H.sourceChangeEvent)(this.id())),this._updateSources();const s=At.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"}
|
||
_handleRestoringFactoryDefaults(){const e=this._properties.state();(0,Gt.applyDefaultColorsToPropsState)(e,this._metaInfo.value()),this._properties.merge(e)}_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,_.ensureNotNull)(this._series.bars().lastIndex())-e;return(0,_.ensureNotNull)(this._series.bars().valueAt(t))[0]}return null}_concatPriceAxisViews(){this._priceAxisViews=[...this._priceAxisViewsBase,...this._graphicsPriceAxisViews]}_onStudyLoading(e){this._setStatus({type:Tt.StudyStatusType.Loading,startTime:Date.now()}),this._statusView?.update((0,H.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_handleStudyError(e){this.clearData(),this._setStatus(e),this._statusView?.update((0,H.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_createStudyError(e){let t;return t=(0,f.isString)(e)?{error:this._getStudyErrorText(e),title:e.includes("study_not_auth")?"Access error":this._defaultErrorTitle()}:{...e,title:e.title??this._defaultErrorTitle()},(0,Tt.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=fs(_s({...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=fs(_s({...s,...n?.format}),i,r,this.properties().childs().precision.value());t&&this._plotFormatters.set(e,t)}for(const e of t.plots)if((0,j.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,_.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,T.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:Tt.StudyStatusType.Error,errorDescription:{error:Zt}}),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,X.makeNextSymbolId)(),e,(r=>{switch(this._pendingResolveSymbols.delete(e),r.method){case"symbol_resolved":{this._setStatus({type:Tt.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:Tt.StudyStatusType.Error,errorDescription:{error:r.params[1]}}),this._onSymbolError(),r.params[1]===q.permissionDenied&&r.params[2]){if(r.params[2]!==q.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,_.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,_.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,_.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=b(o),void 0!==l&&l in s&&(l=void 0)),s[l||o.id]=(0,f.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(rs){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,Dt.symbolTitle)(a,t.noExchanges);else as&&(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,V.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 B.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,_.ensureNotNull)(e.priceScale());if(t!==s){const t=this._model.paneForSource(this),i=(0,
|
||
_.ensureNotNull)(this._model.paneForSource(e));t===i&&i.move(this,s,!0)}}}_calcSources(){const e=this._properties.childs().inputs.state();return B.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(f.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,_.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(),this._dataUpdated.fire()}_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,H.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._updateMaxOffsetValue()}_applyPlotToPrecalculatedAutoscaleInfo(e,t,s){const i=s.id,r=this._properties.childs().styles.childs()[i],n=(0,j.isShapesPlot)(s)||(0,j.isCharsPlot)(s);t.useMainSeriesRange=t.useMainSeriesRange||(0,j.isArrowsPlot)(s);let o=(0,j.isLinePlot)(s)||(0,j.isOhlcPlot)(s);if(n){const e=(0,_.ensureDefined)(r).childs().location.value(),s=[E.MarkLocation.Absolute,E.MarkLocation.Top,E.MarkLocation.Bottom].indexOf(e)<0;t.useMainSeriesRange=t.useMainSeriesRange||n&&s,o=o||e===E.MarkLocation.Absolute}if(!o)return t;const a={name:i,offset:this.offset(i)},l=r.childs().plottype.value();if((0,j.doesLinePlotStyleSupportFillBreaks)(l)){const i=this._metaInfo.value().plots.indexOf(s),r=this._getMinMaxForPlotThatSupportFillBreaks(i,l,e);t.baseValueMinMax=(0,D.mergeMinMax)(t.baseValueMinMax,r)}if(!this._skipHistogramBaseOnAutoScale()&&[j.LineStudyPlotStyle.Histogram,j.LineStudyPlotStyle.Columns,j.LineStudyPlotStyle.Area].indexOf(l)>=0){const s=(this._metaInfo.value().styles??{})?.[i]?.histogramBase;if(void 0===s)return t;const{startTimePoint:r,endTimePoint:n}=e,o=this.data().minMaxOnRangeCached(r,n,[a]);return(0,f.isNumber)(s)&&null!==o&&(t.baseValueMinMax=(0,D.mergeMinMax)(t.baseValueMinMax,{min:s,max:s}),t.baseValueMinMax=(0,D.mergeMinMax)(t.baseValueMinMax,o)),t}return t.fields.push(a),t}_getFirstValForPlotThatSupportFillBreaks(e,t){const s=this.data().plottableRange(),i=e+1,r=s.search(t,k.PlotRowSearchMode.NearestLeft,i);if(r){if(s.search(t,k.PlotRowSearchMode.NearestRight,i))return r.value[i]}return null}_getMinMaxForPlotThatSupportFillBreaks(e,t,s){const i=this.data().plottableRange(),r=e+1,n=t===j.LineStudyPlotStyle.StepLine||t===j.LineStudyPlotStyle.StepLineWithDiamonds,o=e=>{const t=i.search(e,k.PlotRowSearchMode.NearestLeft,r);if(t){const s=i.search(e,k.PlotRowSearchMode.NearestRight,r);if(s){
|
||
const e=t.value[r];if(n)return{min:e,max:e};{const t=s.value[r];return{min:Math.min(e,t),max:Math.max(e,t)}}}}return null},a=Math.floor(s.logicStartPoint),l=Math.ceil(s.logicEndPoint),h=o(a),u=o(l);return(0,D.mergeMinMax)(h,u)}async _onSourceInputChanged(){if(!this.isStarted()){this._calcSources();Qt}}_buildInputs(e){(0,_.assert)(!!e,"options not set");let t={};try{t=this._prepareInputs(e)}catch(e){Jt.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.forceTreatSourceInputsAsFake&&"source"===e.type)||t.fakeInputsForDisplay||t.onlyAtomValues?s:this._createExtendedInput(s,e.type)}_createExtendedInput(e,t){return{v:e,f:!0,t}}_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,Rt.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 ys){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,H.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,_.assert)(t.length===Object.keys(e).length,"keys quantity should be equal");for(const s of t)if((0,_.assert)(e.hasOwnProperty(s),`key '${s}' should exist in study inputs`),(0,
|
||
_.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,f.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,f.isNumber)(e.volume_precision))return Math.pow(10,e.volume_precision)}return 1}return"inherit"===e.type||Jt.logWarn("Unsupported format type: "+e.type),null}_inputSymbols(){return this.metaInfo().inputs.filter((e=>"symbol"===e.type)).map((e=>(0,_.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)}}}},30220:(e,t,s)=>{s.d(t,{plotShapesData:()=>r});var i=s(91599);const r={shape_arrow_down:{guiName:i.t(null,void 0,s(4458)),id:"shape_arrow_down",paneRendererClass:"PaneRendererArrowDown",pineName:"shape.arrowdown",icon:"arrow_down"},shape_arrow_up:{guiName:i.t(null,void 0,s(62061)),id:"shape_arrow_up",paneRendererClass:"PaneRendererArrowUp",pineName:"shape.arrowup",icon:"arrow_up"},shape_circle:{guiName:i.t(null,void 0,s(94408)),id:"shape_circle",paneRendererClass:"PaneRendererCircleShape",pineName:"shape.circle",icon:"circle"},shape_cross:{guiName:i.t(null,void 0,s(88180)),id:"shape_cross",paneRendererClass:"PaneRendererCrossShape",pineName:"shape.cross",icon:"cross"},shape_diamond:{guiName:i.t(null,void 0,s(81248)),id:"shape_diamond",paneRendererClass:"PaneRendererDiamond",pineName:"shape.diamond",icon:"diamond"},shape_flag:{guiName:i.t(null,void 0,s(71527)),id:"shape_flag",paneRendererClass:"PaneRendererFlagShape",pineName:"shape.flag",icon:"flag"},shape_label_down:{
|
||
guiName:i.t(null,void 0,s(62458)),id:"shape_label_down",paneRendererClass:"PaneRendererLabelDown",pineName:"shape.labeldown",icon:"label_down"},shape_label_up:{guiName:i.t(null,void 0,s(64157)),id:"shape_label_up",paneRendererClass:"PaneRendererLabelUp",pineName:"shape.labelup",icon:"label_up"},shape_square:{guiName:i.t(null,void 0,s(16215)),id:"shape_square",paneRendererClass:"PaneRendererSquare",pineName:"shape.square",icon:"square"},shape_triangle_down:{guiName:i.t(null,void 0,s(71745)),id:"shape_triangle_down",paneRendererClass:"PaneRendererTriangleApexDown",pineName:"shape.triangledown",icon:"triangle_down"},shape_triangle_up:{guiName:i.t(null,void 0,s(99688)),id:"shape_triangle_up",paneRendererClass:"PaneRendererTriangleApexUp",pineName:"shape.triangleup",icon:"triangle_up"},shape_xcross:{guiName:i.t(null,void 0,s(10222)),id:"shape_xcross",paneRendererClass:"PaneRendererXCross",pineName:"shape.xcross",icon:"x_cross"}}}}]); |