{"version":3,"file":"mergeDeep.mjs","names":[],"sources":["../../src/object/mergeDeep.ts"],"sourcesContent":["import { isPlainObject } from '../is/isPlainObject';\n\n/**\n * Recursively merges source objects into target object (deep merge)\n * @param target - The target object\n * @param sources - The source objects\n * @returns Returns the target object\n * @example\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { d: 4, e: 5 }, f: 6 };\n * mergeDeep(obj1, obj2); // { a: 1, b: { c: 2, d: 4, e: 5 }, f: 6 }\n */\nexport function mergeDeep<T extends object, S extends object>(target: T, ...sources: S[]): T & S {\n  if (target == null) {\n    throw new TypeError('Cannot convert undefined or null to object');\n  }\n\n  const result = Object(target);\n\n  for (const source of sources) {\n    if (source != null) {\n      for (const key in source) {\n        if (Object.prototype.hasOwnProperty.call(source, key)) {\n          const targetValue = result[key];\n          const sourceValue = source[key];\n\n          // If both values are plain objects, merge recursively\n          if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {\n            result[key] = mergeDeep(Object(targetValue) as object, sourceValue);\n          } else {\n            result[key] = sourceValue;\n          }\n        }\n      }\n    }\n  }\n\n  return result;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,UAA8C,QAAW,GAAG,SAAqB;CAC/F,IAAI,UAAU,MACZ,MAAM,IAAI,UAAU,4CAA4C;CAGlE,MAAM,SAAS,OAAO,MAAM;CAE5B,KAAK,MAAM,UAAU,SACnB,IAAI,UAAU,MACP;OAAA,MAAM,OAAO,QAChB,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,GAAG,GAAG;GACrD,MAAM,cAAc,OAAO;GAC3B,MAAM,cAAc,OAAO;GAG3B,IAAI,cAAc,WAAW,KAAK,cAAc,WAAW,GACzD,OAAO,OAAO,UAAU,OAAO,WAAW,GAAa,WAAW;QAElE,OAAO,OAAO;EAElB;;CAKN,OAAO;AACT"}