"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[2628],{52879:(e,t,s)=>{s.r(t),s.d(t,{LineToolAnchoredVWAP:()=>z});var i=s(85842),r=s(73775),l=s(7321),a=s(6620),n=s(43459),o=s(93445),u=s(24561),d=s(61874),c=(s(59793),s(9840)),h=s(93418),p=s(33578),y=s(4865),f=s(20737),_=s(44850);class m extends f.StudyLineDataSource{lastValueData(e,t,s){const r={noData:!0},l=this.priceScale();if(this._model.timeScale().isEmpty()||null===l||l.isEmpty()||this.plots().isEmpty())return r;const a=this._model.timeScale().visibleBarsStrictRange();if(null===a)return r;const n=this._studyProps();if(!n.childs().visible.value())return r;const o=this.plots().search(a.lastBar(),_.PlotRowSearchMode.NearestLeft,1);if(null===o)return r;const u=a.contains(o.index),d=!t&&u?o:(0,i.ensureNotNull)(this.plots().last()),c=this.metaInfo().plots.findIndex((t=>t.id===e));if(c<0||!d||!(0,h.default)(d.value[c+1]))return r;const p=d.value[c+1];if(null==p)return r;const y=(0,i.ensureDefined)(n.childs().styles.child(e)),f=(0,i.ensureNotNull)(this.firstValue()),m=l.priceToCoordinate(p,f);return{...l.getFormattedValues(p,f),noData:!1,price:p,color:y.childs().color.value(),coordinate:m,index:d.index}}priceLabelText(e){const t=(0,i.ensureDefined)(this._metaInfo.styles);return(0,i.ensureDefined)(t[e]).title}offset(e){return 0}getMinFirstBarIndexForPlot(){return-1/0}isPlotVisibleAt(e,t){const s=this._studyProps().childs().styles.childs()[e].childs();return(0,p.isPlotVisible)(s.display.value(),t)}hasHighlightedPlots(){return(0,y.highlightContainsSource)(this._model.highlightedPlotInfo(),this.id())}_studyProps(){return this.properties()}}var P=s(95655),b=s(49399),v=s(40180);class S extends v.StudyPriceAxisView{_showPaneLabel(){return!1}_showAxisLabel(){const e=this._model.properties().childs().scalesProperties.childs();return this._visible()&&"VWAP"===this._data.plotName&&e.showStudyLastValue.value()}_visible(){const e=this._source.properties().childs().styles.childs()[this._data.plotName].childs().display.value();return this._source.properties().childs().axisLabelVisible.value()&&Boolean(4&e)}}class V extends u.StudyPlotPaneView{constructor(e,t,s,i){super(e,t,s,i),this._line=e}_makeSureRendererIsValid(){(this._dataInvalidated||this._viewportInvalidated)&&this._updateImplFull(this._viewportInvalidated)&&(this._dataInvalidated=null),this._viewportInvalidated=!1}_updateRenderer(e,t){super._updateRenderer(e,t),this._addAlertsRenderer()}_addAlertsRenderer(){return!1}}var w=s(50721),g=s(70525),A=s(53924),I=s(22663),C=s(5220),D=s(9584);const L=function(e,t,s,i){var r=-1,l=g.default,a=!0,n=e.length,o=[],u=t.length;if(!n)return o;s&&(t=(0,I.default)(t,(0,C.default)(s))),i?(l=A.default,a=!1):t.length>=200&&(l=D.default,a=!1,t=new w.default(t));e:for(;++r"calculate_stDev"===e.id))||((0,i.ensureDefined)(t.inputs).calculate_stDev=!1),t.styles&&(U(t.styles.VWAP,r.defaults.styles?.VWAP?.display),U(t.styles.UpperBand,r.defaults.styles?.UpperBand?.display),U(t.styles.LowerBand,r.defaults.styles?.LowerBand?.display),U(t.styles.UpperBand_2,r.defaults.styles?.UpperBand_2?.display),U(t.styles.LowerBand_2,r.defaults.styles?.LowerBand_2?.display),U(t.styles.UpperBand_3,r.defaults.styles?.UpperBand_3?.display),U(t.styles.LowerBand_3,r.defaults.styles?.LowerBand_3?.display)),t}function U(e,t){if(void 0!==e&&void 0!==e.visible)try{if(void 0!==e.display&&e.display!==t)return;e.display=e.visible?4294967295:0}finally{delete e.visible}}class H extends F.LineDataSourceProperty{constructor(e){super(e),this.hasChild("axisLabelVisible")||this.addChild("axisLabelVisible",new W.Property(true));const t=this.childs().styles.childs().VWAP.childs().linewidth,s=this.childs().styles.childs().VWAP.childs().color;this.addChild("linesWidths",new k.LineToolWidthsProperty([t])),this.addChild("linesColors",new k.LineToolColorsProperty([s]))}static create(e,t,s,i){i&&(i=(0,M.prepareStudyPropsStateForLoadChart)(t,null,i,s,K));const r=(0,M.studyPropsExcludeDefaultsKeys)(t).filter((e=>"intervalsVisibilities"!==e)),n=B((0,o.extractAllPropertiesKeys)(t.defaults).concat((0,o.extractAllPropertiesKeys)((0,M.studyGeneralPropsState)())),...M.blacklistedProperties.concat(r)),u=[...n,...r,...T.commonLineToolPropertiesStateKeys,"axisLabelVisible"];return new this({defaultName:a.StudyMetaInfo.getStudyPropertyRootName(t),factoryDefaultsSupplier:()=>(0,l.merge)((0,l.clone)(t.defaults),(0,M.studyGeneralPropsState)()),nonThemedDefaultsKeys:n,allStateKeys:u,state:i,theme:e})}}const O=(0,r.getLogger)("Chart.AnchoredVWAP");class z extends m{constructor(e,t,s,r,l){s=s||(0,i.ensureNotNull)((0,b.studyMetaInfoRepository)().findByIdSync({type:"java",studyId:E}));const a=t??z.createProperties(e.backgroundTheme().spawnOwnership());super(e,s,"anchoredvwap",a,r,l),this._onVisibleBarsStrictRangeChanged=e=>{const t=this._getPointsetPoints()?.[0].index??null;null!==t&&null!==e&&e.contains(t)&&this._onStudyInputsMayChange()};const[n,o,c,h,p,y,f]=this.metaInfo().plots,_=e.mainSeries(),m=[new V(this,_,e,n.id)];o&&c&&(m.push(new u.StudyPlotPaneView(this,_,e,o.id)),m.push(new u.StudyPlotPaneView(this,_,e,c.id))),h&&p&&y&&f&&(m.push(new u.StudyPlotPaneView(this,_,e,h.id)),m.push(new u.StudyPlotPaneView(this,_,e,p.id)),m.push(new u.StudyPlotPaneView(this,_,e,y.id)),m.push(new u.StudyPlotPaneView(this,_,e,f.id))),this._properties.childs().areaBackground&&m.splice(0,0,new d.AreaBackgroundPaneView(this,e)),this._priceAxisViews=this.metaInfo().plots.map((e=>new S(this,{plotName:e.id}))),m.push(...this._priceAxisViews.map((e=>new P.PanePriceAxisView(e,this,this._model)))),this._anchorPriceCalculated=!1, this._onInputsReadyCallbacks=[],this._setPaneViews(m),e.properties().childs().scalesProperties.childs().showStudyLastValue.subscribe(this,this._onShowStudyLastValueChanged),a.onRestoreFactoryDefaults().subscribe(this,this._onRestoreFactoryDefaults),this._hasAlert.subscribe(this.processHibernate.bind(this),{callWithLast:!0}),this._model.timeScale().visibleBarsStrictRangeChanged().subscribe(this,this._onVisibleBarsStrictRangeChanged)}destroy(){this.properties().onRestoreFactoryDefaults().unsubscribeAll(this),this.model().properties().childs().scalesProperties.childs().showStudyLastValue.unsubscribeAll(this),this._model.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(this),this._onInputsReadyCallbacks=[],super.destroy()}cloneable(){return!1}canHasAlert(){return!0}pointsCount(){return 1}updateAllViews(e){super.updateAllViews(e),this._priceAxisViews.forEach((t=>t.update(e)))}firstValue(){return this._model.mainSeries().firstValue()}priceRange(e){if(!this._isReady()||this.isSourceHidden()||e.targetPriceScale!==this.priceScale())return null;const{startTimePoint:t,endTimePoint:s}=e,r=this.plots().minMaxOnRangeCached(t,s,[{name:this.metaInfo().plots[0].id,offset:0}]);if(null===r)return null;const l=(0,i.ensureNotNull)(this.priceScale());return l.isLog()?new n.PriceRange(l.priceToLogical(r.min),l.priceToLogical(r.max)):new n.PriceRange(r.min,r.max)}isIncludedInAutoScale(){return!0}restoreData(e){super.restoreData(e),void 0!==e.data&&(this._anchorPriceCalculated=!0)}properties(){return super.properties()}sourceId(){return this._studyId()}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}inputsForAlertState(){return null===this._inputs&&O.logWarn("Could not get inputsForAlertState if VWAP has no inputs"),{...this.inputs()}}inputs(){return(0,i.ensureNotNull)(this._inputs)}idForAlert(){return super.idForAlert()}defaultPlotIdForAlert(){return this.metaInfo().plots[0].id}canBeHibernated(){return super.canBeHibernated()&&!this._hasAlert.value()}static createProperties(e,t){const s=a.StudyMetaInfo.getStudyPropertyRootNameById(E),r=(0,i.ensureNotNull)((0,b.studyMetaInfoRepository)().findByIdSync({type:"java",studyId:E})),n=(0,o.createDefaultsState)(!0,s,[],(0,b.studyMetaInfoRepository)().studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(r,r,(0,l.merge)((0,l.clone)(n),t??{}),(0,b.studyMetaInfoRepository)().studyVersioning(),e)}static studyId(){return E}static createPropertiesFromStudyMetaInfoAndState(e,t,s,i,r){const l=H.create(r,t,i,s);return this._configureProperties(l),l}_onPointsetUpdated(e){super._onPointsetUpdated(e),this._onStudyInputsMayChange()}_studyInputs(e){(0,i.assert)(1===e.length,"all the line tool points should be defined");const t=e[0],s=this._getPointTime(t,!1);return null===s?(this._subscribeApplyInputsOnSeriesCompleted(),null):{...this.properties().childs().inputs.state(["start_time"]),start_time:1e3*s}}_isReady(){return super._isReady()&&(null!==this._inputs||this._anchorPriceCalculated)&&this.model().lineBeingEdited()!==this}_onDataCleared(){ super._onDataCleared(),this._anchorPriceCalculated=!1}_onInputsChanged(){if(super._onInputsChanged(),this._updateAlertCreationAvailable(),null!==this._inputs){for(const e of this._onInputsReadyCallbacks)try{e(this._inputs)}catch(e){O.logError(e.stack||e.message)}this._onInputsReadyCallbacks=[]}}_clearAllDataExceptPointsetPoints(){super._clearAllDataExceptPointsetPoints(),this._updateAlertCreationAvailable()}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([s.e(1982),s.e(7686),s.e(2428),s.e(3920),s.e(9328)]).then(s.bind(s,33659))).AnchoredVWAPDefinitionsViewModel}_updateAnchorsPrice(e){if(!e&&(this._anchorPriceCalculated||!this.isActualSymbol()))return;const t=this.firstValue(),s=this.points();if(null===t||0===s.length)return;const i=s[0].index,r=this.plots().valueAt(i);if(null===r)return;const l=r[1];null!=l&&(this._points[0].price=l,this._timePoint[0].price=l,this._anchorPriceCalculated=!0)}async _synchronizeAlert(e){this._onInputsReady((()=>super._synchronizeAlert(e)))}_onInputsReady(e){null!==this._inputs?e(this._inputs):this._onInputsReadyCallbacks.push(e)}_onShowStudyLastValueChanged(){this._priceAxisViews.forEach((e=>e.update((0,c.sourceChangeEvent)(this.id())))),this.model().updateSource(this)}_onRestoreFactoryDefaults(){this.properties().childs().axisLabelVisible.setValue(true)}}},25432:(e,t,s)=>{s.d(t,{commonLineToolPropertiesStateKeys:()=>i});const i=["symbolStateVersion","zOrderVersion","frozen","title","interval","symbol","currencyId","unitId","metricId","visible","adjustedToSplitTime","intervalsVisibilities.ticks","intervalsVisibilities.seconds","intervalsVisibilities.secondsFrom","intervalsVisibilities.secondsTo","intervalsVisibilities.minutes","intervalsVisibilities.minutesFrom","intervalsVisibilities.minutesTo","intervalsVisibilities.hours","intervalsVisibilities.hoursFrom","intervalsVisibilities.hoursTo","intervalsVisibilities.days","intervalsVisibilities.daysFrom","intervalsVisibilities.daysTo","intervalsVisibilities.weeks","intervalsVisibilities.weeksFrom","intervalsVisibilities.weeksTo","intervalsVisibilities.months","intervalsVisibilities.monthsFrom","intervalsVisibilities.monthsTo","intervalsVisibilities.ranges"];var r,l,a;!function(e){e[e.NotShared=0]="NotShared",e[e.SharedInLayout=1]="SharedInLayout",e[e.GloballyShared=2]="GloballyShared"}(r||(r={})),function(e){e.BeforeAllAction="BeforeAll",e.CustomAction="CustomAction"}(l||(l={})),function(e){e.FloatingToolbarButton="FloatingToolbarButton",e.Default="Default"}(a||(a={}))},86371:(e,t,s)=>{s.d(t,{LineDataSourceProperty:()=>o});var i=s(57600),r=s(35558),l=s(85842),a=s(93445),n=s(47895);class o extends a.DefaultProperty{constructor({templateKeys:e,factoryDefaultsSupplier:t,...s}){let i=t;t&&(i=()=>{const e=t();return(0,n.applyDefaultsOverrides)(e,void 0,void 0,s.defaultName),e}),super({saveNonDefaultUserPreferencesOnly:!0,factoryDefaultsSupplier:i,...s}),this._templateKeys=(0,l.ensureDefined)(e||this._allDefaultsKeys)}template(){return(0,a.extractState)(this.state(),this._templateKeys,[])}applyTemplate(e){ this.mergeAndFire((0,a.extractState)((0,r.default)((0,i.default)(this._factoryDefaultsSupplier()),e),this._templateKeys))}}}}]);