import { l as O } from "./logger.mjs";
import "@seamless/logger";
import { L as m, a as d } from "./initializeLogger.mjs";
import { identifyTenant as j } from "@b2x/std/helpers.mjs";
function k(t, n = /* @__PURE__ */ new WeakSet()) {
  if (n.has(t))
    return t;
  n.add(t), Object.freeze(t);
  for (const e of Object.keys(t)) {
    const r = t[e];
    w(r) && !Object.isFrozen(r) && k(r, n);
  }
  return t;
}
function w(t) {
  return typeof t == "object" && t !== null;
}
function p(t, n, e = /* @__PURE__ */ new WeakMap()) {
  return Object.is(t, n) ? !0 : typeof t != typeof n || typeof t != "object" ? !1 : t === null || n === null ? t === n : t instanceof Map != n instanceof Map || t instanceof Set != n instanceof Set || Array.isArray(t) !== Array.isArray(n) || t instanceof Date != n instanceof Date ? !1 : t instanceof Date ? t.getTime() === n.getTime() : t instanceof Map ? S(t, n, e) : t instanceof Set ? g(t, n, e) : Array.isArray(t) ? E(t, n, e) : K(t, n, e);
}
function S(t, n, e) {
  if (t.size !== n.size)
    return !1;
  if (e.has(t))
    return e.get(t) === n;
  e.set(t, n);
  const r = t.entries(), s = n.entries();
  let i = r.next(), u = s.next();
  for (; !(i.done || u.done); ) {
    const [y, f] = i.value, [o, c] = u.value;
    if (!p(f, c, e))
      return !1;
    i = r.next(), u = s.next();
  }
  return !!(i.done && u.done);
}
function g(t, n, e) {
  if (t.size !== n.size)
    return !1;
  if (e.has(t))
    return e.get(t) === n;
  e.set(t, n);
  for (const r of t)
    if (!M(n, r, e))
      return !1;
  return !0;
}
function M(t, n, e) {
  for (const r of t)
    if (p(n, r, e))
      return !0;
  return !1;
}
function E(t, n, e) {
  if (t.length !== n.length)
    return !1;
  if (e.has(t))
    return e.get(t) === n;
  e.set(t, n);
  for (let r = 0; r < t.length; r++) {
    const s = Object.hasOwn(t, r), i = Object.hasOwn(n, r);
    if (s !== i || s && !p(t[r], n[r], e))
      return !1;
  }
  return !0;
}
function K(t, n, e) {
  if (e.has(t))
    return e.get(t) === n;
  e.set(t, n);
  const r = [...Object.keys(t), ...Object.getOwnPropertySymbols(t)], s = [...Object.keys(n), ...Object.getOwnPropertySymbols(n)];
  if (r.length !== s.length)
    return !1;
  for (const i of r)
    if (!(s.includes(i) && p(t[i], n[i], e)))
      return !1;
  return !0;
}
function T(t, n, e = /* @__PURE__ */ new WeakMap()) {
  return Array.isArray(t) && Array.isArray(n) ? n.slice() : Array.isArray(t) && a(n) ? v(t, n) : a(t) && Array.isArray(n) ? W(t, n) : a(t) && a(n) ? A(t, n, e) : a(n) ? n : a(t) ? t : n;
}
function a(t) {
  return Object.prototype.toString.call(t) === "[object Object]";
}
function v(t, n) {
  const e = [...t];
  for (const r of Reflect.ownKeys(n))
    e[r] = n[r];
  return e;
}
function W(t, n) {
  const e = { ...t };
  for (let r = 0; r < n.length; r++)
    e[r] = n[r];
  return e;
}
function A(t, n, e) {
  if (e.has(n))
    return e.get(n);
  const r = { ...t };
  e.set(n, r);
  for (const s of Reflect.ownKeys(n)) {
    const i = n[s], u = t[s];
    if (Array.isArray(u) && Array.isArray(i)) {
      r[s] = i.slice();
      continue;
    }
    if (a(u) && a(i)) {
      r[s] = z(u, i, e);
      continue;
    }
    r[s] = p(i, u) ? u : i;
  }
  return r;
}
function z(t, n, e) {
  const r = A(t, n, e);
  return p(r, t) ? t : r;
}
function R(t) {
  const n = structuredClone(t);
  function e(f, o) {
    for (const c of Reflect.ownKeys(f))
      typeof c == "symbol" && (o[c] = R(f[c]));
  }
  function r(f, o, c) {
    for (let l = 0; l < f.length; l++)
      y(f[l], o[l], c);
  }
  function s(f, o, c) {
    for (const [l, h] of f)
      y(h, o.get(l), c);
  }
  function i(f, o, c) {
    for (const l of f)
      for (const h of o)
        typeof l == "object" && typeof h == "object" && l !== null && h !== null && y(l, h, c);
  }
  function u(f, o, c) {
    for (const l of Reflect.ownKeys(f))
      (typeof l == "string" || typeof l == "symbol") && y(f[l], o[l], c);
  }
  function y(f, o, c = /* @__PURE__ */ new WeakMap()) {
    if (!(!f || typeof f != "object" || !o || typeof o != "object") && !c.has(f)) {
      if (c.set(f, o), e(f, o), Array.isArray(f)) {
        r(f, o, c);
        return;
      }
      if (f instanceof Map && o instanceof Map) {
        s(f, o, c);
        return;
      }
      if (f instanceof Set && o instanceof Set) {
        i(f, o, c);
        return;
      }
      u(f, o, c);
    }
  }
  return y(t, n), n;
}
function V(t, n) {
  const e = {};
  for (const r in n) {
    const s = n[r];
    typeof s == "function" ? e[r] = ((...i) => (j(t, r), s(...i))) : O(`Method "${r}" is not a function and was ignored.`, {
      group: d.UTILS,
      level: m.WARN
    });
  }
  return e;
}
export {
  T as a,
  R as b,
  p as c,
  k as d,
  V as w
};
//# sourceMappingURL=with-usage-tracking.mjs.map
