export function deepMerge(target: Record, source: Record): Record { for (const key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { const targetValue = target[key] const sourceValue = source[key] if (Array.isArray(sourceValue)) { target[key] = Array.isArray(targetValue) ? [...targetValue, ...sourceValue] : [...sourceValue] } else if (isPlainObject(sourceValue)) { const baseValue = isPlainObject(targetValue) ? targetValue : {} target[key] = deepMerge(baseValue, sourceValue) } else { target[key] = sourceValue } } } return target } function isPlainObject(value: unknown): value is Record { if (!value || typeof value !== 'object') return false const proto = Object.getPrototypeOf(value) return proto === Object.prototype || proto === null }