/**
 * Highstock JS v12.6.0 (2026-04-13)
 * @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 t={};t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r=e.default;var n=t.n(r);let s=e.default.SeriesRegistry;var i=t.n(s);let{doc:o,win:a}=n();function l(e,t){let r;for(r in e||(e={}),t)e[r]=t[r];return e}function p(e){return c(e)&&"number"==typeof e.nodeType}function u(e){let t=Object.prototype.toString.call(e);return"[object Array]"===t||"[object Array Iterator]"===t}function c(e,t){return!!e&&"object"==typeof e&&(!t||!u(e))}function g(e,...t){let r,n=[e,...t],s={},i=function(e,t){return"object"!=typeof e&&(e={}),function(e,t,r){for(let r in e)Object.hasOwnProperty.call(e,r)&&t.call((0,e[r]),e[r],r,e)}(t,function(r,n){if("__proto__"!==n&&"constructor"!==n){let s;!c(r,!0)||(s=r?.constructor,c(r,!0)&&!p(r)&&s?.name&&"Object"!==s.name)||p(r)?e[n]=t[n]:e[n]=i(e[n]||{},r)}}),e};!0===e&&(s=n[1],n=Array.prototype.slice.call(n,2));let o=n.length;for(r=0;r<o;r++)s=i(s,n[r]);return s}Array.prototype.find;let{sma:f}=i().seriesTypes;class y extends f{getRegressionLineParameters(e,t){let r=this.options.params.index,n=function(e,t){return u(e)?e[t]:e},s=e.reduce(function(e,t){return t+e},0),i=t.reduce(function(e,t){return n(t,r)+e},0),o=s/e.length,a=i/t.length,l,p,c=0,g=0;for(p=0;p<e.length;p++)c+=(l=e[p]-o)*(n(t[p],r)-a),g+=Math.pow(l,2);let f=g?c/g:0;return{slope:f,intercept:a-f*o}}getEndPointY(e,t){return e.slope*t+e.intercept}transformXData(e,t){let r=e[0];return e.map(function(e){return(e-r)/t})}findClosestDistance(e){let t,r,n;for(n=1;n<e.length-1;n++)(t=e[n]-e[n-1])>0&&(void 0===r||t<r)&&(r=t);return r}getValues(e,t){let r,n,s,i,o,a,l,p,c,g=e.xData,f=e.yData,y=t.period,d={xData:[],yData:[],values:[]},h=this.options.params.xAxisUnit||this.findClosestDistance(g);for(n=y-1;n<=g.length-1;n++)s=n-y+1,i=n+1,o=g[n],l=g.slice(s,i),p=f.slice(s,i),c=this.transformXData(l,h),r=this.getRegressionLineParameters(c,p),a=this.getEndPointY(r,c[c.length-1]),d.values.push({regressionLineParameters:r,x:o,y:a}),u(d.xData)&&d.xData.push(o),u(d.yData)&&d.yData.push(a);return d}}y.defaultOptions=g(f.defaultOptions,{params:{xAxisUnit:null},tooltip:{valueDecimals:4}}),l(y.prototype,{nameBase:"Linear Regression Indicator"}),i().registerSeriesType("linearregression",y),i().registerSeriesType("linearRegression",y);let{linearregression:d}=i().seriesTypes;class h extends d{getEndPointY(e){return e.slope}}h.defaultOptions=g(d.defaultOptions),l(h.prototype,{nameBase:"Linear Regression Slope Indicator"}),i().registerSeriesType("linearregressionslope",h),i().registerSeriesType("linearRegressionSlope",h);let{linearregression:m}=i().seriesTypes;class x extends m{getEndPointY(e){return e.intercept}}x.defaultOptions=g(m.defaultOptions),l(x.prototype,{nameBase:"Linear Regression Intercept Indicator"}),i().registerSeriesType("linearregressionintercept",x),i().registerSeriesType("linearRegressionIntercept",x);let{linearregression:O}=i().seriesTypes;class T extends O{slopeToAngle(e){return 180/Math.PI*Math.atan(e)}getEndPointY(e){return this.slopeToAngle(e.slope)}}T.defaultOptions=g(O.defaultOptions,{tooltip:{pointFormat:'<span style="color:{point.color}">●</span>{series.name}: <b>{point.y}\xb0</b><br/>'}}),l(T.prototype,{nameBase:"Linear Regression Angle Indicator"}),i().registerSeriesType("linearregressionangle",T),i().registerSeriesType("linearRegressionAngle",T);let b=n();export{b as default};