/**
 * Highstock JS v13.0.0 (2026-06-11)
 * @module highcharts/indicators/supertrend
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Wojciech Chmiel
 *
 * A commercial license may be required depending on use,
 * see www.highcharts.com/license
 */import*as e from"../highcharts.js";var o={};o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o);let r=e.default;var t=o.n(r);let l=e.default.SeriesRegistry;var i=o.n(l);let{atr:s,sma:n}=i().seriesTypes;function a(e,o){return{index:o,close:e.getColumn("close")[o],x:e.getColumn("x")[o]}}class p extends n{init(){let e=this;super.init.apply(e,arguments);let o=(0,r.addEvent)(this.chart.constructor,"afterLinkSeries",()=>{let{linkedParent:r,options:t}=e;t&&r&&(t.cropThreshold=(r.options.cropThreshold??0)-((t.params?.period??0)-1)),o()},{order:1})}drawGraph(){let e=this,o=e.options,t=e.linkedParent,l=t.getColumn("x"),i=t?t.points:[],s=e.points,p=e.graph,c=i.length-s.length,d=c>0?c:0,h={options:{gapSize:o.gapSize}},u={top:[],bottom:[],intersect:[]},g={top:{styles:{lineWidth:o.lineWidth,lineColor:o.fallingTrendColor||o.color,dashStyle:o.dashStyle}},bottom:{styles:{lineWidth:o.lineWidth,lineColor:o.risingTrendColor||o.color,dashStyle:o.dashStyle}},intersect:o.changeTrendLine},x,y,m,f,C,T,b,v,S,N=s.length;for(;N--;)x=s[N],y=s[N-1],m=i[N-1+d],f=i[N-2+d],C=i[N+d],T=i[N+d+1],b=x.options.color,v={x:x.x,plotX:x.plotX,plotY:x.plotY,isNull:!1},!f&&m&&(0,r.isNumber)(l[m.index-1])&&(f=a(t,m.index-1)),!T&&C&&(0,r.isNumber)(l[C.index+1])&&(T=a(t,C.index+1)),!m&&f&&(0,r.isNumber)(l[f.index+1])?m=a(t,f.index+1):!m&&C&&(0,r.isNumber)(l[C.index-1])&&(m=a(t,C.index-1)),x&&m&&C&&f&&x.x!==m.x&&(x.x===C.x?(f=m,m=C):x.x===f.x?(m=f,f={close:t.getColumn("close")[m.index-1],x:l[m.index-1]}):T&&x.x===T.x&&(m=T,f=C)),y&&f&&m?(S={x:y.x,plotX:y.plotX,plotY:y.plotY,isNull:!1},x.y>=m.close&&y.y>=f.close?(x.color=b||o.fallingTrendColor||o.color,u.top.push(v)):x.y<m.close&&y.y<f.close?(x.color=b||o.risingTrendColor||o.color,u.bottom.push(v)):(u.intersect.push(v),u.intersect.push(S),u.intersect.push((0,r.merge)(S,{isNull:!0})),x.y>=m.close&&y.y<f.close?(x.color=b||o.fallingTrendColor||o.color,y.color=b||o.risingTrendColor||o.color,u.top.push(v),u.top.push((0,r.merge)(S,{isNull:!0}))):x.y<m.close&&y.y>=f.close&&(x.color=b||o.risingTrendColor||o.color,y.color=b||o.fallingTrendColor||o.color,u.bottom.push(v),u.bottom.push((0,r.merge)(S,{isNull:!0}))))):m&&(x.y>=m.close?(x.color=b||o.fallingTrendColor||o.color,u.top.push(v)):(x.color=b||o.risingTrendColor||o.color,u.bottom.push(v)));(0,r.objectEach)(u,function(o,t){e.points=o,e.options=(0,r.merge)(g[t].styles,h),e.graph=e["graph"+t+"Line"],n.prototype.drawGraph.call(e),e["graph"+t+"Line"]=e.graph}),e.points=s,e.options=o,e.graph=p}getValues(e,o){let t=o.period,l=o.multiplier,i=e.xData,n=e.yData,a=[],p=[],c=[],d=0===t?0:t-1,h=[],u=[],g=[],x,y,m,f,C,T,b,v,S;if(!(i.length<=t)&&(0,r.isArray)(n[0])&&4===n[0].length&&!(t<0)){for(S=0,g=s.prototype.getValues.call(this,e,{period:t}).yData;S<g.length;S++)v=n[d+S],b=n[d+S-1]||[],f=h[S-1],C=u[S-1],T=c[S-1],0===S&&(f=C=T=0),x=(0,r.correctFloat)((v[1]+v[2])/2+l*g[S]),y=(0,r.correctFloat)((v[1]+v[2])/2-l*g[S]),x<f||b[3]>f?h[S]=x:h[S]=f,y>C||b[3]<C?u[S]=y:u[S]=C,T===f&&v[3]<h[S]||T===C&&v[3]<u[S]?m=h[S]:(T===f&&v[3]>h[S]||T===C&&v[3]>u[S])&&(m=u[S]),a.push([i[d+S],m]),p.push(i[d+S]),c.push(m);return{values:a,xData:p,yData:c}}}}p.defaultOptions=(0,r.merge)(n.defaultOptions,{params:{index:void 0,multiplier:3,period:10},risingTrendColor:"var(--highcharts-positive-color)",fallingTrendColor:"var(--highcharts-negative-color)",changeTrendLine:{styles:{lineWidth:1,lineColor:"var(--highcharts-neutral-color-80)",dashStyle:"LongDash"}}}),(0,r.extend)(p.prototype,{nameBase:"Supertrend",nameComponents:["multiplier","period"]}),i().registerSeriesType("supertrend",p);let c=t();export{c as default};