/**
 * Highstock JS v12.6.0 (2026-04-13)
 * @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 t from"../highcharts.js";var e,o={};o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var a=o.n(r);let i=function(t,e,o){return t.reduce((t,r)=>[Math.min(t[0],r[e]),Math.max(t[1],r[o])],[Number.MAX_VALUE,-Number.MAX_VALUE])},n=t.default.SeriesRegistry;var s=o.n(n);let{doc:l,win:p}=a();function h(t){return u(t)&&"number"==typeof t.nodeType}function c(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function u(t,e){return!!t&&"object"==typeof t&&(!e||!c(t))}function f(t,...e){let o,r=[t,...e],a={},i=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,o){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call((0,t[o]),t[o],o,t)}(e,function(o,r){if("__proto__"!==r&&"constructor"!==r){let a;!u(o,!0)||(a=o?.constructor,u(o,!0)&&!h(o)&&a?.name&&"Object"!==a.name)||h(o)?t[r]=e[r]:t[r]=i(t[r]||{},o)}}),t};!0===t&&(a=r[1],r=Array.prototype.slice.call(r,2));let n=r.length;for(o=0;o<n;o++)a=i(a,r[o]);return a}Array.prototype.find;let{sma:{prototype:y}}=s().seriesTypes;!function(t){let e=["bottomLine"],o=["top","bottom"],a=["top"];function i(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function n(t,e){let o=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&o.push(i(t))}),o}function s(){let t=this,e=t.pointValKey,o=t.linesApiNames,a=t.areaLinesNames,s=t.points,l=t.options,p=t.graph,h={options:{gapSize:l.gapSize}},c=[],u=n(t,e),d=s.length,m;if(u.forEach((t,e)=>{for(c[e]=[];d--;)m=s[d],c[e].push({x:m.x,plotX:m.plotX,plotY:m[t],isNull:null==m[t]});d=s.length}),t.userOptions.fillColor&&a.length){let e=c[u.indexOf(i(a[0]))],o=1===a.length?s:c[u.indexOf(i(a[1]))],r=t.color;t.points=o,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=f(s,h),t.graph=t.area,t.fillGraph=!0,y.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}o.forEach((e,o)=>{c[o]?(t.points=c[o],l[e]?t.options=f(l[e].styles,h):(0,r.error)('Error: "There is no '+e+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),t.graph=t["graph"+e],y.drawGraph.call(t),t["graph"+e]=t.graph):(0,r.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=s,t.options=l,t.graph=p,y.drawGraph.call(t)}function l(t){let e,o=[],r=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=y.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",o=y.getGraphPath.call(this,t),r=e.slice(0,o.length);for(let t=r.length-1;t>=0;t--)o.push(r[t])}}else o=y.getGraphPath.apply(this,arguments);return o}function p(t){let e=[];return(this.pointArrayMap||[]).forEach(o=>{e.push(t[o])}),e}function h(){let t=this.pointArrayMap,e=[],o;e=n(this),y.translate.apply(this,arguments),this.points.forEach(r=>{t.forEach((t,a)=>{o=r[t],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(r[e[a]]=this.yAxis.toPixels(o,!0))})})}t.compose=function(t){let r=t.prototype;return r.linesApiNames=r.linesApiNames||e.slice(),r.pointArrayMap=r.pointArrayMap||o.slice(),r.pointValKey=r.pointValKey||"top",r.areaLinesNames=r.areaLinesNames||a.slice(),r.drawGraph=s,r.getGraphPath=l,r.toYData=p,r.translate=h,t}}(e||(e={}));let d=e,{sma:m}=s().seriesTypes;class g extends m{init(){super.init.apply(this,arguments),this.options=f({smoothedLine:{styles:{lineColor:this.color}}},this.options)}getValues(t,e){let o=e.periods[0],r=e.periods[1],a=t.xData,n=t.yData,s=n?n.length:0,l=[],p=[],h=[],u,f,y=null,d,m;if(s<o||!c(n[0])||4!==n[0].length)return;let g=!0,A=0;for(m=o-1;m<s;m++){if(u=(d=i(n.slice(m-o+1,m+1),2,1))[0],isNaN(f=(n[m][3]-u)/(d[1]-u)*100)&&g){A++;continue}g&&!isNaN(f)&&(g=!1);let t=p.push(a[m]);isNaN(f)?h.push([h[t-2]&&"number"==typeof h[t-2][0]?h[t-2][0]:null,null]):h.push([f,null]),m>=A+(o-1)+(r-1)&&(y=super.getValues({xData:p.slice(-r),yData:h.slice(-r)},{period:r}).yData[0]),l.push([a[m],f,y]),h[t-1][1]=y}return{values:l,xData:p,yData:h}}}g.defaultOptions=f(m.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"}}),function(t,e){let o;for(o in t||(t={}),e)t[o]=e[o]}(g.prototype,{areaLinesNames:[],nameComponents:["periods"],nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]}),d.compose(g),s().registerSeriesType("stochastic",g);let A=a();export{A as default};