"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const _Stack = require("./_Stack.js");
const _arrayEach = require("./_arrayEach.js");
const _assignValue = require("./_assignValue.js");
const _baseAssign = require("./_baseAssign.js");
const _baseAssignIn = require("./_baseAssignIn.js");
const _cloneBuffer = require("./_cloneBuffer.js");
const _copyArray = require("./_copyArray.js");
const _copySymbols = require("./_copySymbols.js");
const _copySymbolsIn = require("./_copySymbolsIn.js");
const _getAllKeys = require("./_getAllKeys.js");
const _getAllKeysIn = require("./_getAllKeysIn.js");
const _getTag = require("./_getTag.js");
const _initCloneArray = require("./_initCloneArray.js");
const _initCloneByTag = require("./_initCloneByTag.js");
const _initCloneObject = require("./_initCloneObject.js");
const isArray$1 = require("./isArray.js");
const isBuffer$1 = require("./isBuffer.js");
const isMap$1 = require("./isMap.js");
const isObject$1 = require("./isObject.js");
const isSet$1 = require("./isSet.js");
const keys$1 = require("./keys.js");
const keysIn$1 = require("./keysIn.js");
var Stack = _Stack._Stack, arrayEach = _arrayEach._arrayEach, assignValue = _assignValue._assignValue, baseAssign = _baseAssign._baseAssign, baseAssignIn = _baseAssignIn._baseAssignIn, cloneBuffer = _cloneBuffer._cloneBufferExports, copyArray = _copyArray._copyArray, copySymbols = _copySymbols._copySymbols, copySymbolsIn = _copySymbolsIn._copySymbolsIn, getAllKeys = _getAllKeys._getAllKeys, getAllKeysIn = _getAllKeysIn._getAllKeysIn, getTag = _getTag._getTag, initCloneArray = _initCloneArray._initCloneArray, initCloneByTag = _initCloneByTag._initCloneByTag, initCloneObject = _initCloneObject._initCloneObject, isArray = isArray$1.isArray_1, isBuffer = isBuffer$1.isBufferExports, isMap = isMap$1.isMap_1, isObject = isObject$1.isObject_1, isSet = isSet$1.isSet_1, keys = keys$1.keys_1, keysIn = keysIn$1.keysIn_1;
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 (customizer) {
    result = object ? customizer(value, key, object, stack) : customizer(value);
  }
  if (result !== void 0) {
    return result;
  }
  if (!isObject(value)) {
    return value;
  }
  var isArr = isArray(value);
  if (isArr) {
    result = initCloneArray(value);
    if (!isDeep) {
      return copyArray(value, result);
    }
  } else {
    var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
    if (isBuffer(value)) {
      return cloneBuffer(value, isDeep);
    }
    if (tag == objectTag || tag == argsTag || isFunc && !object) {
      result = isFlat || isFunc ? {} : initCloneObject(value);
      if (!isDeep) {
        return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
      }
    } else {
      if (!cloneableTags[tag]) {
        return object ? value : {};
      }
      result = initCloneByTag(value, tag, isDeep);
    }
  }
  stack || (stack = new Stack());
  var stacked = stack.get(value);
  if (stacked) {
    return stacked;
  }
  stack.set(value, result);
  if (isSet(value)) {
    value.forEach(function(subValue) {
      result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
    });
  } else if (isMap(value)) {
    value.forEach(function(subValue, key2) {
      result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
    });
  }
  var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
  var props = isArr ? void 0 : keysFunc(value);
  arrayEach(props || value, function(subValue, key2) {
    if (props) {
      key2 = subValue;
      subValue = value[key2];
    }
    assignValue(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
  });
  return result;
}
var _baseClone = baseClone;
exports._baseClone = _baseClone;
