text: "use strict";function simpleheat(t){if(!(this instanceof simpleheat))return new simpleheat(t);this._canvas=t="string"==typeof t?document.getElementById(t):t,this._ctx=t.getContext("2d"),this._width=t.width,this._height=t.height,this._max=1,this._data=[]}"undefined"!=typeof module&&(module.exports=simpleheat),simpleheat.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,i){i=void 0===i?15:i;var a=this._circle=this._createCanvas(),e=a.getContext("2d"),s=this._r=t+i;return a.width=a.height=2*s,e.shadowOffsetX=e.shadowOffsetY=2*s,e.shadowBlur=i,e.shadowColor="black",e.beginPath(),e.arc(-s,-s,t,0,2*Math.PI,!0),e.closePath(),e.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(t){var i,a=this._createCanvas(),e=a.getContext("2d"),s=e.createLinearGradient(0,0,0,256);for(i in a.width=1,a.height=256,t)s.addColorStop(+i,t[i]);return e.fillStyle=s,e.fillRect(0,0,1,256),this._grad=e.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var i=this._ctx;i.clearRect(0,0,this._width,this._height);for(var a,e=0,s=this._data.length;e<s;e++)a=this._data[e],i.globalAlpha=Math.max(a[2]/this._max,void 0===t?.05:t),i.drawImage(this._circle,a[0]-this._r,a[1]-this._r);var n=i.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),i.putImageData(n,0,0),this},_colorize:function(t,i){for(var a,e=0,s=t.length;e<s;e+=4)(a=4*t[e+3])&&(t[e]=i[a],t[e+1]=i[1+a],t[e+2]=i[2+a])},_createCanvas:function(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}},L.HeatLayer=(L.Layer||L.Class).extend({initialize:function(t,i){class a extends RBush{toBBox([t,i]){return{minX:i,minY:t,maxX:i,maxY:t}}compareMinX(t,i){return t.x-i.x}compareMinY(t,i){return t.y-i.y}}this._tree=new a,this._tree.load(t),L.setOptions(this,i)},setLatLngs:function(t){return this._tree.clear(),this._tree.load(t),this.redraw()},addLatLng:function(t){return this._tree.insert(t),this.redraw()},setOptions:function(t){return L.setOptions(this,t),this._heat&&this._updateOptions(),this.redraw()},redraw:function(){return this._heat&&!this._frame&&this._map&&!this._map._animating&&(this._frame=L.Util.requestAnimFrame(this._redraw,this)),this},onAdd:function(t){this._map=t,this._canvas||this._initCanvas(),(this.options.pane?this.getPane():t._panes.overlayPane).appendChild(this._canvas),t.on("moveend",this._reset,this),t.options.zoomAnimation&&L.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){(this.options.pane?this.getPane():t.getPanes().overlayPane).removeChild(this._canvas),t.off("moveend",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},_initCanvas:function(){var t=this._canvas=L.DomUtil.create("canvas","leaflet-heatmap-layer leaflet-layer"),i=L.DomUtil.testProp(["transformOrigin","WebkitTransformOrigin","msTransformOrigin"]);t.style[i]="50% 50%";i=this._map.getSize();t.width=i.x,t.height=i.y;i=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(t,"leaflet-zoom-"+(i?"animated":"hide")),this._heat=simpleheat(t),this._updateOptions()},_updateOptions:function(){this._heat.radius(this.options.radius||this._heat.defaultRadius,this.options.blur),this.options.gradient&&this._heat.gradient(this.options.gradient),this.options.max&&this._heat.max(this.options.max)},_reset:function(){var t=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,t);t=this._map.getSize();this._heat._width!==t.x&&(this._canvas.width=this._heat._width=t.x),this._heat._height!==t.y&&(this._canvas.height=this._heat._height=t.y),this._redraw()},_redraw:function(){if(this._map){for(var t,i,a,e=[],s=this._heat._r,n=this._map.getBounds(),h=void 0===this.options.max?1:this.options.max,o=void 0===this.options.maxZoom?this._map.getMaxZoom():this.options.maxZoom,r=1/Math.pow(2,Math.max(0,Math.min(o-this._map.getZoom(),12))),_=s/2,d=[],s=this._map._getMapPanePos(),m=s.x%_,l=s.y%_,u=this._tree.search({minX:n._southWest.lng,minY:n._southWest.lat,maxX:n._northEast.lng,maxY:n._northEast.lat}),c=0,p=u.length;c<p;c++){var f=this._map.latLngToContainerPoint(u[c]),g=Math.floor((f.x-m)/_)+2,v=Math.floor((f.y-l)/_)+2,x=(void 0!==u[c].alt?u[c].alt:void 0!==u[c][2]?+u[c][2]:1)*r;d[v]=d[v]||[],(t=d[v][g])?(t[0]=(t[0]*t[2]+f.x*x)/(t[2]+x),t[1]=(t[1]*t[2]+f.y*x)/(t[2]+x),t[2]+=x):d[v][g]=[f.x,f.y,x]}for(c=0,p=d.length;c<p;c++)if(d[c])for(i=0,a=d[c].length;i<a;i++)(t=d[c][i])&&e.push([Math.round(t[0]),Math.round(t[1]),Math.min(t[2],h)]);this._heat.data(e).draw(this.options.minOpacity),this._frame=null}},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),t=this._map._getCenterOffset(t.center)._multiplyBy(-i).subtract(this._map._getMapPanePos());L.DomUtil.setTransform?L.DomUtil.setTransform(this._canvas,t,i):this._canvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(t)+" scale("+i+")"}}),L.heatLayer=function(t,i){return new L.HeatLayer(t,i)};