"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[9310],{28121:(e,t,i)=>{i.r(t),i.d(t,{LineToolFlatBottom:()=>h});var s=i(50151),n=i(41414),r=i(78176),o=i(87465),l=i(43337),p=i(22613),a=i(65045);class h extends n.LineDataSource{constructor(e,t,s,n){super(e,t??h.createProperties(e.backgroundTheme().spawnOwnership()),s,n),this.version=1,this._hasEditableCoordinates=new p.WatchedValue(!1),Promise.all([i.e(6290),i.e(986),i.e(6668),i.e(1583)]).then(i.bind(i,65967)).then((e=>{this._setPaneViews([new e.FlatBottomPaneView(this,this._model)])}))}pointsCount(){return 3}name(){return"Flat Bottom"}snapTo45DegreesAvailable(){return!0}addPoint(e,t,i){return this._snapTo45DegreesApplicable(t)&&2===this.points().length&&this.snapPoint45Degree(e,this.points()[this.points().length-2]),super.addPoint(e)}setLastPoint(e,t){return this._snapTo45DegreesApplicable(t)&&2===this.points().length&&this.snapPoint45Degree(e,this.points()[this.points().length-2]),super.setLastPoint(e)}setPoint(e,t,i,s){if(this._snapTo45DegreesApplicable(i)&&1===e){const e=0;this.snapPoint45Degree(t,this.points()[e])}const n=this._model.mainSeries().interval();if(2===e)this._points[1].index=t.index,this._points[1].interval=n;else if(3===e)return this._points[0].index=t.index,this._points[0].interval=n,this._points[2].price=t.price,void this._normalizePoints();super.setPoint(e,t)}getPoint(e){return e<3?super.getPoint(e):3===e?{index:this._points[0].index,price:this._points[2].price}:null}canHasAlert(){return!0}template(){const e=super.template();return e.labelText=this.properties().childs().labelText.value(),e}static createProperties(e,t){const i=new r.DefaultProperty({defaultName:"linetoolflatbottom",state:t,theme:e});return this._configureProperties(i),i}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().labelText.setValue(e.labelText??"")}_getAlertPlots(){const e=this._points[0],t=this._points[1],i=[];e.index<=t.index?(i.push(e),i.push(t)):(i.push(t),i.push(e));const s=this._points[2];s.time=t.time,s.index=t.index;const n={price:s.price,time:e.time,index:e.index},r=[];let l,p,a,h;s.index<=n.index?(r.push(s),r.push(n)):(r.push(n),r.push(s)),i[0].price>r[0].price?(l=i,p=r):r[0].price>i[0].price||r[1].price>i[1].price?(l=r,p=i):(l=i,p=r);const d=this.properties().childs().extendLeft.value(),u=this.properties().childs().extendRight.value();return e.index<=t.index?(a=d,h=u):(a=u,h=d),[this._linePointsToAlertPlot(l,"Upper",a,h),this._linePointsToAlertPlot(p,"Lower",d,h)].filter(o.notNull)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,96662))).GeneralTrendFiguresDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.hasChild("labelText")||e.addChild("labelText",new l.Property("")),e.addExcludedKey("labelText",1),e.addChild("textsColors",new a.LineToolColorsProperty([(0,s.ensureDefined)(e.child("labelTextColor"))]))}}}}]);