function e(e2) {
  for (var t2 = arguments.length, r2 = Array(t2 > 1 ? t2 - 1 : 0), n2 = 1; n2 < t2; n2++)
    r2[n2 - 1] = arguments[n2];
  if ("production" !== process.env.NODE_ENV) {
    var o2 = U[e2], i2 = o2 ? "function" == typeof o2 ? o2.apply(null, r2) : o2 : "unknown error nr: " + e2;
    throw Error("[Immer] " + i2);
  }
  throw Error("[Immer] minified error nr: " + e2 + (r2.length ? " " + r2.map(function(e3) {
    return "'" + e3 + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function t(e2) {
  return !!e2 && !!e2[V];
}
function r(e2) {
  var t2;
  return !!e2 && (function(e3) {
    if (!e3 || "object" != typeof e3)
      return false;
    var t3 = Object.getPrototypeOf(e3);
    if (null === t3)
      return true;
    var r2 = Object.hasOwnProperty.call(t3, "constructor") && t3.constructor;
    return r2 === Object || "function" == typeof r2 && Function.toString.call(r2) === W;
  }(e2) || Array.isArray(e2) || !!e2[K] || !!(null === (t2 = e2.constructor) || void 0 === t2 ? void 0 : t2[K]) || a(e2) || c(e2));
}
function n(e2, t2, r2) {
  void 0 === r2 && (r2 = false), 0 === o(e2) ? (r2 ? Object.keys : $)(e2).forEach(function(n2) {
    r2 && "symbol" == typeof n2 || t2(n2, e2[n2], e2);
  }) : e2.forEach(function(r3, n2) {
    return t2(n2, r3, e2);
  });
}
function o(e2) {
  var t2 = e2[V];
  return t2 ? t2.i > 3 ? t2.i - 4 : t2.i : Array.isArray(e2) ? 1 : a(e2) ? 2 : c(e2) ? 3 : 0;
}
function i(e2, t2) {
  return 2 === o(e2) ? e2.has(t2) : Object.prototype.hasOwnProperty.call(e2, t2);
}
function u(e2, t2, r2) {
  var n2 = o(e2);
  2 === n2 ? e2.set(t2, r2) : 3 === n2 ? e2.add(r2) : e2[t2] = r2;
}
function a(e2) {
  return z && e2 instanceof Map;
}
function c(e2) {
  return M && e2 instanceof Set;
}
function f(e2) {
  return e2.o || e2.t;
}
function s(e2) {
  if (Array.isArray(e2))
    return Array.prototype.slice.call(e2);
  var t2 = G(e2);
  delete t2[V];
  for (var r2 = $(t2), n2 = 0; n2 < r2.length; n2++) {
    var o2 = r2[n2], i2 = t2[o2];
    false === i2.writable && (i2.writable = true, i2.configurable = true), (i2.get || i2.set) && (t2[o2] = { configurable: true, writable: true, enumerable: i2.enumerable, value: e2[o2] });
  }
  return Object.create(Object.getPrototypeOf(e2), t2);
}
function l(e2, i2) {
  return void 0 === i2 && (i2 = false), d(e2) || t(e2) || !r(e2) || (o(e2) > 1 && (e2.set = e2.add = e2.clear = e2.delete = p), Object.freeze(e2), i2 && n(e2, function(e3, t2) {
    return l(t2, true);
  }, true)), e2;
}
function p() {
  e(2);
}
function d(e2) {
  return null == e2 || "object" != typeof e2 || Object.isFrozen(e2);
}
function y(t2) {
  var r2 = J[t2];
  return r2 || e(18, t2), r2;
}
function v() {
  return "production" === process.env.NODE_ENV || k || e(0), k;
}
function h(e2, t2) {
  t2 && (y("Patches"), e2.u = [], e2.s = [], e2.v = t2);
}
function b(e2) {
  m(e2), e2.p.forEach(g), e2.p = null;
}
function m(e2) {
  e2 === k && (k = e2.l);
}
function P(e2) {
  return k = { p: [], l: k, h: e2, m: true, _: 0 };
}
function g(e2) {
  var t2 = e2[V];
  0 === t2.i || 1 === t2.i ? t2.j() : t2.g = true;
}
function O(t2, n2) {
  n2._ = n2.p.length;
  var o2 = n2.p[0], i2 = void 0 !== t2 && t2 !== o2;
  return n2.h.O || y("ES5").S(n2, t2, i2), i2 ? (o2[V].P && (b(n2), e(4)), r(t2) && (t2 = j(n2, t2), n2.l || A(n2, t2)), n2.u && y("Patches").M(o2[V].t, t2, n2.u, n2.s)) : t2 = j(n2, o2, []), b(n2), n2.u && n2.v(n2.u, n2.s), t2 !== C ? t2 : void 0;
}
function j(e2, t2, r2) {
  if (d(t2))
    return t2;
  var o2 = t2[V];
  if (!o2)
    return n(t2, function(n2, i3) {
      return w(e2, o2, t2, n2, i3, r2);
    }, true), t2;
  if (o2.A !== e2)
    return t2;
  if (!o2.P)
    return A(e2, o2.t, true), o2.t;
  if (!o2.I) {
    o2.I = true, o2.A._--;
    var i2 = 4 === o2.i || 5 === o2.i ? o2.o = s(o2.k) : o2.o, u2 = i2, a2 = false;
    3 === o2.i && (u2 = new Set(i2), i2.clear(), a2 = true), n(u2, function(t3, n2) {
      return w(e2, o2, i2, t3, n2, r2, a2);
    }), A(e2, i2, false), r2 && e2.u && y("Patches").N(o2, r2, e2.u, e2.s);
  }
  return o2.o;
}
function w(n2, o2, a2, c2, f2, s2, l2) {
  if ("production" !== process.env.NODE_ENV && f2 === a2 && e(5), t(f2)) {
    var p2 = j(n2, f2, s2 && o2 && 3 !== o2.i && !i(o2.R, c2) ? s2.concat(c2) : void 0);
    if (u(a2, c2, p2), !t(p2))
      return;
    n2.m = false;
  } else
    l2 && a2.add(f2);
  if (r(f2) && !d(f2)) {
    if (!n2.h.D && n2._ < 1)
      return;
    j(n2, f2), o2 && o2.A.l || A(n2, f2);
  }
}
function A(e2, t2, r2) {
  void 0 === r2 && (r2 = false), !e2.l && e2.h.D && e2.m && l(t2, r2);
}
function N(e2, t2) {
  var r2 = e2[V];
  return (r2 ? f(r2) : e2)[t2];
}
function D(e2, t2) {
  if (t2 in e2)
    for (var r2 = Object.getPrototypeOf(e2); r2; ) {
      var n2 = Object.getOwnPropertyDescriptor(r2, t2);
      if (n2)
        return n2;
      r2 = Object.getPrototypeOf(r2);
    }
}
function E(e2) {
  e2.P || (e2.P = true, e2.l && E(e2.l));
}
function S(e2) {
  e2.o || (e2.o = s(e2.t));
}
function _(e2, t2, r2) {
  var n2 = a(t2) ? y("MapSet").F(t2, r2) : c(t2) ? y("MapSet").T(t2, r2) : e2.O ? function(e3, t3) {
    var r3 = Array.isArray(e3), n3 = { i: r3 ? 1 : 0, A: t3 ? t3.A : v(), P: false, I: false, R: {}, l: t3, t: e3, k: null, o: null, j: null, C: false }, o2 = n3, i2 = X;
    r3 && (o2 = [n3], i2 = q);
    var u2 = Proxy.revocable(o2, i2), a2 = u2.revoke, c2 = u2.proxy;
    return n3.k = c2, n3.j = a2, c2;
  }(t2, r2) : y("ES5").J(t2, r2);
  return (r2 ? r2.A : v()).p.push(n2), n2;
}
function I(i2) {
  return t(i2) || e(22, i2), function e2(t2) {
    if (!r(t2))
      return t2;
    var i3, a2 = t2[V], c2 = o(t2);
    if (a2) {
      if (!a2.P && (a2.i < 4 || !y("ES5").K(a2)))
        return a2.t;
      a2.I = true, i3 = x(t2, c2), a2.I = false;
    } else
      i3 = x(t2, c2);
    return n(i3, function(t3, r2) {
      a2 && function(e3, t4) {
        return 2 === o(e3) ? e3.get(t4) : e3[t4];
      }(a2.t, t3) === r2 || u(i3, t3, e2(r2));
    }), 3 === c2 ? new Set(i3) : i3;
  }(i2);
}
function x(e2, t2) {
  switch (t2) {
    case 2:
      return new Map(e2);
    case 3:
      return Array.from(e2);
  }
  return s(e2);
}
var R, k, F = "undefined" != typeof Symbol && "symbol" == typeof Symbol("x"), z = "undefined" != typeof Map, M = "undefined" != typeof Set, T = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect, C = F ? Symbol.for("immer-nothing") : ((R = {})["immer-nothing"] = true, R), K = F ? Symbol.for("immer-draftable") : "__$immer_draftable", V = F ? Symbol.for("immer-state") : "__$immer_state", U = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(e2) {
  return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e2;
}, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(e2) {
  return "Cannot apply patch, path doesn't resolve: " + e2;
}, 16: 'Sets cannot have "replace" patches.', 17: function(e2) {
  return "Unsupported patch operation: " + e2;
}, 18: function(e2) {
  return "The plugin for '" + e2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + e2 + "()` when initializing your application.";
}, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(e2) {
  return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + e2 + "'";
}, 22: function(e2) {
  return "'current' expects a draft, got: " + e2;
}, 23: function(e2) {
  return "'original' expects a draft, got: " + e2;
}, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" }, W = "" + Object.prototype.constructor, $ = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function(e2) {
  return Object.getOwnPropertyNames(e2).concat(Object.getOwnPropertySymbols(e2));
} : Object.getOwnPropertyNames, G = Object.getOwnPropertyDescriptors || function(e2) {
  var t2 = {};
  return $(e2).forEach(function(r2) {
    t2[r2] = Object.getOwnPropertyDescriptor(e2, r2);
  }), t2;
}, J = {}, X = { get: function(e2, t2) {
  if (t2 === V)
    return e2;
  var n2 = f(e2);
  if (!i(n2, t2))
    return function(e3, t3, r2) {
      var n3, o3 = D(t3, r2);
      return o3 ? "value" in o3 ? o3.value : null === (n3 = o3.get) || void 0 === n3 ? void 0 : n3.call(e3.k) : void 0;
    }(e2, n2, t2);
  var o2 = n2[t2];
  return e2.I || !r(o2) ? o2 : o2 === N(e2.t, t2) ? (S(e2), e2.o[t2] = _(e2.A.h, o2, e2)) : o2;
}, has: function(e2, t2) {
  return t2 in f(e2);
}, ownKeys: function(e2) {
  return Reflect.ownKeys(f(e2));
}, set: function(e2, t2, r2) {
  var n2 = D(f(e2), t2);
  if (null == n2 ? void 0 : n2.set)
    return n2.set.call(e2.k, r2), true;
  if (!e2.P) {
    var o2 = N(f(e2), t2), u2 = null == o2 ? void 0 : o2[V];
    if (u2 && u2.t === r2)
      return e2.o[t2] = r2, e2.R[t2] = false, true;
    if (function(e3, t3) {
      return e3 === t3 ? 0 !== e3 || 1 / e3 == 1 / t3 : e3 != e3 && t3 != t3;
    }(r2, o2) && (void 0 !== r2 || i(e2.t, t2)))
      return true;
    S(e2), E(e2);
  }
  return e2.o[t2] === r2 && (void 0 !== r2 || t2 in e2.o) || Number.isNaN(r2) && Number.isNaN(e2.o[t2]) || (e2.o[t2] = r2, e2.R[t2] = true), true;
}, deleteProperty: function(e2, t2) {
  return void 0 !== N(e2.t, t2) || t2 in e2.t ? (e2.R[t2] = false, S(e2), E(e2)) : delete e2.R[t2], e2.o && delete e2.o[t2], true;
}, getOwnPropertyDescriptor: function(e2, t2) {
  var r2 = f(e2), n2 = Reflect.getOwnPropertyDescriptor(r2, t2);
  return n2 ? { writable: true, configurable: 1 !== e2.i || "length" !== t2, enumerable: n2.enumerable, value: r2[t2] } : n2;
}, defineProperty: function() {
  e(11);
}, getPrototypeOf: function(e2) {
  return Object.getPrototypeOf(e2.t);
}, setPrototypeOf: function() {
  e(12);
} }, q = {};
n(X, function(e2, t2) {
  q[e2] = function() {
    return arguments[0] = arguments[0][0], t2.apply(this, arguments);
  };
}), q.deleteProperty = function(t2, r2) {
  return "production" !== process.env.NODE_ENV && isNaN(parseInt(r2)) && e(13), q.set.call(this, t2, r2, void 0);
}, q.set = function(t2, r2, n2) {
  return "production" !== process.env.NODE_ENV && "length" !== r2 && isNaN(parseInt(r2)) && e(14), X.set.call(this, t2[0], r2, n2, t2[0]);
};
var B = function() {
  function n2(t2) {
    var n3 = this;
    this.O = T, this.D = true, this.produce = function(t3, o3, i2) {
      if ("function" == typeof t3 && "function" != typeof o3) {
        var u2 = o3;
        o3 = t3;
        var a2 = n3;
        return function(e2) {
          var t4 = this;
          void 0 === e2 && (e2 = u2);
          for (var r2 = arguments.length, n4 = Array(r2 > 1 ? r2 - 1 : 0), i3 = 1; i3 < r2; i3++)
            n4[i3 - 1] = arguments[i3];
          return a2.produce(e2, function(e3) {
            var r3;
            return (r3 = o3).call.apply(r3, [t4, e3].concat(n4));
          });
        };
      }
      var c2;
      if ("function" != typeof o3 && e(6), void 0 !== i2 && "function" != typeof i2 && e(7), r(t3)) {
        var f2 = P(n3), s2 = _(n3, t3, void 0), p2 = true;
        try {
          c2 = o3(s2), p2 = false;
        } finally {
          p2 ? b(f2) : m(f2);
        }
        return "undefined" != typeof Promise && c2 instanceof Promise ? c2.then(function(e2) {
          return h(f2, i2), O(e2, f2);
        }, function(e2) {
          throw b(f2), e2;
        }) : (h(f2, i2), O(c2, f2));
      }
      if (!t3 || "object" != typeof t3) {
        if (void 0 === (c2 = o3(t3)) && (c2 = t3), c2 === C && (c2 = void 0), n3.D && l(c2, true), i2) {
          var d2 = [], v2 = [];
          y("Patches").M(t3, c2, d2, v2), i2(d2, v2);
        }
        return c2;
      }
      e(21, t3);
    }, this.produceWithPatches = function(e2, t3) {
      if ("function" == typeof e2)
        return function(t4) {
          for (var r3 = arguments.length, o4 = Array(r3 > 1 ? r3 - 1 : 0), i3 = 1; i3 < r3; i3++)
            o4[i3 - 1] = arguments[i3];
          return n3.produceWithPatches(t4, function(t5) {
            return e2.apply(void 0, [t5].concat(o4));
          });
        };
      var r2, o3, i2 = n3.produce(e2, t3, function(e3, t4) {
        r2 = e3, o3 = t4;
      });
      return "undefined" != typeof Promise && i2 instanceof Promise ? i2.then(function(e3) {
        return [e3, r2, o3];
      }) : [i2, r2, o3];
    }, "boolean" == typeof (null == t2 ? void 0 : t2.useProxies) && this.setUseProxies(t2.useProxies), "boolean" == typeof (null == t2 ? void 0 : t2.autoFreeze) && this.setAutoFreeze(t2.autoFreeze);
  }
  var o2 = n2.prototype;
  return o2.createDraft = function(n3) {
    r(n3) || e(8), t(n3) && (n3 = I(n3));
    var o3 = P(this), i2 = _(this, n3, void 0);
    return i2[V].C = true, m(o3), i2;
  }, o2.finishDraft = function(t2, r2) {
    var n3 = t2 && t2[V];
    "production" !== process.env.NODE_ENV && (n3 && n3.C || e(9), n3.I && e(10));
    var o3 = n3.A;
    return h(o3, r2), O(void 0, o3);
  }, o2.setAutoFreeze = function(e2) {
    this.D = e2;
  }, o2.setUseProxies = function(t2) {
    t2 && !T && e(20), this.O = t2;
  }, o2.applyPatches = function(e2, r2) {
    var n3;
    for (n3 = r2.length - 1; n3 >= 0; n3--) {
      var o3 = r2[n3];
      if (0 === o3.path.length && "replace" === o3.op) {
        e2 = o3.value;
        break;
      }
    }
    n3 > -1 && (r2 = r2.slice(n3 + 1));
    var i2 = y("Patches").$;
    return t(e2) ? i2(e2, r2) : this.produce(e2, function(e3) {
      return i2(e3, r2);
    });
  }, n2;
}(), H = new B(), L = H.produce;
H.produceWithPatches.bind(H), H.setAutoFreeze.bind(H), H.setUseProxies.bind(H), H.applyPatches.bind(H), H.createDraft.bind(H), H.finishDraft.bind(H);
const Q = L;
export {
  Q as p
};
