let t;/**
 * Highstock JS v13.0.0 (2026-06-11)
 * @module highcharts/modules/datagrouping
 * @requires highcharts
 *
 * Data grouping module
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Torstein Hønsi
 *
 * A commercial license may be required depending on use,
 * see www.highcharts.com/license
 */import*as e from"../highcharts.js";var i,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 i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a=e.default;var n=o.n(a);let r={};function s(t){let e=t.length,i=l(t);return(0,a.isNumber)(i)&&e&&(i=(0,a.correctFloat)(i/e)),i}function l(t){let e=t.length,i;if(!e&&t.hasNulls)i=null;else if(e)for(i=0;e--;)i+=t[e];return i}let u={average:s,averages:function(){let t=[];return[].forEach.call(arguments,function(e){t.push(s(e))}),void 0===t[0]?void 0:t},close:function(t){return t.length?t[t.length-1]:t.hasNulls?null:void 0},high:function(t){return t.length?(0,a.arrayMax)(t):t.hasNulls?null:void 0},hlc:function(t,e,i){if(t=r.high(t),e=r.low(e),i=r.close(i),(0,a.isNumber)(t)||(0,a.isNumber)(e)||(0,a.isNumber)(i))return[t,e,i]},low:function(t){return t.length?(0,a.arrayMin)(t):t.hasNulls?null:void 0},ohlc:function(t,e,i,o){if(t=r.open(t),e=r.high(e),i=r.low(i),o=r.close(o),(0,a.isNumber)(t)||(0,a.isNumber)(e)||(0,a.isNumber)(i)||(0,a.isNumber)(o))return[t,e,i,o]},open:function(t){return t.length?t[0]:t.hasNulls?null:void 0},range:function(t,e){return(t=r.low(t),e=r.high(e),(0,a.isNumber)(t)||(0,a.isNumber)(e))?[t,e]:null===t&&null===e?null:void 0},sum:l};(0,a.extend)(r,u);let h={groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%[AebHMSL]","%[AebHMSL]","-%[HMSL]"],second:["%[AebHMS]","%[AebHMS]","-%[HMS]"],minute:["%[AebHM]","%[AebHM]","-%[HM]"],hour:["%[AebHM]","%[AebHM]","-%[HM]"],day:["%[AebY]","%[Aeb]","-%[AebY]"],week:["%v %[AebY]","%[Aeb]","-%[AebY]"],month:["%[BY]","%[B]","-%[BY]"],year:["%[Y]","%[Y]","-%[Y]"]}},p={line:{},spline:{},area:{},areaspline:{},arearange:{},column:{groupPixelWidth:10},columnrange:{groupPixelWidth:10},candlestick:{groupPixelWidth:10},ohlc:{groupPixelWidth:5},hlc:{groupPixelWidth:5},heikinashi:{groupPixelWidth:10}},d=[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1]],["week",[1]],["month",[1,3,6]],["year",null]];function c(t){let e=this,i=e.series;i.forEach(function(t){t.groupPixelWidth=void 0}),i.forEach(function(i){i.groupPixelWidth=e.getGroupPixelWidth&&e.getGroupPixelWidth(),i.groupPixelWidth&&(i.hasProcessed=!0),i.applyGrouping(!!t.hasExtremesChanged)})}function g(){let t=this.series,e=t.length,i=0,o=!1,n,r;for(;e--;)(r=t[e].options.dataGrouping)&&(i=Math.max(i,(0,a.pick)(r.groupPixelWidth,h.groupPixelWidth)),n=(t[e].dataTable.getModified()||t[e].dataTable).rowCount,(t[e].groupPixelWidth||n>this.chart.plotSizeX/i||n&&r.forced)&&(o=!0));return o?i:0}function m(){this.series.forEach(function(t){t.hasProcessed=!1})}function f(e,i){let o;if(i=(0,a.pick)(i,!0),e||(e={forced:!1,units:null}),this instanceof t)for(o=this.series.length;o--;)this.series[o].update({dataGrouping:e},!1);else this.chart.options.series.forEach(function(t){t.dataGrouping="boolean"==typeof e?e:(0,a.merge)(e,t.dataGrouping)});this.ordinal&&(this.ordinal.slope=void 0),i&&this.chart.redraw()}let y=function(e){t=e;let i=e.prototype;i.applyGrouping||((0,a.addEvent)(e,"afterSetScale",m),(0,a.addEvent)(e,"postProcessData",c),(0,a.extend)(i,{applyGrouping:c,getGroupPixelWidth:g,setDataGrouping:f}))},{setLength:b,splice:x}={convertToNumber:function(t,e){switch(typeof t){case"boolean":return+!!t;case"number":return isNaN(t)&&!e?null:t;default:return isNaN(t=parseFloat(`${t??""}`))&&!e?null:t}},setLength:function(t,e,i){return Array.isArray(t)?(t.length=e,t):t[i?"subarray":"slice"](0,e)},splice:function(t,e,i,o,a=[]){if(Array.isArray(t))return Array.isArray(a)||(a=Array.from(a)),{removed:t.splice(e,i,...a),array:t};let n=Object.getPrototypeOf(t).constructor,r=t[o?"subarray":"slice"](e,e+i),s=new n(t.length-i+a.length);return s.set(t.subarray(0,e),0),s.set(a,e),s.set(t.subarray(e+i),e+a.length),{removed:r,array:s}}},G=class{constructor(t={}){this.isDataTable=!0,this.autoId=!t.id,this.columns={},this.id=t.id||(0,a.uniqueKey)(),this.rowCount=0,this.versionTag=(0,a.uniqueKey)();let e=0;(0,a.objectEach)(t.columns||{},(t,i)=>{this.columns[i]=t.slice(),e=Math.max(e,t.length)}),this.applyRowCount(e)}applyRowCount(t){this.rowCount=t,(0,a.objectEach)(this.columns,(e,i)=>{e.length!==t&&(this.columns[i]=b(e,t))})}deleteRows(t,e=1){if(e>0&&t<this.rowCount){let i=0;(0,a.objectEach)(this.columns,(o,a)=>{this.columns[a]=x(o,t,e).array,i=o.length}),this.rowCount=i}(0,a.fireEvent)(this,"afterDeleteRows",{rowIndex:t,rowCount:e}),this.versionTag=(0,a.uniqueKey)()}getColumn(t,e){return this.columns[t]}getColumns(t,e){return(t||Object.keys(this.columns)).reduce((t,e)=>(t[e]=this.columns[e],t),{})}getRowObject(t,e){let i={},o=this.columns;for(let a of(e??(e=Object.keys(this.columns)),e))i[a]=o[a]?.[t];return i}setColumn(t,e=[],i=0,o){this.setColumns({[t]:e},i,o)}setColumns(t,e,i){let o=this.rowCount;(0,a.objectEach)(t,(t,e)=>{this.columns[e]=t.slice(),o=t.length}),this.applyRowCount(o),i?.silent||((0,a.fireEvent)(this,"afterSetColumns"),this.versionTag=(0,a.uniqueKey)())}setRow(t,e=this.rowCount,i,o){var n;let{columns:r}=this,s=i?this.rowCount+1:e+1,l=Object.keys(t);if(o?.addColumns!==!1)for(let t=0,e=l.length;t<e;t++)r[n=l[t]]||(r[n]=Array(this.rowCount));(0,a.objectEach)(r,(o,a)=>{o&&(i?o=x(o,e,0,!0,[t[a]]).array:o[e]=a in t?t[a]:o[e],r[a]=o)}),this.applyRowCount(Math.max(s,this.rowCount)),o?.silent||((0,a.fireEvent)(this,"afterSetRows",{rowIndex:e}),this.versionTag=(0,a.uniqueKey)())}getModified(){return this.modified||this}};!function(t){function e(){return this.chart.time.getTimeTicks.apply(this.chart.time,arguments)}function i(){if("datetime"!==this.type){this.dateTime=void 0;return}this.dateTime||(this.dateTime=new o(this))}t.compose=function(t){return t.keepProps.includes("dateTime")||(t.keepProps.push("dateTime"),t.prototype.getTimeTicks=e,(0,a.addEvent)(t,"afterSetType",i)),t};class o{constructor(t){this.axis=t}normalizeTimeTickInterval(t,e){let i=e||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],o=i[i.length-1],n=a.timeUnits[o[0]],r=o[1],s,l;for(s=0;s<i.length;s++)if(o=i[s],n=a.timeUnits[o[0]],r=o[1],i[s+1]){let e=(n*r[r.length-1]+a.timeUnits[i[s+1][0]])/2;if(t<=e){l=e/t;break}}n===a.timeUnits.year&&t<5*n&&(r=[1,2,5]);let u=(0,a.normalizeTickInterval)(t/n,r,"year"===o[0]?Math.max((0,a.getMagnitude)(t/n),1):1);return{unitRange:n,count:u,unitName:o[0],match:l}}getXDateFormat(t,e){let{axis:i}=this,o=i.chart.time;return i.closestPointRange?o.getDateFormat(i.closestPointRange,t,i.options.startOfWeek,e)||o.resolveDTLFormat(e.year).main:o.resolveDTLFormat(e.day).main}}t.Additions=o}(i||(i={}));let M=i,v=e.default.SeriesRegistry,{series:{prototype:T}}=o.n(v)(),A=T.generatePoints;function C(t){var e,i,o;let n,r,s=this.chart,l=this.options.dataGrouping,u=!1!==this.allowDG&&l&&(0,a.pick)(l.enabled,s.options.isStock),h=this.reserveSpace(),p=this.currentDataGrouping,c,g,m=!1;u&&!this.requireSorting&&(this.requireSorting=m=!0);let f=!1==(e=this,i=t,!(e.isCartesian&&!e.isDirty&&!e.xAxis.isDirty&&!e.yAxis.isDirty&&!i))||!u;if(m&&(this.requireSorting=!1),f)return;this.destroyGroupedData();let y=l.groupAll?this.dataTable:this.dataTable.getModified()||this.dataTable,b=this.getColumn("x",!l.groupAll),x=s.plotSizeX,G=this.xAxis,v=G.getExtremes(),A=G.options.ordinal,C=this.groupPixelWidth;if(C&&b&&y.rowCount&&x&&(0,a.isNumber)(v.min)){r=!0,this.isDirty=!0,this.points=null;let t=v.min,e=v.max,i=A&&G.ordinal&&G.ordinal.getGroupIntervalFactor(t,e,this)||1,u=C*(e-t)/x*i,p=G.getTimeTicks(M.Additions.prototype.normalizeTimeTickInterval(u,l.units||d),Math.min(t,b[0]),Math.max(e,b[b.length-1]),G.options.startOfWeek,b,this.closestPointRange),m=T.groupData.apply(this,[y,p,l.approximation]),f=m.modified,D=f.getColumn("x",!0),w=0;for(l?.smoothed&&f.rowCount&&(l.firstAnchor="firstPoint",l.anchor="middle",l.lastAnchor="lastPoint",(0,a.error)(32,!1,s,{"dataGrouping.smoothed":"use dataGrouping.anchor"})),n=1;n<p.length;n++)p.info.segmentStarts&&-1!==p.info.segmentStarts.indexOf(n)||(w=Math.max(p[n]-p[n-1],w));(c=p.info).gapSize=w,this.closestPointRange=p.info.totalRange,this.groupMap=m.groupMap,this.currentDataGrouping=c,function(t,e,i){let o=t.options.dataGrouping,n=t.currentDataGrouping&&t.currentDataGrouping.gapSize,r=t.getColumn("x");if(!(o&&r.length&&n&&t.groupMap))return;let s=e.length-1,l=o.anchor,u=o.firstAnchor,h=o.lastAnchor,p=e.length-1,d=0;if(u&&r[0]>=e[0]){let i;d++;let o=t.groupMap[0].start,s=t.groupMap[0].length;(0,a.isNumber)(o)&&(0,a.isNumber)(s)&&(i=o+(s-1)),e[0]=({start:e[0],middle:e[0]+.5*n,end:e[0]+n,firstPoint:r[0],lastPoint:i&&r[i]})[u]}if(s>0&&h&&n&&e[s]>=i-n){p--;let i=t.groupMap[t.groupMap.length-1].start;e[s]=({start:e[s],middle:e[s]+.5*n,end:e[s]+n,firstPoint:i&&r[i],lastPoint:r[r.length-1]})[h]}if(l&&"start"!==l){let t=n*({middle:.5,end:1})[l];for(;p>=d;)e[p]+=t,p--}}(this,D||[],e),h&&D&&(o=D,(0,a.defined)(o[0])&&(0,a.isNumber)(G.min)&&(0,a.isNumber)(G.dataMin)&&o[0]<G.min&&((!(0,a.defined)(G.options.min)&&G.min<=G.dataMin||G.min===G.dataMin)&&(G.min=Math.min(o[0],G.min)),G.dataMin=Math.min(o[0],G.dataMin)),(0,a.defined)(o[o.length-1])&&(0,a.isNumber)(G.max)&&(0,a.isNumber)(G.dataMax)&&o[o.length-1]>G.max&&((!(0,a.defined)(G.options.max)&&(0,a.isNumber)(G.dataMax)&&G.max>=G.dataMax||G.max===G.dataMax)&&(G.max=Math.max(o[o.length-1],G.max)),G.dataMax=Math.max(o[o.length-1],G.dataMax))),l.groupAll&&(this.allGroupedTable=f,D=(f=(g=this.cropData(f,G.min||0,G.max||0)).modified).getColumn("x"),this.cropStart=g.start),this.dataTable.modified=f}else this.groupMap=void 0,this.currentDataGrouping=void 0;this.hasGroupedData=r,this.preventGraphAnimation=(p&&p.totalRange)!==(c&&c.totalRange)}function D(){this.groupedData&&(this.groupedData.forEach(function(t,e){t&&(this.groupedData[e]=t.destroy?t.destroy():null)},this),this.groupedData.length=0,delete this.allGroupedTable)}function w(){A.apply(this),this.destroyGroupedData(),this.groupedData=this.hasGroupedData?this.points:null}function N(){return this.is("arearange")?"range":this.is("ohlc")?"ohlc":this.is("hlc")?"hlc":this.is("column")||this.options.cumulative?"sum":"average"}function P(t,e,i){let o=t===this.dataTable?this.getColumn("x"):t.getColumn("x",!0),n=t.getColumn("y",!0),s=this,l=s.dataTable,u=s.cropStart||0,h=s.data,p=s.options?.data,d=[],c=new G,g=[],m=t.rowCount,f=!!n,y=[],b=s.pointArrayMap,x=b&&b.length,M=["x"].concat(b||["y"]),v=(b||["y"]).map(()=>[]),T=this.options.dataGrouping?.groupAll,A,C,D,w=0,N=0,P="function"==typeof i?i:i&&r[i]?r[i]:r[s.getDGApproximation&&s.getDGApproximation()||"average"];if(x){let t=b.length;for(;t--;)y.push([])}else y.push([]);let S=x||1;for(let t=0;t<=m;t++)if(!(o[t]<e[0])){for(;void 0!==e[w+1]&&o[t]>=e[w+1]||t===m;){if(A=e[w],s.dataGroupInfo={start:T?N:s.cropStart+N,length:y[0].length,groupStart:A},D=P.apply(s,y),s.pointClass&&!(0,a.defined)(s.dataGroupInfo.options)&&p&&(s.dataGroupInfo.options=(0,a.merge)(s.pointClass.prototype.optionsToObject.call({series:s},l.getRowObject(u+N))),M.forEach(function(t){delete s.dataGroupInfo.options[t]})),void 0!==D){d.push(A);let t=(0,a.splat)(D);for(let e=0;e<t.length;e++)v[e].push(t[e]);g.push(s.dataGroupInfo)}N=t;for(let t=0;t<S;t++)y[t].length=0,y[t].hasNulls=!1;if(w+=1,t===m)break}if(t===m)break;if(b){let e,i=T?t:s.cropStart+t,o=h&&h[i]||s.pointClass.prototype.applyOptions.apply({series:s},[l.getRowObject(i)]);for(let t=0;t<x;t++)e=o[b[t]],(0,a.isNumber)(e)?y[t].push(e):null===e&&(y[t].hasNulls=!0)}else C=f?n[t]:null,(0,a.isNumber)(C)?y[0].push(C):null===C&&(y[0].hasNulls=!0)}let k={x:d};return(b||["y"]).forEach((t,e)=>{k[t]=v[e]}),c.setColumns(k),{groupMap:g,modified:c}}function S(t){let e=t.options,i=this.type,o=this.chart.options.plotOptions,r=this.useCommonDataGrouping&&h,s=n().defaultOptions.plotOptions[i].dataGrouping;if(o&&(p[i]||r)){let t=this.chart.rangeSelector;s||(s=(0,a.merge)(h,p[i])),e.dataGrouping=(0,a.merge)(r,s,o.series&&o.series.dataGrouping,o[i].dataGrouping,this.userOptions.dataGrouping,!e.isInternal&&t&&(0,a.isNumber)(t.selected)&&t.buttonOptions[t.selected].dataGrouping)}}let k=function(t){let e=t.prototype;if(!e.applyGrouping){let i=t.prototype.pointClass;(0,a.addEvent)(i,"update",function(){if(this.dataGroup)return(0,a.error)(24,!1,this.series.chart),!1}),(0,a.addEvent)(t,"afterSetOptions",S),(0,a.addEvent)(t,"destroy",D),(0,a.extend)(e,{applyGrouping:C,destroyGroupedData:D,generatePoints:w,getDGApproximation:N,groupData:P})}},E=e.default.Templating,{format:O}=o.n(E)(),{composed:R}=n();function F(t){let e=this.chart,i=e.time,o=t.point,n=o.series,r=n.options,s=n.tooltipOptions,l=r.dataGrouping,u=n.xAxis,p=s.xDateFormat||"",d,c,g,m,f,y=s[t.isFooter?"footerFormat":"headerFormat"];if(u&&"datetime"===u.options.type&&l&&(0,a.isNumber)(o.key)){c=n.currentDataGrouping,g=l.dateTimeLabelFormats||h.dateTimeLabelFormats,c?(m=g[c.unitName],1===c.count?p=m[0]:(p=m[1],d=m[2])):!p&&g&&u.dateTime&&(p=u.dateTime.getXDateFormat(o.x,s.dateTimeLabelFormats));let r=(0,a.pick)(n.groupMap?.[o.index].groupStart,o.key),b=r+(c?.totalRange||0)-1;f=i.dateFormat(p,r),d&&(f+=i.dateFormat(d,b)),n.chart.styledMode&&(y=this.styledModeFormat(y)),t.text=O(y,{point:(0,a.extend)(o,{key:f}),series:n},e),t.preventDefault()}}let W=n();W.dataGrouping=W.dataGrouping||{},W.dataGrouping.approximationDefaults=W.dataGrouping.approximationDefaults||u,W.dataGrouping.approximations=W.dataGrouping.approximations||r,({compose:function(t,e,i){y(t),k(e),i&&(0,a.pushUnique)(R,"DataGrouping")&&(0,a.addEvent)(i,"headerFormatter",F)},groupData:P}).compose(W.Axis,W.Series,W.Tooltip);let j=n();export{j as default};