/**
 * Highmaps JS v12.5.0 (2026-01-12)
 * @module highcharts/modules/heatmap
 * @requires highcharts
 *
 * (c) 2009-2026 Highsoft AS
 * Author: Torstein Honsi
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as t from"../highcharts.js";import"./coloraxis.js";var e,r={};r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var a=r.n(i);let s=t.default.Color;var o=r.n(s);let l=t.default.SeriesRegistry;var n=r.n(l);let h=t.default.SVGElement;var p=r.n(h);let{column:{prototype:d}}=n().seriesTypes,{addEvent:u,defined:c}=a();var m=e||(e={});function y(t){let e=this.series,r=e.chart.renderer;this.moveToTopOnHover&&this.graphic&&(e.stateMarkerGraphic||(e.stateMarkerGraphic=new(p())(r,"use").css({pointerEvents:"none"}).add(this.graphic.parentGroup)),t?.state==="hover"?(this.graphic.attr({id:this.id}),e.stateMarkerGraphic.attr({href:`${r.url}#${this.id}`,visibility:"visible"})):e.stateMarkerGraphic.attr({href:""}))}m.pointMembers={dataLabelOnNull:!0,moveToTopOnHover:!0,isValid:function(){return null!==this.value&&this.value!==1/0&&this.value!==-1/0&&(void 0===this.value||!isNaN(this.value))}},m.seriesMembers={colorKey:"value",axisTypes:["xAxis","yAxis","colorAxis"],parallelArrays:["x","y","value"],pointArrayMap:["value"],trackerGroups:["group","markerGroup","dataLabelsGroup"],colorAttribs:function(t){let e={};return c(t.color)&&(!t.state||"normal"===t.state)&&(e[this.colorProp||"fill"]=t.color),e},pointAttribs:d.pointAttribs},m.compose=function(t){return u(t.prototype.pointClass,"afterSetState",y),t};let g=e,{scatter:{prototype:{pointClass:b}}}=n().seriesTypes,{clamp:v,defined:x,extend:f,pick:M}=a();class k extends b{applyOptions(t,e){return(this.isNull||null===this.value)&&delete this.color,super.applyOptions(t,e),this.formatPrefix=this.isNull||null===this.value?"null":"point",this}getCellAttributes(){let t=this.series,e=t.options,r=(e.colsize||1)/2,i=(e.rowsize||1)/2,a=t.xAxis,s=t.yAxis,o=this.options.marker||t.options.marker,l=t.pointPlacementToXValue(),n=M(this.pointPadding,e.pointPadding,0),h={x1:v(Math.round(a.len-a.translate(this.x-r,!1,!0,!1,!0,-l)),-a.len,2*a.len),x2:v(Math.round(a.len-a.translate(this.x+r,!1,!0,!1,!0,-l)),-a.len,2*a.len),y1:v(Math.round(s.translate(this.y-i,!1,!0,!1,!0)),-s.len,2*s.len),y2:v(Math.round(s.translate(this.y+i,!1,!0,!1,!0)),-s.len,2*s.len)};for(let t of[["width","x"],["height","y"]]){let e=t[0],r=t[1],i=r+"1",l=r+"2",p=Math.abs(h[i]-h[l]),d=o&&o.lineWidth||0,u=Math.abs(h[i]+h[l])/2,c=o&&o[e];if(x(c)&&c<p){let t=c/2+d/2;h[i]=u-t,h[l]=u+t}n&&(("x"===r&&a.reversed||"y"===r&&!s.reversed)&&(i=l,l=r+"1"),h[i]+=n,h[l]-=n)}return h}haloPath(t){if(!t)return[];let{x:e=0,y:r=0,width:i=0,height:a=0}=this.shapeArgs||{};return[["M",e-t,r-t],["L",e-t,r+a+t],["L",e+i+t,r+a+t],["L",e+i+t,r-t],["Z"]]}isValid(){return this.value!==1/0&&this.value!==-1/0}}f(k.prototype,{dataLabelOnNull:!0,moveToTopOnHover:!0,ttBelow:!1});let{isNumber:A}=a(),C=t.default.SVGRenderer;var w=r.n(C);let{doc:P}=a(),{defined:T,pick:D}=a(),{series:O,seriesTypes:{column:G,scatter:R}}=n(),{prototype:{symbols:L}}=w(),{addEvent:E,extend:N,fireEvent:S,isNumber:V,merge:W,pick:F}=a(),{colorFromPoint:I,getContext:j}={colorFromPoint:function(t,e){let r=e.series.colorAxis;if(r){let i=r.toColor(t||0,e).split(")")[0].split("(")[1].split(",").map(t=>D(parseFloat(t),parseInt(t,10)));return i[3]=255*D(i[3],1),T(t)&&e.visible||(i[3]=0),i}return[0,0,0,0]},getContext:function(t){let{canvas:e,context:r}=t;return e&&r?(r.clearRect(0,0,e.width,e.height),r):(t.canvas=P.createElement("canvas"),t.context=t.canvas.getContext("2d",{willReadFrequently:!0})||void 0,t.context)}};class z extends R{constructor(){super(...arguments),this.valueMax=NaN,this.valueMin=NaN,this.isDirtyCanvas=!0}drawPoints(){let t=this,e=t.options,r=e.interpolation,i=e.marker||{};if(r){let{image:e,chart:r,xAxis:i,yAxis:a}=t,{reversed:s=!1,len:o}=i,{reversed:l=!1,len:n}=a,h={width:o,height:n};if(!e||t.isDirtyData||t.isDirtyCanvas){let o=j(t),{canvas:n,options:{colsize:p=1,rowsize:d=1},points:u,points:{length:c}}=t,m=r.colorAxis&&r.colorAxis[0];if(n&&o&&m){let{min:m,max:y}=i.getExtremes(),{min:g,max:b}=a.getExtremes(),v=y-m,x=b-g,f=Math.round(v/p/8*8),M=Math.round(x/d/8*8),[k,A]=[[f,f/v,s,"ceil"],[M,M/x,!l,"floor"]].map(([t,e,r,i])=>r?r=>Math[i](t-e*r):t=>Math[i](e*t)),C=n.width=f+1,w=C*(n.height=M+1),P=(c-1)/w,T=new Uint8ClampedArray(4*w),D=(t,e)=>4*Math.ceil(C*A(e-g)+k(t-m));t.buildKDTree();for(let t=0;t<w;t++){let e=u[Math.ceil(P*t)],{x:r,y:i}=e;T.set(I(e.value,e),D(r,i))}o.putImageData(new ImageData(T,C),0,0),e?e.attr({...h,href:n.toDataURL("image/png",1)}):(t.directTouch=!1,t.image=r.renderer.image(n.toDataURL("image/png",1)).attr(h).add(t.group))}t.isDirtyCanvas=!1}else(e.width!==o||e.height!==n)&&e.attr(h)}else(i.enabled||t._hasPointMarkers)&&(O.prototype.drawPoints.call(t),t.points.forEach(e=>{e.graphic&&(e.graphic[t.chart.styledMode?"css":"animate"](t.colorAttribs(e)),null===e.value&&e.graphic.addClass("highcharts-null-point"))}))}getExtremes(){let{dataMin:t,dataMax:e}=O.prototype.getExtremes.call(this,this.getColumn("value"));return V(t)&&(this.valueMin=t),V(e)&&(this.valueMax=e),O.prototype.getExtremes.call(this)}getValidPoints(t,e){return O.prototype.getValidPoints.call(this,t,e,!0)}hasData(){return!!this.dataTable.rowCount}init(){super.init.apply(this,arguments);let t=this.options;t.pointRange=F(t.pointRange,t.colsize||1),this.yAxis.axisPointRange=t.rowsize||1,L.ellipse=L.circle,t.marker&&V(t.borderRadius)&&(t.marker.r=t.borderRadius)}markerAttribs(t,e){let r=t.shapeArgs||{};if(t.hasImage)return{x:t.plotX,y:t.plotY};if(e&&"normal"!==e){let i=t.options.marker||{},a=this.options.marker||{},s=a.states?.[e]||{},o=i.states?.[e]||{},l=(o.width||s.width||r.width||0)+(o.widthPlus||s.widthPlus||0),n=(o.height||s.height||r.height||0)+(o.heightPlus||s.heightPlus||0);return{x:(r.x||0)+((r.width||0)-l)/2,y:(r.y||0)+((r.height||0)-n)/2,width:l,height:n}}return r}pointAttribs(t,e){let r=O.prototype.pointAttribs.call(this,t,e),i=this.options||{},a=this.chart.options.plotOptions||{},s=a.series||{},l=a.heatmap||{},n=t?.options.borderColor||i.borderColor||l.borderColor||s.borderColor,h=t?.options.borderWidth||i.borderWidth||l.borderWidth||s.borderWidth||r["stroke-width"];if(r.stroke=t?.marker?.lineColor||i.marker?.lineColor||n||this.color,r["stroke-width"]=h,e&&"normal"!==e){let a=W(i.states?.[e],i.marker?.states?.[e],t?.options.marker?.states?.[e]||{});r.fill=a.color||o().parse(r.fill).brighten(a.brightness||0).get(),r.stroke=a.lineColor||r.stroke}return r}translate(){let{borderRadius:t,marker:e}=this.options,r=e?.symbol||"rect",i=L[r]?r:"rect",a=-1!==["circle","square"].indexOf(i);for(let e of(this.generatePoints(),this.points)){let s=e.getCellAttributes(),o=Math.min(s.x1,s.x2),l=Math.min(s.y1,s.y2),n=Math.max(Math.abs(s.x2-s.x1),0),h=Math.max(Math.abs(s.y2-s.y1),0);if(e.hasImage=0===(e.marker?.symbol||r||"").indexOf("url"),a){let t=Math.abs(n-h);o=Math.min(s.x1,s.x2)+(n<h?0:t/2),l=Math.min(s.y1,s.y2)+(n<h?t/2:0),n=h=Math.min(n,h)}e.hasImage&&(e.marker={width:n,height:h}),e.plotX=e.clientX=(s.x1+s.x2)/2,e.plotY=(s.y1+s.y2)/2,e.shapeType="path",e.shapeArgs=W(!0,{x:o,y:l,width:n,height:h},{d:L[i](o,l,n,h,{r:V(t)?t:0})})}S(this,"afterTranslate")}}z.defaultOptions=W(R.defaultOptions,{animation:!1,borderRadius:0,borderWidth:0,interpolation:!1,nullColor:"#f7f7f7",dataLabels:{formatter:function(){let{numberFormatter:t}=this.series.chart,{value:e}=this.point;return A(e)?t(e,-1):""},inside:!0,verticalAlign:"middle",crop:!1,overflow:"allow",padding:0},marker:{symbol:"rect",radius:0,lineColor:void 0,states:{hover:{lineWidthPlus:0},select:{}}},clip:!0,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{hover:{halo:!1,brightness:.2}},legendSymbol:"rectangle"}),E(z,"afterDataClassLegendClick",function(){this.isDirtyCanvas=!0,this.drawPoints(),this.options.enableMouseTracking&&this.drawTracker()}),N(z.prototype,{axisTypes:g.seriesMembers.axisTypes,colorKey:g.seriesMembers.colorKey,directTouch:!0,getExtremesFromAll:!0,keysAffectYAxis:["y"],parallelArrays:g.seriesMembers.parallelArrays,pointArrayMap:["y","value"],pointClass:k,specialGroup:"group",trackerGroups:g.seriesMembers.trackerGroups,alignDataLabel:G.prototype.alignDataLabel,colorAttribs:g.seriesMembers.colorAttribs,getSymbol:O.prototype.getSymbol}),g.compose(z),n().registerSeriesType("heatmap",z);let K=a();export{K as default};