/**
 * Highstock JS v13.0.0 (2026-06-11)
 * @module highcharts/indicators/stochastic
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Paweł Fus
 *
 * A commercial license may be required depending on use,
 * see www.highcharts.com/license
 */import*as e from"../highcharts.js";var t,a={};a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let i=e.default;var o=a.n(i);let r=function(e,t,a){return e.reduce((e,i)=>[Math.min(e[0],i[t]),Math.max(e[1],i[a])],[Number.MAX_VALUE,-Number.MAX_VALUE])},s=e.default.SeriesRegistry;var n=a.n(s);let{sma:{prototype:l}}=n().seriesTypes;!function(e){let t=["bottomLine"],a=["top","bottom"],o=["top"];function r(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function s(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(r(e))}),a}function n(){let e=this,t=e.pointValKey,a=e.linesApiNames,o=e.areaLinesNames,n=e.points,p=e.options,h=e.graph,u={options:{gapSize:p.gapSize}},c=[],d=s(e,t),m=n.length,y;if(d.forEach((e,t)=>{for(c[t]=[];m--;)y=n[m],c[t].push({x:y.x,plotX:y.plotX,plotY:y[e],isNull:!(0,i.defined)(y[e])});m=n.length}),e.userOptions.fillColor&&o.length){let t=c[d.indexOf(r(o[0]))],a=1===o.length?n:c[d.indexOf(r(o[1]))],s=e.color;e.points=a,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,i.merge)(n,u),e.graph=e.area,e.fillGraph=!0,l.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=s}a.forEach((t,a)=>{c[a]?(e.points=c[a],p[t]?e.options=(0,i.merge)(p[t].styles,u):(0,i.error)('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],l.drawGraph.call(e),e["graph"+t]=e.graph):(0,i.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=n,e.options=p,e.graph=h,l.drawGraph.call(e)}function p(e){let t,a=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=l.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=l.getGraphPath.call(this,e),i=t.slice(0,a.length);for(let e=i.length-1;e>=0;e--)a.push(i[e])}}else a=l.getGraphPath.apply(this,arguments);return a}function h(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function u(){let e=this.pointArrayMap,t=[],a;t=s(this),l.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,o)=>{a=i[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(i[t[o]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let i=e.prototype;return i.linesApiNames=i.linesApiNames||t.slice(),i.pointArrayMap=i.pointArrayMap||a.slice(),i.pointValKey=i.pointValKey||"top",i.areaLinesNames=i.areaLinesNames||o.slice(),i.drawGraph=n,i.getGraphPath=p,i.toYData=h,i.translate=u,e}}(t||(t={}));let p=t,{sma:h}=n().seriesTypes;class u extends h{init(){super.init.apply(this,arguments),this.options=(0,i.merge)({smoothedLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let a=t.periods[0],o=t.periods[1],s=e.xData,n=e.yData,l=n?n.length:0,p=[],h=[],u=[],c,d,m=null,y,f;if(l<a||!(0,i.isArray)(n[0])||4!==n[0].length)return;let g=!0,A=0;for(f=a-1;f<l;f++){if(c=(y=r(n.slice(f-a+1,f+1),2,1))[0],isNaN(d=(n[f][3]-c)/(y[1]-c)*100)&&g){A++;continue}g&&!isNaN(d)&&(g=!1);let e=h.push(s[f]);isNaN(d)?u.push([u[e-2]&&"number"==typeof u[e-2][0]?u[e-2][0]:null,null]):u.push([d,null]),f>=A+(a-1)+(o-1)&&(m=super.getValues({xData:h.slice(-o),yData:u.slice(-o)},{period:o}).yData[0]),p.push([s[f],d,m]),u[e-1][1]=m}return{values:p,xData:h,yData:u}}}u.defaultOptions=(0,i.merge)(h.defaultOptions,{params:{index:void 0,period:void 0,periods:[14,3]},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">●</span><b> {series.name}</b><br/>%K: {point.y}<br/>%D: {point.smoothed}<br/>'},smoothedLine:{styles:{lineWidth:1,lineColor:void 0}},dataGrouping:{approximation:"averages"}}),(0,i.extend)(u.prototype,{areaLinesNames:[],nameComponents:["periods"],nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]}),p.compose(u),n().registerSeriesType("stochastic",u);let c=o();export{c as default};