@opengeoweb/webmap-react 8.2.0 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -319,13 +319,16 @@ class CanvasComponent extends Component {
319
319
  overflow: 'hidden',
320
320
  display: 'block',
321
321
  border: 'none'
322
- }
322
+ },
323
+ "data-testid": "canvas-container"
323
324
  }, /*#__PURE__*/React__default.createElement("div", {
324
325
  style: {
325
326
  overflow: 'visible',
326
327
  width: 0,
327
328
  height: 0
328
- }
329
+ },
330
+ role: "presentation",
331
+ "aria-label": "canvas"
329
332
  }, /*#__PURE__*/React__default.createElement("canvas", {
330
333
  ref: canvas => {
331
334
  this.canvas = canvas;
@@ -432,7 +435,7 @@ var $TypeError$8 = TypeError;
432
435
  // `RequireObjectCoercible` abstract operation
433
436
  // https://tc39.es/ecma262/#sec-requireobjectcoercible
434
437
  var requireObjectCoercible$5 = function (it) {
435
- if (isNullOrUndefined$2(it)) throw $TypeError$8("Can't call method on " + it);
438
+ if (isNullOrUndefined$2(it)) throw new $TypeError$8("Can't call method on " + it);
436
439
  return it;
437
440
  };
438
441
 
@@ -487,10 +490,10 @@ var store$2 = sharedStore;
487
490
  (shared$4.exports = function (key, value) {
488
491
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
489
492
  })('versions', []).push({
490
- version: '3.32.2',
493
+ version: '3.33.0',
491
494
  mode: 'global',
492
495
  copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
493
- license: 'https://github.com/zloirock/core-js/blob/v3.32.2/LICENSE',
496
+ license: 'https://github.com/zloirock/core-js/blob/v3.33.0/LICENSE',
494
497
  source: 'https://github.com/zloirock/core-js'
495
498
  });
496
499
 
@@ -643,7 +646,7 @@ var $TypeError$7 = TypeError;
643
646
  // `Assert: Type(argument) is Object`
644
647
  var anObject$9 = function (argument) {
645
648
  if (isObject$a(argument)) return argument;
646
- throw $TypeError$7($String$4(argument) + ' is not an object');
649
+ throw new $TypeError$7($String$4(argument) + ' is not an object');
647
650
  };
648
651
 
649
652
  var objectDefineProperties = {};
@@ -749,7 +752,7 @@ var $TypeError$6 = TypeError;
749
752
  // `Assert: IsCallable(argument) is true`
750
753
  var aCallable$3 = function (argument) {
751
754
  if (isCallable$d(argument)) return argument;
752
- throw $TypeError$6(tryToString(argument) + ' is not a function');
755
+ throw new $TypeError$6(tryToString(argument) + ' is not a function');
753
756
  };
754
757
 
755
758
  var aCallable$2 = aCallable$3;
@@ -775,7 +778,7 @@ var ordinaryToPrimitive$1 = function (input, pref) {
775
778
  if (pref === 'string' && isCallable$c(fn = input.toString) && !isObject$8(val = call$9(fn, input))) return val;
776
779
  if (isCallable$c(fn = input.valueOf) && !isObject$8(val = call$9(fn, input))) return val;
777
780
  if (pref !== 'string' && isCallable$c(fn = input.toString) && !isObject$8(val = call$9(fn, input))) return val;
778
- throw $TypeError$5("Can't convert object to primitive value");
781
+ throw new $TypeError$5("Can't convert object to primitive value");
779
782
  };
780
783
 
781
784
  var call$8 = functionCall;
@@ -798,7 +801,7 @@ var toPrimitive$1 = function (input, pref) {
798
801
  if (pref === undefined) pref = 'default';
799
802
  result = call$8(exoticToPrim, input, pref);
800
803
  if (!isObject$7(result) || isSymbol$3(result)) return result;
801
- throw $TypeError$4("Can't convert object to primitive value");
804
+ throw new $TypeError$4("Can't convert object to primitive value");
802
805
  }
803
806
  if (pref === undefined) pref = 'number';
804
807
  return ordinaryToPrimitive(input, pref);
@@ -853,7 +856,7 @@ objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function de
853
856
  if (IE8_DOM_DEFINE$1) try {
854
857
  return $defineProperty(O, P, Attributes);
855
858
  } catch (error) { /* empty */ }
856
- if ('get' in Attributes || 'set' in Attributes) throw $TypeError$3('Accessors not supported');
859
+ if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$3('Accessors not supported');
857
860
  if ('value' in Attributes) O[P] = Attributes.value;
858
861
  return O;
859
862
  };
@@ -1177,7 +1180,7 @@ var getterFor = function (TYPE) {
1177
1180
  return function (it) {
1178
1181
  var state;
1179
1182
  if (!isObject$6(it) || (state = get$1(it)).type !== TYPE) {
1180
- throw TypeError$1('Incompatible receiver, ' + TYPE + ' required');
1183
+ throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
1181
1184
  } return state;
1182
1185
  };
1183
1186
  };
@@ -1190,7 +1193,7 @@ if (NATIVE_WEAK_MAP || shared$1.state) {
1190
1193
  store$1.set = store$1.set;
1191
1194
  /* eslint-enable no-self-assign -- prototype methods protection */
1192
1195
  set = function (it, metadata) {
1193
- if (store$1.has(it)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
1196
+ if (store$1.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
1194
1197
  metadata.facade = it;
1195
1198
  store$1.set(it, metadata);
1196
1199
  return metadata;
@@ -1205,7 +1208,7 @@ if (NATIVE_WEAK_MAP || shared$1.state) {
1205
1208
  var STATE = sharedKey$1('state');
1206
1209
  hiddenKeys$1[STATE] = true;
1207
1210
  set = function (it, metadata) {
1208
- if (hasOwn$7(it, STATE)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
1211
+ if (hasOwn$7(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
1209
1212
  metadata.facade = it;
1210
1213
  createNonEnumerableProperty$4(it, STATE, metadata);
1211
1214
  return metadata;
@@ -1637,7 +1640,7 @@ var $TypeError$2 = TypeError;
1637
1640
 
1638
1641
  var aPossiblePrototype$1 = function (argument) {
1639
1642
  if (typeof argument == 'object' || isCallable$4(argument)) return argument;
1640
- throw $TypeError$2("Can't set " + $String$1(argument) + ' as a prototype');
1643
+ throw new $TypeError$2("Can't set " + $String$1(argument) + ' as a prototype');
1641
1644
  };
1642
1645
 
1643
1646
  /* eslint-disable no-proto -- safe */
@@ -3759,7 +3762,11 @@ function debounce$3(func, wait = 166) {
3759
3762
  }
3760
3763
 
3761
3764
  function isMuiElement(element, muiNames) {
3762
- return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1;
3765
+ var _muiName, _element$type;
3766
+ return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf( // For server components `muiName` is avaialble in element.type._payload.value.muiName
3767
+ // relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
3768
+ // eslint-disable-next-line no-underscore-dangle
3769
+ (_muiName = element.type.muiName) != null ? _muiName : (_element$type = element.type) == null || (_element$type = _element$type._payload) == null || (_element$type = _element$type.value) == null ? void 0 : _element$type.muiName) !== -1;
3763
3770
  }
3764
3771
 
3765
3772
  function ownerDocument(node) {
@@ -3816,6 +3823,13 @@ function setRef(ref, value) {
3816
3823
  }
3817
3824
  }
3818
3825
 
3826
+ /**
3827
+ * A version of `React.useLayoutEffect` that does not show a warning when server-side rendering.
3828
+ * This is useful for effects that are only needed for client-side rendering but not for SSR.
3829
+ *
3830
+ * Before you use this hook, make sure to read https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
3831
+ * and confirm it doesn't apply to your use-case.
3832
+ */
3819
3833
  const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
3820
3834
  var useEnhancedEffect$1 = useEnhancedEffect;
3821
3835
 
@@ -7165,7 +7179,7 @@ process.env.NODE_ENV !== "production" ? GlobalStyles$2.propTypes = {
7165
7179
  } : void 0;
7166
7180
 
7167
7181
  /**
7168
- * @mui/styled-engine v5.14.10
7182
+ * @mui/styled-engine v5.14.14
7169
7183
  *
7170
7184
  * @license MIT
7171
7185
  * This source code is licensed under the MIT license found in the
@@ -8519,40 +8533,48 @@ const getStyleOverrides = (name, theme) => {
8519
8533
  }
8520
8534
  return null;
8521
8535
  };
8536
+ const transformVariants = variants => {
8537
+ const variantsStyles = {};
8538
+ if (variants) {
8539
+ variants.forEach(definition => {
8540
+ const key = propsToClassKey(definition.props);
8541
+ variantsStyles[key] = definition.style;
8542
+ });
8543
+ }
8544
+ return variantsStyles;
8545
+ };
8522
8546
  const getVariantStyles = (name, theme) => {
8523
8547
  let variants = [];
8524
8548
  if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
8525
8549
  variants = theme.components[name].variants;
8526
8550
  }
8527
- const variantsStyles = {};
8528
- variants.forEach(definition => {
8529
- const key = propsToClassKey(definition.props);
8530
- variantsStyles[key] = definition.style;
8531
- });
8532
- return variantsStyles;
8551
+ return transformVariants(variants);
8533
8552
  };
8534
- const variantsResolver = (props, styles, theme, name) => {
8535
- var _theme$components;
8553
+ const variantsResolver = (props, styles, variants) => {
8536
8554
  const {
8537
8555
  ownerState = {}
8538
8556
  } = props;
8539
8557
  const variantsStyles = [];
8540
- const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
8541
- if (themeVariants) {
8542
- themeVariants.forEach(themeVariant => {
8558
+ if (variants) {
8559
+ variants.forEach(variant => {
8543
8560
  let isMatch = true;
8544
- Object.keys(themeVariant.props).forEach(key => {
8545
- if (ownerState[key] !== themeVariant.props[key] && props[key] !== themeVariant.props[key]) {
8561
+ Object.keys(variant.props).forEach(key => {
8562
+ if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
8546
8563
  isMatch = false;
8547
8564
  }
8548
8565
  });
8549
8566
  if (isMatch) {
8550
- variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
8567
+ variantsStyles.push(styles[propsToClassKey(variant.props)]);
8551
8568
  }
8552
8569
  });
8553
8570
  }
8554
8571
  return variantsStyles;
8555
8572
  };
8573
+ const themeVariantsResolver = (props, styles, theme, name) => {
8574
+ var _theme$components;
8575
+ const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
8576
+ return variantsResolver(props, styles, themeVariants);
8577
+ };
8556
8578
 
8557
8579
  // Update /system/styled/#api in case if this changes
8558
8580
  function shouldForwardProp(prop) {
@@ -8578,6 +8600,29 @@ function defaultOverridesResolver(slot) {
8578
8600
  }
8579
8601
  return (props, styles) => styles[slot];
8580
8602
  }
8603
+ const muiStyledFunctionResolver = ({
8604
+ styledArg,
8605
+ props,
8606
+ defaultTheme,
8607
+ themeId
8608
+ }) => {
8609
+ const resolvedStyles = styledArg(_extends({}, props, {
8610
+ theme: resolveTheme(_extends({}, props, {
8611
+ defaultTheme,
8612
+ themeId
8613
+ }))
8614
+ }));
8615
+ let optionalVariants;
8616
+ if (resolvedStyles && resolvedStyles.variants) {
8617
+ optionalVariants = resolvedStyles.variants;
8618
+ delete resolvedStyles.variants;
8619
+ }
8620
+ if (optionalVariants) {
8621
+ const variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
8622
+ return [resolvedStyles, ...variantsStyles];
8623
+ }
8624
+ return resolvedStyles;
8625
+ };
8581
8626
  function createStyled(input = {}) {
8582
8627
  const {
8583
8628
  themeId,
@@ -8644,16 +8689,61 @@ function createStyled(input = {}) {
8644
8689
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
8645
8690
  // component stays as a function. This condition makes sure that we do not interpolate functions
8646
8691
  // which are basically components used as a selectors.
8647
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
8648
- return stylesArg(_extends({}, props, {
8649
- theme: resolveTheme(_extends({}, props, {
8650
- defaultTheme,
8651
- themeId
8652
- }))
8653
- }));
8654
- } : stylesArg;
8692
+ if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
8693
+ return props => muiStyledFunctionResolver({
8694
+ styledArg: stylesArg,
8695
+ props,
8696
+ defaultTheme,
8697
+ themeId
8698
+ });
8699
+ }
8700
+ if (isPlainObject(stylesArg)) {
8701
+ let transformedStylesArg = stylesArg;
8702
+ let styledArgVariants;
8703
+ if (stylesArg && stylesArg.variants) {
8704
+ styledArgVariants = stylesArg.variants;
8705
+ delete transformedStylesArg.variants;
8706
+ transformedStylesArg = props => {
8707
+ let result = stylesArg;
8708
+ const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
8709
+ variantStyles.forEach(variantStyle => {
8710
+ result = deepmerge(result, variantStyle);
8711
+ });
8712
+ return result;
8713
+ };
8714
+ }
8715
+ return transformedStylesArg;
8716
+ }
8717
+ return stylesArg;
8655
8718
  }) : [];
8656
8719
  let transformedStyleArg = styleArg;
8720
+ if (isPlainObject(styleArg)) {
8721
+ let styledArgVariants;
8722
+ if (styleArg && styleArg.variants) {
8723
+ styledArgVariants = styleArg.variants;
8724
+ delete transformedStyleArg.variants;
8725
+ transformedStyleArg = props => {
8726
+ let result = styleArg;
8727
+ const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
8728
+ variantStyles.forEach(variantStyle => {
8729
+ result = deepmerge(result, variantStyle);
8730
+ });
8731
+ return result;
8732
+ };
8733
+ }
8734
+ } else if (typeof styleArg === 'function' &&
8735
+ // On the server Emotion doesn't use React.forwardRef for creating components, so the created
8736
+ // component stays as a function. This condition makes sure that we do not interpolate functions
8737
+ // which are basically components used as a selectors.
8738
+ styleArg.__emotion_real !== styleArg) {
8739
+ // If the type is function, we need to define the default theme.
8740
+ transformedStyleArg = props => muiStyledFunctionResolver({
8741
+ styledArg: styleArg,
8742
+ props,
8743
+ defaultTheme,
8744
+ themeId
8745
+ });
8746
+ }
8657
8747
  if (componentName && overridesResolver) {
8658
8748
  expressionsWithDefaultTheme.push(props => {
8659
8749
  const theme = resolveTheme(_extends({}, props, {
@@ -8679,7 +8769,7 @@ function createStyled(input = {}) {
8679
8769
  defaultTheme,
8680
8770
  themeId
8681
8771
  }));
8682
- return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
8772
+ return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
8683
8773
  });
8684
8774
  }
8685
8775
  if (!skipSx) {
@@ -8691,18 +8781,6 @@ function createStyled(input = {}) {
8691
8781
  // If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
8692
8782
  transformedStyleArg = [...styleArg, ...placeholders];
8693
8783
  transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
8694
- } else if (typeof styleArg === 'function' &&
8695
- // On the server Emotion doesn't use React.forwardRef for creating components, so the created
8696
- // component stays as a function. This condition makes sure that we do not interpolate functions
8697
- // which are basically components used as a selectors.
8698
- styleArg.__emotion_real !== styleArg) {
8699
- // If the type is function, we need to define the default theme.
8700
- transformedStyleArg = props => styleArg(_extends({}, props, {
8701
- theme: resolveTheme(_extends({}, props, {
8702
- defaultTheme,
8703
- themeId
8704
- }))
8705
- }));
8706
8784
  }
8707
8785
  const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
8708
8786
  if (process.env.NODE_ENV !== 'production') {
@@ -21427,7 +21505,7 @@ var classof$3 = classof$4;
21427
21505
  var $String = String;
21428
21506
 
21429
21507
  var toString$5 = function (argument) {
21430
- if (classof$3(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
21508
+ if (classof$3(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
21431
21509
  return $String(argument);
21432
21510
  };
21433
21511
 
@@ -41059,7 +41137,7 @@ function transform(source, dest, point, enforceAxis) {
41059
41137
  return adjust_axis(dest, true, point);
41060
41138
  }
41061
41139
 
41062
- if (!hasZ) {
41140
+ if (point && !hasZ) {
41063
41141
  delete point.z;
41064
41142
  }
41065
41143
  return point;
@@ -42546,7 +42624,7 @@ function inverse$p(p) {
42546
42624
  return p;
42547
42625
  }
42548
42626
 
42549
- var names$p = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea","Oblique Stereographic Alternative","Double_Stereographic"];
42627
+ var names$p = ["Stereographic_North_Pole", "Oblique_Stereographic", "sterea","Oblique Stereographic Alternative","Double_Stereographic"];
42550
42628
  var sterea = {
42551
42629
  init: init$p,
42552
42630
  forward: forward$p,
@@ -42560,6 +42638,13 @@ function ssfn_(phit, sinphi, eccen) {
42560
42638
  }
42561
42639
 
42562
42640
  function init$o() {
42641
+
42642
+ // setting default parameters
42643
+ this.x0 = this.x0 || 0;
42644
+ this.y0 = this.y0 || 0;
42645
+ this.lat0 = this.lat0 || 0;
42646
+ this.long0 = this.long0 || 0;
42647
+
42563
42648
  this.coslat0 = Math.cos(this.lat0);
42564
42649
  this.sinlat0 = Math.sin(this.lat0);
42565
42650
  if (this.sphere) {
@@ -42581,7 +42666,9 @@ function init$o() {
42581
42666
  }
42582
42667
  }
42583
42668
  this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));
42584
- if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
42669
+ if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN && Math.abs(Math.cos(this.lat_ts)) > EPSLN) {
42670
+ // When k0 is 1 (default value) and lat_ts is a vaild number and lat0 is at a pole and lat_ts is not at a pole
42671
+ // Recalculate k0 using formula 21-35 from p161 of Snyder, 1987
42585
42672
  this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));
42586
42673
  }
42587
42674
  this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
@@ -42712,7 +42799,7 @@ function inverse$o(p) {
42712
42799
 
42713
42800
  }
42714
42801
 
42715
- var names$o = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"];
42802
+ var names$o = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)", "Polar_Stereographic"];
42716
42803
  var stere = {
42717
42804
  init: init$o,
42718
42805
  forward: forward$o,
@@ -49824,8 +49911,6 @@ function intersect(poly1, poly2, options) {
49824
49911
  return multiPolygon(intersection, options.properties);
49825
49912
  }
49826
49913
 
49827
- function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
49828
-
49829
49914
  /* *
49830
49915
  * Licensed under the Apache License, Version 2.0 (the "License");
49831
49916
  * you may not use this file except in compliance with the License.
@@ -49842,67 +49927,6 @@ function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=a
49842
49927
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
49843
49928
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
49844
49929
  * */
49845
- const defaultGeoJSONStyleProperties = {
49846
- fill: '#ff7800',
49847
- 'fill-opacity': 0.2,
49848
- stroke: '#ff7800',
49849
- 'stroke-width': 2,
49850
- 'stroke-opacity': 1
49851
- };
49852
- const emptyGeoJSON = {
49853
- type: 'FeatureCollection',
49854
- features: []
49855
- };
49856
- const featurePoint = {
49857
- type: 'Feature',
49858
- properties: {},
49859
- geometry: {
49860
- type: 'Point',
49861
- coordinates: []
49862
- }
49863
- };
49864
- const featureMultiPoint = {
49865
- type: 'Feature',
49866
- properties: {},
49867
- geometry: {
49868
- type: 'MultiPoint',
49869
- coordinates: [[]]
49870
- }
49871
- };
49872
- const featurePolygon = {
49873
- type: 'Feature',
49874
- properties: {},
49875
- geometry: {
49876
- type: 'Polygon',
49877
- coordinates: [[]]
49878
- }
49879
- };
49880
- const featureBox = {
49881
- type: 'Feature',
49882
- properties: {
49883
- _type: 'box'
49884
- },
49885
- geometry: {
49886
- type: 'Polygon',
49887
- coordinates: [[]]
49888
- }
49889
- };
49890
- const lineString = {
49891
- type: 'FeatureCollection',
49892
- features: [{
49893
- type: 'Feature',
49894
- properties: {
49895
- stroke: '#66F',
49896
- 'stroke-width': 5,
49897
- 'stroke-opacity': '1'
49898
- },
49899
- geometry: {
49900
- type: 'LineString',
49901
- coordinates: [[]]
49902
- }
49903
- }]
49904
- };
49905
-
49906
49930
  /* Function which calculates the distance between two points */
49907
49931
  const distance = (a, b) => {
49908
49932
  return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
@@ -50048,119 +50072,85 @@ const registerDrawFunction = (drawFunction = () => {}) => {
50048
50072
  drawFunctionStore.push(newFunction);
50049
50073
  return id;
50050
50074
  };
50051
- /**
50052
- * Adds properties to the first geojson feature based on the given property object.
50053
- * It only extends or changes the properties which are defined in styleConfig,
50054
- * all other properties in the geojson are left unchanged.
50055
- * @param geojson
50056
- * @param featureProperties
50057
- */
50058
- const addFeatureProperties = (geojson, featureProperties, featureIndex = 0) => {
50059
- if (!geojson) {
50060
- return null;
50061
- }
50062
- return produce(geojson, draft => {
50063
- if (draft.features && draft.features.length > 0 && draft.features[featureIndex] !== undefined && draft.features[featureIndex].properties) {
50064
- Object.keys(featureProperties).forEach(key => {
50065
- draft.features[featureIndex].properties[key] = featureProperties[key];
50066
- });
50067
- }
50068
- });
50069
- };
50070
- /**
50071
- * Returns the intersection of two features. In case of a polygon, only the first feature is used.
50072
- * @param a Feature A
50073
- * @param b Feature B
50074
- * @returns The intersection of the two features.
50075
- */
50076
- const intersectGeoJSONS = (a, b, geoJSONProperties = {
50077
- stroke: '#FF0000',
50078
- 'stroke-width': 10.0,
50079
- 'stroke-opacity': 1,
50080
- fill: '#0000FF',
50081
- 'fill-opacity': 1.0
50082
- }) => {
50083
- const featureA = feature(a.features[0].geometry);
50084
- const featureB = feature(b.features[0].geometry);
50085
- const options = {
50086
- tolerance: 0.001,
50087
- highQuality: true
50088
- };
50089
- const simplifiedA = simplify$1(featureA, options);
50090
- const simplifiedB = simplify$1(featureB, options);
50091
- const intersection = intersect(simplifiedA, simplifiedB);
50092
- return addFeatureProperties({
50093
- type: 'FeatureCollection',
50094
- features: intersection === null ? [{
50095
- type: 'Feature',
50096
- properties: {
50097
- selectionType: 'poly'
50098
- },
50099
- geometry: {
50100
- type: 'Polygon',
50101
- coordinates: [[]]
50102
- }
50103
- }] : [intersection]
50104
- }, geoJSONProperties);
50075
+ const NEW_LINESTRING_CREATED = 'new point in LineString created';
50076
+ const NEW_FEATURE_CREATED = 'new feature created';
50077
+ const NEW_POINT_CREATED = 'new point created';
50078
+
50079
+ /* *
50080
+ * Licensed under the Apache License, Version 2.0 (the "License");
50081
+ * you may not use this file except in compliance with the License.
50082
+ * You may obtain a copy of the License at
50083
+ *
50084
+ * http://www.apache.org/licenses/LICENSE-2.0
50085
+ *
50086
+ * Unless required by applicable law or agreed to in writing, software
50087
+ * distributed under the License is distributed on an "AS IS" BASIS,
50088
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50089
+ * See the License for the specific language governing permissions and
50090
+ * limitations under the License.
50091
+ *
50092
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
50093
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
50094
+ * */
50095
+ const defaultGeoJSONStyleProperties = {
50096
+ fill: '#ff7800',
50097
+ 'fill-opacity': 0.2,
50098
+ stroke: '#ff7800',
50099
+ 'stroke-width': 2,
50100
+ 'stroke-opacity': 1
50105
50101
  };
50106
- /**
50107
- * Adds the intersectionStart and intersectionEnd properties to the GeoJSONS structure
50108
- * @param geoJSONs
50109
- * @returns GeoJSONS extend with intersections
50110
- */
50111
- const createInterSections = (geojson, otherGeoJSON, geoJSONproperties = {
50112
- stroke: '#f24a00',
50113
- 'stroke-width': 1.5,
50114
- 'stroke-opacity': 1,
50115
- fill: '#f24a00',
50116
- 'fill-opacity': 0.5
50117
- }) => {
50118
- const intersections = produce(geojson, () => {
50119
- try {
50120
- return addFeatureProperties(intersectGeoJSONS(geojson, otherGeoJSON), geoJSONproperties);
50121
- } catch (error) {
50122
- return addFeatureProperties(geojson, geoJSONproperties);
50123
- }
50124
- });
50125
- return intersections;
50102
+ const emptyGeoJSON = {
50103
+ type: 'FeatureCollection',
50104
+ features: []
50126
50105
  };
50127
- const getGeoJson = (geojson, shouldAllowMultipleshapes) => {
50128
- if (shouldAllowMultipleshapes) {
50129
- return geojson;
50130
- }
50131
- const {
50132
- geometry
50133
- } = geojson.features[0];
50134
- if (geometry.type === 'Point' || geometry.type === 'LineString') {
50135
- return geojson;
50106
+ const featurePoint = {
50107
+ type: 'Feature',
50108
+ properties: {},
50109
+ geometry: {
50110
+ type: 'Point',
50111
+ coordinates: []
50136
50112
  }
50137
- return geometry.coordinates.length > 1 ? produce(geojson, draft => {
50138
- const draftFeature = draft.features[0];
50139
- draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
50140
- }) : geojson;
50141
50113
  };
50142
- const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleshapes, geoJSONFeatureCollection = emptyGeoJSON) => {
50143
- if (geoJSONFeature.type === 'FeatureCollection') {
50144
- return geoJSONFeature;
50114
+ const featureMultiPoint = {
50115
+ type: 'Feature',
50116
+ properties: {},
50117
+ geometry: {
50118
+ type: 'MultiPoint',
50119
+ coordinates: [[]]
50145
50120
  }
50146
- if (shouldAllowMultipleshapes) {
50147
- return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
50148
- features: geoJSONFeatureCollection.features.concat(geoJSONFeature)
50149
- });
50121
+ };
50122
+ const featurePolygon = {
50123
+ type: 'Feature',
50124
+ properties: {},
50125
+ geometry: {
50126
+ type: 'Polygon',
50127
+ coordinates: [[]]
50150
50128
  }
50151
- return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
50152
- features: [geoJSONFeature]
50153
- });
50154
50129
  };
50155
- // compares 2 geoJSONs and returns true if both have properties.selectionType with the same value
50156
- const isGeoJSONFeatureCreatedByTool = (existingJSON, newGeoJSON) => {
50157
- var _a, _b, _c;
50158
- if (!existingJSON.features.length) {
50159
- return false;
50130
+ const featureBox = {
50131
+ type: 'Feature',
50132
+ properties: {
50133
+ _type: 'box'
50134
+ },
50135
+ geometry: {
50136
+ type: 'Polygon',
50137
+ coordinates: [[]]
50160
50138
  }
50161
- const lastUsedTool = (_a = existingJSON.features[0].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
50162
- const newTool = newGeoJSON.type === 'Feature' ? (_b = newGeoJSON.properties) === null || _b === void 0 ? void 0 : _b.selectionType : (_c = newGeoJSON.features[0].properties) === null || _c === void 0 ? void 0 : _c.selectionType;
50163
- return lastUsedTool !== undefined && newTool !== undefined ? lastUsedTool === newTool : false;
50139
+ };
50140
+ const lineString = {
50141
+ type: 'FeatureCollection',
50142
+ features: [{
50143
+ type: 'Feature',
50144
+ properties: {
50145
+ stroke: '#66F',
50146
+ 'stroke-width': 5,
50147
+ 'stroke-opacity': '1'
50148
+ },
50149
+ geometry: {
50150
+ type: 'LineString',
50151
+ coordinates: [[]]
50152
+ }
50153
+ }]
50164
50154
  };
50165
50155
 
50166
50156
  const colors = {
@@ -50221,12 +50211,12 @@ class MapDraw extends React.PureComponent {
50221
50211
  super(props);
50222
50212
  this.handleGeoJSONUpdate = newGeoJSON => {
50223
50213
  const {
50224
- featureNrToEdit
50214
+ selectedFeatureIndex
50225
50215
  } = this.props;
50226
50216
  this.geojson = lodash.exports.cloneDeep(newGeoJSON);
50227
50217
  /* Ensure that this.snappedPolygonIndex is still within the coordinates array */
50228
- if (this.geojson && this.geojson.features && featureNrToEdit < this.geojson.features.length) {
50229
- const feature = this.geojson.features[featureNrToEdit];
50218
+ if (this.geojson && this.geojson.features && selectedFeatureIndex < this.geojson.features.length) {
50219
+ const feature = this.geojson.features[selectedFeatureIndex];
50230
50220
  if (feature.geometry) {
50231
50221
  const {
50232
50222
  coordinates
@@ -50529,7 +50519,7 @@ class MapDraw extends React.PureComponent {
50529
50519
  mouseMove(event) {
50530
50520
  const {
50531
50521
  isInEditMode,
50532
- featureNrToEdit,
50522
+ selectedFeatureIndex,
50533
50523
  onHoverFeature
50534
50524
  } = this.props;
50535
50525
  if (event && event.rightButton === true) {
@@ -50576,7 +50566,7 @@ class MapDraw extends React.PureComponent {
50576
50566
  if (isInEditMode === false) {
50577
50567
  return undefined;
50578
50568
  }
50579
- const feature = this.geojson.features[featureNrToEdit];
50569
+ const feature = this.geojson.features[selectedFeatureIndex];
50580
50570
  if (!feature) {
50581
50571
  return undefined;
50582
50572
  }
@@ -50679,7 +50669,7 @@ class MapDraw extends React.PureComponent {
50679
50669
  } = event;
50680
50670
  const {
50681
50671
  mapId,
50682
- featureNrToEdit
50672
+ selectedFeatureIndex
50683
50673
  } = this.props;
50684
50674
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50685
50675
  if (this.myDrawMode === DRAWMODE.POLYGON) {
@@ -50688,7 +50678,7 @@ class MapDraw extends React.PureComponent {
50688
50678
  x: mouseX,
50689
50679
  y: mouseY
50690
50680
  });
50691
- const feature = this.geojson.features[featureNrToEdit];
50681
+ const feature = this.geojson.features[selectedFeatureIndex];
50692
50682
  if (this.checkIfFeatureIsBox(feature)) {
50693
50683
  return false;
50694
50684
  }
@@ -50708,7 +50698,7 @@ class MapDraw extends React.PureComponent {
50708
50698
  x: mouseX,
50709
50699
  y: mouseY
50710
50700
  });
50711
- const feature = this.geojson.features[featureNrToEdit];
50701
+ const feature = this.geojson.features[selectedFeatureIndex];
50712
50702
  if (this.checkIfFeatureIsBox(feature)) {
50713
50703
  return false;
50714
50704
  }
@@ -50732,14 +50722,14 @@ class MapDraw extends React.PureComponent {
50732
50722
  } = event;
50733
50723
  const {
50734
50724
  mapId,
50735
- featureNrToEdit
50725
+ selectedFeatureIndex
50736
50726
  } = this.props;
50737
50727
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50738
50728
  if (this.myEditMode === EDITMODE.EMPTY) {
50739
50729
  this.myEditMode = EDITMODE.ADD_FEATURE;
50740
- let feature = this.geojson.features[featureNrToEdit];
50730
+ let feature = this.geojson.features[selectedFeatureIndex];
50741
50731
  // eslint-disable-next-line no-multi-assign
50742
- feature = this.geojson.features[featureNrToEdit] = this.initializeFeature(feature, this.myDrawMode);
50732
+ feature = this.geojson.features[selectedFeatureIndex] = this.initializeFeature(feature, this.myDrawMode);
50743
50733
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
50744
50734
  x: mouseX,
50745
50735
  y: mouseY
@@ -50765,7 +50755,7 @@ class MapDraw extends React.PureComponent {
50765
50755
  this.snappedPolygonIndex = pointGeometry.coordinates.length - 1;
50766
50756
  /* For type POINT it is not possible to add multiple points to the same feature */
50767
50757
  this.myEditMode = EDITMODE.EMPTY;
50768
- this.featureHasChanged('new point created');
50758
+ this.featureHasChanged(NEW_POINT_CREATED);
50769
50759
  }
50770
50760
  if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
50771
50761
  this.myEditMode = EDITMODE.EMPTY;
@@ -50813,7 +50803,7 @@ class MapDraw extends React.PureComponent {
50813
50803
  } else {
50814
50804
  this.mouseIsOverVertexNr = featureCoords.length - 1;
50815
50805
  }
50816
- this.featureHasChanged('new feature created');
50806
+ this.featureHasChanged(NEW_FEATURE_CREATED);
50817
50807
  }
50818
50808
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
50819
50809
  this.myEditMode = EDITMODE.EMPTY;
@@ -50828,7 +50818,7 @@ class MapDraw extends React.PureComponent {
50828
50818
  }
50829
50819
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50830
50820
  this.snappedPolygonIndex = 0;
50831
- this.featureHasChanged('new point in LineString created');
50821
+ this.featureHasChanged(NEW_LINESTRING_CREATED);
50832
50822
  this.mouseIsOverVertexNr = featureCoords.length - 1;
50833
50823
  }
50834
50824
  webmapjs.draw('MapDraw::mouseDown');
@@ -50848,7 +50838,7 @@ class MapDraw extends React.PureComponent {
50848
50838
  } = event;
50849
50839
  const {
50850
50840
  mapId,
50851
- featureNrToEdit
50841
+ selectedFeatureIndex
50852
50842
  } = this.props;
50853
50843
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50854
50844
  if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
@@ -50857,7 +50847,7 @@ class MapDraw extends React.PureComponent {
50857
50847
  x: mouseX,
50858
50848
  y: mouseY
50859
50849
  });
50860
- const feature = this.geojson.features[featureNrToEdit];
50850
+ const feature = this.geojson.features[selectedFeatureIndex];
50861
50851
  const featureCoords = feature.geometry.coordinates;
50862
50852
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50863
50853
  this.featureHasChanged('point added to multipoint');
@@ -50875,7 +50865,7 @@ class MapDraw extends React.PureComponent {
50875
50865
  } = event;
50876
50866
  const {
50877
50867
  mapId,
50878
- featureNrToEdit
50868
+ selectedFeatureIndex
50879
50869
  } = this.props;
50880
50870
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50881
50871
  if (this.myDrawMode === DRAWMODE.POLYGON) {
@@ -50884,7 +50874,7 @@ class MapDraw extends React.PureComponent {
50884
50874
  x: mouseX,
50885
50875
  y: mouseY
50886
50876
  });
50887
- const feature = this.geojson.features[featureNrToEdit];
50877
+ const feature = this.geojson.features[selectedFeatureIndex];
50888
50878
  const featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
50889
50879
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50890
50880
  this.featureHasChanged('vertex added to polygon');
@@ -50902,7 +50892,7 @@ class MapDraw extends React.PureComponent {
50902
50892
  } = event;
50903
50893
  const {
50904
50894
  mapId,
50905
- featureNrToEdit
50895
+ selectedFeatureIndex
50906
50896
  } = this.props;
50907
50897
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50908
50898
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
@@ -50911,7 +50901,7 @@ class MapDraw extends React.PureComponent {
50911
50901
  x: mouseX,
50912
50902
  y: mouseY
50913
50903
  });
50914
- const feature = this.geojson.features[featureNrToEdit];
50904
+ const feature = this.geojson.features[selectedFeatureIndex];
50915
50905
  const featureCoords = feature.geometry.coordinates;
50916
50906
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50917
50907
  this.featureHasChanged('vertex added to LineString');
@@ -50976,10 +50966,10 @@ class MapDraw extends React.PureComponent {
50976
50966
 
50977
50967
  deletePolygon(index) {
50978
50968
  const {
50979
- featureNrToEdit,
50969
+ selectedFeatureIndex,
50980
50970
  deletePolygonCallback
50981
50971
  } = this.props;
50982
- const feature = this.geojson.features[featureNrToEdit];
50972
+ const feature = this.geojson.features[selectedFeatureIndex];
50983
50973
  feature.geometry.coordinates.splice(index, 1);
50984
50974
  if (deletePolygonCallback) {
50985
50975
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -50991,13 +50981,13 @@ class MapDraw extends React.PureComponent {
50991
50981
  /* Deletes any features under the mousecursor */
50992
50982
  const {
50993
50983
  mapId,
50994
- featureNrToEdit
50984
+ selectedFeatureIndex
50995
50985
  } = this.props;
50996
50986
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50997
50987
  if (this.mouseIsOverVertexNr === VERTEX.NONE) {
50998
50988
  return;
50999
50989
  }
51000
- const feature = this.geojson.features[featureNrToEdit];
50990
+ const feature = this.geojson.features[selectedFeatureIndex];
51001
50991
  const featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
51002
50992
  if (featureCoords === undefined) {
51003
50993
  return;
@@ -51082,7 +51072,7 @@ class MapDraw extends React.PureComponent {
51082
51072
  cancelEdit(cancelLastPoint) {
51083
51073
  const {
51084
51074
  isInEditMode,
51085
- featureNrToEdit
51075
+ selectedFeatureIndex
51086
51076
  } = this.props;
51087
51077
  if (isInEditMode === false) {
51088
51078
  return;
@@ -51098,7 +51088,7 @@ class MapDraw extends React.PureComponent {
51098
51088
  if (this.snappedPolygonIndex === SNAPPEDFEATURE.NONE) {
51099
51089
  return;
51100
51090
  }
51101
- const feature = this.geojson.features[featureNrToEdit];
51091
+ const feature = this.geojson.features[selectedFeatureIndex];
51102
51092
  const {
51103
51093
  coordinates
51104
51094
  } = feature.geometry;
@@ -51120,7 +51110,7 @@ class MapDraw extends React.PureComponent {
51120
51110
  }
51121
51111
  }
51122
51112
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
51123
- const feature = this.geojson.features[featureNrToEdit];
51113
+ const feature = this.geojson.features[selectedFeatureIndex];
51124
51114
  const featureCoords = feature.geometry.coordinates;
51125
51115
  featureCoords.pop();
51126
51116
  }
@@ -51359,7 +51349,7 @@ class MapDraw extends React.PureComponent {
51359
51349
  You are free to draw anything you like on the canvas.
51360
51350
  */
51361
51351
  const {
51362
- featureNrToEdit,
51352
+ selectedFeatureIndex,
51363
51353
  isInEditMode
51364
51354
  } = this.props;
51365
51355
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) {
@@ -51385,7 +51375,7 @@ class MapDraw extends React.PureComponent {
51385
51375
  continue;
51386
51376
  }
51387
51377
  for (let j = 0; j < XYCoords.length; j += 1) {
51388
- this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex, feature, featureIndex);
51378
+ this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
51389
51379
  }
51390
51380
  }
51391
51381
  if (featureType === 'MultiPoint') {
@@ -51396,7 +51386,7 @@ class MapDraw extends React.PureComponent {
51396
51386
  continue;
51397
51387
  }
51398
51388
  for (let j = 0; j < XYCoords.length; j += 1) {
51399
- this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex, feature, featureIndex);
51389
+ this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
51400
51390
  }
51401
51391
  }
51402
51392
  if (featureType === 'MultiPolygon') {
@@ -51420,11 +51410,11 @@ class MapDraw extends React.PureComponent {
51420
51410
  if (isInEditMode) {
51421
51411
  /* Draw all vertices on the edges of the polygons */
51422
51412
  for (let j = 0; j < XYCoords.length; j += 1) {
51423
- this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51413
+ this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51424
51414
  }
51425
51415
  if (middle && isInEditMode === true && XYCoords.length >= 3) {
51426
51416
  /* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
51427
- this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && featureNrToEdit === featureIndex, true, isInEditMode && featureNrToEdit === featureIndex);
51417
+ this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
51428
51418
  }
51429
51419
  }
51430
51420
  }
@@ -51463,11 +51453,11 @@ class MapDraw extends React.PureComponent {
51463
51453
  if (isInEditMode) {
51464
51454
  /* Draw all vertices on the edges of the polygons */
51465
51455
  for (let j = 0; j < XYCoords.length; j += 1) {
51466
- this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51456
+ this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51467
51457
  }
51468
51458
  if (middle && isInEditMode === true && XYCoords.length >= 3) {
51469
51459
  /* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
51470
- this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && featureNrToEdit === featureIndex, true, isInEditMode && featureNrToEdit === featureIndex);
51460
+ this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
51471
51461
  }
51472
51462
  }
51473
51463
  }
@@ -51496,14 +51486,14 @@ class MapDraw extends React.PureComponent {
51496
51486
  if (isInEditMode) {
51497
51487
  /* Draw all vertices on the edges of the polygons */
51498
51488
  for (let j = 0; j < XYCoords.length; j += 1) {
51499
- this.drawVertice(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51489
+ this.drawVertice(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51500
51490
  }
51501
51491
  }
51502
51492
  }
51503
51493
  }
51504
51494
  /* Higlight polygon with mousehover */
51505
- if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === featureNrToEdit && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE) {
51506
- const feature = this.geojson.features[featureNrToEdit];
51495
+ if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === selectedFeatureIndex && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE) {
51496
+ const feature = this.geojson.features[selectedFeatureIndex];
51507
51497
  const featureProperties = feature.properties;
51508
51498
  if (this.mouseOverPolygonCoordinates.length >= 2) {
51509
51499
  ctx.beginPath();
@@ -51756,7 +51746,7 @@ class MapDraw extends React.PureComponent {
51756
51746
  drawLine(ctx, XYCoords, featureIndex, lineStringIndex) {
51757
51747
  const {
51758
51748
  isInEditMode,
51759
- featureNrToEdit
51749
+ selectedFeatureIndex
51760
51750
  } = this.props;
51761
51751
  const feature = this.geojson.features[featureIndex];
51762
51752
  if (!feature || !feature.geometry) {
@@ -51809,7 +51799,7 @@ class MapDraw extends React.PureComponent {
51809
51799
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51810
51800
  // @ts-ignore
51811
51801
  middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
51812
- if (isInEditMode === true && this.snappedPolygonIndex === lineStringIndex && this.selectedEdge !== EDGE.NONE && featureNrToEdit === featureIndex) {
51802
+ if (isInEditMode === true && this.snappedPolygonIndex === lineStringIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
51813
51803
  /* Higlight selected edge of a LineString, previousely detected by mouseover event */
51814
51804
  ctx.beginPath();
51815
51805
  ctx.strokeStyle = '#FF0';
@@ -51830,7 +51820,7 @@ class MapDraw extends React.PureComponent {
51830
51820
  drawPolygon(ctx, XYCoords, featureIndex, polygonIndex) {
51831
51821
  const {
51832
51822
  isInEditMode,
51833
- featureNrToEdit
51823
+ selectedFeatureIndex
51834
51824
  } = this.props;
51835
51825
  const feature = this.geojson.features[featureIndex];
51836
51826
  if (!feature || !feature.geometry) {
@@ -51884,7 +51874,7 @@ class MapDraw extends React.PureComponent {
51884
51874
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51885
51875
  // @ts-ignore
51886
51876
  middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
51887
- if (isInEditMode === true && this.snappedPolygonIndex === polygonIndex && this.selectedEdge !== EDGE.NONE && featureNrToEdit === featureIndex) {
51877
+ if (isInEditMode === true && this.snappedPolygonIndex === polygonIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
51888
51878
  /* Higlight selected edge of a polygon, previousely detected by mouseover event */
51889
51879
  ctx.strokeStyle = '#FF0';
51890
51880
  ctx.lineWidth = 5;
@@ -51987,7 +51977,7 @@ class MapDraw extends React.PureComponent {
51987
51977
  const {
51988
51978
  updateGeojson
51989
51979
  } = this.props;
51990
- if (text !== 'new feature created') {
51980
+ if (text !== NEW_FEATURE_CREATED) {
51991
51981
  this.validatePolys(text === 'cancelEdit');
51992
51982
  }
51993
51983
  if (updateGeojson && this.geojson) {
@@ -52003,7 +51993,7 @@ MapDraw.defaultProps = {
52003
51993
  isInEditMode: false,
52004
51994
  isInDeleteMode: false,
52005
51995
  webmapjs: undefined,
52006
- featureNrToEdit: 0
51996
+ selectedFeatureIndex: 0
52007
51997
  };
52008
51998
 
52009
51999
  const MapDrawContainer = ({
@@ -52032,9 +52022,9 @@ const MapDrawContainer = ({
52032
52022
  layer.onClickFeature(hoverInfo);
52033
52023
  }
52034
52024
  },
52035
- updateGeojson: geojson => {
52025
+ updateGeojson: (geojson, reason) => {
52036
52026
  if (layer.updateGeojson) {
52037
- layer.updateGeojson(geojson);
52027
+ layer.updateGeojson(geojson, reason);
52038
52028
  }
52039
52029
  },
52040
52030
  exitDrawModeCallback: reason => {
@@ -52042,7 +52032,7 @@ const MapDrawContainer = ({
52042
52032
  layer.exitDrawModeCallback(reason);
52043
52033
  }
52044
52034
  },
52045
- featureNrToEdit: parseInt(layer.featureNrToEdit || '0', 10)
52035
+ selectedFeatureIndex: parseInt(layer.selectedFeatureIndex || '0', 10)
52046
52036
  }));
52047
52037
  }));
52048
52038
 
@@ -52097,7 +52087,7 @@ const FeatureLayers = ({
52097
52087
  }) => {
52098
52088
  const featureLayerList = geojson ? Array.from(Array(geojson.features.length).keys()).map(index => ({
52099
52089
  key: index,
52100
- value: `layer ${index + 1}: ${geojson.features[index].geometry.type}`
52090
+ value: `feature ${index + 1}: ${geojson.features[index].geometry.type}`
52101
52091
  })) : [];
52102
52092
  return /*#__PURE__*/React__default.createElement(Grid$1, {
52103
52093
  item: true,
@@ -52110,7 +52100,7 @@ const FeatureLayers = ({
52110
52100
  }
52111
52101
  }, /*#__PURE__*/React__default.createElement(InputLabel$1, {
52112
52102
  id: "demo-feature-number"
52113
- }, "Feature layers"), /*#__PURE__*/React__default.createElement(Select$1, {
52103
+ }, "Features"), /*#__PURE__*/React__default.createElement(Select$1, {
52114
52104
  labelId: "demo-feature-type",
52115
52105
  value: (featureLayerList.length ? activeFeatureLayerIndex : '').toString(),
52116
52106
  onChange: event => {
@@ -52555,6 +52545,264 @@ const useGeoJSON = () => {
52555
52545
  };
52556
52546
  };
52557
52547
 
52548
+ /* *
52549
+ * Licensed under the Apache License, Version 2.0 (the "License");
52550
+ * you may not use this file except in compliance with the License.
52551
+ * You may obtain a copy of the License at
52552
+ *
52553
+ * http://www.apache.org/licenses/LICENSE-2.0
52554
+ *
52555
+ * Unless required by applicable law or agreed to in writing, software
52556
+ * distributed under the License is distributed on an "AS IS" BASIS,
52557
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52558
+ * See the License for the specific language governing permissions and
52559
+ * limitations under the License.
52560
+ *
52561
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
52562
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
52563
+ * */
52564
+ const StoryLayoutGrid = ({
52565
+ mapComponent,
52566
+ children
52567
+ }) => {
52568
+ return /*#__PURE__*/React__default.createElement(Paper$1, null, /*#__PURE__*/React__default.createElement(Box$1, {
52569
+ sx: {
52570
+ display: 'grid',
52571
+ gridTemplateColumns: '70% 30%',
52572
+ gridTemplateRows: '150px 1fr',
52573
+ gridTemplateAreas: "'map controls'\n'map textarea'",
52574
+ width: '100%',
52575
+ height: '100vh'
52576
+ }
52577
+ }, /*#__PURE__*/React__default.createElement(Box$1, {
52578
+ sx: {
52579
+ gridArea: 'map',
52580
+ width: '100%',
52581
+ height: '100%'
52582
+ }
52583
+ }, mapComponent), /*#__PURE__*/React__default.createElement(Box$1, {
52584
+ sx: {
52585
+ gridArea: 'controls',
52586
+ width: '100%',
52587
+ height: '100%',
52588
+ padding: 2
52589
+ }
52590
+ }, /*#__PURE__*/React__default.createElement(Grid$1, {
52591
+ spacing: 2,
52592
+ container: true
52593
+ }, children))));
52594
+ };
52595
+
52596
+ const SelectField = ({
52597
+ label,
52598
+ value,
52599
+ onChangeValue,
52600
+ options: _options = [],
52601
+ width: _width = '50%',
52602
+ showValueAsColor: _showValueAsColor = false,
52603
+ labelSuffix: _labelSuffix = ''
52604
+ }) => {
52605
+ const onChange = event => {
52606
+ const {
52607
+ value
52608
+ } = event.target;
52609
+ onChangeValue(value);
52610
+ };
52611
+ const getLabel = currentValue => `${currentValue}${_labelSuffix}`;
52612
+ return /*#__PURE__*/React__default.createElement(FormControl$1, {
52613
+ variant: "filled",
52614
+ sx: {
52615
+ width: _width
52616
+ }
52617
+ }, /*#__PURE__*/React__default.createElement(InputLabel$1, null, label), /*#__PURE__*/React__default.createElement(Select$1, {
52618
+ value: value,
52619
+ onChange: onChange
52620
+ }, _options.map(value => /*#__PURE__*/React__default.createElement(MenuItem$1, {
52621
+ value: value,
52622
+ key: value
52623
+ }, _showValueAsColor ? /*#__PURE__*/React__default.createElement(Box$1, {
52624
+ sx: {
52625
+ backgroundColor: value,
52626
+ width: 20,
52627
+ height: 20
52628
+ }
52629
+ }) : getLabel(value.toString())))));
52630
+ };
52631
+
52632
+ function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
52633
+
52634
+ /**
52635
+ * Adds properties to the first geojson feature based on the given property object.
52636
+ * It only extends or changes the properties which are defined in styleConfig,
52637
+ * all other properties in the geojson are left unchanged.
52638
+ * @param geojson
52639
+ * @param featureProperties
52640
+ */
52641
+ const addFeatureProperties = (geojson, featureProperties, featureIndex = 0) => {
52642
+ if (!geojson) {
52643
+ return null;
52644
+ }
52645
+ return produce(geojson, draft => {
52646
+ if (draft.features && draft.features.length > 0 && draft.features[featureIndex] !== undefined && draft.features[featureIndex].properties) {
52647
+ Object.keys(featureProperties).forEach(key => {
52648
+ draft.features[featureIndex].properties[key] = featureProperties[key];
52649
+ });
52650
+ }
52651
+ });
52652
+ };
52653
+ const getGeoJSONPropertyValue = (property, properties, polygonDrawMode, defaultProperties = defaultGeoJSONStyleProperties) => {
52654
+ // if a shape is set, extract the style from there
52655
+ if (properties[property] !== undefined) {
52656
+ return properties[property];
52657
+ }
52658
+ // if active polygon tool is preset, retreive style from there
52659
+ if (polygonDrawMode) {
52660
+ const polygonDrawModeProperty = polygonDrawMode.shape.type === 'Feature' && polygonDrawMode.shape.properties[property];
52661
+ if (polygonDrawModeProperty !== undefined) {
52662
+ return polygonDrawModeProperty;
52663
+ }
52664
+ }
52665
+ // otherwise get values from defaultStyle
52666
+ return defaultProperties[property];
52667
+ };
52668
+ /**
52669
+ * moves geoJSON feature as new feature. Mutates newGeoJSON
52670
+ * @constructor
52671
+ * @param {GeoJSON.FeatureCollection} currentGeoJSON - current geoJSON
52672
+ * @param {GeoJSON.FeatureCollection} newGeoJSON - new geoJSON
52673
+ * @param {number} featureLayerIndex - feature layer index
52674
+ * @param {string} text - reason of change
52675
+ */
52676
+ const moveFeature = (currentGeoJSON, newGeoJSON, featureLayerIndex, reason) => {
52677
+ const feature = newGeoJSON.features[featureLayerIndex];
52678
+ const currentFeature = currentGeoJSON.features[featureLayerIndex];
52679
+ if (feature) {
52680
+ const {
52681
+ geometry
52682
+ } = feature;
52683
+ if (geometry.type === 'Polygon' && geometry.coordinates.length > 1 && reason === NEW_FEATURE_CREATED) {
52684
+ const lastCoordinate = geometry.coordinates.pop();
52685
+ const copyFeature = Object.assign(Object.assign({}, feature), {
52686
+ geometry: Object.assign(Object.assign({}, geometry), {
52687
+ coordinates: [lastCoordinate]
52688
+ })
52689
+ });
52690
+ newGeoJSON.features.push(copyFeature);
52691
+ return newGeoJSON.features.length - 1;
52692
+ }
52693
+ if (geometry.type === 'LineString' && geometry.coordinates.length > 2 && reason === NEW_LINESTRING_CREATED) {
52694
+ const lastCoordinate = geometry.coordinates.pop();
52695
+ const copyFeature = Object.assign(Object.assign({}, feature), {
52696
+ geometry: Object.assign(Object.assign({}, geometry), {
52697
+ coordinates: [lastCoordinate, lastCoordinate]
52698
+ })
52699
+ });
52700
+ newGeoJSON.features.push(copyFeature);
52701
+ return newGeoJSON.features.length - 1;
52702
+ }
52703
+ if (geometry.type === 'Point' && currentFeature && currentFeature.geometry.type === 'Point' && currentFeature.geometry.coordinates.length > 0 && reason === NEW_POINT_CREATED) {
52704
+ newGeoJSON.features.push(currentFeature);
52705
+ return newGeoJSON.features.length - 1;
52706
+ }
52707
+ }
52708
+ return undefined;
52709
+ };
52710
+ /**
52711
+ * Returns the intersection of two features. In case of a polygon, only the first feature is used.
52712
+ * @param a Feature A
52713
+ * @param b Feature B
52714
+ * @returns The intersection of the two features.
52715
+ */
52716
+ const intersectGeoJSONS = (a, b, geoJSONProperties = {
52717
+ stroke: '#FF0000',
52718
+ 'stroke-width': 10.0,
52719
+ 'stroke-opacity': 1,
52720
+ fill: '#0000FF',
52721
+ 'fill-opacity': 1.0
52722
+ }) => {
52723
+ const featureA = feature(a.features[0].geometry);
52724
+ const featureB = feature(b.features[0].geometry);
52725
+ const options = {
52726
+ tolerance: 0.001,
52727
+ highQuality: true
52728
+ };
52729
+ const simplifiedA = simplify$1(featureA, options);
52730
+ const simplifiedB = simplify$1(featureB, options);
52731
+ const intersection = intersect(simplifiedA, simplifiedB);
52732
+ return addFeatureProperties({
52733
+ type: 'FeatureCollection',
52734
+ features: intersection === null ? [{
52735
+ type: 'Feature',
52736
+ properties: {
52737
+ selectionType: 'poly'
52738
+ },
52739
+ geometry: {
52740
+ type: 'Polygon',
52741
+ coordinates: [[]]
52742
+ }
52743
+ }] : [intersection]
52744
+ }, geoJSONProperties);
52745
+ };
52746
+ /**
52747
+ * Adds the intersectionStart and intersectionEnd properties to the GeoJSONS structure
52748
+ * @param geoJSONs
52749
+ * @returns GeoJSONS extend with intersections
52750
+ */
52751
+ const createInterSections = (geojson, otherGeoJSON, geoJSONproperties = {
52752
+ stroke: '#f24a00',
52753
+ 'stroke-width': 1.5,
52754
+ 'stroke-opacity': 1,
52755
+ fill: '#f24a00',
52756
+ 'fill-opacity': 0.5
52757
+ }) => {
52758
+ const intersections = produce(geojson, () => {
52759
+ try {
52760
+ return addFeatureProperties(intersectGeoJSONS(geojson, otherGeoJSON), geoJSONproperties);
52761
+ } catch (error) {
52762
+ return addFeatureProperties(geojson, geoJSONproperties);
52763
+ }
52764
+ });
52765
+ return intersections;
52766
+ };
52767
+ const getGeoJson = (geojson, shouldAllowMultipleShapes) => {
52768
+ if (shouldAllowMultipleShapes || !geojson.features.length) {
52769
+ return geojson;
52770
+ }
52771
+ const {
52772
+ geometry
52773
+ } = geojson.features[0];
52774
+ if (geometry.type === 'Point' || geometry.type === 'LineString') {
52775
+ return geojson;
52776
+ }
52777
+ return geometry.coordinates.length > 1 ? produce(geojson, draft => {
52778
+ const draftFeature = draft.features[0];
52779
+ draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
52780
+ }) : geojson;
52781
+ };
52782
+ const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleShapes, geoJSONFeatureCollection = emptyGeoJSON) => {
52783
+ if (geoJSONFeature.type === 'FeatureCollection') {
52784
+ return geoJSONFeature;
52785
+ }
52786
+ if (shouldAllowMultipleShapes) {
52787
+ return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
52788
+ features: geoJSONFeatureCollection.features.concat(geoJSONFeature)
52789
+ });
52790
+ }
52791
+ return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
52792
+ features: [geoJSONFeature]
52793
+ });
52794
+ };
52795
+ // compares 2 geoJSONs and returns true if both have properties.selectionType with the same value
52796
+ const isGeoJSONFeatureCreatedByTool = (existingJSON, newGeoJSON) => {
52797
+ var _a, _b, _c;
52798
+ if (!existingJSON.features.length) {
52799
+ return false;
52800
+ }
52801
+ const lastUsedTool = (_a = existingJSON.features[0].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
52802
+ const newTool = newGeoJSON.type === 'Feature' ? (_b = newGeoJSON.properties) === null || _b === void 0 ? void 0 : _b.selectionType : (_c = newGeoJSON.features[0].properties) === null || _c === void 0 ? void 0 : _c.selectionType;
52803
+ return lastUsedTool !== undefined && newTool !== undefined ? lastUsedTool === newTool : false;
52804
+ };
52805
+
52558
52806
  const defaultIntersectionStyleProperties = Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
52559
52807
  'fill-opacity': 0.5
52560
52808
  });
@@ -52636,8 +52884,8 @@ const defaultDelete = {
52636
52884
  const defaultModes = [defaultPoint, defaultPolygon, defaultBox, defaultLineString, defaultDelete];
52637
52885
  const currentlySupportedDrawModes = [defaultPolygon, defaultDelete];
52638
52886
  const useMapDrawTool = ({
52639
- defaultEditModes: _defaultEditModes = defaultModes,
52640
- shouldAllowMultipleshapes: _shouldAllowMultipleshapes = false,
52887
+ defaultDrawModes: _defaultDrawModes = defaultModes,
52888
+ shouldAllowMultipleShapes: _shouldAllowMultipleShapes = false,
52641
52889
  defaultGeoJSON: _defaultGeoJSON = emptyGeoJSON,
52642
52890
  defaultGeoJSONIntersection: _defaultGeoJSONIntersection = emptyIntersectionShape,
52643
52891
  defaultGeoJSONIntersectionBounds,
@@ -52648,14 +52896,14 @@ const useMapDrawTool = ({
52648
52896
  const [geoJSONIntersection, setGeoJSONIntersection] = React__default.useState(_defaultGeoJSONIntersection);
52649
52897
  const [geoJSONIntersectionBounds, setGeoJSONIntersectionBounds] = React__default.useState(defaultGeoJSONIntersectionBounds);
52650
52898
  // state
52651
- const [editModes, setEditModes] = React__default.useState(_defaultEditModes);
52899
+ const [drawModes, setDrawModes] = React__default.useState(_defaultDrawModes);
52652
52900
  const [activeTool, setActiveTool] = React__default.useState('');
52653
52901
  const [drawMode, setDrawMode] = React__default.useState('');
52654
52902
  const [isInEditMode, setEditMode] = React__default.useState(false);
52655
52903
  const [featureLayerIndex, setFeatureLayerIndex] = React__default.useState(0);
52656
52904
  const changeProperties = styleProperties => {
52657
52905
  // update all modes with new properties
52658
- const newModes = editModes.map(mode => {
52906
+ const newModes = drawModes.map(mode => {
52659
52907
  const shape = mode.shape.type === 'Feature' ? Object.assign(Object.assign({}, mode.shape), {
52660
52908
  properties: Object.assign(Object.assign({}, mode.shape.properties), styleProperties)
52661
52909
  }) : addFeatureProperties(mode.shape, styleProperties);
@@ -52663,7 +52911,7 @@ const useMapDrawTool = ({
52663
52911
  shape
52664
52912
  });
52665
52913
  });
52666
- setEditModes(newModes);
52914
+ setDrawModes(newModes);
52667
52915
  // update current geoJSON with new properties
52668
52916
  const updateGeoJSON = addFeatureProperties(geoJSON, styleProperties, featureLayerIndex);
52669
52917
  setGeoJSON(updateGeoJSON);
@@ -52684,7 +52932,7 @@ const useMapDrawTool = ({
52684
52932
  setActiveTool(newMode.drawModeId);
52685
52933
  // updates shape
52686
52934
  const isNewSelectedTool = !isGeoJSONFeatureCreatedByTool(geoJSON, newMode.shape);
52687
- const shouldUpdateShape = !geoJSON.features.length || _shouldAllowMultipleshapes || isNewSelectedTool;
52935
+ const shouldUpdateShape = !geoJSON.features.length || _shouldAllowMultipleShapes || isNewSelectedTool;
52688
52936
  if (shouldUpdateShape) {
52689
52937
  const updatedGeoJSON = changeGeoJSON(newMode.shape);
52690
52938
  setFeatureLayerIndex(updatedGeoJSON.features.length - 1);
@@ -52693,9 +52941,15 @@ const useMapDrawTool = ({
52693
52941
  setDrawMode(newMode.value);
52694
52942
  setEditMode(!!newMode.value);
52695
52943
  };
52696
- const changeGeoJSON = updatedGeoJSON => {
52697
- const geoJSONFeatureCollection = getFeatureCollection(updatedGeoJSON, _shouldAllowMultipleshapes, geoJSON);
52698
- const newGeoJSON = getGeoJson(geoJSONFeatureCollection, _shouldAllowMultipleshapes);
52944
+ const changeGeoJSON = (updatedGeoJSON, reason = '') => {
52945
+ const geoJSONFeatureCollection = getFeatureCollection(updatedGeoJSON, _shouldAllowMultipleShapes, geoJSON);
52946
+ const newGeoJSON = getGeoJson(geoJSONFeatureCollection, _shouldAllowMultipleShapes);
52947
+ if (_shouldAllowMultipleShapes) {
52948
+ const newFeatureIndex = moveFeature(geoJSON, newGeoJSON, featureLayerIndex, reason);
52949
+ if (newFeatureIndex !== undefined) {
52950
+ setFeatureLayerIndex(newFeatureIndex);
52951
+ }
52952
+ }
52699
52953
  setGeoJSON(newGeoJSON);
52700
52954
  if (geoJSONIntersectionBounds) {
52701
52955
  setGeoJSONIntersection(createInterSections(newGeoJSON, geoJSONIntersectionBounds, _defaultGeoJSONIntersectionProperties));
@@ -52710,7 +52964,7 @@ const useMapDrawTool = ({
52710
52964
  };
52711
52965
  const onSetDrawMode = drawMode => {
52712
52966
  setDrawMode(drawMode);
52713
- const newActiveTool = editModes.find(mode => mode.value === drawMode);
52967
+ const newActiveTool = drawModes.find(mode => mode.value === drawMode);
52714
52968
  if (newActiveTool) {
52715
52969
  setActiveTool(newActiveTool.drawModeId);
52716
52970
  }
@@ -52737,7 +52991,7 @@ const useMapDrawTool = ({
52737
52991
  isInEditMode,
52738
52992
  drawMode,
52739
52993
  updateGeojson: changeGeoJSON,
52740
- featureNrToEdit: featureLayerIndex
52994
+ selectedFeatureIndex: featureLayerIndex
52741
52995
  };
52742
52996
  }
52743
52997
  // intersections
@@ -52754,7 +53008,7 @@ const useMapDrawTool = ({
52754
53008
  geoJSONIntersectionBounds,
52755
53009
  setGeoJSON: changeGeoJSON,
52756
53010
  setGeoJSONIntersectionBounds: onSetGeoJSONIntersectionBounds,
52757
- editModes,
53011
+ drawModes,
52758
53012
  isInEditMode,
52759
53013
  changeDrawMode: onSetDrawMode,
52760
53014
  setEditMode,
@@ -52766,12 +53020,66 @@ const useMapDrawTool = ({
52766
53020
  layers,
52767
53021
  getLayer,
52768
53022
  deactivateTool,
52769
- setEditModes,
53023
+ setDrawModes,
52770
53024
  changeProperties,
52771
53025
  getProperties
52772
53026
  };
52773
53027
  };
52774
53028
 
53029
+ // custom buttons
53030
+ const shapeButtonNL = {
53031
+ drawModeId: 'tool-fir',
53032
+ value: DRAWMODE.POLYGON,
53033
+ title: 'Custom FIR NL polygon',
53034
+ shape: intersectionFeatureNL,
53035
+ isSelectable: false
53036
+ };
53037
+ const customLineButton = {
53038
+ drawModeId: 'tool-custom-line',
53039
+ value: DRAWMODE.LINESTRING,
53040
+ title: 'Custom LineString',
53041
+ shape: {
53042
+ type: 'Feature',
53043
+ geometry: {
53044
+ type: 'LineString',
53045
+ coordinates: [[4.136829504703722, 50.944730810381465], [4.450134704406403, 53.81224530783831], [2.5703035061903217, 53.78911570560625], [5.252979278644519, 56.722490281934554], [8.758081200318252, 53.85846624679025], [6.290802752659646, 53.84691579421783], [6.623689527343743, 51.0556380592049], [4.136829504703722, 50.95706693142843]]
53046
+ },
53047
+ properties: defaultGeoJSONStyleProperties
53048
+ },
53049
+ isSelectable: false
53050
+ };
53051
+ // example options
53052
+ const basicExampleDrawOptions = {
53053
+ defaultGeoJSON: {
53054
+ type: 'FeatureCollection',
53055
+ features: [{
53056
+ type: 'Feature',
53057
+ properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
53058
+ selectionType: 'box'
53059
+ }),
53060
+ geometry: {
53061
+ type: 'Polygon',
53062
+ coordinates: [[[9.451665078283622, 53.21804334226515], [4.734608638338736, 53.21804334226515], [4.734608638338736, 54.57650543915101], [9.451665078283622, 54.57650543915101], [9.451665078283622, 53.21804334226515]]]
53063
+ }
53064
+ }]
53065
+ }
53066
+ };
53067
+ const basicExampleMultipleShapeDrawOptions = {
53068
+ shouldAllowMultipleShapes: true,
53069
+ // add multiple tools, and update all with custom color
53070
+ defaultDrawModes: [...defaultModes, shapeButtonNL, customLineButton].map(mode => Object.assign(Object.assign({}, mode), {
53071
+ shape: Object.assign(Object.assign({}, mode.shape), {
53072
+ properties: Object.assign(Object.assign({}, mode.shape.properties), {
53073
+ stroke: '#8F8',
53074
+ 'stroke-width': 4,
53075
+ 'stroke-opacity': 1,
53076
+ fill: '#33ccFF',
53077
+ 'fill-opacity': 0.5
53078
+ })
53079
+ })
53080
+ }))
53081
+ };
53082
+
52775
53083
  var fails$5 = fails$j;
52776
53084
  var global$4 = global$h;
52777
53085
 
@@ -52811,7 +53119,7 @@ var $RegExp$1 = global$3.RegExp;
52811
53119
 
52812
53120
  var regexpUnsupportedDotAll = fails$4(function () {
52813
53121
  var re = $RegExp$1('.', 's');
52814
- return !(re.dotAll && re.exec('\n') && re.flags === 's');
53122
+ return !(re.dotAll && re.test('\n') && re.flags === 's');
52815
53123
  });
52816
53124
 
52817
53125
  var fails$3 = fails$j;
@@ -53159,7 +53467,7 @@ var regexpExecAbstract = function (R, S) {
53159
53467
  return result;
53160
53468
  }
53161
53469
  if (classof$1(R) === 'RegExp') return call$1(regexpExec, R, S);
53162
- throw $TypeError$1('RegExp#exec called on incompatible receiver');
53470
+ throw new $TypeError$1('RegExp#exec called on incompatible receiver');
53163
53471
  };
53164
53472
 
53165
53473
  var apply = functionApply;
@@ -53585,7 +53893,7 @@ var createMethod = function (IS_RIGHT) {
53585
53893
  }
53586
53894
  index += i;
53587
53895
  if (IS_RIGHT ? index < 0 : length <= index) {
53588
- throw $TypeError('Reduce of empty array with no initial value');
53896
+ throw new $TypeError('Reduce of empty array with no initial value');
53589
53897
  }
53590
53898
  }
53591
53899
  for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
@@ -54503,6 +54811,8 @@ class ReactMapView extends React.Component {
54503
54811
  zIndex: 10
54504
54812
  }
54505
54813
  }, /*#__PURE__*/React.createElement("div", {
54814
+ role: "application",
54815
+ "aria-label": "map",
54506
54816
  ref: this.adagucWebMapJSRef
54507
54817
  })), /*#__PURE__*/React.createElement("div", {
54508
54818
  style: {
@@ -56348,4 +56658,4 @@ var publicLayers = /*#__PURE__*/Object.freeze({
56348
56658
  msgNaturalEUMETSAT: msgNaturalEUMETSAT
56349
56659
  });
56350
56660
 
56351
- export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, Legend, LegendDialog, LegendLayout, MapControlButton, MapControls, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, ReactMapView, ReactMapViewLayer, ZoomControls, addFeatureProperties, checkHoverFeatures, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, distance, drawPolyStoryStyles, emptyGeoJSON, featureBox, featureMultiPoint, featurePoint, featurePolygon, formatTime, getDrawFunctionFromStore, getFeatureCollection, getGeoJson, getIcon, getTimeDimension, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, publicLayers, publicServices, registerDrawFunction, simpleBoxGeoJSON, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, useGeoJSON, useMapDrawTool };
56661
+ export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, Legend, LegendDialog, LegendLayout, MapControlButton, MapControls, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, ZoomControls, addFeatureProperties, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, checkHoverFeatures, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, distance, drawPolyStoryStyles, emptyGeoJSON, featureBox, featureMultiPoint, featurePoint, featurePolygon, formatTime, getDrawFunctionFromStore, getFeatureCollection, getGeoJSONPropertyValue, getGeoJson, getIcon, getTimeDimension, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, moveFeature, publicLayers, publicServices, registerDrawFunction, simpleBoxGeoJSON, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, useGeoJSON, useMapDrawTool };