"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DeepCopy_exports = {};
__export(DeepCopy_exports, {
  deepCopy: () => deepCopy
});
module.exports = __toCommonJS(DeepCopy_exports);
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function deepCopy(value) {
  let clones;
  function copy(value2) {
    if (typeof value2 === "object") {
      if (value2 === null) {
        return null;
      }
      let clone = clones?.get(value2);
      if (clone) {
        return clone;
      }
      if (Array.isArray(value2)) {
        clone = value2.map(copy);
      } else if (ArrayBuffer.isView(value2)) {
        const ViewType = value2.constructor;
        clone = ViewType.from(value2);
      } else {
        clone = Object.fromEntries(Object.entries(value2).map(([k, v]) => [k, copy(v)]));
      }
      if (!clones) {
        clones = /* @__PURE__ */ new Map();
      }
      clones.set(value2, clone);
      return clone;
    }
    return value2;
  }
  return copy(value);
}
//# sourceMappingURL=DeepCopy.js.map
