leaflet.pm.min.js 99 KB

1234567
  1. /*!
  2. * Copyright (c) 2017 Sumit Kumar
  3. * leaflet.pm.(https://github.com/codeofsumit/leaflet.pm)
  4. * license: MIT
  5. * version: v0.25.0
  6. */
  7. !function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=18)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(10)),i=L.Class.extend({includes:[n["default"]],options:{snappable:!0,snapDistance:20,cursorMarker:!0,finishOnDoubleClick:!1,finishOn:null,allowSelfIntersection:!0,templineStyle:{},hintlineStyle:{dashArray:"5,5"},markerStyle:{draggable:!0}},initialize:function(t){var e=this;this._map=t,this.shapes=["Marker","Line","Poly","Rectangle","Circle","Cut"],this.shapes.forEach(function(t){e[t]=new L.PM.Draw[t](e._map)})},setPathOptions:function(t){this.options.pathOptions=t},getShapes:function(){return this.shapes},enable:function(t,e){if(!t)throw new Error("Error: Please pass a shape as a parameter. Possible shapes are: ".concat(this.getShapes().join(",")));this.disable(),this[t].enable(e)},disable:function(){var t=this;this.shapes.forEach(function(e){t[e].disable()})},addControls:function(){var t=this;this.shapes.forEach(function(e){t[e].addButton()})}});e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var i=n(r(10)),o=n(r(36)),a=L.Class.extend({includes:[o["default"],i["default"]],options:{snappable:!0,snapDistance:20,allowSelfIntersection:!0,draggable:!0},isPolygon:function(){return this._layer instanceof L.Polygon}});e["default"]=a},function(t,e,r){"use strict";function n(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function i(t,e,r){void 0===r&&(r={});return n({type:"Point",coordinates:t},e,r)}function o(t,e,r){void 0===r&&(r={});for(var i=0,o=t;i<o.length;i++){var a=o[i];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:t},e,r)}function a(t,e,r){if(void 0===r&&(r={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:t},e,r)}function s(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function l(t,e,r){void 0===r&&(r={});return n({type:"MultiLineString",coordinates:t},e,r)}function u(t,e,r){void 0===r&&(r={});return n({type:"MultiPoint",coordinates:t},e,r)}function h(t,e,r){void 0===r&&(r={});return n({type:"MultiPolygon",coordinates:t},e,r)}function c(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t*n}function f(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t/n}function p(t){return 180*(t%(2*Math.PI))/Math.PI}function d(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)&&!/^\s*$/.test(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.earthRadius=6371008.8,e.factors={centimeters:100*e.earthRadius,centimetres:100*e.earthRadius,degrees:e.earthRadius/111325,feet:3.28084*e.earthRadius,inches:39.37*e.earthRadius,kilometers:e.earthRadius/1e3,kilometres:e.earthRadius/1e3,meters:e.earthRadius,metres:e.earthRadius,miles:e.earthRadius/1609.344,millimeters:1e3*e.earthRadius,millimetres:1e3*e.earthRadius,nauticalmiles:e.earthRadius/1852,radians:1,yards:e.earthRadius/1.0936},e.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e.earthRadius,yards:1/1.0936},e.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:3.86e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046},e.feature=n,e.geometry=function(t,e,r){switch(void 0===r&&(r={}),t){case"Point":return i(e).geometry;case"LineString":return a(e).geometry;case"Polygon":return o(e).geometry;case"MultiPoint":return u(e).geometry;case"MultiLineString":return l(e).geometry;case"MultiPolygon":return h(e).geometry;default:throw new Error(t+" is invalid")}},e.point=i,e.points=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return i(t,e)}),r)},e.polygon=o,e.polygons=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return o(t,e)}),r)},e.lineString=a,e.lineStrings=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return a(t,e)}),r)},e.featureCollection=s,e.multiLineString=l,e.multiPoint=u,e.multiPolygon=h,e.geometryCollection=function(t,e,r){return void 0===r&&(r={}),n({type:"GeometryCollection",geometries:t},e,r)},e.round=function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(t*r)/r},e.radiansToLength=c,e.lengthToRadians=f,e.lengthToDegrees=function(t,e){return p(f(t,e))},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},e.radiansToDegrees=p,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(f(t,e),r)},e.convertArea=function(t,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[r];if(!i)throw new Error("invalid original units");var o=e.areaFactors[n];if(!o)throw new Error("invalid final units");return t/i*o},e.isNumber=d,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!d(t))throw new Error("bbox must only contain numbers")})},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")},e.radians2degrees=function(){throw new Error("method has been renamed to `radiansToDegrees`")},e.degrees2radians=function(){throw new Error("method has been renamed to `degreesToRadians`")},e.distanceToDegrees=function(){throw new Error("method has been renamed to `lengthToDegrees`")},e.distanceToRadians=function(){throw new Error("method has been renamed to `lengthToRadians`")},e.radiansToDistance=function(){throw new Error("method has been renamed to `radiansToLength`")},e.bearingToAngle=function(){throw new Error("method has been renamed to `bearingToAzimuth`")},e.convertDistance=function(){throw new Error("method has been renamed to `convertLength`")}},function(t,e,r){var n=r(16)(Object,"create");t.exports=n},function(t,e,r){var n=r(69);t.exports=function(t,e){for(var r=t.length;r--;)if(n(t[r][0],e))return r;return-1}},function(t,e,r){var n=r(75);t.exports=function(t,e){var r=t.__data__;return n(e)?r["string"==typeof e?"string":"hash"]:r.map}},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){var n=r(15),i=r(48),o="[object Symbol]";t.exports=function(t){return"symbol"==typeof t||i(t)&&n(t)==o}},function(t,e,r){var n=r(9).Symbol;t.exports=n},function(t,e,r){var n=r(44),i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")();t.exports=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n={_initSnappableMarkers:function(){this.options.snapDistance=this.options.snapDistance||30,this._assignEvents(this._markers),this._layer.off("pm:dragstart",this._unsnap,this),this._layer.on("pm:dragstart",this._unsnap,this)},_assignEvents:function(t){var e=this;t.forEach(function(t){Array.isArray(t)?e._assignEvents(t):(t.off("drag",e._handleSnapping,e),t.on("drag",e._handleSnapping,e),t.off("dragend",e._cleanupSnapping,e),t.on("dragend",e._cleanupSnapping,e))})},_unsnap:function(){delete this._snapLatLng},_cleanupSnapping:function(){delete this._snapList,this._map.off("pm:remove",this._handleSnapLayerRemoval,this),this.debugIndicatorLines&&this.debugIndicatorLines.forEach(function(t){t.remove()})},_handleSnapLayerRemoval:function(t){var e=t.layer,r=this._snapList.findIndex(function(t){return t._leaflet_id===e._leaflet_id});this._snapList.splice(r,1)},_handleSnapping:function(t){var e=this;if(t.originalEvent.altKey)return!1;if(this._snapList===undefined&&this._createSnapList(t),this._snapList.length<=0)return!1;var r,n=t.target,i=this._calcClosestLayer(n.getLatLng(),this._snapList),o=i.layer instanceof L.Marker||i.layer instanceof L.CircleMarker;r=o?i.latlng:this._checkPrioritiySnapping(i);var a=this.options.snapDistance,s={marker:n,snapLatLng:r,segment:i.segment,layer:this._layer,layerInteractedWith:i.layer};if(i.distance<a){n.setLatLng(r),n._snapped=!0;var l=this._snapLatLng||{},u=r||{};l.lat===u.lat&&l.lng===u.lng||(e._snapLatLng=r,n.fire("pm:snap",s),e._layer.fire("pm:snap",s))}else this._snapLatLng&&(this._unsnap(s),n._snapped=!1,s.marker.fire("pm:unsnap",s),this._layer.fire("pm:unsnap",s));return!0},_checkPrioritiySnapping:function(t){var e,r=this._map,n=t.segment[0],i=t.segment[1],o=t.latlng,a=this._getDistance(r,n,o),s=this._getDistance(r,i,o),l=a<s?n:i;return e=(a<s?a:s)<this.options.snapDistance?l:o,Object.assign({},e)},_createSnapList:function(){var t=this,e=[],r=[],n=this._map;n.off("pm:remove",this._handleSnapLayerRemoval,this),n.on("pm:remove",this._handleSnapLayerRemoval,this),n.eachLayer(function(t){if(t instanceof L.Polyline||t instanceof L.Marker||t instanceof L.CircleMarker){e.push(t);var n=L.polyline([],{color:"red",pmIgnore:!0});r.push(n)}}),e=(e=(e=e.filter(function(e){return t._layer!==e})).filter(function(t){return t._latlng||t._latlngs&&t._latlngs.length>0})).filter(function(t){return!t._pmTempLayer}),this._otherSnapLayers?this._snapList=e.concat(this._otherSnapLayers):this._snapList=e,this.debugIndicatorLines=r},_calcClosestLayer:function(t,e){var r=this,n={};return e.forEach(function(e,i){var o=r._calcLayerDistances(t,e);r.debugIndicatorLines[i].setLatLngs([t,o.latlng]),(n.distance===undefined||o.distance<n.distance)&&((n=o).layer=e)}),n},_calcLayerDistances:function(t,e){var r=this,n=this._map,i=e instanceof L.Marker||e instanceof L.CircleMarker,o=e instanceof L.Polygon,a=t,s=i?e.getLatLng():e.getLatLngs();if(i)return{latlng:Object.assign({},s),distance:this._getDistance(n,s,a)};var l,u;!function c(t){t.forEach(function(e,i){if(Array.isArray(e))c(e);else{var s,h=e;s=o?i+1===t.length?0:i+1:i+1===t.length?undefined:i+1;var f=t[s];if(f){var p=r._getDistanceToSegment(n,a,h,f);(u===undefined||p<u)&&(u=p,l=[h,f])}}})}(s);var h=this._getClosestPointOnSegment(n,t,l[0],l[1]);return{latlng:Object.assign({},h),segment:l,distance:u}},_getClosestPointOnSegment:function(t,e,r,n){var i=t.getMaxZoom();i===Infinity&&(i=t.getZoom());var o=t.project(e,i),a=t.project(r,i),s=t.project(n,i),l=L.LineUtil.closestPointOnSegment(o,a,s);return t.unproject(l,i)},_getDistanceToSegment:function(t,e,r,n){var i=t.latLngToLayerPoint(e),o=t.latLngToLayerPoint(r),a=t.latLngToLayerPoint(n);return L.LineUtil.pointToSegmentDistance(i,o,a)},_getDistance:function(t,e,r){return t.latLngToLayerPoint(e).distanceTo(t.latLngToLayerPoint(r))}};e["default"]=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2);e["default"]=function(t){var e,r,i={type:"FeatureCollection",features:[]};if("LineString"===(r="Feature"===t.type?t.geometry:t).type)e=[r.coordinates];else if("MultiLineString"===r.type)e=r.coordinates;else if("MultiPolygon"===r.type)e=[].concat.apply([],r.coordinates);else{if("Polygon"!==r.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=r.coordinates}return e.forEach(function(t){e.forEach(function(e){for(var r=0;r<t.length-1;r++)for(var o=r;o<e.length-1;o++){if(t===e){if(1===Math.abs(r-o))continue;if(0===r&&o===t.length-2&&t[r][0]===t[t.length-1][0]&&t[r][1]===t[t.length-1][1])continue}var a=function(t,e,r,n,i,o,a,s){var l,u,h,c,f,p={x:null,y:null,onLine1:!1,onLine2:!1};return 0==(l=(s-o)*(r-t)-(a-i)*(n-e))?null!==p.x&&null!==p.y&&p:(u=e-o,h=t-i,c=(a-i)*u-(s-o)*h,f=(r-t)*u-(n-e)*h,u=c/l,h=f/l,p.x=t+u*(r-t),p.y=e+u*(n-e),u>=0&&u<=1&&(p.onLine1=!0),h>=0&&h<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y])}(t[r][0],t[r][1],t[r+1][0],t[r+1][1],e[o][0],e[o][1],e[o+1][0],e[o+1][1]);a&&i.features.push(n.point([a[0],a[1]]))}})}),i}},function(t,e,r){"use strict";function n(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function i(t,e,r){void 0===r&&(r={});return n({type:"Point",coordinates:t},e,r)}function o(t,e,r){void 0===r&&(r={});for(var i=0,o=t;i<o.length;i++){var a=o[i];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:t},e,r)}function a(t,e,r){if(void 0===r&&(r={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:t},e,r)}function s(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function l(t,e,r){void 0===r&&(r={});return n({type:"MultiLineString",coordinates:t},e,r)}function u(t,e,r){void 0===r&&(r={});return n({type:"MultiPoint",coordinates:t},e,r)}function h(t,e,r){void 0===r&&(r={});return n({type:"MultiPolygon",coordinates:t},e,r)}function c(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t*n}function f(t,r){void 0===r&&(r="kilometers");var n=e.factors[r];if(!n)throw new Error(r+" units is invalid");return t/n}function p(t){return 180*(t%(2*Math.PI))/Math.PI}function d(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.earthRadius=6371008.8,e.factors={centimeters:100*e.earthRadius,centimetres:100*e.earthRadius,degrees:e.earthRadius/111325,feet:3.28084*e.earthRadius,inches:39.37*e.earthRadius,kilometers:e.earthRadius/1e3,kilometres:e.earthRadius/1e3,meters:e.earthRadius,metres:e.earthRadius,miles:e.earthRadius/1609.344,millimeters:1e3*e.earthRadius,millimetres:1e3*e.earthRadius,nauticalmiles:e.earthRadius/1852,radians:1,yards:e.earthRadius/1.0936},e.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e.earthRadius,yards:1/1.0936},e.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:3.86e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046},e.feature=n,e.geometry=function(t,e,r){switch(void 0===r&&(r={}),t){case"Point":return i(e).geometry;case"LineString":return a(e).geometry;case"Polygon":return o(e).geometry;case"MultiPoint":return u(e).geometry;case"MultiLineString":return l(e).geometry;case"MultiPolygon":return h(e).geometry;default:throw new Error(t+" is invalid")}},e.point=i,e.points=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return i(t,e)}),r)},e.polygon=o,e.polygons=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return o(t,e)}),r)},e.lineString=a,e.lineStrings=function(t,e,r){return void 0===r&&(r={}),s(t.map(function(t){return a(t,e)}),r)},e.featureCollection=s,e.multiLineString=l,e.multiPoint=u,e.multiPolygon=h,e.geometryCollection=function(t,e,r){return void 0===r&&(r={}),n({type:"GeometryCollection",geometries:t},e,r)},e.round=function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(t*r)/r},e.radiansToLength=c,e.lengthToRadians=f,e.lengthToDegrees=function(t,e){return p(f(t,e))},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},e.radiansToDegrees=p,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(f(t,e),r)},e.convertArea=function(t,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[r];if(!i)throw new Error("invalid original units");var o=e.areaFactors[n];if(!o)throw new Error("invalid final units");return t/i*o},e.isNumber=d,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!d(t))throw new Error("bbox must only contain numbers")})},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")},e.radians2degrees=function(){throw new Error("method has been renamed to `radiansToDegrees`")},e.degrees2radians=function(){throw new Error("method has been renamed to `degreesToRadians`")},e.distanceToDegrees=function(){throw new Error("method has been renamed to `lengthToDegrees`")},e.distanceToRadians=function(){throw new Error("method has been renamed to `lengthToRadians`")},e.radiansToDistance=function(){throw new Error("method has been renamed to `radiansToLength`")},e.bearingToAngle=function(){throw new Error("method has been renamed to `bearingToAzimuth`")},e.convertDistance=function(){throw new Error("method has been renamed to `convertLength`")}},function(t,e,r){var n;!function(e){t.exports=e()}(function(){return function t(e,r,i){function o(s,l){if(!r[s]){if(!e[s]){if(!l&&("function"==typeof n&&n))return n(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return o(r||t)},h,h.exports,t,e,r,i)}return r[s].exports}for(var a="function"==typeof n&&n,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,e,r){"use strict";var n=t("./src/index"),i={union:n.union,diff:n.diff,xor:n.xor,intersection:n.intersection};i["default"]=i,e.exports=i},{"./src/index":12}],2:[function(t,e,r){!function(t,n){"object"==typeof r&&void 0!==e?e.exports=n():t.avl=n()}(this,function(){"use strict";function t(e,r,n,i,o){if(e){i(r+(n?"└── ":"├── ")+o(e)+"\n");var a=r+(n?" ":"│ ");e.left&&t(e.left,a,!1,i,o),e.right&&t(e.right,a,!0,i,o)}}function e(t){if(null===t)return!0;var n=r(t.left),i=r(t.right);return!!(Math.abs(n-i)<=1&&e(t.left)&&e(t.right))}function r(t){return t?1+Math.max(r(t.left),r(t.right)):0}function n(t){var e=t.right;return t.right=e.left,e.left&&(e.left.parent=t),e.parent=t.parent,e.parent&&(e.parent.left===t?e.parent.left=e:e.parent.right=e),t.parent=e,e.left=t,t.balanceFactor+=1,e.balanceFactor<0&&(t.balanceFactor-=e.balanceFactor),e.balanceFactor+=1,t.balanceFactor>0&&(e.balanceFactor+=t.balanceFactor),e}function i(t){var e=t.left;return t.left=e.right,t.left&&(t.left.parent=t),e.parent=t.parent,e.parent&&(e.parent.left===t?e.parent.left=e:e.parent.right=e),t.parent=e,e.right=t,t.balanceFactor-=1,e.balanceFactor>0&&(t.balanceFactor-=e.balanceFactor),e.balanceFactor-=1,t.balanceFactor<0&&(e.balanceFactor+=t.balanceFactor),e}var o=function(t,e){void 0===e&&(e=!1),this._comparator=t||function(t,e){return t>e?1:t<e?-1:0},this._root=null,this._size=0,this._noDuplicates=!!e},a={size:{}};return o.prototype.destroy=function(){return this._root=null,this},a.size.get=function(){return this._size},o.prototype.contains=function(t){if(this._root)for(var e=this._root,r=this._comparator;e;){var n=r(t,e.key);if(0===n)return!0;e=n<0?e.left:e.right}return!1},o.prototype.next=function(t){var e=t;if(e)if(e.right)for(e=e.right;e&&e.left;)e=e.left;else for(e=t.parent;e&&e.right===t;)t=e,e=e.parent;return e},o.prototype.prev=function(t){var e=t;if(e)if(e.left)for(e=e.left;e&&e.right;)e=e.right;else for(e=t.parent;e&&e.left===t;)t=e,e=e.parent;return e},o.prototype.forEach=function(t){for(var e=this._root,r=[],n=!1,i=0;!n;)e?(r.push(e),e=e.left):r.length>0?(t(e=r.pop(),i++),e=e.right):n=!0;return this},o.prototype.keys=function(){for(var t=this._root,e=[],r=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),r.push(t.key),t=t.right):n=!0;return r},o.prototype.values=function(){for(var t=this._root,e=[],r=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),r.push(t.data),t=t.right):n=!0;return r},o.prototype.at=function(t){for(var e=this._root,r=[],n=!1,i=0;!n;)if(e)r.push(e),e=e.left;else if(r.length>0){if(e=r.pop(),i===t)return e;i++,e=e.right}else n=!0;return null},o.prototype.minNode=function(){var t=this._root;if(!t)return null;for(;t.left;)t=t.left;return t},o.prototype.maxNode=function(){var t=this._root;if(!t)return null;for(;t.right;)t=t.right;return t},o.prototype.min=function(){var t=this._root;if(!t)return null;for(;t.left;)t=t.left;return t.key},o.prototype.max=function(){var t=this._root;if(!t)return null;for(;t.right;)t=t.right;return t.key},o.prototype.isEmpty=function(){return!this._root},o.prototype.pop=function(){var t=this._root,e=null;if(t){for(;t.left;)t=t.left;e={key:t.key,data:t.data},this.remove(t.key)}return e},o.prototype.find=function(t){for(var e,r=this._root,n=this._comparator;r;){if(0===(e=n(t,r.key)))return r;r=e<0?r.left:r.right}return null},o.prototype.insert=function(t,e){var r=this;if(!this._root)return this._root={parent:null,left:null,right:null,balanceFactor:0,key:t,data:e},this._size++,this._root;var o=this._comparator,a=this._root,s=null,l=0;if(this._noDuplicates)for(;a;){if(l=o(t,a.key),s=a,0===l)return null;a=l<0?a.left:a.right}else for(;a;)s=a,a=(l=o(t,a.key))<=0?a.left:a.right;var u,h={left:null,right:null,balanceFactor:0,parent:s,key:t,data:e};for(l<=0?s.left=h:s.right=h;s&&((l=o(s.key,t))<0?s.balanceFactor-=1:s.balanceFactor+=1,0!==s.balanceFactor);){if(s.balanceFactor<-1){1===s.right.balanceFactor&&i(s.right),u=n(s),s===r._root&&(r._root=u);break}if(s.balanceFactor>1){-1===s.left.balanceFactor&&n(s.left),u=i(s),s===r._root&&(r._root=u);break}s=s.parent}return this._size++,h},o.prototype.remove=function(t){var e=this;if(!this._root)return null;for(var r=this._root,o=this._comparator,a=0;r&&0!==(a=o(t,r.key));)r=a<0?r.left:r.right;if(!r)return null;var s,l,u=r.key;if(r.left){for(s=r.left;s.left||s.right;){for(;s.right;)s=s.right;r.key=s.key,r.data=s.data,s.left&&(r=s,s=s.left)}r.key=s.key,r.data=s.data,r=s}if(r.right){for(l=r.right;l.left||l.right;){for(;l.left;)l=l.left;r.key=l.key,r.data=l.data,l.right&&(r=l,l=l.right)}r.key=l.key,r.data=l.data,r=l}for(var h,c=r.parent,f=r;c&&(c.left===f?c.balanceFactor-=1:c.balanceFactor+=1,c.balanceFactor<-1?(1===c.right.balanceFactor&&i(c.right),h=n(c),c===e._root&&(e._root=h),c=h):c.balanceFactor>1&&(-1===c.left.balanceFactor&&n(c.left),h=i(c),c===e._root&&(e._root=h),c=h),-1!==c.balanceFactor&&1!==c.balanceFactor);)f=c,c=c.parent;return r.parent&&(r.parent.left===r?r.parent.left=null:r.parent.right=null),r===this._root&&(this._root=null),this._size--,u},o.prototype.load=function(t,e){var r=this;if(void 0===t&&(t=[]),void 0===e&&(e=[]),Array.isArray(t))for(var n=0,i=t.length;n<i;n++)r.insert(t[n],e[n]);return this},o.prototype.isBalanced=function(){return e(this._root)},o.prototype.toString=function(e){return function(e,r){void 0===r&&(r=function(t){return t.key});var n=[];return t(e,"",!0,function(t){return n.push(t)},r),n.join("")}(this._root,e)},Object.defineProperties(o.prototype,a),o})},{}],3:[function(t,e,r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||function(t,e){return t<e?-1:t>e?1:0},this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}e.exports=n,e.exports["default"]=n,n.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0===this.length)return undefined;var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,o=e[i];if(r(n,o)>=0)break;e[t]=o,t=i}e[t]=n},_down:function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t<n;){var o=1+(t<<1),a=o+1,s=e[o];if(a<this.length&&r(e[a],s)<0&&(o=a,s=e[a]),r(s,i)>=0)break;e[t]=s,t=o}e[t]=i}}},{}],4:[function(t,e,r){"use strict";var n=t("./signed_area");e.exports=function(t,e){var r=t.point,i=e.point;return r[0]>i[0]?1:r[0]<i[0]?-1:r[1]!==i[1]?r[1]>i[1]?1:-1:function(t,e,r,i){return t.left!==e.left?t.left?1:-1:0!==n(r,t.otherEvent.point,e.otherEvent.point)?t.isBelow(e.otherEvent.point)?-1:1:!t.isSubject&&e.isSubject?1:-1}(t,e,r)}},{"./signed_area":16}],5:[function(t,e,r){"use strict";var n=t("./signed_area"),i=t("./compare_events"),o=t("./equals");e.exports=function(t,e){if(t===e)return 0;if(0!==n(t.point,t.otherEvent.point,e.point)||0!==n(t.point,t.otherEvent.point,e.otherEvent.point))return o(t.point,e.point)?t.isBelow(e.otherEvent.point)?-1:1:t.point[0]===e.point[0]?t.point[1]<e.point[1]?-1:1:1===i(t,e)?e.isAbove(t.point)?-1:1:t.isBelow(e.point)?-1:1;if(t.isSubject!==e.isSubject)return t.isSubject?-1:1;var r=t.point,a=e.point;return r[0]===a[0]&&r[1]===a[1]?(r=t.otherEvent.point,a=e.otherEvent.point,r[0]===a[0]&&r[1]===a[1]?0:t.contourId>e.contourId?1:-1):1===i(t,e)?1:-1}},{"./compare_events":4,"./equals":10,"./signed_area":16}],6:[function(t,e,r){"use strict";function n(t,e){switch(t.type){case i.NORMAL:switch(e){case a:return!t.otherInOut;case s:return t.otherInOut;case l:return t.isSubject&&t.otherInOut||!t.isSubject&&!t.otherInOut;case u:return!0}break;case i.SAME_TRANSITION:return e===a||e===s;case i.DIFFERENT_TRANSITION:return e===l;case i.NON_CONTRIBUTING:return!1}return!1}var i=t("./edge_type"),o=t("./operation"),a=o.INTERSECTION,s=o.UNION,l=o.DIFFERENCE,u=o.XOR;e.exports=function(t,e,r){null===e?(t.inOut=!1,t.otherInOut=!0):(t.isSubject===e.isSubject?(t.inOut=!e.inOut,t.otherInOut=e.otherInOut):(t.inOut=!e.otherInOut,t.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(t.prevInResult=!n(e,r)||e.isVertical()?e.prevInResult:e)),t.inResult=n(t,r)}},{"./edge_type":9,"./operation":13}],7:[function(t,e,r){"use strict";function n(t,e,r,n){var i=t+1,o=e.length;if(i>o-1)return t-1;for(var a=e[t].point,s=e[i].point;i<o&&s[0]===a[0]&&s[1]===a[1];){if(!r[i])return i;s=e[++i].point}for(i=t-1;r[i]&&i>=n;)i--;return i}var i=t("./compare_events"),o=t("./operation");e.exports=function(t,e){var r,a,s,l=function(t){var e,r,n,o,a=[];for(r=0,n=t.length;r<n;r++)((e=t[r]).left&&e.inResult||!e.left&&e.otherEvent.inResult)&&a.push(e);for(var s=!1;!s;)for(s=!0,r=0,n=a.length;r<n;r++)r+1<n&&1===i(a[r],a[r+1])&&(o=a[r],a[r]=a[r+1],a[r+1]=o,s=!1);for(r=0,n=a.length;r<n;r++)(e=a[r]).pos=r,e.left||(o=e.pos,e.pos=e.otherEvent.pos,e.otherEvent.pos=o);return a}(t),u={},h=[];for(r=0,a=l.length;r<a;r++)if(!u[r]){var c=[[]];l[r].isExteriorRing?e===o.DIFFERENCE&&!l[r].isSubject&&h.length>1?h[h.length-1].push(c[0]):h.push(c):e!==o.DIFFERENCE||l[r].isSubject||0!==h.length?0===h.length?h.push([[c]]):h[h.length-1].push(c[0]):h.push(c);var f=h.length-1,p=r,d=l[r].point;for(c[0].push(d);p>=r;)s=l[p],u[p]=!0,s.left?(s.resultInOut=!1,s.contourId=f):(s.otherEvent.resultInOut=!0,s.otherEvent.contourId=f),u[p=s.pos]=!0,c[0].push(l[p].point),p=n(p,l,u,r);s=l[p=-1===p?r:p],u[p]=u[s.pos]=!0,s.otherEvent.resultInOut=!0,s.otherEvent.contourId=f}return h}},{"./compare_events":4,"./operation":13}],8:[function(t,e,r){"use strict";var n=t("./sweep_event"),i=t("./equals"),o=t("./compare_events");e.exports=function(t,e,r){var a=new n(e,!1,t,t.isSubject),s=new n(e,!0,t.otherEvent,t.isSubject);return i(t.point,t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",t),a.contourId=s.contourId=t.contourId,o(s,t.otherEvent)>0&&(t.otherEvent.left=!0,s.left=!1),t.otherEvent.otherEvent=s,t.otherEvent=a,r.push(s),r.push(a),r}},{"./compare_events":4,"./equals":10,"./sweep_event":18}],9:[function(t,e,r){"use strict";e.exports={NORMAL:0,NON_CONTRIBUTING:1,SAME_TRANSITION:2,DIFFERENT_TRANSITION:3}},{}],10:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]}},{}],11:[function(t,e,r){"use strict";function n(t,e,r,n,i,s){var h,c,f,p,d,g;for(h=0,c=t.length-1;h<c;h++)if(f=t[h],p=t[h+1],d=new o(f,!1,undefined,e),g=new o(p,!1,d,e),d.otherEvent=g,f[0]!==p[0]||f[1]!==p[1]){d.contourId=g.contourId=r,s||(d.isExteriorRing=!1,g.isExteriorRing=!1),a(d,g)>0?g.left=!0:d.left=!0;var _=f[0],m=f[1];i[0]=u(i[0],_),i[1]=u(i[1],m),i[2]=l(i[2],_),i[3]=l(i[3],m),n.push(d),n.push(g)}}var i=t("tinyqueue"),o=t("./sweep_event"),a=t("./compare_events"),s=t("./operation"),l=Math.max,u=Math.min,h=0;e.exports=function(t,e,r,o,l){var u,c,f,p,d,g,_=new i(null,a);for(f=0,p=t.length;f<p;f++)for(d=0,g=(u=t[f]).length;d<g;d++)(c=0===d)&&h++,n(u[d],!0,h,_,r,c);for(f=0,p=e.length;f<p;f++)for(d=0,g=(u=e[f]).length;d<g;d++)c=0===d,l===s.DIFFERENCE&&(c=!1),c&&h++,n(u[d],!1,h,_,o,c);return _}},{"./compare_events":4,"./operation":13,"./sweep_event":18,tinyqueue:3}],12:[function(t,e,r){"use strict";function n(t,e,r){"number"==typeof t[0][0][0]&&(t=[t]),"number"==typeof e[0][0][0]&&(e=[e]);var n=function(t,e,r){var n=null;return t.length*e.length==0&&(r===s.INTERSECTION?n=l:r===s.DIFFERENCE?n=t:r!==s.UNION&&r!==s.XOR||(n=0===t.length?e:t)),n}(t,e,r);if(n)return n===l?null:n;var u=[Infinity,Infinity,-Infinity,-Infinity],h=[Infinity,Infinity,-Infinity,-Infinity],c=a(t,e,u,h,r);if(n=function(t,e,r,n,i){var o=null;return(r[0]>n[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(i===s.INTERSECTION?o=l:i===s.DIFFERENCE?o=t:i!==s.UNION&&i!==s.XOR||(o=t.concat(e))),o}(t,e,u,h,r))return n===l?null:n;var f=i(c,t,e,u,h,r);return o(f,r)}var i=t("./subdivide_segments"),o=t("./connect_edges"),a=t("./fill_queue"),s=t("./operation"),l=[];n.union=function(t,e){return n(t,e,s.UNION)},n.diff=function(t,e){return n(t,e,s.DIFFERENCE)},n.xor=function(t,e){return n(t,e,s.XOR)},n.intersection=function(t,e){return n(t,e,s.INTERSECTION)},n.operations=s,e.exports=n,e.exports["default"]=n},{"./connect_edges":7,"./fill_queue":11,"./operation":13,"./subdivide_segments":17}],13:[function(t,e,r){"use strict";e.exports={INTERSECTION:0,UNION:1,DIFFERENCE:2,XOR:3}},{}],14:[function(t,e,r){"use strict";var n=t("./divide_segment"),i=t("./segment_intersection"),o=t("./equals"),a=t("./compare_events"),s=t("./edge_type");e.exports=function(t,e,r){var l=i(t.point,t.otherEvent.point,e.point,e.otherEvent.point),u=l?l.length:0;if(0===u)return 0;if(1===u&&(o(t.point,e.point)||o(t.otherEvent.point,e.otherEvent.point)))return 0;if(2===u&&t.isSubject===e.isSubject)return 0;if(1===u)return o(t.point,l[0])||o(t.otherEvent.point,l[0])||n(t,l[0],r),o(e.point,l[0])||o(e.otherEvent.point,l[0])||n(e,l[0],r),1;var h=[],c=!1,f=!1;return o(t.point,e.point)?c=!0:1===a(t,e)?h.push(e,t):h.push(t,e),o(t.otherEvent.point,e.otherEvent.point)?f=!0:1===a(t.otherEvent,e.otherEvent)?h.push(e.otherEvent,t.otherEvent):h.push(t.otherEvent,e.otherEvent),c&&f||c?(e.type=s.NON_CONTRIBUTING,t.type=e.inOut===t.inOut?s.SAME_TRANSITION:s.DIFFERENT_TRANSITION,c&&!f&&n(h[1].otherEvent,h[0].point,r),2):f?(n(h[0],h[1].point,r),3):h[0]!==h[3].otherEvent?(n(h[0],h[1].point,r),n(h[1],h[2].point,r),3):(n(h[0],h[1].point,r),n(h[3].otherEvent,h[2].point,r),3)}},{"./compare_events":4,"./divide_segment":8,"./edge_type":9,"./equals":10,"./segment_intersection":15}],15:[function(t,e,r){"use strict";function n(t,e){return t[0]*e[1]-t[1]*e[0]}function i(t,e){return t[0]*e[0]+t[1]*e[1]}e.exports=function(t,e,r,o,a){function s(t,e,r){return[t[0]+e*r[0],t[1]+e*r[1]]}var l=[e[0]-t[0],e[1]-t[1]],u=[o[0]-r[0],o[1]-r[1]],h=[r[0]-t[0],r[1]-t[1]],c=n(l,u),f=c*c,p=i(l,l);if(f>1e-9*p*i(u,u)){var d=n(h,u)/c;if(d<0||d>1)return null;var g=n(h,l)/c;return g<0||g>1?null:a?null:[s(t,d,l)]}var _=i(h,h);if(c=n(h,l),(f=c*c)>1e-9*p*_)return null;var m=i(l,h)/p,y=m+i(l,u)/p,v=Math.min(m,y),b=Math.max(m,y);return v<=1&&b>=0?1===v?a?null:[s(t,v>0?v:0,l)]:0===b?a?null:[s(t,b<1?b:1,l)]:a&&0===v&&1===b?null:[s(t,v>0?v:0,l),s(t,b<1?b:1,l)]:null}},{}],16:[function(t,e,r){"use strict";e.exports=function(t,e,r){return(t[0]-r[0])*(e[1]-r[1])-(e[0]-r[0])*(t[1]-r[1])}},{}],17:[function(t,e,r){"use strict";var n=t("avl"),i=t("./compute_fields"),o=t("./possible_intersection"),a=t("./compare_segments"),s=t("./operation");e.exports=function(t,e,r,l,u,h){for(var c,f,p,d=new n(a),g=[],_=Math.min(l[2],u[2]),m=s.INTERSECTION,y=s.DIFFERENCE;t.length;){var v=t.pop();if(g.push(v),h===m&&v.point[0]>_||h===y&&v.point[0]>l[2])break;if(v.left){f=c=d.insert(v),c=c!==(p=d.minNode())?d.prev(c):null,f=d.next(f);var b,L=c?c.key:null;if(i(v,L,h),f&&2===o(v,f.key,t)&&(i(v,L,h),i(v,f.key,h)),c&&2===o(c.key,v,t)){var k=c;b=(k=k!==p?d.prev(k):null)?k.key:null,i(L,b,h),i(v,L,h)}}else v=v.otherEvent,f=c=d.find(v),c&&f&&(c=c!==p?d.prev(c):null,f=d.next(f),d.remove(v),f&&c&&o(c.key,f.key,t))}return g}},{"./compare_segments":5,"./compute_fields":6,"./operation":13,"./possible_intersection":14,avl:2}],18:[function(t,e,r){"use strict";function n(t,e,r,n,o){this.left=e,this.point=t,this.otherEvent=r,this.isSubject=n,this.type=o||i.NORMAL,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.inResult=!1,this.resultInOut=!1,this.isExteriorRing=!0}var i=t("./edge_type");n.prototype={isBelow:function(t){var e=this.point,r=this.otherEvent.point;return this.left?(e[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(e[1]-t[1])>0:(r[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(r[1]-t[1])>0},isAbove:function(t){return!this.isBelow(t)},isVertical:function(){return this.point[0]===this.otherEvent.point[0]},clone:function(){var t=new n(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.inResult=this.inResult,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t}},e.exports=n},{"./edge_type":9}]},{},[1])(1)})},function(t,e,r){"use strict";function n(t,e,r){if(null!==t)for(var i,o,a,s,l,u,h,c,f=0,p=0,d=t.type,g="FeatureCollection"===d,_="Feature"===d,m=g?t.features.length:1,y=0;y<m;y++){l=(c=!!(h=g?t.features[y].geometry:_?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var v=0;v<l;v++){var b=0,L=0;if(null!==(s=c?h.geometries[v]:h)){u=s.coordinates;var k=s.type;switch(f=!r||"Polygon"!==k&&"MultiPolygon"!==k?0:1,k){case null:break;case"Point":if(!1===e(u,p,y,b,L))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++){if(!1===e(u[i],p,y,b,L))return!1;p++,"MultiPoint"===k&&b++}"LineString"===k&&b++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(o=0;o<u[i].length-f;o++){if(!1===e(u[i][o],p,y,b,L))return!1;p++}"MultiLineString"===k&&b++,"Polygon"===k&&L++}"Polygon"===k&&b++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for(L=0,o=0;o<u[i].length;o++){for(a=0;a<u[i][o].length-f;a++){if(!1===e(u[i][o][a],p,y,b,L))return!1;p++}L++}b++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===n(s.geometries[i],e,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(t,e){var r;switch(t.type){case"FeatureCollection":for(r=0;r<t.features.length&&!1!==e(t.features[r].properties,r);r++);break;case"Feature":e(t.properties,0)}}function o(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var r=0;r<t.features.length&&!1!==e(t.features[r],r);r++);}function a(t,e){var r,n,i,o,a,s,l,u,h,c,f=0,p="FeatureCollection"===t.type,d="Feature"===t.type,g=p?t.features.length:1;for(r=0;r<g;r++){for(s=p?t.features[r].geometry:d?t.geometry:t,u=p?t.features[r].properties:d?t.properties:{},h=p?t.features[r].bbox:d?t.bbox:undefined,c=p?t.features[r].id:d?t.id:undefined,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=l?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,f,u,h,c))return!1;break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===e(o.geometries[n],f,u,h,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,f,u,h,c))return!1;f++}}function s(t,e){a(t,function(t,r,n,i,o){var a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":if(!1===e(h.feature(t,n,{bbox:i,id:o}),r,0))return!1;return}var s;switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<t.coordinates.length;l++){var u={type:s,coordinates:t.coordinates[l]};if(!1===e(h.feature(u,n),r,l))return!1}})}function l(t,e){s(t,function(t,r,i){var o=0;if(t.geometry){var a=t.geometry.type;if("Point"!==a&&"MultiPoint"!==a){var s,l=0,u=0,c=0;return!1!==n(t,function(n,a,f,p,d){if(s===undefined||r>l||p>u||d>c)return s=n,l=r,u=p,c=d,void(o=0);var g=h.lineString([s,n],t.properties);if(!1===e(g,r,i,d,o))return!1;o++,s=n})&&void 0}}})}function u(t,e){if(!t)throw new Error("geojson is required");s(t,function(t,r,n){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,r,n,0,0))return!1;break;case"Polygon":for(var a=0;a<o.length;a++)if(!1===e(h.lineString(o[a],t.properties),r,n,a))return!1}}})}Object.defineProperty(e,"__esModule",{value:!0});var h=r(2);e.coordEach=n,e.coordReduce=function(t,e,r,i){var o=r;return n(t,function(t,n,i,a,s){o=0===n&&r===undefined?t:e(o,t,n,i,a,s)},i),o},e.propEach=i,e.propReduce=function(t,e,r){var n=r;return i(t,function(t,i){n=0===i&&r===undefined?t:e(n,t,i)}),n},e.featureEach=o,e.featureReduce=function(t,e,r){var n=r;return o(t,function(t,i){n=0===i&&r===undefined?t:e(n,t,i)}),n},e.coordAll=function(t){var e=[];return n(t,function(t){e.push(t)}),e},e.geomEach=a,e.geomReduce=function(t,e,r){var n=r;return a(t,function(t,i,o,a,s){n=0===i&&r===undefined?t:e(n,t,i,o,a,s)}),n},e.flattenEach=s,e.flattenReduce=function(t,e,r){var n=r;return s(t,function(t,i,o){n=0===i&&0===o&&r===undefined?t:e(n,t,i,o)}),n},e.segmentEach=l,e.segmentReduce=function(t,e,r){var n=r,i=!1;return l(t,function(t,o,a,s,l){n=!1===i&&r===undefined?t:e(n,t,o,a,s,l),i=!0}),n},e.lineEach=u,e.lineReduce=function(t,e,r){var n=r;return u(t,function(t,i,o,a){n=0===i&&r===undefined?t:e(n,t,i,o,a)}),n},e.findSegment=function(t,e){if(e=e||{},!h.isObject(e))throw new Error("options is invalid");var r,n=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.segmentIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n),s=s||t.features[n].properties,r=t.features[n].geometry;break;case"Feature":s=s||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var l=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=l.length+a-1),h.lineString([l[a],l[a+1]],s,e);case"Polygon":return o<0&&(o=l.length+o),a<0&&(a=l[o].length+a-1),h.lineString([l[o][a],l[o][a+1]],s,e);case"MultiLineString":return i<0&&(i=l.length+i),a<0&&(a=l[i].length+a-1),h.lineString([l[i][a],l[i][a+1]],s,e);case"MultiPolygon":return i<0&&(i=l.length+i),o<0&&(o=l[i].length+o),a<0&&(a=l[i][o].length-a-1),h.lineString([l[i][o][a],l[i][o][a+1]],s,e)}throw new Error("geojson is invalid")},e.findPoint=function(t,e){if(e=e||{},!h.isObject(e))throw new Error("options is invalid");var r,n=e.featureIndex||0,i=e.multiFeatureIndex||0,o=e.geometryIndex||0,a=e.coordIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n),s=s||t.features[n].properties,r=t.features[n].geometry;break;case"Feature":s=s||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var l=r.coordinates;switch(r.type){case"Point":return h.point(l,s,e);case"MultiPoint":return i<0&&(i=l.length+i),h.point(l[i],s,e);case"LineString":return a<0&&(a=l.length+a),h.point(l[a],s,e);case"Polygon":return o<0&&(o=l.length+o),a<0&&(a=l[o].length+a),h.point(l[o][a],s,e);case"MultiLineString":return i<0&&(i=l.length+i),a<0&&(a=l[i].length+a),h.point(l[i][a],s,e);case"MultiPolygon":return i<0&&(i=l.length+i),o<0&&(o=l[i].length+o),a<0&&(a=l[i][o].length-a),h.point(l[i][o][a],s,e)}throw new Error("geojson is invalid")}},function(t,e,r){var n=r(8),i=r(46),o=r(47),a="[object Null]",s="[object Undefined]",l=n?n.toStringTag:undefined;t.exports=function(t){return null==t?t===undefined?s:a:l&&l in Object(t)?i(t):o(t)}},function(t,e,r){var n=r(56),i=r(61);t.exports=function(t,e){var r=i(t,e);return n(r)?r:undefined}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,r){t.exports=r(19)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}r(20);var i=r(21),o=n(r(22)),a=n(r(23)),s=n(r(0));r(25),r(26),r(27),r(28),r(29),r(30);var l=n(r(1));r(37),r(38),r(39),r(83),r(84),r(85),r(86),r(87),L.PM=L.PM||{Map:o["default"],Toolbar:a["default"],Draw:s["default"],Edit:l["default"],version:i.version,initialize:function(){this.addInitHooks()},addInitHooks:function(){L.Map.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Map(this))}),L.LayerGroup.addInitHook(function(){this.pm=new L.PM.Edit.LayerGroup(this)}),L.Marker.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Edit.Marker(this))}),L.Polyline.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Edit.Line(this))}),L.Polygon.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Edit.Poly(this))}),L.Rectangle.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Edit.Rectangle(this))}),L.Circle.addInitHook(function(){this.options.pmIgnore||(this.pm=new L.PM.Edit.Circle(this))})}},L.PM.initialize()},function(t,e){Array.prototype.findIndex=Array.prototype.findIndex||function(t){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof t)throw new TypeError("callback must be a function");for(var e=Object(this),r=e.length>>>0,n=arguments[1],i=0;i<r;i++)if(t.call(n,e[i],i,e))return i;return-1},Array.prototype.find=Array.prototype.find||function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("callback must be a function");for(var e=Object(this),r=e.length>>>0,n=arguments[1],i=0;i<r;i++){var o=e[i];if(t.call(n,o,i,e))return o}},"function"!=typeof Object.assign&&(Object.assign=function(t){"use strict";if(null==t)throw new TypeError("Cannot convert undefined or null to object");t=Object(t);for(var e=1;e<arguments.length;e++){var r=arguments[e];if(null!=r)for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}),[Element.prototype,CharacterData.prototype,DocumentType.prototype].forEach(function(t){t.hasOwnProperty("remove")||Object.defineProperty(t,"remove",{configurable:!0,enumerable:!0,writable:!0,value:function(){this.parentNode.removeChild(this)}})})},function(t,e){t.exports={name:"leaflet.pm",version:"0.25.0",description:"A Leaflet Plugin For Editing Geometry Layers in Leaflet 1.0",keywords:["leaflet","polygon management","geometry editing","map data","map overlay","polygon","geojson","leaflet-draw","data-field-geojson","ui-leaflet-draw"],files:["dist"],main:"dist/leaflet.pm.min.js",dependencies:{"@turf/difference":"6.x","@turf/intersect":"6.x","@turf/kinks":"6.x",lodash:"^4.17.10"},devDependencies:{"@babel/core":"^7.0.0-beta.40","@babel/preset-env":"^7.0.0-beta.40","babel-loader":"^8.0.0-beta.0","css-loader":"^0.28.0",eslint:"^4.18.2","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.9.0","extract-text-webpack-plugin":"^3.0.2","file-loader":"^0.11.1",leaflet:"^1.3.1","style-loader":"^0.19.0",tape:"^4.9.0","tape-run":"^3.0.4","uglifyjs-webpack-plugin":"^1.1.0","url-loader":"^0.6.2",webpack:"^3.11.0"},peerDependencies:{leaflet:"^1.2.0"},scripts:{start:"npm run dev",dev:"./node_modules/.bin/webpack --config=webpack.dev.js",test:"browserify ./spec/test.spec.js | tape-run",build:"./node_modules/.bin/webpack --config=webpack.build.js",prepare:"npm run build"},repository:{type:"git",url:"git+https://github.com/codeofsumit/leaflet.pm.git"},author:{name:"Sumit Kumar",email:"sk@outlook.com",url:"http://twitter.com/TweetsOfSumit"},license:"MIT",bugs:{url:"https://github.com/codeofsumit/leaflet.pm/issues"},homepage:"https://leafletpm.now.sh"}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n=L.Class.extend({initialize:function(t){var e=this;this.map=t,this.Draw=new L.PM.Draw(t),this.Toolbar=new L.PM.Toolbar(t),this.map.on("layerremove",function(t){t.layer.pm&&!t.layer._pmTempLayer&&e.map.fire("pm:remove",t)}),this._globalRemovalMode=!1},addControls:function(t){this.Toolbar.addControls(t)},removeControls:function(){this.Toolbar.removeControls()},toggleControls:function(){this.Toolbar.toggleControls()},controlsVisible:function(){return this.Toolbar.isVisible},enableDraw:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"Poly",e=arguments.length>1?arguments[1]:undefined;this.Draw.enable(t,e)},disableDraw:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"Poly";this.Draw.disable(t)},setPathOptions:function(t){this.Draw.setPathOptions(t)},removeLayer:function(t){var e=t.target;e._layers||e.pm&&e.pm.dragging()||t.target.remove()},toggleGlobalRemovalMode:function(){var t=this;this.globalRemovalEnabled()?(this._globalRemovalMode=!1,this.map.eachLayer(function(e){e.off("click",t.removeLayer)})):(this._globalRemovalMode=!0,this.map.eachLayer(function(e){!e.pm||e.pm.options&&e.pm.options.preventMarkerRemoval||e.on("click",t.removeLayer)})),this.Toolbar.toggleButton("deleteLayer",this._globalRemovalMode)},globalRemovalEnabled:function(){return this._globalRemovalMode},globalEditEnabled:function(){return this._globalEditMode},enableGlobalEditMode:function(t){var e=[];this.map.eachLayer(function(t){(t instanceof L.Polyline||t instanceof L.Marker||t instanceof L.Circle)&&e.push(t)}),e=(e=e.filter(function(t){return!!t.pm})).filter(function(t){return!t._pmTempLayer}),this._globalEditMode=!0,e.forEach(function(e){e.pm.enable(t)}),this.Toolbar.toggleButton("editPolygon",this._globalEditMode),this._fireEditModeEvent(!0)},disableGlobalEditMode:function(){var t=[];this.map.eachLayer(function(e){(e instanceof L.Polyline||e instanceof L.Marker||e instanceof L.Circle)&&t.push(e)}),t=(t=t.filter(function(t){return!!t.pm})).filter(function(t){return!t._pmTempLayer}),this._globalEditMode=!1,t.forEach(function(t){t.pm.disable()}),this.Toolbar.toggleButton("editPolygon",this._globalEditMode),this._fireEditModeEvent(!1)},_fireEditModeEvent:function(t){this.map.fire("pm:globaleditmodetoggled",{enabled:t,map:this.map})},toggleGlobalEditMode:function(t){console.log("toggle global edit mode",t),this.globalEditEnabled()?this.disableGlobalEditMode():this.enableGlobalEditMode(t)}});e["default"]=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(24));L.Control.PMButton=n["default"];var i=L.Class.extend({options:{drawMarker:!0,drawPolygon:!0,drawPolyline:!0,drawCircle:!0,drawRectangle:!0,editMode:!0,cutPolygon:!0,dragPolygon:!1,removalMode:!0,position:"topleft"},initialize:function(t){this.map=t,this.buttons={},this.isVisible=!1,this.container=L.DomUtil.create("div","leaflet-pm-toolbar leaflet-bar leaflet-control"),this._defineButtons()},getButtons:function(){return this.buttons},addControls:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.options;"undefined"!=typeof t.editPolygon&&(t.editMode=t.editPolygon),"undefined"!=typeof t.deleteLayer&&(t.removalMode=t.deleteLayer),L.Util.setOptions(this,t),this._showHideButtons(),this.isVisible=!0},removeControls:function(){var t=this.getButtons();for(var e in t)t[e].remove();this.isVisible=!1},toggleControls:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.options;this.isVisible?this.removeControls():this.addControls(t)},_addButton:function(t,e){return this.buttons[t]=e,this.options[t]=this.options[t]||!1,this.buttons[t]},triggerClickOnToggledButtons:function(t){for(var e in this.buttons)this.buttons[e]!==t&&this.buttons[e].toggled()&&this.buttons[e]._triggerClick()},toggleButton:function(t,e){return"editPolygon"===t&&(t="editMode"),"deleteLayer"===t&&(t="removalMode"),this.triggerClickOnToggledButtons(this.buttons[t]),this.buttons[t].toggle(e)},_defineButtons:function(){var t=this,e={className:" leaflet-pm-icon-delete",onClick:function(){},afterClick:function(){t.map.pm.toggleGlobalRemovalMode()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},r={className:"leaflet-pm-icon-polygon",onClick:function(){},afterClick:function(){t.map.pm.Draw.Poly.toggle()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},n={className:"leaflet-pm-icon-cut",onClick:function(){},afterClick:function(){t.map.pm.Draw.Cut.toggle({snappable:!0,cursorMarker:!0,allowSelfIntersection:!1})},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},i={className:"leaflet-pm-icon-marker",onClick:function(){},afterClick:function(){t.map.pm.Draw.Marker.toggle()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},o={className:"leaflet-pm-icon-polyline",onClick:function(){},afterClick:function(){t.map.pm.Draw.Line.toggle()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},a={className:"leaflet-pm-icon-circle",onClick:function(){},afterClick:function(){t.map.pm.Draw.Circle.toggle()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},s={className:"leaflet-pm-icon-rectangle",onClick:function(){},afterClick:function(){t.map.pm.Draw.Rectangle.toggle()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},l={className:"leaflet-pm-icon-edit",onClick:function(){},afterClick:function(){t.map.pm.toggleGlobalEditMode()},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position},u={className:"leaflet-pm-icon-drag",onClick:function(){},afterClick:function(){},doToggle:!0,toggleStatus:!1,disableOtherButtons:!0,position:this.options.position};this._addButton("drawMarker",new L.Control.PMButton(i)),this._addButton("drawPolyline",new L.Control.PMButton(o)),this._addButton("drawRectangle",new L.Control.PMButton(s)),this._addButton("drawPolygon",new L.Control.PMButton(r)),this._addButton("drawCircle",new L.Control.PMButton(a)),this._addButton("cutPolygon",new L.Control.PMButton(n)),this._addButton("editMode",new L.Control.PMButton(l)),this._addButton("dragPolygon",new L.Control.PMButton(u)),this._addButton("removalMode",new L.Control.PMButton(e))},_showHideButtons:function(){this.removeControls();var t=this.getButtons();for(var e in t)this.options[e]&&(t[e].setPosition(this.options.position),t[e].addTo(this.map))}});e["default"]=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n=L.Control.extend({options:{position:"topleft"},initialize:function(t){this._button=L.Util.setOptions(this,t)},onAdd:function(t){return this._map=t,this._container=this._map.pm.Toolbar.container,this.buttonsDomNode=this._makeButton(this._button),this._container.appendChild(this.buttonsDomNode),this._container},onRemove:function(){return this.buttonsDomNode.remove(),this._container},getText:function(){return this._button.text},getIconUrl:function(){return this._button.iconUrl},destroy:function(){this._button={},this._update()},toggle:function(t){return this._button.toggleStatus="boolean"==typeof t?t:!this._button.toggleStatus,this._applyStyleClasses(),this._button.toggleStatus},toggled:function(){return this._button.toggleStatus},onCreate:function(){this.toggle(!1)},_triggerClick:function(t){this._button.onClick(t),this._clicked(t),this._button.afterClick(t)},_makeButton:function(t){var e=this,r=L.DomUtil.create("a","leaflet-buttons-control-button",this._container);t.toggleStatus&&L.DomUtil.addClass(r,"active");var n=L.DomUtil.create("div","control-icon",r);return t.iconUrl&&n.setAttribute("src",t.iconUrl),t.className&&L.DomUtil.addClass(n,t.className),L.DomEvent.addListener(r,"click",function(){e._button.disableOtherButtons&&e._map.pm.Toolbar.triggerClickOnToggledButtons(e)}),L.DomEvent.addListener(r,"click",this._triggerClick,this),L.DomEvent.disableClickPropagation(r),r},_applyStyleClasses:function(){this._container&&(this._button.toggleStatus?L.DomUtil.addClass(this.buttonsDomNode,"active"):L.DomUtil.removeClass(this.buttonsDomNode,"active"))},_clicked:function(){this._button.doToggle&&this.toggle()}});e["default"]=n},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(0));n["default"].Marker=n["default"].extend({initialize:function(t){this._map=t,this._shape="Marker",this.toolbarButtonName="drawMarker"},enable:function(t){L.Util.setOptions(this,t),this._enabled=!0,this._map.on("click",this._createMarker,this),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!0),this._hintMarker=L.marker([0,0],this.options.markerStyle),this._hintMarker._pmTempLayer=!0,this._hintMarker.addTo(this._map),this._layer=this._hintMarker,this._map.on("mousemove",this._syncHintMarker,this),this._map.fire("pm:drawstart",{shape:this._shape,workingLayer:this._layer}),this._map.eachLayer(function(t){t instanceof L.Marker&&t.pm&&t.pm.enable()})},disable:function(){this._enabled&&(this._map.off("click",this._createMarker,this),this._hintMarker.remove(),this._map.off("mousemove",this._syncHintMarker,this),this._map.eachLayer(function(t){t instanceof L.Marker&&t.pm&&!t._pmTempLayer&&t.pm.disable()}),this._map.fire("pm:drawend",{shape:this._shape}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!1),this._enabled=!1)},enabled:function(){return this._enabled},toggle:function(t){this.enabled()?this.disable():this.enable(t)},_createMarker:function(t){if(t.latlng){this._hintMarker._snapped||this._hintMarker.setLatLng(t.latlng);var e=this._hintMarker.getLatLng(),r=new L.Marker(e,this.options.markerStyle);r.addTo(this._map),r.pm.enable(),this._map.fire("pm:create",{shape:this._shape,marker:r,layer:r}),this._cleanupSnapping()}},_syncHintMarker:function(t){if(this._hintMarker.setLatLng(t.latlng),this.options.snappable){var e=t;e.target=this._hintMarker,this._handleSnapping(e)}}})},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=n(r(11)),o=n(r(0));o["default"].Line=o["default"].extend({initialize:function(t){this._map=t,this._shape="Line",this.toolbarButtonName="drawPolyline",this._doesSelfIntersect=!1},enable:function(t){L.Util.setOptions(this,t),this.options.finishOnDoubleClick&&!this.options.finishOn&&(this.options.finishOn="dblclick"),this._enabled=!0,this._layerGroup=new L.LayerGroup,this._layerGroup._pmTempLayer=!0,this._layerGroup.addTo(this._map),this._layer=L.polyline([],this.options.templineStyle),this._layer._pmTempLayer=!0,this._layerGroup.addLayer(this._layer),this._hintline=L.polyline([],this.options.hintlineStyle),this._hintline._pmTempLayer=!0,this._layerGroup.addLayer(this._hintline),this._hintMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"marker-icon cursor-marker"})}),this._hintMarker._pmTempLayer=!0,this._layerGroup.addLayer(this._hintMarker),this.options.cursorMarker&&L.DomUtil.addClass(this._hintMarker._icon,"visible"),this._map._container.style.cursor="crosshair",this._map.on("click",this._createVertex,this),this.options.finishOn&&this._map.on(this.options.finishOn,this._finishShape,this),"dblclick"===this.options.finishOn&&(this.tempMapDoubleClickZoomState=this._map.doubleClickZoom._enabled,this.tempMapDoubleClickZoomState&&this._map.doubleClickZoom.disable()),this._map.on("mousemove",this._syncHintMarker,this),this._hintMarker.on("move",this._syncHintLine,this),this._map.fire("pm:drawstart",{shape:this._shape,workingLayer:this._layer}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!0),this._otherSnapLayers=[]},disable:function(){this._enabled&&(this._enabled=!1,this._map._container.style.cursor="",this._map.off("click",this._createVertex,this),this._map.off("mousemove",this._syncHintMarker,this),this.options.finishOn&&this._map.off(this.options.finishOn,this._finishShape,this),this.tempMapDoubleClickZoomState&&this._map.doubleClickZoom.enable(),this._map.removeLayer(this._layerGroup),this._map.fire("pm:drawend",{shape:this._shape}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!1),this.options.snappable&&this._cleanupSnapping())},enabled:function(){return this._enabled},toggle:function(t){this.enabled()?this.disable():this.enable(t)},hasSelfIntersection:function(){return(0,i["default"])(this._layer.toGeoJSON()).features.length>0},_syncHintLine:function(){var t=this._layer.getLatLngs();if(t.length>0){var e=t[t.length-1];this._hintline.setLatLngs([e,this._hintMarker.getLatLng()])}},_syncHintMarker:function(t){if(this._hintMarker.setLatLng(t.latlng),this.options.snappable){var e=t;e.target=this._hintMarker,this._handleSnapping(e)}this.options.allowSelfIntersection||this._handleSelfIntersection()},_handleSelfIntersection:function(){var t=L.polyline(this._layer.getLatLngs());t.addLatLng(this._hintMarker.getLatLng());var e=(0,i["default"])(t.toGeoJSON());this._doesSelfIntersect=e.features.length>0,this._doesSelfIntersect?this._hintline.setStyle({color:"red"}):this._hintline.setStyle(this.options.hintlineStyle)},_createVertex:function(t){if(this.options.allowSelfIntersection||!this._doesSelfIntersect){this._hintMarker._snapped||this._hintMarker.setLatLng(t.latlng);var e=this._hintMarker.getLatLng();if(e.equals(this._layer.getLatLngs()[0]))this._finishShape(t);else{var r=0===this._layer.getLatLngs().length;this._layer.addLatLng(e);var n=this._createMarker(e,r);this._hintline.setLatLngs([e,e]),this._layer.fire("pm:vertexadded",{shape:this._shape,workingLayer:this._layer,marker:n,latlng:e})}}},_finishShape:function(){if(this.options.allowSelfIntersection||!this._doesSelfIntersect){var t=this._layer.getLatLngs(),e=L.polyline(t,this.options.pathOptions).addTo(this._map);this.disable(),this._map.fire("pm:create",{shape:this._shape,layer:e}),this.options.snappable&&this._cleanupSnapping()}},_createMarker:function(t){var e=new L.Marker(t,{draggable:!1,icon:L.divIcon({className:"marker-icon"})});return e._pmTempLayer=!0,this._layerGroup.addLayer(e),e.on("click",this._finishShape,this),e}})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(0));n["default"].Poly=n["default"].Line.extend({initialize:function(t){this._map=t,this._shape="Poly",this.toolbarButtonName="drawPolygon"},_finishShape:function(t){if(this.options.allowSelfIntersection||!this._doesSelfIntersect){var e=this._layer.getLatLngs();t&&"dblclick"===t.type&&e.splice(e.length-1,1);var r=L.polygon(e,this.options.pathOptions).addTo(this._map);this.disable(),this._map.fire("pm:create",{shape:this._shape,layer:r}),this._cleanupSnapping(),this._otherSnapLayers.splice(this._tempSnapLayerIndex,1),delete this._tempSnapLayerIndex}},_createMarker:function(t,e){var r=new L.Marker(t,{draggable:!1,icon:L.divIcon({className:"marker-icon"})});return r._pmTempLayer=!0,this._layerGroup.addLayer(r),e&&(r.on("click",this._finishShape,this),this._tempSnapLayerIndex=this._otherSnapLayers.push(r)-1,this.options.snappable&&this._cleanupSnapping()),r}})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(0));n["default"].Rectangle=n["default"].extend({initialize:function(t){this._map=t,this._shape="Rectangle",this.toolbarButtonName="drawRectangle"},enable:function(t){if(L.Util.setOptions(this,t),this._enabled=!0,this._layerGroup=new L.LayerGroup,this._layerGroup._pmTempLayer=!0,this._layerGroup.addTo(this._map),this._layer=L.rectangle([[0,0],[0,0]],this.options.pathOptions),this._layer._pmTempLayer=!0,this._startMarker=L.marker([0,0],{icon:L.divIcon({className:"marker-icon rect-start-marker"}),draggable:!0,zIndexOffset:100,opacity:this.options.cursorMarker?1:0}),this._startMarker._pmTempLayer=!0,this._layerGroup.addLayer(this._startMarker),this._hintMarker=L.marker([0,0],{icon:L.divIcon({className:"marker-icon cursor-marker"})}),this._hintMarker._pmTempLayer=!0,this._layerGroup.addLayer(this._hintMarker),this.options.cursorMarker){L.DomUtil.addClass(this._hintMarker._icon,"visible"),this._styleMarkers=[];for(var e=0;e<2;e+=1){var r=L.marker([0,0],{icon:L.divIcon({className:"marker-icon rect-style-marker"}),draggable:!0,zIndexOffset:100});r._pmTempLayer=!0,this._layerGroup.addLayer(r),this._styleMarkers.push(r)}}this._map._container.style.cursor="crosshair",this._map.on("click",this._placeStartingMarkers,this),this._map.on("mousemove",this._syncHintMarker,this),this._map.fire("pm:drawstart",{shape:this._shape,workingLayer:this._layer}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!0),this._otherSnapLayers=[]},disable:function(){this._enabled&&(this._enabled=!1,this._map._container.style.cursor="",this._map.off("click",this._finishShape,this),this._map.off("click",this._placeStartingMarkers,this),this._map.off("mousemove",this._syncHintMarker,this),this._map.removeLayer(this._layerGroup),this._map.fire("pm:drawend",{shape:this._shape}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!1),this.options.snappable&&this._cleanupSnapping())},enabled:function(){return this._enabled},toggle:function(t){this.enabled()?this.disable():this.enable(t)},_placeStartingMarkers:function(t){this._hintMarker._snapped||this._hintMarker.setLatLng(t.latlng);var e=this._hintMarker.getLatLng();L.DomUtil.addClass(this._startMarker._icon,"visible"),this._startMarker.setLatLng(e),this.options.cursorMarker&&this._styleMarkers&&this._styleMarkers.forEach(function(t){L.DomUtil.addClass(t._icon,"visible"),t.setLatLng(e)}),this._map.off("click",this._placeStartingMarkers,this),this._map.on("click",this._finishShape,this),this._setRectangleOrigin()},_setRectangleOrigin:function(){var t=this._startMarker.getLatLng();t&&(this._layerGroup.addLayer(this._layer),this._layer.setLatLngs([t,t]),this._hintMarker.on("move",this._syncRectangleSize,this))},_syncHintMarker:function(t){if(this._hintMarker.setLatLng(t.latlng),this.options.snappable){var e=t;e.target=this._hintMarker,this._handleSnapping(e)}},_syncRectangleSize:function(){var t=this,e=this._startMarker.getLatLng(),r=this._hintMarker.getLatLng();if(this._layer.setBounds([e,r]),this.options.cursorMarker&&this._styleMarkers){var n=[];this._findCorners().forEach(function(e){e.equals(t._startMarker.getLatLng())||e.equals(t._hintMarker.getLatLng())||n.push(e)}),n.forEach(function(e,r){t._styleMarkers[r].setLatLng(e)})}},_finishShape:function(){var t=this._startMarker.getLatLng(),e=this._hintMarker.getLatLng(),r=L.rectangle([t,e],this.options.pathOptions).addTo(this._map);this.disable(),this._map.fire("pm:create",{shape:this._shape,layer:r})},_findCorners:function(){var t=this._layer.getBounds();return[t.getNorthWest(),t.getNorthEast(),t.getSouthEast(),t.getSouthWest()]}})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(0));n["default"].Circle=n["default"].extend({initialize:function(t){this._map=t,this._shape="Circle",this.toolbarButtonName="drawCircle"},enable:function(t){L.Util.setOptions(this,t),this.options.radius=0,this._enabled=!0,this._layerGroup=new L.LayerGroup,this._layerGroup._pmTempLayer=!0,this._layerGroup.addTo(this._map),this._layer=L.circle([0,0],this.options.templineStyle),this._layer._pmTempLayer=!0,this._layerGroup.addLayer(this._layer),this._centerMarker=L.marker([0,0],{icon:L.divIcon({className:"marker-icon"}),draggable:!1,zIndexOffset:100}),this._centerMarker._pmTempLayer=!0,this._layerGroup.addLayer(this._centerMarker),this._hintMarker=L.marker([0,0],{icon:L.divIcon({className:"marker-icon cursor-marker"})}),this._hintMarker._pmTempLayer=!0,this._layerGroup.addLayer(this._hintMarker),this.options.cursorMarker&&L.DomUtil.addClass(this._hintMarker._icon,"visible"),this._hintline=L.polyline([],this.options.hintlineStyle),this._hintline._pmTempLayer=!0,this._layerGroup.addLayer(this._hintline),this._map._container.style.cursor="crosshair",this._map.on("click",this._placeCenterMarker,this),this._map.on("mousemove",this._syncHintMarker,this),this._map.fire("pm:drawstart",{shape:this._shape,workingLayer:this._layer}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!0),this._otherSnapLayers=[]},disable:function(){this._enabled&&(this._enabled=!1,this._map._container.style.cursor="",this._map.off("click",this._finishShape,this),this._map.off("click",this._placeCenterMarker,this),this._map.off("mousemove",this._syncHintMarker,this),this._map.removeLayer(this._layerGroup),this._map.fire("pm:drawend",{shape:this._shape}),this._map.pm.Toolbar.toggleButton(this.toolbarButtonName,!1),this.options.snappable&&this._cleanupSnapping())},enabled:function(){return this._enabled},toggle:function(t){this.enabled()?this.disable():this.enable(t)},_syncHintLine:function(){var t=this._centerMarker.getLatLng();this._hintline.setLatLngs([t,this._hintMarker.getLatLng()])},_syncCircleRadius:function(){var t=this._centerMarker.getLatLng(),e=this._hintMarker.getLatLng(),r=t.distanceTo(e);this._layer.setRadius(r)},_syncHintMarker:function(t){if(this._hintMarker.setLatLng(t.latlng),this.options.snappable){var e=t;e.target=this._hintMarker,this._handleSnapping(e)}},_placeCenterMarker:function(t){this._hintMarker._snapped||this._hintMarker.setLatLng(t.latlng);var e=this._hintMarker.getLatLng();this._centerMarker.setLatLng(e),this._map.off("click",this._placeCenterMarker,this),this._map.on("click",this._finishShape,this),this._placeCircleCenter()},_placeCircleCenter:function(){var t=this._centerMarker.getLatLng();t&&(this._layer.setLatLng(t),this._hintMarker.on("move",this._syncHintLine,this),this._hintMarker.on("move",this._syncCircleRadius,this),this._layer.fire("pm:centerplaced",{shape:this._shape,workingLayer:this._layer,latlng:t}))},_finishShape:function(){var t=this._centerMarker.getLatLng(),e=this._hintMarker.getLatLng(),r=t.distanceTo(e),n=L.circle(t,{radius:r}).addTo(this._map);this.disable(),this._map.fire("pm:create",{shape:this._shape,layer:n})},_createMarker:function(t){var e=new L.Marker(t,{draggable:!1,icon:L.divIcon({className:"marker-icon"})});return e._pmTempLayer=!0,this._layerGroup.addLayer(e),e}})},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=n(r(31)),o=n(r(33)),a=n(r(0));a["default"].Cut=a["default"].Poly.extend({initialize:function(t){this._map=t,this._shape="Cut",this.toolbarButtonName="cutPolygon"},_cut:function(t){var e=this,r=this._map._layers;Object.keys(r).map(function(t){return r[t]}).filter(function(t){return t.pm}).filter(function(t){return t instanceof L.Polygon}).filter(function(e){return e!==t}).filter(function(e){try{return!!(0,i["default"])(t.toGeoJSON(),e.toGeoJSON())}catch(r){return console.error("You cant cut polygons with self-intersections"),!1}}).forEach(function(r){var n=[],i=(0,o["default"])(r.toGeoJSON(),t.toGeoJSON()),a=L.geoJSON(i,r.options).addTo(e._map);n.push(a),a.addTo(e._map),a.pm.enable(e.options),a.pm.disable(),r.fire("pm:cut",{shape:e._shape,layer:r,resultingLayers:n}),e._map.fire("pm:cut",{shape:e._shape,cuttedLayer:r,resultingLayers:n}),r._pmTempLayer=!0,t._pmTempLayer=!0,r.remove(),t.remove()})},_finishShape:function(){var t=this._layer.getLatLngs(),e=L.polygon(t,this.options.pathOptions);this._cut(e),this.disable(),this._cleanupSnapping(),this._otherSnapLayers.splice(this._tempSnapLayerIndex,1),delete this._tempSnapLayerIndex}})},function(t,e,r){"use strict";function n(t,e,r){void 0===r&&(r={});var i=a.getGeom(t),l=a.getGeom(e);if("Polygon"===i.type&&"Polygon"===l.type){var u=s.intersection(i.coordinates,l.coordinates);if(null===u||0===u.length)return null;if(1===u.length){var h=u[0][0][0],c=u[0][0][u[0][0].length-1];return h[0]===c[0]&&h[1]===c[1]?o.polygon(u[0],r.properties):null}return o.multiPolygon(u,r.properties)}if("MultiPolygon"===i.type){for(var f=[],p=0,d=i.coordinates;p<d.length;p++){var g=d[p],_=n(a.getGeom(o.polygon(g)),l);if(_){var m=a.getGeom(_);if("Polygon"===m.type)f.push(m.coordinates);else{if("MultiPolygon"!==m.type)throw new Error("intersection is invalid");f=f.concat(m.coordinates)}}}return 0===f.length?null:1===f.length?o.polygon(f[0],r.properties):o.multiPolygon(f,r.properties)}if("MultiPolygon"===l.type)return n(l,i);throw new Error("poly1 and poly2 must be either polygons or multiPolygons")}var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e["default"]=t,e};Object.defineProperty(e,"__esModule",{value:!0});var o=r(12),a=r(32),s=i(r(13));e["default"]=n},function(t,e,r){"use strict";function n(t){if(t.length>1&&Object(i.isNumber)(t[0])&&Object(i.isNumber)(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return n(t[0]);throw new Error("coordinates must only contain numbers")}Object.defineProperty(e,"__esModule",{value:!0}),e.getCoord=function(t){if(!t)throw new Error("coord is required");if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates;if(Array.isArray(t)&&t.length>=2&&t[0].length===undefined&&t[1].length===undefined)return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")},e.getCoords=function(t){if(!t)throw new Error("coords is required");if("Feature"===t.type&&null!==t.geometry)return t.geometry.coordinates;if(t.coordinates)return t.coordinates;if(Array.isArray(t))return t;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")},e.containsNumber=n,e.geojsonType=function(t,e,r){if(!e||!r)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.type)},e.featureOf=function(t,e,r){if(!t)throw new Error("No feature passed");if(!r)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.geometry.type)},e.collectionOf=function(t,e,r){if(!t)throw new Error("No featureCollection passed");if(!r)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+r+", FeatureCollection required");for(var n=0;n<t.features.length;n++){var i=t.features[n];if(!i||"Feature"!==i.type||!i.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!i.geometry||i.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+i.geometry.type)}},e.getGeom=function(t){if(!t)throw new Error("geojson is required");if(t.geometry!==undefined)return t.geometry;if(t.coordinates||t.geometries)return t;throw new Error("geojson must be a valid Feature or Geometry Object")},e.getGeomType=function(){throw new Error("invariant.getGeomType has been deprecated in v5.0 in favor of invariant.getType")},e.getType=function(t,e){if(!t)throw new Error((e||"geojson")+" is required");if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error((e||"geojson")+" is invalid")};var i=r(12);r.n(i)},function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t["default"]:t}function i(t){switch(t.type){case"Polygon":return a(t)>1?t:null;case"MultiPolygon":var e=[];if(u.flattenEach(t,function(t){a(t)>1&&e.push(t.geometry.coordinates)}),e.length)return{type:"MultiPolygon",coordinates:e}}}var o=n(r(13)),a=n(r(34)),s=r(2),l=r(35),u=r(14);t.exports=function(t,e){var r=l.getGeom(t),n=l.getGeom(e),a=t.properties||{};if(r=i(r),n=i(n),!r)return null;if(!n)return s.feature(r,a);var u=o.diff(r.coordinates,n.coordinates);return 0===u.length?null:1===u.length?s.polygon(u[0],a):s.multiPolygon(u,a)}},function(t,e,r){"use strict";function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(i(t[0]));for(var r=1;r<t.length;r++)e-=Math.abs(i(t[r]))}return e}function i(t){var e,r,n,i,a,l,u=0,h=t.length;if(h>2){for(l=0;l<h;l++)l===h-2?(n=h-2,i=h-1,a=0):l===h-1?(n=h-1,i=0,a=1):(n=l,i=l+1,a=l+2),e=t[n],r=t[i],u+=(o(t[a][0])-o(e[0]))*Math.sin(o(r[1]));u=u*s*s/2}return u}function o(t){return t*Math.PI/180}Object.defineProperty(e,"__esModule",{value:!0});var a=r(14),s=6378137;e["default"]=function(t){return a.geomReduce(t,function(t,e){return t+function(t){var e,r=0;switch(t.type){case"Polygon":return n(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)r+=n(t.coordinates[e]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)},0)}},function(t,e,r){"use strict";function n(t){if(t.length>1&&i.isNumber(t[0])&&i.isNumber(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return n(t[0]);throw new Error("coordinates must only contain numbers")}Object.defineProperty(e,"__esModule",{value:!0});var i=r(2);e.getCoord=function(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")},e.getCoords=function(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")},e.containsNumber=n,e.geojsonType=function(t,e,r){if(!e||!r)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.type)},e.featureOf=function(t,e,r){if(!t)throw new Error("No feature passed");if(!r)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+t.geometry.type)},e.collectionOf=function(t,e,r){if(!t)throw new Error("No featureCollection passed");if(!r)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+r+", FeatureCollection required");for(var n=0,i=t.features;n<i.length;n++){var o=i[n];if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+r+", Feature with geometry required");if(!o.geometry||o.geometry.type!==e)throw new Error("Invalid input to "+r+": must be a "+e+", given "+o.geometry.type)}},e.getGeom=function(t){return"Feature"===t.type?t.geometry:t},e.getType=function(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=void 0;var n={_initDraggableLayer:function(){this._tempDragCoord=null;var t=this._layer._path?this._layer._path:this._layer._renderer._container;L.DomUtil.addClass(t,"leaflet-pm-draggable"),this._originalMapDragState=this._layer._map.dragging._enabled,this._safeToCacheDragState=!0,this._layer.on("mousedown",this._dragMixinOnMouseDown,this)},_dragMixinOnMouseUp:function(){var t=this,e=this._layer._path?this._layer._path:this._layer._renderer._container;return this._originalMapDragState&&this._layer._map.dragging.enable(),this._safeToCacheDragState=!0,this._layer._map.off("mousemove",this._dragMixinOnMouseMove,this),this._layer.off("mouseup",this._dragMixinOnMouseUp,this),!!this._dragging&&(this._initMarkers(),window.setTimeout(function(){t._dragging=!1,L.DomUtil.removeClass(e,"leaflet-pm-dragging"),t._layer.fire("pm:dragend"),t._fireEdit()},10),!0)},_dragMixinOnMouseMove:function(t){var e=this._layer._path?this._layer._path:this._layer._renderer._container;this._dragging||(this._dragging=!0,L.DomUtil.addClass(e,"leaflet-pm-dragging"),this._layer.bringToFront(),this._originalMapDragState&&this._layer._map.dragging.disable(),this._markerGroup.clearLayers(),this._layer.fire("pm:dragstart")),this._onLayerDrag(t)},_dragMixinOnMouseDown:function(t){t.originalEvent.button>0||(this._safeToCacheDragState&&(this._originalMapDragState=this._layer._map.dragging._enabled,this._safeToCacheDragState=!1),this._tempDragCoord=t.latlng,this._layer.on("mouseup",this._dragMixinOnMouseUp,this),this._layer._map.on("mousemove",this._dragMixinOnMouseMove,this))},dragging:function(){return this._dragging},_onLayerDrag:function(t){var e=t.latlng,r={lat:e.lat-this._tempDragCoord.lat,lng:e.lng-this._tempDragCoord.lng},n=function i(t){return t.map(function(t){return Array.isArray(t)?i(t):{lat:t.lat+r.lat,lng:t.lng+r.lng}})}(this._layer._latlngs);this._layer.setLatLngs(n).redraw(),this._tempDragCoord=e,this._layer.fire("pm:drag")}};e["default"]=n},function(t,e,r){"use strict";(function(t){return t&&t.__esModule?t:{"default":t}})(r(1))["default"].LayerGroup=L.Class.extend({initialize:function(t){var e=this;this._layerGroup=t,this._layers=this.findLayers(),this._layers.forEach(function(t){return e._initLayer(t)}),this._layerGroup.on("layeradd",function(t){t.target._pmTempLayer||(e._layers=e.findLayers(),t.layer.pm&&e._initLayer(t.layer),t.target.pm.enabled()&&e.enable(e.getOptions()))})},findLayers:function(){var t=this._layerGroup.getLayers();return t=t.filter(function(t){return!(t instanceof L.LayerGroup)}),t=t.filter(function(t){return!!t.pm}),t=t.filter(function(t){return!t._pmTempLayer})},_initLayer:function(t){var e=this;["pm:edit","pm:update","pm:remove","pm:dragstart","pm:drag","pm:dragend","pm:snap","pm:unsnap","pm:cut","pm:intersect","pm:raiseMarkers","pm:markerdragend","pm:markerdragstart","pm:vertexadded","pm:vertexremoved","pm:centerplaced"].forEach(function(r){t.on(r,e._fireEvent,e)}),t.pm._layerGroup=this._layerGroup},_fireEvent:function(t){this._layerGroup.fireEvent(t.type,t)},toggleEdit:function(t){this._options=t,this._layers.forEach(function(e){e.pm.toggleEdit(t)})},enable:function(t){this._options=t,this._layers.forEach(function(e){e.pm.enable(t)})},disable:function(){this._layers.forEach(function(t){t.pm.disable()})},enabled:function(){var t=this._layers.find(function(t){return t.pm.enabled()});return!!t},dragging:function(){var t=this._layers.find(function(t){return t.pm.dragging()});return!!t},getOptions:function(){return this._options}})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(1));n["default"].Marker=n["default"].extend({initialize:function(t){this._layer=t,this._enabled=!1,this._layer.on("dragend",this._onDragEnd,this)},toggleEdit:function(t){this.enabled()?this.disable():this.enable(t)},enable:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{draggable:!0,snappable:!0};L.Util.setOptions(this,t),this._map=this._layer._map,this.enabled()||(this._enabled=!0,this.options.preventMarkerRemoval||this._layer.on("contextmenu",this._removeMarker,this),this.options.draggable&&this._layer.dragging.enable(),this.options.snappable&&this._initSnappableMarkers())},enabled:function(){return this._enabled},disable:function(){this._enabled=!1,this._layer.dragging.disable(),this._layer.off("contextmenu",this._removeMarker,this),this._layerEdited&&this._layer.fire("pm:update",{}),this._layerEdited=!1},_removeMarker:function(t){var e=t.target;e.remove(),e.fire("pm:remove")},_onDragEnd:function(t){t.target.fire("pm:edit"),this._layerEdited=!0},_initSnappableMarkers:function(){var t=this._layer;this.options.snapDistance=this.options.snapDistance||30,t.off("drag",this._handleSnapping,this),t.on("drag",this._handleSnapping,this),t.off("dragend",this._cleanupSnapping,this),t.on("dragend",this._cleanupSnapping,this),t.off("pm:dragstart",this._unsnap,this),t.on("pm:dragstart",this._unsnap,this)}})},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=n(r(11)),o=n(r(40)),a=n(r(1));a["default"].Line=a["default"].extend({initialize:function(t){this._layer=t,this._enabled=!1},toggleEdit:function(t){this.enabled()?this.disable():this.enable(t)},enable:function(t){L.Util.setOptions(this,t),this._map=this._layer._map,this._map&&(this.enabled()||this.disable(),this._enabled=!0,this._initMarkers(),this._layer.on("remove",this._onLayerRemove,this),this.options.allowSelfIntersection||this._layer.on("pm:vertexremoved",this._handleSelfIntersectionOnVertexRemoval,this),this.options.draggable&&this._initDraggableLayer(),this.options.allowSelfIntersection||this._handleLayerStyle())},_onLayerRemove:function(t){this.disable(t.target)},enabled:function(){return this._enabled},disable:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this._layer;if(!this.enabled())return!1;if(t.pm._dragging)return!1;t.pm._enabled=!1,t.pm._markerGroup.clearLayers(),t.off("mousedown"),t.off("mouseup"),this._layer.off("remove",this._onLayerRemove),this.options.allowSelfIntersection||this._layer.off("pm:vertexremoved",this._handleSelfIntersectionOnVertexRemoval);var e=t._path?t._path:this._layer._renderer._container;return L.DomUtil.removeClass(e,"leaflet-pm-draggable"),this.hasSelfIntersection()&&L.DomUtil.removeClass(e,"leaflet-pm-invalid"),this._layerEdited&&this._layer.fire("pm:update",{}),this._layerEdited=!1,!0},hasSelfIntersection:function(){return(0,i["default"])(this._layer.toGeoJSON()).features.length>0},_handleSelfIntersectionOnVertexRemoval:function(){this._handleLayerStyle(!0),this.hasSelfIntersection()&&(this._layer.setLatLngs(this._coordsBeforeEdit),this._coordsBeforeEdit=null,this._initMarkers())},_handleLayerStyle:function(t){var e=this._layer._path?this._layer._path:this._layer._renderer._container;if(this.hasSelfIntersection()){if(L.DomUtil.hasClass(e,"leaflet-pm-invalid"))return;t?(L.DomUtil.addClass(e,"leaflet-pm-invalid"),window.setTimeout(function(){L.DomUtil.removeClass(e,"leaflet-pm-invalid")},200)):L.DomUtil.addClass(e,"leaflet-pm-invalid"),this._layer.fire("pm:intersect",{intersection:(0,i["default"])(this._layer.toGeoJSON())})}else L.DomUtil.removeClass(e,"leaflet-pm-invalid")},_initMarkers:function(){var t=this,e=this._map,r=this._layer.getLatLngs();this._markerGroup&&this._markerGroup.clearLayers(),this._markerGroup=new L.LayerGroup,this._markerGroup._pmTempLayer=!0,e.addLayer(this._markerGroup);this._markers=function n(e){if(Array.isArray(e[0]))return e.map(n,t);var r=e.map(t._createMarker,t);return e.map(function(n,i){var o=t.isPolygon()?(i+1)%e.length:i+1;return t._createMiddleMarker(r[i],r[o])}),r}(r),this.options.snappable&&this._initSnappableMarkers()},_createMarker:function(t){var e=new L.Marker(t,{draggable:!this.options.preventVertexEdit,icon:L.divIcon({className:"marker-icon"})});return e._pmTempLayer=!0,e.on("dragstart",this._onMarkerDragStart,this),e.on("move",this._onMarkerDrag,this),e.on("dragend",this._onMarkerDragEnd,this),this.options.preventMarkerRemoval||e.on("contextmenu",this._removeMarker,this),this._markerGroup.addLayer(e),e},_createMiddleMarker:function(t,e){var r=this;if(!t||!e)return!1;var n=this._calcMiddleLatLng(t.getLatLng(),e.getLatLng()),i=this._createMarker(n),o=L.divIcon({className:"marker-icon marker-icon-middle"});return i.setIcon(o),t._middleMarkerNext=i,e._middleMarkerPrev=i,i.on("click",function(){var n=L.divIcon({className:"marker-icon"});i.setIcon(n),r._addMarker(i,t,e)}),i.on("movestart",function(){i.on("moveend",function(){var t=L.divIcon({className:"marker-icon"});i.setIcon(t),i.off("moveend")}),r._addMarker(i,t,e)}),i},_addMarker:function(t,e,r){t.off("movestart"),t.off("click");var n=t.getLatLng(),i=this._layer._latlngs,a=this.findDeepMarkerIndex(this._markers,r),s=a.indexPath,l=a.index,u=a.parentPath,h=s.length>1?(0,o["default"])(i,u):i,c=s.length>1?(0,o["default"])(this._markers,u):this._markers;h.splice(l,0,n),c.splice(l,0,t),this._layer.setLatLngs(i),this._createMiddleMarker(e,t),this._createMiddleMarker(t,r),this._fireEdit(),this._layer.fire("pm:vertexadded",{layer:this._layer,marker:t,indexPath:s}),this.options.snappable&&this._initSnappableMarkers()},_removeMarker:function(t){if(!this.options.allowSelfIntersection){var e=this._layer.getLatLngs();this._coordsBeforeEdit=JSON.parse(JSON.stringify(e))}var r=t.target,n=this._layer.getLatLngs(),i=this.findDeepMarkerIndex(this._markers,r),a=i.indexPath,s=i.index,l=i.parentPath;if(a){var u=a.length>1?(0,o["default"])(n,l):n,h=a.length>1?(0,o["default"])(this._markers,l):this._markers;u.splice(s,1),this._layer.setLatLngs(n),u.length<=1&&(u.splice(0,u.length),this._layer.setLatLngs(n),this.disable(),this.enable(this.options)),this.isEmptyDeep(n)&&this._layer.remove(),r._middleMarkerPrev&&this._markerGroup.removeLayer(r._middleMarkerPrev),r._middleMarkerNext&&this._markerGroup.removeLayer(r._middleMarkerNext),this._markerGroup.removeLayer(r);var c,f;if(this.isPolygon()?(c=(s+1)%h.length,f=(s+(h.length-1))%h.length):(f=s-1<0?undefined:s-1,c=s+1>=h.length?undefined:s+1),c!==f){var p=h[f],d=h[c];this._createMiddleMarker(p,d)}h.splice(s,1),this._fireEdit(),this._layer.fire("pm:vertexremoved",{layer:this._layer,marker:r,indexPath:a})}},isEmptyDeep:function(t){return!function e(t){return t.filter(function(t){return![null,"",undefined].includes(t)}).reduce(function(t,r){return t.concat(Array.isArray(r)?e(r):r)},[])}(t).length},findDeepMarkerIndex:function(t,e){var r;t.some(function i(t){return function(n,o){var a=t.concat(o);return n._leaflet_id===e._leaflet_id?(r=a,!0):Array.isArray(n)&&n.some(i(a))}}([]));var n={};return r&&(n={indexPath:r,index:r[r.length-1],parentPath:r.slice(0,r.length-1)}),n},updatePolygonCoordsFromMarkerDrag:function(t){var e=this._layer.getLatLngs(),r=t.getLatLng(),n=this.findDeepMarkerIndex(this._markers,t),i=n.indexPath,a=n.index,s=n.parentPath;(i.length>1?(0,o["default"])(e,s):e).splice(a,1,r),this._layer.setLatLngs(e).redraw()},_onMarkerDrag:function(t){var e=t.target,r=this.findDeepMarkerIndex(this._markers,e),n=r.indexPath,i=r.index,a=r.parentPath;if(n){this.updatePolygonCoordsFromMarkerDrag(e);var s=n.length>1?(0,o["default"])(this._markers,a):this._markers,l=(i+1)%s.length,u=(i+(s.length-1))%s.length,h=e.getLatLng(),c=s[u].getLatLng(),f=s[l].getLatLng();if(e._middleMarkerNext){var p=this._calcMiddleLatLng(h,f);e._middleMarkerNext.setLatLng(p)}if(e._middleMarkerPrev){var d=this._calcMiddleLatLng(h,c);e._middleMarkerPrev.setLatLng(d)}this.options.allowSelfIntersection||this._handleLayerStyle()}},_onMarkerDragEnd:function(t){var e=t.target,r=this.findDeepMarkerIndex(this._markers,e).indexPath;if(!this.options.allowSelfIntersection&&this.hasSelfIntersection())return this._layer.setLatLngs(this._coordsBeforeEdit),this._coordsBeforeEdit=null,this._initMarkers(),void this._handleLayerStyle();this._layer.fire("pm:markerdragend",{markerEvent:t,indexPath:r}),this._fireEdit()},_onMarkerDragStart:function(t){var e=t.target,r=this.findDeepMarkerIndex(this._markers,e).indexPath;this._layer.fire("pm:markerdragstart",{markerEvent:t,indexPath:r}),this.options.allowSelfIntersection||(this._coordsBeforeEdit=this._layer.getLatLngs())},_fireEdit:function(){this._layerEdited=!0,this._layer.fire("pm:edit")},_calcMiddleLatLng:function(t,e){var r=this._map,n=r.project(t),i=r.project(e);return r.unproject(n._add(i)._divideBy(2))}})},function(t,e,r){var n=r(41);t.exports=function(t,e,r){var i=null==t?undefined:n(t,e);return i===undefined?r:i}},function(t,e,r){var n=r(42),i=r(82);t.exports=function(t,e){for(var r=0,o=(e=n(e,t)).length;null!=t&&r<o;)t=t[i(e[r++])];return r&&r==o?t:undefined}},function(t,e,r){var n=r(6),i=r(43),o=r(49),a=r(79);t.exports=function(t,e){return n(t)?t:i(t,e)?[t]:o(a(t))}},function(t,e,r){var n=r(6),i=r(7),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;t.exports=function(t,e){if(n(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!i(t))||a.test(t)||!o.test(t)||null!=e&&t in Object(e)}},function(t,e,r){(function(e){var r="object"==typeof e&&e&&e.Object===Object&&e;t.exports=r}).call(e,r(45))},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){var n=r(8),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,s=n?n.toStringTag:undefined;t.exports=function(t){var e=o.call(t,s),r=t[s];try{t[s]=undefined;var n=!0}catch(l){}var i=a.call(t);return n&&(e?t[s]=r:delete t[s]),i}},function(t,e){var r=Object.prototype.toString;t.exports=function(t){return r.call(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,r){var n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,o=r(50)(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(n,function(t,r,n,o){e.push(n?o.replace(i,"$1"):r||t)}),e});t.exports=o},function(t,e,r){var n=r(51),i=500;t.exports=function(t){var e=n(t,function(t){return r.size===i&&r.clear(),t}),r=e.cache;return e}},function(t,e,r){function n(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(o);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(n.Cache||i),r}var i=r(52),o="Expected a function";n.Cache=i,t.exports=n},function(t,e,r){function n(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}var i=r(53),o=r(74),a=r(76),s=r(77),l=r(78);n.prototype.clear=i,n.prototype["delete"]=o,n.prototype.get=a,n.prototype.has=s,n.prototype.set=l,t.exports=n},function(t,e,r){var n=r(54),i=r(66),o=r(73);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(o||i),string:new n}}},function(t,e,r){function n(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}var i=r(55),o=r(62),a=r(63),s=r(64),l=r(65);n.prototype.clear=i,n.prototype["delete"]=o,n.prototype.get=a,n.prototype.has=s,n.prototype.set=l,t.exports=n},function(t,e,r){var n=r(3);t.exports=function(){this.__data__=n?n(null):{},this.size=0}},function(t,e,r){var n=r(57),i=r(58),o=r(17),a=r(60),s=/^\[object .+?Constructor\]$/,l=Function.prototype,u=Object.prototype,h=l.toString,c=u.hasOwnProperty,f=RegExp("^"+h.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!o(t)||i(t))&&(n(t)?f:s).test(a(t))}},function(t,e,r){var n=r(15),i=r(17),o="[object AsyncFunction]",a="[object Function]",s="[object GeneratorFunction]",l="[object Proxy]";t.exports=function(t){if(!i(t))return!1;var e=n(t);return e==a||e==s||e==o||e==l}},function(t,e,r){var n=r(59),i=function(){var t=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();t.exports=function(t){return!!i&&i in t}},function(t,e,r){var n=r(9)["__core-js_shared__"];t.exports=n},function(t,e){var r=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return r.call(t)}catch(e){}try{return t+""}catch(e){}}return""}},function(t,e){t.exports=function(t,e){return null==t?undefined:t[e]}},function(t,e){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},function(t,e,r){var n=r(3),i="__lodash_hash_undefined__",o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(n){var r=e[t];return r===i?undefined:r}return o.call(e,t)?e[t]:undefined}},function(t,e,r){var n=r(3),i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return n?e[t]!==undefined:i.call(e,t)}},function(t,e,r){var n=r(3),i="__lodash_hash_undefined__";t.exports=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=n&&e===undefined?i:e,this}},function(t,e,r){function n(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}var i=r(67),o=r(68),a=r(70),s=r(71),l=r(72);n.prototype.clear=i,n.prototype["delete"]=o,n.prototype.get=a,n.prototype.has=s,n.prototype.set=l,t.exports=n},function(t,e){t.exports=function(){this.__data__=[],this.size=0}},function(t,e,r){var n=r(4),i=Array.prototype.splice;t.exports=function(t){var e=this.__data__,r=n(e,t);return!(r<0||(r==e.length-1?e.pop():i.call(e,r,1),--this.size,0))}},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e,r){var n=r(4);t.exports=function(t){var e=this.__data__,r=n(e,t);return r<0?undefined:e[r][1]}},function(t,e,r){var n=r(4);t.exports=function(t){return n(this.__data__,t)>-1}},function(t,e,r){var n=r(4);t.exports=function(t,e){var r=this.__data__,i=n(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}},function(t,e,r){var n=r(16)(r(9),"Map");t.exports=n},function(t,e,r){var n=r(5);t.exports=function(t){var e=n(this,t)["delete"](t);return this.size-=e?1:0,e}},function(t,e){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},function(t,e,r){var n=r(5);t.exports=function(t){return n(this,t).get(t)}},function(t,e,r){var n=r(5);t.exports=function(t){return n(this,t).has(t)}},function(t,e,r){var n=r(5);t.exports=function(t,e){var r=n(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}},function(t,e,r){var n=r(80);t.exports=function(t){return null==t?"":n(t)}},function(t,e,r){function n(t){if("string"==typeof t)return t;if(a(t))return o(t,n)+"";if(s(t))return h?h.call(t):"";var e=t+"";return"0"==e&&1/t==-l?"-0":e}var i=r(8),o=r(81),a=r(6),s=r(7),l=1/0,u=i?i.prototype:undefined,h=u?u.toString:undefined;t.exports=n},function(t,e){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}},function(t,e,r){var n=r(7),i=1/0;t.exports=function(t){if("string"==typeof t||n(t))return t;var e=t+"";return"0"==e&&1/t==-i?"-0":e}},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(1));n["default"].Poly=n["default"].Line.extend({})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(1));n["default"].Rectangle=n["default"].Poly.extend({_initMarkers:function(){var t=this._map,e=this._findCorners();this._markerGroup&&this._markerGroup.clearLayers(),this._markerGroup=new L.LayerGroup,this._markerGroup._pmTempLayer=!0,t.addLayer(this._markerGroup),this._markers=[],this._markers[0]=e.map(this._createMarker,this),this._cornerMarkers=this._markers[0],this.options.snappable&&this._initSnappableMarkers()},_createMarker:function(t,e){var r=new L.Marker(t,{draggable:!this.options.preventVertexEdit,icon:L.divIcon({className:"marker-icon"})});return r._origLatLng=t,r._index=e,r._pmTempLayer=!0,r.on("dragstart",this._onMarkerDragStart,this),r.on("drag",this._onMarkerDrag,this),r.on("dragend",this._onMarkerDragEnd,this),r.on("pm:snap",this._adjustRectangleForMarkerSnap,this),this.options.preventMarkerRemoval||r.on("contextmenu",this._removeMarker,this),this._markerGroup.addLayer(r),r},_removeMarker:function(){return null},_onMarkerDragStart:function(t){var e=t.target,r=this._findCorners();e._oppositeCornerLatLng=r[(e._index+2)%4],e._snapped=!1,this._layer.fire("pm:markerdragstart",{markerEvent:t})},_onMarkerDrag:function(t){var e=t.target;e._index!==undefined&&(e._snapped||this._adjustRectangleForMarkerMove(e))},_onMarkerDragEnd:function(t){var e=this._findCorners();this._adjustAllMarkers(e),this._cornerMarkers.forEach(function(t){delete t._oppositeCornerLatLng}),this._layer.setLatLngs(e),this._layer.redraw(),this._layer.fire("pm:markerdragend",{markerEvent:t}),this._fireEdit()},_adjustRectangleForMarkerMove:function(t){L.extend(t._origLatLng,t._latlng);var e=t.getLatLng();this._layer.setBounds(L.latLngBounds(e,t._oppositeCornerLatLng)),this._adjustAdjacentMarkers(t),this._layer.redraw()},_adjustRectangleForMarkerSnap:function(t){if(this.options.snappable){var e=t.target;this._adjustRectangleForMarkerMove(e)}},_adjustAllMarkers:function(t){t.length&&4==t.length?this._cornerMarkers.forEach(function(e,r){e.setLatLng(t[r])}):console.error("_adjustAllMarkers() requires an array of EXACTLY 4 LatLng coordinates")},_adjustAdjacentMarkers:function(t){if(t&&t.getLatLng&&t._oppositeCornerLatLng){var e=t.getLatLng(),r=t._oppositeCornerLatLng,n=[];this._findCorners().forEach(function(t){t.equals(e)||t.equals(r)||n.push(t)});var i=0;2==n.length&&this._cornerMarkers.forEach(function(t){var o=t.getLatLng();o.equals(e)||o.equals(r)||(t.setLatLng(n[i]),i+=1)})}else console.error("_adjustAdjacentMarkers() requires a valid Marker object")},_findCorners:function(){var t=this._layer.getBounds();return[t.getNorthWest(),t.getNorthEast(),t.getSouthEast(),t.getSouthWest()]}})},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{"default":t}}(r(1));n["default"].Circle=n["default"].extend({initialize:function(t){this._layer=t,this._enabled=!1},toggleEdit:function(t){this.enabled()?this.disable():this.enable(t)},enabled:function(){return this._enabled},enable:function(t){var e=this;L.Util.setOptions(this,t),this._map=this._layer._map,this.enabled()||this.disable(),this._enabled=!0,this._initMarkers(),this._layer.on("remove",function(t){e.disable(t.target)})},disable:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this._layer;if(!this.enabled())return!1;if(t.pm._dragging)return!1;t.pm._enabled=!1,t.pm._layerGroup.clearLayers(),t.off("mousedown"),t.off("mouseup");var e=t._path?t._path:this._layer._renderer._container;return L.DomUtil.removeClass(e,"leaflet-pm-draggable"),this._layerEdited&&this._layer.fire("pm:update",{}),this._layerEdited=!1,!0},_initMarkers:function(){var t=this._map;this._layerGroup&&this._layerGroup.clearLayers(),this._layerGroup=new L.LayerGroup,t.addLayer(this._layerGroup);var e=this._layer.getLatLng(),r=this._layer._radius,n=this._getLatLngOnCircle(e,r);this._centerMarker=this._createCenterMarker(e),this._outerMarker=this._createOuterMarker(n),this._markers=[this._centerMarker,this._outerMarker],this._createHintLine(this._centerMarker,this._outerMarker),this.options.snappable&&this._initSnappableMarkers()},_getLatLngOnCircle:function(t,e){var r=this._map.project(t),n=L.point(r.x+e,r.y);return this._map.unproject(n)},_resizeCircle:function(){this._syncHintLine(),this._syncCircleRadius()},_moveCircle:function(t){var e=t.latlng;this._layer.setLatLng(e);var r=this._layer._radius,n=this._getLatLngOnCircle(e,r);this._outerMarker.setLatLng(n),this._syncHintLine(),this._layer.fire("pm:centerplaced",{layer:this._layer,latlng:e})},_onMarkerDragStart:function(t){this._layer.fire("pm:markerdragstart",{markerEvent:t})},_onMarkerDragEnd:function(t){this._fireEdit(),this._layer.fire("pm:markerdragend",{markerEvent:t})},_syncCircleRadius:function(){var t=this._centerMarker.getLatLng(),e=this._outerMarker.getLatLng(),r=t.distanceTo(e);this._layer.setRadius(r)},_syncHintLine:function(){var t=this._centerMarker.getLatLng(),e=this._outerMarker.getLatLng();this._hintline.setLatLngs([t,e])},_createHintLine:function(t,e){var r=t.getLatLng(),n=e.getLatLng();this._hintline=L.polyline([r,n],this.options.hintlineStyle),this._hintline._pmTempLayer=!0,this._layerGroup.addLayer(this._hintline)},_createCenterMarker:function(t){var e=this._createMarker(t);return e.on("move",this._moveCircle,this),e},_createOuterMarker:function(t){var e=this._createMarker(t);return this.options.preventVertexEdit&&e.dragging.disable(),e.on("move",this._resizeCircle,this),e},_createMarker:function(t){var e=new L.Marker(t,{draggable:!0,icon:L.divIcon({className:"marker-icon"})});return e._origLatLng=t,e._pmTempLayer=!0,e.on("dragstart",this._onMarkerDragStart,this),e.on("dragend",this._onMarkerDragEnd,this),this._layerGroup.addLayer(e),e},_fireEdit:function(){this._layer.fire("pm:edit"),this._layerEdited=!0}})},function(t,e){},function(t,e){}]);