import { getSymbols as e } from "../compat/_internal/getSymbols.js";
import { getTag as t } from "../compat/_internal/getTag.js";
import { argumentsTag as n, arrayBufferTag as r, arrayTag as i, booleanTag as a, dataViewTag as o, dateTag as s, float32ArrayTag as c, float64ArrayTag as l, int16ArrayTag as u, int32ArrayTag as d, int8ArrayTag as f, mapTag as p, numberTag as m, objectTag as h, regexpTag as g, setTag as _, stringTag as v, symbolTag as y, uint16ArrayTag as b, uint32ArrayTag as x, uint8ArrayTag as S, uint8ClampedArrayTag as C } from "../compat/_internal/tags.js";
import { isBuffer as w } from "../predicate/isBuffer.js";
import { isPrimitive as T } from "../predicate/isPrimitive.js";
import { isTypedArray as E } from "../predicate/isTypedArray.js";
//#region ../../node_modules/es-toolkit/dist/object/cloneDeepWith.mjs
function D(e, t) {
	return O(e, void 0, e, /* @__PURE__ */ new Map(), t);
}
function O(e, t, n, r = /* @__PURE__ */ new Map(), i = void 0) {
	let a = i?.(e, t, n, r);
	if (a !== void 0) return a;
	if (T(e)) return e;
	if (r.has(e)) return r.get(e);
	if (Array.isArray(e)) {
		let t = Array(e.length);
		r.set(e, t);
		for (let a = 0; a < e.length; a++) t[a] = O(e[a], a, n, r, i);
		return Object.hasOwn(e, "index") && (t.index = e.index), Object.hasOwn(e, "input") && (t.input = e.input), t;
	}
	if (e instanceof Date) return new Date(e.getTime());
	if (e instanceof RegExp) {
		let t = new RegExp(e.source, e.flags);
		return t.lastIndex = e.lastIndex, t;
	}
	if (e instanceof Map) {
		let t = /* @__PURE__ */ new Map();
		r.set(e, t);
		for (let [a, o] of e) t.set(a, O(o, a, n, r, i));
		return t;
	}
	if (e instanceof Set) {
		let t = /* @__PURE__ */ new Set();
		r.set(e, t);
		for (let a of e) t.add(O(a, void 0, n, r, i));
		return t;
	}
	if (w(e)) return e.subarray();
	if (E(e)) {
		let t = new (Object.getPrototypeOf(e)).constructor(e.length);
		r.set(e, t);
		for (let a = 0; a < e.length; a++) t[a] = O(e[a], a, n, r, i);
		return t;
	}
	if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return e.slice(0);
	if (e instanceof DataView) {
		let t = new DataView(e.buffer.slice(0), e.byteOffset, e.byteLength);
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (typeof File < "u" && e instanceof File) {
		let t = new File([e], e.name, { type: e.type });
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (typeof Blob < "u" && e instanceof Blob) {
		let t = new Blob([e], { type: e.type });
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (e instanceof Error) {
		let t = structuredClone(e);
		return r.set(e, t), t.message = e.message, t.name = e.name, t.stack = e.stack, t.cause = e.cause, t.constructor = e.constructor, k(t, e, n, r, i), t;
	}
	if (e instanceof Boolean) {
		let t = new Boolean(e.valueOf());
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (e instanceof Number) {
		let t = new Number(e.valueOf());
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (e instanceof String) {
		let t = new String(e.valueOf());
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	if (typeof e == "object" && A(e)) {
		let t = Object.create(Object.getPrototypeOf(e));
		return r.set(e, t), k(t, e, n, r, i), t;
	}
	return e;
}
function k(t, n, r = t, i, a) {
	let o = [...Object.keys(n), ...e(n)];
	for (let e = 0; e < o.length; e++) {
		let s = o[e], c = Object.getOwnPropertyDescriptor(t, s);
		(c == null || c.writable) && (t[s] = O(n[s], s, r, i, a));
	}
}
function A(e) {
	switch (t(e)) {
		case n:
		case i:
		case r:
		case o:
		case a:
		case s:
		case c:
		case l:
		case f:
		case u:
		case d:
		case p:
		case m:
		case h:
		case g:
		case _:
		case v:
		case y:
		case S:
		case C:
		case b:
		case x: return !0;
		default: return !1;
	}
}
//#endregion
export { D as cloneDeepWith, k as copyProperties };

//# sourceMappingURL=cloneDeepWith.js.map