diff --git a/index.html b/index.html
index d0efbb0a..0562f0db 100644
--- a/index.html
+++ b/index.html
@@ -7855,6 +7855,7 @@
+
diff --git a/modules/river-generator.js b/modules/river-generator.js
index 08500534..957fe6fc 100644
--- a/modules/river-generator.js
+++ b/modules/river-generator.js
@@ -40,6 +40,7 @@ window.Rivers = (function () {
const cellsNumberModifier = (pointsInput.dataset.cells / 10000) ** 0.25;
const prec = grid.cells.prec;
+ const area = pack.cells.area;
const land = cells.i.filter(i => h[i] >= 20).sort((a, b) => h[b] - h[a]);
const lakeOutCells = Lakes.setClimateData(h);
diff --git a/utils/arrayUtils.js b/utils/arrayUtils.js
index 06f0448c..a466a0b7 100644
--- a/utils/arrayUtils.js
+++ b/utils/arrayUtils.js
@@ -62,3 +62,37 @@ function createTypedArray({maxValue, length, from}) {
function unique(array) {
return [...new Set(array)];
}
+
+// deep copy for Arrays (and other objects)
+function deepCopy(obj) {
+ const id = x=>x;
+ const dcTArray = a => a.map(id);
+ const dcObject = x => Object.fromEntries(Object.entries(x).map(([k,d])=>[k,dcAny(d)]));
+ const dcAny = x => x instanceof Object ? (cf.get(x.constructor)||id)(x) : x;
+ // don't map keys, probably this is what we would expect
+ const dcMapCore = m => [...m.entries()].map(([k,v])=>[k, dcAny(v)]);
+
+ const cf = new Map([
+ [Int8Array, dcTArray],
+ [Uint8Array, dcTArray],
+ [Uint8ClampedArray, dcTArray],
+ [Int16Array, dcTArray],
+ [Uint16Array, dcTArray],
+ [Int32Array, dcTArray],
+ [Uint32Array, dcTArray],
+ [Float32Array, dcTArray],
+ [Float64Array, dcTArray],
+ [BigInt64Array, dcTArray],
+ [BigUint64Array, dcTArray],
+ [Map, m => new Map(dcMapCore(m))],
+ [WeakMap, m => new WeakMap(dcMapCore(m))],
+ [Array, a => a.map(dcAny)],
+ [Set, s => [...s.values()].map(dcAny)],
+ [Date, d => new Date(d.getTime())],
+ [Object, dcObject],
+ // other types will be referenced
+ // ... extend here to implement their custom deep copy
+ ]);
+
+ return dcAny(obj);
+}