dawarich/vendor/javascript/leaflet-draw.js
Eugene Burmakin 151e5cf042 Add areas
2024-07-21 20:09:42 +02:00

2 lines
71 KiB
JavaScript

var t,e;var i="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof self?self:global;!function(a,n,s){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.4",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"<strong>Error:</strong> shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){(this||i)._map=t,(this||i)._container=t._container,(this||i)._overlayPane=t._panes.overlayPane,(this||i)._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},(this||i).options.shapeOptions,e.shapeOptions)),L.setOptions(this||i,e);var a=L.version.split(".");1===parseInt(a[0],10)&&parseInt(a[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){(this||i)._enabled||(L.Handler.prototype.enable.call(this||i),this.fire("enabled",{handler:(this||i).type}),(this||i)._map.fire(L.Draw.Event.DRAWSTART,{layerType:(this||i).type}))},disable:function(){(this||i)._enabled&&(L.Handler.prototype.disable.call(this||i),(this||i)._map.fire(L.Draw.Event.DRAWSTOP,{layerType:(this||i).type}),this.fire("disabled",{handler:(this||i).type}))},addHooks:function(){var t=(this||i)._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),(this||i)._tooltip=new L.Draw.Tooltip((this||i)._map),L.DomEvent.on((this||i)._container,"keyup",(this||i)._cancelDrawing,this||i))},removeHooks:function(){(this||i)._map&&(L.DomUtil.enableTextSelection(),(this||i)._tooltip.dispose(),(this||i)._tooltip=null,L.DomEvent.off((this||i)._container,"keyup",(this||i)._cancelDrawing,this||i))},setOptions:function(t){L.setOptions(this||i,t)},_fireCreatedEvent:function(t){(this||i)._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:(this||i).type})},_cancelDrawing:function(t){27===t.keyCode&&((this||i)._map.fire("draw:canceled",{layerType:(this||i).type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&((this||i).options.icon=(this||i).options.touchIcon),(this||i).options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},(this||i).options.drawError,e.drawError)),(this||i).type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this||i,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this||i),(this||i)._map&&((this||i)._markers=[],(this||i)._markerGroup=new L.LayerGroup,(this||i)._map.addLayer((this||i)._markerGroup),(this||i)._poly=new L.Polyline([],(this||i).options.shapeOptions),(this||i)._tooltip.updateContent(this._getTooltipText()),(this||i)._mouseMarker||((this||i)._mouseMarker=L.marker((this||i)._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:(this||i).options.zIndexOffset})),(this||i)._mouseMarker.on("mouseout",(this||i)._onMouseOut,this||i).on("mousemove",(this||i)._onMouseMove,this||i).on("mousedown",(this||i)._onMouseDown,this||i).on("mouseup",(this||i)._onMouseUp,this||i).addTo((this||i)._map),(this||i)._map.on("mouseup",(this||i)._onMouseUp,this||i).on("mousemove",(this||i)._onMouseMove,this||i).on("zoomlevelschange",(this||i)._onZoomEnd,this||i).on("touchstart",(this||i)._onTouch,this||i).on("zoomend",(this||i)._onZoomEnd,this||i))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this||i),this._clearHideErrorTimeout(),this._cleanUpShape(),(this||i)._map.removeLayer((this||i)._markerGroup),delete(this||i)._markerGroup,delete(this||i)._markers,(this||i)._map.removeLayer((this||i)._poly),delete(this||i)._poly,(this||i)._mouseMarker.off("mousedown",(this||i)._onMouseDown,this||i).off("mouseout",(this||i)._onMouseOut,this||i).off("mouseup",(this||i)._onMouseUp,this||i).off("mousemove",(this||i)._onMouseMove,this||i),(this||i)._map.removeLayer((this||i)._mouseMarker),delete(this||i)._mouseMarker,this._clearGuides(),(this||i)._map.off("mouseup",(this||i)._onMouseUp,this||i).off("mousemove",(this||i)._onMouseMove,this||i).off("zoomlevelschange",(this||i)._onZoomEnd,this||i).off("zoomend",(this||i)._onZoomEnd,this||i).off("touchstart",(this||i)._onTouch,this||i).off("click",(this||i)._onTouch,this||i)},deleteLastVertex:function(){if(!((this||i)._markers.length<=1)){var t=(this||i)._markers.pop(),e=(this||i)._poly,a=e.getLatLngs(),n=a.splice(-1,1)[0];(this||i)._poly.setLatLngs(a),(this||i)._markerGroup.removeLayer(t),e.getLatLngs().length<2&&(this||i)._map.removeLayer(e),this._vertexChanged(n,!1)}},addVertex:function(t){(this||i)._markers.length>=2&&!(this||i).options.allowIntersection&&(this||i)._poly.newLatLngIntersects(t)?this._showErrorTooltip():((this||i)._errorShown&&this._hideErrorTooltip(),(this||i)._markers.push(this._createMarker(t)),(this||i)._poly.addLatLng(t),2===(this||i)._poly.getLatLngs().length&&(this||i)._map.addLayer((this||i)._poly),this._vertexChanged(t,!0))},completeShape:function(){(this||i)._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),(this||i).options.repeatMode&&this.enable())},_finishShape:function(){var t=(this||i)._poly._defaultShape?(this||i)._poly._defaultShape():(this||i)._poly.getLatLngs(),e=(this||i)._poly.newLatLngIntersects(t[t.length-1]);!(this||i).options.allowIntersection&&e||!this._shapeIsValid()?this._showErrorTooltip():(this._fireCreatedEvent(),this.disable(),(this||i).options.repeatMode&&this.enable())},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==(this||i)._markers&&this._updateGuide()},_onMouseMove:function(t){var e=(this||i)._map.mouseEventToLayerPoint(t.originalEvent),a=(this||i)._map.layerPointToLatLng(e);(this||i)._currentLatLng=a,this._updateTooltip(a),this._updateGuide(e),(this||i)._mouseMarker.setLatLng(a),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){(this||i)._map.fire(L.Draw.Event.DRAWVERTEX,{layers:(this||i)._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!(this||i)._clickHandled&&!(this||i)._touchHandled&&!(this||i)._disableMarkers){this._onMouseMove(t),(this||i)._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,a=e.clientX,n=e.clientY;(this||i)._startPoint.call(this||i,a,n)}},_startPoint:function(t,e){(this||i)._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,a=e.clientX,n=e.clientY;(this||i)._endPoint.call(this||i,a,n,t),(this||i)._clickHandled=null},_endPoint:function(t,e,n){if((this||i)._mouseDownOrigin){var s=L.point(t,e).distanceTo((this||i)._mouseDownOrigin),r=this._calculateFinishDistance(n.latlng);(this||i).options.maxPoints>1&&(this||i).options.maxPoints==(this||i)._markers.length+1?(this.addVertex(n.latlng),this._finishShape()):r<10&&L.Browser.touch?this._finishShape():Math.abs(s)<9*(a.devicePixelRatio||1)&&this.addVertex(n.latlng),this._enableNewMarkers()}(this||i)._mouseDownOrigin=null},_onTouch:function(t){var e,a,n=t.originalEvent;!n.touches||!n.touches[0]||(this||i)._clickHandled||(this||i)._touchHandled||(this||i)._disableMarkers||(e=n.touches[0].clientX,a=n.touches[0].clientY,this._disableNewMarkers(),(this||i)._touchHandled=!0,(this||i)._startPoint.call(this||i,e,a),(this||i)._endPoint.call(this||i,e,a,t),(this||i)._touchHandled=null),(this||i)._clickHandled=null},_onMouseOut:function(){(this||i)._tooltip&&(this||i)._tooltip._onMouseOut.call((this||i)._tooltip)},_calculateFinishDistance:function(t){var e;if((this||i)._markers.length>0){var a;if((this||i).type===L.Draw.Polyline.TYPE)a=(this||i)._markers[(this||i)._markers.length-1];else{if((this||i).type!==L.Draw.Polygon.TYPE)return 1/0;a=(this||i)._markers[0]}var n=(this||i)._map.latLngToContainerPoint(a.getLatLng()),s=new L.Marker(t,{icon:(this||i).options.icon,zIndexOffset:2*(this||i).options.zIndexOffset}),r=(this||i)._map.latLngToContainerPoint(s.getLatLng());e=n.distanceTo(r)}else e=1/0;return e},_updateFinishHandler:function(){var t=(this||i)._markers.length;t>1&&(this||i)._markers[t-1].on("click",(this||i)._finishShape,this||i),t>2&&(this||i)._markers[t-2].off("click",(this||i)._finishShape,this||i)},_createMarker:function(t){var e=new L.Marker(t,{icon:(this||i).options.icon,zIndexOffset:2*(this||i).options.zIndexOffset});return(this||i)._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=(this||i)._markers?(this||i)._markers.length:0;e>0&&(t=t||(this||i)._map.latLngToLayerPoint((this||i)._currentLatLng),this._clearGuides(),this._drawGuide((this||i)._map.latLngToLayerPoint((this||i)._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&(this||i)._tooltip.updatePosition(t),(this||i)._errorShown||(this||i)._tooltip.updateContent(e)},_drawGuide:function(t,e){var a,n,s,r=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),l=(this||i).options.guidelineDistance,h=(this||i).options.maxGuideLineLength,d=r>h?r-h:l;for((this||i)._guidesContainer||((this||i)._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",(this||i)._overlayPane));d<r;d+=(this||i).options.guidelineDistance)a=d/r,n={x:Math.floor(t.x*(1-a)+a*e.x),y:Math.floor(t.y*(1-a)+a*e.y)},s=L.DomUtil.create("div","leaflet-draw-guide-dash",(this||i)._guidesContainer),s.style.backgroundColor=(this||i)._errorShown?(this||i).options.drawError.color:(this||i).options.shapeOptions.color,L.DomUtil.setPosition(s,n)},_updateGuideColor:function(t){if((this||i)._guidesContainer)for(var e=0,a=(this||i)._guidesContainer.childNodes.length;e<a;e++)(this||i)._guidesContainer.childNodes[e].style.backgroundColor=t},_clearGuides:function(){if((this||i)._guidesContainer)for(;(this||i)._guidesContainer.firstChild;)(this||i)._guidesContainer.removeChild((this||i)._guidesContainer.firstChild)},_getTooltipText:function(){var t,e,a=(this||i).options.showLength;return 0===(this||i)._markers.length?t={text:L.drawLocal.draw.handlers.polyline.tooltip.start}:(e=a?this._getMeasurementString():"",t=1===(this||i)._markers.length?{text:L.drawLocal.draw.handlers.polyline.tooltip.cont,subtext:e}:{text:L.drawLocal.draw.handlers.polyline.tooltip.end,subtext:e}),t},_updateRunningMeasure:function(t,e){var a,n,s=(this||i)._markers.length;1===(this||i)._markers.length?(this||i)._measurementRunningTotal=0:(a=s-(e?2:1),n=L.GeometryUtil.isVersion07x()?t.distanceTo((this||i)._markers[a].getLatLng())*((this||i).options.factor||1):(this||i)._map.distance(t,(this||i)._markers[a].getLatLng())*((this||i).options.factor||1),(this||i)._measurementRunningTotal+=n*(e?1:-1))},_getMeasurementString:function(){var t,e=(this||i)._currentLatLng,a=(this||i)._markers[(this||i)._markers.length-1].getLatLng();return t=L.GeometryUtil.isVersion07x()?a&&e&&e.distanceTo?(this||i)._measurementRunningTotal+e.distanceTo(a)*((this||i).options.factor||1):(this||i)._measurementRunningTotal||0:a&&e?(this||i)._measurementRunningTotal+(this||i)._map.distance(e,a)*((this||i).options.factor||1):(this||i)._measurementRunningTotal||0,L.GeometryUtil.readableDistance(t,(this||i).options.metric,(this||i).options.feet,(this||i).options.nautic,(this||i).options.precision)},_showErrorTooltip:function(){(this||i)._errorShown=!0,(this||i)._tooltip.showAsError().updateContent({text:(this||i).options.drawError.message}),this._updateGuideColor((this||i).options.drawError.color),(this||i)._poly.setStyle({color:(this||i).options.drawError.color}),this._clearHideErrorTimeout(),(this||i)._hideErrorTimeout=setTimeout(L.Util.bind((this||i)._hideErrorTooltip,this||i),(this||i).options.drawError.timeout)},_hideErrorTooltip:function(){(this||i)._errorShown=!1,this._clearHideErrorTimeout(),(this||i)._tooltip.removeError().updateContent(this._getTooltipText()),this._updateGuideColor((this||i).options.shapeOptions.color),(this||i)._poly.setStyle({color:(this||i).options.shapeOptions.color})},_clearHideErrorTimeout:function(){(this||i)._hideErrorTimeout&&(clearTimeout((this||i)._hideErrorTimeout),(this||i)._hideErrorTimeout=null)},_disableNewMarkers:function(){(this||i)._disableMarkers=!0},_enableNewMarkers:function(){setTimeout(function(){(this||i)._disableMarkers=!1}.bind(this||i),50)},_cleanUpShape:function(){(this||i)._markers.length>1&&(this||i)._markers[(this||i)._markers.length-1].off("click",(this||i)._finishShape,this||i)},_fireCreatedEvent:function(){var t=new(this||i).Poly((this||i)._poly.getLatLngs(),(this||i).options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this||i,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this||i,t,e),(this||i).type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=(this||i)._markers.length;1===t&&(this||i)._markers[0].on("click",(this||i)._finishShape,this||i),t>2&&((this||i)._markers[t-1].on("dblclick",(this||i)._finishShape,this||i),t>3&&(this||i)._markers[t-2].off("dblclick",(this||i)._finishShape,this||i))},_getTooltipText:function(){var t,e;return 0===(this||i)._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:(this||i)._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=(this||i)._area,e="";return t||(this||i).options.showLength?((this||i).options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this||i)),t&&(e+="<br>"+L.GeometryUtil.readableArea(t,(this||i).options.metric,(this||i).options.precision)),e):null},_shapeIsValid:function(){return(this||i)._markers.length>=3},_vertexChanged:function(t,e){var a;!(this||i).options.allowIntersection&&(this||i).options.showArea&&(a=(this||i)._poly.getLatLngs(),(this||i)._area=L.GeometryUtil.geodesicArea(a)),L.Draw.Polyline.prototype._vertexChanged.call(this||i,t,e)},_cleanUpShape:function(){var t=(this||i)._markers.length;t>0&&((this||i)._markers[0].off("click",(this||i)._finishShape,this||i),t>2&&(this||i)._markers[t-1].off("dblclick",(this||i)._finishShape,this||i))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){(this||i)._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this||i,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this||i),(this||i)._map&&((this||i)._mapDraggable=(this||i)._map.dragging.enabled(),(this||i)._mapDraggable&&(this||i)._map.dragging.disable(),(this||i)._container.style.cursor="crosshair",(this||i)._tooltip.updateContent({text:(this||i)._initialLabelText}),(this||i)._map.on("mousedown",(this||i)._onMouseDown,this||i).on("mousemove",(this||i)._onMouseMove,this||i).on("touchstart",(this||i)._onMouseDown,this||i).on("touchmove",(this||i)._onMouseMove,this||i),n.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this||i),(this||i)._map&&((this||i)._mapDraggable&&(this||i)._map.dragging.enable(),(this||i)._container.style.cursor="",(this||i)._map.off("mousedown",(this||i)._onMouseDown,this||i).off("mousemove",(this||i)._onMouseMove,this||i).off("touchstart",(this||i)._onMouseDown,this||i).off("touchmove",(this||i)._onMouseMove,this||i),L.DomEvent.off(n,"mouseup",(this||i)._onMouseUp,this||i),L.DomEvent.off(n,"touchend",(this||i)._onMouseUp,this||i),n.removeEventListener("touchstart",L.DomEvent.preventDefault),(this||i)._shape&&((this||i)._map.removeLayer((this||i)._shape),delete(this||i)._shape)),(this||i)._isDrawing=!1},_getTooltipText:function(){return{text:(this||i)._endLabelText}},_onMouseDown:function(t){(this||i)._isDrawing=!0,(this||i)._startLatLng=t.latlng,L.DomEvent.on(n,"mouseup",(this||i)._onMouseUp,this||i).on(n,"touchend",(this||i)._onMouseUp,this||i).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;(this||i)._tooltip.updatePosition(e),(this||i)._isDrawing&&((this||i)._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){(this||i)._shape&&this._fireCreatedEvent(),this.disable(),(this||i).options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){(this||i).type=L.Draw.Rectangle.TYPE,(this||i)._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this||i,t,e)},disable:function(){(this||i)._enabled&&((this||i)._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this||i))},_onMouseUp:function(t){(this||i)._shape||(this||i)._isCurrentlyTwoClickDrawing?(this||i)._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this||i):(this||i)._isCurrentlyTwoClickDrawing=!0},_drawShape:function(t){(this||i)._shape?(this||i)._shape.setBounds(new L.LatLngBounds((this||i)._startLatLng,t)):((this||i)._shape=new L.Rectangle(new L.LatLngBounds((this||i)._startLatLng,t),(this||i).options.shapeOptions),(this||i)._map.addLayer((this||i)._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle((this||i)._shape.getBounds(),(this||i).options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this||i,t)},_getTooltipText:function(){var t,e,a,n=L.Draw.SimpleShape.prototype._getTooltipText.call(this||i),s=(this||i)._shape,r=(this||i).options.showArea;return s&&(t=(this||i)._shape._defaultShape?(this||i)._shape._defaultShape():(this||i)._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),a=r?L.GeometryUtil.readableArea(e,(this||i).options.metric):""),{text:n.text,subtext:a}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){(this||i).type=L.Draw.Marker.TYPE,(this||i)._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this||i,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this||i),(this||i)._map&&((this||i)._tooltip.updateContent({text:(this||i)._initialLabelText}),(this||i)._mouseMarker||((this||i)._mouseMarker=L.marker((this||i)._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:(this||i).options.zIndexOffset})),(this||i)._mouseMarker.on("click",(this||i)._onClick,this||i).addTo((this||i)._map),(this||i)._map.on("mousemove",(this||i)._onMouseMove,this||i),(this||i)._map.on("click",(this||i)._onTouch,this||i))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this||i),(this||i)._map&&((this||i)._map.off("click",(this||i)._onClick,this||i).off("click",(this||i)._onTouch,this||i),(this||i)._marker&&((this||i)._marker.off("click",(this||i)._onClick,this||i),(this||i)._map.removeLayer((this||i)._marker),delete(this||i)._marker),(this||i)._mouseMarker.off("click",(this||i)._onClick,this||i),(this||i)._map.removeLayer((this||i)._mouseMarker),delete(this||i)._mouseMarker,(this||i)._map.off("mousemove",(this||i)._onMouseMove,this||i))},_onMouseMove:function(t){var e=t.latlng;(this||i)._tooltip.updatePosition(e),(this||i)._mouseMarker.setLatLng(e),(this||i)._marker?(e=(this||i)._mouseMarker.getLatLng(),(this||i)._marker.setLatLng(e)):((this||i)._marker=this._createMarker(e),(this||i)._marker.on("click",(this||i)._onClick,this||i),(this||i)._map.on("click",(this||i)._onClick,this||i).addLayer((this||i)._marker))},_createMarker:function(t){return new L.Marker(t,{icon:(this||i).options.icon,zIndexOffset:(this||i).options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),(this||i).options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch((this||i)._marker.getLatLng(),{icon:(this||i).options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this||i,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){(this||i).type=L.Draw.CircleMarker.TYPE,(this||i)._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this||i,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker((this||i)._marker.getLatLng(),(this||i).options);L.Draw.Feature.prototype._fireCreatedEvent.call(this||i,t)},_createMarker:function(t){return new L.CircleMarker(t,(this||i).options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){(this||i).type=L.Draw.Circle.TYPE,(this||i)._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this||i,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=(this||i)._startLatLng.distanceTo(t);else var e=(this||i)._map.distance((this||i)._startLatLng,t);(this||i)._shape?(this||i)._shape.setRadius(e):((this||i)._shape=new L.Circle((this||i)._startLatLng,e,(this||i).options.shapeOptions),(this||i)._map.addLayer((this||i)._shape))},_fireCreatedEvent:function(){var t=new L.Circle((this||i)._startLatLng,(this||i)._shape.getRadius(),(this||i).options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this||i,t)},_onMouseMove:function(t){var e,a=t.latlng,n=(this||i).options.showRadius,s=(this||i).options.metric;if((this||i)._tooltip.updatePosition(a),(this||i)._isDrawing){this._drawShape(a),e=(this||i)._shape.getRadius().toFixed(1);var r="";n&&(r=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,s,(this||i).options.feet,(this||i).options.nautic)),(this||i)._tooltip.updateContent({text:(this||i)._endLabelText,subtext:r})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){(this||i)._marker=t,L.setOptions(this||i,e)},addHooks:function(){var t=(this||i)._marker;t.dragging.enable(),t.on("dragend",(this||i)._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=(this||i)._marker;t.dragging.disable(),t.off("dragend",(this||i)._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,(this||i)._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=(this||i)._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,a=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=a+"px"}}),L.Marker.addInitHook((function(){L.Edit.Marker&&((this||i).editing=new L.Edit.Marker(this||i),(this||i).options.editable&&(this||i).editing.enable())})),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){(this||i).latlngs=[t._latlngs],t._holes&&((this||i).latlngs=(this||i).latlngs.concat(t._holes)),(this||i)._poly=t,(this||i)._poly.on("revert-edited",(this||i)._updateLatLngs,this||i)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat((this||i)._poly._latlngs)?(this||i)._poly._latlngs:(this||i)._poly._latlngs[0]:(this||i)._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;e<(this||i)._verticesHandlers.length;e++)t((this||i)._verticesHandlers[e])},addHooks:function(){this._initHandlers(),this._eachVertexHandler((function(t){t.addHooks()}))},removeHooks:function(){this._eachVertexHandler((function(t){t.removeHooks()}))},updateMarkers:function(){this._eachVertexHandler((function(t){t.updateMarkers()}))},_initHandlers:function(){(this||i)._verticesHandlers=[];for(var t=0;t<(this||i).latlngs.length;t++)(this||i)._verticesHandlers.push(new L.Edit.PolyVerticesEdit((this||i)._poly,(this||i).latlngs[t],(this||i)._poly.options.poly))},_updateLatLngs:function(t){(this||i).latlngs=[t.layer._latlngs],t.layer._holes&&((this||i).latlngs=(this||i).latlngs.concat(t.layer._holes))}}),L.Edit.PolyVerticesEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),drawError:{color:"#b00b00",timeout:1e3}},initialize:function(t,e,a){L.Browser.touch&&((this||i).options.icon=(this||i).options.touchIcon),(this||i)._poly=t,a&&a.drawError&&(a.drawError=L.Util.extend({},(this||i).options.drawError,a.drawError)),(this||i)._latlngs=e,L.setOptions(this||i,a)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat((this||i)._latlngs)?(this||i)._latlngs:(this||i)._latlngs[0]:(this||i)._latlngs},addHooks:function(){var t=(this||i)._poly,e=t._path;t instanceof L.Polygon||(t.options.fill=!1,t.options.editing&&(t.options.editing.fill=!1)),e&&t.options.editing&&t.options.editing.className&&(t.options.original.className&&t.options.original.className.split(" ").forEach((function(t){L.DomUtil.removeClass(e,t)})),t.options.editing.className.split(" ").forEach((function(t){L.DomUtil.addClass(e,t)}))),t.setStyle(t.options.editing),(this||i)._poly._map&&((this||i)._map=(this||i)._poly._map,(this||i)._markerGroup||this._initMarkers(),(this||i)._poly._map.addLayer((this||i)._markerGroup))},removeHooks:function(){var t=(this||i)._poly,e=t._path;e&&t.options.editing&&t.options.editing.className&&(t.options.editing.className.split(" ").forEach((function(t){L.DomUtil.removeClass(e,t)})),t.options.original.className&&t.options.original.className.split(" ").forEach((function(t){L.DomUtil.addClass(e,t)}))),t.setStyle(t.options.original),t._map&&(t._map.removeLayer((this||i)._markerGroup),delete(this||i)._markerGroup,delete(this||i)._markers)},updateMarkers:function(){(this||i)._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){(this||i)._markerGroup||((this||i)._markerGroup=new L.LayerGroup),(this||i)._markers=[];var t,e,a,n,s=this._defaultShape();for(t=0,a=s.length;t<a;t++)n=this._createMarker(s[t],t),n.on("click",(this||i)._onMarkerClick,this||i),n.on("contextmenu",(this||i)._onContextMenu,this||i),(this||i)._markers.push(n);var r,l;for(t=0,e=a-1;t<a;e=t++)(0!==t||L.Polygon&&(this||i)._poly instanceof L.Polygon)&&(r=(this||i)._markers[e],l=(this||i)._markers[t],this._createMiddleMarker(r,l),this._updatePrevNext(r,l))},_createMarker:function(t,e){var a=new L.Marker.Touch(t,{draggable:!0,icon:(this||i).options.icon});return a._origLatLng=t,a._index=e,a.on("dragstart",(this||i)._onMarkerDragStart,this||i).on("drag",(this||i)._onMarkerDrag,this||i).on("dragend",(this||i)._fireEdit,this||i).on("touchmove",(this||i)._onTouchMove,this||i).on("touchend",(this||i)._fireEdit,this||i).on("MSPointerMove",(this||i)._onTouchMove,this||i).on("MSPointerUp",(this||i)._fireEdit,this||i),(this||i)._markerGroup.addLayer(a),a},_onMarkerDragStart:function(){(this||i)._poly.fire("editstart")},_spliceLatLngs:function(){var t=this._defaultShape(),e=[].splice.apply(t,arguments);return(this||i)._poly._convertLatLngs(t,!0),(this||i)._poly.redraw(),e},_removeMarker:function(t){var e=t._index;(this||i)._markerGroup.removeLayer(t),(this||i)._markers.splice(e,1),this._spliceLatLngs(e,1),this._updateIndexes(e,-1),t.off("dragstart",(this||i)._onMarkerDragStart,this||i).off("drag",(this||i)._onMarkerDrag,this||i).off("dragend",(this||i)._fireEdit,this||i).off("touchmove",(this||i)._onMarkerDrag,this||i).off("touchend",(this||i)._fireEdit,this||i).off("click",(this||i)._onMarkerClick,this||i).off("MSPointerMove",(this||i)._onTouchMove,this||i).off("MSPointerUp",(this||i)._fireEdit,this||i)},_fireEdit:function(){(this||i)._poly.edited=!0,(this||i)._poly.fire("edit"),(this||i)._poly._map.fire(L.Draw.Event.EDITVERTEX,{layers:(this||i)._markerGroup,poly:(this||i)._poly})},_onMarkerDrag:function(t){var e=t.target,a=(this||i)._poly,n=L.LatLngUtil.cloneLatLng(e._origLatLng);if(L.extend(e._origLatLng,e._latlng),a.options.poly){var s=a._map._editTooltip;if(!a.options.poly.allowIntersection&&a.intersects()){L.extend(e._origLatLng,n),e.setLatLng(n);var r=a.options.color;a.setStyle({color:(this||i).options.drawError.color}),s&&s.updateContent({text:L.drawLocal.draw.handlers.polyline.error}),setTimeout((function(){a.setStyle({color:r}),s&&s.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext})}),1e3)}}e._middleLeft&&e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev,e)),e._middleRight&&e._middleRight.setLatLng(this._getMiddleLatLng(e,e._next)),(this||i)._poly._bounds._southWest=L.latLng(1/0,1/0),(this||i)._poly._bounds._northEast=L.latLng(-1/0,-1/0);var l=(this||i)._poly.getLatLngs();(this||i)._poly._convertLatLngs(l,!0),(this||i)._poly.redraw(),(this||i)._poly.fire("editdrag")},_onMarkerClick:function(t){var e=L.Polygon&&(this||i)._poly instanceof L.Polygon?4:3,a=t.target;this._defaultShape().length<e||(this._removeMarker(a),this._updatePrevNext(a._prev,a._next),a._middleLeft&&(this||i)._markerGroup.removeLayer(a._middleLeft),a._middleRight&&(this||i)._markerGroup.removeLayer(a._middleRight),a._prev&&a._next?this._createMiddleMarker(a._prev,a._next):a._prev?a._next||(a._prev._middleRight=null):a._next._middleLeft=null,this._fireEdit())},_onContextMenu:function(t){var e=t.target;(this||i)._poly;(this||i)._poly._map.fire(L.Draw.Event.MARKERCONTEXT,{marker:e,layers:(this||i)._markerGroup,poly:(this||i)._poly}),L.DomEvent.stopPropagation},_onTouchMove:function(t){var e=(this||i)._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),a=(this||i)._map.layerPointToLatLng(e),n=t.target;L.extend(n._origLatLng,a),n._middleLeft&&n._middleLeft.setLatLng(this._getMiddleLatLng(n._prev,n)),n._middleRight&&n._middleRight.setLatLng(this._getMiddleLatLng(n,n._next)),(this||i)._poly.redraw(),this.updateMarkers()},_updateIndexes:function(t,e){(this||i)._markerGroup.eachLayer((function(i){i._index>t&&(i._index+=e)}))},_createMiddleMarker:function(t,e){var a,n,s,r=this._getMiddleLatLng(t,e),l=this._createMarker(r);l.setOpacity(.6),t._middleRight=e._middleLeft=l,n=function(){l.off("touchmove",n,this||i);var s=e._index;l._index=s,l.off("click",a,this||i).on("click",(this||i)._onMarkerClick,this||i),r.lat=l.getLatLng().lat,r.lng=l.getLatLng().lng,this._spliceLatLngs(s,0,r),(this||i)._markers.splice(s,0,l),l.setOpacity(1),this._updateIndexes(s,1),e._index++,this._updatePrevNext(t,l),this._updatePrevNext(l,e),(this||i)._poly.fire("editstart")},s=function(){l.off("dragstart",n,this||i),l.off("dragend",s,this||i),l.off("touchmove",n,this||i),this._createMiddleMarker(t,l),this._createMiddleMarker(l,e)},a=function(){n.call(this||i),s.call(this||i),this._fireEdit()},l.on("click",a,this||i).on("dragstart",n,this||i).on("dragend",s,this||i).on("touchmove",n,this||i),(this||i)._markerGroup.addLayer(l)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var a=(this||i)._poly._map,n=a.project(t.getLatLng()),s=a.project(e.getLatLng());return a.unproject(n._add(s)._divideBy(2))}}),L.Polyline.addInitHook((function(){(this||i).editing||(L.Edit.Poly&&((this||i).editing=new L.Edit.Poly(this||i),(this||i).options.editable&&(this||i).editing.enable()),this.on("add",(function(){(this||i).editing&&(this||i).editing.enabled()&&(this||i).editing.addHooks()})),this.on("remove",(function(){(this||i).editing&&(this||i).editing.enabled()&&(this||i).editing.removeHooks()})))})),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&((this||i).options.moveIcon=(this||i).options.touchMoveIcon,(this||i).options.resizeIcon=(this||i).options.touchResizeIcon),(this||i)._shape=t,L.Util.setOptions(this||i,e)},addHooks:function(){var t=(this||i)._shape;(this||i)._shape._map&&((this||i)._map=(this||i)._shape._map,t.setStyle(t.options.editing),t._map&&((this||i)._map=t._map,(this||i)._markerGroup||this._initMarkers(),(this||i)._map.addLayer((this||i)._markerGroup)))},removeHooks:function(){var t=(this||i)._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker((this||i)._moveMarker);for(var e=0,a=(this||i)._resizeMarkers.length;e<a;e++)this._unbindMarker((this||i)._resizeMarkers[e]);(this||i)._resizeMarkers=null,(this||i)._map.removeLayer((this||i)._markerGroup),delete(this||i)._markerGroup}(this||i)._map=null},updateMarkers:function(){(this||i)._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){(this||i)._markerGroup||((this||i)._markerGroup=new L.LayerGroup),this._createMoveMarker(),this._createResizeMarker()},_createMoveMarker:function(){},_createResizeMarker:function(){},_createMarker:function(t,e){var a=new L.Marker.Touch(t,{draggable:!0,icon:e,zIndexOffset:10});return this._bindMarker(a),(this||i)._markerGroup.addLayer(a),a},_bindMarker:function(t){t.on("dragstart",(this||i)._onMarkerDragStart,this||i).on("drag",(this||i)._onMarkerDrag,this||i).on("dragend",(this||i)._onMarkerDragEnd,this||i).on("touchstart",(this||i)._onTouchStart,this||i).on("touchmove",(this||i)._onTouchMove,this||i).on("MSPointerMove",(this||i)._onTouchMove,this||i).on("touchend",(this||i)._onTouchEnd,this||i).on("MSPointerUp",(this||i)._onTouchEnd,this||i)},_unbindMarker:function(t){t.off("dragstart",(this||i)._onMarkerDragStart,this||i).off("drag",(this||i)._onMarkerDrag,this||i).off("dragend",(this||i)._onMarkerDragEnd,this||i).off("touchstart",(this||i)._onTouchStart,this||i).off("touchmove",(this||i)._onTouchMove,this||i).off("MSPointerMove",(this||i)._onTouchMove,this||i).off("touchend",(this||i)._onTouchEnd,this||i).off("MSPointerUp",(this||i)._onTouchEnd,this||i)},_onMarkerDragStart:function(t){t.target.setOpacity(0),(this||i)._shape.fire("editstart")},_fireEdit:function(){(this||i)._shape.edited=!0,(this||i)._shape.fire("edit")},_onMarkerDrag:function(t){var e=t.target,a=e.getLatLng();e===(this||i)._moveMarker?this._move(a):this._resize(a),(this||i)._shape.redraw(),(this||i)._shape.fire("editdrag")},_onMarkerDragEnd:function(t){t.target.setOpacity(1),this._fireEdit()},_onTouchStart:function(t){if(L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this||i,t),"function"==typeof(this||i)._getCorners){var e=this._getCorners(),a=t.target,n=a._cornerIndex;a.setOpacity(0),(this||i)._oppositeCorner=e[(n+2)%4],this._toggleCornerMarkers(0,n)}(this||i)._shape.fire("editstart")},_onTouchMove:function(t){var e=(this||i)._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),a=(this||i)._map.layerPointToLatLng(e);return t.target===(this||i)._moveMarker?this._move(a):this._resize(a),(this||i)._shape.redraw(),!1},_onTouchEnd:function(t){t.target.setOpacity(1),this.updateMarkers(),this._fireEdit()},_move:function(){},_resize:function(){}}),L.Edit=L.Edit||{},L.Edit.Rectangle=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=(this||i)._shape.getBounds(),e=t.getCenter();(this||i)._moveMarker=this._createMarker(e,(this||i).options.moveIcon)},_createResizeMarker:function(){var t=this._getCorners();(this||i)._resizeMarkers=[];for(var e=0,a=t.length;e<a;e++)(this||i)._resizeMarkers.push(this._createMarker(t[e],(this||i).options.resizeIcon)),(this||i)._resizeMarkers[e]._cornerIndex=e},_onMarkerDragStart:function(t){L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this||i,t);var e=this._getCorners(),a=t.target,n=a._cornerIndex;(this||i)._oppositeCorner=e[(n+2)%4],this._toggleCornerMarkers(0,n)},_onMarkerDragEnd:function(t){var e,a,n=t.target;n===(this||i)._moveMarker&&(e=(this||i)._shape.getBounds(),a=e.getCenter(),n.setLatLng(a)),this._toggleCornerMarkers(1),this._repositionCornerMarkers(),L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this||i,t)},_move:function(t){for(var e,a=(this||i)._shape._defaultShape?(this||i)._shape._defaultShape():(this||i)._shape.getLatLngs(),n=(this||i)._shape.getBounds(),s=n.getCenter(),r=[],l=0,h=a.length;l<h;l++)e=[a[l].lat-s.lat,a[l].lng-s.lng],r.push([t.lat+e[0],t.lng+e[1]]);(this||i)._shape.setLatLngs(r),this._repositionCornerMarkers(),(this||i)._map.fire(L.Draw.Event.EDITMOVE,{layer:(this||i)._shape})},_resize:function(t){var e;(this||i)._shape.setBounds(L.latLngBounds(t,(this||i)._oppositeCorner)),e=(this||i)._shape.getBounds(),(this||i)._moveMarker.setLatLng(e.getCenter()),(this||i)._map.fire(L.Draw.Event.EDITRESIZE,{layer:(this||i)._shape})},_getCorners:function(){var t=(this||i)._shape.getBounds();return[t.getNorthWest(),t.getNorthEast(),t.getSouthEast(),t.getSouthWest()]},_toggleCornerMarkers:function(t){for(var e=0,a=(this||i)._resizeMarkers.length;e<a;e++)(this||i)._resizeMarkers[e].setOpacity(t)},_repositionCornerMarkers:function(){for(var t=this._getCorners(),e=0,a=(this||i)._resizeMarkers.length;e<a;e++)(this||i)._resizeMarkers[e].setLatLng(t[e])}}),L.Rectangle.addInitHook((function(){L.Edit.Rectangle&&((this||i).editing=new L.Edit.Rectangle(this||i),(this||i).options.editable&&(this||i).editing.enable())})),L.Edit=L.Edit||{},L.Edit.CircleMarker=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=(this||i)._shape.getLatLng();(this||i)._moveMarker=this._createMarker(t,(this||i).options.moveIcon)},_createResizeMarker:function(){(this||i)._resizeMarkers=[]},_move:function(t){if((this||i)._resizeMarkers.length){var e=this._getResizeMarkerPoint(t);(this||i)._resizeMarkers[0].setLatLng(e)}(this||i)._shape.setLatLng(t),(this||i)._map.fire(L.Draw.Event.EDITMOVE,{layer:(this||i)._shape})}}),L.CircleMarker.addInitHook((function(){L.Edit.CircleMarker&&((this||i).editing=new L.Edit.CircleMarker(this||i),(this||i).options.editable&&(this||i).editing.enable()),this.on("add",(function(){(this||i).editing&&(this||i).editing.enabled()&&(this||i).editing.addHooks()})),this.on("remove",(function(){(this||i).editing&&(this||i).editing.enabled()&&(this||i).editing.removeHooks()}))})),L.Edit=L.Edit||{},L.Edit.Circle=L.Edit.CircleMarker.extend({_createResizeMarker:function(){var t=(this||i)._shape.getLatLng(),e=this._getResizeMarkerPoint(t);(this||i)._resizeMarkers=[],(this||i)._resizeMarkers.push(this._createMarker(e,(this||i).options.resizeIcon))},_getResizeMarkerPoint:function(t){var e=(this||i)._shape._radius*Math.cos(Math.PI/4),a=(this||i)._map.project(t);return(this||i)._map.unproject([a.x+e,a.y-e])},_resize:function(e){var a=(this||i)._moveMarker.getLatLng();L.GeometryUtil.isVersion07x()?i.radius=t=a.distanceTo(e):t=(this||i)._map.distance(a,e),(this||i)._shape.setRadius(t),(this||i)._map.editTooltip&&(this||i)._map._editTooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.subtext+"<br />"+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(t,!0,(this||i).options.feet,(this||i).options.nautic)}),(this||i)._shape.setRadius(t),(this||i)._map.fire(L.Draw.Event.EDITRESIZE,{layer:(this||i)._shape})}}),L.Circle.addInitHook((function(){L.Edit.Circle&&((this||i).editing=new L.Edit.Circle(this||i),(this||i).options.editable&&(this||i).editing.enable())})),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){(this||i)._map=t,(this||i)._container=t._container,(this||i)._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on((this||i)._container,"touchstart",(this||i)._onTouchStart,this||i),L.DomEvent.on((this||i)._container,"touchend",(this||i)._onTouchEnd,this||i),L.DomEvent.on((this||i)._container,"touchmove",(this||i)._onTouchMove,this||i),this._detectIE()?(L.DomEvent.on((this||i)._container,"MSPointerDown",(this||i)._onTouchStart,this||i),L.DomEvent.on((this||i)._container,"MSPointerUp",(this||i)._onTouchEnd,this||i),L.DomEvent.on((this||i)._container,"MSPointerMove",(this||i)._onTouchMove,this||i),L.DomEvent.on((this||i)._container,"MSPointerCancel",(this||i)._onTouchCancel,this||i)):(L.DomEvent.on((this||i)._container,"touchcancel",(this||i)._onTouchCancel,this||i),L.DomEvent.on((this||i)._container,"touchleave",(this||i)._onTouchLeave,this||i))},removeHooks:function(){L.DomEvent.off((this||i)._container,"touchstart",(this||i)._onTouchStart,this||i),L.DomEvent.off((this||i)._container,"touchend",(this||i)._onTouchEnd,this||i),L.DomEvent.off((this||i)._container,"touchmove",(this||i)._onTouchMove,this||i),this._detectIE()?(L.DomEvent.off((this||i)._container,"MSPointerDown",(this||i)._onTouchStart,this||i),L.DomEvent.off((this||i)._container,"MSPointerUp",(this||i)._onTouchEnd,this||i),L.DomEvent.off((this||i)._container,"MSPointerMove",(this||i)._onTouchMove,this||i),L.DomEvent.off((this||i)._container,"MSPointerCancel",(this||i)._onTouchCancel,this||i)):(L.DomEvent.off((this||i)._container,"touchcancel",(this||i)._onTouchCancel,this||i),L.DomEvent.off((this||i)._container,"touchleave",(this||i)._onTouchLeave,this||i))},_touchEvent:function(t,e){var a={};if(void 0!==t.touches){if(!t.touches.length)return;a=t.touches[0]}else{if("touch"!==t.pointerType)return;if(a=t,!this._filterClick(t))return}var n=(this||i)._map.mouseEventToContainerPoint(a),s=(this||i)._map.mouseEventToLayerPoint(a),r=(this||i)._map.layerPointToLatLng(s);(this||i)._map.fire(e,{latlng:r,layerPoint:s,containerPoint:n,pageX:a.pageX,pageY:a.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){(this||i)._map._loaded&&this._touchEvent(t,"touchstart")},_onTouchEnd:function(t){(this||i)._map._loaded&&this._touchEvent(t,"touchend")},_onTouchCancel:function(t){if((this||i)._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){(this||i)._map._loaded&&this._touchEvent(t,"touchleave")},_onTouchMove:function(t){(this||i)._map._loaded&&this._touchEvent(t,"touchmove")},_detectIE:function(){var t=a.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}var n=t.indexOf("Edge/");return n>0&&parseInt(t.substring(n+5,t.indexOf(".",n)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return(this||i).addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this||i):this._initInteractionLegacy()},_initInteractionLegacy:function(){if((this||i).options.clickable){var t=(this||i)._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];(this||i)._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",(this||i)._onMouseClick,this||i),L.DomEvent.on(t,"keypress",(this||i)._onKeyPress,this||i);for(var a=0;a<e.length;a++)L.DomEvent.on(t,e[a],(this||i)._fireMouseEvent,this||i);L.Handler.MarkerDrag&&((this||i).dragging=new L.Handler.MarkerDrag(this||i),(this||i).options.draggable&&(this||i).dragging.enable())}},_detectIE:function(){var t=a.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}var n=t.indexOf("Edge/");return n>0&&parseInt(t.substring(n+5,t.indexOf(".",n)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,a=t.length;i<a;i++)Array.isArray(t[i])?e.push(L.LatLngUtil.cloneLatLngs(t[i])):e.push(this.cloneLatLng(t[i]));return e},cloneLatLng:function(t){return L.latLng(t.lat,t.lng)}},function(){var t={km:2,ha:2,m:0,mi:2,ac:2,yd:0,ft:0,nm:2};L.GeometryUtil=L.extend(L.GeometryUtil||{},{geodesicArea:function(t){var e,i,a=t.length,n=0,s=Math.PI/180;if(a>2){for(var r=0;r<a;r++)e=t[r],i=t[(r+1)%a],n+=(i.lng-e.lng)*s*(2+Math.sin(e.lat*s)+Math.sin(i.lat*s));n=6378137*n*6378137/2}return Math.abs(n)},formattedNumber:function(t,e){var i=parseFloat(t).toFixed(e),a=L.drawLocal.format&&L.drawLocal.format.numeric,n=a&&a.delimiters,s=n&&n.thousands,r=n&&n.decimal;if(s||r){var l=i.split(".");i=s?l[0].replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s):l[0],r=r||".",l.length>1&&(i=i+r+l[1])}return i},readableArea:function(a,n,s){var r,l,s=L.Util.extend({},t,s);return n?(l=["ha","m"],i.type=e=typeof n,"string"===e?l=[n]:"boolean"!==e&&(l=n),r=a>=1e6&&-1!==l.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*a,s.km)+" km²":a>=1e4&&-1!==l.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*a,s.ha)+" ha":L.GeometryUtil.formattedNumber(a,s.m)+" m²"):(a/=.836127,r=a>=3097600?L.GeometryUtil.formattedNumber(a/3097600,s.mi)+" mi²":a>=4840?L.GeometryUtil.formattedNumber(a/4840,s.ac)+" acres":L.GeometryUtil.formattedNumber(a,s.yd)+" yd²"),r},readableDistance:function(e,i,a,n,s){var r,s=L.Util.extend({},t,s);switch(i?"string"==typeof i?i:"metric":a?"feet":n?"nauticalMile":"yards"){case"metric":r=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,s.km)+" km":L.GeometryUtil.formattedNumber(e,s.m)+" m";break;case"feet":e*=3.28083,r=L.GeometryUtil.formattedNumber(e,s.ft)+" ft";break;case"nauticalMile":e*=.53996,r=L.GeometryUtil.formattedNumber(e/1e3,s.nm)+" nm";break;case"yards":default:e*=1.09361,r=e>1760?L.GeometryUtil.formattedNumber(e/1760,s.mi)+" miles":L.GeometryUtil.formattedNumber(e,s.yd)+" yd"}return r},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,a){return this._checkCounterclockwise(t,i,a)!==this._checkCounterclockwise(e,i,a)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,a)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,a=this._getProjectedPoints(),n=a?a.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=n-1;t>=3;t--)if(e=a[t-1],i=a[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!(this||i)._map&&this.newPointIntersects((this||i)._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),a=i?i.length:0,n=i?i[a-1]:null,s=a-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(n,t,s,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,a){var n,s,r=this._getProjectedPoints();a=a||0;for(var l=i;l>a;l--)if(n=r[l-1],s=r[l],L.LineUtil.segmentsIntersect(t,e,n,s))return!0;return!1},_getProjectedPoints:function(){if(!(this||i)._defaultShape)return(this||i)._originalPoints;for(var t=[],e=this._defaultShape(),a=0;a<e.length;a++)t.push((this||i)._map.latLngToLayerPoint(e[a]));return t}}),L.Polygon.include({intersects:function(){var t,e,a,n,s=this._getProjectedPoints();return!this._tooFewPointsForIntersection()&&(!!L.Polyline.prototype.intersects.call(this||i)||(t=s.length,e=s[0],a=s[t-1],n=t-2,this._lineSegmentsIntersectsRange(a,e,n,1)))}}),L.Control.Draw=L.Control.extend({options:{position:"topleft",draw:{},edit:!1},initialize:function(t){if(L.version<"0.7")throw new Error("Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/");L.Control.prototype.initialize.call(this||i,t);var e;(this||i)._toolbars={},L.DrawToolbar&&(this||i).options.draw&&(e=new L.DrawToolbar((this||i).options.draw),(this||i)._toolbars[L.DrawToolbar.TYPE]=e,(this||i)._toolbars[L.DrawToolbar.TYPE].on("enable",(this||i)._toolbarEnabled,this||i)),L.EditToolbar&&(this||i).options.edit&&(e=new L.EditToolbar((this||i).options.edit),(this||i)._toolbars[L.EditToolbar.TYPE]=e,(this||i)._toolbars[L.EditToolbar.TYPE].on("enable",(this||i)._toolbarEnabled,this||i)),L.toolbar=this||i},onAdd:function(t){var e,a=L.DomUtil.create("div","leaflet-draw"),n=!1;for(var s in(this||i)._toolbars)(this||i)._toolbars.hasOwnProperty(s)&&(e=(this||i)._toolbars[s].addToolbar(t))&&(n||(L.DomUtil.hasClass(e,"leaflet-draw-toolbar-top")||L.DomUtil.addClass(e.childNodes[0],"leaflet-draw-toolbar-top"),n=!0),a.appendChild(e));return a},onRemove:function(){for(var t in(this||i)._toolbars)(this||i)._toolbars.hasOwnProperty(t)&&(this||i)._toolbars[t].removeToolbar()},setDrawingOptions:function(t){for(var e in(this||i)._toolbars)(this||i)._toolbars[e]instanceof L.DrawToolbar&&(this||i)._toolbars[e].setOptions(t)},_toolbarEnabled:function(t){var e=t.target;for(var a in(this||i)._toolbars)(this||i)._toolbars[a]!==e&&(this||i)._toolbars[a].disable()}}),L.Map.mergeOptions({drawControlTooltips:!0,drawControl:!1}),L.Map.addInitHook((function(){(this||i).options.drawControl&&((this||i).drawControl=new L.Control.Draw,this.addControl((this||i).drawControl))})),L.Toolbar=L.Class.extend({initialize:function(t){L.setOptions(this||i,t),(this||i)._modes={},(this||i)._actionButtons=[],(this||i)._activeMode=null;var e=L.version.split(".");1===parseInt(e[0],10)&&parseInt(e[1],10)>=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==(this||i)._activeMode},disable:function(){this.enabled()&&(this||i)._activeMode.handler.disable()},addToolbar:function(t){var e,a=L.DomUtil.create("div","leaflet-draw-section"),n=0,s=(this||i)._toolbarClass||"",r=this.getModeHandlers(t);for((this||i)._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),(this||i)._map=t,e=0;e<r.length;e++)r[e].enabled&&this._initModeHandler(r[e].handler,(this||i)._toolbarContainer,n++,s,r[e].title);if(n)return(this||i)._lastButtonIndex=--n,(this||i)._actionsContainer=L.DomUtil.create("ul","leaflet-draw-actions"),a.appendChild((this||i)._toolbarContainer),a.appendChild((this||i)._actionsContainer),a},removeToolbar:function(){for(var t in(this||i)._modes)(this||i)._modes.hasOwnProperty(t)&&(this._disposeButton((this||i)._modes[t].button,(this||i)._modes[t].handler.enable,(this||i)._modes[t].handler),(this||i)._modes[t].handler.disable(),(this||i)._modes[t].handler.off("enabled",(this||i)._handlerActivated,this||i).off("disabled",(this||i)._handlerDeactivated,this||i));(this||i)._modes={};for(var e=0,a=(this||i)._actionButtons.length;e<a;e++)this._disposeButton((this||i)._actionButtons[e].button,(this||i)._actionButtons[e].callback,this||i);(this||i)._actionButtons=[],(this||i)._actionsContainer=null},_initModeHandler:function(t,e,a,n,s){var r=t.type;(this||i)._modes[r]={},(this||i)._modes[r].handler=t,(this||i)._modes[r].button=this._createButton({type:r,title:s,className:n+"-"+r,container:e,callback:(this||i)._modes[r].handler.enable,context:(this||i)._modes[r].handler}),(this||i)._modes[r].buttonIndex=a,(this||i)._modes[r].handler.on("enabled",(this||i)._handlerActivated,this||i).on("disabled",(this||i)._handlerDeactivated,this||i)},_detectIOS:function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!a.MSStream},_createButton:function(t){var e=L.DomUtil.create("a",t.className||"",t.container),i=L.DomUtil.create("span","sr-only",t.container);e.href="#",e.appendChild(i),t.title&&(e.title=t.title,i.innerHTML=t.title),t.text&&(e.innerHTML=t.text,i.innerHTML=t.text);var a=this._detectIOS()?"touchstart":"click";return L.DomEvent.on(e,"click",L.DomEvent.stopPropagation).on(e,"mousedown",L.DomEvent.stopPropagation).on(e,"dblclick",L.DomEvent.stopPropagation).on(e,"touchstart",L.DomEvent.stopPropagation).on(e,"click",L.DomEvent.preventDefault).on(e,a,t.callback,t.context),e},_disposeButton:function(t,e){var i=this._detectIOS()?"touchstart":"click";L.DomEvent.off(t,"click",L.DomEvent.stopPropagation).off(t,"mousedown",L.DomEvent.stopPropagation).off(t,"dblclick",L.DomEvent.stopPropagation).off(t,"touchstart",L.DomEvent.stopPropagation).off(t,"click",L.DomEvent.preventDefault).off(t,i,e)},_handlerActivated:function(t){this.disable(),(this||i)._activeMode=(this||i)._modes[t.handler],L.DomUtil.addClass((this||i)._activeMode.button,"leaflet-draw-toolbar-button-enabled"),this._showActionsToolbar(),this.fire("enable")},_handlerDeactivated:function(){this._hideActionsToolbar(),L.DomUtil.removeClass((this||i)._activeMode.button,"leaflet-draw-toolbar-button-enabled"),(this||i)._activeMode=null,this.fire("disable")},_createActions:function(t){var e,a,n,s,r=(this||i)._actionsContainer,l=this.getActions(t),h=l.length;for(a=0,n=(this||i)._actionButtons.length;a<n;a++)this._disposeButton((this||i)._actionButtons[a].button,(this||i)._actionButtons[a].callback);for((this||i)._actionButtons=[];r.firstChild;)r.removeChild(r.firstChild);for(var d=0;d<h;d++)"enabled"in l[d]&&!l[d].enabled||(e=L.DomUtil.create("li","",r),s=this._createButton({title:l[d].title,text:l[d].text,container:e,callback:l[d].callback,context:l[d].context}),(this||i)._actionButtons.push({button:s,callback:l[d].callback}))},_showActionsToolbar:function(){var t=(this||i)._activeMode.buttonIndex,e=(this||i)._lastButtonIndex,a=(this||i)._activeMode.button.offsetTop-1;this._createActions((this||i)._activeMode.handler),(this||i)._actionsContainer.style.top=a+"px",0===t&&(L.DomUtil.addClass((this||i)._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.addClass((this||i)._actionsContainer,"leaflet-draw-actions-top")),t===e&&(L.DomUtil.addClass((this||i)._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.addClass((this||i)._actionsContainer,"leaflet-draw-actions-bottom")),(this||i)._actionsContainer.style.display="block",(this||i)._map.fire(L.Draw.Event.TOOLBAROPENED)},_hideActionsToolbar:function(){(this||i)._actionsContainer.style.display="none",L.DomUtil.removeClass((this||i)._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.removeClass((this||i)._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.removeClass((this||i)._actionsContainer,"leaflet-draw-actions-top"),L.DomUtil.removeClass((this||i)._actionsContainer,"leaflet-draw-actions-bottom"),(this||i)._map.fire(L.Draw.Event.TOOLBARCLOSED)}}),L.Draw=L.Draw||{},L.Draw.Tooltip=L.Class.extend({initialize:function(t){(this||i)._map=t,(this||i)._popupPane=t._panes.popupPane,(this||i)._visible=!1,(this||i)._container=t.options.drawControlTooltips?L.DomUtil.create("div","leaflet-draw-tooltip",(this||i)._popupPane):null,(this||i)._singleLineLabel=!1,(this||i)._map.on("mouseout",(this||i)._onMouseOut,this||i)},dispose:function(){(this||i)._map.off("mouseout",(this||i)._onMouseOut,this||i),(this||i)._container&&((this||i)._popupPane.removeChild((this||i)._container),(this||i)._container=null)},updateContent:function(t){return(this||i)._container?(t.subtext=t.subtext||"",0!==t.subtext.length||(this||i)._singleLineLabel?t.subtext.length>0&&(this||i)._singleLineLabel&&(L.DomUtil.removeClass((this||i)._container,"leaflet-draw-tooltip-single"),(this||i)._singleLineLabel=!1):(L.DomUtil.addClass((this||i)._container,"leaflet-draw-tooltip-single"),(this||i)._singleLineLabel=!0),(this||i)._container.innerHTML=(t.subtext.length>0?'<span class="leaflet-draw-tooltip-subtext">'+t.subtext+"</span><br />":"")+"<span>"+t.text+"</span>",t.text||t.subtext?((this||i)._visible=!0,(this||i)._container.style.visibility="inherit"):((this||i)._visible=!1,(this||i)._container.style.visibility="hidden"),this||i):this||i},updatePosition:function(t){var e=(this||i)._map.latLngToLayerPoint(t),a=(this||i)._container;return(this||i)._container&&((this||i)._visible&&(a.style.visibility="inherit"),L.DomUtil.setPosition(a,e)),this||i},showAsError:function(){return(this||i)._container&&L.DomUtil.addClass((this||i)._container,"leaflet-error-draw-tooltip"),this||i},removeError:function(){return(this||i)._container&&L.DomUtil.removeClass((this||i)._container,"leaflet-error-draw-tooltip"),this||i},_onMouseOut:function(){(this||i)._container&&((this||i)._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in(this||i).options)(this||i).options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},(this||i).options[e],t[e]));(this||i)._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this||i,t)},getModeHandlers:function(t){return[{enabled:(this||i).options.polyline,handler:new L.Draw.Polyline(t,(this||i).options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:(this||i).options.polygon,handler:new L.Draw.Polygon(t,(this||i).options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:(this||i).options.rectangle,handler:new L.Draw.Rectangle(t,(this||i).options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:(this||i).options.circle,handler:new L.Draw.Circle(t,(this||i).options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:(this||i).options.marker,handler:new L.Draw.Marker(t,(this||i).options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:(this||i).options.circlemarker,handler:new L.Draw.CircleMarker(t,(this||i).options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:(this||i).disable,context:this||i}]},setOptions:function(t){L.setOptions(this||i,t);for(var e in(this||i)._modes)(this||i)._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&(this||i)._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=(this||i).options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},(this||i).options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},(this||i).options.remove,t.remove)),t.poly&&(t.poly=L.extend({},(this||i).options.poly,t.poly)),(this||i)._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this||i,t),(this||i)._selectedFeatureCount=0},getModeHandlers:function(t){var e=(this||i).options.featureGroup;return[{enabled:(this||i).options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:(this||i).options.edit.selectedPathOptions,poly:(this||i).options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:(this||i).options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:(this||i)._save,context:this||i},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:(this||i).disable,context:this||i}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:(this||i)._clearAllLayers,context:this||i}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this||i,t);return this._checkDisabled(),(this||i).options.featureGroup.on("layeradd layerremove",(this||i)._checkDisabled,this||i),e},removeToolbar:function(){(this||i).options.featureGroup.off("layeradd layerremove",(this||i)._checkDisabled,this||i),L.Toolbar.prototype.removeToolbar.call(this||i)},disable:function(){this.enabled()&&((this||i)._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this||i))},_save:function(){(this||i)._activeMode.handler.save(),(this||i)._activeMode&&(this||i)._activeMode.handler.disable()},_clearAllLayers:function(){(this||i)._activeMode.handler.removeAllLayers(),(this||i)._activeMode&&(this||i)._activeMode.handler.disable()},_checkDisabled:function(){var t,e=(this||i).options.featureGroup,a=0!==e.getLayers().length;(this||i).options.edit&&(t=(this||i)._modes[L.EditToolbar.Edit.TYPE].button,a?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",a?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),(this||i).options.remove&&(t=(this||i)._modes[L.EditToolbar.Delete.TYPE].button,a?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",a?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this||i,t),L.setOptions(this||i,e),(this||i)._featureGroup=e.featureGroup,!((this||i)._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");(this||i)._uneditedLayerProps={},(this||i).type=L.EditToolbar.Edit.TYPE;var a=L.version.split(".");1===parseInt(a[0],10)&&parseInt(a[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!(this||i)._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:(this||i).type}),(this||i)._map.fire(L.Draw.Event.EDITSTART,{handler:(this||i).type}),L.Handler.prototype.enable.call(this||i),(this||i)._featureGroup.on("layeradd",(this||i)._enableLayerEdit,this||i).on("layerremove",(this||i)._disableLayerEdit,this||i))},disable:function(){(this||i)._enabled&&((this||i)._featureGroup.off("layeradd",(this||i)._enableLayerEdit,this||i).off("layerremove",(this||i)._disableLayerEdit,this||i),L.Handler.prototype.disable.call(this||i),(this||i)._map.fire(L.Draw.Event.EDITSTOP,{handler:(this||i).type}),this.fire("disabled",{handler:(this||i).type}))},addHooks:function(){var t=(this||i)._map;t&&(t.getContainer().focus(),(this||i)._featureGroup.eachLayer((this||i)._enableLayerEdit,this||i),(this||i)._tooltip=new L.Draw.Tooltip((this||i)._map),(this||i)._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=(this||i)._tooltip,this._updateTooltip(),(this||i)._map.on("mousemove",(this||i)._onMouseMove,this||i).on("touchmove",(this||i)._onMouseMove,this||i).on("MSPointerMove",(this||i)._onMouseMove,this||i).on(L.Draw.Event.EDITVERTEX,(this||i)._updateTooltip,this||i))},removeHooks:function(){(this||i)._map&&((this||i)._featureGroup.eachLayer((this||i)._disableLayerEdit,this||i),(this||i)._uneditedLayerProps={},(this||i)._tooltip.dispose(),(this||i)._tooltip=null,(this||i)._map.off("mousemove",(this||i)._onMouseMove,this||i).off("touchmove",(this||i)._onMouseMove,this||i).off("MSPointerMove",(this||i)._onMouseMove,this||i).off(L.Draw.Event.EDITVERTEX,(this||i)._updateTooltip,this||i))},revertLayers:function(){(this||i)._featureGroup.eachLayer((function(t){this._revertLayer(t)}),this||i)},save:function(){var t=new L.LayerGroup;(this||i)._featureGroup.eachLayer((function(e){e.edited&&(t.addLayer(e),e.edited=!1)})),(this||i)._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);(this||i)._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?(this||i)._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?(this||i)._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&((this||i)._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){(this||i)._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,(this||i)._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs((this||i)._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng((this||i)._uneditedLayerProps[e].latlng),t.setRadius((this||i)._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng((this||i)._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,a,n=t.layer||t.target||t;this._backupLayer(n),(this||i).options.poly&&(a=L.Util.extend({},(this||i).options.poly),n.options.poly=a),(this||i).options.selectedPathOptions&&(e=L.Util.extend({},(this||i).options.selectedPathOptions),e.maintainColor&&(e.color=n.options.color,e.fillColor=n.options.fillColor),n.options.original=L.extend({},n.options),n.options.editing=e),n instanceof L.Marker?(n.editing&&n.editing.enable(),n.dragging.enable(),n.on("dragend",(this||i)._onMarkerDragEnd).on("touchmove",(this||i)._onTouchMove,this||i).on("MSPointerMove",(this||i)._onTouchMove,this||i).on("touchend",(this||i)._onMarkerDragEnd,this||i).on("MSPointerUp",(this||i)._onMarkerDragEnd,this||i)):n.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(),delete e.options.editing,delete e.options.original,(this||i)._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",(this||i)._onMarkerDragEnd,this||i).off("touchmove",(this||i)._onTouchMove,this||i).off("MSPointerMove",(this||i)._onTouchMove,this||i).off("touchend",(this||i)._onMarkerDragEnd,this||i).off("MSPointerUp",(this||i)._onMarkerDragEnd,this||i)):e.editing.disable()},_onMouseMove:function(t){(this||i)._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,(this||i)._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],a=(this||i)._map.mouseEventToLayerPoint(e),n=(this||i)._map.layerPointToLatLng(a);t.target.setLatLng(n)},_hasAvailableLayers:function(){return 0!==(this||i)._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this||i,t),L.Util.setOptions(this||i,e),(this||i)._deletableLayers=(this||i).options.featureGroup,!((this||i)._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");(this||i).type=L.EditToolbar.Delete.TYPE;var a=L.version.split(".");1===parseInt(a[0],10)&&parseInt(a[1],10)>=2?L.EditToolbar.Delete.include(L.Evented.prototype):L.EditToolbar.Delete.include(L.Mixin.Events)},enable:function(){!(this||i)._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:(this||i).type}),(this||i)._map.fire(L.Draw.Event.DELETESTART,{handler:(this||i).type}),L.Handler.prototype.enable.call(this||i),(this||i)._deletableLayers.on("layeradd",(this||i)._enableLayerDelete,this||i).on("layerremove",(this||i)._disableLayerDelete,this||i))},disable:function(){(this||i)._enabled&&((this||i)._deletableLayers.off("layeradd",(this||i)._enableLayerDelete,this||i).off("layerremove",(this||i)._disableLayerDelete,this||i),L.Handler.prototype.disable.call(this||i),(this||i)._map.fire(L.Draw.Event.DELETESTOP,{handler:(this||i).type}),this.fire("disabled",{handler:(this||i).type}))},addHooks:function(){var t=(this||i)._map;t&&(t.getContainer().focus(),(this||i)._deletableLayers.eachLayer((this||i)._enableLayerDelete,this||i),(this||i)._deletedLayers=new L.LayerGroup,(this||i)._tooltip=new L.Draw.Tooltip((this||i)._map),(this||i)._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),(this||i)._map.on("mousemove",(this||i)._onMouseMove,this||i))},removeHooks:function(){(this||i)._map&&((this||i)._deletableLayers.eachLayer((this||i)._disableLayerDelete,this||i),(this||i)._deletedLayers=null,(this||i)._tooltip.dispose(),(this||i)._tooltip=null,(this||i)._map.off("mousemove",(this||i)._onMouseMove,this||i))},revertLayers:function(){(this||i)._deletedLayers.eachLayer((function(t){(this||i)._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})}),this||i)},save:function(){(this||i)._map.fire(L.Draw.Event.DELETED,{layers:(this||i)._deletedLayers})},removeAllLayers:function(){(this||i)._deletableLayers.eachLayer((function(t){this._removeLayer({layer:t})}),this||i),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",(this||i)._removeLayer,this||i)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",(this||i)._removeLayer,this||i),(this||i)._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;(this||i)._deletableLayers.removeLayer(e),(this||i)._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){(this||i)._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==(this||i)._deletableLayers.getLayers().length}})}(window,document);var a={};export default a;