import isObject_default from "./isObject.js";
import _Stack_default from "./_Stack.js";
import _cloneBuffer_default from "./_cloneBuffer.js";
import _copyArray_default from "./_copyArray.js";
import _initCloneObject_default from "./_initCloneObject.js";
import isArray_default from "./isArray.js";
import isBuffer_default from "./isBuffer.js";
import _assignValue_default from "./_assignValue.js";
import keysIn_default from "./keysIn.js";
import _getTag_default from "./_getTag.js";
import _arrayEach_default from "./_arrayEach.js";
import keys_default from "./keys.js";
import _baseAssign_default from "./_baseAssign.js";
import _baseAssignIn_default from "./_baseAssignIn.js";
import _copySymbols_default from "./_copySymbols.js";
import _copySymbolsIn_default from "./_copySymbolsIn.js";
import _getAllKeys_default from "./_getAllKeys.js";
import _getAllKeysIn_default from "./_getAllKeysIn.js";
import _initCloneArray_default from "./_initCloneArray.js";
import _initCloneByTag_default from "./_initCloneByTag.js";
import isMap_default from "./isMap.js";
import isSet_default from "./isSet.js";
var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4, argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]", arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]", cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = !0, cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = !1;
function baseClone(z, B, V, H, U, W) {
	var G, K = B & CLONE_DEEP_FLAG, q = B & CLONE_FLAT_FLAG, J = B & CLONE_SYMBOLS_FLAG;
	if (V && (G = U ? V(z, H, U, W) : V(z)), G !== void 0) return G;
	if (!isObject_default(z)) return z;
	var Y = isArray_default(z);
	if (Y) {
		if (G = _initCloneArray_default(z), !K) return _copyArray_default(z, G);
	} else {
		var X = _getTag_default(z), Z = X == funcTag || X == genTag;
		if (isBuffer_default(z)) return _cloneBuffer_default(z, K);
		if (X == objectTag || X == argsTag || Z && !U) {
			if (G = q || Z ? {} : _initCloneObject_default(z), !K) return q ? _copySymbolsIn_default(z, _baseAssignIn_default(G, z)) : _copySymbols_default(z, _baseAssign_default(G, z));
		} else {
			if (!cloneableTags[X]) return U ? z : {};
			G = _initCloneByTag_default(z, X, K);
		}
	}
	W ||= new _Stack_default();
	var Q = W.get(z);
	if (Q) return Q;
	W.set(z, G), isSet_default(z) ? z.forEach(function(n) {
		G.add(baseClone(n, B, V, n, z, W));
	}) : isMap_default(z) && z.forEach(function(n, R) {
		G.set(R, baseClone(n, B, V, R, z, W));
	});
	var $ = Y ? void 0 : (J ? q ? _getAllKeysIn_default : _getAllKeys_default : q ? keysIn_default : keys_default)(z);
	return _arrayEach_default($ || z, function(n, R) {
		$ && (R = n, n = z[R]), _assignValue_default(G, R, baseClone(n, B, V, R, z, W));
	}), G;
}
var _baseClone_default = baseClone;
export { _baseClone_default as default };
