/**
 * Highstock JS v13.0.0 (2026-06-11)
 * @module highcharts/indicators/regressions
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Kamil Kulig
 *
 * A commercial license may be required depending on use,
 * see www.highcharts.com/license
 */import*as e from"../highcharts.js";var r={};r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);let t=e.default;var s=r.n(t);let n=e.default.SeriesRegistry;var i=r.n(n);let{sma:a}=i().seriesTypes;class o extends a{getRegressionLineParameters(e,r){let s=this.options.params.index,n=function(e,r){return(0,t.isArray)(e)?e[r]:e},i=e.reduce(function(e,r){return r+e},0),a=r.reduce(function(e,r){return n(r,s)+e},0),o=i/e.length,l=a/r.length,p,g,u=0,d=0;for(g=0;g<e.length;g++)u+=(p=e[g]-o)*(n(r[g],s)-l),d+=Math.pow(p,2);let c=d?u/d:0;return{slope:c,intercept:l-c*o}}getEndPointY(e,r){return e.slope*r+e.intercept}transformXData(e,r){let t=e[0];return e.map(function(e){return(e-t)/r})}findClosestDistance(e){let r,t,s;for(s=1;s<e.length-1;s++)(r=e[s]-e[s-1])>0&&(void 0===t||r<t)&&(t=r);return t}getValues(e,r){let s,n,i,a,o,l,p,g,u,d=e.xData,c=e.yData,y=r.period,f={xData:[],yData:[],values:[]},m=this.options.params.xAxisUnit||this.findClosestDistance(d);for(n=y-1;n<=d.length-1;n++)i=n-y+1,a=n+1,o=d[n],p=d.slice(i,a),g=c.slice(i,a),u=this.transformXData(p,m),s=this.getRegressionLineParameters(u,g),l=this.getEndPointY(s,u[u.length-1]),f.values.push({regressionLineParameters:s,x:o,y:l}),(0,t.isArray)(f.xData)&&f.xData.push(o),(0,t.isArray)(f.yData)&&f.yData.push(l);return f}}o.defaultOptions=(0,t.merge)(a.defaultOptions,{params:{xAxisUnit:null},tooltip:{valueDecimals:4}}),(0,t.extend)(o.prototype,{nameBase:"Linear Regression Indicator"}),i().registerSeriesType("linearregression",o),i().registerSeriesType("linearRegression",o);let{linearregression:l}=i().seriesTypes;class p extends l{getEndPointY(e){return e.slope}}p.defaultOptions=(0,t.merge)(l.defaultOptions),(0,t.extend)(p.prototype,{nameBase:"Linear Regression Slope Indicator"}),i().registerSeriesType("linearregressionslope",p),i().registerSeriesType("linearRegressionSlope",p);let{linearregression:g}=i().seriesTypes;class u extends g{getEndPointY(e){return e.intercept}}u.defaultOptions=(0,t.merge)(g.defaultOptions),(0,t.extend)(u.prototype,{nameBase:"Linear Regression Intercept Indicator"}),i().registerSeriesType("linearregressionintercept",u),i().registerSeriesType("linearRegressionIntercept",u);let{linearregression:d}=i().seriesTypes;class c extends d{slopeToAngle(e){return 180/Math.PI*Math.atan(e)}getEndPointY(e){return this.slopeToAngle(e.slope)}}c.defaultOptions=(0,t.merge)(d.defaultOptions,{tooltip:{pointFormat:'<span style="color:{point.color}">●</span>{series.name}: <b>{point.y}\xb0</b><br/>'}}),(0,t.extend)(c.prototype,{nameBase:"Linear Regression Angle Indicator"}),i().registerSeriesType("linearregressionangle",c),i().registerSeriesType("linearRegressionAngle",c);let y=s();export{y as default};