cachedCleverMerge = (first, second) => {
	if (second === undefined) return /** @type {T} */ (first);
	if (first === undefined) return /** @type {O} */ (second);
	if (typeof second !== "object" || second === null)
		return /** @type {O} */ (second);
	if (typeof first !== "object" || first === null)
		return /** @type {T} */ (first);

	let innerCache = mergeCache.get(first);
	if (innerCache === undefined) {
		innerCache = new WeakMap();
		mergeCache.set(first, innerCache);
	}
	const prevMerge = /** @type {T & O} */ (innerCache.get(second));
	if (prevMerge !== undefined) return prevMerge;
	const newMerge = _cleverMerge(first, second, true);
	innerCache.set(second, newMerge);
	return newMerge;
}
Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
@template T
@template O
@example
// performs cleverMerge(first, second), stores the result in WeakMap and returns result
cachedCleverMerge({a: 1}, {a: 2})
{a: 2}
 // when same arguments passed, gets the result from WeakMap and returns it.
cachedCleverMerge({a: 1}, {a: 2})
{a: 2}
@param {T | null | undefined} first first object
@param {O | null | undefined} second second object
@returns {T & O | T | O} merged object of first and second object