@defra/interactive-map 0.0.8-alpha → 0.0.10-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/DOCS_README.md +39 -0
  2. package/dist/esm/im-core.js +1 -0
  3. package/dist/esm/im-shell.js +1 -0
  4. package/dist/esm/index.js +1 -2
  5. package/dist/umd/im-core.js +1 -1
  6. package/dist/umd/index.js +1 -1
  7. package/docs/api/button-definition.md +104 -3
  8. package/docs/api.md +22 -2
  9. package/docs/architecture/architecture-diagrams.md +1 -3
  10. package/docs/architecture/diagrams-viewer.mdx +12 -0
  11. package/docs/getting-started.md +78 -8
  12. package/docs/govuk-prototype.md +23 -0
  13. package/docs/index.md +23 -0
  14. package/docusaurus.config.cjs +106 -0
  15. package/mise.toml +2 -0
  16. package/package.json +51 -27
  17. package/plugins/beta/datasets/dist/css/index.css +50 -1
  18. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -0
  19. package/plugins/beta/datasets/dist/esm/index.js +1 -2
  20. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -0
  21. package/plugins/beta/draw-es/dist/esm/index.js +1 -2
  22. package/plugins/beta/draw-es/src/api/newPolygon.js +1 -3
  23. package/plugins/beta/draw-es/src/events.js +2 -2
  24. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -0
  25. package/plugins/beta/draw-ml/dist/esm/index.js +1 -2
  26. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  27. package/plugins/beta/draw-ml/src/api/newLine.js +2 -2
  28. package/plugins/beta/draw-ml/src/api/newPolygon.js +2 -2
  29. package/plugins/beta/draw-ml/src/events.js +18 -10
  30. package/plugins/beta/frame/dist/css/index.css +11 -1
  31. package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -0
  32. package/plugins/beta/frame/dist/esm/index.js +1 -2
  33. package/plugins/beta/map-styles/dist/css/index.css +79 -1
  34. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
  35. package/plugins/beta/map-styles/dist/esm/index.js +1 -2
  36. package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
  37. package/plugins/beta/scale-bar/dist/esm/index.js +1 -2
  38. package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -0
  39. package/plugins/beta/use-location/dist/esm/index.js +1 -2
  40. package/plugins/beta/use-location/dist/umd/index.js +1 -1
  41. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -0
  42. package/plugins/interact/dist/esm/index.js +1 -2
  43. package/plugins/search/dist/esm/im-search-plugin.js +1 -0
  44. package/plugins/search/dist/esm/index.js +1 -2
  45. package/plugins/search/src/Search.test.jsx +170 -0
  46. package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +67 -0
  47. package/plugins/search/src/components/Form/Form.test.jsx +158 -0
  48. package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +47 -0
  49. package/plugins/search/src/components/Suggestions/Suggestions.module.scss +1 -1
  50. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +79 -0
  51. package/plugins/search/src/datasets.test.js +46 -0
  52. package/plugins/search/src/events/fetchSuggestions.test.js +212 -0
  53. package/plugins/search/src/events/formHandlers.test.js +232 -0
  54. package/plugins/search/src/events/index.test.js +118 -0
  55. package/plugins/search/src/events/inputHandlers.test.js +104 -0
  56. package/plugins/search/src/events/suggestionHandlers.test.js +166 -0
  57. package/plugins/search/src/index.test.js +47 -0
  58. package/plugins/search/src/reducer.test.js +80 -0
  59. package/plugins/search/src/search.scss +1 -1
  60. package/plugins/search/src/utils/parseOsNamesResults.js +2 -1
  61. package/plugins/search/src/utils/parseOsNamesResults.test.js +140 -0
  62. package/plugins/search/src/utils/updateMap.test.js +52 -0
  63. package/providers/beta/esri/dist/css/index.css +30 -1
  64. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -0
  65. package/providers/beta/esri/dist/esm/index.js +1 -2
  66. package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +1 -0
  67. package/providers/beta/open-names/dist/esm/index.js +1 -2
  68. package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +61 -0
  69. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -0
  70. package/providers/maplibre/dist/esm/index.js +1 -2
  71. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  72. package/providers/maplibre/src/appEvents.test.js +44 -0
  73. package/providers/maplibre/src/index.test.js +60 -0
  74. package/providers/maplibre/src/mapEvents.test.js +115 -0
  75. package/providers/maplibre/src/maplibreProvider.test.js +205 -0
  76. package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +31 -0
  77. package/providers/maplibre/src/utils/detectWebgl.test.js +63 -0
  78. package/providers/maplibre/src/utils/highlightFeatures.test.js +126 -0
  79. package/providers/maplibre/src/utils/labels.js +1 -3
  80. package/providers/maplibre/src/utils/labels.test.js +231 -0
  81. package/providers/maplibre/src/utils/maplibreFixes.test.js +66 -0
  82. package/providers/maplibre/src/utils/queryFeatures.test.js +60 -0
  83. package/providers/maplibre/src/utils/spatial.js +5 -4
  84. package/providers/maplibre/src/utils/spatial.test.js +96 -0
  85. package/rollup.esm.mjs +288 -0
  86. package/src/App/store/appActionsMap.js +1 -1
  87. package/src/InteractiveMap/InteractiveMap.js +3 -2
  88. package/webpack.dev.mjs +9 -1
  89. package/webpack.prod.mjs +8 -1
  90. package/webpack.umd.mjs +1 -2
  91. package/dist/esm/index.js.LICENSE.txt +0 -1
  92. package/plugins/beta/datasets/dist/esm/index.js.LICENSE.txt +0 -1
  93. package/plugins/beta/draw-es/dist/esm/index.js.LICENSE.txt +0 -1
  94. package/plugins/beta/draw-ml/dist/esm/index.js.LICENSE.txt +0 -1
  95. package/plugins/beta/frame/dist/esm/index.js.LICENSE.txt +0 -1
  96. package/plugins/beta/map-styles/dist/esm/index.js.LICENSE.txt +0 -1
  97. package/plugins/beta/scale-bar/dist/esm/index.js.LICENSE.txt +0 -1
  98. package/plugins/beta/use-location/dist/esm/index.js.LICENSE.txt +0 -1
  99. package/plugins/interact/dist/esm/index.js.LICENSE.txt +0 -1
  100. package/plugins/search/dist/esm/index.js.LICENSE.txt +0 -1
  101. package/providers/beta/esri/dist/esm/index.js.LICENSE.txt +0 -1
  102. package/providers/beta/open-names/dist/esm/index.js.LICENSE.txt +0 -1
  103. package/providers/maplibre/dist/esm/index.js.LICENSE.txt +0 -6
  104. package/webpack.esm.mjs +0 -154
