import assignMergeValue from './_assignMergeValue.js';import baseClone from './_baseClone.js';import copyArray from './_copyArray.js';import isArguments from './isArguments.js';import isArray from './isArray.js';import isArrayLikeObject from './isArrayLikeObject.js';import isFunction from './isFunction.js';import isObject from './isObject.js';import isPlainObject from './isPlainObject.js';import isTypedArray from './isTypedArray.js';import toPlainObject from './toPlainObject.js';
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue);
if (stacked) { assignMergeValue(object, key, stacked); return; } var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined;
var isCommon = newValue === undefined;
if (isCommon) { newValue = srcValue; if (isArray(srcValue) || isTypedArray(srcValue)) { if (isArray(objValue)) { newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } else { isCommon = false; newValue = baseClone(srcValue, true); } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { if (isArguments(objValue)) { newValue = toPlainObject(objValue); } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { isCommon = false; newValue = baseClone(srcValue, true); } else { newValue = objValue; } } else { isCommon = false; } } if (isCommon) { stack.set(srcValue, newValue); mergeFunc(newValue, srcValue, srcIndex, customizer, stack); stack['delete'](srcValue); } assignMergeValue(object, key, newValue);}
export default baseMergeDeep;