import { isArray as e } from "../predicate/isArray.js";
import { getTag as t } from "../_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 "../_internal/tags.js";
import { isPrimitive as w } from "../../predicate/isPrimitive.js";
import { isTypedArray as T } from "../predicate/isTypedArray.js";
//#region ../../node_modules/es-toolkit/dist/compat/object/clone.mjs
function E(n) {
	if (w(n)) return n;
	let r = t(n);
	if (!D(n)) return {};
	if (e(n)) {
		let e = Array.from(n);
		return n.length > 0 && typeof n[0] == "string" && Object.hasOwn(n, "index") && (e.index = n.index, e.input = n.input), e;
	}
	if (T(n)) {
		let e = n, t = e.constructor;
		return new t(e.buffer, e.byteOffset, e.length);
	}
	if (r === "[object ArrayBuffer]") return new ArrayBuffer(n.byteLength);
	if (r === "[object DataView]") {
		let e = n, t = e.buffer, r = e.byteOffset, i = e.byteLength, a = new ArrayBuffer(i), o = new Uint8Array(t, r, i);
		return new Uint8Array(a).set(o), new DataView(a);
	}
	if (r === "[object Boolean]" || r === "[object Number]" || r === "[object String]") {
		let e = n.constructor, t = new e(n.valueOf());
		return r === "[object String]" ? A(t, n) : O(t, n), t;
	}
	if (r === "[object Date]") return new Date(Number(n));
	if (r === "[object RegExp]") {
		let e = n, t = new RegExp(e.source, e.flags);
		return t.lastIndex = e.lastIndex, t;
	}
	if (r === "[object Symbol]") return Object(Symbol.prototype.valueOf.call(n));
	if (r === "[object Map]") {
		let e = n, t = /* @__PURE__ */ new Map();
		return e.forEach((e, n) => {
			t.set(n, e);
		}), t;
	}
	if (r === "[object Set]") {
		let e = n, t = /* @__PURE__ */ new Set();
		return e.forEach((e) => {
			t.add(e);
		}), t;
	}
	if (r === "[object Arguments]") {
		let e = n, t = {};
		return O(t, e), t.length = e.length, t[Symbol.iterator] = e[Symbol.iterator], t;
	}
	let i = {};
	return j(i, n), O(i, n), k(i, n), i;
}
function D(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;
	}
}
function O(e, t) {
	for (let n in t) Object.hasOwn(t, n) && (e[n] = t[n]);
}
function k(e, t) {
	let n = Object.getOwnPropertySymbols(t);
	for (let r = 0; r < n.length; r++) {
		let i = n[r];
		Object.prototype.propertyIsEnumerable.call(t, i) && (e[i] = t[i]);
	}
}
function A(e, t) {
	let n = t.valueOf().length;
	for (let r in t) Object.hasOwn(t, r) && (Number.isNaN(Number(r)) || Number(r) >= n) && (e[r] = t[r]);
}
function j(e, t) {
	let n = Object.getPrototypeOf(t);
	n !== null && typeof t.constructor == "function" && Object.setPrototypeOf(e, n);
}
//#endregion
export { E as clone };

//# sourceMappingURL=clone.js.map