import * as u from "react";
import "../../../../../../_virtual/with-selector3.js";
var ye = /* @__PURE__ */ u.version.startsWith("19"), Te = /* @__PURE__ */ Symbol.for(
  ye ? "react.transitional.element" : "react.element"
), Ne = /* @__PURE__ */ Symbol.for("react.portal"), ve = /* @__PURE__ */ Symbol.for("react.fragment"), Se = /* @__PURE__ */ Symbol.for("react.strict_mode"), be = /* @__PURE__ */ Symbol.for("react.profiler"), X = /* @__PURE__ */ Symbol.for("react.consumer"), Z = /* @__PURE__ */ Symbol.for("react.context"), j = /* @__PURE__ */ Symbol.for("react.forward_ref"), Ee = /* @__PURE__ */ Symbol.for("react.suspense"), Pe = /* @__PURE__ */ Symbol.for(
  "react.suspense_list"
), V = /* @__PURE__ */ Symbol.for("react.memo"), he = /* @__PURE__ */ Symbol.for("react.lazy"), _e = /* @__PURE__ */ Symbol.for("react.offscreen"), xe = /* @__PURE__ */ Symbol.for(
  "react.client.reference"
), Me = j, Fe = V;
function $e(e) {
  return typeof e == "string" || typeof e == "function" || e === ve || e === be || e === Se || e === Ee || e === Pe || e === _e || typeof e == "object" && e !== null && (e.$$typeof === he || e.$$typeof === V || e.$$typeof === Z || e.$$typeof === X || e.$$typeof === j || e.$$typeof === xe || e.getModuleId !== void 0);
}
function G(e) {
  if (typeof e == "object" && e !== null) {
    const { $$typeof: t } = e;
    switch (t) {
      case Te:
        switch (e = e.type, e) {
          case ve:
          case be:
          case Se:
          case Ee:
          case Pe:
            return e;
          default:
            switch (e = e && e.$$typeof, e) {
              case Z:
              case j:
              case he:
              case V:
                return e;
              case X:
                return e;
              default:
                return t;
            }
        }
      case Ne:
        return t;
    }
  }
}
function Ae(e) {
  return ye ? G(e) === X : G(e) === Z;
}
function Ie(e) {
  return G(e) === V;
}
function Q(e) {
  typeof console < "u" && typeof console.error == "function" && console.error(e);
  try {
    throw new Error(e);
  } catch {
  }
}
function z(e, t) {
  if (e)
    (t === "mapStateToProps" || t === "mapDispatchToProps") && (Object.prototype.hasOwnProperty.call(e, "dependsOnOwnProps") || Q(
      `The selector for ${t} of connect did not specify a value for dependsOnOwnProps.`
    ));
  else throw new Error(`Unexpected value for ${t} in connect.`);
}
function Ve(e, t, r) {
  z(e, "mapStateToProps"), z(t, "mapDispatchToProps"), z(r, "mergeProps");
}
function Ye(e, t, r, s, {
  areStatesEqual: n,
  areOwnPropsEqual: o,
  areStatePropsEqual: a
}) {
  let f = !1, i, c, l, d, y;
  function m(v, b) {
    return i = v, c = b, l = e(i, c), d = t(s, c), y = r(l, d, c), f = !0, y;
  }
  function E() {
    return l = e(i, c), t.dependsOnOwnProps && (d = t(s, c)), y = r(l, d, c), y;
  }
  function T() {
    return e.dependsOnOwnProps && (l = e(i, c)), t.dependsOnOwnProps && (d = t(s, c)), y = r(l, d, c), y;
  }
  function p() {
    const v = e(i, c), b = !a(v, l);
    return l = v, b && (y = r(l, d, c)), y;
  }
  function P(v, b) {
    const w = !o(b, c), Y = !n(
      v,
      i,
      b,
      c
    );
    return i = v, c = b, w && Y ? E() : w ? T() : Y ? p() : y;
  }
  return function(b, w) {
    return f ? P(b, w) : m(b, w);
  };
}
function De(e, {
  initMapStateToProps: t,
  initMapDispatchToProps: r,
  initMergeProps: s,
  ...n
}) {
  const o = t(e, n), a = r(e, n), f = s(e, n);
  return process.env.NODE_ENV !== "production" && Ve(o, a, f), Ye(o, a, f, e, n);
}
function Ue(e, t) {
  const r = {};
  for (const s in e) {
    const n = e[s];
    typeof n == "function" && (r[s] = (...o) => t(n(...o)));
  }
  return r;
}
function Le(e) {
  if (typeof e != "object" || e === null) return !1;
  const t = Object.getPrototypeOf(e);
  if (t === null) return !0;
  let r = t;
  for (; Object.getPrototypeOf(r) !== null; )
    r = Object.getPrototypeOf(r);
  return t === r;
}
function Oe(e, t, r) {
  Le(e) || Q(
    `${r}() in ${t} must return a plain object. Instead received ${e}.`
  );
}
function H(e) {
  return function(r) {
    const s = e(r);
    function n() {
      return s;
    }
    return n.dependsOnOwnProps = !1, n;
  };
}
function ue(e) {
  return e.dependsOnOwnProps ? !!e.dependsOnOwnProps : e.length !== 1;
}
function me(e, t) {
  return function(s, { displayName: n }) {
    const o = function(f, i) {
      return o.dependsOnOwnProps ? o.mapToProps(f, i) : o.mapToProps(f, void 0);
    };
    return o.dependsOnOwnProps = !0, o.mapToProps = function(f, i) {
      o.mapToProps = e, o.dependsOnOwnProps = ue(e);
      let c = o(f, i);
      return typeof c == "function" && (o.mapToProps = c, o.dependsOnOwnProps = ue(c), c = o(f, i)), process.env.NODE_ENV !== "production" && Oe(c, n, t), c;
    }, o;
  };
}
function ee(e, t) {
  return (r, s) => {
    throw new Error(
      `Invalid value of type ${typeof e} for ${t} argument when connecting component ${s.wrappedComponentName}.`
    );
  };
}
function ke(e) {
  return e && typeof e == "object" ? H(
    (t) => (
      // @ts-ignore
      Ue(e, t)
    )
  ) : e ? typeof e == "function" ? (
    // @ts-ignore
    me(e, "mapDispatchToProps")
  ) : ee(e, "mapDispatchToProps") : H((t) => ({
    dispatch: t
  }));
}
function We(e) {
  return e ? typeof e == "function" ? (
    // @ts-ignore
    me(e, "mapStateToProps")
  ) : ee(e, "mapStateToProps") : H(() => ({}));
}
function Be(e, t, r) {
  return { ...r, ...e, ...t };
}
function qe(e) {
  return function(r, { displayName: s, areMergedPropsEqual: n }) {
    let o = !1, a;
    return function(i, c, l) {
      const d = e(i, c, l);
      return o ? n(d, a) || (a = d) : (o = !0, a = d, process.env.NODE_ENV !== "production" && Oe(a, s, "mergeProps")), a;
    };
  };
}
function ze(e) {
  return e ? typeof e == "function" ? qe(e) : ee(e, "mergeProps") : () => Be;
}
function Ke(e) {
  e();
}
function Ge() {
  let e = null, t = null;
  return {
    clear() {
      e = null, t = null;
    },
    notify() {
      Ke(() => {
        let r = e;
        for (; r; )
          r.callback(), r = r.next;
      });
    },
    get() {
      const r = [];
      let s = e;
      for (; s; )
        r.push(s), s = s.next;
      return r;
    },
    subscribe(r) {
      let s = !0;
      const n = t = {
        callback: r,
        next: null,
        prev: t
      };
      return n.prev ? n.prev.next = n : e = n, function() {
        !s || e === null || (s = !1, n.next ? n.next.prev = n.prev : t = n.prev, n.prev ? n.prev.next = n.next : e = n.next);
      };
    }
  };
}
var ie = {
  notify() {
  },
  get: () => []
};
function we(e, t) {
  let r, s = ie, n = 0, o = !1;
  function a(T) {
    l();
    const p = s.subscribe(T);
    let P = !1;
    return () => {
      P || (P = !0, p(), d());
    };
  }
  function f() {
    s.notify();
  }
  function i() {
    E.onStateChange && E.onStateChange();
  }
  function c() {
    return o;
  }
  function l() {
    n++, r || (r = t ? t.addNestedSub(i) : e.subscribe(i), s = Ge());
  }
  function d() {
    n--, r && n === 0 && (r(), r = void 0, s.clear(), s = ie);
  }
  function y() {
    o || (o = !0, l());
  }
  function m() {
    o && (o = !1, d());
  }
  const E = {
    addNestedSub: a,
    notifyNestedSubs: f,
    handleChangeWrapper: i,
    isSubscribed: c,
    trySubscribe: y,
    tryUnsubscribe: m,
    getListeners: () => s
  };
  return E;
}
var He = () => typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", Je = /* @__PURE__ */ He(), Xe = () => typeof navigator < "u" && navigator.product === "ReactNative", Ze = /* @__PURE__ */ Xe(), je = () => Je || Ze ? u.useLayoutEffect : u.useEffect, I = /* @__PURE__ */ je();
function ae(e, t) {
  return e === t ? e !== 0 || t !== 0 || 1 / e === 1 / t : e !== e && t !== t;
}
function K(e, t) {
  if (ae(e, t)) return !0;
  if (typeof e != "object" || e === null || typeof t != "object" || t === null)
    return !1;
  const r = Object.keys(e), s = Object.keys(t);
  if (r.length !== s.length) return !1;
  for (let n = 0; n < r.length; n++)
    if (!Object.prototype.hasOwnProperty.call(t, r[n]) || !ae(e[r[n]], t[r[n]]))
      return !1;
  return !0;
}
var Qe = {
  childContextTypes: !0,
  contextType: !0,
  contextTypes: !0,
  defaultProps: !0,
  displayName: !0,
  getDefaultProps: !0,
  getDerivedStateFromError: !0,
  getDerivedStateFromProps: !0,
  mixins: !0,
  propTypes: !0,
  type: !0
}, et = {
  name: !0,
  length: !0,
  prototype: !0,
  caller: !0,
  callee: !0,
  arguments: !0,
  arity: !0
}, tt = {
  $$typeof: !0,
  render: !0,
  defaultProps: !0,
  displayName: !0,
  propTypes: !0
}, Ce = {
  $$typeof: !0,
  compare: !0,
  defaultProps: !0,
  displayName: !0,
  propTypes: !0,
  type: !0
}, rt = {
  [Me]: tt,
  [Fe]: Ce
};
function fe(e) {
  return Ie(e) ? Ce : rt[e.$$typeof] || Qe;
}
var nt = Object.defineProperty, ot = Object.getOwnPropertyNames, le = Object.getOwnPropertySymbols, st = Object.getOwnPropertyDescriptor, ct = Object.getPrototypeOf, de = Object.prototype;
function J(e, t) {
  if (typeof t != "string") {
    if (de) {
      const o = ct(t);
      o && o !== de && J(e, o);
    }
    let r = ot(t);
    le && (r = r.concat(le(t)));
    const s = fe(e), n = fe(t);
    for (let o = 0; o < r.length; ++o) {
      const a = r[o];
      if (!et[a] && !(n && n[a]) && !(s && s[a])) {
        const f = st(t, a);
        try {
          nt(e, a, f);
        } catch {
        }
      }
    }
  }
  return e;
}
var ut = /* @__PURE__ */ Symbol.for("react-redux-context"), it = typeof globalThis < "u" ? globalThis : (
  /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
  {}
);
function at() {
  if (!u.createContext) return {};
  const e = it[ut] ??= /* @__PURE__ */ new Map();
  let t = e.get(u.createContext);
  return t || (t = u.createContext(
    null
  ), process.env.NODE_ENV !== "production" && (t.displayName = "ReactRedux"), e.set(u.createContext, t)), t;
}
var ge = /* @__PURE__ */ at(), ft = [null, null], lt = (e) => {
  try {
    return JSON.stringify(e);
  } catch {
    return String(e);
  }
};
function dt(e, t, r) {
  I(() => e(...t), r);
}
function pt(e, t, r, s, n, o) {
  e.current = s, r.current = !1, n.current && (n.current = null, o());
}
function yt(e, t, r, s, n, o, a, f, i, c, l) {
  if (!e) return () => {
  };
  let d = !1, y = null;
  const m = () => {
    if (d || !f.current)
      return;
    const T = t.getState();
    let p, P;
    try {
      p = s(
        T,
        n.current
      );
    } catch (v) {
      P = v, y = v;
    }
    P || (y = null), p === o.current ? a.current || c() : (o.current = p, i.current = p, a.current = !0, l());
  };
  return r.onStateChange = m, r.trySubscribe(), m(), () => {
    if (d = !0, r.tryUnsubscribe(), r.onStateChange = null, y)
      throw y;
  };
}
function vt(e, t) {
  return e === t;
}
var pe = !1;
function St(e, t, r, {
  // The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
  // @ts-ignore
  pure: s,
  areStatesEqual: n = vt,
  areOwnPropsEqual: o = K,
  areStatePropsEqual: a = K,
  areMergedPropsEqual: f = K,
  // use React's forwardRef to expose a ref of the wrapped component
  forwardRef: i = !1,
  // the context consumer to use
  context: c = ge
} = {}) {
  process.env.NODE_ENV !== "production" && s !== void 0 && !pe && (pe = !0, Q(
    'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
  ));
  const l = c, d = We(e), y = ke(t), m = ze(r), E = !!e;
  return (p) => {
    if (process.env.NODE_ENV !== "production" && !/* @__PURE__ */ $e(p))
      throw new Error(
        `You must pass a component to the function returned by connect. Instead received ${lt(
          p
        )}`
      );
    const P = p.displayName || p.name || "Component", v = `Connect(${P})`, b = {
      shouldHandleStateChanges: E,
      displayName: v,
      wrappedComponentName: P,
      WrappedComponent: p,
      // @ts-ignore
      initMapStateToProps: d,
      initMapDispatchToProps: y,
      initMergeProps: m,
      areStatesEqual: n,
      areStatePropsEqual: a,
      areOwnPropsEqual: o,
      areMergedPropsEqual: f
    };
    function w(h) {
      const [C, D, g] = u.useMemo(() => {
        const { reactReduxForwardedRef: S, ..._ } = h;
        return [h.context, S, _];
      }, [h]), x = u.useMemo(() => {
        let S = l;
        if (C?.Consumer && process.env.NODE_ENV !== "production") {
          if (!/* @__PURE__ */ Ae(
            // @ts-ignore
            /* @__PURE__ */ u.createElement(C.Consumer, null)
          ))
            throw new Error(
              "You must pass a valid React context consumer as `props.context`"
            );
          S = C;
        }
        return S;
      }, [C, l]), O = u.useContext(x), N = !!h.store && !!h.store.getState && !!h.store.dispatch, te = !!O && !!O.store;
      if (process.env.NODE_ENV !== "production" && !N && !te)
        throw new Error(
          `Could not find "store" in the context of "${v}". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to ${v} in connect options.`
        );
      const R = N ? h.store : O.store, re = te ? O.getServerState : R.getState, U = u.useMemo(() => De(R.dispatch, b), [R]), [M, ne] = u.useMemo(() => {
        if (!E) return ft;
        const S = we(
          R,
          N ? void 0 : O.subscription
        ), _ = S.notifyNestedSubs.bind(S);
        return [S, _];
      }, [R, N, O]), oe = u.useMemo(() => N ? O : {
        ...O,
        subscription: M
      }, [N, O, M]), L = u.useRef(void 0), k = u.useRef(g), F = u.useRef(void 0), se = u.useRef(!1), W = u.useRef(!1), B = u.useRef(
        void 0
      );
      I(() => (W.current = !0, () => {
        W.current = !1;
      }), []);
      const ce = u.useMemo(() => () => F.current && g === k.current ? F.current : U(R.getState(), g), [R, g]), Re = u.useMemo(() => (_) => M ? yt(
        E,
        R,
        M,
        // @ts-ignore
        U,
        k,
        L,
        se,
        W,
        F,
        ne,
        _
      ) : () => {
      }, [M]);
      dt(pt, [
        k,
        L,
        se,
        g,
        F,
        ne
      ]);
      let A;
      try {
        A = u.useSyncExternalStore(
          // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
          Re,
          // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
          // TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
          ce,
          re ? () => U(re(), g) : ce
        );
      } catch (S) {
        throw B.current && (S.message += `
The error may be correlated with this previous error:
${B.current.stack}

`), S;
      }
      I(() => {
        B.current = void 0, F.current = void 0, L.current = A;
      });
      const q = u.useMemo(() => (
        // @ts-ignore
        /* @__PURE__ */ u.createElement(
          p,
          {
            ...A,
            ref: D
          }
        )
      ), [D, p, A]);
      return u.useMemo(() => E ? /* @__PURE__ */ u.createElement(x.Provider, { value: oe }, q) : q, [x, q, oe]);
    }
    const $ = u.memo(w);
    if ($.WrappedComponent = p, $.displayName = w.displayName = v, i) {
      const C = u.forwardRef(
        function(g, x) {
          return /* @__PURE__ */ u.createElement($, { ...g, reactReduxForwardedRef: x });
        }
      );
      return C.displayName = v, C.WrappedComponent = p, /* @__PURE__ */ J(C, p);
    }
    return /* @__PURE__ */ J($, p);
  };
}
var ht = St;
function bt(e) {
  const { children: t, context: r, serverState: s, store: n } = e, o = u.useMemo(() => {
    const i = we(n), c = {
      store: n,
      subscription: i,
      getServerState: s ? () => s : void 0
    };
    if (process.env.NODE_ENV === "production")
      return c;
    {
      const { identityFunctionCheck: l = "once", stabilityCheck: d = "once" } = e;
      return /* @__PURE__ */ Object.assign(c, {
        stabilityCheck: d,
        identityFunctionCheck: l
      });
    }
  }, [n, s]), a = u.useMemo(() => n.getState(), [n]);
  I(() => {
    const { subscription: i } = o;
    return i.onStateChange = i.notifyNestedSubs, i.trySubscribe(), a !== n.getState() && i.notifyNestedSubs(), () => {
      i.tryUnsubscribe(), i.onStateChange = void 0;
    };
  }, [o, a]);
  const f = r || ge;
  return /* @__PURE__ */ u.createElement(f.Provider, { value: o }, t);
}
var Ot = bt;
export {
  Ot as Provider,
  ge as ReactReduxContext,
  ht as connect,
  K as shallowEqual
};
//# sourceMappingURL=react-redux.js.map