@@ -1,2 +1 @@
1
- /*! For license information please see index.js.LICENSE.txt */
2
- import{useEffect as e}from"react";var t={"./node_modules/@mapbox/geojson-area/index.js"(e,t,r){var n=r("./node_modules/wgs84/index.js");function o(e){var t=0;if(e&&e.length>0){t+=Math.abs(i(e[0]));for(var r=1;r<e.length;r++)t-=Math.abs(i(e[r]))}return t}function i(e){var t,r,o,i,s,u,c=0,l=e.length;if(l>2){for(u=0;u<l;u++)u===l-2?(o=l-2,i=l-1,s=0):u===l-1?(o=l-1,i=0,s=1):(o=u,i=u+1,s=u+2),t=e[o],r=e[i],c+=(a(e[s][0])-a(t[0]))*Math.sin(a(r[1]));c=c*n.RADIUS*n.RADIUS/2}return c}function a(e){return e*Math.PI/180}e.exports.geometry=function e(t){var r,n=0;switch(t.type){case"Polygon":return o(t.coordinates);case"MultiPolygon":for(r=0;r<t.coordinates.length;r++)n+=o(t.coordinates[r]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<t.geometries.length;r++)n+=e(t.geometries[r]);return n}},e.exports.ring=i},"./node_modules/@mapbox/geojson-normalize/index.js"(e){e.exports=function(e){if(!e||!e.type)return null;var r=t[e.type];return r?"geometry"===r?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===r?{type:"FeatureCollection",features:[e]}:"featurecollection"===r?e:void 0:null};var t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},"./node_modules/fast-deep-equal/index.js"(e){e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!==o--;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}},"./node_modules/geojson-rbush/index.js"(e,t,r){var n=r("./node_modules/rbush/rbush.min.js"),o=r("./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js"),i=r("./node_modules/geojson-rbush/node_modules/@turf/meta/dist/js/index.js"),a=r("./node_modules/@turf/bbox/dist/cjs/index.cjs").Ay,s=i.featureEach,u=(i.coordEach,o.polygon,o.featureCollection);function c(e){var t=new n(e);return t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}):s(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}),n.prototype.load.call(this,t)},t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.remove.call(this,e,t)},t.clear=function(){return n.prototype.clear.call(this)},t.search=function(e){var t=n.prototype.search.call(this,this.toBBox(e));return u(t)},t.collides=function(e){return n.prototype.collides.call(this,this.toBBox(e))},t.all=function(){var e=n.prototype.all.call(this);return u(e)},t.toJSON=function(){return n.prototype.toJSON.call(this)},t.fromJSON=function(e){return n.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=a(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=a(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}e.exports=c,e.exports.default=c},"./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js"(e,t){function r(e,t,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=t||{},n.geometry=e,n}function n(e,t,n){if(void 0===n&&(n={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function o(e,t,n){void 0===n&&(n={});for(var o=0,i=e;o<i.length;o++){var a=i[o];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 r({type:"Polygon",coordinates:e},t,n)}function i(e,t,n){if(void 0===n&&(n={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:e},t,n)}function a(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function s(e,t,n){return void 0===n&&(n={}),r({type:"MultiLineString",coordinates:e},t,n)}function u(e,t,n){return void 0===n&&(n={}),r({type:"MultiPoint",coordinates:e},t,n)}function c(e,t,n){return void 0===n&&(n={}),r({type:"MultiPolygon",coordinates:e},t,n)}function l(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e*n}function d(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e/n}function p(e){return e%(2*Math.PI)*180/Math.PI}function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.earthRadius=6371008.8,t.factors={centimeters:100*t.earthRadius,centimetres:100*t.earthRadius,degrees:t.earthRadius/111325,feet:3.28084*t.earthRadius,inches:39.37*t.earthRadius,kilometers:t.earthRadius/1e3,kilometres:t.earthRadius/1e3,meters:t.earthRadius,metres:t.earthRadius,miles:t.earthRadius/1609.344,millimeters:1e3*t.earthRadius,millimetres:1e3*t.earthRadius,nauticalmiles:t.earthRadius/1852,radians:1,yards:1.0936*t.earthRadius},t.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/t.earthRadius,yards:1.0936133},t.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},t.feature=r,t.geometry=function(e,t,r){switch(void 0===r&&(r={}),e){case"Point":return n(t).geometry;case"LineString":return i(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return u(t).geometry;case"MultiLineString":return s(t).geometry;case"MultiPolygon":return c(t).geometry;default:throw new Error(e+" is invalid")}},t.point=n,t.points=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return n(e,t)}),r)},t.polygon=o,t.polygons=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return o(e,t)}),r)},t.lineString=i,t.lineStrings=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return i(e,t)}),r)},t.featureCollection=a,t.multiLineString=s,t.multiPoint=u,t.multiPolygon=c,t.geometryCollection=function(e,t,n){return void 0===n&&(n={}),r({type:"GeometryCollection",geometries:e},t,n)},t.round=function(e,t){if(void 0===t&&(t=0),t&&!(t>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,t||0);return Math.round(e*r)/r},t.radiansToLength=l,t.lengthToRadians=d,t.lengthToDegrees=function(e,t){return p(d(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=p,t.degreesToRadians=function(e){return e%360*Math.PI/180},t.convertLength=function(e,t,r){if(void 0===t&&(t="kilometers"),void 0===r&&(r="kilometers"),!(e>=0))throw new Error("length must be a positive number");return l(d(e,t),r)},t.convertArea=function(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t.areaFactors[r];if(!o)throw new Error("invalid original units");var i=t.areaFactors[n];if(!i)throw new Error("invalid final units");return e/o*i},t.isNumber=f,t.isObject=function(e){return!!e&&e.constructor===Object},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!f(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},"./node_modules/geojson-rbush/node_modules/@turf/meta/dist/js/index.js"(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r("./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js");function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,p=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var E=s.type;switch(p=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(c,f,v,S,w))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,w))return!1;f++,"MultiPoint"===E&&S++}"LineString"===E&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,S,w))return!1;f++}"MultiLineString"===E&&S++,"Polygon"===E&&w++}"Polygon"===E&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,S,w))return!1;f++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature(e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature(l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,d=h,void(a=0);var y=n.lineString([u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString(a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point(c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point(c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point(c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point(c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point(c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point(c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString([c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString([c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString([c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString([c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},"./node_modules/rbush/rbush.min.js"(e){e.exports=function(){function e(e,n,o,i,a){!function e(r,n,o,i,a){for(;i>o;){if(i-o>600){var s=i-o+1,u=n-o+1,c=Math.log(s),l=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(r,n,Math.max(o,Math.floor(n-u*l/s+d)),Math.min(i,Math.floor(n+(s-u)*l/s+d)),a)}var p=r[n],f=o,h=i;for(t(r,o,n),a(r[i],p)>0&&t(r,o,i);f<h;){for(t(r,f,h),f++,h--;a(r[f],p)<0;)f++;for(;a(r[h],p)>0;)h--}0===a(r[o],p)?t(r,o,h):t(r,++h,i),h<=n&&(o=h+1),n<=h&&(i=h-1)}}(e,n,o||0,i||e.length-1,a||r)}function t(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function r(e,t){return e<t?-1:e>t?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(e,t,r){if(!r)return t.indexOf(e);for(var n=0;n<t.length;n++)if(r(e,t[n]))return n;return-1}function i(e,t){a(e,0,e.children.length,t,e)}function a(e,t,r,n,o){o||(o=h(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(var i=t;i<r;i++){var a=e.children[i];s(o,e.leaf?n(a):a)}return o}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function u(e,t){return e.minX-t.minX}function c(e,t){return e.minY-t.minY}function l(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function p(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function f(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function h(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(t,r,n,o,i){for(var a=[r,n];a.length;)if(!((n=a.pop())-(r=a.pop())<=o)){var s=r+Math.ceil((n-r)/o/2)*o;e(t,s,r,n,i),a.push(r,s,s,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,r=[];if(!f(e,t))return r;for(var n=this.toBBox,o=[];t;){for(var i=0;i<t.children.length;i++){var a=t.children[i],s=t.leaf?n(a):a;f(e,s)&&(t.leaf?r.push(a):p(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r},n.prototype.collides=function(e){var t=this.data;if(!f(e,t))return!1;for(var r=[];t;){for(var n=0;n<t.children.length;n++){var o=t.children[n],i=t.leaf?this.toBBox(o):o;if(f(e,i)){if(t.leaf||p(e,i))return!0;r.push(o)}}t=r.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var r=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var n=this.data;this.data=r,r=n}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=h([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var r,n,i,a=this.data,s=this.toBBox(e),u=[],c=[];a||u.length;){if(a||(a=u.pop(),n=u[u.length-1],r=c.pop(),i=!0),a.leaf){var l=o(e,a.children,t);if(-1!==l)return a.children.splice(l,1),u.push(a),this._condense(u),this}i||a.leaf||!p(a,s)?n?(r++,a=n.children[r],i=!1):a=null:(u.push(a),c.push(r),r=0,n=a,a=a.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var r=[];e;)e.leaf?t.push.apply(t,e.children):r.push.apply(r,e.children),e=r.pop();return t},n.prototype._build=function(e,t,r,n){var o,a=r-t+1,s=this._maxEntries;if(a<=s)return i(o=h(e.slice(t,r+1)),this.toBBox),o;n||(n=Math.ceil(Math.log(a)/Math.log(s)),s=Math.ceil(a/Math.pow(s,n-1))),(o=h([])).leaf=!1,o.height=n;var u=Math.ceil(a/s),c=u*Math.ceil(Math.sqrt(s));y(e,t,r,c,this.compareMinX);for(var l=t;l<=r;l+=c){var d=Math.min(l+c-1,r);y(e,l,d,u,this.compareMinY);for(var p=l;p<=d;p+=u){var f=Math.min(p+u-1,d);o.children.push(this._build(e,p,f,n-1))}}return i(o,this.toBBox),o},n.prototype._chooseSubtree=function(e,t,r,n){for(;n.push(t),!t.leaf&&n.length-1!==r;){for(var o=1/0,i=1/0,a=void 0,s=0;s<t.children.length;s++){var u=t.children[s],c=l(u),d=(p=e,f=u,(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.minY))-c);d<i?(i=d,o=c<o?c:o,a=u):d===i&&c<o&&(o=c,a=u)}t=a||t.children[0]}var p,f;return t},n.prototype._insert=function(e,t,r){var n=r?e:this.toBBox(e),o=[],i=this._chooseSubtree(n,this.data,t,o);for(i.children.push(e),s(i,n);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(n,o,t)},n.prototype._split=function(e,t){var r=e[t],n=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,n);var a=this._chooseSplitIndex(r,o,n),s=h(r.children.splice(a,r.children.length-a));s.height=r.height,s.leaf=r.leaf,i(r,this.toBBox),i(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(r,s)},n.prototype._splitRoot=function(e,t){this.data=h([e,t]),this.data.height=e.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,r){for(var n,o,i,s,u,c,d,p=1/0,f=1/0,h=t;h<=r-t;h++){var y=a(e,0,h,this.toBBox),g=a(e,h,r,this.toBBox),m=(o=y,i=g,void 0,void 0,void 0,void 0,s=Math.max(o.minX,i.minX),u=Math.max(o.minY,i.minY),c=Math.min(o.maxX,i.maxX),d=Math.min(o.maxY,i.maxY),Math.max(0,c-s)*Math.max(0,d-u)),v=l(y)+l(g);m<p?(p=m,n=h,f=v<f?v:f):m===p&&v<f&&(f=v,n=h)}return n||r-t},n.prototype._chooseSplitAxis=function(e,t,r){var n=e.leaf?this.compareMinX:u,o=e.leaf?this.compareMinY:c;this._allDistMargin(e,t,r,n)<this._allDistMargin(e,t,r,o)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,r,n){e.children.sort(n);for(var o=this.toBBox,i=a(e,0,t,o),u=a(e,r-t,r,o),c=d(i)+d(u),l=t;l<r-t;l++){var p=e.children[l];s(i,e.leaf?o(p):p),c+=d(i)}for(var f=r-t-1;f>=t;f--){var h=e.children[f];s(u,e.leaf?o(h):h),c+=d(u)}return c},n.prototype._adjustParentBBoxes=function(e,t,r){for(var n=r;n>=0;n--)s(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,r=void 0;t>=0;t--)0===e[t].children.length?t>0?(r=e[t-1].children).splice(r.indexOf(e[t]),1):this.clear():i(e[t],this.toBBox)},n}()},"./node_modules/wgs84/index.js"(e){e.exports.RADIUS=6378137,e.exports.FLATTENING=1/298.257223563,e.exports.POLAR_RADIUS=6356752.3142},"./node_modules/@turf/bbox/dist/cjs/index.cjs"(e,t,r){var n=r("./node_modules/@turf/meta/dist/cjs/index.cjs");var o=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return n.coordEach.call(void 0,e,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r};t.Ay=o},"./node_modules/@turf/helpers/dist/cjs/index.cjs"(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*r,kilometers:6371.0088,kilometres:6371.0088,meters:r,metres:r,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:r/1852,radians:1,yards:6967335.223679999},o={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function i(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function a(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!g(e[0])||!g(e[1]))throw new Error("coordinates must contain numbers");return i({type:"Point",coordinates:e},t,r)}function s(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return i({type:"Polygon",coordinates:e},t,r)}function u(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return i({type:"LineString",coordinates:e},t,r)}function c(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function l(e,t,r={}){return i({type:"MultiLineString",coordinates:e},t,r)}function d(e,t,r={}){return i({type:"MultiPoint",coordinates:e},t,r)}function p(e,t,r={}){return i({type:"MultiPolygon",coordinates:e},t,r)}function f(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e*r}function h(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e/r}function y(e){return e%(2*Math.PI)*180/Math.PI}function g(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}t.areaFactors=o,t.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},t.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},t.convertArea=function(e,t="meters",r="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const n=o[t];if(!n)throw new Error("invalid original units");const i=o[r];if(!i)throw new Error("invalid final units");return e/n*i},t.convertLength=function(e,t="kilometers",r="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return f(h(e,t),r)},t.degreesToRadians=function(e){return e%360*Math.PI/180},t.earthRadius=r,t.factors=n,t.feature=i,t.featureCollection=c,t.geometry=function(e,t,r={}){switch(e){case"Point":return a(t).geometry;case"LineString":return u(t).geometry;case"Polygon":return s(t).geometry;case"MultiPoint":return d(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return p(t).geometry;default:throw new Error(e+" is invalid")}},t.geometryCollection=function(e,t,r={}){return i({type:"GeometryCollection",geometries:e},t,r)},t.isNumber=g,t.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},t.lengthToDegrees=function(e,t){return y(h(e,t))},t.lengthToRadians=h,t.lineString=u,t.lineStrings=function(e,t,r={}){return c(e.map(e=>u(e,t)),r)},t.multiLineString=l,t.multiPoint=d,t.multiPolygon=p,t.point=a,t.points=function(e,t,r={}){return c(e.map(e=>a(e,t)),r)},t.polygon=s,t.polygons=function(e,t,r={}){return c(e.map(e=>s(e,t)),r)},t.radiansToDegrees=y,t.radiansToLength=f,t.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const r=Math.pow(10,t||0);return Math.round(e*r)/r},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!g(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},"./node_modules/@turf/meta/dist/cjs/index.cjs"(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r("./node_modules/@turf/helpers/dist/cjs/index.cjs");function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,p=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var E=s.type;switch(p=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(c,f,v,S,w))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,w))return!1;f++,"MultiPoint"===E&&S++}"LineString"===E&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,S,w))return!1;f++}"MultiLineString"===E&&S++,"Polygon"===E&&w++}"Polygon"===E&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,S,w))return!1;f++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature.call(void 0,e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature.call(void 0,l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,d=h,void(a=0);var y=n.lineString.call(void 0,[u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString.call(void 0,a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point.call(void 0,c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point.call(void 0,c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point.call(void 0,c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point.call(void 0,c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point.call(void 0,c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point.call(void 0,c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString.call(void 0,[c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString.call(void 0,[c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString.call(void 0,[c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString.call(void 0,[c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},"./plugins/beta/draw-ml/src/manifest.js"(t,r,n){n.d(r,{manifest:()=>Ra}),n.r(r);var o={};n.r(o),n.d(o,{LAT_MAX:()=>V,LAT_MIN:()=>F,LAT_RENDERED_MAX:()=>D,LAT_RENDERED_MIN:()=>N,LNG_MAX:()=>U,LNG_MIN:()=>R,activeStates:()=>k,classes:()=>P,cursors:()=>O,events:()=>T,geojsonTypes:()=>_,interactions:()=>j,meta:()=>A,modes:()=>C,sources:()=>M,types:()=>I,updateActions:()=>L});var i={};n.r(i),n.d(i,{isActiveFeature:()=>Y,isBackspaceKey:()=>z,isDeleteKey:()=>Z,isDigit1Key:()=>Q,isDigit2Key:()=>ee,isDigit3Key:()=>te,isDigitKey:()=>re,isEnterKey:()=>W,isEscapeKey:()=>K,isFeature:()=>J,isInactiveFeature:()=>X,isOfMetaType:()=>B,isShiftDown:()=>H,isShiftMousedown:()=>G,isTrue:()=>ne,isVertex:()=>$,noTarget:()=>q});var a={};function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function l(e,t,r){return(t=function(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}n.r(a),n.d(a,{CommonSelectors:()=>i,ModeHandler:()=>ve,StringSet:()=>le,constrainFeatureMovement:()=>Ot,createMidPoint:()=>mt,createSupplementaryPoints:()=>vt,createVertex:()=>Ke,doubleClickZoom:()=>bt,euclideanDistance:()=>ye,featuresAt:()=>pe,getFeatureAtAndSetCursors:()=>he,isClick:()=>ge,isEventAtCoordinates:()=>Nt,isTap:()=>me,mapEventToBoundingBox:()=>ue,moveFeatures:()=>It,sortFeatures:()=>se,stringSetsAreEqual:()=>Ht,theme:()=>Je,toDenseArray:()=>Ve});var d={SET_MODE:function(e,t){return c(c({},e),{},{mode:t})},SET_ACTION:function(e,t){return c(c({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return c(c({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return c(c({},e),{},{selectedVertexIndex:t.index,numVertecies:t.numVertecies})},TOGGLE_SNAP:function(e){return c(c({},e),{},{snap:!e.snap})},SET_SNAP:function(e,t){return c(c({},e),{},{snap:!!t})},SET_HAS_SNAP_LAYERS:function(e,t){return c(c({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return c(c({},e),{},{undoStackLength:t})}};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function y(e,t,r){return(t=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function m(e){var t;return!!(null!=e&&e.status&&null!=e&&e.snapStatus&&(null===(t=e.snapCoords)||void 0===t?void 0:t.length)>=2)}function v(e){return m(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function b(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function S(e,t){var r,n,o;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(r=e.snappedFeatures)&&void 0!==r&&r.length&&(e.snappedFeatures.length=0),null!==(n=e.closeFeatures)&&void 0!==n&&n.length&&(e.closeFeatures.length=0),null!==(o=e.lines)&&void 0!==o&&o.length&&(e.lines.length=0)),null!=t&&t.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}function w(e){var t,r,n;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(t=e.snappedFeatures)&&void 0!==t&&t.length&&(e.snappedFeatures.length=0),null!==(r=e.closeFeatures)&&void 0!==r&&r.length&&(e.closeFeatures.length=0),null!==(n=e.lines)&&void 0!==n&&n.length&&(e.lines.length=0))}function E(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}const P={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},M={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},O={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},I={POLYGON:"polygon",LINE:"line_string",POINT:"point"},_={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},C={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},T={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},L={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},A={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},k={ACTIVE:"true",INACTIVE:"false"},j=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],F=-90,N=-85,V=90,D=85,R=-270,U=270;function B(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function G(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function Y(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===k.ACTIVE&&e.featureTarget.properties.meta===A.FEATURE}function X(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===k.INACTIVE&&e.featureTarget.properties.meta===A.FEATURE}function q(e){return void 0===e.featureTarget}function J(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===A.FEATURE}function $(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===A.VERTEX}function H(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function K(e){return"Escape"===e.key||27===e.keyCode}function W(e){return"Enter"===e.key||13===e.keyCode}function z(e){return"Backspace"===e.key||8===e.keyCode}function Z(e){return"Delete"===e.key||46===e.keyCode}function Q(e){return"1"===e.key||49===e.keyCode}function ee(e){return"2"===e.key||50===e.keyCode}function te(e){return"3"===e.key||51===e.keyCode}function re(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function ne(){return!0}var oe=n("./node_modules/@mapbox/geojson-area/index.js");const ie={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ae(e,t){const r=ie[e.geometry.type]-ie[t.geometry.type];return 0===r&&e.geometry.type===_.POLYGON?e.area-t.area:r}const se=function(e){return e.map(e=>(e.geometry.type===_.POLYGON&&(e.area=oe.geometry({type:_.FEATURE,property:{},geometry:e.geometry})),e)).sort(ae).map(e=>(delete e.area,e))},ue=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function ce(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,r=e.length;t<r;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}ce.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},ce.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},ce.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},ce.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},ce.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const le=ce,de=[A.FEATURE,A.MIDPOINT,A.VERTEX],pe={click:function(e,t,r){return fe(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return fe(e,t,r,r.options.touchBuffer)}};function fe(e,t,r,n){if(null===r.map)return[];const o=e?ue(e,n):t,i={};r.options.styles&&(i.layers=r.options.styles.map(e=>e.id).filter(e=>null!=r.map.getLayer(e)));const a=r.map.queryRenderedFeatures(o,i).filter(e=>-1!==de.indexOf(e.properties.meta)),s=new le,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),se(u)}function he(e,t){const r=pe.click(e,null,t),n={mouse:O.NONE};return r[0]&&(n.mouse=r[0].properties.active===k.ACTIVE?O.MOVE:O.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=O.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function ye(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function ge(e,t,r={}){const n=null!=r.fineTolerance?r.fineTolerance:4,o=null!=r.grossTolerance?r.grossTolerance:12,i=null!=r.interval?r.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const a=ye(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function me(e,t,r={}){const n=null!=r.tolerance?r.tolerance:25,o=null!=r.interval?r.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,ye(e.point,t.point)<n&&t.time-e.time<o}const ve=function(e,t){const r={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===r[e])throw new Error(`Invalid event type: ${e}`);r[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=r[e];let a=i.length;for(;a--;){const e=i[a];if(e.selector(o)){e.fn.call(n,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}},be=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function Se(){return be()}const we=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||Se(),this.type=t.geometry.type};we.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},we.prototype.incomingCoords=function(e){this.setCoordinates(e)},we.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},we.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},we.prototype.setProperty=function(e,t){this.properties[e]=t},we.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:_.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},we.prototype.internal=function(e){const t={id:this.id,meta:A.FEATURE,"meta:type":this.type,active:k.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:_.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const Ee=we,xe=function(e,t){Ee.call(this,e,t)};(xe.prototype=Object.create(Ee.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},xe.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},xe.prototype.getCoordinate=function(){return this.getCoordinates()};const Pe=xe,Me=function(e,t){Ee.call(this,e,t)};(Me.prototype=Object.create(Ee.prototype)).isValid=function(){return this.coordinates.length>1},Me.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},Me.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},Me.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},Me.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const Oe=Me,Ie=function(e,t){Ee.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(Ie.prototype=Object.create(Ee.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},Ie.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},Ie.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},Ie.prototype.addCoordinate=function(e,t,r){this.changed();const n=e.split(".").map(e=>parseInt(e,10));this.coordinates[n[0]].splice(n[1],0,[t,r])},Ie.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];r&&(r.splice(t[1],1),r.length<3&&this.coordinates.splice(t[0],1))},Ie.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];return JSON.parse(JSON.stringify(r[t[1]]))},Ie.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},Ie.prototype.updateCoordinate=function(e,t,r){this.changed();const n=e.split("."),o=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,r]};const _e=Ie,Ce={MultiPoint:Pe,MultiLineString:Oe,MultiPolygon:_e},Te=(e,t,r,n,o)=>{const i=r.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return e[a][t](s,n,o)},Le=function(e,t){if(Ee.call(this,e,t),delete this.coordinates,this.model=Ce[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(Le.prototype=Object.create(Ee.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:Se(),type:_.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},Le.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Le.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Le.prototype.getCoordinate=function(e){return Te(this.features,"getCoordinate",e)},Le.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===_.POLYGON?e.getCoordinates():e.coordinates)))},Le.prototype.updateCoordinate=function(e,t,r){Te(this.features,"updateCoordinate",e,t,r),this.changed()},Le.prototype.addCoordinate=function(e,t,r){Te(this.features,"addCoordinate",e,t,r),this.changed()},Le.prototype.removeCoordinate=function(e){Te(this.features,"removeCoordinate",e),this.changed()},Le.prototype.getFeatures=function(){return this.features};const Ae=Le;function ke(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}ke.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},ke.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},ke.prototype.getSelected=function(){return this._ctx.store.getSelected()},ke.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},ke.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},ke.prototype.getFeature=function(e){return this._ctx.store.get(e)},ke.prototype.select=function(e){return this._ctx.store.select(e)},ke.prototype.deselect=function(e){return this._ctx.store.deselect(e)},ke.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},ke.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},ke.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},ke.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},ke.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},ke.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},ke.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},ke.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},ke.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},ke.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return pe[r](e,t,this._ctx)},ke.prototype.newFeature=function(e){const t=e.geometry.type;return t===_.POINT?new Pe(this._ctx,e):t===_.LINE_STRING?new Oe(this._ctx,e):t===_.POLYGON?new _e(this._ctx,e):new Ae(this._ctx,e)},ke.prototype.isInstanceOf=function(e,t){if(e===_.POINT)return t instanceof Pe;if(e===_.LINE_STRING)return t instanceof Oe;if(e===_.POLYGON)return t instanceof _e;if("MultiFeature"===e)return t instanceof Ae;throw new Error(`Unknown feature class: ${e}`)},ke.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const je=ke;ke.prototype.onSetup=function(){},ke.prototype.onDrag=function(){},ke.prototype.onClick=function(){},ke.prototype.onMouseMove=function(){},ke.prototype.onMouseDown=function(){},ke.prototype.onMouseUp=function(){},ke.prototype.onMouseOut=function(){},ke.prototype.onKeyUp=function(){},ke.prototype.onKeyDown=function(){},ke.prototype.onTouchStart=function(){},ke.prototype.onTouchMove=function(){},ke.prototype.onTouchEnd=function(){},ke.prototype.onTap=function(){},ke.prototype.onStop=function(){},ke.prototype.onTrash=function(){},ke.prototype.onCombineFeature=function(){},ke.prototype.onUncombineFeature=function(){},ke.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const Fe={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},Ne=Object.keys(Fe);const Ve=function(e){return[].concat(e).filter(e=>void 0!==e)};function De(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(M.HOT))return s();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let r=[],n=[];e.isDirty?n=e.getAllIds():(r=e.getChangedIds().filter(t=>void 0!==e.get(t)),n=e.sources.hot.filter(t=>t.properties.id&&-1===r.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===r.indexOf(t)});const i=o!==e.sources.cold.length||n.length>0;function a(r,n){const o=e.get(r).internal(t);e.ctx.events.currentModeRender(o,r=>{r.properties.mode=t,e.sources[n].push(r)})}function s(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(M.COLD).setData({type:_.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(M.HOT).setData({type:_.FEATURE_COLLECTION,features:e.sources.hot}),s()}function Re(e){let t;this._features={},this._featureIds=new le,this._selectedFeatureIds=new le,this._selectedCoordinates=[],this._changedFeatureIds=new le,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,De.call(this),this._emitSelectionChange&&(this.ctx.events.fire(T.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:_.FEATURE,properties:{},geometry:{type:_.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(T.RENDER,{})}))},this.isDirty=!1}function Ue(e,t={}){const r=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===r.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=r}Re.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Re.prototype.setDirty=function(){return this.isDirty=!0,this},Re.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(T.CREATE,{features:[t.toGeoJSON()]})}return this},Re.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(T.UPDATE,{action:t.action?t.action:L.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Re.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Re.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Re.prototype.getAllIds=function(){return this._featureIds.values()},Re.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Re.prototype.delete=function(e,t={}){const r=[];return Ve(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===r.indexOf(this._features[e])&&r.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),r.length&&this.ctx.events.fire(T.DELETE,{features:r}),Ue(this,t),this},Re.prototype.get=function(e){return this._features[e]},Re.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Re.prototype.select=function(e,t={}){return Ve(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},Re.prototype.deselect=function(e,t={}){return Ve(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),Ue(this,t),this},Re.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Re.prototype.setSelected=function(e,t={}){return e=Ve(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},Re.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Re.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Re.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Re.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Re.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Re.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Re.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:L.CHANGE_PROPERTIES})},Re.prototype.storeMapConfig=function(){j.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Re.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Re.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Be=["mode","feature","mouse"];function Ge(e){let t=null,r=null;const n={onRemove(){return e.map.off("load",n.connect),clearInterval(r),n.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",n.connect),clearInterval(r),n.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,r)=>(t[r]=function(e){const t=Object.keys(e);return function(r,n={}){let o={};const i=t.reduce((t,r)=>(t[r]=e[r],t),new je(r));return{start(){o=i.onSetup(n),Ne.forEach(t=>{const r=Fe[t];let n=()=>!1;var a;e[r]&&(n=()=>!0),this.on(t,n,(a=r,e=>i[a](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[r]),t),{});let r={},n={};const o={};let i=null,a=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:O.DRAG}),a.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!ge(r,e))},o.touchdrag=function(e){o.drag(e,e=>!me(n,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const r=he(t,e);t.featureTarget=r,a.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=he(t,e);t.featureTarget=n,a.mousedown(t)},o.mouseup=function(t){const n=he(t,e);t.featureTarget=n,ge(r,{point:t.point,time:(new Date).getTime()})?a.click(t):a.mouseup(t)},o.mouseout=function(e){a.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=pe.touch(t,null,e)[0];t.featureTarget=r,a.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return a.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=pe.touch(t,null,e)[0];t.featureTarget=r,me(n,{time:(new Date).getTime(),point:t.point})?a.tap(t):a.touchend(t)};const s=e=>{const t=z(e),r=Z(e),n=re(e);return!(t||r||n)};function u(r,n,o={}){a.stop();const s=t[r];if(void 0===s)throw new Error(`${r} is not valid`);i=r;const u=s(e,n);a=ve(u,e),o.silent||e.map.fire(T.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(P.CANVAS)&&((z(t)||Z(t))&&e.options.controls.trash?(t.preventDefault(),a.trash()):s(t)?a.keydown(t):Q(t)&&e.options.controls.point?u(C.DRAW_POINT):ee(t)&&e.options.controls.line_string?u(C.DRAW_LINE_STRING):te(t)&&e.options.controls.polygon&&u(C.DRAW_POLYGON))},o.keyup=function(e){s(e)&&a.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:r,options:n,store:o}=e;n.styles.some(e=>r.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const c={trash:!1,combineFeatures:!1,uncombineFeatures:!1},l={start(){i=e.options.defaultMode,a=ve(t[i](e),e)},changeMode:u,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(r=!0),c[e]=t[e]}),r&&e.map.fire(T.ACTIONABLE,{actions:c})},currentModeName:()=>i,currentModeRender:(e,t)=>a.render(e,t),fire(t,r){e.map&&e.map.fire(t,r)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>i};return l}(e),e.ui=function(e){const t={};let r=null,n={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(e){o=Object.assign(o,e)}function a(){if(!e.container)return;const t=[],r=[];Be.forEach(e=>{o[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==o[e]&&r.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),r.length>0&&e.container.classList.add(...r),n=Object.assign(n,o)}function s(e,t={}){const n=document.createElement("button");return n.className=`${P.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",n=>{if(n.preventDefault(),n.stopPropagation(),n.target===r)return u(),void t.onDeactivate();c(e),t.onActivate()},!0),n}function u(){r&&(r.classList.remove(P.ACTIVE_BUTTON),r=null)}function c(e){u();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(P.ACTIVE_BUTTON),r=n)}return{setActiveButton:c,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${P.CONTROL_GROUP} ${P.CONTROL_BASE}`,r?(r[I.POINT]&&(t[I.POINT]=s(I.POINT,{container:n,className:P.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(C.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[I.LINE]&&(t[I.LINE]=s(I.LINE,{container:n,className:P.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(C.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[I.POLYGON]&&(t[I.POLYGON]=s(I.POLYGON,{container:n,className:P.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(C.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=s("trash",{container:n,className:P.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=s("combineFeatures",{container:n,className:P.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=s("uncombineFeatures",{container:n,className:P.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach(e=>{const r=t[e];r.parentNode&&r.parentNode.removeChild(r),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new Re(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?n.connect():(o.on("load",n.connect),r=setInterval(()=>{o.loaded()&&n.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(M.COLD,{data:{type:_.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(M.HOT,{data:{type:_.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(M.COLD)&&e.map.removeSource(M.COLD),e.map.getSource(M.HOT)&&e.map.removeSource(M.HOT)}};return e.setup=n,n}const Ye="#3bb2d0",Xe="#fbb03b",qe="#fff",Je=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],Xe,Ye],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],Xe,Ye],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":qe}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],Xe,Ye]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":qe}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":Xe}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":Xe}}];function $e(e,t){this.x=e,this.y=t}$e.prototype={clone(){return new $e(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:$e},$e.convert=function(e){if(e instanceof $e)return e;if(Array.isArray(e))return new $e(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new $e(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const He=function(e,t){const r=t.getBoundingClientRect();return new $e(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function Ke(e,t,r,n){return{type:_.FEATURE,properties:{meta:A.VERTEX,parent:e,coord_path:r,active:n?k.ACTIVE:k.INACTIVE},geometry:{type:_.POINT,coordinates:t}}}var We=6371008.8,ze={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*We,kilometers:6371.0088,kilometres:6371.0088,meters:We,metres:We,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:We/1852,radians:1,yards:6967335.223679999};function Ze(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function Qe(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!it(e[0])||!it(e[1]))throw new Error("coordinates must contain numbers");return Ze({type:"Point",coordinates:e},t,r)}function et(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Ze({type:"Polygon",coordinates:e},t,r)}function tt(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Ze({type:"LineString",coordinates:e},t,r)}function rt(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function nt(e){return e%(2*Math.PI)*180/Math.PI}function ot(e){return e%360*Math.PI/180}function it(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function at(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,p=0,f=e.type,h="FeatureCollection"===f,y="Feature"===f,g=h?e.features.length:1,m=0;m<g;m++){s=(l=!!(c=h?e.features[m].geometry:y?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var w=a.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(u,p,m,b,S))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,S))return!1;p++,"MultiPoint"===w&&b++}"LineString"===w&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-d;o++){if(!1===t(u[n][o],p,m,b,S))return!1;p++}"MultiLineString"===w&&b++,"Polygon"===w&&S++}"Polygon"===w&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],p,m,b,S))return!1;p++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===at(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function st(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function ut(e,t){st(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(Ze(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(Ze({type:a,coordinates:c},n),r,u))return!1}})}function ct(e){const t={type:"Feature"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=lt(e.properties),null==e.geometry?t.geometry=null:t.geometry=dt(e.geometry),t}function lt(e){const t={};return e?(Object.keys(e).forEach(r=>{const n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(e=>e):t[r]=lt(n):t[r]=n}),t):t}function dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>dt(e)),t):(t.coordinates=pt(e.coordinates),t)}function pt(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>pt(e))}function ft(e,t={}){return ht(e,"mercator",t)}function ht(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&it(e[0])?e="mercator"===t?yt(e):gt(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return ct(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(e=>ct(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return dt(e);default:throw new Error("unknown GeoJSON type")}}(e)),at(e,function(e){var r="mercator"===t?yt(e):gt(e);e[0]=r[0],e[1]=r[1]})),e}function yt(e){var t,r=Math.PI/180,n=6378137,o=20037508.342789244,i=[n*(Math.abs(e[0])<=180?e[0]:e[0]-360*((t=e[0])<0?-1:t>0?1:0))*r,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*r))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function gt(e){var t=180/Math.PI,r=6378137;return[e[0]*t/r,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/r)))*t]}function mt(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>D||n[1]<N||o[1]>D||o[1]<N)return null;const i=ft(n),a=ft(o),s=e=>Number(e.toFixed(8)),u=(e,t)=>(e+t)/2,c=function(e,t={}){return ht(e,"wgs84",t)}([u(i[0],a[0]),u(i[1],a[1])]),l=[s(c[0]),s(c[1])];return{type:_.FEATURE,properties:{meta:A.MIDPOINT,parent:e,lng:l[0],lat:l[1],coord_path:r.properties.coord_path},geometry:{type:_.POINT,coordinates:l}}}const vt=function e(t,r={},n=null){const{type:o,coordinates:i}=t.geometry,a=t.properties&&t.properties.id;let s=[];function u(e,t){let n="",o=null;e.forEach((e,i)=>{const u=null!=t?`${t}.${i}`:String(i),l=Ke(a,e,u,c(u));if(r.midpoints&&o){const e=mt(a,o,l);e&&s.push(e)}o=l;const d=JSON.stringify(e);n!==d&&s.push(l),0===i&&(n=d)})}function c(e){return!!r.selectedPaths&&-1!==r.selectedPaths.indexOf(e)}return o===_.POINT?s.push(Ke(a,i,n,c(n))):o===_.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===_.LINE_STRING?u(i,n):0===o.indexOf(_.MULTI_PREFIX)&&function(){const n=o.replace(_.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:_.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},bt={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:St,LAT_MAX:wt,LAT_RENDERED_MIN:Et,LAT_RENDERED_MAX:xt,LNG_MIN:Pt,LNG_MAX:Mt}=o;function Ot(e,t){let r=St,n=wt,o=St,i=wt,a=Mt,s=Pt;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],r=[e.geometry.coordinates].flat(t),n=r.map(e=>e[0]),o=r.map(e=>e[1]),i=e=>Math.min.apply(null,e),a=e=>Math.max.apply(null,e);return[i(n),i(o),a(n),a(o)]}(e),u=t[1],c=t[3],l=t[0],d=t[2];u>r&&(r=u),c<n&&(n=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),d>s&&(s=d)});const u=t;return r+u.lat>xt&&(u.lat=xt-r),o+u.lat>wt&&(u.lat=wt-o),n+u.lat<Et&&(u.lat=Et-n),i+u.lat<St&&(u.lat=St-i),a+u.lng<=Pt&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=Mt&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function It(e,t){const r=Ot(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+r.lng,lat:e[1]+r.lat};return[t.lng,t.lat]},o=e=>e.map(e=>n(e));let i;e.type===_.POINT?i=n(t):e.type===_.LINE_STRING||e.type===_.MULTI_POINT?i=t.map(n):e.type===_.POLYGON||e.type===_.MULTI_LINE_STRING?i=t.map(o):e.type===_.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const _t={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(T.UPDATE,{action:L.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let r=!1;if(e.length>1){r=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(r=!1)})}const n=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:n,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new le).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){bt.enable(this)},onMouseMove:function(e,t){return J(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};_t.onTap=_t.onClick=function(e,t){return q(t)?this.clickAnywhere(e,t):B(A.VERTEX)(t)?this.clickOnVertex(e,t):J(t)?this.clickOnFeature(e,t):void 0},_t.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),bt.enable(this),this.stopExtendedInteractions(e)},_t.clickOnVertex=function(e,t){this.changeMode(C.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:O.MOVE})},_t.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},_t.clickOnFeature=function(e,t){bt.disable(this),this.stopExtendedInteractions(e);const r=H(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==_.POINT)return this.changeMode(C.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:O.POINTER}),1===n.length&&bt.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:O.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:O.MOVE})),this.doRender(o)},_t.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),Y(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&G(t)?this.startBoxSelect(e,t):void 0},_t.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=He(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},_t.onTouchStart=function(e,t){if(Y(t))return this.startOnActiveFeature(e,t)},_t.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},_t.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:O.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(P.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=He(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,r.x),o=Math.max(e.boxSelectStartLocation.x,r.x),i=Math.min(e.boxSelectStartLocation.y,r.y),a=Math.max(e.boxSelectStartLocation.y,r.y),s=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=s,e.boxSelectElement.style.WebkitTransform=s,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=a-i+"px"},_t.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};It(this.getSelected(),r),e.dragMoveLocation=t.lngLat},_t.onTouchEnd=_t.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,He(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,r,"click"),o=this.getUniqueIds(n).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:O.MOVE}))}this.stopExtendedInteractions(e)},_t.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?k.ACTIVE:k.INACTIVE,r(t),this.fireActionable(),t.properties.active===k.ACTIVE&&t.geometry.type!==_.POINT&&vt(t).forEach(r)},_t.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},_t.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],r=[],n=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==n)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),r.push(i.toGeoJSON())}if(r.length>1){const e=this.newFeature({type:_.FEATURE,properties:r[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(T.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},_t.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],r=[];for(let n=0;n<e.length;n++){const o=e[n];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))}t.length>1&&this.fire(T.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const Ct=_t,Tt=B(A.VERTEX),Lt=B(A.MIDPOINT),At={fireUpdate:function(){this.fire(T.UPDATE,{action:L.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(r.coord_path);H(t)||-1!==n?H(t)&&-1===n&&e.selectedCoordPaths.push(r.coord_path):e.selectedCoordPaths=[r.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties;e.feature.addCoordinate(r.coord_path,r.lng,r.lat),this.fireUpdate(),e.selectedCoordPaths=[r.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,r){It(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=Ot(n.map(e=>({type:_.FEATURE,properties:{},geometry:{type:_.POINT,coordinates:e}})),r);for(let t=0;t<n.length;t++){const r=n[t];e.feature.updateCoordinate(e.selectedCoordPaths[t],r[0]+o.lng,r[1]+o.lat)}},clickNoTarget:function(){this.changeMode(C.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(C.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,r=this.getFeature(t);if(!r)throw new Error("You must provide a featureId to enter direct_select mode");if(r.type===_.POINT)throw new TypeError("direct_select mode doesn't handle point features");const n={featureId:t,feature:r,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,n.selectedCoordPaths)),this.setSelected(t),bt.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){bt.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=k.ACTIVE,r(t),vt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=k.INACTIVE,r(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(C.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=Y(t),n=Tt(t),o=Lt(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:O.MOVE}):this.updateUIClasses({mouse:O.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};At.onTouchStart=At.onMouseDown=function(e,t){return Tt(t)?this.onVertex(e,t):Y(t)?this.onFeature(e,t):Lt(t)?this.onMidpoint(e,t):void 0},At.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,r):this.dragFeature(e,t,r),e.dragMoveLocation=t.lngLat},At.onClick=function(e,t){return q(t)?this.clickNoTarget(e,t):Y(t)?this.clickActiveFeature(e,t):X(t)?this.clickInactive(e,t):void this.stopDragging(e)},At.onTap=function(e,t){return q(t)?this.clickNoTarget(e,t):Y(t)?this.clickActiveFeature(e,t):X(t)?this.clickInactive(e,t):void 0},At.onTouchEnd=At.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const kt=At,jt={onSetup:function(){const e=this.newFeature({type:_.FEATURE,properties:{},geometry:{type:_.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT)}};jt.onTap=jt.onClick=function(e,t){this.updateUIClasses({mouse:O.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(T.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.point.id]})},jt.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},jt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?k.ACTIVE:k.INACTIVE,!n)return r(t)},jt.onTrash=jt.stopDrawingAndRemove,jt.onKeyUp=function(e,t){if(K(t)||W(t))return this.stopDrawingAndRemove(e,t)};const Ft=jt,Nt=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Vt={onSetup:function(){const e=this.newFeature({type:_.FEATURE,properties:{},geometry:{type:_.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),bt.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Nt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:O.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:O.POINTER})}};Vt.onTap=Vt.onClick=function(e,t){return $(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Vt.onKeyUp=function(e,t){K(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT)):W(t)&&this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Vt.onStop=function(e){this.updateUIClasses({mouse:O.NONE}),bt.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(T.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT,{},{silent:!0})))},Vt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?k.ACTIVE:k.INACTIVE,!n)return r(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=A.FEATURE,r(Ke(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(Ke(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(r({type:_.FEATURE,properties:t.properties,geometry:{coordinates:e,type:_.LINE_STRING}}),3===o)return}return r(t)}},Vt.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT)};const Dt=Vt,Rt={onSetup:function(e){const t=(e=e||{}).featureId;let r,n,o="forward";if(t){if(r=this.getFeature(t),!r)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const a=r.coordinates.length-1;if(r.coordinates[a][0]===i[0]&&r.coordinates[a][1]===i[1])n=a+1,r.addCoordinate(n,...r.coordinates[a]);else{if(r.coordinates[0][0]!==i[0]||r.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,r.addCoordinate(n,...r.coordinates[0])}}else r=this.newFeature({type:_.FEATURE,properties:{},geometry:{type:_.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),bt.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Nt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Nt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:O.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:O.POINTER})}};Rt.onTap=Rt.onClick=function(e,t){if($(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Rt.onKeyUp=function(e,t){W(t)?this.changeMode(C.SIMPLE_SELECT,{featureIds:[e.line.id]}):K(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT))},Rt.onStop=function(e){bt.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(T.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT,{},{silent:!0})))},Rt.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(C.SIMPLE_SELECT)},Rt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?k.ACTIVE:k.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=A.FEATURE,r(Ke(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),r(t))};const Ut=Rt,Bt={simple_select:Ct,direct_select:kt,draw_point:Ft,draw_polygon:Dt,draw_line_string:Ut},Gt={defaultMode:C.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Je,modes:Bt,controls:{},userProperties:!1,suppressAPIEvents:!0},Yt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Xt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function qt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?M.HOT:M.COLD}))}var Jt=n("./node_modules/fast-deep-equal/index.js"),$t=n("./node_modules/@mapbox/geojson-normalize/index.js");function Ht(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const Kt={Polygon:_e,LineString:Oe,Point:Pe,MultiPolygon:Ae,MultiLineString:Ae,MultiPoint:Ae};function Wt(e){!function(e,t){const r={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},Xt,e.controls):t.controls=Object.assign({},Yt,e.controls),t=Object.assign({},Gt,t),t.styles=qt(t.styles,"cold").concat(qt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=C;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return pe.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:_.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:_.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:_.FEATURE,properties:{},geometry:{type:_.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==_.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(r),a=new le(i);return o=o.filter(e=>!a.has(e)),o.length&&t.delete(o),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify($t(t))).features.map(t=>{if(t.id=t.id||Se(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=Kt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new n(e,t);e.store.add(o,{silent:r})}else{const n=e.store.get(t.id),o=n.properties;n.properties=t.properties,Jt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),Jt(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),n},t.get=function(t){const r=e.store.get(t);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:_.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==C.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(C.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===C.DIRECT_SELECT?e.events.changeMode(C.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===C.SIMPLE_SELECT&&t.getMode()===C.SIMPLE_SELECT?(Ht(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===C.DIRECT_SELECT&&t.getMode()===C.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,o,{silent:r}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:r}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:r}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:r}),t},t.setFeatureProperty=function(n,o,i){return e.store.setFeatureProperty(n,o,i,{silent:r}),t},t}(r,t),r.api=t;const n=Ge(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=I,t.options=e}(e,this)}Wt.modes=Bt,Wt.constants=o,Wt.lib=a;const zt=Wt;var Zt={onSetup:function(){return{}},onClick:function(){return!1},onKeyUp:function(){return!1},onDrag:function(){return!1},toDisplayFeatures:function(e,t,r){t.properties.active="false",r(t)}};function Qt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return er(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?er(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var tr=function(e){if(null==e||!e.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flat(2);default:return[]}},rr=function(e){if(null==e||!e.coordinates)return[];var t=[],r=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!0}),r+=e.length});break;case"MultiLineString":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!1}),r+=e.length});break;case"MultiPolygon":e.coordinates.forEach(function(e,n){e.forEach(function(e,o){t.push({start:r,length:e.length,path:[n,o],closed:!0}),r+=e.length})})}return t},nr=function(e,t){var r,n=Qt(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t>=o.start&&t<o.start+o.length)return{segment:o,localIdx:t-o.start}}}catch(e){n.e(e)}finally{n.f()}return null},or=function(e,t){var r,n=e.geometry.coordinates,o=Qt(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},ir=function(e,t){var r,n=t.split(".").map(Number),o=Qt(rr(e));try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.path.every(function(e,t){return e===n[t]})&&n.length===i.path.length+1){var a=n[n.length-1];return i.start+a}}}catch(e){o.e(e)}finally{o.f()}return n[n.length-1]},ar=function(e,t){return{x:e.x*t,y:e.y*t}},sr=function(e){return e instanceof window.SVGElement||e.ownerSVGElement};function ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var cr={fireGeometryChange:function(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},pushUndo:function(e){var t=this.map._undoStack;t&&t.push(e)},handleUndo:function(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_vertex"===r.type?this.undoMoveVertex(e,r):"insert_vertex"===r.type?this.undoInsertVertex(e,r):"delete_vertex"===r.type&&this.undoDeleteVertex(e,r)}},undoMoveVertex:function(e,t){var r=t.vertexIndex,n=t.previousPosition,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=rr(i),u=nr(s,r);if(u){or(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,ar(this.map.project(c),e.scale))}}},undoInsertVertex:function(e,t){var r=t.vertexIndex,n=t.featureId,o=this.getFeature(n);if(o){var i=o.toGeoJSON(),a=rr(o),s=nr(a,r);s&&(or(i,s.segment.path).splice(s.localIdx,1),this._applyUndoAndSync(e,i,n),this.clearSelectedCoordinates(),this.hideTouchVertexIndicator(e),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null}))}},undoDeleteVertex:function(e,t){var r=t.vertexIndex,n=t.position,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=rr(i),u=nr(s,r);if(!u){var c,l=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return ur(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(s);try{for(l.s();!(c=l.n()).done;){var d=c.value;if(r===d.start+d.length){u={segment:d,localIdx:d.length};break}}}catch(e){l.e(e)}finally{l.f()}}if(u){or(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o);var p=e.vertecies[r];p&&this.updateTouchVertexTarget(e,ar(this.map.project(p),e.scale)),this.changeMode(e,{selectedVertexIndex:r,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,r)})}}},_applyUndoAndSync:function(e,t,r){this._ctx.api.add(t),e.vertecies=this.getVerticies(r),e.midpoints=this.getMidpoints(r),this._ctx.store.render(),this.fireGeometryChange(e)}};function lr(e){return lr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lr(e)}function dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function pr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function fr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pr(Object(r),!0).forEach(function(t){hr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function hr(e,t,r){return(t=function(e){var t=function(e){if("object"!=lr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=lr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==lr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var yr={addTouchVertexTarget:function(e){var t=e.container.querySelector("[data-touch-vertex-target]");t||(e.container.insertAdjacentHTML("beforeend","\n <svg width='48' height='48' viewBox='0 0 48 48' fill-rule='evenodd' style='display:none;position:absolute;top:50%;left:50%;margin:24px 0 0 -24px' class='touch-vertex-target' data-touch-vertex-target>\n <circle cx='24' cy='24' r='24' fill='currentColor'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill=\"#fff\"/>\n </svg>\n"),t=e.container.querySelector("[data-touch-vertex-target]")),e.touchVertexTarget=t},updateTouchVertexTarget:function(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator:function(e){e.touchVertexTarget.style.display="none"},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"pointer",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||sr(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){w(g(this.map)),null!=e&&e.featureId&&(this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&void 0!==e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=void 0,e._touchMoved=!1)},onTap:function(e,t){var r,n,o=g(this.map);o&&S(o,this.map);var i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if("vertex"===i){var s=this.getFeature(e.featureId),u=ir(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(fr(fr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){var r;w(g(this.map));var n,o=null===(r=e.vertecies)||void 0===r?void 0:r[e.selectedVertexIndex];if(o&&sr(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return dr(e)}(n=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return dr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dr(e,t):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._moveStartIndex=e.selectedVertexIndex,e._touchMoved=!1;var i=t.touches[0].clientX,a=t.touches[0].clientY,s=window.getComputedStyle(e.touchVertexTarget);e.deltaTarget={x:i-Number.parseFloat(s.left),y:a-Number.parseFloat(s.top)};var u=this.map.project(o);e.deltaVertex={x:i/e.scale-u.x,y:a/e.scale-u.y}}},onTouchmove:function(e,t){if(!(e.selectedVertexIndex<0)&&sr(t.target.parentNode)){e._touchMoved=!0;var r=t.touches[0].clientX,n=t.touches[0].clientY,o={x:r/e.scale-e.deltaVertex.x,y:n/e.scale-e.deltaVertex.y},i=this.map.unproject(o);if(E(e)){var a=g(this.map);b(a,this.map,o),i=v(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}}};function gr(e){return gr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gr(e)}function mr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function vr(e,t,r){return(t=function(e){var t=function(e){if("object"!=gr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=gr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function br(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Sr(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Sr(e,t){if(e){if("string"==typeof e)return wr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wr(e,t):void 0}}function wr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Er={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},xr={updateMidpoint:function(e){var t=this;setTimeout(function(){t.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex:function(e,t){var r=br(this.getVertexOrMidpoint(e,t),2),n=r[0],o=r[1];n<0||!o||this.changeMode(e,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mr(Object(r),!0).forEach(function(t){vr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({selectedVertexIndex:n,selectedVertexType:o},"vertex"===o&&{coordPath:this.getCoordPath(e,n)}))},getOffset:function(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?1:5,o=br(t?Er[t.key].map(function(e){return e*n}):[0,0],2),i=o[0],a=o[1];return this.map.unproject({x:r.x+i,y:r.y+a})},getNewCoord:function(e,t){return this.getOffset(tr(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},insertVertex:function(e,t){var r,n=e.selectedVertexIndex-e.vertecies.length,o=this.getOffset(e.midpoints[n],t),i=this.getFeature(e.featureId),a=i.toGeoJSON(),s=n+1,u=null,c=0,l=0,d=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Sr(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(rr(i));try{for(d.s();!(r=d.n()).done;){var p=r.value,f=p.closed?p.length:p.length-1;if(n<l+f){u=p,c=n-l+1,s=p.start+c;break}l+=f}}catch(e){d.e(e)}finally{d.f()}u&&(or(a,u.path).splice(c,0,[o.lng,o.lat]),this._ctx.api.add(a),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),this.changeMode(e,{selectedVertexIndex:s,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,s)}))},moveVertex:function(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).checkSnap&&!1!==e.enableSnap){var r,n=this.map._snapInstance;null!=n&&n.snapStatus&&(null===(r=n.snapCoords)||void 0===r?void 0:r.length)>=2&&(t={lng:n.snapCoords[0],lat:n.snapCoords[1]})}var o=this.getFeature(e.featureId),i=o.toGeoJSON(),a=rr(o),s=nr(a,e.selectedVertexIndex);s&&(or(i,s.segment.path)[s.localIdx]=[t.lng,t.lat],this._ctx.api.add(i),e.vertecies=this.getVerticies(e.featureId),this.map.fire("draw.geometrychange",e.feature))},deleteVertex:function(e){var t,r=this.getFeature(e.featureId);if(r){var n=rr(r),o=nr(n,e.selectedVertexIndex);if(o){var i=o.segment,a=i.closed?3:2;if(!(i.length<=a)){var s=function(e){if(Array.isArray(e))return wr(e)}(t=e.vertecies[e.selectedVertexIndex])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||Sr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=e.selectedVertexIndex;this._ctx.api.trash(),this.clearSelectedCoordinates(),r.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:u,position:s}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}};function Pr(e){var t={type:"Feature"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=Mr(e.properties),t.geometry=Or(e.geometry),t}function Mr(e){var t={};return e?(Object.keys(e).forEach(function(r){var n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(function(e){return e}):t[r]=Mr(n):t[r]=n}),t):t}function Or(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return Or(e)}),t):(t.coordinates=Ir(e.coordinates),t)}function Ir(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return Ir(e)})}function _r(e){for(var t,r,n=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(e),o=0,i=1;i<n.length;)t=r||n[0],o+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return o>0}function Cr(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function Tr(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function Lr(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ar(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return Tr(e,function(e){Ar(e,t)}),e;case"LineString":return kr(Lr(e),t),e;case"Polygon":return jr(Lr(e),t),e;case"MultiLineString":return Lr(e).forEach(function(e){kr(e,t)}),e;case"MultiPolygon":return Lr(e).forEach(function(e){jr(e,t)}),e;case"Point":case"MultiPoint":return e}}function kr(e,t){_r(e)===t&&e.reverse()}function jr(e,t){_r(e[0])!==t&&e[0].reverse();for(var r=1;r<e.length;r++)_r(e[r])===t&&e[r].reverse()}const Fr=function(e,t){if(!(r=t=t||{})||r.constructor!==Object)throw new Error("options is invalid");var r,n=t.reverse||!1,o=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof n)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof o)throw new Error("<mutate> must be a boolean");!1===o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Pr(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(function(e){return Pr(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Or(e);default:throw new Error("unknown GeoJSON type")}}(e));var i=[];switch(e.type){case"GeometryCollection":return Tr(e,function(e){Ar(e,n)}),e;case"FeatureCollection":return Cr(e,function(e){Cr(Ar(e,n),function(e){i.push(e)})}),function(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}(i)}return Ar(e,n)},Nr=11102230246251565e-32,Vr=134217729,Dr=(3+8*Nr)*Nr;function Rr(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],d=0,p=0;l>c==l>-c?(i=c,c=t[++d]):(i=l,l=n[++p]);let f=0;if(d<e&&p<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=l+i,s=i-(a-l),l=n[++p]),i=a,0!==s&&(o[f++]=s);d<e&&p<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p]),i=a,0!==s&&(o[f++]=s);for(;d<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d],i=a,0!==s&&(o[f++]=s);for(;p<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Ur(e){return new Float64Array(e)}const Br=Ur(4),Gr=Ur(8),Yr=Ur(12),Xr=Ur(16),qr=Ur(4);function Jr(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s,c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,d,p,f,h,y,g,m,v,b,S,w,E,x,P;const M=e-o,O=r-o,I=t-i,_=n-i;S=M*_,p=Vr*M,f=p-(p-M),h=M-f,p=Vr*_,y=p-(p-_),g=_-y,w=h*g-(S-f*y-h*y-f*g),E=I*O,p=Vr*I,f=p-(p-I),h=I-f,p=Vr*O,y=p-(p-O),g=O-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,Br[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,Br[1]=b-(m+d)+(d-E),P=v+m,d=P-v,Br[2]=v-(P-d)+(m-d),Br[3]=P;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Br),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(d=e-M,s=e-(M+d)+(d-o),d=r-O,c=r-(O+d)+(d-o),d=t-I,u=t-(I+d)+(d-i),d=n-_,l=n-(_+d)+(d-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+Dr*Math.abs(C),C+=M*l+_*s-(I*c+O*u),C>=T||-C>=T)return C;S=s*_,p=Vr*s,f=p-(p-s),h=s-f,p=Vr*_,y=p-(p-_),g=_-y,w=h*g-(S-f*y-h*y-f*g),E=u*O,p=Vr*u,f=p-(p-u),h=u-f,p=Vr*O,y=p-(p-O),g=O-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,qr[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,qr[1]=b-(m+d)+(d-E),P=v+m,d=P-v,qr[2]=v-(P-d)+(m-d),qr[3]=P;const L=Rr(4,Br,4,qr,Gr);S=M*l,p=Vr*M,f=p-(p-M),h=M-f,p=Vr*l,y=p-(p-l),g=l-y,w=h*g-(S-f*y-h*y-f*g),E=I*c,p=Vr*I,f=p-(p-I),h=I-f,p=Vr*c,y=p-(p-c),g=c-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,qr[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,qr[1]=b-(m+d)+(d-E),P=v+m,d=P-v,qr[2]=v-(P-d)+(m-d),qr[3]=P;const A=Rr(L,Gr,4,qr,Yr);S=s*l,p=Vr*s,f=p-(p-s),h=s-f,p=Vr*l,y=p-(p-l),g=l-y,w=h*g-(S-f*y-h*y-f*g),E=u*c,p=Vr*u,f=p-(p-u),h=u-f,p=Vr*c,y=p-(p-c),g=c-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,qr[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,qr[1]=b-(m+d)+(d-E),P=v+m,d=P-v,qr[2]=v-(P-d)+(m-d),qr[3]=P;const k=Rr(A,Yr,4,qr,Xr);return Xr[k-1]}(e,t,r,n,o,i,c)}function $r(e,t){var r,n,o,i,a,s,u,c,l,d=0,p=e[0],f=e[1],h=t.length;for(r=0;r<h;r++){n=0;var y=t[r],g=y.length-1;if((c=y[0])[0]!==y[g][0]&&c[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,a=c[1]-f;n<g;n++){if(s=(l=y[n+1])[0]-p,u=l[1]-f,0===a&&0===u){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(u>=0&&a<=0||u<=0&&a>=0){if(0===(o=Jr(i,s,a,u,0,0)))return 0;(o>0&&u>0&&a<=0||o<0&&u<=0&&a>0)&&d++}c=l,a=u,i=s}}return d%2!=0}Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(8),Ur(8),Ur(8),Ur(4),Ur(8),Ur(8),Ur(8),Ur(12),Ur(192),Ur(192),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(8),Ur(8),Ur(8),Ur(8),Ur(8),Ur(8),Ur(8),Ur(8),Ur(8),Ur(4),Ur(4),Ur(4),Ur(8),Ur(16),Ur(16),Ur(16),Ur(32),Ur(32),Ur(48),Ur(64),Ur(1152),Ur(1152),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(4),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(24),Ur(1152),Ur(1152),Ur(1152),Ur(1152),Ur(1152),Ur(2304),Ur(2304),Ur(3456),Ur(5760),Ur(8),Ur(8),Ur(8),Ur(16),Ur(24),Ur(48),Ur(48),Ur(96),Ur(192),Ur(384),Ur(384),Ur(384),Ur(768),Ur(96),Ur(96),Ur(96),Ur(1152);const Hr=134217729;function Kr(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],d=0,p=0;l>c==l>-c?(i=c,c=t[++d]):(i=l,l=n[++p]);let f=0;if(d<e&&p<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=l+i,s=i-(a-l),l=n[++p]),i=a,0!==s&&(o[f++]=s);d<e&&p<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p]),i=a,0!==s&&(o[f++]=s);for(;d<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d],i=a,0!==s&&(o[f++]=s);for(;p<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Wr(e){return new Float64Array(e)}const zr=Wr(4),Zr=Wr(8),Qr=Wr(12),en=Wr(16),tn=Wr(4);function rn(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s;if(0===a||0===s||a>0!=s>0)return u;const c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,d,p,f,h,y,g,m,v,b,S,w,E,x,P;const M=e-o,O=r-o,I=t-i,_=n-i;S=M*_,p=Hr*M,f=p-(p-M),h=M-f,p=Hr*_,y=p-(p-_),g=_-y,w=h*g-(S-f*y-h*y-f*g),E=I*O,p=Hr*I,f=p-(p-I),h=I-f,p=Hr*O,y=p-(p-O),g=O-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,zr[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,zr[1]=b-(m+d)+(d-E),P=v+m,d=P-v,zr[2]=v-(P-d)+(m-d),zr[3]=P;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,zr),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(d=e-M,s=e-(M+d)+(d-o),d=r-O,c=r-(O+d)+(d-o),d=t-I,u=t-(I+d)+(d-i),d=n-_,l=n-(_+d)+(d-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+33306690738754706e-32*Math.abs(C),C+=M*l+_*s-(I*c+O*u),C>=T||-C>=T)return C;S=s*_,p=Hr*s,f=p-(p-s),h=s-f,p=Hr*_,y=p-(p-_),g=_-y,w=h*g-(S-f*y-h*y-f*g),E=u*O,p=Hr*u,f=p-(p-u),h=u-f,p=Hr*O,y=p-(p-O),g=O-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,tn[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,tn[1]=b-(m+d)+(d-E),P=v+m,d=P-v,tn[2]=v-(P-d)+(m-d),tn[3]=P;const L=Kr(4,zr,4,tn,Zr);S=M*l,p=Hr*M,f=p-(p-M),h=M-f,p=Hr*l,y=p-(p-l),g=l-y,w=h*g-(S-f*y-h*y-f*g),E=I*c,p=Hr*I,f=p-(p-I),h=I-f,p=Hr*c,y=p-(p-c),g=c-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,tn[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,tn[1]=b-(m+d)+(d-E),P=v+m,d=P-v,tn[2]=v-(P-d)+(m-d),tn[3]=P;const A=Kr(L,Zr,4,tn,Qr);S=s*l,p=Hr*s,f=p-(p-s),h=s-f,p=Hr*l,y=p-(p-l),g=l-y,w=h*g-(S-f*y-h*y-f*g),E=u*c,p=Hr*u,f=p-(p-u),h=u-f,p=Hr*c,y=p-(p-c),g=c-y,x=h*g-(E-f*y-h*y-f*g),m=w-x,d=w-m,tn[0]=w-(m+d)+(d-x),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-E,d=b-m,tn[1]=b-(m+d)+(d-E),P=v+m,d=P-v,tn[2]=v-(P-d)+(m-d),tn[3]=P;const k=Kr(A,Qr,4,tn,en);return en[k-1]}(e,t,r,n,o,i,c)}Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(8),Wr(8),Wr(8),Wr(4),Wr(8),Wr(8),Wr(8),Wr(12),Wr(192),Wr(192),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(8),Wr(8),Wr(8),Wr(8),Wr(8),Wr(8),Wr(8),Wr(8),Wr(8),Wr(4),Wr(4),Wr(4),Wr(8),Wr(16),Wr(16),Wr(16),Wr(32),Wr(32),Wr(48),Wr(64),Wr(1152),Wr(1152),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(4),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(24),Wr(1152),Wr(1152),Wr(1152),Wr(1152),Wr(1152),Wr(2304),Wr(2304),Wr(3456),Wr(5760),Wr(8),Wr(8),Wr(8),Wr(16),Wr(24),Wr(48),Wr(48),Wr(96),Wr(192),Wr(384),Wr(384),Wr(384),Wr(768),Wr(96),Wr(96),Wr(96),Wr(1152);var nn=function(e,t,r,n,o){this.p1=e,this.p2=t,this.edgeType=r,this.originalIndex=n,this.polygonContourId=o,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},on=function(e){this.p=e},an=function(e,t){this.id=e,this.rawCoords=t};function sn(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var un=function(e,t,r,n){this.p=e,this.polylineEdge=t,this.polygonEdge=r,this.isHeadingIn=n,this.distanceFromPolylineEdgeStart=cn(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=cn(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function cn(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*=r,n*=n,Math.sqrt(r+n)}function ln(e,t){return e[0]*t[1]-e[1]*t[0]}function dn(e,t){return e[0]*t[0]+e[1]*t[1]}function pn(e,t,r){return[e[0]+t*r[0],e[1]+t*r[1]]}function fn(e,t,r){var n=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],o=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],i=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],a=ln(n,o),s=a*a,u=dn(n,n);if(s>0){var c=ln(i,o)/a;if(c<0||c>1)return null;var l=ln(i,n)/a;return l<0||l>1?null:0===c||1===c?r?null:[pn(e.p1.p,c,n)]:0===l||1===l?r?null:[pn(t.p1.p,l,o)]:[pn(e.p1.p,c,n)]}var d=dn(i,i);if((s=(a=ln(i,n))*a)>1e-9*u*d)return null;var p=dn(n,i)/u,f=p+dn(n,o)/u,h=Math.min(p,f),y=Math.max(p,f);return h<=1&&y>=0?1===h?r?null:[pn(e.p1.p,h>0?h:0,n)]:0===y?r?null:[pn(e.p1.p,y<1?y:1,n)]:r&&0===h&&1===y?null:[pn(e.p1.p,h>0?h:0,n),pn(e.p1.p,y<1?y:1,n)]:null}function hn(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.polygonContourId===t)return n}}function yn(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function gn(e,t){for(var r=0;r<t.length;r++){var n=t[r];if($r(e[0],[n[0]]))return void n.push(e)}t.push([e])}function mn(e,t){var r=e.polygonEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=vn(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}return r.intersectionPoints[0].incrementVisitCount(),t.push(r.intersectionPoints[0].p),r.intersectionPoints[0]}function vn(e,t){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return null}function bn(e,t){var r=e.polylineEdge;if(2===r.intersectionPoints.length){var n=r.intersectionPoints[r.intersectionPoints.length-1];if(n===e){var o=r.intersectionPoints[0];return t.push(o.p),o.incrementVisitCount(),o}return t.push(n.p),n.incrementVisitCount(),n}if(r.intersectionPoints.length>2&&r.intersectionPoints[0]!==e){var i=vn(e,r.intersectionPoints),a=r.intersectionPoints[i-1];return t.push(a.p),a.incrementVisitCount(),a}for(var s=!0;s;){if(t.push(r.p1.p),void 0===(r=r.prevEdge).originalIndex)return e;r.intersectionPoints.length>0&&(s=!1)}if(void 0===r.originalIndex)return e;var u=r.intersectionPoints[r.intersectionPoints.length-1];return u.incrementVisitCount(),t.push(u.p),u}function Sn(e,t){var r=e.polylineEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=vn(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}if(void 0===r)return e;var a=r.intersectionPoints[0];return a.incrementVisitCount(),t.push(a.p),a}function wn(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function En(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function xn(e){return"Feature"===e.type?e.geometry:e}un.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var Pn=function e(t,r,n={}){if(!0===n.final)return function(t,r){let n=e(r,t);return n=(n+180)%360,n}(t,r);const o=wn(t),i=wn(r),a=ot(o[0]),s=ot(i[0]),u=ot(o[1]),c=ot(i[1]),l=Math.sin(s-a)*Math.cos(c),d=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-a);return nt(Math.atan2(l,d))};function Mn(e,t,r,n={}){const o=wn(e),i=ot(o[0]),a=ot(o[1]),s=ot(r),u=function(e,t="kilometers"){const r=ze[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s)),l=nt(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),d=nt(c);return void 0!==o[2]?Qe([l,d,o[2]],n.properties):Qe([l,d],n.properties)}var On=Mn;function In(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=wn(e),o=xn(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let u=!1;for(var c=0;c<s.length;++c){const e=$r(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(u=!0)}return u}class _n{constructor(e=[],t=Cn){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function Cn(e,t){return e<t?-1:e>t?1:0}function Tn(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Ln(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class An{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let kn=0,jn=0,Fn=0;function Nn(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let r=0;r<n[e].length;r++){let o=n[e][r][0],i=null;jn+=1;for(let a=0;a<n[e][r].length-1;a++){i=n[e][r][a+1];const s=new An(o,kn,jn,Fn),u=new An(i,kn,jn,Fn+1);s.otherEvent=u,u.otherEvent=s,Tn(s,u)>0?(u.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(s),t.push(u),o=i,Fn+=1}}kn+=1}class Vn{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function Dn(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,u=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,l=(c-s)*(o-r)-(u-a)*(i-n);if(0===l)return!1;const d=((u-a)*(n-s)-(c-s)*(r-a))/l,p=((o-r)*(n-s)-(i-n)*(r-a))/l;return d>=0&&d<=1&&p>=0&&p<=1&&[r+d*(o-r),n+d*(i-n)]}function Rn(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(Ze(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(Ze(t));const a=function(e,t){const r=new _n([],Tn);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)Nn(r[e],t)}else Nn(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new _n([],Ln);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new Vn(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=Dn(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(rt(i),o);let s=[];if(n){const e={};a.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,s.push(t))})}else s=a;return rt(s.map(e=>Qe(e)))}function Un(e,t={}){const r=xn(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return Bn(xn(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=xn(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(Bn(e,n))}),rt(o)}(r,t);default:throw new Error("invalid poly")}}function Bn(e,t){return e.length>1?function(e,t,r={}){return Ze({type:"MultiLineString",coordinates:e},t,r)}(e,t):tt(e[0],t)}function Gn(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return ut(e,e=>{ut(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!Yn(t,e);case"Polygon":return!In(e,t)}break;case"LineString":switch(t.type){case"Point":return!Yn(e,t);case"LineString":return!function(e,t,r){return Rn(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!Xn(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!In(t,e);case"LineString":return!Xn(e,t,r);case"Polygon":return!function(e,t,r){for(const r of e.coordinates[0])if(In(r,t))return!0;for(const r of t.coordinates[0])if(In(r,e))return!0;return Rn(Un(e),Un(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}function Yn(e,t){for(let r=0;r<e.coordinates.length-1;r++)if(qn(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function Xn(e,t,r){for(const r of t.coordinates)if(In(r,e))return!0;return Rn(t,Un(e),{ignoreSelfIntersections:r}).features.length>0}function qn(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}var Jn=Object.defineProperty,$n=(e,t)=>Jn(e,"name",{value:t,configurable:!0}),Hn=class{constructor(e){var t,r,n;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(t=null==e?void 0:e.precision)?t:17),this.direction=null!=(r=null==e?void 0:e.direction)&&r,this.compareProperties=null==(n=null==e?void 0:e.compareProperties)||n}compare(e,t){if(e.type!==t.type)return!1;if(!Wn(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){const r=zn(e),n=zn(t);return r.every(e=>n.some(t=>this.compare(e,t)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((e,r)=>Math.abs(e-t[r])<this.precision)}compareLine(e,t,r=0,n=!1){if(!Wn(e,t))return!1;const o=e;let i=t;if(n&&!this.compareCoord(o[0],i[0])){const e=this.fixStartIndex(i,o);if(!e)return!1;i=e}const a=this.compareCoord(o[r],i[r]);return this.direction||a?this.comparePath(o,i):!!this.compareCoord(o[r],i[i.length-(1+r)])&&this.comparePath(o.slice().reverse(),i)}fixStartIndex(e,t){let r,n=-1;for(let r=0;r<e.length;r++)if(this.compareCoord(e[r],t[0])){n=r;break}return n>=0&&(r=[].concat(e.slice(n,e.length),e.slice(1,n+1))),r}comparePath(e,t){return e.every((e,r)=>this.compareCoord(e,t[r]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){const r=e.coordinates.slice(1,e.coordinates.length),n=t.coordinates.slice(1,t.coordinates.length);return r.every(e=>n.some(t=>this.compareLine(e,t,1,!0)))}return!1}compareGeometryCollection(e,t){return Wn(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((e,r)=>this.compare(e,t.geometries[r]))}compareFeature(e,t){return e.id===t.id&&(!this.compareProperties||Qn(e.properties,t.properties))&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return Wn(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((e,r)=>this.compare(e,t.features[r]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||!(!e.bbox||!t.bbox)&&this.compareCoord(e.bbox,t.bbox)}};$n(Hn,"GeojsonEquality");var Kn=Hn;function Wn(e,t){return e.coordinates?e.coordinates.length===t.coordinates.length:e.length===t.length}function zn(e){return e.coordinates.map(t=>({type:e.type.replace("Multi",""),coordinates:t}))}function Zn(e,t,r){return new Kn(r).compare(e,t)}function Qn(e,t){if(null===e&&null===t)return!0;if(null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o of r){const r=e[o],n=t[o],i=eo(r)&&eo(n);if(i&&!Qn(r,n)||!i&&r!==n)return!1}return!0}$n(Wn,"sameLength"),$n(zn,"explode"),$n(Zn,"geojsonEquality"),$n(Qn,"equal");var eo=$n(e=>null!=e&&"object"==typeof e,"isObject");function to(e,t,r={}){const n=wn(e),o=En(t);for(let e=0;e<o.length-1;e++){let t=!1;if(r.ignoreEndVertices&&(0===e&&(t="start"),e===o.length-2&&(t="end"),0===e&&e+1===o.length-1&&(t="both")),ro(o[e],o[e+1],n,t,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function ro(e,t,r,n,o){const i=r[0],a=r[1],s=e[0],u=e[1],c=t[0],l=t[1],d=c-s,p=l-u,f=(r[0]-s)*p-(r[1]-u)*d;if(null!==o){if(Math.abs(f)>o)return!1}else if(0!==f)return!1;return Math.abs(d)===Math.abs(p)&&0===Math.abs(d)?!n&&r[0]===e[0]&&r[1]===e[1]:n?"start"===n?Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<=c:c<=i&&i<s:p>0?u<a&&a<=l:l<=a&&a<u:"end"===n?Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<c:c<i&&i<=s:p>0?u<=a&&a<l:l<a&&a<=u:"both"===n&&(Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<c:c<i&&i<s:p>0?u<a&&a<l:l<a&&a<u):Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<=c:c<=i&&i<=s:p>0?u<=a&&a<=l:l<=a&&a<=u}function no(e,t={}){var r="object"==typeof t?t.mutate:t;if(!e)throw new Error("geojson is required");var n=function(e){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}(e),o=[];switch(n){case"LineString":o=oo(e,n);break;case"MultiLineString":case"Polygon":En(e).forEach(function(e){o.push(oo(e,n))});break;case"MultiPolygon":En(e).forEach(function(e){var t=[];e.forEach(function(e){t.push(oo(e,n))}),o.push(t)});break;case"Point":return e;case"MultiPoint":var i={};En(e).forEach(function(e){var t=e.join("-");Object.prototype.hasOwnProperty.call(i,t)||(o.push(e),i[t]=!0)});break;default:throw new Error(n+" geometry not supported")}return e.coordinates?!0===r?(e.coordinates=o,e):{type:n,coordinates:o}:!0===r?(e.geometry.coordinates=o,e):Ze({type:n,coordinates:o},e.properties,{bbox:e.bbox,id:e.id})}function oo(e,t){const r=En(e);if(2===r.length&&!io(r[0],r[1]))return r;const n=[];let o=0,i=1,a=2;for(n.push(r[o]);a<r.length;)to(r[i],tt([r[o],r[a]]))?i=a:(n.push(r[i]),o=i,i++,a=i),a++;if(n.push(r[i]),"Polygon"===t||"MultiPolygon"===t){if(to(n[0],tt([n[1],n[n.length-2]]))&&(n.shift(),n.pop(),n.push(n[0])),n.length<4)throw new Error("invalid polygon, fewer than 4 points");if(!io(n[0],n[n.length-1]))throw new Error("invalid polygon, first and last points not equal")}return n}function io(e,t){return e[0]===t[0]&&e[1]===t[1]}function ao(e,t,r={}){let n=r.precision;if(n=null==n||isNaN(n)?6:n,"number"!=typeof n||!(n>=0))throw new Error("precision must be a positive number");return xn(e).type===xn(t).type&&Zn(no(e),no(t),{precision:n})}function so(e,t){var r=xn(e),n=xn(t),o=r.type,i=n.type;switch(o){case"MultiPoint":switch(i){case"LineString":return uo(r,n);case"Polygon":return lo(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"LineString":switch(i){case"MultiPoint":return uo(n,r);case"LineString":return function(e,t){const r=Rn(e,t);if(0===r.features.length)return!1;for(const n of r.features)if(!(ao(n.geometry,Qe(e.coordinates[0]))||ao(n.geometry,Qe(e.coordinates[e.coordinates.length-1]))||ao(n.geometry,Qe(t.coordinates[0]))||ao(n.geometry,Qe(t.coordinates[t.coordinates.length-1]))))return!0;return!1}(r,n);case"Polygon":return co(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"Polygon":switch(i){case"MultiPoint":return lo(n,r);case"LineString":return co(n,r);default:throw new Error("feature2 "+i+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function uo(e,t){for(var r=!1,n=!1,o=e.coordinates.length,i=0;i<o&&!r&&!n;){for(var a=0;a<t.coordinates.length-1;a++){var s=!0;0!==a&&a!==t.coordinates.length-2||(s=!1),po(t.coordinates[a],t.coordinates[a+1],e.coordinates[i],s)?r=!0:n=!0}i++}return r&&n}function co(e,t){return Rn(e,Un(t)).features.length>0}function lo(e,t){var r=!1,n=!1,o=e.coordinates.length;for(let i=0;i<o&&(!r||!n);i++)In(Qe(e.coordinates[i]),t)?r=!0:n=!0;return n&&r}function po(e,t,r,n){var o=r[0]-e[0],i=r[1]-e[1],a=t[0]-e[0],s=t[1]-e[1];return 0===o*s-i*a&&(n?Math.abs(a)>=Math.abs(s)?a>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:s>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1]:Math.abs(a)>=Math.abs(s)?a>0?e[0]<r[0]&&r[0]<t[0]:t[0]<r[0]&&r[0]<e[0]:s>0?e[1]<r[1]&&r[1]<t[1]:t[1]<r[1]&&r[1]<e[1])}function fo(e){return e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]}function ho(e){for(var t=0;t<e.length-1;t++)for(var r=e[t],n=t+1;n<e.length-2;n++)if(to(r,tt([e[n],e[n+1]])))return!0;return!1}function yo(e,t,r){for(var n=et(e),o=r+1;o<t.length;o++)if(!Gn(n,et(t[o]))&&so(n,tt(t[o][0])))return!1;return!0}function go(e){let t=0;if(e&&e.length>0){t+=Math.abs(vo(e[0]));for(let r=1;r<e.length;r++)t-=Math.abs(vo(e[r]))}return t}var mo=Math.PI/180;function vo(e){const t=e.length-1;if(t<=2)return 0;let r=0,n=0;for(;n<t;){const o=e[n],i=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*mo,u=i[1]*mo;r+=(a[0]*mo-s)*Math.sin(u),n++}return 20294876564838.72*r}var bo=function(e){return function(e){var t=0;return st(e,function(e,r,n,o,i){t=t+function(e){let t,r=0;switch(e.type){case"Polygon":return go(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)r+=go(e.coordinates[t]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),t}(e)};function So(e){return So="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},So(e)}function wo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Eo(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Eo(e,t){if(e){if("string"==typeof e)return xo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xo(e,t):void 0}}function xo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Po(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Mo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Po(Object(r),!0).forEach(function(t){Oo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Po(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Oo(e,t,r){return(t=function(e){var t=function(e){if("object"!=So(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=So(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==So(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Io=function(e,t){var r,n,o,i,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"meters",n=e.geometry.coordinates,o=[],i=Pn(n[1],n[0]),a=On(n[0],t,i,{units:r});o.push(a.geometry.coordinates);for(var s=0;s<n.length;s++){if(s>0&&s<n.length-1){var u=Pn(n[s-1],n[s]),c=On(n[s],t,u,{units:r});o.push(c.geometry.coordinates)}o.push(n[s])}var l=Pn(n[n.length-2],n[n.length-1]),d=On(n[n.length-1],t,l,{units:r});return o.push(d.geometry.coordinates),tt(o)}(t);try{i=function(e,t){var r=[],n=[],o=[],i=function(e,t,r,n,o){for(var i=0,a=[],s="Feature"===t.type?t.geometry:t,u="LineString"===s.type?[s.coordinates]:s.coordinates,c=0,l=0;l<u.length;l++){for(var d=u[l].length-1,p=new on(u[l][0]),f=null,h={nextEdge:null},y=0;y<d;y++){f=new on(u[l][y+1]),p.nextPoint=f,f.prevPoint=p;var g=new nn(p,f,"polyline",c,null);n.push(g),h.nextEdge=g,g.prevEdge=h,o[0]=Math.min(o[0],p.p[0]),o[1]=Math.min(o[1],p.p[1]),o[2]=Math.max(o[2],p.p[0]),o[3]=Math.max(o[3],p.p[1]),p=f,c+=1,h=g}o[0]=Math.min(o[0],u[l][d][0]),o[1]=Math.min(o[1],u[l][d][1]),o[2]=Math.max(o[2],u[l][d][0]),o[3]=Math.max(o[3],u[l][d][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,S=0;S<b;S++)for(var w=v[S].length,E=0;E<w;E++){i+=1;var x=v[S][E],P=x.length;a.push(new an(i,x));for(var M=new on(x[0]),O=M,I=void 0,_=null,C={nextEdge:null,prevEdge:null},T=null,L=1;L<P;L++)I=new on(x[L]),O.nextPoint=I,I.prevPoint=O,_=new nn(O,I,"polygon",c,i),C.nextEdge=_,_.prevEdge=C,1===L&&(T=_),E>0&&(_.interiorRing=!0),_.intersectPolylineBbox=sn(_,o),r.push(_),O=I,c+=1,C=_;_.nextEdge=T,T.prevEdge=_,I.nextPoint=M.nextPoint,M.prevPoint=I.prevPoint}return a}(Fr(e),t,n,o,[1/0,1/0,1/0,1/0]);if(function(e,t,r){var n,o,i,a=t.length,s=e.length;for(n=0;n<a;n++){var u=t[n];for(o=0;o<s;o++){var c=e[o];if(c.intersectPolylineBbox&&!(c.maxX<u.minX||c.minX>u.maxX||c.maxY<u.minY||c.minY>u.maxY)){var l=fn(u,c);if(null!==l)for(i=0;i<l.length;i++){var d=rn(c.p1.p[0],c.p1.p[1],c.p2.p[0],c.p2.p[1],u.p1.p[0],u.p1.p[1]),p=new un(l[i],u,c,d>0);r.push(p)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(n,o,r),0===r.length)return e;var a={};i.forEach(function(e){return a[e.id]=0}),r.forEach(function(e){var t=e.polygonEdge.polygonContourId;a[t]=a[t]+1});for(var s=0,u=[],c=null,l=0;l<o.length;l++){var d=o[l];if(d.intersectionPoints.length>0){c=d.intersectionPoints[0];break}}for(var p=c,f={visitCount:1};c!==f&&!(s>2*r.length);){if(s=s++,f.visitCount>=2){for(var h=!1,y=0;y<r.length;y++){var g=r[y];if(g.visitCount<2){p=g,h=!0;break}}if(!h)break}p.visitCount=p.visitCount+1;var m=[];u.push(m),m.push(p.p),p.visitCount=p.visitCount+1;var v=mn(p,m),b=!1;if(v===(f=v)&&2===r.length)for(var S=0;S<r.length;S++)r[S].visitCount<2&&(b=!0);for(;v!==p||b;)(v=(v.isHeadingIn?Sn:bn)(v,m))!==p&&(v=mn(v,m)),b=!1;if(f.visitCount>=2){for(var w=!1,E=0;E<r.length;E++){var x=r[E];if(x.visitCount<2){p=x,w=!0;break}}w&&(f=p)}p=f}for(var P=u.map(function(e){return[e]}),M=Object.keys(a),O=0;O<M.length;O++){var I=M[O];0===a[I]&&gn(yn(hn(n,parseInt(I)),i),P)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:P}}}(e,a)}catch(e){return null}var s=[];if("MultiPolygon"!==i.geometry.type)return null;if(2!==i.geometry.coordinates.length)return null;s=i.geometry.coordinates.map(function(t){return et(t,e.properties)});var u=null!==(r=null!==(n=e.id)&&void 0!==n?n:null===(o=e.properties)||void 0===o?void 0:o.id)&&void 0!==r?r:"poly";return rt(s.map(function(t,r){return et(t.geometry.coordinates,Mo(Mo({},e.properties),{},{id:u}),{id:"".concat(u,"-").concat(r+1)})}))},_o=function(e,t){var r=wo(e,2),n=r[0],o=r[1],i=wo(t,2),a=i[0],s=i[1],u=function(e){return e*Math.PI/180},c=u(s-o),l=u(a-n),d=Math.pow(Math.sin(c/2),2)+Math.cos(u(o))*Math.cos(u(s))*Math.pow(Math.sin(l/2),2);return 12742e3*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))},Co=function(e){if(e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e[0].length<=1)return!0;if(e[0].length<=3)for(var r=0;r<e[0].length;r++)for(var n=r+1;n<e[0].length;n++)if(_o(e[0][r],e[0][n])<t)return!1;return!0}(e))return!0;if(!Array.isArray(e)||e.length<4)return!1;var t=e[0],r=e[e.length-1];if(t[0]!==r[0]||t[1]!==r[1])return!1;var n=et([e]);return!(!function(e){if(!e.type)return!1;const t=xn(e),r=t.type,n=t.coordinates;switch(r){case"Point":return n.length>1;case"MultiPoint":for(var o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"LineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"MultiLineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"Polygon":for(o=0;o<t.coordinates.length;o++){if(n[o].length<4)return!1;if(!fo(n[o]))return!1;if(ho(n[o]))return!1;if(o>0&&Rn(et([n[0]]),et([n[o]])).features.length>1)return!1}return!0;case"MultiPolygon":for(o=0;o<t.coordinates.length;o++)for(var i=t.coordinates[o],a=0;a<i.length;a++){if(i[a].length<4)return!1;if(!fo(i[a]))return!1;if(ho(i[a]))return!1;if(0===a&&!yo(i,t.coordinates,o))return!1;if(a>0&&Rn(et([i[0]]),et([i[a]])).features.length>1)return!1}return!0;default:return!1}}(n)||bo(n)<=0)},To=function(e,t,r){var n=t.filter(function(t,n){var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&JSON.stringify(t)!==JSON.stringify(e)});n.length||n.push(e);var o,i=n.map(function(t){return r=Math.abs(e[0]-t[0]),n=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(r,2)+Math.pow(n,2));var r,n}),a=n[i.indexOf(Math.min.apply(Math,(o=i,function(e){if(Array.isArray(e))return xo(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||Eo(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(a)})};function Lo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||jo(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ao(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=jo(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function ko(e){return function(e){if(Array.isArray(e))return Fo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||jo(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jo(e,t){if(e){if("string"==typeof e)return Fo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fo(e,t):void 0}}function Fo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var No={findVertexIndex:function(e,t,r){var n=[];return e.forEach(function(e,r){e[0]===t[0]&&e[1]===t[1]&&n.push(r)}),0===n.length?-1:1===n.length?n[0]:r>=0?n.reduce(function(e,t){return Math.abs(t-r)<Math.abs(e-r)?t:e}):n[0]},getCoordPath:function(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=rr(r),o=nr(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(ko(i.path),[a]).join(".")},syncVertices:function(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies:function(e){return tr(this.getFeature(e))||[]},getMidpoints:function(e){var t=this.getFeature(e),r=tr(t),n=rr(t);if(null==r||!r.length||!n.length)return[];var o,i=[],a=Ao(n);try{for(a.s();!(o=a.n()).done;)for(var s=o.value,u=s.closed?s.length:s.length-1,c=0;c<u;c++){var l=s.start+c,d=s.start+(c+1)%s.length,p=Lo(r[l],2),f=p[0],h=p[1],y=Lo(r[d],2),g=y[0],m=y[1];i.push([(f+g)/2,(h+m)/2])}}catch(e){a.e(e)}finally{a.f()}return i},getVertexOrMidpoint:function(e,t){var r,n,o=this;if(null!==(r=e.vertecies)&&void 0!==r&&r.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertecies)||void 0===n||!n.length)return[-1,null];var i=function(e){return e?Object.values(o.map.project(e)):null},a=[].concat(ko(e.vertecies.map(i)),ko(e.midpoints.map(i))).filter(Boolean);if(!a.length)return[-1,null];var s=a[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),u=To(s,a,t);return[u,u<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=rr(n),i=t.split(".").map(Number),a=0,s=Ao(o);try{for(s.s();!(r=s.n()).done;){var u=r.value;if(u.path.every(function(e,t){return e===i[t]})&&i.length===u.path.length+1){var c=i[i.length-1],l=c>0?c-1:u.length-2;return e.vertecies.length+a+l}a+=u.closed?u.length:u.length-1}}catch(e){s.e(e)}finally{s.f()}return e.vertecies.length}};function Vo(e){return Vo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vo(e)}function Do(e){return function(e){if(Array.isArray(e))return Uo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ro(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ro(e,t){if(e){if("string"==typeof e)return Uo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Uo(e,t):void 0}}function Uo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Bo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Go(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Bo(Object(r),!0).forEach(function(t){Yo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Bo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Yo(e,t,r){return(t=function(e){var t=function(e){if("object"!=Vo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Vo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Vo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Xo=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),qo={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Jo=Go(Go(Go(Go(Go(Go({},kt),cr),yr),xr),No),{},{onSetup:function(e){var t,r,n=this,o=kt.onSetup.call(this,e);Object.assign(o,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:o.featureId||e.featureId,selectedVertexIndex:null!==(t=e.selectedVertexIndex)&&void 0!==t?t:-1,selectedVertexType:e.selectedVertexType,coordPath:e.coordPath,scale:null!==(r=e.scale)&&void 0!==r?r:1});var i=this.getFeature(o.featureId);o.featureType=null==i?void 0:i.type,o.vertecies=this.getVerticies(o.featureId),o.midpoints=this.getMidpoints(o.featureId),this.setupEventListeners(o),"midpoint"===e.selectedVertexType?(o.selectedCoordPaths=[],this.clearSelectedCoordinates(),o.feature&&o.feature.changed(),this._ctx.store.render(),this.updateMidpoint(o.midpoints[e.selectedVertexIndex-o.vertecies.length])):-1===e.selectedVertexIndex&&(o.selectedCoordPaths=[],this.clearSelectedCoordinates(),o.feature&&o.feature.changed(),this._ctx.store.render()),this.addTouchVertexTarget(o);var a=g(this.map);if(a&&S(a,this.map),"touch"===o.interfaceType&&o.selectedVertexIndex>=0&&"vertex"===o.selectedVertexType){var s=o.vertecies[o.selectedVertexIndex];s&&setTimeout(function(){n.updateTouchVertexTarget(o,ar(n.map.project(s),o.scale))},0)}return o._ignorePointermoveDeselect=!0,setTimeout(function(){o._ignorePointermoveDeselect=!1},100),o},setupEventListeners:function(e){var t=this,r=function(r){return function(n){return r.call(t,e,n)}},n=this.handlers={keydown:r(this.onKeydown),keyup:r(this.onKeyup),pointerdown:r(this.onPointerevent),pointermove:r(this.onPointerevent),pointerup:r(this.onPointerevent),click:r(this.onButtonClick),touchstart:r(this.onTouchstart),touchmove:r(this.onTouchmove),touchend:r(this.onTouchend),selectionchange:r(this.onSelectionChange),scalechange:r(this.onScaleChange),update:r(this.onUpdate),move:r(this.onMove)};window.addEventListener("keydown",n.keydown,{capture:!0}),window.addEventListener("keyup",n.keyup,{capture:!0}),window.addEventListener("click",n.click),e.container.addEventListener("pointerdown",n.pointerdown),e.container.addEventListener("pointermove",n.pointermove),e.container.addEventListener("pointerup",n.pointerup),e.container.addEventListener("touchstart",n.touchstart,{passive:!1}),e.container.addEventListener("touchmove",n.touchmove,{passive:!1}),e.container.addEventListener("touchend",n.touchend,{passive:!1}),this.map.on("draw.selectionchange",n.selectionchange),this.map.on("draw.scalechange",n.scalechange),this.map.on("draw.update",n.update),this.map.on("move",n.move)},onSelectionChange:function(e,t){var r,n,o=null===(r=t.points[t.points.length-1])||void 0===r?void 0:r.geometry.coordinates;if("keyboard"!==e.interfaceType&&o&&!e.coordPath){var i,a=null===(i=t.features[0])||void 0===i?void 0:i.geometry,s=tr(a);e.selectedVertexIndex=this.findVertexIndex(s,o,e.selectedVertexIndex)}null!==(n=e.selectedVertexType)&&void 0!==n||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null),this.map.fire("draw.vertexselection",{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertecies:e.vertecies.length});var u=o||(e.selectedVertexIndex>=0?e.vertecies[e.selectedVertexIndex]:null);this.updateTouchVertexTarget(e,u?ar(this.map.project(u),e.scale):null)},onScaleChange:function(e,t){e.scale=t.scale},onUpdate:function(e){var t,r=new Set(e.vertecies.map(function(e){return JSON.stringify(e)}));r.size!==e.vertecies.length&&(e.selectedVertexIndex=e.vertecies.findIndex(function(e){return!r.has(JSON.stringify(e))}),null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null))},onKeydown:function(e,t){if(e.container.contains(document.activeElement)){if(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "===t.key&&e.selectedVertexIndex<0){var r,n,o=g(this.map);if(o&&S(o,this.map),null!==(r=e.vertecies)&&void 0!==r&&r.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertecies)||void 0===n||!n.length)return;return e.isPanEnabled=!1,this.updateVertex(e)}if(!t.altKey&&Xo.has(t.key)&&e.selectedVertexIndex>=0){if(t.preventDefault(),t.stopPropagation(),"midpoint"===e.selectedVertexType)return this.insertVertex(e,t);var i=g(this.map),a=this.getFeature(e.featureId);if(!a)return;var s=tr(a),u=null==s?void 0:s[e.selectedVertexIndex];if(!u)return;if(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=Do(u),e._keyboardMoveStartIndex=e.selectedVertexIndex),E(e)&&e._isSnapped&&i){var c=function(e){var t,r;return null!==(t=null==e||null===(r=e.options)||void 0===r?void 0:r.radius)&&void 0!==t?t:15}(i)+1,l=this.map.project(u),d=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Ro(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(qo[t.key].map(function(e){return e*c}),2),p=d[0],f=d[1];return e._isSnapped=!1,S(i,this.map),this.moveVertex(e,this.map.unproject({x:l.x+p,y:l.y+f}))}var h=this.getNewCoord(e,t);return E(e)&&i&&(b(i,this.map,this.map.project(h)),m(i))?(e._isSnapped=!0,this.moveVertex(e,v(i))):(e._isSnapped=!1,this.moveVertex(e,h))}if(t.altKey&&Xo.has(t.key)&&e.selectedVertexIndex>=0)return t.preventDefault(),t.stopPropagation(),this.updateVertex(e,t.key);if("Escape"===t.key&&this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}),"z"===t.key&&(t.metaKey||t.ctrlKey)&&!t.shiftKey){var y,w=null===(y=document.activeElement)||void 0===y?void 0:y.tagName;if("INPUT"===w||"TEXTAREA"===w)return;return t.preventDefault(),t.stopPropagation(),this.handleUndo(e)}}},onKeyup:function(e,t){e.container.contains(document.activeElement)&&(e.interfaceType="keyboard",Xo.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&void 0!==e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=void 0)),"Delete"===t.key&&this.deleteVertex(e))},onMouseDown:function(e,t){var r,n;w(g(this.map));var o=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,i=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(o)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,kt.onMouseDown.call(this,e,t),"vertex"===o&&i)){var a,s=this.getFeature(e.featureId),u=ir(s,i);e.selectedVertexIndex=u,e.selectedVertexType="vertex",e.coordPath=i;var c=null===(a=e.vertecies)||void 0===a?void 0:a[u];c&&(e._moveStartPosition=Do(c),e._moveStartIndex=u)}if("midpoint"===o){var l=this.getFeature(e.featureId),d=ir(l,i);e._insertedVertexIndex=d,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,i),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire("draw.vertexselection",{index:e.selectedVertexIndex,numVertecies:e.vertecies.length})}},onMouseUp:function(e,t){w(g(this.map));var r=!1;if(e._moveStartPosition&&void 0!==e._moveStartIndex){var n=this.getFeature(e.featureId);if(n){var o,i=null===(o=tr(n))||void 0===o?void 0:o[e._moveStartIndex];i&&(r=i[0]!==e._moveStartPosition[0]||i[1]!==e._moveStartPosition[1])}}var a=e._isInsertingVertex&&void 0!==e._insertedVertexIndex;if(e.dragMoving||r||a)if(this.syncVertices(e),a){var s=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),e.selectedVertexIndex=s,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=void 0,this.map.fire("draw.vertexselection",{index:s,numVertecies:e.vertecies.length})}else r&&e._moveStartPosition&&void 0!==e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition});e._moveStartPosition=null,e._moveStartIndex=null,kt.onMouseUp.call(this,e,t)},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=g(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),E(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),b(n,this.map,t.point);var o=v(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else kt.onDrag.call(this,e,t)}},onMove:function(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,ar(this.map.project(t),e.scale))},onButtonClick:function(e,t){t.target.closest("#".concat(e.deleteVertexButtonId))&&"vertex"===e.selectedVertexType&&this.deleteVertex(e),t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},clickNoTarget:function(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},changeMode:function(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",Go(Go({},e),t))},onStop:function(e){var t=this.handlers;e.container.removeEventListener("pointerdown",t.pointerdown),e.container.removeEventListener("pointermove",t.pointermove),e.container.removeEventListener("pointerup",t.pointerup),e.container.removeEventListener("touchstart",t.touchstart),e.container.removeEventListener("touchmove",t.touchmove),e.container.removeEventListener("touchend",t.touchend),this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.scalechange",t.scalechange),this.map.off("draw.update",t.update),this.map.off("move",t.move),this.map.dragPan.enable(),window.removeEventListener("click",t.click),window.removeEventListener("keydown",t.keydown,{capture:!0}),window.removeEventListener("keyup",t.keyup,{capture:!0}),this.hideTouchVertexIndicator(e)}});function $o(e){return $o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$o(e)}function Ho(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Ko(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ko(e,t){if(e){if("string"==typeof e)return Wo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wo(e,t):void 0}}function Wo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function zo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Zo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?zo(Object(r),!0).forEach(function(t){Qo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Qo(e,t,r){return(t=function(e){var t=function(e){if("object"!=$o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=$o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==$o(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ei=function(e,t){var r=t.featureProp,n=t.geometryType,o=t.getCoords,i=t.validateClick,a=t.createVertices,s=t.excludeFeatureIdFromSetup,u=void 0!==s&&s,c=t.finishOnInvalidClick,l=void 0!==c&&c,d=function(e){return e[r]};return Zo(Zo({},e),{},{onSetup:function(t){var n=this,o=this.map,i=u?Zo(Zo({},t),{},{featureId:void 0}):t,a=Zo(Zo({},e.onSetup.call(this,i)),t);a[r].properties=t.properties;var s=a.container,c=a.interfaceType,l=a.vertexMarkerId,d=s.querySelector("#".concat(l));d.style.display=["touch","keyboard"].includes(c)?"block":"none",a.vertexMarker=d;var p={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,focusHandler:this.onFocus,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo};return Object.entries(p).forEach(function(e){var t,r,o=Ho(e,2);return t=o[0],r=o[1],n[t]=r.bind(n,a)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[s,"focus",this.focusHandler],[s,"blur",this.blurHandler],[s,"pointermove",this.pointermoveHandler],[s,"pointerup",this.pointerupHandler],[o,"pointerdown",this.pointerdownHandler],[o,"draw.create",this.createHandler],[o,"move",this.moveHandler],[o,"draw.undo",this.undoHandler]],this._listeners.forEach(function(e){var t=Ho(e,3),r=t[0],n=t[1],o=t[2];return r.addEventListener?r.addEventListener(n,o):r.on(n,o)}),a},onClick:function(t,r){if(!(r.originalEvent.button>0||this.map._undoInProgress||r.originalEvent.target!==this.map.getCanvas())){var n=g(this.map);if(E(t)&&m(n))r=function(e,t){var r=v(t);return r?h(h({},e),{},{lngLat:r}):e}(r,n);else{var i=o(d(t));i.length>0&&(i[i.length-1]=[r.lngLat.lng,r.lngLat.lat])}var a=o(d(t)).length;e.onClick.call(this,t,r),o(d(t)).length>a&&this.pushDrawUndo(t)}},onTap:function(){},doClick:function(t){if(!this.map._undoInProgress){var r=d(t),n=o(r);if(this.dispatchVertexChange(n),i(r)){var a=g(this.map),s=E(t)&&function(e,t){var r=v(t);if(!r)return null;var n=e.project([r.lng,r.lat]);return{lngLat:r,point:n,originalEvent:new MouseEvent("click",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}}(this.map,a),u=n.length;s?(e.onClick.call(this,t,s),this._ctx.store.render()):this._simulateMouse("click",e.onClick,t),o(d(t)).length>u&&this.pushDrawUndo(t)}else l&&n.length>1&&(n.pop(),this.map.fire("draw.create",{features:[r.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[r.id]}))}},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertecies:e.length})},pushDrawUndo:function(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:n,featureId:d(e).id})},undoVertex:function(e){var t=d(e),r=o(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_reinitializeFeature:function(t,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n){var a=this.map._undoStack;return a&&a.clear(),this._ctx.api.changeMode("draw_line",{featureId:i,container:t.container,interfaceType:t.interfaceType,vertexMarkerId:t.vertexMarkerId,addVertexButtonId:t.addVertexButtonId,getSnapEnabled:t.getSnapEnabled,properties:t.properties}),!0}var s=this.map.getCenter(),u=[[s.lng,s.lat],[s.lng,s.lat]],c=this.newFeature({type:"Feature",properties:t.properties||{},geometry:{type:n,coordinates:[u]}});return c.id=i,this._ctx.store.add(c),t[r]=c,t.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render(),this.dispatchVertexChange(u),!0},_removeLastVertex:function(e,t,r){var i="Polygon"===n?t.coordinates[0]:r;i.splice(i.length-2,1);var a,s=i[i.length-2];s&&(i[i.length-1]=function(e){if(Array.isArray(e))return Wo(e)}(a=s)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||Ko(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),e.currentVertexPosition=Math.max(1,e.currentVertexPosition-1),this._ctx.store.render(),this._updateRubberBand(e,o(t))},_updateRubberBand:function(t,r){if(["touch","keyboard"].includes(t.interfaceType))this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render();else{var o=r["Polygon"===n?r.length-2:r.length-1];if(o){var i={lng:o[0],lat:o[1]},a=this.map.project(i);e.onMouseMove.call(this,t,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render()}}this.dispatchVertexChange(r)},onUndo:function(e,t){var r;"draw_vertex"===(null===(r=t.operation)||void 0===r?void 0:r.type)&&this.undoVertex(e)},_simulateMouse:function(e,t,r){var n=this.map,o=n.getCenter(),i=n.project(o);t.call(this,r,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",r.polygon||r.line)},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&(e.vertexMarker.style.display="block")},onCreate:function(e,t){var r=this._ctx.api,n=t.features[0];r.delete(n.id),n.id=e.featureId,r.add(n,{userProperties:!0})},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onKeydown:function(e,t){var r=this;if("z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey){if(document.activeElement===e.container){if("Escape"===t.key)return t.preventDefault();"Enter"===t.key&&(e.isActive=!0),this._setInterface(e,"keyboard"),this.onMove(e,t)}}else{var n,o=null===(n=document.activeElement)||void 0===n?void 0:n.tagName;if("INPUT"===o||"TEXTAREA"===o)return;t.preventDefault(),t.stopPropagation();var i=this.map._undoStack;if(i&&i.length>0){var a=i.pop();"draw_vertex"===(null==a?void 0:a.type)&&(this.map._undoInProgress=!0,setTimeout(function(){r.map._undoInProgress=!1},100),this.undoVertex(e))}}},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e)):"keyboard"!==e.interfaceType&&this.map.fire("draw.cancel")},onKeyUp:function(t,r){var n=document.activeElement;if(!n||n===t.container||!t.container.contains(n))if("Escape"!==r.key)n!==t.container&&e.onKeyUp.call(this,t,r);else if("keyboard"===t.interfaceType){var o=this.map._undoStack;o&&o.clear(),this._reinitializeFeature(t,d(t))}},onFocus:function(e){e.vertexMarker.style.display=["touch","keyboard"].includes(e.interfaceType)?"block":"none"},onBlur:function(e,t){t.target!==e.container&&(e.vertexMarker.style.display="none")},onMouseMove:function(t,r){if(E(t)){var n=g(this.map);b(n,this.map,r.point);var o=v(n);o&&(r=Zo(Zo({},r),{},{lngLat:o}))}this.map.fire("draw.geometrychange",t.polygon||t.line),e.onMouseMove.call(this,t,r)},onMove:function(t){if(["touch","keyboard"].includes(t.interfaceType)){E(t)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(g(this.map),this.map);var r=g(this.map),n=E(t)&&v(r);if(n){var o=this.map.project([n.lng,n.lat]);e.onMouseMove.call(this,t,{lngLat:n,point:o,originalEvent:new MouseEvent("mousemove",{clientX:o.x,clientY:o.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()}else this._simulateMouse("mousemove",e.onMouseMove,t)}},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"pointer",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&(e.vertexMarker.style.display="none")},onPointerup:function(e){this.dispatchVertexChange(o(d(e)))},toDisplayFeatures:function(t,r,o){e.toDisplayFeatures.call(this,t,r,o);var i=d(t);r.geometry.type===n&&r.id===i.id&&a(r,o,Ke)},onStop:function(t){e.onStop.call(this,t),this._listeners.forEach(function(e){var t=Ho(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),t.vertexMarker.style.display="none"}})},ti=ei(Dt,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return Co(e.coordinates)},createVertices:function(e,t,r){for(var n=e.geometry.coordinates[0],o=1;o<n.length-2;o++)t(r(e.id,n[o],"0.".concat(o)))}}),ri=ei(Ut,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(t=e.coordinates).length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;if(e.length>=2){var r=e[e.length-1],n=e[e.length-2];if(_o(r,n)<t)return!1}return!0}(t);var t},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,createVertices:function(e,t,r){for(var n=e.geometry.coordinates,o=1;o<n.length-1;o++)t(r(e.id,n[o],"".concat(o)))}}),ni={editColorsForeground:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editColorsBackground:{light:"#ffffff",dark:"rgba(11,12,12,1)"},editColorsHalo:{light:"rgba(11,12,12,1)",dark:"#ffffff"},splitInvalidColors:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},splitValidColors:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},stroke:"rgba(212,53,28,1)",strokeWidth:2,fill:"rgba(212,53,28,0.1)",snapLayers:[],snapColors:{vertex:"rgba(212,53,28,1)",midpoint:"rgba(40,161,151,1)",edge:"rgba(29,112,184,1)"},snapRadius:10};function oi(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ii=function(e){var t;return null!==(t=e.mapColorScheme)&&void 0!==t?t:"light"},ai=function(e,t){return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],ni[t]]},si=function(e){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":ai(e,"fill")}}},ui=function(e){return{id:"stroke-inactive",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","false"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ai(e,"stroke"),"line-width":ai(e,"strokeWidth")}}},ci=function(e){return{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":e,"fill-opacity":.1}}},li=function(e){return{id:"stroke-active",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-opacity":1}}},di=function(e){return{id:"stroke-invalid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","invalid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},pi=function(e){return{id:"stroke-valid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","valid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-opacity":1}}},fi=function(e){return{id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},hi=function(e){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"]],paint:{"circle-radius":6,"circle-color":e}}},yi=function(e,t){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":8,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},gi=function(e){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":e}}},mi=function(e){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":4,"circle-color":e}}},vi=function(e,t){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},bi=function(e){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":4,"circle-color":e}}},Si=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},wi=function(e){var t=ni.editColorsForeground[ii(e)],r=ni.editColorsBackground[ii(e)],n=ni.editColorsHalo[ii(e)],o=ni.splitInvalidColors[ii(e)],i=ni.splitValidColors[ii(e)];return[si(e),ci(t),li(t),ui(e),di(o),pi(i),fi(t),mi(t),vi(r,n),bi(t),hi(t),yi(r,n),gi(t),Si(t),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}]},Ei=6371008.8,xi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Ei,metres:Ei,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Pi(e,t,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=t||{},n.geometry=e,n}function Mi(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ti(e[0])||!Ti(e[1]))throw new Error("coordinates must contain numbers");return Pi({type:"Point",coordinates:e},t,r)}function Oi(e,t,r){if(void 0===r&&(r={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return Pi({type:"LineString",coordinates:e},t,r)}function Ii(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function _i(e){return e%(2*Math.PI)*180/Math.PI}function Ci(e){return e%360*Math.PI/180}function Ti(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Li(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Ai(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}const ki=function(e,t,r){void 0===r&&(r={});var n=Li(e),o=Li(t),i=Ci(o[1]-n[1]),a=Ci(o[0]-n[0]),s=Ci(n[1]),u=Ci(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=xi[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)};function ji(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,p=0,f=e.type,h="FeatureCollection"===f,y="Feature"===f,g=h?e.features.length:1,m=0;m<g;m++){s=(l=!!(c=h?e.features[m].geometry:y?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var w=a.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(u,p,m,b,S))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,S))return!1;p++,"MultiPoint"===w&&b++}"LineString"===w&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-d;o++){if(!1===t(u[n][o],p,m,b,S))return!1;p++}"MultiLineString"===w&&b++,"Polygon"===w&&S++}"Polygon"===w&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],p,m,b,S))return!1;p++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===ji(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Fi(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function Ni(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(Pi(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(Pi({type:a,coordinates:c},n),r,u))return!1}})}function Vi(e,t){var r,n,o;return void 0===t&&(t={}),n=("Feature"===(r=e).type?r.geometry:r).coordinates,o=t.properties?t.properties:"Feature"===e.type?e.properties:{},n.length>1?function(e,t,r){return void 0===r&&(r={}),Pi({type:"MultiLineString",coordinates:e},t,r)}(n,o):Oi(n[0],o)}function Di(e,t,r,n){void 0===n&&(n={});var o=Li(e),i=Ci(o[0]),a=Ci(o[1]),s=Ci(r),u=function(e,t){void 0===t&&(t="kilometers");var r=xi[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return Mi([_i(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),_i(c)],n.properties)}const Ri=function(e){if(!e)throw new Error("geojson is required");var t=[];return Ni(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=Ai(n);break;case"LineString":r=[Ai(n)]}r.forEach(function(r){var n=function(e,t){var r=[];return e.reduce(function(e,n){var o,i,a,s,u,c,l=Oi([e,n],t);return l.bbox=(i=n,a=(o=e)[0],s=o[1],[a<(u=i[0])?a:u,s<(c=i[1])?s:c,a>u?a:u,s>c?s:c]),r.push(l),n}),r}(r,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),Ii(t)};var Ui=n("./node_modules/geojson-rbush/index.js");function Bi(e,t){var r=Ai(e),n=Ai(t);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],u=n[0][0],c=n[0][1],l=n[1][0],d=n[1][1],p=(d-c)*(a-o)-(l-u)*(s-i);if(0===p)return null;var f=((l-u)*(i-c)-(d-c)*(o-u))/p,h=((a-o)*(i-c)-(s-i)*(o-u))/p;return f>=0&&f<=1&&h>=0&&h<=1?Mi([o+f*(a-o),i+f*(s-i)]):null}const Gi=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=Pi(e)),"LineString"===t.type&&(t=Pi(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=Bi(e,t);return o&&n.push(o),Ii(n)}var i=Ui();return i.load(Ri(t)),Fi(Ri(e),function(e){Fi(i.search(e),function(t){var o=Bi(e,t);if(o){var i=Ai(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Ii(n)},Yi=function(e,t,r){void 0===r&&(r={});var n=Mi([1/0,1/0],{dist:1/0}),o=0;return Ni(e,function(e){for(var i=Ai(e),a=0;a<i.length-1;a++){var s=Mi(i[a]);s.properties.dist=ki(t,s,r);var u=Mi(i[a+1]);u.properties.dist=ki(t,u,r);var c=ki(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=Pn(s,u),p=Di(t,l,d+90,r),f=Di(t,l,d-90,r),h=Gi(Oi([p.geometry.coordinates,f.geometry.coordinates]),Oi([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=ki(t,y,r),y.properties.location=o+ki(s,y,r)),s.properties.dist<n.properties.dist&&((n=s).properties.index=a,n.properties.location=o),u.properties.dist<n.properties.dist&&((n=u).properties.index=a+1,n.properties.location=o+c),y&&y.properties.dist<n.properties.dist&&((n=y).properties.index=a),o+=c}}),n};var Xi=6371008.8,qi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Xi,metres:Xi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Ji(e){return e%(2*Math.PI)*180/Math.PI}function $i(e){return e%360*Math.PI/180}function Hi(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Ki(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}const Wi=function(e,t,r){void 0===r&&(r={});var n=Ki(e),o=Ki(t),i=$i(o[1]-n[1]),a=$i(o[0]-n[0]),s=$i(n[1]),u=$i(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=qi[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)},zi=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=Ki(e),i=$i(o[0]),a=$i(o[1]),s=$i(r),u=function(e,t){void 0===t&&(t="kilometers");var r=qi[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return function(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Hi(e[0])||!Hi(e[1]))throw new Error("coordinates must contain numbers");return function(e,t,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=t||{},n.geometry=e,n}({type:"Point",coordinates:e},t,r)}([Ji(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Ji(c)],n.properties)}(e,Wi(e,t)/2,Pn(e,t));return r};var Zi=function(){return Zi=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Zi.apply(this,arguments)},Qi=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],r=0;r<e.features.length;r++){var n=e.features[r],o=n.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var a=this.features.unknow.snapPoints;i=Zi(Zi({},i),a)}var s=this.doSnap(n,i);t.push(s)}else void 0!==this.features.unknow?(a=this.features.unknow.snapPoints,s=this.doSnap(n,a),t.push(s)):t.push(n)}var u={type:"FeatureCollection",features:t};this.drawing.set(u),this.onSnapped&&this.onSnapped(u)},e.prototype.isPointSnapped=function(e,t){return ki(Mi(e),Mi(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var r=e.geometry.coordinates;for(var n in t)this.isPointSnapped(r,t[n])&&(e.geometry.coordinates=t[n]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],a=0;a<o.length;a++){for(var s=o[a],u=[],c=0;c<s.length;c++){var l=s[c],d=!1;for(var n in t)if(this.isPointSnapped(l,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(l)}i.push(u)}e.geometry.coordinates=i;break;case"LineString":var p=e.geometry.coordinates;for(u=[],c=0;c<p.length;c++){var f=p[c];for(var n in d=!1,t)if(this.isPointSnapped(f,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(f)}e.geometry.coordinates=u}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,r=this.map.unproject(t),n=[t.x+this.options.radius,t.y],o=this.map.unproject(n),i=ki(Mi([r.lng,r.lat]),Mi([o.lng,o.lat]),{units:"meters"});this.radiusInMeters=i;var a=!1,s=this.getCloseFeatures(e,i);s?(this.snapStatus=!0,this.snapCoords=s.coords,a=function(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},i=[];for(let o=0;o<n;o++)i.push(Mn(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),et([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=Ii(0==a?[]:[a]);this.setMapData(u)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData(Ii([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var r=e.map.getSource("mapbox-gl-draw-hot");if(r){var n=r._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];n.features.length>0&&(n.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],r=t[0].toFixed(6),n=t[1].toFixed(6),o={};if(o["".concat(r,"_").concat(n)]=t,e){var i=e._data;if(i.features.length>0){var a=i.features.find(function(e){return"feature"==e.properties.meta});if(a){var s=a.properties.id;this.features[s]?this.features[s].snapPoints["".concat(r,"_").concat(n)]=t:this.features[s]={id:s,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(r,"_").concat(n)]=t:this.features.unknow={id:s,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,r){var n,o=(n=[],ji(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=ki(Mi(e),Mi([t.lng,t.lat]),{units:"meters"});n<r&&i.push({coords:e,dist:n,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,r){var n=[];switch(e.geometry.type){case"LineString":n.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){n.push(Oi(e))});break;case"Polygon":var o=Vi(e.geometry);n.push(o);break;case"MultiPolygon":Vi(e.geometry).coodinates.map(function(e){n.push(Oi(e))})}return n},e.prototype.searchInMidPoint=function(e,t,r){var n=this.getLines(e,t,r),o=[];n.map(function(e){o=o.concat(Ri(e).features)});var i=[];if(o.map(function(e){var n=zi(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=ki(n,Mi([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=Yi(n[i],Mi([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<r&&o.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(o.length>0)return o.sort(function(e,t){return e.dist-t.dist}),o[0]},e.prototype.getCloseFeatures=function(e,t){var r=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(r.length>0){for(var n,o=!1,i=0;i<r.length;i++){var a=r[i],s=this.options.rules,u=e.lngLat;if(o=!1,-1!==s.indexOf("vertex")&&null==n&&(n=this.searchInVertex(a,u,t))){o=!0;break}if(-1!==s.indexOf("midpoint")&&null==n&&(n=this.searchInMidPoint(a,u,t))){o=!0;break}if(-1!==s.indexOf("edge")&&null==n&&(n=this.searchInEdge(a,u,t))){o=!0;break}}return!!o&&n}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();const ea=Qi;function ta(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ra(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ta(Object(r),!0).forEach(function(t){na(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ta(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function na(e,t,r){return(t=function(e){var t=function(e){if("object"!=oa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=oa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==oa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oa(e){return oa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oa(e)}var ia="snap-helper-circle";function aa(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function sa(e){var t;if(!(!e||e._data&&Array.isArray(null===(t=e._data)||void 0===t?void 0:t.features))){var r={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:function(){return r},set:function(e){r=e&&"object"===oa(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}function ua(e){return ua="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ua(e)}function ca(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function la(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ca(Object(r),!0).forEach(function(t){da(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ca(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function da(e,t,r){return(t=function(e){var t=function(e){if("object"!=ua(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ua(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ua(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var pa=function(e){var t=e.mapStyle,r=e.mapProvider,n=e.events,o=e.eventBus,i=e.snapLayers,a=r.map;zt.constants.classes.CONTROL_BASE="maplibregl-ctrl",zt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",zt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var s=la(la({},zt.modes),{},{disabled:Zt,edit_vertex:Jo,draw_polygon:ti,draw_line:ri}),u=new zt({modes:s,styles:wi(t),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"});a.addControl(u);var c=a.getCanvas(),l=null,d=function(e){1===e.touches.length&&(l={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},p=function(e){if("disabled"===u.getMode()&&l){var t=e.changedTouches[0],r=t.clientX-l.x,n=t.clientY-l.y;Date.now()-l.time<300&&Math.abs(r)<10&&Math.abs(n)<10&&c.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY})),l=null}else l=null};c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",p,{passive:!0}),r.draw=u,r.snapEnabled=!1;var f=function(e){var t=[],r=function(){e.fire("draw.undochange",{length:t.length})};return{push:function(e){t.push(e),r()},pop:function(){var e=t.pop();return r(),e},clear:function(){t.length=0,r()},get length(){return t.length}}}(a);r.undoStack=f,a._undoStack=f,function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;var n=r.layers,o=void 0===n?[]:n,i=r.radius,a=void 0===i?15:i,s=r.rules,u=void 0===s?["vertex","midpoint","edge"]:s,c=r.status,l=void 0!==c&&c,d=r.onSnapped,p=void 0===d?function(){}:d,f=r.colors,h=void 0===f?{}:f;function y(r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,e.getLayer(ia)&&e.removeLayer(ia),e.getSource(ia)&&e.removeSource(ia),sa(r);var n=new ea({map:e,drawing:t,options:{layers:o,radius:a,rules:u},status:l,onSnapped:p}),i=l;return Object.defineProperty(n,"status",{get:function(){return i},set:function(){},configurable:!0}),n.setSnapStatus=function(e){i=e},n._defaultLayers=o,n._activeLayers=null,n.setSnapLayers=function(e){null==e?n._activeLayers=null:Array.isArray(e)&&(n._activeLayers=e)},void 0!==e._pendingSnapLayers&&(n.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=n,n}!function(e){if(!ea.prototype.__snapPatched){ea.prototype.__snapPatched=!0;var t=ea.prototype,r={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=function(){},t.setMapData=function(e){var t,n;if(this.status){var o=r.setMapData.call(this,e);return(null==e||null===(t=e.features)||void 0===t?void 0:t.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(ia)&&this.map.setLayoutProperty(ia,"visibility","visible"),o}},t.drawingSnapCheck=function(){if(this.status)return r.drawingSnapCheck.call(this)},t.getLines=function(e,t,n){var o=e.geometry;if(!o||!o.coordinates)return[];var i=o.coordinates;if(!Array.isArray(i)||0===i.length)return[];try{return"MultiPolygon"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return et(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return tt(e)}):r.getLines.call(this,e,t,n)}catch(e){return console.log(e),[]}},t.getCloseFeatures=function(e,t){var n=this;if(!this.status)return[];var o=this._activeLayers||this._defaultLayers||[];this.options.layers=o.filter(function(e){return n.map.getLayer(e)});var i=this.options.radius||15,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=r.getCloseFeatures.call(this,e,t);return e.point=a,s},t.searchInVertex=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInVertex.apply(this,n);return i&&(i.color=e.vertex),i},t.searchInMidPoint=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInMidPoint.apply(this,n);return i&&(i.color=e.midpoint),i},t.searchInEdge=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInEdge.apply(this,n);return i&&(i.color=e.edge),i},t.snapToClosestPoint=function(e){var t;if(this.status&&(null===(t=this.map)||void 0===t||!t._isZooming))try{var n,o,i=r.snapToClosestPoint.call(this,e);return(null===(n=this.closeFeatures)||void 0===n?void 0:n.length)>100&&(this.closeFeatures.length=0),(null===(o=this.lines)||void 0===o?void 0:o.length)>100&&(this.lines.length=0),i}catch(e){return console.log(e),this.snapStatus=!1,void(this.snapCoords=null)}}}}(ra(ra({},ni.snapColors),h)),e.on("style.load",function(){aa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},function(t){var r;sa(t),e.getSource(ia)||e.addSource(ia,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(ia)||e.addLayer({id:ia,type:"fill",source:ia,paint:{"fill-color":["get","color"],"fill-opacity":.6},layout:{visibility:null!==(r=e._snapInstance)&&void 0!==r&&r.status?"visible":"none"}}),e._snapInstance||y(t)})}),e.on("zoomstart",function(){e._isZooming=!0}),e.on("zoomend",function(){if(e._isZooming=!1,e.getLayer(ia)){e.setLayoutProperty(ia,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(ia,"visibility","visible")}}),aa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},y)}(a,u,{layers:i,radius:10,rules:["vertex","edge"]});var h=function(e){a.once("idle",function(){!function(e,t){wi(t).forEach(function(t){Object.entries(t.paint).forEach(function(r){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return oi(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?oi(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r,2),o=n[0],i=n[1];e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),o,i),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),o,i)})})}(a,e)})};return o.on(n.MAP_SET_STYLE,h),o.on(n.MAP_SET_SIZE,function(e){a.fire("draw.scalechange",{scale:{small:1,medium:1.5,large:2}[e]})}),{draw:u,remove:function(){c.removeEventListener("touchstart",d),c.removeEventListener("touchend",p),o.off(n.MAP_SET_STYLE,h),u.deleteAll(),u.changeMode("disabled"),a.removeControl(u)}}};function fa(e){return fa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fa(e)}function ha(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ya(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ya(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ya(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ga=["stroke","fill","strokeWidth"],ma=function(e){if(!e)return{};for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var o=ha(n[r],2),i=o[0],a=o[1];if(ga.includes(i)&&"object"===fa(a)&&null!==a){var s=Object.entries(a);s.length>0&&(t[i]=s[0][1]);for(var u=0,c=s;u<c.length;u++){var l=ha(c[u],2),d=l[0],p=l[1];t["".concat(i).concat(d.charAt(0).toUpperCase()+d.slice(1))]=p}}else t[i]=a}return t};function va(e){return va="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},va(e)}var ba=["stroke","fill","strokeWidth","properties"];function Sa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function wa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(r),!0).forEach(function(t){Ea(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sa(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ea(e,t,r){return(t=function(e){var t=function(e){if("object"!=va(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=va(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==va(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xa(e){return xa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xa(e)}var Pa=["stroke","fill","strokeWidth","properties"];function Ma(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Oa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ma(Object(r),!0).forEach(function(t){Ia(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ma(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ia(e,t,r){return(t=function(e){var t=function(e){if("object"!=xa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=xa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==xa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _a(e){return _a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_a(e)}var Ca=["stroke","fill","strokeWidth","properties"];function Ta(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function La(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ta(Object(r),!0).forEach(function(t){Aa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ta(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Aa(e,t,r){return(t=function(e){var t=function(e){if("object"!=_a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=_a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==_a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ka(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ja(e){return ja="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ja(e)}function Fa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Na(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Fa(Object(r),!0).forEach(function(t){Va(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fa(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Va(e,t,r){return(t=function(e){var t=function(e){if("object"!=ja(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ja(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ja(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Da=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},Ra={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertecies:null,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:d},InitComponent:function(t){var r=t.appState,n=t.appConfig,o=t.mapState,i=t.pluginConfig,a=t.pluginState,s=t.services,u=t.mapProvider,c=t.buttonConfig,l=s.events,d=s.eventBus,p=o.crossHair,f=["touch","keyboard"].includes(r.interfaceType);e(function(){var e,t,n,s,c,p=null===(e=null===(t=i.includeModes)||void 0===t?void 0:t.includes(r.mode))||void 0===e||e,f=null!==(n=null===(s=i.excludeModes)||void 0===s?void 0:s.includes(r.mode))&&void 0!==n&&n;if(o.isMapReady&&p&&!f){var h=pa({mapStyle:o.mapStyle,snapLayers:i.snapLayers,mapProvider:u,events:l,eventBus:d}).remove;return a.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(c=i.snapLayers)||void 0===c?void 0:c.length)>0}),d.emit("draw:ready"),function(){return h()}}},[o.isMapReady,r.mode]),e(function(){if(["draw_polygon","draw_line"].includes(a.mode)&&f){var e=p.isVisible;return p.fixAtCenter(),function(){e||p.hide()}}},[a.mode,r.interfaceType]),e(function(){if(u.draw){var e=function(e){var t=e.pluginState,r=e.mapProvider,n=e.buttonConfig,o=e.eventBus,i=n.drawDone,a=n.drawAddPoint,s=n.drawUndo,u=n.drawDeletePoint,c=n.drawSnap,l=n.drawCancel,d=r.map,p=r.draw,f=t.dispatch,h=t.feature,y=t.tempFeature,m=function(){r.snapEnabled=!1,f({type:"SET_SNAP",payload:!1});var e,t=g(d);t&&(null===(e=t.setSnapStatus)||void 0===e||e.call(t,!1),w(t)),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none")},v=function(){var e;null===(e=r.undoStack)||void 0===e||e.clear(),f({type:"SET_MODE",payload:null}),f({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}})},b=function(){null!=y&&y.id&&p.delete(y.id),h&&p.add(h),m(),p.changeMode("disabled"),v(),o.emit("draw:cancel",{originalFeature:h})},S=0,E=function(){var e,t=d.getStyle().layers||[];!t.length||null!==(e=t[t.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||t.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return d.moveLayer(e.id)})},P=function(e){return function(t){var r=t.features[0];v(),setTimeout(function(){return p.changeMode("disabled")},0),o.emit(e,{newFeature:r})}},M=P("draw:create"),O=P("draw:edit"),I=function(e){return o.emit("draw:update",e)},_=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),o.emit("draw:vertexselection",e)},C=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertecies:e.numVertecies}})},T=function(e){f({type:"SET_UNDO_STACK_LENGTH",payload:e.length})};return i.onClick=function(){var e,t,n=p.getMode(),o=p.getAll().features,i=null==o?void 0:o[0];if(m(),null===(e=r.undoStack)||void 0===e||e.clear(),"edit_vertex"!==n){if(["draw_polygon","draw_line"].includes(n)&&0!==o.length){var a=i.geometry;if("Polygon"===a.type){var s=a.coordinates[0];a.coordinates[0]=[].concat(function(e){if(Array.isArray(e))return x(e)}(t=s.slice(0,-2))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return x(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[s[0]])}else a.coordinates=a.coordinates.slice(0,-1);d.fire("draw.create",{features:[i]})}}else d.fire("draw.editfinish",{features:[i]})},l.onClick=b,s.onClick=function(){if("edit_vertex"!==p.getMode()){var e=r.undoStack;if(null!=e&&e.length){var t=e.pop();d._undoInProgress=!0,setTimeout(function(){d._undoInProgress=!1},100),d.fire("draw.undo",{operation:t})}}},c.onClick=function(){var e=Date.now();if(!(e-S<300)){S=e;var n=!t.snap;f({type:"TOGGLE_SNAP"}),r.snapEnabled=n;var o=g(d);null!=o&&o.setSnapStatus&&o.setSnapStatus(n),!n&&o&&(w(o),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none"))}},d.on("styledata",E),d.on("draw.cancel",b),d.on("draw.create",M),d.on("draw.editfinish",O),d.on("draw.update",I),d.on("draw.vertexselection",_),d.on("draw.vertexchange",C),d.on("draw.undochange",T),function(){[i,a,s,u,c,l].forEach(function(e){e&&(e.onClick=null)}),d.off("styledata",E),d.off("draw.cancel",b),d.off("draw.create",M),d.off("draw.editfinish",O),d.off("draw.update",I),d.off("draw.vertexselection",_),d.off("draw.vertexchange",C),d.off("draw.undochange",T)}}({appState:r,appConfig:n,mapState:o,mapProvider:u,buttonConfig:c,pluginState:a,events:l,eventBus:d});return function(){return e()}}},[u,r,a])},buttons:[Na({id:"drawAddPoint",label:"Add point",iconId:"plus",variant:"touch",hiddenWhen:function(e){var t=e.appState,r=e.pluginState;return!["draw_polygon","draw_line"].includes(r.mode)||"touch"!==t.interfaceType}},Da(!1)),Na({id:"drawCancel",label:"Cancel",variant:"tertiary",hiddenWhen:function(e){return!e.pluginState.mode}},Da(!0)),Na({id:"drawMenu",label:"Menu",iconId:"menu",variant:"tertiary",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){return e.pluginState.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,r=e.pluginState;return r.selectedVertexIndex>=0&&r.numVertecies>("Polygon"===(null===(t=r.tempFeature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?3:2)},hiddenWhen:function(e){var t=e.pluginState;return!["simple_select","edit_vertex"].includes(t.mode)}}]},Da(!0)),Na({id:"drawDone",label:"Done",variant:"primary",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState;return t.numVertecies>=("draw_polygon"===t.mode?3:2)}},Da(!0))],keyboardShortcuts:[{id:"drawStart",group:"Drawing",title:"Edit vertex",command:"<kbd>Spacebar</kbd></dd>"}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"check",svgContent:'<path d="M20 6 9 17l-5-5"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,d=s.draw,p=s.map,f=u.eventBus;if(d){f.emit("draw:start",{mode:"draw_polygon"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=g(p);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(p._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var m=c.stroke,v=c.fill,b=c.strokeWidth,S=c.properties,w=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,ba),E=wa(wa({},S),ma({stroke:m,fill:v,strokeWidth:b}));d.changeMode("draw_polygon",wa(wa({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},w),{},{properties:E})),l({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,d=s.draw,p=s.map,f=u.eventBus;if(d){f.emit("draw:start",{mode:"draw_line"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=g(p);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(p._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var m=c.stroke,v=c.fill,b=c.strokeWidth,S=c.properties,w=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,Pa),E=Oa(Oa({},S),ma({stroke:m,fill:v,strokeWidth:b}));d.changeMode("draw_line",Oa(Oa({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},w),{},{properties:E})),l({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.mapState,a=e.pluginConfig,s=e.pluginState,u=e.mapProvider,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=s.dispatch,d=u.draw,p=u.map;if(d&&d.get(t)){var f,h=null;h=void 0===c.snapLayers?null!==(f=a.snapLayers)&&void 0!==f?f:null:c.snapLayers;var y=g(p);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(p._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0}),d.changeMode("edit_vertex",{container:n.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(o.id,"-draw-delete-point"),undoButtonId:"".concat(o.id,"-draw-undo"),isPanEnabled:"keyboard"!==n.interfaceType,interfaceType:n.interfaceType,scale:{small:1,medium:1.5,large:2}[i.mapSize],featureId:t,getSnapEnabled:function(){return!0===u.snapEnabled}});var m=d.get(t);return l({type:"SET_FEATURE",payload:{feature:m,tempFeature:m}}),l({type:"SET_MODE",payload:"edit_vertex"}),!0}},addFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;if(o){var a=t.stroke,s=t.fill,u=t.strokeWidth,c=t.properties,l=La(La({},function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,Ca)),{},{properties:La(La({},c),ma({stroke:a,fill:s,strokeWidth:u}))});o.add(l,{userProperties:!0}),i.emit("draw:add",l)}},deleteFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;o&&(o.delete(t),i.emit("draw:delete",{featureIds:t}))},split:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginState,a=e.mapProvider,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=i.dispatch,c=a.draw,l=a.map;if(c){var d=c.get(t),p=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return ka(e)}(r=s.snapLayers||[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return ka(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ka(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=g(l);null!=f&&f.setSnapLayers?f.setSnapLayers(p):s.snapLayers&&(l._pendingSnapLayers=p),u({type:"SET_HAS_SNAP_LAYERS",payload:!0}),c.changeMode("draw_line",{container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===a.snapEnabled},featureId:"_splitter",properties:{splitter:"invalid"}}),l.on("draw.create",function(e){var t=e.features[0],r=Io(d,t);c.setFeatureProperty("_splitter","splitter",r?"valid":"invalid"),u({type:"SET_ACTION",payload:{name:"split",isValid:!!r}})});var h,y,m,v=(h=function(e){if(!(e.coordinates.length<2)){var t={id:"_splitter",geometry:{type:"LineString",coordinates:e.coordinates}},r=!!Io(d,t);e.properties.splitter=r?"valid":"invalid",e.ctx.store.render(),"edit_vertex"===c.getMode()&&u({type:"SET_ACTION",payload:{name:"split",isValid:r}})}},m=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];clearTimeout(y),y=setTimeout(function(){return h.apply(void 0,t)},50)},m.cancel=function(){clearTimeout(y),y=null},m);l.on("draw.geometrychange",v),u({type:"SET_MODE",payload:"draw_line"}),u({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){e.services,console.log("merge"),console.log(t)}}}}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e].call(i.exports,i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof c?n:c,l=Object.create(a.prototype);return s(l,"_invoke",function(r,n,o){var i,a,s,c=0,l=o||[],d=!1,p={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return i=t,a=0,s=e,p.n=r,u}};function f(r,n){for(a=r,s=n,t=0;!d&&c&&!o&&t<l.length;t++){var o,i=l[t],f=p.p,h=i[2];r>3?(o=h===n)&&(s=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=f&&((o=r<2&&f<i[1])?(a=0,p.v=n,p.n=i[1]):f<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,p.n=h,a=0))}if(o||r>1)return u;throw d=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,h),a=l,s=h;(t=a<2?e:s)||!d;){i||(a?a<3?(a>1&&(p.n=-1),f(a,s)):p.n=s:p.v=s);try{if(c=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(d=p.n<0)?s:r.call(n,p))!==u)break}catch(t){i=e,a=1,s=t}finally{c=1}}return{value:t,done:d}}}(r,o,i),!0),l}var u={};function c(){}function l(){}function d(){}t=Object.getPrototypeOf;var p=[][n]?t(t([][n]())):(s(t={},n,function(){return this}),t),f=d.prototype=c.prototype=Object.create(p);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=d,s(f,"constructor",d),s(d,"constructor",l),l.displayName="GeneratorFunction",s(d,o,"GeneratorFunction"),s(f),s(f,o,"Generator"),s(f,n,function(){return this}),s(f,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:h}})()}function s(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}s=function(e,t,r,n){function i(t,r){s(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},s(e,t,r,n)}function u(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach(function(t){d(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function d(e,t,r){return(t=function(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(){var e,t;return l(l({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(e=a().m(function e(){var t;return a().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.resolve().then(n.bind(n,"./plugins/beta/draw-ml/src/manifest.js"));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){u(i,n,o,a,s,"next",e)}function s(e){u(i,n,o,a,s,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}n.d(o,{A:()=>p});const f=o.A;export{f as default};
1
+ import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){r(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function o(){var r;return n(n({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(r=e(function*(){return(yield import(/* webpackChunkName: "im-draw-ml-plugin" */ "./im-draw-ml-plugin.js")).manifest}),function(){return r.apply(this,arguments)})})}export{o as default};