Newer
Older
DH_Apicture / public / static / libs / mapbox / extend / mapbox-gl-draw.js
@zhangqy zhangqy on 29 Nov 122 KB first commit
  1. !function (t, e) {
  2. "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).mapboxgl1.MapboxDraw = e()
  3. }(this, (function () {
  4. "use strict";
  5. const css = `
  6. /* Override default control style */
  7. .mapbox-gl-draw_ctrl-bottom-left,
  8. .mapbox-gl-draw_ctrl-top-left {
  9. margin-left:0;
  10. border-radius:0 4px 4px 0;
  11. }
  12. .mapbox-gl-draw_ctrl-top-right,
  13. .mapbox-gl-draw_ctrl-bottom-right {
  14. margin-right:0;
  15. border-radius:4px 0 0 4px;
  16. }
  17.  
  18. .mapbox-gl-draw_ctrl-draw-btn {
  19. border-color:rgba(0,0,0,0.9);
  20. color:rgba(255,255,255,0.5);
  21. width:30px;
  22. height:30px;
  23. }
  24.  
  25. .mapbox-gl-draw_ctrl-draw-btn.active,
  26. .mapbox-gl-draw_ctrl-draw-btn.active:hover {
  27. background-color:rgb(0 0 0/5%);
  28. }
  29. .mapbox-gl-draw_ctrl-draw-btn {
  30. background-repeat: no-repeat;
  31. background-position: center;
  32. }
  33.  
  34. .mapbox-gl-draw_point {
  35. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="m10 2c-3.3 0-6 2.7-6 6s6 9 6 9 6-5.7 6-9-2.7-6-6-6zm0 2c2.1 0 3.8 1.7 3.8 3.8 0 1.5-1.8 3.9-2.9 5.2h-1.7c-1.1-1.4-2.9-3.8-2.9-5.2-.1-2.1 1.6-3.8 3.7-3.8z"/>%3C/svg>');
  36. }
  37. .mapbox-gl-draw_polygon {
  38. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="m15 12.3v-4.6c.6-.3 1-1 1-1.7 0-1.1-.9-2-2-2-.7 0-1.4.4-1.7 1h-4.6c-.3-.6-1-1-1.7-1-1.1 0-2 .9-2 2 0 .7.4 1.4 1 1.7v4.6c-.6.3-1 1-1 1.7 0 1.1.9 2 2 2 .7 0 1.4-.4 1.7-1h4.6c.3.6 1 1 1.7 1 1.1 0 2-.9 2-2 0-.7-.4-1.4-1-1.7zm-8-.3v-4l1-1h4l1 1v4l-1 1h-4z"/>%3C/svg>');
  39. }
  40. .mapbox-gl-draw_line {
  41. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="m13.5 3.5c-1.4 0-2.5 1.1-2.5 2.5 0 .3 0 .6.2.9l-3.8 3.8c-.3-.1-.6-.2-.9-.2-1.4 0-2.5 1.1-2.5 2.5s1.1 2.5 2.5 2.5 2.5-1.1 2.5-2.5c0-.3 0-.6-.2-.9l3.8-3.8c.3.1.6.2.9.2 1.4 0 2.5-1.1 2.5-2.5s-1.1-2.5-2.5-2.5z"/>%3C/svg>');
  42. }
  43. .mapbox-gl-draw_trash {
  44. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="M10,3.4 c-0.8,0-1.5,0.5-1.8,1.2H5l-1,1v1h12v-1l-1-1h-3.2C11.5,3.9,10.8,3.4,10,3.4z M5,8v7c0,1,1,2,2,2h6c1,0,2-1,2-2V8h-2v5.5h-1.5V8h-3 v5.5H7V8H5z"/>%3C/svg>');
  45. }
  46. .mapbox-gl-draw_uncombine {
  47. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="m12 2c-.3 0-.5.1-.7.3l-1 1c-.4.4-.4 1 0 1.4l1 1c.4.4 1 .4 1.4 0l1-1c.4-.4.4-1 0-1.4l-1-1c-.2-.2-.4-.3-.7-.3zm4 4c-.3 0-.5.1-.7.3l-1 1c-.4.4-.4 1 0 1.4l1 1c.4.4 1 .4 1.4 0l1-1c.4-.4.4-1 0-1.4l-1-1c-.2-.2-.4-.3-.7-.3zm-7 1c-1 0-1 1-.5 1.5.3.3 1 1 1 1l-1 1s-.5.5 0 1 1 0 1 0l1-1 1 1c.5.5 1.5.5 1.5-.5v-4zm-5 3c-.3 0-.5.1-.7.3l-1 1c-.4.4-.4 1 0 1.4l4.9 4.9c.4.4 1 .4 1.4 0l1-1c.4-.4.4-1 0-1.4l-4.9-4.9c-.1-.2-.4-.3-.7-.3z"/>%3C/svg>');
  48. }
  49. .mapbox-gl-draw_combine {
  50. background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="20" height="20">%3Cpath d="M12.1,2c-0.3,0-0.5,0.1-0.7,0.3l-1,1c-0.4,0.4-0.4,1,0,1.4l4.9,4.9c0.4,0.4,1,0.4,1.4,0l1-1 c0.4-0.4,0.4-1,0-1.4l-4.9-4.9C12.6,2.1,12.3,2,12.1,2z M8,8C7,8,7,9,7.5,9.5c0.3,0.3,1,1,1,1l-1,1c0,0-0.5,0.5,0,1s1,0,1,0l1-1l1,1 C11,13,12,13,12,12V8H8z M4,10c-0.3,0-0.5,0.1-0.7,0.3l-1,1c-0.4,0.4-0.4,1,0,1.4l1,1c0.4,0.4,1,0.4,1.4,0l1-1c0.4-0.4,0.4-1,0-1.4 l-1-1C4.5,10.1,4.3,10,4,10z M8,14c-0.3,0-0.5,0.1-0.7,0.3l-1,1c-0.4,0.4-0.4,1,0,1.4l1,1c0.4,0.4,1,0.4,1.4,0l1-1 c0.4-0.4,0.4-1,0-1.4l-1-1C8.5,14.1,8.3,14,8,14z"/>%3C/svg>');
  51. }
  52.  
  53. .mapboxgl-map.mouse-pointer .mapboxgl-canvas-container.mapboxgl-interactive {
  54. cursor: pointer;
  55. }
  56. .mapboxgl-map.mouse-move .mapboxgl-canvas-container.mapboxgl-interactive {
  57. cursor: move;
  58. }
  59. .mapboxgl-map.mouse-add .mapboxgl-canvas-container.mapboxgl-interactive {
  60. cursor: crosshair;
  61. }
  62. .mapboxgl-map.mouse-move.mode-direct_select .mapboxgl-canvas-container.mapboxgl-interactive {
  63. cursor: grab;
  64. cursor: -moz-grab;
  65. cursor: -webkit-grab;
  66. }
  67. .mapboxgl-map.mode-direct_select.feature-vertex.mouse-move .mapboxgl-canvas-container.mapboxgl-interactive {
  68. cursor: move;
  69. }
  70. .mapboxgl-map.mode-direct_select.feature-midpoint.mouse-pointer .mapboxgl-canvas-container.mapboxgl-interactive {
  71. cursor: cell;
  72. }
  73. .mapboxgl-map.mode-direct_select.feature-feature.mouse-move .mapboxgl-canvas-container.mapboxgl-interactive {
  74. cursor: move;
  75. }
  76. .mapboxgl-map.mode-static.mouse-pointer .mapboxgl-canvas-container.mapboxgl-interactive {
  77. cursor: grab;
  78. cursor: -moz-grab;
  79. cursor: -webkit-grab;
  80. }
  81.  
  82. .mapbox-gl-draw_boxselect {
  83. pointer-events: none;
  84. position: absolute;
  85. top: 0;
  86. left: 0;
  87. width: 0;
  88. height: 0;
  89. background: rgba(0,0,0,.1);
  90. border: 2px dotted #fff;
  91. opacity: 0.5;
  92. }`;
  93. document.write(`<style type='text/css'>${css}</style>`);
  94. var t = function (t, e) {
  95. var n = {
  96. drag: [],
  97. click: [],
  98. mousemove: [],
  99. mousedown: [],
  100. mouseup: [],
  101. mouseout: [],
  102. keydown: [],
  103. keyup: [],
  104. touchstart: [],
  105. touchmove: [],
  106. touchend: [],
  107. tap: []
  108. }, o = {
  109. on: function (t, e, o) {
  110. if (void 0 === n[t]) throw new Error("Invalid event type: " + t);
  111. n[t].push({selector: e, fn: o})
  112. }, render: function (t) {
  113. e.store.featureChanged(t)
  114. }
  115. }, r = function (t, r) {
  116. for (var i = n[t], a = i.length; a--;) {
  117. var s = i[a];
  118. if (s.selector(r)) {
  119. s.fn.call(o, r) || e.store.render(), e.ui.updateMapClasses();
  120. break
  121. }
  122. }
  123. };
  124. return t.start.call(o), {
  125. render: t.render, stop: function () {
  126. t.stop && t.stop()
  127. }, trash: function () {
  128. t.trash && (t.trash(), e.store.render())
  129. }, combineFeatures: function () {
  130. t.combineFeatures && t.combineFeatures()
  131. }, uncombineFeatures: function () {
  132. t.uncombineFeatures && t.uncombineFeatures()
  133. }, drag: function (t) {
  134. r("drag", t)
  135. }, click: function (t) {
  136. r("click", t)
  137. }, mousemove: function (t) {
  138. r("mousemove", t)
  139. }, mousedown: function (t) {
  140. r("mousedown", t)
  141. }, mouseup: function (t) {
  142. r("mouseup", t)
  143. }, mouseout: function (t) {
  144. r("mouseout", t)
  145. }, keydown: function (t) {
  146. r("keydown", t)
  147. }, keyup: function (t) {
  148. r("keyup", t)
  149. }, touchstart: function (t) {
  150. r("touchstart", t)
  151. }, touchmove: function (t) {
  152. r("touchmove", t)
  153. }, touchend: function (t) {
  154. r("touchend", t)
  155. }, tap: function (t) {
  156. r("tap", t)
  157. }
  158. }
  159. };
  160.  
  161. function e(t) {
  162. if (t.__esModule) return t;
  163. var e = t.default;
  164. if ("function" == typeof e) {
  165. var n = function t() {
  166. if (this instanceof t) {
  167. var n = [null];
  168. n.push.apply(n, arguments);
  169. var o = Function.bind.apply(e, n);
  170. return new o
  171. }
  172. return e.apply(this, arguments)
  173. };
  174. n.prototype = e.prototype
  175. } else n = {};
  176. return Object.defineProperty(n, "__esModule", {value: !0}), Object.keys(t).forEach((function (e) {
  177. var o = Object.getOwnPropertyDescriptor(t, e);
  178. Object.defineProperty(n, e, o.get ? o : {
  179. enumerable: !0, get: function () {
  180. return t[e]
  181. }
  182. })
  183. })), n
  184. }
  185.  
  186. var n = {}, o = {RADIUS: 6378137, FLATTENING: 1 / 298.257223563, POLAR_RADIUS: 6356752.3142}, r = o;
  187.  
  188. function i(t) {
  189. var e = 0;
  190. if (t && t.length > 0) {
  191. e += Math.abs(a(t[0]));
  192. for (var n = 1; n < t.length; n++) e -= Math.abs(a(t[n]))
  193. }
  194. return e
  195. }
  196.  
  197. function a(t) {
  198. var e, n, o, i, a, u, c = 0, l = t.length;
  199. if (l > 2) {
  200. for (u = 0; u < l; u++) u === l - 2 ? (o = l - 2, i = l - 1, a = 0) : u === l - 1 ? (o = l - 1, i = 0, a = 1) : (o = u, i = u + 1, a = u + 2), e = t[o], n = t[i], c += (s(t[a][0]) - s(e[0])) * Math.sin(s(n[1]));
  201. c = c * r.RADIUS * r.RADIUS / 2
  202. }
  203. return c
  204. }
  205.  
  206. function s(t) {
  207. return t * Math.PI / 180
  208. }
  209.  
  210. n.geometry = function t(e) {
  211. var n, o = 0;
  212. switch (e.type) {
  213. case"Polygon":
  214. return i(e.coordinates);
  215. case"MultiPolygon":
  216. for (n = 0; n < e.coordinates.length; n++) o += i(e.coordinates[n]);
  217. return o;
  218. case"Point":
  219. case"MultiPoint":
  220. case"LineString":
  221. case"MultiLineString":
  222. return 0;
  223. case"GeometryCollection":
  224. for (n = 0; n < e.geometries.length; n++) o += t(e.geometries[n]);
  225. return o
  226. }
  227. }, n.ring = a;
  228. var u = {
  229. CONTROL_BASE: "mapboxgl-ctrl",
  230. CONTROL_PREFIX: "mapboxgl-ctrl-",
  231. CONTROL_BUTTON: "mapbox-gl-draw_ctrl-draw-btn",
  232. CONTROL_BUTTON_LINE: "mapbox-gl-draw_line",
  233. CONTROL_BUTTON_POLYGON: "mapbox-gl-draw_polygon",
  234. CONTROL_BUTTON_POINT: "mapbox-gl-draw_point",
  235. CONTROL_BUTTON_TRASH: "mapbox-gl-draw_trash",
  236. CONTROL_BUTTON_COMBINE_FEATURES: "mapbox-gl-draw_combine",
  237. CONTROL_BUTTON_UNCOMBINE_FEATURES: "mapbox-gl-draw_uncombine",
  238. CONTROL_GROUP: "mapboxgl-ctrl-group",
  239. ATTRIBUTION: "mapboxgl-ctrl-attrib",
  240. ACTIVE_BUTTON: "active",
  241. BOX_SELECT: "mapbox-gl-draw_boxselect"
  242. }, c = {HOT: "mapbox-gl-draw-hot", COLD: "mapbox-gl-draw-cold"},
  243. l = {ADD: "add", MOVE: "move", DRAG: "drag", POINTER: "pointer", NONE: "none"},
  244. d = {POLYGON: "polygon", LINE: "line_string", POINT: "point"}, p = {
  245. FEATURE: "Feature",
  246. POLYGON: "Polygon",
  247. LINE_STRING: "LineString",
  248. POINT: "Point",
  249. FEATURE_COLLECTION: "FeatureCollection",
  250. MULTI_PREFIX: "Multi",
  251. MULTI_POINT: "MultiPoint",
  252. MULTI_LINE_STRING: "MultiLineString",
  253. MULTI_POLYGON: "MultiPolygon"
  254. }, f = {
  255. DRAW_LINE_STRING: "draw_line_string",
  256. DRAW_POLYGON: "draw_polygon",
  257. DRAW_POINT: "draw_point",
  258. SIMPLE_SELECT: "simple_select",
  259. DIRECT_SELECT: "direct_select",
  260. STATIC: "static"
  261. }, h = {
  262. CREATE: "draw.create",
  263. DELETE: "draw.delete",
  264. UPDATE: "draw.update",
  265. SELECTION_CHANGE: "draw.selectionchange",
  266. MODE_CHANGE: "draw.modechange",
  267. ACTIONABLE: "draw.actionable",
  268. RENDER: "draw.render",
  269. COMBINE_FEATURES: "draw.combine",
  270. UNCOMBINE_FEATURES: "draw.uncombine"
  271. }, g = {MOVE: "move", CHANGE_COORDINATES: "change_coordinates"},
  272. y = {FEATURE: "feature", MIDPOINT: "midpoint", VERTEX: "vertex"}, v = {ACTIVE: "true", INACTIVE: "false"},
  273. m = ["scrollZoom", "boxZoom", "dragRotate", "dragPan", "keyboard", "doubleClickZoom", "touchZoomRotate"],
  274. _ = -85, b = Object.freeze({
  275. __proto__: null,
  276. classes: u,
  277. sources: c,
  278. cursors: l,
  279. types: d,
  280. geojsonTypes: p,
  281. modes: f,
  282. events: h,
  283. updateActions: g,
  284. meta: y,
  285. activeStates: v,
  286. interactions: m,
  287. LAT_MIN: -90,
  288. LAT_RENDERED_MIN: _,
  289. LAT_MAX: 90,
  290. LAT_RENDERED_MAX: 85,
  291. LNG_MIN: -270,
  292. LNG_MAX: 270
  293. }), E = {Point: 0, LineString: 1, MultiLineString: 1, Polygon: 2};
  294.  
  295. function T(t, e) {
  296. var n = E[t.geometry.type] - E[e.geometry.type];
  297. return 0 === n && t.geometry.type === p.POLYGON ? t.area - e.area : n
  298. }
  299.  
  300. function C(t) {
  301. return t.map((function (t) {
  302. return t.geometry.type === p.POLYGON && (t.area = n.geometry({
  303. type: p.FEATURE,
  304. property: {},
  305. geometry: t.geometry
  306. })), t
  307. })).sort(T).map((function (t) {
  308. return delete t.area, t
  309. }))
  310. }
  311.  
  312. function O(t, e) {
  313. return void 0 === e && (e = 0), [[t.point.x - e, t.point.y - e], [t.point.x + e, t.point.y + e]]
  314. }
  315.  
  316. function S(t) {
  317. if (this._items = {}, this._nums = {}, this._length = t ? t.length : 0, t) for (var e = 0, n = t.length; e < n; e++) this.add(t[e]), void 0 !== t[e] && ("string" == typeof t[e] ? this._items[t[e]] = e : this._nums[t[e]] = e)
  318. }
  319.  
  320. S.prototype.add = function (t) {
  321. return this.has(t) || (this._length++, "string" == typeof t ? this._items[t] = this._length : this._nums[t] = this._length), this
  322. }, S.prototype.delete = function (t) {
  323. return !1 === this.has(t) || (this._length--, delete this._items[t], delete this._nums[t]), this
  324. }, S.prototype.has = function (t) {
  325. return ("string" == typeof t || "number" == typeof t) && (void 0 !== this._items[t] || void 0 !== this._nums[t])
  326. }, S.prototype.values = function () {
  327. var t = this, e = [];
  328. return Object.keys(this._items).forEach((function (n) {
  329. e.push({k: n, v: t._items[n]})
  330. })), Object.keys(this._nums).forEach((function (n) {
  331. e.push({k: JSON.parse(n), v: t._nums[n]})
  332. })), e.sort((function (t, e) {
  333. return t.v - e.v
  334. })).map((function (t) {
  335. return t.k
  336. }))
  337. }, S.prototype.clear = function () {
  338. return this._length = 0, this._items = {}, this._nums = {}, this
  339. };
  340. var I = [y.FEATURE, y.MIDPOINT, y.VERTEX], x = {
  341. click: function (t, e, n) {
  342. return M(t, e, n, n.options.clickBuffer)
  343. }, touch: function (t, e, n) {
  344. return M(t, e, n, n.options.touchBuffer)
  345. }
  346. };
  347.  
  348. function M(t, e, n, o) {
  349. if (null === n.map) return [];
  350. var r = t ? O(t, o) : e, i = {};
  351. n.options.styles && (i.layers = n.options.styles.map((function (t) {
  352. return t.id
  353. })));
  354. var a = n.map.queryRenderedFeatures(r, i).filter((function (t) {
  355. return -1 !== I.indexOf(t.properties.meta)
  356. })), s = new S, u = [];
  357. return a.forEach((function (t) {
  358. var e = t.properties.id;
  359. s.has(e) || (s.add(e), u.push(t))
  360. })), C(u)
  361. }
  362.  
  363. function L(t, e) {
  364. var n = x.click(t, null, e), o = {mouse: l.NONE};
  365. return n[0] && (o.mouse = n[0].properties.active === v.ACTIVE ? l.MOVE : l.POINTER, o.feature = n[0].properties.meta), -1 !== e.events.currentModeName().indexOf("draw") && (o.mouse = l.ADD), e.ui.queueMapClasses(o), e.ui.updateMapClasses(), n[0]
  366. }
  367.  
  368. function N(t, e) {
  369. var n = t.x - e.x, o = t.y - e.y;
  370. return Math.sqrt(n * n + o * o)
  371. }
  372.  
  373. function A(t, e, n) {
  374. void 0 === n && (n = {});
  375. var o = null != n.fineTolerance ? n.fineTolerance : 4, r = null != n.grossTolerance ? n.grossTolerance : 12,
  376. i = null != n.interval ? n.interval : 500;
  377. t.point = t.point || e.point, t.time = t.time || e.time;
  378. var a = N(t.point, e.point);
  379. return a < o || a < r && e.time - t.time < i
  380. }
  381.  
  382. function P(t, e, n) {
  383. void 0 === n && (n = {});
  384. var o = null != n.tolerance ? n.tolerance : 25, r = null != n.interval ? n.interval : 250;
  385. return t.point = t.point || e.point, t.time = t.time || e.time, N(t.point, e.point) < o && e.time - t.time < r
  386. }
  387.  
  388. var F = {}, w = {
  389. get exports() {
  390. return F
  391. }, set exports(t) {
  392. F = t
  393. }
  394. }.exports = function (t, e) {
  395. if (e || (e = 16), void 0 === t && (t = 128), t <= 0) return "0";
  396. for (var n = Math.log(Math.pow(2, t)) / Math.log(e), o = 2; n === 1 / 0; o *= 2) n = Math.log(Math.pow(2, t / o)) / Math.log(e) * o;
  397. var r = n - Math.floor(n), i = "";
  398. for (o = 0; o < Math.floor(n); o++) {
  399. i = Math.floor(Math.random() * e).toString(e) + i
  400. }
  401. if (r) {
  402. var a = Math.pow(e, r);
  403. i = Math.floor(Math.random() * a).toString(e) + i
  404. }
  405. var s = parseInt(i, e);
  406. return s !== 1 / 0 && s >= Math.pow(2, t) ? w(t, e) : i
  407. };
  408. w.rack = function (t, e, n) {
  409. var o = function (o) {
  410. var i = 0;
  411. do {
  412. if (i++ > 10) {
  413. if (!n) throw new Error("too many ID collisions, use more bits");
  414. t += n
  415. }
  416. var a = w(t, e)
  417. } while (Object.hasOwnProperty.call(r, a));
  418. return r[a] = o, a
  419. }, r = o.hats = {};
  420. return o.get = function (t) {
  421. return o.hats[t]
  422. }, o.set = function (t, e) {
  423. return o.hats[t] = e, o
  424. }, o.bits = t || 128, o.base = e || 16, o
  425. };
  426. var R = function (t, e) {
  427. this.ctx = t, this.properties = e.properties || {}, this.coordinates = e.geometry.coordinates, this.id = e.id || F(), this.type = e.geometry.type
  428. };
  429. R.prototype.changed = function () {
  430. this.ctx.store.featureChanged(this.id)
  431. }, R.prototype.incomingCoords = function (t) {
  432. this.setCoordinates(t)
  433. }, R.prototype.setCoordinates = function (t) {
  434. this.coordinates = t, this.changed()
  435. }, R.prototype.getCoordinates = function () {
  436. return JSON.parse(JSON.stringify(this.coordinates))
  437. }, R.prototype.setProperty = function (t, e) {
  438. this.properties[t] = e
  439. }, R.prototype.toGeoJSON = function () {
  440. return JSON.parse(JSON.stringify({
  441. id: this.id,
  442. type: p.FEATURE,
  443. properties: this.properties,
  444. geometry: {coordinates: this.getCoordinates(), type: this.type}
  445. }))
  446. }, R.prototype.internal = function (t) {
  447. var e = {id: this.id, meta: y.FEATURE, "meta:type": this.type, active: v.INACTIVE, mode: t};
  448. if (this.ctx.options.userProperties) for (var n in this.properties) e["user_" + n] = this.properties[n];
  449. return {type: p.FEATURE, properties: e, geometry: {coordinates: this.getCoordinates(), type: this.type}}
  450. };
  451. var k = function (t, e) {
  452. R.call(this, t, e)
  453. };
  454. (k.prototype = Object.create(R.prototype)).isValid = function () {
  455. return "number" == typeof this.coordinates[0] && "number" == typeof this.coordinates[1]
  456. }, k.prototype.updateCoordinate = function (t, e, n) {
  457. this.coordinates = 3 === arguments.length ? [e, n] : [t, e], this.changed()
  458. }, k.prototype.getCoordinate = function () {
  459. return this.getCoordinates()
  460. };
  461. var D = function (t, e) {
  462. R.call(this, t, e)
  463. };
  464. (D.prototype = Object.create(R.prototype)).isValid = function () {
  465. return this.coordinates.length > 1
  466. }, D.prototype.addCoordinate = function (t, e, n) {
  467. this.changed();
  468. var o = parseInt(t, 10);
  469. this.coordinates.splice(o, 0, [e, n])
  470. }, D.prototype.getCoordinate = function (t) {
  471. var e = parseInt(t, 10);
  472. return JSON.parse(JSON.stringify(this.coordinates[e]))
  473. }, D.prototype.removeCoordinate = function (t) {
  474. this.changed(), this.coordinates.splice(parseInt(t, 10), 1)
  475. }, D.prototype.updateCoordinate = function (t, e, n) {
  476. var o = parseInt(t, 10);
  477. this.coordinates[o] = [e, n], this.changed()
  478. };
  479. var U = function (t, e) {
  480. R.call(this, t, e), this.coordinates = this.coordinates.map((function (t) {
  481. return t.slice(0, -1)
  482. }))
  483. };
  484. (U.prototype = Object.create(R.prototype)).isValid = function () {
  485. return 0 !== this.coordinates.length && this.coordinates.every((function (t) {
  486. return t.length > 2
  487. }))
  488. }, U.prototype.incomingCoords = function (t) {
  489. this.coordinates = t.map((function (t) {
  490. return t.slice(0, -1)
  491. })), this.changed()
  492. }, U.prototype.setCoordinates = function (t) {
  493. this.coordinates = t, this.changed()
  494. }, U.prototype.addCoordinate = function (t, e, n) {
  495. this.changed();
  496. var o = t.split(".").map((function (t) {
  497. return parseInt(t, 10)
  498. }));
  499. this.coordinates[o[0]].splice(o[1], 0, [e, n])
  500. }, U.prototype.removeCoordinate = function (t) {
  501. this.changed();
  502. var e = t.split(".").map((function (t) {
  503. return parseInt(t, 10)
  504. })), n = this.coordinates[e[0]];
  505. n && (n.splice(e[1], 1), n.length < 3 && this.coordinates.splice(e[0], 1))
  506. }, U.prototype.getCoordinate = function (t) {
  507. var e = t.split(".").map((function (t) {
  508. return parseInt(t, 10)
  509. })), n = this.coordinates[e[0]];
  510. return JSON.parse(JSON.stringify(n[e[1]]))
  511. }, U.prototype.getCoordinates = function () {
  512. return this.coordinates.map((function (t) {
  513. return t.concat([t[0]])
  514. }))
  515. }, U.prototype.updateCoordinate = function (t, e, n) {
  516. this.changed();
  517. var o = t.split("."), r = parseInt(o[0], 10), i = parseInt(o[1], 10);
  518. void 0 === this.coordinates[r] && (this.coordinates[r] = []), this.coordinates[r][i] = [e, n]
  519. };
  520. var j = {MultiPoint: k, MultiLineString: D, MultiPolygon: U}, V = function (t, e, n, o, r) {
  521. var i = n.split("."), a = parseInt(i[0], 10), s = i[1] ? i.slice(1).join(".") : null;
  522. return t[a][e](s, o, r)
  523. }, B = function (t, e) {
  524. if (R.call(this, t, e), delete this.coordinates, this.model = j[e.geometry.type], void 0 === this.model) throw new TypeError(e.geometry.type + " is not a valid type");
  525. this.features = this._coordinatesToFeatures(e.geometry.coordinates)
  526. };
  527.  
  528. function G(t) {
  529. this.map = t.map, this.drawConfig = JSON.parse(JSON.stringify(t.options || {})), this._ctx = t
  530. }
  531.  
  532. (B.prototype = Object.create(R.prototype))._coordinatesToFeatures = function (t) {
  533. var e = this, n = this.model.bind(this);
  534. return t.map((function (t) {
  535. return new n(e.ctx, {
  536. id: F(),
  537. type: p.FEATURE,
  538. properties: {},
  539. geometry: {coordinates: t, type: e.type.replace("Multi", "")}
  540. })
  541. }))
  542. }, B.prototype.isValid = function () {
  543. return this.features.every((function (t) {
  544. return t.isValid()
  545. }))
  546. }, B.prototype.setCoordinates = function (t) {
  547. this.features = this._coordinatesToFeatures(t), this.changed()
  548. }, B.prototype.getCoordinate = function (t) {
  549. return V(this.features, "getCoordinate", t)
  550. }, B.prototype.getCoordinates = function () {
  551. return JSON.parse(JSON.stringify(this.features.map((function (t) {
  552. return t.type === p.POLYGON ? t.getCoordinates() : t.coordinates
  553. }))))
  554. }, B.prototype.updateCoordinate = function (t, e, n) {
  555. V(this.features, "updateCoordinate", t, e, n), this.changed()
  556. }, B.prototype.addCoordinate = function (t, e, n) {
  557. V(this.features, "addCoordinate", t, e, n), this.changed()
  558. }, B.prototype.removeCoordinate = function (t) {
  559. V(this.features, "removeCoordinate", t), this.changed()
  560. }, B.prototype.getFeatures = function () {
  561. return this.features
  562. }, G.prototype.setSelected = function (t) {
  563. return this._ctx.store.setSelected(t)
  564. }, G.prototype.setSelectedCoordinates = function (t) {
  565. var e = this;
  566. this._ctx.store.setSelectedCoordinates(t), t.reduce((function (t, n) {
  567. return void 0 === t[n.feature_id] && (t[n.feature_id] = !0, e._ctx.store.get(n.feature_id).changed()), t
  568. }), {})
  569. }, G.prototype.getSelected = function () {
  570. return this._ctx.store.getSelected()
  571. }, G.prototype.getSelectedIds = function () {
  572. return this._ctx.store.getSelectedIds()
  573. }, G.prototype.isSelected = function (t) {
  574. return this._ctx.store.isSelected(t)
  575. }, G.prototype.getFeature = function (t) {
  576. return this._ctx.store.get(t)
  577. }, G.prototype.select = function (t) {
  578. return this._ctx.store.select(t)
  579. }, G.prototype.deselect = function (t) {
  580. return this._ctx.store.deselect(t)
  581. }, G.prototype.deleteFeature = function (t, e) {
  582. return void 0 === e && (e = {}), this._ctx.store.delete(t, e)
  583. }, G.prototype.addFeature = function (t) {
  584. return this._ctx.store.add(t)
  585. }, G.prototype.clearSelectedFeatures = function () {
  586. return this._ctx.store.clearSelected()
  587. }, G.prototype.clearSelectedCoordinates = function () {
  588. return this._ctx.store.clearSelectedCoordinates()
  589. }, G.prototype.setActionableState = function (t) {
  590. void 0 === t && (t = {});
  591. var e = {
  592. trash: t.trash || !1,
  593. combineFeatures: t.combineFeatures || !1,
  594. uncombineFeatures: t.uncombineFeatures || !1
  595. };
  596. return this._ctx.events.actionable(e)
  597. }, G.prototype.changeMode = function (t, e, n) {
  598. return void 0 === e && (e = {}), void 0 === n && (n = {}), this._ctx.events.changeMode(t, e, n)
  599. }, G.prototype.updateUIClasses = function (t) {
  600. return this._ctx.ui.queueMapClasses(t)
  601. }, G.prototype.activateUIButton = function (t) {
  602. return this._ctx.ui.setActiveButton(t)
  603. }, G.prototype.featuresAt = function (t, e, n) {
  604. if (void 0 === n && (n = "click"), "click" !== n && "touch" !== n) throw new Error("invalid buffer type");
  605. return x[n](t, e, this._ctx)
  606. }, G.prototype.newFeature = function (t) {
  607. var e = t.geometry.type;
  608. return e === p.POINT ? new k(this._ctx, t) : e === p.LINE_STRING ? new D(this._ctx, t) : e === p.POLYGON ? new U(this._ctx, t) : new B(this._ctx, t)
  609. }, G.prototype.isInstanceOf = function (t, e) {
  610. if (t === p.POINT) return e instanceof k;
  611. if (t === p.LINE_STRING) return e instanceof D;
  612. if (t === p.POLYGON) return e instanceof U;
  613. if ("MultiFeature" === t) return e instanceof B;
  614. throw new Error("Unknown feature class: " + t)
  615. }, G.prototype.doRender = function (t) {
  616. return this._ctx.store.featureChanged(t)
  617. }, G.prototype.onSetup = function () {
  618. }, G.prototype.onDrag = function () {
  619. }, G.prototype.onClick = function () {
  620. }, G.prototype.onMouseMove = function () {
  621. }, G.prototype.onMouseDown = function () {
  622. }, G.prototype.onMouseUp = function () {
  623. }, G.prototype.onMouseOut = function () {
  624. }, G.prototype.onKeyUp = function () {
  625. }, G.prototype.onKeyDown = function () {
  626. }, G.prototype.onTouchStart = function () {
  627. }, G.prototype.onTouchMove = function () {
  628. }, G.prototype.onTouchEnd = function () {
  629. }, G.prototype.onTap = function () {
  630. }, G.prototype.onStop = function () {
  631. }, G.prototype.onTrash = function () {
  632. }, G.prototype.onCombineFeature = function () {
  633. }, G.prototype.onUncombineFeature = function () {
  634. }, G.prototype.toDisplayFeatures = function () {
  635. throw new Error("You must overwrite toDisplayFeatures")
  636. };
  637. var J = {
  638. drag: "onDrag",
  639. click: "onClick",
  640. mousemove: "onMouseMove",
  641. mousedown: "onMouseDown",
  642. mouseup: "onMouseUp",
  643. mouseout: "onMouseOut",
  644. keyup: "onKeyUp",
  645. keydown: "onKeyDown",
  646. touchstart: "onTouchStart",
  647. touchmove: "onTouchMove",
  648. touchend: "onTouchEnd",
  649. tap: "onTap"
  650. }, z = Object.keys(J);
  651.  
  652. function Y(t) {
  653. var e = Object.keys(t);
  654. return function (n, o) {
  655. void 0 === o && (o = {});
  656. var r = {}, i = e.reduce((function (e, n) {
  657. return e[n] = t[n], e
  658. }), new G(n));
  659. return {
  660. start: function () {
  661. var e = this;
  662. r = i.onSetup(o), z.forEach((function (n) {
  663. var o, a = J[n], s = function () {
  664. return !1
  665. };
  666. t[a] && (s = function () {
  667. return !0
  668. }), e.on(n, s, (o = a, function (t) {
  669. return i[o](r, t)
  670. }))
  671. }))
  672. }, stop: function () {
  673. i.onStop(r)
  674. }, trash: function () {
  675. i.onTrash(r)
  676. }, combineFeatures: function () {
  677. i.onCombineFeatures(r)
  678. }, uncombineFeatures: function () {
  679. i.onUncombineFeatures(r)
  680. }, render: function (t, e) {
  681. i.toDisplayFeatures(r, t, e)
  682. }
  683. }
  684. }
  685. }
  686.  
  687. function $(t) {
  688. return [].concat(t).filter((function (t) {
  689. return void 0 !== t
  690. }))
  691. }
  692.  
  693. function q() {
  694. var t = this;
  695. if (!(t.ctx.map && void 0 !== t.ctx.map.getSource(c.HOT))) return u();
  696. var e = t.ctx.events.currentModeName();
  697. t.ctx.ui.queueMapClasses({mode: e});
  698. var n = [], o = [];
  699. t.isDirty ? o = t.getAllIds() : (n = t.getChangedIds().filter((function (e) {
  700. return void 0 !== t.get(e)
  701. })), o = t.sources.hot.filter((function (e) {
  702. return e.properties.id && -1 === n.indexOf(e.properties.id) && void 0 !== t.get(e.properties.id)
  703. })).map((function (t) {
  704. return t.properties.id
  705. }))), t.sources.hot = [];
  706. var r = t.sources.cold.length;
  707. t.sources.cold = t.isDirty ? [] : t.sources.cold.filter((function (t) {
  708. var e = t.properties.id || t.properties.parent;
  709. return -1 === n.indexOf(e)
  710. }));
  711. var i = r !== t.sources.cold.length || o.length > 0;
  712.  
  713. function a(n, o) {
  714. var r = t.get(n).internal(e);
  715. t.ctx.events.currentModeRender(r, (function (e) {
  716. t.sources[o].push(e)
  717. }))
  718. }
  719.  
  720. if (n.forEach((function (t) {
  721. return a(t, "hot")
  722. })), o.forEach((function (t) {
  723. return a(t, "cold")
  724. })), i && t.ctx.map.getSource(c.COLD).setData({
  725. type: p.FEATURE_COLLECTION,
  726. features: t.sources.cold
  727. }), t.ctx.map.getSource(c.HOT).setData({
  728. type: p.FEATURE_COLLECTION,
  729. features: t.sources.hot
  730. }), t._emitSelectionChange && (t.ctx.map.fire(h.SELECTION_CHANGE, {
  731. features: t.getSelected().map((function (t) {
  732. return t.toGeoJSON()
  733. })), points: t.getSelectedCoordinates().map((function (t) {
  734. return {type: p.FEATURE, properties: {}, geometry: {type: p.POINT, coordinates: t.coordinates}}
  735. }))
  736. }), t._emitSelectionChange = !1), t._deletedFeaturesToEmit.length) {
  737. var s = t._deletedFeaturesToEmit.map((function (t) {
  738. return t.toGeoJSON()
  739. }));
  740. t._deletedFeaturesToEmit = [], t.ctx.map.fire(h.DELETE, {features: s})
  741. }
  742.  
  743. function u() {
  744. t.isDirty = !1, t.clearChangedIds()
  745. }
  746.  
  747. u(), t.ctx.map.fire(h.RENDER, {})
  748. }
  749.  
  750. function H(t) {
  751. var e, n = this;
  752. this._features = {}, this._featureIds = new S, this._selectedFeatureIds = new S, this._selectedCoordinates = [], this._changedFeatureIds = new S, this._deletedFeaturesToEmit = [], this._emitSelectionChange = !1, this._mapInitialConfig = {}, this.ctx = t, this.sources = {
  753. hot: [],
  754. cold: []
  755. }, this.render = function () {
  756. e || (e = requestAnimationFrame((function () {
  757. e = null, q.call(n)
  758. })))
  759. }, this.isDirty = !1
  760. }
  761.  
  762. function X(t, e) {
  763. var n = t._selectedCoordinates.filter((function (e) {
  764. return t._selectedFeatureIds.has(e.feature_id)
  765. }));
  766. t._selectedCoordinates.length === n.length || e.silent || (t._emitSelectionChange = !0), t._selectedCoordinates = n
  767. }
  768.  
  769. H.prototype.createRenderBatch = function () {
  770. var t = this, e = this.render, n = 0;
  771. return this.render = function () {
  772. n++
  773. }, function () {
  774. t.render = e, n > 0 && t.render()
  775. }
  776. }, H.prototype.setDirty = function () {
  777. return this.isDirty = !0, this
  778. }, H.prototype.featureChanged = function (t) {
  779. return this._changedFeatureIds.add(t), this
  780. }, H.prototype.getChangedIds = function () {
  781. return this._changedFeatureIds.values()
  782. }, H.prototype.clearChangedIds = function () {
  783. return this._changedFeatureIds.clear(), this
  784. }, H.prototype.getAllIds = function () {
  785. return this._featureIds.values()
  786. }, H.prototype.add = function (t) {
  787. return this.featureChanged(t.id), this._features[t.id] = t, this._featureIds.add(t.id), this
  788. }, H.prototype.delete = function (t, e) {
  789. var n = this;
  790. return void 0 === e && (e = {}), $(t).forEach((function (t) {
  791. n._featureIds.has(t) && (n._featureIds.delete(t), n._selectedFeatureIds.delete(t), e.silent || -1 === n._deletedFeaturesToEmit.indexOf(n._features[t]) && n._deletedFeaturesToEmit.push(n._features[t]), delete n._features[t], n.isDirty = !0)
  792. })), X(this, e), this
  793. }, H.prototype.get = function (t) {
  794. return this._features[t]
  795. }, H.prototype.getAll = function () {
  796. var t = this;
  797. return Object.keys(this._features).map((function (e) {
  798. return t._features[e]
  799. }))
  800. }, H.prototype.select = function (t, e) {
  801. var n = this;
  802. return void 0 === e && (e = {}), $(t).forEach((function (t) {
  803. n._selectedFeatureIds.has(t) || (n._selectedFeatureIds.add(t), n._changedFeatureIds.add(t), e.silent || (n._emitSelectionChange = !0))
  804. })), this
  805. }, H.prototype.deselect = function (t, e) {
  806. var n = this;
  807. return void 0 === e && (e = {}), $(t).forEach((function (t) {
  808. n._selectedFeatureIds.has(t) && (n._selectedFeatureIds.delete(t), n._changedFeatureIds.add(t), e.silent || (n._emitSelectionChange = !0))
  809. })), X(this, e), this
  810. }, H.prototype.clearSelected = function (t) {
  811. return void 0 === t && (t = {}), this.deselect(this._selectedFeatureIds.values(), {silent: t.silent}), this
  812. }, H.prototype.setSelected = function (t, e) {
  813. var n = this;
  814. return void 0 === e && (e = {}), t = $(t), this.deselect(this._selectedFeatureIds.values().filter((function (e) {
  815. return -1 === t.indexOf(e)
  816. })), {silent: e.silent}), this.select(t.filter((function (t) {
  817. return !n._selectedFeatureIds.has(t)
  818. })), {silent: e.silent}), this
  819. }, H.prototype.setSelectedCoordinates = function (t) {
  820. return this._selectedCoordinates = t, this._emitSelectionChange = !0, this
  821. }, H.prototype.clearSelectedCoordinates = function () {
  822. return this._selectedCoordinates = [], this._emitSelectionChange = !0, this
  823. }, H.prototype.getSelectedIds = function () {
  824. return this._selectedFeatureIds.values()
  825. }, H.prototype.getSelected = function () {
  826. var t = this;
  827. return this._selectedFeatureIds.values().map((function (e) {
  828. return t.get(e)
  829. }))
  830. }, H.prototype.getSelectedCoordinates = function () {
  831. var t = this;
  832. return this._selectedCoordinates.map((function (e) {
  833. return {coordinates: t.get(e.feature_id).getCoordinate(e.coord_path)}
  834. }))
  835. }, H.prototype.isSelected = function (t) {
  836. return this._selectedFeatureIds.has(t)
  837. }, H.prototype.setFeatureProperty = function (t, e, n) {
  838. this.get(t).setProperty(e, n), this.featureChanged(t)
  839. }, H.prototype.storeMapConfig = function () {
  840. var t = this;
  841. m.forEach((function (e) {
  842. t.ctx.map[e] && (t._mapInitialConfig[e] = t.ctx.map[e].isEnabled())
  843. }))
  844. }, H.prototype.restoreMapConfig = function () {
  845. var t = this;
  846. Object.keys(this._mapInitialConfig).forEach((function (e) {
  847. t._mapInitialConfig[e] ? t.ctx.map[e].enable() : t.ctx.map[e].disable()
  848. }))
  849. }, H.prototype.getInitialConfigValue = function (t) {
  850. return void 0 === this._mapInitialConfig[t] || this._mapInitialConfig[t]
  851. };
  852. var W = function () {
  853. for (var t = arguments, e = {}, n = 0; n < arguments.length; n++) {
  854. var o = t[n];
  855. for (var r in o) Z.call(o, r) && (e[r] = o[r])
  856. }
  857. return e
  858. }, Z = Object.prototype.hasOwnProperty;
  859. var K = ["mode", "feature", "mouse"];
  860.  
  861. function Q(e) {
  862. var n = null, o = null, r = {
  863. onRemove: function () {
  864. return e.map.off("load", r.connect), clearInterval(o), r.removeLayers(), e.store.restoreMapConfig(), e.ui.removeButtons(), e.events.removeEventListeners(), e.ui.clearMapClasses(), e.map = null, e.container = null, e.store = null, n && n.parentNode && n.parentNode.removeChild(n), n = null, this
  865. }, connect: function () {
  866. e.map.off("load", r.connect), clearInterval(o), r.addLayers(), e.store.storeMapConfig(), e.events.addEventListeners()
  867. }, onAdd: function (i) {
  868. var a = i.fire;
  869. return i.fire = function (t, e) {
  870. var n = arguments;
  871. return 1 === a.length && 1 !== arguments.length && (n = [W({}, {type: t}, e)]), a.apply(i, n)
  872. }, e.map = i, e.events = function (e) {
  873. var n = Object.keys(e.options.modes).reduce((function (t, n) {
  874. return t[n] = Y(e.options.modes[n]), t
  875. }), {}), o = {}, r = {}, i = {}, a = null, s = null;
  876. i.drag = function (t, n) {
  877. n({
  878. point: t.point,
  879. time: (new Date).getTime()
  880. }) ? (e.ui.queueMapClasses({mouse: l.DRAG}), s.drag(t)) : t.originalEvent.stopPropagation()
  881. }, i.mousedrag = function (t) {
  882. i.drag(t, (function (t) {
  883. return !A(o, t)
  884. }))
  885. }, i.touchdrag = function (t) {
  886. i.drag(t, (function (t) {
  887. return !P(r, t)
  888. }))
  889. }, i.mousemove = function (t) {
  890. if (1 === (void 0 !== t.originalEvent.buttons ? t.originalEvent.buttons : t.originalEvent.which)) return i.mousedrag(t);
  891. var n = L(t, e);
  892. t.featureTarget = n, s.mousemove(t)
  893. }, i.mousedown = function (t) {
  894. o = {time: (new Date).getTime(), point: t.point};
  895. var n = L(t, e);
  896. t.featureTarget = n, s.mousedown(t)
  897. }, i.mouseup = function (t) {
  898. var n = L(t, e);
  899. t.featureTarget = n, A(o, {
  900. point: t.point,
  901. time: (new Date).getTime()
  902. }) ? s.click(t) : s.mouseup(t)
  903. }, i.mouseout = function (t) {
  904. s.mouseout(t)
  905. }, i.touchstart = function (t) {
  906. if (e.options.touchEnabled) {
  907. r = {time: (new Date).getTime(), point: t.point};
  908. var n = x.touch(t, null, e)[0];
  909. t.featureTarget = n, s.touchstart(t)
  910. }
  911. }, i.touchmove = function (t) {
  912. if (e.options.touchEnabled) return s.touchmove(t), i.touchdrag(t)
  913. }, i.touchend = function (t) {
  914. if (e.options.touchEnabled) {
  915. var n = x.touch(t, null, e)[0];
  916. t.featureTarget = n, P(r, {
  917. time: (new Date).getTime(),
  918. point: t.point
  919. }) ? s.tap(t) : s.touchend(t)
  920. }
  921. };
  922. var u = function (t) {
  923. return !(8 === t || 46 === t || t >= 48 && t <= 57)
  924. };
  925.  
  926. function c(o, r, i) {
  927. void 0 === i && (i = {}), s.stop();
  928. var u = n[o];
  929. if (void 0 === u) throw new Error(o + " is not valid");
  930. a = o;
  931. var c = u(e, r);
  932. s = t(c, e), i.silent || e.map.fire(h.MODE_CHANGE, {mode: o}), e.store.setDirty(), e.store.render()
  933. }
  934.  
  935. i.keydown = function (t) {
  936. "mapboxgl-canvas" === (t.srcElement || t.target).classList[0] && (8 !== t.keyCode && 46 !== t.keyCode || !e.options.controls.trash ? u(t.keyCode) ? s.keydown(t) : 49 === t.keyCode && e.options.controls.point ? c(f.DRAW_POINT) : 50 === t.keyCode && e.options.controls.line_string ? c(f.DRAW_LINE_STRING) : 51 === t.keyCode && e.options.controls.polygon && c(f.DRAW_POLYGON) : (t.preventDefault(), s.trash()))
  937. }, i.keyup = function (t) {
  938. u(t.keyCode) && s.keyup(t)
  939. }, i.zoomend = function () {
  940. e.store.changeZoom()
  941. }, i.data = function (t) {
  942. if ("style" === t.dataType) {
  943. var n = e.setup, o = e.map, r = e.options, i = e.store;
  944. r.styles.some((function (t) {
  945. return o.getLayer(t.id)
  946. })) || (n.addLayers(), i.setDirty(), i.render())
  947. }
  948. };
  949. var d = {trash: !1, combineFeatures: !1, uncombineFeatures: !1};
  950. return {
  951. start: function () {
  952. a = e.options.defaultMode, s = t(n[a](e), e)
  953. }, changeMode: c, actionable: function (t) {
  954. var n = !1;
  955. Object.keys(t).forEach((function (e) {
  956. if (void 0 === d[e]) throw new Error("Invalid action type");
  957. d[e] !== t[e] && (n = !0), d[e] = t[e]
  958. })), n && e.map.fire(h.ACTIONABLE, {actions: d})
  959. }, currentModeName: function () {
  960. return a
  961. }, currentModeRender: function (t, e) {
  962. return s.render(t, e)
  963. }, fire: function (t, e) {
  964. i[t] && i[t](e)
  965. }, addEventListeners: function () {
  966. e.map.on("mousemove", i.mousemove), e.map.on("mousedown", i.mousedown), e.map.on("mouseup", i.mouseup), e.map.on("data", i.data), e.map.on("touchmove", i.touchmove, {passive: !0}), e.map.on("touchstart", i.touchstart, {passive: !0}), e.map.on("touchend", i.touchend, {passive: !0}), e.container.addEventListener("mouseout", i.mouseout), e.options.keybindings && (e.container.addEventListener("keydown", i.keydown), e.container.addEventListener("keyup", i.keyup))
  967. }, removeEventListeners: function () {
  968. e.map.off("mousemove", i.mousemove), e.map.off("mousedown", i.mousedown), e.map.off("mouseup", i.mouseup), e.map.off("data", i.data), e.map.off("touchmove", i.touchmove), e.map.off("touchstart", i.touchstart), e.map.off("touchend", i.touchend), e.container.removeEventListener("mouseout", i.mouseout), e.options.keybindings && (e.container.removeEventListener("keydown", i.keydown), e.container.removeEventListener("keyup", i.keyup))
  969. }, trash: function (t) {
  970. s.trash(t)
  971. }, combineFeatures: function () {
  972. s.combineFeatures()
  973. }, uncombineFeatures: function () {
  974. s.uncombineFeatures()
  975. }, getMode: function () {
  976. return a
  977. }
  978. }
  979. }(e), e.ui = function (t) {
  980. var e = {}, n = null, o = {mode: null, feature: null, mouse: null},
  981. r = {mode: null, feature: null, mouse: null};
  982.  
  983. function i(t) {
  984. r = W(r, t)
  985. }
  986.  
  987. function a() {
  988. var e, n;
  989. if (t.container) {
  990. var i = [], a = [];
  991. K.forEach((function (t) {
  992. r[t] !== o[t] && (i.push(t + "-" + o[t]), null !== r[t] && a.push(t + "-" + r[t]))
  993. })), i.length > 0 && (e = t.container.classList).remove.apply(e, i), a.length > 0 && (n = t.container.classList).add.apply(n, a), o = W(o, r)
  994. }
  995. }
  996.  
  997. function s(t, e) {
  998. void 0 === e && (e = {});
  999. var o = document.createElement("button");
  1000. return o.className = u.CONTROL_BUTTON + " " + e.className, o.setAttribute("title", e.title), e.container.appendChild(o), o.addEventListener("click", (function (o) {
  1001. if (o.preventDefault(), o.stopPropagation(), o.target === n) return c(), void e.onDeactivate();
  1002. l(t), e.onActivate()
  1003. }), !0), o
  1004. }
  1005.  
  1006. function c() {
  1007. n && (n.classList.remove(u.ACTIVE_BUTTON), n = null)
  1008. }
  1009.  
  1010. function l(t) {
  1011. c();
  1012. var o = e[t];
  1013. o && o && "trash" !== t && (o.classList.add(u.ACTIVE_BUTTON), n = o)
  1014. }
  1015.  
  1016. return {
  1017. setActiveButton: l, queueMapClasses: i, updateMapClasses: a, clearMapClasses: function () {
  1018. i({mode: null, feature: null, mouse: null}), a()
  1019. }, addButtons: function () {
  1020. var n = t.options.controls, o = document.createElement("div");
  1021. return o.className = u.CONTROL_GROUP + " " + u.CONTROL_BASE, n ? (n[d.LINE] && (e[d.LINE] = s(d.LINE, {
  1022. container: o,
  1023. className: u.CONTROL_BUTTON_LINE,
  1024. title: "LineString tool " + (t.options.keybindings ? "(l)" : ""),
  1025. onActivate: function () {
  1026. return t.events.changeMode(f.DRAW_LINE_STRING)
  1027. },
  1028. onDeactivate: function () {
  1029. return t.events.trash()
  1030. }
  1031. })), n[d.POLYGON] && (e[d.POLYGON] = s(d.POLYGON, {
  1032. container: o,
  1033. className: u.CONTROL_BUTTON_POLYGON,
  1034. title: "Polygon tool " + (t.options.keybindings ? "(p)" : ""),
  1035. onActivate: function () {
  1036. return t.events.changeMode(f.DRAW_POLYGON)
  1037. },
  1038. onDeactivate: function () {
  1039. return t.events.trash()
  1040. }
  1041. })), n[d.POINT] && (e[d.POINT] = s(d.POINT, {
  1042. container: o,
  1043. className: u.CONTROL_BUTTON_POINT,
  1044. title: "Marker tool " + (t.options.keybindings ? "(m)" : ""),
  1045. onActivate: function () {
  1046. return t.events.changeMode(f.DRAW_POINT)
  1047. },
  1048. onDeactivate: function () {
  1049. return t.events.trash()
  1050. }
  1051. })), n.trash && (e.trash = s("trash", {
  1052. container: o,
  1053. className: u.CONTROL_BUTTON_TRASH,
  1054. title: "Delete",
  1055. onActivate: function () {
  1056. t.events.trash()
  1057. }
  1058. })), n.combine_features && (e.combine_features = s("combineFeatures", {
  1059. container: o,
  1060. className: u.CONTROL_BUTTON_COMBINE_FEATURES,
  1061. title: "Combine",
  1062. onActivate: function () {
  1063. t.events.combineFeatures()
  1064. }
  1065. })), n.uncombine_features && (e.uncombine_features = s("uncombineFeatures", {
  1066. container: o,
  1067. className: u.CONTROL_BUTTON_UNCOMBINE_FEATURES,
  1068. title: "Uncombine",
  1069. onActivate: function () {
  1070. t.events.uncombineFeatures()
  1071. }
  1072. })), o) : o
  1073. }, removeButtons: function () {
  1074. Object.keys(e).forEach((function (t) {
  1075. var n = e[t];
  1076. n.parentNode && n.parentNode.removeChild(n), delete e[t]
  1077. }))
  1078. }
  1079. }
  1080. }(e), e.container = i.getContainer(), e.store = new H(e), n = e.ui.addButtons(), e.options.boxSelect && (i.boxZoom.disable(), i.dragPan.disable(), i.dragPan.enable()), i.loaded() ? r.connect() : (i.on("load", r.connect), o = setInterval((function () {
  1081. i.loaded() && r.connect()
  1082. }), 16)), e.events.start(), n
  1083. }, addLayers: function () {
  1084. e.map.addSource(c.COLD, {
  1085. data: {type: p.FEATURE_COLLECTION, features: []},
  1086. type: "geojson"
  1087. }), e.map.addSource(c.HOT, {
  1088. data: {type: p.FEATURE_COLLECTION, features: []},
  1089. type: "geojson"
  1090. }), e.options.styles.forEach((function (t) {
  1091. e.map.addLayer(t)
  1092. })), e.store.setDirty(!0), e.store.render()
  1093. }, removeLayers: function () {
  1094. e.options.styles.forEach((function (t) {
  1095. e.map.getLayer(t.id) && e.map.removeLayer(t.id)
  1096. })), e.map.getSource(c.COLD) && e.map.removeSource(c.COLD), e.map.getSource(c.HOT) && e.map.removeSource(c.HOT)
  1097. }
  1098. };
  1099. return e.setup = r, r
  1100. }
  1101.  
  1102. var tt = [{
  1103. id: "gl-draw-polygon-fill-inactive",
  1104. type: "fill",
  1105. filter: ["all", ["==", "active", "false"], ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
  1106. paint: {"fill-color": "#3bb2d0", "fill-outline-color": "#3bb2d0", "fill-opacity": .1}
  1107. }, {
  1108. id: "gl-draw-polygon-fill-active",
  1109. type: "fill",
  1110. filter: ["all", ["==", "active", "true"], ["==", "$type", "Polygon"]],
  1111. paint: {"fill-color": "#fbb03b", "fill-outline-color": "#fbb03b", "fill-opacity": .1}
  1112. }, {
  1113. id: "gl-draw-polygon-midpoint",
  1114. type: "circle",
  1115. filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]],
  1116. paint: {"circle-radius": 3, "circle-color": "#fbb03b"}
  1117. }, {
  1118. id: "gl-draw-polygon-stroke-inactive",
  1119. type: "line",
  1120. filter: ["all", ["==", "active", "false"], ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
  1121. layout: {"line-cap": "round", "line-join": "round"},
  1122. paint: {"line-color": "#3bb2d0", "line-width": 2}
  1123. }, {
  1124. id: "gl-draw-polygon-stroke-active",
  1125. type: "line",
  1126. filter: ["all", ["==", "active", "true"], ["==", "$type", "Polygon"]],
  1127. layout: {"line-cap": "round", "line-join": "round"},
  1128. paint: {"line-color": "#fbb03b", "line-dasharray": [.2, 2], "line-width": 2}
  1129. }, {
  1130. id: "gl-draw-line-inactive",
  1131. type: "line",
  1132. filter: ["all", ["==", "active", "false"], ["==", "$type", "LineString"], ["!=", "mode", "static"]],
  1133. layout: {"line-cap": "round", "line-join": "round"},
  1134. paint: {"line-color": "#3bb2d0", "line-width": 2}
  1135. }, {
  1136. id: "gl-draw-line-active",
  1137. type: "line",
  1138. filter: ["all", ["==", "$type", "LineString"], ["==", "active", "true"]],
  1139. layout: {"line-cap": "round", "line-join": "round"},
  1140. paint: {"line-color": "#fbb03b", "line-dasharray": [.2, 2], "line-width": 2}
  1141. }, {
  1142. id: "gl-draw-polygon-and-line-vertex-stroke-inactive",
  1143. type: "circle",
  1144. filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
  1145. paint: {"circle-radius": 5, "circle-color": "#fff"}
  1146. }, {
  1147. id: "gl-draw-polygon-and-line-vertex-inactive",
  1148. type: "circle",
  1149. filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
  1150. paint: {"circle-radius": 3, "circle-color": "#fbb03b"}
  1151. }, {
  1152. id: "gl-draw-point-point-stroke-inactive",
  1153. type: "circle",
  1154. filter: ["all", ["==", "active", "false"], ["==", "$type", "Point"], ["==", "meta", "feature"], ["!=", "mode", "static"]],
  1155. paint: {"circle-radius": 5, "circle-opacity": 1, "circle-color": "#fff"}
  1156. }, {
  1157. id: "gl-draw-point-inactive",
  1158. type: "circle",
  1159. filter: ["all", ["==", "active", "false"], ["==", "$type", "Point"], ["==", "meta", "feature"], ["!=", "mode", "static"]],
  1160. paint: {"circle-radius": 3, "circle-color": "#3bb2d0"}
  1161. }, {
  1162. id: "gl-draw-point-stroke-active",
  1163. type: "circle",
  1164. filter: ["all", ["==", "$type", "Point"], ["==", "active", "true"], ["!=", "meta", "midpoint"]],
  1165. paint: {"circle-radius": 7, "circle-color": "#fff"}
  1166. }, {
  1167. id: "gl-draw-point-active",
  1168. type: "circle",
  1169. filter: ["all", ["==", "$type", "Point"], ["!=", "meta", "midpoint"], ["==", "active", "true"]],
  1170. paint: {"circle-radius": 5, "circle-color": "#fbb03b"}
  1171. }, {
  1172. id: "gl-draw-polygon-fill-static",
  1173. type: "fill",
  1174. filter: ["all", ["==", "mode", "static"], ["==", "$type", "Polygon"]],
  1175. paint: {"fill-color": "#404040", "fill-outline-color": "#404040", "fill-opacity": .1}
  1176. }, {
  1177. id: "gl-draw-polygon-stroke-static",
  1178. type: "line",
  1179. filter: ["all", ["==", "mode", "static"], ["==", "$type", "Polygon"]],
  1180. layout: {"line-cap": "round", "line-join": "round"},
  1181. paint: {"line-color": "#404040", "line-width": 2}
  1182. }, {
  1183. id: "gl-draw-line-static",
  1184. type: "line",
  1185. filter: ["all", ["==", "mode", "static"], ["==", "$type", "LineString"]],
  1186. layout: {"line-cap": "round", "line-join": "round"},
  1187. paint: {"line-color": "#404040", "line-width": 2}
  1188. }, {
  1189. id: "gl-draw-point-static",
  1190. type: "circle",
  1191. filter: ["all", ["==", "mode", "static"], ["==", "$type", "Point"]],
  1192. paint: {"circle-radius": 5, "circle-color": "#404040"}
  1193. }];
  1194.  
  1195. function et(t) {
  1196. return function (e) {
  1197. var n = e.featureTarget;
  1198. return !!n && (!!n.properties && n.properties.meta === t)
  1199. }
  1200. }
  1201.  
  1202. function nt(t) {
  1203. return !!t.originalEvent && (!!t.originalEvent.shiftKey && 0 === t.originalEvent.button)
  1204. }
  1205.  
  1206. function ot(t) {
  1207. return !!t.featureTarget && (!!t.featureTarget.properties && (t.featureTarget.properties.active === v.ACTIVE && t.featureTarget.properties.meta === y.FEATURE))
  1208. }
  1209.  
  1210. function rt(t) {
  1211. return !!t.featureTarget && (!!t.featureTarget.properties && (t.featureTarget.properties.active === v.INACTIVE && t.featureTarget.properties.meta === y.FEATURE))
  1212. }
  1213.  
  1214. function it(t) {
  1215. return void 0 === t.featureTarget
  1216. }
  1217.  
  1218. function at(t) {
  1219. return !!t.featureTarget && (!!t.featureTarget.properties && t.featureTarget.properties.meta === y.FEATURE)
  1220. }
  1221.  
  1222. function st(t) {
  1223. var e = t.featureTarget;
  1224. return !!e && (!!e.properties && e.properties.meta === y.VERTEX)
  1225. }
  1226.  
  1227. function ut(t) {
  1228. return !!t.originalEvent && !0 === t.originalEvent.shiftKey
  1229. }
  1230.  
  1231. function ct(t) {
  1232. return 27 === t.keyCode
  1233. }
  1234.  
  1235. function lt(t) {
  1236. return 13 === t.keyCode
  1237. }
  1238.  
  1239. var dt = Object.freeze({
  1240. __proto__: null,
  1241. isOfMetaType: et,
  1242. isShiftMousedown: nt,
  1243. isActiveFeature: ot,
  1244. isInactiveFeature: rt,
  1245. noTarget: it,
  1246. isFeature: at,
  1247. isVertex: st,
  1248. isShiftDown: ut,
  1249. isEscapeKey: ct,
  1250. isEnterKey: lt,
  1251. isTrue: function () {
  1252. return !0
  1253. }
  1254. }), pt = ft;
  1255.  
  1256. function ft(t, e) {
  1257. this.x = t, this.y = e
  1258. }
  1259.  
  1260. function ht(t, e) {
  1261. var n = e.getBoundingClientRect();
  1262. return new pt(t.clientX - n.left - (e.clientLeft || 0), t.clientY - n.top - (e.clientTop || 0))
  1263. }
  1264.  
  1265. function gt(t, e, n, o) {
  1266. return {
  1267. type: p.FEATURE,
  1268. properties: {meta: y.VERTEX, parent: t, coord_path: n, active: o ? v.ACTIVE : v.INACTIVE},
  1269. geometry: {type: p.POINT, coordinates: e}
  1270. }
  1271. }
  1272.  
  1273. function yt(t, e, n) {
  1274. var o = e.geometry.coordinates, r = n.geometry.coordinates;
  1275. if (o[1] > 85 || o[1] < _ || r[1] > 85 || r[1] < _) return null;
  1276. var i = {lng: (o[0] + r[0]) / 2, lat: (o[1] + r[1]) / 2};
  1277. return {
  1278. type: p.FEATURE,
  1279. properties: {meta: y.MIDPOINT, parent: t, lng: i.lng, lat: i.lat, coord_path: n.properties.coord_path},
  1280. geometry: {type: p.POINT, coordinates: [i.lng, i.lat]}
  1281. }
  1282. }
  1283.  
  1284. function vt(t, e, n) {
  1285. void 0 === e && (e = {}), void 0 === n && (n = null);
  1286. var o, r = t.geometry, i = r.type, a = r.coordinates, s = t.properties && t.properties.id, u = [];
  1287.  
  1288. function c(t, n) {
  1289. var o = "", r = null;
  1290. t.forEach((function (t, i) {
  1291. var a = null != n ? n + "." + i : String(i), c = gt(s, t, a, l(a));
  1292. if (e.midpoints && r) {
  1293. var d = yt(s, r, c);
  1294. d && u.push(d)
  1295. }
  1296. r = c;
  1297. var p = JSON.stringify(t);
  1298. o !== p && u.push(c), 0 === i && (o = p)
  1299. }))
  1300. }
  1301.  
  1302. function l(t) {
  1303. return !!e.selectedPaths && -1 !== e.selectedPaths.indexOf(t)
  1304. }
  1305.  
  1306. return i === p.POINT ? u.push(gt(s, a, n, l(n))) : i === p.POLYGON ? a.forEach((function (t, e) {
  1307. c(t, null !== n ? n + "." + e : String(e))
  1308. })) : i === p.LINE_STRING ? c(a, n) : 0 === i.indexOf(p.MULTI_PREFIX) && (o = i.replace(p.MULTI_PREFIX, ""), a.forEach((function (n, r) {
  1309. var i = {type: p.FEATURE, properties: t.properties, geometry: {type: o, coordinates: n}};
  1310. u = u.concat(vt(i, e, r))
  1311. }))), u
  1312. }
  1313.  
  1314. ft.prototype = {
  1315. clone: function () {
  1316. return new ft(this.x, this.y)
  1317. }, add: function (t) {
  1318. return this.clone()._add(t)
  1319. }, sub: function (t) {
  1320. return this.clone()._sub(t)
  1321. }, multByPoint: function (t) {
  1322. return this.clone()._multByPoint(t)
  1323. }, divByPoint: function (t) {
  1324. return this.clone()._divByPoint(t)
  1325. }, mult: function (t) {
  1326. return this.clone()._mult(t)
  1327. }, div: function (t) {
  1328. return this.clone()._div(t)
  1329. }, rotate: function (t) {
  1330. return this.clone()._rotate(t)
  1331. }, rotateAround: function (t, e) {
  1332. return this.clone()._rotateAround(t, e)
  1333. }, matMult: function (t) {
  1334. return this.clone()._matMult(t)
  1335. }, unit: function () {
  1336. return this.clone()._unit()
  1337. }, perp: function () {
  1338. return this.clone()._perp()
  1339. }, round: function () {
  1340. return this.clone()._round()
  1341. }, mag: function () {
  1342. return Math.sqrt(this.x * this.x + this.y * this.y)
  1343. }, equals: function (t) {
  1344. return this.x === t.x && this.y === t.y
  1345. }, dist: function (t) {
  1346. return Math.sqrt(this.distSqr(t))
  1347. }, distSqr: function (t) {
  1348. var e = t.x - this.x, n = t.y - this.y;
  1349. return e * e + n * n
  1350. }, angle: function () {
  1351. return Math.atan2(this.y, this.x)
  1352. }, angleTo: function (t) {
  1353. return Math.atan2(this.y - t.y, this.x - t.x)
  1354. }, angleWith: function (t) {
  1355. return this.angleWithSep(t.x, t.y)
  1356. }, angleWithSep: function (t, e) {
  1357. return Math.atan2(this.x * e - this.y * t, this.x * t + this.y * e)
  1358. }, _matMult: function (t) {
  1359. var e = t[0] * this.x + t[1] * this.y, n = t[2] * this.x + t[3] * this.y;
  1360. return this.x = e, this.y = n, this
  1361. }, _add: function (t) {
  1362. return this.x += t.x, this.y += t.y, this
  1363. }, _sub: function (t) {
  1364. return this.x -= t.x, this.y -= t.y, this
  1365. }, _mult: function (t) {
  1366. return this.x *= t, this.y *= t, this
  1367. }, _div: function (t) {
  1368. return this.x /= t, this.y /= t, this
  1369. }, _multByPoint: function (t) {
  1370. return this.x *= t.x, this.y *= t.y, this
  1371. }, _divByPoint: function (t) {
  1372. return this.x /= t.x, this.y /= t.y, this
  1373. }, _unit: function () {
  1374. return this._div(this.mag()), this
  1375. }, _perp: function () {
  1376. var t = this.y;
  1377. return this.y = this.x, this.x = -t, this
  1378. }, _rotate: function (t) {
  1379. var e = Math.cos(t), n = Math.sin(t), o = e * this.x - n * this.y, r = n * this.x + e * this.y;
  1380. return this.x = o, this.y = r, this
  1381. }, _rotateAround: function (t, e) {
  1382. var n = Math.cos(t), o = Math.sin(t), r = e.x + n * (this.x - e.x) - o * (this.y - e.y),
  1383. i = e.y + o * (this.x - e.x) + n * (this.y - e.y);
  1384. return this.x = r, this.y = i, this
  1385. }, _round: function () {
  1386. return this.x = Math.round(this.x), this.y = Math.round(this.y), this
  1387. }
  1388. }, ft.convert = function (t) {
  1389. return t instanceof ft ? t : Array.isArray(t) ? new ft(t[0], t[1]) : t
  1390. };
  1391. var mt = {
  1392. enable: function (t) {
  1393. setTimeout((function () {
  1394. t.map && t.map.doubleClickZoom && t._ctx && t._ctx.store && t._ctx.store.getInitialConfigValue && t._ctx.store.getInitialConfigValue("doubleClickZoom") && t.map.doubleClickZoom.enable()
  1395. }), 0)
  1396. }, disable: function (t) {
  1397. setTimeout((function () {
  1398. t.map && t.map.doubleClickZoom && t.map.doubleClickZoom.disable()
  1399. }), 0)
  1400. }
  1401. }, _t = {}, bt = {
  1402. get exports() {
  1403. return _t
  1404. }, set exports(t) {
  1405. _t = t
  1406. }
  1407. }, Et = function (t) {
  1408. if (!t || !t.type) return null;
  1409. var e = Tt[t.type];
  1410. if (!e) return null;
  1411. if ("geometry" === e) return {
  1412. type: "FeatureCollection",
  1413. features: [{type: "Feature", properties: {}, geometry: t}]
  1414. };
  1415. if ("feature" === e) return {type: "FeatureCollection", features: [t]};
  1416. if ("featurecollection" === e) return t
  1417. }, Tt = {
  1418. Point: "geometry",
  1419. MultiPoint: "geometry",
  1420. LineString: "geometry",
  1421. MultiLineString: "geometry",
  1422. Polygon: "geometry",
  1423. MultiPolygon: "geometry",
  1424. GeometryCollection: "geometry",
  1425. Feature: "feature",
  1426. FeatureCollection: "featurecollection"
  1427. };
  1428. var Ct = Object.freeze({
  1429. __proto__: null, default: function t(e) {
  1430. switch (e && e.type || null) {
  1431. case"FeatureCollection":
  1432. return e.features = e.features.reduce((function (e, n) {
  1433. return e.concat(t(n))
  1434. }), []), e;
  1435. case"Feature":
  1436. return e.geometry ? t(e.geometry).map((function (t) {
  1437. var n = {type: "Feature", properties: JSON.parse(JSON.stringify(e.properties)), geometry: t};
  1438. return void 0 !== e.id && (n.id = e.id), n
  1439. })) : [e];
  1440. case"MultiPoint":
  1441. return e.coordinates.map((function (t) {
  1442. return {type: "Point", coordinates: t}
  1443. }));
  1444. case"MultiPolygon":
  1445. return e.coordinates.map((function (t) {
  1446. return {type: "Polygon", coordinates: t}
  1447. }));
  1448. case"MultiLineString":
  1449. return e.coordinates.map((function (t) {
  1450. return {type: "LineString", coordinates: t}
  1451. }));
  1452. case"GeometryCollection":
  1453. return e.geometries.map(t).reduce((function (t, e) {
  1454. return t.concat(e)
  1455. }), []);
  1456. case"Point":
  1457. case"Polygon":
  1458. case"LineString":
  1459. return [e]
  1460. }
  1461. }
  1462. }), Ot = Et, St = e(Ct), It = function (t) {
  1463. return function t(e) {
  1464. if (Array.isArray(e) && e.length && "number" == typeof e[0]) return [e];
  1465. return e.reduce((function (e, n) {
  1466. return Array.isArray(n) && Array.isArray(n[0]) ? e.concat(t(n)) : (e.push(n), e)
  1467. }), [])
  1468. }(t)
  1469. };
  1470. St instanceof Function || (St = St.default);
  1471. var xt = {}, Mt = {
  1472. get exports() {
  1473. return xt
  1474. }, set exports(t) {
  1475. xt = t
  1476. }
  1477. }.exports = function (t) {
  1478. return new Lt(t)
  1479. };
  1480.  
  1481. function Lt(t) {
  1482. this.value = t
  1483. }
  1484.  
  1485. function Nt(t, e, n) {
  1486. var o = [], r = [], i = !0;
  1487. return function t(a) {
  1488. var s = n ? At(a) : a, u = {}, c = !0, l = {
  1489. node: s,
  1490. node_: a,
  1491. path: [].concat(o),
  1492. parent: r[r.length - 1],
  1493. parents: r,
  1494. key: o.slice(-1)[0],
  1495. isRoot: 0 === o.length,
  1496. level: o.length,
  1497. circular: null,
  1498. update: function (t, e) {
  1499. l.isRoot || (l.parent.node[l.key] = t), l.node = t, e && (c = !1)
  1500. },
  1501. delete: function (t) {
  1502. delete l.parent.node[l.key], t && (c = !1)
  1503. },
  1504. remove: function (t) {
  1505. wt(l.parent.node) ? l.parent.node.splice(l.key, 1) : delete l.parent.node[l.key], t && (c = !1)
  1506. },
  1507. keys: null,
  1508. before: function (t) {
  1509. u.before = t
  1510. },
  1511. after: function (t) {
  1512. u.after = t
  1513. },
  1514. pre: function (t) {
  1515. u.pre = t
  1516. },
  1517. post: function (t) {
  1518. u.post = t
  1519. },
  1520. stop: function () {
  1521. i = !1
  1522. },
  1523. block: function () {
  1524. c = !1
  1525. }
  1526. };
  1527. if (!i) return l;
  1528.  
  1529. function d() {
  1530. if ("object" == typeof l.node && null !== l.node) {
  1531. l.keys && l.node_ === l.node || (l.keys = Pt(l.node)), l.isLeaf = 0 == l.keys.length;
  1532. for (var t = 0; t < r.length; t++) if (r[t].node_ === a) {
  1533. l.circular = r[t];
  1534. break
  1535. }
  1536. } else l.isLeaf = !0, l.keys = null;
  1537. l.notLeaf = !l.isLeaf, l.notRoot = !l.isRoot
  1538. }
  1539.  
  1540. d();
  1541. var p = e.call(l, l.node);
  1542. return void 0 !== p && l.update && l.update(p), u.before && u.before.call(l, l.node), c ? ("object" != typeof l.node || null === l.node || l.circular || (r.push(l), d(), Rt(l.keys, (function (e, r) {
  1543. o.push(e), u.pre && u.pre.call(l, l.node[e], e);
  1544. var i = t(l.node[e]);
  1545. n && kt.call(l.node, e) && (l.node[e] = i.node), i.isLast = r == l.keys.length - 1, i.isFirst = 0 == r, u.post && u.post.call(l, i), o.pop()
  1546. })), r.pop()), u.after && u.after.call(l, l.node), l) : l
  1547. }(t).node
  1548. }
  1549.  
  1550. function At(t) {
  1551. if ("object" == typeof t && null !== t) {
  1552. var e;
  1553. if (wt(t)) e = []; else if ("[object Date]" === Ft(t)) e = new Date(t.getTime ? t.getTime() : t); else if (function (t) {
  1554. return "[object RegExp]" === Ft(t)
  1555. }(t)) e = new RegExp(t); else if (function (t) {
  1556. return "[object Error]" === Ft(t)
  1557. }(t)) e = {message: t.message}; else if (function (t) {
  1558. return "[object Boolean]" === Ft(t)
  1559. }(t)) e = new Boolean(t); else if (function (t) {
  1560. return "[object Number]" === Ft(t)
  1561. }(t)) e = new Number(t); else if (function (t) {
  1562. return "[object String]" === Ft(t)
  1563. }(t)) e = new String(t); else if (Object.create && Object.getPrototypeOf) e = Object.create(Object.getPrototypeOf(t)); else if (t.constructor === Object) e = {}; else {
  1564. var n = t.constructor && t.constructor.prototype || t.__proto__ || {}, o = function () {
  1565. };
  1566. o.prototype = n, e = new o
  1567. }
  1568. return Rt(Pt(t), (function (n) {
  1569. e[n] = t[n]
  1570. })), e
  1571. }
  1572. return t
  1573. }
  1574.  
  1575. Lt.prototype.get = function (t) {
  1576. for (var e = this.value, n = 0; n < t.length; n++) {
  1577. var o = t[n];
  1578. if (!e || !kt.call(e, o)) {
  1579. e = void 0;
  1580. break
  1581. }
  1582. e = e[o]
  1583. }
  1584. return e
  1585. }, Lt.prototype.has = function (t) {
  1586. for (var e = this.value, n = 0; n < t.length; n++) {
  1587. var o = t[n];
  1588. if (!e || !kt.call(e, o)) return !1;
  1589. e = e[o]
  1590. }
  1591. return !0
  1592. }, Lt.prototype.set = function (t, e) {
  1593. for (var n = this.value, o = 0; o < t.length - 1; o++) {
  1594. var r = t[o];
  1595. kt.call(n, r) || (n[r] = {}), n = n[r]
  1596. }
  1597. return n[t[o]] = e, e
  1598. }, Lt.prototype.map = function (t) {
  1599. return Nt(this.value, t, !0)
  1600. }, Lt.prototype.forEach = function (t) {
  1601. return this.value = Nt(this.value, t, !1), this.value
  1602. }, Lt.prototype.reduce = function (t, e) {
  1603. var n = 1 === arguments.length, o = n ? this.value : e;
  1604. return this.forEach((function (e) {
  1605. this.isRoot && n || (o = t.call(this, o, e))
  1606. })), o
  1607. }, Lt.prototype.paths = function () {
  1608. var t = [];
  1609. return this.forEach((function (e) {
  1610. t.push(this.path)
  1611. })), t
  1612. }, Lt.prototype.nodes = function () {
  1613. var t = [];
  1614. return this.forEach((function (e) {
  1615. t.push(this.node)
  1616. })), t
  1617. }, Lt.prototype.clone = function () {
  1618. var t = [], e = [];
  1619. return function n(o) {
  1620. for (var r = 0; r < t.length; r++) if (t[r] === o) return e[r];
  1621. if ("object" == typeof o && null !== o) {
  1622. var i = At(o);
  1623. return t.push(o), e.push(i), Rt(Pt(o), (function (t) {
  1624. i[t] = n(o[t])
  1625. })), t.pop(), e.pop(), i
  1626. }
  1627. return o
  1628. }(this.value)
  1629. };
  1630. var Pt = Object.keys || function (t) {
  1631. var e = [];
  1632. for (var n in t) e.push(n);
  1633. return e
  1634. };
  1635.  
  1636. function Ft(t) {
  1637. return Object.prototype.toString.call(t)
  1638. }
  1639.  
  1640. var wt = Array.isArray || function (t) {
  1641. return "[object Array]" === Object.prototype.toString.call(t)
  1642. }, Rt = function (t, e) {
  1643. if (t.forEach) return t.forEach(e);
  1644. for (var n = 0; n < t.length; n++) e(t[n], n, t)
  1645. };
  1646. Rt(Pt(Lt.prototype), (function (t) {
  1647. Mt[t] = function (e) {
  1648. var n = [].slice.call(arguments, 1), o = new Lt(e);
  1649. return o[t].apply(o, n)
  1650. }
  1651. }));
  1652. var kt = Object.hasOwnProperty || function (t, e) {
  1653. return e in t
  1654. }, Dt = Ut;
  1655.  
  1656. function Ut(t) {
  1657. if (!(this instanceof Ut)) return new Ut(t);
  1658. this._bbox = t || [1 / 0, 1 / 0, -1 / 0, -1 / 0], this._valid = !!t
  1659. }
  1660.  
  1661. Ut.prototype.include = function (t) {
  1662. return this._valid = !0, this._bbox[0] = Math.min(this._bbox[0], t[0]), this._bbox[1] = Math.min(this._bbox[1], t[1]), this._bbox[2] = Math.max(this._bbox[2], t[0]), this._bbox[3] = Math.max(this._bbox[3], t[1]), this
  1663. }, Ut.prototype.equals = function (t) {
  1664. var e;
  1665. return e = t instanceof Ut ? t.bbox() : t, this._bbox[0] == e[0] && this._bbox[1] == e[1] && this._bbox[2] == e[2] && this._bbox[3] == e[3]
  1666. }, Ut.prototype.center = function (t) {
  1667. return this._valid ? [(this._bbox[0] + this._bbox[2]) / 2, (this._bbox[1] + this._bbox[3]) / 2] : null
  1668. }, Ut.prototype.union = function (t) {
  1669. var e;
  1670. return this._valid = !0, e = t instanceof Ut ? t.bbox() : t, this._bbox[0] = Math.min(this._bbox[0], e[0]), this._bbox[1] = Math.min(this._bbox[1], e[1]), this._bbox[2] = Math.max(this._bbox[2], e[2]), this._bbox[3] = Math.max(this._bbox[3], e[3]), this
  1671. }, Ut.prototype.bbox = function () {
  1672. return this._valid ? this._bbox : null
  1673. }, Ut.prototype.contains = function (t) {
  1674. if (!t) return this._fastContains();
  1675. if (!this._valid) return null;
  1676. var e = t[0], n = t[1];
  1677. return this._bbox[0] <= e && this._bbox[1] <= n && this._bbox[2] >= e && this._bbox[3] >= n
  1678. }, Ut.prototype.intersect = function (t) {
  1679. return this._valid ? (e = t instanceof Ut ? t.bbox() : t, !(this._bbox[0] > e[2] || this._bbox[2] < e[0] || this._bbox[3] < e[1] || this._bbox[1] > e[3])) : null;
  1680. var e
  1681. }, Ut.prototype._fastContains = function () {
  1682. if (!this._valid) return new Function("return null;");
  1683. var t = "return " + this._bbox[0] + "<= ll[0] &&" + this._bbox[1] + "<= ll[1] &&" + this._bbox[2] + ">= ll[0] &&" + this._bbox[3] + ">= ll[1]";
  1684. return new Function("ll", t)
  1685. }, Ut.prototype.polygon = function () {
  1686. return this._valid ? {
  1687. type: "Polygon",
  1688. coordinates: [[[this._bbox[0], this._bbox[1]], [this._bbox[2], this._bbox[1]], [this._bbox[2], this._bbox[3]], [this._bbox[0], this._bbox[3]], [this._bbox[0], this._bbox[1]]]]
  1689. } : null
  1690. };
  1691. var jt = function (t) {
  1692. if (!t) return [];
  1693. var e = St(Ot(t)), n = [];
  1694. return e.features.forEach((function (t) {
  1695. t.geometry && (n = n.concat(It(t.geometry.coordinates)))
  1696. })), n
  1697. }, Vt = xt, Bt = Dt, Gt = {
  1698. features: ["FeatureCollection"],
  1699. coordinates: ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"],
  1700. geometry: ["Feature"],
  1701. geometries: ["GeometryCollection"]
  1702. }, Jt = Object.keys(Gt);
  1703.  
  1704. function zt(t) {
  1705. for (var e = Bt(), n = jt(t), o = 0; o < n.length; o++) e.include(n[o]);
  1706. return e
  1707. }
  1708.  
  1709. bt.exports = function (t) {
  1710. return zt(t).bbox()
  1711. }, _t.polygon = function (t) {
  1712. return zt(t).polygon()
  1713. }, _t.bboxify = function (t) {
  1714. return Vt(t).map((function (t) {
  1715. t && (Jt.some((function (e) {
  1716. return !!t[e] && -1 !== Gt[e].indexOf(t.type)
  1717. })) && (t.bbox = zt(t).bbox(), this.update(t)))
  1718. }))
  1719. };
  1720. var Yt = -90;
  1721.  
  1722. function $t(t, e) {
  1723. var n = Yt, o = 90, r = Yt, i = 90, a = 270, s = -270;
  1724. t.forEach((function (t) {
  1725. var e = _t(t), u = e[1], c = e[3], l = e[0], d = e[2];
  1726. u > n && (n = u), c < o && (o = c), c > r && (r = c), u < i && (i = u), l < a && (a = l), d > s && (s = d)
  1727. }));
  1728. var u = e;
  1729. return n + u.lat > 85 && (u.lat = 85 - n), r + u.lat > 90 && (u.lat = 90 - r), o + u.lat < -85 && (u.lat = -85 - o), i + u.lat < Yt && (u.lat = Yt - i), a + u.lng <= -270 && (u.lng += 360 * Math.ceil(Math.abs(u.lng) / 360)), s + u.lng >= 270 && (u.lng -= 360 * Math.ceil(Math.abs(u.lng) / 360)), u
  1730. }
  1731.  
  1732. function qt(t, e) {
  1733. var n = $t(t.map((function (t) {
  1734. return t.toGeoJSON()
  1735. })), e);
  1736. t.forEach((function (t) {
  1737. var e, o = t.getCoordinates(), r = function (t) {
  1738. var e = {lng: t[0] + n.lng, lat: t[1] + n.lat};
  1739. return [e.lng, e.lat]
  1740. }, i = function (t) {
  1741. return t.map((function (t) {
  1742. return r(t)
  1743. }))
  1744. };
  1745. t.type === p.POINT ? e = r(o) : t.type === p.LINE_STRING || t.type === p.MULTI_POINT ? e = o.map(r) : t.type === p.POLYGON || t.type === p.MULTI_LINE_STRING ? e = o.map(i) : t.type === p.MULTI_POLYGON && (e = o.map((function (t) {
  1746. return t.map((function (t) {
  1747. return i(t)
  1748. }))
  1749. }))), t.incomingCoords(e)
  1750. }))
  1751. }
  1752.  
  1753. var Ht = {
  1754. onSetup: function (t) {
  1755. var e = this, n = {
  1756. dragMoveLocation: null,
  1757. boxSelectStartLocation: null,
  1758. boxSelectElement: void 0,
  1759. boxSelecting: !1,
  1760. canBoxSelect: !1,
  1761. dragMoving: !1,
  1762. canDragMove: !1,
  1763. initiallySelectedFeatureIds: t.featureIds || []
  1764. };
  1765. return this.setSelected(n.initiallySelectedFeatureIds.filter((function (t) {
  1766. return void 0 !== e.getFeature(t)
  1767. }))), this.fireActionable(), this.setActionableState({
  1768. combineFeatures: !0,
  1769. uncombineFeatures: !0,
  1770. trash: !0
  1771. }), n
  1772. }, fireUpdate: function () {
  1773. this.map.fire(h.UPDATE, {
  1774. action: g.MOVE, features: this.getSelected().map((function (t) {
  1775. return t.toGeoJSON()
  1776. }))
  1777. })
  1778. }, fireActionable: function () {
  1779. var t = this, e = this.getSelected(), n = e.filter((function (e) {
  1780. return t.isInstanceOf("MultiFeature", e)
  1781. })), o = !1;
  1782. if (e.length > 1) {
  1783. o = !0;
  1784. var r = e[0].type.replace("Multi", "");
  1785. e.forEach((function (t) {
  1786. t.type.replace("Multi", "") !== r && (o = !1)
  1787. }))
  1788. }
  1789. var i = n.length > 0, a = e.length > 0;
  1790. this.setActionableState({combineFeatures: o, uncombineFeatures: i, trash: a})
  1791. }, getUniqueIds: function (t) {
  1792. return t.length ? t.map((function (t) {
  1793. return t.properties.id
  1794. })).filter((function (t) {
  1795. return void 0 !== t
  1796. })).reduce((function (t, e) {
  1797. return t.add(e), t
  1798. }), new S).values() : []
  1799. }, stopExtendedInteractions: function (t) {
  1800. t.boxSelectElement && (t.boxSelectElement.parentNode && t.boxSelectElement.parentNode.removeChild(t.boxSelectElement), t.boxSelectElement = null), this.map.dragPan.enable(), t.boxSelecting = !1, t.canBoxSelect = !1, t.dragMoving = !1, t.canDragMove = !1
  1801. }, onStop: function () {
  1802. mt.enable(this)
  1803. }, onMouseMove: function (t) {
  1804. return this.stopExtendedInteractions(t), !0
  1805. }, onMouseOut: function (t) {
  1806. return !t.dragMoving || this.fireUpdate()
  1807. }
  1808. };
  1809. Ht.onTap = Ht.onClick = function (t, e) {
  1810. return it(e) ? this.clickAnywhere(t, e) : et(y.VERTEX)(e) ? this.clickOnVertex(t, e) : at(e) ? this.clickOnFeature(t, e) : void 0
  1811. }, Ht.clickAnywhere = function (t) {
  1812. var e = this, n = this.getSelectedIds();
  1813. n.length && (this.clearSelectedFeatures(), n.forEach((function (t) {
  1814. return e.doRender(t)
  1815. }))), mt.enable(this), this.stopExtendedInteractions(t)
  1816. }, Ht.clickOnVertex = function (t, e) {
  1817. this.changeMode(f.DIRECT_SELECT, {
  1818. featureId: e.featureTarget.properties.parent,
  1819. coordPath: e.featureTarget.properties.coord_path,
  1820. startPos: e.lngLat
  1821. }), this.updateUIClasses({mouse: l.MOVE})
  1822. }, Ht.startOnActiveFeature = function (t, e) {
  1823. this.stopExtendedInteractions(t), this.map.dragPan.disable(), this.doRender(e.featureTarget.properties.id), t.canDragMove = !0, t.dragMoveLocation = e.lngLat
  1824. }, Ht.clickOnFeature = function (t, e) {
  1825. var n = this;
  1826. mt.disable(this), this.stopExtendedInteractions(t);
  1827. var o = ut(e), r = this.getSelectedIds(), i = e.featureTarget.properties.id, a = this.isSelected(i);
  1828. if (!o && a && this.getFeature(i).type !== p.POINT) return this.changeMode(f.DIRECT_SELECT, {featureId: i});
  1829. a && o ? (this.deselect(i), this.updateUIClasses({mouse: l.POINTER}), 1 === r.length && mt.enable(this)) : !a && o ? (this.select(i), this.updateUIClasses({mouse: l.MOVE})) : a || o || (r.forEach((function (t) {
  1830. return n.doRender(t)
  1831. })), this.setSelected(i), this.updateUIClasses({mouse: l.MOVE})), this.doRender(i)
  1832. }, Ht.onMouseDown = function (t, e) {
  1833. return ot(e) ? this.startOnActiveFeature(t, e) : this.drawConfig.boxSelect && nt(e) ? this.startBoxSelect(t, e) : void 0
  1834. }, Ht.startBoxSelect = function (t, e) {
  1835. this.stopExtendedInteractions(t), this.map.dragPan.disable(), t.boxSelectStartLocation = ht(e.originalEvent, this.map.getContainer()), t.canBoxSelect = !0
  1836. }, Ht.onTouchStart = function (t, e) {
  1837. if (ot(e)) return this.startOnActiveFeature(t, e)
  1838. }, Ht.onDrag = function (t, e) {
  1839. return t.canDragMove ? this.dragMove(t, e) : this.drawConfig.boxSelect && t.canBoxSelect ? this.whileBoxSelect(t, e) : void 0
  1840. }, Ht.whileBoxSelect = function (t, e) {
  1841. t.boxSelecting = !0, this.updateUIClasses({mouse: l.ADD}), t.boxSelectElement || (t.boxSelectElement = document.createElement("div"), t.boxSelectElement.classList.add(u.BOX_SELECT), this.map.getContainer().appendChild(t.boxSelectElement));
  1842. var n = ht(e.originalEvent, this.map.getContainer()), o = Math.min(t.boxSelectStartLocation.x, n.x),
  1843. r = Math.max(t.boxSelectStartLocation.x, n.x), i = Math.min(t.boxSelectStartLocation.y, n.y),
  1844. a = Math.max(t.boxSelectStartLocation.y, n.y), s = "translate(" + o + "px, " + i + "px)";
  1845. t.boxSelectElement.style.transform = s, t.boxSelectElement.style.WebkitTransform = s, t.boxSelectElement.style.width = r - o + "px", t.boxSelectElement.style.height = a - i + "px"
  1846. }, Ht.dragMove = function (t, e) {
  1847. t.dragMoving = !0, e.originalEvent.stopPropagation();
  1848. var n = {lng: e.lngLat.lng - t.dragMoveLocation.lng, lat: e.lngLat.lat - t.dragMoveLocation.lat};
  1849. qt(this.getSelected(), n), t.dragMoveLocation = e.lngLat
  1850. }, Ht.onTouchEnd = Ht.onMouseUp = function (t, e) {
  1851. var n = this;
  1852. if (t.dragMoving) this.fireUpdate(); else if (t.boxSelecting) {
  1853. var o = [t.boxSelectStartLocation, ht(e.originalEvent, this.map.getContainer())],
  1854. r = this.featuresAt(null, o, "click"), i = this.getUniqueIds(r).filter((function (t) {
  1855. return !n.isSelected(t)
  1856. }));
  1857. i.length && (this.select(i), i.forEach((function (t) {
  1858. return n.doRender(t)
  1859. })), this.updateUIClasses({mouse: l.MOVE}))
  1860. }
  1861. this.stopExtendedInteractions(t)
  1862. }, Ht.toDisplayFeatures = function (t, e, n) {
  1863. e.properties.active = this.isSelected(e.properties.id) ? v.ACTIVE : v.INACTIVE, n(e), this.fireActionable(), e.properties.active === v.ACTIVE && e.geometry.type !== p.POINT && vt(e).forEach(n)
  1864. }, Ht.onTrash = function () {
  1865. this.deleteFeature(this.getSelectedIds()), this.fireActionable()
  1866. }, Ht.onCombineFeatures = function () {
  1867. var t = this.getSelected();
  1868. if (!(0 === t.length || t.length < 2)) {
  1869. for (var e = [], n = [], o = t[0].type.replace("Multi", ""), r = 0; r < t.length; r++) {
  1870. var i = t[r];
  1871. if (i.type.replace("Multi", "") !== o) return;
  1872. i.type.includes("Multi") ? i.getCoordinates().forEach((function (t) {
  1873. e.push(t)
  1874. })) : e.push(i.getCoordinates()), n.push(i.toGeoJSON())
  1875. }
  1876. if (n.length > 1) {
  1877. var a = this.newFeature({
  1878. type: p.FEATURE,
  1879. properties: n[0].properties,
  1880. geometry: {type: "Multi" + o, coordinates: e}
  1881. });
  1882. this.addFeature(a), this.deleteFeature(this.getSelectedIds(), {silent: !0}), this.setSelected([a.id]), this.map.fire(h.COMBINE_FEATURES, {
  1883. createdFeatures: [a.toGeoJSON()],
  1884. deletedFeatures: n
  1885. })
  1886. }
  1887. this.fireActionable()
  1888. }
  1889. }, Ht.onUncombineFeatures = function () {
  1890. var t = this, e = this.getSelected();
  1891. if (0 !== e.length) {
  1892. for (var n = [], o = [], r = function (r) {
  1893. var i = e[r];
  1894. t.isInstanceOf("MultiFeature", i) && (i.getFeatures().forEach((function (e) {
  1895. t.addFeature(e), e.properties = i.properties, n.push(e.toGeoJSON()), t.select([e.id])
  1896. })), t.deleteFeature(i.id, {silent: !0}), o.push(i.toGeoJSON()))
  1897. }, i = 0; i < e.length; i++) r(i);
  1898. n.length > 1 && this.map.fire(h.UNCOMBINE_FEATURES, {
  1899. createdFeatures: n,
  1900. deletedFeatures: o
  1901. }), this.fireActionable()
  1902. }
  1903. };
  1904. var Xt = et(y.VERTEX), Wt = et(y.MIDPOINT), Zt = {
  1905. fireUpdate: function () {
  1906. this.map.fire(h.UPDATE, {
  1907. action: g.CHANGE_COORDINATES, features: this.getSelected().map((function (t) {
  1908. return t.toGeoJSON()
  1909. }))
  1910. })
  1911. }, fireActionable: function (t) {
  1912. this.setActionableState({
  1913. combineFeatures: !1,
  1914. uncombineFeatures: !1,
  1915. trash: t.selectedCoordPaths.length > 0
  1916. })
  1917. }, startDragging: function (t, e) {
  1918. this.map.dragPan.disable(), t.canDragMove = !0, t.dragMoveLocation = e.lngLat
  1919. }, stopDragging: function (t) {
  1920. this.map.dragPan.enable(), t.dragMoving = !1, t.canDragMove = !1, t.dragMoveLocation = null
  1921. }, onVertex: function (t, e) {
  1922. this.startDragging(t, e);
  1923. var n = e.featureTarget.properties, o = t.selectedCoordPaths.indexOf(n.coord_path);
  1924. ut(e) || -1 !== o ? ut(e) && -1 === o && t.selectedCoordPaths.push(n.coord_path) : t.selectedCoordPaths = [n.coord_path];
  1925. var r = this.pathsToCoordinates(t.featureId, t.selectedCoordPaths);
  1926. this.setSelectedCoordinates(r)
  1927. }, onMidpoint: function (t, e) {
  1928. this.startDragging(t, e);
  1929. var n = e.featureTarget.properties;
  1930. t.feature.addCoordinate(n.coord_path, n.lng, n.lat), this.fireUpdate(), t.selectedCoordPaths = [n.coord_path]
  1931. }, pathsToCoordinates: function (t, e) {
  1932. return e.map((function (e) {
  1933. return {feature_id: t, coord_path: e}
  1934. }))
  1935. }, onFeature: function (t, e) {
  1936. 0 === t.selectedCoordPaths.length ? this.startDragging(t, e) : this.stopDragging(t)
  1937. }, dragFeature: function (t, e, n) {
  1938. qt(this.getSelected(), n), t.dragMoveLocation = e.lngLat
  1939. }, dragVertex: function (t, e, n) {
  1940. for (var o = t.selectedCoordPaths.map((function (e) {
  1941. return t.feature.getCoordinate(e)
  1942. })), r = $t(o.map((function (t) {
  1943. return {type: p.FEATURE, properties: {}, geometry: {type: p.POINT, coordinates: t}}
  1944. })), n), i = 0; i < o.length; i++) {
  1945. var a = o[i];
  1946. t.feature.updateCoordinate(t.selectedCoordPaths[i], a[0] + r.lng, a[1] + r.lat)
  1947. }
  1948. }, clickNoTarget: function () {
  1949. this.changeMode(f.SIMPLE_SELECT)
  1950. }, clickInactive: function () {
  1951. this.changeMode(f.SIMPLE_SELECT)
  1952. }, clickActiveFeature: function (t) {
  1953. t.selectedCoordPaths = [], this.clearSelectedCoordinates(), t.feature.changed()
  1954. }, onSetup: function (t) {
  1955. var e = t.featureId, n = this.getFeature(e);
  1956. if (!n) throw new Error("You must provide a featureId to enter direct_select mode");
  1957. if (n.type === p.POINT) throw new TypeError("direct_select mode doesn't handle point features");
  1958. var o = {
  1959. featureId: e,
  1960. feature: n,
  1961. dragMoveLocation: t.startPos || null,
  1962. dragMoving: !1,
  1963. canDragMove: !1,
  1964. selectedCoordPaths: t.coordPath ? [t.coordPath] : []
  1965. };
  1966. return this.setSelectedCoordinates(this.pathsToCoordinates(e, o.selectedCoordPaths)), this.setSelected(e), mt.disable(this), this.setActionableState({trash: !0}), o
  1967. }, onStop: function () {
  1968. mt.enable(this), this.clearSelectedCoordinates()
  1969. }, toDisplayFeatures: function (t, e, n) {
  1970. t.featureId === e.properties.id ? (e.properties.active = v.ACTIVE, n(e), vt(e, {
  1971. map: this.map,
  1972. midpoints: !0,
  1973. selectedPaths: t.selectedCoordPaths
  1974. }).forEach(n)) : (e.properties.active = v.INACTIVE, n(e)), this.fireActionable(t)
  1975. }, onTrash: function (t) {
  1976. t.selectedCoordPaths.sort((function (t, e) {
  1977. return e.localeCompare(t, "en", {numeric: !0})
  1978. })).forEach((function (e) {
  1979. return t.feature.removeCoordinate(e)
  1980. })), this.fireUpdate(), t.selectedCoordPaths = [], this.clearSelectedCoordinates(), this.fireActionable(t), !1 === t.feature.isValid() && (this.deleteFeature([t.featureId]), this.changeMode(f.SIMPLE_SELECT, {}))
  1981. }, onMouseMove: function (t, e) {
  1982. var n = ot(e), o = Xt(e), r = 0 === t.selectedCoordPaths.length;
  1983. return n && r || o && !r ? this.updateUIClasses({mouse: l.MOVE}) : this.updateUIClasses({mouse: l.NONE}), this.stopDragging(t), !0
  1984. }, onMouseOut: function (t) {
  1985. return t.dragMoving && this.fireUpdate(), !0
  1986. }
  1987. };
  1988. Zt.onTouchStart = Zt.onMouseDown = function (t, e) {
  1989. return Xt(e) ? this.onVertex(t, e) : ot(e) ? this.onFeature(t, e) : Wt(e) ? this.onMidpoint(t, e) : void 0
  1990. }, Zt.onDrag = function (t, e) {
  1991. if (!0 === t.canDragMove) {
  1992. t.dragMoving = !0, e.originalEvent.stopPropagation();
  1993. var n = {lng: e.lngLat.lng - t.dragMoveLocation.lng, lat: e.lngLat.lat - t.dragMoveLocation.lat};
  1994. t.selectedCoordPaths.length > 0 ? this.dragVertex(t, e, n) : this.dragFeature(t, e, n), t.dragMoveLocation = e.lngLat
  1995. }
  1996. }, Zt.onClick = function (t, e) {
  1997. return it(e) ? this.clickNoTarget(t, e) : ot(e) ? this.clickActiveFeature(t, e) : rt(e) ? this.clickInactive(t, e) : void this.stopDragging(t)
  1998. }, Zt.onTap = function (t, e) {
  1999. return it(e) ? this.clickNoTarget(t, e) : ot(e) ? this.clickActiveFeature(t, e) : rt(e) ? this.clickInactive(t, e) : void 0
  2000. }, Zt.onTouchEnd = Zt.onMouseUp = function (t) {
  2001. t.dragMoving && this.fireUpdate(), this.stopDragging(t)
  2002. };
  2003. var Kt = {};
  2004.  
  2005. function Qt(t, e) {
  2006. return !!t.lngLat && (t.lngLat.lng === e[0] && t.lngLat.lat === e[1])
  2007. }
  2008.  
  2009. Kt.onSetup = function () {
  2010. var t = this.newFeature({type: p.FEATURE, properties: {}, geometry: {type: p.POINT, coordinates: []}});
  2011. return this.addFeature(t), this.clearSelectedFeatures(), this.updateUIClasses({mouse: l.ADD}), this.activateUIButton(d.POINT), this.setActionableState({trash: !0}), {point: t}
  2012. }, Kt.stopDrawingAndRemove = function (t) {
  2013. this.deleteFeature([t.point.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT)
  2014. }, Kt.onTap = Kt.onClick = function (t, e) {
  2015. this.updateUIClasses({mouse: l.MOVE}), t.point.updateCoordinate("", e.lngLat.lng, e.lngLat.lat), this.map.fire(h.CREATE, {features: [t.point.toGeoJSON()]}), this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.point.id]})
  2016. }, Kt.onStop = function (t) {
  2017. this.activateUIButton(), t.point.getCoordinate().length || this.deleteFeature([t.point.id], {silent: !0})
  2018. }, Kt.toDisplayFeatures = function (t, e, n) {
  2019. var o = e.properties.id === t.point.id;
  2020. if (e.properties.active = o ? v.ACTIVE : v.INACTIVE, !o) return n(e)
  2021. }, Kt.onTrash = Kt.stopDrawingAndRemove, Kt.onKeyUp = function (t, e) {
  2022. if (ct(e) || lt(e)) return this.stopDrawingAndRemove(t, e)
  2023. };
  2024. var te = {
  2025. onSetup: function () {
  2026. var t = this.newFeature({type: p.FEATURE, properties: {}, geometry: {type: p.POLYGON, coordinates: [[]]}});
  2027. return this.addFeature(t), this.clearSelectedFeatures(), mt.disable(this), this.updateUIClasses({mouse: l.ADD}), this.activateUIButton(d.POLYGON), this.setActionableState({trash: !0}), {
  2028. polygon: t,
  2029. currentVertexPosition: 0
  2030. }
  2031. }, clickAnywhere: function (t, e) {
  2032. if (t.currentVertexPosition > 0 && Qt(e, t.polygon.coordinates[0][t.currentVertexPosition - 1])) return this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.polygon.id]});
  2033. this.updateUIClasses({mouse: l.ADD}), t.polygon.updateCoordinate("0." + t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat), t.currentVertexPosition++, t.polygon.updateCoordinate("0." + t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat)
  2034. }, clickOnVertex: function (t) {
  2035. return this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.polygon.id]})
  2036. }, onMouseMove: function (t, e) {
  2037. t.polygon.updateCoordinate("0." + t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat), st(e) && this.updateUIClasses({mouse: l.POINTER})
  2038. }
  2039. };
  2040. te.onTap = te.onClick = function (t, e) {
  2041. return st(e) ? this.clickOnVertex(t, e) : this.clickAnywhere(t, e)
  2042. }, te.onKeyUp = function (t, e) {
  2043. ct(e) ? (this.deleteFeature([t.polygon.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT)) : lt(e) && this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.polygon.id]})
  2044. }, te.onStop = function (t) {
  2045. this.updateUIClasses({mouse: l.NONE}), mt.enable(this), this.activateUIButton(), void 0 !== this.getFeature(t.polygon.id) && (t.polygon.removeCoordinate("0." + t.currentVertexPosition), t.polygon.isValid() ? this.map.fire(h.CREATE, {features: [t.polygon.toGeoJSON()]}) : (this.deleteFeature([t.polygon.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT, {}, {silent: !0})))
  2046. }, te.toDisplayFeatures = function (t, e, n) {
  2047. var o = e.properties.id === t.polygon.id;
  2048. if (e.properties.active = o ? v.ACTIVE : v.INACTIVE, !o) return n(e);
  2049. if (0 !== e.geometry.coordinates.length) {
  2050. var r = e.geometry.coordinates[0].length;
  2051. if (!(r < 3)) {
  2052. if (e.properties.meta = y.FEATURE, n(gt(t.polygon.id, e.geometry.coordinates[0][0], "0.0", !1)), r > 3) {
  2053. var i = e.geometry.coordinates[0].length - 3;
  2054. n(gt(t.polygon.id, e.geometry.coordinates[0][i], "0." + i, !1))
  2055. }
  2056. if (r <= 4) {
  2057. var a = [[e.geometry.coordinates[0][0][0], e.geometry.coordinates[0][0][1]], [e.geometry.coordinates[0][1][0], e.geometry.coordinates[0][1][1]]];
  2058. if (n({
  2059. type: p.FEATURE,
  2060. properties: e.properties,
  2061. geometry: {coordinates: a, type: p.LINE_STRING}
  2062. }), 3 === r) return
  2063. }
  2064. return n(e)
  2065. }
  2066. }
  2067. }, te.onTrash = function (t) {
  2068. this.deleteFeature([t.polygon.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT)
  2069. };
  2070. var ee = {
  2071. onSetup: function (t) {
  2072. var e, n, o = (t = t || {}).featureId, r = "forward";
  2073. if (o) {
  2074. if (!(e = this.getFeature(o))) throw new Error("Could not find a feature with the provided featureId");
  2075. var i = t.from;
  2076. 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");
  2077. var a = e.coordinates.length - 1;
  2078. if (e.coordinates[a][0] === i[0] && e.coordinates[a][1] === i[1]) n = a + 1, e.addCoordinate.apply(e, [n].concat(e.coordinates[a])); else {
  2079. if (e.coordinates[0][0] !== i[0] || e.coordinates[0][1] !== i[1]) throw new Error("`from` should match the point at either the start or the end of the provided LineString");
  2080. r = "backwards", n = 0, e.addCoordinate.apply(e, [n].concat(e.coordinates[0]))
  2081. }
  2082. } else e = this.newFeature({
  2083. type: p.FEATURE,
  2084. properties: {},
  2085. geometry: {type: p.LINE_STRING, coordinates: []}
  2086. }), n = 0, this.addFeature(e);
  2087. return this.clearSelectedFeatures(), mt.disable(this), this.updateUIClasses({mouse: l.ADD}), this.activateUIButton(d.LINE), this.setActionableState({trash: !0}), {
  2088. line: e,
  2089. currentVertexPosition: n,
  2090. direction: r
  2091. }
  2092. }, clickAnywhere: function (t, e) {
  2093. if (t.currentVertexPosition > 0 && Qt(e, t.line.coordinates[t.currentVertexPosition - 1]) || "backwards" === t.direction && Qt(e, t.line.coordinates[t.currentVertexPosition + 1])) return this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.line.id]});
  2094. this.updateUIClasses({mouse: l.ADD}), t.line.updateCoordinate(t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat), "forward" === t.direction ? (t.currentVertexPosition++, t.line.updateCoordinate(t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat)) : t.line.addCoordinate(0, e.lngLat.lng, e.lngLat.lat)
  2095. }, clickOnVertex: function (t) {
  2096. return this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.line.id]})
  2097. }, onMouseMove: function (t, e) {
  2098. t.line.updateCoordinate(t.currentVertexPosition, e.lngLat.lng, e.lngLat.lat), st(e) && this.updateUIClasses({mouse: l.POINTER})
  2099. }
  2100. };
  2101. ee.onTap = ee.onClick = function (t, e) {
  2102. if (st(e)) return this.clickOnVertex(t, e);
  2103. this.clickAnywhere(t, e)
  2104. }, ee.onKeyUp = function (t, e) {
  2105. lt(e) ? this.changeMode(f.SIMPLE_SELECT, {featureIds: [t.line.id]}) : ct(e) && (this.deleteFeature([t.line.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT))
  2106. }, ee.onStop = function (t) {
  2107. mt.enable(this), this.activateUIButton(), void 0 !== this.getFeature(t.line.id) && (t.line.removeCoordinate("" + t.currentVertexPosition), t.line.isValid() ? this.map.fire(h.CREATE, {features: [t.line.toGeoJSON()]}) : (this.deleteFeature([t.line.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT, {}, {silent: !0})))
  2108. }, ee.onTrash = function (t) {
  2109. this.deleteFeature([t.line.id], {silent: !0}), this.changeMode(f.SIMPLE_SELECT)
  2110. }, ee.toDisplayFeatures = function (t, e, n) {
  2111. var o = e.properties.id === t.line.id;
  2112. if (e.properties.active = o ? v.ACTIVE : v.INACTIVE, !o) return n(e);
  2113. e.geometry.coordinates.length < 2 || (e.properties.meta = y.FEATURE, n(gt(t.line.id, e.geometry.coordinates["forward" === t.direction ? e.geometry.coordinates.length - 2 : 1], "" + ("forward" === t.direction ? e.geometry.coordinates.length - 2 : 1), !1)), n(e))
  2114. };
  2115. var ne = {simple_select: Ht, direct_select: Zt, draw_point: Kt, draw_polygon: te, draw_line_string: ee}, oe = {
  2116. defaultMode: f.SIMPLE_SELECT,
  2117. keybindings: !0,
  2118. touchEnabled: !0,
  2119. clickBuffer: 2,
  2120. touchBuffer: 25,
  2121. boxSelect: !0,
  2122. displayControlsDefault: !0,
  2123. styles: tt,
  2124. modes: ne,
  2125. controls: {},
  2126. userProperties: !1
  2127. }, re = {point: !0, line_string: !0, polygon: !0, trash: !0, combine_features: !0, uncombine_features: !0},
  2128. ie = {point: !1, line_string: !1, polygon: !1, trash: !1, combine_features: !1, uncombine_features: !1};
  2129.  
  2130. function ae(t, e) {
  2131. return t.map((function (t) {
  2132. return t.source ? t : W(t, {id: t.id + "." + e, source: "hot" === e ? c.HOT : c.COLD})
  2133. }))
  2134. }
  2135.  
  2136. var se = {};
  2137. !function (t, e) {
  2138. var n = "__lodash_hash_undefined__", o = 9007199254740991, r = "[object Arguments]", i = "[object Array]",
  2139. a = "[object Boolean]", s = "[object Date]", u = "[object Error]", c = "[object Function]",
  2140. l = "[object Map]", d = "[object Number]", p = "[object Object]", f = "[object Promise]",
  2141. h = "[object RegExp]", g = "[object Set]", y = "[object String]", v = "[object Symbol]",
  2142. m = "[object WeakMap]", _ = "[object ArrayBuffer]", b = "[object DataView]",
  2143. E = /^\[object .+?Constructor\]$/, T = /^(?:0|[1-9]\d*)$/, C = {};
  2144. C["[object Float32Array]"] = C["[object Float64Array]"] = C["[object Int8Array]"] = C["[object Int16Array]"] = C["[object Int32Array]"] = C["[object Uint8Array]"] = C["[object Uint8ClampedArray]"] = C["[object Uint16Array]"] = C["[object Uint32Array]"] = !0, C[r] = C[i] = C[_] = C[a] = C[b] = C[s] = C[u] = C[c] = C[l] = C[d] = C[p] = C[h] = C[g] = C[y] = C[m] = !1;
  2145. var O = "object" == typeof global && global && global.Object === Object && global,
  2146. S = "object" == typeof self && self && self.Object === Object && self,
  2147. I = O || S || Function("return this")(), x = e && !e.nodeType && e, M = x && t && !t.nodeType && t,
  2148. L = M && M.exports === x, N = L && O.process, A = function () {
  2149. try {
  2150. return N && N.binding && N.binding("util")
  2151. } catch (t) {
  2152. }
  2153. }(), P = A && A.isTypedArray;
  2154.  
  2155. function F(t, e) {
  2156. for (var n = -1, o = null == t ? 0 : t.length; ++n < o;) if (e(t[n], n, t)) return !0;
  2157. return !1
  2158. }
  2159.  
  2160. function w(t) {
  2161. var e = -1, n = Array(t.size);
  2162. return t.forEach((function (t, o) {
  2163. n[++e] = [o, t]
  2164. })), n
  2165. }
  2166.  
  2167. function R(t) {
  2168. var e = -1, n = Array(t.size);
  2169. return t.forEach((function (t) {
  2170. n[++e] = t
  2171. })), n
  2172. }
  2173.  
  2174. var k, D, U, j = Array.prototype, V = Function.prototype, B = Object.prototype, G = I["__core-js_shared__"],
  2175. J = V.toString, z = B.hasOwnProperty,
  2176. Y = (k = /[^.]+$/.exec(G && G.keys && G.keys.IE_PROTO || "")) ? "Symbol(src)_1." + k : "", $ = B.toString,
  2177. q = RegExp("^" + J.call(z).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"),
  2178. H = L ? I.Buffer : void 0, X = I.Symbol, W = I.Uint8Array, Z = B.propertyIsEnumerable, K = j.splice,
  2179. Q = X ? X.toStringTag : void 0, tt = Object.getOwnPropertySymbols, et = H ? H.isBuffer : void 0,
  2180. nt = (D = Object.keys, U = Object, function (t) {
  2181. return D(U(t))
  2182. }), ot = At(I, "DataView"), rt = At(I, "Map"), it = At(I, "Promise"), at = At(I, "Set"),
  2183. st = At(I, "WeakMap"), ut = At(Object, "create"), ct = Rt(ot), lt = Rt(rt), dt = Rt(it), pt = Rt(at),
  2184. ft = Rt(st), ht = X ? X.prototype : void 0, gt = ht ? ht.valueOf : void 0;
  2185.  
  2186. function yt(t) {
  2187. var e = -1, n = null == t ? 0 : t.length;
  2188. for (this.clear(); ++e < n;) {
  2189. var o = t[e];
  2190. this.set(o[0], o[1])
  2191. }
  2192. }
  2193.  
  2194. function vt(t) {
  2195. var e = -1, n = null == t ? 0 : t.length;
  2196. for (this.clear(); ++e < n;) {
  2197. var o = t[e];
  2198. this.set(o[0], o[1])
  2199. }
  2200. }
  2201.  
  2202. function mt(t) {
  2203. var e = -1, n = null == t ? 0 : t.length;
  2204. for (this.clear(); ++e < n;) {
  2205. var o = t[e];
  2206. this.set(o[0], o[1])
  2207. }
  2208. }
  2209.  
  2210. function _t(t) {
  2211. var e = -1, n = null == t ? 0 : t.length;
  2212. for (this.__data__ = new mt; ++e < n;) this.add(t[e])
  2213. }
  2214.  
  2215. function bt(t) {
  2216. var e = this.__data__ = new vt(t);
  2217. this.size = e.size
  2218. }
  2219.  
  2220. function Et(t, e) {
  2221. var n = Ut(t), o = !n && Dt(t), r = !n && !o && jt(t), i = !n && !o && !r && zt(t), a = n || o || r || i,
  2222. s = a ? function (t, e) {
  2223. for (var n = -1, o = Array(t); ++n < t;) o[n] = e(n);
  2224. return o
  2225. }(t.length, String) : [], u = s.length;
  2226. for (var c in t) !e && !z.call(t, c) || a && ("length" == c || r && ("offset" == c || "parent" == c) || i && ("buffer" == c || "byteLength" == c || "byteOffset" == c) || wt(c, u)) || s.push(c);
  2227. return s
  2228. }
  2229.  
  2230. function Tt(t, e) {
  2231. for (var n = t.length; n--;) if (kt(t[n][0], e)) return n;
  2232. return -1
  2233. }
  2234.  
  2235. function Ct(t) {
  2236. return null == t ? void 0 === t ? "[object Undefined]" : "[object Null]" : Q && Q in Object(t) ? function (t) {
  2237. var e = z.call(t, Q), n = t[Q];
  2238. try {
  2239. t[Q] = void 0;
  2240. var o = !0
  2241. } catch (t) {
  2242. }
  2243. var r = $.call(t);
  2244. o && (e ? t[Q] = n : delete t[Q]);
  2245. return r
  2246. }(t) : function (t) {
  2247. return $.call(t)
  2248. }(t)
  2249. }
  2250.  
  2251. function Ot(t) {
  2252. return Jt(t) && Ct(t) == r
  2253. }
  2254.  
  2255. function St(t, e, n, o, c) {
  2256. return t === e || (null == t || null == e || !Jt(t) && !Jt(e) ? t != t && e != e : function (t, e, n, o, c, f) {
  2257. var m = Ut(t), E = Ut(e), T = m ? i : Ft(t), C = E ? i : Ft(e), O = (T = T == r ? p : T) == p,
  2258. S = (C = C == r ? p : C) == p, I = T == C;
  2259. if (I && jt(t)) {
  2260. if (!jt(e)) return !1;
  2261. m = !0, O = !1
  2262. }
  2263. if (I && !O) return f || (f = new bt), m || zt(t) ? Mt(t, e, n, o, c, f) : function (t, e, n, o, r, i, c) {
  2264. switch (n) {
  2265. case b:
  2266. if (t.byteLength != e.byteLength || t.byteOffset != e.byteOffset) return !1;
  2267. t = t.buffer, e = e.buffer;
  2268. case _:
  2269. return !(t.byteLength != e.byteLength || !i(new W(t), new W(e)));
  2270. case a:
  2271. case s:
  2272. case d:
  2273. return kt(+t, +e);
  2274. case u:
  2275. return t.name == e.name && t.message == e.message;
  2276. case h:
  2277. case y:
  2278. return t == e + "";
  2279. case l:
  2280. var p = w;
  2281. case g:
  2282. var f = 1 & o;
  2283. if (p || (p = R), t.size != e.size && !f) return !1;
  2284. var m = c.get(t);
  2285. if (m) return m == e;
  2286. o |= 2, c.set(t, e);
  2287. var E = Mt(p(t), p(e), o, r, i, c);
  2288. return c.delete(t), E;
  2289. case v:
  2290. if (gt) return gt.call(t) == gt.call(e)
  2291. }
  2292. return !1
  2293. }(t, e, T, n, o, c, f);
  2294. if (!(1 & n)) {
  2295. var x = O && z.call(t, "__wrapped__"), M = S && z.call(e, "__wrapped__");
  2296. if (x || M) {
  2297. var L = x ? t.value() : t, N = M ? e.value() : e;
  2298. return f || (f = new bt), c(L, N, n, o, f)
  2299. }
  2300. }
  2301. if (!I) return !1;
  2302. return f || (f = new bt), function (t, e, n, o, r, i) {
  2303. var a = 1 & n, s = Lt(t), u = s.length, c = Lt(e).length;
  2304. if (u != c && !a) return !1;
  2305. var l = u;
  2306. for (; l--;) {
  2307. var d = s[l];
  2308. if (!(a ? d in e : z.call(e, d))) return !1
  2309. }
  2310. var p = i.get(t);
  2311. if (p && i.get(e)) return p == e;
  2312. var f = !0;
  2313. i.set(t, e), i.set(e, t);
  2314. var h = a;
  2315. for (; ++l < u;) {
  2316. var g = t[d = s[l]], y = e[d];
  2317. if (o) var v = a ? o(y, g, d, e, t, i) : o(g, y, d, t, e, i);
  2318. if (!(void 0 === v ? g === y || r(g, y, n, o, i) : v)) {
  2319. f = !1;
  2320. break
  2321. }
  2322. h || (h = "constructor" == d)
  2323. }
  2324. if (f && !h) {
  2325. var m = t.constructor, _ = e.constructor;
  2326. m == _ || !("constructor" in t) || !("constructor" in e) || "function" == typeof m && m instanceof m && "function" == typeof _ && _ instanceof _ || (f = !1)
  2327. }
  2328. return i.delete(t), i.delete(e), f
  2329. }(t, e, n, o, c, f)
  2330. }(t, e, n, o, St, c))
  2331. }
  2332.  
  2333. function It(t) {
  2334. return !(!Gt(t) || function (t) {
  2335. return !!Y && Y in t
  2336. }(t)) && (Vt(t) ? q : E).test(Rt(t))
  2337. }
  2338.  
  2339. function xt(t) {
  2340. if (n = (e = t) && e.constructor, o = "function" == typeof n && n.prototype || B, e !== o) return nt(t);
  2341. var e, n, o, r = [];
  2342. for (var i in Object(t)) z.call(t, i) && "constructor" != i && r.push(i);
  2343. return r
  2344. }
  2345.  
  2346. function Mt(t, e, n, o, r, i) {
  2347. var a = 1 & n, s = t.length, u = e.length;
  2348. if (s != u && !(a && u > s)) return !1;
  2349. var c = i.get(t);
  2350. if (c && i.get(e)) return c == e;
  2351. var l = -1, d = !0, p = 2 & n ? new _t : void 0;
  2352. for (i.set(t, e), i.set(e, t); ++l < s;) {
  2353. var f = t[l], h = e[l];
  2354. if (o) var g = a ? o(h, f, l, e, t, i) : o(f, h, l, t, e, i);
  2355. if (void 0 !== g) {
  2356. if (g) continue;
  2357. d = !1;
  2358. break
  2359. }
  2360. if (p) {
  2361. if (!F(e, (function (t, e) {
  2362. if (a = e, !p.has(a) && (f === t || r(f, t, n, o, i))) return p.push(e);
  2363. var a
  2364. }))) {
  2365. d = !1;
  2366. break
  2367. }
  2368. } else if (f !== h && !r(f, h, n, o, i)) {
  2369. d = !1;
  2370. break
  2371. }
  2372. }
  2373. return i.delete(t), i.delete(e), d
  2374. }
  2375.  
  2376. function Lt(t) {
  2377. return function (t, e, n) {
  2378. var o = e(t);
  2379. return Ut(t) ? o : function (t, e) {
  2380. for (var n = -1, o = e.length, r = t.length; ++n < o;) t[r + n] = e[n];
  2381. return t
  2382. }(o, n(t))
  2383. }(t, Yt, Pt)
  2384. }
  2385.  
  2386. function Nt(t, e) {
  2387. var n, o, r = t.__data__;
  2388. return ("string" == (o = typeof (n = e)) || "number" == o || "symbol" == o || "boolean" == o ? "__proto__" !== n : null === n) ? r["string" == typeof e ? "string" : "hash"] : r.map
  2389. }
  2390.  
  2391. function At(t, e) {
  2392. var n = function (t, e) {
  2393. return null == t ? void 0 : t[e]
  2394. }(t, e);
  2395. return It(n) ? n : void 0
  2396. }
  2397.  
  2398. yt.prototype.clear = function () {
  2399. this.__data__ = ut ? ut(null) : {}, this.size = 0
  2400. }, yt.prototype.delete = function (t) {
  2401. var e = this.has(t) && delete this.__data__[t];
  2402. return this.size -= e ? 1 : 0, e
  2403. }, yt.prototype.get = function (t) {
  2404. var e = this.__data__;
  2405. if (ut) {
  2406. var o = e[t];
  2407. return o === n ? void 0 : o
  2408. }
  2409. return z.call(e, t) ? e[t] : void 0
  2410. }, yt.prototype.has = function (t) {
  2411. var e = this.__data__;
  2412. return ut ? void 0 !== e[t] : z.call(e, t)
  2413. }, yt.prototype.set = function (t, e) {
  2414. var o = this.__data__;
  2415. return this.size += this.has(t) ? 0 : 1, o[t] = ut && void 0 === e ? n : e, this
  2416. }, vt.prototype.clear = function () {
  2417. this.__data__ = [], this.size = 0
  2418. }, vt.prototype.delete = function (t) {
  2419. var e = this.__data__, n = Tt(e, t);
  2420. return !(n < 0) && (n == e.length - 1 ? e.pop() : K.call(e, n, 1), --this.size, !0)
  2421. }, vt.prototype.get = function (t) {
  2422. var e = this.__data__, n = Tt(e, t);
  2423. return n < 0 ? void 0 : e[n][1]
  2424. }, vt.prototype.has = function (t) {
  2425. return Tt(this.__data__, t) > -1
  2426. }, vt.prototype.set = function (t, e) {
  2427. var n = this.__data__, o = Tt(n, t);
  2428. return o < 0 ? (++this.size, n.push([t, e])) : n[o][1] = e, this
  2429. }, mt.prototype.clear = function () {
  2430. this.size = 0, this.__data__ = {hash: new yt, map: new (rt || vt), string: new yt}
  2431. }, mt.prototype.delete = function (t) {
  2432. var e = Nt(this, t).delete(t);
  2433. return this.size -= e ? 1 : 0, e
  2434. }, mt.prototype.get = function (t) {
  2435. return Nt(this, t).get(t)
  2436. }, mt.prototype.has = function (t) {
  2437. return Nt(this, t).has(t)
  2438. }, mt.prototype.set = function (t, e) {
  2439. var n = Nt(this, t), o = n.size;
  2440. return n.set(t, e), this.size += n.size == o ? 0 : 1, this
  2441. }, _t.prototype.add = _t.prototype.push = function (t) {
  2442. return this.__data__.set(t, n), this
  2443. }, _t.prototype.has = function (t) {
  2444. return this.__data__.has(t)
  2445. }, bt.prototype.clear = function () {
  2446. this.__data__ = new vt, this.size = 0
  2447. }, bt.prototype.delete = function (t) {
  2448. var e = this.__data__, n = e.delete(t);
  2449. return this.size = e.size, n
  2450. }, bt.prototype.get = function (t) {
  2451. return this.__data__.get(t)
  2452. }, bt.prototype.has = function (t) {
  2453. return this.__data__.has(t)
  2454. }, bt.prototype.set = function (t, e) {
  2455. var n = this.__data__;
  2456. if (n instanceof vt) {
  2457. var o = n.__data__;
  2458. if (!rt || o.length < 199) return o.push([t, e]), this.size = ++n.size, this;
  2459. n = this.__data__ = new mt(o)
  2460. }
  2461. return n.set(t, e), this.size = n.size, this
  2462. };
  2463. var Pt = tt ? function (t) {
  2464. return null == t ? [] : (t = Object(t), function (t, e) {
  2465. for (var n = -1, o = null == t ? 0 : t.length, r = 0, i = []; ++n < o;) {
  2466. var a = t[n];
  2467. e(a, n, t) && (i[r++] = a)
  2468. }
  2469. return i
  2470. }(tt(t), (function (e) {
  2471. return Z.call(t, e)
  2472. })))
  2473. } : function () {
  2474. return []
  2475. }, Ft = Ct;
  2476.  
  2477. function wt(t, e) {
  2478. return !!(e = null == e ? o : e) && ("number" == typeof t || T.test(t)) && t > -1 && t % 1 == 0 && t < e
  2479. }
  2480.  
  2481. function Rt(t) {
  2482. if (null != t) {
  2483. try {
  2484. return J.call(t)
  2485. } catch (t) {
  2486. }
  2487. try {
  2488. return t + ""
  2489. } catch (t) {
  2490. }
  2491. }
  2492. return ""
  2493. }
  2494.  
  2495. function kt(t, e) {
  2496. return t === e || t != t && e != e
  2497. }
  2498.  
  2499. (ot && Ft(new ot(new ArrayBuffer(1))) != b || rt && Ft(new rt) != l || it && Ft(it.resolve()) != f || at && Ft(new at) != g || st && Ft(new st) != m) && (Ft = function (t) {
  2500. var e = Ct(t), n = e == p ? t.constructor : void 0, o = n ? Rt(n) : "";
  2501. if (o) switch (o) {
  2502. case ct:
  2503. return b;
  2504. case lt:
  2505. return l;
  2506. case dt:
  2507. return f;
  2508. case pt:
  2509. return g;
  2510. case ft:
  2511. return m
  2512. }
  2513. return e
  2514. });
  2515. var Dt = Ot(function () {
  2516. return arguments
  2517. }()) ? Ot : function (t) {
  2518. return Jt(t) && z.call(t, "callee") && !Z.call(t, "callee")
  2519. }, Ut = Array.isArray;
  2520. var jt = et || function () {
  2521. return !1
  2522. };
  2523.  
  2524. function Vt(t) {
  2525. if (!Gt(t)) return !1;
  2526. var e = Ct(t);
  2527. return e == c || "[object GeneratorFunction]" == e || "[object AsyncFunction]" == e || "[object Proxy]" == e
  2528. }
  2529.  
  2530. function Bt(t) {
  2531. return "number" == typeof t && t > -1 && t % 1 == 0 && t <= o
  2532. }
  2533.  
  2534. function Gt(t) {
  2535. var e = typeof t;
  2536. return null != t && ("object" == e || "function" == e)
  2537. }
  2538.  
  2539. function Jt(t) {
  2540. return null != t && "object" == typeof t
  2541. }
  2542.  
  2543. var zt = P ? function (t) {
  2544. return function (e) {
  2545. return t(e)
  2546. }
  2547. }(P) : function (t) {
  2548. return Jt(t) && Bt(t.length) && !!C[Ct(t)]
  2549. };
  2550.  
  2551. function Yt(t) {
  2552. return null != (e = t) && Bt(e.length) && !Vt(e) ? Et(t) : xt(t);
  2553. var e
  2554. }
  2555.  
  2556. t.exports = function (t, e) {
  2557. return St(t, e)
  2558. }
  2559. }({
  2560. get exports() {
  2561. return se
  2562. }, set exports(t) {
  2563. se = t
  2564. }
  2565. }, se);
  2566. var ue = se;
  2567.  
  2568. function ce(t, e) {
  2569. return t.length === e.length && JSON.stringify(t.map((function (t) {
  2570. return t
  2571. })).sort()) === JSON.stringify(e.map((function (t) {
  2572. return t
  2573. })).sort())
  2574. }
  2575.  
  2576. var le = {Polygon: U, LineString: D, Point: k, MultiPolygon: B, MultiLineString: B, MultiPoint: B};
  2577. var de = Object.freeze({
  2578. __proto__: null,
  2579. CommonSelectors: dt,
  2580. constrainFeatureMovement: $t,
  2581. createMidPoint: yt,
  2582. createSupplementaryPoints: vt,
  2583. createVertex: gt,
  2584. doubleClickZoom: mt,
  2585. euclideanDistance: N,
  2586. featuresAt: x,
  2587. getFeatureAtAndSetCursors: L,
  2588. isClick: A,
  2589. isEventAtCoordinates: Qt,
  2590. isTap: P,
  2591. mapEventToBoundingBox: O,
  2592. ModeHandler: t,
  2593. moveFeatures: qt,
  2594. sortFeatures: C,
  2595. stringSetsAreEqual: ce,
  2596. StringSet: S,
  2597. theme: tt,
  2598. toDenseArray: $
  2599. }), pe = function (t, e) {
  2600. var n = {
  2601. options: t = function (t) {
  2602. void 0 === t && (t = {});
  2603. var e = W(t);
  2604. return t.controls || (e.controls = {}), !1 === t.displayControlsDefault ? e.controls = W(ie, t.controls) : e.controls = W(re, t.controls), (e = W(oe, e)).styles = ae(e.styles, "cold").concat(ae(e.styles, "hot")), e
  2605. }(t)
  2606. };
  2607. e = function (t, e) {
  2608. return e.modes = f, e.getFeatureIdsAt = function (e) {
  2609. return x.click({point: e}, null, t).map((function (t) {
  2610. return t.properties.id
  2611. }))
  2612. }, e.getSelectedIds = function () {
  2613. return t.store.getSelectedIds()
  2614. }, e.getSelected = function () {
  2615. return {
  2616. type: p.FEATURE_COLLECTION, features: t.store.getSelectedIds().map((function (e) {
  2617. return t.store.get(e)
  2618. })).map((function (t) {
  2619. return t.toGeoJSON()
  2620. }))
  2621. }
  2622. }, e.getSelectedPoints = function () {
  2623. return {
  2624. type: p.FEATURE_COLLECTION, features: t.store.getSelectedCoordinates().map((function (t) {
  2625. return {type: p.FEATURE, properties: {}, geometry: {type: p.POINT, coordinates: t.coordinates}}
  2626. }))
  2627. }
  2628. }, e.set = function (n) {
  2629. if (void 0 === n.type || n.type !== p.FEATURE_COLLECTION || !Array.isArray(n.features)) throw new Error("Invalid FeatureCollection");
  2630. var o = t.store.createRenderBatch(), r = t.store.getAllIds().slice(), i = e.add(n), a = new S(i);
  2631. return (r = r.filter((function (t) {
  2632. return !a.has(t)
  2633. }))).length && e.delete(r), o(), i
  2634. }, e.add = function (e) {
  2635. var n = JSON.parse(JSON.stringify(Et(e))).features.map((function (e) {
  2636. if (e.id = e.id || F(), null === e.geometry) throw new Error("Invalid geometry: null");
  2637. if (void 0 === t.store.get(e.id) || t.store.get(e.id).type !== e.geometry.type) {
  2638. var n = le[e.geometry.type];
  2639. if (void 0 === n) throw new Error("Invalid geometry type: " + e.geometry.type + ".");
  2640. var o = new n(t, e);
  2641. t.store.add(o)
  2642. } else {
  2643. var r = t.store.get(e.id);
  2644. r.properties = e.properties, ue(r.getCoordinates(), e.geometry.coordinates) || r.incomingCoords(e.geometry.coordinates)
  2645. }
  2646. return e.id
  2647. }));
  2648. return t.store.render(), n
  2649. }, e.get = function (e) {
  2650. var n = t.store.get(e);
  2651. if (n) return n.toGeoJSON()
  2652. }, e.getAll = function () {
  2653. return {
  2654. type: p.FEATURE_COLLECTION, features: t.store.getAll().map((function (t) {
  2655. return t.toGeoJSON()
  2656. }))
  2657. }
  2658. }, e.delete = function (n) {
  2659. return t.store.delete(n, {silent: !0}), e.getMode() !== f.DIRECT_SELECT || t.store.getSelectedIds().length ? t.store.render() : t.events.changeMode(f.SIMPLE_SELECT, void 0, {silent: !0}), e
  2660. }, e.deleteAll = function () {
  2661. return t.store.delete(t.store.getAllIds(), {silent: !0}), e.getMode() === f.DIRECT_SELECT ? t.events.changeMode(f.SIMPLE_SELECT, void 0, {silent: !0}) : t.store.render(), e
  2662. }, e.changeMode = function (n, o) {
  2663. return void 0 === o && (o = {}), n === f.SIMPLE_SELECT && e.getMode() === f.SIMPLE_SELECT ? (ce(o.featureIds || [], t.store.getSelectedIds()) || (t.store.setSelected(o.featureIds, {silent: !0}), t.store.render()), e) : (n === f.DIRECT_SELECT && e.getMode() === f.DIRECT_SELECT && o.featureId === t.store.getSelectedIds()[0] || t.events.changeMode(n, o, {silent: !0}), e)
  2664. }, e.getMode = function () {
  2665. return t.events.getMode()
  2666. }, e.trash = function () {
  2667. return t.events.trash({silent: !0}), e
  2668. }, e.combineFeatures = function () {
  2669. return t.events.combineFeatures({silent: !0}), e
  2670. }, e.uncombineFeatures = function () {
  2671. return t.events.uncombineFeatures({silent: !0}), e
  2672. }, e.setFeatureProperty = function (n, o, r) {
  2673. return t.store.setFeatureProperty(n, o, r), e
  2674. }, e
  2675. }(n, e), n.api = e;
  2676. var o = Q(n);
  2677. return e.onAdd = o.onAdd, e.onRemove = o.onRemove, e.types = d, e.options = t, e
  2678. };
  2679.  
  2680. function fe(t) {
  2681. pe(t, this)
  2682. }
  2683.  
  2684. return fe.modes = ne, fe.constants = b, fe.lib = de, fe
  2685. }));
  2686. //# sourceMappingURL=mapbox-gl-draw.js.map