"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const _Stack = require("./_Stack.cjs");
const _arrayEach = require("./_arrayEach.cjs");
const _assignValue = require("./_assignValue.cjs");
const _baseAssign = require("./_baseAssign.cjs");
const _baseAssignIn = require("./_baseAssignIn.cjs");
const _cloneBuffer = require("./_cloneBuffer.cjs");
const _copyArray = require("./_copyArray.cjs");
const _copySymbols = require("./_copySymbols.cjs");
const _copySymbolsIn = require("./_copySymbolsIn.cjs");
const _getAllKeys = require("./_getAllKeys.cjs");
const _getAllKeysIn = require("./_getAllKeysIn.cjs");
const _getTag = require("./_getTag.cjs");
const _initCloneArray = require("./_initCloneArray.cjs");
const _initCloneByTag = require("./_initCloneByTag.cjs");
const _initCloneObject = require("./_initCloneObject.cjs");
const isArray = require("./isArray.cjs");
const isBuffer = require("./isBuffer.cjs");
const isMap = require("./isMap.cjs");
const isObject = require("./isObject.cjs");
const isSet = require("./isSet.cjs");
const keys = require("./keys.cjs");
const keysIn = require("./keysIn.cjs");
var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
var 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]";
var 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]";
var 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] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
function baseClone(value, bitmask, customizer, key, object, stack) {
  var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
  if (result !== void 0) {
    return result;
  }
  if (!isObject.default(value)) {
    return value;
  }
  var isArr = isArray.default(value);
  if (isArr) {
    result = _initCloneArray.default(value);
    if (!isDeep) {
      return _copyArray.default(value, result);
    }
  } else {
    var tag = _getTag.default(value), isFunc = tag == funcTag || tag == genTag;
    if (isBuffer.default(value)) {
      return _cloneBuffer.default(value, isDeep);
    }
    if (tag == objectTag || tag == argsTag || isFunc && !object) {
      result = isFlat || isFunc ? {} : _initCloneObject.default(value);
      if (!isDeep) {
        return isFlat ? _copySymbolsIn.default(value, _baseAssignIn.default(result, value)) : _copySymbols.default(value, _baseAssign.default(result, value));
      }
    } else {
      if (!cloneableTags[tag]) {
        return object ? value : {};
      }
      result = _initCloneByTag.default(value, tag, isDeep);
    }
  }
  stack || (stack = new _Stack.default());
  var stacked = stack.get(value);
  if (stacked) {
    return stacked;
  }
  stack.set(value, result);
  if (isSet.default(value)) {
    value.forEach(function(subValue) {
      result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
    });
  } else if (isMap.default(value)) {
    value.forEach(function(subValue, key2) {
      result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
    });
  }
  var keysFunc = isFull ? isFlat ? _getAllKeysIn.default : _getAllKeys.default : isFlat ? keysIn.default : keys.default;
  var props = isArr ? void 0 : keysFunc(value);
  _arrayEach.default(props || value, function(subValue, key2) {
    if (props) {
      key2 = subValue;
      subValue = value[key2];
    }
    _assignValue.default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
  });
  return result;
}
exports.default = baseClone;
//# sourceMappingURL=_baseClone.cjs.map
