UNPKG

245 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/l7')) :
3 typeof define === 'function' && define.amd ? define(['exports', '@antv/l7'], factory) :
4 (global = global || self, factory((global.L7 = global.L7 || {}, global.L7.Draw = {}), global.L7));
5}(this, (function (exports, l7) { 'use strict';
6
7 function _classCallCheck(instance, Constructor) {
8 if (!(instance instanceof Constructor)) {
9 throw new TypeError("Cannot call a class as a function");
10 }
11 }
12
13 function _defineProperties(target, props) {
14 for (var i = 0; i < props.length; i++) {
15 var descriptor = props[i];
16 descriptor.enumerable = descriptor.enumerable || false;
17 descriptor.configurable = true;
18 if ("value" in descriptor) descriptor.writable = true;
19 Object.defineProperty(target, descriptor.key, descriptor);
20 }
21 }
22
23 function _createClass(Constructor, protoProps, staticProps) {
24 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25 if (staticProps) _defineProperties(Constructor, staticProps);
26 return Constructor;
27 }
28
29 function _defineProperty(obj, key, value) {
30 if (key in obj) {
31 Object.defineProperty(obj, key, {
32 value: value,
33 enumerable: true,
34 configurable: true,
35 writable: true
36 });
37 } else {
38 obj[key] = value;
39 }
40
41 return obj;
42 }
43
44 function ownKeys(object, enumerableOnly) {
45 var keys = Object.keys(object);
46
47 if (Object.getOwnPropertySymbols) {
48 var symbols = Object.getOwnPropertySymbols(object);
49 if (enumerableOnly) symbols = symbols.filter(function (sym) {
50 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
51 });
52 keys.push.apply(keys, symbols);
53 }
54
55 return keys;
56 }
57
58 function _objectSpread2(target) {
59 for (var i = 1; i < arguments.length; i++) {
60 var source = arguments[i] != null ? arguments[i] : {};
61
62 if (i % 2) {
63 ownKeys(Object(source), true).forEach(function (key) {
64 _defineProperty(target, key, source[key]);
65 });
66 } else if (Object.getOwnPropertyDescriptors) {
67 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
68 } else {
69 ownKeys(Object(source)).forEach(function (key) {
70 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
71 });
72 }
73 }
74
75 return target;
76 }
77
78 function _inherits(subClass, superClass) {
79 if (typeof superClass !== "function" && superClass !== null) {
80 throw new TypeError("Super expression must either be null or a function");
81 }
82
83 subClass.prototype = Object.create(superClass && superClass.prototype, {
84 constructor: {
85 value: subClass,
86 writable: true,
87 configurable: true
88 }
89 });
90 if (superClass) _setPrototypeOf(subClass, superClass);
91 }
92
93 function _getPrototypeOf(o) {
94 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
95 return o.__proto__ || Object.getPrototypeOf(o);
96 };
97 return _getPrototypeOf(o);
98 }
99
100 function _setPrototypeOf(o, p) {
101 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
102 o.__proto__ = p;
103 return o;
104 };
105
106 return _setPrototypeOf(o, p);
107 }
108
109 function _isNativeReflectConstruct() {
110 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
111 if (Reflect.construct.sham) return false;
112 if (typeof Proxy === "function") return true;
113
114 try {
115 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
116 return true;
117 } catch (e) {
118 return false;
119 }
120 }
121
122 function _assertThisInitialized(self) {
123 if (self === void 0) {
124 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
125 }
126
127 return self;
128 }
129
130 function _possibleConstructorReturn(self, call) {
131 if (call && (typeof call === "object" || typeof call === "function")) {
132 return call;
133 }
134
135 return _assertThisInitialized(self);
136 }
137
138 function _createSuper(Derived) {
139 var hasNativeReflectConstruct = _isNativeReflectConstruct();
140
141 return function _createSuperInternal() {
142 var Super = _getPrototypeOf(Derived),
143 result;
144
145 if (hasNativeReflectConstruct) {
146 var NewTarget = _getPrototypeOf(this).constructor;
147
148 result = Reflect.construct(Super, arguments, NewTarget);
149 } else {
150 result = Super.apply(this, arguments);
151 }
152
153 return _possibleConstructorReturn(this, result);
154 };
155 }
156
157 function _superPropBase(object, property) {
158 while (!Object.prototype.hasOwnProperty.call(object, property)) {
159 object = _getPrototypeOf(object);
160 if (object === null) break;
161 }
162
163 return object;
164 }
165
166 function _get(target, property, receiver) {
167 if (typeof Reflect !== "undefined" && Reflect.get) {
168 _get = Reflect.get;
169 } else {
170 _get = function _get(target, property, receiver) {
171 var base = _superPropBase(target, property);
172
173 if (!base) return;
174 var desc = Object.getOwnPropertyDescriptor(base, property);
175
176 if (desc.get) {
177 return desc.get.call(receiver);
178 }
179
180 return desc.value;
181 };
182 }
183
184 return _get(target, property, receiver || target);
185 }
186
187 function _unsupportedIterableToArray(o, minLen) {
188 if (!o) return;
189 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
190 var n = Object.prototype.toString.call(o).slice(8, -1);
191 if (n === "Object" && o.constructor) n = o.constructor.name;
192 if (n === "Map" || n === "Set") return Array.from(o);
193 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
194 }
195
196 function _arrayLikeToArray(arr, len) {
197 if (len == null || len > arr.length) len = arr.length;
198
199 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
200
201 return arr2;
202 }
203
204 function _createForOfIteratorHelper(o, allowArrayLike) {
205 var it;
206
207 if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
208 if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
209 if (it) o = it;
210 var i = 0;
211
212 var F = function () {};
213
214 return {
215 s: F,
216 n: function () {
217 if (i >= o.length) return {
218 done: true
219 };
220 return {
221 done: false,
222 value: o[i++]
223 };
224 },
225 e: function (e) {
226 throw e;
227 },
228 f: F
229 };
230 }
231
232 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
233 }
234
235 var normalCompletion = true,
236 didErr = false,
237 err;
238 return {
239 s: function () {
240 it = o[Symbol.iterator]();
241 },
242 n: function () {
243 var step = it.next();
244 normalCompletion = step.done;
245 return step;
246 },
247 e: function (e) {
248 didErr = true;
249 err = e;
250 },
251 f: function () {
252 try {
253 if (!normalCompletion && it.return != null) it.return();
254 } finally {
255 if (didErr) throw err;
256 }
257 }
258 };
259 }
260
261 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
262
263 function unwrapExports (x) {
264 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
265 }
266
267 function createCommonjsModule(fn, module) {
268 return module = { exports: {} }, fn(module, module.exports), module.exports;
269 }
270
271 var helpers = createCommonjsModule(function (module, exports) {
272 Object.defineProperty(exports, "__esModule", { value: true });
273 /**
274 * @module helpers
275 */
276 /**
277 * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
278 *
279 * @memberof helpers
280 * @type {number}
281 */
282 exports.earthRadius = 6371008.8;
283 /**
284 * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
285 *
286 * @memberof helpers
287 * @type {Object}
288 */
289 exports.factors = {
290 centimeters: exports.earthRadius * 100,
291 centimetres: exports.earthRadius * 100,
292 degrees: exports.earthRadius / 111325,
293 feet: exports.earthRadius * 3.28084,
294 inches: exports.earthRadius * 39.370,
295 kilometers: exports.earthRadius / 1000,
296 kilometres: exports.earthRadius / 1000,
297 meters: exports.earthRadius,
298 metres: exports.earthRadius,
299 miles: exports.earthRadius / 1609.344,
300 millimeters: exports.earthRadius * 1000,
301 millimetres: exports.earthRadius * 1000,
302 nauticalmiles: exports.earthRadius / 1852,
303 radians: 1,
304 yards: exports.earthRadius / 1.0936,
305 };
306 /**
307 * Units of measurement factors based on 1 meter.
308 *
309 * @memberof helpers
310 * @type {Object}
311 */
312 exports.unitsFactors = {
313 centimeters: 100,
314 centimetres: 100,
315 degrees: 1 / 111325,
316 feet: 3.28084,
317 inches: 39.370,
318 kilometers: 1 / 1000,
319 kilometres: 1 / 1000,
320 meters: 1,
321 metres: 1,
322 miles: 1 / 1609.344,
323 millimeters: 1000,
324 millimetres: 1000,
325 nauticalmiles: 1 / 1852,
326 radians: 1 / exports.earthRadius,
327 yards: 1 / 1.0936,
328 };
329 /**
330 * Area of measurement factors based on 1 square meter.
331 *
332 * @memberof helpers
333 * @type {Object}
334 */
335 exports.areaFactors = {
336 acres: 0.000247105,
337 centimeters: 10000,
338 centimetres: 10000,
339 feet: 10.763910417,
340 inches: 1550.003100006,
341 kilometers: 0.000001,
342 kilometres: 0.000001,
343 meters: 1,
344 metres: 1,
345 miles: 3.86e-7,
346 millimeters: 1000000,
347 millimetres: 1000000,
348 yards: 1.195990046,
349 };
350 /**
351 * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
352 *
353 * @name feature
354 * @param {Geometry} geometry input geometry
355 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
356 * @param {Object} [options={}] Optional Parameters
357 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
358 * @param {string|number} [options.id] Identifier associated with the Feature
359 * @returns {Feature} a GeoJSON Feature
360 * @example
361 * var geometry = {
362 * "type": "Point",
363 * "coordinates": [110, 50]
364 * };
365 *
366 * var feature = turf.feature(geometry);
367 *
368 * //=feature
369 */
370 function feature(geom, properties, options) {
371 if (options === void 0) { options = {}; }
372 var feat = { type: "Feature" };
373 if (options.id === 0 || options.id) {
374 feat.id = options.id;
375 }
376 if (options.bbox) {
377 feat.bbox = options.bbox;
378 }
379 feat.properties = properties || {};
380 feat.geometry = geom;
381 return feat;
382 }
383 exports.feature = feature;
384 /**
385 * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
386 * For GeometryCollection type use `helpers.geometryCollection`
387 *
388 * @name geometry
389 * @param {string} type Geometry Type
390 * @param {Array<any>} coordinates Coordinates
391 * @param {Object} [options={}] Optional Parameters
392 * @returns {Geometry} a GeoJSON Geometry
393 * @example
394 * var type = "Point";
395 * var coordinates = [110, 50];
396 * var geometry = turf.geometry(type, coordinates);
397 * // => geometry
398 */
399 function geometry(type, coordinates, options) {
400 switch (type) {
401 case "Point": return point(coordinates).geometry;
402 case "LineString": return lineString(coordinates).geometry;
403 case "Polygon": return polygon(coordinates).geometry;
404 case "MultiPoint": return multiPoint(coordinates).geometry;
405 case "MultiLineString": return multiLineString(coordinates).geometry;
406 case "MultiPolygon": return multiPolygon(coordinates).geometry;
407 default: throw new Error(type + " is invalid");
408 }
409 }
410 exports.geometry = geometry;
411 /**
412 * Creates a {@link Point} {@link Feature} from a Position.
413 *
414 * @name point
415 * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
416 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
417 * @param {Object} [options={}] Optional Parameters
418 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
419 * @param {string|number} [options.id] Identifier associated with the Feature
420 * @returns {Feature<Point>} a Point feature
421 * @example
422 * var point = turf.point([-75.343, 39.984]);
423 *
424 * //=point
425 */
426 function point(coordinates, properties, options) {
427 if (options === void 0) { options = {}; }
428 var geom = {
429 type: "Point",
430 coordinates: coordinates,
431 };
432 return feature(geom, properties, options);
433 }
434 exports.point = point;
435 /**
436 * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
437 *
438 * @name points
439 * @param {Array<Array<number>>} coordinates an array of Points
440 * @param {Object} [properties={}] Translate these properties to each Feature
441 * @param {Object} [options={}] Optional Parameters
442 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
443 * associated with the FeatureCollection
444 * @param {string|number} [options.id] Identifier associated with the FeatureCollection
445 * @returns {FeatureCollection<Point>} Point Feature
446 * @example
447 * var points = turf.points([
448 * [-75, 39],
449 * [-80, 45],
450 * [-78, 50]
451 * ]);
452 *
453 * //=points
454 */
455 function points(coordinates, properties, options) {
456 if (options === void 0) { options = {}; }
457 return featureCollection(coordinates.map(function (coords) {
458 return point(coords, properties);
459 }), options);
460 }
461 exports.points = points;
462 /**
463 * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
464 *
465 * @name polygon
466 * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
467 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
468 * @param {Object} [options={}] Optional Parameters
469 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
470 * @param {string|number} [options.id] Identifier associated with the Feature
471 * @returns {Feature<Polygon>} Polygon Feature
472 * @example
473 * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
474 *
475 * //=polygon
476 */
477 function polygon(coordinates, properties, options) {
478 if (options === void 0) { options = {}; }
479 for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
480 var ring = coordinates_1[_i];
481 if (ring.length < 4) {
482 throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
483 }
484 for (var j = 0; j < ring[ring.length - 1].length; j++) {
485 // Check if first point of Polygon contains two numbers
486 if (ring[ring.length - 1][j] !== ring[0][j]) {
487 throw new Error("First and last Position are not equivalent.");
488 }
489 }
490 }
491 var geom = {
492 type: "Polygon",
493 coordinates: coordinates,
494 };
495 return feature(geom, properties, options);
496 }
497 exports.polygon = polygon;
498 /**
499 * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
500 *
501 * @name polygons
502 * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates
503 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
504 * @param {Object} [options={}] Optional Parameters
505 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
506 * @param {string|number} [options.id] Identifier associated with the FeatureCollection
507 * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
508 * @example
509 * var polygons = turf.polygons([
510 * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
511 * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
512 * ]);
513 *
514 * //=polygons
515 */
516 function polygons(coordinates, properties, options) {
517 if (options === void 0) { options = {}; }
518 return featureCollection(coordinates.map(function (coords) {
519 return polygon(coords, properties);
520 }), options);
521 }
522 exports.polygons = polygons;
523 /**
524 * Creates a {@link LineString} {@link Feature} from an Array of Positions.
525 *
526 * @name lineString
527 * @param {Array<Array<number>>} coordinates an array of Positions
528 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
529 * @param {Object} [options={}] Optional Parameters
530 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
531 * @param {string|number} [options.id] Identifier associated with the Feature
532 * @returns {Feature<LineString>} LineString Feature
533 * @example
534 * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
535 * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
536 *
537 * //=linestring1
538 * //=linestring2
539 */
540 function lineString(coordinates, properties, options) {
541 if (options === void 0) { options = {}; }
542 if (coordinates.length < 2) {
543 throw new Error("coordinates must be an array of two or more positions");
544 }
545 var geom = {
546 type: "LineString",
547 coordinates: coordinates,
548 };
549 return feature(geom, properties, options);
550 }
551 exports.lineString = lineString;
552 /**
553 * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
554 *
555 * @name lineStrings
556 * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
557 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
558 * @param {Object} [options={}] Optional Parameters
559 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
560 * associated with the FeatureCollection
561 * @param {string|number} [options.id] Identifier associated with the FeatureCollection
562 * @returns {FeatureCollection<LineString>} LineString FeatureCollection
563 * @example
564 * var linestrings = turf.lineStrings([
565 * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
566 * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
567 * ]);
568 *
569 * //=linestrings
570 */
571 function lineStrings(coordinates, properties, options) {
572 if (options === void 0) { options = {}; }
573 return featureCollection(coordinates.map(function (coords) {
574 return lineString(coords, properties);
575 }), options);
576 }
577 exports.lineStrings = lineStrings;
578 /**
579 * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
580 *
581 * @name featureCollection
582 * @param {Feature[]} features input features
583 * @param {Object} [options={}] Optional Parameters
584 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
585 * @param {string|number} [options.id] Identifier associated with the Feature
586 * @returns {FeatureCollection} FeatureCollection of Features
587 * @example
588 * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
589 * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
590 * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
591 *
592 * var collection = turf.featureCollection([
593 * locationA,
594 * locationB,
595 * locationC
596 * ]);
597 *
598 * //=collection
599 */
600 function featureCollection(features, options) {
601 if (options === void 0) { options = {}; }
602 var fc = { type: "FeatureCollection" };
603 if (options.id) {
604 fc.id = options.id;
605 }
606 if (options.bbox) {
607 fc.bbox = options.bbox;
608 }
609 fc.features = features;
610 return fc;
611 }
612 exports.featureCollection = featureCollection;
613 /**
614 * Creates a {@link Feature<MultiLineString>} based on a
615 * coordinate array. Properties can be added optionally.
616 *
617 * @name multiLineString
618 * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings
619 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
620 * @param {Object} [options={}] Optional Parameters
621 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
622 * @param {string|number} [options.id] Identifier associated with the Feature
623 * @returns {Feature<MultiLineString>} a MultiLineString feature
624 * @throws {Error} if no coordinates are passed
625 * @example
626 * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
627 *
628 * //=multiLine
629 */
630 function multiLineString(coordinates, properties, options) {
631 if (options === void 0) { options = {}; }
632 var geom = {
633 type: "MultiLineString",
634 coordinates: coordinates,
635 };
636 return feature(geom, properties, options);
637 }
638 exports.multiLineString = multiLineString;
639 /**
640 * Creates a {@link Feature<MultiPoint>} based on a
641 * coordinate array. Properties can be added optionally.
642 *
643 * @name multiPoint
644 * @param {Array<Array<number>>} coordinates an array of Positions
645 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
646 * @param {Object} [options={}] Optional Parameters
647 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
648 * @param {string|number} [options.id] Identifier associated with the Feature
649 * @returns {Feature<MultiPoint>} a MultiPoint feature
650 * @throws {Error} if no coordinates are passed
651 * @example
652 * var multiPt = turf.multiPoint([[0,0],[10,10]]);
653 *
654 * //=multiPt
655 */
656 function multiPoint(coordinates, properties, options) {
657 if (options === void 0) { options = {}; }
658 var geom = {
659 type: "MultiPoint",
660 coordinates: coordinates,
661 };
662 return feature(geom, properties, options);
663 }
664 exports.multiPoint = multiPoint;
665 /**
666 * Creates a {@link Feature<MultiPolygon>} based on a
667 * coordinate array. Properties can be added optionally.
668 *
669 * @name multiPolygon
670 * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons
671 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
672 * @param {Object} [options={}] Optional Parameters
673 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
674 * @param {string|number} [options.id] Identifier associated with the Feature
675 * @returns {Feature<MultiPolygon>} a multipolygon feature
676 * @throws {Error} if no coordinates are passed
677 * @example
678 * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
679 *
680 * //=multiPoly
681 *
682 */
683 function multiPolygon(coordinates, properties, options) {
684 if (options === void 0) { options = {}; }
685 var geom = {
686 type: "MultiPolygon",
687 coordinates: coordinates,
688 };
689 return feature(geom, properties, options);
690 }
691 exports.multiPolygon = multiPolygon;
692 /**
693 * Creates a {@link Feature<GeometryCollection>} based on a
694 * coordinate array. Properties can be added optionally.
695 *
696 * @name geometryCollection
697 * @param {Array<Geometry>} geometries an array of GeoJSON Geometries
698 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
699 * @param {Object} [options={}] Optional Parameters
700 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
701 * @param {string|number} [options.id] Identifier associated with the Feature
702 * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
703 * @example
704 * var pt = turf.geometry("Point", [100, 0]);
705 * var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
706 * var collection = turf.geometryCollection([pt, line]);
707 *
708 * // => collection
709 */
710 function geometryCollection(geometries, properties, options) {
711 if (options === void 0) { options = {}; }
712 var geom = {
713 type: "GeometryCollection",
714 geometries: geometries,
715 };
716 return feature(geom, properties, options);
717 }
718 exports.geometryCollection = geometryCollection;
719 /**
720 * Round number to precision
721 *
722 * @param {number} num Number
723 * @param {number} [precision=0] Precision
724 * @returns {number} rounded number
725 * @example
726 * turf.round(120.4321)
727 * //=120
728 *
729 * turf.round(120.4321, 2)
730 * //=120.43
731 */
732 function round(num, precision) {
733 if (precision === void 0) { precision = 0; }
734 if (precision && !(precision >= 0)) {
735 throw new Error("precision must be a positive number");
736 }
737 var multiplier = Math.pow(10, precision || 0);
738 return Math.round(num * multiplier) / multiplier;
739 }
740 exports.round = round;
741 /**
742 * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
743 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
744 *
745 * @name radiansToLength
746 * @param {number} radians in radians across the sphere
747 * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
748 * meters, kilometres, kilometers.
749 * @returns {number} distance
750 */
751 function radiansToLength(radians, units) {
752 if (units === void 0) { units = "kilometers"; }
753 var factor = exports.factors[units];
754 if (!factor) {
755 throw new Error(units + " units is invalid");
756 }
757 return radians * factor;
758 }
759 exports.radiansToLength = radiansToLength;
760 /**
761 * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
762 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
763 *
764 * @name lengthToRadians
765 * @param {number} distance in real units
766 * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
767 * meters, kilometres, kilometers.
768 * @returns {number} radians
769 */
770 function lengthToRadians(distance, units) {
771 if (units === void 0) { units = "kilometers"; }
772 var factor = exports.factors[units];
773 if (!factor) {
774 throw new Error(units + " units is invalid");
775 }
776 return distance / factor;
777 }
778 exports.lengthToRadians = lengthToRadians;
779 /**
780 * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
781 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
782 *
783 * @name lengthToDegrees
784 * @param {number} distance in real units
785 * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
786 * meters, kilometres, kilometers.
787 * @returns {number} degrees
788 */
789 function lengthToDegrees(distance, units) {
790 return radiansToDegrees(lengthToRadians(distance, units));
791 }
792 exports.lengthToDegrees = lengthToDegrees;
793 /**
794 * Converts any bearing angle from the north line direction (positive clockwise)
795 * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
796 *
797 * @name bearingToAzimuth
798 * @param {number} bearing angle, between -180 and +180 degrees
799 * @returns {number} angle between 0 and 360 degrees
800 */
801 function bearingToAzimuth(bearing) {
802 var angle = bearing % 360;
803 if (angle < 0) {
804 angle += 360;
805 }
806 return angle;
807 }
808 exports.bearingToAzimuth = bearingToAzimuth;
809 /**
810 * Converts an angle in radians to degrees
811 *
812 * @name radiansToDegrees
813 * @param {number} radians angle in radians
814 * @returns {number} degrees between 0 and 360 degrees
815 */
816 function radiansToDegrees(radians) {
817 var degrees = radians % (2 * Math.PI);
818 return degrees * 180 / Math.PI;
819 }
820 exports.radiansToDegrees = radiansToDegrees;
821 /**
822 * Converts an angle in degrees to radians
823 *
824 * @name degreesToRadians
825 * @param {number} degrees angle between 0 and 360 degrees
826 * @returns {number} angle in radians
827 */
828 function degreesToRadians(degrees) {
829 var radians = degrees % 360;
830 return radians * Math.PI / 180;
831 }
832 exports.degreesToRadians = degreesToRadians;
833 /**
834 * Converts a length to the requested unit.
835 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
836 *
837 * @param {number} length to be converted
838 * @param {Units} [originalUnit="kilometers"] of the length
839 * @param {Units} [finalUnit="kilometers"] returned unit
840 * @returns {number} the converted length
841 */
842 function convertLength(length, originalUnit, finalUnit) {
843 if (originalUnit === void 0) { originalUnit = "kilometers"; }
844 if (finalUnit === void 0) { finalUnit = "kilometers"; }
845 if (!(length >= 0)) {
846 throw new Error("length must be a positive number");
847 }
848 return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
849 }
850 exports.convertLength = convertLength;
851 /**
852 * Converts a area to the requested unit.
853 * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
854 * @param {number} area to be converted
855 * @param {Units} [originalUnit="meters"] of the distance
856 * @param {Units} [finalUnit="kilometers"] returned unit
857 * @returns {number} the converted distance
858 */
859 function convertArea(area, originalUnit, finalUnit) {
860 if (originalUnit === void 0) { originalUnit = "meters"; }
861 if (finalUnit === void 0) { finalUnit = "kilometers"; }
862 if (!(area >= 0)) {
863 throw new Error("area must be a positive number");
864 }
865 var startFactor = exports.areaFactors[originalUnit];
866 if (!startFactor) {
867 throw new Error("invalid original units");
868 }
869 var finalFactor = exports.areaFactors[finalUnit];
870 if (!finalFactor) {
871 throw new Error("invalid final units");
872 }
873 return (area / startFactor) * finalFactor;
874 }
875 exports.convertArea = convertArea;
876 /**
877 * isNumber
878 *
879 * @param {*} num Number to validate
880 * @returns {boolean} true/false
881 * @example
882 * turf.isNumber(123)
883 * //=true
884 * turf.isNumber('foo')
885 * //=false
886 */
887 function isNumber(num) {
888 return !isNaN(num) && num !== null && !Array.isArray(num) && !/^\s*$/.test(num);
889 }
890 exports.isNumber = isNumber;
891 /**
892 * isObject
893 *
894 * @param {*} input variable to validate
895 * @returns {boolean} true/false
896 * @example
897 * turf.isObject({elevation: 10})
898 * //=true
899 * turf.isObject('foo')
900 * //=false
901 */
902 function isObject(input) {
903 return (!!input) && (input.constructor === Object);
904 }
905 exports.isObject = isObject;
906 /**
907 * Validate BBox
908 *
909 * @private
910 * @param {Array<number>} bbox BBox to validate
911 * @returns {void}
912 * @throws Error if BBox is not valid
913 * @example
914 * validateBBox([-180, -40, 110, 50])
915 * //=OK
916 * validateBBox([-180, -40])
917 * //=Error
918 * validateBBox('Foo')
919 * //=Error
920 * validateBBox(5)
921 * //=Error
922 * validateBBox(null)
923 * //=Error
924 * validateBBox(undefined)
925 * //=Error
926 */
927 function validateBBox(bbox) {
928 if (!bbox) {
929 throw new Error("bbox is required");
930 }
931 if (!Array.isArray(bbox)) {
932 throw new Error("bbox must be an Array");
933 }
934 if (bbox.length !== 4 && bbox.length !== 6) {
935 throw new Error("bbox must be an Array of 4 or 6 numbers");
936 }
937 bbox.forEach(function (num) {
938 if (!isNumber(num)) {
939 throw new Error("bbox must only contain numbers");
940 }
941 });
942 }
943 exports.validateBBox = validateBBox;
944 /**
945 * Validate Id
946 *
947 * @private
948 * @param {string|number} id Id to validate
949 * @returns {void}
950 * @throws Error if Id is not valid
951 * @example
952 * validateId([-180, -40, 110, 50])
953 * //=Error
954 * validateId([-180, -40])
955 * //=Error
956 * validateId('Foo')
957 * //=OK
958 * validateId(5)
959 * //=OK
960 * validateId(null)
961 * //=Error
962 * validateId(undefined)
963 * //=Error
964 */
965 function validateId(id) {
966 if (!id) {
967 throw new Error("id is required");
968 }
969 if (["string", "number"].indexOf(typeof id) === -1) {
970 throw new Error("id must be a number or a string");
971 }
972 }
973 exports.validateId = validateId;
974 // Deprecated methods
975 function radians2degrees() {
976 throw new Error("method has been renamed to `radiansToDegrees`");
977 }
978 exports.radians2degrees = radians2degrees;
979 function degrees2radians() {
980 throw new Error("method has been renamed to `degreesToRadians`");
981 }
982 exports.degrees2radians = degrees2radians;
983 function distanceToDegrees() {
984 throw new Error("method has been renamed to `lengthToDegrees`");
985 }
986 exports.distanceToDegrees = distanceToDegrees;
987 function distanceToRadians() {
988 throw new Error("method has been renamed to `lengthToRadians`");
989 }
990 exports.distanceToRadians = distanceToRadians;
991 function radiansToDistance() {
992 throw new Error("method has been renamed to `radiansToLength`");
993 }
994 exports.radiansToDistance = radiansToDistance;
995 function bearingToAngle() {
996 throw new Error("method has been renamed to `bearingToAzimuth`");
997 }
998 exports.bearingToAngle = bearingToAngle;
999 function convertDistance() {
1000 throw new Error("method has been renamed to `convertLength`");
1001 }
1002 exports.convertDistance = convertDistance;
1003 });
1004
1005 unwrapExports(helpers);
1006 var helpers_1 = helpers.earthRadius;
1007 var helpers_2 = helpers.factors;
1008 var helpers_3 = helpers.unitsFactors;
1009 var helpers_4 = helpers.areaFactors;
1010 var helpers_5 = helpers.feature;
1011 var helpers_6 = helpers.geometry;
1012 var helpers_7 = helpers.point;
1013 var helpers_8 = helpers.points;
1014 var helpers_9 = helpers.polygon;
1015 var helpers_10 = helpers.polygons;
1016 var helpers_11 = helpers.lineString;
1017 var helpers_12 = helpers.lineStrings;
1018 var helpers_13 = helpers.featureCollection;
1019 var helpers_14 = helpers.multiLineString;
1020 var helpers_15 = helpers.multiPoint;
1021 var helpers_16 = helpers.multiPolygon;
1022 var helpers_17 = helpers.geometryCollection;
1023 var helpers_18 = helpers.round;
1024 var helpers_19 = helpers.radiansToLength;
1025 var helpers_20 = helpers.lengthToRadians;
1026 var helpers_21 = helpers.lengthToDegrees;
1027 var helpers_22 = helpers.bearingToAzimuth;
1028 var helpers_23 = helpers.radiansToDegrees;
1029 var helpers_24 = helpers.degreesToRadians;
1030 var helpers_25 = helpers.convertLength;
1031 var helpers_26 = helpers.convertArea;
1032 var helpers_27 = helpers.isNumber;
1033 var helpers_28 = helpers.isObject;
1034 var helpers_29 = helpers.validateBBox;
1035 var helpers_30 = helpers.validateId;
1036 var helpers_31 = helpers.radians2degrees;
1037 var helpers_32 = helpers.degrees2radians;
1038 var helpers_33 = helpers.distanceToDegrees;
1039 var helpers_34 = helpers.distanceToRadians;
1040 var helpers_35 = helpers.radiansToDistance;
1041 var helpers_36 = helpers.bearingToAngle;
1042 var helpers_37 = helpers.convertDistance;
1043
1044 var DrawEvent;
1045
1046 (function (DrawEvent) {
1047 DrawEvent["CREATE"] = "draw.create";
1048 DrawEvent["DELETE"] = "draw.delete";
1049 DrawEvent["Move"] = "draw.move";
1050 DrawEvent["Edit"] = "draw.edit";
1051 DrawEvent["UPDATE"] = "draw.update";
1052 DrawEvent["CHANGE"] = "draw.change";
1053 DrawEvent["SELECTION_CHANGE"] = "draw.selectionchange";
1054 DrawEvent["MODE_CHANGE"] = "draw.modechange";
1055 DrawEvent["ACTIONABLE"] = "draw.actionable";
1056 DrawEvent["RENDER"] = "draw.render";
1057 DrawEvent["COMBINE_FEATURES"] = "draw.combine";
1058 DrawEvent["UNCOMBINE_FEATURES"] = "draw.uncombine";
1059 })(DrawEvent || (DrawEvent = {}));
1060
1061 var DrawModes;
1062
1063 (function (DrawModes) {
1064 DrawModes["DRAW_Circle"] = "draw_circle";
1065 DrawModes["DRAW_Rect"] = "draw_react";
1066 DrawModes["DRAW_LINE_STRING"] = "draw_line_string";
1067 DrawModes["DRAW_POLYGON"] = "draw_polygon";
1068 DrawModes["DRAW_POINT"] = "draw_point";
1069 DrawModes["SIMPLE_SELECT"] = "simple_select";
1070 DrawModes["DIRECT_SELECT"] = "direct_select";
1071 DrawModes["STATIC"] = "static";
1072 })(DrawModes || (DrawModes = {}));
1073
1074 var FeatureType;
1075
1076 (function (FeatureType) {
1077 FeatureType["FEATURE"] = "Feature";
1078 FeatureType["POLYGON"] = "Polygon";
1079 FeatureType["LINE_STRING"] = "LineString";
1080 FeatureType["POINT"] = "Point";
1081 FeatureType["FEATURE_COLLECTION"] = "FeatureCollection";
1082 FeatureType["MULTI_PREFIX"] = "Multi";
1083 FeatureType["MULTI_POINT"] = "MultiPoint";
1084 FeatureType["MULTI_LINE_STRING"] = "MultiLineString";
1085 FeatureType["MULTI_POLYGON"] = "MultiPolygon";
1086 })(FeatureType || (FeatureType = {}));
1087
1088 var invariant = createCommonjsModule(function (module, exports) {
1089 Object.defineProperty(exports, "__esModule", { value: true });
1090
1091 /**
1092 * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
1093 *
1094 * @name getCoord
1095 * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
1096 * @returns {Array<number>} coordinates
1097 * @example
1098 * var pt = turf.point([10, 10]);
1099 *
1100 * var coord = turf.getCoord(pt);
1101 * //= [10, 10]
1102 */
1103 function getCoord(coord) {
1104 if (!coord) {
1105 throw new Error("coord is required");
1106 }
1107 if (!Array.isArray(coord)) {
1108 if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
1109 return coord.geometry.coordinates;
1110 }
1111 if (coord.type === "Point") {
1112 return coord.coordinates;
1113 }
1114 }
1115 if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
1116 return coord;
1117 }
1118 throw new Error("coord must be GeoJSON Point or an Array of numbers");
1119 }
1120 exports.getCoord = getCoord;
1121 /**
1122 * Unwrap coordinates from a Feature, Geometry Object or an Array
1123 *
1124 * @name getCoords
1125 * @param {Array<any>|Geometry|Feature} coords Feature, Geometry Object or an Array
1126 * @returns {Array<any>} coordinates
1127 * @example
1128 * var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);
1129 *
1130 * var coords = turf.getCoords(poly);
1131 * //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
1132 */
1133 function getCoords(coords) {
1134 if (Array.isArray(coords)) {
1135 return coords;
1136 }
1137 // Feature
1138 if (coords.type === "Feature") {
1139 if (coords.geometry !== null) {
1140 return coords.geometry.coordinates;
1141 }
1142 }
1143 else {
1144 // Geometry
1145 if (coords.coordinates) {
1146 return coords.coordinates;
1147 }
1148 }
1149 throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
1150 }
1151 exports.getCoords = getCoords;
1152 /**
1153 * Checks if coordinates contains a number
1154 *
1155 * @name containsNumber
1156 * @param {Array<any>} coordinates GeoJSON Coordinates
1157 * @returns {boolean} true if Array contains a number
1158 */
1159 function containsNumber(coordinates) {
1160 if (coordinates.length > 1 && helpers.isNumber(coordinates[0]) && helpers.isNumber(coordinates[1])) {
1161 return true;
1162 }
1163 if (Array.isArray(coordinates[0]) && coordinates[0].length) {
1164 return containsNumber(coordinates[0]);
1165 }
1166 throw new Error("coordinates must only contain numbers");
1167 }
1168 exports.containsNumber = containsNumber;
1169 /**
1170 * Enforce expectations about types of GeoJSON objects for Turf.
1171 *
1172 * @name geojsonType
1173 * @param {GeoJSON} value any GeoJSON object
1174 * @param {string} type expected GeoJSON type
1175 * @param {string} name name of calling function
1176 * @throws {Error} if value is not the expected type.
1177 */
1178 function geojsonType(value, type, name) {
1179 if (!type || !name) {
1180 throw new Error("type and name required");
1181 }
1182 if (!value || value.type !== type) {
1183 throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + value.type);
1184 }
1185 }
1186 exports.geojsonType = geojsonType;
1187 /**
1188 * Enforce expectations about types of {@link Feature} inputs for Turf.
1189 * Internally this uses {@link geojsonType} to judge geometry types.
1190 *
1191 * @name featureOf
1192 * @param {Feature} feature a feature with an expected geometry type
1193 * @param {string} type expected GeoJSON type
1194 * @param {string} name name of calling function
1195 * @throws {Error} error if value is not the expected type.
1196 */
1197 function featureOf(feature, type, name) {
1198 if (!feature) {
1199 throw new Error("No feature passed");
1200 }
1201 if (!name) {
1202 throw new Error(".featureOf() requires a name");
1203 }
1204 if (!feature || feature.type !== "Feature" || !feature.geometry) {
1205 throw new Error("Invalid input to " + name + ", Feature with geometry required");
1206 }
1207 if (!feature.geometry || feature.geometry.type !== type) {
1208 throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type);
1209 }
1210 }
1211 exports.featureOf = featureOf;
1212 /**
1213 * Enforce expectations about types of {@link FeatureCollection} inputs for Turf.
1214 * Internally this uses {@link geojsonType} to judge geometry types.
1215 *
1216 * @name collectionOf
1217 * @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged
1218 * @param {string} type expected GeoJSON type
1219 * @param {string} name name of calling function
1220 * @throws {Error} if value is not the expected type.
1221 */
1222 function collectionOf(featureCollection, type, name) {
1223 if (!featureCollection) {
1224 throw new Error("No featureCollection passed");
1225 }
1226 if (!name) {
1227 throw new Error(".collectionOf() requires a name");
1228 }
1229 if (!featureCollection || featureCollection.type !== "FeatureCollection") {
1230 throw new Error("Invalid input to " + name + ", FeatureCollection required");
1231 }
1232 for (var _i = 0, _a = featureCollection.features; _i < _a.length; _i++) {
1233 var feature = _a[_i];
1234 if (!feature || feature.type !== "Feature" || !feature.geometry) {
1235 throw new Error("Invalid input to " + name + ", Feature with geometry required");
1236 }
1237 if (!feature.geometry || feature.geometry.type !== type) {
1238 throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type);
1239 }
1240 }
1241 }
1242 exports.collectionOf = collectionOf;
1243 /**
1244 * Get Geometry from Feature or Geometry Object
1245 *
1246 * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
1247 * @returns {Geometry|null} GeoJSON Geometry Object
1248 * @throws {Error} if geojson is not a Feature or Geometry Object
1249 * @example
1250 * var point = {
1251 * "type": "Feature",
1252 * "properties": {},
1253 * "geometry": {
1254 * "type": "Point",
1255 * "coordinates": [110, 40]
1256 * }
1257 * }
1258 * var geom = turf.getGeom(point)
1259 * //={"type": "Point", "coordinates": [110, 40]}
1260 */
1261 function getGeom(geojson) {
1262 if (geojson.type === "Feature") {
1263 return geojson.geometry;
1264 }
1265 return geojson;
1266 }
1267 exports.getGeom = getGeom;
1268 /**
1269 * Get GeoJSON object's type, Geometry type is prioritize.
1270 *
1271 * @param {GeoJSON} geojson GeoJSON object
1272 * @param {string} [name="geojson"] name of the variable to display in error message
1273 * @returns {string} GeoJSON type
1274 * @example
1275 * var point = {
1276 * "type": "Feature",
1277 * "properties": {},
1278 * "geometry": {
1279 * "type": "Point",
1280 * "coordinates": [110, 40]
1281 * }
1282 * }
1283 * var geom = turf.getType(point)
1284 * //="Point"
1285 */
1286 function getType(geojson, name) {
1287 if (geojson.type === "FeatureCollection") {
1288 return "FeatureCollection";
1289 }
1290 if (geojson.type === "GeometryCollection") {
1291 return "GeometryCollection";
1292 }
1293 if (geojson.type === "Feature" && geojson.geometry !== null) {
1294 return geojson.geometry.type;
1295 }
1296 return geojson.type;
1297 }
1298 exports.getType = getType;
1299 });
1300
1301 unwrapExports(invariant);
1302 var invariant_1 = invariant.getCoord;
1303 var invariant_2 = invariant.getCoords;
1304 var invariant_3 = invariant.containsNumber;
1305 var invariant_4 = invariant.geojsonType;
1306 var invariant_5 = invariant.featureOf;
1307 var invariant_6 = invariant.collectionOf;
1308 var invariant_7 = invariant.getGeom;
1309 var invariant_8 = invariant.getType;
1310
1311 var destination_1 = createCommonjsModule(function (module, exports) {
1312 Object.defineProperty(exports, "__esModule", { value: true });
1313 // http://en.wikipedia.org/wiki/Haversine_formula
1314 // http://www.movable-type.co.uk/scripts/latlong.html
1315
1316
1317 /**
1318 * Takes a {@link Point} and calculates the location of a destination point given a distance in
1319 * degrees, radians, miles, or kilometers; and bearing in degrees.
1320 * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
1321 *
1322 * @name destination
1323 * @param {Coord} origin starting point
1324 * @param {number} distance distance from the origin point
1325 * @param {number} bearing ranging from -180 to 180
1326 * @param {Object} [options={}] Optional parameters
1327 * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
1328 * @param {Object} [options.properties={}] Translate properties to Point
1329 * @returns {Feature<Point>} destination point
1330 * @example
1331 * var point = turf.point([-75.343, 39.984]);
1332 * var distance = 50;
1333 * var bearing = 90;
1334 * var options = {units: 'miles'};
1335 *
1336 * var destination = turf.destination(point, distance, bearing, options);
1337 *
1338 * //addToMap
1339 * var addToMap = [point, destination]
1340 * destination.properties['marker-color'] = '#f00';
1341 * point.properties['marker-color'] = '#0f0';
1342 */
1343 function destination(origin, distance, bearing, options) {
1344 if (options === void 0) { options = {}; }
1345 // Handle input
1346 var coordinates1 = invariant.getCoord(origin);
1347 var longitude1 = helpers.degreesToRadians(coordinates1[0]);
1348 var latitude1 = helpers.degreesToRadians(coordinates1[1]);
1349 var bearingRad = helpers.degreesToRadians(bearing);
1350 var radians = helpers.lengthToRadians(distance, options.units);
1351 // Main
1352 var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
1353 Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad));
1354 var longitude2 = longitude1 + Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
1355 var lng = helpers.radiansToDegrees(longitude2);
1356 var lat = helpers.radiansToDegrees(latitude2);
1357 return helpers.point([lng, lat], options.properties);
1358 }
1359 exports.default = destination;
1360 });
1361
1362 unwrapExports(destination_1);
1363
1364 var circle_1 = createCommonjsModule(function (module, exports) {
1365 Object.defineProperty(exports, "__esModule", { value: true });
1366
1367
1368 /**
1369 * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
1370 *
1371 * @name circle
1372 * @param {Feature<Point>|number[]} center center point
1373 * @param {number} radius radius of the circle
1374 * @param {Object} [options={}] Optional parameters
1375 * @param {number} [options.steps=64] number of steps
1376 * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
1377 * @param {Object} [options.properties={}] properties
1378 * @returns {Feature<Polygon>} circle polygon
1379 * @example
1380 * var center = [-75.343, 39.984];
1381 * var radius = 5;
1382 * var options = {steps: 10, units: 'kilometers', properties: {foo: 'bar'}};
1383 * var circle = turf.circle(center, radius, options);
1384 *
1385 * //addToMap
1386 * var addToMap = [turf.point(center), circle]
1387 */
1388 function circle(center, radius, options) {
1389 if (options === void 0) { options = {}; }
1390 // default params
1391 var steps = options.steps || 64;
1392 var properties = options.properties ? options.properties : (!Array.isArray(center) && center.type === 'Feature' && center.properties) ? center.properties : {};
1393 // main
1394 var coordinates = [];
1395 for (var i = 0; i < steps; i++) {
1396 coordinates.push(destination_1.default(center, radius, i * -360 / steps, options).geometry.coordinates);
1397 }
1398 coordinates.push(coordinates[0]);
1399 return helpers.polygon([coordinates], properties);
1400 }
1401 exports.default = circle;
1402 });
1403
1404 var turfCircle = unwrapExports(circle_1);
1405
1406 var distance_1 = createCommonjsModule(function (module, exports) {
1407 Object.defineProperty(exports, "__esModule", { value: true });
1408
1409
1410 //http://en.wikipedia.org/wiki/Haversine_formula
1411 //http://www.movable-type.co.uk/scripts/latlong.html
1412 /**
1413 * Calculates the distance between two {@link Point|points} in degrees, radians, miles, or kilometers.
1414 * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
1415 *
1416 * @name distance
1417 * @param {Coord} from origin point
1418 * @param {Coord} to destination point
1419 * @param {Object} [options={}] Optional parameters
1420 * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
1421 * @returns {number} distance between the two points
1422 * @example
1423 * var from = turf.point([-75.343, 39.984]);
1424 * var to = turf.point([-75.534, 39.123]);
1425 * var options = {units: 'miles'};
1426 *
1427 * var distance = turf.distance(from, to, options);
1428 *
1429 * //addToMap
1430 * var addToMap = [from, to];
1431 * from.properties.distance = distance;
1432 * to.properties.distance = distance;
1433 */
1434 function distance(from, to, options) {
1435 if (options === void 0) { options = {}; }
1436 var coordinates1 = invariant.getCoord(from);
1437 var coordinates2 = invariant.getCoord(to);
1438 var dLat = helpers.degreesToRadians((coordinates2[1] - coordinates1[1]));
1439 var dLon = helpers.degreesToRadians((coordinates2[0] - coordinates1[0]));
1440 var lat1 = helpers.degreesToRadians(coordinates1[1]);
1441 var lat2 = helpers.degreesToRadians(coordinates2[1]);
1442 var a = Math.pow(Math.sin(dLat / 2), 2) +
1443 Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
1444 return helpers.radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units);
1445 }
1446 exports.default = distance;
1447 });
1448
1449 var turfDistance = unwrapExports(distance_1);
1450
1451 function createCircle(center, endPoint, options) {
1452 var radius = turfDistance(helpers_7(center), helpers_7(endPoint), options);
1453 var feature = turfCircle(center, radius, {
1454 units: options.units,
1455 steps: options.steps,
1456 properties: _objectSpread2(_objectSpread2({}, options), {}, {
1457 active: true,
1458 type: 'circle',
1459 radius: radius,
1460 startPoint: {
1461 lng: center[0],
1462 lat: center[1]
1463 },
1464 endPoint: {
1465 lng: endPoint[0],
1466 lat: endPoint[1]
1467 }
1468 })
1469 });
1470 return feature;
1471 }
1472 function createRect(startPoint, endPoint, options) {
1473 var minX = Math.min(startPoint[0], endPoint[0]);
1474 var minY = Math.min(startPoint[1], endPoint[1]);
1475 var maxX = Math.max(startPoint[0], endPoint[0]);
1476 var maxY = Math.max(startPoint[1], endPoint[1]);
1477 var feature = {
1478 type: 'Feature',
1479 properties: _objectSpread2({
1480 type: 'rect',
1481 active: true,
1482 startPoint: {
1483 lng: startPoint[0],
1484 lat: startPoint[1]
1485 },
1486 endPoint: {
1487 lng: endPoint[0],
1488 lat: endPoint[1]
1489 }
1490 }, options),
1491 geometry: {
1492 type: 'Polygon',
1493 coordinates: [[[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]]]
1494 }
1495 };
1496 return feature;
1497 }
1498 function createPolygon(points, options) {
1499 var coords = points.map(function (p) {
1500 return [p.lng, p.lat];
1501 });
1502
1503 if (points.length < 2) {
1504 return helpers_7(coords[0], options);
1505 } else if (points.length < 3) {
1506 return helpers_11(coords, options);
1507 } else {
1508 coords.push(coords[0]);
1509 return helpers_9([coords], options);
1510 }
1511 }
1512 function createLine(points, options) {
1513 var coords = points.map(function (p) {
1514 return [p.lng, p.lat];
1515 });
1516
1517 if (points.length < 2) {
1518 return helpers_7(coords[0], options);
1519 } else {
1520 return helpers_11(coords, options);
1521 }
1522 }
1523 function createPoint(points) {
1524 var features = points.map(function (p, index) {
1525 return helpers_7([p.lng, p.lat], {
1526 active: true,
1527 id: index.toString()
1528 });
1529 });
1530 return helpers_13(features);
1531 }
1532
1533 function moveFeatures (features, delta) {
1534 features.forEach(function (feature) {
1535 var geometry = feature.geometry;
1536 var nextCoord;
1537 var type = geometry.type,
1538 coordinates = geometry.coordinates;
1539
1540 switch (type) {
1541 case FeatureType.POINT:
1542 nextCoord = movePoint(coordinates, delta);
1543 break;
1544
1545 case FeatureType.LINE_STRING:
1546 case FeatureType.MULTI_POINT:
1547 nextCoord = moveRing(coordinates, delta);
1548 break;
1549
1550 case FeatureType.POLYGON:
1551 case FeatureType.MULTI_LINE_STRING:
1552 nextCoord = moveMultiPolygon(coordinates, delta);
1553 break;
1554
1555 case FeatureType.MULTI_POLYGON:
1556 nextCoord = coordinates.map(function (mult) {
1557 return moveMultiPolygon(mult, delta);
1558 });
1559 break;
1560 }
1561
1562 if (nextCoord) {
1563 geometry.coordinates = nextCoord;
1564 }
1565 });
1566 return features;
1567 }
1568 function movePoint(coord, delta) {
1569 return [coord[0] + delta.lng, coord[1] + delta.lat];
1570 }
1571 function moveRing(coords, delta) {
1572 return coords.map(function (coord) {
1573 return movePoint(coord, delta);
1574 });
1575 }
1576 function moveMultiPolygon(mult, delta) {
1577 return mult.map(function (ring) {
1578 return moveRing(ring, delta);
1579 });
1580 }
1581
1582 function renderFeature(fe, style) {
1583 var _fe$features$, _fe$features$$geometr;
1584
1585 var type = (_fe$features$ = fe.features[0]) === null || _fe$features$ === void 0 ? void 0 : (_fe$features$$geometr = _fe$features$.geometry) === null || _fe$features$$geometr === void 0 ? void 0 : _fe$features$$geometr.type;
1586 var layers;
1587
1588 switch (type) {
1589 case 'Point':
1590 layers = drawPoint(fe, style.point);
1591 break;
1592
1593 case 'LineString':
1594 layers = drawLine(fe, style.line);
1595 break;
1596
1597 case 'Polygon':
1598 layers = drawPolyon(fe, style.polygon);
1599 break;
1600 }
1601
1602 return layers;
1603 }
1604
1605 function drawPoint(fe, style) {
1606 var layer = new l7.PointLayer({
1607 zIndex: 2,
1608 pickingBuffer: 3
1609 }).source(fe).shape('circle').color(style.color).size(style.size).style(style.style);
1610 return [layer];
1611 }
1612
1613 function drawLine(fe, style) {
1614 var layer = new l7.LineLayer({
1615 pickingBuffer: 3
1616 }).source(fe).shape('line').color(style.color).size(style.size).style(style.style);
1617 return [layer];
1618 }
1619
1620 function drawPolyon(fe, style) {
1621 var fill = new l7.PolygonLayer().source(fe).shape('fill').color(style.color).size(style.size).style({
1622 opacity: style.style.opacity
1623 });
1624 var line = new l7.PolygonLayer().source(fe).shape('line').color(style.style.stroke).size(style.style.strokeWidth).style({
1625 opacity: style.style.strokeOpacity,
1626 lineType: style.style.lineType,
1627 dashArray: style.style.dashArray
1628 });
1629 return [fill, line];
1630 }
1631
1632 var BaseRenderLayer = /*#__PURE__*/function () {
1633 function BaseRenderLayer(draw) {
1634 _classCallCheck(this, BaseRenderLayer);
1635
1636 this.drawLayers = [];
1637 this.draw = draw;
1638 }
1639
1640 _createClass(BaseRenderLayer, [{
1641 key: "update",
1642 value: function update(feature) {
1643 if (this.drawLayers.length > 0) {
1644 this.updateData(feature);
1645 }
1646
1647 this.removeLayers();
1648 var style = this.draw.getStyle('normal');
1649 this.drawLayers = renderFeature(feature, style);
1650 this.addLayers();
1651 }
1652 }, {
1653 key: "on",
1654 value: function on(type, handler) {
1655 var layer = this.drawLayers[0];
1656 layer.on(type, handler);
1657 }
1658 }, {
1659 key: "off",
1660 value: function off(type, handler) {
1661 var layer = this.drawLayers[0];
1662 layer.off(type, handler);
1663 }
1664 }, {
1665 key: "emit",
1666 value: function emit(type, e) {
1667 var layer = this.drawLayers[0];
1668 layer.emit(type, e);
1669 }
1670 }, {
1671 key: "updateData",
1672 value: function updateData(data) {
1673 if (this.drawLayers.length === 0) {
1674 this.update(data);
1675 }
1676
1677 this.drawLayers.forEach(function (layer) {
1678 return layer.setData(data);
1679 });
1680 }
1681 }, {
1682 key: "destroy",
1683 value: function destroy() {
1684 this.removeLayers();
1685 }
1686 }, {
1687 key: "removeLayers",
1688 value: function removeLayers() {
1689 var _this = this;
1690
1691 if (this.drawLayers.length !== 0) {
1692 this.drawLayers.forEach(function (layer) {
1693 return _this.draw.scene.removeLayer(layer);
1694 });
1695 }
1696 }
1697 }, {
1698 key: "addLayers",
1699 value: function addLayers() {
1700 var _this2 = this;
1701
1702 this.drawLayers.forEach(function (layer) {
1703 return _this2.draw.scene.addLayer(layer);
1704 });
1705 }
1706 }, {
1707 key: "show",
1708 value: function show() {
1709 this.drawLayers.forEach(function (layer) {
1710 return layer.show();
1711 });
1712 }
1713 }, {
1714 key: "hide",
1715 value: function hide() {
1716 this.drawLayers.forEach(function (layer) {
1717 return layer.hide();
1718 });
1719 }
1720 }]);
1721
1722 return BaseRenderLayer;
1723 }();
1724
1725 var DrawLayer = /*#__PURE__*/function (_BaseRender) {
1726 _inherits(DrawLayer, _BaseRender);
1727
1728 var _super = _createSuper(DrawLayer);
1729
1730 function DrawLayer() {
1731 var _this;
1732
1733 _classCallCheck(this, DrawLayer);
1734
1735 _this = _super.apply(this, arguments);
1736
1737 _this.onMouseMove = function (e) {
1738 _this.draw.setCursor('move');
1739
1740 _this.draw.selectMode.enable();
1741 };
1742
1743 _this.onUnMouseMove = function (e) {
1744 _this.draw.resetCursor();
1745
1746 _this.draw.selectMode.disable();
1747 };
1748
1749 _this.onClick = function (e) {
1750 _this.draw.selectMode.disable();
1751
1752 _this.draw.editMode.enable();
1753
1754 _this.disableSelect();
1755
1756 _this.draw.resetCursor();
1757
1758 _this.enableEdit();
1759
1760 _this.draw.setCurrentFeature(e.feature);
1761
1762 _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.DIRECT_SELECT);
1763 };
1764
1765 _this.onUnClick = function (e) {
1766 _this.draw.selectMode.disable();
1767
1768 _this.draw.editMode.disable();
1769
1770 _this.draw.source.setFeatureUnActive(_this.draw.getCurrentFeature());
1771
1772 _this.disableSelect();
1773
1774 _this.disableEdit();
1775
1776 _this.hide();
1777
1778 _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
1779 };
1780
1781 return _this;
1782 }
1783
1784 _createClass(DrawLayer, [{
1785 key: "update",
1786 value: function update(feature) {
1787 this.removeLayers();
1788 var style = this.draw.getStyle('active');
1789 this.drawLayers = renderFeature(feature, style);
1790 this.addLayers();
1791 }
1792 }, {
1793 key: "enableSelect",
1794 value: function enableSelect() {
1795 this.show();
1796
1797 if (this.isEnableDrag) {
1798 return;
1799 }
1800
1801 var layer = this.drawLayers[0];
1802 layer.on('mouseenter', this.onMouseMove);
1803 layer.on('mouseout', this.onUnMouseMove);
1804
1805 if (this.draw.editEnable) {
1806 layer.on('click', this.onClick);
1807 }
1808
1809 layer.on('unclick', this.onUnClick);
1810 this.isEnableDrag = true;
1811 }
1812 }, {
1813 key: "disableSelect",
1814 value: function disableSelect() {
1815 if (!this.isEnableDrag) {
1816 return;
1817 }
1818
1819 var layer = this.drawLayers[0];
1820 layer.off('mouseenter', this.onMouseMove);
1821 layer.off('mouseout', this.onUnMouseMove);
1822 layer.off('click', this.onClick);
1823 layer.off('unclick', this.onUnClick);
1824 this.isEnableDrag = false;
1825 }
1826 }, {
1827 key: "enableEdit",
1828 value: function enableEdit() {
1829 if (this.isEnableEdit) {
1830 return;
1831 }
1832
1833 var layer = this.drawLayers[0];
1834 layer.on('unclick', this.onUnClick);
1835 this.isEnableDrag = true;
1836 }
1837 }, {
1838 key: "disableEdit",
1839 value: function disableEdit() {
1840 if (!this.isEnableEdit) {
1841 return;
1842 }
1843
1844 var layer = this.drawLayers[0];
1845 layer.off('unclick', this.onUnClick);
1846 this.isEnableDrag = false;
1847 }
1848 }]);
1849
1850 return DrawLayer;
1851 }(BaseRenderLayer);
1852
1853 var DrawResultLayer = /*#__PURE__*/function (_BaseRender) {
1854 _inherits(DrawResultLayer, _BaseRender);
1855
1856 var _super = _createSuper(DrawResultLayer);
1857
1858 function DrawResultLayer() {
1859 var _this;
1860
1861 _classCallCheck(this, DrawResultLayer);
1862
1863 _this = _super.apply(this, arguments);
1864
1865 _this.onClick = function (e) {
1866 _this.draw.source.setFeatureUnActive(_this.draw.getCurrentFeature());
1867
1868 _this.draw.setCurrentFeature(e.feature);
1869
1870 _this.draw.source.setFeatureActive(e.feature);
1871
1872 _this.updateData(_this.draw.source.data);
1873
1874 _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
1875 };
1876
1877 _this.onDeleteClick = function (e) {
1878 _this.draw.source.removeFeature(e.feature);
1879
1880 _this.updateData(_this.draw.source.data);
1881 };
1882
1883 return _this;
1884 }
1885
1886 _createClass(DrawResultLayer, [{
1887 key: "update",
1888 value: function update(feature) {
1889 if (this.drawLayers.length > 0) {
1890 this.updateData(feature);
1891 return;
1892 }
1893
1894 this.removeLayers();
1895 var style = this.draw.getStyle('normal');
1896 this.drawLayers = renderFeature(feature, style);
1897 this.addFilter();
1898 this.addLayers();
1899 }
1900 }, {
1901 key: "enableSelect",
1902 value: function enableSelect() {
1903 if (this.isEnableDrag) {
1904 return;
1905 }
1906
1907 if (!this.draw.selectEnable) {
1908 return;
1909 }
1910
1911 var layer = this.drawLayers[0];
1912 layer.on('click', this.onClick);
1913 this.isEnableDrag = true;
1914 }
1915 }, {
1916 key: "disableSelect",
1917 value: function disableSelect() {
1918 if (!this.isEnableDrag) {
1919 return;
1920 }
1921
1922 var layer = this.drawLayers[0];
1923 layer.off('click', this.onClick);
1924 this.isEnableDrag = false;
1925 }
1926 }, {
1927 key: "enableDelete",
1928 value: function enableDelete() {
1929 this.disableSelect();
1930 var layer = this.drawLayers[0];
1931 layer.on('click', this.onDeleteClick);
1932 }
1933 }, {
1934 key: "disableDelete",
1935 value: function disableDelete() {
1936 var layer = this.drawLayers[0];
1937 layer.off('click', this.onDeleteClick);
1938 }
1939 }, {
1940 key: "addFilter",
1941 value: function addFilter() {
1942 this.drawLayers.forEach(function (layer) {
1943 return layer.filter('active', function (active) {
1944 return !active;
1945 });
1946 });
1947 }
1948 }]);
1949
1950 return DrawResultLayer;
1951 }(BaseRenderLayer);
1952
1953 var DrawVertexLayer = /*#__PURE__*/function (_BaseRender) {
1954 _inherits(DrawVertexLayer, _BaseRender);
1955
1956 var _super = _createSuper(DrawVertexLayer);
1957
1958 function DrawVertexLayer() {
1959 var _this;
1960
1961 _classCallCheck(this, DrawVertexLayer);
1962
1963 _this = _super.apply(this, arguments);
1964
1965 _this.onMouseEnter = function (e) {
1966 _this.draw.setCursor('move');
1967
1968 _this.draw.setCurrentVertex(e.feature);
1969
1970 _this.draw.editMode.enable();
1971 };
1972
1973 _this.onMouseOut = function (e) {
1974 _this.draw.resetCursor();
1975
1976 _this.draw.editMode.disable();
1977 };
1978
1979 _this.onClick = function (e) {
1980 _this.draw.setCurrentVertex(e.feature);
1981
1982 _this.draw.editMode.enable();
1983 };
1984
1985 return _this;
1986 }
1987
1988 _createClass(DrawVertexLayer, [{
1989 key: "update",
1990 value: function update(feature) {
1991 this.removeLayers();
1992 var style = this.draw.getStyle('active');
1993 this.drawLayers = renderFeature(feature, style);
1994 this.addLayers();
1995 }
1996 }, {
1997 key: "enableSelect",
1998 value: function enableSelect() {
1999 return;
2000 }
2001 }, {
2002 key: "disableSelect",
2003 value: function disableSelect() {
2004 return;
2005 }
2006 }, {
2007 key: "enableEdit",
2008 value: function enableEdit() {
2009 if (this.isEnableEdit) {
2010 return;
2011 }
2012
2013 var layer = this.drawLayers[0];
2014 layer.on('mouseenter', this.onMouseEnter);
2015 layer.on('mouseout', this.onMouseOut);
2016 layer.on('click', this.onClick);
2017 this.isEnableEdit = true;
2018 }
2019 }, {
2020 key: "disableEdit",
2021 value: function disableEdit() {
2022 if (!this.isEnableEdit) {
2023 return;
2024 }
2025
2026 var layer = this.drawLayers[0];
2027 layer.off('mouseenter', this.onMouseEnter);
2028 layer.off('mouseout', this.onMouseOut);
2029 layer.off('click', this.onClick);
2030 this.isEnableEdit = false;
2031 }
2032 }]);
2033
2034 return DrawVertexLayer;
2035 }(BaseRenderLayer);
2036
2037 var eventemitter3 = createCommonjsModule(function (module) {
2038
2039 var has = Object.prototype.hasOwnProperty
2040 , prefix = '~';
2041
2042 /**
2043 * Constructor to create a storage for our `EE` objects.
2044 * An `Events` instance is a plain object whose properties are event names.
2045 *
2046 * @constructor
2047 * @private
2048 */
2049 function Events() {}
2050
2051 //
2052 // We try to not inherit from `Object.prototype`. In some engines creating an
2053 // instance in this way is faster than calling `Object.create(null)` directly.
2054 // If `Object.create(null)` is not supported we prefix the event names with a
2055 // character to make sure that the built-in object properties are not
2056 // overridden or used as an attack vector.
2057 //
2058 if (Object.create) {
2059 Events.prototype = Object.create(null);
2060
2061 //
2062 // This hack is needed because the `__proto__` property is still inherited in
2063 // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
2064 //
2065 if (!new Events().__proto__) prefix = false;
2066 }
2067
2068 /**
2069 * Representation of a single event listener.
2070 *
2071 * @param {Function} fn The listener function.
2072 * @param {*} context The context to invoke the listener with.
2073 * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
2074 * @constructor
2075 * @private
2076 */
2077 function EE(fn, context, once) {
2078 this.fn = fn;
2079 this.context = context;
2080 this.once = once || false;
2081 }
2082
2083 /**
2084 * Add a listener for a given event.
2085 *
2086 * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
2087 * @param {(String|Symbol)} event The event name.
2088 * @param {Function} fn The listener function.
2089 * @param {*} context The context to invoke the listener with.
2090 * @param {Boolean} once Specify if the listener is a one-time listener.
2091 * @returns {EventEmitter}
2092 * @private
2093 */
2094 function addListener(emitter, event, fn, context, once) {
2095 if (typeof fn !== 'function') {
2096 throw new TypeError('The listener must be a function');
2097 }
2098
2099 var listener = new EE(fn, context || emitter, once)
2100 , evt = prefix ? prefix + event : event;
2101
2102 if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
2103 else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
2104 else emitter._events[evt] = [emitter._events[evt], listener];
2105
2106 return emitter;
2107 }
2108
2109 /**
2110 * Clear event by name.
2111 *
2112 * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
2113 * @param {(String|Symbol)} evt The Event name.
2114 * @private
2115 */
2116 function clearEvent(emitter, evt) {
2117 if (--emitter._eventsCount === 0) emitter._events = new Events();
2118 else delete emitter._events[evt];
2119 }
2120
2121 /**
2122 * Minimal `EventEmitter` interface that is molded against the Node.js
2123 * `EventEmitter` interface.
2124 *
2125 * @constructor
2126 * @public
2127 */
2128 function EventEmitter() {
2129 this._events = new Events();
2130 this._eventsCount = 0;
2131 }
2132
2133 /**
2134 * Return an array listing the events for which the emitter has registered
2135 * listeners.
2136 *
2137 * @returns {Array}
2138 * @public
2139 */
2140 EventEmitter.prototype.eventNames = function eventNames() {
2141 var names = []
2142 , events
2143 , name;
2144
2145 if (this._eventsCount === 0) return names;
2146
2147 for (name in (events = this._events)) {
2148 if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
2149 }
2150
2151 if (Object.getOwnPropertySymbols) {
2152 return names.concat(Object.getOwnPropertySymbols(events));
2153 }
2154
2155 return names;
2156 };
2157
2158 /**
2159 * Return the listeners registered for a given event.
2160 *
2161 * @param {(String|Symbol)} event The event name.
2162 * @returns {Array} The registered listeners.
2163 * @public
2164 */
2165 EventEmitter.prototype.listeners = function listeners(event) {
2166 var evt = prefix ? prefix + event : event
2167 , handlers = this._events[evt];
2168
2169 if (!handlers) return [];
2170 if (handlers.fn) return [handlers.fn];
2171
2172 for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
2173 ee[i] = handlers[i].fn;
2174 }
2175
2176 return ee;
2177 };
2178
2179 /**
2180 * Return the number of listeners listening to a given event.
2181 *
2182 * @param {(String|Symbol)} event The event name.
2183 * @returns {Number} The number of listeners.
2184 * @public
2185 */
2186 EventEmitter.prototype.listenerCount = function listenerCount(event) {
2187 var evt = prefix ? prefix + event : event
2188 , listeners = this._events[evt];
2189
2190 if (!listeners) return 0;
2191 if (listeners.fn) return 1;
2192 return listeners.length;
2193 };
2194
2195 /**
2196 * Calls each of the listeners registered for a given event.
2197 *
2198 * @param {(String|Symbol)} event The event name.
2199 * @returns {Boolean} `true` if the event had listeners, else `false`.
2200 * @public
2201 */
2202 EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
2203 var evt = prefix ? prefix + event : event;
2204
2205 if (!this._events[evt]) return false;
2206
2207 var listeners = this._events[evt]
2208 , len = arguments.length
2209 , args
2210 , i;
2211
2212 if (listeners.fn) {
2213 if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
2214
2215 switch (len) {
2216 case 1: return listeners.fn.call(listeners.context), true;
2217 case 2: return listeners.fn.call(listeners.context, a1), true;
2218 case 3: return listeners.fn.call(listeners.context, a1, a2), true;
2219 case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
2220 case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
2221 case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
2222 }
2223
2224 for (i = 1, args = new Array(len -1); i < len; i++) {
2225 args[i - 1] = arguments[i];
2226 }
2227
2228 listeners.fn.apply(listeners.context, args);
2229 } else {
2230 var length = listeners.length
2231 , j;
2232
2233 for (i = 0; i < length; i++) {
2234 if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
2235
2236 switch (len) {
2237 case 1: listeners[i].fn.call(listeners[i].context); break;
2238 case 2: listeners[i].fn.call(listeners[i].context, a1); break;
2239 case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
2240 case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
2241 default:
2242 if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
2243 args[j - 1] = arguments[j];
2244 }
2245
2246 listeners[i].fn.apply(listeners[i].context, args);
2247 }
2248 }
2249 }
2250
2251 return true;
2252 };
2253
2254 /**
2255 * Add a listener for a given event.
2256 *
2257 * @param {(String|Symbol)} event The event name.
2258 * @param {Function} fn The listener function.
2259 * @param {*} [context=this] The context to invoke the listener with.
2260 * @returns {EventEmitter} `this`.
2261 * @public
2262 */
2263 EventEmitter.prototype.on = function on(event, fn, context) {
2264 return addListener(this, event, fn, context, false);
2265 };
2266
2267 /**
2268 * Add a one-time listener for a given event.
2269 *
2270 * @param {(String|Symbol)} event The event name.
2271 * @param {Function} fn The listener function.
2272 * @param {*} [context=this] The context to invoke the listener with.
2273 * @returns {EventEmitter} `this`.
2274 * @public
2275 */
2276 EventEmitter.prototype.once = function once(event, fn, context) {
2277 return addListener(this, event, fn, context, true);
2278 };
2279
2280 /**
2281 * Remove the listeners of a given event.
2282 *
2283 * @param {(String|Symbol)} event The event name.
2284 * @param {Function} fn Only remove the listeners that match this function.
2285 * @param {*} context Only remove the listeners that have this context.
2286 * @param {Boolean} once Only remove one-time listeners.
2287 * @returns {EventEmitter} `this`.
2288 * @public
2289 */
2290 EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
2291 var evt = prefix ? prefix + event : event;
2292
2293 if (!this._events[evt]) return this;
2294 if (!fn) {
2295 clearEvent(this, evt);
2296 return this;
2297 }
2298
2299 var listeners = this._events[evt];
2300
2301 if (listeners.fn) {
2302 if (
2303 listeners.fn === fn &&
2304 (!once || listeners.once) &&
2305 (!context || listeners.context === context)
2306 ) {
2307 clearEvent(this, evt);
2308 }
2309 } else {
2310 for (var i = 0, events = [], length = listeners.length; i < length; i++) {
2311 if (
2312 listeners[i].fn !== fn ||
2313 (once && !listeners[i].once) ||
2314 (context && listeners[i].context !== context)
2315 ) {
2316 events.push(listeners[i]);
2317 }
2318 }
2319
2320 //
2321 // Reset the array, or remove it completely if we have no more listeners.
2322 //
2323 if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
2324 else clearEvent(this, evt);
2325 }
2326
2327 return this;
2328 };
2329
2330 /**
2331 * Remove all listeners, or those of the specified event.
2332 *
2333 * @param {(String|Symbol)} [event] The event name.
2334 * @returns {EventEmitter} `this`.
2335 * @public
2336 */
2337 EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
2338 var evt;
2339
2340 if (event) {
2341 evt = prefix ? prefix + event : event;
2342 if (this._events[evt]) clearEvent(this, evt);
2343 } else {
2344 this._events = new Events();
2345 this._eventsCount = 0;
2346 }
2347
2348 return this;
2349 };
2350
2351 //
2352 // Alias methods names because people roll like that.
2353 //
2354 EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
2355 EventEmitter.prototype.addListener = EventEmitter.prototype.on;
2356
2357 //
2358 // Expose the prefix.
2359 //
2360 EventEmitter.prefixed = prefix;
2361
2362 //
2363 // Allow `EventEmitter` to be imported as module namespace.
2364 //
2365 EventEmitter.EventEmitter = EventEmitter;
2366
2367 //
2368 // Expose the module.
2369 //
2370 {
2371 module.exports = EventEmitter;
2372 }
2373 });
2374 var eventemitter3_1 = eventemitter3.EventEmitter;
2375
2376 /**
2377 * Removes all key-value entries from the list cache.
2378 *
2379 * @private
2380 * @name clear
2381 * @memberOf ListCache
2382 */
2383 function listCacheClear() {
2384 this.__data__ = [];
2385 this.size = 0;
2386 }
2387
2388 var _listCacheClear = listCacheClear;
2389
2390 /**
2391 * Performs a
2392 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2393 * comparison between two values to determine if they are equivalent.
2394 *
2395 * @static
2396 * @memberOf _
2397 * @since 4.0.0
2398 * @category Lang
2399 * @param {*} value The value to compare.
2400 * @param {*} other The other value to compare.
2401 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2402 * @example
2403 *
2404 * var object = { 'a': 1 };
2405 * var other = { 'a': 1 };
2406 *
2407 * _.eq(object, object);
2408 * // => true
2409 *
2410 * _.eq(object, other);
2411 * // => false
2412 *
2413 * _.eq('a', 'a');
2414 * // => true
2415 *
2416 * _.eq('a', Object('a'));
2417 * // => false
2418 *
2419 * _.eq(NaN, NaN);
2420 * // => true
2421 */
2422 function eq(value, other) {
2423 return value === other || (value !== value && other !== other);
2424 }
2425
2426 var eq_1 = eq;
2427
2428 /**
2429 * Gets the index at which the `key` is found in `array` of key-value pairs.
2430 *
2431 * @private
2432 * @param {Array} array The array to inspect.
2433 * @param {*} key The key to search for.
2434 * @returns {number} Returns the index of the matched value, else `-1`.
2435 */
2436 function assocIndexOf(array, key) {
2437 var length = array.length;
2438 while (length--) {
2439 if (eq_1(array[length][0], key)) {
2440 return length;
2441 }
2442 }
2443 return -1;
2444 }
2445
2446 var _assocIndexOf = assocIndexOf;
2447
2448 /** Used for built-in method references. */
2449 var arrayProto = Array.prototype;
2450
2451 /** Built-in value references. */
2452 var splice = arrayProto.splice;
2453
2454 /**
2455 * Removes `key` and its value from the list cache.
2456 *
2457 * @private
2458 * @name delete
2459 * @memberOf ListCache
2460 * @param {string} key The key of the value to remove.
2461 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2462 */
2463 function listCacheDelete(key) {
2464 var data = this.__data__,
2465 index = _assocIndexOf(data, key);
2466
2467 if (index < 0) {
2468 return false;
2469 }
2470 var lastIndex = data.length - 1;
2471 if (index == lastIndex) {
2472 data.pop();
2473 } else {
2474 splice.call(data, index, 1);
2475 }
2476 --this.size;
2477 return true;
2478 }
2479
2480 var _listCacheDelete = listCacheDelete;
2481
2482 /**
2483 * Gets the list cache value for `key`.
2484 *
2485 * @private
2486 * @name get
2487 * @memberOf ListCache
2488 * @param {string} key The key of the value to get.
2489 * @returns {*} Returns the entry value.
2490 */
2491 function listCacheGet(key) {
2492 var data = this.__data__,
2493 index = _assocIndexOf(data, key);
2494
2495 return index < 0 ? undefined : data[index][1];
2496 }
2497
2498 var _listCacheGet = listCacheGet;
2499
2500 /**
2501 * Checks if a list cache value for `key` exists.
2502 *
2503 * @private
2504 * @name has
2505 * @memberOf ListCache
2506 * @param {string} key The key of the entry to check.
2507 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2508 */
2509 function listCacheHas(key) {
2510 return _assocIndexOf(this.__data__, key) > -1;
2511 }
2512
2513 var _listCacheHas = listCacheHas;
2514
2515 /**
2516 * Sets the list cache `key` to `value`.
2517 *
2518 * @private
2519 * @name set
2520 * @memberOf ListCache
2521 * @param {string} key The key of the value to set.
2522 * @param {*} value The value to set.
2523 * @returns {Object} Returns the list cache instance.
2524 */
2525 function listCacheSet(key, value) {
2526 var data = this.__data__,
2527 index = _assocIndexOf(data, key);
2528
2529 if (index < 0) {
2530 ++this.size;
2531 data.push([key, value]);
2532 } else {
2533 data[index][1] = value;
2534 }
2535 return this;
2536 }
2537
2538 var _listCacheSet = listCacheSet;
2539
2540 /**
2541 * Creates an list cache object.
2542 *
2543 * @private
2544 * @constructor
2545 * @param {Array} [entries] The key-value pairs to cache.
2546 */
2547 function ListCache(entries) {
2548 var index = -1,
2549 length = entries == null ? 0 : entries.length;
2550
2551 this.clear();
2552 while (++index < length) {
2553 var entry = entries[index];
2554 this.set(entry[0], entry[1]);
2555 }
2556 }
2557
2558 // Add methods to `ListCache`.
2559 ListCache.prototype.clear = _listCacheClear;
2560 ListCache.prototype['delete'] = _listCacheDelete;
2561 ListCache.prototype.get = _listCacheGet;
2562 ListCache.prototype.has = _listCacheHas;
2563 ListCache.prototype.set = _listCacheSet;
2564
2565 var _ListCache = ListCache;
2566
2567 /**
2568 * Removes all key-value entries from the stack.
2569 *
2570 * @private
2571 * @name clear
2572 * @memberOf Stack
2573 */
2574 function stackClear() {
2575 this.__data__ = new _ListCache;
2576 this.size = 0;
2577 }
2578
2579 var _stackClear = stackClear;
2580
2581 /**
2582 * Removes `key` and its value from the stack.
2583 *
2584 * @private
2585 * @name delete
2586 * @memberOf Stack
2587 * @param {string} key The key of the value to remove.
2588 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2589 */
2590 function stackDelete(key) {
2591 var data = this.__data__,
2592 result = data['delete'](key);
2593
2594 this.size = data.size;
2595 return result;
2596 }
2597
2598 var _stackDelete = stackDelete;
2599
2600 /**
2601 * Gets the stack value for `key`.
2602 *
2603 * @private
2604 * @name get
2605 * @memberOf Stack
2606 * @param {string} key The key of the value to get.
2607 * @returns {*} Returns the entry value.
2608 */
2609 function stackGet(key) {
2610 return this.__data__.get(key);
2611 }
2612
2613 var _stackGet = stackGet;
2614
2615 /**
2616 * Checks if a stack value for `key` exists.
2617 *
2618 * @private
2619 * @name has
2620 * @memberOf Stack
2621 * @param {string} key The key of the entry to check.
2622 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2623 */
2624 function stackHas(key) {
2625 return this.__data__.has(key);
2626 }
2627
2628 var _stackHas = stackHas;
2629
2630 /** Detect free variable `global` from Node.js. */
2631 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2632
2633 var _freeGlobal = freeGlobal;
2634
2635 /** Detect free variable `self`. */
2636 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
2637
2638 /** Used as a reference to the global object. */
2639 var root = _freeGlobal || freeSelf || Function('return this')();
2640
2641 var _root = root;
2642
2643 /** Built-in value references. */
2644 var Symbol$1 = _root.Symbol;
2645
2646 var _Symbol = Symbol$1;
2647
2648 /** Used for built-in method references. */
2649 var objectProto = Object.prototype;
2650
2651 /** Used to check objects for own properties. */
2652 var hasOwnProperty = objectProto.hasOwnProperty;
2653
2654 /**
2655 * Used to resolve the
2656 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2657 * of values.
2658 */
2659 var nativeObjectToString = objectProto.toString;
2660
2661 /** Built-in value references. */
2662 var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
2663
2664 /**
2665 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
2666 *
2667 * @private
2668 * @param {*} value The value to query.
2669 * @returns {string} Returns the raw `toStringTag`.
2670 */
2671 function getRawTag(value) {
2672 var isOwn = hasOwnProperty.call(value, symToStringTag),
2673 tag = value[symToStringTag];
2674
2675 try {
2676 value[symToStringTag] = undefined;
2677 var unmasked = true;
2678 } catch (e) {}
2679
2680 var result = nativeObjectToString.call(value);
2681 if (unmasked) {
2682 if (isOwn) {
2683 value[symToStringTag] = tag;
2684 } else {
2685 delete value[symToStringTag];
2686 }
2687 }
2688 return result;
2689 }
2690
2691 var _getRawTag = getRawTag;
2692
2693 /** Used for built-in method references. */
2694 var objectProto$1 = Object.prototype;
2695
2696 /**
2697 * Used to resolve the
2698 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2699 * of values.
2700 */
2701 var nativeObjectToString$1 = objectProto$1.toString;
2702
2703 /**
2704 * Converts `value` to a string using `Object.prototype.toString`.
2705 *
2706 * @private
2707 * @param {*} value The value to convert.
2708 * @returns {string} Returns the converted string.
2709 */
2710 function objectToString(value) {
2711 return nativeObjectToString$1.call(value);
2712 }
2713
2714 var _objectToString = objectToString;
2715
2716 /** `Object#toString` result references. */
2717 var nullTag = '[object Null]',
2718 undefinedTag = '[object Undefined]';
2719
2720 /** Built-in value references. */
2721 var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
2722
2723 /**
2724 * The base implementation of `getTag` without fallbacks for buggy environments.
2725 *
2726 * @private
2727 * @param {*} value The value to query.
2728 * @returns {string} Returns the `toStringTag`.
2729 */
2730 function baseGetTag(value) {
2731 if (value == null) {
2732 return value === undefined ? undefinedTag : nullTag;
2733 }
2734 return (symToStringTag$1 && symToStringTag$1 in Object(value))
2735 ? _getRawTag(value)
2736 : _objectToString(value);
2737 }
2738
2739 var _baseGetTag = baseGetTag;
2740
2741 /**
2742 * Checks if `value` is the
2743 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2744 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2745 *
2746 * @static
2747 * @memberOf _
2748 * @since 0.1.0
2749 * @category Lang
2750 * @param {*} value The value to check.
2751 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2752 * @example
2753 *
2754 * _.isObject({});
2755 * // => true
2756 *
2757 * _.isObject([1, 2, 3]);
2758 * // => true
2759 *
2760 * _.isObject(_.noop);
2761 * // => true
2762 *
2763 * _.isObject(null);
2764 * // => false
2765 */
2766 function isObject(value) {
2767 var type = typeof value;
2768 return value != null && (type == 'object' || type == 'function');
2769 }
2770
2771 var isObject_1 = isObject;
2772
2773 /** `Object#toString` result references. */
2774 var asyncTag = '[object AsyncFunction]',
2775 funcTag = '[object Function]',
2776 genTag = '[object GeneratorFunction]',
2777 proxyTag = '[object Proxy]';
2778
2779 /**
2780 * Checks if `value` is classified as a `Function` object.
2781 *
2782 * @static
2783 * @memberOf _
2784 * @since 0.1.0
2785 * @category Lang
2786 * @param {*} value The value to check.
2787 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2788 * @example
2789 *
2790 * _.isFunction(_);
2791 * // => true
2792 *
2793 * _.isFunction(/abc/);
2794 * // => false
2795 */
2796 function isFunction(value) {
2797 if (!isObject_1(value)) {
2798 return false;
2799 }
2800 // The use of `Object#toString` avoids issues with the `typeof` operator
2801 // in Safari 9 which returns 'object' for typed arrays and other constructors.
2802 var tag = _baseGetTag(value);
2803 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2804 }
2805
2806 var isFunction_1 = isFunction;
2807
2808 /** Used to detect overreaching core-js shims. */
2809 var coreJsData = _root['__core-js_shared__'];
2810
2811 var _coreJsData = coreJsData;
2812
2813 /** Used to detect methods masquerading as native. */
2814 var maskSrcKey = (function() {
2815 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
2816 return uid ? ('Symbol(src)_1.' + uid) : '';
2817 }());
2818
2819 /**
2820 * Checks if `func` has its source masked.
2821 *
2822 * @private
2823 * @param {Function} func The function to check.
2824 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
2825 */
2826 function isMasked(func) {
2827 return !!maskSrcKey && (maskSrcKey in func);
2828 }
2829
2830 var _isMasked = isMasked;
2831
2832 /** Used for built-in method references. */
2833 var funcProto = Function.prototype;
2834
2835 /** Used to resolve the decompiled source of functions. */
2836 var funcToString = funcProto.toString;
2837
2838 /**
2839 * Converts `func` to its source code.
2840 *
2841 * @private
2842 * @param {Function} func The function to convert.
2843 * @returns {string} Returns the source code.
2844 */
2845 function toSource(func) {
2846 if (func != null) {
2847 try {
2848 return funcToString.call(func);
2849 } catch (e) {}
2850 try {
2851 return (func + '');
2852 } catch (e) {}
2853 }
2854 return '';
2855 }
2856
2857 var _toSource = toSource;
2858
2859 /**
2860 * Used to match `RegExp`
2861 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
2862 */
2863 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2864
2865 /** Used to detect host constructors (Safari). */
2866 var reIsHostCtor = /^\[object .+?Constructor\]$/;
2867
2868 /** Used for built-in method references. */
2869 var funcProto$1 = Function.prototype,
2870 objectProto$2 = Object.prototype;
2871
2872 /** Used to resolve the decompiled source of functions. */
2873 var funcToString$1 = funcProto$1.toString;
2874
2875 /** Used to check objects for own properties. */
2876 var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2877
2878 /** Used to detect if a method is native. */
2879 var reIsNative = RegExp('^' +
2880 funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
2881 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
2882 );
2883
2884 /**
2885 * The base implementation of `_.isNative` without bad shim checks.
2886 *
2887 * @private
2888 * @param {*} value The value to check.
2889 * @returns {boolean} Returns `true` if `value` is a native function,
2890 * else `false`.
2891 */
2892 function baseIsNative(value) {
2893 if (!isObject_1(value) || _isMasked(value)) {
2894 return false;
2895 }
2896 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
2897 return pattern.test(_toSource(value));
2898 }
2899
2900 var _baseIsNative = baseIsNative;
2901
2902 /**
2903 * Gets the value at `key` of `object`.
2904 *
2905 * @private
2906 * @param {Object} [object] The object to query.
2907 * @param {string} key The key of the property to get.
2908 * @returns {*} Returns the property value.
2909 */
2910 function getValue(object, key) {
2911 return object == null ? undefined : object[key];
2912 }
2913
2914 var _getValue = getValue;
2915
2916 /**
2917 * Gets the native function at `key` of `object`.
2918 *
2919 * @private
2920 * @param {Object} object The object to query.
2921 * @param {string} key The key of the method to get.
2922 * @returns {*} Returns the function if it's native, else `undefined`.
2923 */
2924 function getNative(object, key) {
2925 var value = _getValue(object, key);
2926 return _baseIsNative(value) ? value : undefined;
2927 }
2928
2929 var _getNative = getNative;
2930
2931 /* Built-in method references that are verified to be native. */
2932 var Map = _getNative(_root, 'Map');
2933
2934 var _Map = Map;
2935
2936 /* Built-in method references that are verified to be native. */
2937 var nativeCreate = _getNative(Object, 'create');
2938
2939 var _nativeCreate = nativeCreate;
2940
2941 /**
2942 * Removes all key-value entries from the hash.
2943 *
2944 * @private
2945 * @name clear
2946 * @memberOf Hash
2947 */
2948 function hashClear() {
2949 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
2950 this.size = 0;
2951 }
2952
2953 var _hashClear = hashClear;
2954
2955 /**
2956 * Removes `key` and its value from the hash.
2957 *
2958 * @private
2959 * @name delete
2960 * @memberOf Hash
2961 * @param {Object} hash The hash to modify.
2962 * @param {string} key The key of the value to remove.
2963 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2964 */
2965 function hashDelete(key) {
2966 var result = this.has(key) && delete this.__data__[key];
2967 this.size -= result ? 1 : 0;
2968 return result;
2969 }
2970
2971 var _hashDelete = hashDelete;
2972
2973 /** Used to stand-in for `undefined` hash values. */
2974 var HASH_UNDEFINED = '__lodash_hash_undefined__';
2975
2976 /** Used for built-in method references. */
2977 var objectProto$3 = Object.prototype;
2978
2979 /** Used to check objects for own properties. */
2980 var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2981
2982 /**
2983 * Gets the hash value for `key`.
2984 *
2985 * @private
2986 * @name get
2987 * @memberOf Hash
2988 * @param {string} key The key of the value to get.
2989 * @returns {*} Returns the entry value.
2990 */
2991 function hashGet(key) {
2992 var data = this.__data__;
2993 if (_nativeCreate) {
2994 var result = data[key];
2995 return result === HASH_UNDEFINED ? undefined : result;
2996 }
2997 return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
2998 }
2999
3000 var _hashGet = hashGet;
3001
3002 /** Used for built-in method references. */
3003 var objectProto$4 = Object.prototype;
3004
3005 /** Used to check objects for own properties. */
3006 var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
3007
3008 /**
3009 * Checks if a hash value for `key` exists.
3010 *
3011 * @private
3012 * @name has
3013 * @memberOf Hash
3014 * @param {string} key The key of the entry to check.
3015 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3016 */
3017 function hashHas(key) {
3018 var data = this.__data__;
3019 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
3020 }
3021
3022 var _hashHas = hashHas;
3023
3024 /** Used to stand-in for `undefined` hash values. */
3025 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
3026
3027 /**
3028 * Sets the hash `key` to `value`.
3029 *
3030 * @private
3031 * @name set
3032 * @memberOf Hash
3033 * @param {string} key The key of the value to set.
3034 * @param {*} value The value to set.
3035 * @returns {Object} Returns the hash instance.
3036 */
3037 function hashSet(key, value) {
3038 var data = this.__data__;
3039 this.size += this.has(key) ? 0 : 1;
3040 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
3041 return this;
3042 }
3043
3044 var _hashSet = hashSet;
3045
3046 /**
3047 * Creates a hash object.
3048 *
3049 * @private
3050 * @constructor
3051 * @param {Array} [entries] The key-value pairs to cache.
3052 */
3053 function Hash(entries) {
3054 var index = -1,
3055 length = entries == null ? 0 : entries.length;
3056
3057 this.clear();
3058 while (++index < length) {
3059 var entry = entries[index];
3060 this.set(entry[0], entry[1]);
3061 }
3062 }
3063
3064 // Add methods to `Hash`.
3065 Hash.prototype.clear = _hashClear;
3066 Hash.prototype['delete'] = _hashDelete;
3067 Hash.prototype.get = _hashGet;
3068 Hash.prototype.has = _hashHas;
3069 Hash.prototype.set = _hashSet;
3070
3071 var _Hash = Hash;
3072
3073 /**
3074 * Removes all key-value entries from the map.
3075 *
3076 * @private
3077 * @name clear
3078 * @memberOf MapCache
3079 */
3080 function mapCacheClear() {
3081 this.size = 0;
3082 this.__data__ = {
3083 'hash': new _Hash,
3084 'map': new (_Map || _ListCache),
3085 'string': new _Hash
3086 };
3087 }
3088
3089 var _mapCacheClear = mapCacheClear;
3090
3091 /**
3092 * Checks if `value` is suitable for use as unique object key.
3093 *
3094 * @private
3095 * @param {*} value The value to check.
3096 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
3097 */
3098 function isKeyable(value) {
3099 var type = typeof value;
3100 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
3101 ? (value !== '__proto__')
3102 : (value === null);
3103 }
3104
3105 var _isKeyable = isKeyable;
3106
3107 /**
3108 * Gets the data for `map`.
3109 *
3110 * @private
3111 * @param {Object} map The map to query.
3112 * @param {string} key The reference key.
3113 * @returns {*} Returns the map data.
3114 */
3115 function getMapData(map, key) {
3116 var data = map.__data__;
3117 return _isKeyable(key)
3118 ? data[typeof key == 'string' ? 'string' : 'hash']
3119 : data.map;
3120 }
3121
3122 var _getMapData = getMapData;
3123
3124 /**
3125 * Removes `key` and its value from the map.
3126 *
3127 * @private
3128 * @name delete
3129 * @memberOf MapCache
3130 * @param {string} key The key of the value to remove.
3131 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3132 */
3133 function mapCacheDelete(key) {
3134 var result = _getMapData(this, key)['delete'](key);
3135 this.size -= result ? 1 : 0;
3136 return result;
3137 }
3138
3139 var _mapCacheDelete = mapCacheDelete;
3140
3141 /**
3142 * Gets the map value for `key`.
3143 *
3144 * @private
3145 * @name get
3146 * @memberOf MapCache
3147 * @param {string} key The key of the value to get.
3148 * @returns {*} Returns the entry value.
3149 */
3150 function mapCacheGet(key) {
3151 return _getMapData(this, key).get(key);
3152 }
3153
3154 var _mapCacheGet = mapCacheGet;
3155
3156 /**
3157 * Checks if a map value for `key` exists.
3158 *
3159 * @private
3160 * @name has
3161 * @memberOf MapCache
3162 * @param {string} key The key of the entry to check.
3163 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3164 */
3165 function mapCacheHas(key) {
3166 return _getMapData(this, key).has(key);
3167 }
3168
3169 var _mapCacheHas = mapCacheHas;
3170
3171 /**
3172 * Sets the map `key` to `value`.
3173 *
3174 * @private
3175 * @name set
3176 * @memberOf MapCache
3177 * @param {string} key The key of the value to set.
3178 * @param {*} value The value to set.
3179 * @returns {Object} Returns the map cache instance.
3180 */
3181 function mapCacheSet(key, value) {
3182 var data = _getMapData(this, key),
3183 size = data.size;
3184
3185 data.set(key, value);
3186 this.size += data.size == size ? 0 : 1;
3187 return this;
3188 }
3189
3190 var _mapCacheSet = mapCacheSet;
3191
3192 /**
3193 * Creates a map cache object to store key-value pairs.
3194 *
3195 * @private
3196 * @constructor
3197 * @param {Array} [entries] The key-value pairs to cache.
3198 */
3199 function MapCache(entries) {
3200 var index = -1,
3201 length = entries == null ? 0 : entries.length;
3202
3203 this.clear();
3204 while (++index < length) {
3205 var entry = entries[index];
3206 this.set(entry[0], entry[1]);
3207 }
3208 }
3209
3210 // Add methods to `MapCache`.
3211 MapCache.prototype.clear = _mapCacheClear;
3212 MapCache.prototype['delete'] = _mapCacheDelete;
3213 MapCache.prototype.get = _mapCacheGet;
3214 MapCache.prototype.has = _mapCacheHas;
3215 MapCache.prototype.set = _mapCacheSet;
3216
3217 var _MapCache = MapCache;
3218
3219 /** Used as the size to enable large array optimizations. */
3220 var LARGE_ARRAY_SIZE = 200;
3221
3222 /**
3223 * Sets the stack `key` to `value`.
3224 *
3225 * @private
3226 * @name set
3227 * @memberOf Stack
3228 * @param {string} key The key of the value to set.
3229 * @param {*} value The value to set.
3230 * @returns {Object} Returns the stack cache instance.
3231 */
3232 function stackSet(key, value) {
3233 var data = this.__data__;
3234 if (data instanceof _ListCache) {
3235 var pairs = data.__data__;
3236 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
3237 pairs.push([key, value]);
3238 this.size = ++data.size;
3239 return this;
3240 }
3241 data = this.__data__ = new _MapCache(pairs);
3242 }
3243 data.set(key, value);
3244 this.size = data.size;
3245 return this;
3246 }
3247
3248 var _stackSet = stackSet;
3249
3250 /**
3251 * Creates a stack cache object to store key-value pairs.
3252 *
3253 * @private
3254 * @constructor
3255 * @param {Array} [entries] The key-value pairs to cache.
3256 */
3257 function Stack(entries) {
3258 var data = this.__data__ = new _ListCache(entries);
3259 this.size = data.size;
3260 }
3261
3262 // Add methods to `Stack`.
3263 Stack.prototype.clear = _stackClear;
3264 Stack.prototype['delete'] = _stackDelete;
3265 Stack.prototype.get = _stackGet;
3266 Stack.prototype.has = _stackHas;
3267 Stack.prototype.set = _stackSet;
3268
3269 var _Stack = Stack;
3270
3271 var defineProperty = (function() {
3272 try {
3273 var func = _getNative(Object, 'defineProperty');
3274 func({}, '', {});
3275 return func;
3276 } catch (e) {}
3277 }());
3278
3279 var _defineProperty$1 = defineProperty;
3280
3281 /**
3282 * The base implementation of `assignValue` and `assignMergeValue` without
3283 * value checks.
3284 *
3285 * @private
3286 * @param {Object} object The object to modify.
3287 * @param {string} key The key of the property to assign.
3288 * @param {*} value The value to assign.
3289 */
3290 function baseAssignValue(object, key, value) {
3291 if (key == '__proto__' && _defineProperty$1) {
3292 _defineProperty$1(object, key, {
3293 'configurable': true,
3294 'enumerable': true,
3295 'value': value,
3296 'writable': true
3297 });
3298 } else {
3299 object[key] = value;
3300 }
3301 }
3302
3303 var _baseAssignValue = baseAssignValue;
3304
3305 /**
3306 * This function is like `assignValue` except that it doesn't assign
3307 * `undefined` values.
3308 *
3309 * @private
3310 * @param {Object} object The object to modify.
3311 * @param {string} key The key of the property to assign.
3312 * @param {*} value The value to assign.
3313 */
3314 function assignMergeValue(object, key, value) {
3315 if ((value !== undefined && !eq_1(object[key], value)) ||
3316 (value === undefined && !(key in object))) {
3317 _baseAssignValue(object, key, value);
3318 }
3319 }
3320
3321 var _assignMergeValue = assignMergeValue;
3322
3323 /**
3324 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
3325 *
3326 * @private
3327 * @param {boolean} [fromRight] Specify iterating from right to left.
3328 * @returns {Function} Returns the new base function.
3329 */
3330 function createBaseFor(fromRight) {
3331 return function(object, iteratee, keysFunc) {
3332 var index = -1,
3333 iterable = Object(object),
3334 props = keysFunc(object),
3335 length = props.length;
3336
3337 while (length--) {
3338 var key = props[fromRight ? length : ++index];
3339 if (iteratee(iterable[key], key, iterable) === false) {
3340 break;
3341 }
3342 }
3343 return object;
3344 };
3345 }
3346
3347 var _createBaseFor = createBaseFor;
3348
3349 /**
3350 * The base implementation of `baseForOwn` which iterates over `object`
3351 * properties returned by `keysFunc` and invokes `iteratee` for each property.
3352 * Iteratee functions may exit iteration early by explicitly returning `false`.
3353 *
3354 * @private
3355 * @param {Object} object The object to iterate over.
3356 * @param {Function} iteratee The function invoked per iteration.
3357 * @param {Function} keysFunc The function to get the keys of `object`.
3358 * @returns {Object} Returns `object`.
3359 */
3360 var baseFor = _createBaseFor();
3361
3362 var _baseFor = baseFor;
3363
3364 var _cloneBuffer = createCommonjsModule(function (module, exports) {
3365 /** Detect free variable `exports`. */
3366 var freeExports = exports && !exports.nodeType && exports;
3367
3368 /** Detect free variable `module`. */
3369 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
3370
3371 /** Detect the popular CommonJS extension `module.exports`. */
3372 var moduleExports = freeModule && freeModule.exports === freeExports;
3373
3374 /** Built-in value references. */
3375 var Buffer = moduleExports ? _root.Buffer : undefined,
3376 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
3377
3378 /**
3379 * Creates a clone of `buffer`.
3380 *
3381 * @private
3382 * @param {Buffer} buffer The buffer to clone.
3383 * @param {boolean} [isDeep] Specify a deep clone.
3384 * @returns {Buffer} Returns the cloned buffer.
3385 */
3386 function cloneBuffer(buffer, isDeep) {
3387 if (isDeep) {
3388 return buffer.slice();
3389 }
3390 var length = buffer.length,
3391 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
3392
3393 buffer.copy(result);
3394 return result;
3395 }
3396
3397 module.exports = cloneBuffer;
3398 });
3399
3400 /** Built-in value references. */
3401 var Uint8Array = _root.Uint8Array;
3402
3403 var _Uint8Array = Uint8Array;
3404
3405 /**
3406 * Creates a clone of `arrayBuffer`.
3407 *
3408 * @private
3409 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
3410 * @returns {ArrayBuffer} Returns the cloned array buffer.
3411 */
3412 function cloneArrayBuffer(arrayBuffer) {
3413 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
3414 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
3415 return result;
3416 }
3417
3418 var _cloneArrayBuffer = cloneArrayBuffer;
3419
3420 /**
3421 * Creates a clone of `typedArray`.
3422 *
3423 * @private
3424 * @param {Object} typedArray The typed array to clone.
3425 * @param {boolean} [isDeep] Specify a deep clone.
3426 * @returns {Object} Returns the cloned typed array.
3427 */
3428 function cloneTypedArray(typedArray, isDeep) {
3429 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
3430 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
3431 }
3432
3433 var _cloneTypedArray = cloneTypedArray;
3434
3435 /**
3436 * Copies the values of `source` to `array`.
3437 *
3438 * @private
3439 * @param {Array} source The array to copy values from.
3440 * @param {Array} [array=[]] The array to copy values to.
3441 * @returns {Array} Returns `array`.
3442 */
3443 function copyArray(source, array) {
3444 var index = -1,
3445 length = source.length;
3446
3447 array || (array = Array(length));
3448 while (++index < length) {
3449 array[index] = source[index];
3450 }
3451 return array;
3452 }
3453
3454 var _copyArray = copyArray;
3455
3456 /** Built-in value references. */
3457 var objectCreate = Object.create;
3458
3459 /**
3460 * The base implementation of `_.create` without support for assigning
3461 * properties to the created object.
3462 *
3463 * @private
3464 * @param {Object} proto The object to inherit from.
3465 * @returns {Object} Returns the new object.
3466 */
3467 var baseCreate = (function() {
3468 function object() {}
3469 return function(proto) {
3470 if (!isObject_1(proto)) {
3471 return {};
3472 }
3473 if (objectCreate) {
3474 return objectCreate(proto);
3475 }
3476 object.prototype = proto;
3477 var result = new object;
3478 object.prototype = undefined;
3479 return result;
3480 };
3481 }());
3482
3483 var _baseCreate = baseCreate;
3484
3485 /**
3486 * Creates a unary function that invokes `func` with its argument transformed.
3487 *
3488 * @private
3489 * @param {Function} func The function to wrap.
3490 * @param {Function} transform The argument transform.
3491 * @returns {Function} Returns the new function.
3492 */
3493 function overArg(func, transform) {
3494 return function(arg) {
3495 return func(transform(arg));
3496 };
3497 }
3498
3499 var _overArg = overArg;
3500
3501 /** Built-in value references. */
3502 var getPrototype = _overArg(Object.getPrototypeOf, Object);
3503
3504 var _getPrototype = getPrototype;
3505
3506 /** Used for built-in method references. */
3507 var objectProto$5 = Object.prototype;
3508
3509 /**
3510 * Checks if `value` is likely a prototype object.
3511 *
3512 * @private
3513 * @param {*} value The value to check.
3514 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
3515 */
3516 function isPrototype(value) {
3517 var Ctor = value && value.constructor,
3518 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
3519
3520 return value === proto;
3521 }
3522
3523 var _isPrototype = isPrototype;
3524
3525 /**
3526 * Initializes an object clone.
3527 *
3528 * @private
3529 * @param {Object} object The object to clone.
3530 * @returns {Object} Returns the initialized clone.
3531 */
3532 function initCloneObject(object) {
3533 return (typeof object.constructor == 'function' && !_isPrototype(object))
3534 ? _baseCreate(_getPrototype(object))
3535 : {};
3536 }
3537
3538 var _initCloneObject = initCloneObject;
3539
3540 /**
3541 * Checks if `value` is object-like. A value is object-like if it's not `null`
3542 * and has a `typeof` result of "object".
3543 *
3544 * @static
3545 * @memberOf _
3546 * @since 4.0.0
3547 * @category Lang
3548 * @param {*} value The value to check.
3549 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3550 * @example
3551 *
3552 * _.isObjectLike({});
3553 * // => true
3554 *
3555 * _.isObjectLike([1, 2, 3]);
3556 * // => true
3557 *
3558 * _.isObjectLike(_.noop);
3559 * // => false
3560 *
3561 * _.isObjectLike(null);
3562 * // => false
3563 */
3564 function isObjectLike(value) {
3565 return value != null && typeof value == 'object';
3566 }
3567
3568 var isObjectLike_1 = isObjectLike;
3569
3570 /** `Object#toString` result references. */
3571 var argsTag = '[object Arguments]';
3572
3573 /**
3574 * The base implementation of `_.isArguments`.
3575 *
3576 * @private
3577 * @param {*} value The value to check.
3578 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3579 */
3580 function baseIsArguments(value) {
3581 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
3582 }
3583
3584 var _baseIsArguments = baseIsArguments;
3585
3586 /** Used for built-in method references. */
3587 var objectProto$6 = Object.prototype;
3588
3589 /** Used to check objects for own properties. */
3590 var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
3591
3592 /** Built-in value references. */
3593 var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
3594
3595 /**
3596 * Checks if `value` is likely an `arguments` object.
3597 *
3598 * @static
3599 * @memberOf _
3600 * @since 0.1.0
3601 * @category Lang
3602 * @param {*} value The value to check.
3603 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3604 * else `false`.
3605 * @example
3606 *
3607 * _.isArguments(function() { return arguments; }());
3608 * // => true
3609 *
3610 * _.isArguments([1, 2, 3]);
3611 * // => false
3612 */
3613 var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
3614 return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') &&
3615 !propertyIsEnumerable.call(value, 'callee');
3616 };
3617
3618 var isArguments_1 = isArguments;
3619
3620 /**
3621 * Checks if `value` is classified as an `Array` object.
3622 *
3623 * @static
3624 * @memberOf _
3625 * @since 0.1.0
3626 * @category Lang
3627 * @param {*} value The value to check.
3628 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3629 * @example
3630 *
3631 * _.isArray([1, 2, 3]);
3632 * // => true
3633 *
3634 * _.isArray(document.body.children);
3635 * // => false
3636 *
3637 * _.isArray('abc');
3638 * // => false
3639 *
3640 * _.isArray(_.noop);
3641 * // => false
3642 */
3643 var isArray = Array.isArray;
3644
3645 var isArray_1 = isArray;
3646
3647 /** Used as references for various `Number` constants. */
3648 var MAX_SAFE_INTEGER = 9007199254740991;
3649
3650 /**
3651 * Checks if `value` is a valid array-like length.
3652 *
3653 * **Note:** This method is loosely based on
3654 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3655 *
3656 * @static
3657 * @memberOf _
3658 * @since 4.0.0
3659 * @category Lang
3660 * @param {*} value The value to check.
3661 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3662 * @example
3663 *
3664 * _.isLength(3);
3665 * // => true
3666 *
3667 * _.isLength(Number.MIN_VALUE);
3668 * // => false
3669 *
3670 * _.isLength(Infinity);
3671 * // => false
3672 *
3673 * _.isLength('3');
3674 * // => false
3675 */
3676 function isLength(value) {
3677 return typeof value == 'number' &&
3678 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3679 }
3680
3681 var isLength_1 = isLength;
3682
3683 /**
3684 * Checks if `value` is array-like. A value is considered array-like if it's
3685 * not a function and has a `value.length` that's an integer greater than or
3686 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3687 *
3688 * @static
3689 * @memberOf _
3690 * @since 4.0.0
3691 * @category Lang
3692 * @param {*} value The value to check.
3693 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3694 * @example
3695 *
3696 * _.isArrayLike([1, 2, 3]);
3697 * // => true
3698 *
3699 * _.isArrayLike(document.body.children);
3700 * // => true
3701 *
3702 * _.isArrayLike('abc');
3703 * // => true
3704 *
3705 * _.isArrayLike(_.noop);
3706 * // => false
3707 */
3708 function isArrayLike(value) {
3709 return value != null && isLength_1(value.length) && !isFunction_1(value);
3710 }
3711
3712 var isArrayLike_1 = isArrayLike;
3713
3714 /**
3715 * This method is like `_.isArrayLike` except that it also checks if `value`
3716 * is an object.
3717 *
3718 * @static
3719 * @memberOf _
3720 * @since 4.0.0
3721 * @category Lang
3722 * @param {*} value The value to check.
3723 * @returns {boolean} Returns `true` if `value` is an array-like object,
3724 * else `false`.
3725 * @example
3726 *
3727 * _.isArrayLikeObject([1, 2, 3]);
3728 * // => true
3729 *
3730 * _.isArrayLikeObject(document.body.children);
3731 * // => true
3732 *
3733 * _.isArrayLikeObject('abc');
3734 * // => false
3735 *
3736 * _.isArrayLikeObject(_.noop);
3737 * // => false
3738 */
3739 function isArrayLikeObject(value) {
3740 return isObjectLike_1(value) && isArrayLike_1(value);
3741 }
3742
3743 var isArrayLikeObject_1 = isArrayLikeObject;
3744
3745 /**
3746 * This method returns `false`.
3747 *
3748 * @static
3749 * @memberOf _
3750 * @since 4.13.0
3751 * @category Util
3752 * @returns {boolean} Returns `false`.
3753 * @example
3754 *
3755 * _.times(2, _.stubFalse);
3756 * // => [false, false]
3757 */
3758 function stubFalse() {
3759 return false;
3760 }
3761
3762 var stubFalse_1 = stubFalse;
3763
3764 var isBuffer_1 = createCommonjsModule(function (module, exports) {
3765 /** Detect free variable `exports`. */
3766 var freeExports = exports && !exports.nodeType && exports;
3767
3768 /** Detect free variable `module`. */
3769 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
3770
3771 /** Detect the popular CommonJS extension `module.exports`. */
3772 var moduleExports = freeModule && freeModule.exports === freeExports;
3773
3774 /** Built-in value references. */
3775 var Buffer = moduleExports ? _root.Buffer : undefined;
3776
3777 /* Built-in method references for those with the same name as other `lodash` methods. */
3778 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
3779
3780 /**
3781 * Checks if `value` is a buffer.
3782 *
3783 * @static
3784 * @memberOf _
3785 * @since 4.3.0
3786 * @category Lang
3787 * @param {*} value The value to check.
3788 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
3789 * @example
3790 *
3791 * _.isBuffer(new Buffer(2));
3792 * // => true
3793 *
3794 * _.isBuffer(new Uint8Array(2));
3795 * // => false
3796 */
3797 var isBuffer = nativeIsBuffer || stubFalse_1;
3798
3799 module.exports = isBuffer;
3800 });
3801
3802 /** `Object#toString` result references. */
3803 var objectTag = '[object Object]';
3804
3805 /** Used for built-in method references. */
3806 var funcProto$2 = Function.prototype,
3807 objectProto$7 = Object.prototype;
3808
3809 /** Used to resolve the decompiled source of functions. */
3810 var funcToString$2 = funcProto$2.toString;
3811
3812 /** Used to check objects for own properties. */
3813 var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
3814
3815 /** Used to infer the `Object` constructor. */
3816 var objectCtorString = funcToString$2.call(Object);
3817
3818 /**
3819 * Checks if `value` is a plain object, that is, an object created by the
3820 * `Object` constructor or one with a `[[Prototype]]` of `null`.
3821 *
3822 * @static
3823 * @memberOf _
3824 * @since 0.8.0
3825 * @category Lang
3826 * @param {*} value The value to check.
3827 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
3828 * @example
3829 *
3830 * function Foo() {
3831 * this.a = 1;
3832 * }
3833 *
3834 * _.isPlainObject(new Foo);
3835 * // => false
3836 *
3837 * _.isPlainObject([1, 2, 3]);
3838 * // => false
3839 *
3840 * _.isPlainObject({ 'x': 0, 'y': 0 });
3841 * // => true
3842 *
3843 * _.isPlainObject(Object.create(null));
3844 * // => true
3845 */
3846 function isPlainObject(value) {
3847 if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
3848 return false;
3849 }
3850 var proto = _getPrototype(value);
3851 if (proto === null) {
3852 return true;
3853 }
3854 var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor;
3855 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
3856 funcToString$2.call(Ctor) == objectCtorString;
3857 }
3858
3859 var isPlainObject_1 = isPlainObject;
3860
3861 /** `Object#toString` result references. */
3862 var argsTag$1 = '[object Arguments]',
3863 arrayTag = '[object Array]',
3864 boolTag = '[object Boolean]',
3865 dateTag = '[object Date]',
3866 errorTag = '[object Error]',
3867 funcTag$1 = '[object Function]',
3868 mapTag = '[object Map]',
3869 numberTag = '[object Number]',
3870 objectTag$1 = '[object Object]',
3871 regexpTag = '[object RegExp]',
3872 setTag = '[object Set]',
3873 stringTag = '[object String]',
3874 weakMapTag = '[object WeakMap]';
3875
3876 var arrayBufferTag = '[object ArrayBuffer]',
3877 dataViewTag = '[object DataView]',
3878 float32Tag = '[object Float32Array]',
3879 float64Tag = '[object Float64Array]',
3880 int8Tag = '[object Int8Array]',
3881 int16Tag = '[object Int16Array]',
3882 int32Tag = '[object Int32Array]',
3883 uint8Tag = '[object Uint8Array]',
3884 uint8ClampedTag = '[object Uint8ClampedArray]',
3885 uint16Tag = '[object Uint16Array]',
3886 uint32Tag = '[object Uint32Array]';
3887
3888 /** Used to identify `toStringTag` values of typed arrays. */
3889 var typedArrayTags = {};
3890 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
3891 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
3892 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
3893 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
3894 typedArrayTags[uint32Tag] = true;
3895 typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
3896 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
3897 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
3898 typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
3899 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
3900 typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
3901 typedArrayTags[setTag] = typedArrayTags[stringTag] =
3902 typedArrayTags[weakMapTag] = false;
3903
3904 /**
3905 * The base implementation of `_.isTypedArray` without Node.js optimizations.
3906 *
3907 * @private
3908 * @param {*} value The value to check.
3909 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3910 */
3911 function baseIsTypedArray(value) {
3912 return isObjectLike_1(value) &&
3913 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
3914 }
3915
3916 var _baseIsTypedArray = baseIsTypedArray;
3917
3918 /**
3919 * The base implementation of `_.unary` without support for storing metadata.
3920 *
3921 * @private
3922 * @param {Function} func The function to cap arguments for.
3923 * @returns {Function} Returns the new capped function.
3924 */
3925 function baseUnary(func) {
3926 return function(value) {
3927 return func(value);
3928 };
3929 }
3930
3931 var _baseUnary = baseUnary;
3932
3933 var _nodeUtil = createCommonjsModule(function (module, exports) {
3934 /** Detect free variable `exports`. */
3935 var freeExports = exports && !exports.nodeType && exports;
3936
3937 /** Detect free variable `module`. */
3938 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
3939
3940 /** Detect the popular CommonJS extension `module.exports`. */
3941 var moduleExports = freeModule && freeModule.exports === freeExports;
3942
3943 /** Detect free variable `process` from Node.js. */
3944 var freeProcess = moduleExports && _freeGlobal.process;
3945
3946 /** Used to access faster Node.js helpers. */
3947 var nodeUtil = (function() {
3948 try {
3949 // Use `util.types` for Node.js 10+.
3950 var types = freeModule && freeModule.require && freeModule.require('util').types;
3951
3952 if (types) {
3953 return types;
3954 }
3955
3956 // Legacy `process.binding('util')` for Node.js < 10.
3957 return freeProcess && freeProcess.binding && freeProcess.binding('util');
3958 } catch (e) {}
3959 }());
3960
3961 module.exports = nodeUtil;
3962 });
3963
3964 /* Node.js helper references. */
3965 var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
3966
3967 /**
3968 * Checks if `value` is classified as a typed array.
3969 *
3970 * @static
3971 * @memberOf _
3972 * @since 3.0.0
3973 * @category Lang
3974 * @param {*} value The value to check.
3975 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3976 * @example
3977 *
3978 * _.isTypedArray(new Uint8Array);
3979 * // => true
3980 *
3981 * _.isTypedArray([]);
3982 * // => false
3983 */
3984 var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
3985
3986 var isTypedArray_1 = isTypedArray;
3987
3988 /**
3989 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
3990 *
3991 * @private
3992 * @param {Object} object The object to query.
3993 * @param {string} key The key of the property to get.
3994 * @returns {*} Returns the property value.
3995 */
3996 function safeGet(object, key) {
3997 if (key === 'constructor' && typeof object[key] === 'function') {
3998 return;
3999 }
4000
4001 if (key == '__proto__') {
4002 return;
4003 }
4004
4005 return object[key];
4006 }
4007
4008 var _safeGet = safeGet;
4009
4010 /** Used for built-in method references. */
4011 var objectProto$8 = Object.prototype;
4012
4013 /** Used to check objects for own properties. */
4014 var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
4015
4016 /**
4017 * Assigns `value` to `key` of `object` if the existing value is not equivalent
4018 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
4019 * for equality comparisons.
4020 *
4021 * @private
4022 * @param {Object} object The object to modify.
4023 * @param {string} key The key of the property to assign.
4024 * @param {*} value The value to assign.
4025 */
4026 function assignValue(object, key, value) {
4027 var objValue = object[key];
4028 if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) ||
4029 (value === undefined && !(key in object))) {
4030 _baseAssignValue(object, key, value);
4031 }
4032 }
4033
4034 var _assignValue = assignValue;
4035
4036 /**
4037 * Copies properties of `source` to `object`.
4038 *
4039 * @private
4040 * @param {Object} source The object to copy properties from.
4041 * @param {Array} props The property identifiers to copy.
4042 * @param {Object} [object={}] The object to copy properties to.
4043 * @param {Function} [customizer] The function to customize copied values.
4044 * @returns {Object} Returns `object`.
4045 */
4046 function copyObject(source, props, object, customizer) {
4047 var isNew = !object;
4048 object || (object = {});
4049
4050 var index = -1,
4051 length = props.length;
4052
4053 while (++index < length) {
4054 var key = props[index];
4055
4056 var newValue = customizer
4057 ? customizer(object[key], source[key], key, object, source)
4058 : undefined;
4059
4060 if (newValue === undefined) {
4061 newValue = source[key];
4062 }
4063 if (isNew) {
4064 _baseAssignValue(object, key, newValue);
4065 } else {
4066 _assignValue(object, key, newValue);
4067 }
4068 }
4069 return object;
4070 }
4071
4072 var _copyObject = copyObject;
4073
4074 /**
4075 * The base implementation of `_.times` without support for iteratee shorthands
4076 * or max array length checks.
4077 *
4078 * @private
4079 * @param {number} n The number of times to invoke `iteratee`.
4080 * @param {Function} iteratee The function invoked per iteration.
4081 * @returns {Array} Returns the array of results.
4082 */
4083 function baseTimes(n, iteratee) {
4084 var index = -1,
4085 result = Array(n);
4086
4087 while (++index < n) {
4088 result[index] = iteratee(index);
4089 }
4090 return result;
4091 }
4092
4093 var _baseTimes = baseTimes;
4094
4095 /** Used as references for various `Number` constants. */
4096 var MAX_SAFE_INTEGER$1 = 9007199254740991;
4097
4098 /** Used to detect unsigned integer values. */
4099 var reIsUint = /^(?:0|[1-9]\d*)$/;
4100
4101 /**
4102 * Checks if `value` is a valid array-like index.
4103 *
4104 * @private
4105 * @param {*} value The value to check.
4106 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
4107 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
4108 */
4109 function isIndex(value, length) {
4110 var type = typeof value;
4111 length = length == null ? MAX_SAFE_INTEGER$1 : length;
4112
4113 return !!length &&
4114 (type == 'number' ||
4115 (type != 'symbol' && reIsUint.test(value))) &&
4116 (value > -1 && value % 1 == 0 && value < length);
4117 }
4118
4119 var _isIndex = isIndex;
4120
4121 /** Used for built-in method references. */
4122 var objectProto$9 = Object.prototype;
4123
4124 /** Used to check objects for own properties. */
4125 var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
4126
4127 /**
4128 * Creates an array of the enumerable property names of the array-like `value`.
4129 *
4130 * @private
4131 * @param {*} value The value to query.
4132 * @param {boolean} inherited Specify returning inherited property names.
4133 * @returns {Array} Returns the array of property names.
4134 */
4135 function arrayLikeKeys(value, inherited) {
4136 var isArr = isArray_1(value),
4137 isArg = !isArr && isArguments_1(value),
4138 isBuff = !isArr && !isArg && isBuffer_1(value),
4139 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
4140 skipIndexes = isArr || isArg || isBuff || isType,
4141 result = skipIndexes ? _baseTimes(value.length, String) : [],
4142 length = result.length;
4143
4144 for (var key in value) {
4145 if ((inherited || hasOwnProperty$7.call(value, key)) &&
4146 !(skipIndexes && (
4147 // Safari 9 has enumerable `arguments.length` in strict mode.
4148 key == 'length' ||
4149 // Node.js 0.10 has enumerable non-index properties on buffers.
4150 (isBuff && (key == 'offset' || key == 'parent')) ||
4151 // PhantomJS 2 has enumerable non-index properties on typed arrays.
4152 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
4153 // Skip index properties.
4154 _isIndex(key, length)
4155 ))) {
4156 result.push(key);
4157 }
4158 }
4159 return result;
4160 }
4161
4162 var _arrayLikeKeys = arrayLikeKeys;
4163
4164 /**
4165 * This function is like
4166 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
4167 * except that it includes inherited enumerable properties.
4168 *
4169 * @private
4170 * @param {Object} object The object to query.
4171 * @returns {Array} Returns the array of property names.
4172 */
4173 function nativeKeysIn(object) {
4174 var result = [];
4175 if (object != null) {
4176 for (var key in Object(object)) {
4177 result.push(key);
4178 }
4179 }
4180 return result;
4181 }
4182
4183 var _nativeKeysIn = nativeKeysIn;
4184
4185 /** Used for built-in method references. */
4186 var objectProto$a = Object.prototype;
4187
4188 /** Used to check objects for own properties. */
4189 var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
4190
4191 /**
4192 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
4193 *
4194 * @private
4195 * @param {Object} object The object to query.
4196 * @returns {Array} Returns the array of property names.
4197 */
4198 function baseKeysIn(object) {
4199 if (!isObject_1(object)) {
4200 return _nativeKeysIn(object);
4201 }
4202 var isProto = _isPrototype(object),
4203 result = [];
4204
4205 for (var key in object) {
4206 if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
4207 result.push(key);
4208 }
4209 }
4210 return result;
4211 }
4212
4213 var _baseKeysIn = baseKeysIn;
4214
4215 /**
4216 * Creates an array of the own and inherited enumerable property names of `object`.
4217 *
4218 * **Note:** Non-object values are coerced to objects.
4219 *
4220 * @static
4221 * @memberOf _
4222 * @since 3.0.0
4223 * @category Object
4224 * @param {Object} object The object to query.
4225 * @returns {Array} Returns the array of property names.
4226 * @example
4227 *
4228 * function Foo() {
4229 * this.a = 1;
4230 * this.b = 2;
4231 * }
4232 *
4233 * Foo.prototype.c = 3;
4234 *
4235 * _.keysIn(new Foo);
4236 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
4237 */
4238 function keysIn(object) {
4239 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
4240 }
4241
4242 var keysIn_1 = keysIn;
4243
4244 /**
4245 * Converts `value` to a plain object flattening inherited enumerable string
4246 * keyed properties of `value` to own properties of the plain object.
4247 *
4248 * @static
4249 * @memberOf _
4250 * @since 3.0.0
4251 * @category Lang
4252 * @param {*} value The value to convert.
4253 * @returns {Object} Returns the converted plain object.
4254 * @example
4255 *
4256 * function Foo() {
4257 * this.b = 2;
4258 * }
4259 *
4260 * Foo.prototype.c = 3;
4261 *
4262 * _.assign({ 'a': 1 }, new Foo);
4263 * // => { 'a': 1, 'b': 2 }
4264 *
4265 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
4266 * // => { 'a': 1, 'b': 2, 'c': 3 }
4267 */
4268 function toPlainObject(value) {
4269 return _copyObject(value, keysIn_1(value));
4270 }
4271
4272 var toPlainObject_1 = toPlainObject;
4273
4274 /**
4275 * A specialized version of `baseMerge` for arrays and objects which performs
4276 * deep merges and tracks traversed objects enabling objects with circular
4277 * references to be merged.
4278 *
4279 * @private
4280 * @param {Object} object The destination object.
4281 * @param {Object} source The source object.
4282 * @param {string} key The key of the value to merge.
4283 * @param {number} srcIndex The index of `source`.
4284 * @param {Function} mergeFunc The function to merge values.
4285 * @param {Function} [customizer] The function to customize assigned values.
4286 * @param {Object} [stack] Tracks traversed source values and their merged
4287 * counterparts.
4288 */
4289 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
4290 var objValue = _safeGet(object, key),
4291 srcValue = _safeGet(source, key),
4292 stacked = stack.get(srcValue);
4293
4294 if (stacked) {
4295 _assignMergeValue(object, key, stacked);
4296 return;
4297 }
4298 var newValue = customizer
4299 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
4300 : undefined;
4301
4302 var isCommon = newValue === undefined;
4303
4304 if (isCommon) {
4305 var isArr = isArray_1(srcValue),
4306 isBuff = !isArr && isBuffer_1(srcValue),
4307 isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
4308
4309 newValue = srcValue;
4310 if (isArr || isBuff || isTyped) {
4311 if (isArray_1(objValue)) {
4312 newValue = objValue;
4313 }
4314 else if (isArrayLikeObject_1(objValue)) {
4315 newValue = _copyArray(objValue);
4316 }
4317 else if (isBuff) {
4318 isCommon = false;
4319 newValue = _cloneBuffer(srcValue, true);
4320 }
4321 else if (isTyped) {
4322 isCommon = false;
4323 newValue = _cloneTypedArray(srcValue, true);
4324 }
4325 else {
4326 newValue = [];
4327 }
4328 }
4329 else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
4330 newValue = objValue;
4331 if (isArguments_1(objValue)) {
4332 newValue = toPlainObject_1(objValue);
4333 }
4334 else if (!isObject_1(objValue) || isFunction_1(objValue)) {
4335 newValue = _initCloneObject(srcValue);
4336 }
4337 }
4338 else {
4339 isCommon = false;
4340 }
4341 }
4342 if (isCommon) {
4343 // Recursively merge objects and arrays (susceptible to call stack limits).
4344 stack.set(srcValue, newValue);
4345 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
4346 stack['delete'](srcValue);
4347 }
4348 _assignMergeValue(object, key, newValue);
4349 }
4350
4351 var _baseMergeDeep = baseMergeDeep;
4352
4353 /**
4354 * The base implementation of `_.merge` without support for multiple sources.
4355 *
4356 * @private
4357 * @param {Object} object The destination object.
4358 * @param {Object} source The source object.
4359 * @param {number} srcIndex The index of `source`.
4360 * @param {Function} [customizer] The function to customize merged values.
4361 * @param {Object} [stack] Tracks traversed source values and their merged
4362 * counterparts.
4363 */
4364 function baseMerge(object, source, srcIndex, customizer, stack) {
4365 if (object === source) {
4366 return;
4367 }
4368 _baseFor(source, function(srcValue, key) {
4369 stack || (stack = new _Stack);
4370 if (isObject_1(srcValue)) {
4371 _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
4372 }
4373 else {
4374 var newValue = customizer
4375 ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
4376 : undefined;
4377
4378 if (newValue === undefined) {
4379 newValue = srcValue;
4380 }
4381 _assignMergeValue(object, key, newValue);
4382 }
4383 }, keysIn_1);
4384 }
4385
4386 var _baseMerge = baseMerge;
4387
4388 /**
4389 * This method returns the first argument it receives.
4390 *
4391 * @static
4392 * @since 0.1.0
4393 * @memberOf _
4394 * @category Util
4395 * @param {*} value Any value.
4396 * @returns {*} Returns `value`.
4397 * @example
4398 *
4399 * var object = { 'a': 1 };
4400 *
4401 * console.log(_.identity(object) === object);
4402 * // => true
4403 */
4404 function identity(value) {
4405 return value;
4406 }
4407
4408 var identity_1 = identity;
4409
4410 /**
4411 * A faster alternative to `Function#apply`, this function invokes `func`
4412 * with the `this` binding of `thisArg` and the arguments of `args`.
4413 *
4414 * @private
4415 * @param {Function} func The function to invoke.
4416 * @param {*} thisArg The `this` binding of `func`.
4417 * @param {Array} args The arguments to invoke `func` with.
4418 * @returns {*} Returns the result of `func`.
4419 */
4420 function apply(func, thisArg, args) {
4421 switch (args.length) {
4422 case 0: return func.call(thisArg);
4423 case 1: return func.call(thisArg, args[0]);
4424 case 2: return func.call(thisArg, args[0], args[1]);
4425 case 3: return func.call(thisArg, args[0], args[1], args[2]);
4426 }
4427 return func.apply(thisArg, args);
4428 }
4429
4430 var _apply = apply;
4431
4432 /* Built-in method references for those with the same name as other `lodash` methods. */
4433 var nativeMax = Math.max;
4434
4435 /**
4436 * A specialized version of `baseRest` which transforms the rest array.
4437 *
4438 * @private
4439 * @param {Function} func The function to apply a rest parameter to.
4440 * @param {number} [start=func.length-1] The start position of the rest parameter.
4441 * @param {Function} transform The rest array transform.
4442 * @returns {Function} Returns the new function.
4443 */
4444 function overRest(func, start, transform) {
4445 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
4446 return function() {
4447 var args = arguments,
4448 index = -1,
4449 length = nativeMax(args.length - start, 0),
4450 array = Array(length);
4451
4452 while (++index < length) {
4453 array[index] = args[start + index];
4454 }
4455 index = -1;
4456 var otherArgs = Array(start + 1);
4457 while (++index < start) {
4458 otherArgs[index] = args[index];
4459 }
4460 otherArgs[start] = transform(array);
4461 return _apply(func, this, otherArgs);
4462 };
4463 }
4464
4465 var _overRest = overRest;
4466
4467 /**
4468 * Creates a function that returns `value`.
4469 *
4470 * @static
4471 * @memberOf _
4472 * @since 2.4.0
4473 * @category Util
4474 * @param {*} value The value to return from the new function.
4475 * @returns {Function} Returns the new constant function.
4476 * @example
4477 *
4478 * var objects = _.times(2, _.constant({ 'a': 1 }));
4479 *
4480 * console.log(objects);
4481 * // => [{ 'a': 1 }, { 'a': 1 }]
4482 *
4483 * console.log(objects[0] === objects[1]);
4484 * // => true
4485 */
4486 function constant(value) {
4487 return function() {
4488 return value;
4489 };
4490 }
4491
4492 var constant_1 = constant;
4493
4494 /**
4495 * The base implementation of `setToString` without support for hot loop shorting.
4496 *
4497 * @private
4498 * @param {Function} func The function to modify.
4499 * @param {Function} string The `toString` result.
4500 * @returns {Function} Returns `func`.
4501 */
4502 var baseSetToString = !_defineProperty$1 ? identity_1 : function(func, string) {
4503 return _defineProperty$1(func, 'toString', {
4504 'configurable': true,
4505 'enumerable': false,
4506 'value': constant_1(string),
4507 'writable': true
4508 });
4509 };
4510
4511 var _baseSetToString = baseSetToString;
4512
4513 /** Used to detect hot functions by number of calls within a span of milliseconds. */
4514 var HOT_COUNT = 800,
4515 HOT_SPAN = 16;
4516
4517 /* Built-in method references for those with the same name as other `lodash` methods. */
4518 var nativeNow = Date.now;
4519
4520 /**
4521 * Creates a function that'll short out and invoke `identity` instead
4522 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
4523 * milliseconds.
4524 *
4525 * @private
4526 * @param {Function} func The function to restrict.
4527 * @returns {Function} Returns the new shortable function.
4528 */
4529 function shortOut(func) {
4530 var count = 0,
4531 lastCalled = 0;
4532
4533 return function() {
4534 var stamp = nativeNow(),
4535 remaining = HOT_SPAN - (stamp - lastCalled);
4536
4537 lastCalled = stamp;
4538 if (remaining > 0) {
4539 if (++count >= HOT_COUNT) {
4540 return arguments[0];
4541 }
4542 } else {
4543 count = 0;
4544 }
4545 return func.apply(undefined, arguments);
4546 };
4547 }
4548
4549 var _shortOut = shortOut;
4550
4551 /**
4552 * Sets the `toString` method of `func` to return `string`.
4553 *
4554 * @private
4555 * @param {Function} func The function to modify.
4556 * @param {Function} string The `toString` result.
4557 * @returns {Function} Returns `func`.
4558 */
4559 var setToString = _shortOut(_baseSetToString);
4560
4561 var _setToString = setToString;
4562
4563 /**
4564 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
4565 *
4566 * @private
4567 * @param {Function} func The function to apply a rest parameter to.
4568 * @param {number} [start=func.length-1] The start position of the rest parameter.
4569 * @returns {Function} Returns the new function.
4570 */
4571 function baseRest(func, start) {
4572 return _setToString(_overRest(func, start, identity_1), func + '');
4573 }
4574
4575 var _baseRest = baseRest;
4576
4577 /**
4578 * Checks if the given arguments are from an iteratee call.
4579 *
4580 * @private
4581 * @param {*} value The potential iteratee value argument.
4582 * @param {*} index The potential iteratee index or key argument.
4583 * @param {*} object The potential iteratee object argument.
4584 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
4585 * else `false`.
4586 */
4587 function isIterateeCall(value, index, object) {
4588 if (!isObject_1(object)) {
4589 return false;
4590 }
4591 var type = typeof index;
4592 if (type == 'number'
4593 ? (isArrayLike_1(object) && _isIndex(index, object.length))
4594 : (type == 'string' && index in object)
4595 ) {
4596 return eq_1(object[index], value);
4597 }
4598 return false;
4599 }
4600
4601 var _isIterateeCall = isIterateeCall;
4602
4603 /**
4604 * Creates a function like `_.assign`.
4605 *
4606 * @private
4607 * @param {Function} assigner The function to assign values.
4608 * @returns {Function} Returns the new assigner function.
4609 */
4610 function createAssigner(assigner) {
4611 return _baseRest(function(object, sources) {
4612 var index = -1,
4613 length = sources.length,
4614 customizer = length > 1 ? sources[length - 1] : undefined,
4615 guard = length > 2 ? sources[2] : undefined;
4616
4617 customizer = (assigner.length > 3 && typeof customizer == 'function')
4618 ? (length--, customizer)
4619 : undefined;
4620
4621 if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
4622 customizer = length < 3 ? undefined : customizer;
4623 length = 1;
4624 }
4625 object = Object(object);
4626 while (++index < length) {
4627 var source = sources[index];
4628 if (source) {
4629 assigner(object, source, index, customizer);
4630 }
4631 }
4632 return object;
4633 });
4634 }
4635
4636 var _createAssigner = createAssigner;
4637
4638 /**
4639 * This method is like `_.assign` except that it recursively merges own and
4640 * inherited enumerable string keyed properties of source objects into the
4641 * destination object. Source properties that resolve to `undefined` are
4642 * skipped if a destination value exists. Array and plain object properties
4643 * are merged recursively. Other objects and value types are overridden by
4644 * assignment. Source objects are applied from left to right. Subsequent
4645 * sources overwrite property assignments of previous sources.
4646 *
4647 * **Note:** This method mutates `object`.
4648 *
4649 * @static
4650 * @memberOf _
4651 * @since 0.5.0
4652 * @category Object
4653 * @param {Object} object The destination object.
4654 * @param {...Object} [sources] The source objects.
4655 * @returns {Object} Returns `object`.
4656 * @example
4657 *
4658 * var object = {
4659 * 'a': [{ 'b': 2 }, { 'd': 4 }]
4660 * };
4661 *
4662 * var other = {
4663 * 'a': [{ 'c': 3 }, { 'e': 5 }]
4664 * };
4665 *
4666 * _.merge(object, other);
4667 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
4668 */
4669 var merge = _createAssigner(function(object, source, srcIndex) {
4670 _baseMerge(object, source, srcIndex);
4671 });
4672
4673 var merge_1 = merge;
4674
4675 /**
4676 * A specialized version of `_.forEach` for arrays without support for
4677 * iteratee shorthands.
4678 *
4679 * @private
4680 * @param {Array} [array] The array to iterate over.
4681 * @param {Function} iteratee The function invoked per iteration.
4682 * @returns {Array} Returns `array`.
4683 */
4684 function arrayEach(array, iteratee) {
4685 var index = -1,
4686 length = array == null ? 0 : array.length;
4687
4688 while (++index < length) {
4689 if (iteratee(array[index], index, array) === false) {
4690 break;
4691 }
4692 }
4693 return array;
4694 }
4695
4696 var _arrayEach = arrayEach;
4697
4698 /* Built-in method references for those with the same name as other `lodash` methods. */
4699 var nativeKeys = _overArg(Object.keys, Object);
4700
4701 var _nativeKeys = nativeKeys;
4702
4703 /** Used for built-in method references. */
4704 var objectProto$b = Object.prototype;
4705
4706 /** Used to check objects for own properties. */
4707 var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
4708
4709 /**
4710 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
4711 *
4712 * @private
4713 * @param {Object} object The object to query.
4714 * @returns {Array} Returns the array of property names.
4715 */
4716 function baseKeys(object) {
4717 if (!_isPrototype(object)) {
4718 return _nativeKeys(object);
4719 }
4720 var result = [];
4721 for (var key in Object(object)) {
4722 if (hasOwnProperty$9.call(object, key) && key != 'constructor') {
4723 result.push(key);
4724 }
4725 }
4726 return result;
4727 }
4728
4729 var _baseKeys = baseKeys;
4730
4731 /**
4732 * Creates an array of the own enumerable property names of `object`.
4733 *
4734 * **Note:** Non-object values are coerced to objects. See the
4735 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
4736 * for more details.
4737 *
4738 * @static
4739 * @since 0.1.0
4740 * @memberOf _
4741 * @category Object
4742 * @param {Object} object The object to query.
4743 * @returns {Array} Returns the array of property names.
4744 * @example
4745 *
4746 * function Foo() {
4747 * this.a = 1;
4748 * this.b = 2;
4749 * }
4750 *
4751 * Foo.prototype.c = 3;
4752 *
4753 * _.keys(new Foo);
4754 * // => ['a', 'b'] (iteration order is not guaranteed)
4755 *
4756 * _.keys('hi');
4757 * // => ['0', '1']
4758 */
4759 function keys(object) {
4760 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
4761 }
4762
4763 var keys_1 = keys;
4764
4765 /**
4766 * The base implementation of `_.assign` without support for multiple sources
4767 * or `customizer` functions.
4768 *
4769 * @private
4770 * @param {Object} object The destination object.
4771 * @param {Object} source The source object.
4772 * @returns {Object} Returns `object`.
4773 */
4774 function baseAssign(object, source) {
4775 return object && _copyObject(source, keys_1(source), object);
4776 }
4777
4778 var _baseAssign = baseAssign;
4779
4780 /**
4781 * The base implementation of `_.assignIn` without support for multiple sources
4782 * or `customizer` functions.
4783 *
4784 * @private
4785 * @param {Object} object The destination object.
4786 * @param {Object} source The source object.
4787 * @returns {Object} Returns `object`.
4788 */
4789 function baseAssignIn(object, source) {
4790 return object && _copyObject(source, keysIn_1(source), object);
4791 }
4792
4793 var _baseAssignIn = baseAssignIn;
4794
4795 /**
4796 * A specialized version of `_.filter` for arrays without support for
4797 * iteratee shorthands.
4798 *
4799 * @private
4800 * @param {Array} [array] The array to iterate over.
4801 * @param {Function} predicate The function invoked per iteration.
4802 * @returns {Array} Returns the new filtered array.
4803 */
4804 function arrayFilter(array, predicate) {
4805 var index = -1,
4806 length = array == null ? 0 : array.length,
4807 resIndex = 0,
4808 result = [];
4809
4810 while (++index < length) {
4811 var value = array[index];
4812 if (predicate(value, index, array)) {
4813 result[resIndex++] = value;
4814 }
4815 }
4816 return result;
4817 }
4818
4819 var _arrayFilter = arrayFilter;
4820
4821 /**
4822 * This method returns a new empty array.
4823 *
4824 * @static
4825 * @memberOf _
4826 * @since 4.13.0
4827 * @category Util
4828 * @returns {Array} Returns the new empty array.
4829 * @example
4830 *
4831 * var arrays = _.times(2, _.stubArray);
4832 *
4833 * console.log(arrays);
4834 * // => [[], []]
4835 *
4836 * console.log(arrays[0] === arrays[1]);
4837 * // => false
4838 */
4839 function stubArray() {
4840 return [];
4841 }
4842
4843 var stubArray_1 = stubArray;
4844
4845 /** Used for built-in method references. */
4846 var objectProto$c = Object.prototype;
4847
4848 /** Built-in value references. */
4849 var propertyIsEnumerable$1 = objectProto$c.propertyIsEnumerable;
4850
4851 /* Built-in method references for those with the same name as other `lodash` methods. */
4852 var nativeGetSymbols = Object.getOwnPropertySymbols;
4853
4854 /**
4855 * Creates an array of the own enumerable symbols of `object`.
4856 *
4857 * @private
4858 * @param {Object} object The object to query.
4859 * @returns {Array} Returns the array of symbols.
4860 */
4861 var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
4862 if (object == null) {
4863 return [];
4864 }
4865 object = Object(object);
4866 return _arrayFilter(nativeGetSymbols(object), function(symbol) {
4867 return propertyIsEnumerable$1.call(object, symbol);
4868 });
4869 };
4870
4871 var _getSymbols = getSymbols;
4872
4873 /**
4874 * Copies own symbols of `source` to `object`.
4875 *
4876 * @private
4877 * @param {Object} source The object to copy symbols from.
4878 * @param {Object} [object={}] The object to copy symbols to.
4879 * @returns {Object} Returns `object`.
4880 */
4881 function copySymbols(source, object) {
4882 return _copyObject(source, _getSymbols(source), object);
4883 }
4884
4885 var _copySymbols = copySymbols;
4886
4887 /**
4888 * Appends the elements of `values` to `array`.
4889 *
4890 * @private
4891 * @param {Array} array The array to modify.
4892 * @param {Array} values The values to append.
4893 * @returns {Array} Returns `array`.
4894 */
4895 function arrayPush(array, values) {
4896 var index = -1,
4897 length = values.length,
4898 offset = array.length;
4899
4900 while (++index < length) {
4901 array[offset + index] = values[index];
4902 }
4903 return array;
4904 }
4905
4906 var _arrayPush = arrayPush;
4907
4908 /* Built-in method references for those with the same name as other `lodash` methods. */
4909 var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
4910
4911 /**
4912 * Creates an array of the own and inherited enumerable symbols of `object`.
4913 *
4914 * @private
4915 * @param {Object} object The object to query.
4916 * @returns {Array} Returns the array of symbols.
4917 */
4918 var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
4919 var result = [];
4920 while (object) {
4921 _arrayPush(result, _getSymbols(object));
4922 object = _getPrototype(object);
4923 }
4924 return result;
4925 };
4926
4927 var _getSymbolsIn = getSymbolsIn;
4928
4929 /**
4930 * Copies own and inherited symbols of `source` to `object`.
4931 *
4932 * @private
4933 * @param {Object} source The object to copy symbols from.
4934 * @param {Object} [object={}] The object to copy symbols to.
4935 * @returns {Object} Returns `object`.
4936 */
4937 function copySymbolsIn(source, object) {
4938 return _copyObject(source, _getSymbolsIn(source), object);
4939 }
4940
4941 var _copySymbolsIn = copySymbolsIn;
4942
4943 /**
4944 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
4945 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
4946 * symbols of `object`.
4947 *
4948 * @private
4949 * @param {Object} object The object to query.
4950 * @param {Function} keysFunc The function to get the keys of `object`.
4951 * @param {Function} symbolsFunc The function to get the symbols of `object`.
4952 * @returns {Array} Returns the array of property names and symbols.
4953 */
4954 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
4955 var result = keysFunc(object);
4956 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
4957 }
4958
4959 var _baseGetAllKeys = baseGetAllKeys;
4960
4961 /**
4962 * Creates an array of own enumerable property names and symbols of `object`.
4963 *
4964 * @private
4965 * @param {Object} object The object to query.
4966 * @returns {Array} Returns the array of property names and symbols.
4967 */
4968 function getAllKeys(object) {
4969 return _baseGetAllKeys(object, keys_1, _getSymbols);
4970 }
4971
4972 var _getAllKeys = getAllKeys;
4973
4974 /**
4975 * Creates an array of own and inherited enumerable property names and
4976 * symbols of `object`.
4977 *
4978 * @private
4979 * @param {Object} object The object to query.
4980 * @returns {Array} Returns the array of property names and symbols.
4981 */
4982 function getAllKeysIn(object) {
4983 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
4984 }
4985
4986 var _getAllKeysIn = getAllKeysIn;
4987
4988 /* Built-in method references that are verified to be native. */
4989 var DataView = _getNative(_root, 'DataView');
4990
4991 var _DataView = DataView;
4992
4993 /* Built-in method references that are verified to be native. */
4994 var Promise = _getNative(_root, 'Promise');
4995
4996 var _Promise = Promise;
4997
4998 /* Built-in method references that are verified to be native. */
4999 var Set = _getNative(_root, 'Set');
5000
5001 var _Set = Set;
5002
5003 /* Built-in method references that are verified to be native. */
5004 var WeakMap = _getNative(_root, 'WeakMap');
5005
5006 var _WeakMap = WeakMap;
5007
5008 /** `Object#toString` result references. */
5009 var mapTag$1 = '[object Map]',
5010 objectTag$2 = '[object Object]',
5011 promiseTag = '[object Promise]',
5012 setTag$1 = '[object Set]',
5013 weakMapTag$1 = '[object WeakMap]';
5014
5015 var dataViewTag$1 = '[object DataView]';
5016
5017 /** Used to detect maps, sets, and weakmaps. */
5018 var dataViewCtorString = _toSource(_DataView),
5019 mapCtorString = _toSource(_Map),
5020 promiseCtorString = _toSource(_Promise),
5021 setCtorString = _toSource(_Set),
5022 weakMapCtorString = _toSource(_WeakMap);
5023
5024 /**
5025 * Gets the `toStringTag` of `value`.
5026 *
5027 * @private
5028 * @param {*} value The value to query.
5029 * @returns {string} Returns the `toStringTag`.
5030 */
5031 var getTag = _baseGetTag;
5032
5033 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
5034 if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
5035 (_Map && getTag(new _Map) != mapTag$1) ||
5036 (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
5037 (_Set && getTag(new _Set) != setTag$1) ||
5038 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
5039 getTag = function(value) {
5040 var result = _baseGetTag(value),
5041 Ctor = result == objectTag$2 ? value.constructor : undefined,
5042 ctorString = Ctor ? _toSource(Ctor) : '';
5043
5044 if (ctorString) {
5045 switch (ctorString) {
5046 case dataViewCtorString: return dataViewTag$1;
5047 case mapCtorString: return mapTag$1;
5048 case promiseCtorString: return promiseTag;
5049 case setCtorString: return setTag$1;
5050 case weakMapCtorString: return weakMapTag$1;
5051 }
5052 }
5053 return result;
5054 };
5055 }
5056
5057 var _getTag = getTag;
5058
5059 /** Used for built-in method references. */
5060 var objectProto$d = Object.prototype;
5061
5062 /** Used to check objects for own properties. */
5063 var hasOwnProperty$a = objectProto$d.hasOwnProperty;
5064
5065 /**
5066 * Initializes an array clone.
5067 *
5068 * @private
5069 * @param {Array} array The array to clone.
5070 * @returns {Array} Returns the initialized clone.
5071 */
5072 function initCloneArray(array) {
5073 var length = array.length,
5074 result = new array.constructor(length);
5075
5076 // Add properties assigned by `RegExp#exec`.
5077 if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
5078 result.index = array.index;
5079 result.input = array.input;
5080 }
5081 return result;
5082 }
5083
5084 var _initCloneArray = initCloneArray;
5085
5086 /**
5087 * Creates a clone of `dataView`.
5088 *
5089 * @private
5090 * @param {Object} dataView The data view to clone.
5091 * @param {boolean} [isDeep] Specify a deep clone.
5092 * @returns {Object} Returns the cloned data view.
5093 */
5094 function cloneDataView(dataView, isDeep) {
5095 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
5096 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
5097 }
5098
5099 var _cloneDataView = cloneDataView;
5100
5101 /** Used to match `RegExp` flags from their coerced string values. */
5102 var reFlags = /\w*$/;
5103
5104 /**
5105 * Creates a clone of `regexp`.
5106 *
5107 * @private
5108 * @param {Object} regexp The regexp to clone.
5109 * @returns {Object} Returns the cloned regexp.
5110 */
5111 function cloneRegExp(regexp) {
5112 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
5113 result.lastIndex = regexp.lastIndex;
5114 return result;
5115 }
5116
5117 var _cloneRegExp = cloneRegExp;
5118
5119 /** Used to convert symbols to primitives and strings. */
5120 var symbolProto = _Symbol ? _Symbol.prototype : undefined,
5121 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
5122
5123 /**
5124 * Creates a clone of the `symbol` object.
5125 *
5126 * @private
5127 * @param {Object} symbol The symbol object to clone.
5128 * @returns {Object} Returns the cloned symbol object.
5129 */
5130 function cloneSymbol(symbol) {
5131 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
5132 }
5133
5134 var _cloneSymbol = cloneSymbol;
5135
5136 /** `Object#toString` result references. */
5137 var boolTag$1 = '[object Boolean]',
5138 dateTag$1 = '[object Date]',
5139 mapTag$2 = '[object Map]',
5140 numberTag$1 = '[object Number]',
5141 regexpTag$1 = '[object RegExp]',
5142 setTag$2 = '[object Set]',
5143 stringTag$1 = '[object String]',
5144 symbolTag = '[object Symbol]';
5145
5146 var arrayBufferTag$1 = '[object ArrayBuffer]',
5147 dataViewTag$2 = '[object DataView]',
5148 float32Tag$1 = '[object Float32Array]',
5149 float64Tag$1 = '[object Float64Array]',
5150 int8Tag$1 = '[object Int8Array]',
5151 int16Tag$1 = '[object Int16Array]',
5152 int32Tag$1 = '[object Int32Array]',
5153 uint8Tag$1 = '[object Uint8Array]',
5154 uint8ClampedTag$1 = '[object Uint8ClampedArray]',
5155 uint16Tag$1 = '[object Uint16Array]',
5156 uint32Tag$1 = '[object Uint32Array]';
5157
5158 /**
5159 * Initializes an object clone based on its `toStringTag`.
5160 *
5161 * **Note:** This function only supports cloning values with tags of
5162 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
5163 *
5164 * @private
5165 * @param {Object} object The object to clone.
5166 * @param {string} tag The `toStringTag` of the object to clone.
5167 * @param {boolean} [isDeep] Specify a deep clone.
5168 * @returns {Object} Returns the initialized clone.
5169 */
5170 function initCloneByTag(object, tag, isDeep) {
5171 var Ctor = object.constructor;
5172 switch (tag) {
5173 case arrayBufferTag$1:
5174 return _cloneArrayBuffer(object);
5175
5176 case boolTag$1:
5177 case dateTag$1:
5178 return new Ctor(+object);
5179
5180 case dataViewTag$2:
5181 return _cloneDataView(object, isDeep);
5182
5183 case float32Tag$1: case float64Tag$1:
5184 case int8Tag$1: case int16Tag$1: case int32Tag$1:
5185 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
5186 return _cloneTypedArray(object, isDeep);
5187
5188 case mapTag$2:
5189 return new Ctor;
5190
5191 case numberTag$1:
5192 case stringTag$1:
5193 return new Ctor(object);
5194
5195 case regexpTag$1:
5196 return _cloneRegExp(object);
5197
5198 case setTag$2:
5199 return new Ctor;
5200
5201 case symbolTag:
5202 return _cloneSymbol(object);
5203 }
5204 }
5205
5206 var _initCloneByTag = initCloneByTag;
5207
5208 /** `Object#toString` result references. */
5209 var mapTag$3 = '[object Map]';
5210
5211 /**
5212 * The base implementation of `_.isMap` without Node.js optimizations.
5213 *
5214 * @private
5215 * @param {*} value The value to check.
5216 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
5217 */
5218 function baseIsMap(value) {
5219 return isObjectLike_1(value) && _getTag(value) == mapTag$3;
5220 }
5221
5222 var _baseIsMap = baseIsMap;
5223
5224 /* Node.js helper references. */
5225 var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
5226
5227 /**
5228 * Checks if `value` is classified as a `Map` object.
5229 *
5230 * @static
5231 * @memberOf _
5232 * @since 4.3.0
5233 * @category Lang
5234 * @param {*} value The value to check.
5235 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
5236 * @example
5237 *
5238 * _.isMap(new Map);
5239 * // => true
5240 *
5241 * _.isMap(new WeakMap);
5242 * // => false
5243 */
5244 var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
5245
5246 var isMap_1 = isMap;
5247
5248 /** `Object#toString` result references. */
5249 var setTag$3 = '[object Set]';
5250
5251 /**
5252 * The base implementation of `_.isSet` without Node.js optimizations.
5253 *
5254 * @private
5255 * @param {*} value The value to check.
5256 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
5257 */
5258 function baseIsSet(value) {
5259 return isObjectLike_1(value) && _getTag(value) == setTag$3;
5260 }
5261
5262 var _baseIsSet = baseIsSet;
5263
5264 /* Node.js helper references. */
5265 var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
5266
5267 /**
5268 * Checks if `value` is classified as a `Set` object.
5269 *
5270 * @static
5271 * @memberOf _
5272 * @since 4.3.0
5273 * @category Lang
5274 * @param {*} value The value to check.
5275 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
5276 * @example
5277 *
5278 * _.isSet(new Set);
5279 * // => true
5280 *
5281 * _.isSet(new WeakSet);
5282 * // => false
5283 */
5284 var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
5285
5286 var isSet_1 = isSet;
5287
5288 /** Used to compose bitmasks for cloning. */
5289 var CLONE_DEEP_FLAG = 1,
5290 CLONE_FLAT_FLAG = 2,
5291 CLONE_SYMBOLS_FLAG = 4;
5292
5293 /** `Object#toString` result references. */
5294 var argsTag$2 = '[object Arguments]',
5295 arrayTag$1 = '[object Array]',
5296 boolTag$2 = '[object Boolean]',
5297 dateTag$2 = '[object Date]',
5298 errorTag$1 = '[object Error]',
5299 funcTag$2 = '[object Function]',
5300 genTag$1 = '[object GeneratorFunction]',
5301 mapTag$4 = '[object Map]',
5302 numberTag$2 = '[object Number]',
5303 objectTag$3 = '[object Object]',
5304 regexpTag$2 = '[object RegExp]',
5305 setTag$4 = '[object Set]',
5306 stringTag$2 = '[object String]',
5307 symbolTag$1 = '[object Symbol]',
5308 weakMapTag$2 = '[object WeakMap]';
5309
5310 var arrayBufferTag$2 = '[object ArrayBuffer]',
5311 dataViewTag$3 = '[object DataView]',
5312 float32Tag$2 = '[object Float32Array]',
5313 float64Tag$2 = '[object Float64Array]',
5314 int8Tag$2 = '[object Int8Array]',
5315 int16Tag$2 = '[object Int16Array]',
5316 int32Tag$2 = '[object Int32Array]',
5317 uint8Tag$2 = '[object Uint8Array]',
5318 uint8ClampedTag$2 = '[object Uint8ClampedArray]',
5319 uint16Tag$2 = '[object Uint16Array]',
5320 uint32Tag$2 = '[object Uint32Array]';
5321
5322 /** Used to identify `toStringTag` values supported by `_.clone`. */
5323 var cloneableTags = {};
5324 cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
5325 cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
5326 cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
5327 cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
5328 cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
5329 cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
5330 cloneableTags[numberTag$2] = cloneableTags[objectTag$3] =
5331 cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
5332 cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
5333 cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
5334 cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
5335 cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
5336 cloneableTags[weakMapTag$2] = false;
5337
5338 /**
5339 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
5340 * traversed objects.
5341 *
5342 * @private
5343 * @param {*} value The value to clone.
5344 * @param {boolean} bitmask The bitmask flags.
5345 * 1 - Deep clone
5346 * 2 - Flatten inherited properties
5347 * 4 - Clone symbols
5348 * @param {Function} [customizer] The function to customize cloning.
5349 * @param {string} [key] The key of `value`.
5350 * @param {Object} [object] The parent object of `value`.
5351 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
5352 * @returns {*} Returns the cloned value.
5353 */
5354 function baseClone(value, bitmask, customizer, key, object, stack) {
5355 var result,
5356 isDeep = bitmask & CLONE_DEEP_FLAG,
5357 isFlat = bitmask & CLONE_FLAT_FLAG,
5358 isFull = bitmask & CLONE_SYMBOLS_FLAG;
5359
5360 if (customizer) {
5361 result = object ? customizer(value, key, object, stack) : customizer(value);
5362 }
5363 if (result !== undefined) {
5364 return result;
5365 }
5366 if (!isObject_1(value)) {
5367 return value;
5368 }
5369 var isArr = isArray_1(value);
5370 if (isArr) {
5371 result = _initCloneArray(value);
5372 if (!isDeep) {
5373 return _copyArray(value, result);
5374 }
5375 } else {
5376 var tag = _getTag(value),
5377 isFunc = tag == funcTag$2 || tag == genTag$1;
5378
5379 if (isBuffer_1(value)) {
5380 return _cloneBuffer(value, isDeep);
5381 }
5382 if (tag == objectTag$3 || tag == argsTag$2 || (isFunc && !object)) {
5383 result = (isFlat || isFunc) ? {} : _initCloneObject(value);
5384 if (!isDeep) {
5385 return isFlat
5386 ? _copySymbolsIn(value, _baseAssignIn(result, value))
5387 : _copySymbols(value, _baseAssign(result, value));
5388 }
5389 } else {
5390 if (!cloneableTags[tag]) {
5391 return object ? value : {};
5392 }
5393 result = _initCloneByTag(value, tag, isDeep);
5394 }
5395 }
5396 // Check for circular references and return its corresponding clone.
5397 stack || (stack = new _Stack);
5398 var stacked = stack.get(value);
5399 if (stacked) {
5400 return stacked;
5401 }
5402 stack.set(value, result);
5403
5404 if (isSet_1(value)) {
5405 value.forEach(function(subValue) {
5406 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
5407 });
5408 } else if (isMap_1(value)) {
5409 value.forEach(function(subValue, key) {
5410 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
5411 });
5412 }
5413
5414 var keysFunc = isFull
5415 ? (isFlat ? _getAllKeysIn : _getAllKeys)
5416 : (isFlat ? keysIn_1 : keys_1);
5417
5418 var props = isArr ? undefined : keysFunc(value);
5419 _arrayEach(props || value, function(subValue, key) {
5420 if (props) {
5421 key = subValue;
5422 subValue = value[key];
5423 }
5424 // Recursively populate clone (susceptible to call stack limits).
5425 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
5426 });
5427 return result;
5428 }
5429
5430 var _baseClone = baseClone;
5431
5432 /** Used to compose bitmasks for cloning. */
5433 var CLONE_DEEP_FLAG$1 = 1,
5434 CLONE_SYMBOLS_FLAG$1 = 4;
5435
5436 /**
5437 * This method is like `_.clone` except that it recursively clones `value`.
5438 *
5439 * @static
5440 * @memberOf _
5441 * @since 1.0.0
5442 * @category Lang
5443 * @param {*} value The value to recursively clone.
5444 * @returns {*} Returns the deep cloned value.
5445 * @see _.clone
5446 * @example
5447 *
5448 * var objects = [{ 'a': 1 }, { 'b': 2 }];
5449 *
5450 * var deep = _.cloneDeep(objects);
5451 * console.log(deep[0] === objects[0]);
5452 * // => false
5453 */
5454 function cloneDeep(value) {
5455 return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
5456 }
5457
5458 var cloneDeep_1 = cloneDeep;
5459
5460 var DrawSource = /*#__PURE__*/function () {
5461 function DrawSource(data) {
5462 _classCallCheck(this, DrawSource);
5463
5464 this.data = data || this.getDefaultData();
5465 }
5466
5467 _createClass(DrawSource, [{
5468 key: "addFeature",
5469 value: function addFeature(feature) {
5470 this.data.features.push(feature);
5471 }
5472 }, {
5473 key: "getData",
5474 value: function getData() {
5475 var features = cloneDeep_1(this.data.features).map(function (feature) {
5476 var _feature$properties, _feature$properties2;
5477
5478 feature.properties = {
5479 id: feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id,
5480 type: feature === null || feature === void 0 ? void 0 : (_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.type
5481 };
5482 return feature;
5483 });
5484 return {
5485 type: 'FeatureCollection',
5486 features: features
5487 };
5488 }
5489 }, {
5490 key: "getFeature",
5491 value: function getFeature(id) {
5492 var result = this.data.features.find(function (fe) {
5493 var _fe$properties;
5494
5495 return (fe === null || fe === void 0 ? void 0 : (_fe$properties = fe.properties) === null || _fe$properties === void 0 ? void 0 : _fe$properties.id) === id;
5496 });
5497 return result;
5498 }
5499 }, {
5500 key: "removeAllFeatures",
5501 value: function removeAllFeatures() {
5502 this.data = this.getDefaultData();
5503 }
5504 }, {
5505 key: "removeFeature",
5506 value: function removeFeature(feature) {
5507 var index = this.getFeatureIndex(feature);
5508
5509 if (index !== undefined) {
5510 this.data.features.splice(index, 1);
5511 }
5512 }
5513 }, {
5514 key: "setFeatureActive",
5515 value: function setFeatureActive(feature) {
5516 var _feature$properties3;
5517
5518 var fe = this.getFeature(feature === null || feature === void 0 ? void 0 : (_feature$properties3 = feature.properties) === null || _feature$properties3 === void 0 ? void 0 : _feature$properties3.id);
5519
5520 if (fe && fe.properties) {
5521 fe.properties.active = true;
5522 }
5523 }
5524 }, {
5525 key: "setFeatureUnActive",
5526 value: function setFeatureUnActive(feature) {
5527 var _feature$properties4;
5528
5529 var fe = this.getFeature(feature === null || feature === void 0 ? void 0 : (_feature$properties4 = feature.properties) === null || _feature$properties4 === void 0 ? void 0 : _feature$properties4.id);
5530
5531 if (fe && fe.properties) {
5532 fe.properties.active = false;
5533 }
5534 }
5535 }, {
5536 key: "clearFeatureActive",
5537 value: function clearFeatureActive() {
5538 this.data.features.forEach(function (fe) {
5539 if (fe && fe.properties) {
5540 fe.properties.active = false;
5541 }
5542 });
5543 }
5544 }, {
5545 key: "updateFeature",
5546 value: function updateFeature(feature) {
5547 this.removeFeature(feature);
5548 this.addFeature(feature);
5549 }
5550 }, {
5551 key: "destroy",
5552 value: function destroy() {
5553 this.data = this.getDefaultData();
5554 }
5555 }, {
5556 key: "getDefaultData",
5557 value: function getDefaultData() {
5558 return {
5559 type: 'FeatureCollection',
5560 features: []
5561 };
5562 }
5563 }, {
5564 key: "getFeatureIndex",
5565 value: function getFeatureIndex(feature) {
5566 return this.data.features.findIndex(function (fe) {
5567 var _fe$properties2, _feature$properties5;
5568
5569 return (fe === null || fe === void 0 ? void 0 : (_fe$properties2 = fe.properties) === null || _fe$properties2 === void 0 ? void 0 : _fe$properties2.id) === (feature === null || feature === void 0 ? void 0 : (_feature$properties5 = feature.properties) === null || _feature$properties5 === void 0 ? void 0 : _feature$properties5.id);
5570 });
5571 }
5572 }]);
5573
5574 return DrawSource;
5575 }();
5576
5577 var LayerStyles = {
5578 active: {
5579 point: {
5580 type: 'PointLayer',
5581 shape: 'circle',
5582 color: '#fbb03b',
5583 size: 5,
5584 style: {
5585 stroke: '#fff',
5586 strokeWidth: 2
5587 }
5588 },
5589 line: {
5590 type: 'LineLayer',
5591 shape: 'line',
5592 color: '#fbb03b',
5593 size: 1,
5594 style: {
5595 opacity: 1,
5596 lineType: 'dash',
5597 dashArray: [2, 2]
5598 }
5599 },
5600 polygon: {
5601 shape: 'fill',
5602 color: '#fbb03b',
5603 style: {
5604 opacity: 0.1,
5605 stroke: '#fbb03b',
5606 strokeWidth: 1,
5607 strokeOpacity: 1,
5608 lineType: 'dash',
5609 dashArray: [2, 2]
5610 }
5611 }
5612 },
5613 normal: {
5614 polygon: {
5615 type: 'PolygonLayer',
5616 shape: 'fill',
5617 color: '#3bb2d0',
5618 style: {
5619 opacity: 0.1,
5620 stroke: '#3bb2d0',
5621 strokeWidth: 1,
5622 strokeOpacity: 1,
5623 lineType: 'solid',
5624 dashArray: [2, 2]
5625 }
5626 },
5627 line: {
5628 type: 'LineLayer',
5629 shape: 'line',
5630 size: 1,
5631 color: '#3bb2d0',
5632 style: {
5633 opacity: 1
5634 }
5635 },
5636 point: {
5637 type: 'PointLayer',
5638 shape: 'circle',
5639 color: '#3bb2d0',
5640 size: 3,
5641 style: {
5642 stroke: '#fff',
5643 strokeWidth: 2
5644 }
5645 }
5646 },
5647 normal_point: {
5648 type: 'PointLayer',
5649 shape: 'circle',
5650 color: '#3bb2d0',
5651 size: 3,
5652 style: {
5653 stroke: '#fff',
5654 strokeWidth: 2
5655 }
5656 },
5657 mid_point: {
5658 point: {
5659 type: 'PointLayer',
5660 shape: 'circle',
5661 color: '#fbb03b',
5662 size: 3,
5663 style: {}
5664 }
5665 }
5666 };
5667
5668 var DrawFeatureId = 0;
5669
5670 var DrawMode = /*#__PURE__*/function (_EventEmitter) {
5671 _inherits(DrawMode, _EventEmitter);
5672
5673 var _super = _createSuper(DrawMode);
5674
5675 function DrawMode(scene) {
5676 var _this;
5677
5678 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5679
5680 _classCallCheck(this, DrawMode);
5681
5682 _this = _super.call(this);
5683 _this.isEnable = false;
5684 _this.options = {
5685 style: LayerStyles
5686 };
5687 _this.drawStatus = 'Drawing';
5688 var data = options.data;
5689 _this.scene = scene;
5690 _this.source = new DrawSource(data);
5691 _this.options = merge_1(_this.options, _this.getDefaultOptions(), options);
5692 _this.title = _this.getOption('title');
5693 return _this;
5694 }
5695
5696 _createClass(DrawMode, [{
5697 key: "enable",
5698 value: function enable() {
5699 if (this.isEnable) {
5700 return;
5701 } // @ts-ignore
5702
5703
5704 this.scene.setMapStatus({
5705 dragEnable: false
5706 });
5707 this.scene.on('dragstart', this.onDragStart);
5708 this.scene.on('dragging', this.onDragging);
5709 this.scene.on('dragend', this.onDragEnd);
5710 this.scene.on('click', this.onClick);
5711 this.setCursor(this.getOption('cursor'));
5712 this.isEnable = true;
5713 }
5714 }, {
5715 key: "disable",
5716 value: function disable() {
5717 if (!this.isEnable) {
5718 return;
5719 }
5720
5721 this.scene.off('dragstart', this.onDragStart);
5722 this.scene.off('dragging', this.onDragging);
5723 this.scene.off('dragend', this.onDragEnd);
5724 this.scene.off('click', this.onClick);
5725 this.resetCursor(); // @ts-ignore
5726
5727 this.scene.setMapStatus({
5728 dragEnable: true
5729 });
5730 this.isEnable = false;
5731 }
5732 }, {
5733 key: "setCurrentFeature",
5734 value: function setCurrentFeature(feature) {
5735 this.currentFeature = feature;
5736 this.source.setFeatureActive(feature);
5737 }
5738 }, {
5739 key: "setCurrentVertex",
5740 value: function setCurrentVertex(feature) {
5741 this.currentVertex = feature;
5742 }
5743 }, {
5744 key: "deleteCurrentFeature",
5745 value: function deleteCurrentFeature() {
5746 throw new Error('子类未实现该方法');
5747 }
5748 }, {
5749 key: "getCurrentVertex",
5750 value: function getCurrentVertex() {
5751 return this.currentVertex;
5752 }
5753 }, {
5754 key: "getCurrentFeature",
5755 value: function getCurrentFeature() {
5756 return this.currentFeature;
5757 }
5758 }, {
5759 key: "getOption",
5760 value: function getOption(key) {
5761 return this.options[key];
5762 }
5763 }, {
5764 key: "getStyle",
5765 value: function getStyle(id) {
5766 return this.getOption('style')[id];
5767 }
5768 }, {
5769 key: "getUniqId",
5770 value: function getUniqId() {
5771 return DrawFeatureId++;
5772 }
5773 }, {
5774 key: "setCursor",
5775 value: function setCursor(cursor) {
5776 var container = this.scene.getMapCanvasContainer();
5777
5778 if (container) {
5779 container.style.cursor = cursor;
5780 }
5781 }
5782 }, {
5783 key: "resetCursor",
5784 value: function resetCursor() {
5785 var container = this.scene.getMapCanvasContainer();
5786
5787 if (container) {
5788 container.removeAttribute('style');
5789 }
5790 }
5791 }, {
5792 key: "destroy",
5793 value: function destroy() {
5794 DrawFeatureId = 0;
5795 this.removeAllListeners();
5796 this.disable();
5797 }
5798 }, {
5799 key: "getDefaultOptions",
5800 value: function getDefaultOptions() {
5801 return {};
5802 }
5803 }, {
5804 key: "onClick",
5805 value: function onClick(e) {
5806 return null;
5807 }
5808 }]);
5809
5810 return DrawMode;
5811 }(eventemitter3_1);
5812
5813 var DrawDelete = /*#__PURE__*/function (_DrawFeature) {
5814 _inherits(DrawDelete, _DrawFeature);
5815
5816 var _super = _createSuper(DrawDelete);
5817
5818 // 绘制完成之后显示
5819 function DrawDelete(scene) {
5820 var _this;
5821
5822 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5823
5824 _classCallCheck(this, DrawDelete);
5825
5826 _this = _super.call(this, scene, options);
5827
5828 _this.onDragging = function (e) {
5829 return;
5830 };
5831
5832 _this.onDragEnd = function () {
5833 throw new Error('Method not implemented.');
5834 };
5835
5836 _this.onClick = function () {
5837 return null;
5838 };
5839
5840 return _this;
5841 }
5842
5843 _createClass(DrawDelete, [{
5844 key: "enable",
5845 value: function enable() {
5846 this.emit(DrawEvent.DELETE, '');
5847 }
5848 }, {
5849 key: "disable",
5850 value: function disable() {
5851 return null;
5852 }
5853 }, {
5854 key: "getDefaultOptions",
5855 value: function getDefaultOptions() {
5856 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawDelete.prototype), "getDefaultOptions", this).call(this)), {}, {
5857 title: '删除图形'
5858 });
5859 }
5860 }, {
5861 key: "onDragStart",
5862 value: function onDragStart(e) {
5863 throw new Error('Method not implemented.');
5864 }
5865 }]);
5866
5867 return DrawDelete;
5868 }(DrawMode);
5869
5870 var DrawEdit = /*#__PURE__*/function (_DrawFeature) {
5871 _inherits(DrawEdit, _DrawFeature);
5872
5873 var _super = _createSuper(DrawEdit);
5874
5875 // 绘制完成之后显示
5876 function DrawEdit(scene) {
5877 var _this;
5878
5879 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5880
5881 _classCallCheck(this, DrawEdit);
5882
5883 _this = _super.call(this, scene, options);
5884
5885 _this.onDragStart = function (e) {// @ts-ignore
5886 };
5887
5888 _this.onDragging = function (e) {
5889 _this.endPoint = e.lngLat;
5890
5891 _this.emit(DrawEvent.Edit, _this.endPoint);
5892
5893 return;
5894 };
5895
5896 _this.onDragEnd = function () {
5897 _this.emit(DrawEvent.UPDATE, _this.currentFeature);
5898
5899 _this.resetCursor();
5900
5901 _this.disable();
5902 };
5903
5904 _this.onClick = function () {
5905 return null;
5906 };
5907
5908 return _this;
5909 }
5910
5911 _createClass(DrawEdit, [{
5912 key: "setEditFeature",
5913 value: function setEditFeature(feature) {
5914 this.currentFeature = feature;
5915 }
5916 }, {
5917 key: "getDefaultOptions",
5918 value: function getDefaultOptions() {
5919 return {
5920 steps: 64,
5921 units: 'kilometres',
5922 cursor: 'move'
5923 };
5924 }
5925 }]);
5926
5927 return DrawEdit;
5928 }(DrawMode);
5929
5930 var DrawSelect = /*#__PURE__*/function (_DrawFeature) {
5931 _inherits(DrawSelect, _DrawFeature);
5932
5933 var _super = _createSuper(DrawSelect);
5934
5935 // 绘制完成之后显示
5936 function DrawSelect(scene) {
5937 var _this;
5938
5939 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5940
5941 _classCallCheck(this, DrawSelect);
5942
5943 _this = _super.call(this, scene, options);
5944
5945 _this.onDragStart = function (e) {
5946 _this.scene.setMapStatus({
5947 dragEnable: false
5948 });
5949
5950 _this.dragStartPoint = e.lngLat;
5951 };
5952
5953 _this.onDragging = function (e) {
5954 var delta = {
5955 lng: e.lngLat.lng - _this.dragStartPoint.lng,
5956 lat: e.lngLat.lat - _this.dragStartPoint.lat
5957 };
5958
5959 _this.emit(DrawEvent.Move, delta);
5960
5961 _this.dragStartPoint = e.lngLat;
5962 return;
5963 };
5964
5965 _this.onDragEnd = function () {
5966 _this.emit(DrawEvent.UPDATE, _this.currentFeature);
5967 };
5968
5969 _this.onClick = function () {
5970 return null;
5971 };
5972
5973 return _this;
5974 }
5975
5976 _createClass(DrawSelect, [{
5977 key: "setSelectedFeature",
5978 value: function setSelectedFeature(feature) {
5979 this.currentFeature = feature;
5980 }
5981 }, {
5982 key: "getDefaultOptions",
5983 value: function getDefaultOptions() {
5984 return {
5985 steps: 64,
5986 units: 'kilometers',
5987 cursor: 'move'
5988 };
5989 }
5990 }]);
5991
5992 return DrawSelect;
5993 }(DrawMode);
5994
5995 var DrawFeature = /*#__PURE__*/function (_DrawMode) {
5996 _inherits(DrawFeature, _DrawMode);
5997
5998 var _super = _createSuper(DrawFeature);
5999
6000 function DrawFeature(scene) {
6001 var _this;
6002
6003 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6004
6005 _classCallCheck(this, DrawFeature);
6006
6007 _this = _super.call(this, scene, options);
6008
6009 _this.onModeChange = function (mode) {
6010 var _this$currentFeature, _this$currentFeature$, _this$currentFeature2, _this$currentFeature3;
6011
6012 switch (mode) {
6013 case DrawModes.DIRECT_SELECT:
6014 if (!_this.editEnable) {
6015 return;
6016 }
6017
6018 _this.editMode.enable();
6019
6020 _this.editMode.setEditFeature(_this.currentFeature);
6021
6022 _this.drawLayer.updateData(helpers_13([_this.currentFeature]));
6023
6024 _this.drawVertexLayer.updateData(helpers_13((_this$currentFeature = _this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : (_this$currentFeature$ = _this$currentFeature.properties) === null || _this$currentFeature$ === void 0 ? void 0 : _this$currentFeature$.pointFeatures));
6025
6026 _this.drawVertexLayer.show();
6027
6028 _this.drawVertexLayer.enableEdit();
6029
6030 _this.showOtherLayer();
6031
6032 _this.drawStatus = 'DrawEdit';
6033 break;
6034
6035 case DrawModes.SIMPLE_SELECT:
6036 if (!_this.selectEnable) {
6037 _this.drawLayer.hide();
6038
6039 _this.drawVertexLayer.hide();
6040
6041 _this.hideOtherLayer();
6042
6043 _this.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
6044
6045 return;
6046 }
6047
6048 _this.selectMode.setSelectedFeature(_this.currentFeature);
6049
6050 _this.selectMode.enable();
6051
6052 _this.drawLayer.updateData( // TODO:导入数据不能正常使用
6053 helpers_13([_this.currentFeature]));
6054
6055 _this.drawLayer.enableSelect();
6056
6057 _this.drawVertexLayer.updateData(helpers_13((_this$currentFeature2 = _this.currentFeature) === null || _this$currentFeature2 === void 0 ? void 0 : (_this$currentFeature3 = _this$currentFeature2.properties) === null || _this$currentFeature3 === void 0 ? void 0 : _this$currentFeature3.pointFeatures));
6058
6059 _this.drawVertexLayer.disableEdit();
6060
6061 _this.drawVertexLayer.show();
6062
6063 _this.drawLayer.show();
6064
6065 _this.showOtherLayer();
6066
6067 _this.drawStatus = 'DrawSelected';
6068 break;
6069
6070 case DrawModes.STATIC:
6071 _this.source.updateFeature(_this.currentFeature);
6072
6073 _this.selectMode.disable();
6074
6075 _this.editMode.disable();
6076
6077 _this.source.clearFeatureActive();
6078
6079 _this.drawVertexLayer.hide();
6080
6081 _this.drawVertexLayer.disableEdit();
6082
6083 _this.hideOtherLayer();
6084
6085 _this.normalLayer.update(_this.source.data);
6086
6087 _this.normalLayer.enableSelect();
6088
6089 _this.drawStatus = 'DrawFinish';
6090 break;
6091 }
6092 };
6093
6094 _this.onDrawCreate = function (feature) {
6095 _this.source.addFeature(feature);
6096 };
6097
6098 _this.onDrawUpdate = function (feature) {
6099 _this.source.updateFeature(_this.currentFeature);
6100
6101 _this.emit(DrawEvent.UPDATE, _this.currentFeature);
6102 };
6103
6104 _this.onDrawMove = function (delta) {
6105 if (_this.drawStatus === 'DrawSelected') {
6106 _this.moveFeature(delta);
6107 }
6108 };
6109
6110 _this.onDrawEdit = function (endpoint) {
6111 _this.editFeature(endpoint);
6112 };
6113
6114 _this.onDrawDelete = function () {
6115 if (_this.drawStatus === 'DrawSelected') {
6116 _this.clear();
6117
6118 _this.source.removeFeature(_this.currentFeature);
6119
6120 _this.normalLayer.update(_this.source.data);
6121
6122 _this.drawLayer.disableSelect();
6123
6124 _this.selectMode.disable();
6125
6126 _this.currentFeature = null; // this.drawStatus = 'DrawDelete';
6127 }
6128 };
6129
6130 _this.addKeyDownEvent = function (event) {
6131 // tslint:disable-next-line:no-arg
6132 var e = event || window.event;
6133
6134 if (e && e.keyCode === 8) {
6135 _this.deleteMode.enable();
6136 }
6137 };
6138
6139 _this.drawLayer = new DrawLayer(_assertThisInitialized(_this));
6140 _this.drawVertexLayer = new DrawVertexLayer(_assertThisInitialized(_this));
6141 _this.normalLayer = new DrawResultLayer(_assertThisInitialized(_this));
6142 _this.selectEnable = _this.getOption('selectEnable');
6143 _this.editEnable = _this.getOption('editEnable'); // this.editLayer = new EditLayer(this);
6144
6145 _this.selectMode = new DrawSelect(_this.scene, {});
6146 _this.editMode = new DrawEdit(_this.scene, {});
6147 _this.deleteMode = new DrawDelete(_this.scene, {});
6148
6149 _this.selectMode.on(DrawEvent.UPDATE, _this.onDrawUpdate);
6150
6151 _this.selectMode.on(DrawEvent.Move, _this.onDrawMove);
6152
6153 _this.editMode.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
6154
6155 _this.editMode.on(DrawEvent.UPDATE, _this.onDrawUpdate);
6156
6157 _this.editMode.on(DrawEvent.Edit, _this.onDrawEdit);
6158
6159 _this.selectMode.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
6160
6161 _this.deleteMode.on(DrawEvent.DELETE, _this.onDrawDelete);
6162
6163 _this.on(DrawEvent.CREATE, _this.onDrawCreate);
6164
6165 _this.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
6166
6167 document.addEventListener('keydown', _this.addKeyDownEvent);
6168
6169 if (_this.options.data && _this.initData()) {
6170 _this.normalLayer.update(_this.source.data);
6171
6172 _this.normalLayer.enableSelect();
6173 }
6174
6175 return _this;
6176 }
6177
6178 _createClass(DrawFeature, [{
6179 key: "setCurrentFeature",
6180 value: function setCurrentFeature(feature) {
6181 this.currentFeature = feature; // @ts-ignore
6182
6183 this.pointFeatures = feature.properties.pointFeatures;
6184 this.source.setFeatureActive(feature);
6185 }
6186 }, {
6187 key: "deleteCurrentFeature",
6188 value: function deleteCurrentFeature() {
6189 this.deleteMode.enable();
6190 }
6191 }, {
6192 key: "disableLayer",
6193 value: function disableLayer() {
6194 // this.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
6195 this.drawLayer.disableSelect();
6196 }
6197 }, {
6198 key: "enableLayer",
6199 value: function enableLayer() {
6200 this.drawLayer.enableSelect();
6201 }
6202 }, {
6203 key: "getData",
6204 value: function getData() {
6205 return this.source.getData();
6206 }
6207 }, {
6208 key: "removeAllData",
6209 value: function removeAllData() {
6210 this.source.removeAllFeatures();
6211 this.currentFeature = null;
6212 this.drawLayer.hide();
6213 this.drawVertexLayer.hide();
6214 this.normalLayer.hide();
6215 this.hideOtherLayer();
6216 }
6217 }, {
6218 key: "clear",
6219 value: function clear() {
6220 this.drawLayer.disableSelect();
6221 this.drawLayer.disableEdit();
6222 this.drawLayer.hide();
6223 this.drawVertexLayer.hide();
6224 this.hideOtherLayer();
6225 this.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
6226 }
6227 }, {
6228 key: "reset",
6229 value: function reset() {
6230 this.drawLayer.show();
6231 this.drawVertexLayer.show();
6232 this.showOtherLayer();
6233 }
6234 }, {
6235 key: "addVertex",
6236 value: function addVertex(feature) {
6237 throw new Error('子类未实现该方法');
6238 }
6239 }, {
6240 key: "onRemove",
6241 value: function onRemove() {
6242 this.destroy();
6243 this.selectMode.destroy();
6244 this.editMode.destroy();
6245 this.source.destroy();
6246 this.drawLayer.destroy();
6247 this.drawVertexLayer.destroy();
6248 this.normalLayer.destroy();
6249 document.removeEventListener('keydown', this.addKeyDownEvent);
6250 }
6251 }, {
6252 key: "getDefaultOptions",
6253 value: function getDefaultOptions() {
6254 return {
6255 steps: 64,
6256 units: 'kilometers',
6257 cursor: 'crosshair',
6258 editEnable: true,
6259 selectEnable: true
6260 };
6261 }
6262 }, {
6263 key: "initData",
6264 value: function initData() {
6265 return false;
6266 }
6267 }, {
6268 key: "addDrawPopup",
6269 value: function addDrawPopup(lnglat, dis) {
6270 var popup = new l7.Popup({
6271 anchor: 'left',
6272 closeButton: false
6273 }).setLnglat(lnglat).setText("\u534A\u5F84:".concat(dis.toFixed(2), "\u5343\u7C73"));
6274 this.scene.addPopup(popup);
6275 this.popup = popup;
6276 }
6277 }]);
6278
6279 return DrawFeature;
6280 }(DrawMode);
6281
6282 var DrawCircle = /*#__PURE__*/function (_DrawFeature) {
6283 _inherits(DrawCircle, _DrawFeature);
6284
6285 var _super = _createSuper(DrawCircle);
6286
6287 function DrawCircle(scene) {
6288 var _this;
6289
6290 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6291
6292 _classCallCheck(this, DrawCircle);
6293
6294 _this = _super.call(this, scene, options);
6295
6296 _this.onDragStart = function (e) {
6297 if (_this.drawStatus !== 'Drawing') {
6298 _this.drawLayer.emit('unclick', null);
6299 }
6300
6301 _this.startPoint = e.lngLat;
6302
6303 _this.setCursor('grabbing');
6304
6305 _this.initCenterLayer();
6306
6307 _this.centerLayer.setData([_this.startPoint]);
6308 };
6309
6310 _this.onDragging = function (e) {
6311 _this.endPoint = e.lngLat;
6312
6313 var feature = _this.createFeature();
6314
6315 var properties = feature.properties;
6316
6317 _this.drawLayer.update(helpers_13([feature]));
6318
6319 _this.drawVertexLayer.update(helpers_13(properties.pointFeatures));
6320 };
6321
6322 _this.onDragEnd = function () {
6323 var feature = _this.createFeature("".concat(_this.getUniqId()));
6324
6325 var properties = feature.properties;
6326
6327 _this.drawLayer.update(helpers_13([feature]));
6328
6329 _this.drawVertexLayer.update(helpers_13(properties.pointFeatures));
6330
6331 _this.emit(DrawEvent.CREATE, _this.currentFeature);
6332
6333 _this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
6334
6335 _this.disable();
6336 };
6337
6338 _this.type = 'circle';
6339 return _this;
6340 }
6341
6342 _createClass(DrawCircle, [{
6343 key: "drawFinish",
6344 value: function drawFinish() {
6345 return null;
6346 }
6347 }, {
6348 key: "setCurrentFeature",
6349 value: function setCurrentFeature(feature) {
6350 this.currentFeature = feature; // @ts-ignore
6351
6352 this.pointFeatures = feature.properties.pointFeatures; // @ts-ignore
6353
6354 this.startPoint = feature.properties.startPoint; // @ts-ignore
6355
6356 this.endPoint = feature.properties.endPoint;
6357 this.source.setFeatureActive(feature);
6358 }
6359 }, {
6360 key: "getDefaultOptions",
6361 value: function getDefaultOptions() {
6362 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawCircle.prototype), "getDefaultOptions", this).call(this)), {}, {
6363 title: '绘制圆'
6364 });
6365 }
6366 }, {
6367 key: "moveFeature",
6368 value: function moveFeature(delta) {
6369 var newFeature = moveFeatures([this.currentFeature], delta);
6370 this.drawLayer.updateData(helpers_13(newFeature));
6371 var newPointFeture = moveFeatures(this.pointFeatures, delta);
6372 this.drawVertexLayer.updateData(helpers_13(newPointFeture));
6373 var newStartPoint = movePoint([this.startPoint.lng, this.startPoint.lat], delta);
6374 this.startPoint = {
6375 lat: newStartPoint[1],
6376 lng: newStartPoint[0]
6377 };
6378 var newEndPoint = movePoint([this.endPoint.lng, this.endPoint.lat], delta);
6379 var endPointObj = {
6380 lat: newEndPoint[1],
6381 lng: newEndPoint[0]
6382 };
6383 newFeature[0].properties = _objectSpread2(_objectSpread2({}, newFeature[0].properties), {}, {
6384 startPoint: this.startPoint,
6385 endPoint: endPointObj,
6386 pointFeatures: newPointFeture
6387 });
6388 this.centerLayer.setData([this.startPoint]);
6389 this.setCurrentFeature(newFeature[0]);
6390
6391 var changeFeature = _objectSpread2({}, newFeature[0]);
6392
6393 this.emit(DrawEvent.CHANGE, changeFeature);
6394 }
6395 }, {
6396 key: "createFeature",
6397 value: function createFeature() {
6398 var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0';
6399 var points = createPoint([this.endPoint]);
6400 var feature = createCircle([this.startPoint.lng, this.startPoint.lat], [this.endPoint.lng, this.endPoint.lat], {
6401 pointFeatures: points.features,
6402 units: this.getOption('units'),
6403 steps: this.getOption('steps'),
6404 id: id
6405 });
6406 this.setCurrentFeature(feature);
6407 return feature;
6408 }
6409 }, {
6410 key: "editFeature",
6411 value: function editFeature(endPoint) {
6412 this.endPoint = endPoint;
6413 var newFeature = this.createFeature();
6414 var properties = newFeature.properties;
6415 this.drawLayer.updateData(helpers_13([newFeature]));
6416 this.drawVertexLayer.updateData(helpers_13(properties.pointFeatures));
6417 this.emit(DrawEvent.CHANGE, helpers_13([newFeature]).features[0]);
6418 }
6419 }, {
6420 key: "showOtherLayer",
6421 value: function showOtherLayer() {
6422 var _this$currentFeature, _this$currentFeature$;
6423
6424 this.centerLayer.setData([(_this$currentFeature = this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : (_this$currentFeature$ = _this$currentFeature.properties) === null || _this$currentFeature$ === void 0 ? void 0 : _this$currentFeature$.startPoint]);
6425 this.centerLayer.show();
6426 }
6427 }, {
6428 key: "hideOtherLayer",
6429 value: function hideOtherLayer() {
6430 if (this.currentFeature) {
6431 this.centerLayer.hide();
6432 }
6433 }
6434 }, {
6435 key: "initCenterLayer",
6436 value: function initCenterLayer() {
6437 var centerStyle = this.getStyle('active').point;
6438 var layer = new l7.PointLayer().source([this.startPoint], {
6439 parser: {
6440 type: 'json',
6441 x: 'lng',
6442 y: 'lat'
6443 }
6444 }).shape('circle').color(centerStyle.color).size(centerStyle.size).style(centerStyle.style);
6445 this.scene.addLayer(layer);
6446 this.centerLayer = layer;
6447 }
6448 }]);
6449
6450 return DrawCircle;
6451 }(DrawFeature);
6452
6453 /**
6454 * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
6455 */
6456
6457 /**
6458 * Converts an angle in radians to degrees
6459 *
6460 * @name radiansToDegrees
6461 * @param {number} radians angle in radians
6462 * @returns {number} degrees between 0 and 360 degrees
6463 */
6464 function radiansToDegrees(radians) {
6465 if (radians === null || radians === undefined) throw new Error('radians is required');
6466
6467 var degrees = radians % (2 * Math.PI);
6468 return degrees * 180 / Math.PI;
6469 }
6470
6471 /**
6472 * Converts an angle in degrees to radians
6473 *
6474 * @name degreesToRadians
6475 * @param {number} degrees angle between 0 and 360 degrees
6476 * @returns {number} angle in radians
6477 */
6478 function degreesToRadians(degrees) {
6479 if (degrees === null || degrees === undefined) throw new Error('degrees is required');
6480
6481 var radians = degrees % 360;
6482 return radians * Math.PI / 180;
6483 }
6484
6485 /**
6486 * isObject
6487 *
6488 * @param {*} input variable to validate
6489 * @returns {boolean} true/false
6490 * @example
6491 * turf.isObject({elevation: 10})
6492 * //=true
6493 * turf.isObject('foo')
6494 * //=false
6495 */
6496 function isObject$1(input) {
6497 return (!!input) && (input.constructor === Object);
6498 }
6499
6500 /**
6501 * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
6502 *
6503 * @name getCoord
6504 * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
6505 * @returns {Array<number>} coordinates
6506 * @example
6507 * var pt = turf.point([10, 10]);
6508 *
6509 * var coord = turf.getCoord(pt);
6510 * //= [10, 10]
6511 */
6512 function getCoord(coord) {
6513 if (!coord) throw new Error('coord is required');
6514 if (coord.type === 'Feature' && coord.geometry !== null && coord.geometry.type === 'Point') return coord.geometry.coordinates;
6515 if (coord.type === 'Point') return coord.coordinates;
6516 if (Array.isArray(coord) && coord.length >= 2 && coord[0].length === undefined && coord[1].length === undefined) return coord;
6517
6518 throw new Error('coord must be GeoJSON Point or an Array of numbers');
6519 }
6520
6521 //http://en.wikipedia.org/wiki/Haversine_formula
6522 //http://www.movable-type.co.uk/scripts/latlong.html
6523
6524 /**
6525 * Takes two {@link Point|points} and finds the geographic bearing between them,
6526 * i.e. the angle measured in degrees from the north line (0 degrees)
6527 *
6528 * @name bearing
6529 * @param {Coord} start starting Point
6530 * @param {Coord} end ending Point
6531 * @param {Object} [options={}] Optional parameters
6532 * @param {boolean} [options.final=false] calculates the final bearing if true
6533 * @returns {number} bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
6534 * @example
6535 * var point1 = turf.point([-75.343, 39.984]);
6536 * var point2 = turf.point([-75.534, 39.123]);
6537 *
6538 * var bearing = turf.bearing(point1, point2);
6539 *
6540 * //addToMap
6541 * var addToMap = [point1, point2]
6542 * point1.properties['marker-color'] = '#f00'
6543 * point2.properties['marker-color'] = '#0f0'
6544 * point1.properties.bearing = bearing
6545 */
6546 function bearing(start, end, options) {
6547 // Optional parameters
6548 options = options || {};
6549 if (!isObject$1(options)) throw new Error('options is invalid');
6550 var final = options.final;
6551
6552 // Reverse calculation
6553 if (final === true) return calculateFinalBearing(start, end);
6554
6555 var coordinates1 = getCoord(start);
6556 var coordinates2 = getCoord(end);
6557
6558 var lon1 = degreesToRadians(coordinates1[0]);
6559 var lon2 = degreesToRadians(coordinates2[0]);
6560 var lat1 = degreesToRadians(coordinates1[1]);
6561 var lat2 = degreesToRadians(coordinates2[1]);
6562 var a = Math.sin(lon2 - lon1) * Math.cos(lat2);
6563 var b = Math.cos(lat1) * Math.sin(lat2) -
6564 Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
6565
6566 return radiansToDegrees(Math.atan2(a, b));
6567 }
6568
6569 /**
6570 * Calculates Final Bearing
6571 *
6572 * @private
6573 * @param {Coord} start starting Point
6574 * @param {Coord} end ending Point
6575 * @returns {number} bearing
6576 */
6577 function calculateFinalBearing(start, end) {
6578 // Swap start & end
6579 var bear = bearing(end, start);
6580 bear = (bear + 180) % 360;
6581 return bear;
6582 }
6583
6584 /**
6585 * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
6586 */
6587 var earthRadius = 6371008.8;
6588
6589 /**
6590 * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
6591 */
6592 var factors = {
6593 meters: earthRadius,
6594 metres: earthRadius,
6595 millimeters: earthRadius * 1000,
6596 millimetres: earthRadius * 1000,
6597 centimeters: earthRadius * 100,
6598 centimetres: earthRadius * 100,
6599 kilometers: earthRadius / 1000,
6600 kilometres: earthRadius / 1000,
6601 miles: earthRadius / 1609.344,
6602 nauticalmiles: earthRadius / 1852,
6603 inches: earthRadius * 39.370,
6604 yards: earthRadius / 1.0936,
6605 feet: earthRadius * 3.28084,
6606 radians: 1,
6607 degrees: earthRadius / 111325,
6608 };
6609
6610 /**
6611 * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
6612 *
6613 * @name feature
6614 * @param {Geometry} geometry input geometry
6615 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
6616 * @param {Object} [options={}] Optional Parameters
6617 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
6618 * @param {string|number} [options.id] Identifier associated with the Feature
6619 * @returns {Feature} a GeoJSON Feature
6620 * @example
6621 * var geometry = {
6622 * "type": "Point",
6623 * "coordinates": [110, 50]
6624 * };
6625 *
6626 * var feature = turf.feature(geometry);
6627 *
6628 * //=feature
6629 */
6630 function feature(geometry, properties, options) {
6631 // Optional Parameters
6632 options = options || {};
6633 if (!isObject$2(options)) throw new Error('options is invalid');
6634 var bbox = options.bbox;
6635 var id = options.id;
6636
6637 // Validation
6638 if (geometry === undefined) throw new Error('geometry is required');
6639 if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
6640 if (bbox) validateBBox(bbox);
6641 if (id) validateId(id);
6642
6643 // Main
6644 var feat = {type: 'Feature'};
6645 if (id) feat.id = id;
6646 if (bbox) feat.bbox = bbox;
6647 feat.properties = properties || {};
6648 feat.geometry = geometry;
6649 return feat;
6650 }
6651
6652 /**
6653 * Creates a {@link Point} {@link Feature} from a Position.
6654 *
6655 * @name point
6656 * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
6657 * @param {Object} [properties={}] an Object of key-value pairs to add as properties
6658 * @param {Object} [options={}] Optional Parameters
6659 * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
6660 * @param {string|number} [options.id] Identifier associated with the Feature
6661 * @returns {Feature<Point>} a Point feature
6662 * @example
6663 * var point = turf.point([-75.343, 39.984]);
6664 *
6665 * //=point
6666 */
6667 function point(coordinates, properties, options) {
6668 if (!coordinates) throw new Error('coordinates is required');
6669 if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
6670 if (coordinates.length < 2) throw new Error('coordinates must be at least 2 numbers long');
6671 if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('coordinates must contain numbers');
6672
6673 return feature({
6674 type: 'Point',
6675 coordinates: coordinates
6676 }, properties, options);
6677 }
6678
6679 /**
6680 * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
6681 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
6682 *
6683 * @name radiansToLength
6684 * @param {number} radians in radians across the sphere
6685 * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
6686 * @returns {number} distance
6687 */
6688 function radiansToLength(radians, units) {
6689 if (radians === undefined || radians === null) throw new Error('radians is required');
6690
6691 if (units && typeof units !== 'string') throw new Error('units must be a string');
6692 var factor = factors[units || 'kilometers'];
6693 if (!factor) throw new Error(units + ' units is invalid');
6694 return radians * factor;
6695 }
6696
6697 /**
6698 * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
6699 * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
6700 *
6701 * @name lengthToRadians
6702 * @param {number} distance in real units
6703 * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
6704 * @returns {number} radians
6705 */
6706 function lengthToRadians(distance, units) {
6707 if (distance === undefined || distance === null) throw new Error('distance is required');
6708
6709 if (units && typeof units !== 'string') throw new Error('units must be a string');
6710 var factor = factors[units || 'kilometers'];
6711 if (!factor) throw new Error(units + ' units is invalid');
6712 return distance / factor;
6713 }
6714
6715 /**
6716 * Converts an angle in radians to degrees
6717 *
6718 * @name radiansToDegrees
6719 * @param {number} radians angle in radians
6720 * @returns {number} degrees between 0 and 360 degrees
6721 */
6722 function radiansToDegrees$1(radians) {
6723 if (radians === null || radians === undefined) throw new Error('radians is required');
6724
6725 var degrees = radians % (2 * Math.PI);
6726 return degrees * 180 / Math.PI;
6727 }
6728
6729 /**
6730 * Converts an angle in degrees to radians
6731 *
6732 * @name degreesToRadians
6733 * @param {number} degrees angle between 0 and 360 degrees
6734 * @returns {number} angle in radians
6735 */
6736 function degreesToRadians$1(degrees) {
6737 if (degrees === null || degrees === undefined) throw new Error('degrees is required');
6738
6739 var radians = degrees % 360;
6740 return radians * Math.PI / 180;
6741 }
6742
6743 /**
6744 * isNumber
6745 *
6746 * @param {*} num Number to validate
6747 * @returns {boolean} true/false
6748 * @example
6749 * turf.isNumber(123)
6750 * //=true
6751 * turf.isNumber('foo')
6752 * //=false
6753 */
6754 function isNumber(num) {
6755 return !isNaN(num) && num !== null && !Array.isArray(num);
6756 }
6757
6758 /**
6759 * isObject
6760 *
6761 * @param {*} input variable to validate
6762 * @returns {boolean} true/false
6763 * @example
6764 * turf.isObject({elevation: 10})
6765 * //=true
6766 * turf.isObject('foo')
6767 * //=false
6768 */
6769 function isObject$2(input) {
6770 return (!!input) && (input.constructor === Object);
6771 }
6772
6773 /**
6774 * Validate BBox
6775 *
6776 * @private
6777 * @param {Array<number>} bbox BBox to validate
6778 * @returns {void}
6779 * @throws Error if BBox is not valid
6780 * @example
6781 * validateBBox([-180, -40, 110, 50])
6782 * //=OK
6783 * validateBBox([-180, -40])
6784 * //=Error
6785 * validateBBox('Foo')
6786 * //=Error
6787 * validateBBox(5)
6788 * //=Error
6789 * validateBBox(null)
6790 * //=Error
6791 * validateBBox(undefined)
6792 * //=Error
6793 */
6794 function validateBBox(bbox) {
6795 if (!bbox) throw new Error('bbox is required');
6796 if (!Array.isArray(bbox)) throw new Error('bbox must be an Array');
6797 if (bbox.length !== 4 && bbox.length !== 6) throw new Error('bbox must be an Array of 4 or 6 numbers');
6798 bbox.forEach(function (num) {
6799 if (!isNumber(num)) throw new Error('bbox must only contain numbers');
6800 });
6801 }
6802
6803 /**
6804 * Validate Id
6805 *
6806 * @private
6807 * @param {string|number} id Id to validate
6808 * @returns {void}
6809 * @throws Error if Id is not valid
6810 * @example
6811 * validateId([-180, -40, 110, 50])
6812 * //=Error
6813 * validateId([-180, -40])
6814 * //=Error
6815 * validateId('Foo')
6816 * //=OK
6817 * validateId(5)
6818 * //=OK
6819 * validateId(null)
6820 * //=Error
6821 * validateId(undefined)
6822 * //=Error
6823 */
6824 function validateId(id) {
6825 if (!id) throw new Error('id is required');
6826 if (['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
6827 }
6828
6829 /**
6830 * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
6831 *
6832 * @name getCoord
6833 * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
6834 * @returns {Array<number>} coordinates
6835 * @example
6836 * var pt = turf.point([10, 10]);
6837 *
6838 * var coord = turf.getCoord(pt);
6839 * //= [10, 10]
6840 */
6841 function getCoord$1(coord) {
6842 if (!coord) throw new Error('coord is required');
6843 if (coord.type === 'Feature' && coord.geometry !== null && coord.geometry.type === 'Point') return coord.geometry.coordinates;
6844 if (coord.type === 'Point') return coord.coordinates;
6845 if (Array.isArray(coord) && coord.length >= 2 && coord[0].length === undefined && coord[1].length === undefined) return coord;
6846
6847 throw new Error('coord must be GeoJSON Point or an Array of numbers');
6848 }
6849
6850 //http://en.wikipedia.org/wiki/Haversine_formula
6851 //http://www.movable-type.co.uk/scripts/latlong.html
6852 /**
6853 * Takes a {@link Point} and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
6854 *
6855 * @name destination
6856 * @param {Coord} origin starting point
6857 * @param {number} distance distance from the origin point
6858 * @param {number} bearing ranging from -180 to 180
6859 * @param {Object} [options={}] Optional parameters
6860 * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
6861 * @param {Object} [options.properties={}] Translate properties to Point
6862 * @returns {Feature<Point>} destination point
6863 * @example
6864 * var point = turf.point([-75.343, 39.984]);
6865 * var distance = 50;
6866 * var bearing = 90;
6867 * var options = {units: 'miles'};
6868 *
6869 * var destination = turf.destination(point, distance, bearing, options);
6870 *
6871 * //addToMap
6872 * var addToMap = [point, destination]
6873 * destination.properties['marker-color'] = '#f00';
6874 * point.properties['marker-color'] = '#0f0';
6875 */
6876 function destination(origin, distance, bearing, options) {
6877 // Optional parameters
6878 options = options || {};
6879 if (!isObject$2(options)) throw new Error('options is invalid');
6880 var units = options.units;
6881 var properties = options.properties;
6882
6883 // Handle input
6884 var coordinates1 = getCoord$1(origin);
6885 var longitude1 = degreesToRadians$1(coordinates1[0]);
6886 var latitude1 = degreesToRadians$1(coordinates1[1]);
6887 var bearing_rad = degreesToRadians$1(bearing);
6888 var radians = lengthToRadians(distance, units);
6889
6890 // Main
6891 var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
6892 Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
6893 var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
6894 Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
6895 var lng = radiansToDegrees$1(longitude2);
6896 var lat = radiansToDegrees$1(latitude2);
6897
6898 return point([lng, lat], properties);
6899 }
6900
6901 //http://en.wikipedia.org/wiki/Haversine_formula
6902 //http://www.movable-type.co.uk/scripts/latlong.html
6903
6904 /**
6905 * Calculates the distance between two {@link Point|points} in degrees, radians,
6906 * miles, or kilometers. This uses the
6907 * [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula)
6908 * to account for global curvature.
6909 *
6910 * @name distance
6911 * @param {Coord} from origin point
6912 * @param {Coord} to destination point
6913 * @param {Object} [options={}] Optional parameters
6914 * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
6915 * @returns {number} distance between the two points
6916 * @example
6917 * var from = turf.point([-75.343, 39.984]);
6918 * var to = turf.point([-75.534, 39.123]);
6919 * var options = {units: 'miles'};
6920 *
6921 * var distance = turf.distance(from, to, options);
6922 *
6923 * //addToMap
6924 * var addToMap = [from, to];
6925 * from.properties.distance = distance;
6926 * to.properties.distance = distance;
6927 */
6928 function distance(from, to, options) {
6929 // Optional parameters
6930 options = options || {};
6931 if (!isObject$2(options)) throw new Error('options is invalid');
6932 var units = options.units;
6933
6934 var coordinates1 = getCoord$1(from);
6935 var coordinates2 = getCoord$1(to);
6936 var dLat = degreesToRadians$1((coordinates2[1] - coordinates1[1]));
6937 var dLon = degreesToRadians$1((coordinates2[0] - coordinates1[0]));
6938 var lat1 = degreesToRadians$1(coordinates1[1]);
6939 var lat2 = degreesToRadians$1(coordinates2[1]);
6940
6941 var a = Math.pow(Math.sin(dLat / 2), 2) +
6942 Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
6943
6944 return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units);
6945 }
6946
6947 /**
6948 * Takes two {@link Point|points} and returns a point midway between them.
6949 * The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.
6950 *
6951 * @name midpoint
6952 * @param {Coord} point1 first point
6953 * @param {Coord} point2 second point
6954 * @returns {Feature<Point>} a point midway between `pt1` and `pt2`
6955 * @example
6956 * var point1 = turf.point([144.834823, -37.771257]);
6957 * var point2 = turf.point([145.14244, -37.830937]);
6958 *
6959 * var midpoint = turf.midpoint(point1, point2);
6960 *
6961 * //addToMap
6962 * var addToMap = [point1, point2, midpoint];
6963 * midpoint.properties['marker-color'] = '#f00';
6964 */
6965 function midpoint(point1, point2) {
6966 var dist = distance(point1, point2);
6967 var heading = bearing(point1, point2);
6968 var midpoint = destination(point1, dist / 2, heading);
6969
6970 return midpoint;
6971 }
6972
6973 var DrawVertexLayer$1 = /*#__PURE__*/function (_BaseRender) {
6974 _inherits(DrawVertexLayer, _BaseRender);
6975
6976 var _super = _createSuper(DrawVertexLayer);
6977
6978 function DrawVertexLayer() {
6979 var _this;
6980
6981 _classCallCheck(this, DrawVertexLayer);
6982
6983 _this = _super.apply(this, arguments);
6984
6985 _this.onMouseEnter = function (e) {
6986 _this.draw.setCursor('pointer');
6987 };
6988
6989 _this.onMouseOut = function (e) {
6990 _this.draw.resetCursor();
6991 };
6992
6993 _this.onClick = function (e) {
6994 _this.draw.addVertex(e.feature); // 添加一个顶点 1.更新顶点 2.更新重点
6995
6996 };
6997
6998 return _this;
6999 }
7000
7001 _createClass(DrawVertexLayer, [{
7002 key: "update",
7003 value: function update(pointFeatures) {
7004 this.removeLayers();
7005 var midFeatures = this.calcMidPointData(pointFeatures);
7006 var style = this.draw.getStyle('mid_point');
7007 this.drawLayers = renderFeature(midFeatures, style);
7008 this.addLayers();
7009 this.enableEdit();
7010 }
7011 }, {
7012 key: "updateData",
7013 value: function updateData(data) {
7014 var midFeatures = this.calcMidPointData(data);
7015 this.drawLayers.forEach(function (layer) {
7016 return layer.setData(midFeatures);
7017 });
7018 }
7019 }, {
7020 key: "enableEdit",
7021 value: function enableEdit() {
7022 var layer = this.drawLayers[0];
7023 layer.on('mouseenter', this.onMouseEnter);
7024 layer.on('mouseout', this.onMouseOut);
7025 layer.on('click', this.onClick);
7026 }
7027 }, {
7028 key: "disableEdit",
7029 value: function disableEdit() {
7030 var layer = this.drawLayers[0];
7031 layer.off('mouseenter', this.onMouseEnter);
7032 layer.off('mouseout', this.onMouseOut);
7033 layer.off('click', this.onClick);
7034 }
7035 }, {
7036 key: "calcMidPointData",
7037 value: function calcMidPointData(fe) {
7038 var _this2 = this;
7039
7040 var midFeatures = [];
7041 fe.features.forEach(function (item, index) {
7042 var preFeature = item;
7043
7044 if (_this2.draw.type === 'line' && index === fe.features.length - 1) {
7045 return;
7046 }
7047
7048 var nextFeature = index !== fe.features.length - 1 ? fe.features[index + 1] : fe.features[0]; // @ts-ignore
7049
7050 var point = midpoint(preFeature, nextFeature); // @ts-ignore
7051
7052 point.properties.id = index;
7053 midFeatures.push(point);
7054 });
7055 return helpers_13(midFeatures);
7056 }
7057 }]);
7058
7059 return DrawVertexLayer;
7060 }(BaseRenderLayer);
7061
7062 var DrawPolygon = /*#__PURE__*/function (_DrawFeature) {
7063 _inherits(DrawPolygon, _DrawFeature);
7064
7065 var _super = _createSuper(DrawPolygon);
7066
7067 function DrawPolygon(scene) {
7068 var _this;
7069
7070 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7071
7072 _classCallCheck(this, DrawPolygon);
7073
7074 _this = _super.call(this, scene, options);
7075 _this.points = [];
7076
7077 _this.onDragStart = function (e) {
7078 return null;
7079 };
7080
7081 _this.onDragging = function (e) {
7082 return null;
7083 };
7084
7085 _this.onDragEnd = function () {
7086 return null;
7087 };
7088
7089 _this.onClick = function (e) {
7090 if (_this.drawStatus !== 'Drawing') {
7091 _this.drawLayer.emit('unclick', null);
7092 }
7093
7094 var lngLat = e.lngLat || e.lnglat;
7095 _this.endPoint = lngLat;
7096
7097 _this.points.push(lngLat);
7098
7099 var feature = _this.createFeature(_this.points);
7100
7101 var pointfeatures = createPoint([_this.points[0], _this.endPoint]);
7102
7103 _this.drawLayer.update(helpers_13([feature]));
7104
7105 _this.drawVertexLayer.update(helpers_13(pointfeatures.features));
7106
7107 _this.onDraw();
7108 };
7109
7110 _this.onMouseMove = function (e) {
7111 var lngLat = e.lngLat || e.lnglat;
7112
7113 if (_this.points.length === 0) {
7114 return;
7115 }
7116
7117 var tmpPoints = _this.points.slice();
7118
7119 tmpPoints.push(lngLat);
7120
7121 var feature = _this.createFeature(tmpPoints);
7122
7123 _this.drawLayer.update(helpers_13([feature]));
7124 };
7125
7126 _this.onDblClick = function (e) {
7127 var lngLat = e.lngLat || e.lnglat;
7128
7129 if (_this.points.length < 2) {
7130 return;
7131 }
7132
7133 _this.points.push(lngLat);
7134
7135 _this.drawFinish();
7136 };
7137
7138 _this.onDraw = function () {
7139 _this.drawVertexLayer.on('mousemove', function (e) {
7140 _this.setCursor('pointer');
7141 });
7142
7143 _this.drawVertexLayer.on('mouseout', function () {
7144 _this.setCursor('crosshair');
7145 });
7146
7147 _this.drawVertexLayer.on('click', function () {
7148 _this.resetCursor();
7149
7150 _this.drawFinish();
7151 });
7152 };
7153
7154 _this.type = 'polygon';
7155 _this.drawMidVertexLayer = new DrawVertexLayer$1(_assertThisInitialized(_this));
7156
7157 _this.on(DrawEvent.MODE_CHANGE, _this.addMidLayerEvent);
7158
7159 return _this;
7160 }
7161
7162 _createClass(DrawPolygon, [{
7163 key: "enable",
7164 value: function enable() {
7165 _get(_getPrototypeOf(DrawPolygon.prototype), "enable", this).call(this);
7166
7167 this.scene.on('mousemove', this.onMouseMove);
7168 this.scene.on('dblclick', this.onDblClick); // 关闭双击放大
7169 }
7170 }, {
7171 key: "disable",
7172 value: function disable() {
7173 _get(_getPrototypeOf(DrawPolygon.prototype), "disable", this).call(this);
7174
7175 this.scene.off('mousemove', this.onMouseMove);
7176 this.scene.off('dblclick', this.onDblClick);
7177 }
7178 }, {
7179 key: "drawFinish",
7180 value: function drawFinish() {
7181 this.points = this.points.reverse();
7182 var feature = this.createFeature(this.points);
7183 var properties = feature.properties;
7184 this.drawLayer.update(helpers_13([feature]));
7185 this.drawVertexLayer.update(helpers_13(properties.pointFeatures)); // @ts-ignore
7186
7187 this.emit(DrawEvent.CREATE, this.currentFeature);
7188 this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
7189 this.points = [];
7190 this.disable();
7191 }
7192 }, {
7193 key: "addVertex",
7194 value: function addVertex(vertex) {
7195 var _vertex$geometry, _feature$geometry;
7196
7197 // @ts-ignore
7198 var id = vertex.properties.id;
7199 var coord = vertex === null || vertex === void 0 ? void 0 : (_vertex$geometry = vertex.geometry) === null || _vertex$geometry === void 0 ? void 0 : _vertex$geometry.coordinates;
7200 var feature = this.currentFeature;
7201 var type = feature === null || feature === void 0 ? void 0 : (_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type;
7202 var points = [];
7203
7204 if (type === 'Polygon') {
7205 var _feature$geometry2;
7206
7207 var coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry2 = feature.geometry) === null || _feature$geometry2 === void 0 ? void 0 : _feature$geometry2.coordinates;
7208 coords[0].splice(id + 1, 0, coord);
7209
7210 for (var i = 0; i < coords[0].length - 1; i++) {
7211 points.push({
7212 lng: coords[0][i][0],
7213 lat: coords[0][i][1]
7214 });
7215 }
7216 } else {
7217 var _feature$geometry3;
7218
7219 var _coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry3 = feature.geometry) === null || _feature$geometry3 === void 0 ? void 0 : _feature$geometry3.coordinates;
7220
7221 _coords.splice(id + 1, 0, coord);
7222
7223 var _iterator = _createForOfIteratorHelper(_coords),
7224 _step;
7225
7226 try {
7227 for (_iterator.s(); !(_step = _iterator.n()).done;) {
7228 var coor = _step.value;
7229 points.push({
7230 lng: coor[0],
7231 lat: coor[1]
7232 });
7233 }
7234 } catch (err) {
7235 _iterator.e(err);
7236 } finally {
7237 _iterator.f();
7238 }
7239 }
7240
7241 var pointfeatures = createPoint(points);
7242 this.pointFeatures = pointfeatures.features;
7243 this.drawLayer.updateData(helpers_13([feature]));
7244 this.drawVertexLayer.updateData(pointfeatures);
7245 this.drawMidVertexLayer.updateData(helpers_13(this.pointFeatures)); // @ts-ignore
7246
7247 feature.properties.pointFeatures = pointfeatures.features;
7248 this.setCurrentFeature(feature);
7249 }
7250 }, {
7251 key: "getDefaultOptions",
7252 value: function getDefaultOptions() {
7253 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawPolygon.prototype), "getDefaultOptions", this).call(this)), {}, {
7254 title: '绘制多边形'
7255 });
7256 }
7257 }, {
7258 key: "moveFeature",
7259 value: function moveFeature(delta) {
7260 var newFeature = moveFeatures([this.currentFeature], delta);
7261 var newPointFeture = moveFeatures(this.pointFeatures, delta);
7262 this.drawLayer.updateData(helpers_13(newFeature));
7263 this.drawVertexLayer.updateData(helpers_13(newPointFeture));
7264 newFeature[0].properties = _objectSpread2(_objectSpread2({}, newFeature[0].properties), {}, {
7265 pointFeatures: newPointFeture
7266 });
7267 this.setCurrentFeature(newFeature[0]);
7268 }
7269 }, {
7270 key: "createFeature",
7271 value: function createFeature(points, id) {
7272 var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7273 var pointfeatures = createPoint(points);
7274 this.pointFeatures = pointfeatures.features;
7275 var feature = createPolygon(points, {
7276 id: id || this.getUniqId(),
7277 type: 'polygon',
7278 active: active,
7279 pointFeatures: this.pointFeatures
7280 });
7281 this.setCurrentFeature(feature);
7282 return feature;
7283 }
7284 }, {
7285 key: "editFeature",
7286 value: function editFeature(vertex) {
7287 var selectVertexed = this.currentVertex;
7288
7289 if (selectVertexed === null) {
7290 return;
7291 } else {
7292 var _this$currentFeature;
7293
7294 // @ts-ignore
7295 var id = selectVertexed.properties.id * 1; // @ts-ignore
7296
7297 selectVertexed.geometry.coordinates = [vertex.lng, vertex.lat]; // @ts-ignore
7298
7299 this.pointFeatures[id].geometry.coordinates = [vertex.lng, vertex.lat];
7300 this.drawVertexLayer.updateData(helpers_13(this.pointFeatures));
7301 this.drawMidVertexLayer.updateData(helpers_13(this.pointFeatures));
7302 this.editPolygonVertex(id, vertex);
7303 this.drawLayer.updateData(helpers_13([this.currentFeature]));
7304 var feature = this.currentFeature;
7305 feature.properties = _objectSpread2(_objectSpread2({}, (_this$currentFeature = this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : _this$currentFeature.properties), {}, {
7306 pointFeatures: this.pointFeatures
7307 });
7308 this.setCurrentFeature(feature);
7309 }
7310 }
7311 }, {
7312 key: "showOtherLayer",
7313 value: function showOtherLayer() {
7314 // if (this.editMode.isEnable) {
7315 // this.drawMidVertexLayer.update(featureCollection(this.pointFeatures));
7316 // this.drawMidVertexLayer.show();
7317 // }
7318 return null;
7319 }
7320 }, {
7321 key: "hideOtherLayer",
7322 value: function hideOtherLayer() {
7323 return null;
7324 }
7325 }, {
7326 key: "addMidLayerEvent",
7327 value: function addMidLayerEvent(mode) {
7328 switch (mode) {
7329 case DrawModes.DIRECT_SELECT:
7330 this.drawMidVertexLayer.update(helpers_13(this.pointFeatures));
7331 this.drawMidVertexLayer.show();
7332 break;
7333
7334 case DrawModes.STATIC:
7335 this.drawMidVertexLayer.hide();
7336 break;
7337 }
7338 }
7339 }, {
7340 key: "initData",
7341 value: function initData() {
7342 var _this2 = this;
7343
7344 var features = [];
7345 this.source.data.features.forEach(function (feature) {
7346 if (feature.geometry.type === 'Polygon') {
7347 var _feature$properties;
7348
7349 var points = feature.geometry.coordinates[0].map(function (coord) {
7350 return {
7351 lng: coord[0],
7352 lat: coord[1]
7353 };
7354 });
7355 features.push(_this2.createFeature(points.slice(1), feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
7356 }
7357 });
7358 this.source.data.features = features;
7359 return true;
7360 }
7361 }, {
7362 key: "editPolygonVertex",
7363 value: function editPolygonVertex(id, vertex) {
7364 var _feature$geometry4;
7365
7366 var feature = this.currentFeature;
7367 var type = feature === null || feature === void 0 ? void 0 : (_feature$geometry4 = feature.geometry) === null || _feature$geometry4 === void 0 ? void 0 : _feature$geometry4.type;
7368
7369 if (type === 'Polygon') {
7370 var _feature$geometry5;
7371
7372 var coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry5 = feature.geometry) === null || _feature$geometry5 === void 0 ? void 0 : _feature$geometry5.coordinates;
7373 coords[0][id] = [vertex.lng, vertex.lat];
7374
7375 if (-id === 0) {
7376 coords[0][coords[0].length - 1] = [vertex.lng, vertex.lat];
7377 }
7378 } else {
7379 var _feature$geometry6;
7380
7381 var _coords2 = feature === null || feature === void 0 ? void 0 : (_feature$geometry6 = feature.geometry) === null || _feature$geometry6 === void 0 ? void 0 : _feature$geometry6.coordinates;
7382
7383 _coords2[id] = [vertex.lng, vertex.lat];
7384 }
7385
7386 this.setCurrentFeature(feature);
7387 this.drawLayer.updateData(helpers_13([this.currentFeature]));
7388 }
7389 }]);
7390
7391 return DrawPolygon;
7392 }(DrawFeature);
7393
7394 var DrawLine = /*#__PURE__*/function (_DrawPolygon) {
7395 _inherits(DrawLine, _DrawPolygon);
7396
7397 var _super = _createSuper(DrawLine);
7398
7399 function DrawLine(scene) {
7400 var _this;
7401
7402 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7403
7404 _classCallCheck(this, DrawLine);
7405
7406 _this = _super.call(this, scene, options);
7407 _this.type = 'line';
7408 return _this;
7409 }
7410
7411 _createClass(DrawLine, [{
7412 key: "getDefaultOptions",
7413 value: function getDefaultOptions() {
7414 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawLine.prototype), "getDefaultOptions", this).call(this)), {}, {
7415 title: '绘制线'
7416 });
7417 }
7418 }, {
7419 key: "moveFeature",
7420 value: function moveFeature(delta) {
7421 var newFeature = moveFeatures([this.currentFeature], delta);
7422 var newPointFeture = moveFeatures(this.pointFeatures, delta);
7423 this.drawLayer.updateData(helpers_13(newFeature));
7424 this.drawVertexLayer.updateData(helpers_13(newPointFeture));
7425 this.currentFeature = newFeature[0];
7426 this.pointFeatures = newPointFeture;
7427 return this.currentFeature;
7428 }
7429 }, {
7430 key: "createFeature",
7431 value: function createFeature(points, id) {
7432 var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7433 var pointfeatures = createPoint(points);
7434 this.pointFeatures = pointfeatures.features;
7435 var feature = createLine(points, {
7436 id: id || this.getUniqId(),
7437 type: 'line',
7438 active: active,
7439 pointFeatures: this.pointFeatures
7440 });
7441 this.setCurrentFeature(feature);
7442 return feature;
7443 }
7444 }, {
7445 key: "initData",
7446 value: function initData() {
7447 var _this2 = this;
7448
7449 var features = [];
7450 this.source.data.features.forEach(function (feature) {
7451 if (feature.geometry.type === 'LineString') {
7452 var _feature$properties;
7453
7454 // @ts-ignore
7455 var points = feature.geometry.coordinates.map(function (coord) {
7456 return {
7457 lng: coord[0],
7458 lat: coord[1]
7459 };
7460 });
7461 features.push(_this2.createFeature(points, feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
7462 }
7463 });
7464 this.source.data.features = features;
7465 return true;
7466 }
7467 }]);
7468
7469 return DrawLine;
7470 }(DrawPolygon);
7471
7472 var DrawPoint = /*#__PURE__*/function (_DrawFeature) {
7473 _inherits(DrawPoint, _DrawFeature);
7474
7475 var _super = _createSuper(DrawPoint);
7476
7477 function DrawPoint(scene) {
7478 var _this;
7479
7480 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7481
7482 _classCallCheck(this, DrawPoint);
7483
7484 _this = _super.call(this, scene, options);
7485
7486 _this.onDragStart = function (e) {
7487 return null;
7488 };
7489
7490 _this.onDragging = function (e) {
7491 return null;
7492 };
7493
7494 _this.onDragEnd = function () {
7495 return null;
7496 };
7497
7498 _this.onClick = function (e) {
7499 if (_this.drawStatus !== 'Drawing') {
7500 _this.drawLayer.emit('unclick', null);
7501 }
7502
7503 var lngLat = e.lngLat || e.lnglat;
7504
7505 var feature = _this.createFeature(lngLat);
7506
7507 _this.drawLayer.update(helpers_13([feature]));
7508
7509 _this.drawVertexLayer.update(helpers_13([feature]));
7510
7511 _this.drawFinish();
7512 };
7513
7514 _this.type = 'point';
7515 return _this;
7516 }
7517
7518 _createClass(DrawPoint, [{
7519 key: "drawFinish",
7520 value: function drawFinish() {
7521 this.emit(DrawEvent.CREATE, this.currentFeature);
7522 this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
7523 this.disable();
7524 }
7525 }, {
7526 key: "getDefaultOptions",
7527 value: function getDefaultOptions() {
7528 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawPoint.prototype), "getDefaultOptions", this).call(this)), {}, {
7529 title: '绘制点'
7530 });
7531 }
7532 }, {
7533 key: "moveFeature",
7534 value: function moveFeature(delta) {
7535 var newFeature = moveFeatures([this.currentFeature], delta);
7536 this.drawLayer.updateData(helpers_13(newFeature));
7537 this.drawVertexLayer.updateData(helpers_13(newFeature));
7538 this.currentFeature = newFeature[0];
7539 this.pointFeatures = newFeature;
7540 this.currentFeature.properties = _objectSpread2(_objectSpread2({}, this.currentFeature.properties), {}, {
7541 pointFeatures: newFeature
7542 });
7543 return this.currentFeature;
7544 }
7545 }, {
7546 key: "createFeature",
7547 value: function createFeature(p, id) {
7548 var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7549 var feature = helpers_7([p.lng, p.lat], {
7550 id: id || this.getUniqId(),
7551 type: 'point',
7552 active: active,
7553 pointFeatures: [helpers_7([p.lng, p.lat])]
7554 });
7555 this.setCurrentFeature(feature);
7556 return feature;
7557 }
7558 }, {
7559 key: "initData",
7560 value: function initData() {
7561 var _this2 = this;
7562
7563 var features = [];
7564 this.source.data.features.forEach(function (feature) {
7565 if (feature.geometry.type === 'Point') {
7566 var _feature$properties;
7567
7568 var p = {
7569 lng: feature.geometry.coordinates[0],
7570 lat: feature.geometry.coordinates[1]
7571 };
7572 features.push(_this2.createFeature(p, feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
7573 }
7574 });
7575 this.source.data.features = features;
7576 return true;
7577 }
7578 }, {
7579 key: "editFeature",
7580 value: function editFeature(endPoint) {
7581 this.createFeature(endPoint);
7582 }
7583 }, {
7584 key: "showOtherLayer",
7585 value: function showOtherLayer() {
7586 return null;
7587 }
7588 }, {
7589 key: "hideOtherLayer",
7590 value: function hideOtherLayer() {
7591 return null;
7592 }
7593 }]);
7594
7595 return DrawPoint;
7596 }(DrawFeature);
7597
7598 var DrawRect = /*#__PURE__*/function (_DrawCircle) {
7599 _inherits(DrawRect, _DrawCircle);
7600
7601 var _super = _createSuper(DrawRect);
7602
7603 function DrawRect(scene) {
7604 var _this;
7605
7606 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7607
7608 _classCallCheck(this, DrawRect);
7609
7610 _this = _super.call(this, scene, options);
7611 _this.type = 'rect';
7612 return _this;
7613 }
7614
7615 _createClass(DrawRect, [{
7616 key: "drawFinish",
7617 value: function drawFinish() {
7618 return null;
7619 }
7620 }, {
7621 key: "getDefaultOptions",
7622 value: function getDefaultOptions() {
7623 return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawRect.prototype), "getDefaultOptions", this).call(this)), {}, {
7624 title: '绘制矩形'
7625 });
7626 }
7627 }, {
7628 key: "createFeature",
7629 value: function createFeature() {
7630 var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0';
7631 var points = createPoint([this.endPoint]);
7632 var feature = createRect([this.startPoint.lng, this.startPoint.lat], [this.endPoint.lng, this.endPoint.lat], {
7633 id: id,
7634 pointFeatures: points.features
7635 });
7636 this.setCurrentFeature(feature);
7637 return feature;
7638 }
7639 }]);
7640
7641 return DrawRect;
7642 }(DrawCircle);
7643
7644 function styleInject(css, ref) {
7645 if ( ref === void 0 ) ref = {};
7646 var insertAt = ref.insertAt;
7647
7648 if (!css || typeof document === 'undefined') { return; }
7649
7650 var head = document.head || document.getElementsByTagName('head')[0];
7651 var style = document.createElement('style');
7652 style.type = 'text/css';
7653
7654 if (insertAt === 'top') {
7655 if (head.firstChild) {
7656 head.insertBefore(style, head.firstChild);
7657 } else {
7658 head.appendChild(style);
7659 }
7660 } else {
7661 head.appendChild(style);
7662 }
7663
7664 if (style.styleSheet) {
7665 style.styleSheet.cssText = css;
7666 } else {
7667 style.appendChild(document.createTextNode(css));
7668 }
7669 }
7670
7671 var css = ".l7-control-draw {\n border-radius: 4px;\n background: #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);\n display: flex;\n}\n.l7-control-draw button {\n background-repeat: no-repeat;\n background-position: center;\n background-size: 20px 20px;\n background-color: #fff;\n width: 30px;\n height: 30px;\n display: block;\n padding: 0;\n outline: none;\n border: 0;\n margin: 1px;\n box-sizing: border-box;\n cursor: pointer;\n}\n.l7-control-draw button:not(:disabled):hover {\n background-color: rgba(0, 0, 0, 0.05);\n}\n.l7-control-draw button:focus {\n box-shadow: 0 0 2px 2px #0096ff;\n}\n.l7-control-draw .draw-point {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjYxMTY0NjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDExOTQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI5MzUiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTQ5LjI1IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNjA5LjUzNiA3MDcuMDcyYTE5NS4wNzIgMTk1LjA3MiAwIDEgMSAwLTM5MC4xNDQgMTk1LjA3MiAxOTUuMDcyIDAgMCAxIDAgMzkwLjE0NHoiIGZpbGw9IiMyYzJjMmMiIHAtaWQ9IjI5MzYiPjwvcGF0aD48cGF0aCBkPSJNMTA0OC40MDUzMzMgNDE0LjQ2NGExNDYuMjYxMzMzIDE0Ni4yNjEzMzMgMCAxIDEgMC0yOTIuNTIyNjY3IDE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6TTE3MC42NjY2NjcgOTk5LjU5NDY2N2ExNDYuMjYxMzMzIDE0Ni4yNjEzMzMgMCAxIDEgMC0yOTIuNTIyNjY3IDE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6IG0wLTY4Mi42NjY2NjdBMTQ2LjI2MTMzMyAxNDYuMjYxMzMzIDAgMSAxIDE3MC42NjY2NjcgMjQuNDA1MzMzYTE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6IiBmaWxsPSIjMmMyYzJjIiBwLWlkPSIyOTM3Ij48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-line {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjYxMDY5NTk0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxOTMiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNOTAwLjkzIDMwMC4yOThjLTQxLjA2NyAwLTc0LjQ3IDMzLjQyOS03NC40NyA3NC40OTEgMCAxMCAxLjk5MiAxOS41MzMgNS41ODEgMjguMjU3bC0yMjAuMjYyIDIwNS4xOGE3My45OSA3My45OSAwIDAgMC00MS4yMzItMTIuNTA0IDc0LjE3IDc0LjE3IDAgMCAwLTIyLjQ1MSAzLjQ1MWwtNzAuMTEzLTEzOS42MzhhNzQuMTM4IDc0LjEzOCAwIDAgMCA4LjE0Ni0zMy45MmMwLTQxLjA2Mi0zMy4zODMtNzQuNDktNzQuNDQ1LTc0LjQ5cy03NC40NDUgMzMuNDI4LTc0LjQ0NSA3NC40OWMwIDMuODI1IDAuMjkyIDcuNjA0IDAuODU1IDExLjMxNkwxNjAuODYgNjI3LjIyYTczLjg4NyA3My44ODcgMCAwIDAtMzkuNzk4LTExLjU5N2MtNDEuMDYyIDAtNzQuNDcgMzMuNDIzLTc0LjQ3IDc0LjQ5IDAgNDEuMDgzIDMzLjQwOCA3NC41MTcgNzQuNDcgNzQuNTE3IDQxLjA0MiAwIDc0LjQyLTMzLjQyOCA3NC40Mi03NC41MTZhNzQuMjMgNzQuMjMgMCAwIDAtMy4yOTMtMjEuODk5bDE3MS40MzMtMTg1LjcxMmE3NC40NTUgNzQuNDU1IDAgMCAwIDc2LjMzNCAxMi4wNzhsNjcuMzkgMTM2LjE5MmE3NC4xNjggNzQuMTY4IDAgMCAwLTExLjIzOCAzOS40NWMwIDQxLjA4MiAzMy4zODIgNzQuNTE2IDc0LjQ0NCA3NC41MTYgNDEuMDY4IDAgNzQuNDQ1LTMzLjQyOSA3NC40NDUtNzQuNTE3YTc0LjM0MiA3NC4zNDIgMCAwIDAtMi43MjQtMTkuOTE2bDIyNC42NzEtMjA5LjI2NWE3My45NjQgNzMuOTY0IDAgMCAwIDMzLjk5MiA4LjI0OGM0MS4wNDIgMCA3NC40MTktMzMuNDI4IDc0LjQxOS03NC40OS0wLjAxLTQxLjA2OC0zMy4zODgtNzQuNTAyLTc0LjQyNC03NC41MDJ6TTEyMS4wNjkgNzEzLjA0MmEyMi45MTcgMjIuOTE3IDAgMCAxIDAtNDUuODMgMjIuOTMyIDIyLjkzMiAwIDAgMSAyMi44NzYgMjIuOTAzYy0wLjAwNSAxMi42NDYtMTAuMjg2IDIyLjkyNy0yMi44NzYgMjIuOTI3eiBtMjc2LjMxLTI2OS41MzdhMjIuODYgMjIuODYgMCAwIDEtOC41OS0xNy44OSAyMi45MzggMjIuOTM4IDAgMCAxIDIyLjkwMS0yMi45MDEgMjIuOTEyIDIyLjkxMiAwIDAgMSAyMi44NzYgMjIuOTAxYzAgNi4wNDctMi4zMiAxMS43MjUtNi41MDcgMTYuMDFsLTAuMiAwLjE4NWMtOS4wNjggOS4wNTItMjUuMDQyIDYuMDc3LTMwLjQ4IDEuNjk1ek01NzAuNTUzIDY5My4xNGEyMi45MjIgMjIuOTIyIDAgMCAxLTIyLjg3Ni0yMi45MjcgMjIuNzMzIDIyLjczMyAwIDAgMSA4LjI4LTE3LjYyM2MwLjMzNy0wLjI0IDAuNjg1LTAuNDgxIDEuMDEzLTAuNzQyIDAuMi0wLjE1OSAwLjM5LTAuMzIzIDAuNTg0LTAuNDkyYTIyLjY0IDIyLjY0IDAgMCAxIDEyLjk5NC00LjA0NSAyMi45MjcgMjIuOTI3IDAgMCAxIDIyLjg4MSAyMi45MDIgMjIuOTM4IDIyLjkzOCAwIDAgMS0yMi44NzYgMjIuOTI3eiBtMzMwLjM3OS0yOTUuNDVjLTEyLjY1MiAwLTIyLjkwMi0xMC4yOC0yMi45MDItMjIuOXMxMC4yNS0yMi45MDMgMjIuOTAyLTIyLjkwM2EyMi45MjcgMjIuOTI3IDAgMCAxIDIyLjg3IDIyLjkwMiAyMi45MjcgMjIuOTI3IDAgMCAxLTIyLjg3IDIyLjkwMnoiIHAtaWQ9IjIxOTQiPjwvcGF0aD48L3N2Zz4=');\n}\n.l7-control-draw .draw-polygon {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5MzI3Nzc1IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3MzkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNDIxLjE0OSA5OTAuNDA0bC0xNDMuMzE4LTEzNy4xNS00My42NzktNDEuNzY0TDMxLjg0OSA2MTcuODUzbDIzNC4wNzQtNDg1LjQ4OCAxMjUuMTQxIDE3LjAyNiAxMDMuNjE0IDE0LjA0MS04LjA1NyA1OS40NTYtMTAzLjYzLTE0LjA0My04MS45Ni0xMS4xNTEtOTguMTAzIDIwMy40MzItOTguMTA1IDIwMy41MTkgMTcwLjgwNiAxNjMuNDkgNDMuNjgxIDQxLjc2NiAzNi4xNTcgMzQuNjE2IDc1LjY5OCA3Mi40IDM2LjUyOS0xOS42MjEgNTUuNzE4LTI5Ljk3MSA1MS43MDctMjcuNzM2IDUxLjgzNC0yNy45NjcgMTcuMTEtOS4xMTQgMTcuMTg4LTkuMyAzNC40NzYtMTguNDggMTcuMjM5LTkuMyAzNC41NDItMTguNTA1IDE3LjMxNS05LjM4NyAxNy4yNTYtOS4yMDEgNDYuOTgtMjUuMjkzLTQuOTk1LTI3LjM3NS04LjgzNi00OC45NjYtMTUuMzQxLTg0Ljg5MSA1OS4wNDQtMTAuNjcgMTUuMzQyIDg0Ljg5OCA4LjgyNyA0OC45MTggMTIuODMxIDcwLjMyOC0zMy43MTcgMTguMDQ5LTUxLjgyNyAyNy45MDQtMTcuMjM2IDkuMTktMTcuMjcyIDkuMzY1LTM0LjQ5MyAxOC40NzgtMzQuNTMxIDE4LjU3Ni0xNy4yMTMgOS4yMi0xNy4yOTIgOS4zNTYtMTcuMDk3IDkuMTA2LTE3LjIxOCA5LjMzNXoiIGZpbGw9IiMzRTNBMzkiIHAtaWQ9IjE3NDAiPjwvcGF0aD48cGF0aCBkPSJNNzUyLjUyNCA1NS40MzRoNjB2MzcwLjMyM2gtNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxNzQxIj48L3BhdGg+PHBhdGggZD0iTTU5Ny4zODUgMjA1LjY5N2gzNzAuMjc5djYwSDU5Ny4zODV6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxNzQyIj48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-rect {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5Mjk5NTYxIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjEwMDEiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNzY1LjIzNCA2OS40MTdoNjB2MzcwLjYwNWgtNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDAyIj48L3BhdGg+PHBhdGggZD0iTTYxNC4xOTMgMjE5LjgwN2gzNjIuMTI4djYwSDYxNC4xOTN6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDAzIj48L3BhdGg+PHBhdGggZD0iTTgyNS4yMzQgOTc1LjkzNkg4OS44MTlWMjI0LjcwN2gzNjcuNzA4djYwSDE0OS44MTl2NjMxLjIyOWg2MTUuNDE1VjYwMC4yOTloNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDA0Ij48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-circle {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5MjYwMDI2IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI3NzYiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDg4MS4wNjY2NjdBMzY5LjA2NjY2NyAzNjkuMDY2NjY3IDAgMSAxIDg4MS4wNjY2NjcgNTEyIDM2OS40OTMzMzMgMzY5LjQ5MzMzMyAwIDAgMSA1MTIgODgxLjA2NjY2N3ogbTAtNjgyLjY2NjY2N0EzMTMuNiAzMTMuNiAwIDEgMCA4MjUuNiA1MTIgMzE0LjAyNjY2NyAzMTQuMDI2NjY3IDAgMCAwIDUxMiAxOTguNHoiIGZpbGw9IiIgcC1pZD0iMjc3NyI+PC9wYXRoPjwvc3ZnPg==');\n}\n.l7-control-draw .draw-delete {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NzMwNDEyNjU0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQ4MDQiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNMjEzLjMzMzMzMyAyODIuODM3MzMzYzAtMjAuNjkzMzMzIDE2LjE3MDY2Ny0zNy40MTg2NjcgMzYuMDk2LTM3LjQxODY2NmgxODAuNDh2LTM3LjM3NmMwLTIwLjY1MDY2NyAxNi4yMTMzMzMtMzcuMzc2IDM2LjEzODY2Ny0zNy4zNzZoNzIuMTkyYzE5Ljk2OCAwIDM2LjEzODY2NyAxNi43MjUzMzMgMzYuMTM4NjY3IDM3LjM3NnYzNy4zNzZoMTgwLjQ4YzE5Ljk2OCAwIDM2LjA5NiAxNi43MjUzMzMgMzYuMDk2IDM3LjQxODY2NnYzNy4zNzZIMjEzLjMzMzMzM3YtMzcuMzc2eiBtNTQxLjUyNTMzNCAxMTIuMTI4djQyMC45OTJjMCAyMC42MDgtMTYuMTI4IDM3LjM3Ni0zNi4wOTYgMzcuMzc2SDI4NS41MjUzMzNjLTE5LjkyNTMzMyAwLTM2LjA5Ni0xNi43NjgtMzYuMDk2LTM3LjM3NlYzNTcuNTQ2NjY3aDUwNS40MjkzMzR2MzcuMzc2ek0zOTMuODU2IDQ2OS43NmMwLTIwLjY1MDY2Ny0xNi4xNzA2NjctMzcuNDE4NjY3LTM2LjA5Ni0zNy40MTg2NjctMTkuOTY4IDAtMzYuMTM4NjY3IDE2Ljc2OC0zNi4xMzg2NjcgMzcuNDE4NjY3djI3MS40MDI2NjdjMCAyMC42NTA2NjcgMTYuMjEzMzMzIDM3LjQxODY2NyAzNi4xMzg2NjcgMzcuNDE4NjY2IDE5LjkyNTMzMyAwIDM2LjA5Ni0xNi43NjggMzYuMDk2LTM3LjQxODY2NlY0NjkuNzZ6IG0xNDQuMzg0IDBjMC0yMC42NTA2NjctMTYuMTI4LTM3LjQxODY2Ny0zNi4wOTYtMzcuNDE4NjY3LTE5LjkyNTMzMyAwLTM2LjA5NiAxNi43NjgtMzYuMDk2IDM3LjQxODY2N3YyNzEuNDAyNjY3YzAgMjAuNjUwNjY3IDE2LjE3MDY2NyAzNy40MTg2NjcgMzYuMDk2IDM3LjQxODY2NiAxOS45NjggMCAzNi4wOTYtMTYuNzY4IDM2LjA5Ni0zNy40MTg2NjZWNDY5Ljc2eiBtMTQ0LjQyNjY2NyAwYzAtMjAuNjUwNjY3LTE2LjE3MDY2Ny0zNy40MTg2NjctMzYuMDk2LTM3LjQxODY2Ny0xOS45NjggMC0zNi4wOTYgMTYuNzY4LTM2LjA5NiAzNy40MTg2Njd2MjcxLjQwMjY2N2MwIDIwLjY1MDY2NyAxNi4xMjggMzcuNDE4NjY3IDM2LjA5NiAzNy40MTg2NjYgMTkuOTI1MzMzIDAgMzYuMDk2LTE2Ljc2OCAzNi4wOTYtMzcuNDE4NjY2VjQ2OS43NnoiIHAtaWQ9IjQ4MDUiPjwvcGF0aD48L3N2Zz4=');\n}\n.horizontal {\n flex-direction: row;\n}\n.horizontal button:focus:first-child {\n border-radius: 4px 0px 0px 4px;\n}\n.horizontal button:focus:last-child {\n border-radius: 0px 4px 4px 4px;\n}\n.horizontal button + button {\n border-left: 1px solid #eee;\n}\n.vertical {\n flex-direction: column;\n}\n.vertical button:focus:first-child {\n border-radius: 4px 4px 0 0;\n}\n.vertical button:focus:last-child {\n border-radius: 0px 0px 4px 4px;\n}\n.vertical button + button {\n border-top: 1px solid #eee;\n}\n";
7672 styleInject(css);
7673
7674 var DrawType = {
7675 point: DrawPoint,
7676 line: DrawLine,
7677 polygon: DrawPolygon,
7678 circle: DrawCircle,
7679 rect: DrawRect
7680 };
7681 var DrawControl = /*#__PURE__*/function (_Control) {
7682 _inherits(DrawControl, _Control);
7683
7684 var _super = _createSuper(DrawControl);
7685
7686 function DrawControl(scene, options) {
7687 var _this;
7688
7689 _classCallCheck(this, DrawControl);
7690
7691 _this = _super.call(this, options);
7692 _this.draw = {};
7693
7694 _this.onButtonClick = function (type, e) {
7695 for (var draw in _this.draw) {
7696 if (draw === type) {
7697 _this.draw[draw].enable();
7698 } else {
7699 _this.draw[draw].disable();
7700 }
7701 }
7702 };
7703
7704 _this.onDeleteMode = function (type, e) {
7705 e.stopPropagation();
7706
7707 if (!_this.currentDraw) {
7708 return;
7709 }
7710
7711 _this.currentDraw.deleteMode.enable();
7712
7713 return false;
7714 };
7715
7716 _this.onModeChange = function (type, mode) {
7717 if (mode === DrawModes.SIMPLE_SELECT) {
7718 _this.currentDraw = _this.draw[type];
7719 }
7720 };
7721
7722 _this.scene = scene;
7723 return _this;
7724 }
7725
7726 _createClass(DrawControl, [{
7727 key: "getDefault",
7728 value: function getDefault() {
7729 return {
7730 position: l7.PositionType.TOPLEFT,
7731 controls: {
7732 point: true,
7733 line: true,
7734 polygon: true,
7735 rect: true,
7736 circle: true,
7737 delete: true
7738 },
7739 name: 'draw'
7740 };
7741 }
7742 }, {
7743 key: "onAdd",
7744 value: function onAdd() {
7745 var layout = this.controlOption.layout;
7746 var controlClass = 'l7-control-draw' + ' ' + layout;
7747 var controls = this.controlOption.controls;
7748 var container = l7.DOM.create('div', controlClass);
7749 this.addControls(controls, container); // 代理每个绘制组件的事件
7750
7751 this.addControlEvent(); // 监听组件 选中, 编辑
7752
7753 return container;
7754 }
7755 }, {
7756 key: "onRemove",
7757 value: function onRemove() {
7758 for (var draw in this.draw) {
7759 if (this.draw[draw]) {
7760 this.draw[draw].destroy();
7761 }
7762 }
7763 }
7764 }, {
7765 key: "getDraw",
7766 value: function getDraw(type) {
7767 var controls = this.controlOption.controls;
7768
7769 if (controls[type]) {
7770 return this.draw[type];
7771 }
7772
7773 return null;
7774 }
7775 }, {
7776 key: "getAllData",
7777 value: function getAllData() {
7778 var res = {};
7779
7780 for (var draw in this.draw) {
7781 if (this.draw[draw]) {
7782 res[draw] = this.draw[draw].getData();
7783 }
7784 }
7785
7786 return res;
7787 }
7788 }, {
7789 key: "removeAllData",
7790 value: function removeAllData() {
7791 for (var draw in this.draw) {
7792 if (this.draw[draw]) {
7793 this.draw[draw].removeAllData();
7794 }
7795 }
7796 }
7797 }, {
7798 key: "addControls",
7799 value: function addControls(controls, container) {
7800 var style = this.controlOption.style;
7801
7802 for (var type in controls) {
7803 if (DrawType[type] && controls[type] !== false) {
7804 var drawOption = helpers_28(controls[type]) ? controls[type] : {};
7805
7806 if (style) {
7807 drawOption.style = style;
7808 }
7809
7810 var draw = new DrawType[type](this.scene, drawOption);
7811 draw.on(DrawEvent.MODE_CHANGE, this.onModeChange.bind(null, type));
7812 this.draw[type] = draw;
7813 this.createButton(draw.title, 'draw-' + type, container, 'click', this.onButtonClick.bind(null, type));
7814 } else if (type === 'delete' && controls[type] !== false) {
7815 var _draw = new DrawDelete(this.scene);
7816
7817 _draw.on(DrawEvent.MODE_CHANGE, this.onModeChange.bind(null, type));
7818
7819 this.createButton(_draw.title, 'draw-' + type, container, 'mousedown', this.onDeleteMode.bind(null, type));
7820 }
7821 }
7822 }
7823 }, {
7824 key: "addControlEvent",
7825 value: function addControlEvent() {
7826 var _this2 = this;
7827
7828 var _loop = function _loop(draw) {
7829 if (_this2.draw[draw]) {
7830 ['draw.create', 'draw.update', 'draw.delete'].forEach(function (type) {
7831 _this2.draw[draw].on(type, function (feature) {
7832 _this2.emit(type, {
7833 drawType: draw,
7834 feature: feature
7835 });
7836 });
7837 });
7838 }
7839 };
7840
7841 for (var draw in this.draw) {
7842 _loop(draw);
7843 }
7844 }
7845 }, {
7846 key: "createButton",
7847 value: function createButton(tile, className, container, eventType, fn) {
7848 var link = l7.DOM.create('button', className, container);
7849 link.title = tile;
7850 link.addEventListener(eventType, fn, false);
7851 return link;
7852 }
7853 }]);
7854
7855 return DrawControl;
7856 }(l7.Control);
7857
7858 exports.DrawCircle = DrawCircle;
7859 exports.DrawControl = DrawControl;
7860 exports.DrawDelete = DrawDelete;
7861 exports.DrawFeature = DrawFeature;
7862 exports.DrawLine = DrawLine;
7863 exports.DrawMode = DrawMode;
7864 exports.DrawPoint = DrawPoint;
7865 exports.DrawPolygon = DrawPolygon;
7866 exports.DrawRect = DrawRect;
7867
7868 Object.defineProperty(exports, '__esModule', { value: true });
7869
7870})));
7871//# sourceMappingURL=l7-draw.js.map