var IS = Object.defineProperty;
var FS = (r, t, i) => t in r ? IS(r, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[t] = i;
var Rt = (r, t, i) => FS(r, typeof t != "symbol" ? t + "" : t, i);
var Uh = { exports: {} }, re = {};
/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var p0;
function HS() {
  if (p0) return re;
  p0 = 1;
  var r = Symbol.for("react.transitional.element"), t = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), c = Symbol.for("react.consumer"), h = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), p = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), _ = Symbol.for("react.activity"), x = Symbol.iterator;
  function S(P) {
    return P === null || typeof P != "object" ? null : (P = x && P[x] || P["@@iterator"], typeof P == "function" ? P : null);
  }
  var E = {
    isMounted: function() {
      return !1;
    },
    enqueueForceUpdate: function() {
    },
    enqueueReplaceState: function() {
    },
    enqueueSetState: function() {
    }
  }, b = Object.assign, M = {};
  function v(P, st, xt) {
    this.props = P, this.context = st, this.refs = M, this.updater = xt || E;
  }
  v.prototype.isReactComponent = {}, v.prototype.setState = function(P, st) {
    if (typeof P != "object" && typeof P != "function" && P != null)
      throw Error(
        "takes an object of state variables to update or a function which returns an object of state variables."
      );
    this.updater.enqueueSetState(this, P, st, "setState");
  }, v.prototype.forceUpdate = function(P) {
    this.updater.enqueueForceUpdate(this, P, "forceUpdate");
  };
  function B() {
  }
  B.prototype = v.prototype;
  function U(P, st, xt) {
    this.props = P, this.context = st, this.refs = M, this.updater = xt || E;
  }
  var w = U.prototype = new B();
  w.constructor = U, b(w, v.prototype), w.isPureReactComponent = !0;
  var F = Array.isArray;
  function L() {
  }
  var O = { H: null, A: null, T: null, S: null }, G = Object.prototype.hasOwnProperty;
  function C(P, st, xt) {
    var j = xt.ref;
    return {
      $$typeof: r,
      type: P,
      key: st,
      ref: j !== void 0 ? j : null,
      props: xt
    };
  }
  function T(P, st) {
    return C(P.type, st, P.props);
  }
  function I(P) {
    return typeof P == "object" && P !== null && P.$$typeof === r;
  }
  function J(P) {
    var st = { "=": "=0", ":": "=2" };
    return "$" + P.replace(/[=:]/g, function(xt) {
      return st[xt];
    });
  }
  var $ = /\/+/g;
  function lt(P, st) {
    return typeof P == "object" && P !== null && P.key != null ? J("" + P.key) : st.toString(36);
  }
  function pt(P) {
    switch (P.status) {
      case "fulfilled":
        return P.value;
      case "rejected":
        throw P.reason;
      default:
        switch (typeof P.status == "string" ? P.then(L, L) : (P.status = "pending", P.then(
          function(st) {
            P.status === "pending" && (P.status = "fulfilled", P.value = st);
          },
          function(st) {
            P.status === "pending" && (P.status = "rejected", P.reason = st);
          }
        )), P.status) {
          case "fulfilled":
            return P.value;
          case "rejected":
            throw P.reason;
        }
    }
    throw P;
  }
  function z(P, st, xt, j, ht) {
    var Et = typeof P;
    (Et === "undefined" || Et === "boolean") && (P = null);
    var vt = !1;
    if (P === null) vt = !0;
    else
      switch (Et) {
        case "bigint":
        case "string":
        case "number":
          vt = !0;
          break;
        case "object":
          switch (P.$$typeof) {
            case r:
            case t:
              vt = !0;
              break;
            case g:
              return vt = P._init, z(
                vt(P._payload),
                st,
                xt,
                j,
                ht
              );
          }
      }
    if (vt)
      return ht = ht(P), vt = j === "" ? "." + lt(P, 0) : j, F(ht) ? (xt = "", vt != null && (xt = vt.replace($, "$&/") + "/"), z(ht, st, xt, "", function(ae) {
        return ae;
      })) : ht != null && (I(ht) && (ht = T(
        ht,
        xt + (ht.key == null || P && P.key === ht.key ? "" : ("" + ht.key).replace(
          $,
          "$&/"
        ) + "/") + vt
      )), st.push(ht)), 1;
    vt = 0;
    var Ht = j === "" ? "." : j + ":";
    if (F(P))
      for (var Lt = 0; Lt < P.length; Lt++)
        j = P[Lt], Et = Ht + lt(j, Lt), vt += z(
          j,
          st,
          xt,
          Et,
          ht
        );
    else if (Lt = S(P), typeof Lt == "function")
      for (P = Lt.call(P), Lt = 0; !(j = P.next()).done; )
        j = j.value, Et = Ht + lt(j, Lt++), vt += z(
          j,
          st,
          xt,
          Et,
          ht
        );
    else if (Et === "object") {
      if (typeof P.then == "function")
        return z(
          pt(P),
          st,
          xt,
          j,
          ht
        );
      throw st = String(P), Error(
        "Objects are not valid as a React child (found: " + (st === "[object Object]" ? "object with keys {" + Object.keys(P).join(", ") + "}" : st) + "). If you meant to render a collection of children, use an array instead."
      );
    }
    return vt;
  }
  function tt(P, st, xt) {
    if (P == null) return P;
    var j = [], ht = 0;
    return z(P, j, "", "", function(Et) {
      return st.call(xt, Et, ht++);
    }), j;
  }
  function K(P) {
    if (P._status === -1) {
      var st = P._result;
      st = st(), st.then(
        function(xt) {
          (P._status === 0 || P._status === -1) && (P._status = 1, P._result = xt);
        },
        function(xt) {
          (P._status === 0 || P._status === -1) && (P._status = 2, P._result = xt);
        }
      ), P._status === -1 && (P._status = 0, P._result = st);
    }
    if (P._status === 1) return P._result.default;
    throw P._result;
  }
  var yt = typeof reportError == "function" ? reportError : function(P) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var st = new window.ErrorEvent("error", {
        bubbles: !0,
        cancelable: !0,
        message: typeof P == "object" && P !== null && typeof P.message == "string" ? String(P.message) : String(P),
        error: P
      });
      if (!window.dispatchEvent(st)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", P);
      return;
    }
    console.error(P);
  }, Mt = {
    map: tt,
    forEach: function(P, st, xt) {
      tt(
        P,
        function() {
          st.apply(this, arguments);
        },
        xt
      );
    },
    count: function(P) {
      var st = 0;
      return tt(P, function() {
        st++;
      }), st;
    },
    toArray: function(P) {
      return tt(P, function(st) {
        return st;
      }) || [];
    },
    only: function(P) {
      if (!I(P))
        throw Error(
          "React.Children.only expected to receive a single React element child."
        );
      return P;
    }
  };
  return re.Activity = _, re.Children = Mt, re.Component = v, re.Fragment = i, re.Profiler = l, re.PureComponent = U, re.StrictMode = s, re.Suspense = m, re.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = O, re.__COMPILER_RUNTIME = {
    __proto__: null,
    c: function(P) {
      return O.H.useMemoCache(P);
    }
  }, re.cache = function(P) {
    return function() {
      return P.apply(null, arguments);
    };
  }, re.cacheSignal = function() {
    return null;
  }, re.cloneElement = function(P, st, xt) {
    if (P == null)
      throw Error(
        "The argument must be a React element, but you passed " + P + "."
      );
    var j = b({}, P.props), ht = P.key;
    if (st != null)
      for (Et in st.key !== void 0 && (ht = "" + st.key), st)
        !G.call(st, Et) || Et === "key" || Et === "__self" || Et === "__source" || Et === "ref" && st.ref === void 0 || (j[Et] = st[Et]);
    var Et = arguments.length - 2;
    if (Et === 1) j.children = xt;
    else if (1 < Et) {
      for (var vt = Array(Et), Ht = 0; Ht < Et; Ht++)
        vt[Ht] = arguments[Ht + 2];
      j.children = vt;
    }
    return C(P.type, ht, j);
  }, re.createContext = function(P) {
    return P = {
      $$typeof: h,
      _currentValue: P,
      _currentValue2: P,
      _threadCount: 0,
      Provider: null,
      Consumer: null
    }, P.Provider = P, P.Consumer = {
      $$typeof: c,
      _context: P
    }, P;
  }, re.createElement = function(P, st, xt) {
    var j, ht = {}, Et = null;
    if (st != null)
      for (j in st.key !== void 0 && (Et = "" + st.key), st)
        G.call(st, j) && j !== "key" && j !== "__self" && j !== "__source" && (ht[j] = st[j]);
    var vt = arguments.length - 2;
    if (vt === 1) ht.children = xt;
    else if (1 < vt) {
      for (var Ht = Array(vt), Lt = 0; Lt < vt; Lt++)
        Ht[Lt] = arguments[Lt + 2];
      ht.children = Ht;
    }
    if (P && P.defaultProps)
      for (j in vt = P.defaultProps, vt)
        ht[j] === void 0 && (ht[j] = vt[j]);
    return C(P, Et, ht);
  }, re.createRef = function() {
    return { current: null };
  }, re.forwardRef = function(P) {
    return { $$typeof: d, render: P };
  }, re.isValidElement = I, re.lazy = function(P) {
    return {
      $$typeof: g,
      _payload: { _status: -1, _result: P },
      _init: K
    };
  }, re.memo = function(P, st) {
    return {
      $$typeof: p,
      type: P,
      compare: st === void 0 ? null : st
    };
  }, re.startTransition = function(P) {
    var st = O.T, xt = {};
    O.T = xt;
    try {
      var j = P(), ht = O.S;
      ht !== null && ht(xt, j), typeof j == "object" && j !== null && typeof j.then == "function" && j.then(L, yt);
    } catch (Et) {
      yt(Et);
    } finally {
      st !== null && xt.types !== null && (st.types = xt.types), O.T = st;
    }
  }, re.unstable_useCacheRefresh = function() {
    return O.H.useCacheRefresh();
  }, re.use = function(P) {
    return O.H.use(P);
  }, re.useActionState = function(P, st, xt) {
    return O.H.useActionState(P, st, xt);
  }, re.useCallback = function(P, st) {
    return O.H.useCallback(P, st);
  }, re.useContext = function(P) {
    return O.H.useContext(P);
  }, re.useDebugValue = function() {
  }, re.useDeferredValue = function(P, st) {
    return O.H.useDeferredValue(P, st);
  }, re.useEffect = function(P, st) {
    return O.H.useEffect(P, st);
  }, re.useEffectEvent = function(P) {
    return O.H.useEffectEvent(P);
  }, re.useId = function() {
    return O.H.useId();
  }, re.useImperativeHandle = function(P, st, xt) {
    return O.H.useImperativeHandle(P, st, xt);
  }, re.useInsertionEffect = function(P, st) {
    return O.H.useInsertionEffect(P, st);
  }, re.useLayoutEffect = function(P, st) {
    return O.H.useLayoutEffect(P, st);
  }, re.useMemo = function(P, st) {
    return O.H.useMemo(P, st);
  }, re.useOptimistic = function(P, st) {
    return O.H.useOptimistic(P, st);
  }, re.useReducer = function(P, st, xt) {
    return O.H.useReducer(P, st, xt);
  }, re.useRef = function(P) {
    return O.H.useRef(P);
  }, re.useState = function(P) {
    return O.H.useState(P);
  }, re.useSyncExternalStore = function(P, st, xt) {
    return O.H.useSyncExternalStore(
      P,
      st,
      xt
    );
  }, re.useTransition = function() {
    return O.H.useTransition();
  }, re.version = "19.2.4", re;
}
var m0;
function gp() {
  return m0 || (m0 = 1, Uh.exports = HS()), Uh.exports;
}
var qt = gp(), Lh = { exports: {} }, Ko = {}, Nh = { exports: {} }, Oh = {};
/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var g0;
function GS() {
  return g0 || (g0 = 1, (function(r) {
    function t(z, tt) {
      var K = z.length;
      z.push(tt);
      t: for (; 0 < K; ) {
        var yt = K - 1 >>> 1, Mt = z[yt];
        if (0 < l(Mt, tt))
          z[yt] = tt, z[K] = Mt, K = yt;
        else break t;
      }
    }
    function i(z) {
      return z.length === 0 ? null : z[0];
    }
    function s(z) {
      if (z.length === 0) return null;
      var tt = z[0], K = z.pop();
      if (K !== tt) {
        z[0] = K;
        t: for (var yt = 0, Mt = z.length, P = Mt >>> 1; yt < P; ) {
          var st = 2 * (yt + 1) - 1, xt = z[st], j = st + 1, ht = z[j];
          if (0 > l(xt, K))
            j < Mt && 0 > l(ht, xt) ? (z[yt] = ht, z[j] = K, yt = j) : (z[yt] = xt, z[st] = K, yt = st);
          else if (j < Mt && 0 > l(ht, K))
            z[yt] = ht, z[j] = K, yt = j;
          else break t;
        }
      }
      return tt;
    }
    function l(z, tt) {
      var K = z.sortIndex - tt.sortIndex;
      return K !== 0 ? K : z.id - tt.id;
    }
    if (r.unstable_now = void 0, typeof performance == "object" && typeof performance.now == "function") {
      var c = performance;
      r.unstable_now = function() {
        return c.now();
      };
    } else {
      var h = Date, d = h.now();
      r.unstable_now = function() {
        return h.now() - d;
      };
    }
    var m = [], p = [], g = 1, _ = null, x = 3, S = !1, E = !1, b = !1, M = !1, v = typeof setTimeout == "function" ? setTimeout : null, B = typeof clearTimeout == "function" ? clearTimeout : null, U = typeof setImmediate < "u" ? setImmediate : null;
    function w(z) {
      for (var tt = i(p); tt !== null; ) {
        if (tt.callback === null) s(p);
        else if (tt.startTime <= z)
          s(p), tt.sortIndex = tt.expirationTime, t(m, tt);
        else break;
        tt = i(p);
      }
    }
    function F(z) {
      if (b = !1, w(z), !E)
        if (i(m) !== null)
          E = !0, L || (L = !0, J());
        else {
          var tt = i(p);
          tt !== null && pt(F, tt.startTime - z);
        }
    }
    var L = !1, O = -1, G = 5, C = -1;
    function T() {
      return M ? !0 : !(r.unstable_now() - C < G);
    }
    function I() {
      if (M = !1, L) {
        var z = r.unstable_now();
        C = z;
        var tt = !0;
        try {
          t: {
            E = !1, b && (b = !1, B(O), O = -1), S = !0;
            var K = x;
            try {
              e: {
                for (w(z), _ = i(m); _ !== null && !(_.expirationTime > z && T()); ) {
                  var yt = _.callback;
                  if (typeof yt == "function") {
                    _.callback = null, x = _.priorityLevel;
                    var Mt = yt(
                      _.expirationTime <= z
                    );
                    if (z = r.unstable_now(), typeof Mt == "function") {
                      _.callback = Mt, w(z), tt = !0;
                      break e;
                    }
                    _ === i(m) && s(m), w(z);
                  } else s(m);
                  _ = i(m);
                }
                if (_ !== null) tt = !0;
                else {
                  var P = i(p);
                  P !== null && pt(
                    F,
                    P.startTime - z
                  ), tt = !1;
                }
              }
              break t;
            } finally {
              _ = null, x = K, S = !1;
            }
            tt = void 0;
          }
        } finally {
          tt ? J() : L = !1;
        }
      }
    }
    var J;
    if (typeof U == "function")
      J = function() {
        U(I);
      };
    else if (typeof MessageChannel < "u") {
      var $ = new MessageChannel(), lt = $.port2;
      $.port1.onmessage = I, J = function() {
        lt.postMessage(null);
      };
    } else
      J = function() {
        v(I, 0);
      };
    function pt(z, tt) {
      O = v(function() {
        z(r.unstable_now());
      }, tt);
    }
    r.unstable_IdlePriority = 5, r.unstable_ImmediatePriority = 1, r.unstable_LowPriority = 4, r.unstable_NormalPriority = 3, r.unstable_Profiling = null, r.unstable_UserBlockingPriority = 2, r.unstable_cancelCallback = function(z) {
      z.callback = null;
    }, r.unstable_forceFrameRate = function(z) {
      0 > z || 125 < z ? console.error(
        "forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"
      ) : G = 0 < z ? Math.floor(1e3 / z) : 5;
    }, r.unstable_getCurrentPriorityLevel = function() {
      return x;
    }, r.unstable_next = function(z) {
      switch (x) {
        case 1:
        case 2:
        case 3:
          var tt = 3;
          break;
        default:
          tt = x;
      }
      var K = x;
      x = tt;
      try {
        return z();
      } finally {
        x = K;
      }
    }, r.unstable_requestPaint = function() {
      M = !0;
    }, r.unstable_runWithPriority = function(z, tt) {
      switch (z) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          break;
        default:
          z = 3;
      }
      var K = x;
      x = z;
      try {
        return tt();
      } finally {
        x = K;
      }
    }, r.unstable_scheduleCallback = function(z, tt, K) {
      var yt = r.unstable_now();
      switch (typeof K == "object" && K !== null ? (K = K.delay, K = typeof K == "number" && 0 < K ? yt + K : yt) : K = yt, z) {
        case 1:
          var Mt = -1;
          break;
        case 2:
          Mt = 250;
          break;
        case 5:
          Mt = 1073741823;
          break;
        case 4:
          Mt = 1e4;
          break;
        default:
          Mt = 5e3;
      }
      return Mt = K + Mt, z = {
        id: g++,
        callback: tt,
        priorityLevel: z,
        startTime: K,
        expirationTime: Mt,
        sortIndex: -1
      }, K > yt ? (z.sortIndex = K, t(p, z), i(m) === null && z === i(p) && (b ? (B(O), O = -1) : b = !0, pt(F, K - yt))) : (z.sortIndex = Mt, t(m, z), E || S || (E = !0, L || (L = !0, J()))), z;
    }, r.unstable_shouldYield = T, r.unstable_wrapCallback = function(z) {
      var tt = x;
      return function() {
        var K = x;
        x = tt;
        try {
          return z.apply(this, arguments);
        } finally {
          x = K;
        }
      };
    };
  })(Oh)), Oh;
}
var _0;
function VS() {
  return _0 || (_0 = 1, Nh.exports = GS()), Nh.exports;
}
var Ph = { exports: {} }, Nn = {};
/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var v0;
function kS() {
  if (v0) return Nn;
  v0 = 1;
  var r = gp();
  function t(m) {
    var p = "https://react.dev/errors/" + m;
    if (1 < arguments.length) {
      p += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var g = 2; g < arguments.length; g++)
        p += "&args[]=" + encodeURIComponent(arguments[g]);
    }
    return "Minified React error #" + m + "; visit " + p + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function i() {
  }
  var s = {
    d: {
      f: i,
      r: function() {
        throw Error(t(522));
      },
      D: i,
      C: i,
      L: i,
      m: i,
      X: i,
      S: i,
      M: i
    },
    p: 0,
    findDOMNode: null
  }, l = Symbol.for("react.portal");
  function c(m, p, g) {
    var _ = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
    return {
      $$typeof: l,
      key: _ == null ? null : "" + _,
      children: m,
      containerInfo: p,
      implementation: g
    };
  }
  var h = r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
  function d(m, p) {
    if (m === "font") return "";
    if (typeof p == "string")
      return p === "use-credentials" ? p : "";
  }
  return Nn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = s, Nn.createPortal = function(m, p) {
    var g = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
    if (!p || p.nodeType !== 1 && p.nodeType !== 9 && p.nodeType !== 11)
      throw Error(t(299));
    return c(m, p, null, g);
  }, Nn.flushSync = function(m) {
    var p = h.T, g = s.p;
    try {
      if (h.T = null, s.p = 2, m) return m();
    } finally {
      h.T = p, s.p = g, s.d.f();
    }
  }, Nn.preconnect = function(m, p) {
    typeof m == "string" && (p ? (p = p.crossOrigin, p = typeof p == "string" ? p === "use-credentials" ? p : "" : void 0) : p = null, s.d.C(m, p));
  }, Nn.prefetchDNS = function(m) {
    typeof m == "string" && s.d.D(m);
  }, Nn.preinit = function(m, p) {
    if (typeof m == "string" && p && typeof p.as == "string") {
      var g = p.as, _ = d(g, p.crossOrigin), x = typeof p.integrity == "string" ? p.integrity : void 0, S = typeof p.fetchPriority == "string" ? p.fetchPriority : void 0;
      g === "style" ? s.d.S(
        m,
        typeof p.precedence == "string" ? p.precedence : void 0,
        {
          crossOrigin: _,
          integrity: x,
          fetchPriority: S
        }
      ) : g === "script" && s.d.X(m, {
        crossOrigin: _,
        integrity: x,
        fetchPriority: S,
        nonce: typeof p.nonce == "string" ? p.nonce : void 0
      });
    }
  }, Nn.preinitModule = function(m, p) {
    if (typeof m == "string")
      if (typeof p == "object" && p !== null) {
        if (p.as == null || p.as === "script") {
          var g = d(
            p.as,
            p.crossOrigin
          );
          s.d.M(m, {
            crossOrigin: g,
            integrity: typeof p.integrity == "string" ? p.integrity : void 0,
            nonce: typeof p.nonce == "string" ? p.nonce : void 0
          });
        }
      } else p == null && s.d.M(m);
  }, Nn.preload = function(m, p) {
    if (typeof m == "string" && typeof p == "object" && p !== null && typeof p.as == "string") {
      var g = p.as, _ = d(g, p.crossOrigin);
      s.d.L(m, g, {
        crossOrigin: _,
        integrity: typeof p.integrity == "string" ? p.integrity : void 0,
        nonce: typeof p.nonce == "string" ? p.nonce : void 0,
        type: typeof p.type == "string" ? p.type : void 0,
        fetchPriority: typeof p.fetchPriority == "string" ? p.fetchPriority : void 0,
        referrerPolicy: typeof p.referrerPolicy == "string" ? p.referrerPolicy : void 0,
        imageSrcSet: typeof p.imageSrcSet == "string" ? p.imageSrcSet : void 0,
        imageSizes: typeof p.imageSizes == "string" ? p.imageSizes : void 0,
        media: typeof p.media == "string" ? p.media : void 0
      });
    }
  }, Nn.preloadModule = function(m, p) {
    if (typeof m == "string")
      if (p) {
        var g = d(p.as, p.crossOrigin);
        s.d.m(m, {
          as: typeof p.as == "string" && p.as !== "script" ? p.as : void 0,
          crossOrigin: g,
          integrity: typeof p.integrity == "string" ? p.integrity : void 0
        });
      } else s.d.m(m);
  }, Nn.requestFormReset = function(m) {
    s.d.r(m);
  }, Nn.unstable_batchedUpdates = function(m, p) {
    return m(p);
  }, Nn.useFormState = function(m, p, g) {
    return h.H.useFormState(m, p, g);
  }, Nn.useFormStatus = function() {
    return h.H.useHostTransitionStatus();
  }, Nn.version = "19.2.4", Nn;
}
var x0;
function XS() {
  if (x0) return Ph.exports;
  x0 = 1;
  function r() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r);
      } catch (t) {
        console.error(t);
      }
  }
  return r(), Ph.exports = kS(), Ph.exports;
}
/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var y0;
function WS() {
  if (y0) return Ko;
  y0 = 1;
  var r = VS(), t = gp(), i = XS();
  function s(e) {
    var n = "https://react.dev/errors/" + e;
    if (1 < arguments.length) {
      n += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var a = 2; a < arguments.length; a++)
        n += "&args[]=" + encodeURIComponent(arguments[a]);
    }
    return "Minified React error #" + e + "; visit " + n + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function l(e) {
    return !(!e || e.nodeType !== 1 && e.nodeType !== 9 && e.nodeType !== 11);
  }
  function c(e) {
    var n = e, a = e;
    if (e.alternate) for (; n.return; ) n = n.return;
    else {
      e = n;
      do
        n = e, (n.flags & 4098) !== 0 && (a = n.return), e = n.return;
      while (e);
    }
    return n.tag === 3 ? a : null;
  }
  function h(e) {
    if (e.tag === 13) {
      var n = e.memoizedState;
      if (n === null && (e = e.alternate, e !== null && (n = e.memoizedState)), n !== null) return n.dehydrated;
    }
    return null;
  }
  function d(e) {
    if (e.tag === 31) {
      var n = e.memoizedState;
      if (n === null && (e = e.alternate, e !== null && (n = e.memoizedState)), n !== null) return n.dehydrated;
    }
    return null;
  }
  function m(e) {
    if (c(e) !== e)
      throw Error(s(188));
  }
  function p(e) {
    var n = e.alternate;
    if (!n) {
      if (n = c(e), n === null) throw Error(s(188));
      return n !== e ? null : e;
    }
    for (var a = e, o = n; ; ) {
      var u = a.return;
      if (u === null) break;
      var f = u.alternate;
      if (f === null) {
        if (o = u.return, o !== null) {
          a = o;
          continue;
        }
        break;
      }
      if (u.child === f.child) {
        for (f = u.child; f; ) {
          if (f === a) return m(u), e;
          if (f === o) return m(u), n;
          f = f.sibling;
        }
        throw Error(s(188));
      }
      if (a.return !== o.return) a = u, o = f;
      else {
        for (var y = !1, A = u.child; A; ) {
          if (A === a) {
            y = !0, a = u, o = f;
            break;
          }
          if (A === o) {
            y = !0, o = u, a = f;
            break;
          }
          A = A.sibling;
        }
        if (!y) {
          for (A = f.child; A; ) {
            if (A === a) {
              y = !0, a = f, o = u;
              break;
            }
            if (A === o) {
              y = !0, o = f, a = u;
              break;
            }
            A = A.sibling;
          }
          if (!y) throw Error(s(189));
        }
      }
      if (a.alternate !== o) throw Error(s(190));
    }
    if (a.tag !== 3) throw Error(s(188));
    return a.stateNode.current === a ? e : n;
  }
  function g(e) {
    var n = e.tag;
    if (n === 5 || n === 26 || n === 27 || n === 6) return e;
    for (e = e.child; e !== null; ) {
      if (n = g(e), n !== null) return n;
      e = e.sibling;
    }
    return null;
  }
  var _ = Object.assign, x = Symbol.for("react.element"), S = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), M = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), B = Symbol.for("react.consumer"), U = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), L = Symbol.for("react.suspense_list"), O = Symbol.for("react.memo"), G = Symbol.for("react.lazy"), C = Symbol.for("react.activity"), T = Symbol.for("react.memo_cache_sentinel"), I = Symbol.iterator;
  function J(e) {
    return e === null || typeof e != "object" ? null : (e = I && e[I] || e["@@iterator"], typeof e == "function" ? e : null);
  }
  var $ = Symbol.for("react.client.reference");
  function lt(e) {
    if (e == null) return null;
    if (typeof e == "function")
      return e.$$typeof === $ ? null : e.displayName || e.name || null;
    if (typeof e == "string") return e;
    switch (e) {
      case b:
        return "Fragment";
      case v:
        return "Profiler";
      case M:
        return "StrictMode";
      case F:
        return "Suspense";
      case L:
        return "SuspenseList";
      case C:
        return "Activity";
    }
    if (typeof e == "object")
      switch (e.$$typeof) {
        case E:
          return "Portal";
        case U:
          return e.displayName || "Context";
        case B:
          return (e._context.displayName || "Context") + ".Consumer";
        case w:
          var n = e.render;
          return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
        case O:
          return n = e.displayName || null, n !== null ? n : lt(e.type) || "Memo";
        case G:
          n = e._payload, e = e._init;
          try {
            return lt(e(n));
          } catch {
          }
      }
    return null;
  }
  var pt = Array.isArray, z = t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, tt = i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = {
    pending: !1,
    data: null,
    method: null,
    action: null
  }, yt = [], Mt = -1;
  function P(e) {
    return { current: e };
  }
  function st(e) {
    0 > Mt || (e.current = yt[Mt], yt[Mt] = null, Mt--);
  }
  function xt(e, n) {
    Mt++, yt[Mt] = e.current, e.current = n;
  }
  var j = P(null), ht = P(null), Et = P(null), vt = P(null);
  function Ht(e, n) {
    switch (xt(Et, n), xt(ht, e), xt(j, null), n.nodeType) {
      case 9:
      case 11:
        e = (e = n.documentElement) && (e = e.namespaceURI) ? B_(e) : 0;
        break;
      default:
        if (e = n.tagName, n = n.namespaceURI)
          n = B_(n), e = I_(n, e);
        else
          switch (e) {
            case "svg":
              e = 1;
              break;
            case "math":
              e = 2;
              break;
            default:
              e = 0;
          }
    }
    st(j), xt(j, e);
  }
  function Lt() {
    st(j), st(ht), st(Et);
  }
  function ae(e) {
    e.memoizedState !== null && xt(vt, e);
    var n = j.current, a = I_(n, e.type);
    n !== a && (xt(ht, e), xt(j, a));
  }
  function Ne(e) {
    ht.current === e && (st(j), st(ht)), vt.current === e && (st(vt), Yo._currentValue = K);
  }
  var de, We;
  function V(e) {
    if (de === void 0)
      try {
        throw Error();
      } catch (a) {
        var n = a.stack.trim().match(/\n( *(at )?)/);
        de = n && n[1] || "", We = -1 < a.stack.indexOf(`
    at`) ? " (<anonymous>)" : -1 < a.stack.indexOf("@") ? "@unknown:0:0" : "";
      }
    return `
` + de + e + We;
  }
  var vn = !1;
  function fe(e, n) {
    if (!e || vn) return "";
    vn = !0;
    var a = Error.prepareStackTrace;
    Error.prepareStackTrace = void 0;
    try {
      var o = {
        DetermineComponentFrameRoot: function() {
          try {
            if (n) {
              var gt = function() {
                throw Error();
              };
              if (Object.defineProperty(gt.prototype, "props", {
                set: function() {
                  throw Error();
                }
              }), typeof Reflect == "object" && Reflect.construct) {
                try {
                  Reflect.construct(gt, []);
                } catch (ct) {
                  var at = ct;
                }
                Reflect.construct(e, [], gt);
              } else {
                try {
                  gt.call();
                } catch (ct) {
                  at = ct;
                }
                e.call(gt.prototype);
              }
            } else {
              try {
                throw Error();
              } catch (ct) {
                at = ct;
              }
              (gt = e()) && typeof gt.catch == "function" && gt.catch(function() {
              });
            }
          } catch (ct) {
            if (ct && at && typeof ct.stack == "string")
              return [ct.stack, at.stack];
          }
          return [null, null];
        }
      };
      o.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
      var u = Object.getOwnPropertyDescriptor(
        o.DetermineComponentFrameRoot,
        "name"
      );
      u && u.configurable && Object.defineProperty(
        o.DetermineComponentFrameRoot,
        "name",
        { value: "DetermineComponentFrameRoot" }
      );
      var f = o.DetermineComponentFrameRoot(), y = f[0], A = f[1];
      if (y && A) {
        var H = y.split(`
`), nt = A.split(`
`);
        for (u = o = 0; o < H.length && !H[o].includes("DetermineComponentFrameRoot"); )
          o++;
        for (; u < nt.length && !nt[u].includes(
          "DetermineComponentFrameRoot"
        ); )
          u++;
        if (o === H.length || u === nt.length)
          for (o = H.length - 1, u = nt.length - 1; 1 <= o && 0 <= u && H[o] !== nt[u]; )
            u--;
        for (; 1 <= o && 0 <= u; o--, u--)
          if (H[o] !== nt[u]) {
            if (o !== 1 || u !== 1)
              do
                if (o--, u--, 0 > u || H[o] !== nt[u]) {
                  var ft = `
` + H[o].replace(" at new ", " at ");
                  return e.displayName && ft.includes("<anonymous>") && (ft = ft.replace("<anonymous>", e.displayName)), ft;
                }
              while (1 <= o && 0 <= u);
            break;
          }
      }
    } finally {
      vn = !1, Error.prepareStackTrace = a;
    }
    return (a = e ? e.displayName || e.name : "") ? V(a) : "";
  }
  function pe(e, n) {
    switch (e.tag) {
      case 26:
      case 27:
      case 5:
        return V(e.type);
      case 16:
        return V("Lazy");
      case 13:
        return e.child !== n && n !== null ? V("Suspense Fallback") : V("Suspense");
      case 19:
        return V("SuspenseList");
      case 0:
      case 15:
        return fe(e.type, !1);
      case 11:
        return fe(e.type.render, !1);
      case 1:
        return fe(e.type, !0);
      case 31:
        return V("Activity");
      default:
        return "";
    }
  }
  function Yt(e) {
    try {
      var n = "", a = null;
      do
        n += pe(e, a), a = e, e = e.return;
      while (e);
      return n;
    } catch (o) {
      return `
Error generating stack: ` + o.message + `
` + o.stack;
    }
  }
  var Ue = Object.prototype.hasOwnProperty, Xt = r.unstable_scheduleCallback, N = r.unstable_cancelCallback, R = r.unstable_shouldYield, it = r.unstable_requestPaint, dt = r.unstable_now, St = r.unstable_getCurrentPriorityLevel, Q = r.unstable_ImmediatePriority, Tt = r.unstable_UserBlockingPriority, wt = r.unstable_NormalPriority, Bt = r.unstable_LowPriority, xe = r.unstable_IdlePriority, Ct = r.log, Gt = r.unstable_setDisableYieldValue, jt = null, Wt = null;
  function It(e) {
    if (typeof Ct == "function" && Gt(e), Wt && typeof Wt.setStrictMode == "function")
      try {
        Wt.setStrictMode(jt, e);
      } catch {
      }
  }
  var te = Math.clz32 ? Math.clz32 : W, oe = Math.log, ze = Math.LN2;
  function W(e) {
    return e >>>= 0, e === 0 ? 32 : 31 - (oe(e) / ze | 0) | 0;
  }
  var Dt = 256, ut = 262144, _t = 4194304;
  function Ut(e) {
    var n = e & 42;
    if (n !== 0) return n;
    switch (e & -e) {
      case 1:
        return 1;
      case 2:
        return 2;
      case 4:
        return 4;
      case 8:
        return 8;
      case 16:
        return 16;
      case 32:
        return 32;
      case 64:
        return 64;
      case 128:
        return 128;
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
        return e & 261888;
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return e & 3932160;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        return e & 62914560;
      case 67108864:
        return 67108864;
      case 134217728:
        return 134217728;
      case 268435456:
        return 268435456;
      case 536870912:
        return 536870912;
      case 1073741824:
        return 0;
      default:
        return e;
    }
  }
  function Nt(e, n, a) {
    var o = e.pendingLanes;
    if (o === 0) return 0;
    var u = 0, f = e.suspendedLanes, y = e.pingedLanes;
    e = e.warmLanes;
    var A = o & 134217727;
    return A !== 0 ? (o = A & ~f, o !== 0 ? u = Ut(o) : (y &= A, y !== 0 ? u = Ut(y) : a || (a = A & ~e, a !== 0 && (u = Ut(a))))) : (A = o & ~f, A !== 0 ? u = Ut(A) : y !== 0 ? u = Ut(y) : a || (a = o & ~e, a !== 0 && (u = Ut(a)))), u === 0 ? 0 : n !== 0 && n !== u && (n & f) === 0 && (f = u & -u, a = n & -n, f >= a || f === 32 && (a & 4194048) !== 0) ? n : u;
  }
  function ee(e, n) {
    return (e.pendingLanes & ~(e.suspendedLanes & ~e.pingedLanes) & n) === 0;
  }
  function Ke(e, n) {
    switch (e) {
      case 1:
      case 2:
      case 4:
      case 8:
      case 64:
        return n + 250;
      case 16:
      case 32:
      case 128:
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return n + 5e3;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        return -1;
      case 67108864:
      case 134217728:
      case 268435456:
      case 536870912:
      case 1073741824:
        return -1;
      default:
        return -1;
    }
  }
  function hn() {
    var e = _t;
    return _t <<= 1, (_t & 62914560) === 0 && (_t = 4194304), e;
  }
  function Ae(e) {
    for (var n = [], a = 0; 31 > a; a++) n.push(e);
    return n;
  }
  function En(e, n) {
    e.pendingLanes |= n, n !== 268435456 && (e.suspendedLanes = 0, e.pingedLanes = 0, e.warmLanes = 0);
  }
  function bi(e, n, a, o, u, f) {
    var y = e.pendingLanes;
    e.pendingLanes = a, e.suspendedLanes = 0, e.pingedLanes = 0, e.warmLanes = 0, e.expiredLanes &= a, e.entangledLanes &= a, e.errorRecoveryDisabledLanes &= a, e.shellSuspendCounter = 0;
    var A = e.entanglements, H = e.expirationTimes, nt = e.hiddenUpdates;
    for (a = y & ~a; 0 < a; ) {
      var ft = 31 - te(a), gt = 1 << ft;
      A[ft] = 0, H[ft] = -1;
      var at = nt[ft];
      if (at !== null)
        for (nt[ft] = null, ft = 0; ft < at.length; ft++) {
          var ct = at[ft];
          ct !== null && (ct.lane &= -536870913);
        }
      a &= ~gt;
    }
    o !== 0 && io(e, o, 0), f !== 0 && u === 0 && e.tag !== 0 && (e.suspendedLanes |= f & ~(y & ~n));
  }
  function io(e, n, a) {
    e.pendingLanes |= n, e.suspendedLanes &= ~n;
    var o = 31 - te(n);
    e.entangledLanes |= n, e.entanglements[o] = e.entanglements[o] | 1073741824 | a & 261930;
  }
  function ao(e, n) {
    var a = e.entangledLanes |= n;
    for (e = e.entanglements; a; ) {
      var o = 31 - te(a), u = 1 << o;
      u & n | e[o] & n && (e[o] |= n), a &= ~u;
    }
  }
  function Ni(e, n) {
    var a = n & -n;
    return a = (a & 42) !== 0 ? 1 : ns(a), (a & (e.suspendedLanes | n)) !== 0 ? 0 : a;
  }
  function ns(e) {
    switch (e) {
      case 2:
        e = 1;
        break;
      case 8:
        e = 4;
        break;
      case 32:
        e = 16;
        break;
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
        e = 128;
        break;
      case 268435456:
        e = 134217728;
        break;
      default:
        e = 0;
    }
    return e;
  }
  function Hs(e) {
    return e &= -e, 2 < e ? 8 < e ? (e & 134217727) !== 0 ? 32 : 268435456 : 8 : 2;
  }
  function so() {
    var e = tt.p;
    return e !== 0 ? e : (e = window.event, e === void 0 ? 32 : o0(e.type));
  }
  function is(e, n) {
    var a = tt.p;
    try {
      return tt.p = e, n();
    } finally {
      tt.p = a;
    }
  }
  var Ti = Math.random().toString(36).slice(2), $e = "__reactFiber$" + Ti, bn = "__reactProps$" + Ti, Vi = "__reactContainer$" + Ti, ro = "__reactEvents$" + Ti, bu = "__reactListeners$" + Ti, Tu = "__reactHandles$" + Ti, ml = "__reactResources$" + Ti, as = "__reactMarker$" + Ti;
  function oo(e) {
    delete e[$e], delete e[bn], delete e[ro], delete e[bu], delete e[Tu];
  }
  function D(e) {
    var n = e[$e];
    if (n) return n;
    for (var a = e.parentNode; a; ) {
      if (n = a[Vi] || a[$e]) {
        if (a = n.alternate, n.child !== null || a !== null && a.child !== null)
          for (e = W_(e); e !== null; ) {
            if (a = e[$e]) return a;
            e = W_(e);
          }
        return n;
      }
      e = a, a = e.parentNode;
    }
    return null;
  }
  function Y(e) {
    if (e = e[$e] || e[Vi]) {
      var n = e.tag;
      if (n === 5 || n === 6 || n === 13 || n === 31 || n === 26 || n === 27 || n === 3)
        return e;
    }
    return null;
  }
  function rt(e) {
    var n = e.tag;
    if (n === 5 || n === 26 || n === 27 || n === 6) return e.stateNode;
    throw Error(s(33));
  }
  function ot(e) {
    var n = e[ml];
    return n || (n = e[ml] = { hoistableStyles: /* @__PURE__ */ new Map(), hoistableScripts: /* @__PURE__ */ new Map() }), n;
  }
  function X(e) {
    e[as] = !0;
  }
  var At = /* @__PURE__ */ new Set(), Ot = {};
  function zt(e, n) {
    Ft(e, n), Ft(e + "Capture", n);
  }
  function Ft(e, n) {
    for (Ot[e] = n, e = 0; e < n.length; e++)
      At.add(n[e]);
  }
  var ne = RegExp(
    "^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"
  ), ie = {}, Zt = {};
  function Me(e) {
    return Ue.call(Zt, e) ? !0 : Ue.call(ie, e) ? !1 : ne.test(e) ? Zt[e] = !0 : (ie[e] = !0, !1);
  }
  function Ee(e, n, a) {
    if (Me(n))
      if (a === null) e.removeAttribute(n);
      else {
        switch (typeof a) {
          case "undefined":
          case "function":
          case "symbol":
            e.removeAttribute(n);
            return;
          case "boolean":
            var o = n.toLowerCase().slice(0, 5);
            if (o !== "data-" && o !== "aria-") {
              e.removeAttribute(n);
              return;
            }
        }
        e.setAttribute(n, "" + a);
      }
  }
  function qe(e, n, a) {
    if (a === null) e.removeAttribute(n);
    else {
      switch (typeof a) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          e.removeAttribute(n);
          return;
      }
      e.setAttribute(n, "" + a);
    }
  }
  function Re(e, n, a, o) {
    if (o === null) e.removeAttribute(a);
    else {
      switch (typeof o) {
        case "undefined":
        case "function":
        case "symbol":
        case "boolean":
          e.removeAttribute(a);
          return;
      }
      e.setAttributeNS(n, a, "" + o);
    }
  }
  function se(e) {
    switch (typeof e) {
      case "bigint":
      case "boolean":
      case "number":
      case "string":
      case "undefined":
        return e;
      case "object":
        return e;
      default:
        return "";
    }
  }
  function Qt(e) {
    var n = e.type;
    return (e = e.nodeName) && e.toLowerCase() === "input" && (n === "checkbox" || n === "radio");
  }
  function dn(e, n, a) {
    var o = Object.getOwnPropertyDescriptor(
      e.constructor.prototype,
      n
    );
    if (!e.hasOwnProperty(n) && typeof o < "u" && typeof o.get == "function" && typeof o.set == "function") {
      var u = o.get, f = o.set;
      return Object.defineProperty(e, n, {
        configurable: !0,
        get: function() {
          return u.call(this);
        },
        set: function(y) {
          a = "" + y, f.call(this, y);
        }
      }), Object.defineProperty(e, n, {
        enumerable: o.enumerable
      }), {
        getValue: function() {
          return a;
        },
        setValue: function(y) {
          a = "" + y;
        },
        stopTracking: function() {
          e._valueTracker = null, delete e[n];
        }
      };
    }
  }
  function Te(e) {
    if (!e._valueTracker) {
      var n = Qt(e) ? "checked" : "value";
      e._valueTracker = dn(
        e,
        n,
        "" + e[n]
      );
    }
  }
  function Wn(e) {
    if (!e) return !1;
    var n = e._valueTracker;
    if (!n) return !0;
    var a = n.getValue(), o = "";
    return e && (o = Qt(e) ? e.checked ? "true" : "false" : e.value), e = o, e !== a ? (n.setValue(e), !0) : !1;
  }
  function Ai(e) {
    if (e = e || (typeof document < "u" ? document : void 0), typeof e > "u") return null;
    try {
      return e.activeElement || e.body;
    } catch {
      return e.body;
    }
  }
  var In = /[\n"\\]/g;
  function xn(e) {
    return e.replace(
      In,
      function(n) {
        return "\\" + n.charCodeAt(0).toString(16) + " ";
      }
    );
  }
  function Be(e, n, a, o, u, f, y, A) {
    e.name = "", y != null && typeof y != "function" && typeof y != "symbol" && typeof y != "boolean" ? e.type = y : e.removeAttribute("type"), n != null ? y === "number" ? (n === 0 && e.value === "" || e.value != n) && (e.value = "" + se(n)) : e.value !== "" + se(n) && (e.value = "" + se(n)) : y !== "submit" && y !== "reset" || e.removeAttribute("value"), n != null ? Ln(e, y, se(n)) : a != null ? Ln(e, y, se(a)) : o != null && e.removeAttribute("value"), u == null && f != null && (e.defaultChecked = !!f), u != null && (e.checked = u && typeof u != "function" && typeof u != "symbol"), A != null && typeof A != "function" && typeof A != "symbol" && typeof A != "boolean" ? e.name = "" + se(A) : e.removeAttribute("name");
  }
  function Fn(e, n, a, o, u, f, y, A) {
    if (f != null && typeof f != "function" && typeof f != "symbol" && typeof f != "boolean" && (e.type = f), n != null || a != null) {
      if (!(f !== "submit" && f !== "reset" || n != null)) {
        Te(e);
        return;
      }
      a = a != null ? "" + se(a) : "", n = n != null ? "" + se(n) : a, A || n === e.value || (e.value = n), e.defaultValue = n;
    }
    o = o ?? u, o = typeof o != "function" && typeof o != "symbol" && !!o, e.checked = A ? e.checked : !!o, e.defaultChecked = !!o, y != null && typeof y != "function" && typeof y != "symbol" && typeof y != "boolean" && (e.name = y), Te(e);
  }
  function Ln(e, n, a) {
    n === "number" && Ai(e.ownerDocument) === e || e.defaultValue === "" + a || (e.defaultValue = "" + a);
  }
  function tn(e, n, a, o) {
    if (e = e.options, n) {
      n = {};
      for (var u = 0; u < a.length; u++)
        n["$" + a[u]] = !0;
      for (a = 0; a < e.length; a++)
        u = n.hasOwnProperty("$" + e[a].value), e[a].selected !== u && (e[a].selected = u), u && o && (e[a].defaultSelected = !0);
    } else {
      for (a = "" + se(a), n = null, u = 0; u < e.length; u++) {
        if (e[u].value === a) {
          e[u].selected = !0, o && (e[u].defaultSelected = !0);
          return;
        }
        n !== null || e[u].disabled || (n = e[u]);
      }
      n !== null && (n.selected = !0);
    }
  }
  function Tn(e, n, a) {
    if (n != null && (n = "" + se(n), n !== e.value && (e.value = n), a == null)) {
      e.defaultValue !== n && (e.defaultValue = n);
      return;
    }
    e.defaultValue = a != null ? "" + se(a) : "";
  }
  function Gs(e, n, a, o) {
    if (n == null) {
      if (o != null) {
        if (a != null) throw Error(s(92));
        if (pt(o)) {
          if (1 < o.length) throw Error(s(93));
          o = o[0];
        }
        a = o;
      }
      a == null && (a = ""), n = a;
    }
    a = se(n), e.defaultValue = a, o = e.textContent, o === a && o !== "" && o !== null && (e.value = o), Te(e);
  }
  function Yn(e, n) {
    if (n) {
      var a = e.firstChild;
      if (a && a === e.lastChild && a.nodeType === 3) {
        a.nodeValue = n;
        return;
      }
    }
    e.textContent = n;
  }
  var Nx = new Set(
    "animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(
      " "
    )
  );
  function Op(e, n, a) {
    var o = n.indexOf("--") === 0;
    a == null || typeof a == "boolean" || a === "" ? o ? e.setProperty(n, "") : n === "float" ? e.cssFloat = "" : e[n] = "" : o ? e.setProperty(n, a) : typeof a != "number" || a === 0 || Nx.has(n) ? n === "float" ? e.cssFloat = a : e[n] = ("" + a).trim() : e[n] = a + "px";
  }
  function Pp(e, n, a) {
    if (n != null && typeof n != "object")
      throw Error(s(62));
    if (e = e.style, a != null) {
      for (var o in a)
        !a.hasOwnProperty(o) || n != null && n.hasOwnProperty(o) || (o.indexOf("--") === 0 ? e.setProperty(o, "") : o === "float" ? e.cssFloat = "" : e[o] = "");
      for (var u in n)
        o = n[u], n.hasOwnProperty(u) && a[u] !== o && Op(e, u, o);
    } else
      for (var f in n)
        n.hasOwnProperty(f) && Op(e, f, n[f]);
  }
  function Au(e) {
    if (e.indexOf("-") === -1) return !1;
    switch (e) {
      case "annotation-xml":
      case "color-profile":
      case "font-face":
      case "font-face-src":
      case "font-face-uri":
      case "font-face-format":
      case "font-face-name":
      case "missing-glyph":
        return !1;
      default:
        return !0;
    }
  }
  var Ox = /* @__PURE__ */ new Map([
    ["acceptCharset", "accept-charset"],
    ["htmlFor", "for"],
    ["httpEquiv", "http-equiv"],
    ["crossOrigin", "crossorigin"],
    ["accentHeight", "accent-height"],
    ["alignmentBaseline", "alignment-baseline"],
    ["arabicForm", "arabic-form"],
    ["baselineShift", "baseline-shift"],
    ["capHeight", "cap-height"],
    ["clipPath", "clip-path"],
    ["clipRule", "clip-rule"],
    ["colorInterpolation", "color-interpolation"],
    ["colorInterpolationFilters", "color-interpolation-filters"],
    ["colorProfile", "color-profile"],
    ["colorRendering", "color-rendering"],
    ["dominantBaseline", "dominant-baseline"],
    ["enableBackground", "enable-background"],
    ["fillOpacity", "fill-opacity"],
    ["fillRule", "fill-rule"],
    ["floodColor", "flood-color"],
    ["floodOpacity", "flood-opacity"],
    ["fontFamily", "font-family"],
    ["fontSize", "font-size"],
    ["fontSizeAdjust", "font-size-adjust"],
    ["fontStretch", "font-stretch"],
    ["fontStyle", "font-style"],
    ["fontVariant", "font-variant"],
    ["fontWeight", "font-weight"],
    ["glyphName", "glyph-name"],
    ["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
    ["glyphOrientationVertical", "glyph-orientation-vertical"],
    ["horizAdvX", "horiz-adv-x"],
    ["horizOriginX", "horiz-origin-x"],
    ["imageRendering", "image-rendering"],
    ["letterSpacing", "letter-spacing"],
    ["lightingColor", "lighting-color"],
    ["markerEnd", "marker-end"],
    ["markerMid", "marker-mid"],
    ["markerStart", "marker-start"],
    ["overlinePosition", "overline-position"],
    ["overlineThickness", "overline-thickness"],
    ["paintOrder", "paint-order"],
    ["panose-1", "panose-1"],
    ["pointerEvents", "pointer-events"],
    ["renderingIntent", "rendering-intent"],
    ["shapeRendering", "shape-rendering"],
    ["stopColor", "stop-color"],
    ["stopOpacity", "stop-opacity"],
    ["strikethroughPosition", "strikethrough-position"],
    ["strikethroughThickness", "strikethrough-thickness"],
    ["strokeDasharray", "stroke-dasharray"],
    ["strokeDashoffset", "stroke-dashoffset"],
    ["strokeLinecap", "stroke-linecap"],
    ["strokeLinejoin", "stroke-linejoin"],
    ["strokeMiterlimit", "stroke-miterlimit"],
    ["strokeOpacity", "stroke-opacity"],
    ["strokeWidth", "stroke-width"],
    ["textAnchor", "text-anchor"],
    ["textDecoration", "text-decoration"],
    ["textRendering", "text-rendering"],
    ["transformOrigin", "transform-origin"],
    ["underlinePosition", "underline-position"],
    ["underlineThickness", "underline-thickness"],
    ["unicodeBidi", "unicode-bidi"],
    ["unicodeRange", "unicode-range"],
    ["unitsPerEm", "units-per-em"],
    ["vAlphabetic", "v-alphabetic"],
    ["vHanging", "v-hanging"],
    ["vIdeographic", "v-ideographic"],
    ["vMathematical", "v-mathematical"],
    ["vectorEffect", "vector-effect"],
    ["vertAdvY", "vert-adv-y"],
    ["vertOriginX", "vert-origin-x"],
    ["vertOriginY", "vert-origin-y"],
    ["wordSpacing", "word-spacing"],
    ["writingMode", "writing-mode"],
    ["xmlnsXlink", "xmlns:xlink"],
    ["xHeight", "x-height"]
  ]), Px = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;
  function gl(e) {
    return Px.test("" + e) ? "javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')" : e;
  }
  function ki() {
  }
  var Ru = null;
  function Cu(e) {
    return e = e.target || e.srcElement || window, e.correspondingUseElement && (e = e.correspondingUseElement), e.nodeType === 3 ? e.parentNode : e;
  }
  var Vs = null, ks = null;
  function zp(e) {
    var n = Y(e);
    if (n && (e = n.stateNode)) {
      var a = e[bn] || null;
      t: switch (e = n.stateNode, n.type) {
        case "input":
          if (Be(
            e,
            a.value,
            a.defaultValue,
            a.defaultValue,
            a.checked,
            a.defaultChecked,
            a.type,
            a.name
          ), n = a.name, a.type === "radio" && n != null) {
            for (a = e; a.parentNode; ) a = a.parentNode;
            for (a = a.querySelectorAll(
              'input[name="' + xn(
                "" + n
              ) + '"][type="radio"]'
            ), n = 0; n < a.length; n++) {
              var o = a[n];
              if (o !== e && o.form === e.form) {
                var u = o[bn] || null;
                if (!u) throw Error(s(90));
                Be(
                  o,
                  u.value,
                  u.defaultValue,
                  u.defaultValue,
                  u.checked,
                  u.defaultChecked,
                  u.type,
                  u.name
                );
              }
            }
            for (n = 0; n < a.length; n++)
              o = a[n], o.form === e.form && Wn(o);
          }
          break t;
        case "textarea":
          Tn(e, a.value, a.defaultValue);
          break t;
        case "select":
          n = a.value, n != null && tn(e, !!a.multiple, n, !1);
      }
    }
  }
  var wu = !1;
  function Bp(e, n, a) {
    if (wu) return e(n, a);
    wu = !0;
    try {
      var o = e(n);
      return o;
    } finally {
      if (wu = !1, (Vs !== null || ks !== null) && (ic(), Vs && (n = Vs, e = ks, ks = Vs = null, zp(n), e)))
        for (n = 0; n < e.length; n++) zp(e[n]);
    }
  }
  function lo(e, n) {
    var a = e.stateNode;
    if (a === null) return null;
    var o = a[bn] || null;
    if (o === null) return null;
    a = o[n];
    t: switch (n) {
      case "onClick":
      case "onClickCapture":
      case "onDoubleClick":
      case "onDoubleClickCapture":
      case "onMouseDown":
      case "onMouseDownCapture":
      case "onMouseMove":
      case "onMouseMoveCapture":
      case "onMouseUp":
      case "onMouseUpCapture":
      case "onMouseEnter":
        (o = !o.disabled) || (e = e.type, o = !(e === "button" || e === "input" || e === "select" || e === "textarea")), e = !o;
        break t;
      default:
        e = !1;
    }
    if (e) return null;
    if (a && typeof a != "function")
      throw Error(
        s(231, n, typeof a)
      );
    return a;
  }
  var Xi = !(typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u"), Du = !1;
  if (Xi)
    try {
      var co = {};
      Object.defineProperty(co, "passive", {
        get: function() {
          Du = !0;
        }
      }), window.addEventListener("test", co, co), window.removeEventListener("test", co, co);
    } catch {
      Du = !1;
    }
  var va = null, Uu = null, _l = null;
  function Ip() {
    if (_l) return _l;
    var e, n = Uu, a = n.length, o, u = "value" in va ? va.value : va.textContent, f = u.length;
    for (e = 0; e < a && n[e] === u[e]; e++) ;
    var y = a - e;
    for (o = 1; o <= y && n[a - o] === u[f - o]; o++) ;
    return _l = u.slice(e, 1 < o ? 1 - o : void 0);
  }
  function vl(e) {
    var n = e.keyCode;
    return "charCode" in e ? (e = e.charCode, e === 0 && n === 13 && (e = 13)) : e = n, e === 10 && (e = 13), 32 <= e || e === 13 ? e : 0;
  }
  function xl() {
    return !0;
  }
  function Fp() {
    return !1;
  }
  function qn(e) {
    function n(a, o, u, f, y) {
      this._reactName = a, this._targetInst = u, this.type = o, this.nativeEvent = f, this.target = y, this.currentTarget = null;
      for (var A in e)
        e.hasOwnProperty(A) && (a = e[A], this[A] = a ? a(f) : f[A]);
      return this.isDefaultPrevented = (f.defaultPrevented != null ? f.defaultPrevented : f.returnValue === !1) ? xl : Fp, this.isPropagationStopped = Fp, this;
    }
    return _(n.prototype, {
      preventDefault: function() {
        this.defaultPrevented = !0;
        var a = this.nativeEvent;
        a && (a.preventDefault ? a.preventDefault() : typeof a.returnValue != "unknown" && (a.returnValue = !1), this.isDefaultPrevented = xl);
      },
      stopPropagation: function() {
        var a = this.nativeEvent;
        a && (a.stopPropagation ? a.stopPropagation() : typeof a.cancelBubble != "unknown" && (a.cancelBubble = !0), this.isPropagationStopped = xl);
      },
      persist: function() {
      },
      isPersistent: xl
    }), n;
  }
  var ss = {
    eventPhase: 0,
    bubbles: 0,
    cancelable: 0,
    timeStamp: function(e) {
      return e.timeStamp || Date.now();
    },
    defaultPrevented: 0,
    isTrusted: 0
  }, yl = qn(ss), uo = _({}, ss, { view: 0, detail: 0 }), zx = qn(uo), Lu, Nu, fo, Sl = _({}, uo, {
    screenX: 0,
    screenY: 0,
    clientX: 0,
    clientY: 0,
    pageX: 0,
    pageY: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    getModifierState: Pu,
    button: 0,
    buttons: 0,
    relatedTarget: function(e) {
      return e.relatedTarget === void 0 ? e.fromElement === e.srcElement ? e.toElement : e.fromElement : e.relatedTarget;
    },
    movementX: function(e) {
      return "movementX" in e ? e.movementX : (e !== fo && (fo && e.type === "mousemove" ? (Lu = e.screenX - fo.screenX, Nu = e.screenY - fo.screenY) : Nu = Lu = 0, fo = e), Lu);
    },
    movementY: function(e) {
      return "movementY" in e ? e.movementY : Nu;
    }
  }), Hp = qn(Sl), Bx = _({}, Sl, { dataTransfer: 0 }), Ix = qn(Bx), Fx = _({}, uo, { relatedTarget: 0 }), Ou = qn(Fx), Hx = _({}, ss, {
    animationName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), Gx = qn(Hx), Vx = _({}, ss, {
    clipboardData: function(e) {
      return "clipboardData" in e ? e.clipboardData : window.clipboardData;
    }
  }), kx = qn(Vx), Xx = _({}, ss, { data: 0 }), Gp = qn(Xx), Wx = {
    Esc: "Escape",
    Spacebar: " ",
    Left: "ArrowLeft",
    Up: "ArrowUp",
    Right: "ArrowRight",
    Down: "ArrowDown",
    Del: "Delete",
    Win: "OS",
    Menu: "ContextMenu",
    Apps: "ContextMenu",
    Scroll: "ScrollLock",
    MozPrintableKey: "Unidentified"
  }, Yx = {
    8: "Backspace",
    9: "Tab",
    12: "Clear",
    13: "Enter",
    16: "Shift",
    17: "Control",
    18: "Alt",
    19: "Pause",
    20: "CapsLock",
    27: "Escape",
    32: " ",
    33: "PageUp",
    34: "PageDown",
    35: "End",
    36: "Home",
    37: "ArrowLeft",
    38: "ArrowUp",
    39: "ArrowRight",
    40: "ArrowDown",
    45: "Insert",
    46: "Delete",
    112: "F1",
    113: "F2",
    114: "F3",
    115: "F4",
    116: "F5",
    117: "F6",
    118: "F7",
    119: "F8",
    120: "F9",
    121: "F10",
    122: "F11",
    123: "F12",
    144: "NumLock",
    145: "ScrollLock",
    224: "Meta"
  }, qx = {
    Alt: "altKey",
    Control: "ctrlKey",
    Meta: "metaKey",
    Shift: "shiftKey"
  };
  function jx(e) {
    var n = this.nativeEvent;
    return n.getModifierState ? n.getModifierState(e) : (e = qx[e]) ? !!n[e] : !1;
  }
  function Pu() {
    return jx;
  }
  var Zx = _({}, uo, {
    key: function(e) {
      if (e.key) {
        var n = Wx[e.key] || e.key;
        if (n !== "Unidentified") return n;
      }
      return e.type === "keypress" ? (e = vl(e), e === 13 ? "Enter" : String.fromCharCode(e)) : e.type === "keydown" || e.type === "keyup" ? Yx[e.keyCode] || "Unidentified" : "";
    },
    code: 0,
    location: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    repeat: 0,
    locale: 0,
    getModifierState: Pu,
    charCode: function(e) {
      return e.type === "keypress" ? vl(e) : 0;
    },
    keyCode: function(e) {
      return e.type === "keydown" || e.type === "keyup" ? e.keyCode : 0;
    },
    which: function(e) {
      return e.type === "keypress" ? vl(e) : e.type === "keydown" || e.type === "keyup" ? e.keyCode : 0;
    }
  }), Kx = qn(Zx), Qx = _({}, Sl, {
    pointerId: 0,
    width: 0,
    height: 0,
    pressure: 0,
    tangentialPressure: 0,
    tiltX: 0,
    tiltY: 0,
    twist: 0,
    pointerType: 0,
    isPrimary: 0
  }), Vp = qn(Qx), Jx = _({}, uo, {
    touches: 0,
    targetTouches: 0,
    changedTouches: 0,
    altKey: 0,
    metaKey: 0,
    ctrlKey: 0,
    shiftKey: 0,
    getModifierState: Pu
  }), $x = qn(Jx), ty = _({}, ss, {
    propertyName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), ey = qn(ty), ny = _({}, Sl, {
    deltaX: function(e) {
      return "deltaX" in e ? e.deltaX : "wheelDeltaX" in e ? -e.wheelDeltaX : 0;
    },
    deltaY: function(e) {
      return "deltaY" in e ? e.deltaY : "wheelDeltaY" in e ? -e.wheelDeltaY : "wheelDelta" in e ? -e.wheelDelta : 0;
    },
    deltaZ: 0,
    deltaMode: 0
  }), iy = qn(ny), ay = _({}, ss, {
    newState: 0,
    oldState: 0
  }), sy = qn(ay), ry = [9, 13, 27, 32], zu = Xi && "CompositionEvent" in window, ho = null;
  Xi && "documentMode" in document && (ho = document.documentMode);
  var oy = Xi && "TextEvent" in window && !ho, kp = Xi && (!zu || ho && 8 < ho && 11 >= ho), Xp = " ", Wp = !1;
  function Yp(e, n) {
    switch (e) {
      case "keyup":
        return ry.indexOf(n.keyCode) !== -1;
      case "keydown":
        return n.keyCode !== 229;
      case "keypress":
      case "mousedown":
      case "focusout":
        return !0;
      default:
        return !1;
    }
  }
  function qp(e) {
    return e = e.detail, typeof e == "object" && "data" in e ? e.data : null;
  }
  var Xs = !1;
  function ly(e, n) {
    switch (e) {
      case "compositionend":
        return qp(n);
      case "keypress":
        return n.which !== 32 ? null : (Wp = !0, Xp);
      case "textInput":
        return e = n.data, e === Xp && Wp ? null : e;
      default:
        return null;
    }
  }
  function cy(e, n) {
    if (Xs)
      return e === "compositionend" || !zu && Yp(e, n) ? (e = Ip(), _l = Uu = va = null, Xs = !1, e) : null;
    switch (e) {
      case "paste":
        return null;
      case "keypress":
        if (!(n.ctrlKey || n.altKey || n.metaKey) || n.ctrlKey && n.altKey) {
          if (n.char && 1 < n.char.length)
            return n.char;
          if (n.which) return String.fromCharCode(n.which);
        }
        return null;
      case "compositionend":
        return kp && n.locale !== "ko" ? null : n.data;
      default:
        return null;
    }
  }
  var uy = {
    color: !0,
    date: !0,
    datetime: !0,
    "datetime-local": !0,
    email: !0,
    month: !0,
    number: !0,
    password: !0,
    range: !0,
    search: !0,
    tel: !0,
    text: !0,
    time: !0,
    url: !0,
    week: !0
  };
  function jp(e) {
    var n = e && e.nodeName && e.nodeName.toLowerCase();
    return n === "input" ? !!uy[e.type] : n === "textarea";
  }
  function Zp(e, n, a, o) {
    Vs ? ks ? ks.push(o) : ks = [o] : Vs = o, n = uc(n, "onChange"), 0 < n.length && (a = new yl(
      "onChange",
      "change",
      null,
      a,
      o
    ), e.push({ event: a, listeners: n }));
  }
  var po = null, mo = null;
  function fy(e) {
    U_(e, 0);
  }
  function Ml(e) {
    var n = rt(e);
    if (Wn(n)) return e;
  }
  function Kp(e, n) {
    if (e === "change") return n;
  }
  var Qp = !1;
  if (Xi) {
    var Bu;
    if (Xi) {
      var Iu = "oninput" in document;
      if (!Iu) {
        var Jp = document.createElement("div");
        Jp.setAttribute("oninput", "return;"), Iu = typeof Jp.oninput == "function";
      }
      Bu = Iu;
    } else Bu = !1;
    Qp = Bu && (!document.documentMode || 9 < document.documentMode);
  }
  function $p() {
    po && (po.detachEvent("onpropertychange", tm), mo = po = null);
  }
  function tm(e) {
    if (e.propertyName === "value" && Ml(mo)) {
      var n = [];
      Zp(
        n,
        mo,
        e,
        Cu(e)
      ), Bp(fy, n);
    }
  }
  function hy(e, n, a) {
    e === "focusin" ? ($p(), po = n, mo = a, po.attachEvent("onpropertychange", tm)) : e === "focusout" && $p();
  }
  function dy(e) {
    if (e === "selectionchange" || e === "keyup" || e === "keydown")
      return Ml(mo);
  }
  function py(e, n) {
    if (e === "click") return Ml(n);
  }
  function my(e, n) {
    if (e === "input" || e === "change")
      return Ml(n);
  }
  function gy(e, n) {
    return e === n && (e !== 0 || 1 / e === 1 / n) || e !== e && n !== n;
  }
  var ei = typeof Object.is == "function" ? Object.is : gy;
  function go(e, n) {
    if (ei(e, n)) return !0;
    if (typeof e != "object" || e === null || typeof n != "object" || n === null)
      return !1;
    var a = Object.keys(e), o = Object.keys(n);
    if (a.length !== o.length) return !1;
    for (o = 0; o < a.length; o++) {
      var u = a[o];
      if (!Ue.call(n, u) || !ei(e[u], n[u]))
        return !1;
    }
    return !0;
  }
  function em(e) {
    for (; e && e.firstChild; ) e = e.firstChild;
    return e;
  }
  function nm(e, n) {
    var a = em(e);
    e = 0;
    for (var o; a; ) {
      if (a.nodeType === 3) {
        if (o = e + a.textContent.length, e <= n && o >= n)
          return { node: a, offset: n - e };
        e = o;
      }
      t: {
        for (; a; ) {
          if (a.nextSibling) {
            a = a.nextSibling;
            break t;
          }
          a = a.parentNode;
        }
        a = void 0;
      }
      a = em(a);
    }
  }
  function im(e, n) {
    return e && n ? e === n ? !0 : e && e.nodeType === 3 ? !1 : n && n.nodeType === 3 ? im(e, n.parentNode) : "contains" in e ? e.contains(n) : e.compareDocumentPosition ? !!(e.compareDocumentPosition(n) & 16) : !1 : !1;
  }
  function am(e) {
    e = e != null && e.ownerDocument != null && e.ownerDocument.defaultView != null ? e.ownerDocument.defaultView : window;
    for (var n = Ai(e.document); n instanceof e.HTMLIFrameElement; ) {
      try {
        var a = typeof n.contentWindow.location.href == "string";
      } catch {
        a = !1;
      }
      if (a) e = n.contentWindow;
      else break;
      n = Ai(e.document);
    }
    return n;
  }
  function Fu(e) {
    var n = e && e.nodeName && e.nodeName.toLowerCase();
    return n && (n === "input" && (e.type === "text" || e.type === "search" || e.type === "tel" || e.type === "url" || e.type === "password") || n === "textarea" || e.contentEditable === "true");
  }
  var _y = Xi && "documentMode" in document && 11 >= document.documentMode, Ws = null, Hu = null, _o = null, Gu = !1;
  function sm(e, n, a) {
    var o = a.window === a ? a.document : a.nodeType === 9 ? a : a.ownerDocument;
    Gu || Ws == null || Ws !== Ai(o) || (o = Ws, "selectionStart" in o && Fu(o) ? o = { start: o.selectionStart, end: o.selectionEnd } : (o = (o.ownerDocument && o.ownerDocument.defaultView || window).getSelection(), o = {
      anchorNode: o.anchorNode,
      anchorOffset: o.anchorOffset,
      focusNode: o.focusNode,
      focusOffset: o.focusOffset
    }), _o && go(_o, o) || (_o = o, o = uc(Hu, "onSelect"), 0 < o.length && (n = new yl(
      "onSelect",
      "select",
      null,
      n,
      a
    ), e.push({ event: n, listeners: o }), n.target = Ws)));
  }
  function rs(e, n) {
    var a = {};
    return a[e.toLowerCase()] = n.toLowerCase(), a["Webkit" + e] = "webkit" + n, a["Moz" + e] = "moz" + n, a;
  }
  var Ys = {
    animationend: rs("Animation", "AnimationEnd"),
    animationiteration: rs("Animation", "AnimationIteration"),
    animationstart: rs("Animation", "AnimationStart"),
    transitionrun: rs("Transition", "TransitionRun"),
    transitionstart: rs("Transition", "TransitionStart"),
    transitioncancel: rs("Transition", "TransitionCancel"),
    transitionend: rs("Transition", "TransitionEnd")
  }, Vu = {}, rm = {};
  Xi && (rm = document.createElement("div").style, "AnimationEvent" in window || (delete Ys.animationend.animation, delete Ys.animationiteration.animation, delete Ys.animationstart.animation), "TransitionEvent" in window || delete Ys.transitionend.transition);
  function os(e) {
    if (Vu[e]) return Vu[e];
    if (!Ys[e]) return e;
    var n = Ys[e], a;
    for (a in n)
      if (n.hasOwnProperty(a) && a in rm)
        return Vu[e] = n[a];
    return e;
  }
  var om = os("animationend"), lm = os("animationiteration"), cm = os("animationstart"), vy = os("transitionrun"), xy = os("transitionstart"), yy = os("transitioncancel"), um = os("transitionend"), fm = /* @__PURE__ */ new Map(), ku = "abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(
    " "
  );
  ku.push("scrollEnd");
  function Ri(e, n) {
    fm.set(e, n), zt(n, [e]);
  }
  var El = typeof reportError == "function" ? reportError : function(e) {
    if (typeof window == "object" && typeof window.ErrorEvent == "function") {
      var n = new window.ErrorEvent("error", {
        bubbles: !0,
        cancelable: !0,
        message: typeof e == "object" && e !== null && typeof e.message == "string" ? String(e.message) : String(e),
        error: e
      });
      if (!window.dispatchEvent(n)) return;
    } else if (typeof process == "object" && typeof process.emit == "function") {
      process.emit("uncaughtException", e);
      return;
    }
    console.error(e);
  }, hi = [], qs = 0, Xu = 0;
  function bl() {
    for (var e = qs, n = Xu = qs = 0; n < e; ) {
      var a = hi[n];
      hi[n++] = null;
      var o = hi[n];
      hi[n++] = null;
      var u = hi[n];
      hi[n++] = null;
      var f = hi[n];
      if (hi[n++] = null, o !== null && u !== null) {
        var y = o.pending;
        y === null ? u.next = u : (u.next = y.next, y.next = u), o.pending = u;
      }
      f !== 0 && hm(a, u, f);
    }
  }
  function Tl(e, n, a, o) {
    hi[qs++] = e, hi[qs++] = n, hi[qs++] = a, hi[qs++] = o, Xu |= o, e.lanes |= o, e = e.alternate, e !== null && (e.lanes |= o);
  }
  function Wu(e, n, a, o) {
    return Tl(e, n, a, o), Al(e);
  }
  function ls(e, n) {
    return Tl(e, null, null, n), Al(e);
  }
  function hm(e, n, a) {
    e.lanes |= a;
    var o = e.alternate;
    o !== null && (o.lanes |= a);
    for (var u = !1, f = e.return; f !== null; )
      f.childLanes |= a, o = f.alternate, o !== null && (o.childLanes |= a), f.tag === 22 && (e = f.stateNode, e === null || e._visibility & 1 || (u = !0)), e = f, f = f.return;
    return e.tag === 3 ? (f = e.stateNode, u && n !== null && (u = 31 - te(a), e = f.hiddenUpdates, o = e[u], o === null ? e[u] = [n] : o.push(n), n.lane = a | 536870912), f) : null;
  }
  function Al(e) {
    if (50 < Fo)
      throw Fo = 0, eh = null, Error(s(185));
    for (var n = e.return; n !== null; )
      e = n, n = e.return;
    return e.tag === 3 ? e.stateNode : null;
  }
  var js = {};
  function Sy(e, n, a, o) {
    this.tag = e, this.key = a, this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null, this.index = 0, this.refCleanup = this.ref = null, this.pendingProps = n, this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null, this.mode = o, this.subtreeFlags = this.flags = 0, this.deletions = null, this.childLanes = this.lanes = 0, this.alternate = null;
  }
  function ni(e, n, a, o) {
    return new Sy(e, n, a, o);
  }
  function Yu(e) {
    return e = e.prototype, !(!e || !e.isReactComponent);
  }
  function Wi(e, n) {
    var a = e.alternate;
    return a === null ? (a = ni(
      e.tag,
      n,
      e.key,
      e.mode
    ), a.elementType = e.elementType, a.type = e.type, a.stateNode = e.stateNode, a.alternate = e, e.alternate = a) : (a.pendingProps = n, a.type = e.type, a.flags = 0, a.subtreeFlags = 0, a.deletions = null), a.flags = e.flags & 65011712, a.childLanes = e.childLanes, a.lanes = e.lanes, a.child = e.child, a.memoizedProps = e.memoizedProps, a.memoizedState = e.memoizedState, a.updateQueue = e.updateQueue, n = e.dependencies, a.dependencies = n === null ? null : { lanes: n.lanes, firstContext: n.firstContext }, a.sibling = e.sibling, a.index = e.index, a.ref = e.ref, a.refCleanup = e.refCleanup, a;
  }
  function dm(e, n) {
    e.flags &= 65011714;
    var a = e.alternate;
    return a === null ? (e.childLanes = 0, e.lanes = n, e.child = null, e.subtreeFlags = 0, e.memoizedProps = null, e.memoizedState = null, e.updateQueue = null, e.dependencies = null, e.stateNode = null) : (e.childLanes = a.childLanes, e.lanes = a.lanes, e.child = a.child, e.subtreeFlags = 0, e.deletions = null, e.memoizedProps = a.memoizedProps, e.memoizedState = a.memoizedState, e.updateQueue = a.updateQueue, e.type = a.type, n = a.dependencies, e.dependencies = n === null ? null : {
      lanes: n.lanes,
      firstContext: n.firstContext
    }), e;
  }
  function Rl(e, n, a, o, u, f) {
    var y = 0;
    if (o = e, typeof e == "function") Yu(e) && (y = 1);
    else if (typeof e == "string")
      y = AS(
        e,
        a,
        j.current
      ) ? 26 : e === "html" || e === "head" || e === "body" ? 27 : 5;
    else
      t: switch (e) {
        case C:
          return e = ni(31, a, n, u), e.elementType = C, e.lanes = f, e;
        case b:
          return cs(a.children, u, f, n);
        case M:
          y = 8, u |= 24;
          break;
        case v:
          return e = ni(12, a, n, u | 2), e.elementType = v, e.lanes = f, e;
        case F:
          return e = ni(13, a, n, u), e.elementType = F, e.lanes = f, e;
        case L:
          return e = ni(19, a, n, u), e.elementType = L, e.lanes = f, e;
        default:
          if (typeof e == "object" && e !== null)
            switch (e.$$typeof) {
              case U:
                y = 10;
                break t;
              case B:
                y = 9;
                break t;
              case w:
                y = 11;
                break t;
              case O:
                y = 14;
                break t;
              case G:
                y = 16, o = null;
                break t;
            }
          y = 29, a = Error(
            s(130, e === null ? "null" : typeof e, "")
          ), o = null;
      }
    return n = ni(y, a, n, u), n.elementType = e, n.type = o, n.lanes = f, n;
  }
  function cs(e, n, a, o) {
    return e = ni(7, e, o, n), e.lanes = a, e;
  }
  function qu(e, n, a) {
    return e = ni(6, e, null, n), e.lanes = a, e;
  }
  function pm(e) {
    var n = ni(18, null, null, 0);
    return n.stateNode = e, n;
  }
  function ju(e, n, a) {
    return n = ni(
      4,
      e.children !== null ? e.children : [],
      e.key,
      n
    ), n.lanes = a, n.stateNode = {
      containerInfo: e.containerInfo,
      pendingChildren: null,
      implementation: e.implementation
    }, n;
  }
  var mm = /* @__PURE__ */ new WeakMap();
  function di(e, n) {
    if (typeof e == "object" && e !== null) {
      var a = mm.get(e);
      return a !== void 0 ? a : (n = {
        value: e,
        source: n,
        stack: Yt(n)
      }, mm.set(e, n), n);
    }
    return {
      value: e,
      source: n,
      stack: Yt(n)
    };
  }
  var Zs = [], Ks = 0, Cl = null, vo = 0, pi = [], mi = 0, xa = null, Oi = 1, Pi = "";
  function Yi(e, n) {
    Zs[Ks++] = vo, Zs[Ks++] = Cl, Cl = e, vo = n;
  }
  function gm(e, n, a) {
    pi[mi++] = Oi, pi[mi++] = Pi, pi[mi++] = xa, xa = e;
    var o = Oi;
    e = Pi;
    var u = 32 - te(o) - 1;
    o &= ~(1 << u), a += 1;
    var f = 32 - te(n) + u;
    if (30 < f) {
      var y = u - u % 5;
      f = (o & (1 << y) - 1).toString(32), o >>= y, u -= y, Oi = 1 << 32 - te(n) + u | a << u | o, Pi = f + e;
    } else
      Oi = 1 << f | a << u | o, Pi = e;
  }
  function Zu(e) {
    e.return !== null && (Yi(e, 1), gm(e, 1, 0));
  }
  function Ku(e) {
    for (; e === Cl; )
      Cl = Zs[--Ks], Zs[Ks] = null, vo = Zs[--Ks], Zs[Ks] = null;
    for (; e === xa; )
      xa = pi[--mi], pi[mi] = null, Pi = pi[--mi], pi[mi] = null, Oi = pi[--mi], pi[mi] = null;
  }
  function _m(e, n) {
    pi[mi++] = Oi, pi[mi++] = Pi, pi[mi++] = xa, Oi = n.id, Pi = n.overflow, xa = e;
  }
  var An = null, je = null, be = !1, ya = null, gi = !1, Qu = Error(s(519));
  function Sa(e) {
    var n = Error(
      s(
        418,
        1 < arguments.length && arguments[1] !== void 0 && arguments[1] ? "text" : "HTML",
        ""
      )
    );
    throw xo(di(n, e)), Qu;
  }
  function vm(e) {
    var n = e.stateNode, a = e.type, o = e.memoizedProps;
    switch (n[$e] = e, n[bn] = o, a) {
      case "dialog":
        ge("cancel", n), ge("close", n);
        break;
      case "iframe":
      case "object":
      case "embed":
        ge("load", n);
        break;
      case "video":
      case "audio":
        for (a = 0; a < Go.length; a++)
          ge(Go[a], n);
        break;
      case "source":
        ge("error", n);
        break;
      case "img":
      case "image":
      case "link":
        ge("error", n), ge("load", n);
        break;
      case "details":
        ge("toggle", n);
        break;
      case "input":
        ge("invalid", n), Fn(
          n,
          o.value,
          o.defaultValue,
          o.checked,
          o.defaultChecked,
          o.type,
          o.name,
          !0
        );
        break;
      case "select":
        ge("invalid", n);
        break;
      case "textarea":
        ge("invalid", n), Gs(n, o.value, o.defaultValue, o.children);
    }
    a = o.children, typeof a != "string" && typeof a != "number" && typeof a != "bigint" || n.textContent === "" + a || o.suppressHydrationWarning === !0 || P_(n.textContent, a) ? (o.popover != null && (ge("beforetoggle", n), ge("toggle", n)), o.onScroll != null && ge("scroll", n), o.onScrollEnd != null && ge("scrollend", n), o.onClick != null && (n.onclick = ki), n = !0) : n = !1, n || Sa(e, !0);
  }
  function xm(e) {
    for (An = e.return; An; )
      switch (An.tag) {
        case 5:
        case 31:
        case 13:
          gi = !1;
          return;
        case 27:
        case 3:
          gi = !0;
          return;
        default:
          An = An.return;
      }
  }
  function Qs(e) {
    if (e !== An) return !1;
    if (!be) return xm(e), be = !0, !1;
    var n = e.tag, a;
    if ((a = n !== 3 && n !== 27) && ((a = n === 5) && (a = e.type, a = !(a !== "form" && a !== "button") || gh(e.type, e.memoizedProps)), a = !a), a && je && Sa(e), xm(e), n === 13) {
      if (e = e.memoizedState, e = e !== null ? e.dehydrated : null, !e) throw Error(s(317));
      je = X_(e);
    } else if (n === 31) {
      if (e = e.memoizedState, e = e !== null ? e.dehydrated : null, !e) throw Error(s(317));
      je = X_(e);
    } else
      n === 27 ? (n = je, Pa(e.type) ? (e = Sh, Sh = null, je = e) : je = n) : je = An ? vi(e.stateNode.nextSibling) : null;
    return !0;
  }
  function us() {
    je = An = null, be = !1;
  }
  function Ju() {
    var e = ya;
    return e !== null && (Qn === null ? Qn = e : Qn.push.apply(
      Qn,
      e
    ), ya = null), e;
  }
  function xo(e) {
    ya === null ? ya = [e] : ya.push(e);
  }
  var $u = P(null), fs = null, qi = null;
  function Ma(e, n, a) {
    xt($u, n._currentValue), n._currentValue = a;
  }
  function ji(e) {
    e._currentValue = $u.current, st($u);
  }
  function tf(e, n, a) {
    for (; e !== null; ) {
      var o = e.alternate;
      if ((e.childLanes & n) !== n ? (e.childLanes |= n, o !== null && (o.childLanes |= n)) : o !== null && (o.childLanes & n) !== n && (o.childLanes |= n), e === a) break;
      e = e.return;
    }
  }
  function ef(e, n, a, o) {
    var u = e.child;
    for (u !== null && (u.return = e); u !== null; ) {
      var f = u.dependencies;
      if (f !== null) {
        var y = u.child;
        f = f.firstContext;
        t: for (; f !== null; ) {
          var A = f;
          f = u;
          for (var H = 0; H < n.length; H++)
            if (A.context === n[H]) {
              f.lanes |= a, A = f.alternate, A !== null && (A.lanes |= a), tf(
                f.return,
                a,
                e
              ), o || (y = null);
              break t;
            }
          f = A.next;
        }
      } else if (u.tag === 18) {
        if (y = u.return, y === null) throw Error(s(341));
        y.lanes |= a, f = y.alternate, f !== null && (f.lanes |= a), tf(y, a, e), y = null;
      } else y = u.child;
      if (y !== null) y.return = u;
      else
        for (y = u; y !== null; ) {
          if (y === e) {
            y = null;
            break;
          }
          if (u = y.sibling, u !== null) {
            u.return = y.return, y = u;
            break;
          }
          y = y.return;
        }
      u = y;
    }
  }
  function Js(e, n, a, o) {
    e = null;
    for (var u = n, f = !1; u !== null; ) {
      if (!f) {
        if ((u.flags & 524288) !== 0) f = !0;
        else if ((u.flags & 262144) !== 0) break;
      }
      if (u.tag === 10) {
        var y = u.alternate;
        if (y === null) throw Error(s(387));
        if (y = y.memoizedProps, y !== null) {
          var A = u.type;
          ei(u.pendingProps.value, y.value) || (e !== null ? e.push(A) : e = [A]);
        }
      } else if (u === vt.current) {
        if (y = u.alternate, y === null) throw Error(s(387));
        y.memoizedState.memoizedState !== u.memoizedState.memoizedState && (e !== null ? e.push(Yo) : e = [Yo]);
      }
      u = u.return;
    }
    e !== null && ef(
      n,
      e,
      a,
      o
    ), n.flags |= 262144;
  }
  function wl(e) {
    for (e = e.firstContext; e !== null; ) {
      if (!ei(
        e.context._currentValue,
        e.memoizedValue
      ))
        return !0;
      e = e.next;
    }
    return !1;
  }
  function hs(e) {
    fs = e, qi = null, e = e.dependencies, e !== null && (e.firstContext = null);
  }
  function Rn(e) {
    return ym(fs, e);
  }
  function Dl(e, n) {
    return fs === null && hs(e), ym(e, n);
  }
  function ym(e, n) {
    var a = n._currentValue;
    if (n = { context: n, memoizedValue: a, next: null }, qi === null) {
      if (e === null) throw Error(s(308));
      qi = n, e.dependencies = { lanes: 0, firstContext: n }, e.flags |= 524288;
    } else qi = qi.next = n;
    return a;
  }
  var My = typeof AbortController < "u" ? AbortController : function() {
    var e = [], n = this.signal = {
      aborted: !1,
      addEventListener: function(a, o) {
        e.push(o);
      }
    };
    this.abort = function() {
      n.aborted = !0, e.forEach(function(a) {
        return a();
      });
    };
  }, Ey = r.unstable_scheduleCallback, by = r.unstable_NormalPriority, rn = {
    $$typeof: U,
    Consumer: null,
    Provider: null,
    _currentValue: null,
    _currentValue2: null,
    _threadCount: 0
  };
  function nf() {
    return {
      controller: new My(),
      data: /* @__PURE__ */ new Map(),
      refCount: 0
    };
  }
  function yo(e) {
    e.refCount--, e.refCount === 0 && Ey(by, function() {
      e.controller.abort();
    });
  }
  var So = null, af = 0, $s = 0, tr = null;
  function Ty(e, n) {
    if (So === null) {
      var a = So = [];
      af = 0, $s = oh(), tr = {
        status: "pending",
        value: void 0,
        then: function(o) {
          a.push(o);
        }
      };
    }
    return af++, n.then(Sm, Sm), n;
  }
  function Sm() {
    if (--af === 0 && So !== null) {
      tr !== null && (tr.status = "fulfilled");
      var e = So;
      So = null, $s = 0, tr = null;
      for (var n = 0; n < e.length; n++) (0, e[n])();
    }
  }
  function Ay(e, n) {
    var a = [], o = {
      status: "pending",
      value: null,
      reason: null,
      then: function(u) {
        a.push(u);
      }
    };
    return e.then(
      function() {
        o.status = "fulfilled", o.value = n;
        for (var u = 0; u < a.length; u++) (0, a[u])(n);
      },
      function(u) {
        for (o.status = "rejected", o.reason = u, u = 0; u < a.length; u++)
          (0, a[u])(void 0);
      }
    ), o;
  }
  var Mm = z.S;
  z.S = function(e, n) {
    s_ = dt(), typeof n == "object" && n !== null && typeof n.then == "function" && Ty(e, n), Mm !== null && Mm(e, n);
  };
  var ds = P(null);
  function sf() {
    var e = ds.current;
    return e !== null ? e : Ye.pooledCache;
  }
  function Ul(e, n) {
    n === null ? xt(ds, ds.current) : xt(ds, n.pool);
  }
  function Em() {
    var e = sf();
    return e === null ? null : { parent: rn._currentValue, pool: e };
  }
  var er = Error(s(460)), rf = Error(s(474)), Ll = Error(s(542)), Nl = { then: function() {
  } };
  function bm(e) {
    return e = e.status, e === "fulfilled" || e === "rejected";
  }
  function Tm(e, n, a) {
    switch (a = e[a], a === void 0 ? e.push(n) : a !== n && (n.then(ki, ki), n = a), n.status) {
      case "fulfilled":
        return n.value;
      case "rejected":
        throw e = n.reason, Rm(e), e;
      default:
        if (typeof n.status == "string") n.then(ki, ki);
        else {
          if (e = Ye, e !== null && 100 < e.shellSuspendCounter)
            throw Error(s(482));
          e = n, e.status = "pending", e.then(
            function(o) {
              if (n.status === "pending") {
                var u = n;
                u.status = "fulfilled", u.value = o;
              }
            },
            function(o) {
              if (n.status === "pending") {
                var u = n;
                u.status = "rejected", u.reason = o;
              }
            }
          );
        }
        switch (n.status) {
          case "fulfilled":
            return n.value;
          case "rejected":
            throw e = n.reason, Rm(e), e;
        }
        throw ms = n, er;
    }
  }
  function ps(e) {
    try {
      var n = e._init;
      return n(e._payload);
    } catch (a) {
      throw a !== null && typeof a == "object" && typeof a.then == "function" ? (ms = a, er) : a;
    }
  }
  var ms = null;
  function Am() {
    if (ms === null) throw Error(s(459));
    var e = ms;
    return ms = null, e;
  }
  function Rm(e) {
    if (e === er || e === Ll)
      throw Error(s(483));
  }
  var nr = null, Mo = 0;
  function Ol(e) {
    var n = Mo;
    return Mo += 1, nr === null && (nr = []), Tm(nr, e, n);
  }
  function Eo(e, n) {
    n = n.props.ref, e.ref = n !== void 0 ? n : null;
  }
  function Pl(e, n) {
    throw n.$$typeof === x ? Error(s(525)) : (e = Object.prototype.toString.call(n), Error(
      s(
        31,
        e === "[object Object]" ? "object with keys {" + Object.keys(n).join(", ") + "}" : e
      )
    ));
  }
  function Cm(e) {
    function n(Z, k) {
      if (e) {
        var et = Z.deletions;
        et === null ? (Z.deletions = [k], Z.flags |= 16) : et.push(k);
      }
    }
    function a(Z, k) {
      if (!e) return null;
      for (; k !== null; )
        n(Z, k), k = k.sibling;
      return null;
    }
    function o(Z) {
      for (var k = /* @__PURE__ */ new Map(); Z !== null; )
        Z.key !== null ? k.set(Z.key, Z) : k.set(Z.index, Z), Z = Z.sibling;
      return k;
    }
    function u(Z, k) {
      return Z = Wi(Z, k), Z.index = 0, Z.sibling = null, Z;
    }
    function f(Z, k, et) {
      return Z.index = et, e ? (et = Z.alternate, et !== null ? (et = et.index, et < k ? (Z.flags |= 67108866, k) : et) : (Z.flags |= 67108866, k)) : (Z.flags |= 1048576, k);
    }
    function y(Z) {
      return e && Z.alternate === null && (Z.flags |= 67108866), Z;
    }
    function A(Z, k, et, mt) {
      return k === null || k.tag !== 6 ? (k = qu(et, Z.mode, mt), k.return = Z, k) : (k = u(k, et), k.return = Z, k);
    }
    function H(Z, k, et, mt) {
      var Kt = et.type;
      return Kt === b ? ft(
        Z,
        k,
        et.props.children,
        mt,
        et.key
      ) : k !== null && (k.elementType === Kt || typeof Kt == "object" && Kt !== null && Kt.$$typeof === G && ps(Kt) === k.type) ? (k = u(k, et.props), Eo(k, et), k.return = Z, k) : (k = Rl(
        et.type,
        et.key,
        et.props,
        null,
        Z.mode,
        mt
      ), Eo(k, et), k.return = Z, k);
    }
    function nt(Z, k, et, mt) {
      return k === null || k.tag !== 4 || k.stateNode.containerInfo !== et.containerInfo || k.stateNode.implementation !== et.implementation ? (k = ju(et, Z.mode, mt), k.return = Z, k) : (k = u(k, et.children || []), k.return = Z, k);
    }
    function ft(Z, k, et, mt, Kt) {
      return k === null || k.tag !== 7 ? (k = cs(
        et,
        Z.mode,
        mt,
        Kt
      ), k.return = Z, k) : (k = u(k, et), k.return = Z, k);
    }
    function gt(Z, k, et) {
      if (typeof k == "string" && k !== "" || typeof k == "number" || typeof k == "bigint")
        return k = qu(
          "" + k,
          Z.mode,
          et
        ), k.return = Z, k;
      if (typeof k == "object" && k !== null) {
        switch (k.$$typeof) {
          case S:
            return et = Rl(
              k.type,
              k.key,
              k.props,
              null,
              Z.mode,
              et
            ), Eo(et, k), et.return = Z, et;
          case E:
            return k = ju(
              k,
              Z.mode,
              et
            ), k.return = Z, k;
          case G:
            return k = ps(k), gt(Z, k, et);
        }
        if (pt(k) || J(k))
          return k = cs(
            k,
            Z.mode,
            et,
            null
          ), k.return = Z, k;
        if (typeof k.then == "function")
          return gt(Z, Ol(k), et);
        if (k.$$typeof === U)
          return gt(
            Z,
            Dl(Z, k),
            et
          );
        Pl(Z, k);
      }
      return null;
    }
    function at(Z, k, et, mt) {
      var Kt = k !== null ? k.key : null;
      if (typeof et == "string" && et !== "" || typeof et == "number" || typeof et == "bigint")
        return Kt !== null ? null : A(Z, k, "" + et, mt);
      if (typeof et == "object" && et !== null) {
        switch (et.$$typeof) {
          case S:
            return et.key === Kt ? H(Z, k, et, mt) : null;
          case E:
            return et.key === Kt ? nt(Z, k, et, mt) : null;
          case G:
            return et = ps(et), at(Z, k, et, mt);
        }
        if (pt(et) || J(et))
          return Kt !== null ? null : ft(Z, k, et, mt, null);
        if (typeof et.then == "function")
          return at(
            Z,
            k,
            Ol(et),
            mt
          );
        if (et.$$typeof === U)
          return at(
            Z,
            k,
            Dl(Z, et),
            mt
          );
        Pl(Z, et);
      }
      return null;
    }
    function ct(Z, k, et, mt, Kt) {
      if (typeof mt == "string" && mt !== "" || typeof mt == "number" || typeof mt == "bigint")
        return Z = Z.get(et) || null, A(k, Z, "" + mt, Kt);
      if (typeof mt == "object" && mt !== null) {
        switch (mt.$$typeof) {
          case S:
            return Z = Z.get(
              mt.key === null ? et : mt.key
            ) || null, H(k, Z, mt, Kt);
          case E:
            return Z = Z.get(
              mt.key === null ? et : mt.key
            ) || null, nt(k, Z, mt, Kt);
          case G:
            return mt = ps(mt), ct(
              Z,
              k,
              et,
              mt,
              Kt
            );
        }
        if (pt(mt) || J(mt))
          return Z = Z.get(et) || null, ft(k, Z, mt, Kt, null);
        if (typeof mt.then == "function")
          return ct(
            Z,
            k,
            et,
            Ol(mt),
            Kt
          );
        if (mt.$$typeof === U)
          return ct(
            Z,
            k,
            et,
            Dl(k, mt),
            Kt
          );
        Pl(k, mt);
      }
      return null;
    }
    function Vt(Z, k, et, mt) {
      for (var Kt = null, Ce = null, kt = k, ce = k = 0, Se = null; kt !== null && ce < et.length; ce++) {
        kt.index > ce ? (Se = kt, kt = null) : Se = kt.sibling;
        var we = at(
          Z,
          kt,
          et[ce],
          mt
        );
        if (we === null) {
          kt === null && (kt = Se);
          break;
        }
        e && kt && we.alternate === null && n(Z, kt), k = f(we, k, ce), Ce === null ? Kt = we : Ce.sibling = we, Ce = we, kt = Se;
      }
      if (ce === et.length)
        return a(Z, kt), be && Yi(Z, ce), Kt;
      if (kt === null) {
        for (; ce < et.length; ce++)
          kt = gt(Z, et[ce], mt), kt !== null && (k = f(
            kt,
            k,
            ce
          ), Ce === null ? Kt = kt : Ce.sibling = kt, Ce = kt);
        return be && Yi(Z, ce), Kt;
      }
      for (kt = o(kt); ce < et.length; ce++)
        Se = ct(
          kt,
          Z,
          ce,
          et[ce],
          mt
        ), Se !== null && (e && Se.alternate !== null && kt.delete(
          Se.key === null ? ce : Se.key
        ), k = f(
          Se,
          k,
          ce
        ), Ce === null ? Kt = Se : Ce.sibling = Se, Ce = Se);
      return e && kt.forEach(function(Ha) {
        return n(Z, Ha);
      }), be && Yi(Z, ce), Kt;
    }
    function Jt(Z, k, et, mt) {
      if (et == null) throw Error(s(151));
      for (var Kt = null, Ce = null, kt = k, ce = k = 0, Se = null, we = et.next(); kt !== null && !we.done; ce++, we = et.next()) {
        kt.index > ce ? (Se = kt, kt = null) : Se = kt.sibling;
        var Ha = at(Z, kt, we.value, mt);
        if (Ha === null) {
          kt === null && (kt = Se);
          break;
        }
        e && kt && Ha.alternate === null && n(Z, kt), k = f(Ha, k, ce), Ce === null ? Kt = Ha : Ce.sibling = Ha, Ce = Ha, kt = Se;
      }
      if (we.done)
        return a(Z, kt), be && Yi(Z, ce), Kt;
      if (kt === null) {
        for (; !we.done; ce++, we = et.next())
          we = gt(Z, we.value, mt), we !== null && (k = f(we, k, ce), Ce === null ? Kt = we : Ce.sibling = we, Ce = we);
        return be && Yi(Z, ce), Kt;
      }
      for (kt = o(kt); !we.done; ce++, we = et.next())
        we = ct(kt, Z, ce, we.value, mt), we !== null && (e && we.alternate !== null && kt.delete(we.key === null ? ce : we.key), k = f(we, k, ce), Ce === null ? Kt = we : Ce.sibling = we, Ce = we);
      return e && kt.forEach(function(BS) {
        return n(Z, BS);
      }), be && Yi(Z, ce), Kt;
    }
    function He(Z, k, et, mt) {
      if (typeof et == "object" && et !== null && et.type === b && et.key === null && (et = et.props.children), typeof et == "object" && et !== null) {
        switch (et.$$typeof) {
          case S:
            t: {
              for (var Kt = et.key; k !== null; ) {
                if (k.key === Kt) {
                  if (Kt = et.type, Kt === b) {
                    if (k.tag === 7) {
                      a(
                        Z,
                        k.sibling
                      ), mt = u(
                        k,
                        et.props.children
                      ), mt.return = Z, Z = mt;
                      break t;
                    }
                  } else if (k.elementType === Kt || typeof Kt == "object" && Kt !== null && Kt.$$typeof === G && ps(Kt) === k.type) {
                    a(
                      Z,
                      k.sibling
                    ), mt = u(k, et.props), Eo(mt, et), mt.return = Z, Z = mt;
                    break t;
                  }
                  a(Z, k);
                  break;
                } else n(Z, k);
                k = k.sibling;
              }
              et.type === b ? (mt = cs(
                et.props.children,
                Z.mode,
                mt,
                et.key
              ), mt.return = Z, Z = mt) : (mt = Rl(
                et.type,
                et.key,
                et.props,
                null,
                Z.mode,
                mt
              ), Eo(mt, et), mt.return = Z, Z = mt);
            }
            return y(Z);
          case E:
            t: {
              for (Kt = et.key; k !== null; ) {
                if (k.key === Kt)
                  if (k.tag === 4 && k.stateNode.containerInfo === et.containerInfo && k.stateNode.implementation === et.implementation) {
                    a(
                      Z,
                      k.sibling
                    ), mt = u(k, et.children || []), mt.return = Z, Z = mt;
                    break t;
                  } else {
                    a(Z, k);
                    break;
                  }
                else n(Z, k);
                k = k.sibling;
              }
              mt = ju(et, Z.mode, mt), mt.return = Z, Z = mt;
            }
            return y(Z);
          case G:
            return et = ps(et), He(
              Z,
              k,
              et,
              mt
            );
        }
        if (pt(et))
          return Vt(
            Z,
            k,
            et,
            mt
          );
        if (J(et)) {
          if (Kt = J(et), typeof Kt != "function") throw Error(s(150));
          return et = Kt.call(et), Jt(
            Z,
            k,
            et,
            mt
          );
        }
        if (typeof et.then == "function")
          return He(
            Z,
            k,
            Ol(et),
            mt
          );
        if (et.$$typeof === U)
          return He(
            Z,
            k,
            Dl(Z, et),
            mt
          );
        Pl(Z, et);
      }
      return typeof et == "string" && et !== "" || typeof et == "number" || typeof et == "bigint" ? (et = "" + et, k !== null && k.tag === 6 ? (a(Z, k.sibling), mt = u(k, et), mt.return = Z, Z = mt) : (a(Z, k), mt = qu(et, Z.mode, mt), mt.return = Z, Z = mt), y(Z)) : a(Z, k);
    }
    return function(Z, k, et, mt) {
      try {
        Mo = 0;
        var Kt = He(
          Z,
          k,
          et,
          mt
        );
        return nr = null, Kt;
      } catch (kt) {
        if (kt === er || kt === Ll) throw kt;
        var Ce = ni(29, kt, null, Z.mode);
        return Ce.lanes = mt, Ce.return = Z, Ce;
      } finally {
      }
    };
  }
  var gs = Cm(!0), wm = Cm(!1), Ea = !1;
  function of(e) {
    e.updateQueue = {
      baseState: e.memoizedState,
      firstBaseUpdate: null,
      lastBaseUpdate: null,
      shared: { pending: null, lanes: 0, hiddenCallbacks: null },
      callbacks: null
    };
  }
  function lf(e, n) {
    e = e.updateQueue, n.updateQueue === e && (n.updateQueue = {
      baseState: e.baseState,
      firstBaseUpdate: e.firstBaseUpdate,
      lastBaseUpdate: e.lastBaseUpdate,
      shared: e.shared,
      callbacks: null
    });
  }
  function ba(e) {
    return { lane: e, tag: 0, payload: null, callback: null, next: null };
  }
  function Ta(e, n, a) {
    var o = e.updateQueue;
    if (o === null) return null;
    if (o = o.shared, (Le & 2) !== 0) {
      var u = o.pending;
      return u === null ? n.next = n : (n.next = u.next, u.next = n), o.pending = n, n = Al(e), hm(e, null, a), n;
    }
    return Tl(e, o, n, a), Al(e);
  }
  function bo(e, n, a) {
    if (n = n.updateQueue, n !== null && (n = n.shared, (a & 4194048) !== 0)) {
      var o = n.lanes;
      o &= e.pendingLanes, a |= o, n.lanes = a, ao(e, a);
    }
  }
  function cf(e, n) {
    var a = e.updateQueue, o = e.alternate;
    if (o !== null && (o = o.updateQueue, a === o)) {
      var u = null, f = null;
      if (a = a.firstBaseUpdate, a !== null) {
        do {
          var y = {
            lane: a.lane,
            tag: a.tag,
            payload: a.payload,
            callback: null,
            next: null
          };
          f === null ? u = f = y : f = f.next = y, a = a.next;
        } while (a !== null);
        f === null ? u = f = n : f = f.next = n;
      } else u = f = n;
      a = {
        baseState: o.baseState,
        firstBaseUpdate: u,
        lastBaseUpdate: f,
        shared: o.shared,
        callbacks: o.callbacks
      }, e.updateQueue = a;
      return;
    }
    e = a.lastBaseUpdate, e === null ? a.firstBaseUpdate = n : e.next = n, a.lastBaseUpdate = n;
  }
  var uf = !1;
  function To() {
    if (uf) {
      var e = tr;
      if (e !== null) throw e;
    }
  }
  function Ao(e, n, a, o) {
    uf = !1;
    var u = e.updateQueue;
    Ea = !1;
    var f = u.firstBaseUpdate, y = u.lastBaseUpdate, A = u.shared.pending;
    if (A !== null) {
      u.shared.pending = null;
      var H = A, nt = H.next;
      H.next = null, y === null ? f = nt : y.next = nt, y = H;
      var ft = e.alternate;
      ft !== null && (ft = ft.updateQueue, A = ft.lastBaseUpdate, A !== y && (A === null ? ft.firstBaseUpdate = nt : A.next = nt, ft.lastBaseUpdate = H));
    }
    if (f !== null) {
      var gt = u.baseState;
      y = 0, ft = nt = H = null, A = f;
      do {
        var at = A.lane & -536870913, ct = at !== A.lane;
        if (ct ? (ye & at) === at : (o & at) === at) {
          at !== 0 && at === $s && (uf = !0), ft !== null && (ft = ft.next = {
            lane: 0,
            tag: A.tag,
            payload: A.payload,
            callback: null,
            next: null
          });
          t: {
            var Vt = e, Jt = A;
            at = n;
            var He = a;
            switch (Jt.tag) {
              case 1:
                if (Vt = Jt.payload, typeof Vt == "function") {
                  gt = Vt.call(He, gt, at);
                  break t;
                }
                gt = Vt;
                break t;
              case 3:
                Vt.flags = Vt.flags & -65537 | 128;
              case 0:
                if (Vt = Jt.payload, at = typeof Vt == "function" ? Vt.call(He, gt, at) : Vt, at == null) break t;
                gt = _({}, gt, at);
                break t;
              case 2:
                Ea = !0;
            }
          }
          at = A.callback, at !== null && (e.flags |= 64, ct && (e.flags |= 8192), ct = u.callbacks, ct === null ? u.callbacks = [at] : ct.push(at));
        } else
          ct = {
            lane: at,
            tag: A.tag,
            payload: A.payload,
            callback: A.callback,
            next: null
          }, ft === null ? (nt = ft = ct, H = gt) : ft = ft.next = ct, y |= at;
        if (A = A.next, A === null) {
          if (A = u.shared.pending, A === null)
            break;
          ct = A, A = ct.next, ct.next = null, u.lastBaseUpdate = ct, u.shared.pending = null;
        }
      } while (!0);
      ft === null && (H = gt), u.baseState = H, u.firstBaseUpdate = nt, u.lastBaseUpdate = ft, f === null && (u.shared.lanes = 0), Da |= y, e.lanes = y, e.memoizedState = gt;
    }
  }
  function Dm(e, n) {
    if (typeof e != "function")
      throw Error(s(191, e));
    e.call(n);
  }
  function Um(e, n) {
    var a = e.callbacks;
    if (a !== null)
      for (e.callbacks = null, e = 0; e < a.length; e++)
        Dm(a[e], n);
  }
  var ir = P(null), zl = P(0);
  function Lm(e, n) {
    e = ia, xt(zl, e), xt(ir, n), ia = e | n.baseLanes;
  }
  function ff() {
    xt(zl, ia), xt(ir, ir.current);
  }
  function hf() {
    ia = zl.current, st(ir), st(zl);
  }
  var ii = P(null), _i = null;
  function Aa(e) {
    var n = e.alternate;
    xt(an, an.current & 1), xt(ii, e), _i === null && (n === null || ir.current !== null || n.memoizedState !== null) && (_i = e);
  }
  function df(e) {
    xt(an, an.current), xt(ii, e), _i === null && (_i = e);
  }
  function Nm(e) {
    e.tag === 22 ? (xt(an, an.current), xt(ii, e), _i === null && (_i = e)) : Ra();
  }
  function Ra() {
    xt(an, an.current), xt(ii, ii.current);
  }
  function ai(e) {
    st(ii), _i === e && (_i = null), st(an);
  }
  var an = P(0);
  function Bl(e) {
    for (var n = e; n !== null; ) {
      if (n.tag === 13) {
        var a = n.memoizedState;
        if (a !== null && (a = a.dehydrated, a === null || xh(a) || yh(a)))
          return n;
      } else if (n.tag === 19 && (n.memoizedProps.revealOrder === "forwards" || n.memoizedProps.revealOrder === "backwards" || n.memoizedProps.revealOrder === "unstable_legacy-backwards" || n.memoizedProps.revealOrder === "together")) {
        if ((n.flags & 128) !== 0) return n;
      } else if (n.child !== null) {
        n.child.return = n, n = n.child;
        continue;
      }
      if (n === e) break;
      for (; n.sibling === null; ) {
        if (n.return === null || n.return === e) return null;
        n = n.return;
      }
      n.sibling.return = n.return, n = n.sibling;
    }
    return null;
  }
  var Zi = 0, le = null, Ie = null, on = null, Il = !1, ar = !1, _s = !1, Fl = 0, Ro = 0, sr = null, Ry = 0;
  function en() {
    throw Error(s(321));
  }
  function pf(e, n) {
    if (n === null) return !1;
    for (var a = 0; a < n.length && a < e.length; a++)
      if (!ei(e[a], n[a])) return !1;
    return !0;
  }
  function mf(e, n, a, o, u, f) {
    return Zi = f, le = n, n.memoizedState = null, n.updateQueue = null, n.lanes = 0, z.H = e === null || e.memoizedState === null ? gg : Df, _s = !1, f = a(o, u), _s = !1, ar && (f = Pm(
      n,
      a,
      o,
      u
    )), Om(e), f;
  }
  function Om(e) {
    z.H = Do;
    var n = Ie !== null && Ie.next !== null;
    if (Zi = 0, on = Ie = le = null, Il = !1, Ro = 0, sr = null, n) throw Error(s(300));
    e === null || ln || (e = e.dependencies, e !== null && wl(e) && (ln = !0));
  }
  function Pm(e, n, a, o) {
    le = e;
    var u = 0;
    do {
      if (ar && (sr = null), Ro = 0, ar = !1, 25 <= u) throw Error(s(301));
      if (u += 1, on = Ie = null, e.updateQueue != null) {
        var f = e.updateQueue;
        f.lastEffect = null, f.events = null, f.stores = null, f.memoCache != null && (f.memoCache.index = 0);
      }
      z.H = _g, f = n(a, o);
    } while (ar);
    return f;
  }
  function Cy() {
    var e = z.H, n = e.useState()[0];
    return n = typeof n.then == "function" ? Co(n) : n, e = e.useState()[0], (Ie !== null ? Ie.memoizedState : null) !== e && (le.flags |= 1024), n;
  }
  function gf() {
    var e = Fl !== 0;
    return Fl = 0, e;
  }
  function _f(e, n, a) {
    n.updateQueue = e.updateQueue, n.flags &= -2053, e.lanes &= ~a;
  }
  function vf(e) {
    if (Il) {
      for (e = e.memoizedState; e !== null; ) {
        var n = e.queue;
        n !== null && (n.pending = null), e = e.next;
      }
      Il = !1;
    }
    Zi = 0, on = Ie = le = null, ar = !1, Ro = Fl = 0, sr = null;
  }
  function Hn() {
    var e = {
      memoizedState: null,
      baseState: null,
      baseQueue: null,
      queue: null,
      next: null
    };
    return on === null ? le.memoizedState = on = e : on = on.next = e, on;
  }
  function sn() {
    if (Ie === null) {
      var e = le.alternate;
      e = e !== null ? e.memoizedState : null;
    } else e = Ie.next;
    var n = on === null ? le.memoizedState : on.next;
    if (n !== null)
      on = n, Ie = e;
    else {
      if (e === null)
        throw le.alternate === null ? Error(s(467)) : Error(s(310));
      Ie = e, e = {
        memoizedState: Ie.memoizedState,
        baseState: Ie.baseState,
        baseQueue: Ie.baseQueue,
        queue: Ie.queue,
        next: null
      }, on === null ? le.memoizedState = on = e : on = on.next = e;
    }
    return on;
  }
  function Hl() {
    return { lastEffect: null, events: null, stores: null, memoCache: null };
  }
  function Co(e) {
    var n = Ro;
    return Ro += 1, sr === null && (sr = []), e = Tm(sr, e, n), n = le, (on === null ? n.memoizedState : on.next) === null && (n = n.alternate, z.H = n === null || n.memoizedState === null ? gg : Df), e;
  }
  function Gl(e) {
    if (e !== null && typeof e == "object") {
      if (typeof e.then == "function") return Co(e);
      if (e.$$typeof === U) return Rn(e);
    }
    throw Error(s(438, String(e)));
  }
  function xf(e) {
    var n = null, a = le.updateQueue;
    if (a !== null && (n = a.memoCache), n == null) {
      var o = le.alternate;
      o !== null && (o = o.updateQueue, o !== null && (o = o.memoCache, o != null && (n = {
        data: o.data.map(function(u) {
          return u.slice();
        }),
        index: 0
      })));
    }
    if (n == null && (n = { data: [], index: 0 }), a === null && (a = Hl(), le.updateQueue = a), a.memoCache = n, a = n.data[n.index], a === void 0)
      for (a = n.data[n.index] = Array(e), o = 0; o < e; o++)
        a[o] = T;
    return n.index++, a;
  }
  function Ki(e, n) {
    return typeof n == "function" ? n(e) : n;
  }
  function Vl(e) {
    var n = sn();
    return yf(n, Ie, e);
  }
  function yf(e, n, a) {
    var o = e.queue;
    if (o === null) throw Error(s(311));
    o.lastRenderedReducer = a;
    var u = e.baseQueue, f = o.pending;
    if (f !== null) {
      if (u !== null) {
        var y = u.next;
        u.next = f.next, f.next = y;
      }
      n.baseQueue = u = f, o.pending = null;
    }
    if (f = e.baseState, u === null) e.memoizedState = f;
    else {
      n = u.next;
      var A = y = null, H = null, nt = n, ft = !1;
      do {
        var gt = nt.lane & -536870913;
        if (gt !== nt.lane ? (ye & gt) === gt : (Zi & gt) === gt) {
          var at = nt.revertLane;
          if (at === 0)
            H !== null && (H = H.next = {
              lane: 0,
              revertLane: 0,
              gesture: null,
              action: nt.action,
              hasEagerState: nt.hasEagerState,
              eagerState: nt.eagerState,
              next: null
            }), gt === $s && (ft = !0);
          else if ((Zi & at) === at) {
            nt = nt.next, at === $s && (ft = !0);
            continue;
          } else
            gt = {
              lane: 0,
              revertLane: nt.revertLane,
              gesture: null,
              action: nt.action,
              hasEagerState: nt.hasEagerState,
              eagerState: nt.eagerState,
              next: null
            }, H === null ? (A = H = gt, y = f) : H = H.next = gt, le.lanes |= at, Da |= at;
          gt = nt.action, _s && a(f, gt), f = nt.hasEagerState ? nt.eagerState : a(f, gt);
        } else
          at = {
            lane: gt,
            revertLane: nt.revertLane,
            gesture: nt.gesture,
            action: nt.action,
            hasEagerState: nt.hasEagerState,
            eagerState: nt.eagerState,
            next: null
          }, H === null ? (A = H = at, y = f) : H = H.next = at, le.lanes |= gt, Da |= gt;
        nt = nt.next;
      } while (nt !== null && nt !== n);
      if (H === null ? y = f : H.next = A, !ei(f, e.memoizedState) && (ln = !0, ft && (a = tr, a !== null)))
        throw a;
      e.memoizedState = f, e.baseState = y, e.baseQueue = H, o.lastRenderedState = f;
    }
    return u === null && (o.lanes = 0), [e.memoizedState, o.dispatch];
  }
  function Sf(e) {
    var n = sn(), a = n.queue;
    if (a === null) throw Error(s(311));
    a.lastRenderedReducer = e;
    var o = a.dispatch, u = a.pending, f = n.memoizedState;
    if (u !== null) {
      a.pending = null;
      var y = u = u.next;
      do
        f = e(f, y.action), y = y.next;
      while (y !== u);
      ei(f, n.memoizedState) || (ln = !0), n.memoizedState = f, n.baseQueue === null && (n.baseState = f), a.lastRenderedState = f;
    }
    return [f, o];
  }
  function zm(e, n, a) {
    var o = le, u = sn(), f = be;
    if (f) {
      if (a === void 0) throw Error(s(407));
      a = a();
    } else a = n();
    var y = !ei(
      (Ie || u).memoizedState,
      a
    );
    if (y && (u.memoizedState = a, ln = !0), u = u.queue, bf(Fm.bind(null, o, u, e), [
      e
    ]), u.getSnapshot !== n || y || on !== null && on.memoizedState.tag & 1) {
      if (o.flags |= 2048, rr(
        9,
        { destroy: void 0 },
        Im.bind(
          null,
          o,
          u,
          a,
          n
        ),
        null
      ), Ye === null) throw Error(s(349));
      f || (Zi & 127) !== 0 || Bm(o, n, a);
    }
    return a;
  }
  function Bm(e, n, a) {
    e.flags |= 16384, e = { getSnapshot: n, value: a }, n = le.updateQueue, n === null ? (n = Hl(), le.updateQueue = n, n.stores = [e]) : (a = n.stores, a === null ? n.stores = [e] : a.push(e));
  }
  function Im(e, n, a, o) {
    n.value = a, n.getSnapshot = o, Hm(n) && Gm(e);
  }
  function Fm(e, n, a) {
    return a(function() {
      Hm(n) && Gm(e);
    });
  }
  function Hm(e) {
    var n = e.getSnapshot;
    e = e.value;
    try {
      var a = n();
      return !ei(e, a);
    } catch {
      return !0;
    }
  }
  function Gm(e) {
    var n = ls(e, 2);
    n !== null && Jn(n, e, 2);
  }
  function Mf(e) {
    var n = Hn();
    if (typeof e == "function") {
      var a = e;
      if (e = a(), _s) {
        It(!0);
        try {
          a();
        } finally {
          It(!1);
        }
      }
    }
    return n.memoizedState = n.baseState = e, n.queue = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: Ki,
      lastRenderedState: e
    }, n;
  }
  function Vm(e, n, a, o) {
    return e.baseState = a, yf(
      e,
      Ie,
      typeof o == "function" ? o : Ki
    );
  }
  function wy(e, n, a, o, u) {
    if (Wl(e)) throw Error(s(485));
    if (e = n.action, e !== null) {
      var f = {
        payload: u,
        action: e,
        next: null,
        isTransition: !0,
        status: "pending",
        value: null,
        reason: null,
        listeners: [],
        then: function(y) {
          f.listeners.push(y);
        }
      };
      z.T !== null ? a(!0) : f.isTransition = !1, o(f), a = n.pending, a === null ? (f.next = n.pending = f, km(n, f)) : (f.next = a.next, n.pending = a.next = f);
    }
  }
  function km(e, n) {
    var a = n.action, o = n.payload, u = e.state;
    if (n.isTransition) {
      var f = z.T, y = {};
      z.T = y;
      try {
        var A = a(u, o), H = z.S;
        H !== null && H(y, A), Xm(e, n, A);
      } catch (nt) {
        Ef(e, n, nt);
      } finally {
        f !== null && y.types !== null && (f.types = y.types), z.T = f;
      }
    } else
      try {
        f = a(u, o), Xm(e, n, f);
      } catch (nt) {
        Ef(e, n, nt);
      }
  }
  function Xm(e, n, a) {
    a !== null && typeof a == "object" && typeof a.then == "function" ? a.then(
      function(o) {
        Wm(e, n, o);
      },
      function(o) {
        return Ef(e, n, o);
      }
    ) : Wm(e, n, a);
  }
  function Wm(e, n, a) {
    n.status = "fulfilled", n.value = a, Ym(n), e.state = a, n = e.pending, n !== null && (a = n.next, a === n ? e.pending = null : (a = a.next, n.next = a, km(e, a)));
  }
  function Ef(e, n, a) {
    var o = e.pending;
    if (e.pending = null, o !== null) {
      o = o.next;
      do
        n.status = "rejected", n.reason = a, Ym(n), n = n.next;
      while (n !== o);
    }
    e.action = null;
  }
  function Ym(e) {
    e = e.listeners;
    for (var n = 0; n < e.length; n++) (0, e[n])();
  }
  function qm(e, n) {
    return n;
  }
  function jm(e, n) {
    if (be) {
      var a = Ye.formState;
      if (a !== null) {
        t: {
          var o = le;
          if (be) {
            if (je) {
              e: {
                for (var u = je, f = gi; u.nodeType !== 8; ) {
                  if (!f) {
                    u = null;
                    break e;
                  }
                  if (u = vi(
                    u.nextSibling
                  ), u === null) {
                    u = null;
                    break e;
                  }
                }
                f = u.data, u = f === "F!" || f === "F" ? u : null;
              }
              if (u) {
                je = vi(
                  u.nextSibling
                ), o = u.data === "F!";
                break t;
              }
            }
            Sa(o);
          }
          o = !1;
        }
        o && (n = a[0]);
      }
    }
    return a = Hn(), a.memoizedState = a.baseState = n, o = {
      pending: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: qm,
      lastRenderedState: n
    }, a.queue = o, a = dg.bind(
      null,
      le,
      o
    ), o.dispatch = a, o = Mf(!1), f = wf.bind(
      null,
      le,
      !1,
      o.queue
    ), o = Hn(), u = {
      state: n,
      dispatch: null,
      action: e,
      pending: null
    }, o.queue = u, a = wy.bind(
      null,
      le,
      u,
      f,
      a
    ), u.dispatch = a, o.memoizedState = e, [n, a, !1];
  }
  function Zm(e) {
    var n = sn();
    return Km(n, Ie, e);
  }
  function Km(e, n, a) {
    if (n = yf(
      e,
      n,
      qm
    )[0], e = Vl(Ki)[0], typeof n == "object" && n !== null && typeof n.then == "function")
      try {
        var o = Co(n);
      } catch (y) {
        throw y === er ? Ll : y;
      }
    else o = n;
    n = sn();
    var u = n.queue, f = u.dispatch;
    return a !== n.memoizedState && (le.flags |= 2048, rr(
      9,
      { destroy: void 0 },
      Dy.bind(null, u, a),
      null
    )), [o, f, e];
  }
  function Dy(e, n) {
    e.action = n;
  }
  function Qm(e) {
    var n = sn(), a = Ie;
    if (a !== null)
      return Km(n, a, e);
    sn(), n = n.memoizedState, a = sn();
    var o = a.queue.dispatch;
    return a.memoizedState = e, [n, o, !1];
  }
  function rr(e, n, a, o) {
    return e = { tag: e, create: a, deps: o, inst: n, next: null }, n = le.updateQueue, n === null && (n = Hl(), le.updateQueue = n), a = n.lastEffect, a === null ? n.lastEffect = e.next = e : (o = a.next, a.next = e, e.next = o, n.lastEffect = e), e;
  }
  function Jm() {
    return sn().memoizedState;
  }
  function kl(e, n, a, o) {
    var u = Hn();
    le.flags |= e, u.memoizedState = rr(
      1 | n,
      { destroy: void 0 },
      a,
      o === void 0 ? null : o
    );
  }
  function Xl(e, n, a, o) {
    var u = sn();
    o = o === void 0 ? null : o;
    var f = u.memoizedState.inst;
    Ie !== null && o !== null && pf(o, Ie.memoizedState.deps) ? u.memoizedState = rr(n, f, a, o) : (le.flags |= e, u.memoizedState = rr(
      1 | n,
      f,
      a,
      o
    ));
  }
  function $m(e, n) {
    kl(8390656, 8, e, n);
  }
  function bf(e, n) {
    Xl(2048, 8, e, n);
  }
  function Uy(e) {
    le.flags |= 4;
    var n = le.updateQueue;
    if (n === null)
      n = Hl(), le.updateQueue = n, n.events = [e];
    else {
      var a = n.events;
      a === null ? n.events = [e] : a.push(e);
    }
  }
  function tg(e) {
    var n = sn().memoizedState;
    return Uy({ ref: n, nextImpl: e }), function() {
      if ((Le & 2) !== 0) throw Error(s(440));
      return n.impl.apply(void 0, arguments);
    };
  }
  function eg(e, n) {
    return Xl(4, 2, e, n);
  }
  function ng(e, n) {
    return Xl(4, 4, e, n);
  }
  function ig(e, n) {
    if (typeof n == "function") {
      e = e();
      var a = n(e);
      return function() {
        typeof a == "function" ? a() : n(null);
      };
    }
    if (n != null)
      return e = e(), n.current = e, function() {
        n.current = null;
      };
  }
  function ag(e, n, a) {
    a = a != null ? a.concat([e]) : null, Xl(4, 4, ig.bind(null, n, e), a);
  }
  function Tf() {
  }
  function sg(e, n) {
    var a = sn();
    n = n === void 0 ? null : n;
    var o = a.memoizedState;
    return n !== null && pf(n, o[1]) ? o[0] : (a.memoizedState = [e, n], e);
  }
  function rg(e, n) {
    var a = sn();
    n = n === void 0 ? null : n;
    var o = a.memoizedState;
    if (n !== null && pf(n, o[1]))
      return o[0];
    if (o = e(), _s) {
      It(!0);
      try {
        e();
      } finally {
        It(!1);
      }
    }
    return a.memoizedState = [o, n], o;
  }
  function Af(e, n, a) {
    return a === void 0 || (Zi & 1073741824) !== 0 && (ye & 261930) === 0 ? e.memoizedState = n : (e.memoizedState = a, e = o_(), le.lanes |= e, Da |= e, a);
  }
  function og(e, n, a, o) {
    return ei(a, n) ? a : ir.current !== null ? (e = Af(e, a, o), ei(e, n) || (ln = !0), e) : (Zi & 42) === 0 || (Zi & 1073741824) !== 0 && (ye & 261930) === 0 ? (ln = !0, e.memoizedState = a) : (e = o_(), le.lanes |= e, Da |= e, n);
  }
  function lg(e, n, a, o, u) {
    var f = tt.p;
    tt.p = f !== 0 && 8 > f ? f : 8;
    var y = z.T, A = {};
    z.T = A, wf(e, !1, n, a);
    try {
      var H = u(), nt = z.S;
      if (nt !== null && nt(A, H), H !== null && typeof H == "object" && typeof H.then == "function") {
        var ft = Ay(
          H,
          o
        );
        wo(
          e,
          n,
          ft,
          oi(e)
        );
      } else
        wo(
          e,
          n,
          o,
          oi(e)
        );
    } catch (gt) {
      wo(
        e,
        n,
        { then: function() {
        }, status: "rejected", reason: gt },
        oi()
      );
    } finally {
      tt.p = f, y !== null && A.types !== null && (y.types = A.types), z.T = y;
    }
  }
  function Ly() {
  }
  function Rf(e, n, a, o) {
    if (e.tag !== 5) throw Error(s(476));
    var u = cg(e).queue;
    lg(
      e,
      u,
      n,
      K,
      a === null ? Ly : function() {
        return ug(e), a(o);
      }
    );
  }
  function cg(e) {
    var n = e.memoizedState;
    if (n !== null) return n;
    n = {
      memoizedState: K,
      baseState: K,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: Ki,
        lastRenderedState: K
      },
      next: null
    };
    var a = {};
    return n.next = {
      memoizedState: a,
      baseState: a,
      baseQueue: null,
      queue: {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: Ki,
        lastRenderedState: a
      },
      next: null
    }, e.memoizedState = n, e = e.alternate, e !== null && (e.memoizedState = n), n;
  }
  function ug(e) {
    var n = cg(e);
    n.next === null && (n = e.alternate.memoizedState), wo(
      e,
      n.next.queue,
      {},
      oi()
    );
  }
  function Cf() {
    return Rn(Yo);
  }
  function fg() {
    return sn().memoizedState;
  }
  function hg() {
    return sn().memoizedState;
  }
  function Ny(e) {
    for (var n = e.return; n !== null; ) {
      switch (n.tag) {
        case 24:
        case 3:
          var a = oi();
          e = ba(a);
          var o = Ta(n, e, a);
          o !== null && (Jn(o, n, a), bo(o, n, a)), n = { cache: nf() }, e.payload = n;
          return;
      }
      n = n.return;
    }
  }
  function Oy(e, n, a) {
    var o = oi();
    a = {
      lane: o,
      revertLane: 0,
      gesture: null,
      action: a,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, Wl(e) ? pg(n, a) : (a = Wu(e, n, a, o), a !== null && (Jn(a, e, o), mg(a, n, o)));
  }
  function dg(e, n, a) {
    var o = oi();
    wo(e, n, a, o);
  }
  function wo(e, n, a, o) {
    var u = {
      lane: o,
      revertLane: 0,
      gesture: null,
      action: a,
      hasEagerState: !1,
      eagerState: null,
      next: null
    };
    if (Wl(e)) pg(n, u);
    else {
      var f = e.alternate;
      if (e.lanes === 0 && (f === null || f.lanes === 0) && (f = n.lastRenderedReducer, f !== null))
        try {
          var y = n.lastRenderedState, A = f(y, a);
          if (u.hasEagerState = !0, u.eagerState = A, ei(A, y))
            return Tl(e, n, u, 0), Ye === null && bl(), !1;
        } catch {
        } finally {
        }
      if (a = Wu(e, n, u, o), a !== null)
        return Jn(a, e, o), mg(a, n, o), !0;
    }
    return !1;
  }
  function wf(e, n, a, o) {
    if (o = {
      lane: 2,
      revertLane: oh(),
      gesture: null,
      action: o,
      hasEagerState: !1,
      eagerState: null,
      next: null
    }, Wl(e)) {
      if (n) throw Error(s(479));
    } else
      n = Wu(
        e,
        a,
        o,
        2
      ), n !== null && Jn(n, e, 2);
  }
  function Wl(e) {
    var n = e.alternate;
    return e === le || n !== null && n === le;
  }
  function pg(e, n) {
    ar = Il = !0;
    var a = e.pending;
    a === null ? n.next = n : (n.next = a.next, a.next = n), e.pending = n;
  }
  function mg(e, n, a) {
    if ((a & 4194048) !== 0) {
      var o = n.lanes;
      o &= e.pendingLanes, a |= o, n.lanes = a, ao(e, a);
    }
  }
  var Do = {
    readContext: Rn,
    use: Gl,
    useCallback: en,
    useContext: en,
    useEffect: en,
    useImperativeHandle: en,
    useLayoutEffect: en,
    useInsertionEffect: en,
    useMemo: en,
    useReducer: en,
    useRef: en,
    useState: en,
    useDebugValue: en,
    useDeferredValue: en,
    useTransition: en,
    useSyncExternalStore: en,
    useId: en,
    useHostTransitionStatus: en,
    useFormState: en,
    useActionState: en,
    useOptimistic: en,
    useMemoCache: en,
    useCacheRefresh: en
  };
  Do.useEffectEvent = en;
  var gg = {
    readContext: Rn,
    use: Gl,
    useCallback: function(e, n) {
      return Hn().memoizedState = [
        e,
        n === void 0 ? null : n
      ], e;
    },
    useContext: Rn,
    useEffect: $m,
    useImperativeHandle: function(e, n, a) {
      a = a != null ? a.concat([e]) : null, kl(
        4194308,
        4,
        ig.bind(null, n, e),
        a
      );
    },
    useLayoutEffect: function(e, n) {
      return kl(4194308, 4, e, n);
    },
    useInsertionEffect: function(e, n) {
      kl(4, 2, e, n);
    },
    useMemo: function(e, n) {
      var a = Hn();
      n = n === void 0 ? null : n;
      var o = e();
      if (_s) {
        It(!0);
        try {
          e();
        } finally {
          It(!1);
        }
      }
      return a.memoizedState = [o, n], o;
    },
    useReducer: function(e, n, a) {
      var o = Hn();
      if (a !== void 0) {
        var u = a(n);
        if (_s) {
          It(!0);
          try {
            a(n);
          } finally {
            It(!1);
          }
        }
      } else u = n;
      return o.memoizedState = o.baseState = u, e = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: e,
        lastRenderedState: u
      }, o.queue = e, e = e.dispatch = Oy.bind(
        null,
        le,
        e
      ), [o.memoizedState, e];
    },
    useRef: function(e) {
      var n = Hn();
      return e = { current: e }, n.memoizedState = e;
    },
    useState: function(e) {
      e = Mf(e);
      var n = e.queue, a = dg.bind(null, le, n);
      return n.dispatch = a, [e.memoizedState, a];
    },
    useDebugValue: Tf,
    useDeferredValue: function(e, n) {
      var a = Hn();
      return Af(a, e, n);
    },
    useTransition: function() {
      var e = Mf(!1);
      return e = lg.bind(
        null,
        le,
        e.queue,
        !0,
        !1
      ), Hn().memoizedState = e, [!1, e];
    },
    useSyncExternalStore: function(e, n, a) {
      var o = le, u = Hn();
      if (be) {
        if (a === void 0)
          throw Error(s(407));
        a = a();
      } else {
        if (a = n(), Ye === null)
          throw Error(s(349));
        (ye & 127) !== 0 || Bm(o, n, a);
      }
      u.memoizedState = a;
      var f = { value: a, getSnapshot: n };
      return u.queue = f, $m(Fm.bind(null, o, f, e), [
        e
      ]), o.flags |= 2048, rr(
        9,
        { destroy: void 0 },
        Im.bind(
          null,
          o,
          f,
          a,
          n
        ),
        null
      ), a;
    },
    useId: function() {
      var e = Hn(), n = Ye.identifierPrefix;
      if (be) {
        var a = Pi, o = Oi;
        a = (o & ~(1 << 32 - te(o) - 1)).toString(32) + a, n = "_" + n + "R_" + a, a = Fl++, 0 < a && (n += "H" + a.toString(32)), n += "_";
      } else
        a = Ry++, n = "_" + n + "r_" + a.toString(32) + "_";
      return e.memoizedState = n;
    },
    useHostTransitionStatus: Cf,
    useFormState: jm,
    useActionState: jm,
    useOptimistic: function(e) {
      var n = Hn();
      n.memoizedState = n.baseState = e;
      var a = {
        pending: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: null,
        lastRenderedState: null
      };
      return n.queue = a, n = wf.bind(
        null,
        le,
        !0,
        a
      ), a.dispatch = n, [e, n];
    },
    useMemoCache: xf,
    useCacheRefresh: function() {
      return Hn().memoizedState = Ny.bind(
        null,
        le
      );
    },
    useEffectEvent: function(e) {
      var n = Hn(), a = { impl: e };
      return n.memoizedState = a, function() {
        if ((Le & 2) !== 0)
          throw Error(s(440));
        return a.impl.apply(void 0, arguments);
      };
    }
  }, Df = {
    readContext: Rn,
    use: Gl,
    useCallback: sg,
    useContext: Rn,
    useEffect: bf,
    useImperativeHandle: ag,
    useInsertionEffect: eg,
    useLayoutEffect: ng,
    useMemo: rg,
    useReducer: Vl,
    useRef: Jm,
    useState: function() {
      return Vl(Ki);
    },
    useDebugValue: Tf,
    useDeferredValue: function(e, n) {
      var a = sn();
      return og(
        a,
        Ie.memoizedState,
        e,
        n
      );
    },
    useTransition: function() {
      var e = Vl(Ki)[0], n = sn().memoizedState;
      return [
        typeof e == "boolean" ? e : Co(e),
        n
      ];
    },
    useSyncExternalStore: zm,
    useId: fg,
    useHostTransitionStatus: Cf,
    useFormState: Zm,
    useActionState: Zm,
    useOptimistic: function(e, n) {
      var a = sn();
      return Vm(a, Ie, e, n);
    },
    useMemoCache: xf,
    useCacheRefresh: hg
  };
  Df.useEffectEvent = tg;
  var _g = {
    readContext: Rn,
    use: Gl,
    useCallback: sg,
    useContext: Rn,
    useEffect: bf,
    useImperativeHandle: ag,
    useInsertionEffect: eg,
    useLayoutEffect: ng,
    useMemo: rg,
    useReducer: Sf,
    useRef: Jm,
    useState: function() {
      return Sf(Ki);
    },
    useDebugValue: Tf,
    useDeferredValue: function(e, n) {
      var a = sn();
      return Ie === null ? Af(a, e, n) : og(
        a,
        Ie.memoizedState,
        e,
        n
      );
    },
    useTransition: function() {
      var e = Sf(Ki)[0], n = sn().memoizedState;
      return [
        typeof e == "boolean" ? e : Co(e),
        n
      ];
    },
    useSyncExternalStore: zm,
    useId: fg,
    useHostTransitionStatus: Cf,
    useFormState: Qm,
    useActionState: Qm,
    useOptimistic: function(e, n) {
      var a = sn();
      return Ie !== null ? Vm(a, Ie, e, n) : (a.baseState = e, [e, a.queue.dispatch]);
    },
    useMemoCache: xf,
    useCacheRefresh: hg
  };
  _g.useEffectEvent = tg;
  function Uf(e, n, a, o) {
    n = e.memoizedState, a = a(o, n), a = a == null ? n : _({}, n, a), e.memoizedState = a, e.lanes === 0 && (e.updateQueue.baseState = a);
  }
  var Lf = {
    enqueueSetState: function(e, n, a) {
      e = e._reactInternals;
      var o = oi(), u = ba(o);
      u.payload = n, a != null && (u.callback = a), n = Ta(e, u, o), n !== null && (Jn(n, e, o), bo(n, e, o));
    },
    enqueueReplaceState: function(e, n, a) {
      e = e._reactInternals;
      var o = oi(), u = ba(o);
      u.tag = 1, u.payload = n, a != null && (u.callback = a), n = Ta(e, u, o), n !== null && (Jn(n, e, o), bo(n, e, o));
    },
    enqueueForceUpdate: function(e, n) {
      e = e._reactInternals;
      var a = oi(), o = ba(a);
      o.tag = 2, n != null && (o.callback = n), n = Ta(e, o, a), n !== null && (Jn(n, e, a), bo(n, e, a));
    }
  };
  function vg(e, n, a, o, u, f, y) {
    return e = e.stateNode, typeof e.shouldComponentUpdate == "function" ? e.shouldComponentUpdate(o, f, y) : n.prototype && n.prototype.isPureReactComponent ? !go(a, o) || !go(u, f) : !0;
  }
  function xg(e, n, a, o) {
    e = n.state, typeof n.componentWillReceiveProps == "function" && n.componentWillReceiveProps(a, o), typeof n.UNSAFE_componentWillReceiveProps == "function" && n.UNSAFE_componentWillReceiveProps(a, o), n.state !== e && Lf.enqueueReplaceState(n, n.state, null);
  }
  function vs(e, n) {
    var a = n;
    if ("ref" in n) {
      a = {};
      for (var o in n)
        o !== "ref" && (a[o] = n[o]);
    }
    if (e = e.defaultProps) {
      a === n && (a = _({}, a));
      for (var u in e)
        a[u] === void 0 && (a[u] = e[u]);
    }
    return a;
  }
  function yg(e) {
    El(e);
  }
  function Sg(e) {
    console.error(e);
  }
  function Mg(e) {
    El(e);
  }
  function Yl(e, n) {
    try {
      var a = e.onUncaughtError;
      a(n.value, { componentStack: n.stack });
    } catch (o) {
      setTimeout(function() {
        throw o;
      });
    }
  }
  function Eg(e, n, a) {
    try {
      var o = e.onCaughtError;
      o(a.value, {
        componentStack: a.stack,
        errorBoundary: n.tag === 1 ? n.stateNode : null
      });
    } catch (u) {
      setTimeout(function() {
        throw u;
      });
    }
  }
  function Nf(e, n, a) {
    return a = ba(a), a.tag = 3, a.payload = { element: null }, a.callback = function() {
      Yl(e, n);
    }, a;
  }
  function bg(e) {
    return e = ba(e), e.tag = 3, e;
  }
  function Tg(e, n, a, o) {
    var u = a.type.getDerivedStateFromError;
    if (typeof u == "function") {
      var f = o.value;
      e.payload = function() {
        return u(f);
      }, e.callback = function() {
        Eg(n, a, o);
      };
    }
    var y = a.stateNode;
    y !== null && typeof y.componentDidCatch == "function" && (e.callback = function() {
      Eg(n, a, o), typeof u != "function" && (Ua === null ? Ua = /* @__PURE__ */ new Set([this]) : Ua.add(this));
      var A = o.stack;
      this.componentDidCatch(o.value, {
        componentStack: A !== null ? A : ""
      });
    });
  }
  function Py(e, n, a, o, u) {
    if (a.flags |= 32768, o !== null && typeof o == "object" && typeof o.then == "function") {
      if (n = a.alternate, n !== null && Js(
        n,
        a,
        u,
        !0
      ), a = ii.current, a !== null) {
        switch (a.tag) {
          case 31:
          case 13:
            return _i === null ? ac() : a.alternate === null && nn === 0 && (nn = 3), a.flags &= -257, a.flags |= 65536, a.lanes = u, o === Nl ? a.flags |= 16384 : (n = a.updateQueue, n === null ? a.updateQueue = /* @__PURE__ */ new Set([o]) : n.add(o), ah(e, o, u)), !1;
          case 22:
            return a.flags |= 65536, o === Nl ? a.flags |= 16384 : (n = a.updateQueue, n === null ? (n = {
              transitions: null,
              markerInstances: null,
              retryQueue: /* @__PURE__ */ new Set([o])
            }, a.updateQueue = n) : (a = n.retryQueue, a === null ? n.retryQueue = /* @__PURE__ */ new Set([o]) : a.add(o)), ah(e, o, u)), !1;
        }
        throw Error(s(435, a.tag));
      }
      return ah(e, o, u), ac(), !1;
    }
    if (be)
      return n = ii.current, n !== null ? ((n.flags & 65536) === 0 && (n.flags |= 256), n.flags |= 65536, n.lanes = u, o !== Qu && (e = Error(s(422), { cause: o }), xo(di(e, a)))) : (o !== Qu && (n = Error(s(423), {
        cause: o
      }), xo(
        di(n, a)
      )), e = e.current.alternate, e.flags |= 65536, u &= -u, e.lanes |= u, o = di(o, a), u = Nf(
        e.stateNode,
        o,
        u
      ), cf(e, u), nn !== 4 && (nn = 2)), !1;
    var f = Error(s(520), { cause: o });
    if (f = di(f, a), Io === null ? Io = [f] : Io.push(f), nn !== 4 && (nn = 2), n === null) return !0;
    o = di(o, a), a = n;
    do {
      switch (a.tag) {
        case 3:
          return a.flags |= 65536, e = u & -u, a.lanes |= e, e = Nf(a.stateNode, o, e), cf(a, e), !1;
        case 1:
          if (n = a.type, f = a.stateNode, (a.flags & 128) === 0 && (typeof n.getDerivedStateFromError == "function" || f !== null && typeof f.componentDidCatch == "function" && (Ua === null || !Ua.has(f))))
            return a.flags |= 65536, u &= -u, a.lanes |= u, u = bg(u), Tg(
              u,
              e,
              a,
              o
            ), cf(a, u), !1;
      }
      a = a.return;
    } while (a !== null);
    return !1;
  }
  var Of = Error(s(461)), ln = !1;
  function Cn(e, n, a, o) {
    n.child = e === null ? wm(n, null, a, o) : gs(
      n,
      e.child,
      a,
      o
    );
  }
  function Ag(e, n, a, o, u) {
    a = a.render;
    var f = n.ref;
    if ("ref" in o) {
      var y = {};
      for (var A in o)
        A !== "ref" && (y[A] = o[A]);
    } else y = o;
    return hs(n), o = mf(
      e,
      n,
      a,
      y,
      f,
      u
    ), A = gf(), e !== null && !ln ? (_f(e, n, u), Qi(e, n, u)) : (be && A && Zu(n), n.flags |= 1, Cn(e, n, o, u), n.child);
  }
  function Rg(e, n, a, o, u) {
    if (e === null) {
      var f = a.type;
      return typeof f == "function" && !Yu(f) && f.defaultProps === void 0 && a.compare === null ? (n.tag = 15, n.type = f, Cg(
        e,
        n,
        f,
        o,
        u
      )) : (e = Rl(
        a.type,
        null,
        o,
        n,
        n.mode,
        u
      ), e.ref = n.ref, e.return = n, n.child = e);
    }
    if (f = e.child, !Vf(e, u)) {
      var y = f.memoizedProps;
      if (a = a.compare, a = a !== null ? a : go, a(y, o) && e.ref === n.ref)
        return Qi(e, n, u);
    }
    return n.flags |= 1, e = Wi(f, o), e.ref = n.ref, e.return = n, n.child = e;
  }
  function Cg(e, n, a, o, u) {
    if (e !== null) {
      var f = e.memoizedProps;
      if (go(f, o) && e.ref === n.ref)
        if (ln = !1, n.pendingProps = o = f, Vf(e, u))
          (e.flags & 131072) !== 0 && (ln = !0);
        else
          return n.lanes = e.lanes, Qi(e, n, u);
    }
    return Pf(
      e,
      n,
      a,
      o,
      u
    );
  }
  function wg(e, n, a, o) {
    var u = o.children, f = e !== null ? e.memoizedState : null;
    if (e === null && n.stateNode === null && (n.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), o.mode === "hidden") {
      if ((n.flags & 128) !== 0) {
        if (f = f !== null ? f.baseLanes | a : a, e !== null) {
          for (o = n.child = e.child, u = 0; o !== null; )
            u = u | o.lanes | o.childLanes, o = o.sibling;
          o = u & ~f;
        } else o = 0, n.child = null;
        return Dg(
          e,
          n,
          f,
          a,
          o
        );
      }
      if ((a & 536870912) !== 0)
        n.memoizedState = { baseLanes: 0, cachePool: null }, e !== null && Ul(
          n,
          f !== null ? f.cachePool : null
        ), f !== null ? Lm(n, f) : ff(), Nm(n);
      else
        return o = n.lanes = 536870912, Dg(
          e,
          n,
          f !== null ? f.baseLanes | a : a,
          a,
          o
        );
    } else
      f !== null ? (Ul(n, f.cachePool), Lm(n, f), Ra(), n.memoizedState = null) : (e !== null && Ul(n, null), ff(), Ra());
    return Cn(e, n, u, a), n.child;
  }
  function Uo(e, n) {
    return e !== null && e.tag === 22 || n.stateNode !== null || (n.stateNode = {
      _visibility: 1,
      _pendingMarkers: null,
      _retryCache: null,
      _transitions: null
    }), n.sibling;
  }
  function Dg(e, n, a, o, u) {
    var f = sf();
    return f = f === null ? null : { parent: rn._currentValue, pool: f }, n.memoizedState = {
      baseLanes: a,
      cachePool: f
    }, e !== null && Ul(n, null), ff(), Nm(n), e !== null && Js(e, n, o, !0), n.childLanes = u, null;
  }
  function ql(e, n) {
    return n = Zl(
      { mode: n.mode, children: n.children },
      e.mode
    ), n.ref = e.ref, e.child = n, n.return = e, n;
  }
  function Ug(e, n, a) {
    return gs(n, e.child, null, a), e = ql(n, n.pendingProps), e.flags |= 2, ai(n), n.memoizedState = null, e;
  }
  function zy(e, n, a) {
    var o = n.pendingProps, u = (n.flags & 128) !== 0;
    if (n.flags &= -129, e === null) {
      if (be) {
        if (o.mode === "hidden")
          return e = ql(n, o), n.lanes = 536870912, Uo(null, e);
        if (df(n), (e = je) ? (e = k_(
          e,
          gi
        ), e = e !== null && e.data === "&" ? e : null, e !== null && (n.memoizedState = {
          dehydrated: e,
          treeContext: xa !== null ? { id: Oi, overflow: Pi } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, a = pm(e), a.return = n, n.child = a, An = n, je = null)) : e = null, e === null) throw Sa(n);
        return n.lanes = 536870912, null;
      }
      return ql(n, o);
    }
    var f = e.memoizedState;
    if (f !== null) {
      var y = f.dehydrated;
      if (df(n), u)
        if (n.flags & 256)
          n.flags &= -257, n = Ug(
            e,
            n,
            a
          );
        else if (n.memoizedState !== null)
          n.child = e.child, n.flags |= 128, n = null;
        else throw Error(s(558));
      else if (ln || Js(e, n, a, !1), u = (a & e.childLanes) !== 0, ln || u) {
        if (o = Ye, o !== null && (y = Ni(o, a), y !== 0 && y !== f.retryLane))
          throw f.retryLane = y, ls(e, y), Jn(o, e, y), Of;
        ac(), n = Ug(
          e,
          n,
          a
        );
      } else
        e = f.treeContext, je = vi(y.nextSibling), An = n, be = !0, ya = null, gi = !1, e !== null && _m(n, e), n = ql(n, o), n.flags |= 4096;
      return n;
    }
    return e = Wi(e.child, {
      mode: o.mode,
      children: o.children
    }), e.ref = n.ref, n.child = e, e.return = n, e;
  }
  function jl(e, n) {
    var a = n.ref;
    if (a === null)
      e !== null && e.ref !== null && (n.flags |= 4194816);
    else {
      if (typeof a != "function" && typeof a != "object")
        throw Error(s(284));
      (e === null || e.ref !== a) && (n.flags |= 4194816);
    }
  }
  function Pf(e, n, a, o, u) {
    return hs(n), a = mf(
      e,
      n,
      a,
      o,
      void 0,
      u
    ), o = gf(), e !== null && !ln ? (_f(e, n, u), Qi(e, n, u)) : (be && o && Zu(n), n.flags |= 1, Cn(e, n, a, u), n.child);
  }
  function Lg(e, n, a, o, u, f) {
    return hs(n), n.updateQueue = null, a = Pm(
      n,
      o,
      a,
      u
    ), Om(e), o = gf(), e !== null && !ln ? (_f(e, n, f), Qi(e, n, f)) : (be && o && Zu(n), n.flags |= 1, Cn(e, n, a, f), n.child);
  }
  function Ng(e, n, a, o, u) {
    if (hs(n), n.stateNode === null) {
      var f = js, y = a.contextType;
      typeof y == "object" && y !== null && (f = Rn(y)), f = new a(o, f), n.memoizedState = f.state !== null && f.state !== void 0 ? f.state : null, f.updater = Lf, n.stateNode = f, f._reactInternals = n, f = n.stateNode, f.props = o, f.state = n.memoizedState, f.refs = {}, of(n), y = a.contextType, f.context = typeof y == "object" && y !== null ? Rn(y) : js, f.state = n.memoizedState, y = a.getDerivedStateFromProps, typeof y == "function" && (Uf(
        n,
        a,
        y,
        o
      ), f.state = n.memoizedState), typeof a.getDerivedStateFromProps == "function" || typeof f.getSnapshotBeforeUpdate == "function" || typeof f.UNSAFE_componentWillMount != "function" && typeof f.componentWillMount != "function" || (y = f.state, typeof f.componentWillMount == "function" && f.componentWillMount(), typeof f.UNSAFE_componentWillMount == "function" && f.UNSAFE_componentWillMount(), y !== f.state && Lf.enqueueReplaceState(f, f.state, null), Ao(n, o, f, u), To(), f.state = n.memoizedState), typeof f.componentDidMount == "function" && (n.flags |= 4194308), o = !0;
    } else if (e === null) {
      f = n.stateNode;
      var A = n.memoizedProps, H = vs(a, A);
      f.props = H;
      var nt = f.context, ft = a.contextType;
      y = js, typeof ft == "object" && ft !== null && (y = Rn(ft));
      var gt = a.getDerivedStateFromProps;
      ft = typeof gt == "function" || typeof f.getSnapshotBeforeUpdate == "function", A = n.pendingProps !== A, ft || typeof f.UNSAFE_componentWillReceiveProps != "function" && typeof f.componentWillReceiveProps != "function" || (A || nt !== y) && xg(
        n,
        f,
        o,
        y
      ), Ea = !1;
      var at = n.memoizedState;
      f.state = at, Ao(n, o, f, u), To(), nt = n.memoizedState, A || at !== nt || Ea ? (typeof gt == "function" && (Uf(
        n,
        a,
        gt,
        o
      ), nt = n.memoizedState), (H = Ea || vg(
        n,
        a,
        H,
        o,
        at,
        nt,
        y
      )) ? (ft || typeof f.UNSAFE_componentWillMount != "function" && typeof f.componentWillMount != "function" || (typeof f.componentWillMount == "function" && f.componentWillMount(), typeof f.UNSAFE_componentWillMount == "function" && f.UNSAFE_componentWillMount()), typeof f.componentDidMount == "function" && (n.flags |= 4194308)) : (typeof f.componentDidMount == "function" && (n.flags |= 4194308), n.memoizedProps = o, n.memoizedState = nt), f.props = o, f.state = nt, f.context = y, o = H) : (typeof f.componentDidMount == "function" && (n.flags |= 4194308), o = !1);
    } else {
      f = n.stateNode, lf(e, n), y = n.memoizedProps, ft = vs(a, y), f.props = ft, gt = n.pendingProps, at = f.context, nt = a.contextType, H = js, typeof nt == "object" && nt !== null && (H = Rn(nt)), A = a.getDerivedStateFromProps, (nt = typeof A == "function" || typeof f.getSnapshotBeforeUpdate == "function") || typeof f.UNSAFE_componentWillReceiveProps != "function" && typeof f.componentWillReceiveProps != "function" || (y !== gt || at !== H) && xg(
        n,
        f,
        o,
        H
      ), Ea = !1, at = n.memoizedState, f.state = at, Ao(n, o, f, u), To();
      var ct = n.memoizedState;
      y !== gt || at !== ct || Ea || e !== null && e.dependencies !== null && wl(e.dependencies) ? (typeof A == "function" && (Uf(
        n,
        a,
        A,
        o
      ), ct = n.memoizedState), (ft = Ea || vg(
        n,
        a,
        ft,
        o,
        at,
        ct,
        H
      ) || e !== null && e.dependencies !== null && wl(e.dependencies)) ? (nt || typeof f.UNSAFE_componentWillUpdate != "function" && typeof f.componentWillUpdate != "function" || (typeof f.componentWillUpdate == "function" && f.componentWillUpdate(o, ct, H), typeof f.UNSAFE_componentWillUpdate == "function" && f.UNSAFE_componentWillUpdate(
        o,
        ct,
        H
      )), typeof f.componentDidUpdate == "function" && (n.flags |= 4), typeof f.getSnapshotBeforeUpdate == "function" && (n.flags |= 1024)) : (typeof f.componentDidUpdate != "function" || y === e.memoizedProps && at === e.memoizedState || (n.flags |= 4), typeof f.getSnapshotBeforeUpdate != "function" || y === e.memoizedProps && at === e.memoizedState || (n.flags |= 1024), n.memoizedProps = o, n.memoizedState = ct), f.props = o, f.state = ct, f.context = H, o = ft) : (typeof f.componentDidUpdate != "function" || y === e.memoizedProps && at === e.memoizedState || (n.flags |= 4), typeof f.getSnapshotBeforeUpdate != "function" || y === e.memoizedProps && at === e.memoizedState || (n.flags |= 1024), o = !1);
    }
    return f = o, jl(e, n), o = (n.flags & 128) !== 0, f || o ? (f = n.stateNode, a = o && typeof a.getDerivedStateFromError != "function" ? null : f.render(), n.flags |= 1, e !== null && o ? (n.child = gs(
      n,
      e.child,
      null,
      u
    ), n.child = gs(
      n,
      null,
      a,
      u
    )) : Cn(e, n, a, u), n.memoizedState = f.state, e = n.child) : e = Qi(
      e,
      n,
      u
    ), e;
  }
  function Og(e, n, a, o) {
    return us(), n.flags |= 256, Cn(e, n, a, o), n.child;
  }
  var zf = {
    dehydrated: null,
    treeContext: null,
    retryLane: 0,
    hydrationErrors: null
  };
  function Bf(e) {
    return { baseLanes: e, cachePool: Em() };
  }
  function If(e, n, a) {
    return e = e !== null ? e.childLanes & ~a : 0, n && (e |= ri), e;
  }
  function Pg(e, n, a) {
    var o = n.pendingProps, u = !1, f = (n.flags & 128) !== 0, y;
    if ((y = f) || (y = e !== null && e.memoizedState === null ? !1 : (an.current & 2) !== 0), y && (u = !0, n.flags &= -129), y = (n.flags & 32) !== 0, n.flags &= -33, e === null) {
      if (be) {
        if (u ? Aa(n) : Ra(), (e = je) ? (e = k_(
          e,
          gi
        ), e = e !== null && e.data !== "&" ? e : null, e !== null && (n.memoizedState = {
          dehydrated: e,
          treeContext: xa !== null ? { id: Oi, overflow: Pi } : null,
          retryLane: 536870912,
          hydrationErrors: null
        }, a = pm(e), a.return = n, n.child = a, An = n, je = null)) : e = null, e === null) throw Sa(n);
        return yh(e) ? n.lanes = 32 : n.lanes = 536870912, null;
      }
      var A = o.children;
      return o = o.fallback, u ? (Ra(), u = n.mode, A = Zl(
        { mode: "hidden", children: A },
        u
      ), o = cs(
        o,
        u,
        a,
        null
      ), A.return = n, o.return = n, A.sibling = o, n.child = A, o = n.child, o.memoizedState = Bf(a), o.childLanes = If(
        e,
        y,
        a
      ), n.memoizedState = zf, Uo(null, o)) : (Aa(n), Ff(n, A));
    }
    var H = e.memoizedState;
    if (H !== null && (A = H.dehydrated, A !== null)) {
      if (f)
        n.flags & 256 ? (Aa(n), n.flags &= -257, n = Hf(
          e,
          n,
          a
        )) : n.memoizedState !== null ? (Ra(), n.child = e.child, n.flags |= 128, n = null) : (Ra(), A = o.fallback, u = n.mode, o = Zl(
          { mode: "visible", children: o.children },
          u
        ), A = cs(
          A,
          u,
          a,
          null
        ), A.flags |= 2, o.return = n, A.return = n, o.sibling = A, n.child = o, gs(
          n,
          e.child,
          null,
          a
        ), o = n.child, o.memoizedState = Bf(a), o.childLanes = If(
          e,
          y,
          a
        ), n.memoizedState = zf, n = Uo(null, o));
      else if (Aa(n), yh(A)) {
        if (y = A.nextSibling && A.nextSibling.dataset, y) var nt = y.dgst;
        y = nt, o = Error(s(419)), o.stack = "", o.digest = y, xo({ value: o, source: null, stack: null }), n = Hf(
          e,
          n,
          a
        );
      } else if (ln || Js(e, n, a, !1), y = (a & e.childLanes) !== 0, ln || y) {
        if (y = Ye, y !== null && (o = Ni(y, a), o !== 0 && o !== H.retryLane))
          throw H.retryLane = o, ls(e, o), Jn(y, e, o), Of;
        xh(A) || ac(), n = Hf(
          e,
          n,
          a
        );
      } else
        xh(A) ? (n.flags |= 192, n.child = e.child, n = null) : (e = H.treeContext, je = vi(
          A.nextSibling
        ), An = n, be = !0, ya = null, gi = !1, e !== null && _m(n, e), n = Ff(
          n,
          o.children
        ), n.flags |= 4096);
      return n;
    }
    return u ? (Ra(), A = o.fallback, u = n.mode, H = e.child, nt = H.sibling, o = Wi(H, {
      mode: "hidden",
      children: o.children
    }), o.subtreeFlags = H.subtreeFlags & 65011712, nt !== null ? A = Wi(
      nt,
      A
    ) : (A = cs(
      A,
      u,
      a,
      null
    ), A.flags |= 2), A.return = n, o.return = n, o.sibling = A, n.child = o, Uo(null, o), o = n.child, A = e.child.memoizedState, A === null ? A = Bf(a) : (u = A.cachePool, u !== null ? (H = rn._currentValue, u = u.parent !== H ? { parent: H, pool: H } : u) : u = Em(), A = {
      baseLanes: A.baseLanes | a,
      cachePool: u
    }), o.memoizedState = A, o.childLanes = If(
      e,
      y,
      a
    ), n.memoizedState = zf, Uo(e.child, o)) : (Aa(n), a = e.child, e = a.sibling, a = Wi(a, {
      mode: "visible",
      children: o.children
    }), a.return = n, a.sibling = null, e !== null && (y = n.deletions, y === null ? (n.deletions = [e], n.flags |= 16) : y.push(e)), n.child = a, n.memoizedState = null, a);
  }
  function Ff(e, n) {
    return n = Zl(
      { mode: "visible", children: n },
      e.mode
    ), n.return = e, e.child = n;
  }
  function Zl(e, n) {
    return e = ni(22, e, null, n), e.lanes = 0, e;
  }
  function Hf(e, n, a) {
    return gs(n, e.child, null, a), e = Ff(
      n,
      n.pendingProps.children
    ), e.flags |= 2, n.memoizedState = null, e;
  }
  function zg(e, n, a) {
    e.lanes |= n;
    var o = e.alternate;
    o !== null && (o.lanes |= n), tf(e.return, n, a);
  }
  function Gf(e, n, a, o, u, f) {
    var y = e.memoizedState;
    y === null ? e.memoizedState = {
      isBackwards: n,
      rendering: null,
      renderingStartTime: 0,
      last: o,
      tail: a,
      tailMode: u,
      treeForkCount: f
    } : (y.isBackwards = n, y.rendering = null, y.renderingStartTime = 0, y.last = o, y.tail = a, y.tailMode = u, y.treeForkCount = f);
  }
  function Bg(e, n, a) {
    var o = n.pendingProps, u = o.revealOrder, f = o.tail;
    o = o.children;
    var y = an.current, A = (y & 2) !== 0;
    if (A ? (y = y & 1 | 2, n.flags |= 128) : y &= 1, xt(an, y), Cn(e, n, o, a), o = be ? vo : 0, !A && e !== null && (e.flags & 128) !== 0)
      t: for (e = n.child; e !== null; ) {
        if (e.tag === 13)
          e.memoizedState !== null && zg(e, a, n);
        else if (e.tag === 19)
          zg(e, a, n);
        else if (e.child !== null) {
          e.child.return = e, e = e.child;
          continue;
        }
        if (e === n) break t;
        for (; e.sibling === null; ) {
          if (e.return === null || e.return === n)
            break t;
          e = e.return;
        }
        e.sibling.return = e.return, e = e.sibling;
      }
    switch (u) {
      case "forwards":
        for (a = n.child, u = null; a !== null; )
          e = a.alternate, e !== null && Bl(e) === null && (u = a), a = a.sibling;
        a = u, a === null ? (u = n.child, n.child = null) : (u = a.sibling, a.sibling = null), Gf(
          n,
          !1,
          u,
          a,
          f,
          o
        );
        break;
      case "backwards":
      case "unstable_legacy-backwards":
        for (a = null, u = n.child, n.child = null; u !== null; ) {
          if (e = u.alternate, e !== null && Bl(e) === null) {
            n.child = u;
            break;
          }
          e = u.sibling, u.sibling = a, a = u, u = e;
        }
        Gf(
          n,
          !0,
          a,
          null,
          f,
          o
        );
        break;
      case "together":
        Gf(
          n,
          !1,
          null,
          null,
          void 0,
          o
        );
        break;
      default:
        n.memoizedState = null;
    }
    return n.child;
  }
  function Qi(e, n, a) {
    if (e !== null && (n.dependencies = e.dependencies), Da |= n.lanes, (a & n.childLanes) === 0)
      if (e !== null) {
        if (Js(
          e,
          n,
          a,
          !1
        ), (a & n.childLanes) === 0)
          return null;
      } else return null;
    if (e !== null && n.child !== e.child)
      throw Error(s(153));
    if (n.child !== null) {
      for (e = n.child, a = Wi(e, e.pendingProps), n.child = a, a.return = n; e.sibling !== null; )
        e = e.sibling, a = a.sibling = Wi(e, e.pendingProps), a.return = n;
      a.sibling = null;
    }
    return n.child;
  }
  function Vf(e, n) {
    return (e.lanes & n) !== 0 ? !0 : (e = e.dependencies, !!(e !== null && wl(e)));
  }
  function By(e, n, a) {
    switch (n.tag) {
      case 3:
        Ht(n, n.stateNode.containerInfo), Ma(n, rn, e.memoizedState.cache), us();
        break;
      case 27:
      case 5:
        ae(n);
        break;
      case 4:
        Ht(n, n.stateNode.containerInfo);
        break;
      case 10:
        Ma(
          n,
          n.type,
          n.memoizedProps.value
        );
        break;
      case 31:
        if (n.memoizedState !== null)
          return n.flags |= 128, df(n), null;
        break;
      case 13:
        var o = n.memoizedState;
        if (o !== null)
          return o.dehydrated !== null ? (Aa(n), n.flags |= 128, null) : (a & n.child.childLanes) !== 0 ? Pg(e, n, a) : (Aa(n), e = Qi(
            e,
            n,
            a
          ), e !== null ? e.sibling : null);
        Aa(n);
        break;
      case 19:
        var u = (e.flags & 128) !== 0;
        if (o = (a & n.childLanes) !== 0, o || (Js(
          e,
          n,
          a,
          !1
        ), o = (a & n.childLanes) !== 0), u) {
          if (o)
            return Bg(
              e,
              n,
              a
            );
          n.flags |= 128;
        }
        if (u = n.memoizedState, u !== null && (u.rendering = null, u.tail = null, u.lastEffect = null), xt(an, an.current), o) break;
        return null;
      case 22:
        return n.lanes = 0, wg(
          e,
          n,
          a,
          n.pendingProps
        );
      case 24:
        Ma(n, rn, e.memoizedState.cache);
    }
    return Qi(e, n, a);
  }
  function Ig(e, n, a) {
    if (e !== null)
      if (e.memoizedProps !== n.pendingProps)
        ln = !0;
      else {
        if (!Vf(e, a) && (n.flags & 128) === 0)
          return ln = !1, By(
            e,
            n,
            a
          );
        ln = (e.flags & 131072) !== 0;
      }
    else
      ln = !1, be && (n.flags & 1048576) !== 0 && gm(n, vo, n.index);
    switch (n.lanes = 0, n.tag) {
      case 16:
        t: {
          var o = n.pendingProps;
          if (e = ps(n.elementType), n.type = e, typeof e == "function")
            Yu(e) ? (o = vs(e, o), n.tag = 1, n = Ng(
              null,
              n,
              e,
              o,
              a
            )) : (n.tag = 0, n = Pf(
              null,
              n,
              e,
              o,
              a
            ));
          else {
            if (e != null) {
              var u = e.$$typeof;
              if (u === w) {
                n.tag = 11, n = Ag(
                  null,
                  n,
                  e,
                  o,
                  a
                );
                break t;
              } else if (u === O) {
                n.tag = 14, n = Rg(
                  null,
                  n,
                  e,
                  o,
                  a
                );
                break t;
              }
            }
            throw n = lt(e) || e, Error(s(306, n, ""));
          }
        }
        return n;
      case 0:
        return Pf(
          e,
          n,
          n.type,
          n.pendingProps,
          a
        );
      case 1:
        return o = n.type, u = vs(
          o,
          n.pendingProps
        ), Ng(
          e,
          n,
          o,
          u,
          a
        );
      case 3:
        t: {
          if (Ht(
            n,
            n.stateNode.containerInfo
          ), e === null) throw Error(s(387));
          o = n.pendingProps;
          var f = n.memoizedState;
          u = f.element, lf(e, n), Ao(n, o, null, a);
          var y = n.memoizedState;
          if (o = y.cache, Ma(n, rn, o), o !== f.cache && ef(
            n,
            [rn],
            a,
            !0
          ), To(), o = y.element, f.isDehydrated)
            if (f = {
              element: o,
              isDehydrated: !1,
              cache: y.cache
            }, n.updateQueue.baseState = f, n.memoizedState = f, n.flags & 256) {
              n = Og(
                e,
                n,
                o,
                a
              );
              break t;
            } else if (o !== u) {
              u = di(
                Error(s(424)),
                n
              ), xo(u), n = Og(
                e,
                n,
                o,
                a
              );
              break t;
            } else {
              switch (e = n.stateNode.containerInfo, e.nodeType) {
                case 9:
                  e = e.body;
                  break;
                default:
                  e = e.nodeName === "HTML" ? e.ownerDocument.body : e;
              }
              for (je = vi(e.firstChild), An = n, be = !0, ya = null, gi = !0, a = wm(
                n,
                null,
                o,
                a
              ), n.child = a; a; )
                a.flags = a.flags & -3 | 4096, a = a.sibling;
            }
          else {
            if (us(), o === u) {
              n = Qi(
                e,
                n,
                a
              );
              break t;
            }
            Cn(e, n, o, a);
          }
          n = n.child;
        }
        return n;
      case 26:
        return jl(e, n), e === null ? (a = Z_(
          n.type,
          null,
          n.pendingProps,
          null
        )) ? n.memoizedState = a : be || (a = n.type, e = n.pendingProps, o = fc(
          Et.current
        ).createElement(a), o[$e] = n, o[bn] = e, wn(o, a, e), X(o), n.stateNode = o) : n.memoizedState = Z_(
          n.type,
          e.memoizedProps,
          n.pendingProps,
          e.memoizedState
        ), null;
      case 27:
        return ae(n), e === null && be && (o = n.stateNode = Y_(
          n.type,
          n.pendingProps,
          Et.current
        ), An = n, gi = !0, u = je, Pa(n.type) ? (Sh = u, je = vi(o.firstChild)) : je = u), Cn(
          e,
          n,
          n.pendingProps.children,
          a
        ), jl(e, n), e === null && (n.flags |= 4194304), n.child;
      case 5:
        return e === null && be && ((u = o = je) && (o = dS(
          o,
          n.type,
          n.pendingProps,
          gi
        ), o !== null ? (n.stateNode = o, An = n, je = vi(o.firstChild), gi = !1, u = !0) : u = !1), u || Sa(n)), ae(n), u = n.type, f = n.pendingProps, y = e !== null ? e.memoizedProps : null, o = f.children, gh(u, f) ? o = null : y !== null && gh(u, y) && (n.flags |= 32), n.memoizedState !== null && (u = mf(
          e,
          n,
          Cy,
          null,
          null,
          a
        ), Yo._currentValue = u), jl(e, n), Cn(e, n, o, a), n.child;
      case 6:
        return e === null && be && ((e = a = je) && (a = pS(
          a,
          n.pendingProps,
          gi
        ), a !== null ? (n.stateNode = a, An = n, je = null, e = !0) : e = !1), e || Sa(n)), null;
      case 13:
        return Pg(e, n, a);
      case 4:
        return Ht(
          n,
          n.stateNode.containerInfo
        ), o = n.pendingProps, e === null ? n.child = gs(
          n,
          null,
          o,
          a
        ) : Cn(e, n, o, a), n.child;
      case 11:
        return Ag(
          e,
          n,
          n.type,
          n.pendingProps,
          a
        );
      case 7:
        return Cn(
          e,
          n,
          n.pendingProps,
          a
        ), n.child;
      case 8:
        return Cn(
          e,
          n,
          n.pendingProps.children,
          a
        ), n.child;
      case 12:
        return Cn(
          e,
          n,
          n.pendingProps.children,
          a
        ), n.child;
      case 10:
        return o = n.pendingProps, Ma(n, n.type, o.value), Cn(e, n, o.children, a), n.child;
      case 9:
        return u = n.type._context, o = n.pendingProps.children, hs(n), u = Rn(u), o = o(u), n.flags |= 1, Cn(e, n, o, a), n.child;
      case 14:
        return Rg(
          e,
          n,
          n.type,
          n.pendingProps,
          a
        );
      case 15:
        return Cg(
          e,
          n,
          n.type,
          n.pendingProps,
          a
        );
      case 19:
        return Bg(e, n, a);
      case 31:
        return zy(e, n, a);
      case 22:
        return wg(
          e,
          n,
          a,
          n.pendingProps
        );
      case 24:
        return hs(n), o = Rn(rn), e === null ? (u = sf(), u === null && (u = Ye, f = nf(), u.pooledCache = f, f.refCount++, f !== null && (u.pooledCacheLanes |= a), u = f), n.memoizedState = { parent: o, cache: u }, of(n), Ma(n, rn, u)) : ((e.lanes & a) !== 0 && (lf(e, n), Ao(n, null, null, a), To()), u = e.memoizedState, f = n.memoizedState, u.parent !== o ? (u = { parent: o, cache: o }, n.memoizedState = u, n.lanes === 0 && (n.memoizedState = n.updateQueue.baseState = u), Ma(n, rn, o)) : (o = f.cache, Ma(n, rn, o), o !== u.cache && ef(
          n,
          [rn],
          a,
          !0
        ))), Cn(
          e,
          n,
          n.pendingProps.children,
          a
        ), n.child;
      case 29:
        throw n.pendingProps;
    }
    throw Error(s(156, n.tag));
  }
  function Ji(e) {
    e.flags |= 4;
  }
  function kf(e, n, a, o, u) {
    if ((n = (e.mode & 32) !== 0) && (n = !1), n) {
      if (e.flags |= 16777216, (u & 335544128) === u)
        if (e.stateNode.complete) e.flags |= 8192;
        else if (f_()) e.flags |= 8192;
        else
          throw ms = Nl, rf;
    } else e.flags &= -16777217;
  }
  function Fg(e, n) {
    if (n.type !== "stylesheet" || (n.state.loading & 4) !== 0)
      e.flags &= -16777217;
    else if (e.flags |= 16777216, !t0(n))
      if (f_()) e.flags |= 8192;
      else
        throw ms = Nl, rf;
  }
  function Kl(e, n) {
    n !== null && (e.flags |= 4), e.flags & 16384 && (n = e.tag !== 22 ? hn() : 536870912, e.lanes |= n, ur |= n);
  }
  function Lo(e, n) {
    if (!be)
      switch (e.tailMode) {
        case "hidden":
          n = e.tail;
          for (var a = null; n !== null; )
            n.alternate !== null && (a = n), n = n.sibling;
          a === null ? e.tail = null : a.sibling = null;
          break;
        case "collapsed":
          a = e.tail;
          for (var o = null; a !== null; )
            a.alternate !== null && (o = a), a = a.sibling;
          o === null ? n || e.tail === null ? e.tail = null : e.tail.sibling = null : o.sibling = null;
      }
  }
  function Ze(e) {
    var n = e.alternate !== null && e.alternate.child === e.child, a = 0, o = 0;
    if (n)
      for (var u = e.child; u !== null; )
        a |= u.lanes | u.childLanes, o |= u.subtreeFlags & 65011712, o |= u.flags & 65011712, u.return = e, u = u.sibling;
    else
      for (u = e.child; u !== null; )
        a |= u.lanes | u.childLanes, o |= u.subtreeFlags, o |= u.flags, u.return = e, u = u.sibling;
    return e.subtreeFlags |= o, e.childLanes = a, n;
  }
  function Iy(e, n, a) {
    var o = n.pendingProps;
    switch (Ku(n), n.tag) {
      case 16:
      case 15:
      case 0:
      case 11:
      case 7:
      case 8:
      case 12:
      case 9:
      case 14:
        return Ze(n), null;
      case 1:
        return Ze(n), null;
      case 3:
        return a = n.stateNode, o = null, e !== null && (o = e.memoizedState.cache), n.memoizedState.cache !== o && (n.flags |= 2048), ji(rn), Lt(), a.pendingContext && (a.context = a.pendingContext, a.pendingContext = null), (e === null || e.child === null) && (Qs(n) ? Ji(n) : e === null || e.memoizedState.isDehydrated && (n.flags & 256) === 0 || (n.flags |= 1024, Ju())), Ze(n), null;
      case 26:
        var u = n.type, f = n.memoizedState;
        return e === null ? (Ji(n), f !== null ? (Ze(n), Fg(n, f)) : (Ze(n), kf(
          n,
          u,
          null,
          o,
          a
        ))) : f ? f !== e.memoizedState ? (Ji(n), Ze(n), Fg(n, f)) : (Ze(n), n.flags &= -16777217) : (e = e.memoizedProps, e !== o && Ji(n), Ze(n), kf(
          n,
          u,
          e,
          o,
          a
        )), null;
      case 27:
        if (Ne(n), a = Et.current, u = n.type, e !== null && n.stateNode != null)
          e.memoizedProps !== o && Ji(n);
        else {
          if (!o) {
            if (n.stateNode === null)
              throw Error(s(166));
            return Ze(n), null;
          }
          e = j.current, Qs(n) ? vm(n) : (e = Y_(u, o, a), n.stateNode = e, Ji(n));
        }
        return Ze(n), null;
      case 5:
        if (Ne(n), u = n.type, e !== null && n.stateNode != null)
          e.memoizedProps !== o && Ji(n);
        else {
          if (!o) {
            if (n.stateNode === null)
              throw Error(s(166));
            return Ze(n), null;
          }
          if (f = j.current, Qs(n))
            vm(n);
          else {
            var y = fc(
              Et.current
            );
            switch (f) {
              case 1:
                f = y.createElementNS(
                  "http://www.w3.org/2000/svg",
                  u
                );
                break;
              case 2:
                f = y.createElementNS(
                  "http://www.w3.org/1998/Math/MathML",
                  u
                );
                break;
              default:
                switch (u) {
                  case "svg":
                    f = y.createElementNS(
                      "http://www.w3.org/2000/svg",
                      u
                    );
                    break;
                  case "math":
                    f = y.createElementNS(
                      "http://www.w3.org/1998/Math/MathML",
                      u
                    );
                    break;
                  case "script":
                    f = y.createElement("div"), f.innerHTML = "<script><\/script>", f = f.removeChild(
                      f.firstChild
                    );
                    break;
                  case "select":
                    f = typeof o.is == "string" ? y.createElement("select", {
                      is: o.is
                    }) : y.createElement("select"), o.multiple ? f.multiple = !0 : o.size && (f.size = o.size);
                    break;
                  default:
                    f = typeof o.is == "string" ? y.createElement(u, { is: o.is }) : y.createElement(u);
                }
            }
            f[$e] = n, f[bn] = o;
            t: for (y = n.child; y !== null; ) {
              if (y.tag === 5 || y.tag === 6)
                f.appendChild(y.stateNode);
              else if (y.tag !== 4 && y.tag !== 27 && y.child !== null) {
                y.child.return = y, y = y.child;
                continue;
              }
              if (y === n) break t;
              for (; y.sibling === null; ) {
                if (y.return === null || y.return === n)
                  break t;
                y = y.return;
              }
              y.sibling.return = y.return, y = y.sibling;
            }
            n.stateNode = f;
            t: switch (wn(f, u, o), u) {
              case "button":
              case "input":
              case "select":
              case "textarea":
                o = !!o.autoFocus;
                break t;
              case "img":
                o = !0;
                break t;
              default:
                o = !1;
            }
            o && Ji(n);
          }
        }
        return Ze(n), kf(
          n,
          n.type,
          e === null ? null : e.memoizedProps,
          n.pendingProps,
          a
        ), null;
      case 6:
        if (e && n.stateNode != null)
          e.memoizedProps !== o && Ji(n);
        else {
          if (typeof o != "string" && n.stateNode === null)
            throw Error(s(166));
          if (e = Et.current, Qs(n)) {
            if (e = n.stateNode, a = n.memoizedProps, o = null, u = An, u !== null)
              switch (u.tag) {
                case 27:
                case 5:
                  o = u.memoizedProps;
              }
            e[$e] = n, e = !!(e.nodeValue === a || o !== null && o.suppressHydrationWarning === !0 || P_(e.nodeValue, a)), e || Sa(n, !0);
          } else
            e = fc(e).createTextNode(
              o
            ), e[$e] = n, n.stateNode = e;
        }
        return Ze(n), null;
      case 31:
        if (a = n.memoizedState, e === null || e.memoizedState !== null) {
          if (o = Qs(n), a !== null) {
            if (e === null) {
              if (!o) throw Error(s(318));
              if (e = n.memoizedState, e = e !== null ? e.dehydrated : null, !e) throw Error(s(557));
              e[$e] = n;
            } else
              us(), (n.flags & 128) === 0 && (n.memoizedState = null), n.flags |= 4;
            Ze(n), e = !1;
          } else
            a = Ju(), e !== null && e.memoizedState !== null && (e.memoizedState.hydrationErrors = a), e = !0;
          if (!e)
            return n.flags & 256 ? (ai(n), n) : (ai(n), null);
          if ((n.flags & 128) !== 0)
            throw Error(s(558));
        }
        return Ze(n), null;
      case 13:
        if (o = n.memoizedState, e === null || e.memoizedState !== null && e.memoizedState.dehydrated !== null) {
          if (u = Qs(n), o !== null && o.dehydrated !== null) {
            if (e === null) {
              if (!u) throw Error(s(318));
              if (u = n.memoizedState, u = u !== null ? u.dehydrated : null, !u) throw Error(s(317));
              u[$e] = n;
            } else
              us(), (n.flags & 128) === 0 && (n.memoizedState = null), n.flags |= 4;
            Ze(n), u = !1;
          } else
            u = Ju(), e !== null && e.memoizedState !== null && (e.memoizedState.hydrationErrors = u), u = !0;
          if (!u)
            return n.flags & 256 ? (ai(n), n) : (ai(n), null);
        }
        return ai(n), (n.flags & 128) !== 0 ? (n.lanes = a, n) : (a = o !== null, e = e !== null && e.memoizedState !== null, a && (o = n.child, u = null, o.alternate !== null && o.alternate.memoizedState !== null && o.alternate.memoizedState.cachePool !== null && (u = o.alternate.memoizedState.cachePool.pool), f = null, o.memoizedState !== null && o.memoizedState.cachePool !== null && (f = o.memoizedState.cachePool.pool), f !== u && (o.flags |= 2048)), a !== e && a && (n.child.flags |= 8192), Kl(n, n.updateQueue), Ze(n), null);
      case 4:
        return Lt(), e === null && fh(n.stateNode.containerInfo), Ze(n), null;
      case 10:
        return ji(n.type), Ze(n), null;
      case 19:
        if (st(an), o = n.memoizedState, o === null) return Ze(n), null;
        if (u = (n.flags & 128) !== 0, f = o.rendering, f === null)
          if (u) Lo(o, !1);
          else {
            if (nn !== 0 || e !== null && (e.flags & 128) !== 0)
              for (e = n.child; e !== null; ) {
                if (f = Bl(e), f !== null) {
                  for (n.flags |= 128, Lo(o, !1), e = f.updateQueue, n.updateQueue = e, Kl(n, e), n.subtreeFlags = 0, e = a, a = n.child; a !== null; )
                    dm(a, e), a = a.sibling;
                  return xt(
                    an,
                    an.current & 1 | 2
                  ), be && Yi(n, o.treeForkCount), n.child;
                }
                e = e.sibling;
              }
            o.tail !== null && dt() > ec && (n.flags |= 128, u = !0, Lo(o, !1), n.lanes = 4194304);
          }
        else {
          if (!u)
            if (e = Bl(f), e !== null) {
              if (n.flags |= 128, u = !0, e = e.updateQueue, n.updateQueue = e, Kl(n, e), Lo(o, !0), o.tail === null && o.tailMode === "hidden" && !f.alternate && !be)
                return Ze(n), null;
            } else
              2 * dt() - o.renderingStartTime > ec && a !== 536870912 && (n.flags |= 128, u = !0, Lo(o, !1), n.lanes = 4194304);
          o.isBackwards ? (f.sibling = n.child, n.child = f) : (e = o.last, e !== null ? e.sibling = f : n.child = f, o.last = f);
        }
        return o.tail !== null ? (e = o.tail, o.rendering = e, o.tail = e.sibling, o.renderingStartTime = dt(), e.sibling = null, a = an.current, xt(
          an,
          u ? a & 1 | 2 : a & 1
        ), be && Yi(n, o.treeForkCount), e) : (Ze(n), null);
      case 22:
      case 23:
        return ai(n), hf(), o = n.memoizedState !== null, e !== null ? e.memoizedState !== null !== o && (n.flags |= 8192) : o && (n.flags |= 8192), o ? (a & 536870912) !== 0 && (n.flags & 128) === 0 && (Ze(n), n.subtreeFlags & 6 && (n.flags |= 8192)) : Ze(n), a = n.updateQueue, a !== null && Kl(n, a.retryQueue), a = null, e !== null && e.memoizedState !== null && e.memoizedState.cachePool !== null && (a = e.memoizedState.cachePool.pool), o = null, n.memoizedState !== null && n.memoizedState.cachePool !== null && (o = n.memoizedState.cachePool.pool), o !== a && (n.flags |= 2048), e !== null && st(ds), null;
      case 24:
        return a = null, e !== null && (a = e.memoizedState.cache), n.memoizedState.cache !== a && (n.flags |= 2048), ji(rn), Ze(n), null;
      case 25:
        return null;
      case 30:
        return null;
    }
    throw Error(s(156, n.tag));
  }
  function Fy(e, n) {
    switch (Ku(n), n.tag) {
      case 1:
        return e = n.flags, e & 65536 ? (n.flags = e & -65537 | 128, n) : null;
      case 3:
        return ji(rn), Lt(), e = n.flags, (e & 65536) !== 0 && (e & 128) === 0 ? (n.flags = e & -65537 | 128, n) : null;
      case 26:
      case 27:
      case 5:
        return Ne(n), null;
      case 31:
        if (n.memoizedState !== null) {
          if (ai(n), n.alternate === null)
            throw Error(s(340));
          us();
        }
        return e = n.flags, e & 65536 ? (n.flags = e & -65537 | 128, n) : null;
      case 13:
        if (ai(n), e = n.memoizedState, e !== null && e.dehydrated !== null) {
          if (n.alternate === null)
            throw Error(s(340));
          us();
        }
        return e = n.flags, e & 65536 ? (n.flags = e & -65537 | 128, n) : null;
      case 19:
        return st(an), null;
      case 4:
        return Lt(), null;
      case 10:
        return ji(n.type), null;
      case 22:
      case 23:
        return ai(n), hf(), e !== null && st(ds), e = n.flags, e & 65536 ? (n.flags = e & -65537 | 128, n) : null;
      case 24:
        return ji(rn), null;
      case 25:
        return null;
      default:
        return null;
    }
  }
  function Hg(e, n) {
    switch (Ku(n), n.tag) {
      case 3:
        ji(rn), Lt();
        break;
      case 26:
      case 27:
      case 5:
        Ne(n);
        break;
      case 4:
        Lt();
        break;
      case 31:
        n.memoizedState !== null && ai(n);
        break;
      case 13:
        ai(n);
        break;
      case 19:
        st(an);
        break;
      case 10:
        ji(n.type);
        break;
      case 22:
      case 23:
        ai(n), hf(), e !== null && st(ds);
        break;
      case 24:
        ji(rn);
    }
  }
  function No(e, n) {
    try {
      var a = n.updateQueue, o = a !== null ? a.lastEffect : null;
      if (o !== null) {
        var u = o.next;
        a = u;
        do {
          if ((a.tag & e) === e) {
            o = void 0;
            var f = a.create, y = a.inst;
            o = f(), y.destroy = o;
          }
          a = a.next;
        } while (a !== u);
      }
    } catch (A) {
      Pe(n, n.return, A);
    }
  }
  function Ca(e, n, a) {
    try {
      var o = n.updateQueue, u = o !== null ? o.lastEffect : null;
      if (u !== null) {
        var f = u.next;
        o = f;
        do {
          if ((o.tag & e) === e) {
            var y = o.inst, A = y.destroy;
            if (A !== void 0) {
              y.destroy = void 0, u = n;
              var H = a, nt = A;
              try {
                nt();
              } catch (ft) {
                Pe(
                  u,
                  H,
                  ft
                );
              }
            }
          }
          o = o.next;
        } while (o !== f);
      }
    } catch (ft) {
      Pe(n, n.return, ft);
    }
  }
  function Gg(e) {
    var n = e.updateQueue;
    if (n !== null) {
      var a = e.stateNode;
      try {
        Um(n, a);
      } catch (o) {
        Pe(e, e.return, o);
      }
    }
  }
  function Vg(e, n, a) {
    a.props = vs(
      e.type,
      e.memoizedProps
    ), a.state = e.memoizedState;
    try {
      a.componentWillUnmount();
    } catch (o) {
      Pe(e, n, o);
    }
  }
  function Oo(e, n) {
    try {
      var a = e.ref;
      if (a !== null) {
        switch (e.tag) {
          case 26:
          case 27:
          case 5:
            var o = e.stateNode;
            break;
          case 30:
            o = e.stateNode;
            break;
          default:
            o = e.stateNode;
        }
        typeof a == "function" ? e.refCleanup = a(o) : a.current = o;
      }
    } catch (u) {
      Pe(e, n, u);
    }
  }
  function zi(e, n) {
    var a = e.ref, o = e.refCleanup;
    if (a !== null)
      if (typeof o == "function")
        try {
          o();
        } catch (u) {
          Pe(e, n, u);
        } finally {
          e.refCleanup = null, e = e.alternate, e != null && (e.refCleanup = null);
        }
      else if (typeof a == "function")
        try {
          a(null);
        } catch (u) {
          Pe(e, n, u);
        }
      else a.current = null;
  }
  function kg(e) {
    var n = e.type, a = e.memoizedProps, o = e.stateNode;
    try {
      t: switch (n) {
        case "button":
        case "input":
        case "select":
        case "textarea":
          a.autoFocus && o.focus();
          break t;
        case "img":
          a.src ? o.src = a.src : a.srcSet && (o.srcset = a.srcSet);
      }
    } catch (u) {
      Pe(e, e.return, u);
    }
  }
  function Xf(e, n, a) {
    try {
      var o = e.stateNode;
      oS(o, e.type, a, n), o[bn] = n;
    } catch (u) {
      Pe(e, e.return, u);
    }
  }
  function Xg(e) {
    return e.tag === 5 || e.tag === 3 || e.tag === 26 || e.tag === 27 && Pa(e.type) || e.tag === 4;
  }
  function Wf(e) {
    t: for (; ; ) {
      for (; e.sibling === null; ) {
        if (e.return === null || Xg(e.return)) return null;
        e = e.return;
      }
      for (e.sibling.return = e.return, e = e.sibling; e.tag !== 5 && e.tag !== 6 && e.tag !== 18; ) {
        if (e.tag === 27 && Pa(e.type) || e.flags & 2 || e.child === null || e.tag === 4) continue t;
        e.child.return = e, e = e.child;
      }
      if (!(e.flags & 2)) return e.stateNode;
    }
  }
  function Yf(e, n, a) {
    var o = e.tag;
    if (o === 5 || o === 6)
      e = e.stateNode, n ? (a.nodeType === 9 ? a.body : a.nodeName === "HTML" ? a.ownerDocument.body : a).insertBefore(e, n) : (n = a.nodeType === 9 ? a.body : a.nodeName === "HTML" ? a.ownerDocument.body : a, n.appendChild(e), a = a._reactRootContainer, a != null || n.onclick !== null || (n.onclick = ki));
    else if (o !== 4 && (o === 27 && Pa(e.type) && (a = e.stateNode, n = null), e = e.child, e !== null))
      for (Yf(e, n, a), e = e.sibling; e !== null; )
        Yf(e, n, a), e = e.sibling;
  }
  function Ql(e, n, a) {
    var o = e.tag;
    if (o === 5 || o === 6)
      e = e.stateNode, n ? a.insertBefore(e, n) : a.appendChild(e);
    else if (o !== 4 && (o === 27 && Pa(e.type) && (a = e.stateNode), e = e.child, e !== null))
      for (Ql(e, n, a), e = e.sibling; e !== null; )
        Ql(e, n, a), e = e.sibling;
  }
  function Wg(e) {
    var n = e.stateNode, a = e.memoizedProps;
    try {
      for (var o = e.type, u = n.attributes; u.length; )
        n.removeAttributeNode(u[0]);
      wn(n, o, a), n[$e] = e, n[bn] = a;
    } catch (f) {
      Pe(e, e.return, f);
    }
  }
  var $i = !1, cn = !1, qf = !1, Yg = typeof WeakSet == "function" ? WeakSet : Set, yn = null;
  function Hy(e, n) {
    if (e = e.containerInfo, ph = vc, e = am(e), Fu(e)) {
      if ("selectionStart" in e)
        var a = {
          start: e.selectionStart,
          end: e.selectionEnd
        };
      else
        t: {
          a = (a = e.ownerDocument) && a.defaultView || window;
          var o = a.getSelection && a.getSelection();
          if (o && o.rangeCount !== 0) {
            a = o.anchorNode;
            var u = o.anchorOffset, f = o.focusNode;
            o = o.focusOffset;
            try {
              a.nodeType, f.nodeType;
            } catch {
              a = null;
              break t;
            }
            var y = 0, A = -1, H = -1, nt = 0, ft = 0, gt = e, at = null;
            e: for (; ; ) {
              for (var ct; gt !== a || u !== 0 && gt.nodeType !== 3 || (A = y + u), gt !== f || o !== 0 && gt.nodeType !== 3 || (H = y + o), gt.nodeType === 3 && (y += gt.nodeValue.length), (ct = gt.firstChild) !== null; )
                at = gt, gt = ct;
              for (; ; ) {
                if (gt === e) break e;
                if (at === a && ++nt === u && (A = y), at === f && ++ft === o && (H = y), (ct = gt.nextSibling) !== null) break;
                gt = at, at = gt.parentNode;
              }
              gt = ct;
            }
            a = A === -1 || H === -1 ? null : { start: A, end: H };
          } else a = null;
        }
      a = a || { start: 0, end: 0 };
    } else a = null;
    for (mh = { focusedElem: e, selectionRange: a }, vc = !1, yn = n; yn !== null; )
      if (n = yn, e = n.child, (n.subtreeFlags & 1028) !== 0 && e !== null)
        e.return = n, yn = e;
      else
        for (; yn !== null; ) {
          switch (n = yn, f = n.alternate, e = n.flags, n.tag) {
            case 0:
              if ((e & 4) !== 0 && (e = n.updateQueue, e = e !== null ? e.events : null, e !== null))
                for (a = 0; a < e.length; a++)
                  u = e[a], u.ref.impl = u.nextImpl;
              break;
            case 11:
            case 15:
              break;
            case 1:
              if ((e & 1024) !== 0 && f !== null) {
                e = void 0, a = n, u = f.memoizedProps, f = f.memoizedState, o = a.stateNode;
                try {
                  var Vt = vs(
                    a.type,
                    u
                  );
                  e = o.getSnapshotBeforeUpdate(
                    Vt,
                    f
                  ), o.__reactInternalSnapshotBeforeUpdate = e;
                } catch (Jt) {
                  Pe(
                    a,
                    a.return,
                    Jt
                  );
                }
              }
              break;
            case 3:
              if ((e & 1024) !== 0) {
                if (e = n.stateNode.containerInfo, a = e.nodeType, a === 9)
                  vh(e);
                else if (a === 1)
                  switch (e.nodeName) {
                    case "HEAD":
                    case "HTML":
                    case "BODY":
                      vh(e);
                      break;
                    default:
                      e.textContent = "";
                  }
              }
              break;
            case 5:
            case 26:
            case 27:
            case 6:
            case 4:
            case 17:
              break;
            default:
              if ((e & 1024) !== 0) throw Error(s(163));
          }
          if (e = n.sibling, e !== null) {
            e.return = n.return, yn = e;
            break;
          }
          yn = n.return;
        }
  }
  function qg(e, n, a) {
    var o = a.flags;
    switch (a.tag) {
      case 0:
      case 11:
      case 15:
        ea(e, a), o & 4 && No(5, a);
        break;
      case 1:
        if (ea(e, a), o & 4)
          if (e = a.stateNode, n === null)
            try {
              e.componentDidMount();
            } catch (y) {
              Pe(a, a.return, y);
            }
          else {
            var u = vs(
              a.type,
              n.memoizedProps
            );
            n = n.memoizedState;
            try {
              e.componentDidUpdate(
                u,
                n,
                e.__reactInternalSnapshotBeforeUpdate
              );
            } catch (y) {
              Pe(
                a,
                a.return,
                y
              );
            }
          }
        o & 64 && Gg(a), o & 512 && Oo(a, a.return);
        break;
      case 3:
        if (ea(e, a), o & 64 && (e = a.updateQueue, e !== null)) {
          if (n = null, a.child !== null)
            switch (a.child.tag) {
              case 27:
              case 5:
                n = a.child.stateNode;
                break;
              case 1:
                n = a.child.stateNode;
            }
          try {
            Um(e, n);
          } catch (y) {
            Pe(a, a.return, y);
          }
        }
        break;
      case 27:
        n === null && o & 4 && Wg(a);
      case 26:
      case 5:
        ea(e, a), n === null && o & 4 && kg(a), o & 512 && Oo(a, a.return);
        break;
      case 12:
        ea(e, a);
        break;
      case 31:
        ea(e, a), o & 4 && Kg(e, a);
        break;
      case 13:
        ea(e, a), o & 4 && Qg(e, a), o & 64 && (e = a.memoizedState, e !== null && (e = e.dehydrated, e !== null && (a = Zy.bind(
          null,
          a
        ), mS(e, a))));
        break;
      case 22:
        if (o = a.memoizedState !== null || $i, !o) {
          n = n !== null && n.memoizedState !== null || cn, u = $i;
          var f = cn;
          $i = o, (cn = n) && !f ? na(
            e,
            a,
            (a.subtreeFlags & 8772) !== 0
          ) : ea(e, a), $i = u, cn = f;
        }
        break;
      case 30:
        break;
      default:
        ea(e, a);
    }
  }
  function jg(e) {
    var n = e.alternate;
    n !== null && (e.alternate = null, jg(n)), e.child = null, e.deletions = null, e.sibling = null, e.tag === 5 && (n = e.stateNode, n !== null && oo(n)), e.stateNode = null, e.return = null, e.dependencies = null, e.memoizedProps = null, e.memoizedState = null, e.pendingProps = null, e.stateNode = null, e.updateQueue = null;
  }
  var Qe = null, jn = !1;
  function ta(e, n, a) {
    for (a = a.child; a !== null; )
      Zg(e, n, a), a = a.sibling;
  }
  function Zg(e, n, a) {
    if (Wt && typeof Wt.onCommitFiberUnmount == "function")
      try {
        Wt.onCommitFiberUnmount(jt, a);
      } catch {
      }
    switch (a.tag) {
      case 26:
        cn || zi(a, n), ta(
          e,
          n,
          a
        ), a.memoizedState ? a.memoizedState.count-- : a.stateNode && (a = a.stateNode, a.parentNode.removeChild(a));
        break;
      case 27:
        cn || zi(a, n);
        var o = Qe, u = jn;
        Pa(a.type) && (Qe = a.stateNode, jn = !1), ta(
          e,
          n,
          a
        ), ko(a.stateNode), Qe = o, jn = u;
        break;
      case 5:
        cn || zi(a, n);
      case 6:
        if (o = Qe, u = jn, Qe = null, ta(
          e,
          n,
          a
        ), Qe = o, jn = u, Qe !== null)
          if (jn)
            try {
              (Qe.nodeType === 9 ? Qe.body : Qe.nodeName === "HTML" ? Qe.ownerDocument.body : Qe).removeChild(a.stateNode);
            } catch (f) {
              Pe(
                a,
                n,
                f
              );
            }
          else
            try {
              Qe.removeChild(a.stateNode);
            } catch (f) {
              Pe(
                a,
                n,
                f
              );
            }
        break;
      case 18:
        Qe !== null && (jn ? (e = Qe, G_(
          e.nodeType === 9 ? e.body : e.nodeName === "HTML" ? e.ownerDocument.body : e,
          a.stateNode
        ), vr(e)) : G_(Qe, a.stateNode));
        break;
      case 4:
        o = Qe, u = jn, Qe = a.stateNode.containerInfo, jn = !0, ta(
          e,
          n,
          a
        ), Qe = o, jn = u;
        break;
      case 0:
      case 11:
      case 14:
      case 15:
        Ca(2, a, n), cn || Ca(4, a, n), ta(
          e,
          n,
          a
        );
        break;
      case 1:
        cn || (zi(a, n), o = a.stateNode, typeof o.componentWillUnmount == "function" && Vg(
          a,
          n,
          o
        )), ta(
          e,
          n,
          a
        );
        break;
      case 21:
        ta(
          e,
          n,
          a
        );
        break;
      case 22:
        cn = (o = cn) || a.memoizedState !== null, ta(
          e,
          n,
          a
        ), cn = o;
        break;
      default:
        ta(
          e,
          n,
          a
        );
    }
  }
  function Kg(e, n) {
    if (n.memoizedState === null && (e = n.alternate, e !== null && (e = e.memoizedState, e !== null))) {
      e = e.dehydrated;
      try {
        vr(e);
      } catch (a) {
        Pe(n, n.return, a);
      }
    }
  }
  function Qg(e, n) {
    if (n.memoizedState === null && (e = n.alternate, e !== null && (e = e.memoizedState, e !== null && (e = e.dehydrated, e !== null))))
      try {
        vr(e);
      } catch (a) {
        Pe(n, n.return, a);
      }
  }
  function Gy(e) {
    switch (e.tag) {
      case 31:
      case 13:
      case 19:
        var n = e.stateNode;
        return n === null && (n = e.stateNode = new Yg()), n;
      case 22:
        return e = e.stateNode, n = e._retryCache, n === null && (n = e._retryCache = new Yg()), n;
      default:
        throw Error(s(435, e.tag));
    }
  }
  function Jl(e, n) {
    var a = Gy(e);
    n.forEach(function(o) {
      if (!a.has(o)) {
        a.add(o);
        var u = Ky.bind(null, e, o);
        o.then(u, u);
      }
    });
  }
  function Zn(e, n) {
    var a = n.deletions;
    if (a !== null)
      for (var o = 0; o < a.length; o++) {
        var u = a[o], f = e, y = n, A = y;
        t: for (; A !== null; ) {
          switch (A.tag) {
            case 27:
              if (Pa(A.type)) {
                Qe = A.stateNode, jn = !1;
                break t;
              }
              break;
            case 5:
              Qe = A.stateNode, jn = !1;
              break t;
            case 3:
            case 4:
              Qe = A.stateNode.containerInfo, jn = !0;
              break t;
          }
          A = A.return;
        }
        if (Qe === null) throw Error(s(160));
        Zg(f, y, u), Qe = null, jn = !1, f = u.alternate, f !== null && (f.return = null), u.return = null;
      }
    if (n.subtreeFlags & 13886)
      for (n = n.child; n !== null; )
        Jg(n, e), n = n.sibling;
  }
  var Ci = null;
  function Jg(e, n) {
    var a = e.alternate, o = e.flags;
    switch (e.tag) {
      case 0:
      case 11:
      case 14:
      case 15:
        Zn(n, e), Kn(e), o & 4 && (Ca(3, e, e.return), No(3, e), Ca(5, e, e.return));
        break;
      case 1:
        Zn(n, e), Kn(e), o & 512 && (cn || a === null || zi(a, a.return)), o & 64 && $i && (e = e.updateQueue, e !== null && (o = e.callbacks, o !== null && (a = e.shared.hiddenCallbacks, e.shared.hiddenCallbacks = a === null ? o : a.concat(o))));
        break;
      case 26:
        var u = Ci;
        if (Zn(n, e), Kn(e), o & 512 && (cn || a === null || zi(a, a.return)), o & 4) {
          var f = a !== null ? a.memoizedState : null;
          if (o = e.memoizedState, a === null)
            if (o === null)
              if (e.stateNode === null) {
                t: {
                  o = e.type, a = e.memoizedProps, u = u.ownerDocument || u;
                  e: switch (o) {
                    case "title":
                      f = u.getElementsByTagName("title")[0], (!f || f[as] || f[$e] || f.namespaceURI === "http://www.w3.org/2000/svg" || f.hasAttribute("itemprop")) && (f = u.createElement(o), u.head.insertBefore(
                        f,
                        u.querySelector("head > title")
                      )), wn(f, o, a), f[$e] = e, X(f), o = f;
                      break t;
                    case "link":
                      var y = J_(
                        "link",
                        "href",
                        u
                      ).get(o + (a.href || ""));
                      if (y) {
                        for (var A = 0; A < y.length; A++)
                          if (f = y[A], f.getAttribute("href") === (a.href == null || a.href === "" ? null : a.href) && f.getAttribute("rel") === (a.rel == null ? null : a.rel) && f.getAttribute("title") === (a.title == null ? null : a.title) && f.getAttribute("crossorigin") === (a.crossOrigin == null ? null : a.crossOrigin)) {
                            y.splice(A, 1);
                            break e;
                          }
                      }
                      f = u.createElement(o), wn(f, o, a), u.head.appendChild(f);
                      break;
                    case "meta":
                      if (y = J_(
                        "meta",
                        "content",
                        u
                      ).get(o + (a.content || ""))) {
                        for (A = 0; A < y.length; A++)
                          if (f = y[A], f.getAttribute("content") === (a.content == null ? null : "" + a.content) && f.getAttribute("name") === (a.name == null ? null : a.name) && f.getAttribute("property") === (a.property == null ? null : a.property) && f.getAttribute("http-equiv") === (a.httpEquiv == null ? null : a.httpEquiv) && f.getAttribute("charset") === (a.charSet == null ? null : a.charSet)) {
                            y.splice(A, 1);
                            break e;
                          }
                      }
                      f = u.createElement(o), wn(f, o, a), u.head.appendChild(f);
                      break;
                    default:
                      throw Error(s(468, o));
                  }
                  f[$e] = e, X(f), o = f;
                }
                e.stateNode = o;
              } else
                $_(
                  u,
                  e.type,
                  e.stateNode
                );
            else
              e.stateNode = Q_(
                u,
                o,
                e.memoizedProps
              );
          else
            f !== o ? (f === null ? a.stateNode !== null && (a = a.stateNode, a.parentNode.removeChild(a)) : f.count--, o === null ? $_(
              u,
              e.type,
              e.stateNode
            ) : Q_(
              u,
              o,
              e.memoizedProps
            )) : o === null && e.stateNode !== null && Xf(
              e,
              e.memoizedProps,
              a.memoizedProps
            );
        }
        break;
      case 27:
        Zn(n, e), Kn(e), o & 512 && (cn || a === null || zi(a, a.return)), a !== null && o & 4 && Xf(
          e,
          e.memoizedProps,
          a.memoizedProps
        );
        break;
      case 5:
        if (Zn(n, e), Kn(e), o & 512 && (cn || a === null || zi(a, a.return)), e.flags & 32) {
          u = e.stateNode;
          try {
            Yn(u, "");
          } catch (Vt) {
            Pe(e, e.return, Vt);
          }
        }
        o & 4 && e.stateNode != null && (u = e.memoizedProps, Xf(
          e,
          u,
          a !== null ? a.memoizedProps : u
        )), o & 1024 && (qf = !0);
        break;
      case 6:
        if (Zn(n, e), Kn(e), o & 4) {
          if (e.stateNode === null)
            throw Error(s(162));
          o = e.memoizedProps, a = e.stateNode;
          try {
            a.nodeValue = o;
          } catch (Vt) {
            Pe(e, e.return, Vt);
          }
        }
        break;
      case 3:
        if (pc = null, u = Ci, Ci = hc(n.containerInfo), Zn(n, e), Ci = u, Kn(e), o & 4 && a !== null && a.memoizedState.isDehydrated)
          try {
            vr(n.containerInfo);
          } catch (Vt) {
            Pe(e, e.return, Vt);
          }
        qf && (qf = !1, $g(e));
        break;
      case 4:
        o = Ci, Ci = hc(
          e.stateNode.containerInfo
        ), Zn(n, e), Kn(e), Ci = o;
        break;
      case 12:
        Zn(n, e), Kn(e);
        break;
      case 31:
        Zn(n, e), Kn(e), o & 4 && (o = e.updateQueue, o !== null && (e.updateQueue = null, Jl(e, o)));
        break;
      case 13:
        Zn(n, e), Kn(e), e.child.flags & 8192 && e.memoizedState !== null != (a !== null && a.memoizedState !== null) && (tc = dt()), o & 4 && (o = e.updateQueue, o !== null && (e.updateQueue = null, Jl(e, o)));
        break;
      case 22:
        u = e.memoizedState !== null;
        var H = a !== null && a.memoizedState !== null, nt = $i, ft = cn;
        if ($i = nt || u, cn = ft || H, Zn(n, e), cn = ft, $i = nt, Kn(e), o & 8192)
          t: for (n = e.stateNode, n._visibility = u ? n._visibility & -2 : n._visibility | 1, u && (a === null || H || $i || cn || xs(e)), a = null, n = e; ; ) {
            if (n.tag === 5 || n.tag === 26) {
              if (a === null) {
                H = a = n;
                try {
                  if (f = H.stateNode, u)
                    y = f.style, typeof y.setProperty == "function" ? y.setProperty("display", "none", "important") : y.display = "none";
                  else {
                    A = H.stateNode;
                    var gt = H.memoizedProps.style, at = gt != null && gt.hasOwnProperty("display") ? gt.display : null;
                    A.style.display = at == null || typeof at == "boolean" ? "" : ("" + at).trim();
                  }
                } catch (Vt) {
                  Pe(H, H.return, Vt);
                }
              }
            } else if (n.tag === 6) {
              if (a === null) {
                H = n;
                try {
                  H.stateNode.nodeValue = u ? "" : H.memoizedProps;
                } catch (Vt) {
                  Pe(H, H.return, Vt);
                }
              }
            } else if (n.tag === 18) {
              if (a === null) {
                H = n;
                try {
                  var ct = H.stateNode;
                  u ? V_(ct, !0) : V_(H.stateNode, !1);
                } catch (Vt) {
                  Pe(H, H.return, Vt);
                }
              }
            } else if ((n.tag !== 22 && n.tag !== 23 || n.memoizedState === null || n === e) && n.child !== null) {
              n.child.return = n, n = n.child;
              continue;
            }
            if (n === e) break t;
            for (; n.sibling === null; ) {
              if (n.return === null || n.return === e) break t;
              a === n && (a = null), n = n.return;
            }
            a === n && (a = null), n.sibling.return = n.return, n = n.sibling;
          }
        o & 4 && (o = e.updateQueue, o !== null && (a = o.retryQueue, a !== null && (o.retryQueue = null, Jl(e, a))));
        break;
      case 19:
        Zn(n, e), Kn(e), o & 4 && (o = e.updateQueue, o !== null && (e.updateQueue = null, Jl(e, o)));
        break;
      case 30:
        break;
      case 21:
        break;
      default:
        Zn(n, e), Kn(e);
    }
  }
  function Kn(e) {
    var n = e.flags;
    if (n & 2) {
      try {
        for (var a, o = e.return; o !== null; ) {
          if (Xg(o)) {
            a = o;
            break;
          }
          o = o.return;
        }
        if (a == null) throw Error(s(160));
        switch (a.tag) {
          case 27:
            var u = a.stateNode, f = Wf(e);
            Ql(e, f, u);
            break;
          case 5:
            var y = a.stateNode;
            a.flags & 32 && (Yn(y, ""), a.flags &= -33);
            var A = Wf(e);
            Ql(e, A, y);
            break;
          case 3:
          case 4:
            var H = a.stateNode.containerInfo, nt = Wf(e);
            Yf(
              e,
              nt,
              H
            );
            break;
          default:
            throw Error(s(161));
        }
      } catch (ft) {
        Pe(e, e.return, ft);
      }
      e.flags &= -3;
    }
    n & 4096 && (e.flags &= -4097);
  }
  function $g(e) {
    if (e.subtreeFlags & 1024)
      for (e = e.child; e !== null; ) {
        var n = e;
        $g(n), n.tag === 5 && n.flags & 1024 && n.stateNode.reset(), e = e.sibling;
      }
  }
  function ea(e, n) {
    if (n.subtreeFlags & 8772)
      for (n = n.child; n !== null; )
        qg(e, n.alternate, n), n = n.sibling;
  }
  function xs(e) {
    for (e = e.child; e !== null; ) {
      var n = e;
      switch (n.tag) {
        case 0:
        case 11:
        case 14:
        case 15:
          Ca(4, n, n.return), xs(n);
          break;
        case 1:
          zi(n, n.return);
          var a = n.stateNode;
          typeof a.componentWillUnmount == "function" && Vg(
            n,
            n.return,
            a
          ), xs(n);
          break;
        case 27:
          ko(n.stateNode);
        case 26:
        case 5:
          zi(n, n.return), xs(n);
          break;
        case 22:
          n.memoizedState === null && xs(n);
          break;
        case 30:
          xs(n);
          break;
        default:
          xs(n);
      }
      e = e.sibling;
    }
  }
  function na(e, n, a) {
    for (a = a && (n.subtreeFlags & 8772) !== 0, n = n.child; n !== null; ) {
      var o = n.alternate, u = e, f = n, y = f.flags;
      switch (f.tag) {
        case 0:
        case 11:
        case 15:
          na(
            u,
            f,
            a
          ), No(4, f);
          break;
        case 1:
          if (na(
            u,
            f,
            a
          ), o = f, u = o.stateNode, typeof u.componentDidMount == "function")
            try {
              u.componentDidMount();
            } catch (nt) {
              Pe(o, o.return, nt);
            }
          if (o = f, u = o.updateQueue, u !== null) {
            var A = o.stateNode;
            try {
              var H = u.shared.hiddenCallbacks;
              if (H !== null)
                for (u.shared.hiddenCallbacks = null, u = 0; u < H.length; u++)
                  Dm(H[u], A);
            } catch (nt) {
              Pe(o, o.return, nt);
            }
          }
          a && y & 64 && Gg(f), Oo(f, f.return);
          break;
        case 27:
          Wg(f);
        case 26:
        case 5:
          na(
            u,
            f,
            a
          ), a && o === null && y & 4 && kg(f), Oo(f, f.return);
          break;
        case 12:
          na(
            u,
            f,
            a
          );
          break;
        case 31:
          na(
            u,
            f,
            a
          ), a && y & 4 && Kg(u, f);
          break;
        case 13:
          na(
            u,
            f,
            a
          ), a && y & 4 && Qg(u, f);
          break;
        case 22:
          f.memoizedState === null && na(
            u,
            f,
            a
          ), Oo(f, f.return);
          break;
        case 30:
          break;
        default:
          na(
            u,
            f,
            a
          );
      }
      n = n.sibling;
    }
  }
  function jf(e, n) {
    var a = null;
    e !== null && e.memoizedState !== null && e.memoizedState.cachePool !== null && (a = e.memoizedState.cachePool.pool), e = null, n.memoizedState !== null && n.memoizedState.cachePool !== null && (e = n.memoizedState.cachePool.pool), e !== a && (e != null && e.refCount++, a != null && yo(a));
  }
  function Zf(e, n) {
    e = null, n.alternate !== null && (e = n.alternate.memoizedState.cache), n = n.memoizedState.cache, n !== e && (n.refCount++, e != null && yo(e));
  }
  function wi(e, n, a, o) {
    if (n.subtreeFlags & 10256)
      for (n = n.child; n !== null; )
        t_(
          e,
          n,
          a,
          o
        ), n = n.sibling;
  }
  function t_(e, n, a, o) {
    var u = n.flags;
    switch (n.tag) {
      case 0:
      case 11:
      case 15:
        wi(
          e,
          n,
          a,
          o
        ), u & 2048 && No(9, n);
        break;
      case 1:
        wi(
          e,
          n,
          a,
          o
        );
        break;
      case 3:
        wi(
          e,
          n,
          a,
          o
        ), u & 2048 && (e = null, n.alternate !== null && (e = n.alternate.memoizedState.cache), n = n.memoizedState.cache, n !== e && (n.refCount++, e != null && yo(e)));
        break;
      case 12:
        if (u & 2048) {
          wi(
            e,
            n,
            a,
            o
          ), e = n.stateNode;
          try {
            var f = n.memoizedProps, y = f.id, A = f.onPostCommit;
            typeof A == "function" && A(
              y,
              n.alternate === null ? "mount" : "update",
              e.passiveEffectDuration,
              -0
            );
          } catch (H) {
            Pe(n, n.return, H);
          }
        } else
          wi(
            e,
            n,
            a,
            o
          );
        break;
      case 31:
        wi(
          e,
          n,
          a,
          o
        );
        break;
      case 13:
        wi(
          e,
          n,
          a,
          o
        );
        break;
      case 23:
        break;
      case 22:
        f = n.stateNode, y = n.alternate, n.memoizedState !== null ? f._visibility & 2 ? wi(
          e,
          n,
          a,
          o
        ) : Po(e, n) : f._visibility & 2 ? wi(
          e,
          n,
          a,
          o
        ) : (f._visibility |= 2, or(
          e,
          n,
          a,
          o,
          (n.subtreeFlags & 10256) !== 0 || !1
        )), u & 2048 && jf(y, n);
        break;
      case 24:
        wi(
          e,
          n,
          a,
          o
        ), u & 2048 && Zf(n.alternate, n);
        break;
      default:
        wi(
          e,
          n,
          a,
          o
        );
    }
  }
  function or(e, n, a, o, u) {
    for (u = u && ((n.subtreeFlags & 10256) !== 0 || !1), n = n.child; n !== null; ) {
      var f = e, y = n, A = a, H = o, nt = y.flags;
      switch (y.tag) {
        case 0:
        case 11:
        case 15:
          or(
            f,
            y,
            A,
            H,
            u
          ), No(8, y);
          break;
        case 23:
          break;
        case 22:
          var ft = y.stateNode;
          y.memoizedState !== null ? ft._visibility & 2 ? or(
            f,
            y,
            A,
            H,
            u
          ) : Po(
            f,
            y
          ) : (ft._visibility |= 2, or(
            f,
            y,
            A,
            H,
            u
          )), u && nt & 2048 && jf(
            y.alternate,
            y
          );
          break;
        case 24:
          or(
            f,
            y,
            A,
            H,
            u
          ), u && nt & 2048 && Zf(y.alternate, y);
          break;
        default:
          or(
            f,
            y,
            A,
            H,
            u
          );
      }
      n = n.sibling;
    }
  }
  function Po(e, n) {
    if (n.subtreeFlags & 10256)
      for (n = n.child; n !== null; ) {
        var a = e, o = n, u = o.flags;
        switch (o.tag) {
          case 22:
            Po(a, o), u & 2048 && jf(
              o.alternate,
              o
            );
            break;
          case 24:
            Po(a, o), u & 2048 && Zf(o.alternate, o);
            break;
          default:
            Po(a, o);
        }
        n = n.sibling;
      }
  }
  var zo = 8192;
  function lr(e, n, a) {
    if (e.subtreeFlags & zo)
      for (e = e.child; e !== null; )
        e_(
          e,
          n,
          a
        ), e = e.sibling;
  }
  function e_(e, n, a) {
    switch (e.tag) {
      case 26:
        lr(
          e,
          n,
          a
        ), e.flags & zo && e.memoizedState !== null && RS(
          a,
          Ci,
          e.memoizedState,
          e.memoizedProps
        );
        break;
      case 5:
        lr(
          e,
          n,
          a
        );
        break;
      case 3:
      case 4:
        var o = Ci;
        Ci = hc(e.stateNode.containerInfo), lr(
          e,
          n,
          a
        ), Ci = o;
        break;
      case 22:
        e.memoizedState === null && (o = e.alternate, o !== null && o.memoizedState !== null ? (o = zo, zo = 16777216, lr(
          e,
          n,
          a
        ), zo = o) : lr(
          e,
          n,
          a
        ));
        break;
      default:
        lr(
          e,
          n,
          a
        );
    }
  }
  function n_(e) {
    var n = e.alternate;
    if (n !== null && (e = n.child, e !== null)) {
      n.child = null;
      do
        n = e.sibling, e.sibling = null, e = n;
      while (e !== null);
    }
  }
  function Bo(e) {
    var n = e.deletions;
    if ((e.flags & 16) !== 0) {
      if (n !== null)
        for (var a = 0; a < n.length; a++) {
          var o = n[a];
          yn = o, a_(
            o,
            e
          );
        }
      n_(e);
    }
    if (e.subtreeFlags & 10256)
      for (e = e.child; e !== null; )
        i_(e), e = e.sibling;
  }
  function i_(e) {
    switch (e.tag) {
      case 0:
      case 11:
      case 15:
        Bo(e), e.flags & 2048 && Ca(9, e, e.return);
        break;
      case 3:
        Bo(e);
        break;
      case 12:
        Bo(e);
        break;
      case 22:
        var n = e.stateNode;
        e.memoizedState !== null && n._visibility & 2 && (e.return === null || e.return.tag !== 13) ? (n._visibility &= -3, $l(e)) : Bo(e);
        break;
      default:
        Bo(e);
    }
  }
  function $l(e) {
    var n = e.deletions;
    if ((e.flags & 16) !== 0) {
      if (n !== null)
        for (var a = 0; a < n.length; a++) {
          var o = n[a];
          yn = o, a_(
            o,
            e
          );
        }
      n_(e);
    }
    for (e = e.child; e !== null; ) {
      switch (n = e, n.tag) {
        case 0:
        case 11:
        case 15:
          Ca(8, n, n.return), $l(n);
          break;
        case 22:
          a = n.stateNode, a._visibility & 2 && (a._visibility &= -3, $l(n));
          break;
        default:
          $l(n);
      }
      e = e.sibling;
    }
  }
  function a_(e, n) {
    for (; yn !== null; ) {
      var a = yn;
      switch (a.tag) {
        case 0:
        case 11:
        case 15:
          Ca(8, a, n);
          break;
        case 23:
        case 22:
          if (a.memoizedState !== null && a.memoizedState.cachePool !== null) {
            var o = a.memoizedState.cachePool.pool;
            o != null && o.refCount++;
          }
          break;
        case 24:
          yo(a.memoizedState.cache);
      }
      if (o = a.child, o !== null) o.return = a, yn = o;
      else
        t: for (a = e; yn !== null; ) {
          o = yn;
          var u = o.sibling, f = o.return;
          if (jg(o), o === a) {
            yn = null;
            break t;
          }
          if (u !== null) {
            u.return = f, yn = u;
            break t;
          }
          yn = f;
        }
    }
  }
  var Vy = {
    getCacheForType: function(e) {
      var n = Rn(rn), a = n.data.get(e);
      return a === void 0 && (a = e(), n.data.set(e, a)), a;
    },
    cacheSignal: function() {
      return Rn(rn).controller.signal;
    }
  }, ky = typeof WeakMap == "function" ? WeakMap : Map, Le = 0, Ye = null, me = null, ye = 0, Oe = 0, si = null, wa = !1, cr = !1, Kf = !1, ia = 0, nn = 0, Da = 0, ys = 0, Qf = 0, ri = 0, ur = 0, Io = null, Qn = null, Jf = !1, tc = 0, s_ = 0, ec = 1 / 0, nc = null, Ua = null, pn = 0, La = null, fr = null, aa = 0, $f = 0, th = null, r_ = null, Fo = 0, eh = null;
  function oi() {
    return (Le & 2) !== 0 && ye !== 0 ? ye & -ye : z.T !== null ? oh() : so();
  }
  function o_() {
    if (ri === 0)
      if ((ye & 536870912) === 0 || be) {
        var e = ut;
        ut <<= 1, (ut & 3932160) === 0 && (ut = 262144), ri = e;
      } else ri = 536870912;
    return e = ii.current, e !== null && (e.flags |= 32), ri;
  }
  function Jn(e, n, a) {
    (e === Ye && (Oe === 2 || Oe === 9) || e.cancelPendingCommit !== null) && (hr(e, 0), Na(
      e,
      ye,
      ri,
      !1
    )), En(e, a), ((Le & 2) === 0 || e !== Ye) && (e === Ye && ((Le & 2) === 0 && (ys |= a), nn === 4 && Na(
      e,
      ye,
      ri,
      !1
    )), Bi(e));
  }
  function l_(e, n, a) {
    if ((Le & 6) !== 0) throw Error(s(327));
    var o = !a && (n & 127) === 0 && (n & e.expiredLanes) === 0 || ee(e, n), u = o ? Yy(e, n) : ih(e, n, !0), f = o;
    do {
      if (u === 0) {
        cr && !o && Na(e, n, 0, !1);
        break;
      } else {
        if (a = e.current.alternate, f && !Xy(a)) {
          u = ih(e, n, !1), f = !1;
          continue;
        }
        if (u === 2) {
          if (f = n, e.errorRecoveryDisabledLanes & f)
            var y = 0;
          else
            y = e.pendingLanes & -536870913, y = y !== 0 ? y : y & 536870912 ? 536870912 : 0;
          if (y !== 0) {
            n = y;
            t: {
              var A = e;
              u = Io;
              var H = A.current.memoizedState.isDehydrated;
              if (H && (hr(A, y).flags |= 256), y = ih(
                A,
                y,
                !1
              ), y !== 2) {
                if (Kf && !H) {
                  A.errorRecoveryDisabledLanes |= f, ys |= f, u = 4;
                  break t;
                }
                f = Qn, Qn = u, f !== null && (Qn === null ? Qn = f : Qn.push.apply(
                  Qn,
                  f
                ));
              }
              u = y;
            }
            if (f = !1, u !== 2) continue;
          }
        }
        if (u === 1) {
          hr(e, 0), Na(e, n, 0, !0);
          break;
        }
        t: {
          switch (o = e, f = u, f) {
            case 0:
            case 1:
              throw Error(s(345));
            case 4:
              if ((n & 4194048) !== n) break;
            case 6:
              Na(
                o,
                n,
                ri,
                !wa
              );
              break t;
            case 2:
              Qn = null;
              break;
            case 3:
            case 5:
              break;
            default:
              throw Error(s(329));
          }
          if ((n & 62914560) === n && (u = tc + 300 - dt(), 10 < u)) {
            if (Na(
              o,
              n,
              ri,
              !wa
            ), Nt(o, 0, !0) !== 0) break t;
            aa = n, o.timeoutHandle = F_(
              c_.bind(
                null,
                o,
                a,
                Qn,
                nc,
                Jf,
                n,
                ri,
                ys,
                ur,
                wa,
                f,
                "Throttled",
                -0,
                0
              ),
              u
            );
            break t;
          }
          c_(
            o,
            a,
            Qn,
            nc,
            Jf,
            n,
            ri,
            ys,
            ur,
            wa,
            f,
            null,
            -0,
            0
          );
        }
      }
      break;
    } while (!0);
    Bi(e);
  }
  function c_(e, n, a, o, u, f, y, A, H, nt, ft, gt, at, ct) {
    if (e.timeoutHandle = -1, gt = n.subtreeFlags, gt & 8192 || (gt & 16785408) === 16785408) {
      gt = {
        stylesheets: null,
        count: 0,
        imgCount: 0,
        imgBytes: 0,
        suspenseyImages: [],
        waitingForImages: !0,
        waitingForViewTransition: !1,
        unsuspend: ki
      }, e_(
        n,
        f,
        gt
      );
      var Vt = (f & 62914560) === f ? tc - dt() : (f & 4194048) === f ? s_ - dt() : 0;
      if (Vt = CS(
        gt,
        Vt
      ), Vt !== null) {
        aa = f, e.cancelPendingCommit = Vt(
          __.bind(
            null,
            e,
            n,
            f,
            a,
            o,
            u,
            y,
            A,
            H,
            ft,
            gt,
            null,
            at,
            ct
          )
        ), Na(e, f, y, !nt);
        return;
      }
    }
    __(
      e,
      n,
      f,
      a,
      o,
      u,
      y,
      A,
      H
    );
  }
  function Xy(e) {
    for (var n = e; ; ) {
      var a = n.tag;
      if ((a === 0 || a === 11 || a === 15) && n.flags & 16384 && (a = n.updateQueue, a !== null && (a = a.stores, a !== null)))
        for (var o = 0; o < a.length; o++) {
          var u = a[o], f = u.getSnapshot;
          u = u.value;
          try {
            if (!ei(f(), u)) return !1;
          } catch {
            return !1;
          }
        }
      if (a = n.child, n.subtreeFlags & 16384 && a !== null)
        a.return = n, n = a;
      else {
        if (n === e) break;
        for (; n.sibling === null; ) {
          if (n.return === null || n.return === e) return !0;
          n = n.return;
        }
        n.sibling.return = n.return, n = n.sibling;
      }
    }
    return !0;
  }
  function Na(e, n, a, o) {
    n &= ~Qf, n &= ~ys, e.suspendedLanes |= n, e.pingedLanes &= ~n, o && (e.warmLanes |= n), o = e.expirationTimes;
    for (var u = n; 0 < u; ) {
      var f = 31 - te(u), y = 1 << f;
      o[f] = -1, u &= ~y;
    }
    a !== 0 && io(e, a, n);
  }
  function ic() {
    return (Le & 6) === 0 ? (Ho(0), !1) : !0;
  }
  function nh() {
    if (me !== null) {
      if (Oe === 0)
        var e = me.return;
      else
        e = me, qi = fs = null, vf(e), nr = null, Mo = 0, e = me;
      for (; e !== null; )
        Hg(e.alternate, e), e = e.return;
      me = null;
    }
  }
  function hr(e, n) {
    var a = e.timeoutHandle;
    a !== -1 && (e.timeoutHandle = -1, uS(a)), a = e.cancelPendingCommit, a !== null && (e.cancelPendingCommit = null, a()), aa = 0, nh(), Ye = e, me = a = Wi(e.current, null), ye = n, Oe = 0, si = null, wa = !1, cr = ee(e, n), Kf = !1, ur = ri = Qf = ys = Da = nn = 0, Qn = Io = null, Jf = !1, (n & 8) !== 0 && (n |= n & 32);
    var o = e.entangledLanes;
    if (o !== 0)
      for (e = e.entanglements, o &= n; 0 < o; ) {
        var u = 31 - te(o), f = 1 << u;
        n |= e[u], o &= ~f;
      }
    return ia = n, bl(), a;
  }
  function u_(e, n) {
    le = null, z.H = Do, n === er || n === Ll ? (n = Am(), Oe = 3) : n === rf ? (n = Am(), Oe = 4) : Oe = n === Of ? 8 : n !== null && typeof n == "object" && typeof n.then == "function" ? 6 : 1, si = n, me === null && (nn = 1, Yl(
      e,
      di(n, e.current)
    ));
  }
  function f_() {
    var e = ii.current;
    return e === null ? !0 : (ye & 4194048) === ye ? _i === null : (ye & 62914560) === ye || (ye & 536870912) !== 0 ? e === _i : !1;
  }
  function h_() {
    var e = z.H;
    return z.H = Do, e === null ? Do : e;
  }
  function d_() {
    var e = z.A;
    return z.A = Vy, e;
  }
  function ac() {
    nn = 4, wa || (ye & 4194048) !== ye && ii.current !== null || (cr = !0), (Da & 134217727) === 0 && (ys & 134217727) === 0 || Ye === null || Na(
      Ye,
      ye,
      ri,
      !1
    );
  }
  function ih(e, n, a) {
    var o = Le;
    Le |= 2;
    var u = h_(), f = d_();
    (Ye !== e || ye !== n) && (nc = null, hr(e, n)), n = !1;
    var y = nn;
    t: do
      try {
        if (Oe !== 0 && me !== null) {
          var A = me, H = si;
          switch (Oe) {
            case 8:
              nh(), y = 6;
              break t;
            case 3:
            case 2:
            case 9:
            case 6:
              ii.current === null && (n = !0);
              var nt = Oe;
              if (Oe = 0, si = null, dr(e, A, H, nt), a && cr) {
                y = 0;
                break t;
              }
              break;
            default:
              nt = Oe, Oe = 0, si = null, dr(e, A, H, nt);
          }
        }
        Wy(), y = nn;
        break;
      } catch (ft) {
        u_(e, ft);
      }
    while (!0);
    return n && e.shellSuspendCounter++, qi = fs = null, Le = o, z.H = u, z.A = f, me === null && (Ye = null, ye = 0, bl()), y;
  }
  function Wy() {
    for (; me !== null; ) p_(me);
  }
  function Yy(e, n) {
    var a = Le;
    Le |= 2;
    var o = h_(), u = d_();
    Ye !== e || ye !== n ? (nc = null, ec = dt() + 500, hr(e, n)) : cr = ee(
      e,
      n
    );
    t: do
      try {
        if (Oe !== 0 && me !== null) {
          n = me;
          var f = si;
          e: switch (Oe) {
            case 1:
              Oe = 0, si = null, dr(e, n, f, 1);
              break;
            case 2:
            case 9:
              if (bm(f)) {
                Oe = 0, si = null, m_(n);
                break;
              }
              n = function() {
                Oe !== 2 && Oe !== 9 || Ye !== e || (Oe = 7), Bi(e);
              }, f.then(n, n);
              break t;
            case 3:
              Oe = 7;
              break t;
            case 4:
              Oe = 5;
              break t;
            case 7:
              bm(f) ? (Oe = 0, si = null, m_(n)) : (Oe = 0, si = null, dr(e, n, f, 7));
              break;
            case 5:
              var y = null;
              switch (me.tag) {
                case 26:
                  y = me.memoizedState;
                case 5:
                case 27:
                  var A = me;
                  if (y ? t0(y) : A.stateNode.complete) {
                    Oe = 0, si = null;
                    var H = A.sibling;
                    if (H !== null) me = H;
                    else {
                      var nt = A.return;
                      nt !== null ? (me = nt, sc(nt)) : me = null;
                    }
                    break e;
                  }
              }
              Oe = 0, si = null, dr(e, n, f, 5);
              break;
            case 6:
              Oe = 0, si = null, dr(e, n, f, 6);
              break;
            case 8:
              nh(), nn = 6;
              break t;
            default:
              throw Error(s(462));
          }
        }
        qy();
        break;
      } catch (ft) {
        u_(e, ft);
      }
    while (!0);
    return qi = fs = null, z.H = o, z.A = u, Le = a, me !== null ? 0 : (Ye = null, ye = 0, bl(), nn);
  }
  function qy() {
    for (; me !== null && !R(); )
      p_(me);
  }
  function p_(e) {
    var n = Ig(e.alternate, e, ia);
    e.memoizedProps = e.pendingProps, n === null ? sc(e) : me = n;
  }
  function m_(e) {
    var n = e, a = n.alternate;
    switch (n.tag) {
      case 15:
      case 0:
        n = Lg(
          a,
          n,
          n.pendingProps,
          n.type,
          void 0,
          ye
        );
        break;
      case 11:
        n = Lg(
          a,
          n,
          n.pendingProps,
          n.type.render,
          n.ref,
          ye
        );
        break;
      case 5:
        vf(n);
      default:
        Hg(a, n), n = me = dm(n, ia), n = Ig(a, n, ia);
    }
    e.memoizedProps = e.pendingProps, n === null ? sc(e) : me = n;
  }
  function dr(e, n, a, o) {
    qi = fs = null, vf(n), nr = null, Mo = 0;
    var u = n.return;
    try {
      if (Py(
        e,
        u,
        n,
        a,
        ye
      )) {
        nn = 1, Yl(
          e,
          di(a, e.current)
        ), me = null;
        return;
      }
    } catch (f) {
      if (u !== null) throw me = u, f;
      nn = 1, Yl(
        e,
        di(a, e.current)
      ), me = null;
      return;
    }
    n.flags & 32768 ? (be || o === 1 ? e = !0 : cr || (ye & 536870912) !== 0 ? e = !1 : (wa = e = !0, (o === 2 || o === 9 || o === 3 || o === 6) && (o = ii.current, o !== null && o.tag === 13 && (o.flags |= 16384))), g_(n, e)) : sc(n);
  }
  function sc(e) {
    var n = e;
    do {
      if ((n.flags & 32768) !== 0) {
        g_(
          n,
          wa
        );
        return;
      }
      e = n.return;
      var a = Iy(
        n.alternate,
        n,
        ia
      );
      if (a !== null) {
        me = a;
        return;
      }
      if (n = n.sibling, n !== null) {
        me = n;
        return;
      }
      me = n = e;
    } while (n !== null);
    nn === 0 && (nn = 5);
  }
  function g_(e, n) {
    do {
      var a = Fy(e.alternate, e);
      if (a !== null) {
        a.flags &= 32767, me = a;
        return;
      }
      if (a = e.return, a !== null && (a.flags |= 32768, a.subtreeFlags = 0, a.deletions = null), !n && (e = e.sibling, e !== null)) {
        me = e;
        return;
      }
      me = e = a;
    } while (e !== null);
    nn = 6, me = null;
  }
  function __(e, n, a, o, u, f, y, A, H) {
    e.cancelPendingCommit = null;
    do
      rc();
    while (pn !== 0);
    if ((Le & 6) !== 0) throw Error(s(327));
    if (n !== null) {
      if (n === e.current) throw Error(s(177));
      if (f = n.lanes | n.childLanes, f |= Xu, bi(
        e,
        a,
        f,
        y,
        A,
        H
      ), e === Ye && (me = Ye = null, ye = 0), fr = n, La = e, aa = a, $f = f, th = u, r_ = o, (n.subtreeFlags & 10256) !== 0 || (n.flags & 10256) !== 0 ? (e.callbackNode = null, e.callbackPriority = 0, Qy(wt, function() {
        return M_(), null;
      })) : (e.callbackNode = null, e.callbackPriority = 0), o = (n.flags & 13878) !== 0, (n.subtreeFlags & 13878) !== 0 || o) {
        o = z.T, z.T = null, u = tt.p, tt.p = 2, y = Le, Le |= 4;
        try {
          Hy(e, n, a);
        } finally {
          Le = y, tt.p = u, z.T = o;
        }
      }
      pn = 1, v_(), x_(), y_();
    }
  }
  function v_() {
    if (pn === 1) {
      pn = 0;
      var e = La, n = fr, a = (n.flags & 13878) !== 0;
      if ((n.subtreeFlags & 13878) !== 0 || a) {
        a = z.T, z.T = null;
        var o = tt.p;
        tt.p = 2;
        var u = Le;
        Le |= 4;
        try {
          Jg(n, e);
          var f = mh, y = am(e.containerInfo), A = f.focusedElem, H = f.selectionRange;
          if (y !== A && A && A.ownerDocument && im(
            A.ownerDocument.documentElement,
            A
          )) {
            if (H !== null && Fu(A)) {
              var nt = H.start, ft = H.end;
              if (ft === void 0 && (ft = nt), "selectionStart" in A)
                A.selectionStart = nt, A.selectionEnd = Math.min(
                  ft,
                  A.value.length
                );
              else {
                var gt = A.ownerDocument || document, at = gt && gt.defaultView || window;
                if (at.getSelection) {
                  var ct = at.getSelection(), Vt = A.textContent.length, Jt = Math.min(H.start, Vt), He = H.end === void 0 ? Jt : Math.min(H.end, Vt);
                  !ct.extend && Jt > He && (y = He, He = Jt, Jt = y);
                  var Z = nm(
                    A,
                    Jt
                  ), k = nm(
                    A,
                    He
                  );
                  if (Z && k && (ct.rangeCount !== 1 || ct.anchorNode !== Z.node || ct.anchorOffset !== Z.offset || ct.focusNode !== k.node || ct.focusOffset !== k.offset)) {
                    var et = gt.createRange();
                    et.setStart(Z.node, Z.offset), ct.removeAllRanges(), Jt > He ? (ct.addRange(et), ct.extend(k.node, k.offset)) : (et.setEnd(k.node, k.offset), ct.addRange(et));
                  }
                }
              }
            }
            for (gt = [], ct = A; ct = ct.parentNode; )
              ct.nodeType === 1 && gt.push({
                element: ct,
                left: ct.scrollLeft,
                top: ct.scrollTop
              });
            for (typeof A.focus == "function" && A.focus(), A = 0; A < gt.length; A++) {
              var mt = gt[A];
              mt.element.scrollLeft = mt.left, mt.element.scrollTop = mt.top;
            }
          }
          vc = !!ph, mh = ph = null;
        } finally {
          Le = u, tt.p = o, z.T = a;
        }
      }
      e.current = n, pn = 2;
    }
  }
  function x_() {
    if (pn === 2) {
      pn = 0;
      var e = La, n = fr, a = (n.flags & 8772) !== 0;
      if ((n.subtreeFlags & 8772) !== 0 || a) {
        a = z.T, z.T = null;
        var o = tt.p;
        tt.p = 2;
        var u = Le;
        Le |= 4;
        try {
          qg(e, n.alternate, n);
        } finally {
          Le = u, tt.p = o, z.T = a;
        }
      }
      pn = 3;
    }
  }
  function y_() {
    if (pn === 4 || pn === 3) {
      pn = 0, it();
      var e = La, n = fr, a = aa, o = r_;
      (n.subtreeFlags & 10256) !== 0 || (n.flags & 10256) !== 0 ? pn = 5 : (pn = 0, fr = La = null, S_(e, e.pendingLanes));
      var u = e.pendingLanes;
      if (u === 0 && (Ua = null), Hs(a), n = n.stateNode, Wt && typeof Wt.onCommitFiberRoot == "function")
        try {
          Wt.onCommitFiberRoot(
            jt,
            n,
            void 0,
            (n.current.flags & 128) === 128
          );
        } catch {
        }
      if (o !== null) {
        n = z.T, u = tt.p, tt.p = 2, z.T = null;
        try {
          for (var f = e.onRecoverableError, y = 0; y < o.length; y++) {
            var A = o[y];
            f(A.value, {
              componentStack: A.stack
            });
          }
        } finally {
          z.T = n, tt.p = u;
        }
      }
      (aa & 3) !== 0 && rc(), Bi(e), u = e.pendingLanes, (a & 261930) !== 0 && (u & 42) !== 0 ? e === eh ? Fo++ : (Fo = 0, eh = e) : Fo = 0, Ho(0);
    }
  }
  function S_(e, n) {
    (e.pooledCacheLanes &= n) === 0 && (n = e.pooledCache, n != null && (e.pooledCache = null, yo(n)));
  }
  function rc() {
    return v_(), x_(), y_(), M_();
  }
  function M_() {
    if (pn !== 5) return !1;
    var e = La, n = $f;
    $f = 0;
    var a = Hs(aa), o = z.T, u = tt.p;
    try {
      tt.p = 32 > a ? 32 : a, z.T = null, a = th, th = null;
      var f = La, y = aa;
      if (pn = 0, fr = La = null, aa = 0, (Le & 6) !== 0) throw Error(s(331));
      var A = Le;
      if (Le |= 4, i_(f.current), t_(
        f,
        f.current,
        y,
        a
      ), Le = A, Ho(0, !1), Wt && typeof Wt.onPostCommitFiberRoot == "function")
        try {
          Wt.onPostCommitFiberRoot(jt, f);
        } catch {
        }
      return !0;
    } finally {
      tt.p = u, z.T = o, S_(e, n);
    }
  }
  function E_(e, n, a) {
    n = di(a, n), n = Nf(e.stateNode, n, 2), e = Ta(e, n, 2), e !== null && (En(e, 2), Bi(e));
  }
  function Pe(e, n, a) {
    if (e.tag === 3)
      E_(e, e, a);
    else
      for (; n !== null; ) {
        if (n.tag === 3) {
          E_(
            n,
            e,
            a
          );
          break;
        } else if (n.tag === 1) {
          var o = n.stateNode;
          if (typeof n.type.getDerivedStateFromError == "function" || typeof o.componentDidCatch == "function" && (Ua === null || !Ua.has(o))) {
            e = di(a, e), a = bg(2), o = Ta(n, a, 2), o !== null && (Tg(
              a,
              o,
              n,
              e
            ), En(o, 2), Bi(o));
            break;
          }
        }
        n = n.return;
      }
  }
  function ah(e, n, a) {
    var o = e.pingCache;
    if (o === null) {
      o = e.pingCache = new ky();
      var u = /* @__PURE__ */ new Set();
      o.set(n, u);
    } else
      u = o.get(n), u === void 0 && (u = /* @__PURE__ */ new Set(), o.set(n, u));
    u.has(a) || (Kf = !0, u.add(a), e = jy.bind(null, e, n, a), n.then(e, e));
  }
  function jy(e, n, a) {
    var o = e.pingCache;
    o !== null && o.delete(n), e.pingedLanes |= e.suspendedLanes & a, e.warmLanes &= ~a, Ye === e && (ye & a) === a && (nn === 4 || nn === 3 && (ye & 62914560) === ye && 300 > dt() - tc ? (Le & 2) === 0 && hr(e, 0) : Qf |= a, ur === ye && (ur = 0)), Bi(e);
  }
  function b_(e, n) {
    n === 0 && (n = hn()), e = ls(e, n), e !== null && (En(e, n), Bi(e));
  }
  function Zy(e) {
    var n = e.memoizedState, a = 0;
    n !== null && (a = n.retryLane), b_(e, a);
  }
  function Ky(e, n) {
    var a = 0;
    switch (e.tag) {
      case 31:
      case 13:
        var o = e.stateNode, u = e.memoizedState;
        u !== null && (a = u.retryLane);
        break;
      case 19:
        o = e.stateNode;
        break;
      case 22:
        o = e.stateNode._retryCache;
        break;
      default:
        throw Error(s(314));
    }
    o !== null && o.delete(n), b_(e, a);
  }
  function Qy(e, n) {
    return Xt(e, n);
  }
  var oc = null, pr = null, sh = !1, lc = !1, rh = !1, Oa = 0;
  function Bi(e) {
    e !== pr && e.next === null && (pr === null ? oc = pr = e : pr = pr.next = e), lc = !0, sh || (sh = !0, $y());
  }
  function Ho(e, n) {
    if (!rh && lc) {
      rh = !0;
      do
        for (var a = !1, o = oc; o !== null; ) {
          if (e !== 0) {
            var u = o.pendingLanes;
            if (u === 0) var f = 0;
            else {
              var y = o.suspendedLanes, A = o.pingedLanes;
              f = (1 << 31 - te(42 | e) + 1) - 1, f &= u & ~(y & ~A), f = f & 201326741 ? f & 201326741 | 1 : f ? f | 2 : 0;
            }
            f !== 0 && (a = !0, C_(o, f));
          } else
            f = ye, f = Nt(
              o,
              o === Ye ? f : 0,
              o.cancelPendingCommit !== null || o.timeoutHandle !== -1
            ), (f & 3) === 0 || ee(o, f) || (a = !0, C_(o, f));
          o = o.next;
        }
      while (a);
      rh = !1;
    }
  }
  function Jy() {
    T_();
  }
  function T_() {
    lc = sh = !1;
    var e = 0;
    Oa !== 0 && cS() && (e = Oa);
    for (var n = dt(), a = null, o = oc; o !== null; ) {
      var u = o.next, f = A_(o, n);
      f === 0 ? (o.next = null, a === null ? oc = u : a.next = u, u === null && (pr = a)) : (a = o, (e !== 0 || (f & 3) !== 0) && (lc = !0)), o = u;
    }
    pn !== 0 && pn !== 5 || Ho(e), Oa !== 0 && (Oa = 0);
  }
  function A_(e, n) {
    for (var a = e.suspendedLanes, o = e.pingedLanes, u = e.expirationTimes, f = e.pendingLanes & -62914561; 0 < f; ) {
      var y = 31 - te(f), A = 1 << y, H = u[y];
      H === -1 ? ((A & a) === 0 || (A & o) !== 0) && (u[y] = Ke(A, n)) : H <= n && (e.expiredLanes |= A), f &= ~A;
    }
    if (n = Ye, a = ye, a = Nt(
      e,
      e === n ? a : 0,
      e.cancelPendingCommit !== null || e.timeoutHandle !== -1
    ), o = e.callbackNode, a === 0 || e === n && (Oe === 2 || Oe === 9) || e.cancelPendingCommit !== null)
      return o !== null && o !== null && N(o), e.callbackNode = null, e.callbackPriority = 0;
    if ((a & 3) === 0 || ee(e, a)) {
      if (n = a & -a, n === e.callbackPriority) return n;
      switch (o !== null && N(o), Hs(a)) {
        case 2:
        case 8:
          a = Tt;
          break;
        case 32:
          a = wt;
          break;
        case 268435456:
          a = xe;
          break;
        default:
          a = wt;
      }
      return o = R_.bind(null, e), a = Xt(a, o), e.callbackPriority = n, e.callbackNode = a, n;
    }
    return o !== null && o !== null && N(o), e.callbackPriority = 2, e.callbackNode = null, 2;
  }
  function R_(e, n) {
    if (pn !== 0 && pn !== 5)
      return e.callbackNode = null, e.callbackPriority = 0, null;
    var a = e.callbackNode;
    if (rc() && e.callbackNode !== a)
      return null;
    var o = ye;
    return o = Nt(
      e,
      e === Ye ? o : 0,
      e.cancelPendingCommit !== null || e.timeoutHandle !== -1
    ), o === 0 ? null : (l_(e, o, n), A_(e, dt()), e.callbackNode != null && e.callbackNode === a ? R_.bind(null, e) : null);
  }
  function C_(e, n) {
    if (rc()) return null;
    l_(e, n, !0);
  }
  function $y() {
    fS(function() {
      (Le & 6) !== 0 ? Xt(
        Q,
        Jy
      ) : T_();
    });
  }
  function oh() {
    if (Oa === 0) {
      var e = $s;
      e === 0 && (e = Dt, Dt <<= 1, (Dt & 261888) === 0 && (Dt = 256)), Oa = e;
    }
    return Oa;
  }
  function w_(e) {
    return e == null || typeof e == "symbol" || typeof e == "boolean" ? null : typeof e == "function" ? e : gl("" + e);
  }
  function D_(e, n) {
    var a = n.ownerDocument.createElement("input");
    return a.name = n.name, a.value = n.value, e.id && a.setAttribute("form", e.id), n.parentNode.insertBefore(a, n), e = new FormData(e), a.parentNode.removeChild(a), e;
  }
  function tS(e, n, a, o, u) {
    if (n === "submit" && a && a.stateNode === u) {
      var f = w_(
        (u[bn] || null).action
      ), y = o.submitter;
      y && (n = (n = y[bn] || null) ? w_(n.formAction) : y.getAttribute("formAction"), n !== null && (f = n, y = null));
      var A = new yl(
        "action",
        "action",
        null,
        o,
        u
      );
      e.push({
        event: A,
        listeners: [
          {
            instance: null,
            listener: function() {
              if (o.defaultPrevented) {
                if (Oa !== 0) {
                  var H = y ? D_(u, y) : new FormData(u);
                  Rf(
                    a,
                    {
                      pending: !0,
                      data: H,
                      method: u.method,
                      action: f
                    },
                    null,
                    H
                  );
                }
              } else
                typeof f == "function" && (A.preventDefault(), H = y ? D_(u, y) : new FormData(u), Rf(
                  a,
                  {
                    pending: !0,
                    data: H,
                    method: u.method,
                    action: f
                  },
                  f,
                  H
                ));
            },
            currentTarget: u
          }
        ]
      });
    }
  }
  for (var lh = 0; lh < ku.length; lh++) {
    var ch = ku[lh], eS = ch.toLowerCase(), nS = ch[0].toUpperCase() + ch.slice(1);
    Ri(
      eS,
      "on" + nS
    );
  }
  Ri(om, "onAnimationEnd"), Ri(lm, "onAnimationIteration"), Ri(cm, "onAnimationStart"), Ri("dblclick", "onDoubleClick"), Ri("focusin", "onFocus"), Ri("focusout", "onBlur"), Ri(vy, "onTransitionRun"), Ri(xy, "onTransitionStart"), Ri(yy, "onTransitionCancel"), Ri(um, "onTransitionEnd"), Ft("onMouseEnter", ["mouseout", "mouseover"]), Ft("onMouseLeave", ["mouseout", "mouseover"]), Ft("onPointerEnter", ["pointerout", "pointerover"]), Ft("onPointerLeave", ["pointerout", "pointerover"]), zt(
    "onChange",
    "change click focusin focusout input keydown keyup selectionchange".split(" ")
  ), zt(
    "onSelect",
    "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(
      " "
    )
  ), zt("onBeforeInput", [
    "compositionend",
    "keypress",
    "textInput",
    "paste"
  ]), zt(
    "onCompositionEnd",
    "compositionend focusout keydown keypress keyup mousedown".split(" ")
  ), zt(
    "onCompositionStart",
    "compositionstart focusout keydown keypress keyup mousedown".split(" ")
  ), zt(
    "onCompositionUpdate",
    "compositionupdate focusout keydown keypress keyup mousedown".split(" ")
  );
  var Go = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(
    " "
  ), iS = new Set(
    "beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Go)
  );
  function U_(e, n) {
    n = (n & 4) !== 0;
    for (var a = 0; a < e.length; a++) {
      var o = e[a], u = o.event;
      o = o.listeners;
      t: {
        var f = void 0;
        if (n)
          for (var y = o.length - 1; 0 <= y; y--) {
            var A = o[y], H = A.instance, nt = A.currentTarget;
            if (A = A.listener, H !== f && u.isPropagationStopped())
              break t;
            f = A, u.currentTarget = nt;
            try {
              f(u);
            } catch (ft) {
              El(ft);
            }
            u.currentTarget = null, f = H;
          }
        else
          for (y = 0; y < o.length; y++) {
            if (A = o[y], H = A.instance, nt = A.currentTarget, A = A.listener, H !== f && u.isPropagationStopped())
              break t;
            f = A, u.currentTarget = nt;
            try {
              f(u);
            } catch (ft) {
              El(ft);
            }
            u.currentTarget = null, f = H;
          }
      }
    }
  }
  function ge(e, n) {
    var a = n[ro];
    a === void 0 && (a = n[ro] = /* @__PURE__ */ new Set());
    var o = e + "__bubble";
    a.has(o) || (L_(n, e, 2, !1), a.add(o));
  }
  function uh(e, n, a) {
    var o = 0;
    n && (o |= 4), L_(
      a,
      e,
      o,
      n
    );
  }
  var cc = "_reactListening" + Math.random().toString(36).slice(2);
  function fh(e) {
    if (!e[cc]) {
      e[cc] = !0, At.forEach(function(a) {
        a !== "selectionchange" && (iS.has(a) || uh(a, !1, e), uh(a, !0, e));
      });
      var n = e.nodeType === 9 ? e : e.ownerDocument;
      n === null || n[cc] || (n[cc] = !0, uh("selectionchange", !1, n));
    }
  }
  function L_(e, n, a, o) {
    switch (o0(n)) {
      case 2:
        var u = US;
        break;
      case 8:
        u = LS;
        break;
      default:
        u = Ah;
    }
    a = u.bind(
      null,
      n,
      a,
      e
    ), u = void 0, !Du || n !== "touchstart" && n !== "touchmove" && n !== "wheel" || (u = !0), o ? u !== void 0 ? e.addEventListener(n, a, {
      capture: !0,
      passive: u
    }) : e.addEventListener(n, a, !0) : u !== void 0 ? e.addEventListener(n, a, {
      passive: u
    }) : e.addEventListener(n, a, !1);
  }
  function hh(e, n, a, o, u) {
    var f = o;
    if ((n & 1) === 0 && (n & 2) === 0 && o !== null)
      t: for (; ; ) {
        if (o === null) return;
        var y = o.tag;
        if (y === 3 || y === 4) {
          var A = o.stateNode.containerInfo;
          if (A === u) break;
          if (y === 4)
            for (y = o.return; y !== null; ) {
              var H = y.tag;
              if ((H === 3 || H === 4) && y.stateNode.containerInfo === u)
                return;
              y = y.return;
            }
          for (; A !== null; ) {
            if (y = D(A), y === null) return;
            if (H = y.tag, H === 5 || H === 6 || H === 26 || H === 27) {
              o = f = y;
              continue t;
            }
            A = A.parentNode;
          }
        }
        o = o.return;
      }
    Bp(function() {
      var nt = f, ft = Cu(a), gt = [];
      t: {
        var at = fm.get(e);
        if (at !== void 0) {
          var ct = yl, Vt = e;
          switch (e) {
            case "keypress":
              if (vl(a) === 0) break t;
            case "keydown":
            case "keyup":
              ct = Kx;
              break;
            case "focusin":
              Vt = "focus", ct = Ou;
              break;
            case "focusout":
              Vt = "blur", ct = Ou;
              break;
            case "beforeblur":
            case "afterblur":
              ct = Ou;
              break;
            case "click":
              if (a.button === 2) break t;
            case "auxclick":
            case "dblclick":
            case "mousedown":
            case "mousemove":
            case "mouseup":
            case "mouseout":
            case "mouseover":
            case "contextmenu":
              ct = Hp;
              break;
            case "drag":
            case "dragend":
            case "dragenter":
            case "dragexit":
            case "dragleave":
            case "dragover":
            case "dragstart":
            case "drop":
              ct = Ix;
              break;
            case "touchcancel":
            case "touchend":
            case "touchmove":
            case "touchstart":
              ct = $x;
              break;
            case om:
            case lm:
            case cm:
              ct = Gx;
              break;
            case um:
              ct = ey;
              break;
            case "scroll":
            case "scrollend":
              ct = zx;
              break;
            case "wheel":
              ct = iy;
              break;
            case "copy":
            case "cut":
            case "paste":
              ct = kx;
              break;
            case "gotpointercapture":
            case "lostpointercapture":
            case "pointercancel":
            case "pointerdown":
            case "pointermove":
            case "pointerout":
            case "pointerover":
            case "pointerup":
              ct = Vp;
              break;
            case "toggle":
            case "beforetoggle":
              ct = sy;
          }
          var Jt = (n & 4) !== 0, He = !Jt && (e === "scroll" || e === "scrollend"), Z = Jt ? at !== null ? at + "Capture" : null : at;
          Jt = [];
          for (var k = nt, et; k !== null; ) {
            var mt = k;
            if (et = mt.stateNode, mt = mt.tag, mt !== 5 && mt !== 26 && mt !== 27 || et === null || Z === null || (mt = lo(k, Z), mt != null && Jt.push(
              Vo(k, mt, et)
            )), He) break;
            k = k.return;
          }
          0 < Jt.length && (at = new ct(
            at,
            Vt,
            null,
            a,
            ft
          ), gt.push({ event: at, listeners: Jt }));
        }
      }
      if ((n & 7) === 0) {
        t: {
          if (at = e === "mouseover" || e === "pointerover", ct = e === "mouseout" || e === "pointerout", at && a !== Ru && (Vt = a.relatedTarget || a.fromElement) && (D(Vt) || Vt[Vi]))
            break t;
          if ((ct || at) && (at = ft.window === ft ? ft : (at = ft.ownerDocument) ? at.defaultView || at.parentWindow : window, ct ? (Vt = a.relatedTarget || a.toElement, ct = nt, Vt = Vt ? D(Vt) : null, Vt !== null && (He = c(Vt), Jt = Vt.tag, Vt !== He || Jt !== 5 && Jt !== 27 && Jt !== 6) && (Vt = null)) : (ct = null, Vt = nt), ct !== Vt)) {
            if (Jt = Hp, mt = "onMouseLeave", Z = "onMouseEnter", k = "mouse", (e === "pointerout" || e === "pointerover") && (Jt = Vp, mt = "onPointerLeave", Z = "onPointerEnter", k = "pointer"), He = ct == null ? at : rt(ct), et = Vt == null ? at : rt(Vt), at = new Jt(
              mt,
              k + "leave",
              ct,
              a,
              ft
            ), at.target = He, at.relatedTarget = et, mt = null, D(ft) === nt && (Jt = new Jt(
              Z,
              k + "enter",
              Vt,
              a,
              ft
            ), Jt.target = et, Jt.relatedTarget = He, mt = Jt), He = mt, ct && Vt)
              e: {
                for (Jt = aS, Z = ct, k = Vt, et = 0, mt = Z; mt; mt = Jt(mt))
                  et++;
                mt = 0;
                for (var Kt = k; Kt; Kt = Jt(Kt))
                  mt++;
                for (; 0 < et - mt; )
                  Z = Jt(Z), et--;
                for (; 0 < mt - et; )
                  k = Jt(k), mt--;
                for (; et--; ) {
                  if (Z === k || k !== null && Z === k.alternate) {
                    Jt = Z;
                    break e;
                  }
                  Z = Jt(Z), k = Jt(k);
                }
                Jt = null;
              }
            else Jt = null;
            ct !== null && N_(
              gt,
              at,
              ct,
              Jt,
              !1
            ), Vt !== null && He !== null && N_(
              gt,
              He,
              Vt,
              Jt,
              !0
            );
          }
        }
        t: {
          if (at = nt ? rt(nt) : window, ct = at.nodeName && at.nodeName.toLowerCase(), ct === "select" || ct === "input" && at.type === "file")
            var Ce = Kp;
          else if (jp(at))
            if (Qp)
              Ce = my;
            else {
              Ce = dy;
              var kt = hy;
            }
          else
            ct = at.nodeName, !ct || ct.toLowerCase() !== "input" || at.type !== "checkbox" && at.type !== "radio" ? nt && Au(nt.elementType) && (Ce = Kp) : Ce = py;
          if (Ce && (Ce = Ce(e, nt))) {
            Zp(
              gt,
              Ce,
              a,
              ft
            );
            break t;
          }
          kt && kt(e, at, nt), e === "focusout" && nt && at.type === "number" && nt.memoizedProps.value != null && Ln(at, "number", at.value);
        }
        switch (kt = nt ? rt(nt) : window, e) {
          case "focusin":
            (jp(kt) || kt.contentEditable === "true") && (Ws = kt, Hu = nt, _o = null);
            break;
          case "focusout":
            _o = Hu = Ws = null;
            break;
          case "mousedown":
            Gu = !0;
            break;
          case "contextmenu":
          case "mouseup":
          case "dragend":
            Gu = !1, sm(gt, a, ft);
            break;
          case "selectionchange":
            if (_y) break;
          case "keydown":
          case "keyup":
            sm(gt, a, ft);
        }
        var ce;
        if (zu)
          t: {
            switch (e) {
              case "compositionstart":
                var Se = "onCompositionStart";
                break t;
              case "compositionend":
                Se = "onCompositionEnd";
                break t;
              case "compositionupdate":
                Se = "onCompositionUpdate";
                break t;
            }
            Se = void 0;
          }
        else
          Xs ? Yp(e, a) && (Se = "onCompositionEnd") : e === "keydown" && a.keyCode === 229 && (Se = "onCompositionStart");
        Se && (kp && a.locale !== "ko" && (Xs || Se !== "onCompositionStart" ? Se === "onCompositionEnd" && Xs && (ce = Ip()) : (va = ft, Uu = "value" in va ? va.value : va.textContent, Xs = !0)), kt = uc(nt, Se), 0 < kt.length && (Se = new Gp(
          Se,
          e,
          null,
          a,
          ft
        ), gt.push({ event: Se, listeners: kt }), ce ? Se.data = ce : (ce = qp(a), ce !== null && (Se.data = ce)))), (ce = oy ? ly(e, a) : cy(e, a)) && (Se = uc(nt, "onBeforeInput"), 0 < Se.length && (kt = new Gp(
          "onBeforeInput",
          "beforeinput",
          null,
          a,
          ft
        ), gt.push({
          event: kt,
          listeners: Se
        }), kt.data = ce)), tS(
          gt,
          e,
          nt,
          a,
          ft
        );
      }
      U_(gt, n);
    });
  }
  function Vo(e, n, a) {
    return {
      instance: e,
      listener: n,
      currentTarget: a
    };
  }
  function uc(e, n) {
    for (var a = n + "Capture", o = []; e !== null; ) {
      var u = e, f = u.stateNode;
      if (u = u.tag, u !== 5 && u !== 26 && u !== 27 || f === null || (u = lo(e, a), u != null && o.unshift(
        Vo(e, u, f)
      ), u = lo(e, n), u != null && o.push(
        Vo(e, u, f)
      )), e.tag === 3) return o;
      e = e.return;
    }
    return [];
  }
  function aS(e) {
    if (e === null) return null;
    do
      e = e.return;
    while (e && e.tag !== 5 && e.tag !== 27);
    return e || null;
  }
  function N_(e, n, a, o, u) {
    for (var f = n._reactName, y = []; a !== null && a !== o; ) {
      var A = a, H = A.alternate, nt = A.stateNode;
      if (A = A.tag, H !== null && H === o) break;
      A !== 5 && A !== 26 && A !== 27 || nt === null || (H = nt, u ? (nt = lo(a, f), nt != null && y.unshift(
        Vo(a, nt, H)
      )) : u || (nt = lo(a, f), nt != null && y.push(
        Vo(a, nt, H)
      ))), a = a.return;
    }
    y.length !== 0 && e.push({ event: n, listeners: y });
  }
  var sS = /\r\n?/g, rS = /\u0000|\uFFFD/g;
  function O_(e) {
    return (typeof e == "string" ? e : "" + e).replace(sS, `
`).replace(rS, "");
  }
  function P_(e, n) {
    return n = O_(n), O_(e) === n;
  }
  function Fe(e, n, a, o, u, f) {
    switch (a) {
      case "children":
        typeof o == "string" ? n === "body" || n === "textarea" && o === "" || Yn(e, o) : (typeof o == "number" || typeof o == "bigint") && n !== "body" && Yn(e, "" + o);
        break;
      case "className":
        qe(e, "class", o);
        break;
      case "tabIndex":
        qe(e, "tabindex", o);
        break;
      case "dir":
      case "role":
      case "viewBox":
      case "width":
      case "height":
        qe(e, a, o);
        break;
      case "style":
        Pp(e, o, f);
        break;
      case "data":
        if (n !== "object") {
          qe(e, "data", o);
          break;
        }
      case "src":
      case "href":
        if (o === "" && (n !== "a" || a !== "href")) {
          e.removeAttribute(a);
          break;
        }
        if (o == null || typeof o == "function" || typeof o == "symbol" || typeof o == "boolean") {
          e.removeAttribute(a);
          break;
        }
        o = gl("" + o), e.setAttribute(a, o);
        break;
      case "action":
      case "formAction":
        if (typeof o == "function") {
          e.setAttribute(
            a,
            "javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
          );
          break;
        } else
          typeof f == "function" && (a === "formAction" ? (n !== "input" && Fe(e, n, "name", u.name, u, null), Fe(
            e,
            n,
            "formEncType",
            u.formEncType,
            u,
            null
          ), Fe(
            e,
            n,
            "formMethod",
            u.formMethod,
            u,
            null
          ), Fe(
            e,
            n,
            "formTarget",
            u.formTarget,
            u,
            null
          )) : (Fe(e, n, "encType", u.encType, u, null), Fe(e, n, "method", u.method, u, null), Fe(e, n, "target", u.target, u, null)));
        if (o == null || typeof o == "symbol" || typeof o == "boolean") {
          e.removeAttribute(a);
          break;
        }
        o = gl("" + o), e.setAttribute(a, o);
        break;
      case "onClick":
        o != null && (e.onclick = ki);
        break;
      case "onScroll":
        o != null && ge("scroll", e);
        break;
      case "onScrollEnd":
        o != null && ge("scrollend", e);
        break;
      case "dangerouslySetInnerHTML":
        if (o != null) {
          if (typeof o != "object" || !("__html" in o))
            throw Error(s(61));
          if (a = o.__html, a != null) {
            if (u.children != null) throw Error(s(60));
            e.innerHTML = a;
          }
        }
        break;
      case "multiple":
        e.multiple = o && typeof o != "function" && typeof o != "symbol";
        break;
      case "muted":
        e.muted = o && typeof o != "function" && typeof o != "symbol";
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "defaultValue":
      case "defaultChecked":
      case "innerHTML":
      case "ref":
        break;
      case "autoFocus":
        break;
      case "xlinkHref":
        if (o == null || typeof o == "function" || typeof o == "boolean" || typeof o == "symbol") {
          e.removeAttribute("xlink:href");
          break;
        }
        a = gl("" + o), e.setAttributeNS(
          "http://www.w3.org/1999/xlink",
          "xlink:href",
          a
        );
        break;
      case "contentEditable":
      case "spellCheck":
      case "draggable":
      case "value":
      case "autoReverse":
      case "externalResourcesRequired":
      case "focusable":
      case "preserveAlpha":
        o != null && typeof o != "function" && typeof o != "symbol" ? e.setAttribute(a, "" + o) : e.removeAttribute(a);
        break;
      case "inert":
      case "allowFullScreen":
      case "async":
      case "autoPlay":
      case "controls":
      case "default":
      case "defer":
      case "disabled":
      case "disablePictureInPicture":
      case "disableRemotePlayback":
      case "formNoValidate":
      case "hidden":
      case "loop":
      case "noModule":
      case "noValidate":
      case "open":
      case "playsInline":
      case "readOnly":
      case "required":
      case "reversed":
      case "scoped":
      case "seamless":
      case "itemScope":
        o && typeof o != "function" && typeof o != "symbol" ? e.setAttribute(a, "") : e.removeAttribute(a);
        break;
      case "capture":
      case "download":
        o === !0 ? e.setAttribute(a, "") : o !== !1 && o != null && typeof o != "function" && typeof o != "symbol" ? e.setAttribute(a, o) : e.removeAttribute(a);
        break;
      case "cols":
      case "rows":
      case "size":
      case "span":
        o != null && typeof o != "function" && typeof o != "symbol" && !isNaN(o) && 1 <= o ? e.setAttribute(a, o) : e.removeAttribute(a);
        break;
      case "rowSpan":
      case "start":
        o == null || typeof o == "function" || typeof o == "symbol" || isNaN(o) ? e.removeAttribute(a) : e.setAttribute(a, o);
        break;
      case "popover":
        ge("beforetoggle", e), ge("toggle", e), Ee(e, "popover", o);
        break;
      case "xlinkActuate":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:actuate",
          o
        );
        break;
      case "xlinkArcrole":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:arcrole",
          o
        );
        break;
      case "xlinkRole":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:role",
          o
        );
        break;
      case "xlinkShow":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:show",
          o
        );
        break;
      case "xlinkTitle":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:title",
          o
        );
        break;
      case "xlinkType":
        Re(
          e,
          "http://www.w3.org/1999/xlink",
          "xlink:type",
          o
        );
        break;
      case "xmlBase":
        Re(
          e,
          "http://www.w3.org/XML/1998/namespace",
          "xml:base",
          o
        );
        break;
      case "xmlLang":
        Re(
          e,
          "http://www.w3.org/XML/1998/namespace",
          "xml:lang",
          o
        );
        break;
      case "xmlSpace":
        Re(
          e,
          "http://www.w3.org/XML/1998/namespace",
          "xml:space",
          o
        );
        break;
      case "is":
        Ee(e, "is", o);
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        (!(2 < a.length) || a[0] !== "o" && a[0] !== "O" || a[1] !== "n" && a[1] !== "N") && (a = Ox.get(a) || a, Ee(e, a, o));
    }
  }
  function dh(e, n, a, o, u, f) {
    switch (a) {
      case "style":
        Pp(e, o, f);
        break;
      case "dangerouslySetInnerHTML":
        if (o != null) {
          if (typeof o != "object" || !("__html" in o))
            throw Error(s(61));
          if (a = o.__html, a != null) {
            if (u.children != null) throw Error(s(60));
            e.innerHTML = a;
          }
        }
        break;
      case "children":
        typeof o == "string" ? Yn(e, o) : (typeof o == "number" || typeof o == "bigint") && Yn(e, "" + o);
        break;
      case "onScroll":
        o != null && ge("scroll", e);
        break;
      case "onScrollEnd":
        o != null && ge("scrollend", e);
        break;
      case "onClick":
        o != null && (e.onclick = ki);
        break;
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
      case "innerHTML":
      case "ref":
        break;
      case "innerText":
      case "textContent":
        break;
      default:
        if (!Ot.hasOwnProperty(a))
          t: {
            if (a[0] === "o" && a[1] === "n" && (u = a.endsWith("Capture"), n = a.slice(2, u ? a.length - 7 : void 0), f = e[bn] || null, f = f != null ? f[a] : null, typeof f == "function" && e.removeEventListener(n, f, u), typeof o == "function")) {
              typeof f != "function" && f !== null && (a in e ? e[a] = null : e.hasAttribute(a) && e.removeAttribute(a)), e.addEventListener(n, o, u);
              break t;
            }
            a in e ? e[a] = o : o === !0 ? e.setAttribute(a, "") : Ee(e, a, o);
          }
    }
  }
  function wn(e, n, a) {
    switch (n) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "img":
        ge("error", e), ge("load", e);
        var o = !1, u = !1, f;
        for (f in a)
          if (a.hasOwnProperty(f)) {
            var y = a[f];
            if (y != null)
              switch (f) {
                case "src":
                  o = !0;
                  break;
                case "srcSet":
                  u = !0;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  throw Error(s(137, n));
                default:
                  Fe(e, n, f, y, a, null);
              }
          }
        u && Fe(e, n, "srcSet", a.srcSet, a, null), o && Fe(e, n, "src", a.src, a, null);
        return;
      case "input":
        ge("invalid", e);
        var A = f = y = u = null, H = null, nt = null;
        for (o in a)
          if (a.hasOwnProperty(o)) {
            var ft = a[o];
            if (ft != null)
              switch (o) {
                case "name":
                  u = ft;
                  break;
                case "type":
                  y = ft;
                  break;
                case "checked":
                  H = ft;
                  break;
                case "defaultChecked":
                  nt = ft;
                  break;
                case "value":
                  f = ft;
                  break;
                case "defaultValue":
                  A = ft;
                  break;
                case "children":
                case "dangerouslySetInnerHTML":
                  if (ft != null)
                    throw Error(s(137, n));
                  break;
                default:
                  Fe(e, n, o, ft, a, null);
              }
          }
        Fn(
          e,
          f,
          A,
          H,
          nt,
          y,
          u,
          !1
        );
        return;
      case "select":
        ge("invalid", e), o = y = f = null;
        for (u in a)
          if (a.hasOwnProperty(u) && (A = a[u], A != null))
            switch (u) {
              case "value":
                f = A;
                break;
              case "defaultValue":
                y = A;
                break;
              case "multiple":
                o = A;
              default:
                Fe(e, n, u, A, a, null);
            }
        n = f, a = y, e.multiple = !!o, n != null ? tn(e, !!o, n, !1) : a != null && tn(e, !!o, a, !0);
        return;
      case "textarea":
        ge("invalid", e), f = u = o = null;
        for (y in a)
          if (a.hasOwnProperty(y) && (A = a[y], A != null))
            switch (y) {
              case "value":
                o = A;
                break;
              case "defaultValue":
                u = A;
                break;
              case "children":
                f = A;
                break;
              case "dangerouslySetInnerHTML":
                if (A != null) throw Error(s(91));
                break;
              default:
                Fe(e, n, y, A, a, null);
            }
        Gs(e, o, u, f);
        return;
      case "option":
        for (H in a)
          if (a.hasOwnProperty(H) && (o = a[H], o != null))
            switch (H) {
              case "selected":
                e.selected = o && typeof o != "function" && typeof o != "symbol";
                break;
              default:
                Fe(e, n, H, o, a, null);
            }
        return;
      case "dialog":
        ge("beforetoggle", e), ge("toggle", e), ge("cancel", e), ge("close", e);
        break;
      case "iframe":
      case "object":
        ge("load", e);
        break;
      case "video":
      case "audio":
        for (o = 0; o < Go.length; o++)
          ge(Go[o], e);
        break;
      case "image":
        ge("error", e), ge("load", e);
        break;
      case "details":
        ge("toggle", e);
        break;
      case "embed":
      case "source":
      case "link":
        ge("error", e), ge("load", e);
      case "area":
      case "base":
      case "br":
      case "col":
      case "hr":
      case "keygen":
      case "meta":
      case "param":
      case "track":
      case "wbr":
      case "menuitem":
        for (nt in a)
          if (a.hasOwnProperty(nt) && (o = a[nt], o != null))
            switch (nt) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(s(137, n));
              default:
                Fe(e, n, nt, o, a, null);
            }
        return;
      default:
        if (Au(n)) {
          for (ft in a)
            a.hasOwnProperty(ft) && (o = a[ft], o !== void 0 && dh(
              e,
              n,
              ft,
              o,
              a,
              void 0
            ));
          return;
        }
    }
    for (A in a)
      a.hasOwnProperty(A) && (o = a[A], o != null && Fe(e, n, A, o, a, null));
  }
  function oS(e, n, a, o) {
    switch (n) {
      case "div":
      case "span":
      case "svg":
      case "path":
      case "a":
      case "g":
      case "p":
      case "li":
        break;
      case "input":
        var u = null, f = null, y = null, A = null, H = null, nt = null, ft = null;
        for (ct in a) {
          var gt = a[ct];
          if (a.hasOwnProperty(ct) && gt != null)
            switch (ct) {
              case "checked":
                break;
              case "value":
                break;
              case "defaultValue":
                H = gt;
              default:
                o.hasOwnProperty(ct) || Fe(e, n, ct, null, o, gt);
            }
        }
        for (var at in o) {
          var ct = o[at];
          if (gt = a[at], o.hasOwnProperty(at) && (ct != null || gt != null))
            switch (at) {
              case "type":
                f = ct;
                break;
              case "name":
                u = ct;
                break;
              case "checked":
                nt = ct;
                break;
              case "defaultChecked":
                ft = ct;
                break;
              case "value":
                y = ct;
                break;
              case "defaultValue":
                A = ct;
                break;
              case "children":
              case "dangerouslySetInnerHTML":
                if (ct != null)
                  throw Error(s(137, n));
                break;
              default:
                ct !== gt && Fe(
                  e,
                  n,
                  at,
                  ct,
                  o,
                  gt
                );
            }
        }
        Be(
          e,
          y,
          A,
          H,
          nt,
          ft,
          f,
          u
        );
        return;
      case "select":
        ct = y = A = at = null;
        for (f in a)
          if (H = a[f], a.hasOwnProperty(f) && H != null)
            switch (f) {
              case "value":
                break;
              case "multiple":
                ct = H;
              default:
                o.hasOwnProperty(f) || Fe(
                  e,
                  n,
                  f,
                  null,
                  o,
                  H
                );
            }
        for (u in o)
          if (f = o[u], H = a[u], o.hasOwnProperty(u) && (f != null || H != null))
            switch (u) {
              case "value":
                at = f;
                break;
              case "defaultValue":
                A = f;
                break;
              case "multiple":
                y = f;
              default:
                f !== H && Fe(
                  e,
                  n,
                  u,
                  f,
                  o,
                  H
                );
            }
        n = A, a = y, o = ct, at != null ? tn(e, !!a, at, !1) : !!o != !!a && (n != null ? tn(e, !!a, n, !0) : tn(e, !!a, a ? [] : "", !1));
        return;
      case "textarea":
        ct = at = null;
        for (A in a)
          if (u = a[A], a.hasOwnProperty(A) && u != null && !o.hasOwnProperty(A))
            switch (A) {
              case "value":
                break;
              case "children":
                break;
              default:
                Fe(e, n, A, null, o, u);
            }
        for (y in o)
          if (u = o[y], f = a[y], o.hasOwnProperty(y) && (u != null || f != null))
            switch (y) {
              case "value":
                at = u;
                break;
              case "defaultValue":
                ct = u;
                break;
              case "children":
                break;
              case "dangerouslySetInnerHTML":
                if (u != null) throw Error(s(91));
                break;
              default:
                u !== f && Fe(e, n, y, u, o, f);
            }
        Tn(e, at, ct);
        return;
      case "option":
        for (var Vt in a)
          if (at = a[Vt], a.hasOwnProperty(Vt) && at != null && !o.hasOwnProperty(Vt))
            switch (Vt) {
              case "selected":
                e.selected = !1;
                break;
              default:
                Fe(
                  e,
                  n,
                  Vt,
                  null,
                  o,
                  at
                );
            }
        for (H in o)
          if (at = o[H], ct = a[H], o.hasOwnProperty(H) && at !== ct && (at != null || ct != null))
            switch (H) {
              case "selected":
                e.selected = at && typeof at != "function" && typeof at != "symbol";
                break;
              default:
                Fe(
                  e,
                  n,
                  H,
                  at,
                  o,
                  ct
                );
            }
        return;
      case "img":
      case "link":
      case "area":
      case "base":
      case "br":
      case "col":
      case "embed":
      case "hr":
      case "keygen":
      case "meta":
      case "param":
      case "source":
      case "track":
      case "wbr":
      case "menuitem":
        for (var Jt in a)
          at = a[Jt], a.hasOwnProperty(Jt) && at != null && !o.hasOwnProperty(Jt) && Fe(e, n, Jt, null, o, at);
        for (nt in o)
          if (at = o[nt], ct = a[nt], o.hasOwnProperty(nt) && at !== ct && (at != null || ct != null))
            switch (nt) {
              case "children":
              case "dangerouslySetInnerHTML":
                if (at != null)
                  throw Error(s(137, n));
                break;
              default:
                Fe(
                  e,
                  n,
                  nt,
                  at,
                  o,
                  ct
                );
            }
        return;
      default:
        if (Au(n)) {
          for (var He in a)
            at = a[He], a.hasOwnProperty(He) && at !== void 0 && !o.hasOwnProperty(He) && dh(
              e,
              n,
              He,
              void 0,
              o,
              at
            );
          for (ft in o)
            at = o[ft], ct = a[ft], !o.hasOwnProperty(ft) || at === ct || at === void 0 && ct === void 0 || dh(
              e,
              n,
              ft,
              at,
              o,
              ct
            );
          return;
        }
    }
    for (var Z in a)
      at = a[Z], a.hasOwnProperty(Z) && at != null && !o.hasOwnProperty(Z) && Fe(e, n, Z, null, o, at);
    for (gt in o)
      at = o[gt], ct = a[gt], !o.hasOwnProperty(gt) || at === ct || at == null && ct == null || Fe(e, n, gt, at, o, ct);
  }
  function z_(e) {
    switch (e) {
      case "css":
      case "script":
      case "font":
      case "img":
      case "image":
      case "input":
      case "link":
        return !0;
      default:
        return !1;
    }
  }
  function lS() {
    if (typeof performance.getEntriesByType == "function") {
      for (var e = 0, n = 0, a = performance.getEntriesByType("resource"), o = 0; o < a.length; o++) {
        var u = a[o], f = u.transferSize, y = u.initiatorType, A = u.duration;
        if (f && A && z_(y)) {
          for (y = 0, A = u.responseEnd, o += 1; o < a.length; o++) {
            var H = a[o], nt = H.startTime;
            if (nt > A) break;
            var ft = H.transferSize, gt = H.initiatorType;
            ft && z_(gt) && (H = H.responseEnd, y += ft * (H < A ? 1 : (A - nt) / (H - nt)));
          }
          if (--o, n += 8 * (f + y) / (u.duration / 1e3), e++, 10 < e) break;
        }
      }
      if (0 < e) return n / e / 1e6;
    }
    return navigator.connection && (e = navigator.connection.downlink, typeof e == "number") ? e : 5;
  }
  var ph = null, mh = null;
  function fc(e) {
    return e.nodeType === 9 ? e : e.ownerDocument;
  }
  function B_(e) {
    switch (e) {
      case "http://www.w3.org/2000/svg":
        return 1;
      case "http://www.w3.org/1998/Math/MathML":
        return 2;
      default:
        return 0;
    }
  }
  function I_(e, n) {
    if (e === 0)
      switch (n) {
        case "svg":
          return 1;
        case "math":
          return 2;
        default:
          return 0;
      }
    return e === 1 && n === "foreignObject" ? 0 : e;
  }
  function gh(e, n) {
    return e === "textarea" || e === "noscript" || typeof n.children == "string" || typeof n.children == "number" || typeof n.children == "bigint" || typeof n.dangerouslySetInnerHTML == "object" && n.dangerouslySetInnerHTML !== null && n.dangerouslySetInnerHTML.__html != null;
  }
  var _h = null;
  function cS() {
    var e = window.event;
    return e && e.type === "popstate" ? e === _h ? !1 : (_h = e, !0) : (_h = null, !1);
  }
  var F_ = typeof setTimeout == "function" ? setTimeout : void 0, uS = typeof clearTimeout == "function" ? clearTimeout : void 0, H_ = typeof Promise == "function" ? Promise : void 0, fS = typeof queueMicrotask == "function" ? queueMicrotask : typeof H_ < "u" ? function(e) {
    return H_.resolve(null).then(e).catch(hS);
  } : F_;
  function hS(e) {
    setTimeout(function() {
      throw e;
    });
  }
  function Pa(e) {
    return e === "head";
  }
  function G_(e, n) {
    var a = n, o = 0;
    do {
      var u = a.nextSibling;
      if (e.removeChild(a), u && u.nodeType === 8)
        if (a = u.data, a === "/$" || a === "/&") {
          if (o === 0) {
            e.removeChild(u), vr(n);
            return;
          }
          o--;
        } else if (a === "$" || a === "$?" || a === "$~" || a === "$!" || a === "&")
          o++;
        else if (a === "html")
          ko(e.ownerDocument.documentElement);
        else if (a === "head") {
          a = e.ownerDocument.head, ko(a);
          for (var f = a.firstChild; f; ) {
            var y = f.nextSibling, A = f.nodeName;
            f[as] || A === "SCRIPT" || A === "STYLE" || A === "LINK" && f.rel.toLowerCase() === "stylesheet" || a.removeChild(f), f = y;
          }
        } else
          a === "body" && ko(e.ownerDocument.body);
      a = u;
    } while (a);
    vr(n);
  }
  function V_(e, n) {
    var a = e;
    e = 0;
    do {
      var o = a.nextSibling;
      if (a.nodeType === 1 ? n ? (a._stashedDisplay = a.style.display, a.style.display = "none") : (a.style.display = a._stashedDisplay || "", a.getAttribute("style") === "" && a.removeAttribute("style")) : a.nodeType === 3 && (n ? (a._stashedText = a.nodeValue, a.nodeValue = "") : a.nodeValue = a._stashedText || ""), o && o.nodeType === 8)
        if (a = o.data, a === "/$") {
          if (e === 0) break;
          e--;
        } else
          a !== "$" && a !== "$?" && a !== "$~" && a !== "$!" || e++;
      a = o;
    } while (a);
  }
  function vh(e) {
    var n = e.firstChild;
    for (n && n.nodeType === 10 && (n = n.nextSibling); n; ) {
      var a = n;
      switch (n = n.nextSibling, a.nodeName) {
        case "HTML":
        case "HEAD":
        case "BODY":
          vh(a), oo(a);
          continue;
        case "SCRIPT":
        case "STYLE":
          continue;
        case "LINK":
          if (a.rel.toLowerCase() === "stylesheet") continue;
      }
      e.removeChild(a);
    }
  }
  function dS(e, n, a, o) {
    for (; e.nodeType === 1; ) {
      var u = a;
      if (e.nodeName.toLowerCase() !== n.toLowerCase()) {
        if (!o && (e.nodeName !== "INPUT" || e.type !== "hidden"))
          break;
      } else if (o) {
        if (!e[as])
          switch (n) {
            case "meta":
              if (!e.hasAttribute("itemprop")) break;
              return e;
            case "link":
              if (f = e.getAttribute("rel"), f === "stylesheet" && e.hasAttribute("data-precedence"))
                break;
              if (f !== u.rel || e.getAttribute("href") !== (u.href == null || u.href === "" ? null : u.href) || e.getAttribute("crossorigin") !== (u.crossOrigin == null ? null : u.crossOrigin) || e.getAttribute("title") !== (u.title == null ? null : u.title))
                break;
              return e;
            case "style":
              if (e.hasAttribute("data-precedence")) break;
              return e;
            case "script":
              if (f = e.getAttribute("src"), (f !== (u.src == null ? null : u.src) || e.getAttribute("type") !== (u.type == null ? null : u.type) || e.getAttribute("crossorigin") !== (u.crossOrigin == null ? null : u.crossOrigin)) && f && e.hasAttribute("async") && !e.hasAttribute("itemprop"))
                break;
              return e;
            default:
              return e;
          }
      } else if (n === "input" && e.type === "hidden") {
        var f = u.name == null ? null : "" + u.name;
        if (u.type === "hidden" && e.getAttribute("name") === f)
          return e;
      } else return e;
      if (e = vi(e.nextSibling), e === null) break;
    }
    return null;
  }
  function pS(e, n, a) {
    if (n === "") return null;
    for (; e.nodeType !== 3; )
      if ((e.nodeType !== 1 || e.nodeName !== "INPUT" || e.type !== "hidden") && !a || (e = vi(e.nextSibling), e === null)) return null;
    return e;
  }
  function k_(e, n) {
    for (; e.nodeType !== 8; )
      if ((e.nodeType !== 1 || e.nodeName !== "INPUT" || e.type !== "hidden") && !n || (e = vi(e.nextSibling), e === null)) return null;
    return e;
  }
  function xh(e) {
    return e.data === "$?" || e.data === "$~";
  }
  function yh(e) {
    return e.data === "$!" || e.data === "$?" && e.ownerDocument.readyState !== "loading";
  }
  function mS(e, n) {
    var a = e.ownerDocument;
    if (e.data === "$~") e._reactRetry = n;
    else if (e.data !== "$?" || a.readyState !== "loading")
      n();
    else {
      var o = function() {
        n(), a.removeEventListener("DOMContentLoaded", o);
      };
      a.addEventListener("DOMContentLoaded", o), e._reactRetry = o;
    }
  }
  function vi(e) {
    for (; e != null; e = e.nextSibling) {
      var n = e.nodeType;
      if (n === 1 || n === 3) break;
      if (n === 8) {
        if (n = e.data, n === "$" || n === "$!" || n === "$?" || n === "$~" || n === "&" || n === "F!" || n === "F")
          break;
        if (n === "/$" || n === "/&") return null;
      }
    }
    return e;
  }
  var Sh = null;
  function X_(e) {
    e = e.nextSibling;
    for (var n = 0; e; ) {
      if (e.nodeType === 8) {
        var a = e.data;
        if (a === "/$" || a === "/&") {
          if (n === 0)
            return vi(e.nextSibling);
          n--;
        } else
          a !== "$" && a !== "$!" && a !== "$?" && a !== "$~" && a !== "&" || n++;
      }
      e = e.nextSibling;
    }
    return null;
  }
  function W_(e) {
    e = e.previousSibling;
    for (var n = 0; e; ) {
      if (e.nodeType === 8) {
        var a = e.data;
        if (a === "$" || a === "$!" || a === "$?" || a === "$~" || a === "&") {
          if (n === 0) return e;
          n--;
        } else a !== "/$" && a !== "/&" || n++;
      }
      e = e.previousSibling;
    }
    return null;
  }
  function Y_(e, n, a) {
    switch (n = fc(a), e) {
      case "html":
        if (e = n.documentElement, !e) throw Error(s(452));
        return e;
      case "head":
        if (e = n.head, !e) throw Error(s(453));
        return e;
      case "body":
        if (e = n.body, !e) throw Error(s(454));
        return e;
      default:
        throw Error(s(451));
    }
  }
  function ko(e) {
    for (var n = e.attributes; n.length; )
      e.removeAttributeNode(n[0]);
    oo(e);
  }
  var xi = /* @__PURE__ */ new Map(), q_ = /* @__PURE__ */ new Set();
  function hc(e) {
    return typeof e.getRootNode == "function" ? e.getRootNode() : e.nodeType === 9 ? e : e.ownerDocument;
  }
  var sa = tt.d;
  tt.d = {
    f: gS,
    r: _S,
    D: vS,
    C: xS,
    L: yS,
    m: SS,
    X: ES,
    S: MS,
    M: bS
  };
  function gS() {
    var e = sa.f(), n = ic();
    return e || n;
  }
  function _S(e) {
    var n = Y(e);
    n !== null && n.tag === 5 && n.type === "form" ? ug(n) : sa.r(e);
  }
  var mr = typeof document > "u" ? null : document;
  function j_(e, n, a) {
    var o = mr;
    if (o && typeof n == "string" && n) {
      var u = xn(n);
      u = 'link[rel="' + e + '"][href="' + u + '"]', typeof a == "string" && (u += '[crossorigin="' + a + '"]'), q_.has(u) || (q_.add(u), e = { rel: e, crossOrigin: a, href: n }, o.querySelector(u) === null && (n = o.createElement("link"), wn(n, "link", e), X(n), o.head.appendChild(n)));
    }
  }
  function vS(e) {
    sa.D(e), j_("dns-prefetch", e, null);
  }
  function xS(e, n) {
    sa.C(e, n), j_("preconnect", e, n);
  }
  function yS(e, n, a) {
    sa.L(e, n, a);
    var o = mr;
    if (o && e && n) {
      var u = 'link[rel="preload"][as="' + xn(n) + '"]';
      n === "image" && a && a.imageSrcSet ? (u += '[imagesrcset="' + xn(
        a.imageSrcSet
      ) + '"]', typeof a.imageSizes == "string" && (u += '[imagesizes="' + xn(
        a.imageSizes
      ) + '"]')) : u += '[href="' + xn(e) + '"]';
      var f = u;
      switch (n) {
        case "style":
          f = gr(e);
          break;
        case "script":
          f = _r(e);
      }
      xi.has(f) || (e = _(
        {
          rel: "preload",
          href: n === "image" && a && a.imageSrcSet ? void 0 : e,
          as: n
        },
        a
      ), xi.set(f, e), o.querySelector(u) !== null || n === "style" && o.querySelector(Xo(f)) || n === "script" && o.querySelector(Wo(f)) || (n = o.createElement("link"), wn(n, "link", e), X(n), o.head.appendChild(n)));
    }
  }
  function SS(e, n) {
    sa.m(e, n);
    var a = mr;
    if (a && e) {
      var o = n && typeof n.as == "string" ? n.as : "script", u = 'link[rel="modulepreload"][as="' + xn(o) + '"][href="' + xn(e) + '"]', f = u;
      switch (o) {
        case "audioworklet":
        case "paintworklet":
        case "serviceworker":
        case "sharedworker":
        case "worker":
        case "script":
          f = _r(e);
      }
      if (!xi.has(f) && (e = _({ rel: "modulepreload", href: e }, n), xi.set(f, e), a.querySelector(u) === null)) {
        switch (o) {
          case "audioworklet":
          case "paintworklet":
          case "serviceworker":
          case "sharedworker":
          case "worker":
          case "script":
            if (a.querySelector(Wo(f)))
              return;
        }
        o = a.createElement("link"), wn(o, "link", e), X(o), a.head.appendChild(o);
      }
    }
  }
  function MS(e, n, a) {
    sa.S(e, n, a);
    var o = mr;
    if (o && e) {
      var u = ot(o).hoistableStyles, f = gr(e);
      n = n || "default";
      var y = u.get(f);
      if (!y) {
        var A = { loading: 0, preload: null };
        if (y = o.querySelector(
          Xo(f)
        ))
          A.loading = 5;
        else {
          e = _(
            { rel: "stylesheet", href: e, "data-precedence": n },
            a
          ), (a = xi.get(f)) && Mh(e, a);
          var H = y = o.createElement("link");
          X(H), wn(H, "link", e), H._p = new Promise(function(nt, ft) {
            H.onload = nt, H.onerror = ft;
          }), H.addEventListener("load", function() {
            A.loading |= 1;
          }), H.addEventListener("error", function() {
            A.loading |= 2;
          }), A.loading |= 4, dc(y, n, o);
        }
        y = {
          type: "stylesheet",
          instance: y,
          count: 1,
          state: A
        }, u.set(f, y);
      }
    }
  }
  function ES(e, n) {
    sa.X(e, n);
    var a = mr;
    if (a && e) {
      var o = ot(a).hoistableScripts, u = _r(e), f = o.get(u);
      f || (f = a.querySelector(Wo(u)), f || (e = _({ src: e, async: !0 }, n), (n = xi.get(u)) && Eh(e, n), f = a.createElement("script"), X(f), wn(f, "link", e), a.head.appendChild(f)), f = {
        type: "script",
        instance: f,
        count: 1,
        state: null
      }, o.set(u, f));
    }
  }
  function bS(e, n) {
    sa.M(e, n);
    var a = mr;
    if (a && e) {
      var o = ot(a).hoistableScripts, u = _r(e), f = o.get(u);
      f || (f = a.querySelector(Wo(u)), f || (e = _({ src: e, async: !0, type: "module" }, n), (n = xi.get(u)) && Eh(e, n), f = a.createElement("script"), X(f), wn(f, "link", e), a.head.appendChild(f)), f = {
        type: "script",
        instance: f,
        count: 1,
        state: null
      }, o.set(u, f));
    }
  }
  function Z_(e, n, a, o) {
    var u = (u = Et.current) ? hc(u) : null;
    if (!u) throw Error(s(446));
    switch (e) {
      case "meta":
      case "title":
        return null;
      case "style":
        return typeof a.precedence == "string" && typeof a.href == "string" ? (n = gr(a.href), a = ot(
          u
        ).hoistableStyles, o = a.get(n), o || (o = {
          type: "style",
          instance: null,
          count: 0,
          state: null
        }, a.set(n, o)), o) : { type: "void", instance: null, count: 0, state: null };
      case "link":
        if (a.rel === "stylesheet" && typeof a.href == "string" && typeof a.precedence == "string") {
          e = gr(a.href);
          var f = ot(
            u
          ).hoistableStyles, y = f.get(e);
          if (y || (u = u.ownerDocument || u, y = {
            type: "stylesheet",
            instance: null,
            count: 0,
            state: { loading: 0, preload: null }
          }, f.set(e, y), (f = u.querySelector(
            Xo(e)
          )) && !f._p && (y.instance = f, y.state.loading = 5), xi.has(e) || (a = {
            rel: "preload",
            as: "style",
            href: a.href,
            crossOrigin: a.crossOrigin,
            integrity: a.integrity,
            media: a.media,
            hrefLang: a.hrefLang,
            referrerPolicy: a.referrerPolicy
          }, xi.set(e, a), f || TS(
            u,
            e,
            a,
            y.state
          ))), n && o === null)
            throw Error(s(528, ""));
          return y;
        }
        if (n && o !== null)
          throw Error(s(529, ""));
        return null;
      case "script":
        return n = a.async, a = a.src, typeof a == "string" && n && typeof n != "function" && typeof n != "symbol" ? (n = _r(a), a = ot(
          u
        ).hoistableScripts, o = a.get(n), o || (o = {
          type: "script",
          instance: null,
          count: 0,
          state: null
        }, a.set(n, o)), o) : { type: "void", instance: null, count: 0, state: null };
      default:
        throw Error(s(444, e));
    }
  }
  function gr(e) {
    return 'href="' + xn(e) + '"';
  }
  function Xo(e) {
    return 'link[rel="stylesheet"][' + e + "]";
  }
  function K_(e) {
    return _({}, e, {
      "data-precedence": e.precedence,
      precedence: null
    });
  }
  function TS(e, n, a, o) {
    e.querySelector('link[rel="preload"][as="style"][' + n + "]") ? o.loading = 1 : (n = e.createElement("link"), o.preload = n, n.addEventListener("load", function() {
      return o.loading |= 1;
    }), n.addEventListener("error", function() {
      return o.loading |= 2;
    }), wn(n, "link", a), X(n), e.head.appendChild(n));
  }
  function _r(e) {
    return '[src="' + xn(e) + '"]';
  }
  function Wo(e) {
    return "script[async]" + e;
  }
  function Q_(e, n, a) {
    if (n.count++, n.instance === null)
      switch (n.type) {
        case "style":
          var o = e.querySelector(
            'style[data-href~="' + xn(a.href) + '"]'
          );
          if (o)
            return n.instance = o, X(o), o;
          var u = _({}, a, {
            "data-href": a.href,
            "data-precedence": a.precedence,
            href: null,
            precedence: null
          });
          return o = (e.ownerDocument || e).createElement(
            "style"
          ), X(o), wn(o, "style", u), dc(o, a.precedence, e), n.instance = o;
        case "stylesheet":
          u = gr(a.href);
          var f = e.querySelector(
            Xo(u)
          );
          if (f)
            return n.state.loading |= 4, n.instance = f, X(f), f;
          o = K_(a), (u = xi.get(u)) && Mh(o, u), f = (e.ownerDocument || e).createElement("link"), X(f);
          var y = f;
          return y._p = new Promise(function(A, H) {
            y.onload = A, y.onerror = H;
          }), wn(f, "link", o), n.state.loading |= 4, dc(f, a.precedence, e), n.instance = f;
        case "script":
          return f = _r(a.src), (u = e.querySelector(
            Wo(f)
          )) ? (n.instance = u, X(u), u) : (o = a, (u = xi.get(f)) && (o = _({}, a), Eh(o, u)), e = e.ownerDocument || e, u = e.createElement("script"), X(u), wn(u, "link", o), e.head.appendChild(u), n.instance = u);
        case "void":
          return null;
        default:
          throw Error(s(443, n.type));
      }
    else
      n.type === "stylesheet" && (n.state.loading & 4) === 0 && (o = n.instance, n.state.loading |= 4, dc(o, a.precedence, e));
    return n.instance;
  }
  function dc(e, n, a) {
    for (var o = a.querySelectorAll(
      'link[rel="stylesheet"][data-precedence],style[data-precedence]'
    ), u = o.length ? o[o.length - 1] : null, f = u, y = 0; y < o.length; y++) {
      var A = o[y];
      if (A.dataset.precedence === n) f = A;
      else if (f !== u) break;
    }
    f ? f.parentNode.insertBefore(e, f.nextSibling) : (n = a.nodeType === 9 ? a.head : a, n.insertBefore(e, n.firstChild));
  }
  function Mh(e, n) {
    e.crossOrigin == null && (e.crossOrigin = n.crossOrigin), e.referrerPolicy == null && (e.referrerPolicy = n.referrerPolicy), e.title == null && (e.title = n.title);
  }
  function Eh(e, n) {
    e.crossOrigin == null && (e.crossOrigin = n.crossOrigin), e.referrerPolicy == null && (e.referrerPolicy = n.referrerPolicy), e.integrity == null && (e.integrity = n.integrity);
  }
  var pc = null;
  function J_(e, n, a) {
    if (pc === null) {
      var o = /* @__PURE__ */ new Map(), u = pc = /* @__PURE__ */ new Map();
      u.set(a, o);
    } else
      u = pc, o = u.get(a), o || (o = /* @__PURE__ */ new Map(), u.set(a, o));
    if (o.has(e)) return o;
    for (o.set(e, null), a = a.getElementsByTagName(e), u = 0; u < a.length; u++) {
      var f = a[u];
      if (!(f[as] || f[$e] || e === "link" && f.getAttribute("rel") === "stylesheet") && f.namespaceURI !== "http://www.w3.org/2000/svg") {
        var y = f.getAttribute(n) || "";
        y = e + y;
        var A = o.get(y);
        A ? A.push(f) : o.set(y, [f]);
      }
    }
    return o;
  }
  function $_(e, n, a) {
    e = e.ownerDocument || e, e.head.insertBefore(
      a,
      n === "title" ? e.querySelector("head > title") : null
    );
  }
  function AS(e, n, a) {
    if (a === 1 || n.itemProp != null) return !1;
    switch (e) {
      case "meta":
      case "title":
        return !0;
      case "style":
        if (typeof n.precedence != "string" || typeof n.href != "string" || n.href === "")
          break;
        return !0;
      case "link":
        if (typeof n.rel != "string" || typeof n.href != "string" || n.href === "" || n.onLoad || n.onError)
          break;
        switch (n.rel) {
          case "stylesheet":
            return e = n.disabled, typeof n.precedence == "string" && e == null;
          default:
            return !0;
        }
      case "script":
        if (n.async && typeof n.async != "function" && typeof n.async != "symbol" && !n.onLoad && !n.onError && n.src && typeof n.src == "string")
          return !0;
    }
    return !1;
  }
  function t0(e) {
    return !(e.type === "stylesheet" && (e.state.loading & 3) === 0);
  }
  function RS(e, n, a, o) {
    if (a.type === "stylesheet" && (typeof o.media != "string" || matchMedia(o.media).matches !== !1) && (a.state.loading & 4) === 0) {
      if (a.instance === null) {
        var u = gr(o.href), f = n.querySelector(
          Xo(u)
        );
        if (f) {
          n = f._p, n !== null && typeof n == "object" && typeof n.then == "function" && (e.count++, e = mc.bind(e), n.then(e, e)), a.state.loading |= 4, a.instance = f, X(f);
          return;
        }
        f = n.ownerDocument || n, o = K_(o), (u = xi.get(u)) && Mh(o, u), f = f.createElement("link"), X(f);
        var y = f;
        y._p = new Promise(function(A, H) {
          y.onload = A, y.onerror = H;
        }), wn(f, "link", o), a.instance = f;
      }
      e.stylesheets === null && (e.stylesheets = /* @__PURE__ */ new Map()), e.stylesheets.set(a, n), (n = a.state.preload) && (a.state.loading & 3) === 0 && (e.count++, a = mc.bind(e), n.addEventListener("load", a), n.addEventListener("error", a));
    }
  }
  var bh = 0;
  function CS(e, n) {
    return e.stylesheets && e.count === 0 && _c(e, e.stylesheets), 0 < e.count || 0 < e.imgCount ? function(a) {
      var o = setTimeout(function() {
        if (e.stylesheets && _c(e, e.stylesheets), e.unsuspend) {
          var f = e.unsuspend;
          e.unsuspend = null, f();
        }
      }, 6e4 + n);
      0 < e.imgBytes && bh === 0 && (bh = 62500 * lS());
      var u = setTimeout(
        function() {
          if (e.waitingForImages = !1, e.count === 0 && (e.stylesheets && _c(e, e.stylesheets), e.unsuspend)) {
            var f = e.unsuspend;
            e.unsuspend = null, f();
          }
        },
        (e.imgBytes > bh ? 50 : 800) + n
      );
      return e.unsuspend = a, function() {
        e.unsuspend = null, clearTimeout(o), clearTimeout(u);
      };
    } : null;
  }
  function mc() {
    if (this.count--, this.count === 0 && (this.imgCount === 0 || !this.waitingForImages)) {
      if (this.stylesheets) _c(this, this.stylesheets);
      else if (this.unsuspend) {
        var e = this.unsuspend;
        this.unsuspend = null, e();
      }
    }
  }
  var gc = null;
  function _c(e, n) {
    e.stylesheets = null, e.unsuspend !== null && (e.count++, gc = /* @__PURE__ */ new Map(), n.forEach(wS, e), gc = null, mc.call(e));
  }
  function wS(e, n) {
    if (!(n.state.loading & 4)) {
      var a = gc.get(e);
      if (a) var o = a.get(null);
      else {
        a = /* @__PURE__ */ new Map(), gc.set(e, a);
        for (var u = e.querySelectorAll(
          "link[data-precedence],style[data-precedence]"
        ), f = 0; f < u.length; f++) {
          var y = u[f];
          (y.nodeName === "LINK" || y.getAttribute("media") !== "not all") && (a.set(y.dataset.precedence, y), o = y);
        }
        o && a.set(null, o);
      }
      u = n.instance, y = u.getAttribute("data-precedence"), f = a.get(y) || o, f === o && a.set(null, u), a.set(y, u), this.count++, o = mc.bind(this), u.addEventListener("load", o), u.addEventListener("error", o), f ? f.parentNode.insertBefore(u, f.nextSibling) : (e = e.nodeType === 9 ? e.head : e, e.insertBefore(u, e.firstChild)), n.state.loading |= 4;
    }
  }
  var Yo = {
    $$typeof: U,
    Provider: null,
    Consumer: null,
    _currentValue: K,
    _currentValue2: K,
    _threadCount: 0
  };
  function DS(e, n, a, o, u, f, y, A, H) {
    this.tag = 1, this.containerInfo = e, this.pingCache = this.current = this.pendingChildren = null, this.timeoutHandle = -1, this.callbackNode = this.next = this.pendingContext = this.context = this.cancelPendingCommit = null, this.callbackPriority = 0, this.expirationTimes = Ae(-1), this.entangledLanes = this.shellSuspendCounter = this.errorRecoveryDisabledLanes = this.expiredLanes = this.warmLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0, this.entanglements = Ae(0), this.hiddenUpdates = Ae(null), this.identifierPrefix = o, this.onUncaughtError = u, this.onCaughtError = f, this.onRecoverableError = y, this.pooledCache = null, this.pooledCacheLanes = 0, this.formState = H, this.incompleteTransitions = /* @__PURE__ */ new Map();
  }
  function e0(e, n, a, o, u, f, y, A, H, nt, ft, gt) {
    return e = new DS(
      e,
      n,
      a,
      y,
      H,
      nt,
      ft,
      gt,
      A
    ), n = 1, f === !0 && (n |= 24), f = ni(3, null, null, n), e.current = f, f.stateNode = e, n = nf(), n.refCount++, e.pooledCache = n, n.refCount++, f.memoizedState = {
      element: o,
      isDehydrated: a,
      cache: n
    }, of(f), e;
  }
  function n0(e) {
    return e ? (e = js, e) : js;
  }
  function i0(e, n, a, o, u, f) {
    u = n0(u), o.context === null ? o.context = u : o.pendingContext = u, o = ba(n), o.payload = { element: a }, f = f === void 0 ? null : f, f !== null && (o.callback = f), a = Ta(e, o, n), a !== null && (Jn(a, e, n), bo(a, e, n));
  }
  function a0(e, n) {
    if (e = e.memoizedState, e !== null && e.dehydrated !== null) {
      var a = e.retryLane;
      e.retryLane = a !== 0 && a < n ? a : n;
    }
  }
  function Th(e, n) {
    a0(e, n), (e = e.alternate) && a0(e, n);
  }
  function s0(e) {
    if (e.tag === 13 || e.tag === 31) {
      var n = ls(e, 67108864);
      n !== null && Jn(n, e, 67108864), Th(e, 67108864);
    }
  }
  function r0(e) {
    if (e.tag === 13 || e.tag === 31) {
      var n = oi();
      n = ns(n);
      var a = ls(e, n);
      a !== null && Jn(a, e, n), Th(e, n);
    }
  }
  var vc = !0;
  function US(e, n, a, o) {
    var u = z.T;
    z.T = null;
    var f = tt.p;
    try {
      tt.p = 2, Ah(e, n, a, o);
    } finally {
      tt.p = f, z.T = u;
    }
  }
  function LS(e, n, a, o) {
    var u = z.T;
    z.T = null;
    var f = tt.p;
    try {
      tt.p = 8, Ah(e, n, a, o);
    } finally {
      tt.p = f, z.T = u;
    }
  }
  function Ah(e, n, a, o) {
    if (vc) {
      var u = Rh(o);
      if (u === null)
        hh(
          e,
          n,
          o,
          xc,
          a
        ), l0(e, o);
      else if (OS(
        u,
        e,
        n,
        a,
        o
      ))
        o.stopPropagation();
      else if (l0(e, o), n & 4 && -1 < NS.indexOf(e)) {
        for (; u !== null; ) {
          var f = Y(u);
          if (f !== null)
            switch (f.tag) {
              case 3:
                if (f = f.stateNode, f.current.memoizedState.isDehydrated) {
                  var y = Ut(f.pendingLanes);
                  if (y !== 0) {
                    var A = f;
                    for (A.pendingLanes |= 2, A.entangledLanes |= 2; y; ) {
                      var H = 1 << 31 - te(y);
                      A.entanglements[1] |= H, y &= ~H;
                    }
                    Bi(f), (Le & 6) === 0 && (ec = dt() + 500, Ho(0));
                  }
                }
                break;
              case 31:
              case 13:
                A = ls(f, 2), A !== null && Jn(A, f, 2), ic(), Th(f, 2);
            }
          if (f = Rh(o), f === null && hh(
            e,
            n,
            o,
            xc,
            a
          ), f === u) break;
          u = f;
        }
        u !== null && o.stopPropagation();
      } else
        hh(
          e,
          n,
          o,
          null,
          a
        );
    }
  }
  function Rh(e) {
    return e = Cu(e), Ch(e);
  }
  var xc = null;
  function Ch(e) {
    if (xc = null, e = D(e), e !== null) {
      var n = c(e);
      if (n === null) e = null;
      else {
        var a = n.tag;
        if (a === 13) {
          if (e = h(n), e !== null) return e;
          e = null;
        } else if (a === 31) {
          if (e = d(n), e !== null) return e;
          e = null;
        } else if (a === 3) {
          if (n.stateNode.current.memoizedState.isDehydrated)
            return n.tag === 3 ? n.stateNode.containerInfo : null;
          e = null;
        } else n !== e && (e = null);
      }
    }
    return xc = e, null;
  }
  function o0(e) {
    switch (e) {
      case "beforetoggle":
      case "cancel":
      case "click":
      case "close":
      case "contextmenu":
      case "copy":
      case "cut":
      case "auxclick":
      case "dblclick":
      case "dragend":
      case "dragstart":
      case "drop":
      case "focusin":
      case "focusout":
      case "input":
      case "invalid":
      case "keydown":
      case "keypress":
      case "keyup":
      case "mousedown":
      case "mouseup":
      case "paste":
      case "pause":
      case "play":
      case "pointercancel":
      case "pointerdown":
      case "pointerup":
      case "ratechange":
      case "reset":
      case "resize":
      case "seeked":
      case "submit":
      case "toggle":
      case "touchcancel":
      case "touchend":
      case "touchstart":
      case "volumechange":
      case "change":
      case "selectionchange":
      case "textInput":
      case "compositionstart":
      case "compositionend":
      case "compositionupdate":
      case "beforeblur":
      case "afterblur":
      case "beforeinput":
      case "blur":
      case "fullscreenchange":
      case "focus":
      case "hashchange":
      case "popstate":
      case "select":
      case "selectstart":
        return 2;
      case "drag":
      case "dragenter":
      case "dragexit":
      case "dragleave":
      case "dragover":
      case "mousemove":
      case "mouseout":
      case "mouseover":
      case "pointermove":
      case "pointerout":
      case "pointerover":
      case "scroll":
      case "touchmove":
      case "wheel":
      case "mouseenter":
      case "mouseleave":
      case "pointerenter":
      case "pointerleave":
        return 8;
      case "message":
        switch (St()) {
          case Q:
            return 2;
          case Tt:
            return 8;
          case wt:
          case Bt:
            return 32;
          case xe:
            return 268435456;
          default:
            return 32;
        }
      default:
        return 32;
    }
  }
  var wh = !1, za = null, Ba = null, Ia = null, qo = /* @__PURE__ */ new Map(), jo = /* @__PURE__ */ new Map(), Fa = [], NS = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(
    " "
  );
  function l0(e, n) {
    switch (e) {
      case "focusin":
      case "focusout":
        za = null;
        break;
      case "dragenter":
      case "dragleave":
        Ba = null;
        break;
      case "mouseover":
      case "mouseout":
        Ia = null;
        break;
      case "pointerover":
      case "pointerout":
        qo.delete(n.pointerId);
        break;
      case "gotpointercapture":
      case "lostpointercapture":
        jo.delete(n.pointerId);
    }
  }
  function Zo(e, n, a, o, u, f) {
    return e === null || e.nativeEvent !== f ? (e = {
      blockedOn: n,
      domEventName: a,
      eventSystemFlags: o,
      nativeEvent: f,
      targetContainers: [u]
    }, n !== null && (n = Y(n), n !== null && s0(n)), e) : (e.eventSystemFlags |= o, n = e.targetContainers, u !== null && n.indexOf(u) === -1 && n.push(u), e);
  }
  function OS(e, n, a, o, u) {
    switch (n) {
      case "focusin":
        return za = Zo(
          za,
          e,
          n,
          a,
          o,
          u
        ), !0;
      case "dragenter":
        return Ba = Zo(
          Ba,
          e,
          n,
          a,
          o,
          u
        ), !0;
      case "mouseover":
        return Ia = Zo(
          Ia,
          e,
          n,
          a,
          o,
          u
        ), !0;
      case "pointerover":
        var f = u.pointerId;
        return qo.set(
          f,
          Zo(
            qo.get(f) || null,
            e,
            n,
            a,
            o,
            u
          )
        ), !0;
      case "gotpointercapture":
        return f = u.pointerId, jo.set(
          f,
          Zo(
            jo.get(f) || null,
            e,
            n,
            a,
            o,
            u
          )
        ), !0;
    }
    return !1;
  }
  function c0(e) {
    var n = D(e.target);
    if (n !== null) {
      var a = c(n);
      if (a !== null) {
        if (n = a.tag, n === 13) {
          if (n = h(a), n !== null) {
            e.blockedOn = n, is(e.priority, function() {
              r0(a);
            });
            return;
          }
        } else if (n === 31) {
          if (n = d(a), n !== null) {
            e.blockedOn = n, is(e.priority, function() {
              r0(a);
            });
            return;
          }
        } else if (n === 3 && a.stateNode.current.memoizedState.isDehydrated) {
          e.blockedOn = a.tag === 3 ? a.stateNode.containerInfo : null;
          return;
        }
      }
    }
    e.blockedOn = null;
  }
  function yc(e) {
    if (e.blockedOn !== null) return !1;
    for (var n = e.targetContainers; 0 < n.length; ) {
      var a = Rh(e.nativeEvent);
      if (a === null) {
        a = e.nativeEvent;
        var o = new a.constructor(
          a.type,
          a
        );
        Ru = o, a.target.dispatchEvent(o), Ru = null;
      } else
        return n = Y(a), n !== null && s0(n), e.blockedOn = a, !1;
      n.shift();
    }
    return !0;
  }
  function u0(e, n, a) {
    yc(e) && a.delete(n);
  }
  function PS() {
    wh = !1, za !== null && yc(za) && (za = null), Ba !== null && yc(Ba) && (Ba = null), Ia !== null && yc(Ia) && (Ia = null), qo.forEach(u0), jo.forEach(u0);
  }
  function Sc(e, n) {
    e.blockedOn === n && (e.blockedOn = null, wh || (wh = !0, r.unstable_scheduleCallback(
      r.unstable_NormalPriority,
      PS
    )));
  }
  var Mc = null;
  function f0(e) {
    Mc !== e && (Mc = e, r.unstable_scheduleCallback(
      r.unstable_NormalPriority,
      function() {
        Mc === e && (Mc = null);
        for (var n = 0; n < e.length; n += 3) {
          var a = e[n], o = e[n + 1], u = e[n + 2];
          if (typeof o != "function") {
            if (Ch(o || a) === null)
              continue;
            break;
          }
          var f = Y(a);
          f !== null && (e.splice(n, 3), n -= 3, Rf(
            f,
            {
              pending: !0,
              data: u,
              method: a.method,
              action: o
            },
            o,
            u
          ));
        }
      }
    ));
  }
  function vr(e) {
    function n(H) {
      return Sc(H, e);
    }
    za !== null && Sc(za, e), Ba !== null && Sc(Ba, e), Ia !== null && Sc(Ia, e), qo.forEach(n), jo.forEach(n);
    for (var a = 0; a < Fa.length; a++) {
      var o = Fa[a];
      o.blockedOn === e && (o.blockedOn = null);
    }
    for (; 0 < Fa.length && (a = Fa[0], a.blockedOn === null); )
      c0(a), a.blockedOn === null && Fa.shift();
    if (a = (e.ownerDocument || e).$$reactFormReplay, a != null)
      for (o = 0; o < a.length; o += 3) {
        var u = a[o], f = a[o + 1], y = u[bn] || null;
        if (typeof f == "function")
          y || f0(a);
        else if (y) {
          var A = null;
          if (f && f.hasAttribute("formAction")) {
            if (u = f, y = f[bn] || null)
              A = y.formAction;
            else if (Ch(u) !== null) continue;
          } else A = y.action;
          typeof A == "function" ? a[o + 1] = A : (a.splice(o, 3), o -= 3), f0(a);
        }
      }
  }
  function h0() {
    function e(f) {
      f.canIntercept && f.info === "react-transition" && f.intercept({
        handler: function() {
          return new Promise(function(y) {
            return u = y;
          });
        },
        focusReset: "manual",
        scroll: "manual"
      });
    }
    function n() {
      u !== null && (u(), u = null), o || setTimeout(a, 20);
    }
    function a() {
      if (!o && !navigation.transition) {
        var f = navigation.currentEntry;
        f && f.url != null && navigation.navigate(f.url, {
          state: f.getState(),
          info: "react-transition",
          history: "replace"
        });
      }
    }
    if (typeof navigation == "object") {
      var o = !1, u = null;
      return navigation.addEventListener("navigate", e), navigation.addEventListener("navigatesuccess", n), navigation.addEventListener("navigateerror", n), setTimeout(a, 100), function() {
        o = !0, navigation.removeEventListener("navigate", e), navigation.removeEventListener("navigatesuccess", n), navigation.removeEventListener("navigateerror", n), u !== null && (u(), u = null);
      };
    }
  }
  function Dh(e) {
    this._internalRoot = e;
  }
  Ec.prototype.render = Dh.prototype.render = function(e) {
    var n = this._internalRoot;
    if (n === null) throw Error(s(409));
    var a = n.current, o = oi();
    i0(a, o, e, n, null, null);
  }, Ec.prototype.unmount = Dh.prototype.unmount = function() {
    var e = this._internalRoot;
    if (e !== null) {
      this._internalRoot = null;
      var n = e.containerInfo;
      i0(e.current, 2, null, e, null, null), ic(), n[Vi] = null;
    }
  };
  function Ec(e) {
    this._internalRoot = e;
  }
  Ec.prototype.unstable_scheduleHydration = function(e) {
    if (e) {
      var n = so();
      e = { blockedOn: null, target: e, priority: n };
      for (var a = 0; a < Fa.length && n !== 0 && n < Fa[a].priority; a++) ;
      Fa.splice(a, 0, e), a === 0 && c0(e);
    }
  };
  var d0 = t.version;
  if (d0 !== "19.2.4")
    throw Error(
      s(
        527,
        d0,
        "19.2.4"
      )
    );
  tt.findDOMNode = function(e) {
    var n = e._reactInternals;
    if (n === void 0)
      throw typeof e.render == "function" ? Error(s(188)) : (e = Object.keys(e).join(","), Error(s(268, e)));
    return e = p(n), e = e !== null ? g(e) : null, e = e === null ? null : e.stateNode, e;
  };
  var zS = {
    bundleType: 0,
    version: "19.2.4",
    rendererPackageName: "react-dom",
    currentDispatcherRef: z,
    reconcilerVersion: "19.2.4"
  };
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u") {
    var bc = __REACT_DEVTOOLS_GLOBAL_HOOK__;
    if (!bc.isDisabled && bc.supportsFiber)
      try {
        jt = bc.inject(
          zS
        ), Wt = bc;
      } catch {
      }
  }
  return Ko.createRoot = function(e, n) {
    if (!l(e)) throw Error(s(299));
    var a = !1, o = "", u = yg, f = Sg, y = Mg;
    return n != null && (n.unstable_strictMode === !0 && (a = !0), n.identifierPrefix !== void 0 && (o = n.identifierPrefix), n.onUncaughtError !== void 0 && (u = n.onUncaughtError), n.onCaughtError !== void 0 && (f = n.onCaughtError), n.onRecoverableError !== void 0 && (y = n.onRecoverableError)), n = e0(
      e,
      1,
      !1,
      null,
      null,
      a,
      o,
      null,
      u,
      f,
      y,
      h0
    ), e[Vi] = n.current, fh(e), new Dh(n);
  }, Ko.hydrateRoot = function(e, n, a) {
    if (!l(e)) throw Error(s(299));
    var o = !1, u = "", f = yg, y = Sg, A = Mg, H = null;
    return a != null && (a.unstable_strictMode === !0 && (o = !0), a.identifierPrefix !== void 0 && (u = a.identifierPrefix), a.onUncaughtError !== void 0 && (f = a.onUncaughtError), a.onCaughtError !== void 0 && (y = a.onCaughtError), a.onRecoverableError !== void 0 && (A = a.onRecoverableError), a.formState !== void 0 && (H = a.formState)), n = e0(
      e,
      1,
      !0,
      n,
      a ?? null,
      o,
      u,
      H,
      f,
      y,
      A,
      h0
    ), n.context = n0(null), a = n.current, o = oi(), o = ns(o), u = ba(o), u.callback = null, Ta(a, u, o), a = o, n.current.lanes = a, En(n, a), Bi(n), e[Vi] = n.current, fh(e), new Ec(n);
  }, Ko.version = "19.2.4", Ko;
}
var S0;
function YS() {
  if (S0) return Lh.exports;
  S0 = 1;
  function r() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r);
      } catch (t) {
        console.error(t);
      }
  }
  return r(), Lh.exports = WS(), Lh.exports;
}
var qS = YS(), zh = { exports: {} }, Qo = {};
/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var M0;
function jS() {
  if (M0) return Qo;
  M0 = 1;
  var r = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
  function i(s, l, c) {
    var h = null;
    if (c !== void 0 && (h = "" + c), l.key !== void 0 && (h = "" + l.key), "key" in l) {
      c = {};
      for (var d in l)
        d !== "key" && (c[d] = l[d]);
    } else c = l;
    return l = c.ref, {
      $$typeof: r,
      type: s,
      key: h,
      ref: l !== void 0 ? l : null,
      props: c
    };
  }
  return Qo.Fragment = t, Qo.jsx = i, Qo.jsxs = i, Qo;
}
var E0;
function ZS() {
  return E0 || (E0 = 1, zh.exports = jS()), zh.exports;
}
var bt = ZS();
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const _p = "172", Xr = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Vr = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, KS = 0, b0 = 1, QS = 2, $v = 1, JS = 2, ha = 3, ts = 0, ti = 1, da = 2, Qa = 0, Wr = 1, T0 = 2, A0 = 3, R0 = 4, $S = 5, ws = 100, tM = 101, eM = 102, nM = 103, iM = 104, aM = 200, sM = 201, rM = 202, oM = 203, Md = 204, Ed = 205, lM = 206, cM = 207, uM = 208, fM = 209, hM = 210, dM = 211, pM = 212, mM = 213, gM = 214, bd = 0, Td = 1, Ad = 2, jr = 3, Rd = 4, Cd = 5, wd = 6, Dd = 7, vp = 0, _M = 1, vM = 2, Ja = 0, xM = 1, yM = 2, SM = 3, MM = 4, EM = 5, bM = 6, TM = 7, tx = 300, Zr = 301, Kr = 302, Ud = 303, Ld = 304, xu = 306, Nd = 1e3, Us = 1001, Od = 1002, Dn = 1003, AM = 1004, Tc = 1005, Hi = 1006, Bh = 1007, Ls = 1008, ga = 1009, ex = 1010, nx = 1011, ul = 1012, xp = 1013, Ps = 1014, Ei = 1015, hl = 1016, yp = 1017, Sp = 1018, Qr = 1020, ix = 35902, ax = 1021, sx = 1022, fi = 1023, rx = 1024, ox = 1025, Yr = 1026, Jr = 1027, Mp = 1028, Ep = 1029, lx = 1030, bp = 1031, Tp = 1033, nu = 33776, iu = 33777, au = 33778, su = 33779, Pd = 35840, zd = 35841, Bd = 35842, Id = 35843, Fd = 36196, Hd = 37492, Gd = 37496, Vd = 37808, kd = 37809, Xd = 37810, Wd = 37811, Yd = 37812, qd = 37813, jd = 37814, Zd = 37815, Kd = 37816, Qd = 37817, Jd = 37818, $d = 37819, tp = 37820, ep = 37821, ru = 36492, np = 36494, ip = 36495, cx = 36283, ap = 36284, sp = 36285, rp = 36286, RM = 3200, CM = 3201, ux = 0, wM = 1, Ka = "", Si = "srgb", $r = "srgb-linear", uu = "linear", Ge = "srgb", xr = 7680, C0 = 519, DM = 512, UM = 513, LM = 514, fx = 515, NM = 516, OM = 517, PM = 518, zM = 519, Ns = 35044, w0 = 35048, fu = "300 es", pa = 2e3, hu = 2001;
class Bs {
  addEventListener(t, i) {
    this._listeners === void 0 && (this._listeners = {});
    const s = this._listeners;
    s[t] === void 0 && (s[t] = []), s[t].indexOf(i) === -1 && s[t].push(i);
  }
  hasEventListener(t, i) {
    if (this._listeners === void 0) return !1;
    const s = this._listeners;
    return s[t] !== void 0 && s[t].indexOf(i) !== -1;
  }
  removeEventListener(t, i) {
    if (this._listeners === void 0) return;
    const l = this._listeners[t];
    if (l !== void 0) {
      const c = l.indexOf(i);
      c !== -1 && l.splice(c, 1);
    }
  }
  dispatchEvent(t) {
    if (this._listeners === void 0) return;
    const s = this._listeners[t.type];
    if (s !== void 0) {
      t.target = this;
      const l = s.slice(0);
      for (let c = 0, h = l.length; c < h; c++)
        l[c].call(this, t);
      t.target = null;
    }
  }
}
const On = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"], ou = Math.PI / 180, op = 180 / Math.PI;
function $a() {
  const r = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0, s = Math.random() * 4294967295 | 0;
  return (On[r & 255] + On[r >> 8 & 255] + On[r >> 16 & 255] + On[r >> 24 & 255] + "-" + On[t & 255] + On[t >> 8 & 255] + "-" + On[t >> 16 & 15 | 64] + On[t >> 24 & 255] + "-" + On[i & 63 | 128] + On[i >> 8 & 255] + "-" + On[i >> 16 & 255] + On[i >> 24 & 255] + On[s & 255] + On[s >> 8 & 255] + On[s >> 16 & 255] + On[s >> 24 & 255]).toLowerCase();
}
function _e(r, t, i) {
  return Math.max(t, Math.min(i, r));
}
function BM(r, t) {
  return (r % t + t) % t;
}
function Ih(r, t, i) {
  return (1 - i) * r + i * t;
}
function Fi(r, t) {
  switch (t.constructor) {
    case Float32Array:
      return r;
    case Uint32Array:
      return r / 4294967295;
    case Uint16Array:
      return r / 65535;
    case Uint8Array:
      return r / 255;
    case Int32Array:
      return Math.max(r / 2147483647, -1);
    case Int16Array:
      return Math.max(r / 32767, -1);
    case Int8Array:
      return Math.max(r / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function Ve(r, t) {
  switch (t.constructor) {
    case Float32Array:
      return r;
    case Uint32Array:
      return Math.round(r * 4294967295);
    case Uint16Array:
      return Math.round(r * 65535);
    case Uint8Array:
      return Math.round(r * 255);
    case Int32Array:
      return Math.round(r * 2147483647);
    case Int16Array:
      return Math.round(r * 32767);
    case Int8Array:
      return Math.round(r * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const IM = {
  DEG2RAD: ou
};
class $t {
  constructor(t = 0, i = 0) {
    $t.prototype.isVector2 = !0, this.x = t, this.y = i;
  }
  get width() {
    return this.x;
  }
  set width(t) {
    this.x = t;
  }
  get height() {
    return this.y;
  }
  set height(t) {
    this.y = t;
  }
  set(t, i) {
    return this.x = t, this.y = i, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setComponent(t, i) {
    switch (t) {
      case 0:
        this.x = i;
        break;
      case 1:
        this.y = i;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this;
  }
  addVectors(t, i) {
    return this.x = t.x + i.x, this.y = t.y + i.y, this;
  }
  addScaledVector(t, i) {
    return this.x += t.x * i, this.y += t.y * i, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this;
  }
  subVectors(t, i) {
    return this.x = t.x - i.x, this.y = t.y - i.y, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this;
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  applyMatrix3(t) {
    const i = this.x, s = this.y, l = t.elements;
    return this.x = l[0] * i + l[3] * s + l[6], this.y = l[1] * i + l[4] * s + l[7], this;
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
  }
  clamp(t, i) {
    return this.x = _e(this.x, t.x, i.x), this.y = _e(this.y, t.y, i.y), this;
  }
  clampScalar(t, i) {
    return this.x = _e(this.x, t, i), this.y = _e(this.y, t, i), this;
  }
  clampLength(t, i) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(_e(s, t, i));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this;
  }
  dot(t) {
    return this.x * t.x + this.y * t.y;
  }
  cross(t) {
    return this.x * t.y - this.y * t.x;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  angle() {
    return Math.atan2(-this.y, -this.x) + Math.PI;
  }
  angleTo(t) {
    const i = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (i === 0) return Math.PI / 2;
    const s = this.dot(t) / i;
    return Math.acos(_e(s, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const i = this.x - t.x, s = this.y - t.y;
    return i * i + s * s;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, i) {
    return this.x += (t.x - this.x) * i, this.y += (t.y - this.y) * i, this;
  }
  lerpVectors(t, i, s) {
    return this.x = t.x + (i.x - t.x) * s, this.y = t.y + (i.y - t.y) * s, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y;
  }
  fromArray(t, i = 0) {
    return this.x = t[i], this.y = t[i + 1], this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this.x, t[i + 1] = this.y, t;
  }
  fromBufferAttribute(t, i) {
    return this.x = t.getX(i), this.y = t.getY(i), this;
  }
  rotateAround(t, i) {
    const s = Math.cos(i), l = Math.sin(i), c = this.x - t.x, h = this.y - t.y;
    return this.x = c * s - h * l + t.x, this.y = c * l + h * s + t.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class ue {
  constructor(t, i, s, l, c, h, d, m, p) {
    ue.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, i, s, l, c, h, d, m, p);
  }
  set(t, i, s, l, c, h, d, m, p) {
    const g = this.elements;
    return g[0] = t, g[1] = l, g[2] = d, g[3] = i, g[4] = c, g[5] = m, g[6] = s, g[7] = h, g[8] = p, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(t) {
    const i = this.elements, s = t.elements;
    return i[0] = s[0], i[1] = s[1], i[2] = s[2], i[3] = s[3], i[4] = s[4], i[5] = s[5], i[6] = s[6], i[7] = s[7], i[8] = s[8], this;
  }
  extractBasis(t, i, s) {
    return t.setFromMatrix3Column(this, 0), i.setFromMatrix3Column(this, 1), s.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(t) {
    const i = t.elements;
    return this.set(
      i[0],
      i[4],
      i[8],
      i[1],
      i[5],
      i[9],
      i[2],
      i[6],
      i[10]
    ), this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, i) {
    const s = t.elements, l = i.elements, c = this.elements, h = s[0], d = s[3], m = s[6], p = s[1], g = s[4], _ = s[7], x = s[2], S = s[5], E = s[8], b = l[0], M = l[3], v = l[6], B = l[1], U = l[4], w = l[7], F = l[2], L = l[5], O = l[8];
    return c[0] = h * b + d * B + m * F, c[3] = h * M + d * U + m * L, c[6] = h * v + d * w + m * O, c[1] = p * b + g * B + _ * F, c[4] = p * M + g * U + _ * L, c[7] = p * v + g * w + _ * O, c[2] = x * b + S * B + E * F, c[5] = x * M + S * U + E * L, c[8] = x * v + S * w + E * O, this;
  }
  multiplyScalar(t) {
    const i = this.elements;
    return i[0] *= t, i[3] *= t, i[6] *= t, i[1] *= t, i[4] *= t, i[7] *= t, i[2] *= t, i[5] *= t, i[8] *= t, this;
  }
  determinant() {
    const t = this.elements, i = t[0], s = t[1], l = t[2], c = t[3], h = t[4], d = t[5], m = t[6], p = t[7], g = t[8];
    return i * h * g - i * d * p - s * c * g + s * d * m + l * c * p - l * h * m;
  }
  invert() {
    const t = this.elements, i = t[0], s = t[1], l = t[2], c = t[3], h = t[4], d = t[5], m = t[6], p = t[7], g = t[8], _ = g * h - d * p, x = d * m - g * c, S = p * c - h * m, E = i * _ + s * x + l * S;
    if (E === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const b = 1 / E;
    return t[0] = _ * b, t[1] = (l * p - g * s) * b, t[2] = (d * s - l * h) * b, t[3] = x * b, t[4] = (g * i - l * m) * b, t[5] = (l * c - d * i) * b, t[6] = S * b, t[7] = (s * m - p * i) * b, t[8] = (h * i - s * c) * b, this;
  }
  transpose() {
    let t;
    const i = this.elements;
    return t = i[1], i[1] = i[3], i[3] = t, t = i[2], i[2] = i[6], i[6] = t, t = i[5], i[5] = i[7], i[7] = t, this;
  }
  getNormalMatrix(t) {
    return this.setFromMatrix4(t).invert().transpose();
  }
  transposeIntoArray(t) {
    const i = this.elements;
    return t[0] = i[0], t[1] = i[3], t[2] = i[6], t[3] = i[1], t[4] = i[4], t[5] = i[7], t[6] = i[2], t[7] = i[5], t[8] = i[8], this;
  }
  setUvTransform(t, i, s, l, c, h, d) {
    const m = Math.cos(c), p = Math.sin(c);
    return this.set(
      s * m,
      s * p,
      -s * (m * h + p * d) + h + t,
      -l * p,
      l * m,
      -l * (-p * h + m * d) + d + i,
      0,
      0,
      1
    ), this;
  }
  //
  scale(t, i) {
    return this.premultiply(Fh.makeScale(t, i)), this;
  }
  rotate(t) {
    return this.premultiply(Fh.makeRotation(-t)), this;
  }
  translate(t, i) {
    return this.premultiply(Fh.makeTranslation(t, i)), this;
  }
  // for 2D Transforms
  makeTranslation(t, i) {
    return t.isVector2 ? this.set(
      1,
      0,
      t.x,
      0,
      1,
      t.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      t,
      0,
      1,
      i,
      0,
      0,
      1
    ), this;
  }
  makeRotation(t) {
    const i = Math.cos(t), s = Math.sin(t);
    return this.set(
      i,
      -s,
      0,
      s,
      i,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, i) {
    return this.set(
      t,
      0,
      0,
      0,
      i,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(t) {
    const i = this.elements, s = t.elements;
    for (let l = 0; l < 9; l++)
      if (i[l] !== s[l]) return !1;
    return !0;
  }
  fromArray(t, i = 0) {
    for (let s = 0; s < 9; s++)
      this.elements[s] = t[s + i];
    return this;
  }
  toArray(t = [], i = 0) {
    const s = this.elements;
    return t[i] = s[0], t[i + 1] = s[1], t[i + 2] = s[2], t[i + 3] = s[3], t[i + 4] = s[4], t[i + 5] = s[5], t[i + 6] = s[6], t[i + 7] = s[7], t[i + 8] = s[8], t;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const Fh = /* @__PURE__ */ new ue();
function hx(r) {
  for (let t = r.length - 1; t >= 0; --t)
    if (r[t] >= 65535) return !0;
  return !1;
}
function du(r) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", r);
}
function FM() {
  const r = du("canvas");
  return r.style.display = "block", r;
}
const D0 = {};
function Gr(r) {
  r in D0 || (D0[r] = !0, console.warn(r));
}
function HM(r, t, i) {
  return new Promise(function(s, l) {
    function c() {
      switch (r.clientWaitSync(t, r.SYNC_FLUSH_COMMANDS_BIT, 0)) {
        case r.WAIT_FAILED:
          l();
          break;
        case r.TIMEOUT_EXPIRED:
          setTimeout(c, i);
          break;
        default:
          s();
      }
    }
    setTimeout(c, i);
  });
}
function GM(r) {
  const t = r.elements;
  t[2] = 0.5 * t[2] + 0.5 * t[3], t[6] = 0.5 * t[6] + 0.5 * t[7], t[10] = 0.5 * t[10] + 0.5 * t[11], t[14] = 0.5 * t[14] + 0.5 * t[15];
}
function VM(r) {
  const t = r.elements;
  t[11] === -1 ? (t[10] = -t[10] - 1, t[14] = -t[14]) : (t[10] = -t[10], t[14] = -t[14] + 1);
}
const U0 = /* @__PURE__ */ new ue().set(
  0.4123908,
  0.3575843,
  0.1804808,
  0.212639,
  0.7151687,
  0.0721923,
  0.0193308,
  0.1191948,
  0.9505322
), L0 = /* @__PURE__ */ new ue().set(
  3.2409699,
  -1.5373832,
  -0.4986108,
  -0.9692436,
  1.8759675,
  0.0415551,
  0.0556301,
  -0.203977,
  1.0569715
);
function kM() {
  const r = {
    enabled: !0,
    workingColorSpace: $r,
    /**
     * Implementations of supported color spaces.
     *
     * Required:
     *	- primaries: chromaticity coordinates [ rx ry gx gy bx by ]
     *	- whitePoint: reference white [ x y ]
     *	- transfer: transfer function (pre-defined)
     *	- toXYZ: Matrix3 RGB to XYZ transform
     *	- fromXYZ: Matrix3 XYZ to RGB transform
     *	- luminanceCoefficients: RGB luminance coefficients
     *
     * Optional:
     *  - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
     *  - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
     *
     * Reference:
     * - https://www.russellcottrell.com/photo/matrixCalculator.htm
     */
    spaces: {},
    convert: function(l, c, h) {
      return this.enabled === !1 || c === h || !c || !h || (this.spaces[c].transfer === Ge && (l.r = ma(l.r), l.g = ma(l.g), l.b = ma(l.b)), this.spaces[c].primaries !== this.spaces[h].primaries && (l.applyMatrix3(this.spaces[c].toXYZ), l.applyMatrix3(this.spaces[h].fromXYZ)), this.spaces[h].transfer === Ge && (l.r = qr(l.r), l.g = qr(l.g), l.b = qr(l.b))), l;
    },
    fromWorkingColorSpace: function(l, c) {
      return this.convert(l, this.workingColorSpace, c);
    },
    toWorkingColorSpace: function(l, c) {
      return this.convert(l, c, this.workingColorSpace);
    },
    getPrimaries: function(l) {
      return this.spaces[l].primaries;
    },
    getTransfer: function(l) {
      return l === Ka ? uu : this.spaces[l].transfer;
    },
    getLuminanceCoefficients: function(l, c = this.workingColorSpace) {
      return l.fromArray(this.spaces[c].luminanceCoefficients);
    },
    define: function(l) {
      Object.assign(this.spaces, l);
    },
    // Internal APIs
    _getMatrix: function(l, c, h) {
      return l.copy(this.spaces[c].toXYZ).multiply(this.spaces[h].fromXYZ);
    },
    _getDrawingBufferColorSpace: function(l) {
      return this.spaces[l].outputColorSpaceConfig.drawingBufferColorSpace;
    },
    _getUnpackColorSpace: function(l = this.workingColorSpace) {
      return this.spaces[l].workingColorSpaceConfig.unpackColorSpace;
    }
  }, t = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], i = [0.2126, 0.7152, 0.0722], s = [0.3127, 0.329];
  return r.define({
    [$r]: {
      primaries: t,
      whitePoint: s,
      transfer: uu,
      toXYZ: U0,
      fromXYZ: L0,
      luminanceCoefficients: i,
      workingColorSpaceConfig: { unpackColorSpace: Si },
      outputColorSpaceConfig: { drawingBufferColorSpace: Si }
    },
    [Si]: {
      primaries: t,
      whitePoint: s,
      transfer: Ge,
      toXYZ: U0,
      fromXYZ: L0,
      luminanceCoefficients: i,
      outputColorSpaceConfig: { drawingBufferColorSpace: Si }
    }
  }), r;
}
const De = /* @__PURE__ */ kM();
function ma(r) {
  return r < 0.04045 ? r * 0.0773993808 : Math.pow(r * 0.9478672986 + 0.0521327014, 2.4);
}
function qr(r) {
  return r < 31308e-7 ? r * 12.92 : 1.055 * Math.pow(r, 0.41666) - 0.055;
}
let yr;
class XM {
  static getDataURL(t) {
    if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
      return t.src;
    let i;
    if (t instanceof HTMLCanvasElement)
      i = t;
    else {
      yr === void 0 && (yr = du("canvas")), yr.width = t.width, yr.height = t.height;
      const s = yr.getContext("2d");
      t instanceof ImageData ? s.putImageData(t, 0, 0) : s.drawImage(t, 0, 0, t.width, t.height), i = yr;
    }
    return i.width > 2048 || i.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), i.toDataURL("image/jpeg", 0.6)) : i.toDataURL("image/png");
  }
  static sRGBToLinear(t) {
    if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) {
      const i = du("canvas");
      i.width = t.width, i.height = t.height;
      const s = i.getContext("2d");
      s.drawImage(t, 0, 0, t.width, t.height);
      const l = s.getImageData(0, 0, t.width, t.height), c = l.data;
      for (let h = 0; h < c.length; h++)
        c[h] = ma(c[h] / 255) * 255;
      return s.putImageData(l, 0, 0), i;
    } else if (t.data) {
      const i = t.data.slice(0);
      for (let s = 0; s < i.length; s++)
        i instanceof Uint8Array || i instanceof Uint8ClampedArray ? i[s] = Math.floor(ma(i[s] / 255) * 255) : i[s] = ma(i[s]);
      return {
        data: i,
        width: t.width,
        height: t.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t;
  }
}
let WM = 0;
class dx {
  constructor(t = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: WM++ }), this.uuid = $a(), this.data = t, this.dataReady = !0, this.version = 0;
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  toJSON(t) {
    const i = t === void 0 || typeof t == "string";
    if (!i && t.images[this.uuid] !== void 0)
      return t.images[this.uuid];
    const s = {
      uuid: this.uuid,
      url: ""
    }, l = this.data;
    if (l !== null) {
      let c;
      if (Array.isArray(l)) {
        c = [];
        for (let h = 0, d = l.length; h < d; h++)
          l[h].isDataTexture ? c.push(Hh(l[h].image)) : c.push(Hh(l[h]));
      } else
        c = Hh(l);
      s.url = c;
    }
    return i || (t.images[this.uuid] = s), s;
  }
}
function Hh(r) {
  return typeof HTMLImageElement < "u" && r instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && r instanceof ImageBitmap ? XM.getDataURL(r) : r.data ? {
    data: Array.from(r.data),
    width: r.width,
    height: r.height,
    type: r.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let YM = 0;
class zn extends Bs {
  constructor(t = zn.DEFAULT_IMAGE, i = zn.DEFAULT_MAPPING, s = Us, l = Us, c = Hi, h = Ls, d = fi, m = ga, p = zn.DEFAULT_ANISOTROPY, g = Ka) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: YM++ }), this.uuid = $a(), this.name = "", this.source = new dx(t), this.mipmaps = [], this.mapping = i, this.channel = 0, this.wrapS = s, this.wrapT = l, this.magFilter = c, this.minFilter = h, this.anisotropy = p, this.format = d, this.internalFormat = null, this.type = m, this.offset = new $t(0, 0), this.repeat = new $t(1, 1), this.center = new $t(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ue(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = g, this.userData = {}, this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  }
  get image() {
    return this.source.data;
  }
  set image(t = null) {
    this.source.data = t;
  }
  updateMatrix() {
    this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.name = t.name, this.source = t.source, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.channel = t.channel, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.colorSpace = t.colorSpace, this.renderTarget = t.renderTarget, this.isRenderTargetTexture = t.isRenderTargetTexture, this.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this;
  }
  toJSON(t) {
    const i = t === void 0 || typeof t == "string";
    if (!i && t.textures[this.uuid] !== void 0)
      return t.textures[this.uuid];
    const s = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(t).uuid,
      mapping: this.mapping,
      channel: this.channel,
      repeat: [this.repeat.x, this.repeat.y],
      offset: [this.offset.x, this.offset.y],
      center: [this.center.x, this.center.y],
      rotation: this.rotation,
      wrap: [this.wrapS, this.wrapT],
      format: this.format,
      internalFormat: this.internalFormat,
      type: this.type,
      colorSpace: this.colorSpace,
      minFilter: this.minFilter,
      magFilter: this.magFilter,
      anisotropy: this.anisotropy,
      flipY: this.flipY,
      generateMipmaps: this.generateMipmaps,
      premultiplyAlpha: this.premultiplyAlpha,
      unpackAlignment: this.unpackAlignment
    };
    return Object.keys(this.userData).length > 0 && (s.userData = this.userData), i || (t.textures[this.uuid] = s), s;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(t) {
    if (this.mapping !== tx) return t;
    if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
      switch (this.wrapS) {
        case Nd:
          t.x = t.x - Math.floor(t.x);
          break;
        case Us:
          t.x = t.x < 0 ? 0 : 1;
          break;
        case Od:
          Math.abs(Math.floor(t.x) % 2) === 1 ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x);
          break;
      }
    if (t.y < 0 || t.y > 1)
      switch (this.wrapT) {
        case Nd:
          t.y = t.y - Math.floor(t.y);
          break;
        case Us:
          t.y = t.y < 0 ? 0 : 1;
          break;
        case Od:
          Math.abs(Math.floor(t.y) % 2) === 1 ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y);
          break;
      }
    return this.flipY && (t.y = 1 - t.y), t;
  }
  set needsUpdate(t) {
    t === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  set needsPMREMUpdate(t) {
    t === !0 && this.pmremVersion++;
  }
}
zn.DEFAULT_IMAGE = null;
zn.DEFAULT_MAPPING = tx;
zn.DEFAULT_ANISOTROPY = 1;
class Je {
  constructor(t = 0, i = 0, s = 0, l = 1) {
    Je.prototype.isVector4 = !0, this.x = t, this.y = i, this.z = s, this.w = l;
  }
  get width() {
    return this.z;
  }
  set width(t) {
    this.z = t;
  }
  get height() {
    return this.w;
  }
  set height(t) {
    this.w = t;
  }
  set(t, i, s, l) {
    return this.x = t, this.y = i, this.z = s, this.w = l, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this.z = t, this.w = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setZ(t) {
    return this.z = t, this;
  }
  setW(t) {
    return this.w = t, this;
  }
  setComponent(t, i) {
    switch (t) {
      case 0:
        this.x = i;
        break;
      case 1:
        this.y = i;
        break;
      case 2:
        this.z = i;
        break;
      case 3:
        this.w = i;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      case 3:
        return this.w;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z, this.w);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this.z = t.z, this.w = t.w !== void 0 ? t.w : 1, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this.z += t.z, this.w += t.w, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this.z += t, this.w += t, this;
  }
  addVectors(t, i) {
    return this.x = t.x + i.x, this.y = t.y + i.y, this.z = t.z + i.z, this.w = t.w + i.w, this;
  }
  addScaledVector(t, i) {
    return this.x += t.x * i, this.y += t.y * i, this.z += t.z * i, this.w += t.w * i, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this.z -= t.z, this.w -= t.w, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this.z -= t, this.w -= t, this;
  }
  subVectors(t, i) {
    return this.x = t.x - i.x, this.y = t.y - i.y, this.z = t.z - i.z, this.w = t.w - i.w, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this.z *= t.z, this.w *= t.w, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this.z *= t, this.w *= t, this;
  }
  applyMatrix4(t) {
    const i = this.x, s = this.y, l = this.z, c = this.w, h = t.elements;
    return this.x = h[0] * i + h[4] * s + h[8] * l + h[12] * c, this.y = h[1] * i + h[5] * s + h[9] * l + h[13] * c, this.z = h[2] * i + h[6] * s + h[10] * l + h[14] * c, this.w = h[3] * i + h[7] * s + h[11] * l + h[15] * c, this;
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this.z /= t.z, this.w /= t.w, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  setAxisAngleFromQuaternion(t) {
    this.w = 2 * Math.acos(t.w);
    const i = Math.sqrt(1 - t.w * t.w);
    return i < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = t.x / i, this.y = t.y / i, this.z = t.z / i), this;
  }
  setAxisAngleFromRotationMatrix(t) {
    let i, s, l, c;
    const m = t.elements, p = m[0], g = m[4], _ = m[8], x = m[1], S = m[5], E = m[9], b = m[2], M = m[6], v = m[10];
    if (Math.abs(g - x) < 0.01 && Math.abs(_ - b) < 0.01 && Math.abs(E - M) < 0.01) {
      if (Math.abs(g + x) < 0.1 && Math.abs(_ + b) < 0.1 && Math.abs(E + M) < 0.1 && Math.abs(p + S + v - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      i = Math.PI;
      const U = (p + 1) / 2, w = (S + 1) / 2, F = (v + 1) / 2, L = (g + x) / 4, O = (_ + b) / 4, G = (E + M) / 4;
      return U > w && U > F ? U < 0.01 ? (s = 0, l = 0.707106781, c = 0.707106781) : (s = Math.sqrt(U), l = L / s, c = O / s) : w > F ? w < 0.01 ? (s = 0.707106781, l = 0, c = 0.707106781) : (l = Math.sqrt(w), s = L / l, c = G / l) : F < 0.01 ? (s = 0.707106781, l = 0.707106781, c = 0) : (c = Math.sqrt(F), s = O / c, l = G / c), this.set(s, l, c, i), this;
    }
    let B = Math.sqrt((M - E) * (M - E) + (_ - b) * (_ - b) + (x - g) * (x - g));
    return Math.abs(B) < 1e-3 && (B = 1), this.x = (M - E) / B, this.y = (_ - b) / B, this.z = (x - g) / B, this.w = Math.acos((p + S + v - 1) / 2), this;
  }
  setFromMatrixPosition(t) {
    const i = t.elements;
    return this.x = i[12], this.y = i[13], this.z = i[14], this.w = i[15], this;
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this.w = Math.min(this.w, t.w), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this.w = Math.max(this.w, t.w), this;
  }
  clamp(t, i) {
    return this.x = _e(this.x, t.x, i.x), this.y = _e(this.y, t.y, i.y), this.z = _e(this.z, t.z, i.z), this.w = _e(this.w, t.w, i.w), this;
  }
  clampScalar(t, i) {
    return this.x = _e(this.x, t, i), this.y = _e(this.y, t, i), this.z = _e(this.z, t, i), this.w = _e(this.w, t, i), this;
  }
  clampLength(t, i) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(_e(s, t, i));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
  }
  dot(t) {
    return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.w;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, i) {
    return this.x += (t.x - this.x) * i, this.y += (t.y - this.y) * i, this.z += (t.z - this.z) * i, this.w += (t.w - this.w) * i, this;
  }
  lerpVectors(t, i, s) {
    return this.x = t.x + (i.x - t.x) * s, this.y = t.y + (i.y - t.y) * s, this.z = t.z + (i.z - t.z) * s, this.w = t.w + (i.w - t.w) * s, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y && t.z === this.z && t.w === this.w;
  }
  fromArray(t, i = 0) {
    return this.x = t[i], this.y = t[i + 1], this.z = t[i + 2], this.w = t[i + 3], this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this.x, t[i + 1] = this.y, t[i + 2] = this.z, t[i + 3] = this.w, t;
  }
  fromBufferAttribute(t, i) {
    return this.x = t.getX(i), this.y = t.getY(i), this.z = t.getZ(i), this.w = t.getW(i), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z, yield this.w;
  }
}
class qM extends Bs {
  constructor(t = 1, i = 1, s = {}) {
    super(), this.isRenderTarget = !0, this.width = t, this.height = i, this.depth = 1, this.scissor = new Je(0, 0, t, i), this.scissorTest = !1, this.viewport = new Je(0, 0, t, i);
    const l = { width: t, height: i, depth: 1 };
    s = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: Hi,
      depthBuffer: !0,
      stencilBuffer: !1,
      resolveDepthBuffer: !0,
      resolveStencilBuffer: !0,
      depthTexture: null,
      samples: 0,
      count: 1
    }, s);
    const c = new zn(l, s.mapping, s.wrapS, s.wrapT, s.magFilter, s.minFilter, s.format, s.type, s.anisotropy, s.colorSpace);
    c.flipY = !1, c.generateMipmaps = s.generateMipmaps, c.internalFormat = s.internalFormat, this.textures = [];
    const h = s.count;
    for (let d = 0; d < h; d++)
      this.textures[d] = c.clone(), this.textures[d].isRenderTargetTexture = !0, this.textures[d].renderTarget = this;
    this.depthBuffer = s.depthBuffer, this.stencilBuffer = s.stencilBuffer, this.resolveDepthBuffer = s.resolveDepthBuffer, this.resolveStencilBuffer = s.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = s.depthTexture, this.samples = s.samples;
  }
  get texture() {
    return this.textures[0];
  }
  set texture(t) {
    this.textures[0] = t;
  }
  set depthTexture(t) {
    this._depthTexture !== null && (this._depthTexture.renderTarget = null), t !== null && (t.renderTarget = this), this._depthTexture = t;
  }
  get depthTexture() {
    return this._depthTexture;
  }
  setSize(t, i, s = 1) {
    if (this.width !== t || this.height !== i || this.depth !== s) {
      this.width = t, this.height = i, this.depth = s;
      for (let l = 0, c = this.textures.length; l < c; l++)
        this.textures[l].image.width = t, this.textures[l].image.height = i, this.textures[l].image.depth = s;
      this.dispose();
    }
    this.viewport.set(0, 0, t, i), this.scissor.set(0, 0, t, i);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.width = t.width, this.height = t.height, this.depth = t.depth, this.scissor.copy(t.scissor), this.scissorTest = t.scissorTest, this.viewport.copy(t.viewport), this.textures.length = 0;
    for (let s = 0, l = t.textures.length; s < l; s++)
      this.textures[s] = t.textures[s].clone(), this.textures[s].isRenderTargetTexture = !0, this.textures[s].renderTarget = this;
    const i = Object.assign({}, t.texture.image);
    return this.texture.source = new dx(i), this.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, this.resolveDepthBuffer = t.resolveDepthBuffer, this.resolveStencilBuffer = t.resolveStencilBuffer, t.depthTexture !== null && (this.depthTexture = t.depthTexture.clone()), this.samples = t.samples, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class zs extends qM {
  constructor(t = 1, i = 1, s = {}) {
    super(t, i, s), this.isWebGLRenderTarget = !0;
  }
}
class px extends zn {
  constructor(t = null, i = 1, s = 1, l = 1) {
    super(null), this.isDataArrayTexture = !0, this.image = { data: t, width: i, height: s, depth: l }, this.magFilter = Dn, this.minFilter = Dn, this.wrapR = Us, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();
  }
  addLayerUpdate(t) {
    this.layerUpdates.add(t);
  }
  clearLayerUpdates() {
    this.layerUpdates.clear();
  }
}
class jM extends zn {
  constructor(t = null, i = 1, s = 1, l = 1) {
    super(null), this.isData3DTexture = !0, this.image = { data: t, width: i, height: s, depth: l }, this.magFilter = Dn, this.minFilter = Dn, this.wrapR = Us, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class es {
  constructor(t = 0, i = 0, s = 0, l = 1) {
    this.isQuaternion = !0, this._x = t, this._y = i, this._z = s, this._w = l;
  }
  static slerpFlat(t, i, s, l, c, h, d) {
    let m = s[l + 0], p = s[l + 1], g = s[l + 2], _ = s[l + 3];
    const x = c[h + 0], S = c[h + 1], E = c[h + 2], b = c[h + 3];
    if (d === 0) {
      t[i + 0] = m, t[i + 1] = p, t[i + 2] = g, t[i + 3] = _;
      return;
    }
    if (d === 1) {
      t[i + 0] = x, t[i + 1] = S, t[i + 2] = E, t[i + 3] = b;
      return;
    }
    if (_ !== b || m !== x || p !== S || g !== E) {
      let M = 1 - d;
      const v = m * x + p * S + g * E + _ * b, B = v >= 0 ? 1 : -1, U = 1 - v * v;
      if (U > Number.EPSILON) {
        const F = Math.sqrt(U), L = Math.atan2(F, v * B);
        M = Math.sin(M * L) / F, d = Math.sin(d * L) / F;
      }
      const w = d * B;
      if (m = m * M + x * w, p = p * M + S * w, g = g * M + E * w, _ = _ * M + b * w, M === 1 - d) {
        const F = 1 / Math.sqrt(m * m + p * p + g * g + _ * _);
        m *= F, p *= F, g *= F, _ *= F;
      }
    }
    t[i] = m, t[i + 1] = p, t[i + 2] = g, t[i + 3] = _;
  }
  static multiplyQuaternionsFlat(t, i, s, l, c, h) {
    const d = s[l], m = s[l + 1], p = s[l + 2], g = s[l + 3], _ = c[h], x = c[h + 1], S = c[h + 2], E = c[h + 3];
    return t[i] = d * E + g * _ + m * S - p * x, t[i + 1] = m * E + g * x + p * _ - d * S, t[i + 2] = p * E + g * S + d * x - m * _, t[i + 3] = g * E - d * _ - m * x - p * S, t;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get w() {
    return this._w;
  }
  set w(t) {
    this._w = t, this._onChangeCallback();
  }
  set(t, i, s, l) {
    return this._x = t, this._y = i, this._z = s, this._w = l, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._w);
  }
  copy(t) {
    return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
  }
  setFromEuler(t, i = !0) {
    const s = t._x, l = t._y, c = t._z, h = t._order, d = Math.cos, m = Math.sin, p = d(s / 2), g = d(l / 2), _ = d(c / 2), x = m(s / 2), S = m(l / 2), E = m(c / 2);
    switch (h) {
      case "XYZ":
        this._x = x * g * _ + p * S * E, this._y = p * S * _ - x * g * E, this._z = p * g * E + x * S * _, this._w = p * g * _ - x * S * E;
        break;
      case "YXZ":
        this._x = x * g * _ + p * S * E, this._y = p * S * _ - x * g * E, this._z = p * g * E - x * S * _, this._w = p * g * _ + x * S * E;
        break;
      case "ZXY":
        this._x = x * g * _ - p * S * E, this._y = p * S * _ + x * g * E, this._z = p * g * E + x * S * _, this._w = p * g * _ - x * S * E;
        break;
      case "ZYX":
        this._x = x * g * _ - p * S * E, this._y = p * S * _ + x * g * E, this._z = p * g * E - x * S * _, this._w = p * g * _ + x * S * E;
        break;
      case "YZX":
        this._x = x * g * _ + p * S * E, this._y = p * S * _ + x * g * E, this._z = p * g * E - x * S * _, this._w = p * g * _ - x * S * E;
        break;
      case "XZY":
        this._x = x * g * _ - p * S * E, this._y = p * S * _ - x * g * E, this._z = p * g * E + x * S * _, this._w = p * g * _ + x * S * E;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + h);
    }
    return i === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(t, i) {
    const s = i / 2, l = Math.sin(s);
    return this._x = t.x * l, this._y = t.y * l, this._z = t.z * l, this._w = Math.cos(s), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t) {
    const i = t.elements, s = i[0], l = i[4], c = i[8], h = i[1], d = i[5], m = i[9], p = i[2], g = i[6], _ = i[10], x = s + d + _;
    if (x > 0) {
      const S = 0.5 / Math.sqrt(x + 1);
      this._w = 0.25 / S, this._x = (g - m) * S, this._y = (c - p) * S, this._z = (h - l) * S;
    } else if (s > d && s > _) {
      const S = 2 * Math.sqrt(1 + s - d - _);
      this._w = (g - m) / S, this._x = 0.25 * S, this._y = (l + h) / S, this._z = (c + p) / S;
    } else if (d > _) {
      const S = 2 * Math.sqrt(1 + d - s - _);
      this._w = (c - p) / S, this._x = (l + h) / S, this._y = 0.25 * S, this._z = (m + g) / S;
    } else {
      const S = 2 * Math.sqrt(1 + _ - s - d);
      this._w = (h - l) / S, this._x = (c + p) / S, this._y = (m + g) / S, this._z = 0.25 * S;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(t, i) {
    let s = t.dot(i) + 1;
    return s < Number.EPSILON ? (s = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = s) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = s)) : (this._x = t.y * i.z - t.z * i.y, this._y = t.z * i.x - t.x * i.z, this._z = t.x * i.y - t.y * i.x, this._w = s), this.normalize();
  }
  angleTo(t) {
    return 2 * Math.acos(Math.abs(_e(this.dot(t), -1, 1)));
  }
  rotateTowards(t, i) {
    const s = this.angleTo(t);
    if (s === 0) return this;
    const l = Math.min(1, i / s);
    return this.slerp(t, l), this;
  }
  identity() {
    return this.set(0, 0, 0, 1);
  }
  invert() {
    return this.conjugate();
  }
  conjugate() {
    return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  }
  dot(t) {
    return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
  }
  lengthSq() {
    return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  }
  length() {
    return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  }
  normalize() {
    let t = this.length();
    return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
  }
  multiply(t) {
    return this.multiplyQuaternions(this, t);
  }
  premultiply(t) {
    return this.multiplyQuaternions(t, this);
  }
  multiplyQuaternions(t, i) {
    const s = t._x, l = t._y, c = t._z, h = t._w, d = i._x, m = i._y, p = i._z, g = i._w;
    return this._x = s * g + h * d + l * p - c * m, this._y = l * g + h * m + c * d - s * p, this._z = c * g + h * p + s * m - l * d, this._w = h * g - s * d - l * m - c * p, this._onChangeCallback(), this;
  }
  slerp(t, i) {
    if (i === 0) return this;
    if (i === 1) return this.copy(t);
    const s = this._x, l = this._y, c = this._z, h = this._w;
    let d = h * t._w + s * t._x + l * t._y + c * t._z;
    if (d < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, d = -d) : this.copy(t), d >= 1)
      return this._w = h, this._x = s, this._y = l, this._z = c, this;
    const m = 1 - d * d;
    if (m <= Number.EPSILON) {
      const S = 1 - i;
      return this._w = S * h + i * this._w, this._x = S * s + i * this._x, this._y = S * l + i * this._y, this._z = S * c + i * this._z, this.normalize(), this;
    }
    const p = Math.sqrt(m), g = Math.atan2(p, d), _ = Math.sin((1 - i) * g) / p, x = Math.sin(i * g) / p;
    return this._w = h * _ + this._w * x, this._x = s * _ + this._x * x, this._y = l * _ + this._y * x, this._z = c * _ + this._z * x, this._onChangeCallback(), this;
  }
  slerpQuaternions(t, i, s) {
    return this.copy(t).slerp(i, s);
  }
  random() {
    const t = 2 * Math.PI * Math.random(), i = 2 * Math.PI * Math.random(), s = Math.random(), l = Math.sqrt(1 - s), c = Math.sqrt(s);
    return this.set(
      l * Math.sin(t),
      l * Math.cos(t),
      c * Math.sin(i),
      c * Math.cos(i)
    );
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
  }
  fromArray(t, i = 0) {
    return this._x = t[i], this._y = t[i + 1], this._z = t[i + 2], this._w = t[i + 3], this._onChangeCallback(), this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this._x, t[i + 1] = this._y, t[i + 2] = this._z, t[i + 3] = this._w, t;
  }
  fromBufferAttribute(t, i) {
    return this._x = t.getX(i), this._y = t.getY(i), this._z = t.getZ(i), this._w = t.getW(i), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class q {
  constructor(t = 0, i = 0, s = 0) {
    q.prototype.isVector3 = !0, this.x = t, this.y = i, this.z = s;
  }
  set(t, i, s) {
    return s === void 0 && (s = this.z), this.x = t, this.y = i, this.z = s, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this.z = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setZ(t) {
    return this.z = t, this;
  }
  setComponent(t, i) {
    switch (t) {
      case 0:
        this.x = i;
        break;
      case 1:
        this.y = i;
        break;
      case 2:
        this.z = i;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this.z = t.z, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this.z += t.z, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this.z += t, this;
  }
  addVectors(t, i) {
    return this.x = t.x + i.x, this.y = t.y + i.y, this.z = t.z + i.z, this;
  }
  addScaledVector(t, i) {
    return this.x += t.x * i, this.y += t.y * i, this.z += t.z * i, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this.z -= t, this;
  }
  subVectors(t, i) {
    return this.x = t.x - i.x, this.y = t.y - i.y, this.z = t.z - i.z, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this.z *= t, this;
  }
  multiplyVectors(t, i) {
    return this.x = t.x * i.x, this.y = t.y * i.y, this.z = t.z * i.z, this;
  }
  applyEuler(t) {
    return this.applyQuaternion(N0.setFromEuler(t));
  }
  applyAxisAngle(t, i) {
    return this.applyQuaternion(N0.setFromAxisAngle(t, i));
  }
  applyMatrix3(t) {
    const i = this.x, s = this.y, l = this.z, c = t.elements;
    return this.x = c[0] * i + c[3] * s + c[6] * l, this.y = c[1] * i + c[4] * s + c[7] * l, this.z = c[2] * i + c[5] * s + c[8] * l, this;
  }
  applyNormalMatrix(t) {
    return this.applyMatrix3(t).normalize();
  }
  applyMatrix4(t) {
    const i = this.x, s = this.y, l = this.z, c = t.elements, h = 1 / (c[3] * i + c[7] * s + c[11] * l + c[15]);
    return this.x = (c[0] * i + c[4] * s + c[8] * l + c[12]) * h, this.y = (c[1] * i + c[5] * s + c[9] * l + c[13]) * h, this.z = (c[2] * i + c[6] * s + c[10] * l + c[14]) * h, this;
  }
  applyQuaternion(t) {
    const i = this.x, s = this.y, l = this.z, c = t.x, h = t.y, d = t.z, m = t.w, p = 2 * (h * l - d * s), g = 2 * (d * i - c * l), _ = 2 * (c * s - h * i);
    return this.x = i + m * p + h * _ - d * g, this.y = s + m * g + d * p - c * _, this.z = l + m * _ + c * g - h * p, this;
  }
  project(t) {
    return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);
  }
  unproject(t) {
    return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);
  }
  transformDirection(t) {
    const i = this.x, s = this.y, l = this.z, c = t.elements;
    return this.x = c[0] * i + c[4] * s + c[8] * l, this.y = c[1] * i + c[5] * s + c[9] * l, this.z = c[2] * i + c[6] * s + c[10] * l, this.normalize();
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
  }
  clamp(t, i) {
    return this.x = _e(this.x, t.x, i.x), this.y = _e(this.y, t.y, i.y), this.z = _e(this.z, t.z, i.z), this;
  }
  clampScalar(t, i) {
    return this.x = _e(this.x, t, i), this.y = _e(this.y, t, i), this.z = _e(this.z, t, i), this;
  }
  clampLength(t, i) {
    const s = this.length();
    return this.divideScalar(s || 1).multiplyScalar(_e(s, t, i));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
  }
  dot(t) {
    return this.x * t.x + this.y * t.y + this.z * t.z;
  }
  // TODO lengthSquared?
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, i) {
    return this.x += (t.x - this.x) * i, this.y += (t.y - this.y) * i, this.z += (t.z - this.z) * i, this;
  }
  lerpVectors(t, i, s) {
    return this.x = t.x + (i.x - t.x) * s, this.y = t.y + (i.y - t.y) * s, this.z = t.z + (i.z - t.z) * s, this;
  }
  cross(t) {
    return this.crossVectors(this, t);
  }
  crossVectors(t, i) {
    const s = t.x, l = t.y, c = t.z, h = i.x, d = i.y, m = i.z;
    return this.x = l * m - c * d, this.y = c * h - s * m, this.z = s * d - l * h, this;
  }
  projectOnVector(t) {
    const i = t.lengthSq();
    if (i === 0) return this.set(0, 0, 0);
    const s = t.dot(this) / i;
    return this.copy(t).multiplyScalar(s);
  }
  projectOnPlane(t) {
    return Gh.copy(this).projectOnVector(t), this.sub(Gh);
  }
  reflect(t) {
    return this.sub(Gh.copy(t).multiplyScalar(2 * this.dot(t)));
  }
  angleTo(t) {
    const i = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (i === 0) return Math.PI / 2;
    const s = this.dot(t) / i;
    return Math.acos(_e(s, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const i = this.x - t.x, s = this.y - t.y, l = this.z - t.z;
    return i * i + s * s + l * l;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
  }
  setFromSpherical(t) {
    return this.setFromSphericalCoords(t.radius, t.phi, t.theta);
  }
  setFromSphericalCoords(t, i, s) {
    const l = Math.sin(i) * t;
    return this.x = l * Math.sin(s), this.y = Math.cos(i) * t, this.z = l * Math.cos(s), this;
  }
  setFromCylindrical(t) {
    return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
  }
  setFromCylindricalCoords(t, i, s) {
    return this.x = t * Math.sin(i), this.y = s, this.z = t * Math.cos(i), this;
  }
  setFromMatrixPosition(t) {
    const i = t.elements;
    return this.x = i[12], this.y = i[13], this.z = i[14], this;
  }
  setFromMatrixScale(t) {
    const i = this.setFromMatrixColumn(t, 0).length(), s = this.setFromMatrixColumn(t, 1).length(), l = this.setFromMatrixColumn(t, 2).length();
    return this.x = i, this.y = s, this.z = l, this;
  }
  setFromMatrixColumn(t, i) {
    return this.fromArray(t.elements, i * 4);
  }
  setFromMatrix3Column(t, i) {
    return this.fromArray(t.elements, i * 3);
  }
  setFromEuler(t) {
    return this.x = t._x, this.y = t._y, this.z = t._z, this;
  }
  setFromColor(t) {
    return this.x = t.r, this.y = t.g, this.z = t.b, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y && t.z === this.z;
  }
  fromArray(t, i = 0) {
    return this.x = t[i], this.y = t[i + 1], this.z = t[i + 2], this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this.x, t[i + 1] = this.y, t[i + 2] = this.z, t;
  }
  fromBufferAttribute(t, i) {
    return this.x = t.getX(i), this.y = t.getY(i), this.z = t.getZ(i), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  }
  randomDirection() {
    const t = Math.random() * Math.PI * 2, i = Math.random() * 2 - 1, s = Math.sqrt(1 - i * i);
    return this.x = s * Math.cos(t), this.y = i, this.z = s * Math.sin(t), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const Gh = /* @__PURE__ */ new q(), N0 = /* @__PURE__ */ new es();
class Is {
  constructor(t = new q(1 / 0, 1 / 0, 1 / 0), i = new q(-1 / 0, -1 / 0, -1 / 0)) {
    this.isBox3 = !0, this.min = t, this.max = i;
  }
  set(t, i) {
    return this.min.copy(t), this.max.copy(i), this;
  }
  setFromArray(t) {
    this.makeEmpty();
    for (let i = 0, s = t.length; i < s; i += 3)
      this.expandByPoint(Di.fromArray(t, i));
    return this;
  }
  setFromBufferAttribute(t) {
    this.makeEmpty();
    for (let i = 0, s = t.count; i < s; i++)
      this.expandByPoint(Di.fromBufferAttribute(t, i));
    return this;
  }
  setFromPoints(t) {
    this.makeEmpty();
    for (let i = 0, s = t.length; i < s; i++)
      this.expandByPoint(t[i]);
    return this;
  }
  setFromCenterAndSize(t, i) {
    const s = Di.copy(i).multiplyScalar(0.5);
    return this.min.copy(t).sub(s), this.max.copy(t).add(s), this;
  }
  setFromObject(t, i = !1) {
    return this.makeEmpty(), this.expandByObject(t, i);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.min.copy(t.min), this.max.copy(t.max), this;
  }
  makeEmpty() {
    return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
  }
  isEmpty() {
    return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  }
  getCenter(t) {
    return this.isEmpty() ? t.set(0, 0, 0) : t.addVectors(this.min, this.max).multiplyScalar(0.5);
  }
  getSize(t) {
    return this.isEmpty() ? t.set(0, 0, 0) : t.subVectors(this.max, this.min);
  }
  expandByPoint(t) {
    return this.min.min(t), this.max.max(t), this;
  }
  expandByVector(t) {
    return this.min.sub(t), this.max.add(t), this;
  }
  expandByScalar(t) {
    return this.min.addScalar(-t), this.max.addScalar(t), this;
  }
  expandByObject(t, i = !1) {
    t.updateWorldMatrix(!1, !1);
    const s = t.geometry;
    if (s !== void 0) {
      const c = s.getAttribute("position");
      if (i === !0 && c !== void 0 && t.isInstancedMesh !== !0)
        for (let h = 0, d = c.count; h < d; h++)
          t.isMesh === !0 ? t.getVertexPosition(h, Di) : Di.fromBufferAttribute(c, h), Di.applyMatrix4(t.matrixWorld), this.expandByPoint(Di);
      else
        t.boundingBox !== void 0 ? (t.boundingBox === null && t.computeBoundingBox(), Ac.copy(t.boundingBox)) : (s.boundingBox === null && s.computeBoundingBox(), Ac.copy(s.boundingBox)), Ac.applyMatrix4(t.matrixWorld), this.union(Ac);
    }
    const l = t.children;
    for (let c = 0, h = l.length; c < h; c++)
      this.expandByObject(l[c], i);
    return this;
  }
  containsPoint(t) {
    return t.x >= this.min.x && t.x <= this.max.x && t.y >= this.min.y && t.y <= this.max.y && t.z >= this.min.z && t.z <= this.max.z;
  }
  containsBox(t) {
    return this.min.x <= t.min.x && t.max.x <= this.max.x && this.min.y <= t.min.y && t.max.y <= this.max.y && this.min.z <= t.min.z && t.max.z <= this.max.z;
  }
  getParameter(t, i) {
    return i.set(
      (t.x - this.min.x) / (this.max.x - this.min.x),
      (t.y - this.min.y) / (this.max.y - this.min.y),
      (t.z - this.min.z) / (this.max.z - this.min.z)
    );
  }
  intersectsBox(t) {
    return t.max.x >= this.min.x && t.min.x <= this.max.x && t.max.y >= this.min.y && t.min.y <= this.max.y && t.max.z >= this.min.z && t.min.z <= this.max.z;
  }
  intersectsSphere(t) {
    return this.clampPoint(t.center, Di), Di.distanceToSquared(t.center) <= t.radius * t.radius;
  }
  intersectsPlane(t) {
    let i, s;
    return t.normal.x > 0 ? (i = t.normal.x * this.min.x, s = t.normal.x * this.max.x) : (i = t.normal.x * this.max.x, s = t.normal.x * this.min.x), t.normal.y > 0 ? (i += t.normal.y * this.min.y, s += t.normal.y * this.max.y) : (i += t.normal.y * this.max.y, s += t.normal.y * this.min.y), t.normal.z > 0 ? (i += t.normal.z * this.min.z, s += t.normal.z * this.max.z) : (i += t.normal.z * this.max.z, s += t.normal.z * this.min.z), i <= -t.constant && s >= -t.constant;
  }
  intersectsTriangle(t) {
    if (this.isEmpty())
      return !1;
    this.getCenter(Jo), Rc.subVectors(this.max, Jo), Sr.subVectors(t.a, Jo), Mr.subVectors(t.b, Jo), Er.subVectors(t.c, Jo), Ga.subVectors(Mr, Sr), Va.subVectors(Er, Mr), Ss.subVectors(Sr, Er);
    let i = [
      0,
      -Ga.z,
      Ga.y,
      0,
      -Va.z,
      Va.y,
      0,
      -Ss.z,
      Ss.y,
      Ga.z,
      0,
      -Ga.x,
      Va.z,
      0,
      -Va.x,
      Ss.z,
      0,
      -Ss.x,
      -Ga.y,
      Ga.x,
      0,
      -Va.y,
      Va.x,
      0,
      -Ss.y,
      Ss.x,
      0
    ];
    return !Vh(i, Sr, Mr, Er, Rc) || (i = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Vh(i, Sr, Mr, Er, Rc)) ? !1 : (Cc.crossVectors(Ga, Va), i = [Cc.x, Cc.y, Cc.z], Vh(i, Sr, Mr, Er, Rc));
  }
  clampPoint(t, i) {
    return i.copy(t).clamp(this.min, this.max);
  }
  distanceToPoint(t) {
    return this.clampPoint(t, Di).distanceTo(t);
  }
  getBoundingSphere(t) {
    return this.isEmpty() ? t.makeEmpty() : (this.getCenter(t.center), t.radius = this.getSize(Di).length() * 0.5), t;
  }
  intersect(t) {
    return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this;
  }
  union(t) {
    return this.min.min(t.min), this.max.max(t.max), this;
  }
  applyMatrix4(t) {
    return this.isEmpty() ? this : (ra[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), ra[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), ra[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), ra[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), ra[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), ra[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), ra[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), ra[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(ra), this);
  }
  translate(t) {
    return this.min.add(t), this.max.add(t), this;
  }
  equals(t) {
    return t.min.equals(this.min) && t.max.equals(this.max);
  }
}
const ra = [
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q(),
  /* @__PURE__ */ new q()
], Di = /* @__PURE__ */ new q(), Ac = /* @__PURE__ */ new Is(), Sr = /* @__PURE__ */ new q(), Mr = /* @__PURE__ */ new q(), Er = /* @__PURE__ */ new q(), Ga = /* @__PURE__ */ new q(), Va = /* @__PURE__ */ new q(), Ss = /* @__PURE__ */ new q(), Jo = /* @__PURE__ */ new q(), Rc = /* @__PURE__ */ new q(), Cc = /* @__PURE__ */ new q(), Ms = /* @__PURE__ */ new q();
function Vh(r, t, i, s, l) {
  for (let c = 0, h = r.length - 3; c <= h; c += 3) {
    Ms.fromArray(r, c);
    const d = l.x * Math.abs(Ms.x) + l.y * Math.abs(Ms.y) + l.z * Math.abs(Ms.z), m = t.dot(Ms), p = i.dot(Ms), g = s.dot(Ms);
    if (Math.max(-Math.max(m, p, g), Math.min(m, p, g)) > d)
      return !1;
  }
  return !0;
}
const ZM = /* @__PURE__ */ new Is(), $o = /* @__PURE__ */ new q(), kh = /* @__PURE__ */ new q();
class eo {
  constructor(t = new q(), i = -1) {
    this.isSphere = !0, this.center = t, this.radius = i;
  }
  set(t, i) {
    return this.center.copy(t), this.radius = i, this;
  }
  setFromPoints(t, i) {
    const s = this.center;
    i !== void 0 ? s.copy(i) : ZM.setFromPoints(t).getCenter(s);
    let l = 0;
    for (let c = 0, h = t.length; c < h; c++)
      l = Math.max(l, s.distanceToSquared(t[c]));
    return this.radius = Math.sqrt(l), this;
  }
  copy(t) {
    return this.center.copy(t.center), this.radius = t.radius, this;
  }
  isEmpty() {
    return this.radius < 0;
  }
  makeEmpty() {
    return this.center.set(0, 0, 0), this.radius = -1, this;
  }
  containsPoint(t) {
    return t.distanceToSquared(this.center) <= this.radius * this.radius;
  }
  distanceToPoint(t) {
    return t.distanceTo(this.center) - this.radius;
  }
  intersectsSphere(t) {
    const i = this.radius + t.radius;
    return t.center.distanceToSquared(this.center) <= i * i;
  }
  intersectsBox(t) {
    return t.intersectsSphere(this);
  }
  intersectsPlane(t) {
    return Math.abs(t.distanceToPoint(this.center)) <= this.radius;
  }
  clampPoint(t, i) {
    const s = this.center.distanceToSquared(t);
    return i.copy(t), s > this.radius * this.radius && (i.sub(this.center).normalize(), i.multiplyScalar(this.radius).add(this.center)), i;
  }
  getBoundingBox(t) {
    return this.isEmpty() ? (t.makeEmpty(), t) : (t.set(this.center, this.center), t.expandByScalar(this.radius), t);
  }
  applyMatrix4(t) {
    return this.center.applyMatrix4(t), this.radius = this.radius * t.getMaxScaleOnAxis(), this;
  }
  translate(t) {
    return this.center.add(t), this;
  }
  expandByPoint(t) {
    if (this.isEmpty())
      return this.center.copy(t), this.radius = 0, this;
    $o.subVectors(t, this.center);
    const i = $o.lengthSq();
    if (i > this.radius * this.radius) {
      const s = Math.sqrt(i), l = (s - this.radius) * 0.5;
      this.center.addScaledVector($o, l / s), this.radius += l;
    }
    return this;
  }
  union(t) {
    return t.isEmpty() ? this : this.isEmpty() ? (this.copy(t), this) : (this.center.equals(t.center) === !0 ? this.radius = Math.max(this.radius, t.radius) : (kh.subVectors(t.center, this.center).setLength(t.radius), this.expandByPoint($o.copy(t.center).add(kh)), this.expandByPoint($o.copy(t.center).sub(kh))), this);
  }
  equals(t) {
    return t.center.equals(this.center) && t.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const oa = /* @__PURE__ */ new q(), Xh = /* @__PURE__ */ new q(), wc = /* @__PURE__ */ new q(), ka = /* @__PURE__ */ new q(), Wh = /* @__PURE__ */ new q(), Dc = /* @__PURE__ */ new q(), Yh = /* @__PURE__ */ new q();
class Ap {
  constructor(t = new q(), i = new q(0, 0, -1)) {
    this.origin = t, this.direction = i;
  }
  set(t, i) {
    return this.origin.copy(t), this.direction.copy(i), this;
  }
  copy(t) {
    return this.origin.copy(t.origin), this.direction.copy(t.direction), this;
  }
  at(t, i) {
    return i.copy(this.origin).addScaledVector(this.direction, t);
  }
  lookAt(t) {
    return this.direction.copy(t).sub(this.origin).normalize(), this;
  }
  recast(t) {
    return this.origin.copy(this.at(t, oa)), this;
  }
  closestPointToPoint(t, i) {
    i.subVectors(t, this.origin);
    const s = i.dot(this.direction);
    return s < 0 ? i.copy(this.origin) : i.copy(this.origin).addScaledVector(this.direction, s);
  }
  distanceToPoint(t) {
    return Math.sqrt(this.distanceSqToPoint(t));
  }
  distanceSqToPoint(t) {
    const i = oa.subVectors(t, this.origin).dot(this.direction);
    return i < 0 ? this.origin.distanceToSquared(t) : (oa.copy(this.origin).addScaledVector(this.direction, i), oa.distanceToSquared(t));
  }
  distanceSqToSegment(t, i, s, l) {
    Xh.copy(t).add(i).multiplyScalar(0.5), wc.copy(i).sub(t).normalize(), ka.copy(this.origin).sub(Xh);
    const c = t.distanceTo(i) * 0.5, h = -this.direction.dot(wc), d = ka.dot(this.direction), m = -ka.dot(wc), p = ka.lengthSq(), g = Math.abs(1 - h * h);
    let _, x, S, E;
    if (g > 0)
      if (_ = h * m - d, x = h * d - m, E = c * g, _ >= 0)
        if (x >= -E)
          if (x <= E) {
            const b = 1 / g;
            _ *= b, x *= b, S = _ * (_ + h * x + 2 * d) + x * (h * _ + x + 2 * m) + p;
          } else
            x = c, _ = Math.max(0, -(h * x + d)), S = -_ * _ + x * (x + 2 * m) + p;
        else
          x = -c, _ = Math.max(0, -(h * x + d)), S = -_ * _ + x * (x + 2 * m) + p;
      else
        x <= -E ? (_ = Math.max(0, -(-h * c + d)), x = _ > 0 ? -c : Math.min(Math.max(-c, -m), c), S = -_ * _ + x * (x + 2 * m) + p) : x <= E ? (_ = 0, x = Math.min(Math.max(-c, -m), c), S = x * (x + 2 * m) + p) : (_ = Math.max(0, -(h * c + d)), x = _ > 0 ? c : Math.min(Math.max(-c, -m), c), S = -_ * _ + x * (x + 2 * m) + p);
    else
      x = h > 0 ? -c : c, _ = Math.max(0, -(h * x + d)), S = -_ * _ + x * (x + 2 * m) + p;
    return s && s.copy(this.origin).addScaledVector(this.direction, _), l && l.copy(Xh).addScaledVector(wc, x), S;
  }
  intersectSphere(t, i) {
    oa.subVectors(t.center, this.origin);
    const s = oa.dot(this.direction), l = oa.dot(oa) - s * s, c = t.radius * t.radius;
    if (l > c) return null;
    const h = Math.sqrt(c - l), d = s - h, m = s + h;
    return m < 0 ? null : d < 0 ? this.at(m, i) : this.at(d, i);
  }
  intersectsSphere(t) {
    return this.distanceSqToPoint(t.center) <= t.radius * t.radius;
  }
  distanceToPlane(t) {
    const i = t.normal.dot(this.direction);
    if (i === 0)
      return t.distanceToPoint(this.origin) === 0 ? 0 : null;
    const s = -(this.origin.dot(t.normal) + t.constant) / i;
    return s >= 0 ? s : null;
  }
  intersectPlane(t, i) {
    const s = this.distanceToPlane(t);
    return s === null ? null : this.at(s, i);
  }
  intersectsPlane(t) {
    const i = t.distanceToPoint(this.origin);
    return i === 0 || t.normal.dot(this.direction) * i < 0;
  }
  intersectBox(t, i) {
    let s, l, c, h, d, m;
    const p = 1 / this.direction.x, g = 1 / this.direction.y, _ = 1 / this.direction.z, x = this.origin;
    return p >= 0 ? (s = (t.min.x - x.x) * p, l = (t.max.x - x.x) * p) : (s = (t.max.x - x.x) * p, l = (t.min.x - x.x) * p), g >= 0 ? (c = (t.min.y - x.y) * g, h = (t.max.y - x.y) * g) : (c = (t.max.y - x.y) * g, h = (t.min.y - x.y) * g), s > h || c > l || ((c > s || isNaN(s)) && (s = c), (h < l || isNaN(l)) && (l = h), _ >= 0 ? (d = (t.min.z - x.z) * _, m = (t.max.z - x.z) * _) : (d = (t.max.z - x.z) * _, m = (t.min.z - x.z) * _), s > m || d > l) || ((d > s || s !== s) && (s = d), (m < l || l !== l) && (l = m), l < 0) ? null : this.at(s >= 0 ? s : l, i);
  }
  intersectsBox(t) {
    return this.intersectBox(t, oa) !== null;
  }
  intersectTriangle(t, i, s, l, c) {
    Wh.subVectors(i, t), Dc.subVectors(s, t), Yh.crossVectors(Wh, Dc);
    let h = this.direction.dot(Yh), d;
    if (h > 0) {
      if (l) return null;
      d = 1;
    } else if (h < 0)
      d = -1, h = -h;
    else
      return null;
    ka.subVectors(this.origin, t);
    const m = d * this.direction.dot(Dc.crossVectors(ka, Dc));
    if (m < 0)
      return null;
    const p = d * this.direction.dot(Wh.cross(ka));
    if (p < 0 || m + p > h)
      return null;
    const g = -d * ka.dot(Yh);
    return g < 0 ? null : this.at(g / h, c);
  }
  applyMatrix4(t) {
    return this.origin.applyMatrix4(t), this.direction.transformDirection(t), this;
  }
  equals(t) {
    return t.origin.equals(this.origin) && t.direction.equals(this.direction);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Xe {
  constructor(t, i, s, l, c, h, d, m, p, g, _, x, S, E, b, M) {
    Xe.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, i, s, l, c, h, d, m, p, g, _, x, S, E, b, M);
  }
  set(t, i, s, l, c, h, d, m, p, g, _, x, S, E, b, M) {
    const v = this.elements;
    return v[0] = t, v[4] = i, v[8] = s, v[12] = l, v[1] = c, v[5] = h, v[9] = d, v[13] = m, v[2] = p, v[6] = g, v[10] = _, v[14] = x, v[3] = S, v[7] = E, v[11] = b, v[15] = M, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  clone() {
    return new Xe().fromArray(this.elements);
  }
  copy(t) {
    const i = this.elements, s = t.elements;
    return i[0] = s[0], i[1] = s[1], i[2] = s[2], i[3] = s[3], i[4] = s[4], i[5] = s[5], i[6] = s[6], i[7] = s[7], i[8] = s[8], i[9] = s[9], i[10] = s[10], i[11] = s[11], i[12] = s[12], i[13] = s[13], i[14] = s[14], i[15] = s[15], this;
  }
  copyPosition(t) {
    const i = this.elements, s = t.elements;
    return i[12] = s[12], i[13] = s[13], i[14] = s[14], this;
  }
  setFromMatrix3(t) {
    const i = t.elements;
    return this.set(
      i[0],
      i[3],
      i[6],
      0,
      i[1],
      i[4],
      i[7],
      0,
      i[2],
      i[5],
      i[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(t, i, s) {
    return t.setFromMatrixColumn(this, 0), i.setFromMatrixColumn(this, 1), s.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(t, i, s) {
    return this.set(
      t.x,
      i.x,
      s.x,
      0,
      t.y,
      i.y,
      s.y,
      0,
      t.z,
      i.z,
      s.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(t) {
    const i = this.elements, s = t.elements, l = 1 / br.setFromMatrixColumn(t, 0).length(), c = 1 / br.setFromMatrixColumn(t, 1).length(), h = 1 / br.setFromMatrixColumn(t, 2).length();
    return i[0] = s[0] * l, i[1] = s[1] * l, i[2] = s[2] * l, i[3] = 0, i[4] = s[4] * c, i[5] = s[5] * c, i[6] = s[6] * c, i[7] = 0, i[8] = s[8] * h, i[9] = s[9] * h, i[10] = s[10] * h, i[11] = 0, i[12] = 0, i[13] = 0, i[14] = 0, i[15] = 1, this;
  }
  makeRotationFromEuler(t) {
    const i = this.elements, s = t.x, l = t.y, c = t.z, h = Math.cos(s), d = Math.sin(s), m = Math.cos(l), p = Math.sin(l), g = Math.cos(c), _ = Math.sin(c);
    if (t.order === "XYZ") {
      const x = h * g, S = h * _, E = d * g, b = d * _;
      i[0] = m * g, i[4] = -m * _, i[8] = p, i[1] = S + E * p, i[5] = x - b * p, i[9] = -d * m, i[2] = b - x * p, i[6] = E + S * p, i[10] = h * m;
    } else if (t.order === "YXZ") {
      const x = m * g, S = m * _, E = p * g, b = p * _;
      i[0] = x + b * d, i[4] = E * d - S, i[8] = h * p, i[1] = h * _, i[5] = h * g, i[9] = -d, i[2] = S * d - E, i[6] = b + x * d, i[10] = h * m;
    } else if (t.order === "ZXY") {
      const x = m * g, S = m * _, E = p * g, b = p * _;
      i[0] = x - b * d, i[4] = -h * _, i[8] = E + S * d, i[1] = S + E * d, i[5] = h * g, i[9] = b - x * d, i[2] = -h * p, i[6] = d, i[10] = h * m;
    } else if (t.order === "ZYX") {
      const x = h * g, S = h * _, E = d * g, b = d * _;
      i[0] = m * g, i[4] = E * p - S, i[8] = x * p + b, i[1] = m * _, i[5] = b * p + x, i[9] = S * p - E, i[2] = -p, i[6] = d * m, i[10] = h * m;
    } else if (t.order === "YZX") {
      const x = h * m, S = h * p, E = d * m, b = d * p;
      i[0] = m * g, i[4] = b - x * _, i[8] = E * _ + S, i[1] = _, i[5] = h * g, i[9] = -d * g, i[2] = -p * g, i[6] = S * _ + E, i[10] = x - b * _;
    } else if (t.order === "XZY") {
      const x = h * m, S = h * p, E = d * m, b = d * p;
      i[0] = m * g, i[4] = -_, i[8] = p * g, i[1] = x * _ + b, i[5] = h * g, i[9] = S * _ - E, i[2] = E * _ - S, i[6] = d * g, i[10] = b * _ + x;
    }
    return i[3] = 0, i[7] = 0, i[11] = 0, i[12] = 0, i[13] = 0, i[14] = 0, i[15] = 1, this;
  }
  makeRotationFromQuaternion(t) {
    return this.compose(KM, t, QM);
  }
  lookAt(t, i, s) {
    const l = this.elements;
    return li.subVectors(t, i), li.lengthSq() === 0 && (li.z = 1), li.normalize(), Xa.crossVectors(s, li), Xa.lengthSq() === 0 && (Math.abs(s.z) === 1 ? li.x += 1e-4 : li.z += 1e-4, li.normalize(), Xa.crossVectors(s, li)), Xa.normalize(), Uc.crossVectors(li, Xa), l[0] = Xa.x, l[4] = Uc.x, l[8] = li.x, l[1] = Xa.y, l[5] = Uc.y, l[9] = li.y, l[2] = Xa.z, l[6] = Uc.z, l[10] = li.z, this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, i) {
    const s = t.elements, l = i.elements, c = this.elements, h = s[0], d = s[4], m = s[8], p = s[12], g = s[1], _ = s[5], x = s[9], S = s[13], E = s[2], b = s[6], M = s[10], v = s[14], B = s[3], U = s[7], w = s[11], F = s[15], L = l[0], O = l[4], G = l[8], C = l[12], T = l[1], I = l[5], J = l[9], $ = l[13], lt = l[2], pt = l[6], z = l[10], tt = l[14], K = l[3], yt = l[7], Mt = l[11], P = l[15];
    return c[0] = h * L + d * T + m * lt + p * K, c[4] = h * O + d * I + m * pt + p * yt, c[8] = h * G + d * J + m * z + p * Mt, c[12] = h * C + d * $ + m * tt + p * P, c[1] = g * L + _ * T + x * lt + S * K, c[5] = g * O + _ * I + x * pt + S * yt, c[9] = g * G + _ * J + x * z + S * Mt, c[13] = g * C + _ * $ + x * tt + S * P, c[2] = E * L + b * T + M * lt + v * K, c[6] = E * O + b * I + M * pt + v * yt, c[10] = E * G + b * J + M * z + v * Mt, c[14] = E * C + b * $ + M * tt + v * P, c[3] = B * L + U * T + w * lt + F * K, c[7] = B * O + U * I + w * pt + F * yt, c[11] = B * G + U * J + w * z + F * Mt, c[15] = B * C + U * $ + w * tt + F * P, this;
  }
  multiplyScalar(t) {
    const i = this.elements;
    return i[0] *= t, i[4] *= t, i[8] *= t, i[12] *= t, i[1] *= t, i[5] *= t, i[9] *= t, i[13] *= t, i[2] *= t, i[6] *= t, i[10] *= t, i[14] *= t, i[3] *= t, i[7] *= t, i[11] *= t, i[15] *= t, this;
  }
  determinant() {
    const t = this.elements, i = t[0], s = t[4], l = t[8], c = t[12], h = t[1], d = t[5], m = t[9], p = t[13], g = t[2], _ = t[6], x = t[10], S = t[14], E = t[3], b = t[7], M = t[11], v = t[15];
    return E * (+c * m * _ - l * p * _ - c * d * x + s * p * x + l * d * S - s * m * S) + b * (+i * m * S - i * p * x + c * h * x - l * h * S + l * p * g - c * m * g) + M * (+i * p * _ - i * d * S - c * h * _ + s * h * S + c * d * g - s * p * g) + v * (-l * d * g - i * m * _ + i * d * x + l * h * _ - s * h * x + s * m * g);
  }
  transpose() {
    const t = this.elements;
    let i;
    return i = t[1], t[1] = t[4], t[4] = i, i = t[2], t[2] = t[8], t[8] = i, i = t[6], t[6] = t[9], t[9] = i, i = t[3], t[3] = t[12], t[12] = i, i = t[7], t[7] = t[13], t[13] = i, i = t[11], t[11] = t[14], t[14] = i, this;
  }
  setPosition(t, i, s) {
    const l = this.elements;
    return t.isVector3 ? (l[12] = t.x, l[13] = t.y, l[14] = t.z) : (l[12] = t, l[13] = i, l[14] = s), this;
  }
  invert() {
    const t = this.elements, i = t[0], s = t[1], l = t[2], c = t[3], h = t[4], d = t[5], m = t[6], p = t[7], g = t[8], _ = t[9], x = t[10], S = t[11], E = t[12], b = t[13], M = t[14], v = t[15], B = _ * M * p - b * x * p + b * m * S - d * M * S - _ * m * v + d * x * v, U = E * x * p - g * M * p - E * m * S + h * M * S + g * m * v - h * x * v, w = g * b * p - E * _ * p + E * d * S - h * b * S - g * d * v + h * _ * v, F = E * _ * m - g * b * m - E * d * x + h * b * x + g * d * M - h * _ * M, L = i * B + s * U + l * w + c * F;
    if (L === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const O = 1 / L;
    return t[0] = B * O, t[1] = (b * x * c - _ * M * c - b * l * S + s * M * S + _ * l * v - s * x * v) * O, t[2] = (d * M * c - b * m * c + b * l * p - s * M * p - d * l * v + s * m * v) * O, t[3] = (_ * m * c - d * x * c - _ * l * p + s * x * p + d * l * S - s * m * S) * O, t[4] = U * O, t[5] = (g * M * c - E * x * c + E * l * S - i * M * S - g * l * v + i * x * v) * O, t[6] = (E * m * c - h * M * c - E * l * p + i * M * p + h * l * v - i * m * v) * O, t[7] = (h * x * c - g * m * c + g * l * p - i * x * p - h * l * S + i * m * S) * O, t[8] = w * O, t[9] = (E * _ * c - g * b * c - E * s * S + i * b * S + g * s * v - i * _ * v) * O, t[10] = (h * b * c - E * d * c + E * s * p - i * b * p - h * s * v + i * d * v) * O, t[11] = (g * d * c - h * _ * c - g * s * p + i * _ * p + h * s * S - i * d * S) * O, t[12] = F * O, t[13] = (g * b * l - E * _ * l + E * s * x - i * b * x - g * s * M + i * _ * M) * O, t[14] = (E * d * l - h * b * l - E * s * m + i * b * m + h * s * M - i * d * M) * O, t[15] = (h * _ * l - g * d * l + g * s * m - i * _ * m - h * s * x + i * d * x) * O, this;
  }
  scale(t) {
    const i = this.elements, s = t.x, l = t.y, c = t.z;
    return i[0] *= s, i[4] *= l, i[8] *= c, i[1] *= s, i[5] *= l, i[9] *= c, i[2] *= s, i[6] *= l, i[10] *= c, i[3] *= s, i[7] *= l, i[11] *= c, this;
  }
  getMaxScaleOnAxis() {
    const t = this.elements, i = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], s = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], l = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
    return Math.sqrt(Math.max(i, s, l));
  }
  makeTranslation(t, i, s) {
    return t.isVector3 ? this.set(
      1,
      0,
      0,
      t.x,
      0,
      1,
      0,
      t.y,
      0,
      0,
      1,
      t.z,
      0,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      0,
      t,
      0,
      1,
      0,
      i,
      0,
      0,
      1,
      s,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(t) {
    const i = Math.cos(t), s = Math.sin(t);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      i,
      -s,
      0,
      0,
      s,
      i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(t) {
    const i = Math.cos(t), s = Math.sin(t);
    return this.set(
      i,
      0,
      s,
      0,
      0,
      1,
      0,
      0,
      -s,
      0,
      i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(t) {
    const i = Math.cos(t), s = Math.sin(t);
    return this.set(
      i,
      -s,
      0,
      0,
      s,
      i,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(t, i) {
    const s = Math.cos(i), l = Math.sin(i), c = 1 - s, h = t.x, d = t.y, m = t.z, p = c * h, g = c * d;
    return this.set(
      p * h + s,
      p * d - l * m,
      p * m + l * d,
      0,
      p * d + l * m,
      g * d + s,
      g * m - l * h,
      0,
      p * m - l * d,
      g * m + l * h,
      c * m * m + s,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, i, s) {
    return this.set(
      t,
      0,
      0,
      0,
      0,
      i,
      0,
      0,
      0,
      0,
      s,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(t, i, s, l, c, h) {
    return this.set(
      1,
      s,
      c,
      0,
      t,
      1,
      h,
      0,
      i,
      l,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(t, i, s) {
    const l = this.elements, c = i._x, h = i._y, d = i._z, m = i._w, p = c + c, g = h + h, _ = d + d, x = c * p, S = c * g, E = c * _, b = h * g, M = h * _, v = d * _, B = m * p, U = m * g, w = m * _, F = s.x, L = s.y, O = s.z;
    return l[0] = (1 - (b + v)) * F, l[1] = (S + w) * F, l[2] = (E - U) * F, l[3] = 0, l[4] = (S - w) * L, l[5] = (1 - (x + v)) * L, l[6] = (M + B) * L, l[7] = 0, l[8] = (E + U) * O, l[9] = (M - B) * O, l[10] = (1 - (x + b)) * O, l[11] = 0, l[12] = t.x, l[13] = t.y, l[14] = t.z, l[15] = 1, this;
  }
  decompose(t, i, s) {
    const l = this.elements;
    let c = br.set(l[0], l[1], l[2]).length();
    const h = br.set(l[4], l[5], l[6]).length(), d = br.set(l[8], l[9], l[10]).length();
    this.determinant() < 0 && (c = -c), t.x = l[12], t.y = l[13], t.z = l[14], Ui.copy(this);
    const p = 1 / c, g = 1 / h, _ = 1 / d;
    return Ui.elements[0] *= p, Ui.elements[1] *= p, Ui.elements[2] *= p, Ui.elements[4] *= g, Ui.elements[5] *= g, Ui.elements[6] *= g, Ui.elements[8] *= _, Ui.elements[9] *= _, Ui.elements[10] *= _, i.setFromRotationMatrix(Ui), s.x = c, s.y = h, s.z = d, this;
  }
  makePerspective(t, i, s, l, c, h, d = pa) {
    const m = this.elements, p = 2 * c / (i - t), g = 2 * c / (s - l), _ = (i + t) / (i - t), x = (s + l) / (s - l);
    let S, E;
    if (d === pa)
      S = -(h + c) / (h - c), E = -2 * h * c / (h - c);
    else if (d === hu)
      S = -h / (h - c), E = -h * c / (h - c);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + d);
    return m[0] = p, m[4] = 0, m[8] = _, m[12] = 0, m[1] = 0, m[5] = g, m[9] = x, m[13] = 0, m[2] = 0, m[6] = 0, m[10] = S, m[14] = E, m[3] = 0, m[7] = 0, m[11] = -1, m[15] = 0, this;
  }
  makeOrthographic(t, i, s, l, c, h, d = pa) {
    const m = this.elements, p = 1 / (i - t), g = 1 / (s - l), _ = 1 / (h - c), x = (i + t) * p, S = (s + l) * g;
    let E, b;
    if (d === pa)
      E = (h + c) * _, b = -2 * _;
    else if (d === hu)
      E = c * _, b = -1 * _;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + d);
    return m[0] = 2 * p, m[4] = 0, m[8] = 0, m[12] = -x, m[1] = 0, m[5] = 2 * g, m[9] = 0, m[13] = -S, m[2] = 0, m[6] = 0, m[10] = b, m[14] = -E, m[3] = 0, m[7] = 0, m[11] = 0, m[15] = 1, this;
  }
  equals(t) {
    const i = this.elements, s = t.elements;
    for (let l = 0; l < 16; l++)
      if (i[l] !== s[l]) return !1;
    return !0;
  }
  fromArray(t, i = 0) {
    for (let s = 0; s < 16; s++)
      this.elements[s] = t[s + i];
    return this;
  }
  toArray(t = [], i = 0) {
    const s = this.elements;
    return t[i] = s[0], t[i + 1] = s[1], t[i + 2] = s[2], t[i + 3] = s[3], t[i + 4] = s[4], t[i + 5] = s[5], t[i + 6] = s[6], t[i + 7] = s[7], t[i + 8] = s[8], t[i + 9] = s[9], t[i + 10] = s[10], t[i + 11] = s[11], t[i + 12] = s[12], t[i + 13] = s[13], t[i + 14] = s[14], t[i + 15] = s[15], t;
  }
}
const br = /* @__PURE__ */ new q(), Ui = /* @__PURE__ */ new Xe(), KM = /* @__PURE__ */ new q(0, 0, 0), QM = /* @__PURE__ */ new q(1, 1, 1), Xa = /* @__PURE__ */ new q(), Uc = /* @__PURE__ */ new q(), li = /* @__PURE__ */ new q(), O0 = /* @__PURE__ */ new Xe(), P0 = /* @__PURE__ */ new es();
class Gi {
  constructor(t = 0, i = 0, s = 0, l = Gi.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = t, this._y = i, this._z = s, this._order = l;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get order() {
    return this._order;
  }
  set order(t) {
    this._order = t, this._onChangeCallback();
  }
  set(t, i, s, l = this._order) {
    return this._x = t, this._y = i, this._z = s, this._order = l, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._order);
  }
  copy(t) {
    return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t, i = this._order, s = !0) {
    const l = t.elements, c = l[0], h = l[4], d = l[8], m = l[1], p = l[5], g = l[9], _ = l[2], x = l[6], S = l[10];
    switch (i) {
      case "XYZ":
        this._y = Math.asin(_e(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._x = Math.atan2(-g, S), this._z = Math.atan2(-h, c)) : (this._x = Math.atan2(x, p), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-_e(g, -1, 1)), Math.abs(g) < 0.9999999 ? (this._y = Math.atan2(d, S), this._z = Math.atan2(m, p)) : (this._y = Math.atan2(-_, c), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(_e(x, -1, 1)), Math.abs(x) < 0.9999999 ? (this._y = Math.atan2(-_, S), this._z = Math.atan2(-h, p)) : (this._y = 0, this._z = Math.atan2(m, c));
        break;
      case "ZYX":
        this._y = Math.asin(-_e(_, -1, 1)), Math.abs(_) < 0.9999999 ? (this._x = Math.atan2(x, S), this._z = Math.atan2(m, c)) : (this._x = 0, this._z = Math.atan2(-h, p));
        break;
      case "YZX":
        this._z = Math.asin(_e(m, -1, 1)), Math.abs(m) < 0.9999999 ? (this._x = Math.atan2(-g, p), this._y = Math.atan2(-_, c)) : (this._x = 0, this._y = Math.atan2(d, S));
        break;
      case "XZY":
        this._z = Math.asin(-_e(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(x, p), this._y = Math.atan2(d, c)) : (this._x = Math.atan2(-g, S), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + i);
    }
    return this._order = i, s === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(t, i, s) {
    return O0.makeRotationFromQuaternion(t), this.setFromRotationMatrix(O0, i, s);
  }
  setFromVector3(t, i = this._order) {
    return this.set(t.x, t.y, t.z, i);
  }
  reorder(t) {
    return P0.setFromEuler(this), this.setFromQuaternion(P0, t);
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
  }
  fromArray(t) {
    return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this._x, t[i + 1] = this._y, t[i + 2] = this._z, t[i + 3] = this._order, t;
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._order;
  }
}
Gi.DEFAULT_ORDER = "XYZ";
class mx {
  constructor() {
    this.mask = 1;
  }
  set(t) {
    this.mask = (1 << t | 0) >>> 0;
  }
  enable(t) {
    this.mask |= 1 << t | 0;
  }
  enableAll() {
    this.mask = -1;
  }
  toggle(t) {
    this.mask ^= 1 << t | 0;
  }
  disable(t) {
    this.mask &= ~(1 << t | 0);
  }
  disableAll() {
    this.mask = 0;
  }
  test(t) {
    return (this.mask & t.mask) !== 0;
  }
  isEnabled(t) {
    return (this.mask & (1 << t | 0)) !== 0;
  }
}
let JM = 0;
const z0 = /* @__PURE__ */ new q(), Tr = /* @__PURE__ */ new es(), la = /* @__PURE__ */ new Xe(), Lc = /* @__PURE__ */ new q(), tl = /* @__PURE__ */ new q(), $M = /* @__PURE__ */ new q(), tE = /* @__PURE__ */ new es(), B0 = /* @__PURE__ */ new q(1, 0, 0), I0 = /* @__PURE__ */ new q(0, 1, 0), F0 = /* @__PURE__ */ new q(0, 0, 1), H0 = { type: "added" }, eE = { type: "removed" }, Ar = { type: "childadded", child: null }, qh = { type: "childremoved", child: null };
class fn extends Bs {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: JM++ }), this.uuid = $a(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = fn.DEFAULT_UP.clone();
    const t = new q(), i = new Gi(), s = new es(), l = new q(1, 1, 1);
    function c() {
      s.setFromEuler(i, !1);
    }
    function h() {
      i.setFromQuaternion(s, void 0, !1);
    }
    i._onChange(c), s._onChange(h), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: i
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: s
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: l
      },
      modelViewMatrix: {
        value: new Xe()
      },
      normalMatrix: {
        value: new ue()
      }
    }), this.matrix = new Xe(), this.matrixWorld = new Xe(), this.matrixAutoUpdate = fn.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new mx(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  onBeforeShadow() {
  }
  onAfterShadow() {
  }
  onBeforeRender() {
  }
  onAfterRender() {
  }
  applyMatrix4(t) {
    this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale);
  }
  applyQuaternion(t) {
    return this.quaternion.premultiply(t), this;
  }
  setRotationFromAxisAngle(t, i) {
    this.quaternion.setFromAxisAngle(t, i);
  }
  setRotationFromEuler(t) {
    this.quaternion.setFromEuler(t, !0);
  }
  setRotationFromMatrix(t) {
    this.quaternion.setFromRotationMatrix(t);
  }
  setRotationFromQuaternion(t) {
    this.quaternion.copy(t);
  }
  rotateOnAxis(t, i) {
    return Tr.setFromAxisAngle(t, i), this.quaternion.multiply(Tr), this;
  }
  rotateOnWorldAxis(t, i) {
    return Tr.setFromAxisAngle(t, i), this.quaternion.premultiply(Tr), this;
  }
  rotateX(t) {
    return this.rotateOnAxis(B0, t);
  }
  rotateY(t) {
    return this.rotateOnAxis(I0, t);
  }
  rotateZ(t) {
    return this.rotateOnAxis(F0, t);
  }
  translateOnAxis(t, i) {
    return z0.copy(t).applyQuaternion(this.quaternion), this.position.add(z0.multiplyScalar(i)), this;
  }
  translateX(t) {
    return this.translateOnAxis(B0, t);
  }
  translateY(t) {
    return this.translateOnAxis(I0, t);
  }
  translateZ(t) {
    return this.translateOnAxis(F0, t);
  }
  localToWorld(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(la.copy(this.matrixWorld).invert());
  }
  lookAt(t, i, s) {
    t.isVector3 ? Lc.copy(t) : Lc.set(t, i, s);
    const l = this.parent;
    this.updateWorldMatrix(!0, !1), tl.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? la.lookAt(tl, Lc, this.up) : la.lookAt(Lc, tl, this.up), this.quaternion.setFromRotationMatrix(la), l && (la.extractRotation(l.matrixWorld), Tr.setFromRotationMatrix(la), this.quaternion.premultiply(Tr.invert()));
  }
  add(t) {
    if (arguments.length > 1) {
      for (let i = 0; i < arguments.length; i++)
        this.add(arguments[i]);
      return this;
    }
    return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.removeFromParent(), t.parent = this, this.children.push(t), t.dispatchEvent(H0), Ar.child = t, this.dispatchEvent(Ar), Ar.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
  }
  remove(t) {
    if (arguments.length > 1) {
      for (let s = 0; s < arguments.length; s++)
        this.remove(arguments[s]);
      return this;
    }
    const i = this.children.indexOf(t);
    return i !== -1 && (t.parent = null, this.children.splice(i, 1), t.dispatchEvent(eE), qh.child = t, this.dispatchEvent(qh), qh.child = null), this;
  }
  removeFromParent() {
    const t = this.parent;
    return t !== null && t.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(t) {
    return this.updateWorldMatrix(!0, !1), la.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), la.multiply(t.parent.matrixWorld)), t.applyMatrix4(la), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(H0), Ar.child = t, this.dispatchEvent(Ar), Ar.child = null, this;
  }
  getObjectById(t) {
    return this.getObjectByProperty("id", t);
  }
  getObjectByName(t) {
    return this.getObjectByProperty("name", t);
  }
  getObjectByProperty(t, i) {
    if (this[t] === i) return this;
    for (let s = 0, l = this.children.length; s < l; s++) {
      const h = this.children[s].getObjectByProperty(t, i);
      if (h !== void 0)
        return h;
    }
  }
  getObjectsByProperty(t, i, s = []) {
    this[t] === i && s.push(this);
    const l = this.children;
    for (let c = 0, h = l.length; c < h; c++)
      l[c].getObjectsByProperty(t, i, s);
    return s;
  }
  getWorldPosition(t) {
    return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(tl, t, $M), t;
  }
  getWorldScale(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(tl, tE, t), t;
  }
  getWorldDirection(t) {
    this.updateWorldMatrix(!0, !1);
    const i = this.matrixWorld.elements;
    return t.set(i[8], i[9], i[10]).normalize();
  }
  raycast() {
  }
  traverse(t) {
    t(this);
    const i = this.children;
    for (let s = 0, l = i.length; s < l; s++)
      i[s].traverse(t);
  }
  traverseVisible(t) {
    if (this.visible === !1) return;
    t(this);
    const i = this.children;
    for (let s = 0, l = i.length; s < l; s++)
      i[s].traverseVisible(t);
  }
  traverseAncestors(t) {
    const i = this.parent;
    i !== null && (t(i), i.traverseAncestors(t));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(t) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, t = !0);
    const i = this.children;
    for (let s = 0, l = i.length; s < l; s++)
      i[s].updateMatrixWorld(t);
  }
  updateWorldMatrix(t, i) {
    const s = this.parent;
    if (t === !0 && s !== null && s.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), i === !0) {
      const l = this.children;
      for (let c = 0, h = l.length; c < h; c++)
        l[c].updateWorldMatrix(!1, !0);
    }
  }
  toJSON(t) {
    const i = t === void 0 || typeof t == "string", s = {};
    i && (t = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, s.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const l = {};
    l.uuid = this.uuid, l.type = this.type, this.name !== "" && (l.name = this.name), this.castShadow === !0 && (l.castShadow = !0), this.receiveShadow === !0 && (l.receiveShadow = !0), this.visible === !1 && (l.visible = !1), this.frustumCulled === !1 && (l.frustumCulled = !1), this.renderOrder !== 0 && (l.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (l.userData = this.userData), l.layers = this.layers.mask, l.matrix = this.matrix.toArray(), l.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (l.matrixAutoUpdate = !1), this.isInstancedMesh && (l.type = "InstancedMesh", l.count = this.count, l.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (l.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (l.type = "BatchedMesh", l.perObjectFrustumCulled = this.perObjectFrustumCulled, l.sortObjects = this.sortObjects, l.drawRanges = this._drawRanges, l.reservedRanges = this._reservedRanges, l.visibility = this._visibility, l.active = this._active, l.bounds = this._bounds.map((d) => ({
      boxInitialized: d.boxInitialized,
      boxMin: d.box.min.toArray(),
      boxMax: d.box.max.toArray(),
      sphereInitialized: d.sphereInitialized,
      sphereRadius: d.sphere.radius,
      sphereCenter: d.sphere.center.toArray()
    })), l.maxInstanceCount = this._maxInstanceCount, l.maxVertexCount = this._maxVertexCount, l.maxIndexCount = this._maxIndexCount, l.geometryInitialized = this._geometryInitialized, l.geometryCount = this._geometryCount, l.matricesTexture = this._matricesTexture.toJSON(t), this._colorsTexture !== null && (l.colorsTexture = this._colorsTexture.toJSON(t)), this.boundingSphere !== null && (l.boundingSphere = {
      center: l.boundingSphere.center.toArray(),
      radius: l.boundingSphere.radius
    }), this.boundingBox !== null && (l.boundingBox = {
      min: l.boundingBox.min.toArray(),
      max: l.boundingBox.max.toArray()
    }));
    function c(d, m) {
      return d[m.uuid] === void 0 && (d[m.uuid] = m.toJSON(t)), m.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? l.background = this.background.toJSON() : this.background.isTexture && (l.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (l.environment = this.environment.toJSON(t).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      l.geometry = c(t.geometries, this.geometry);
      const d = this.geometry.parameters;
      if (d !== void 0 && d.shapes !== void 0) {
        const m = d.shapes;
        if (Array.isArray(m))
          for (let p = 0, g = m.length; p < g; p++) {
            const _ = m[p];
            c(t.shapes, _);
          }
        else
          c(t.shapes, m);
      }
    }
    if (this.isSkinnedMesh && (l.bindMode = this.bindMode, l.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (c(t.skeletons, this.skeleton), l.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const d = [];
        for (let m = 0, p = this.material.length; m < p; m++)
          d.push(c(t.materials, this.material[m]));
        l.material = d;
      } else
        l.material = c(t.materials, this.material);
    if (this.children.length > 0) {
      l.children = [];
      for (let d = 0; d < this.children.length; d++)
        l.children.push(this.children[d].toJSON(t).object);
    }
    if (this.animations.length > 0) {
      l.animations = [];
      for (let d = 0; d < this.animations.length; d++) {
        const m = this.animations[d];
        l.animations.push(c(t.animations, m));
      }
    }
    if (i) {
      const d = h(t.geometries), m = h(t.materials), p = h(t.textures), g = h(t.images), _ = h(t.shapes), x = h(t.skeletons), S = h(t.animations), E = h(t.nodes);
      d.length > 0 && (s.geometries = d), m.length > 0 && (s.materials = m), p.length > 0 && (s.textures = p), g.length > 0 && (s.images = g), _.length > 0 && (s.shapes = _), x.length > 0 && (s.skeletons = x), S.length > 0 && (s.animations = S), E.length > 0 && (s.nodes = E);
    }
    return s.object = l, s;
    function h(d) {
      const m = [];
      for (const p in d) {
        const g = d[p];
        delete g.metadata, m.push(g);
      }
      return m;
    }
  }
  clone(t) {
    return new this.constructor().copy(this, t);
  }
  copy(t, i = !0) {
    if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), i === !0)
      for (let s = 0; s < t.children.length; s++) {
        const l = t.children[s];
        this.add(l.clone());
      }
    return this;
  }
}
fn.DEFAULT_UP = /* @__PURE__ */ new q(0, 1, 0);
fn.DEFAULT_MATRIX_AUTO_UPDATE = !0;
fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const Li = /* @__PURE__ */ new q(), ca = /* @__PURE__ */ new q(), jh = /* @__PURE__ */ new q(), ua = /* @__PURE__ */ new q(), Rr = /* @__PURE__ */ new q(), Cr = /* @__PURE__ */ new q(), G0 = /* @__PURE__ */ new q(), Zh = /* @__PURE__ */ new q(), Kh = /* @__PURE__ */ new q(), Qh = /* @__PURE__ */ new q(), Jh = /* @__PURE__ */ new Je(), $h = /* @__PURE__ */ new Je(), td = /* @__PURE__ */ new Je();
class Mi {
  constructor(t = new q(), i = new q(), s = new q()) {
    this.a = t, this.b = i, this.c = s;
  }
  static getNormal(t, i, s, l) {
    l.subVectors(s, i), Li.subVectors(t, i), l.cross(Li);
    const c = l.lengthSq();
    return c > 0 ? l.multiplyScalar(1 / Math.sqrt(c)) : l.set(0, 0, 0);
  }
  // static/instance method to calculate barycentric coordinates
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  static getBarycoord(t, i, s, l, c) {
    Li.subVectors(l, i), ca.subVectors(s, i), jh.subVectors(t, i);
    const h = Li.dot(Li), d = Li.dot(ca), m = Li.dot(jh), p = ca.dot(ca), g = ca.dot(jh), _ = h * p - d * d;
    if (_ === 0)
      return c.set(0, 0, 0), null;
    const x = 1 / _, S = (p * m - d * g) * x, E = (h * g - d * m) * x;
    return c.set(1 - S - E, E, S);
  }
  static containsPoint(t, i, s, l) {
    return this.getBarycoord(t, i, s, l, ua) === null ? !1 : ua.x >= 0 && ua.y >= 0 && ua.x + ua.y <= 1;
  }
  static getInterpolation(t, i, s, l, c, h, d, m) {
    return this.getBarycoord(t, i, s, l, ua) === null ? (m.x = 0, m.y = 0, "z" in m && (m.z = 0), "w" in m && (m.w = 0), null) : (m.setScalar(0), m.addScaledVector(c, ua.x), m.addScaledVector(h, ua.y), m.addScaledVector(d, ua.z), m);
  }
  static getInterpolatedAttribute(t, i, s, l, c, h) {
    return Jh.setScalar(0), $h.setScalar(0), td.setScalar(0), Jh.fromBufferAttribute(t, i), $h.fromBufferAttribute(t, s), td.fromBufferAttribute(t, l), h.setScalar(0), h.addScaledVector(Jh, c.x), h.addScaledVector($h, c.y), h.addScaledVector(td, c.z), h;
  }
  static isFrontFacing(t, i, s, l) {
    return Li.subVectors(s, i), ca.subVectors(t, i), Li.cross(ca).dot(l) < 0;
  }
  set(t, i, s) {
    return this.a.copy(t), this.b.copy(i), this.c.copy(s), this;
  }
  setFromPointsAndIndices(t, i, s, l) {
    return this.a.copy(t[i]), this.b.copy(t[s]), this.c.copy(t[l]), this;
  }
  setFromAttributeAndIndices(t, i, s, l) {
    return this.a.fromBufferAttribute(t, i), this.b.fromBufferAttribute(t, s), this.c.fromBufferAttribute(t, l), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.a.copy(t.a), this.b.copy(t.b), this.c.copy(t.c), this;
  }
  getArea() {
    return Li.subVectors(this.c, this.b), ca.subVectors(this.a, this.b), Li.cross(ca).length() * 0.5;
  }
  getMidpoint(t) {
    return t.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(t) {
    return Mi.getNormal(this.a, this.b, this.c, t);
  }
  getPlane(t) {
    return t.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(t, i) {
    return Mi.getBarycoord(t, this.a, this.b, this.c, i);
  }
  getInterpolation(t, i, s, l, c) {
    return Mi.getInterpolation(t, this.a, this.b, this.c, i, s, l, c);
  }
  containsPoint(t) {
    return Mi.containsPoint(t, this.a, this.b, this.c);
  }
  isFrontFacing(t) {
    return Mi.isFrontFacing(this.a, this.b, this.c, t);
  }
  intersectsBox(t) {
    return t.intersectsTriangle(this);
  }
  closestPointToPoint(t, i) {
    const s = this.a, l = this.b, c = this.c;
    let h, d;
    Rr.subVectors(l, s), Cr.subVectors(c, s), Zh.subVectors(t, s);
    const m = Rr.dot(Zh), p = Cr.dot(Zh);
    if (m <= 0 && p <= 0)
      return i.copy(s);
    Kh.subVectors(t, l);
    const g = Rr.dot(Kh), _ = Cr.dot(Kh);
    if (g >= 0 && _ <= g)
      return i.copy(l);
    const x = m * _ - g * p;
    if (x <= 0 && m >= 0 && g <= 0)
      return h = m / (m - g), i.copy(s).addScaledVector(Rr, h);
    Qh.subVectors(t, c);
    const S = Rr.dot(Qh), E = Cr.dot(Qh);
    if (E >= 0 && S <= E)
      return i.copy(c);
    const b = S * p - m * E;
    if (b <= 0 && p >= 0 && E <= 0)
      return d = p / (p - E), i.copy(s).addScaledVector(Cr, d);
    const M = g * E - S * _;
    if (M <= 0 && _ - g >= 0 && S - E >= 0)
      return G0.subVectors(c, l), d = (_ - g) / (_ - g + (S - E)), i.copy(l).addScaledVector(G0, d);
    const v = 1 / (M + b + x);
    return h = b * v, d = x * v, i.copy(s).addScaledVector(Rr, h).addScaledVector(Cr, d);
  }
  equals(t) {
    return t.a.equals(this.a) && t.b.equals(this.b) && t.c.equals(this.c);
  }
}
const gx = {
  aliceblue: 15792383,
  antiquewhite: 16444375,
  aqua: 65535,
  aquamarine: 8388564,
  azure: 15794175,
  beige: 16119260,
  bisque: 16770244,
  black: 0,
  blanchedalmond: 16772045,
  blue: 255,
  blueviolet: 9055202,
  brown: 10824234,
  burlywood: 14596231,
  cadetblue: 6266528,
  chartreuse: 8388352,
  chocolate: 13789470,
  coral: 16744272,
  cornflowerblue: 6591981,
  cornsilk: 16775388,
  crimson: 14423100,
  cyan: 65535,
  darkblue: 139,
  darkcyan: 35723,
  darkgoldenrod: 12092939,
  darkgray: 11119017,
  darkgreen: 25600,
  darkgrey: 11119017,
  darkkhaki: 12433259,
  darkmagenta: 9109643,
  darkolivegreen: 5597999,
  darkorange: 16747520,
  darkorchid: 10040012,
  darkred: 9109504,
  darksalmon: 15308410,
  darkseagreen: 9419919,
  darkslateblue: 4734347,
  darkslategray: 3100495,
  darkslategrey: 3100495,
  darkturquoise: 52945,
  darkviolet: 9699539,
  deeppink: 16716947,
  deepskyblue: 49151,
  dimgray: 6908265,
  dimgrey: 6908265,
  dodgerblue: 2003199,
  firebrick: 11674146,
  floralwhite: 16775920,
  forestgreen: 2263842,
  fuchsia: 16711935,
  gainsboro: 14474460,
  ghostwhite: 16316671,
  gold: 16766720,
  goldenrod: 14329120,
  gray: 8421504,
  green: 32768,
  greenyellow: 11403055,
  grey: 8421504,
  honeydew: 15794160,
  hotpink: 16738740,
  indianred: 13458524,
  indigo: 4915330,
  ivory: 16777200,
  khaki: 15787660,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  lightgoldenrodyellow: 16448210,
  lightgray: 13882323,
  lightgreen: 9498256,
  lightgrey: 13882323,
  lightpink: 16758465,
  lightsalmon: 16752762,
  lightseagreen: 2142890,
  lightskyblue: 8900346,
  lightslategray: 7833753,
  lightslategrey: 7833753,
  lightsteelblue: 11584734,
  lightyellow: 16777184,
  lime: 65280,
  limegreen: 3329330,
  linen: 16445670,
  magenta: 16711935,
  maroon: 8388608,
  mediumaquamarine: 6737322,
  mediumblue: 205,
  mediumorchid: 12211667,
  mediumpurple: 9662683,
  mediumseagreen: 3978097,
  mediumslateblue: 8087790,
  mediumspringgreen: 64154,
  mediumturquoise: 4772300,
  mediumvioletred: 13047173,
  midnightblue: 1644912,
  mintcream: 16121850,
  mistyrose: 16770273,
  moccasin: 16770229,
  navajowhite: 16768685,
  navy: 128,
  oldlace: 16643558,
  olive: 8421376,
  olivedrab: 7048739,
  orange: 16753920,
  orangered: 16729344,
  orchid: 14315734,
  palegoldenrod: 15657130,
  palegreen: 10025880,
  paleturquoise: 11529966,
  palevioletred: 14381203,
  papayawhip: 16773077,
  peachpuff: 16767673,
  peru: 13468991,
  pink: 16761035,
  plum: 14524637,
  powderblue: 11591910,
  purple: 8388736,
  rebeccapurple: 6697881,
  red: 16711680,
  rosybrown: 12357519,
  royalblue: 4286945,
  saddlebrown: 9127187,
  salmon: 16416882,
  sandybrown: 16032864,
  seagreen: 3050327,
  seashell: 16774638,
  sienna: 10506797,
  silver: 12632256,
  skyblue: 8900331,
  slateblue: 6970061,
  slategray: 7372944,
  slategrey: 7372944,
  snow: 16775930,
  springgreen: 65407,
  steelblue: 4620980,
  tan: 13808780,
  teal: 32896,
  thistle: 14204888,
  tomato: 16737095,
  turquoise: 4251856,
  violet: 15631086,
  wheat: 16113331,
  white: 16777215,
  whitesmoke: 16119285,
  yellow: 16776960,
  yellowgreen: 10145074
}, Wa = { h: 0, s: 0, l: 0 }, Nc = { h: 0, s: 0, l: 0 };
function ed(r, t, i) {
  return i < 0 && (i += 1), i > 1 && (i -= 1), i < 1 / 6 ? r + (t - r) * 6 * i : i < 1 / 2 ? t : i < 2 / 3 ? r + (t - r) * 6 * (2 / 3 - i) : r;
}
class ve {
  constructor(t, i, s) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, i, s);
  }
  set(t, i, s) {
    if (i === void 0 && s === void 0) {
      const l = t;
      l && l.isColor ? this.copy(l) : typeof l == "number" ? this.setHex(l) : typeof l == "string" && this.setStyle(l);
    } else
      this.setRGB(t, i, s);
    return this;
  }
  setScalar(t) {
    return this.r = t, this.g = t, this.b = t, this;
  }
  setHex(t, i = Si) {
    return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, De.toWorkingColorSpace(this, i), this;
  }
  setRGB(t, i, s, l = De.workingColorSpace) {
    return this.r = t, this.g = i, this.b = s, De.toWorkingColorSpace(this, l), this;
  }
  setHSL(t, i, s, l = De.workingColorSpace) {
    if (t = BM(t, 1), i = _e(i, 0, 1), s = _e(s, 0, 1), i === 0)
      this.r = this.g = this.b = s;
    else {
      const c = s <= 0.5 ? s * (1 + i) : s + i - s * i, h = 2 * s - c;
      this.r = ed(h, c, t + 1 / 3), this.g = ed(h, c, t), this.b = ed(h, c, t - 1 / 3);
    }
    return De.toWorkingColorSpace(this, l), this;
  }
  setStyle(t, i = Si) {
    function s(c) {
      c !== void 0 && parseFloat(c) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
    }
    let l;
    if (l = /^(\w+)\(([^\)]*)\)/.exec(t)) {
      let c;
      const h = l[1], d = l[2];
      switch (h) {
        case "rgb":
        case "rgba":
          if (c = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))
            return s(c[4]), this.setRGB(
              Math.min(255, parseInt(c[1], 10)) / 255,
              Math.min(255, parseInt(c[2], 10)) / 255,
              Math.min(255, parseInt(c[3], 10)) / 255,
              i
            );
          if (c = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))
            return s(c[4]), this.setRGB(
              Math.min(100, parseInt(c[1], 10)) / 100,
              Math.min(100, parseInt(c[2], 10)) / 100,
              Math.min(100, parseInt(c[3], 10)) / 100,
              i
            );
          break;
        case "hsl":
        case "hsla":
          if (c = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))
            return s(c[4]), this.setHSL(
              parseFloat(c[1]) / 360,
              parseFloat(c[2]) / 100,
              parseFloat(c[3]) / 100,
              i
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + t);
      }
    } else if (l = /^\#([A-Fa-f\d]+)$/.exec(t)) {
      const c = l[1], h = c.length;
      if (h === 3)
        return this.setRGB(
          parseInt(c.charAt(0), 16) / 15,
          parseInt(c.charAt(1), 16) / 15,
          parseInt(c.charAt(2), 16) / 15,
          i
        );
      if (h === 6)
        return this.setHex(parseInt(c, 16), i);
      console.warn("THREE.Color: Invalid hex color " + t);
    } else if (t && t.length > 0)
      return this.setColorName(t, i);
    return this;
  }
  setColorName(t, i = Si) {
    const s = gx[t.toLowerCase()];
    return s !== void 0 ? this.setHex(s, i) : console.warn("THREE.Color: Unknown color " + t), this;
  }
  clone() {
    return new this.constructor(this.r, this.g, this.b);
  }
  copy(t) {
    return this.r = t.r, this.g = t.g, this.b = t.b, this;
  }
  copySRGBToLinear(t) {
    return this.r = ma(t.r), this.g = ma(t.g), this.b = ma(t.b), this;
  }
  copyLinearToSRGB(t) {
    return this.r = qr(t.r), this.g = qr(t.g), this.b = qr(t.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(t = Si) {
    return De.fromWorkingColorSpace(Pn.copy(this), t), Math.round(_e(Pn.r * 255, 0, 255)) * 65536 + Math.round(_e(Pn.g * 255, 0, 255)) * 256 + Math.round(_e(Pn.b * 255, 0, 255));
  }
  getHexString(t = Si) {
    return ("000000" + this.getHex(t).toString(16)).slice(-6);
  }
  getHSL(t, i = De.workingColorSpace) {
    De.fromWorkingColorSpace(Pn.copy(this), i);
    const s = Pn.r, l = Pn.g, c = Pn.b, h = Math.max(s, l, c), d = Math.min(s, l, c);
    let m, p;
    const g = (d + h) / 2;
    if (d === h)
      m = 0, p = 0;
    else {
      const _ = h - d;
      switch (p = g <= 0.5 ? _ / (h + d) : _ / (2 - h - d), h) {
        case s:
          m = (l - c) / _ + (l < c ? 6 : 0);
          break;
        case l:
          m = (c - s) / _ + 2;
          break;
        case c:
          m = (s - l) / _ + 4;
          break;
      }
      m /= 6;
    }
    return t.h = m, t.s = p, t.l = g, t;
  }
  getRGB(t, i = De.workingColorSpace) {
    return De.fromWorkingColorSpace(Pn.copy(this), i), t.r = Pn.r, t.g = Pn.g, t.b = Pn.b, t;
  }
  getStyle(t = Si) {
    De.fromWorkingColorSpace(Pn.copy(this), t);
    const i = Pn.r, s = Pn.g, l = Pn.b;
    return t !== Si ? `color(${t} ${i.toFixed(3)} ${s.toFixed(3)} ${l.toFixed(3)})` : `rgb(${Math.round(i * 255)},${Math.round(s * 255)},${Math.round(l * 255)})`;
  }
  offsetHSL(t, i, s) {
    return this.getHSL(Wa), this.setHSL(Wa.h + t, Wa.s + i, Wa.l + s);
  }
  add(t) {
    return this.r += t.r, this.g += t.g, this.b += t.b, this;
  }
  addColors(t, i) {
    return this.r = t.r + i.r, this.g = t.g + i.g, this.b = t.b + i.b, this;
  }
  addScalar(t) {
    return this.r += t, this.g += t, this.b += t, this;
  }
  sub(t) {
    return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this;
  }
  multiply(t) {
    return this.r *= t.r, this.g *= t.g, this.b *= t.b, this;
  }
  multiplyScalar(t) {
    return this.r *= t, this.g *= t, this.b *= t, this;
  }
  lerp(t, i) {
    return this.r += (t.r - this.r) * i, this.g += (t.g - this.g) * i, this.b += (t.b - this.b) * i, this;
  }
  lerpColors(t, i, s) {
    return this.r = t.r + (i.r - t.r) * s, this.g = t.g + (i.g - t.g) * s, this.b = t.b + (i.b - t.b) * s, this;
  }
  lerpHSL(t, i) {
    this.getHSL(Wa), t.getHSL(Nc);
    const s = Ih(Wa.h, Nc.h, i), l = Ih(Wa.s, Nc.s, i), c = Ih(Wa.l, Nc.l, i);
    return this.setHSL(s, l, c), this;
  }
  setFromVector3(t) {
    return this.r = t.x, this.g = t.y, this.b = t.z, this;
  }
  applyMatrix3(t) {
    const i = this.r, s = this.g, l = this.b, c = t.elements;
    return this.r = c[0] * i + c[3] * s + c[6] * l, this.g = c[1] * i + c[4] * s + c[7] * l, this.b = c[2] * i + c[5] * s + c[8] * l, this;
  }
  equals(t) {
    return t.r === this.r && t.g === this.g && t.b === this.b;
  }
  fromArray(t, i = 0) {
    return this.r = t[i], this.g = t[i + 1], this.b = t[i + 2], this;
  }
  toArray(t = [], i = 0) {
    return t[i] = this.r, t[i + 1] = this.g, t[i + 2] = this.b, t;
  }
  fromBufferAttribute(t, i) {
    return this.r = t.getX(i), this.g = t.getY(i), this.b = t.getZ(i), this;
  }
  toJSON() {
    return this.getHex();
  }
  *[Symbol.iterator]() {
    yield this.r, yield this.g, yield this.b;
  }
}
const Pn = /* @__PURE__ */ new ve();
ve.NAMES = gx;
let nE = 0;
class Fs extends Bs {
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: nE++ }), this.uuid = $a(), this.name = "", this.type = "Material", this.blending = Wr, this.side = ts, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = Md, this.blendDst = Ed, this.blendEquation = ws, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new ve(0, 0, 0), this.blendAlpha = 0, this.depthFunc = jr, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = C0, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = xr, this.stencilZFail = xr, this.stencilZPass = xr, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaToCoverage = !1, this.premultipliedAlpha = !1, this.forceSinglePass = !1, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0;
  }
  get alphaTest() {
    return this._alphaTest;
  }
  set alphaTest(t) {
    this._alphaTest > 0 != t > 0 && this.version++, this._alphaTest = t;
  }
  // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
  onBeforeRender() {
  }
  onBeforeCompile() {
  }
  customProgramCacheKey() {
    return this.onBeforeCompile.toString();
  }
  setValues(t) {
    if (t !== void 0)
      for (const i in t) {
        const s = t[i];
        if (s === void 0) {
          console.warn(`THREE.Material: parameter '${i}' has value of undefined.`);
          continue;
        }
        const l = this[i];
        if (l === void 0) {
          console.warn(`THREE.Material: '${i}' is not a property of THREE.${this.type}.`);
          continue;
        }
        l && l.isColor ? l.set(s) : l && l.isVector3 && s && s.isVector3 ? l.copy(s) : this[i] = s;
      }
  }
  toJSON(t) {
    const i = t === void 0 || typeof t == "string";
    i && (t = {
      textures: {},
      images: {}
    });
    const s = {
      metadata: {
        version: 4.6,
        type: "Material",
        generator: "Material.toJSON"
      }
    };
    s.uuid = this.uuid, s.type = this.type, this.name !== "" && (s.name = this.name), this.color && this.color.isColor && (s.color = this.color.getHex()), this.roughness !== void 0 && (s.roughness = this.roughness), this.metalness !== void 0 && (s.metalness = this.metalness), this.sheen !== void 0 && (s.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (s.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (s.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (s.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (s.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (s.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (s.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (s.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (s.shininess = this.shininess), this.clearcoat !== void 0 && (s.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (s.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (s.clearcoatMap = this.clearcoatMap.toJSON(t).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (s.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(t).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (s.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(t).uuid, s.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.dispersion !== void 0 && (s.dispersion = this.dispersion), this.iridescence !== void 0 && (s.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (s.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (s.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (s.iridescenceMap = this.iridescenceMap.toJSON(t).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (s.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(t).uuid), this.anisotropy !== void 0 && (s.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (s.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (s.anisotropyMap = this.anisotropyMap.toJSON(t).uuid), this.map && this.map.isTexture && (s.map = this.map.toJSON(t).uuid), this.matcap && this.matcap.isTexture && (s.matcap = this.matcap.toJSON(t).uuid), this.alphaMap && this.alphaMap.isTexture && (s.alphaMap = this.alphaMap.toJSON(t).uuid), this.lightMap && this.lightMap.isTexture && (s.lightMap = this.lightMap.toJSON(t).uuid, s.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (s.aoMap = this.aoMap.toJSON(t).uuid, s.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (s.bumpMap = this.bumpMap.toJSON(t).uuid, s.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (s.normalMap = this.normalMap.toJSON(t).uuid, s.normalMapType = this.normalMapType, s.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (s.displacementMap = this.displacementMap.toJSON(t).uuid, s.displacementScale = this.displacementScale, s.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (s.roughnessMap = this.roughnessMap.toJSON(t).uuid), this.metalnessMap && this.metalnessMap.isTexture && (s.metalnessMap = this.metalnessMap.toJSON(t).uuid), this.emissiveMap && this.emissiveMap.isTexture && (s.emissiveMap = this.emissiveMap.toJSON(t).uuid), this.specularMap && this.specularMap.isTexture && (s.specularMap = this.specularMap.toJSON(t).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (s.specularIntensityMap = this.specularIntensityMap.toJSON(t).uuid), this.specularColorMap && this.specularColorMap.isTexture && (s.specularColorMap = this.specularColorMap.toJSON(t).uuid), this.envMap && this.envMap.isTexture && (s.envMap = this.envMap.toJSON(t).uuid, this.combine !== void 0 && (s.combine = this.combine)), this.envMapRotation !== void 0 && (s.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (s.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (s.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (s.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (s.gradientMap = this.gradientMap.toJSON(t).uuid), this.transmission !== void 0 && (s.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (s.transmissionMap = this.transmissionMap.toJSON(t).uuid), this.thickness !== void 0 && (s.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (s.thicknessMap = this.thicknessMap.toJSON(t).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (s.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (s.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (s.size = this.size), this.shadowSide !== null && (s.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (s.sizeAttenuation = this.sizeAttenuation), this.blending !== Wr && (s.blending = this.blending), this.side !== ts && (s.side = this.side), this.vertexColors === !0 && (s.vertexColors = !0), this.opacity < 1 && (s.opacity = this.opacity), this.transparent === !0 && (s.transparent = !0), this.blendSrc !== Md && (s.blendSrc = this.blendSrc), this.blendDst !== Ed && (s.blendDst = this.blendDst), this.blendEquation !== ws && (s.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (s.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (s.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (s.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (s.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (s.blendAlpha = this.blendAlpha), this.depthFunc !== jr && (s.depthFunc = this.depthFunc), this.depthTest === !1 && (s.depthTest = this.depthTest), this.depthWrite === !1 && (s.depthWrite = this.depthWrite), this.colorWrite === !1 && (s.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (s.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== C0 && (s.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (s.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (s.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== xr && (s.stencilFail = this.stencilFail), this.stencilZFail !== xr && (s.stencilZFail = this.stencilZFail), this.stencilZPass !== xr && (s.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (s.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (s.rotation = this.rotation), this.polygonOffset === !0 && (s.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (s.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (s.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (s.linewidth = this.linewidth), this.dashSize !== void 0 && (s.dashSize = this.dashSize), this.gapSize !== void 0 && (s.gapSize = this.gapSize), this.scale !== void 0 && (s.scale = this.scale), this.dithering === !0 && (s.dithering = !0), this.alphaTest > 0 && (s.alphaTest = this.alphaTest), this.alphaHash === !0 && (s.alphaHash = !0), this.alphaToCoverage === !0 && (s.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (s.premultipliedAlpha = !0), this.forceSinglePass === !0 && (s.forceSinglePass = !0), this.wireframe === !0 && (s.wireframe = !0), this.wireframeLinewidth > 1 && (s.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (s.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (s.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (s.flatShading = !0), this.visible === !1 && (s.visible = !1), this.toneMapped === !1 && (s.toneMapped = !1), this.fog === !1 && (s.fog = !1), Object.keys(this.userData).length > 0 && (s.userData = this.userData);
    function l(c) {
      const h = [];
      for (const d in c) {
        const m = c[d];
        delete m.metadata, h.push(m);
      }
      return h;
    }
    if (i) {
      const c = l(t.textures), h = l(t.images);
      c.length > 0 && (s.textures = c), h.length > 0 && (s.images = h);
    }
    return s;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.name = t.name, this.blending = t.blending, this.side = t.side, this.vertexColors = t.vertexColors, this.opacity = t.opacity, this.transparent = t.transparent, this.blendSrc = t.blendSrc, this.blendDst = t.blendDst, this.blendEquation = t.blendEquation, this.blendSrcAlpha = t.blendSrcAlpha, this.blendDstAlpha = t.blendDstAlpha, this.blendEquationAlpha = t.blendEquationAlpha, this.blendColor.copy(t.blendColor), this.blendAlpha = t.blendAlpha, this.depthFunc = t.depthFunc, this.depthTest = t.depthTest, this.depthWrite = t.depthWrite, this.stencilWriteMask = t.stencilWriteMask, this.stencilFunc = t.stencilFunc, this.stencilRef = t.stencilRef, this.stencilFuncMask = t.stencilFuncMask, this.stencilFail = t.stencilFail, this.stencilZFail = t.stencilZFail, this.stencilZPass = t.stencilZPass, this.stencilWrite = t.stencilWrite;
    const i = t.clippingPlanes;
    let s = null;
    if (i !== null) {
      const l = i.length;
      s = new Array(l);
      for (let c = 0; c !== l; ++c)
        s[c] = i[c].clone();
    }
    return this.clippingPlanes = s, this.clipIntersection = t.clipIntersection, this.clipShadows = t.clipShadows, this.shadowSide = t.shadowSide, this.colorWrite = t.colorWrite, this.precision = t.precision, this.polygonOffset = t.polygonOffset, this.polygonOffsetFactor = t.polygonOffsetFactor, this.polygonOffsetUnits = t.polygonOffsetUnits, this.dithering = t.dithering, this.alphaTest = t.alphaTest, this.alphaHash = t.alphaHash, this.alphaToCoverage = t.alphaToCoverage, this.premultipliedAlpha = t.premultipliedAlpha, this.forceSinglePass = t.forceSinglePass, this.visible = t.visible, this.toneMapped = t.toneMapped, this.userData = JSON.parse(JSON.stringify(t.userData)), this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  onBuild() {
    console.warn("Material: onBuild() has been removed.");
  }
}
class yu extends Fs {
  constructor(t) {
    super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new ve(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Gi(), this.combine = vp, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.specularMap = t.specularMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.envMapRotation.copy(t.envMapRotation), this.combine = t.combine, this.reflectivity = t.reflectivity, this.refractionRatio = t.refractionRatio, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.fog = t.fog, this;
  }
}
const un = /* @__PURE__ */ new q(), Oc = /* @__PURE__ */ new $t();
class Mn {
  constructor(t, i, s = !1) {
    if (Array.isArray(t))
      throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
    this.isBufferAttribute = !0, this.name = "", this.array = t, this.itemSize = i, this.count = t !== void 0 ? t.length / i : 0, this.normalized = s, this.usage = Ns, this.updateRanges = [], this.gpuType = Ei, this.version = 0;
  }
  onUploadCallback() {
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  setUsage(t) {
    return this.usage = t, this;
  }
  addUpdateRange(t, i) {
    this.updateRanges.push({ start: t, count: i });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(t) {
    return this.name = t.name, this.array = new t.array.constructor(t.array), this.itemSize = t.itemSize, this.count = t.count, this.normalized = t.normalized, this.usage = t.usage, this.gpuType = t.gpuType, this;
  }
  copyAt(t, i, s) {
    t *= this.itemSize, s *= i.itemSize;
    for (let l = 0, c = this.itemSize; l < c; l++)
      this.array[t + l] = i.array[s + l];
    return this;
  }
  copyArray(t) {
    return this.array.set(t), this;
  }
  applyMatrix3(t) {
    if (this.itemSize === 2)
      for (let i = 0, s = this.count; i < s; i++)
        Oc.fromBufferAttribute(this, i), Oc.applyMatrix3(t), this.setXY(i, Oc.x, Oc.y);
    else if (this.itemSize === 3)
      for (let i = 0, s = this.count; i < s; i++)
        un.fromBufferAttribute(this, i), un.applyMatrix3(t), this.setXYZ(i, un.x, un.y, un.z);
    return this;
  }
  applyMatrix4(t) {
    for (let i = 0, s = this.count; i < s; i++)
      un.fromBufferAttribute(this, i), un.applyMatrix4(t), this.setXYZ(i, un.x, un.y, un.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let i = 0, s = this.count; i < s; i++)
      un.fromBufferAttribute(this, i), un.applyNormalMatrix(t), this.setXYZ(i, un.x, un.y, un.z);
    return this;
  }
  transformDirection(t) {
    for (let i = 0, s = this.count; i < s; i++)
      un.fromBufferAttribute(this, i), un.transformDirection(t), this.setXYZ(i, un.x, un.y, un.z);
    return this;
  }
  set(t, i = 0) {
    return this.array.set(t, i), this;
  }
  getComponent(t, i) {
    let s = this.array[t * this.itemSize + i];
    return this.normalized && (s = Fi(s, this.array)), s;
  }
  setComponent(t, i, s) {
    return this.normalized && (s = Ve(s, this.array)), this.array[t * this.itemSize + i] = s, this;
  }
  getX(t) {
    let i = this.array[t * this.itemSize];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  setX(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.array[t * this.itemSize] = i, this;
  }
  getY(t) {
    let i = this.array[t * this.itemSize + 1];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  setY(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.array[t * this.itemSize + 1] = i, this;
  }
  getZ(t) {
    let i = this.array[t * this.itemSize + 2];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  setZ(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.array[t * this.itemSize + 2] = i, this;
  }
  getW(t) {
    let i = this.array[t * this.itemSize + 3];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  setW(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.array[t * this.itemSize + 3] = i, this;
  }
  setXY(t, i, s) {
    return t *= this.itemSize, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array)), this.array[t + 0] = i, this.array[t + 1] = s, this;
  }
  setXYZ(t, i, s, l) {
    return t *= this.itemSize, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array), l = Ve(l, this.array)), this.array[t + 0] = i, this.array[t + 1] = s, this.array[t + 2] = l, this;
  }
  setXYZW(t, i, s, l, c) {
    return t *= this.itemSize, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array), l = Ve(l, this.array), c = Ve(c, this.array)), this.array[t + 0] = i, this.array[t + 1] = s, this.array[t + 2] = l, this.array[t + 3] = c, this;
  }
  onUpload(t) {
    return this.onUploadCallback = t, this;
  }
  clone() {
    return new this.constructor(this.array, this.itemSize).copy(this);
  }
  toJSON() {
    const t = {
      itemSize: this.itemSize,
      type: this.array.constructor.name,
      array: Array.from(this.array),
      normalized: this.normalized
    };
    return this.name !== "" && (t.name = this.name), this.usage !== Ns && (t.usage = this.usage), t;
  }
}
class _x extends Mn {
  constructor(t, i, s) {
    super(new Uint16Array(t), i, s);
  }
}
class vx extends Mn {
  constructor(t, i, s) {
    super(new Uint32Array(t), i, s);
  }
}
class Bn extends Mn {
  constructor(t, i, s) {
    super(new Float32Array(t), i, s);
  }
}
let iE = 0;
const yi = /* @__PURE__ */ new Xe(), nd = /* @__PURE__ */ new fn(), wr = /* @__PURE__ */ new q(), ci = /* @__PURE__ */ new Is(), el = /* @__PURE__ */ new Is(), Sn = /* @__PURE__ */ new q();
class Xn extends Bs {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: iE++ }), this.uuid = $a(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};
  }
  getIndex() {
    return this.index;
  }
  setIndex(t) {
    return Array.isArray(t) ? this.index = new (hx(t) ? vx : _x)(t, 1) : this.index = t, this;
  }
  setIndirect(t) {
    return this.indirect = t, this;
  }
  getIndirect() {
    return this.indirect;
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, i) {
    return this.attributes[t] = i, this;
  }
  deleteAttribute(t) {
    return delete this.attributes[t], this;
  }
  hasAttribute(t) {
    return this.attributes[t] !== void 0;
  }
  addGroup(t, i, s = 0) {
    this.groups.push({
      start: t,
      count: i,
      materialIndex: s
    });
  }
  clearGroups() {
    this.groups = [];
  }
  setDrawRange(t, i) {
    this.drawRange.start = t, this.drawRange.count = i;
  }
  applyMatrix4(t) {
    const i = this.attributes.position;
    i !== void 0 && (i.applyMatrix4(t), i.needsUpdate = !0);
    const s = this.attributes.normal;
    if (s !== void 0) {
      const c = new ue().getNormalMatrix(t);
      s.applyNormalMatrix(c), s.needsUpdate = !0;
    }
    const l = this.attributes.tangent;
    return l !== void 0 && (l.transformDirection(t), l.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  applyQuaternion(t) {
    return yi.makeRotationFromQuaternion(t), this.applyMatrix4(yi), this;
  }
  rotateX(t) {
    return yi.makeRotationX(t), this.applyMatrix4(yi), this;
  }
  rotateY(t) {
    return yi.makeRotationY(t), this.applyMatrix4(yi), this;
  }
  rotateZ(t) {
    return yi.makeRotationZ(t), this.applyMatrix4(yi), this;
  }
  translate(t, i, s) {
    return yi.makeTranslation(t, i, s), this.applyMatrix4(yi), this;
  }
  scale(t, i, s) {
    return yi.makeScale(t, i, s), this.applyMatrix4(yi), this;
  }
  lookAt(t) {
    return nd.lookAt(t), nd.updateMatrix(), this.applyMatrix4(nd.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(wr).negate(), this.translate(wr.x, wr.y, wr.z), this;
  }
  setFromPoints(t) {
    const i = this.getAttribute("position");
    if (i === void 0) {
      const s = [];
      for (let l = 0, c = t.length; l < c; l++) {
        const h = t[l];
        s.push(h.x, h.y, h.z || 0);
      }
      this.setAttribute("position", new Bn(s, 3));
    } else {
      const s = Math.min(t.length, i.count);
      for (let l = 0; l < s; l++) {
        const c = t[l];
        i.setXYZ(l, c.x, c.y, c.z || 0);
      }
      t.length > i.count && console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), i.needsUpdate = !0;
    }
    return this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new Is());
    const t = this.attributes.position, i = this.morphAttributes.position;
    if (t && t.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(
        new q(-1 / 0, -1 / 0, -1 / 0),
        new q(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (t !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(t), i)
        for (let s = 0, l = i.length; s < l; s++) {
          const c = i[s];
          ci.setFromBufferAttribute(c), this.morphTargetsRelative ? (Sn.addVectors(this.boundingBox.min, ci.min), this.boundingBox.expandByPoint(Sn), Sn.addVectors(this.boundingBox.max, ci.max), this.boundingBox.expandByPoint(Sn)) : (this.boundingBox.expandByPoint(ci.min), this.boundingBox.expandByPoint(ci.max));
        }
    } else
      this.boundingBox.makeEmpty();
    (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
  }
  computeBoundingSphere() {
    this.boundingSphere === null && (this.boundingSphere = new eo());
    const t = this.attributes.position, i = this.morphAttributes.position;
    if (t && t.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new q(), 1 / 0);
      return;
    }
    if (t) {
      const s = this.boundingSphere.center;
      if (ci.setFromBufferAttribute(t), i)
        for (let c = 0, h = i.length; c < h; c++) {
          const d = i[c];
          el.setFromBufferAttribute(d), this.morphTargetsRelative ? (Sn.addVectors(ci.min, el.min), ci.expandByPoint(Sn), Sn.addVectors(ci.max, el.max), ci.expandByPoint(Sn)) : (ci.expandByPoint(el.min), ci.expandByPoint(el.max));
        }
      ci.getCenter(s);
      let l = 0;
      for (let c = 0, h = t.count; c < h; c++)
        Sn.fromBufferAttribute(t, c), l = Math.max(l, s.distanceToSquared(Sn));
      if (i)
        for (let c = 0, h = i.length; c < h; c++) {
          const d = i[c], m = this.morphTargetsRelative;
          for (let p = 0, g = d.count; p < g; p++)
            Sn.fromBufferAttribute(d, p), m && (wr.fromBufferAttribute(t, p), Sn.add(wr)), l = Math.max(l, s.distanceToSquared(Sn));
        }
      this.boundingSphere.radius = Math.sqrt(l), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
    }
  }
  computeTangents() {
    const t = this.index, i = this.attributes;
    if (t === null || i.position === void 0 || i.normal === void 0 || i.uv === void 0) {
      console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
      return;
    }
    const s = i.position, l = i.normal, c = i.uv;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Mn(new Float32Array(4 * s.count), 4));
    const h = this.getAttribute("tangent"), d = [], m = [];
    for (let G = 0; G < s.count; G++)
      d[G] = new q(), m[G] = new q();
    const p = new q(), g = new q(), _ = new q(), x = new $t(), S = new $t(), E = new $t(), b = new q(), M = new q();
    function v(G, C, T) {
      p.fromBufferAttribute(s, G), g.fromBufferAttribute(s, C), _.fromBufferAttribute(s, T), x.fromBufferAttribute(c, G), S.fromBufferAttribute(c, C), E.fromBufferAttribute(c, T), g.sub(p), _.sub(p), S.sub(x), E.sub(x);
      const I = 1 / (S.x * E.y - E.x * S.y);
      isFinite(I) && (b.copy(g).multiplyScalar(E.y).addScaledVector(_, -S.y).multiplyScalar(I), M.copy(_).multiplyScalar(S.x).addScaledVector(g, -E.x).multiplyScalar(I), d[G].add(b), d[C].add(b), d[T].add(b), m[G].add(M), m[C].add(M), m[T].add(M));
    }
    let B = this.groups;
    B.length === 0 && (B = [{
      start: 0,
      count: t.count
    }]);
    for (let G = 0, C = B.length; G < C; ++G) {
      const T = B[G], I = T.start, J = T.count;
      for (let $ = I, lt = I + J; $ < lt; $ += 3)
        v(
          t.getX($ + 0),
          t.getX($ + 1),
          t.getX($ + 2)
        );
    }
    const U = new q(), w = new q(), F = new q(), L = new q();
    function O(G) {
      F.fromBufferAttribute(l, G), L.copy(F);
      const C = d[G];
      U.copy(C), U.sub(F.multiplyScalar(F.dot(C))).normalize(), w.crossVectors(L, C);
      const I = w.dot(m[G]) < 0 ? -1 : 1;
      h.setXYZW(G, U.x, U.y, U.z, I);
    }
    for (let G = 0, C = B.length; G < C; ++G) {
      const T = B[G], I = T.start, J = T.count;
      for (let $ = I, lt = I + J; $ < lt; $ += 3)
        O(t.getX($ + 0)), O(t.getX($ + 1)), O(t.getX($ + 2));
    }
  }
  computeVertexNormals() {
    const t = this.index, i = this.getAttribute("position");
    if (i !== void 0) {
      let s = this.getAttribute("normal");
      if (s === void 0)
        s = new Mn(new Float32Array(i.count * 3), 3), this.setAttribute("normal", s);
      else
        for (let x = 0, S = s.count; x < S; x++)
          s.setXYZ(x, 0, 0, 0);
      const l = new q(), c = new q(), h = new q(), d = new q(), m = new q(), p = new q(), g = new q(), _ = new q();
      if (t)
        for (let x = 0, S = t.count; x < S; x += 3) {
          const E = t.getX(x + 0), b = t.getX(x + 1), M = t.getX(x + 2);
          l.fromBufferAttribute(i, E), c.fromBufferAttribute(i, b), h.fromBufferAttribute(i, M), g.subVectors(h, c), _.subVectors(l, c), g.cross(_), d.fromBufferAttribute(s, E), m.fromBufferAttribute(s, b), p.fromBufferAttribute(s, M), d.add(g), m.add(g), p.add(g), s.setXYZ(E, d.x, d.y, d.z), s.setXYZ(b, m.x, m.y, m.z), s.setXYZ(M, p.x, p.y, p.z);
        }
      else
        for (let x = 0, S = i.count; x < S; x += 3)
          l.fromBufferAttribute(i, x + 0), c.fromBufferAttribute(i, x + 1), h.fromBufferAttribute(i, x + 2), g.subVectors(h, c), _.subVectors(l, c), g.cross(_), s.setXYZ(x + 0, g.x, g.y, g.z), s.setXYZ(x + 1, g.x, g.y, g.z), s.setXYZ(x + 2, g.x, g.y, g.z);
      this.normalizeNormals(), s.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const t = this.attributes.normal;
    for (let i = 0, s = t.count; i < s; i++)
      Sn.fromBufferAttribute(t, i), Sn.normalize(), t.setXYZ(i, Sn.x, Sn.y, Sn.z);
  }
  toNonIndexed() {
    function t(d, m) {
      const p = d.array, g = d.itemSize, _ = d.normalized, x = new p.constructor(m.length * g);
      let S = 0, E = 0;
      for (let b = 0, M = m.length; b < M; b++) {
        d.isInterleavedBufferAttribute ? S = m[b] * d.data.stride + d.offset : S = m[b] * g;
        for (let v = 0; v < g; v++)
          x[E++] = p[S++];
      }
      return new Mn(x, g, _);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const i = new Xn(), s = this.index.array, l = this.attributes;
    for (const d in l) {
      const m = l[d], p = t(m, s);
      i.setAttribute(d, p);
    }
    const c = this.morphAttributes;
    for (const d in c) {
      const m = [], p = c[d];
      for (let g = 0, _ = p.length; g < _; g++) {
        const x = p[g], S = t(x, s);
        m.push(S);
      }
      i.morphAttributes[d] = m;
    }
    i.morphTargetsRelative = this.morphTargetsRelative;
    const h = this.groups;
    for (let d = 0, m = h.length; d < m; d++) {
      const p = h[d];
      i.addGroup(p.start, p.count, p.materialIndex);
    }
    return i;
  }
  toJSON() {
    const t = {
      metadata: {
        version: 4.6,
        type: "BufferGeometry",
        generator: "BufferGeometry.toJSON"
      }
    };
    if (t.uuid = this.uuid, t.type = this.type, this.name !== "" && (t.name = this.name), Object.keys(this.userData).length > 0 && (t.userData = this.userData), this.parameters !== void 0) {
      const m = this.parameters;
      for (const p in m)
        m[p] !== void 0 && (t[p] = m[p]);
      return t;
    }
    t.data = { attributes: {} };
    const i = this.index;
    i !== null && (t.data.index = {
      type: i.array.constructor.name,
      array: Array.prototype.slice.call(i.array)
    });
    const s = this.attributes;
    for (const m in s) {
      const p = s[m];
      t.data.attributes[m] = p.toJSON(t.data);
    }
    const l = {};
    let c = !1;
    for (const m in this.morphAttributes) {
      const p = this.morphAttributes[m], g = [];
      for (let _ = 0, x = p.length; _ < x; _++) {
        const S = p[_];
        g.push(S.toJSON(t.data));
      }
      g.length > 0 && (l[m] = g, c = !0);
    }
    c && (t.data.morphAttributes = l, t.data.morphTargetsRelative = this.morphTargetsRelative);
    const h = this.groups;
    h.length > 0 && (t.data.groups = JSON.parse(JSON.stringify(h)));
    const d = this.boundingSphere;
    return d !== null && (t.data.boundingSphere = {
      center: d.center.toArray(),
      radius: d.radius
    }), t;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;
    const i = {};
    this.name = t.name;
    const s = t.index;
    s !== null && this.setIndex(s.clone(i));
    const l = t.attributes;
    for (const p in l) {
      const g = l[p];
      this.setAttribute(p, g.clone(i));
    }
    const c = t.morphAttributes;
    for (const p in c) {
      const g = [], _ = c[p];
      for (let x = 0, S = _.length; x < S; x++)
        g.push(_[x].clone(i));
      this.morphAttributes[p] = g;
    }
    this.morphTargetsRelative = t.morphTargetsRelative;
    const h = t.groups;
    for (let p = 0, g = h.length; p < g; p++) {
      const _ = h[p];
      this.addGroup(_.start, _.count, _.materialIndex);
    }
    const d = t.boundingBox;
    d !== null && (this.boundingBox = d.clone());
    const m = t.boundingSphere;
    return m !== null && (this.boundingSphere = m.clone()), this.drawRange.start = t.drawRange.start, this.drawRange.count = t.drawRange.count, this.userData = t.userData, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
const V0 = /* @__PURE__ */ new Xe(), Es = /* @__PURE__ */ new Ap(), Pc = /* @__PURE__ */ new eo(), k0 = /* @__PURE__ */ new q(), zc = /* @__PURE__ */ new q(), Bc = /* @__PURE__ */ new q(), Ic = /* @__PURE__ */ new q(), id = /* @__PURE__ */ new q(), Fc = /* @__PURE__ */ new q(), X0 = /* @__PURE__ */ new q(), Hc = /* @__PURE__ */ new q();
class Un extends fn {
  constructor(t = new Xn(), i = new yu()) {
    super(), this.isMesh = !0, this.type = "Mesh", this.geometry = t, this.material = i, this.updateMorphTargets();
  }
  copy(t, i) {
    return super.copy(t, i), t.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = t.morphTargetInfluences.slice()), t.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, t.morphTargetDictionary)), this.material = Array.isArray(t.material) ? t.material.slice() : t.material, this.geometry = t.geometry, this;
  }
  updateMorphTargets() {
    const i = this.geometry.morphAttributes, s = Object.keys(i);
    if (s.length > 0) {
      const l = i[s[0]];
      if (l !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let c = 0, h = l.length; c < h; c++) {
          const d = l[c].name || String(c);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[d] = c;
        }
      }
    }
  }
  getVertexPosition(t, i) {
    const s = this.geometry, l = s.attributes.position, c = s.morphAttributes.position, h = s.morphTargetsRelative;
    i.fromBufferAttribute(l, t);
    const d = this.morphTargetInfluences;
    if (c && d) {
      Fc.set(0, 0, 0);
      for (let m = 0, p = c.length; m < p; m++) {
        const g = d[m], _ = c[m];
        g !== 0 && (id.fromBufferAttribute(_, t), h ? Fc.addScaledVector(id, g) : Fc.addScaledVector(id.sub(i), g));
      }
      i.add(Fc);
    }
    return i;
  }
  raycast(t, i) {
    const s = this.geometry, l = this.material, c = this.matrixWorld;
    l !== void 0 && (s.boundingSphere === null && s.computeBoundingSphere(), Pc.copy(s.boundingSphere), Pc.applyMatrix4(c), Es.copy(t.ray).recast(t.near), !(Pc.containsPoint(Es.origin) === !1 && (Es.intersectSphere(Pc, k0) === null || Es.origin.distanceToSquared(k0) > (t.far - t.near) ** 2)) && (V0.copy(c).invert(), Es.copy(t.ray).applyMatrix4(V0), !(s.boundingBox !== null && Es.intersectsBox(s.boundingBox) === !1) && this._computeIntersections(t, i, Es)));
  }
  _computeIntersections(t, i, s) {
    let l;
    const c = this.geometry, h = this.material, d = c.index, m = c.attributes.position, p = c.attributes.uv, g = c.attributes.uv1, _ = c.attributes.normal, x = c.groups, S = c.drawRange;
    if (d !== null)
      if (Array.isArray(h))
        for (let E = 0, b = x.length; E < b; E++) {
          const M = x[E], v = h[M.materialIndex], B = Math.max(M.start, S.start), U = Math.min(d.count, Math.min(M.start + M.count, S.start + S.count));
          for (let w = B, F = U; w < F; w += 3) {
            const L = d.getX(w), O = d.getX(w + 1), G = d.getX(w + 2);
            l = Gc(this, v, t, s, p, g, _, L, O, G), l && (l.faceIndex = Math.floor(w / 3), l.face.materialIndex = M.materialIndex, i.push(l));
          }
        }
      else {
        const E = Math.max(0, S.start), b = Math.min(d.count, S.start + S.count);
        for (let M = E, v = b; M < v; M += 3) {
          const B = d.getX(M), U = d.getX(M + 1), w = d.getX(M + 2);
          l = Gc(this, h, t, s, p, g, _, B, U, w), l && (l.faceIndex = Math.floor(M / 3), i.push(l));
        }
      }
    else if (m !== void 0)
      if (Array.isArray(h))
        for (let E = 0, b = x.length; E < b; E++) {
          const M = x[E], v = h[M.materialIndex], B = Math.max(M.start, S.start), U = Math.min(m.count, Math.min(M.start + M.count, S.start + S.count));
          for (let w = B, F = U; w < F; w += 3) {
            const L = w, O = w + 1, G = w + 2;
            l = Gc(this, v, t, s, p, g, _, L, O, G), l && (l.faceIndex = Math.floor(w / 3), l.face.materialIndex = M.materialIndex, i.push(l));
          }
        }
      else {
        const E = Math.max(0, S.start), b = Math.min(m.count, S.start + S.count);
        for (let M = E, v = b; M < v; M += 3) {
          const B = M, U = M + 1, w = M + 2;
          l = Gc(this, h, t, s, p, g, _, B, U, w), l && (l.faceIndex = Math.floor(M / 3), i.push(l));
        }
      }
  }
}
function aE(r, t, i, s, l, c, h, d) {
  let m;
  if (t.side === ti ? m = s.intersectTriangle(h, c, l, !0, d) : m = s.intersectTriangle(l, c, h, t.side === ts, d), m === null) return null;
  Hc.copy(d), Hc.applyMatrix4(r.matrixWorld);
  const p = i.ray.origin.distanceTo(Hc);
  return p < i.near || p > i.far ? null : {
    distance: p,
    point: Hc.clone(),
    object: r
  };
}
function Gc(r, t, i, s, l, c, h, d, m, p) {
  r.getVertexPosition(d, zc), r.getVertexPosition(m, Bc), r.getVertexPosition(p, Ic);
  const g = aE(r, t, i, s, zc, Bc, Ic, X0);
  if (g) {
    const _ = new q();
    Mi.getBarycoord(X0, zc, Bc, Ic, _), l && (g.uv = Mi.getInterpolatedAttribute(l, d, m, p, _, new $t())), c && (g.uv1 = Mi.getInterpolatedAttribute(c, d, m, p, _, new $t())), h && (g.normal = Mi.getInterpolatedAttribute(h, d, m, p, _, new q()), g.normal.dot(s.direction) > 0 && g.normal.multiplyScalar(-1));
    const x = {
      a: d,
      b: m,
      c: p,
      normal: new q(),
      materialIndex: 0
    };
    Mi.getNormal(zc, Bc, Ic, x.normal), g.face = x, g.barycoord = _;
  }
  return g;
}
class dl extends Xn {
  constructor(t = 1, i = 1, s = 1, l = 1, c = 1, h = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: t,
      height: i,
      depth: s,
      widthSegments: l,
      heightSegments: c,
      depthSegments: h
    };
    const d = this;
    l = Math.floor(l), c = Math.floor(c), h = Math.floor(h);
    const m = [], p = [], g = [], _ = [];
    let x = 0, S = 0;
    E("z", "y", "x", -1, -1, s, i, t, h, c, 0), E("z", "y", "x", 1, -1, s, i, -t, h, c, 1), E("x", "z", "y", 1, 1, t, s, i, l, h, 2), E("x", "z", "y", 1, -1, t, s, -i, l, h, 3), E("x", "y", "z", 1, -1, t, i, s, l, c, 4), E("x", "y", "z", -1, -1, t, i, -s, l, c, 5), this.setIndex(m), this.setAttribute("position", new Bn(p, 3)), this.setAttribute("normal", new Bn(g, 3)), this.setAttribute("uv", new Bn(_, 2));
    function E(b, M, v, B, U, w, F, L, O, G, C) {
      const T = w / O, I = F / G, J = w / 2, $ = F / 2, lt = L / 2, pt = O + 1, z = G + 1;
      let tt = 0, K = 0;
      const yt = new q();
      for (let Mt = 0; Mt < z; Mt++) {
        const P = Mt * I - $;
        for (let st = 0; st < pt; st++) {
          const xt = st * T - J;
          yt[b] = xt * B, yt[M] = P * U, yt[v] = lt, p.push(yt.x, yt.y, yt.z), yt[b] = 0, yt[M] = 0, yt[v] = L > 0 ? 1 : -1, g.push(yt.x, yt.y, yt.z), _.push(st / O), _.push(1 - Mt / G), tt += 1;
        }
      }
      for (let Mt = 0; Mt < G; Mt++)
        for (let P = 0; P < O; P++) {
          const st = x + P + pt * Mt, xt = x + P + pt * (Mt + 1), j = x + (P + 1) + pt * (Mt + 1), ht = x + (P + 1) + pt * Mt;
          m.push(st, xt, ht), m.push(xt, j, ht), K += 6;
        }
      d.addGroup(S, K, C), S += K, x += tt;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new dl(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments);
  }
}
function to(r) {
  const t = {};
  for (const i in r) {
    t[i] = {};
    for (const s in r[i]) {
      const l = r[i][s];
      l && (l.isColor || l.isMatrix3 || l.isMatrix4 || l.isVector2 || l.isVector3 || l.isVector4 || l.isTexture || l.isQuaternion) ? l.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[i][s] = null) : t[i][s] = l.clone() : Array.isArray(l) ? t[i][s] = l.slice() : t[i][s] = l;
    }
  }
  return t;
}
function Vn(r) {
  const t = {};
  for (let i = 0; i < r.length; i++) {
    const s = to(r[i]);
    for (const l in s)
      t[l] = s[l];
  }
  return t;
}
function sE(r) {
  const t = [];
  for (let i = 0; i < r.length; i++)
    t.push(r[i].clone());
  return t;
}
function xx(r) {
  const t = r.getRenderTarget();
  return t === null ? r.outputColorSpace : t.isXRRenderTarget === !0 ? t.texture.colorSpace : De.workingColorSpace;
}
const rE = { clone: to, merge: Vn };
var oE = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, lE = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class _a extends Fs {
  constructor(t) {
    super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = oE, this.fragmentShader = lE, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = {
      clipCullDistance: !1,
      // set to use vertex shader clipping
      multiDraw: !1
      // set to use vertex shader multi_draw / enable gl_DrawID
    }, this.defaultAttributeValues = {
      color: [1, 1, 1],
      uv: [0, 0],
      uv1: [0, 0]
    }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, t !== void 0 && this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.fragmentShader = t.fragmentShader, this.vertexShader = t.vertexShader, this.uniforms = to(t.uniforms), this.uniformsGroups = sE(t.uniformsGroups), this.defines = Object.assign({}, t.defines), this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.fog = t.fog, this.lights = t.lights, this.clipping = t.clipping, this.extensions = Object.assign({}, t.extensions), this.glslVersion = t.glslVersion, this;
  }
  toJSON(t) {
    const i = super.toJSON(t);
    i.glslVersion = this.glslVersion, i.uniforms = {};
    for (const l in this.uniforms) {
      const h = this.uniforms[l].value;
      h && h.isTexture ? i.uniforms[l] = {
        type: "t",
        value: h.toJSON(t).uuid
      } : h && h.isColor ? i.uniforms[l] = {
        type: "c",
        value: h.getHex()
      } : h && h.isVector2 ? i.uniforms[l] = {
        type: "v2",
        value: h.toArray()
      } : h && h.isVector3 ? i.uniforms[l] = {
        type: "v3",
        value: h.toArray()
      } : h && h.isVector4 ? i.uniforms[l] = {
        type: "v4",
        value: h.toArray()
      } : h && h.isMatrix3 ? i.uniforms[l] = {
        type: "m3",
        value: h.toArray()
      } : h && h.isMatrix4 ? i.uniforms[l] = {
        type: "m4",
        value: h.toArray()
      } : i.uniforms[l] = {
        value: h
      };
    }
    Object.keys(this.defines).length > 0 && (i.defines = this.defines), i.vertexShader = this.vertexShader, i.fragmentShader = this.fragmentShader, i.lights = this.lights, i.clipping = this.clipping;
    const s = {};
    for (const l in this.extensions)
      this.extensions[l] === !0 && (s[l] = !0);
    return Object.keys(s).length > 0 && (i.extensions = s), i;
  }
}
class yx extends fn {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Xe(), this.projectionMatrix = new Xe(), this.projectionMatrixInverse = new Xe(), this.coordinateSystem = pa;
  }
  copy(t, i) {
    return super.copy(t, i), this.matrixWorldInverse.copy(t.matrixWorldInverse), this.projectionMatrix.copy(t.projectionMatrix), this.projectionMatrixInverse.copy(t.projectionMatrixInverse), this.coordinateSystem = t.coordinateSystem, this;
  }
  getWorldDirection(t) {
    return super.getWorldDirection(t).negate();
  }
  updateMatrixWorld(t) {
    super.updateMatrixWorld(t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  updateWorldMatrix(t, i) {
    super.updateWorldMatrix(t, i), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Ya = /* @__PURE__ */ new q(), W0 = /* @__PURE__ */ new $t(), Y0 = /* @__PURE__ */ new $t();
class ui extends yx {
  constructor(t = 50, i = 1, s = 0.1, l = 2e3) {
    super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = t, this.zoom = 1, this.near = s, this.far = l, this.focus = 10, this.aspect = i, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix();
  }
  copy(t, i) {
    return super.copy(t, i), this.fov = t.fov, this.zoom = t.zoom, this.near = t.near, this.far = t.far, this.focus = t.focus, this.aspect = t.aspect, this.view = t.view === null ? null : Object.assign({}, t.view), this.filmGauge = t.filmGauge, this.filmOffset = t.filmOffset, this;
  }
  /**
   * Sets the FOV by focal length in respect to the current .filmGauge.
   *
   * The default film gauge is 35, so that the focal length can be specified for
   * a 35mm (full frame) camera.
   *
   * @param {number} focalLength - Values for focal length and film gauge must have the same unit.
   */
  setFocalLength(t) {
    const i = 0.5 * this.getFilmHeight() / t;
    this.fov = op * 2 * Math.atan(i), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   *
   * @returns {number}
   */
  getFocalLength() {
    const t = Math.tan(ou * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / t;
  }
  getEffectiveFOV() {
    return op * 2 * Math.atan(
      Math.tan(ou * 0.5 * this.fov) / this.zoom
    );
  }
  getFilmWidth() {
    return this.filmGauge * Math.min(this.aspect, 1);
  }
  getFilmHeight() {
    return this.filmGauge / Math.max(this.aspect, 1);
  }
  /**
   * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
   * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle.
   *
   * @param {number} distance
   * @param {Vector2} minTarget
   * @param {Vector2} maxTarget
   */
  getViewBounds(t, i, s) {
    Ya.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), i.set(Ya.x, Ya.y).multiplyScalar(-t / Ya.z), Ya.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), s.set(Ya.x, Ya.y).multiplyScalar(-t / Ya.z);
  }
  /**
   * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
   *
   * @param {number} distance
   * @param {Vector2} target - Vector2 target used to store result where x is width and y is height.
   * @returns {Vector2}
   */
  getViewSize(t, i) {
    return this.getViewBounds(t, W0, Y0), i.subVectors(Y0, W0);
  }
  /**
   * Sets an offset in a larger frustum. This is useful for multi-window or
   * multi-monitor/multi-machine setups.
   *
   * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
   * the monitors are in grid like this
   *
   *   +---+---+---+
   *   | A | B | C |
   *   +---+---+---+
   *   | D | E | F |
   *   +---+---+---+
   *
   * then for each monitor you would call it like this
   *
   *   const w = 1920;
   *   const h = 1080;
   *   const fullWidth = w * 3;
   *   const fullHeight = h * 2;
   *
   *   --A--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
   *   --B--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
   *   --C--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
   *   --D--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
   *   --E--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
   *   --F--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
   *
   *   Note there is no reason monitors have to be the same size or in a grid.
   *
   * @param {number} fullWidth
   * @param {number} fullHeight
   * @param {number} x
   * @param {number} y
   * @param {number} width
   * @param {number} height
   */
  setViewOffset(t, i, s, l, c, h) {
    this.aspect = t / i, this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = t, this.view.fullHeight = i, this.view.offsetX = s, this.view.offsetY = l, this.view.width = c, this.view.height = h, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const t = this.near;
    let i = t * Math.tan(ou * 0.5 * this.fov) / this.zoom, s = 2 * i, l = this.aspect * s, c = -0.5 * l;
    const h = this.view;
    if (this.view !== null && this.view.enabled) {
      const m = h.fullWidth, p = h.fullHeight;
      c += h.offsetX * l / m, i -= h.offsetY * s / p, l *= h.width / m, s *= h.height / p;
    }
    const d = this.filmOffset;
    d !== 0 && (c += t * d / this.getFilmWidth()), this.projectionMatrix.makePerspective(c, c + l, i, i - s, t, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(t) {
    const i = super.toJSON(t);
    return i.object.fov = this.fov, i.object.zoom = this.zoom, i.object.near = this.near, i.object.far = this.far, i.object.focus = this.focus, i.object.aspect = this.aspect, this.view !== null && (i.object.view = Object.assign({}, this.view)), i.object.filmGauge = this.filmGauge, i.object.filmOffset = this.filmOffset, i;
  }
}
const Dr = -90, Ur = 1;
class cE extends fn {
  constructor(t, i, s) {
    super(), this.type = "CubeCamera", this.renderTarget = s, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const l = new ui(Dr, Ur, t, i);
    l.layers = this.layers, this.add(l);
    const c = new ui(Dr, Ur, t, i);
    c.layers = this.layers, this.add(c);
    const h = new ui(Dr, Ur, t, i);
    h.layers = this.layers, this.add(h);
    const d = new ui(Dr, Ur, t, i);
    d.layers = this.layers, this.add(d);
    const m = new ui(Dr, Ur, t, i);
    m.layers = this.layers, this.add(m);
    const p = new ui(Dr, Ur, t, i);
    p.layers = this.layers, this.add(p);
  }
  updateCoordinateSystem() {
    const t = this.coordinateSystem, i = this.children.concat(), [s, l, c, h, d, m] = i;
    for (const p of i) this.remove(p);
    if (t === pa)
      s.up.set(0, 1, 0), s.lookAt(1, 0, 0), l.up.set(0, 1, 0), l.lookAt(-1, 0, 0), c.up.set(0, 0, -1), c.lookAt(0, 1, 0), h.up.set(0, 0, 1), h.lookAt(0, -1, 0), d.up.set(0, 1, 0), d.lookAt(0, 0, 1), m.up.set(0, 1, 0), m.lookAt(0, 0, -1);
    else if (t === hu)
      s.up.set(0, -1, 0), s.lookAt(-1, 0, 0), l.up.set(0, -1, 0), l.lookAt(1, 0, 0), c.up.set(0, 0, 1), c.lookAt(0, 1, 0), h.up.set(0, 0, -1), h.lookAt(0, -1, 0), d.up.set(0, -1, 0), d.lookAt(0, 0, 1), m.up.set(0, -1, 0), m.lookAt(0, 0, -1);
    else
      throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + t);
    for (const p of i)
      this.add(p), p.updateMatrixWorld();
  }
  update(t, i) {
    this.parent === null && this.updateMatrixWorld();
    const { renderTarget: s, activeMipmapLevel: l } = this;
    this.coordinateSystem !== t.coordinateSystem && (this.coordinateSystem = t.coordinateSystem, this.updateCoordinateSystem());
    const [c, h, d, m, p, g] = this.children, _ = t.getRenderTarget(), x = t.getActiveCubeFace(), S = t.getActiveMipmapLevel(), E = t.xr.enabled;
    t.xr.enabled = !1;
    const b = s.texture.generateMipmaps;
    s.texture.generateMipmaps = !1, t.setRenderTarget(s, 0, l), t.render(i, c), t.setRenderTarget(s, 1, l), t.render(i, h), t.setRenderTarget(s, 2, l), t.render(i, d), t.setRenderTarget(s, 3, l), t.render(i, m), t.setRenderTarget(s, 4, l), t.render(i, p), s.texture.generateMipmaps = b, t.setRenderTarget(s, 5, l), t.render(i, g), t.setRenderTarget(_, x, S), t.xr.enabled = E, s.texture.needsPMREMUpdate = !0;
  }
}
class Sx extends zn {
  constructor(t, i, s, l, c, h, d, m, p, g) {
    t = t !== void 0 ? t : [], i = i !== void 0 ? i : Zr, super(t, i, s, l, c, h, d, m, p, g), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(t) {
    this.image = t;
  }
}
class uE extends zs {
  constructor(t = 1, i = {}) {
    super(t, t, i), this.isWebGLCubeRenderTarget = !0;
    const s = { width: t, height: t, depth: 1 }, l = [s, s, s, s, s, s];
    this.texture = new Sx(l, i.mapping, i.wrapS, i.wrapT, i.magFilter, i.minFilter, i.format, i.type, i.anisotropy, i.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = i.generateMipmaps !== void 0 ? i.generateMipmaps : !1, this.texture.minFilter = i.minFilter !== void 0 ? i.minFilter : Hi;
  }
  fromEquirectangularTexture(t, i) {
    this.texture.type = i.type, this.texture.colorSpace = i.colorSpace, this.texture.generateMipmaps = i.generateMipmaps, this.texture.minFilter = i.minFilter, this.texture.magFilter = i.magFilter;
    const s = {
      uniforms: {
        tEquirect: { value: null }
      },
      vertexShader: (
        /* glsl */
        `

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`
      ),
      fragmentShader: (
        /* glsl */
        `

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`
      )
    }, l = new dl(5, 5, 5), c = new _a({
      name: "CubemapFromEquirect",
      uniforms: to(s.uniforms),
      vertexShader: s.vertexShader,
      fragmentShader: s.fragmentShader,
      side: ti,
      blending: Qa
    });
    c.uniforms.tEquirect.value = i;
    const h = new Un(l, c), d = i.minFilter;
    return i.minFilter === Ls && (i.minFilter = Hi), new cE(1, 10, this).update(t, h), i.minFilter = d, h.geometry.dispose(), h.material.dispose(), this;
  }
  clear(t, i, s, l) {
    const c = t.getRenderTarget();
    for (let h = 0; h < 6; h++)
      t.setRenderTarget(this, h), t.clear(i, s, l);
    t.setRenderTarget(c);
  }
}
class Mx extends fn {
  constructor() {
    super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new Gi(), this.environmentIntensity = 1, this.environmentRotation = new Gi(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  copy(t, i) {
    return super.copy(t, i), t.background !== null && (this.background = t.background.clone()), t.environment !== null && (this.environment = t.environment.clone()), t.fog !== null && (this.fog = t.fog.clone()), this.backgroundBlurriness = t.backgroundBlurriness, this.backgroundIntensity = t.backgroundIntensity, this.backgroundRotation.copy(t.backgroundRotation), this.environmentIntensity = t.environmentIntensity, this.environmentRotation.copy(t.environmentRotation), t.overrideMaterial !== null && (this.overrideMaterial = t.overrideMaterial.clone()), this.matrixAutoUpdate = t.matrixAutoUpdate, this;
  }
  toJSON(t) {
    const i = super.toJSON(t);
    return this.fog !== null && (i.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (i.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (i.object.backgroundIntensity = this.backgroundIntensity), i.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (i.object.environmentIntensity = this.environmentIntensity), i.object.environmentRotation = this.environmentRotation.toArray(), i;
  }
}
class fE {
  constructor(t, i) {
    this.isInterleavedBuffer = !0, this.array = t, this.stride = i, this.count = t !== void 0 ? t.length / i : 0, this.usage = Ns, this.updateRanges = [], this.version = 0, this.uuid = $a();
  }
  onUploadCallback() {
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  setUsage(t) {
    return this.usage = t, this;
  }
  addUpdateRange(t, i) {
    this.updateRanges.push({ start: t, count: i });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(t) {
    return this.array = new t.array.constructor(t.array), this.count = t.count, this.stride = t.stride, this.usage = t.usage, this;
  }
  copyAt(t, i, s) {
    t *= this.stride, s *= i.stride;
    for (let l = 0, c = this.stride; l < c; l++)
      this.array[t + l] = i.array[s + l];
    return this;
  }
  set(t, i = 0) {
    return this.array.set(t, i), this;
  }
  clone(t) {
    t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = $a()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer);
    const i = new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]), s = new this.constructor(i, this.stride);
    return s.setUsage(this.usage), s;
  }
  onUpload(t) {
    return this.onUploadCallback = t, this;
  }
  toJSON(t) {
    return t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = $a()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), {
      uuid: this.uuid,
      buffer: this.array.buffer._uuid,
      type: this.array.constructor.name,
      stride: this.stride
    };
  }
}
const Gn = /* @__PURE__ */ new q();
class pu {
  constructor(t, i, s, l = !1) {
    this.isInterleavedBufferAttribute = !0, this.name = "", this.data = t, this.itemSize = i, this.offset = s, this.normalized = l;
  }
  get count() {
    return this.data.count;
  }
  get array() {
    return this.data.array;
  }
  set needsUpdate(t) {
    this.data.needsUpdate = t;
  }
  applyMatrix4(t) {
    for (let i = 0, s = this.data.count; i < s; i++)
      Gn.fromBufferAttribute(this, i), Gn.applyMatrix4(t), this.setXYZ(i, Gn.x, Gn.y, Gn.z);
    return this;
  }
  applyNormalMatrix(t) {
    for (let i = 0, s = this.count; i < s; i++)
      Gn.fromBufferAttribute(this, i), Gn.applyNormalMatrix(t), this.setXYZ(i, Gn.x, Gn.y, Gn.z);
    return this;
  }
  transformDirection(t) {
    for (let i = 0, s = this.count; i < s; i++)
      Gn.fromBufferAttribute(this, i), Gn.transformDirection(t), this.setXYZ(i, Gn.x, Gn.y, Gn.z);
    return this;
  }
  getComponent(t, i) {
    let s = this.array[t * this.data.stride + this.offset + i];
    return this.normalized && (s = Fi(s, this.array)), s;
  }
  setComponent(t, i, s) {
    return this.normalized && (s = Ve(s, this.array)), this.data.array[t * this.data.stride + this.offset + i] = s, this;
  }
  setX(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.data.array[t * this.data.stride + this.offset] = i, this;
  }
  setY(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.data.array[t * this.data.stride + this.offset + 1] = i, this;
  }
  setZ(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.data.array[t * this.data.stride + this.offset + 2] = i, this;
  }
  setW(t, i) {
    return this.normalized && (i = Ve(i, this.array)), this.data.array[t * this.data.stride + this.offset + 3] = i, this;
  }
  getX(t) {
    let i = this.data.array[t * this.data.stride + this.offset];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  getY(t) {
    let i = this.data.array[t * this.data.stride + this.offset + 1];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  getZ(t) {
    let i = this.data.array[t * this.data.stride + this.offset + 2];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  getW(t) {
    let i = this.data.array[t * this.data.stride + this.offset + 3];
    return this.normalized && (i = Fi(i, this.array)), i;
  }
  setXY(t, i, s) {
    return t = t * this.data.stride + this.offset, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array)), this.data.array[t + 0] = i, this.data.array[t + 1] = s, this;
  }
  setXYZ(t, i, s, l) {
    return t = t * this.data.stride + this.offset, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array), l = Ve(l, this.array)), this.data.array[t + 0] = i, this.data.array[t + 1] = s, this.data.array[t + 2] = l, this;
  }
  setXYZW(t, i, s, l, c) {
    return t = t * this.data.stride + this.offset, this.normalized && (i = Ve(i, this.array), s = Ve(s, this.array), l = Ve(l, this.array), c = Ve(c, this.array)), this.data.array[t + 0] = i, this.data.array[t + 1] = s, this.data.array[t + 2] = l, this.data.array[t + 3] = c, this;
  }
  clone(t) {
    if (t === void 0) {
      console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");
      const i = [];
      for (let s = 0; s < this.count; s++) {
        const l = s * this.data.stride + this.offset;
        for (let c = 0; c < this.itemSize; c++)
          i.push(this.data.array[l + c]);
      }
      return new Mn(new this.array.constructor(i), this.itemSize, this.normalized);
    } else
      return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.clone(t)), new pu(t.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);
  }
  toJSON(t) {
    if (t === void 0) {
      console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");
      const i = [];
      for (let s = 0; s < this.count; s++) {
        const l = s * this.data.stride + this.offset;
        for (let c = 0; c < this.itemSize; c++)
          i.push(this.data.array[l + c]);
      }
      return {
        itemSize: this.itemSize,
        type: this.array.constructor.name,
        array: i,
        normalized: this.normalized
      };
    } else
      return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.toJSON(t)), {
        isInterleavedBufferAttribute: !0,
        itemSize: this.itemSize,
        data: this.data.uuid,
        offset: this.offset,
        normalized: this.normalized
      };
  }
}
class lp extends Fs {
  constructor(t) {
    super(), this.isSpriteMaterial = !0, this.type = "SpriteMaterial", this.color = new ve(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.alphaMap = t.alphaMap, this.rotation = t.rotation, this.sizeAttenuation = t.sizeAttenuation, this.fog = t.fog, this;
  }
}
let Lr;
const nl = /* @__PURE__ */ new q(), Nr = /* @__PURE__ */ new q(), Or = /* @__PURE__ */ new q(), Pr = /* @__PURE__ */ new $t(), il = /* @__PURE__ */ new $t(), Ex = /* @__PURE__ */ new Xe(), Vc = /* @__PURE__ */ new q(), al = /* @__PURE__ */ new q(), kc = /* @__PURE__ */ new q(), q0 = /* @__PURE__ */ new $t(), ad = /* @__PURE__ */ new $t(), j0 = /* @__PURE__ */ new $t();
class sd extends fn {
  constructor(t = new lp()) {
    if (super(), this.isSprite = !0, this.type = "Sprite", Lr === void 0) {
      Lr = new Xn();
      const i = new Float32Array([
        -0.5,
        -0.5,
        0,
        0,
        0,
        0.5,
        -0.5,
        0,
        1,
        0,
        0.5,
        0.5,
        0,
        1,
        1,
        -0.5,
        0.5,
        0,
        0,
        1
      ]), s = new fE(i, 5);
      Lr.setIndex([0, 1, 2, 0, 2, 3]), Lr.setAttribute("position", new pu(s, 3, 0, !1)), Lr.setAttribute("uv", new pu(s, 2, 3, !1));
    }
    this.geometry = Lr, this.material = t, this.center = new $t(0.5, 0.5);
  }
  raycast(t, i) {
    t.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), Nr.setFromMatrixScale(this.matrixWorld), Ex.copy(t.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse, this.matrixWorld), Or.setFromMatrixPosition(this.modelViewMatrix), t.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && Nr.multiplyScalar(-Or.z);
    const s = this.material.rotation;
    let l, c;
    s !== 0 && (c = Math.cos(s), l = Math.sin(s));
    const h = this.center;
    Xc(Vc.set(-0.5, -0.5, 0), Or, h, Nr, l, c), Xc(al.set(0.5, -0.5, 0), Or, h, Nr, l, c), Xc(kc.set(0.5, 0.5, 0), Or, h, Nr, l, c), q0.set(0, 0), ad.set(1, 0), j0.set(1, 1);
    let d = t.ray.intersectTriangle(Vc, al, kc, !1, nl);
    if (d === null && (Xc(al.set(-0.5, 0.5, 0), Or, h, Nr, l, c), ad.set(0, 1), d = t.ray.intersectTriangle(Vc, kc, al, !1, nl), d === null))
      return;
    const m = t.ray.origin.distanceTo(nl);
    m < t.near || m > t.far || i.push({
      distance: m,
      point: nl.clone(),
      uv: Mi.getInterpolation(nl, Vc, al, kc, q0, ad, j0, new $t()),
      face: null,
      object: this
    });
  }
  copy(t, i) {
    return super.copy(t, i), t.center !== void 0 && this.center.copy(t.center), this.material = t.material, this;
  }
}
function Xc(r, t, i, s, l, c) {
  Pr.subVectors(r, i).addScalar(0.5).multiply(s), l !== void 0 ? (il.x = c * Pr.x - l * Pr.y, il.y = l * Pr.x + c * Pr.y) : il.copy(Pr), r.copy(t), r.x += il.x, r.y += il.y, r.applyMatrix4(Ex);
}
class cp extends zn {
  constructor(t = null, i = 1, s = 1, l, c, h, d, m, p = Dn, g = Dn, _, x) {
    super(null, h, d, m, p, g, l, c, _, x), this.isDataTexture = !0, this.image = { data: t, width: i, height: s }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class kn extends Mn {
  constructor(t, i, s, l = 1) {
    super(t, i, s), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = l;
  }
  copy(t) {
    return super.copy(t), this.meshPerAttribute = t.meshPerAttribute, this;
  }
  toJSON() {
    const t = super.toJSON();
    return t.meshPerAttribute = this.meshPerAttribute, t.isInstancedBufferAttribute = !0, t;
  }
}
const zr = /* @__PURE__ */ new Xe(), Z0 = /* @__PURE__ */ new Xe(), Wc = [], K0 = /* @__PURE__ */ new Is(), hE = /* @__PURE__ */ new Xe(), sl = /* @__PURE__ */ new Un(), rl = /* @__PURE__ */ new eo();
class Q0 extends Un {
  constructor(t, i, s) {
    super(t, i), this.isInstancedMesh = !0, this.instanceMatrix = new kn(new Float32Array(s * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = s, this.boundingBox = null, this.boundingSphere = null;
    for (let l = 0; l < s; l++)
      this.setMatrixAt(l, hE);
  }
  computeBoundingBox() {
    const t = this.geometry, i = this.count;
    this.boundingBox === null && (this.boundingBox = new Is()), t.boundingBox === null && t.computeBoundingBox(), this.boundingBox.makeEmpty();
    for (let s = 0; s < i; s++)
      this.getMatrixAt(s, zr), K0.copy(t.boundingBox).applyMatrix4(zr), this.boundingBox.union(K0);
  }
  computeBoundingSphere() {
    const t = this.geometry, i = this.count;
    this.boundingSphere === null && (this.boundingSphere = new eo()), t.boundingSphere === null && t.computeBoundingSphere(), this.boundingSphere.makeEmpty();
    for (let s = 0; s < i; s++)
      this.getMatrixAt(s, zr), rl.copy(t.boundingSphere).applyMatrix4(zr), this.boundingSphere.union(rl);
  }
  copy(t, i) {
    return super.copy(t, i), this.instanceMatrix.copy(t.instanceMatrix), t.morphTexture !== null && (this.morphTexture = t.morphTexture.clone()), t.instanceColor !== null && (this.instanceColor = t.instanceColor.clone()), this.count = t.count, t.boundingBox !== null && (this.boundingBox = t.boundingBox.clone()), t.boundingSphere !== null && (this.boundingSphere = t.boundingSphere.clone()), this;
  }
  getColorAt(t, i) {
    i.fromArray(this.instanceColor.array, t * 3);
  }
  getMatrixAt(t, i) {
    i.fromArray(this.instanceMatrix.array, t * 16);
  }
  getMorphAt(t, i) {
    const s = i.morphTargetInfluences, l = this.morphTexture.source.data.data, c = s.length + 1, h = t * c + 1;
    for (let d = 0; d < s.length; d++)
      s[d] = l[h + d];
  }
  raycast(t, i) {
    const s = this.matrixWorld, l = this.count;
    if (sl.geometry = this.geometry, sl.material = this.material, sl.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), rl.copy(this.boundingSphere), rl.applyMatrix4(s), t.ray.intersectsSphere(rl) !== !1))
      for (let c = 0; c < l; c++) {
        this.getMatrixAt(c, zr), Z0.multiplyMatrices(s, zr), sl.matrixWorld = Z0, sl.raycast(t, Wc);
        for (let h = 0, d = Wc.length; h < d; h++) {
          const m = Wc[h];
          m.instanceId = c, m.object = this, i.push(m);
        }
        Wc.length = 0;
      }
  }
  setColorAt(t, i) {
    this.instanceColor === null && (this.instanceColor = new kn(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), i.toArray(this.instanceColor.array, t * 3);
  }
  setMatrixAt(t, i) {
    i.toArray(this.instanceMatrix.array, t * 16);
  }
  setMorphAt(t, i) {
    const s = i.morphTargetInfluences, l = s.length + 1;
    this.morphTexture === null && (this.morphTexture = new cp(new Float32Array(l * this.count), l, this.count, Mp, Ei));
    const c = this.morphTexture.source.data.data;
    let h = 0;
    for (let p = 0; p < s.length; p++)
      h += s[p];
    const d = this.geometry.morphTargetsRelative ? 1 : 1 - h, m = l * t;
    c[m] = d, c.set(s, m + 1);
  }
  updateMorphTargets() {
  }
  dispose() {
    return this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null), this;
  }
}
const rd = /* @__PURE__ */ new q(), dE = /* @__PURE__ */ new q(), pE = /* @__PURE__ */ new ue();
class ja {
  constructor(t = new q(1, 0, 0), i = 0) {
    this.isPlane = !0, this.normal = t, this.constant = i;
  }
  set(t, i) {
    return this.normal.copy(t), this.constant = i, this;
  }
  setComponents(t, i, s, l) {
    return this.normal.set(t, i, s), this.constant = l, this;
  }
  setFromNormalAndCoplanarPoint(t, i) {
    return this.normal.copy(t), this.constant = -i.dot(this.normal), this;
  }
  setFromCoplanarPoints(t, i, s) {
    const l = rd.subVectors(s, i).cross(dE.subVectors(t, i)).normalize();
    return this.setFromNormalAndCoplanarPoint(l, t), this;
  }
  copy(t) {
    return this.normal.copy(t.normal), this.constant = t.constant, this;
  }
  normalize() {
    const t = 1 / this.normal.length();
    return this.normal.multiplyScalar(t), this.constant *= t, this;
  }
  negate() {
    return this.constant *= -1, this.normal.negate(), this;
  }
  distanceToPoint(t) {
    return this.normal.dot(t) + this.constant;
  }
  distanceToSphere(t) {
    return this.distanceToPoint(t.center) - t.radius;
  }
  projectPoint(t, i) {
    return i.copy(t).addScaledVector(this.normal, -this.distanceToPoint(t));
  }
  intersectLine(t, i) {
    const s = t.delta(rd), l = this.normal.dot(s);
    if (l === 0)
      return this.distanceToPoint(t.start) === 0 ? i.copy(t.start) : null;
    const c = -(t.start.dot(this.normal) + this.constant) / l;
    return c < 0 || c > 1 ? null : i.copy(t.start).addScaledVector(s, c);
  }
  intersectsLine(t) {
    const i = this.distanceToPoint(t.start), s = this.distanceToPoint(t.end);
    return i < 0 && s > 0 || s < 0 && i > 0;
  }
  intersectsBox(t) {
    return t.intersectsPlane(this);
  }
  intersectsSphere(t) {
    return t.intersectsPlane(this);
  }
  coplanarPoint(t) {
    return t.copy(this.normal).multiplyScalar(-this.constant);
  }
  applyMatrix4(t, i) {
    const s = i || pE.getNormalMatrix(t), l = this.coplanarPoint(rd).applyMatrix4(t), c = this.normal.applyMatrix3(s).normalize();
    return this.constant = -l.dot(c), this;
  }
  translate(t) {
    return this.constant -= t.dot(this.normal), this;
  }
  equals(t) {
    return t.normal.equals(this.normal) && t.constant === this.constant;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const bs = /* @__PURE__ */ new eo(), Yc = /* @__PURE__ */ new q();
class Rp {
  constructor(t = new ja(), i = new ja(), s = new ja(), l = new ja(), c = new ja(), h = new ja()) {
    this.planes = [t, i, s, l, c, h];
  }
  set(t, i, s, l, c, h) {
    const d = this.planes;
    return d[0].copy(t), d[1].copy(i), d[2].copy(s), d[3].copy(l), d[4].copy(c), d[5].copy(h), this;
  }
  copy(t) {
    const i = this.planes;
    for (let s = 0; s < 6; s++)
      i[s].copy(t.planes[s]);
    return this;
  }
  setFromProjectionMatrix(t, i = pa) {
    const s = this.planes, l = t.elements, c = l[0], h = l[1], d = l[2], m = l[3], p = l[4], g = l[5], _ = l[6], x = l[7], S = l[8], E = l[9], b = l[10], M = l[11], v = l[12], B = l[13], U = l[14], w = l[15];
    if (s[0].setComponents(m - c, x - p, M - S, w - v).normalize(), s[1].setComponents(m + c, x + p, M + S, w + v).normalize(), s[2].setComponents(m + h, x + g, M + E, w + B).normalize(), s[3].setComponents(m - h, x - g, M - E, w - B).normalize(), s[4].setComponents(m - d, x - _, M - b, w - U).normalize(), i === pa)
      s[5].setComponents(m + d, x + _, M + b, w + U).normalize();
    else if (i === hu)
      s[5].setComponents(d, _, b, U).normalize();
    else
      throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + i);
    return this;
  }
  intersectsObject(t) {
    if (t.boundingSphere !== void 0)
      t.boundingSphere === null && t.computeBoundingSphere(), bs.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);
    else {
      const i = t.geometry;
      i.boundingSphere === null && i.computeBoundingSphere(), bs.copy(i.boundingSphere).applyMatrix4(t.matrixWorld);
    }
    return this.intersectsSphere(bs);
  }
  intersectsSprite(t) {
    return bs.center.set(0, 0, 0), bs.radius = 0.7071067811865476, bs.applyMatrix4(t.matrixWorld), this.intersectsSphere(bs);
  }
  intersectsSphere(t) {
    const i = this.planes, s = t.center, l = -t.radius;
    for (let c = 0; c < 6; c++)
      if (i[c].distanceToPoint(s) < l)
        return !1;
    return !0;
  }
  intersectsBox(t) {
    const i = this.planes;
    for (let s = 0; s < 6; s++) {
      const l = i[s];
      if (Yc.x = l.normal.x > 0 ? t.max.x : t.min.x, Yc.y = l.normal.y > 0 ? t.max.y : t.min.y, Yc.z = l.normal.z > 0 ? t.max.z : t.min.z, l.distanceToPoint(Yc) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(t) {
    const i = this.planes;
    for (let s = 0; s < 6; s++)
      if (i[s].distanceToPoint(t) < 0)
        return !1;
    return !0;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Su extends Fs {
  constructor(t) {
    super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new ve(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.map = t.map, this.linewidth = t.linewidth, this.linecap = t.linecap, this.linejoin = t.linejoin, this.fog = t.fog, this;
  }
}
const mu = /* @__PURE__ */ new q(), gu = /* @__PURE__ */ new q(), J0 = /* @__PURE__ */ new Xe(), ol = /* @__PURE__ */ new Ap(), qc = /* @__PURE__ */ new eo(), od = /* @__PURE__ */ new q(), $0 = /* @__PURE__ */ new q();
class fl extends fn {
  constructor(t = new Xn(), i = new Su()) {
    super(), this.isLine = !0, this.type = "Line", this.geometry = t, this.material = i, this.updateMorphTargets();
  }
  copy(t, i) {
    return super.copy(t, i), this.material = Array.isArray(t.material) ? t.material.slice() : t.material, this.geometry = t.geometry, this;
  }
  computeLineDistances() {
    const t = this.geometry;
    if (t.index === null) {
      const i = t.attributes.position, s = [0];
      for (let l = 1, c = i.count; l < c; l++)
        mu.fromBufferAttribute(i, l - 1), gu.fromBufferAttribute(i, l), s[l] = s[l - 1], s[l] += mu.distanceTo(gu);
      t.setAttribute("lineDistance", new Bn(s, 1));
    } else
      console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
  raycast(t, i) {
    const s = this.geometry, l = this.matrixWorld, c = t.params.Line.threshold, h = s.drawRange;
    if (s.boundingSphere === null && s.computeBoundingSphere(), qc.copy(s.boundingSphere), qc.applyMatrix4(l), qc.radius += c, t.ray.intersectsSphere(qc) === !1) return;
    J0.copy(l).invert(), ol.copy(t.ray).applyMatrix4(J0);
    const d = c / ((this.scale.x + this.scale.y + this.scale.z) / 3), m = d * d, p = this.isLineSegments ? 2 : 1, g = s.index, x = s.attributes.position;
    if (g !== null) {
      const S = Math.max(0, h.start), E = Math.min(g.count, h.start + h.count);
      for (let b = S, M = E - 1; b < M; b += p) {
        const v = g.getX(b), B = g.getX(b + 1), U = jc(this, t, ol, m, v, B);
        U && i.push(U);
      }
      if (this.isLineLoop) {
        const b = g.getX(E - 1), M = g.getX(S), v = jc(this, t, ol, m, b, M);
        v && i.push(v);
      }
    } else {
      const S = Math.max(0, h.start), E = Math.min(x.count, h.start + h.count);
      for (let b = S, M = E - 1; b < M; b += p) {
        const v = jc(this, t, ol, m, b, b + 1);
        v && i.push(v);
      }
      if (this.isLineLoop) {
        const b = jc(this, t, ol, m, E - 1, S);
        b && i.push(b);
      }
    }
  }
  updateMorphTargets() {
    const i = this.geometry.morphAttributes, s = Object.keys(i);
    if (s.length > 0) {
      const l = i[s[0]];
      if (l !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let c = 0, h = l.length; c < h; c++) {
          const d = l[c].name || String(c);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[d] = c;
        }
      }
    }
  }
}
function jc(r, t, i, s, l, c) {
  const h = r.geometry.attributes.position;
  if (mu.fromBufferAttribute(h, l), gu.fromBufferAttribute(h, c), i.distanceSqToSegment(mu, gu, od, $0) > s) return;
  od.applyMatrix4(r.matrixWorld);
  const m = t.ray.origin.distanceTo(od);
  if (!(m < t.near || m > t.far))
    return {
      distance: m,
      // What do we want? intersection point on the ray or on the segment??
      // point: raycaster.ray.at( distance ),
      point: $0.clone().applyMatrix4(r.matrixWorld),
      index: l,
      face: null,
      faceIndex: null,
      barycoord: null,
      object: r
    };
}
const tv = /* @__PURE__ */ new q(), ev = /* @__PURE__ */ new q();
class mE extends fl {
  constructor(t, i) {
    super(t, i), this.isLineSegments = !0, this.type = "LineSegments";
  }
  computeLineDistances() {
    const t = this.geometry;
    if (t.index === null) {
      const i = t.attributes.position, s = [];
      for (let l = 0, c = i.count; l < c; l += 2)
        tv.fromBufferAttribute(i, l), ev.fromBufferAttribute(i, l + 1), s[l] = l === 0 ? 0 : s[l - 1], s[l + 1] = s[l] + tv.distanceTo(ev);
      t.setAttribute("lineDistance", new Bn(s, 1));
    } else
      console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
}
class Os extends fn {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
}
class gE extends zn {
  constructor(t, i, s, l, c, h, d, m, p) {
    super(t, i, s, l, c, h, d, m, p), this.isCanvasTexture = !0, this.needsUpdate = !0;
  }
}
class bx extends zn {
  constructor(t, i, s, l, c, h, d, m, p, g = Yr) {
    if (g !== Yr && g !== Jr)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    s === void 0 && g === Yr && (s = Ps), s === void 0 && g === Jr && (s = Qr), super(null, l, c, h, d, m, g, s, p), this.isDepthTexture = !0, this.image = { width: t, height: i }, this.magFilter = d !== void 0 ? d : Dn, this.minFilter = m !== void 0 ? m : Dn, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(t) {
    return super.copy(t), this.compareFunction = t.compareFunction, this;
  }
  toJSON(t) {
    const i = super.toJSON(t);
    return this.compareFunction !== null && (i.compareFunction = this.compareFunction), i;
  }
}
class pl extends Xn {
  constructor(t = 1, i = 1, s = 1, l = 32, c = 1, h = !1, d = 0, m = Math.PI * 2) {
    super(), this.type = "CylinderGeometry", this.parameters = {
      radiusTop: t,
      radiusBottom: i,
      height: s,
      radialSegments: l,
      heightSegments: c,
      openEnded: h,
      thetaStart: d,
      thetaLength: m
    };
    const p = this;
    l = Math.floor(l), c = Math.floor(c);
    const g = [], _ = [], x = [], S = [];
    let E = 0;
    const b = [], M = s / 2;
    let v = 0;
    B(), h === !1 && (t > 0 && U(!0), i > 0 && U(!1)), this.setIndex(g), this.setAttribute("position", new Bn(_, 3)), this.setAttribute("normal", new Bn(x, 3)), this.setAttribute("uv", new Bn(S, 2));
    function B() {
      const w = new q(), F = new q();
      let L = 0;
      const O = (i - t) / s;
      for (let G = 0; G <= c; G++) {
        const C = [], T = G / c, I = T * (i - t) + t;
        for (let J = 0; J <= l; J++) {
          const $ = J / l, lt = $ * m + d, pt = Math.sin(lt), z = Math.cos(lt);
          F.x = I * pt, F.y = -T * s + M, F.z = I * z, _.push(F.x, F.y, F.z), w.set(pt, O, z).normalize(), x.push(w.x, w.y, w.z), S.push($, 1 - T), C.push(E++);
        }
        b.push(C);
      }
      for (let G = 0; G < l; G++)
        for (let C = 0; C < c; C++) {
          const T = b[C][G], I = b[C + 1][G], J = b[C + 1][G + 1], $ = b[C][G + 1];
          (t > 0 || C !== 0) && (g.push(T, I, $), L += 3), (i > 0 || C !== c - 1) && (g.push(I, J, $), L += 3);
        }
      p.addGroup(v, L, 0), v += L;
    }
    function U(w) {
      const F = E, L = new $t(), O = new q();
      let G = 0;
      const C = w === !0 ? t : i, T = w === !0 ? 1 : -1;
      for (let J = 1; J <= l; J++)
        _.push(0, M * T, 0), x.push(0, T, 0), S.push(0.5, 0.5), E++;
      const I = E;
      for (let J = 0; J <= l; J++) {
        const lt = J / l * m + d, pt = Math.cos(lt), z = Math.sin(lt);
        O.x = C * z, O.y = M * T, O.z = C * pt, _.push(O.x, O.y, O.z), x.push(0, T, 0), L.x = pt * 0.5 + 0.5, L.y = z * 0.5 * T + 0.5, S.push(L.x, L.y), E++;
      }
      for (let J = 0; J < l; J++) {
        const $ = F + J, lt = I + J;
        w === !0 ? g.push(lt, lt + 1, $) : g.push(lt + 1, lt, $), G += 3;
      }
      p.addGroup(v, G, w === !0 ? 1 : 2), v += G;
    }
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new pl(t.radiusTop, t.radiusBottom, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class Cp extends pl {
  constructor(t = 1, i = 1, s = 32, l = 1, c = !1, h = 0, d = Math.PI * 2) {
    super(0, t, i, s, l, c, h, d), this.type = "ConeGeometry", this.parameters = {
      radius: t,
      height: i,
      radialSegments: s,
      heightSegments: l,
      openEnded: c,
      thetaStart: h,
      thetaLength: d
    };
  }
  static fromJSON(t) {
    return new Cp(t.radius, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength);
  }
}
class Mu extends Xn {
  constructor(t = 1, i = 1, s = 1, l = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: t,
      height: i,
      widthSegments: s,
      heightSegments: l
    };
    const c = t / 2, h = i / 2, d = Math.floor(s), m = Math.floor(l), p = d + 1, g = m + 1, _ = t / d, x = i / m, S = [], E = [], b = [], M = [];
    for (let v = 0; v < g; v++) {
      const B = v * x - h;
      for (let U = 0; U < p; U++) {
        const w = U * _ - c;
        E.push(w, -B, 0), b.push(0, 0, 1), M.push(U / d), M.push(1 - v / m);
      }
    }
    for (let v = 0; v < m; v++)
      for (let B = 0; B < d; B++) {
        const U = B + p * v, w = B + p * (v + 1), F = B + 1 + p * (v + 1), L = B + 1 + p * v;
        S.push(U, w, L), S.push(w, F, L);
      }
    this.setIndex(S), this.setAttribute("position", new Bn(E, 3)), this.setAttribute("normal", new Bn(b, 3)), this.setAttribute("uv", new Bn(M, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new Mu(t.width, t.height, t.widthSegments, t.heightSegments);
  }
}
class wp extends Xn {
  constructor(t = 1, i = 32, s = 16, l = 0, c = Math.PI * 2, h = 0, d = Math.PI) {
    super(), this.type = "SphereGeometry", this.parameters = {
      radius: t,
      widthSegments: i,
      heightSegments: s,
      phiStart: l,
      phiLength: c,
      thetaStart: h,
      thetaLength: d
    }, i = Math.max(3, Math.floor(i)), s = Math.max(2, Math.floor(s));
    const m = Math.min(h + d, Math.PI);
    let p = 0;
    const g = [], _ = new q(), x = new q(), S = [], E = [], b = [], M = [];
    for (let v = 0; v <= s; v++) {
      const B = [], U = v / s;
      let w = 0;
      v === 0 && h === 0 ? w = 0.5 / i : v === s && m === Math.PI && (w = -0.5 / i);
      for (let F = 0; F <= i; F++) {
        const L = F / i;
        _.x = -t * Math.cos(l + L * c) * Math.sin(h + U * d), _.y = t * Math.cos(h + U * d), _.z = t * Math.sin(l + L * c) * Math.sin(h + U * d), E.push(_.x, _.y, _.z), x.copy(_).normalize(), b.push(x.x, x.y, x.z), M.push(L + w, 1 - U), B.push(p++);
      }
      g.push(B);
    }
    for (let v = 0; v < s; v++)
      for (let B = 0; B < i; B++) {
        const U = g[v][B + 1], w = g[v][B], F = g[v + 1][B], L = g[v + 1][B + 1];
        (v !== 0 || h > 0) && S.push(U, w, L), (v !== s - 1 || m < Math.PI) && S.push(w, F, L);
      }
    this.setIndex(S), this.setAttribute("position", new Bn(E, 3)), this.setAttribute("normal", new Bn(b, 3)), this.setAttribute("uv", new Bn(M, 2));
  }
  copy(t) {
    return super.copy(t), this.parameters = Object.assign({}, t.parameters), this;
  }
  static fromJSON(t) {
    return new wp(t.radius, t.widthSegments, t.heightSegments, t.phiStart, t.phiLength, t.thetaStart, t.thetaLength);
  }
}
class Tx extends _a {
  constructor(t) {
    super(t), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial";
  }
}
class nv extends Fs {
  constructor(t) {
    super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new ve(16777215), this.specular = new ve(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ve(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = ux, this.normalScale = new $t(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Gi(), this.combine = vp, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.color.copy(t.color), this.specular.copy(t.specular), this.shininess = t.shininess, this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.emissive.copy(t.emissive), this.emissiveMap = t.emissiveMap, this.emissiveIntensity = t.emissiveIntensity, this.bumpMap = t.bumpMap, this.bumpScale = t.bumpScale, this.normalMap = t.normalMap, this.normalMapType = t.normalMapType, this.normalScale.copy(t.normalScale), this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this.specularMap = t.specularMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.envMapRotation.copy(t.envMapRotation), this.combine = t.combine, this.reflectivity = t.reflectivity, this.refractionRatio = t.refractionRatio, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.flatShading = t.flatShading, this.fog = t.fog, this;
  }
}
class _E extends Fs {
  constructor(t) {
    super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = RM, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.depthPacking = t.depthPacking, this.map = t.map, this.alphaMap = t.alphaMap, this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this;
  }
}
class vE extends Fs {
  constructor(t) {
    super(), this.isMeshDistanceMaterial = !0, this.type = "MeshDistanceMaterial", this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(t);
  }
  copy(t) {
    return super.copy(t), this.map = t.map, this.alphaMap = t.alphaMap, this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this;
  }
}
class Dp extends fn {
  constructor(t, i = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new ve(t), this.intensity = i;
  }
  dispose() {
  }
  copy(t, i) {
    return super.copy(t, i), this.color.copy(t.color), this.intensity = t.intensity, this;
  }
  toJSON(t) {
    const i = super.toJSON(t);
    return i.object.color = this.color.getHex(), i.object.intensity = this.intensity, this.groundColor !== void 0 && (i.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (i.object.distance = this.distance), this.angle !== void 0 && (i.object.angle = this.angle), this.decay !== void 0 && (i.object.decay = this.decay), this.penumbra !== void 0 && (i.object.penumbra = this.penumbra), this.shadow !== void 0 && (i.object.shadow = this.shadow.toJSON()), this.target !== void 0 && (i.object.target = this.target.uuid), i;
  }
}
class xE extends Dp {
  constructor(t, i, s) {
    super(t, s), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(fn.DEFAULT_UP), this.updateMatrix(), this.groundColor = new ve(i);
  }
  copy(t, i) {
    return super.copy(t, i), this.groundColor.copy(t.groundColor), this;
  }
}
const ld = /* @__PURE__ */ new Xe(), iv = /* @__PURE__ */ new q(), av = /* @__PURE__ */ new q();
class yE {
  constructor(t) {
    this.camera = t, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new $t(512, 512), this.map = null, this.mapPass = null, this.matrix = new Xe(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Rp(), this._frameExtents = new $t(1, 1), this._viewportCount = 1, this._viewports = [
      new Je(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(t) {
    const i = this.camera, s = this.matrix;
    iv.setFromMatrixPosition(t.matrixWorld), i.position.copy(iv), av.setFromMatrixPosition(t.target.matrixWorld), i.lookAt(av), i.updateMatrixWorld(), ld.multiplyMatrices(i.projectionMatrix, i.matrixWorldInverse), this._frustum.setFromProjectionMatrix(ld), s.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), s.multiply(ld);
  }
  getViewport(t) {
    return this._viewports[t];
  }
  getFrameExtents() {
    return this._frameExtents;
  }
  dispose() {
    this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();
  }
  copy(t) {
    return this.camera = t.camera.clone(), this.intensity = t.intensity, this.bias = t.bias, this.radius = t.radius, this.mapSize.copy(t.mapSize), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  toJSON() {
    const t = {};
    return this.intensity !== 1 && (t.intensity = this.intensity), this.bias !== 0 && (t.bias = this.bias), this.normalBias !== 0 && (t.normalBias = this.normalBias), this.radius !== 1 && (t.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (t.mapSize = this.mapSize.toArray()), t.camera = this.camera.toJSON(!1).object, delete t.camera.matrix, t;
  }
}
class Za extends yx {
  constructor(t = -1, i = 1, s = 1, l = -1, c = 0.1, h = 2e3) {
    super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = t, this.right = i, this.top = s, this.bottom = l, this.near = c, this.far = h, this.updateProjectionMatrix();
  }
  copy(t, i) {
    return super.copy(t, i), this.left = t.left, this.right = t.right, this.top = t.top, this.bottom = t.bottom, this.near = t.near, this.far = t.far, this.zoom = t.zoom, this.view = t.view === null ? null : Object.assign({}, t.view), this;
  }
  setViewOffset(t, i, s, l, c, h) {
    this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = t, this.view.fullHeight = i, this.view.offsetX = s, this.view.offsetY = l, this.view.width = c, this.view.height = h, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const t = (this.right - this.left) / (2 * this.zoom), i = (this.top - this.bottom) / (2 * this.zoom), s = (this.right + this.left) / 2, l = (this.top + this.bottom) / 2;
    let c = s - t, h = s + t, d = l + i, m = l - i;
    if (this.view !== null && this.view.enabled) {
      const p = (this.right - this.left) / this.view.fullWidth / this.zoom, g = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      c += p * this.view.offsetX, h = c + p * this.view.width, d -= g * this.view.offsetY, m = d - g * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(c, h, d, m, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(t) {
    const i = super.toJSON(t);
    return i.object.zoom = this.zoom, i.object.left = this.left, i.object.right = this.right, i.object.top = this.top, i.object.bottom = this.bottom, i.object.near = this.near, i.object.far = this.far, this.view !== null && (i.object.view = Object.assign({}, this.view)), i;
  }
}
class SE extends yE {
  constructor() {
    super(new Za(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class lu extends Dp {
  constructor(t, i) {
    super(t, i), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(fn.DEFAULT_UP), this.updateMatrix(), this.target = new fn(), this.shadow = new SE();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(t) {
    return super.copy(t), this.target = t.target.clone(), this.shadow = t.shadow.clone(), this;
  }
}
class ME extends Dp {
  constructor(t, i) {
    super(t, i), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class Ax extends Xn {
  constructor() {
    super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0;
  }
  copy(t) {
    return super.copy(t), this.instanceCount = t.instanceCount, this;
  }
  toJSON() {
    const t = super.toJSON();
    return t.instanceCount = this.instanceCount, t.isInstancedBufferGeometry = !0, t;
  }
}
class EE extends ui {
  constructor(t = []) {
    super(), this.isArrayCamera = !0, this.cameras = t;
  }
}
class sv {
  constructor(t = 1, i = 0, s = 0) {
    return this.radius = t, this.phi = i, this.theta = s, this;
  }
  set(t, i, s) {
    return this.radius = t, this.phi = i, this.theta = s, this;
  }
  copy(t) {
    return this.radius = t.radius, this.phi = t.phi, this.theta = t.theta, this;
  }
  // restrict phi to be between EPS and PI-EPS
  makeSafe() {
    return this.phi = _e(this.phi, 1e-6, Math.PI - 1e-6), this;
  }
  setFromVector3(t) {
    return this.setFromCartesianCoords(t.x, t.y, t.z);
  }
  setFromCartesianCoords(t, i, s) {
    return this.radius = Math.sqrt(t * t + i * i + s * s), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(t, s), this.phi = Math.acos(_e(i / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const rv = /* @__PURE__ */ new q();
let Zc, cd;
class bE extends fn {
  // dir is assumed to be normalized
  constructor(t = new q(0, 0, 1), i = new q(0, 0, 0), s = 1, l = 16776960, c = s * 0.2, h = c * 0.2) {
    super(), this.type = "ArrowHelper", Zc === void 0 && (Zc = new Xn(), Zc.setAttribute("position", new Bn([0, 0, 0, 0, 1, 0], 3)), cd = new pl(0, 0.5, 1, 5, 1), cd.translate(0, -0.5, 0)), this.position.copy(i), this.line = new fl(Zc, new Su({ color: l, toneMapped: !1 })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new Un(cd, new yu({ color: l, toneMapped: !1 })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(t), this.setLength(s, c, h);
  }
  setDirection(t) {
    if (t.y > 0.99999)
      this.quaternion.set(0, 0, 0, 1);
    else if (t.y < -0.99999)
      this.quaternion.set(1, 0, 0, 0);
    else {
      rv.set(t.z, 0, -t.x).normalize();
      const i = Math.acos(t.y);
      this.quaternion.setFromAxisAngle(rv, i);
    }
  }
  setLength(t, i = t * 0.2, s = i * 0.2) {
    this.line.scale.set(1, Math.max(1e-4, t - i), 1), this.line.updateMatrix(), this.cone.scale.set(s, i, s), this.cone.position.y = t, this.cone.updateMatrix();
  }
  setColor(t) {
    this.line.material.color.set(t), this.cone.material.color.set(t);
  }
  copy(t) {
    return super.copy(t, !1), this.line.copy(t.line), this.cone.copy(t.cone), this;
  }
  dispose() {
    this.line.geometry.dispose(), this.line.material.dispose(), this.cone.geometry.dispose(), this.cone.material.dispose();
  }
}
class TE extends Bs {
  constructor(t, i = null) {
    super(), this.object = t, this.domElement = i, this.enabled = !0, this.state = -1, this.keys = {}, this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null }, this.touches = { ONE: null, TWO: null };
  }
  connect() {
  }
  disconnect() {
  }
  dispose() {
  }
  update() {
  }
}
function ov(r, t, i, s) {
  const l = AE(s);
  switch (i) {
    // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
    case ax:
      return r * t;
    case rx:
      return r * t;
    case ox:
      return r * t * 2;
    case Mp:
      return r * t / l.components * l.byteLength;
    case Ep:
      return r * t / l.components * l.byteLength;
    case lx:
      return r * t * 2 / l.components * l.byteLength;
    case bp:
      return r * t * 2 / l.components * l.byteLength;
    case sx:
      return r * t * 3 / l.components * l.byteLength;
    case fi:
      return r * t * 4 / l.components * l.byteLength;
    case Tp:
      return r * t * 4 / l.components * l.byteLength;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
    case nu:
    case iu:
      return Math.floor((r + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case au:
    case su:
      return Math.floor((r + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
    case zd:
    case Id:
      return Math.max(r, 16) * Math.max(t, 8) / 4;
    case Pd:
    case Bd:
      return Math.max(r, 8) * Math.max(t, 8) / 2;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
    case Fd:
    case Hd:
      return Math.floor((r + 3) / 4) * Math.floor((t + 3) / 4) * 8;
    case Gd:
      return Math.floor((r + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
    case Vd:
      return Math.floor((r + 3) / 4) * Math.floor((t + 3) / 4) * 16;
    case kd:
      return Math.floor((r + 4) / 5) * Math.floor((t + 3) / 4) * 16;
    case Xd:
      return Math.floor((r + 4) / 5) * Math.floor((t + 4) / 5) * 16;
    case Wd:
      return Math.floor((r + 5) / 6) * Math.floor((t + 4) / 5) * 16;
    case Yd:
      return Math.floor((r + 5) / 6) * Math.floor((t + 5) / 6) * 16;
    case qd:
      return Math.floor((r + 7) / 8) * Math.floor((t + 4) / 5) * 16;
    case jd:
      return Math.floor((r + 7) / 8) * Math.floor((t + 5) / 6) * 16;
    case Zd:
      return Math.floor((r + 7) / 8) * Math.floor((t + 7) / 8) * 16;
    case Kd:
      return Math.floor((r + 9) / 10) * Math.floor((t + 4) / 5) * 16;
    case Qd:
      return Math.floor((r + 9) / 10) * Math.floor((t + 5) / 6) * 16;
    case Jd:
      return Math.floor((r + 9) / 10) * Math.floor((t + 7) / 8) * 16;
    case $d:
      return Math.floor((r + 9) / 10) * Math.floor((t + 9) / 10) * 16;
    case tp:
      return Math.floor((r + 11) / 12) * Math.floor((t + 9) / 10) * 16;
    case ep:
      return Math.floor((r + 11) / 12) * Math.floor((t + 11) / 12) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
    case ru:
    case np:
    case ip:
      return Math.ceil(r / 4) * Math.ceil(t / 4) * 16;
    // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
    case cx:
    case ap:
      return Math.ceil(r / 4) * Math.ceil(t / 4) * 8;
    case sp:
    case rp:
      return Math.ceil(r / 4) * Math.ceil(t / 4) * 16;
  }
  throw new Error(
    `Unable to determine texture byte length for ${i} format.`
  );
}
function AE(r) {
  switch (r) {
    case ga:
    case ex:
      return { byteLength: 1, components: 1 };
    case ul:
    case nx:
    case hl:
      return { byteLength: 2, components: 1 };
    case yp:
    case Sp:
      return { byteLength: 2, components: 4 };
    case Ps:
    case xp:
    case Ei:
      return { byteLength: 4, components: 1 };
    case ix:
      return { byteLength: 4, components: 3 };
  }
  throw new Error(`Unknown texture type ${r}.`);
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: _p
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = _p);
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
function Rx() {
  let r = null, t = !1, i = null, s = null;
  function l(c, h) {
    i(c, h), s = r.requestAnimationFrame(l);
  }
  return {
    start: function() {
      t !== !0 && i !== null && (s = r.requestAnimationFrame(l), t = !0);
    },
    stop: function() {
      r.cancelAnimationFrame(s), t = !1;
    },
    setAnimationLoop: function(c) {
      i = c;
    },
    setContext: function(c) {
      r = c;
    }
  };
}
function RE(r) {
  const t = /* @__PURE__ */ new WeakMap();
  function i(d, m) {
    const p = d.array, g = d.usage, _ = p.byteLength, x = r.createBuffer();
    r.bindBuffer(m, x), r.bufferData(m, p, g), d.onUploadCallback();
    let S;
    if (p instanceof Float32Array)
      S = r.FLOAT;
    else if (p instanceof Uint16Array)
      d.isFloat16BufferAttribute ? S = r.HALF_FLOAT : S = r.UNSIGNED_SHORT;
    else if (p instanceof Int16Array)
      S = r.SHORT;
    else if (p instanceof Uint32Array)
      S = r.UNSIGNED_INT;
    else if (p instanceof Int32Array)
      S = r.INT;
    else if (p instanceof Int8Array)
      S = r.BYTE;
    else if (p instanceof Uint8Array)
      S = r.UNSIGNED_BYTE;
    else if (p instanceof Uint8ClampedArray)
      S = r.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + p);
    return {
      buffer: x,
      type: S,
      bytesPerElement: p.BYTES_PER_ELEMENT,
      version: d.version,
      size: _
    };
  }
  function s(d, m, p) {
    const g = m.array, _ = m.updateRanges;
    if (r.bindBuffer(p, d), _.length === 0)
      r.bufferSubData(p, 0, g);
    else {
      _.sort((S, E) => S.start - E.start);
      let x = 0;
      for (let S = 1; S < _.length; S++) {
        const E = _[x], b = _[S];
        b.start <= E.start + E.count + 1 ? E.count = Math.max(
          E.count,
          b.start + b.count - E.start
        ) : (++x, _[x] = b);
      }
      _.length = x + 1;
      for (let S = 0, E = _.length; S < E; S++) {
        const b = _[S];
        r.bufferSubData(
          p,
          b.start * g.BYTES_PER_ELEMENT,
          g,
          b.start,
          b.count
        );
      }
      m.clearUpdateRanges();
    }
    m.onUploadCallback();
  }
  function l(d) {
    return d.isInterleavedBufferAttribute && (d = d.data), t.get(d);
  }
  function c(d) {
    d.isInterleavedBufferAttribute && (d = d.data);
    const m = t.get(d);
    m && (r.deleteBuffer(m.buffer), t.delete(d));
  }
  function h(d, m) {
    if (d.isInterleavedBufferAttribute && (d = d.data), d.isGLBufferAttribute) {
      const g = t.get(d);
      (!g || g.version < d.version) && t.set(d, {
        buffer: d.buffer,
        type: d.type,
        bytesPerElement: d.elementSize,
        version: d.version
      });
      return;
    }
    const p = t.get(d);
    if (p === void 0)
      t.set(d, i(d, m));
    else if (p.version < d.version) {
      if (p.size !== d.array.byteLength)
        throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");
      s(p.buffer, d, m), p.version = d.version;
    }
  }
  return {
    get: l,
    remove: c,
    update: h
  };
}
var CE = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, wE = `#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`, DE = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, UE = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, LE = `#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`, NE = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, OE = `#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`, PE = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, zE = `#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`, BE = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`, IE = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, FE = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, HE = `float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`, GE = `#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`, VE = `#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`, kE = `#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`, XE = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, WE = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, YE = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, qE = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, jE = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, ZE = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`, KE = `#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`, QE = `#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`, JE = `#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`, $E = `vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`, tb = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, eb = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, nb = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, ib = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, ab = "gl_FragColor = linearToOutputTexel( gl_FragColor );", sb = `vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`, rb = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`, ob = `#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`, lb = `#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`, cb = `#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`, ub = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`, fb = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, hb = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, db = `#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`, pb = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, mb = `#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`, gb = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, _b = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, vb = `varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`, xb = `uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`, yb = `#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`, Sb = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, Mb = `varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`, Eb = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, bb = `varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`, Tb = `PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`, Ab = `struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`, Rb = `
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`, Cb = `#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`, wb = `#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`, Db = `#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, Ub = `#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, Lb = `#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, Nb = `#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`, Ob = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, Pb = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, zb = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`, Bb = `#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, Ib = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, Fb = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, Hb = `#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`, Gb = `#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`, Vb = `#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`, kb = `#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`, Xb = `#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`, Wb = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`, Yb = `#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`, qb = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, jb = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, Zb = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, Kb = `#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`, Qb = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, Jb = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, $b = `#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`, tT = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, eT = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, nT = `vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`, iT = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, aT = `vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`, sT = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, rT = `#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`, oT = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, lT = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, cT = `#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`, uT = `#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`, fT = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`, hT = `float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`, dT = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, pT = `#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, mT = `#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`, gT = `#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`, _T = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, vT = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, xT = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, yT = `#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`, ST = `#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`, MT = `#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		#else
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`, ET = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, bT = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, TT = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`, AT = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;
const RT = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, CT = `uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, wT = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, DT = `#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, UT = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, LT = `uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, NT = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`, OT = `#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`, PT = `#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`, zT = `#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`, BT = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, IT = `uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, FT = `uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, HT = `uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, GT = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`, VT = `uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, kT = `#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, XT = `#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, WT = `#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`, YT = `#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, qT = `#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`, jT = `#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`, ZT = `#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, KT = `#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, QT = `#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`, JT = `#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, $T = `#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, t1 = `#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, e1 = `uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`, n1 = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, i1 = `#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, a1 = `uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, s1 = `uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, r1 = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, he = {
  alphahash_fragment: CE,
  alphahash_pars_fragment: wE,
  alphamap_fragment: DE,
  alphamap_pars_fragment: UE,
  alphatest_fragment: LE,
  alphatest_pars_fragment: NE,
  aomap_fragment: OE,
  aomap_pars_fragment: PE,
  batching_pars_vertex: zE,
  batching_vertex: BE,
  begin_vertex: IE,
  beginnormal_vertex: FE,
  bsdfs: HE,
  iridescence_fragment: GE,
  bumpmap_pars_fragment: VE,
  clipping_planes_fragment: kE,
  clipping_planes_pars_fragment: XE,
  clipping_planes_pars_vertex: WE,
  clipping_planes_vertex: YE,
  color_fragment: qE,
  color_pars_fragment: jE,
  color_pars_vertex: ZE,
  color_vertex: KE,
  common: QE,
  cube_uv_reflection_fragment: JE,
  defaultnormal_vertex: $E,
  displacementmap_pars_vertex: tb,
  displacementmap_vertex: eb,
  emissivemap_fragment: nb,
  emissivemap_pars_fragment: ib,
  colorspace_fragment: ab,
  colorspace_pars_fragment: sb,
  envmap_fragment: rb,
  envmap_common_pars_fragment: ob,
  envmap_pars_fragment: lb,
  envmap_pars_vertex: cb,
  envmap_physical_pars_fragment: yb,
  envmap_vertex: ub,
  fog_vertex: fb,
  fog_pars_vertex: hb,
  fog_fragment: db,
  fog_pars_fragment: pb,
  gradientmap_pars_fragment: mb,
  lightmap_pars_fragment: gb,
  lights_lambert_fragment: _b,
  lights_lambert_pars_fragment: vb,
  lights_pars_begin: xb,
  lights_toon_fragment: Sb,
  lights_toon_pars_fragment: Mb,
  lights_phong_fragment: Eb,
  lights_phong_pars_fragment: bb,
  lights_physical_fragment: Tb,
  lights_physical_pars_fragment: Ab,
  lights_fragment_begin: Rb,
  lights_fragment_maps: Cb,
  lights_fragment_end: wb,
  logdepthbuf_fragment: Db,
  logdepthbuf_pars_fragment: Ub,
  logdepthbuf_pars_vertex: Lb,
  logdepthbuf_vertex: Nb,
  map_fragment: Ob,
  map_pars_fragment: Pb,
  map_particle_fragment: zb,
  map_particle_pars_fragment: Bb,
  metalnessmap_fragment: Ib,
  metalnessmap_pars_fragment: Fb,
  morphinstance_vertex: Hb,
  morphcolor_vertex: Gb,
  morphnormal_vertex: Vb,
  morphtarget_pars_vertex: kb,
  morphtarget_vertex: Xb,
  normal_fragment_begin: Wb,
  normal_fragment_maps: Yb,
  normal_pars_fragment: qb,
  normal_pars_vertex: jb,
  normal_vertex: Zb,
  normalmap_pars_fragment: Kb,
  clearcoat_normal_fragment_begin: Qb,
  clearcoat_normal_fragment_maps: Jb,
  clearcoat_pars_fragment: $b,
  iridescence_pars_fragment: tT,
  opaque_fragment: eT,
  packing: nT,
  premultiplied_alpha_fragment: iT,
  project_vertex: aT,
  dithering_fragment: sT,
  dithering_pars_fragment: rT,
  roughnessmap_fragment: oT,
  roughnessmap_pars_fragment: lT,
  shadowmap_pars_fragment: cT,
  shadowmap_pars_vertex: uT,
  shadowmap_vertex: fT,
  shadowmask_pars_fragment: hT,
  skinbase_vertex: dT,
  skinning_pars_vertex: pT,
  skinning_vertex: mT,
  skinnormal_vertex: gT,
  specularmap_fragment: _T,
  specularmap_pars_fragment: vT,
  tonemapping_fragment: xT,
  tonemapping_pars_fragment: yT,
  transmission_fragment: ST,
  transmission_pars_fragment: MT,
  uv_pars_fragment: ET,
  uv_pars_vertex: bT,
  uv_vertex: TT,
  worldpos_vertex: AT,
  background_vert: RT,
  background_frag: CT,
  backgroundCube_vert: wT,
  backgroundCube_frag: DT,
  cube_vert: UT,
  cube_frag: LT,
  depth_vert: NT,
  depth_frag: OT,
  distanceRGBA_vert: PT,
  distanceRGBA_frag: zT,
  equirect_vert: BT,
  equirect_frag: IT,
  linedashed_vert: FT,
  linedashed_frag: HT,
  meshbasic_vert: GT,
  meshbasic_frag: VT,
  meshlambert_vert: kT,
  meshlambert_frag: XT,
  meshmatcap_vert: WT,
  meshmatcap_frag: YT,
  meshnormal_vert: qT,
  meshnormal_frag: jT,
  meshphong_vert: ZT,
  meshphong_frag: KT,
  meshphysical_vert: QT,
  meshphysical_frag: JT,
  meshtoon_vert: $T,
  meshtoon_frag: t1,
  points_vert: e1,
  points_frag: n1,
  shadow_vert: i1,
  shadow_frag: a1,
  sprite_vert: s1,
  sprite_frag: r1
}, Pt = {
  common: {
    diffuse: { value: /* @__PURE__ */ new ve(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new ue() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ue() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  envmap: {
    envMap: { value: null },
    envMapRotation: { value: /* @__PURE__ */ new ue() },
    flipEnvMap: { value: -1 },
    reflectivity: { value: 1 },
    // basic, lambert, phong
    ior: { value: 1.5 },
    // physical
    refractionRatio: { value: 0.98 }
    // basic, lambert, phong
  },
  aomap: {
    aoMap: { value: null },
    aoMapIntensity: { value: 1 },
    aoMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new ue() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new ue() },
    normalScale: { value: /* @__PURE__ */ new $t(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new ue() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new ue() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new ve(16777215) }
  },
  lights: {
    ambientLightColor: { value: [] },
    lightProbe: { value: [] },
    directionalLights: { value: [], properties: {
      direction: {},
      color: {}
    } },
    directionalLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    directionalShadowMap: { value: [] },
    directionalShadowMatrix: { value: [] },
    spotLights: { value: [], properties: {
      color: {},
      position: {},
      direction: {},
      distance: {},
      coneCos: {},
      penumbraCos: {},
      decay: {}
    } },
    spotLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    spotLightMap: { value: [] },
    spotShadowMap: { value: [] },
    spotLightMatrix: { value: [] },
    pointLights: { value: [], properties: {
      color: {},
      position: {},
      decay: {},
      distance: {}
    } },
    pointLightShadows: { value: [], properties: {
      shadowIntensity: 1,
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {},
      shadowCameraNear: {},
      shadowCameraFar: {}
    } },
    pointShadowMap: { value: [] },
    pointShadowMatrix: { value: [] },
    hemisphereLights: { value: [], properties: {
      direction: {},
      skyColor: {},
      groundColor: {}
    } },
    // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
    rectAreaLights: { value: [], properties: {
      color: {},
      position: {},
      width: {},
      height: {}
    } },
    ltc_1: { value: null },
    ltc_2: { value: null }
  },
  points: {
    diffuse: { value: /* @__PURE__ */ new ve(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ue() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new ue() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new ve(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new $t(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new ue() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new ue() },
    alphaTest: { value: 0 }
  }
}, Ii = {
  basic: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.specularmap,
      Pt.envmap,
      Pt.aomap,
      Pt.lightmap,
      Pt.fog
    ]),
    vertexShader: he.meshbasic_vert,
    fragmentShader: he.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.specularmap,
      Pt.envmap,
      Pt.aomap,
      Pt.lightmap,
      Pt.emissivemap,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      Pt.fog,
      Pt.lights,
      {
        emissive: { value: /* @__PURE__ */ new ve(0) }
      }
    ]),
    vertexShader: he.meshlambert_vert,
    fragmentShader: he.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.specularmap,
      Pt.envmap,
      Pt.aomap,
      Pt.lightmap,
      Pt.emissivemap,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      Pt.fog,
      Pt.lights,
      {
        emissive: { value: /* @__PURE__ */ new ve(0) },
        specular: { value: /* @__PURE__ */ new ve(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: he.meshphong_vert,
    fragmentShader: he.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.envmap,
      Pt.aomap,
      Pt.lightmap,
      Pt.emissivemap,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      Pt.roughnessmap,
      Pt.metalnessmap,
      Pt.fog,
      Pt.lights,
      {
        emissive: { value: /* @__PURE__ */ new ve(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
      }
    ]),
    vertexShader: he.meshphysical_vert,
    fragmentShader: he.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.aomap,
      Pt.lightmap,
      Pt.emissivemap,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      Pt.gradientmap,
      Pt.fog,
      Pt.lights,
      {
        emissive: { value: /* @__PURE__ */ new ve(0) }
      }
    ]),
    vertexShader: he.meshtoon_vert,
    fragmentShader: he.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      Pt.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: he.meshmatcap_vert,
    fragmentShader: he.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.points,
      Pt.fog
    ]),
    vertexShader: he.points_vert,
    fragmentShader: he.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: he.linedashed_vert,
    fragmentShader: he.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.displacementmap
    ]),
    vertexShader: he.depth_vert,
    fragmentShader: he.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.bumpmap,
      Pt.normalmap,
      Pt.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: he.meshnormal_vert,
    fragmentShader: he.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.sprite,
      Pt.fog
    ]),
    vertexShader: he.sprite_vert,
    fragmentShader: he.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new ue() },
      t2D: { value: null },
      backgroundIntensity: { value: 1 }
    },
    vertexShader: he.background_vert,
    fragmentShader: he.background_frag
  },
  backgroundCube: {
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 },
      backgroundBlurriness: { value: 0 },
      backgroundIntensity: { value: 1 },
      backgroundRotation: { value: /* @__PURE__ */ new ue() }
    },
    vertexShader: he.backgroundCube_vert,
    fragmentShader: he.backgroundCube_frag
  },
  cube: {
    uniforms: {
      tCube: { value: null },
      tFlip: { value: -1 },
      opacity: { value: 1 }
    },
    vertexShader: he.cube_vert,
    fragmentShader: he.cube_frag
  },
  equirect: {
    uniforms: {
      tEquirect: { value: null }
    },
    vertexShader: he.equirect_vert,
    fragmentShader: he.equirect_frag
  },
  distanceRGBA: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.common,
      Pt.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new q() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: he.distanceRGBA_vert,
    fragmentShader: he.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ Vn([
      Pt.lights,
      Pt.fog,
      {
        color: { value: /* @__PURE__ */ new ve(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: he.shadow_vert,
    fragmentShader: he.shadow_frag
  }
};
Ii.physical = {
  uniforms: /* @__PURE__ */ Vn([
    Ii.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new ue() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new ue() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new $t(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new ue() },
      dispersion: { value: 0 },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new ue() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new ue() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new ve(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new ue() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new ue() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new ue() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new $t() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new ue() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new ve(0) },
      specularColor: { value: /* @__PURE__ */ new ve(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new ue() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new ue() },
      anisotropyVector: { value: /* @__PURE__ */ new $t() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new ue() }
    }
  ]),
  vertexShader: he.meshphysical_vert,
  fragmentShader: he.meshphysical_frag
};
const Kc = { r: 0, b: 0, g: 0 }, Ts = /* @__PURE__ */ new Gi(), o1 = /* @__PURE__ */ new Xe();
function l1(r, t, i, s, l, c, h) {
  const d = new ve(0);
  let m = c === !0 ? 0 : 1, p, g, _ = null, x = 0, S = null;
  function E(U) {
    let w = U.isScene === !0 ? U.background : null;
    return w && w.isTexture && (w = (U.backgroundBlurriness > 0 ? i : t).get(w)), w;
  }
  function b(U) {
    let w = !1;
    const F = E(U);
    F === null ? v(d, m) : F && F.isColor && (v(F, 1), w = !0);
    const L = r.xr.getEnvironmentBlendMode();
    L === "additive" ? s.buffers.color.setClear(0, 0, 0, 1, h) : L === "alpha-blend" && s.buffers.color.setClear(0, 0, 0, 0, h), (r.autoClear || w) && (s.buffers.depth.setTest(!0), s.buffers.depth.setMask(!0), s.buffers.color.setMask(!0), r.clear(r.autoClearColor, r.autoClearDepth, r.autoClearStencil));
  }
  function M(U, w) {
    const F = E(w);
    F && (F.isCubeTexture || F.mapping === xu) ? (g === void 0 && (g = new Un(
      new dl(1, 1, 1),
      new _a({
        name: "BackgroundCubeMaterial",
        uniforms: to(Ii.backgroundCube.uniforms),
        vertexShader: Ii.backgroundCube.vertexShader,
        fragmentShader: Ii.backgroundCube.fragmentShader,
        side: ti,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), g.geometry.deleteAttribute("normal"), g.geometry.deleteAttribute("uv"), g.onBeforeRender = function(L, O, G) {
      this.matrixWorld.copyPosition(G.matrixWorld);
    }, Object.defineProperty(g.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), l.update(g)), Ts.copy(w.backgroundRotation), Ts.x *= -1, Ts.y *= -1, Ts.z *= -1, F.isCubeTexture && F.isRenderTargetTexture === !1 && (Ts.y *= -1, Ts.z *= -1), g.material.uniforms.envMap.value = F, g.material.uniforms.flipEnvMap.value = F.isCubeTexture && F.isRenderTargetTexture === !1 ? -1 : 1, g.material.uniforms.backgroundBlurriness.value = w.backgroundBlurriness, g.material.uniforms.backgroundIntensity.value = w.backgroundIntensity, g.material.uniforms.backgroundRotation.value.setFromMatrix4(o1.makeRotationFromEuler(Ts)), g.material.toneMapped = De.getTransfer(F.colorSpace) !== Ge, (_ !== F || x !== F.version || S !== r.toneMapping) && (g.material.needsUpdate = !0, _ = F, x = F.version, S = r.toneMapping), g.layers.enableAll(), U.unshift(g, g.geometry, g.material, 0, 0, null)) : F && F.isTexture && (p === void 0 && (p = new Un(
      new Mu(2, 2),
      new _a({
        name: "BackgroundMaterial",
        uniforms: to(Ii.background.uniforms),
        vertexShader: Ii.background.vertexShader,
        fragmentShader: Ii.background.fragmentShader,
        side: ts,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), p.geometry.deleteAttribute("normal"), Object.defineProperty(p.material, "map", {
      get: function() {
        return this.uniforms.t2D.value;
      }
    }), l.update(p)), p.material.uniforms.t2D.value = F, p.material.uniforms.backgroundIntensity.value = w.backgroundIntensity, p.material.toneMapped = De.getTransfer(F.colorSpace) !== Ge, F.matrixAutoUpdate === !0 && F.updateMatrix(), p.material.uniforms.uvTransform.value.copy(F.matrix), (_ !== F || x !== F.version || S !== r.toneMapping) && (p.material.needsUpdate = !0, _ = F, x = F.version, S = r.toneMapping), p.layers.enableAll(), U.unshift(p, p.geometry, p.material, 0, 0, null));
  }
  function v(U, w) {
    U.getRGB(Kc, xx(r)), s.buffers.color.setClear(Kc.r, Kc.g, Kc.b, w, h);
  }
  function B() {
    g !== void 0 && (g.geometry.dispose(), g.material.dispose()), p !== void 0 && (p.geometry.dispose(), p.material.dispose());
  }
  return {
    getClearColor: function() {
      return d;
    },
    setClearColor: function(U, w = 1) {
      d.set(U), m = w, v(d, m);
    },
    getClearAlpha: function() {
      return m;
    },
    setClearAlpha: function(U) {
      m = U, v(d, m);
    },
    render: b,
    addToRenderList: M,
    dispose: B
  };
}
function c1(r, t) {
  const i = r.getParameter(r.MAX_VERTEX_ATTRIBS), s = {}, l = x(null);
  let c = l, h = !1;
  function d(T, I, J, $, lt) {
    let pt = !1;
    const z = _($, J, I);
    c !== z && (c = z, p(c.object)), pt = S(T, $, J, lt), pt && E(T, $, J, lt), lt !== null && t.update(lt, r.ELEMENT_ARRAY_BUFFER), (pt || h) && (h = !1, w(T, I, J, $), lt !== null && r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, t.get(lt).buffer));
  }
  function m() {
    return r.createVertexArray();
  }
  function p(T) {
    return r.bindVertexArray(T);
  }
  function g(T) {
    return r.deleteVertexArray(T);
  }
  function _(T, I, J) {
    const $ = J.wireframe === !0;
    let lt = s[T.id];
    lt === void 0 && (lt = {}, s[T.id] = lt);
    let pt = lt[I.id];
    pt === void 0 && (pt = {}, lt[I.id] = pt);
    let z = pt[$];
    return z === void 0 && (z = x(m()), pt[$] = z), z;
  }
  function x(T) {
    const I = [], J = [], $ = [];
    for (let lt = 0; lt < i; lt++)
      I[lt] = 0, J[lt] = 0, $[lt] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: I,
      enabledAttributes: J,
      attributeDivisors: $,
      object: T,
      attributes: {},
      index: null
    };
  }
  function S(T, I, J, $) {
    const lt = c.attributes, pt = I.attributes;
    let z = 0;
    const tt = J.getAttributes();
    for (const K in tt)
      if (tt[K].location >= 0) {
        const Mt = lt[K];
        let P = pt[K];
        if (P === void 0 && (K === "instanceMatrix" && T.instanceMatrix && (P = T.instanceMatrix), K === "instanceColor" && T.instanceColor && (P = T.instanceColor)), Mt === void 0 || Mt.attribute !== P || P && Mt.data !== P.data) return !0;
        z++;
      }
    return c.attributesNum !== z || c.index !== $;
  }
  function E(T, I, J, $) {
    const lt = {}, pt = I.attributes;
    let z = 0;
    const tt = J.getAttributes();
    for (const K in tt)
      if (tt[K].location >= 0) {
        let Mt = pt[K];
        Mt === void 0 && (K === "instanceMatrix" && T.instanceMatrix && (Mt = T.instanceMatrix), K === "instanceColor" && T.instanceColor && (Mt = T.instanceColor));
        const P = {};
        P.attribute = Mt, Mt && Mt.data && (P.data = Mt.data), lt[K] = P, z++;
      }
    c.attributes = lt, c.attributesNum = z, c.index = $;
  }
  function b() {
    const T = c.newAttributes;
    for (let I = 0, J = T.length; I < J; I++)
      T[I] = 0;
  }
  function M(T) {
    v(T, 0);
  }
  function v(T, I) {
    const J = c.newAttributes, $ = c.enabledAttributes, lt = c.attributeDivisors;
    J[T] = 1, $[T] === 0 && (r.enableVertexAttribArray(T), $[T] = 1), lt[T] !== I && (r.vertexAttribDivisor(T, I), lt[T] = I);
  }
  function B() {
    const T = c.newAttributes, I = c.enabledAttributes;
    for (let J = 0, $ = I.length; J < $; J++)
      I[J] !== T[J] && (r.disableVertexAttribArray(J), I[J] = 0);
  }
  function U(T, I, J, $, lt, pt, z) {
    z === !0 ? r.vertexAttribIPointer(T, I, J, lt, pt) : r.vertexAttribPointer(T, I, J, $, lt, pt);
  }
  function w(T, I, J, $) {
    b();
    const lt = $.attributes, pt = J.getAttributes(), z = I.defaultAttributeValues;
    for (const tt in pt) {
      const K = pt[tt];
      if (K.location >= 0) {
        let yt = lt[tt];
        if (yt === void 0 && (tt === "instanceMatrix" && T.instanceMatrix && (yt = T.instanceMatrix), tt === "instanceColor" && T.instanceColor && (yt = T.instanceColor)), yt !== void 0) {
          const Mt = yt.normalized, P = yt.itemSize, st = t.get(yt);
          if (st === void 0) continue;
          const xt = st.buffer, j = st.type, ht = st.bytesPerElement, Et = j === r.INT || j === r.UNSIGNED_INT || yt.gpuType === xp;
          if (yt.isInterleavedBufferAttribute) {
            const vt = yt.data, Ht = vt.stride, Lt = yt.offset;
            if (vt.isInstancedInterleavedBuffer) {
              for (let ae = 0; ae < K.locationSize; ae++)
                v(K.location + ae, vt.meshPerAttribute);
              T.isInstancedMesh !== !0 && $._maxInstanceCount === void 0 && ($._maxInstanceCount = vt.meshPerAttribute * vt.count);
            } else
              for (let ae = 0; ae < K.locationSize; ae++)
                M(K.location + ae);
            r.bindBuffer(r.ARRAY_BUFFER, xt);
            for (let ae = 0; ae < K.locationSize; ae++)
              U(
                K.location + ae,
                P / K.locationSize,
                j,
                Mt,
                Ht * ht,
                (Lt + P / K.locationSize * ae) * ht,
                Et
              );
          } else {
            if (yt.isInstancedBufferAttribute) {
              for (let vt = 0; vt < K.locationSize; vt++)
                v(K.location + vt, yt.meshPerAttribute);
              T.isInstancedMesh !== !0 && $._maxInstanceCount === void 0 && ($._maxInstanceCount = yt.meshPerAttribute * yt.count);
            } else
              for (let vt = 0; vt < K.locationSize; vt++)
                M(K.location + vt);
            r.bindBuffer(r.ARRAY_BUFFER, xt);
            for (let vt = 0; vt < K.locationSize; vt++)
              U(
                K.location + vt,
                P / K.locationSize,
                j,
                Mt,
                P * ht,
                P / K.locationSize * vt * ht,
                Et
              );
          }
        } else if (z !== void 0) {
          const Mt = z[tt];
          if (Mt !== void 0)
            switch (Mt.length) {
              case 2:
                r.vertexAttrib2fv(K.location, Mt);
                break;
              case 3:
                r.vertexAttrib3fv(K.location, Mt);
                break;
              case 4:
                r.vertexAttrib4fv(K.location, Mt);
                break;
              default:
                r.vertexAttrib1fv(K.location, Mt);
            }
        }
      }
    }
    B();
  }
  function F() {
    G();
    for (const T in s) {
      const I = s[T];
      for (const J in I) {
        const $ = I[J];
        for (const lt in $)
          g($[lt].object), delete $[lt];
        delete I[J];
      }
      delete s[T];
    }
  }
  function L(T) {
    if (s[T.id] === void 0) return;
    const I = s[T.id];
    for (const J in I) {
      const $ = I[J];
      for (const lt in $)
        g($[lt].object), delete $[lt];
      delete I[J];
    }
    delete s[T.id];
  }
  function O(T) {
    for (const I in s) {
      const J = s[I];
      if (J[T.id] === void 0) continue;
      const $ = J[T.id];
      for (const lt in $)
        g($[lt].object), delete $[lt];
      delete J[T.id];
    }
  }
  function G() {
    C(), h = !0, c !== l && (c = l, p(c.object));
  }
  function C() {
    l.geometry = null, l.program = null, l.wireframe = !1;
  }
  return {
    setup: d,
    reset: G,
    resetDefaultState: C,
    dispose: F,
    releaseStatesOfGeometry: L,
    releaseStatesOfProgram: O,
    initAttributes: b,
    enableAttribute: M,
    disableUnusedAttributes: B
  };
}
function u1(r, t, i) {
  let s;
  function l(p) {
    s = p;
  }
  function c(p, g) {
    r.drawArrays(s, p, g), i.update(g, s, 1);
  }
  function h(p, g, _) {
    _ !== 0 && (r.drawArraysInstanced(s, p, g, _), i.update(g, s, _));
  }
  function d(p, g, _) {
    if (_ === 0) return;
    t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s, p, 0, g, 0, _);
    let S = 0;
    for (let E = 0; E < _; E++)
      S += g[E];
    i.update(S, s, 1);
  }
  function m(p, g, _, x) {
    if (_ === 0) return;
    const S = t.get("WEBGL_multi_draw");
    if (S === null)
      for (let E = 0; E < p.length; E++)
        h(p[E], g[E], x[E]);
    else {
      S.multiDrawArraysInstancedWEBGL(s, p, 0, g, 0, x, 0, _);
      let E = 0;
      for (let b = 0; b < _; b++)
        E += g[b] * x[b];
      i.update(E, s, 1);
    }
  }
  this.setMode = l, this.render = c, this.renderInstances = h, this.renderMultiDraw = d, this.renderMultiDrawInstances = m;
}
function f1(r, t, i, s) {
  let l;
  function c() {
    if (l !== void 0) return l;
    if (t.has("EXT_texture_filter_anisotropic") === !0) {
      const O = t.get("EXT_texture_filter_anisotropic");
      l = r.getParameter(O.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      l = 0;
    return l;
  }
  function h(O) {
    return !(O !== fi && s.convert(O) !== r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT));
  }
  function d(O) {
    const G = O === hl && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float"));
    return !(O !== ga && s.convert(O) !== r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
    O !== Ei && !G);
  }
  function m(O) {
    if (O === "highp") {
      if (r.getShaderPrecisionFormat(r.VERTEX_SHADER, r.HIGH_FLOAT).precision > 0 && r.getShaderPrecisionFormat(r.FRAGMENT_SHADER, r.HIGH_FLOAT).precision > 0)
        return "highp";
      O = "mediump";
    }
    return O === "mediump" && r.getShaderPrecisionFormat(r.VERTEX_SHADER, r.MEDIUM_FLOAT).precision > 0 && r.getShaderPrecisionFormat(r.FRAGMENT_SHADER, r.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
  }
  let p = i.precision !== void 0 ? i.precision : "highp";
  const g = m(p);
  g !== p && (console.warn("THREE.WebGLRenderer:", p, "not supported, using", g, "instead."), p = g);
  const _ = i.logarithmicDepthBuffer === !0, x = i.reverseDepthBuffer === !0 && t.has("EXT_clip_control"), S = r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS), E = r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS), b = r.getParameter(r.MAX_TEXTURE_SIZE), M = r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE), v = r.getParameter(r.MAX_VERTEX_ATTRIBS), B = r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS), U = r.getParameter(r.MAX_VARYING_VECTORS), w = r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS), F = E > 0, L = r.getParameter(r.MAX_SAMPLES);
  return {
    isWebGL2: !0,
    // keeping this for backwards compatibility
    getMaxAnisotropy: c,
    getMaxPrecision: m,
    textureFormatReadable: h,
    textureTypeReadable: d,
    precision: p,
    logarithmicDepthBuffer: _,
    reverseDepthBuffer: x,
    maxTextures: S,
    maxVertexTextures: E,
    maxTextureSize: b,
    maxCubemapSize: M,
    maxAttributes: v,
    maxVertexUniforms: B,
    maxVaryings: U,
    maxFragmentUniforms: w,
    vertexTextures: F,
    maxSamples: L
  };
}
function h1(r) {
  const t = this;
  let i = null, s = 0, l = !1, c = !1;
  const h = new ja(), d = new ue(), m = { value: null, needsUpdate: !1 };
  this.uniform = m, this.numPlanes = 0, this.numIntersection = 0, this.init = function(_, x) {
    const S = _.length !== 0 || x || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    s !== 0 || l;
    return l = x, s = _.length, S;
  }, this.beginShadows = function() {
    c = !0, g(null);
  }, this.endShadows = function() {
    c = !1;
  }, this.setGlobalState = function(_, x) {
    i = g(_, x, 0);
  }, this.setState = function(_, x, S) {
    const E = _.clippingPlanes, b = _.clipIntersection, M = _.clipShadows, v = r.get(_);
    if (!l || E === null || E.length === 0 || c && !M)
      c ? g(null) : p();
    else {
      const B = c ? 0 : s, U = B * 4;
      let w = v.clippingState || null;
      m.value = w, w = g(E, x, U, S);
      for (let F = 0; F !== U; ++F)
        w[F] = i[F];
      v.clippingState = w, this.numIntersection = b ? this.numPlanes : 0, this.numPlanes += B;
    }
  };
  function p() {
    m.value !== i && (m.value = i, m.needsUpdate = s > 0), t.numPlanes = s, t.numIntersection = 0;
  }
  function g(_, x, S, E) {
    const b = _ !== null ? _.length : 0;
    let M = null;
    if (b !== 0) {
      if (M = m.value, E !== !0 || M === null) {
        const v = S + b * 4, B = x.matrixWorldInverse;
        d.getNormalMatrix(B), (M === null || M.length < v) && (M = new Float32Array(v));
        for (let U = 0, w = S; U !== b; ++U, w += 4)
          h.copy(_[U]).applyMatrix4(B, d), h.normal.toArray(M, w), M[w + 3] = h.constant;
      }
      m.value = M, m.needsUpdate = !0;
    }
    return t.numPlanes = b, t.numIntersection = 0, M;
  }
}
function d1(r) {
  let t = /* @__PURE__ */ new WeakMap();
  function i(h, d) {
    return d === Ud ? h.mapping = Zr : d === Ld && (h.mapping = Kr), h;
  }
  function s(h) {
    if (h && h.isTexture) {
      const d = h.mapping;
      if (d === Ud || d === Ld)
        if (t.has(h)) {
          const m = t.get(h).texture;
          return i(m, h.mapping);
        } else {
          const m = h.image;
          if (m && m.height > 0) {
            const p = new uE(m.height);
            return p.fromEquirectangularTexture(r, h), t.set(h, p), h.addEventListener("dispose", l), i(p.texture, h.mapping);
          } else
            return null;
        }
    }
    return h;
  }
  function l(h) {
    const d = h.target;
    d.removeEventListener("dispose", l);
    const m = t.get(d);
    m !== void 0 && (t.delete(d), m.dispose());
  }
  function c() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: s,
    dispose: c
  };
}
const kr = 4, lv = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Ds = 20, ud = /* @__PURE__ */ new Za(), cv = /* @__PURE__ */ new ve();
let fd = null, hd = 0, dd = 0, pd = !1;
const Cs = (1 + Math.sqrt(5)) / 2, Br = 1 / Cs, uv = [
  /* @__PURE__ */ new q(-Cs, Br, 0),
  /* @__PURE__ */ new q(Cs, Br, 0),
  /* @__PURE__ */ new q(-Br, 0, Cs),
  /* @__PURE__ */ new q(Br, 0, Cs),
  /* @__PURE__ */ new q(0, Cs, -Br),
  /* @__PURE__ */ new q(0, Cs, Br),
  /* @__PURE__ */ new q(-1, 1, -1),
  /* @__PURE__ */ new q(1, 1, -1),
  /* @__PURE__ */ new q(-1, 1, 1),
  /* @__PURE__ */ new q(1, 1, 1)
];
class fv {
  constructor(t) {
    this._renderer = t, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial);
  }
  /**
   * Generates a PMREM from a supplied Scene, which can be faster than using an
   * image if networking bandwidth is low. Optional sigma specifies a blur radius
   * in radians to be applied to the scene before PMREM generation. Optional near
   * and far planes ensure the scene is rendered in its entirety (the cubeCamera
   * is placed at the origin).
   *
   * @param {Scene} scene
   * @param {number} sigma
   * @param {number} near
   * @param {number} far
   * @return {WebGLRenderTarget}
   */
  fromScene(t, i = 0, s = 0.1, l = 100) {
    fd = this._renderer.getRenderTarget(), hd = this._renderer.getActiveCubeFace(), dd = this._renderer.getActiveMipmapLevel(), pd = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(256);
    const c = this._allocateTargets();
    return c.depthBuffer = !0, this._sceneToCubeUV(t, s, l, c), i > 0 && this._blur(c, 0, 0, i), this._applyPMREM(c), this._cleanup(c), c;
  }
  /**
   * Generates a PMREM from an equirectangular texture, which can be either LDR
   * or HDR. The ideal input image size is 1k (1024 x 512),
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported equirectangular image size is 64 x 32.
   *
   * @param {Texture} equirectangular
   * @param {WebGLRenderTarget} [renderTarget=null] - Optional render target.
   * @return {WebGLRenderTarget}
   */
  fromEquirectangular(t, i = null) {
    return this._fromTexture(t, i);
  }
  /**
   * Generates a PMREM from an cubemap texture, which can be either LDR
   * or HDR. The ideal input cube size is 256 x 256,
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported cube size is 16 x 16.
   *
   * @param {Texture} cubemap
   * @param {null} [renderTarget=null] - Optional render target.
   * @return {WebGLRenderTarget}
   */
  fromCubemap(t, i = null) {
    return this._fromTexture(t, i);
  }
  /**
   * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileCubemapShader() {
    this._cubemapMaterial === null && (this._cubemapMaterial = pv(), this._compileMaterial(this._cubemapMaterial));
  }
  /**
   * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileEquirectangularShader() {
    this._equirectMaterial === null && (this._equirectMaterial = dv(), this._compileMaterial(this._equirectMaterial));
  }
  /**
   * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
   * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
   * one of them will cause any others to also become unusable.
   */
  dispose() {
    this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose();
  }
  // private interface
  _setSize(t) {
    this._lodMax = Math.floor(Math.log2(t)), this._cubeSize = Math.pow(2, this._lodMax);
  }
  _dispose() {
    this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
    for (let t = 0; t < this._lodPlanes.length; t++)
      this._lodPlanes[t].dispose();
  }
  _cleanup(t) {
    this._renderer.setRenderTarget(fd, hd, dd), this._renderer.xr.enabled = pd, t.scissorTest = !1, Qc(t, 0, 0, t.width, t.height);
  }
  _fromTexture(t, i) {
    t.mapping === Zr || t.mapping === Kr ? this._setSize(t.image.length === 0 ? 16 : t.image[0].width || t.image[0].image.width) : this._setSize(t.image.width / 4), fd = this._renderer.getRenderTarget(), hd = this._renderer.getActiveCubeFace(), dd = this._renderer.getActiveMipmapLevel(), pd = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
    const s = i || this._allocateTargets();
    return this._textureToCubeUV(t, s), this._applyPMREM(s), this._cleanup(s), s;
  }
  _allocateTargets() {
    const t = 3 * Math.max(this._cubeSize, 112), i = 4 * this._cubeSize, s = {
      magFilter: Hi,
      minFilter: Hi,
      generateMipmaps: !1,
      type: hl,
      format: fi,
      colorSpace: $r,
      depthBuffer: !1
    }, l = hv(t, i, s);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== t || this._pingPongRenderTarget.height !== i) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = hv(t, i, s);
      const { _lodMax: c } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = p1(c)), this._blurMaterial = m1(c, t, i);
    }
    return l;
  }
  _compileMaterial(t) {
    const i = new Un(this._lodPlanes[0], t);
    this._renderer.compile(i, ud);
  }
  _sceneToCubeUV(t, i, s, l) {
    const d = new ui(90, 1, i, s), m = [1, -1, 1, 1, 1, 1], p = [1, 1, 1, -1, -1, -1], g = this._renderer, _ = g.autoClear, x = g.toneMapping;
    g.getClearColor(cv), g.toneMapping = Ja, g.autoClear = !1;
    const S = new yu({
      name: "PMREM.Background",
      side: ti,
      depthWrite: !1,
      depthTest: !1
    }), E = new Un(new dl(), S);
    let b = !1;
    const M = t.background;
    M ? M.isColor && (S.color.copy(M), t.background = null, b = !0) : (S.color.copy(cv), b = !0);
    for (let v = 0; v < 6; v++) {
      const B = v % 3;
      B === 0 ? (d.up.set(0, m[v], 0), d.lookAt(p[v], 0, 0)) : B === 1 ? (d.up.set(0, 0, m[v]), d.lookAt(0, p[v], 0)) : (d.up.set(0, m[v], 0), d.lookAt(0, 0, p[v]));
      const U = this._cubeSize;
      Qc(l, B * U, v > 2 ? U : 0, U, U), g.setRenderTarget(l), b && g.render(E, d), g.render(t, d);
    }
    E.geometry.dispose(), E.material.dispose(), g.toneMapping = x, g.autoClear = _, t.background = M;
  }
  _textureToCubeUV(t, i) {
    const s = this._renderer, l = t.mapping === Zr || t.mapping === Kr;
    l ? (this._cubemapMaterial === null && (this._cubemapMaterial = pv()), this._cubemapMaterial.uniforms.flipEnvMap.value = t.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = dv());
    const c = l ? this._cubemapMaterial : this._equirectMaterial, h = new Un(this._lodPlanes[0], c), d = c.uniforms;
    d.envMap.value = t;
    const m = this._cubeSize;
    Qc(i, 0, 0, 3 * m, 2 * m), s.setRenderTarget(i), s.render(h, ud);
  }
  _applyPMREM(t) {
    const i = this._renderer, s = i.autoClear;
    i.autoClear = !1;
    const l = this._lodPlanes.length;
    for (let c = 1; c < l; c++) {
      const h = Math.sqrt(this._sigmas[c] * this._sigmas[c] - this._sigmas[c - 1] * this._sigmas[c - 1]), d = uv[(l - c - 1) % uv.length];
      this._blur(t, c - 1, c, h, d);
    }
    i.autoClear = s;
  }
  /**
   * This is a two-pass Gaussian blur for a cubemap. Normally this is done
   * vertically and horizontally, but this breaks down on a cube. Here we apply
   * the blur latitudinally (around the poles), and then longitudinally (towards
   * the poles) to approximate the orthogonally-separable blur. It is least
   * accurate at the poles, but still does a decent job.
   *
   * @param {WebGLRenderTarget} cubeUVRenderTarget
   * @param {number} lodIn
   * @param {number} lodOut
   * @param {number} sigma
   * @param {Vector3} [poleAxis]
   */
  _blur(t, i, s, l, c) {
    const h = this._pingPongRenderTarget;
    this._halfBlur(
      t,
      h,
      i,
      s,
      l,
      "latitudinal",
      c
    ), this._halfBlur(
      h,
      t,
      s,
      s,
      l,
      "longitudinal",
      c
    );
  }
  _halfBlur(t, i, s, l, c, h, d) {
    const m = this._renderer, p = this._blurMaterial;
    h !== "latitudinal" && h !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const g = 3, _ = new Un(this._lodPlanes[l], p), x = p.uniforms, S = this._sizeLods[s] - 1, E = isFinite(c) ? Math.PI / (2 * S) : 2 * Math.PI / (2 * Ds - 1), b = c / E, M = isFinite(c) ? 1 + Math.floor(g * b) : Ds;
    M > Ds && console.warn(`sigmaRadians, ${c}, is too large and will clip, as it requested ${M} samples when the maximum is set to ${Ds}`);
    const v = [];
    let B = 0;
    for (let O = 0; O < Ds; ++O) {
      const G = O / b, C = Math.exp(-G * G / 2);
      v.push(C), O === 0 ? B += C : O < M && (B += 2 * C);
    }
    for (let O = 0; O < v.length; O++)
      v[O] = v[O] / B;
    x.envMap.value = t.texture, x.samples.value = M, x.weights.value = v, x.latitudinal.value = h === "latitudinal", d && (x.poleAxis.value = d);
    const { _lodMax: U } = this;
    x.dTheta.value = E, x.mipInt.value = U - s;
    const w = this._sizeLods[l], F = 3 * w * (l > U - kr ? l - U + kr : 0), L = 4 * (this._cubeSize - w);
    Qc(i, F, L, 3 * w, 2 * w), m.setRenderTarget(i), m.render(_, ud);
  }
}
function p1(r) {
  const t = [], i = [], s = [];
  let l = r;
  const c = r - kr + 1 + lv.length;
  for (let h = 0; h < c; h++) {
    const d = Math.pow(2, l);
    i.push(d);
    let m = 1 / d;
    h > r - kr ? m = lv[h - r + kr - 1] : h === 0 && (m = 0), s.push(m);
    const p = 1 / (d - 2), g = -p, _ = 1 + p, x = [g, g, _, g, _, _, g, g, _, _, g, _], S = 6, E = 6, b = 3, M = 2, v = 1, B = new Float32Array(b * E * S), U = new Float32Array(M * E * S), w = new Float32Array(v * E * S);
    for (let L = 0; L < S; L++) {
      const O = L % 3 * 2 / 3 - 1, G = L > 2 ? 0 : -1, C = [
        O,
        G,
        0,
        O + 2 / 3,
        G,
        0,
        O + 2 / 3,
        G + 1,
        0,
        O,
        G,
        0,
        O + 2 / 3,
        G + 1,
        0,
        O,
        G + 1,
        0
      ];
      B.set(C, b * E * L), U.set(x, M * E * L);
      const T = [L, L, L, L, L, L];
      w.set(T, v * E * L);
    }
    const F = new Xn();
    F.setAttribute("position", new Mn(B, b)), F.setAttribute("uv", new Mn(U, M)), F.setAttribute("faceIndex", new Mn(w, v)), t.push(F), l > kr && l--;
  }
  return { lodPlanes: t, sizeLods: i, sigmas: s };
}
function hv(r, t, i) {
  const s = new zs(r, t, i);
  return s.texture.mapping = xu, s.texture.name = "PMREM.cubeUv", s.scissorTest = !0, s;
}
function Qc(r, t, i, s, l) {
  r.viewport.set(t, i, s, l), r.scissor.set(t, i, s, l);
}
function m1(r, t, i) {
  const s = new Float32Array(Ds), l = new q(0, 1, 0);
  return new _a({
    name: "SphericalGaussianBlur",
    defines: {
      n: Ds,
      CUBEUV_TEXEL_WIDTH: 1 / t,
      CUBEUV_TEXEL_HEIGHT: 1 / i,
      CUBEUV_MAX_MIP: `${r}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: s },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: l }
    },
    vertexShader: Up(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`
    ),
    blending: Qa,
    depthTest: !1,
    depthWrite: !1
  });
}
function dv() {
  return new _a({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: Up(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`
    ),
    blending: Qa,
    depthTest: !1,
    depthWrite: !1
  });
}
function pv() {
  return new _a({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: Up(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`
    ),
    blending: Qa,
    depthTest: !1,
    depthWrite: !1
  });
}
function Up() {
  return (
    /* glsl */
    `

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`
  );
}
function g1(r) {
  let t = /* @__PURE__ */ new WeakMap(), i = null;
  function s(d) {
    if (d && d.isTexture) {
      const m = d.mapping, p = m === Ud || m === Ld, g = m === Zr || m === Kr;
      if (p || g) {
        let _ = t.get(d);
        const x = _ !== void 0 ? _.texture.pmremVersion : 0;
        if (d.isRenderTargetTexture && d.pmremVersion !== x)
          return i === null && (i = new fv(r)), _ = p ? i.fromEquirectangular(d, _) : i.fromCubemap(d, _), _.texture.pmremVersion = d.pmremVersion, t.set(d, _), _.texture;
        if (_ !== void 0)
          return _.texture;
        {
          const S = d.image;
          return p && S && S.height > 0 || g && S && l(S) ? (i === null && (i = new fv(r)), _ = p ? i.fromEquirectangular(d) : i.fromCubemap(d), _.texture.pmremVersion = d.pmremVersion, t.set(d, _), d.addEventListener("dispose", c), _.texture) : null;
        }
      }
    }
    return d;
  }
  function l(d) {
    let m = 0;
    const p = 6;
    for (let g = 0; g < p; g++)
      d[g] !== void 0 && m++;
    return m === p;
  }
  function c(d) {
    const m = d.target;
    m.removeEventListener("dispose", c);
    const p = t.get(m);
    p !== void 0 && (t.delete(m), p.dispose());
  }
  function h() {
    t = /* @__PURE__ */ new WeakMap(), i !== null && (i.dispose(), i = null);
  }
  return {
    get: s,
    dispose: h
  };
}
function _1(r) {
  const t = {};
  function i(s) {
    if (t[s] !== void 0)
      return t[s];
    let l;
    switch (s) {
      case "WEBGL_depth_texture":
        l = r.getExtension("WEBGL_depth_texture") || r.getExtension("MOZ_WEBGL_depth_texture") || r.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        l = r.getExtension("EXT_texture_filter_anisotropic") || r.getExtension("MOZ_EXT_texture_filter_anisotropic") || r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
        break;
      case "WEBGL_compressed_texture_s3tc":
        l = r.getExtension("WEBGL_compressed_texture_s3tc") || r.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
        break;
      case "WEBGL_compressed_texture_pvrtc":
        l = r.getExtension("WEBGL_compressed_texture_pvrtc") || r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        l = r.getExtension(s);
    }
    return t[s] = l, l;
  }
  return {
    has: function(s) {
      return i(s) !== null;
    },
    init: function() {
      i("EXT_color_buffer_float"), i("WEBGL_clip_cull_distance"), i("OES_texture_float_linear"), i("EXT_color_buffer_half_float"), i("WEBGL_multisampled_render_to_texture"), i("WEBGL_render_shared_exponent");
    },
    get: function(s) {
      const l = i(s);
      return l === null && Gr("THREE.WebGLRenderer: " + s + " extension not supported."), l;
    }
  };
}
function v1(r, t, i, s) {
  const l = {}, c = /* @__PURE__ */ new WeakMap();
  function h(_) {
    const x = _.target;
    x.index !== null && t.remove(x.index);
    for (const E in x.attributes)
      t.remove(x.attributes[E]);
    x.removeEventListener("dispose", h), delete l[x.id];
    const S = c.get(x);
    S && (t.remove(S), c.delete(x)), s.releaseStatesOfGeometry(x), x.isInstancedBufferGeometry === !0 && delete x._maxInstanceCount, i.memory.geometries--;
  }
  function d(_, x) {
    return l[x.id] === !0 || (x.addEventListener("dispose", h), l[x.id] = !0, i.memory.geometries++), x;
  }
  function m(_) {
    const x = _.attributes;
    for (const S in x)
      t.update(x[S], r.ARRAY_BUFFER);
  }
  function p(_) {
    const x = [], S = _.index, E = _.attributes.position;
    let b = 0;
    if (S !== null) {
      const B = S.array;
      b = S.version;
      for (let U = 0, w = B.length; U < w; U += 3) {
        const F = B[U + 0], L = B[U + 1], O = B[U + 2];
        x.push(F, L, L, O, O, F);
      }
    } else if (E !== void 0) {
      const B = E.array;
      b = E.version;
      for (let U = 0, w = B.length / 3 - 1; U < w; U += 3) {
        const F = U + 0, L = U + 1, O = U + 2;
        x.push(F, L, L, O, O, F);
      }
    } else
      return;
    const M = new (hx(x) ? vx : _x)(x, 1);
    M.version = b;
    const v = c.get(_);
    v && t.remove(v), c.set(_, M);
  }
  function g(_) {
    const x = c.get(_);
    if (x) {
      const S = _.index;
      S !== null && x.version < S.version && p(_);
    } else
      p(_);
    return c.get(_);
  }
  return {
    get: d,
    update: m,
    getWireframeAttribute: g
  };
}
function x1(r, t, i) {
  let s;
  function l(x) {
    s = x;
  }
  let c, h;
  function d(x) {
    c = x.type, h = x.bytesPerElement;
  }
  function m(x, S) {
    r.drawElements(s, S, c, x * h), i.update(S, s, 1);
  }
  function p(x, S, E) {
    E !== 0 && (r.drawElementsInstanced(s, S, c, x * h, E), i.update(S, s, E));
  }
  function g(x, S, E) {
    if (E === 0) return;
    t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(s, S, 0, c, x, 0, E);
    let M = 0;
    for (let v = 0; v < E; v++)
      M += S[v];
    i.update(M, s, 1);
  }
  function _(x, S, E, b) {
    if (E === 0) return;
    const M = t.get("WEBGL_multi_draw");
    if (M === null)
      for (let v = 0; v < x.length; v++)
        p(x[v] / h, S[v], b[v]);
    else {
      M.multiDrawElementsInstancedWEBGL(s, S, 0, c, x, 0, b, 0, E);
      let v = 0;
      for (let B = 0; B < E; B++)
        v += S[B] * b[B];
      i.update(v, s, 1);
    }
  }
  this.setMode = l, this.setIndex = d, this.render = m, this.renderInstances = p, this.renderMultiDraw = g, this.renderMultiDrawInstances = _;
}
function y1(r) {
  const t = {
    geometries: 0,
    textures: 0
  }, i = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function s(c, h, d) {
    switch (i.calls++, h) {
      case r.TRIANGLES:
        i.triangles += d * (c / 3);
        break;
      case r.LINES:
        i.lines += d * (c / 2);
        break;
      case r.LINE_STRIP:
        i.lines += d * (c - 1);
        break;
      case r.LINE_LOOP:
        i.lines += d * c;
        break;
      case r.POINTS:
        i.points += d * c;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", h);
        break;
    }
  }
  function l() {
    i.calls = 0, i.triangles = 0, i.points = 0, i.lines = 0;
  }
  return {
    memory: t,
    render: i,
    programs: null,
    autoReset: !0,
    reset: l,
    update: s
  };
}
function S1(r, t, i) {
  const s = /* @__PURE__ */ new WeakMap(), l = new Je();
  function c(h, d, m) {
    const p = h.morphTargetInfluences, g = d.morphAttributes.position || d.morphAttributes.normal || d.morphAttributes.color, _ = g !== void 0 ? g.length : 0;
    let x = s.get(d);
    if (x === void 0 || x.count !== _) {
      let C = function() {
        O.dispose(), s.delete(d), d.removeEventListener("dispose", C);
      };
      x !== void 0 && x.texture.dispose();
      const S = d.morphAttributes.position !== void 0, E = d.morphAttributes.normal !== void 0, b = d.morphAttributes.color !== void 0, M = d.morphAttributes.position || [], v = d.morphAttributes.normal || [], B = d.morphAttributes.color || [];
      let U = 0;
      S === !0 && (U = 1), E === !0 && (U = 2), b === !0 && (U = 3);
      let w = d.attributes.position.count * U, F = 1;
      w > t.maxTextureSize && (F = Math.ceil(w / t.maxTextureSize), w = t.maxTextureSize);
      const L = new Float32Array(w * F * 4 * _), O = new px(L, w, F, _);
      O.type = Ei, O.needsUpdate = !0;
      const G = U * 4;
      for (let T = 0; T < _; T++) {
        const I = M[T], J = v[T], $ = B[T], lt = w * F * 4 * T;
        for (let pt = 0; pt < I.count; pt++) {
          const z = pt * G;
          S === !0 && (l.fromBufferAttribute(I, pt), L[lt + z + 0] = l.x, L[lt + z + 1] = l.y, L[lt + z + 2] = l.z, L[lt + z + 3] = 0), E === !0 && (l.fromBufferAttribute(J, pt), L[lt + z + 4] = l.x, L[lt + z + 5] = l.y, L[lt + z + 6] = l.z, L[lt + z + 7] = 0), b === !0 && (l.fromBufferAttribute($, pt), L[lt + z + 8] = l.x, L[lt + z + 9] = l.y, L[lt + z + 10] = l.z, L[lt + z + 11] = $.itemSize === 4 ? l.w : 1);
        }
      }
      x = {
        count: _,
        texture: O,
        size: new $t(w, F)
      }, s.set(d, x), d.addEventListener("dispose", C);
    }
    if (h.isInstancedMesh === !0 && h.morphTexture !== null)
      m.getUniforms().setValue(r, "morphTexture", h.morphTexture, i);
    else {
      let S = 0;
      for (let b = 0; b < p.length; b++)
        S += p[b];
      const E = d.morphTargetsRelative ? 1 : 1 - S;
      m.getUniforms().setValue(r, "morphTargetBaseInfluence", E), m.getUniforms().setValue(r, "morphTargetInfluences", p);
    }
    m.getUniforms().setValue(r, "morphTargetsTexture", x.texture, i), m.getUniforms().setValue(r, "morphTargetsTextureSize", x.size);
  }
  return {
    update: c
  };
}
function M1(r, t, i, s) {
  let l = /* @__PURE__ */ new WeakMap();
  function c(m) {
    const p = s.render.frame, g = m.geometry, _ = t.get(m, g);
    if (l.get(_) !== p && (t.update(_), l.set(_, p)), m.isInstancedMesh && (m.hasEventListener("dispose", d) === !1 && m.addEventListener("dispose", d), l.get(m) !== p && (i.update(m.instanceMatrix, r.ARRAY_BUFFER), m.instanceColor !== null && i.update(m.instanceColor, r.ARRAY_BUFFER), l.set(m, p))), m.isSkinnedMesh) {
      const x = m.skeleton;
      l.get(x) !== p && (x.update(), l.set(x, p));
    }
    return _;
  }
  function h() {
    l = /* @__PURE__ */ new WeakMap();
  }
  function d(m) {
    const p = m.target;
    p.removeEventListener("dispose", d), i.remove(p.instanceMatrix), p.instanceColor !== null && i.remove(p.instanceColor);
  }
  return {
    update: c,
    dispose: h
  };
}
const Cx = /* @__PURE__ */ new zn(), mv = /* @__PURE__ */ new bx(1, 1), wx = /* @__PURE__ */ new px(), Dx = /* @__PURE__ */ new jM(), Ux = /* @__PURE__ */ new Sx(), gv = [], _v = [], vv = new Float32Array(16), xv = new Float32Array(9), yv = new Float32Array(4);
function no(r, t, i) {
  const s = r[0];
  if (s <= 0 || s > 0) return r;
  const l = t * i;
  let c = gv[l];
  if (c === void 0 && (c = new Float32Array(l), gv[l] = c), t !== 0) {
    s.toArray(c, 0);
    for (let h = 1, d = 0; h !== t; ++h)
      d += i, r[h].toArray(c, d);
  }
  return c;
}
function gn(r, t) {
  if (r.length !== t.length) return !1;
  for (let i = 0, s = r.length; i < s; i++)
    if (r[i] !== t[i]) return !1;
  return !0;
}
function _n(r, t) {
  for (let i = 0, s = t.length; i < s; i++)
    r[i] = t[i];
}
function Eu(r, t) {
  let i = _v[t];
  i === void 0 && (i = new Int32Array(t), _v[t] = i);
  for (let s = 0; s !== t; ++s)
    i[s] = r.allocateTextureUnit();
  return i;
}
function E1(r, t) {
  const i = this.cache;
  i[0] !== t && (r.uniform1f(this.addr, t), i[0] = t);
}
function b1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y) && (r.uniform2f(this.addr, t.x, t.y), i[0] = t.x, i[1] = t.y);
  else {
    if (gn(i, t)) return;
    r.uniform2fv(this.addr, t), _n(i, t);
  }
}
function T1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (r.uniform3f(this.addr, t.x, t.y, t.z), i[0] = t.x, i[1] = t.y, i[2] = t.z);
  else if (t.r !== void 0)
    (i[0] !== t.r || i[1] !== t.g || i[2] !== t.b) && (r.uniform3f(this.addr, t.r, t.g, t.b), i[0] = t.r, i[1] = t.g, i[2] = t.b);
  else {
    if (gn(i, t)) return;
    r.uniform3fv(this.addr, t), _n(i, t);
  }
}
function A1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (r.uniform4f(this.addr, t.x, t.y, t.z, t.w), i[0] = t.x, i[1] = t.y, i[2] = t.z, i[3] = t.w);
  else {
    if (gn(i, t)) return;
    r.uniform4fv(this.addr, t), _n(i, t);
  }
}
function R1(r, t) {
  const i = this.cache, s = t.elements;
  if (s === void 0) {
    if (gn(i, t)) return;
    r.uniformMatrix2fv(this.addr, !1, t), _n(i, t);
  } else {
    if (gn(i, s)) return;
    yv.set(s), r.uniformMatrix2fv(this.addr, !1, yv), _n(i, s);
  }
}
function C1(r, t) {
  const i = this.cache, s = t.elements;
  if (s === void 0) {
    if (gn(i, t)) return;
    r.uniformMatrix3fv(this.addr, !1, t), _n(i, t);
  } else {
    if (gn(i, s)) return;
    xv.set(s), r.uniformMatrix3fv(this.addr, !1, xv), _n(i, s);
  }
}
function w1(r, t) {
  const i = this.cache, s = t.elements;
  if (s === void 0) {
    if (gn(i, t)) return;
    r.uniformMatrix4fv(this.addr, !1, t), _n(i, t);
  } else {
    if (gn(i, s)) return;
    vv.set(s), r.uniformMatrix4fv(this.addr, !1, vv), _n(i, s);
  }
}
function D1(r, t) {
  const i = this.cache;
  i[0] !== t && (r.uniform1i(this.addr, t), i[0] = t);
}
function U1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y) && (r.uniform2i(this.addr, t.x, t.y), i[0] = t.x, i[1] = t.y);
  else {
    if (gn(i, t)) return;
    r.uniform2iv(this.addr, t), _n(i, t);
  }
}
function L1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (r.uniform3i(this.addr, t.x, t.y, t.z), i[0] = t.x, i[1] = t.y, i[2] = t.z);
  else {
    if (gn(i, t)) return;
    r.uniform3iv(this.addr, t), _n(i, t);
  }
}
function N1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (r.uniform4i(this.addr, t.x, t.y, t.z, t.w), i[0] = t.x, i[1] = t.y, i[2] = t.z, i[3] = t.w);
  else {
    if (gn(i, t)) return;
    r.uniform4iv(this.addr, t), _n(i, t);
  }
}
function O1(r, t) {
  const i = this.cache;
  i[0] !== t && (r.uniform1ui(this.addr, t), i[0] = t);
}
function P1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y) && (r.uniform2ui(this.addr, t.x, t.y), i[0] = t.x, i[1] = t.y);
  else {
    if (gn(i, t)) return;
    r.uniform2uiv(this.addr, t), _n(i, t);
  }
}
function z1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (r.uniform3ui(this.addr, t.x, t.y, t.z), i[0] = t.x, i[1] = t.y, i[2] = t.z);
  else {
    if (gn(i, t)) return;
    r.uniform3uiv(this.addr, t), _n(i, t);
  }
}
function B1(r, t) {
  const i = this.cache;
  if (t.x !== void 0)
    (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (r.uniform4ui(this.addr, t.x, t.y, t.z, t.w), i[0] = t.x, i[1] = t.y, i[2] = t.z, i[3] = t.w);
  else {
    if (gn(i, t)) return;
    r.uniform4uiv(this.addr, t), _n(i, t);
  }
}
function I1(r, t, i) {
  const s = this.cache, l = i.allocateTextureUnit();
  s[0] !== l && (r.uniform1i(this.addr, l), s[0] = l);
  let c;
  this.type === r.SAMPLER_2D_SHADOW ? (mv.compareFunction = fx, c = mv) : c = Cx, i.setTexture2D(t || c, l);
}
function F1(r, t, i) {
  const s = this.cache, l = i.allocateTextureUnit();
  s[0] !== l && (r.uniform1i(this.addr, l), s[0] = l), i.setTexture3D(t || Dx, l);
}
function H1(r, t, i) {
  const s = this.cache, l = i.allocateTextureUnit();
  s[0] !== l && (r.uniform1i(this.addr, l), s[0] = l), i.setTextureCube(t || Ux, l);
}
function G1(r, t, i) {
  const s = this.cache, l = i.allocateTextureUnit();
  s[0] !== l && (r.uniform1i(this.addr, l), s[0] = l), i.setTexture2DArray(t || wx, l);
}
function V1(r) {
  switch (r) {
    case 5126:
      return E1;
    // FLOAT
    case 35664:
      return b1;
    // _VEC2
    case 35665:
      return T1;
    // _VEC3
    case 35666:
      return A1;
    // _VEC4
    case 35674:
      return R1;
    // _MAT2
    case 35675:
      return C1;
    // _MAT3
    case 35676:
      return w1;
    // _MAT4
    case 5124:
    case 35670:
      return D1;
    // INT, BOOL
    case 35667:
    case 35671:
      return U1;
    // _VEC2
    case 35668:
    case 35672:
      return L1;
    // _VEC3
    case 35669:
    case 35673:
      return N1;
    // _VEC4
    case 5125:
      return O1;
    // UINT
    case 36294:
      return P1;
    // _VEC2
    case 36295:
      return z1;
    // _VEC3
    case 36296:
      return B1;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return I1;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return F1;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return H1;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return G1;
  }
}
function k1(r, t) {
  r.uniform1fv(this.addr, t);
}
function X1(r, t) {
  const i = no(t, this.size, 2);
  r.uniform2fv(this.addr, i);
}
function W1(r, t) {
  const i = no(t, this.size, 3);
  r.uniform3fv(this.addr, i);
}
function Y1(r, t) {
  const i = no(t, this.size, 4);
  r.uniform4fv(this.addr, i);
}
function q1(r, t) {
  const i = no(t, this.size, 4);
  r.uniformMatrix2fv(this.addr, !1, i);
}
function j1(r, t) {
  const i = no(t, this.size, 9);
  r.uniformMatrix3fv(this.addr, !1, i);
}
function Z1(r, t) {
  const i = no(t, this.size, 16);
  r.uniformMatrix4fv(this.addr, !1, i);
}
function K1(r, t) {
  r.uniform1iv(this.addr, t);
}
function Q1(r, t) {
  r.uniform2iv(this.addr, t);
}
function J1(r, t) {
  r.uniform3iv(this.addr, t);
}
function $1(r, t) {
  r.uniform4iv(this.addr, t);
}
function tA(r, t) {
  r.uniform1uiv(this.addr, t);
}
function eA(r, t) {
  r.uniform2uiv(this.addr, t);
}
function nA(r, t) {
  r.uniform3uiv(this.addr, t);
}
function iA(r, t) {
  r.uniform4uiv(this.addr, t);
}
function aA(r, t, i) {
  const s = this.cache, l = t.length, c = Eu(i, l);
  gn(s, c) || (r.uniform1iv(this.addr, c), _n(s, c));
  for (let h = 0; h !== l; ++h)
    i.setTexture2D(t[h] || Cx, c[h]);
}
function sA(r, t, i) {
  const s = this.cache, l = t.length, c = Eu(i, l);
  gn(s, c) || (r.uniform1iv(this.addr, c), _n(s, c));
  for (let h = 0; h !== l; ++h)
    i.setTexture3D(t[h] || Dx, c[h]);
}
function rA(r, t, i) {
  const s = this.cache, l = t.length, c = Eu(i, l);
  gn(s, c) || (r.uniform1iv(this.addr, c), _n(s, c));
  for (let h = 0; h !== l; ++h)
    i.setTextureCube(t[h] || Ux, c[h]);
}
function oA(r, t, i) {
  const s = this.cache, l = t.length, c = Eu(i, l);
  gn(s, c) || (r.uniform1iv(this.addr, c), _n(s, c));
  for (let h = 0; h !== l; ++h)
    i.setTexture2DArray(t[h] || wx, c[h]);
}
function lA(r) {
  switch (r) {
    case 5126:
      return k1;
    // FLOAT
    case 35664:
      return X1;
    // _VEC2
    case 35665:
      return W1;
    // _VEC3
    case 35666:
      return Y1;
    // _VEC4
    case 35674:
      return q1;
    // _MAT2
    case 35675:
      return j1;
    // _MAT3
    case 35676:
      return Z1;
    // _MAT4
    case 5124:
    case 35670:
      return K1;
    // INT, BOOL
    case 35667:
    case 35671:
      return Q1;
    // _VEC2
    case 35668:
    case 35672:
      return J1;
    // _VEC3
    case 35669:
    case 35673:
      return $1;
    // _VEC4
    case 5125:
      return tA;
    // UINT
    case 36294:
      return eA;
    // _VEC2
    case 36295:
      return nA;
    // _VEC3
    case 36296:
      return iA;
    // _VEC4
    case 35678:
    // SAMPLER_2D
    case 36198:
    // SAMPLER_EXTERNAL_OES
    case 36298:
    // INT_SAMPLER_2D
    case 36306:
    // UNSIGNED_INT_SAMPLER_2D
    case 35682:
      return aA;
    case 35679:
    // SAMPLER_3D
    case 36299:
    // INT_SAMPLER_3D
    case 36307:
      return sA;
    case 35680:
    // SAMPLER_CUBE
    case 36300:
    // INT_SAMPLER_CUBE
    case 36308:
    // UNSIGNED_INT_SAMPLER_CUBE
    case 36293:
      return rA;
    case 36289:
    // SAMPLER_2D_ARRAY
    case 36303:
    // INT_SAMPLER_2D_ARRAY
    case 36311:
    // UNSIGNED_INT_SAMPLER_2D_ARRAY
    case 36292:
      return oA;
  }
}
class cA {
  constructor(t, i, s) {
    this.id = t, this.addr = s, this.cache = [], this.type = i.type, this.setValue = V1(i.type);
  }
}
class uA {
  constructor(t, i, s) {
    this.id = t, this.addr = s, this.cache = [], this.type = i.type, this.size = i.size, this.setValue = lA(i.type);
  }
}
class fA {
  constructor(t) {
    this.id = t, this.seq = [], this.map = {};
  }
  setValue(t, i, s) {
    const l = this.seq;
    for (let c = 0, h = l.length; c !== h; ++c) {
      const d = l[c];
      d.setValue(t, i[d.id], s);
    }
  }
}
const md = /(\w+)(\])?(\[|\.)?/g;
function Sv(r, t) {
  r.seq.push(t), r.map[t.id] = t;
}
function hA(r, t, i) {
  const s = r.name, l = s.length;
  for (md.lastIndex = 0; ; ) {
    const c = md.exec(s), h = md.lastIndex;
    let d = c[1];
    const m = c[2] === "]", p = c[3];
    if (m && (d = d | 0), p === void 0 || p === "[" && h + 2 === l) {
      Sv(i, p === void 0 ? new cA(d, r, t) : new uA(d, r, t));
      break;
    } else {
      let _ = i.map[d];
      _ === void 0 && (_ = new fA(d), Sv(i, _)), i = _;
    }
  }
}
class cu {
  constructor(t, i) {
    this.seq = [], this.map = {};
    const s = t.getProgramParameter(i, t.ACTIVE_UNIFORMS);
    for (let l = 0; l < s; ++l) {
      const c = t.getActiveUniform(i, l), h = t.getUniformLocation(i, c.name);
      hA(c, h, this);
    }
  }
  setValue(t, i, s, l) {
    const c = this.map[i];
    c !== void 0 && c.setValue(t, s, l);
  }
  setOptional(t, i, s) {
    const l = i[s];
    l !== void 0 && this.setValue(t, s, l);
  }
  static upload(t, i, s, l) {
    for (let c = 0, h = i.length; c !== h; ++c) {
      const d = i[c], m = s[d.id];
      m.needsUpdate !== !1 && d.setValue(t, m.value, l);
    }
  }
  static seqWithValue(t, i) {
    const s = [];
    for (let l = 0, c = t.length; l !== c; ++l) {
      const h = t[l];
      h.id in i && s.push(h);
    }
    return s;
  }
}
function Mv(r, t, i) {
  const s = r.createShader(t);
  return r.shaderSource(s, i), r.compileShader(s), s;
}
const dA = 37297;
let pA = 0;
function mA(r, t) {
  const i = r.split(`
`), s = [], l = Math.max(t - 6, 0), c = Math.min(t + 6, i.length);
  for (let h = l; h < c; h++) {
    const d = h + 1;
    s.push(`${d === t ? ">" : " "} ${d}: ${i[h]}`);
  }
  return s.join(`
`);
}
const Ev = /* @__PURE__ */ new ue();
function gA(r) {
  De._getMatrix(Ev, De.workingColorSpace, r);
  const t = `mat3( ${Ev.elements.map((i) => i.toFixed(4))} )`;
  switch (De.getTransfer(r)) {
    case uu:
      return [t, "LinearTransferOETF"];
    case Ge:
      return [t, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space: ", r), [t, "LinearTransferOETF"];
  }
}
function bv(r, t, i) {
  const s = r.getShaderParameter(t, r.COMPILE_STATUS), l = r.getShaderInfoLog(t).trim();
  if (s && l === "") return "";
  const c = /ERROR: 0:(\d+)/.exec(l);
  if (c) {
    const h = parseInt(c[1]);
    return i.toUpperCase() + `

` + l + `

` + mA(r.getShaderSource(t), h);
  } else
    return l;
}
function _A(r, t) {
  const i = gA(t);
  return [
    `vec4 ${r}( vec4 value ) {`,
    `	return ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,
    "}"
  ].join(`
`);
}
function vA(r, t) {
  let i;
  switch (t) {
    case xM:
      i = "Linear";
      break;
    case yM:
      i = "Reinhard";
      break;
    case SM:
      i = "Cineon";
      break;
    case MM:
      i = "ACESFilmic";
      break;
    case bM:
      i = "AgX";
      break;
    case TM:
      i = "Neutral";
      break;
    case EM:
      i = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", t), i = "Linear";
  }
  return "vec3 " + r + "( vec3 color ) { return " + i + "ToneMapping( color ); }";
}
const Jc = /* @__PURE__ */ new q();
function xA() {
  De.getLuminanceCoefficients(Jc);
  const r = Jc.x.toFixed(4), t = Jc.y.toFixed(4), i = Jc.z.toFixed(4);
  return [
    "float luminance( const in vec3 rgb ) {",
    `	const vec3 weights = vec3( ${r}, ${t}, ${i} );`,
    "	return dot( weights, rgb );",
    "}"
  ].join(`
`);
}
function yA(r) {
  return [
    r.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",
    r.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""
  ].filter(cl).join(`
`);
}
function SA(r) {
  const t = [];
  for (const i in r) {
    const s = r[i];
    s !== !1 && t.push("#define " + i + " " + s);
  }
  return t.join(`
`);
}
function MA(r, t) {
  const i = {}, s = r.getProgramParameter(t, r.ACTIVE_ATTRIBUTES);
  for (let l = 0; l < s; l++) {
    const c = r.getActiveAttrib(t, l), h = c.name;
    let d = 1;
    c.type === r.FLOAT_MAT2 && (d = 2), c.type === r.FLOAT_MAT3 && (d = 3), c.type === r.FLOAT_MAT4 && (d = 4), i[h] = {
      type: c.type,
      location: r.getAttribLocation(t, h),
      locationSize: d
    };
  }
  return i;
}
function cl(r) {
  return r !== "";
}
function Tv(r, t) {
  const i = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps;
  return r.replace(/NUM_DIR_LIGHTS/g, t.numDirLights).replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, i).replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, t.numPointLights).replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows);
}
function Av(r, t) {
  return r.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
}
const EA = /^[ \t]*#include +<([\w\d./]+)>/gm;
function up(r) {
  return r.replace(EA, TA);
}
const bA = /* @__PURE__ */ new Map();
function TA(r, t) {
  let i = he[t];
  if (i === void 0) {
    const s = bA.get(t);
    if (s !== void 0)
      i = he[s], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', t, s);
    else
      throw new Error("Can not resolve #include <" + t + ">");
  }
  return up(i);
}
const AA = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;
function Rv(r) {
  return r.replace(AA, RA);
}
function RA(r, t, i, s) {
  let l = "";
  for (let c = parseInt(t); c < parseInt(i); c++)
    l += s.replace(/\[\s*i\s*\]/g, "[ " + c + " ]").replace(/UNROLLED_LOOP_INDEX/g, c);
  return l;
}
function Cv(r) {
  let t = `precision ${r.precision} float;
	precision ${r.precision} int;
	precision ${r.precision} sampler2D;
	precision ${r.precision} samplerCube;
	precision ${r.precision} sampler3D;
	precision ${r.precision} sampler2DArray;
	precision ${r.precision} sampler2DShadow;
	precision ${r.precision} samplerCubeShadow;
	precision ${r.precision} sampler2DArrayShadow;
	precision ${r.precision} isampler2D;
	precision ${r.precision} isampler3D;
	precision ${r.precision} isamplerCube;
	precision ${r.precision} isampler2DArray;
	precision ${r.precision} usampler2D;
	precision ${r.precision} usampler3D;
	precision ${r.precision} usamplerCube;
	precision ${r.precision} usampler2DArray;
	`;
  return r.precision === "highp" ? t += `
#define HIGH_PRECISION` : r.precision === "mediump" ? t += `
#define MEDIUM_PRECISION` : r.precision === "lowp" && (t += `
#define LOW_PRECISION`), t;
}
function CA(r) {
  let t = "SHADOWMAP_TYPE_BASIC";
  return r.shadowMapType === $v ? t = "SHADOWMAP_TYPE_PCF" : r.shadowMapType === JS ? t = "SHADOWMAP_TYPE_PCF_SOFT" : r.shadowMapType === ha && (t = "SHADOWMAP_TYPE_VSM"), t;
}
function wA(r) {
  let t = "ENVMAP_TYPE_CUBE";
  if (r.envMap)
    switch (r.envMapMode) {
      case Zr:
      case Kr:
        t = "ENVMAP_TYPE_CUBE";
        break;
      case xu:
        t = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return t;
}
function DA(r) {
  let t = "ENVMAP_MODE_REFLECTION";
  if (r.envMap)
    switch (r.envMapMode) {
      case Kr:
        t = "ENVMAP_MODE_REFRACTION";
        break;
    }
  return t;
}
function UA(r) {
  let t = "ENVMAP_BLENDING_NONE";
  if (r.envMap)
    switch (r.combine) {
      case vp:
        t = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case _M:
        t = "ENVMAP_BLENDING_MIX";
        break;
      case vM:
        t = "ENVMAP_BLENDING_ADD";
        break;
    }
  return t;
}
function LA(r) {
  const t = r.envMapCubeUVHeight;
  if (t === null) return null;
  const i = Math.log2(t) - 2, s = 1 / t;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, i), 112)), texelHeight: s, maxMip: i };
}
function NA(r, t, i, s) {
  const l = r.getContext(), c = i.defines;
  let h = i.vertexShader, d = i.fragmentShader;
  const m = CA(i), p = wA(i), g = DA(i), _ = UA(i), x = LA(i), S = yA(i), E = SA(c), b = l.createProgram();
  let M, v, B = i.glslVersion ? "#version " + i.glslVersion + `
` : "";
  i.isRawShaderMaterial ? (M = [
    "#define SHADER_TYPE " + i.shaderType,
    "#define SHADER_NAME " + i.shaderName,
    E
  ].filter(cl).join(`
`), M.length > 0 && (M += `
`), v = [
    "#define SHADER_TYPE " + i.shaderType,
    "#define SHADER_NAME " + i.shaderName,
    E
  ].filter(cl).join(`
`), v.length > 0 && (v += `
`)) : (M = [
    Cv(i),
    "#define SHADER_TYPE " + i.shaderType,
    "#define SHADER_NAME " + i.shaderName,
    E,
    i.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",
    i.batching ? "#define USE_BATCHING" : "",
    i.batchingColor ? "#define USE_BATCHING_COLOR" : "",
    i.instancing ? "#define USE_INSTANCING" : "",
    i.instancingColor ? "#define USE_INSTANCING_COLOR" : "",
    i.instancingMorph ? "#define USE_INSTANCING_MORPH" : "",
    i.useFog && i.fog ? "#define USE_FOG" : "",
    i.useFog && i.fogExp2 ? "#define FOG_EXP2" : "",
    i.map ? "#define USE_MAP" : "",
    i.envMap ? "#define USE_ENVMAP" : "",
    i.envMap ? "#define " + g : "",
    i.lightMap ? "#define USE_LIGHTMAP" : "",
    i.aoMap ? "#define USE_AOMAP" : "",
    i.bumpMap ? "#define USE_BUMPMAP" : "",
    i.normalMap ? "#define USE_NORMALMAP" : "",
    i.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    i.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    i.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",
    i.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    i.anisotropy ? "#define USE_ANISOTROPY" : "",
    i.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    i.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    i.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    i.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    i.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    i.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    i.specularMap ? "#define USE_SPECULARMAP" : "",
    i.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    i.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    i.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    i.metalnessMap ? "#define USE_METALNESSMAP" : "",
    i.alphaMap ? "#define USE_ALPHAMAP" : "",
    i.alphaHash ? "#define USE_ALPHAHASH" : "",
    i.transmission ? "#define USE_TRANSMISSION" : "",
    i.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    i.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    i.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    i.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    //
    i.mapUv ? "#define MAP_UV " + i.mapUv : "",
    i.alphaMapUv ? "#define ALPHAMAP_UV " + i.alphaMapUv : "",
    i.lightMapUv ? "#define LIGHTMAP_UV " + i.lightMapUv : "",
    i.aoMapUv ? "#define AOMAP_UV " + i.aoMapUv : "",
    i.emissiveMapUv ? "#define EMISSIVEMAP_UV " + i.emissiveMapUv : "",
    i.bumpMapUv ? "#define BUMPMAP_UV " + i.bumpMapUv : "",
    i.normalMapUv ? "#define NORMALMAP_UV " + i.normalMapUv : "",
    i.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + i.displacementMapUv : "",
    i.metalnessMapUv ? "#define METALNESSMAP_UV " + i.metalnessMapUv : "",
    i.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + i.roughnessMapUv : "",
    i.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + i.anisotropyMapUv : "",
    i.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + i.clearcoatMapUv : "",
    i.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + i.clearcoatNormalMapUv : "",
    i.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + i.clearcoatRoughnessMapUv : "",
    i.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + i.iridescenceMapUv : "",
    i.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + i.iridescenceThicknessMapUv : "",
    i.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + i.sheenColorMapUv : "",
    i.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + i.sheenRoughnessMapUv : "",
    i.specularMapUv ? "#define SPECULARMAP_UV " + i.specularMapUv : "",
    i.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + i.specularColorMapUv : "",
    i.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + i.specularIntensityMapUv : "",
    i.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + i.transmissionMapUv : "",
    i.thicknessMapUv ? "#define THICKNESSMAP_UV " + i.thicknessMapUv : "",
    //
    i.vertexTangents && i.flatShading === !1 ? "#define USE_TANGENT" : "",
    i.vertexColors ? "#define USE_COLOR" : "",
    i.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    i.vertexUv1s ? "#define USE_UV1" : "",
    i.vertexUv2s ? "#define USE_UV2" : "",
    i.vertexUv3s ? "#define USE_UV3" : "",
    i.pointsUvs ? "#define USE_POINTS_UV" : "",
    i.flatShading ? "#define FLAT_SHADED" : "",
    i.skinning ? "#define USE_SKINNING" : "",
    i.morphTargets ? "#define USE_MORPHTARGETS" : "",
    i.morphNormals && i.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",
    i.morphColors ? "#define USE_MORPHCOLORS" : "",
    i.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + i.morphTextureStride : "",
    i.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + i.morphTargetsCount : "",
    i.doubleSided ? "#define DOUBLE_SIDED" : "",
    i.flipSided ? "#define FLIP_SIDED" : "",
    i.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    i.shadowMapEnabled ? "#define " + m : "",
    i.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
    i.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    i.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    i.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",
    "uniform mat4 modelMatrix;",
    "uniform mat4 modelViewMatrix;",
    "uniform mat4 projectionMatrix;",
    "uniform mat4 viewMatrix;",
    "uniform mat3 normalMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    "#ifdef USE_INSTANCING",
    "	attribute mat4 instanceMatrix;",
    "#endif",
    "#ifdef USE_INSTANCING_COLOR",
    "	attribute vec3 instanceColor;",
    "#endif",
    "#ifdef USE_INSTANCING_MORPH",
    "	uniform sampler2D morphTexture;",
    "#endif",
    "attribute vec3 position;",
    "attribute vec3 normal;",
    "attribute vec2 uv;",
    "#ifdef USE_UV1",
    "	attribute vec2 uv1;",
    "#endif",
    "#ifdef USE_UV2",
    "	attribute vec2 uv2;",
    "#endif",
    "#ifdef USE_UV3",
    "	attribute vec2 uv3;",
    "#endif",
    "#ifdef USE_TANGENT",
    "	attribute vec4 tangent;",
    "#endif",
    "#if defined( USE_COLOR_ALPHA )",
    "	attribute vec4 color;",
    "#elif defined( USE_COLOR )",
    "	attribute vec3 color;",
    "#endif",
    "#ifdef USE_SKINNING",
    "	attribute vec4 skinIndex;",
    "	attribute vec4 skinWeight;",
    "#endif",
    `
`
  ].filter(cl).join(`
`), v = [
    Cv(i),
    "#define SHADER_TYPE " + i.shaderType,
    "#define SHADER_NAME " + i.shaderName,
    E,
    i.useFog && i.fog ? "#define USE_FOG" : "",
    i.useFog && i.fogExp2 ? "#define FOG_EXP2" : "",
    i.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "",
    i.map ? "#define USE_MAP" : "",
    i.matcap ? "#define USE_MATCAP" : "",
    i.envMap ? "#define USE_ENVMAP" : "",
    i.envMap ? "#define " + p : "",
    i.envMap ? "#define " + g : "",
    i.envMap ? "#define " + _ : "",
    x ? "#define CUBEUV_TEXEL_WIDTH " + x.texelWidth : "",
    x ? "#define CUBEUV_TEXEL_HEIGHT " + x.texelHeight : "",
    x ? "#define CUBEUV_MAX_MIP " + x.maxMip + ".0" : "",
    i.lightMap ? "#define USE_LIGHTMAP" : "",
    i.aoMap ? "#define USE_AOMAP" : "",
    i.bumpMap ? "#define USE_BUMPMAP" : "",
    i.normalMap ? "#define USE_NORMALMAP" : "",
    i.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    i.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    i.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    i.anisotropy ? "#define USE_ANISOTROPY" : "",
    i.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    i.clearcoat ? "#define USE_CLEARCOAT" : "",
    i.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    i.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    i.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    i.dispersion ? "#define USE_DISPERSION" : "",
    i.iridescence ? "#define USE_IRIDESCENCE" : "",
    i.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    i.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    i.specularMap ? "#define USE_SPECULARMAP" : "",
    i.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    i.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    i.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    i.metalnessMap ? "#define USE_METALNESSMAP" : "",
    i.alphaMap ? "#define USE_ALPHAMAP" : "",
    i.alphaTest ? "#define USE_ALPHATEST" : "",
    i.alphaHash ? "#define USE_ALPHAHASH" : "",
    i.sheen ? "#define USE_SHEEN" : "",
    i.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    i.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    i.transmission ? "#define USE_TRANSMISSION" : "",
    i.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    i.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    i.vertexTangents && i.flatShading === !1 ? "#define USE_TANGENT" : "",
    i.vertexColors || i.instancingColor || i.batchingColor ? "#define USE_COLOR" : "",
    i.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    i.vertexUv1s ? "#define USE_UV1" : "",
    i.vertexUv2s ? "#define USE_UV2" : "",
    i.vertexUv3s ? "#define USE_UV3" : "",
    i.pointsUvs ? "#define USE_POINTS_UV" : "",
    i.gradientMap ? "#define USE_GRADIENTMAP" : "",
    i.flatShading ? "#define FLAT_SHADED" : "",
    i.doubleSided ? "#define DOUBLE_SIDED" : "",
    i.flipSided ? "#define FLIP_SIDED" : "",
    i.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    i.shadowMapEnabled ? "#define " + m : "",
    i.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
    i.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    i.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
    i.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
    i.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    i.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",
    "uniform mat4 viewMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    i.toneMapping !== Ja ? "#define TONE_MAPPING" : "",
    i.toneMapping !== Ja ? he.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    i.toneMapping !== Ja ? vA("toneMapping", i.toneMapping) : "",
    i.dithering ? "#define DITHERING" : "",
    i.opaque ? "#define OPAQUE" : "",
    he.colorspace_pars_fragment,
    // this code is required here because it is used by the various encoding/decoding function defined below
    _A("linearToOutputTexel", i.outputColorSpace),
    xA(),
    i.useDepthPacking ? "#define DEPTH_PACKING " + i.depthPacking : "",
    `
`
  ].filter(cl).join(`
`)), h = up(h), h = Tv(h, i), h = Av(h, i), d = up(d), d = Tv(d, i), d = Av(d, i), h = Rv(h), d = Rv(d), i.isRawShaderMaterial !== !0 && (B = `#version 300 es
`, M = [
    S,
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + M, v = [
    "#define varying in",
    i.glslVersion === fu ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    i.glslVersion === fu ? "" : "#define gl_FragColor pc_fragColor",
    "#define gl_FragDepthEXT gl_FragDepth",
    "#define texture2D texture",
    "#define textureCube texture",
    "#define texture2DProj textureProj",
    "#define texture2DLodEXT textureLod",
    "#define texture2DProjLodEXT textureProjLod",
    "#define textureCubeLodEXT textureLod",
    "#define texture2DGradEXT textureGrad",
    "#define texture2DProjGradEXT textureProjGrad",
    "#define textureCubeGradEXT textureGrad"
  ].join(`
`) + `
` + v);
  const U = B + M + h, w = B + v + d, F = Mv(l, l.VERTEX_SHADER, U), L = Mv(l, l.FRAGMENT_SHADER, w);
  l.attachShader(b, F), l.attachShader(b, L), i.index0AttributeName !== void 0 ? l.bindAttribLocation(b, 0, i.index0AttributeName) : i.morphTargets === !0 && l.bindAttribLocation(b, 0, "position"), l.linkProgram(b);
  function O(I) {
    if (r.debug.checkShaderErrors) {
      const J = l.getProgramInfoLog(b).trim(), $ = l.getShaderInfoLog(F).trim(), lt = l.getShaderInfoLog(L).trim();
      let pt = !0, z = !0;
      if (l.getProgramParameter(b, l.LINK_STATUS) === !1)
        if (pt = !1, typeof r.debug.onShaderError == "function")
          r.debug.onShaderError(l, b, F, L);
        else {
          const tt = bv(l, F, "vertex"), K = bv(l, L, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + l.getError() + " - VALIDATE_STATUS " + l.getProgramParameter(b, l.VALIDATE_STATUS) + `

Material Name: ` + I.name + `
Material Type: ` + I.type + `

Program Info Log: ` + J + `
` + tt + `
` + K
          );
        }
      else J !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", J) : ($ === "" || lt === "") && (z = !1);
      z && (I.diagnostics = {
        runnable: pt,
        programLog: J,
        vertexShader: {
          log: $,
          prefix: M
        },
        fragmentShader: {
          log: lt,
          prefix: v
        }
      });
    }
    l.deleteShader(F), l.deleteShader(L), G = new cu(l, b), C = MA(l, b);
  }
  let G;
  this.getUniforms = function() {
    return G === void 0 && O(this), G;
  };
  let C;
  this.getAttributes = function() {
    return C === void 0 && O(this), C;
  };
  let T = i.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return T === !1 && (T = l.getProgramParameter(b, dA)), T;
  }, this.destroy = function() {
    s.releaseStatesOfProgram(this), l.deleteProgram(b), this.program = void 0;
  }, this.type = i.shaderType, this.name = i.shaderName, this.id = pA++, this.cacheKey = t, this.usedTimes = 1, this.program = b, this.vertexShader = F, this.fragmentShader = L, this;
}
let OA = 0;
class PA {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(t) {
    const i = t.vertexShader, s = t.fragmentShader, l = this._getShaderStage(i), c = this._getShaderStage(s), h = this._getShaderCacheForMaterial(t);
    return h.has(l) === !1 && (h.add(l), l.usedTimes++), h.has(c) === !1 && (h.add(c), c.usedTimes++), this;
  }
  remove(t) {
    const i = this.materialCache.get(t);
    for (const s of i)
      s.usedTimes--, s.usedTimes === 0 && this.shaderCache.delete(s.code);
    return this.materialCache.delete(t), this;
  }
  getVertexShaderID(t) {
    return this._getShaderStage(t.vertexShader).id;
  }
  getFragmentShaderID(t) {
    return this._getShaderStage(t.fragmentShader).id;
  }
  dispose() {
    this.shaderCache.clear(), this.materialCache.clear();
  }
  _getShaderCacheForMaterial(t) {
    const i = this.materialCache;
    let s = i.get(t);
    return s === void 0 && (s = /* @__PURE__ */ new Set(), i.set(t, s)), s;
  }
  _getShaderStage(t) {
    const i = this.shaderCache;
    let s = i.get(t);
    return s === void 0 && (s = new zA(t), i.set(t, s)), s;
  }
}
class zA {
  constructor(t) {
    this.id = OA++, this.code = t, this.usedTimes = 0;
  }
}
function BA(r, t, i, s, l, c, h) {
  const d = new mx(), m = new PA(), p = /* @__PURE__ */ new Set(), g = [], _ = l.logarithmicDepthBuffer, x = l.vertexTextures;
  let S = l.precision;
  const E = {
    MeshDepthMaterial: "depth",
    MeshDistanceMaterial: "distanceRGBA",
    MeshNormalMaterial: "normal",
    MeshBasicMaterial: "basic",
    MeshLambertMaterial: "lambert",
    MeshPhongMaterial: "phong",
    MeshToonMaterial: "toon",
    MeshStandardMaterial: "physical",
    MeshPhysicalMaterial: "physical",
    MeshMatcapMaterial: "matcap",
    LineBasicMaterial: "basic",
    LineDashedMaterial: "dashed",
    PointsMaterial: "points",
    ShadowMaterial: "shadow",
    SpriteMaterial: "sprite"
  };
  function b(C) {
    return p.add(C), C === 0 ? "uv" : `uv${C}`;
  }
  function M(C, T, I, J, $) {
    const lt = J.fog, pt = $.geometry, z = C.isMeshStandardMaterial ? J.environment : null, tt = (C.isMeshStandardMaterial ? i : t).get(C.envMap || z), K = tt && tt.mapping === xu ? tt.image.height : null, yt = E[C.type];
    C.precision !== null && (S = l.getMaxPrecision(C.precision), S !== C.precision && console.warn("THREE.WebGLProgram.getParameters:", C.precision, "not supported, using", S, "instead."));
    const Mt = pt.morphAttributes.position || pt.morphAttributes.normal || pt.morphAttributes.color, P = Mt !== void 0 ? Mt.length : 0;
    let st = 0;
    pt.morphAttributes.position !== void 0 && (st = 1), pt.morphAttributes.normal !== void 0 && (st = 2), pt.morphAttributes.color !== void 0 && (st = 3);
    let xt, j, ht, Et;
    if (yt) {
      const Ae = Ii[yt];
      xt = Ae.vertexShader, j = Ae.fragmentShader;
    } else
      xt = C.vertexShader, j = C.fragmentShader, m.update(C), ht = m.getVertexShaderID(C), Et = m.getFragmentShaderID(C);
    const vt = r.getRenderTarget(), Ht = r.state.buffers.depth.getReversed(), Lt = $.isInstancedMesh === !0, ae = $.isBatchedMesh === !0, Ne = !!C.map, de = !!C.matcap, We = !!tt, V = !!C.aoMap, vn = !!C.lightMap, fe = !!C.bumpMap, pe = !!C.normalMap, Yt = !!C.displacementMap, Ue = !!C.emissiveMap, Xt = !!C.metalnessMap, N = !!C.roughnessMap, R = C.anisotropy > 0, it = C.clearcoat > 0, dt = C.dispersion > 0, St = C.iridescence > 0, Q = C.sheen > 0, Tt = C.transmission > 0, wt = R && !!C.anisotropyMap, Bt = it && !!C.clearcoatMap, xe = it && !!C.clearcoatNormalMap, Ct = it && !!C.clearcoatRoughnessMap, Gt = St && !!C.iridescenceMap, jt = St && !!C.iridescenceThicknessMap, Wt = Q && !!C.sheenColorMap, It = Q && !!C.sheenRoughnessMap, te = !!C.specularMap, oe = !!C.specularColorMap, ze = !!C.specularIntensityMap, W = Tt && !!C.transmissionMap, Dt = Tt && !!C.thicknessMap, ut = !!C.gradientMap, _t = !!C.alphaMap, Ut = C.alphaTest > 0, Nt = !!C.alphaHash, ee = !!C.extensions;
    let Ke = Ja;
    C.toneMapped && (vt === null || vt.isXRRenderTarget === !0) && (Ke = r.toneMapping);
    const hn = {
      shaderID: yt,
      shaderType: C.type,
      shaderName: C.name,
      vertexShader: xt,
      fragmentShader: j,
      defines: C.defines,
      customVertexShaderID: ht,
      customFragmentShaderID: Et,
      isRawShaderMaterial: C.isRawShaderMaterial === !0,
      glslVersion: C.glslVersion,
      precision: S,
      batching: ae,
      batchingColor: ae && $._colorsTexture !== null,
      instancing: Lt,
      instancingColor: Lt && $.instanceColor !== null,
      instancingMorph: Lt && $.morphTexture !== null,
      supportsVertexTextures: x,
      outputColorSpace: vt === null ? r.outputColorSpace : vt.isXRRenderTarget === !0 ? vt.texture.colorSpace : $r,
      alphaToCoverage: !!C.alphaToCoverage,
      map: Ne,
      matcap: de,
      envMap: We,
      envMapMode: We && tt.mapping,
      envMapCubeUVHeight: K,
      aoMap: V,
      lightMap: vn,
      bumpMap: fe,
      normalMap: pe,
      displacementMap: x && Yt,
      emissiveMap: Ue,
      normalMapObjectSpace: pe && C.normalMapType === wM,
      normalMapTangentSpace: pe && C.normalMapType === ux,
      metalnessMap: Xt,
      roughnessMap: N,
      anisotropy: R,
      anisotropyMap: wt,
      clearcoat: it,
      clearcoatMap: Bt,
      clearcoatNormalMap: xe,
      clearcoatRoughnessMap: Ct,
      dispersion: dt,
      iridescence: St,
      iridescenceMap: Gt,
      iridescenceThicknessMap: jt,
      sheen: Q,
      sheenColorMap: Wt,
      sheenRoughnessMap: It,
      specularMap: te,
      specularColorMap: oe,
      specularIntensityMap: ze,
      transmission: Tt,
      transmissionMap: W,
      thicknessMap: Dt,
      gradientMap: ut,
      opaque: C.transparent === !1 && C.blending === Wr && C.alphaToCoverage === !1,
      alphaMap: _t,
      alphaTest: Ut,
      alphaHash: Nt,
      combine: C.combine,
      //
      mapUv: Ne && b(C.map.channel),
      aoMapUv: V && b(C.aoMap.channel),
      lightMapUv: vn && b(C.lightMap.channel),
      bumpMapUv: fe && b(C.bumpMap.channel),
      normalMapUv: pe && b(C.normalMap.channel),
      displacementMapUv: Yt && b(C.displacementMap.channel),
      emissiveMapUv: Ue && b(C.emissiveMap.channel),
      metalnessMapUv: Xt && b(C.metalnessMap.channel),
      roughnessMapUv: N && b(C.roughnessMap.channel),
      anisotropyMapUv: wt && b(C.anisotropyMap.channel),
      clearcoatMapUv: Bt && b(C.clearcoatMap.channel),
      clearcoatNormalMapUv: xe && b(C.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: Ct && b(C.clearcoatRoughnessMap.channel),
      iridescenceMapUv: Gt && b(C.iridescenceMap.channel),
      iridescenceThicknessMapUv: jt && b(C.iridescenceThicknessMap.channel),
      sheenColorMapUv: Wt && b(C.sheenColorMap.channel),
      sheenRoughnessMapUv: It && b(C.sheenRoughnessMap.channel),
      specularMapUv: te && b(C.specularMap.channel),
      specularColorMapUv: oe && b(C.specularColorMap.channel),
      specularIntensityMapUv: ze && b(C.specularIntensityMap.channel),
      transmissionMapUv: W && b(C.transmissionMap.channel),
      thicknessMapUv: Dt && b(C.thicknessMap.channel),
      alphaMapUv: _t && b(C.alphaMap.channel),
      //
      vertexTangents: !!pt.attributes.tangent && (pe || R),
      vertexColors: C.vertexColors,
      vertexAlphas: C.vertexColors === !0 && !!pt.attributes.color && pt.attributes.color.itemSize === 4,
      pointsUvs: $.isPoints === !0 && !!pt.attributes.uv && (Ne || _t),
      fog: !!lt,
      useFog: C.fog === !0,
      fogExp2: !!lt && lt.isFogExp2,
      flatShading: C.flatShading === !0,
      sizeAttenuation: C.sizeAttenuation === !0,
      logarithmicDepthBuffer: _,
      reverseDepthBuffer: Ht,
      skinning: $.isSkinnedMesh === !0,
      morphTargets: pt.morphAttributes.position !== void 0,
      morphNormals: pt.morphAttributes.normal !== void 0,
      morphColors: pt.morphAttributes.color !== void 0,
      morphTargetsCount: P,
      morphTextureStride: st,
      numDirLights: T.directional.length,
      numPointLights: T.point.length,
      numSpotLights: T.spot.length,
      numSpotLightMaps: T.spotLightMap.length,
      numRectAreaLights: T.rectArea.length,
      numHemiLights: T.hemi.length,
      numDirLightShadows: T.directionalShadowMap.length,
      numPointLightShadows: T.pointShadowMap.length,
      numSpotLightShadows: T.spotShadowMap.length,
      numSpotLightShadowsWithMaps: T.numSpotLightShadowsWithMaps,
      numLightProbes: T.numLightProbes,
      numClippingPlanes: h.numPlanes,
      numClipIntersection: h.numIntersection,
      dithering: C.dithering,
      shadowMapEnabled: r.shadowMap.enabled && I.length > 0,
      shadowMapType: r.shadowMap.type,
      toneMapping: Ke,
      decodeVideoTexture: Ne && C.map.isVideoTexture === !0 && De.getTransfer(C.map.colorSpace) === Ge,
      decodeVideoTextureEmissive: Ue && C.emissiveMap.isVideoTexture === !0 && De.getTransfer(C.emissiveMap.colorSpace) === Ge,
      premultipliedAlpha: C.premultipliedAlpha,
      doubleSided: C.side === da,
      flipSided: C.side === ti,
      useDepthPacking: C.depthPacking >= 0,
      depthPacking: C.depthPacking || 0,
      index0AttributeName: C.index0AttributeName,
      extensionClipCullDistance: ee && C.extensions.clipCullDistance === !0 && s.has("WEBGL_clip_cull_distance"),
      extensionMultiDraw: (ee && C.extensions.multiDraw === !0 || ae) && s.has("WEBGL_multi_draw"),
      rendererExtensionParallelShaderCompile: s.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: C.customProgramCacheKey()
    };
    return hn.vertexUv1s = p.has(1), hn.vertexUv2s = p.has(2), hn.vertexUv3s = p.has(3), p.clear(), hn;
  }
  function v(C) {
    const T = [];
    if (C.shaderID ? T.push(C.shaderID) : (T.push(C.customVertexShaderID), T.push(C.customFragmentShaderID)), C.defines !== void 0)
      for (const I in C.defines)
        T.push(I), T.push(C.defines[I]);
    return C.isRawShaderMaterial === !1 && (B(T, C), U(T, C), T.push(r.outputColorSpace)), T.push(C.customProgramCacheKey), T.join();
  }
  function B(C, T) {
    C.push(T.precision), C.push(T.outputColorSpace), C.push(T.envMapMode), C.push(T.envMapCubeUVHeight), C.push(T.mapUv), C.push(T.alphaMapUv), C.push(T.lightMapUv), C.push(T.aoMapUv), C.push(T.bumpMapUv), C.push(T.normalMapUv), C.push(T.displacementMapUv), C.push(T.emissiveMapUv), C.push(T.metalnessMapUv), C.push(T.roughnessMapUv), C.push(T.anisotropyMapUv), C.push(T.clearcoatMapUv), C.push(T.clearcoatNormalMapUv), C.push(T.clearcoatRoughnessMapUv), C.push(T.iridescenceMapUv), C.push(T.iridescenceThicknessMapUv), C.push(T.sheenColorMapUv), C.push(T.sheenRoughnessMapUv), C.push(T.specularMapUv), C.push(T.specularColorMapUv), C.push(T.specularIntensityMapUv), C.push(T.transmissionMapUv), C.push(T.thicknessMapUv), C.push(T.combine), C.push(T.fogExp2), C.push(T.sizeAttenuation), C.push(T.morphTargetsCount), C.push(T.morphAttributeCount), C.push(T.numDirLights), C.push(T.numPointLights), C.push(T.numSpotLights), C.push(T.numSpotLightMaps), C.push(T.numHemiLights), C.push(T.numRectAreaLights), C.push(T.numDirLightShadows), C.push(T.numPointLightShadows), C.push(T.numSpotLightShadows), C.push(T.numSpotLightShadowsWithMaps), C.push(T.numLightProbes), C.push(T.shadowMapType), C.push(T.toneMapping), C.push(T.numClippingPlanes), C.push(T.numClipIntersection), C.push(T.depthPacking);
  }
  function U(C, T) {
    d.disableAll(), T.supportsVertexTextures && d.enable(0), T.instancing && d.enable(1), T.instancingColor && d.enable(2), T.instancingMorph && d.enable(3), T.matcap && d.enable(4), T.envMap && d.enable(5), T.normalMapObjectSpace && d.enable(6), T.normalMapTangentSpace && d.enable(7), T.clearcoat && d.enable(8), T.iridescence && d.enable(9), T.alphaTest && d.enable(10), T.vertexColors && d.enable(11), T.vertexAlphas && d.enable(12), T.vertexUv1s && d.enable(13), T.vertexUv2s && d.enable(14), T.vertexUv3s && d.enable(15), T.vertexTangents && d.enable(16), T.anisotropy && d.enable(17), T.alphaHash && d.enable(18), T.batching && d.enable(19), T.dispersion && d.enable(20), T.batchingColor && d.enable(21), C.push(d.mask), d.disableAll(), T.fog && d.enable(0), T.useFog && d.enable(1), T.flatShading && d.enable(2), T.logarithmicDepthBuffer && d.enable(3), T.reverseDepthBuffer && d.enable(4), T.skinning && d.enable(5), T.morphTargets && d.enable(6), T.morphNormals && d.enable(7), T.morphColors && d.enable(8), T.premultipliedAlpha && d.enable(9), T.shadowMapEnabled && d.enable(10), T.doubleSided && d.enable(11), T.flipSided && d.enable(12), T.useDepthPacking && d.enable(13), T.dithering && d.enable(14), T.transmission && d.enable(15), T.sheen && d.enable(16), T.opaque && d.enable(17), T.pointsUvs && d.enable(18), T.decodeVideoTexture && d.enable(19), T.decodeVideoTextureEmissive && d.enable(20), T.alphaToCoverage && d.enable(21), C.push(d.mask);
  }
  function w(C) {
    const T = E[C.type];
    let I;
    if (T) {
      const J = Ii[T];
      I = rE.clone(J.uniforms);
    } else
      I = C.uniforms;
    return I;
  }
  function F(C, T) {
    let I;
    for (let J = 0, $ = g.length; J < $; J++) {
      const lt = g[J];
      if (lt.cacheKey === T) {
        I = lt, ++I.usedTimes;
        break;
      }
    }
    return I === void 0 && (I = new NA(r, T, C, c), g.push(I)), I;
  }
  function L(C) {
    if (--C.usedTimes === 0) {
      const T = g.indexOf(C);
      g[T] = g[g.length - 1], g.pop(), C.destroy();
    }
  }
  function O(C) {
    m.remove(C);
  }
  function G() {
    m.dispose();
  }
  return {
    getParameters: M,
    getProgramCacheKey: v,
    getUniforms: w,
    acquireProgram: F,
    releaseProgram: L,
    releaseShaderCache: O,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: g,
    dispose: G
  };
}
function IA() {
  let r = /* @__PURE__ */ new WeakMap();
  function t(h) {
    return r.has(h);
  }
  function i(h) {
    let d = r.get(h);
    return d === void 0 && (d = {}, r.set(h, d)), d;
  }
  function s(h) {
    r.delete(h);
  }
  function l(h, d, m) {
    r.get(h)[d] = m;
  }
  function c() {
    r = /* @__PURE__ */ new WeakMap();
  }
  return {
    has: t,
    get: i,
    remove: s,
    update: l,
    dispose: c
  };
}
function FA(r, t) {
  return r.groupOrder !== t.groupOrder ? r.groupOrder - t.groupOrder : r.renderOrder !== t.renderOrder ? r.renderOrder - t.renderOrder : r.material.id !== t.material.id ? r.material.id - t.material.id : r.z !== t.z ? r.z - t.z : r.id - t.id;
}
function wv(r, t) {
  return r.groupOrder !== t.groupOrder ? r.groupOrder - t.groupOrder : r.renderOrder !== t.renderOrder ? r.renderOrder - t.renderOrder : r.z !== t.z ? t.z - r.z : r.id - t.id;
}
function Dv() {
  const r = [];
  let t = 0;
  const i = [], s = [], l = [];
  function c() {
    t = 0, i.length = 0, s.length = 0, l.length = 0;
  }
  function h(_, x, S, E, b, M) {
    let v = r[t];
    return v === void 0 ? (v = {
      id: _.id,
      object: _,
      geometry: x,
      material: S,
      groupOrder: E,
      renderOrder: _.renderOrder,
      z: b,
      group: M
    }, r[t] = v) : (v.id = _.id, v.object = _, v.geometry = x, v.material = S, v.groupOrder = E, v.renderOrder = _.renderOrder, v.z = b, v.group = M), t++, v;
  }
  function d(_, x, S, E, b, M) {
    const v = h(_, x, S, E, b, M);
    S.transmission > 0 ? s.push(v) : S.transparent === !0 ? l.push(v) : i.push(v);
  }
  function m(_, x, S, E, b, M) {
    const v = h(_, x, S, E, b, M);
    S.transmission > 0 ? s.unshift(v) : S.transparent === !0 ? l.unshift(v) : i.unshift(v);
  }
  function p(_, x) {
    i.length > 1 && i.sort(_ || FA), s.length > 1 && s.sort(x || wv), l.length > 1 && l.sort(x || wv);
  }
  function g() {
    for (let _ = t, x = r.length; _ < x; _++) {
      const S = r[_];
      if (S.id === null) break;
      S.id = null, S.object = null, S.geometry = null, S.material = null, S.group = null;
    }
  }
  return {
    opaque: i,
    transmissive: s,
    transparent: l,
    init: c,
    push: d,
    unshift: m,
    finish: g,
    sort: p
  };
}
function HA() {
  let r = /* @__PURE__ */ new WeakMap();
  function t(s, l) {
    const c = r.get(s);
    let h;
    return c === void 0 ? (h = new Dv(), r.set(s, [h])) : l >= c.length ? (h = new Dv(), c.push(h)) : h = c[l], h;
  }
  function i() {
    r = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: t,
    dispose: i
  };
}
function GA() {
  const r = {};
  return {
    get: function(t) {
      if (r[t.id] !== void 0)
        return r[t.id];
      let i;
      switch (t.type) {
        case "DirectionalLight":
          i = {
            direction: new q(),
            color: new ve()
          };
          break;
        case "SpotLight":
          i = {
            position: new q(),
            direction: new q(),
            color: new ve(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          i = {
            position: new q(),
            color: new ve(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          i = {
            direction: new q(),
            skyColor: new ve(),
            groundColor: new ve()
          };
          break;
        case "RectAreaLight":
          i = {
            color: new ve(),
            position: new q(),
            halfWidth: new q(),
            halfHeight: new q()
          };
          break;
      }
      return r[t.id] = i, i;
    }
  };
}
function VA() {
  const r = {};
  return {
    get: function(t) {
      if (r[t.id] !== void 0)
        return r[t.id];
      let i;
      switch (t.type) {
        case "DirectionalLight":
          i = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new $t()
          };
          break;
        case "SpotLight":
          i = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new $t()
          };
          break;
        case "PointLight":
          i = {
            shadowIntensity: 1,
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new $t(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return r[t.id] = i, i;
    }
  };
}
let kA = 0;
function XA(r, t) {
  return (t.castShadow ? 2 : 0) - (r.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (r.map ? 1 : 0);
}
function WA(r) {
  const t = new GA(), i = VA(), s = {
    version: 0,
    hash: {
      directionalLength: -1,
      pointLength: -1,
      spotLength: -1,
      rectAreaLength: -1,
      hemiLength: -1,
      numDirectionalShadows: -1,
      numPointShadows: -1,
      numSpotShadows: -1,
      numSpotMaps: -1,
      numLightProbes: -1
    },
    ambient: [0, 0, 0],
    probe: [],
    directional: [],
    directionalShadow: [],
    directionalShadowMap: [],
    directionalShadowMatrix: [],
    spot: [],
    spotLightMap: [],
    spotShadow: [],
    spotShadowMap: [],
    spotLightMatrix: [],
    rectArea: [],
    rectAreaLTC1: null,
    rectAreaLTC2: null,
    point: [],
    pointShadow: [],
    pointShadowMap: [],
    pointShadowMatrix: [],
    hemi: [],
    numSpotLightShadowsWithMaps: 0,
    numLightProbes: 0
  };
  for (let p = 0; p < 9; p++) s.probe.push(new q());
  const l = new q(), c = new Xe(), h = new Xe();
  function d(p) {
    let g = 0, _ = 0, x = 0;
    for (let C = 0; C < 9; C++) s.probe[C].set(0, 0, 0);
    let S = 0, E = 0, b = 0, M = 0, v = 0, B = 0, U = 0, w = 0, F = 0, L = 0, O = 0;
    p.sort(XA);
    for (let C = 0, T = p.length; C < T; C++) {
      const I = p[C], J = I.color, $ = I.intensity, lt = I.distance, pt = I.shadow && I.shadow.map ? I.shadow.map.texture : null;
      if (I.isAmbientLight)
        g += J.r * $, _ += J.g * $, x += J.b * $;
      else if (I.isLightProbe) {
        for (let z = 0; z < 9; z++)
          s.probe[z].addScaledVector(I.sh.coefficients[z], $);
        O++;
      } else if (I.isDirectionalLight) {
        const z = t.get(I);
        if (z.color.copy(I.color).multiplyScalar(I.intensity), I.castShadow) {
          const tt = I.shadow, K = i.get(I);
          K.shadowIntensity = tt.intensity, K.shadowBias = tt.bias, K.shadowNormalBias = tt.normalBias, K.shadowRadius = tt.radius, K.shadowMapSize = tt.mapSize, s.directionalShadow[S] = K, s.directionalShadowMap[S] = pt, s.directionalShadowMatrix[S] = I.shadow.matrix, B++;
        }
        s.directional[S] = z, S++;
      } else if (I.isSpotLight) {
        const z = t.get(I);
        z.position.setFromMatrixPosition(I.matrixWorld), z.color.copy(J).multiplyScalar($), z.distance = lt, z.coneCos = Math.cos(I.angle), z.penumbraCos = Math.cos(I.angle * (1 - I.penumbra)), z.decay = I.decay, s.spot[b] = z;
        const tt = I.shadow;
        if (I.map && (s.spotLightMap[F] = I.map, F++, tt.updateMatrices(I), I.castShadow && L++), s.spotLightMatrix[b] = tt.matrix, I.castShadow) {
          const K = i.get(I);
          K.shadowIntensity = tt.intensity, K.shadowBias = tt.bias, K.shadowNormalBias = tt.normalBias, K.shadowRadius = tt.radius, K.shadowMapSize = tt.mapSize, s.spotShadow[b] = K, s.spotShadowMap[b] = pt, w++;
        }
        b++;
      } else if (I.isRectAreaLight) {
        const z = t.get(I);
        z.color.copy(J).multiplyScalar($), z.halfWidth.set(I.width * 0.5, 0, 0), z.halfHeight.set(0, I.height * 0.5, 0), s.rectArea[M] = z, M++;
      } else if (I.isPointLight) {
        const z = t.get(I);
        if (z.color.copy(I.color).multiplyScalar(I.intensity), z.distance = I.distance, z.decay = I.decay, I.castShadow) {
          const tt = I.shadow, K = i.get(I);
          K.shadowIntensity = tt.intensity, K.shadowBias = tt.bias, K.shadowNormalBias = tt.normalBias, K.shadowRadius = tt.radius, K.shadowMapSize = tt.mapSize, K.shadowCameraNear = tt.camera.near, K.shadowCameraFar = tt.camera.far, s.pointShadow[E] = K, s.pointShadowMap[E] = pt, s.pointShadowMatrix[E] = I.shadow.matrix, U++;
        }
        s.point[E] = z, E++;
      } else if (I.isHemisphereLight) {
        const z = t.get(I);
        z.skyColor.copy(I.color).multiplyScalar($), z.groundColor.copy(I.groundColor).multiplyScalar($), s.hemi[v] = z, v++;
      }
    }
    M > 0 && (r.has("OES_texture_float_linear") === !0 ? (s.rectAreaLTC1 = Pt.LTC_FLOAT_1, s.rectAreaLTC2 = Pt.LTC_FLOAT_2) : (s.rectAreaLTC1 = Pt.LTC_HALF_1, s.rectAreaLTC2 = Pt.LTC_HALF_2)), s.ambient[0] = g, s.ambient[1] = _, s.ambient[2] = x;
    const G = s.hash;
    (G.directionalLength !== S || G.pointLength !== E || G.spotLength !== b || G.rectAreaLength !== M || G.hemiLength !== v || G.numDirectionalShadows !== B || G.numPointShadows !== U || G.numSpotShadows !== w || G.numSpotMaps !== F || G.numLightProbes !== O) && (s.directional.length = S, s.spot.length = b, s.rectArea.length = M, s.point.length = E, s.hemi.length = v, s.directionalShadow.length = B, s.directionalShadowMap.length = B, s.pointShadow.length = U, s.pointShadowMap.length = U, s.spotShadow.length = w, s.spotShadowMap.length = w, s.directionalShadowMatrix.length = B, s.pointShadowMatrix.length = U, s.spotLightMatrix.length = w + F - L, s.spotLightMap.length = F, s.numSpotLightShadowsWithMaps = L, s.numLightProbes = O, G.directionalLength = S, G.pointLength = E, G.spotLength = b, G.rectAreaLength = M, G.hemiLength = v, G.numDirectionalShadows = B, G.numPointShadows = U, G.numSpotShadows = w, G.numSpotMaps = F, G.numLightProbes = O, s.version = kA++);
  }
  function m(p, g) {
    let _ = 0, x = 0, S = 0, E = 0, b = 0;
    const M = g.matrixWorldInverse;
    for (let v = 0, B = p.length; v < B; v++) {
      const U = p[v];
      if (U.isDirectionalLight) {
        const w = s.directional[_];
        w.direction.setFromMatrixPosition(U.matrixWorld), l.setFromMatrixPosition(U.target.matrixWorld), w.direction.sub(l), w.direction.transformDirection(M), _++;
      } else if (U.isSpotLight) {
        const w = s.spot[S];
        w.position.setFromMatrixPosition(U.matrixWorld), w.position.applyMatrix4(M), w.direction.setFromMatrixPosition(U.matrixWorld), l.setFromMatrixPosition(U.target.matrixWorld), w.direction.sub(l), w.direction.transformDirection(M), S++;
      } else if (U.isRectAreaLight) {
        const w = s.rectArea[E];
        w.position.setFromMatrixPosition(U.matrixWorld), w.position.applyMatrix4(M), h.identity(), c.copy(U.matrixWorld), c.premultiply(M), h.extractRotation(c), w.halfWidth.set(U.width * 0.5, 0, 0), w.halfHeight.set(0, U.height * 0.5, 0), w.halfWidth.applyMatrix4(h), w.halfHeight.applyMatrix4(h), E++;
      } else if (U.isPointLight) {
        const w = s.point[x];
        w.position.setFromMatrixPosition(U.matrixWorld), w.position.applyMatrix4(M), x++;
      } else if (U.isHemisphereLight) {
        const w = s.hemi[b];
        w.direction.setFromMatrixPosition(U.matrixWorld), w.direction.transformDirection(M), b++;
      }
    }
  }
  return {
    setup: d,
    setupView: m,
    state: s
  };
}
function Uv(r) {
  const t = new WA(r), i = [], s = [];
  function l(g) {
    p.camera = g, i.length = 0, s.length = 0;
  }
  function c(g) {
    i.push(g);
  }
  function h(g) {
    s.push(g);
  }
  function d() {
    t.setup(i);
  }
  function m(g) {
    t.setupView(i, g);
  }
  const p = {
    lightsArray: i,
    shadowsArray: s,
    camera: null,
    lights: t,
    transmissionRenderTarget: {}
  };
  return {
    init: l,
    state: p,
    setupLights: d,
    setupLightsView: m,
    pushLight: c,
    pushShadow: h
  };
}
function YA(r) {
  let t = /* @__PURE__ */ new WeakMap();
  function i(l, c = 0) {
    const h = t.get(l);
    let d;
    return h === void 0 ? (d = new Uv(r), t.set(l, [d])) : c >= h.length ? (d = new Uv(r), h.push(d)) : d = h[c], d;
  }
  function s() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: i,
    dispose: s
  };
}
const qA = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, jA = `uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;
function ZA(r, t, i) {
  let s = new Rp();
  const l = new $t(), c = new $t(), h = new Je(), d = new _E({ depthPacking: CM }), m = new vE(), p = {}, g = i.maxTextureSize, _ = { [ts]: ti, [ti]: ts, [da]: da }, x = new _a({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new $t() },
      radius: { value: 4 }
    },
    vertexShader: qA,
    fragmentShader: jA
  }), S = x.clone();
  S.defines.HORIZONTAL_PASS = 1;
  const E = new Xn();
  E.setAttribute(
    "position",
    new Mn(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const b = new Un(E, x), M = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = $v;
  let v = this.type;
  this.render = function(L, O, G) {
    if (M.enabled === !1 || M.autoUpdate === !1 && M.needsUpdate === !1 || L.length === 0) return;
    const C = r.getRenderTarget(), T = r.getActiveCubeFace(), I = r.getActiveMipmapLevel(), J = r.state;
    J.setBlending(Qa), J.buffers.color.setClear(1, 1, 1, 1), J.buffers.depth.setTest(!0), J.setScissorTest(!1);
    const $ = v !== ha && this.type === ha, lt = v === ha && this.type !== ha;
    for (let pt = 0, z = L.length; pt < z; pt++) {
      const tt = L[pt], K = tt.shadow;
      if (K === void 0) {
        console.warn("THREE.WebGLShadowMap:", tt, "has no shadow.");
        continue;
      }
      if (K.autoUpdate === !1 && K.needsUpdate === !1) continue;
      l.copy(K.mapSize);
      const yt = K.getFrameExtents();
      if (l.multiply(yt), c.copy(K.mapSize), (l.x > g || l.y > g) && (l.x > g && (c.x = Math.floor(g / yt.x), l.x = c.x * yt.x, K.mapSize.x = c.x), l.y > g && (c.y = Math.floor(g / yt.y), l.y = c.y * yt.y, K.mapSize.y = c.y)), K.map === null || $ === !0 || lt === !0) {
        const P = this.type !== ha ? { minFilter: Dn, magFilter: Dn } : {};
        K.map !== null && K.map.dispose(), K.map = new zs(l.x, l.y, P), K.map.texture.name = tt.name + ".shadowMap", K.camera.updateProjectionMatrix();
      }
      r.setRenderTarget(K.map), r.clear();
      const Mt = K.getViewportCount();
      for (let P = 0; P < Mt; P++) {
        const st = K.getViewport(P);
        h.set(
          c.x * st.x,
          c.y * st.y,
          c.x * st.z,
          c.y * st.w
        ), J.viewport(h), K.updateMatrices(tt, P), s = K.getFrustum(), w(O, G, K.camera, tt, this.type);
      }
      K.isPointLightShadow !== !0 && this.type === ha && B(K, G), K.needsUpdate = !1;
    }
    v = this.type, M.needsUpdate = !1, r.setRenderTarget(C, T, I);
  };
  function B(L, O) {
    const G = t.update(b);
    x.defines.VSM_SAMPLES !== L.blurSamples && (x.defines.VSM_SAMPLES = L.blurSamples, S.defines.VSM_SAMPLES = L.blurSamples, x.needsUpdate = !0, S.needsUpdate = !0), L.mapPass === null && (L.mapPass = new zs(l.x, l.y)), x.uniforms.shadow_pass.value = L.map.texture, x.uniforms.resolution.value = L.mapSize, x.uniforms.radius.value = L.radius, r.setRenderTarget(L.mapPass), r.clear(), r.renderBufferDirect(O, null, G, x, b, null), S.uniforms.shadow_pass.value = L.mapPass.texture, S.uniforms.resolution.value = L.mapSize, S.uniforms.radius.value = L.radius, r.setRenderTarget(L.map), r.clear(), r.renderBufferDirect(O, null, G, S, b, null);
  }
  function U(L, O, G, C) {
    let T = null;
    const I = G.isPointLight === !0 ? L.customDistanceMaterial : L.customDepthMaterial;
    if (I !== void 0)
      T = I;
    else if (T = G.isPointLight === !0 ? m : d, r.localClippingEnabled && O.clipShadows === !0 && Array.isArray(O.clippingPlanes) && O.clippingPlanes.length !== 0 || O.displacementMap && O.displacementScale !== 0 || O.alphaMap && O.alphaTest > 0 || O.map && O.alphaTest > 0) {
      const J = T.uuid, $ = O.uuid;
      let lt = p[J];
      lt === void 0 && (lt = {}, p[J] = lt);
      let pt = lt[$];
      pt === void 0 && (pt = T.clone(), lt[$] = pt, O.addEventListener("dispose", F)), T = pt;
    }
    if (T.visible = O.visible, T.wireframe = O.wireframe, C === ha ? T.side = O.shadowSide !== null ? O.shadowSide : O.side : T.side = O.shadowSide !== null ? O.shadowSide : _[O.side], T.alphaMap = O.alphaMap, T.alphaTest = O.alphaTest, T.map = O.map, T.clipShadows = O.clipShadows, T.clippingPlanes = O.clippingPlanes, T.clipIntersection = O.clipIntersection, T.displacementMap = O.displacementMap, T.displacementScale = O.displacementScale, T.displacementBias = O.displacementBias, T.wireframeLinewidth = O.wireframeLinewidth, T.linewidth = O.linewidth, G.isPointLight === !0 && T.isMeshDistanceMaterial === !0) {
      const J = r.properties.get(T);
      J.light = G;
    }
    return T;
  }
  function w(L, O, G, C, T) {
    if (L.visible === !1) return;
    if (L.layers.test(O.layers) && (L.isMesh || L.isLine || L.isPoints) && (L.castShadow || L.receiveShadow && T === ha) && (!L.frustumCulled || s.intersectsObject(L))) {
      L.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse, L.matrixWorld);
      const $ = t.update(L), lt = L.material;
      if (Array.isArray(lt)) {
        const pt = $.groups;
        for (let z = 0, tt = pt.length; z < tt; z++) {
          const K = pt[z], yt = lt[K.materialIndex];
          if (yt && yt.visible) {
            const Mt = U(L, yt, C, T);
            L.onBeforeShadow(r, L, O, G, $, Mt, K), r.renderBufferDirect(G, null, $, Mt, L, K), L.onAfterShadow(r, L, O, G, $, Mt, K);
          }
        }
      } else if (lt.visible) {
        const pt = U(L, lt, C, T);
        L.onBeforeShadow(r, L, O, G, $, pt, null), r.renderBufferDirect(G, null, $, pt, L, null), L.onAfterShadow(r, L, O, G, $, pt, null);
      }
    }
    const J = L.children;
    for (let $ = 0, lt = J.length; $ < lt; $++)
      w(J[$], O, G, C, T);
  }
  function F(L) {
    L.target.removeEventListener("dispose", F);
    for (const G in p) {
      const C = p[G], T = L.target.uuid;
      T in C && (C[T].dispose(), delete C[T]);
    }
  }
}
const KA = {
  [bd]: Td,
  [Ad]: wd,
  [Rd]: Dd,
  [jr]: Cd,
  [Td]: bd,
  [wd]: Ad,
  [Dd]: Rd,
  [Cd]: jr
};
function QA(r, t) {
  function i() {
    let W = !1;
    const Dt = new Je();
    let ut = null;
    const _t = new Je(0, 0, 0, 0);
    return {
      setMask: function(Ut) {
        ut !== Ut && !W && (r.colorMask(Ut, Ut, Ut, Ut), ut = Ut);
      },
      setLocked: function(Ut) {
        W = Ut;
      },
      setClear: function(Ut, Nt, ee, Ke, hn) {
        hn === !0 && (Ut *= Ke, Nt *= Ke, ee *= Ke), Dt.set(Ut, Nt, ee, Ke), _t.equals(Dt) === !1 && (r.clearColor(Ut, Nt, ee, Ke), _t.copy(Dt));
      },
      reset: function() {
        W = !1, ut = null, _t.set(-1, 0, 0, 0);
      }
    };
  }
  function s() {
    let W = !1, Dt = !1, ut = null, _t = null, Ut = null;
    return {
      setReversed: function(Nt) {
        if (Dt !== Nt) {
          const ee = t.get("EXT_clip_control");
          Dt ? ee.clipControlEXT(ee.LOWER_LEFT_EXT, ee.ZERO_TO_ONE_EXT) : ee.clipControlEXT(ee.LOWER_LEFT_EXT, ee.NEGATIVE_ONE_TO_ONE_EXT);
          const Ke = Ut;
          Ut = null, this.setClear(Ke);
        }
        Dt = Nt;
      },
      getReversed: function() {
        return Dt;
      },
      setTest: function(Nt) {
        Nt ? vt(r.DEPTH_TEST) : Ht(r.DEPTH_TEST);
      },
      setMask: function(Nt) {
        ut !== Nt && !W && (r.depthMask(Nt), ut = Nt);
      },
      setFunc: function(Nt) {
        if (Dt && (Nt = KA[Nt]), _t !== Nt) {
          switch (Nt) {
            case bd:
              r.depthFunc(r.NEVER);
              break;
            case Td:
              r.depthFunc(r.ALWAYS);
              break;
            case Ad:
              r.depthFunc(r.LESS);
              break;
            case jr:
              r.depthFunc(r.LEQUAL);
              break;
            case Rd:
              r.depthFunc(r.EQUAL);
              break;
            case Cd:
              r.depthFunc(r.GEQUAL);
              break;
            case wd:
              r.depthFunc(r.GREATER);
              break;
            case Dd:
              r.depthFunc(r.NOTEQUAL);
              break;
            default:
              r.depthFunc(r.LEQUAL);
          }
          _t = Nt;
        }
      },
      setLocked: function(Nt) {
        W = Nt;
      },
      setClear: function(Nt) {
        Ut !== Nt && (Dt && (Nt = 1 - Nt), r.clearDepth(Nt), Ut = Nt);
      },
      reset: function() {
        W = !1, ut = null, _t = null, Ut = null, Dt = !1;
      }
    };
  }
  function l() {
    let W = !1, Dt = null, ut = null, _t = null, Ut = null, Nt = null, ee = null, Ke = null, hn = null;
    return {
      setTest: function(Ae) {
        W || (Ae ? vt(r.STENCIL_TEST) : Ht(r.STENCIL_TEST));
      },
      setMask: function(Ae) {
        Dt !== Ae && !W && (r.stencilMask(Ae), Dt = Ae);
      },
      setFunc: function(Ae, En, bi) {
        (ut !== Ae || _t !== En || Ut !== bi) && (r.stencilFunc(Ae, En, bi), ut = Ae, _t = En, Ut = bi);
      },
      setOp: function(Ae, En, bi) {
        (Nt !== Ae || ee !== En || Ke !== bi) && (r.stencilOp(Ae, En, bi), Nt = Ae, ee = En, Ke = bi);
      },
      setLocked: function(Ae) {
        W = Ae;
      },
      setClear: function(Ae) {
        hn !== Ae && (r.clearStencil(Ae), hn = Ae);
      },
      reset: function() {
        W = !1, Dt = null, ut = null, _t = null, Ut = null, Nt = null, ee = null, Ke = null, hn = null;
      }
    };
  }
  const c = new i(), h = new s(), d = new l(), m = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
  let g = {}, _ = {}, x = /* @__PURE__ */ new WeakMap(), S = [], E = null, b = !1, M = null, v = null, B = null, U = null, w = null, F = null, L = null, O = new ve(0, 0, 0), G = 0, C = !1, T = null, I = null, J = null, $ = null, lt = null;
  const pt = r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let z = !1, tt = 0;
  const K = r.getParameter(r.VERSION);
  K.indexOf("WebGL") !== -1 ? (tt = parseFloat(/^WebGL (\d)/.exec(K)[1]), z = tt >= 1) : K.indexOf("OpenGL ES") !== -1 && (tt = parseFloat(/^OpenGL ES (\d)/.exec(K)[1]), z = tt >= 2);
  let yt = null, Mt = {};
  const P = r.getParameter(r.SCISSOR_BOX), st = r.getParameter(r.VIEWPORT), xt = new Je().fromArray(P), j = new Je().fromArray(st);
  function ht(W, Dt, ut, _t) {
    const Ut = new Uint8Array(4), Nt = r.createTexture();
    r.bindTexture(W, Nt), r.texParameteri(W, r.TEXTURE_MIN_FILTER, r.NEAREST), r.texParameteri(W, r.TEXTURE_MAG_FILTER, r.NEAREST);
    for (let ee = 0; ee < ut; ee++)
      W === r.TEXTURE_3D || W === r.TEXTURE_2D_ARRAY ? r.texImage3D(Dt, 0, r.RGBA, 1, 1, _t, 0, r.RGBA, r.UNSIGNED_BYTE, Ut) : r.texImage2D(Dt + ee, 0, r.RGBA, 1, 1, 0, r.RGBA, r.UNSIGNED_BYTE, Ut);
    return Nt;
  }
  const Et = {};
  Et[r.TEXTURE_2D] = ht(r.TEXTURE_2D, r.TEXTURE_2D, 1), Et[r.TEXTURE_CUBE_MAP] = ht(r.TEXTURE_CUBE_MAP, r.TEXTURE_CUBE_MAP_POSITIVE_X, 6), Et[r.TEXTURE_2D_ARRAY] = ht(r.TEXTURE_2D_ARRAY, r.TEXTURE_2D_ARRAY, 1, 1), Et[r.TEXTURE_3D] = ht(r.TEXTURE_3D, r.TEXTURE_3D, 1, 1), c.setClear(0, 0, 0, 1), h.setClear(1), d.setClear(0), vt(r.DEPTH_TEST), h.setFunc(jr), fe(!1), pe(b0), vt(r.CULL_FACE), V(Qa);
  function vt(W) {
    g[W] !== !0 && (r.enable(W), g[W] = !0);
  }
  function Ht(W) {
    g[W] !== !1 && (r.disable(W), g[W] = !1);
  }
  function Lt(W, Dt) {
    return _[W] !== Dt ? (r.bindFramebuffer(W, Dt), _[W] = Dt, W === r.DRAW_FRAMEBUFFER && (_[r.FRAMEBUFFER] = Dt), W === r.FRAMEBUFFER && (_[r.DRAW_FRAMEBUFFER] = Dt), !0) : !1;
  }
  function ae(W, Dt) {
    let ut = S, _t = !1;
    if (W) {
      ut = x.get(Dt), ut === void 0 && (ut = [], x.set(Dt, ut));
      const Ut = W.textures;
      if (ut.length !== Ut.length || ut[0] !== r.COLOR_ATTACHMENT0) {
        for (let Nt = 0, ee = Ut.length; Nt < ee; Nt++)
          ut[Nt] = r.COLOR_ATTACHMENT0 + Nt;
        ut.length = Ut.length, _t = !0;
      }
    } else
      ut[0] !== r.BACK && (ut[0] = r.BACK, _t = !0);
    _t && r.drawBuffers(ut);
  }
  function Ne(W) {
    return E !== W ? (r.useProgram(W), E = W, !0) : !1;
  }
  const de = {
    [ws]: r.FUNC_ADD,
    [tM]: r.FUNC_SUBTRACT,
    [eM]: r.FUNC_REVERSE_SUBTRACT
  };
  de[nM] = r.MIN, de[iM] = r.MAX;
  const We = {
    [aM]: r.ZERO,
    [sM]: r.ONE,
    [rM]: r.SRC_COLOR,
    [Md]: r.SRC_ALPHA,
    [hM]: r.SRC_ALPHA_SATURATE,
    [uM]: r.DST_COLOR,
    [lM]: r.DST_ALPHA,
    [oM]: r.ONE_MINUS_SRC_COLOR,
    [Ed]: r.ONE_MINUS_SRC_ALPHA,
    [fM]: r.ONE_MINUS_DST_COLOR,
    [cM]: r.ONE_MINUS_DST_ALPHA,
    [dM]: r.CONSTANT_COLOR,
    [pM]: r.ONE_MINUS_CONSTANT_COLOR,
    [mM]: r.CONSTANT_ALPHA,
    [gM]: r.ONE_MINUS_CONSTANT_ALPHA
  };
  function V(W, Dt, ut, _t, Ut, Nt, ee, Ke, hn, Ae) {
    if (W === Qa) {
      b === !0 && (Ht(r.BLEND), b = !1);
      return;
    }
    if (b === !1 && (vt(r.BLEND), b = !0), W !== $S) {
      if (W !== M || Ae !== C) {
        if ((v !== ws || w !== ws) && (r.blendEquation(r.FUNC_ADD), v = ws, w = ws), Ae)
          switch (W) {
            case Wr:
              r.blendFuncSeparate(r.ONE, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA);
              break;
            case T0:
              r.blendFunc(r.ONE, r.ONE);
              break;
            case A0:
              r.blendFuncSeparate(r.ZERO, r.ONE_MINUS_SRC_COLOR, r.ZERO, r.ONE);
              break;
            case R0:
              r.blendFuncSeparate(r.ZERO, r.SRC_COLOR, r.ZERO, r.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", W);
              break;
          }
        else
          switch (W) {
            case Wr:
              r.blendFuncSeparate(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA);
              break;
            case T0:
              r.blendFunc(r.SRC_ALPHA, r.ONE);
              break;
            case A0:
              r.blendFuncSeparate(r.ZERO, r.ONE_MINUS_SRC_COLOR, r.ZERO, r.ONE);
              break;
            case R0:
              r.blendFunc(r.ZERO, r.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", W);
              break;
          }
        B = null, U = null, F = null, L = null, O.set(0, 0, 0), G = 0, M = W, C = Ae;
      }
      return;
    }
    Ut = Ut || Dt, Nt = Nt || ut, ee = ee || _t, (Dt !== v || Ut !== w) && (r.blendEquationSeparate(de[Dt], de[Ut]), v = Dt, w = Ut), (ut !== B || _t !== U || Nt !== F || ee !== L) && (r.blendFuncSeparate(We[ut], We[_t], We[Nt], We[ee]), B = ut, U = _t, F = Nt, L = ee), (Ke.equals(O) === !1 || hn !== G) && (r.blendColor(Ke.r, Ke.g, Ke.b, hn), O.copy(Ke), G = hn), M = W, C = !1;
  }
  function vn(W, Dt) {
    W.side === da ? Ht(r.CULL_FACE) : vt(r.CULL_FACE);
    let ut = W.side === ti;
    Dt && (ut = !ut), fe(ut), W.blending === Wr && W.transparent === !1 ? V(Qa) : V(W.blending, W.blendEquation, W.blendSrc, W.blendDst, W.blendEquationAlpha, W.blendSrcAlpha, W.blendDstAlpha, W.blendColor, W.blendAlpha, W.premultipliedAlpha), h.setFunc(W.depthFunc), h.setTest(W.depthTest), h.setMask(W.depthWrite), c.setMask(W.colorWrite);
    const _t = W.stencilWrite;
    d.setTest(_t), _t && (d.setMask(W.stencilWriteMask), d.setFunc(W.stencilFunc, W.stencilRef, W.stencilFuncMask), d.setOp(W.stencilFail, W.stencilZFail, W.stencilZPass)), Ue(W.polygonOffset, W.polygonOffsetFactor, W.polygonOffsetUnits), W.alphaToCoverage === !0 ? vt(r.SAMPLE_ALPHA_TO_COVERAGE) : Ht(r.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function fe(W) {
    T !== W && (W ? r.frontFace(r.CW) : r.frontFace(r.CCW), T = W);
  }
  function pe(W) {
    W !== KS ? (vt(r.CULL_FACE), W !== I && (W === b0 ? r.cullFace(r.BACK) : W === QS ? r.cullFace(r.FRONT) : r.cullFace(r.FRONT_AND_BACK))) : Ht(r.CULL_FACE), I = W;
  }
  function Yt(W) {
    W !== J && (z && r.lineWidth(W), J = W);
  }
  function Ue(W, Dt, ut) {
    W ? (vt(r.POLYGON_OFFSET_FILL), ($ !== Dt || lt !== ut) && (r.polygonOffset(Dt, ut), $ = Dt, lt = ut)) : Ht(r.POLYGON_OFFSET_FILL);
  }
  function Xt(W) {
    W ? vt(r.SCISSOR_TEST) : Ht(r.SCISSOR_TEST);
  }
  function N(W) {
    W === void 0 && (W = r.TEXTURE0 + pt - 1), yt !== W && (r.activeTexture(W), yt = W);
  }
  function R(W, Dt, ut) {
    ut === void 0 && (yt === null ? ut = r.TEXTURE0 + pt - 1 : ut = yt);
    let _t = Mt[ut];
    _t === void 0 && (_t = { type: void 0, texture: void 0 }, Mt[ut] = _t), (_t.type !== W || _t.texture !== Dt) && (yt !== ut && (r.activeTexture(ut), yt = ut), r.bindTexture(W, Dt || Et[W]), _t.type = W, _t.texture = Dt);
  }
  function it() {
    const W = Mt[yt];
    W !== void 0 && W.type !== void 0 && (r.bindTexture(W.type, null), W.type = void 0, W.texture = void 0);
  }
  function dt() {
    try {
      r.compressedTexImage2D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function St() {
    try {
      r.compressedTexImage3D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Q() {
    try {
      r.texSubImage2D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Tt() {
    try {
      r.texSubImage3D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function wt() {
    try {
      r.compressedTexSubImage2D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Bt() {
    try {
      r.compressedTexSubImage3D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function xe() {
    try {
      r.texStorage2D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Ct() {
    try {
      r.texStorage3D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Gt() {
    try {
      r.texImage2D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function jt() {
    try {
      r.texImage3D.apply(r, arguments);
    } catch (W) {
      console.error("THREE.WebGLState:", W);
    }
  }
  function Wt(W) {
    xt.equals(W) === !1 && (r.scissor(W.x, W.y, W.z, W.w), xt.copy(W));
  }
  function It(W) {
    j.equals(W) === !1 && (r.viewport(W.x, W.y, W.z, W.w), j.copy(W));
  }
  function te(W, Dt) {
    let ut = p.get(Dt);
    ut === void 0 && (ut = /* @__PURE__ */ new WeakMap(), p.set(Dt, ut));
    let _t = ut.get(W);
    _t === void 0 && (_t = r.getUniformBlockIndex(Dt, W.name), ut.set(W, _t));
  }
  function oe(W, Dt) {
    const _t = p.get(Dt).get(W);
    m.get(Dt) !== _t && (r.uniformBlockBinding(Dt, _t, W.__bindingPointIndex), m.set(Dt, _t));
  }
  function ze() {
    r.disable(r.BLEND), r.disable(r.CULL_FACE), r.disable(r.DEPTH_TEST), r.disable(r.POLYGON_OFFSET_FILL), r.disable(r.SCISSOR_TEST), r.disable(r.STENCIL_TEST), r.disable(r.SAMPLE_ALPHA_TO_COVERAGE), r.blendEquation(r.FUNC_ADD), r.blendFunc(r.ONE, r.ZERO), r.blendFuncSeparate(r.ONE, r.ZERO, r.ONE, r.ZERO), r.blendColor(0, 0, 0, 0), r.colorMask(!0, !0, !0, !0), r.clearColor(0, 0, 0, 0), r.depthMask(!0), r.depthFunc(r.LESS), h.setReversed(!1), r.clearDepth(1), r.stencilMask(4294967295), r.stencilFunc(r.ALWAYS, 0, 4294967295), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), r.clearStencil(0), r.cullFace(r.BACK), r.frontFace(r.CCW), r.polygonOffset(0, 0), r.activeTexture(r.TEXTURE0), r.bindFramebuffer(r.FRAMEBUFFER, null), r.bindFramebuffer(r.DRAW_FRAMEBUFFER, null), r.bindFramebuffer(r.READ_FRAMEBUFFER, null), r.useProgram(null), r.lineWidth(1), r.scissor(0, 0, r.canvas.width, r.canvas.height), r.viewport(0, 0, r.canvas.width, r.canvas.height), g = {}, yt = null, Mt = {}, _ = {}, x = /* @__PURE__ */ new WeakMap(), S = [], E = null, b = !1, M = null, v = null, B = null, U = null, w = null, F = null, L = null, O = new ve(0, 0, 0), G = 0, C = !1, T = null, I = null, J = null, $ = null, lt = null, xt.set(0, 0, r.canvas.width, r.canvas.height), j.set(0, 0, r.canvas.width, r.canvas.height), c.reset(), h.reset(), d.reset();
  }
  return {
    buffers: {
      color: c,
      depth: h,
      stencil: d
    },
    enable: vt,
    disable: Ht,
    bindFramebuffer: Lt,
    drawBuffers: ae,
    useProgram: Ne,
    setBlending: V,
    setMaterial: vn,
    setFlipSided: fe,
    setCullFace: pe,
    setLineWidth: Yt,
    setPolygonOffset: Ue,
    setScissorTest: Xt,
    activeTexture: N,
    bindTexture: R,
    unbindTexture: it,
    compressedTexImage2D: dt,
    compressedTexImage3D: St,
    texImage2D: Gt,
    texImage3D: jt,
    updateUBOMapping: te,
    uniformBlockBinding: oe,
    texStorage2D: xe,
    texStorage3D: Ct,
    texSubImage2D: Q,
    texSubImage3D: Tt,
    compressedTexSubImage2D: wt,
    compressedTexSubImage3D: Bt,
    scissor: Wt,
    viewport: It,
    reset: ze
  };
}
function JA(r, t, i, s, l, c, h) {
  const d = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, m = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), p = new $t(), g = /* @__PURE__ */ new WeakMap();
  let _;
  const x = /* @__PURE__ */ new WeakMap();
  let S = !1;
  try {
    S = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function E(N, R) {
    return S ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(N, R)
    ) : du("canvas");
  }
  function b(N, R, it) {
    let dt = 1;
    const St = Xt(N);
    if ((St.width > it || St.height > it) && (dt = it / Math.max(St.width, St.height)), dt < 1)
      if (typeof HTMLImageElement < "u" && N instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && N instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && N instanceof ImageBitmap || typeof VideoFrame < "u" && N instanceof VideoFrame) {
        const Q = Math.floor(dt * St.width), Tt = Math.floor(dt * St.height);
        _ === void 0 && (_ = E(Q, Tt));
        const wt = R ? E(Q, Tt) : _;
        return wt.width = Q, wt.height = Tt, wt.getContext("2d").drawImage(N, 0, 0, Q, Tt), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + St.width + "x" + St.height + ") to (" + Q + "x" + Tt + ")."), wt;
      } else
        return "data" in N && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + St.width + "x" + St.height + ")."), N;
    return N;
  }
  function M(N) {
    return N.generateMipmaps;
  }
  function v(N) {
    r.generateMipmap(N);
  }
  function B(N) {
    return N.isWebGLCubeRenderTarget ? r.TEXTURE_CUBE_MAP : N.isWebGL3DRenderTarget ? r.TEXTURE_3D : N.isWebGLArrayRenderTarget || N.isCompressedArrayTexture ? r.TEXTURE_2D_ARRAY : r.TEXTURE_2D;
  }
  function U(N, R, it, dt, St = !1) {
    if (N !== null) {
      if (r[N] !== void 0) return r[N];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + N + "'");
    }
    let Q = R;
    if (R === r.RED && (it === r.FLOAT && (Q = r.R32F), it === r.HALF_FLOAT && (Q = r.R16F), it === r.UNSIGNED_BYTE && (Q = r.R8)), R === r.RED_INTEGER && (it === r.UNSIGNED_BYTE && (Q = r.R8UI), it === r.UNSIGNED_SHORT && (Q = r.R16UI), it === r.UNSIGNED_INT && (Q = r.R32UI), it === r.BYTE && (Q = r.R8I), it === r.SHORT && (Q = r.R16I), it === r.INT && (Q = r.R32I)), R === r.RG && (it === r.FLOAT && (Q = r.RG32F), it === r.HALF_FLOAT && (Q = r.RG16F), it === r.UNSIGNED_BYTE && (Q = r.RG8)), R === r.RG_INTEGER && (it === r.UNSIGNED_BYTE && (Q = r.RG8UI), it === r.UNSIGNED_SHORT && (Q = r.RG16UI), it === r.UNSIGNED_INT && (Q = r.RG32UI), it === r.BYTE && (Q = r.RG8I), it === r.SHORT && (Q = r.RG16I), it === r.INT && (Q = r.RG32I)), R === r.RGB_INTEGER && (it === r.UNSIGNED_BYTE && (Q = r.RGB8UI), it === r.UNSIGNED_SHORT && (Q = r.RGB16UI), it === r.UNSIGNED_INT && (Q = r.RGB32UI), it === r.BYTE && (Q = r.RGB8I), it === r.SHORT && (Q = r.RGB16I), it === r.INT && (Q = r.RGB32I)), R === r.RGBA_INTEGER && (it === r.UNSIGNED_BYTE && (Q = r.RGBA8UI), it === r.UNSIGNED_SHORT && (Q = r.RGBA16UI), it === r.UNSIGNED_INT && (Q = r.RGBA32UI), it === r.BYTE && (Q = r.RGBA8I), it === r.SHORT && (Q = r.RGBA16I), it === r.INT && (Q = r.RGBA32I)), R === r.RGB && it === r.UNSIGNED_INT_5_9_9_9_REV && (Q = r.RGB9_E5), R === r.RGBA) {
      const Tt = St ? uu : De.getTransfer(dt);
      it === r.FLOAT && (Q = r.RGBA32F), it === r.HALF_FLOAT && (Q = r.RGBA16F), it === r.UNSIGNED_BYTE && (Q = Tt === Ge ? r.SRGB8_ALPHA8 : r.RGBA8), it === r.UNSIGNED_SHORT_4_4_4_4 && (Q = r.RGBA4), it === r.UNSIGNED_SHORT_5_5_5_1 && (Q = r.RGB5_A1);
    }
    return (Q === r.R16F || Q === r.R32F || Q === r.RG16F || Q === r.RG32F || Q === r.RGBA16F || Q === r.RGBA32F) && t.get("EXT_color_buffer_float"), Q;
  }
  function w(N, R) {
    let it;
    return N ? R === null || R === Ps || R === Qr ? it = r.DEPTH24_STENCIL8 : R === Ei ? it = r.DEPTH32F_STENCIL8 : R === ul && (it = r.DEPTH24_STENCIL8, console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : R === null || R === Ps || R === Qr ? it = r.DEPTH_COMPONENT24 : R === Ei ? it = r.DEPTH_COMPONENT32F : R === ul && (it = r.DEPTH_COMPONENT16), it;
  }
  function F(N, R) {
    return M(N) === !0 || N.isFramebufferTexture && N.minFilter !== Dn && N.minFilter !== Hi ? Math.log2(Math.max(R.width, R.height)) + 1 : N.mipmaps !== void 0 && N.mipmaps.length > 0 ? N.mipmaps.length : N.isCompressedTexture && Array.isArray(N.image) ? R.mipmaps.length : 1;
  }
  function L(N) {
    const R = N.target;
    R.removeEventListener("dispose", L), G(R), R.isVideoTexture && g.delete(R);
  }
  function O(N) {
    const R = N.target;
    R.removeEventListener("dispose", O), T(R);
  }
  function G(N) {
    const R = s.get(N);
    if (R.__webglInit === void 0) return;
    const it = N.source, dt = x.get(it);
    if (dt) {
      const St = dt[R.__cacheKey];
      St.usedTimes--, St.usedTimes === 0 && C(N), Object.keys(dt).length === 0 && x.delete(it);
    }
    s.remove(N);
  }
  function C(N) {
    const R = s.get(N);
    r.deleteTexture(R.__webglTexture);
    const it = N.source, dt = x.get(it);
    delete dt[R.__cacheKey], h.memory.textures--;
  }
  function T(N) {
    const R = s.get(N);
    if (N.depthTexture && (N.depthTexture.dispose(), s.remove(N.depthTexture)), N.isWebGLCubeRenderTarget)
      for (let dt = 0; dt < 6; dt++) {
        if (Array.isArray(R.__webglFramebuffer[dt]))
          for (let St = 0; St < R.__webglFramebuffer[dt].length; St++) r.deleteFramebuffer(R.__webglFramebuffer[dt][St]);
        else
          r.deleteFramebuffer(R.__webglFramebuffer[dt]);
        R.__webglDepthbuffer && r.deleteRenderbuffer(R.__webglDepthbuffer[dt]);
      }
    else {
      if (Array.isArray(R.__webglFramebuffer))
        for (let dt = 0; dt < R.__webglFramebuffer.length; dt++) r.deleteFramebuffer(R.__webglFramebuffer[dt]);
      else
        r.deleteFramebuffer(R.__webglFramebuffer);
      if (R.__webglDepthbuffer && r.deleteRenderbuffer(R.__webglDepthbuffer), R.__webglMultisampledFramebuffer && r.deleteFramebuffer(R.__webglMultisampledFramebuffer), R.__webglColorRenderbuffer)
        for (let dt = 0; dt < R.__webglColorRenderbuffer.length; dt++)
          R.__webglColorRenderbuffer[dt] && r.deleteRenderbuffer(R.__webglColorRenderbuffer[dt]);
      R.__webglDepthRenderbuffer && r.deleteRenderbuffer(R.__webglDepthRenderbuffer);
    }
    const it = N.textures;
    for (let dt = 0, St = it.length; dt < St; dt++) {
      const Q = s.get(it[dt]);
      Q.__webglTexture && (r.deleteTexture(Q.__webglTexture), h.memory.textures--), s.remove(it[dt]);
    }
    s.remove(N);
  }
  let I = 0;
  function J() {
    I = 0;
  }
  function $() {
    const N = I;
    return N >= l.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + N + " texture units while this GPU supports only " + l.maxTextures), I += 1, N;
  }
  function lt(N) {
    const R = [];
    return R.push(N.wrapS), R.push(N.wrapT), R.push(N.wrapR || 0), R.push(N.magFilter), R.push(N.minFilter), R.push(N.anisotropy), R.push(N.internalFormat), R.push(N.format), R.push(N.type), R.push(N.generateMipmaps), R.push(N.premultiplyAlpha), R.push(N.flipY), R.push(N.unpackAlignment), R.push(N.colorSpace), R.join();
  }
  function pt(N, R) {
    const it = s.get(N);
    if (N.isVideoTexture && Yt(N), N.isRenderTargetTexture === !1 && N.version > 0 && it.__version !== N.version) {
      const dt = N.image;
      if (dt === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if (dt.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        j(it, N, R);
        return;
      }
    }
    i.bindTexture(r.TEXTURE_2D, it.__webglTexture, r.TEXTURE0 + R);
  }
  function z(N, R) {
    const it = s.get(N);
    if (N.version > 0 && it.__version !== N.version) {
      j(it, N, R);
      return;
    }
    i.bindTexture(r.TEXTURE_2D_ARRAY, it.__webglTexture, r.TEXTURE0 + R);
  }
  function tt(N, R) {
    const it = s.get(N);
    if (N.version > 0 && it.__version !== N.version) {
      j(it, N, R);
      return;
    }
    i.bindTexture(r.TEXTURE_3D, it.__webglTexture, r.TEXTURE0 + R);
  }
  function K(N, R) {
    const it = s.get(N);
    if (N.version > 0 && it.__version !== N.version) {
      ht(it, N, R);
      return;
    }
    i.bindTexture(r.TEXTURE_CUBE_MAP, it.__webglTexture, r.TEXTURE0 + R);
  }
  const yt = {
    [Nd]: r.REPEAT,
    [Us]: r.CLAMP_TO_EDGE,
    [Od]: r.MIRRORED_REPEAT
  }, Mt = {
    [Dn]: r.NEAREST,
    [AM]: r.NEAREST_MIPMAP_NEAREST,
    [Tc]: r.NEAREST_MIPMAP_LINEAR,
    [Hi]: r.LINEAR,
    [Bh]: r.LINEAR_MIPMAP_NEAREST,
    [Ls]: r.LINEAR_MIPMAP_LINEAR
  }, P = {
    [DM]: r.NEVER,
    [zM]: r.ALWAYS,
    [UM]: r.LESS,
    [fx]: r.LEQUAL,
    [LM]: r.EQUAL,
    [PM]: r.GEQUAL,
    [NM]: r.GREATER,
    [OM]: r.NOTEQUAL
  };
  function st(N, R) {
    if (R.type === Ei && t.has("OES_texture_float_linear") === !1 && (R.magFilter === Hi || R.magFilter === Bh || R.magFilter === Tc || R.magFilter === Ls || R.minFilter === Hi || R.minFilter === Bh || R.minFilter === Tc || R.minFilter === Ls) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), r.texParameteri(N, r.TEXTURE_WRAP_S, yt[R.wrapS]), r.texParameteri(N, r.TEXTURE_WRAP_T, yt[R.wrapT]), (N === r.TEXTURE_3D || N === r.TEXTURE_2D_ARRAY) && r.texParameteri(N, r.TEXTURE_WRAP_R, yt[R.wrapR]), r.texParameteri(N, r.TEXTURE_MAG_FILTER, Mt[R.magFilter]), r.texParameteri(N, r.TEXTURE_MIN_FILTER, Mt[R.minFilter]), R.compareFunction && (r.texParameteri(N, r.TEXTURE_COMPARE_MODE, r.COMPARE_REF_TO_TEXTURE), r.texParameteri(N, r.TEXTURE_COMPARE_FUNC, P[R.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
      if (R.magFilter === Dn || R.minFilter !== Tc && R.minFilter !== Ls || R.type === Ei && t.has("OES_texture_float_linear") === !1) return;
      if (R.anisotropy > 1 || s.get(R).__currentAnisotropy) {
        const it = t.get("EXT_texture_filter_anisotropic");
        r.texParameterf(N, it.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(R.anisotropy, l.getMaxAnisotropy())), s.get(R).__currentAnisotropy = R.anisotropy;
      }
    }
  }
  function xt(N, R) {
    let it = !1;
    N.__webglInit === void 0 && (N.__webglInit = !0, R.addEventListener("dispose", L));
    const dt = R.source;
    let St = x.get(dt);
    St === void 0 && (St = {}, x.set(dt, St));
    const Q = lt(R);
    if (Q !== N.__cacheKey) {
      St[Q] === void 0 && (St[Q] = {
        texture: r.createTexture(),
        usedTimes: 0
      }, h.memory.textures++, it = !0), St[Q].usedTimes++;
      const Tt = St[N.__cacheKey];
      Tt !== void 0 && (St[N.__cacheKey].usedTimes--, Tt.usedTimes === 0 && C(R)), N.__cacheKey = Q, N.__webglTexture = St[Q].texture;
    }
    return it;
  }
  function j(N, R, it) {
    let dt = r.TEXTURE_2D;
    (R.isDataArrayTexture || R.isCompressedArrayTexture) && (dt = r.TEXTURE_2D_ARRAY), R.isData3DTexture && (dt = r.TEXTURE_3D);
    const St = xt(N, R), Q = R.source;
    i.bindTexture(dt, N.__webglTexture, r.TEXTURE0 + it);
    const Tt = s.get(Q);
    if (Q.version !== Tt.__version || St === !0) {
      i.activeTexture(r.TEXTURE0 + it);
      const wt = De.getPrimaries(De.workingColorSpace), Bt = R.colorSpace === Ka ? null : De.getPrimaries(R.colorSpace), xe = R.colorSpace === Ka || wt === Bt ? r.NONE : r.BROWSER_DEFAULT_WEBGL;
      r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, R.flipY), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, R.premultiplyAlpha), r.pixelStorei(r.UNPACK_ALIGNMENT, R.unpackAlignment), r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL, xe);
      let Ct = b(R.image, !1, l.maxTextureSize);
      Ct = Ue(R, Ct);
      const Gt = c.convert(R.format, R.colorSpace), jt = c.convert(R.type);
      let Wt = U(R.internalFormat, Gt, jt, R.colorSpace, R.isVideoTexture);
      st(dt, R);
      let It;
      const te = R.mipmaps, oe = R.isVideoTexture !== !0, ze = Tt.__version === void 0 || St === !0, W = Q.dataReady, Dt = F(R, Ct);
      if (R.isDepthTexture)
        Wt = w(R.format === Jr, R.type), ze && (oe ? i.texStorage2D(r.TEXTURE_2D, 1, Wt, Ct.width, Ct.height) : i.texImage2D(r.TEXTURE_2D, 0, Wt, Ct.width, Ct.height, 0, Gt, jt, null));
      else if (R.isDataTexture)
        if (te.length > 0) {
          oe && ze && i.texStorage2D(r.TEXTURE_2D, Dt, Wt, te[0].width, te[0].height);
          for (let ut = 0, _t = te.length; ut < _t; ut++)
            It = te[ut], oe ? W && i.texSubImage2D(r.TEXTURE_2D, ut, 0, 0, It.width, It.height, Gt, jt, It.data) : i.texImage2D(r.TEXTURE_2D, ut, Wt, It.width, It.height, 0, Gt, jt, It.data);
          R.generateMipmaps = !1;
        } else
          oe ? (ze && i.texStorage2D(r.TEXTURE_2D, Dt, Wt, Ct.width, Ct.height), W && i.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, Ct.width, Ct.height, Gt, jt, Ct.data)) : i.texImage2D(r.TEXTURE_2D, 0, Wt, Ct.width, Ct.height, 0, Gt, jt, Ct.data);
      else if (R.isCompressedTexture)
        if (R.isCompressedArrayTexture) {
          oe && ze && i.texStorage3D(r.TEXTURE_2D_ARRAY, Dt, Wt, te[0].width, te[0].height, Ct.depth);
          for (let ut = 0, _t = te.length; ut < _t; ut++)
            if (It = te[ut], R.format !== fi)
              if (Gt !== null)
                if (oe) {
                  if (W)
                    if (R.layerUpdates.size > 0) {
                      const Ut = ov(It.width, It.height, R.format, R.type);
                      for (const Nt of R.layerUpdates) {
                        const ee = It.data.subarray(
                          Nt * Ut / It.data.BYTES_PER_ELEMENT,
                          (Nt + 1) * Ut / It.data.BYTES_PER_ELEMENT
                        );
                        i.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY, ut, 0, 0, Nt, It.width, It.height, 1, Gt, ee);
                      }
                      R.clearLayerUpdates();
                    } else
                      i.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY, ut, 0, 0, 0, It.width, It.height, Ct.depth, Gt, It.data);
                } else
                  i.compressedTexImage3D(r.TEXTURE_2D_ARRAY, ut, Wt, It.width, It.height, Ct.depth, 0, It.data, 0, 0);
              else
                console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
            else
              oe ? W && i.texSubImage3D(r.TEXTURE_2D_ARRAY, ut, 0, 0, 0, It.width, It.height, Ct.depth, Gt, jt, It.data) : i.texImage3D(r.TEXTURE_2D_ARRAY, ut, Wt, It.width, It.height, Ct.depth, 0, Gt, jt, It.data);
        } else {
          oe && ze && i.texStorage2D(r.TEXTURE_2D, Dt, Wt, te[0].width, te[0].height);
          for (let ut = 0, _t = te.length; ut < _t; ut++)
            It = te[ut], R.format !== fi ? Gt !== null ? oe ? W && i.compressedTexSubImage2D(r.TEXTURE_2D, ut, 0, 0, It.width, It.height, Gt, It.data) : i.compressedTexImage2D(r.TEXTURE_2D, ut, Wt, It.width, It.height, 0, It.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : oe ? W && i.texSubImage2D(r.TEXTURE_2D, ut, 0, 0, It.width, It.height, Gt, jt, It.data) : i.texImage2D(r.TEXTURE_2D, ut, Wt, It.width, It.height, 0, Gt, jt, It.data);
        }
      else if (R.isDataArrayTexture)
        if (oe) {
          if (ze && i.texStorage3D(r.TEXTURE_2D_ARRAY, Dt, Wt, Ct.width, Ct.height, Ct.depth), W)
            if (R.layerUpdates.size > 0) {
              const ut = ov(Ct.width, Ct.height, R.format, R.type);
              for (const _t of R.layerUpdates) {
                const Ut = Ct.data.subarray(
                  _t * ut / Ct.data.BYTES_PER_ELEMENT,
                  (_t + 1) * ut / Ct.data.BYTES_PER_ELEMENT
                );
                i.texSubImage3D(r.TEXTURE_2D_ARRAY, 0, 0, 0, _t, Ct.width, Ct.height, 1, Gt, jt, Ut);
              }
              R.clearLayerUpdates();
            } else
              i.texSubImage3D(r.TEXTURE_2D_ARRAY, 0, 0, 0, 0, Ct.width, Ct.height, Ct.depth, Gt, jt, Ct.data);
        } else
          i.texImage3D(r.TEXTURE_2D_ARRAY, 0, Wt, Ct.width, Ct.height, Ct.depth, 0, Gt, jt, Ct.data);
      else if (R.isData3DTexture)
        oe ? (ze && i.texStorage3D(r.TEXTURE_3D, Dt, Wt, Ct.width, Ct.height, Ct.depth), W && i.texSubImage3D(r.TEXTURE_3D, 0, 0, 0, 0, Ct.width, Ct.height, Ct.depth, Gt, jt, Ct.data)) : i.texImage3D(r.TEXTURE_3D, 0, Wt, Ct.width, Ct.height, Ct.depth, 0, Gt, jt, Ct.data);
      else if (R.isFramebufferTexture) {
        if (ze)
          if (oe)
            i.texStorage2D(r.TEXTURE_2D, Dt, Wt, Ct.width, Ct.height);
          else {
            let ut = Ct.width, _t = Ct.height;
            for (let Ut = 0; Ut < Dt; Ut++)
              i.texImage2D(r.TEXTURE_2D, Ut, Wt, ut, _t, 0, Gt, jt, null), ut >>= 1, _t >>= 1;
          }
      } else if (te.length > 0) {
        if (oe && ze) {
          const ut = Xt(te[0]);
          i.texStorage2D(r.TEXTURE_2D, Dt, Wt, ut.width, ut.height);
        }
        for (let ut = 0, _t = te.length; ut < _t; ut++)
          It = te[ut], oe ? W && i.texSubImage2D(r.TEXTURE_2D, ut, 0, 0, Gt, jt, It) : i.texImage2D(r.TEXTURE_2D, ut, Wt, Gt, jt, It);
        R.generateMipmaps = !1;
      } else if (oe) {
        if (ze) {
          const ut = Xt(Ct);
          i.texStorage2D(r.TEXTURE_2D, Dt, Wt, ut.width, ut.height);
        }
        W && i.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, Gt, jt, Ct);
      } else
        i.texImage2D(r.TEXTURE_2D, 0, Wt, Gt, jt, Ct);
      M(R) && v(dt), Tt.__version = Q.version, R.onUpdate && R.onUpdate(R);
    }
    N.__version = R.version;
  }
  function ht(N, R, it) {
    if (R.image.length !== 6) return;
    const dt = xt(N, R), St = R.source;
    i.bindTexture(r.TEXTURE_CUBE_MAP, N.__webglTexture, r.TEXTURE0 + it);
    const Q = s.get(St);
    if (St.version !== Q.__version || dt === !0) {
      i.activeTexture(r.TEXTURE0 + it);
      const Tt = De.getPrimaries(De.workingColorSpace), wt = R.colorSpace === Ka ? null : De.getPrimaries(R.colorSpace), Bt = R.colorSpace === Ka || Tt === wt ? r.NONE : r.BROWSER_DEFAULT_WEBGL;
      r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, R.flipY), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, R.premultiplyAlpha), r.pixelStorei(r.UNPACK_ALIGNMENT, R.unpackAlignment), r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL, Bt);
      const xe = R.isCompressedTexture || R.image[0].isCompressedTexture, Ct = R.image[0] && R.image[0].isDataTexture, Gt = [];
      for (let _t = 0; _t < 6; _t++)
        !xe && !Ct ? Gt[_t] = b(R.image[_t], !0, l.maxCubemapSize) : Gt[_t] = Ct ? R.image[_t].image : R.image[_t], Gt[_t] = Ue(R, Gt[_t]);
      const jt = Gt[0], Wt = c.convert(R.format, R.colorSpace), It = c.convert(R.type), te = U(R.internalFormat, Wt, It, R.colorSpace), oe = R.isVideoTexture !== !0, ze = Q.__version === void 0 || dt === !0, W = St.dataReady;
      let Dt = F(R, jt);
      st(r.TEXTURE_CUBE_MAP, R);
      let ut;
      if (xe) {
        oe && ze && i.texStorage2D(r.TEXTURE_CUBE_MAP, Dt, te, jt.width, jt.height);
        for (let _t = 0; _t < 6; _t++) {
          ut = Gt[_t].mipmaps;
          for (let Ut = 0; Ut < ut.length; Ut++) {
            const Nt = ut[Ut];
            R.format !== fi ? Wt !== null ? oe ? W && i.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut, 0, 0, Nt.width, Nt.height, Wt, Nt.data) : i.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut, te, Nt.width, Nt.height, 0, Nt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : oe ? W && i.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut, 0, 0, Nt.width, Nt.height, Wt, It, Nt.data) : i.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut, te, Nt.width, Nt.height, 0, Wt, It, Nt.data);
          }
        }
      } else {
        if (ut = R.mipmaps, oe && ze) {
          ut.length > 0 && Dt++;
          const _t = Xt(Gt[0]);
          i.texStorage2D(r.TEXTURE_CUBE_MAP, Dt, te, _t.width, _t.height);
        }
        for (let _t = 0; _t < 6; _t++)
          if (Ct) {
            oe ? W && i.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, 0, 0, 0, Gt[_t].width, Gt[_t].height, Wt, It, Gt[_t].data) : i.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, 0, te, Gt[_t].width, Gt[_t].height, 0, Wt, It, Gt[_t].data);
            for (let Ut = 0; Ut < ut.length; Ut++) {
              const ee = ut[Ut].image[_t].image;
              oe ? W && i.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut + 1, 0, 0, ee.width, ee.height, Wt, It, ee.data) : i.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut + 1, te, ee.width, ee.height, 0, Wt, It, ee.data);
            }
          } else {
            oe ? W && i.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, 0, 0, 0, Wt, It, Gt[_t]) : i.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, 0, te, Wt, It, Gt[_t]);
            for (let Ut = 0; Ut < ut.length; Ut++) {
              const Nt = ut[Ut];
              oe ? W && i.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut + 1, 0, 0, Wt, It, Nt.image[_t]) : i.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + _t, Ut + 1, te, Wt, It, Nt.image[_t]);
            }
          }
      }
      M(R) && v(r.TEXTURE_CUBE_MAP), Q.__version = St.version, R.onUpdate && R.onUpdate(R);
    }
    N.__version = R.version;
  }
  function Et(N, R, it, dt, St, Q) {
    const Tt = c.convert(it.format, it.colorSpace), wt = c.convert(it.type), Bt = U(it.internalFormat, Tt, wt, it.colorSpace), xe = s.get(R), Ct = s.get(it);
    if (Ct.__renderTarget = R, !xe.__hasExternalTextures) {
      const Gt = Math.max(1, R.width >> Q), jt = Math.max(1, R.height >> Q);
      St === r.TEXTURE_3D || St === r.TEXTURE_2D_ARRAY ? i.texImage3D(St, Q, Bt, Gt, jt, R.depth, 0, Tt, wt, null) : i.texImage2D(St, Q, Bt, Gt, jt, 0, Tt, wt, null);
    }
    i.bindFramebuffer(r.FRAMEBUFFER, N), pe(R) ? d.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER, dt, St, Ct.__webglTexture, 0, fe(R)) : (St === r.TEXTURE_2D || St >= r.TEXTURE_CUBE_MAP_POSITIVE_X && St <= r.TEXTURE_CUBE_MAP_NEGATIVE_Z) && r.framebufferTexture2D(r.FRAMEBUFFER, dt, St, Ct.__webglTexture, Q), i.bindFramebuffer(r.FRAMEBUFFER, null);
  }
  function vt(N, R, it) {
    if (r.bindRenderbuffer(r.RENDERBUFFER, N), R.depthBuffer) {
      const dt = R.depthTexture, St = dt && dt.isDepthTexture ? dt.type : null, Q = w(R.stencilBuffer, St), Tt = R.stencilBuffer ? r.DEPTH_STENCIL_ATTACHMENT : r.DEPTH_ATTACHMENT, wt = fe(R);
      pe(R) ? d.renderbufferStorageMultisampleEXT(r.RENDERBUFFER, wt, Q, R.width, R.height) : it ? r.renderbufferStorageMultisample(r.RENDERBUFFER, wt, Q, R.width, R.height) : r.renderbufferStorage(r.RENDERBUFFER, Q, R.width, R.height), r.framebufferRenderbuffer(r.FRAMEBUFFER, Tt, r.RENDERBUFFER, N);
    } else {
      const dt = R.textures;
      for (let St = 0; St < dt.length; St++) {
        const Q = dt[St], Tt = c.convert(Q.format, Q.colorSpace), wt = c.convert(Q.type), Bt = U(Q.internalFormat, Tt, wt, Q.colorSpace), xe = fe(R);
        it && pe(R) === !1 ? r.renderbufferStorageMultisample(r.RENDERBUFFER, xe, Bt, R.width, R.height) : pe(R) ? d.renderbufferStorageMultisampleEXT(r.RENDERBUFFER, xe, Bt, R.width, R.height) : r.renderbufferStorage(r.RENDERBUFFER, Bt, R.width, R.height);
      }
    }
    r.bindRenderbuffer(r.RENDERBUFFER, null);
  }
  function Ht(N, R) {
    if (R && R.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");
    if (i.bindFramebuffer(r.FRAMEBUFFER, N), !(R.depthTexture && R.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    const dt = s.get(R.depthTexture);
    dt.__renderTarget = R, (!dt.__webglTexture || R.depthTexture.image.width !== R.width || R.depthTexture.image.height !== R.height) && (R.depthTexture.image.width = R.width, R.depthTexture.image.height = R.height, R.depthTexture.needsUpdate = !0), pt(R.depthTexture, 0);
    const St = dt.__webglTexture, Q = fe(R);
    if (R.depthTexture.format === Yr)
      pe(R) ? d.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER, r.DEPTH_ATTACHMENT, r.TEXTURE_2D, St, 0, Q) : r.framebufferTexture2D(r.FRAMEBUFFER, r.DEPTH_ATTACHMENT, r.TEXTURE_2D, St, 0);
    else if (R.depthTexture.format === Jr)
      pe(R) ? d.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER, r.DEPTH_STENCIL_ATTACHMENT, r.TEXTURE_2D, St, 0, Q) : r.framebufferTexture2D(r.FRAMEBUFFER, r.DEPTH_STENCIL_ATTACHMENT, r.TEXTURE_2D, St, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function Lt(N) {
    const R = s.get(N), it = N.isWebGLCubeRenderTarget === !0;
    if (R.__boundDepthTexture !== N.depthTexture) {
      const dt = N.depthTexture;
      if (R.__depthDisposeCallback && R.__depthDisposeCallback(), dt) {
        const St = () => {
          delete R.__boundDepthTexture, delete R.__depthDisposeCallback, dt.removeEventListener("dispose", St);
        };
        dt.addEventListener("dispose", St), R.__depthDisposeCallback = St;
      }
      R.__boundDepthTexture = dt;
    }
    if (N.depthTexture && !R.__autoAllocateDepthBuffer) {
      if (it) throw new Error("target.depthTexture not supported in Cube render targets");
      Ht(R.__webglFramebuffer, N);
    } else if (it) {
      R.__webglDepthbuffer = [];
      for (let dt = 0; dt < 6; dt++)
        if (i.bindFramebuffer(r.FRAMEBUFFER, R.__webglFramebuffer[dt]), R.__webglDepthbuffer[dt] === void 0)
          R.__webglDepthbuffer[dt] = r.createRenderbuffer(), vt(R.__webglDepthbuffer[dt], N, !1);
        else {
          const St = N.stencilBuffer ? r.DEPTH_STENCIL_ATTACHMENT : r.DEPTH_ATTACHMENT, Q = R.__webglDepthbuffer[dt];
          r.bindRenderbuffer(r.RENDERBUFFER, Q), r.framebufferRenderbuffer(r.FRAMEBUFFER, St, r.RENDERBUFFER, Q);
        }
    } else if (i.bindFramebuffer(r.FRAMEBUFFER, R.__webglFramebuffer), R.__webglDepthbuffer === void 0)
      R.__webglDepthbuffer = r.createRenderbuffer(), vt(R.__webglDepthbuffer, N, !1);
    else {
      const dt = N.stencilBuffer ? r.DEPTH_STENCIL_ATTACHMENT : r.DEPTH_ATTACHMENT, St = R.__webglDepthbuffer;
      r.bindRenderbuffer(r.RENDERBUFFER, St), r.framebufferRenderbuffer(r.FRAMEBUFFER, dt, r.RENDERBUFFER, St);
    }
    i.bindFramebuffer(r.FRAMEBUFFER, null);
  }
  function ae(N, R, it) {
    const dt = s.get(N);
    R !== void 0 && Et(dt.__webglFramebuffer, N, N.texture, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, 0), it !== void 0 && Lt(N);
  }
  function Ne(N) {
    const R = N.texture, it = s.get(N), dt = s.get(R);
    N.addEventListener("dispose", O);
    const St = N.textures, Q = N.isWebGLCubeRenderTarget === !0, Tt = St.length > 1;
    if (Tt || (dt.__webglTexture === void 0 && (dt.__webglTexture = r.createTexture()), dt.__version = R.version, h.memory.textures++), Q) {
      it.__webglFramebuffer = [];
      for (let wt = 0; wt < 6; wt++)
        if (R.mipmaps && R.mipmaps.length > 0) {
          it.__webglFramebuffer[wt] = [];
          for (let Bt = 0; Bt < R.mipmaps.length; Bt++)
            it.__webglFramebuffer[wt][Bt] = r.createFramebuffer();
        } else
          it.__webglFramebuffer[wt] = r.createFramebuffer();
    } else {
      if (R.mipmaps && R.mipmaps.length > 0) {
        it.__webglFramebuffer = [];
        for (let wt = 0; wt < R.mipmaps.length; wt++)
          it.__webglFramebuffer[wt] = r.createFramebuffer();
      } else
        it.__webglFramebuffer = r.createFramebuffer();
      if (Tt)
        for (let wt = 0, Bt = St.length; wt < Bt; wt++) {
          const xe = s.get(St[wt]);
          xe.__webglTexture === void 0 && (xe.__webglTexture = r.createTexture(), h.memory.textures++);
        }
      if (N.samples > 0 && pe(N) === !1) {
        it.__webglMultisampledFramebuffer = r.createFramebuffer(), it.__webglColorRenderbuffer = [], i.bindFramebuffer(r.FRAMEBUFFER, it.__webglMultisampledFramebuffer);
        for (let wt = 0; wt < St.length; wt++) {
          const Bt = St[wt];
          it.__webglColorRenderbuffer[wt] = r.createRenderbuffer(), r.bindRenderbuffer(r.RENDERBUFFER, it.__webglColorRenderbuffer[wt]);
          const xe = c.convert(Bt.format, Bt.colorSpace), Ct = c.convert(Bt.type), Gt = U(Bt.internalFormat, xe, Ct, Bt.colorSpace, N.isXRRenderTarget === !0), jt = fe(N);
          r.renderbufferStorageMultisample(r.RENDERBUFFER, jt, Gt, N.width, N.height), r.framebufferRenderbuffer(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0 + wt, r.RENDERBUFFER, it.__webglColorRenderbuffer[wt]);
        }
        r.bindRenderbuffer(r.RENDERBUFFER, null), N.depthBuffer && (it.__webglDepthRenderbuffer = r.createRenderbuffer(), vt(it.__webglDepthRenderbuffer, N, !0)), i.bindFramebuffer(r.FRAMEBUFFER, null);
      }
    }
    if (Q) {
      i.bindTexture(r.TEXTURE_CUBE_MAP, dt.__webglTexture), st(r.TEXTURE_CUBE_MAP, R);
      for (let wt = 0; wt < 6; wt++)
        if (R.mipmaps && R.mipmaps.length > 0)
          for (let Bt = 0; Bt < R.mipmaps.length; Bt++)
            Et(it.__webglFramebuffer[wt][Bt], N, R, r.COLOR_ATTACHMENT0, r.TEXTURE_CUBE_MAP_POSITIVE_X + wt, Bt);
        else
          Et(it.__webglFramebuffer[wt], N, R, r.COLOR_ATTACHMENT0, r.TEXTURE_CUBE_MAP_POSITIVE_X + wt, 0);
      M(R) && v(r.TEXTURE_CUBE_MAP), i.unbindTexture();
    } else if (Tt) {
      for (let wt = 0, Bt = St.length; wt < Bt; wt++) {
        const xe = St[wt], Ct = s.get(xe);
        i.bindTexture(r.TEXTURE_2D, Ct.__webglTexture), st(r.TEXTURE_2D, xe), Et(it.__webglFramebuffer, N, xe, r.COLOR_ATTACHMENT0 + wt, r.TEXTURE_2D, 0), M(xe) && v(r.TEXTURE_2D);
      }
      i.unbindTexture();
    } else {
      let wt = r.TEXTURE_2D;
      if ((N.isWebGL3DRenderTarget || N.isWebGLArrayRenderTarget) && (wt = N.isWebGL3DRenderTarget ? r.TEXTURE_3D : r.TEXTURE_2D_ARRAY), i.bindTexture(wt, dt.__webglTexture), st(wt, R), R.mipmaps && R.mipmaps.length > 0)
        for (let Bt = 0; Bt < R.mipmaps.length; Bt++)
          Et(it.__webglFramebuffer[Bt], N, R, r.COLOR_ATTACHMENT0, wt, Bt);
      else
        Et(it.__webglFramebuffer, N, R, r.COLOR_ATTACHMENT0, wt, 0);
      M(R) && v(wt), i.unbindTexture();
    }
    N.depthBuffer && Lt(N);
  }
  function de(N) {
    const R = N.textures;
    for (let it = 0, dt = R.length; it < dt; it++) {
      const St = R[it];
      if (M(St)) {
        const Q = B(N), Tt = s.get(St).__webglTexture;
        i.bindTexture(Q, Tt), v(Q), i.unbindTexture();
      }
    }
  }
  const We = [], V = [];
  function vn(N) {
    if (N.samples > 0) {
      if (pe(N) === !1) {
        const R = N.textures, it = N.width, dt = N.height;
        let St = r.COLOR_BUFFER_BIT;
        const Q = N.stencilBuffer ? r.DEPTH_STENCIL_ATTACHMENT : r.DEPTH_ATTACHMENT, Tt = s.get(N), wt = R.length > 1;
        if (wt)
          for (let Bt = 0; Bt < R.length; Bt++)
            i.bindFramebuffer(r.FRAMEBUFFER, Tt.__webglMultisampledFramebuffer), r.framebufferRenderbuffer(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0 + Bt, r.RENDERBUFFER, null), i.bindFramebuffer(r.FRAMEBUFFER, Tt.__webglFramebuffer), r.framebufferTexture2D(r.DRAW_FRAMEBUFFER, r.COLOR_ATTACHMENT0 + Bt, r.TEXTURE_2D, null, 0);
        i.bindFramebuffer(r.READ_FRAMEBUFFER, Tt.__webglMultisampledFramebuffer), i.bindFramebuffer(r.DRAW_FRAMEBUFFER, Tt.__webglFramebuffer);
        for (let Bt = 0; Bt < R.length; Bt++) {
          if (N.resolveDepthBuffer && (N.depthBuffer && (St |= r.DEPTH_BUFFER_BIT), N.stencilBuffer && N.resolveStencilBuffer && (St |= r.STENCIL_BUFFER_BIT)), wt) {
            r.framebufferRenderbuffer(r.READ_FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.RENDERBUFFER, Tt.__webglColorRenderbuffer[Bt]);
            const xe = s.get(R[Bt]).__webglTexture;
            r.framebufferTexture2D(r.DRAW_FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, xe, 0);
          }
          r.blitFramebuffer(0, 0, it, dt, 0, 0, it, dt, St, r.NEAREST), m === !0 && (We.length = 0, V.length = 0, We.push(r.COLOR_ATTACHMENT0 + Bt), N.depthBuffer && N.resolveDepthBuffer === !1 && (We.push(Q), V.push(Q), r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER, V)), r.invalidateFramebuffer(r.READ_FRAMEBUFFER, We));
        }
        if (i.bindFramebuffer(r.READ_FRAMEBUFFER, null), i.bindFramebuffer(r.DRAW_FRAMEBUFFER, null), wt)
          for (let Bt = 0; Bt < R.length; Bt++) {
            i.bindFramebuffer(r.FRAMEBUFFER, Tt.__webglMultisampledFramebuffer), r.framebufferRenderbuffer(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0 + Bt, r.RENDERBUFFER, Tt.__webglColorRenderbuffer[Bt]);
            const xe = s.get(R[Bt]).__webglTexture;
            i.bindFramebuffer(r.FRAMEBUFFER, Tt.__webglFramebuffer), r.framebufferTexture2D(r.DRAW_FRAMEBUFFER, r.COLOR_ATTACHMENT0 + Bt, r.TEXTURE_2D, xe, 0);
          }
        i.bindFramebuffer(r.DRAW_FRAMEBUFFER, Tt.__webglMultisampledFramebuffer);
      } else if (N.depthBuffer && N.resolveDepthBuffer === !1 && m) {
        const R = N.stencilBuffer ? r.DEPTH_STENCIL_ATTACHMENT : r.DEPTH_ATTACHMENT;
        r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER, [R]);
      }
    }
  }
  function fe(N) {
    return Math.min(l.maxSamples, N.samples);
  }
  function pe(N) {
    const R = s.get(N);
    return N.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && R.__useRenderToTexture !== !1;
  }
  function Yt(N) {
    const R = h.render.frame;
    g.get(N) !== R && (g.set(N, R), N.update());
  }
  function Ue(N, R) {
    const it = N.colorSpace, dt = N.format, St = N.type;
    return N.isCompressedTexture === !0 || N.isVideoTexture === !0 || it !== $r && it !== Ka && (De.getTransfer(it) === Ge ? (dt !== fi || St !== ga) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", it)), R;
  }
  function Xt(N) {
    return typeof HTMLImageElement < "u" && N instanceof HTMLImageElement ? (p.width = N.naturalWidth || N.width, p.height = N.naturalHeight || N.height) : typeof VideoFrame < "u" && N instanceof VideoFrame ? (p.width = N.displayWidth, p.height = N.displayHeight) : (p.width = N.width, p.height = N.height), p;
  }
  this.allocateTextureUnit = $, this.resetTextureUnits = J, this.setTexture2D = pt, this.setTexture2DArray = z, this.setTexture3D = tt, this.setTextureCube = K, this.rebindTextures = ae, this.setupRenderTarget = Ne, this.updateRenderTargetMipmap = de, this.updateMultisampleRenderTarget = vn, this.setupDepthRenderbuffer = Lt, this.setupFrameBufferTexture = Et, this.useMultisampledRTT = pe;
}
function $A(r, t) {
  function i(s, l = Ka) {
    let c;
    const h = De.getTransfer(l);
    if (s === ga) return r.UNSIGNED_BYTE;
    if (s === yp) return r.UNSIGNED_SHORT_4_4_4_4;
    if (s === Sp) return r.UNSIGNED_SHORT_5_5_5_1;
    if (s === ix) return r.UNSIGNED_INT_5_9_9_9_REV;
    if (s === ex) return r.BYTE;
    if (s === nx) return r.SHORT;
    if (s === ul) return r.UNSIGNED_SHORT;
    if (s === xp) return r.INT;
    if (s === Ps) return r.UNSIGNED_INT;
    if (s === Ei) return r.FLOAT;
    if (s === hl) return r.HALF_FLOAT;
    if (s === ax) return r.ALPHA;
    if (s === sx) return r.RGB;
    if (s === fi) return r.RGBA;
    if (s === rx) return r.LUMINANCE;
    if (s === ox) return r.LUMINANCE_ALPHA;
    if (s === Yr) return r.DEPTH_COMPONENT;
    if (s === Jr) return r.DEPTH_STENCIL;
    if (s === Mp) return r.RED;
    if (s === Ep) return r.RED_INTEGER;
    if (s === lx) return r.RG;
    if (s === bp) return r.RG_INTEGER;
    if (s === Tp) return r.RGBA_INTEGER;
    if (s === nu || s === iu || s === au || s === su)
      if (h === Ge)
        if (c = t.get("WEBGL_compressed_texture_s3tc_srgb"), c !== null) {
          if (s === nu) return c.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (s === iu) return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (s === au) return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (s === su) return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (c = t.get("WEBGL_compressed_texture_s3tc"), c !== null) {
        if (s === nu) return c.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (s === iu) return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (s === au) return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (s === su) return c.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (s === Pd || s === zd || s === Bd || s === Id)
      if (c = t.get("WEBGL_compressed_texture_pvrtc"), c !== null) {
        if (s === Pd) return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (s === zd) return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (s === Bd) return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (s === Id) return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (s === Fd || s === Hd || s === Gd)
      if (c = t.get("WEBGL_compressed_texture_etc"), c !== null) {
        if (s === Fd || s === Hd) return h === Ge ? c.COMPRESSED_SRGB8_ETC2 : c.COMPRESSED_RGB8_ETC2;
        if (s === Gd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : c.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (s === Vd || s === kd || s === Xd || s === Wd || s === Yd || s === qd || s === jd || s === Zd || s === Kd || s === Qd || s === Jd || s === $d || s === tp || s === ep)
      if (c = t.get("WEBGL_compressed_texture_astc"), c !== null) {
        if (s === Vd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : c.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (s === kd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : c.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (s === Xd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : c.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (s === Wd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : c.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (s === Yd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : c.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (s === qd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : c.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (s === jd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : c.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (s === Zd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : c.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (s === Kd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : c.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (s === Qd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : c.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (s === Jd) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : c.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (s === $d) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : c.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (s === tp) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : c.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (s === ep) return h === Ge ? c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : c.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (s === ru || s === np || s === ip)
      if (c = t.get("EXT_texture_compression_bptc"), c !== null) {
        if (s === ru) return h === Ge ? c.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : c.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (s === np) return c.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (s === ip) return c.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (s === cx || s === ap || s === sp || s === rp)
      if (c = t.get("EXT_texture_compression_rgtc"), c !== null) {
        if (s === ru) return c.COMPRESSED_RED_RGTC1_EXT;
        if (s === ap) return c.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (s === sp) return c.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (s === rp) return c.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return s === Qr ? r.UNSIGNED_INT_24_8 : r[s] !== void 0 ? r[s] : null;
  }
  return { convert: i };
}
const tR = { type: "move" };
class gd {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new Os(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand;
  }
  getTargetRaySpace() {
    return this._targetRay === null && (this._targetRay = new Os(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new q(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new q()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new Os(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new q(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new q()), this._grip;
  }
  dispatchEvent(t) {
    return this._targetRay !== null && this._targetRay.dispatchEvent(t), this._grip !== null && this._grip.dispatchEvent(t), this._hand !== null && this._hand.dispatchEvent(t), this;
  }
  connect(t) {
    if (t && t.hand) {
      const i = this._hand;
      if (i)
        for (const s of t.hand.values())
          this._getHandJoint(i, s);
    }
    return this.dispatchEvent({ type: "connected", data: t }), this;
  }
  disconnect(t) {
    return this.dispatchEvent({ type: "disconnected", data: t }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this;
  }
  update(t, i, s) {
    let l = null, c = null, h = null;
    const d = this._targetRay, m = this._grip, p = this._hand;
    if (t && i.session.visibilityState !== "visible-blurred") {
      if (p && t.hand) {
        h = !0;
        for (const b of t.hand.values()) {
          const M = i.getJointPose(b, s), v = this._getHandJoint(p, b);
          M !== null && (v.matrix.fromArray(M.transform.matrix), v.matrix.decompose(v.position, v.rotation, v.scale), v.matrixWorldNeedsUpdate = !0, v.jointRadius = M.radius), v.visible = M !== null;
        }
        const g = p.joints["index-finger-tip"], _ = p.joints["thumb-tip"], x = g.position.distanceTo(_.position), S = 0.02, E = 5e-3;
        p.inputState.pinching && x > S + E ? (p.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: t.handedness,
          target: this
        })) : !p.inputState.pinching && x <= S - E && (p.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: t.handedness,
          target: this
        }));
      } else
        m !== null && t.gripSpace && (c = i.getPose(t.gripSpace, s), c !== null && (m.matrix.fromArray(c.transform.matrix), m.matrix.decompose(m.position, m.rotation, m.scale), m.matrixWorldNeedsUpdate = !0, c.linearVelocity ? (m.hasLinearVelocity = !0, m.linearVelocity.copy(c.linearVelocity)) : m.hasLinearVelocity = !1, c.angularVelocity ? (m.hasAngularVelocity = !0, m.angularVelocity.copy(c.angularVelocity)) : m.hasAngularVelocity = !1));
      d !== null && (l = i.getPose(t.targetRaySpace, s), l === null && c !== null && (l = c), l !== null && (d.matrix.fromArray(l.transform.matrix), d.matrix.decompose(d.position, d.rotation, d.scale), d.matrixWorldNeedsUpdate = !0, l.linearVelocity ? (d.hasLinearVelocity = !0, d.linearVelocity.copy(l.linearVelocity)) : d.hasLinearVelocity = !1, l.angularVelocity ? (d.hasAngularVelocity = !0, d.angularVelocity.copy(l.angularVelocity)) : d.hasAngularVelocity = !1, this.dispatchEvent(tR)));
    }
    return d !== null && (d.visible = l !== null), m !== null && (m.visible = c !== null), p !== null && (p.visible = h !== null), this;
  }
  // private method
  _getHandJoint(t, i) {
    if (t.joints[i.jointName] === void 0) {
      const s = new Os();
      s.matrixAutoUpdate = !1, s.visible = !1, t.joints[i.jointName] = s, t.add(s);
    }
    return t.joints[i.jointName];
  }
}
const eR = `
void main() {

	gl_Position = vec4( position, 1.0 );

}`, nR = `
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`;
class iR {
  constructor() {
    this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
  }
  init(t, i, s) {
    if (this.texture === null) {
      const l = new zn(), c = t.properties.get(l);
      c.__webglTexture = i.texture, (i.depthNear !== s.depthNear || i.depthFar !== s.depthFar) && (this.depthNear = i.depthNear, this.depthFar = i.depthFar), this.texture = l;
    }
  }
  getMesh(t) {
    if (this.texture !== null && this.mesh === null) {
      const i = t.cameras[0].viewport, s = new _a({
        vertexShader: eR,
        fragmentShader: nR,
        uniforms: {
          depthColor: { value: this.texture },
          depthWidth: { value: i.z },
          depthHeight: { value: i.w }
        }
      });
      this.mesh = new Un(new Mu(20, 20), s);
    }
    return this.mesh;
  }
  reset() {
    this.texture = null, this.mesh = null;
  }
  getDepthTexture() {
    return this.texture;
  }
}
class aR extends Bs {
  constructor(t, i) {
    super();
    const s = this;
    let l = null, c = 1, h = null, d = "local-floor", m = 1, p = null, g = null, _ = null, x = null, S = null, E = null;
    const b = new iR(), M = i.getContextAttributes();
    let v = null, B = null;
    const U = [], w = [], F = new $t();
    let L = null;
    const O = new ui();
    O.viewport = new Je();
    const G = new ui();
    G.viewport = new Je();
    const C = [O, G], T = new EE();
    let I = null, J = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(j) {
      let ht = U[j];
      return ht === void 0 && (ht = new gd(), U[j] = ht), ht.getTargetRaySpace();
    }, this.getControllerGrip = function(j) {
      let ht = U[j];
      return ht === void 0 && (ht = new gd(), U[j] = ht), ht.getGripSpace();
    }, this.getHand = function(j) {
      let ht = U[j];
      return ht === void 0 && (ht = new gd(), U[j] = ht), ht.getHandSpace();
    };
    function $(j) {
      const ht = w.indexOf(j.inputSource);
      if (ht === -1)
        return;
      const Et = U[ht];
      Et !== void 0 && (Et.update(j.inputSource, j.frame, p || h), Et.dispatchEvent({ type: j.type, data: j.inputSource }));
    }
    function lt() {
      l.removeEventListener("select", $), l.removeEventListener("selectstart", $), l.removeEventListener("selectend", $), l.removeEventListener("squeeze", $), l.removeEventListener("squeezestart", $), l.removeEventListener("squeezeend", $), l.removeEventListener("end", lt), l.removeEventListener("inputsourceschange", pt);
      for (let j = 0; j < U.length; j++) {
        const ht = w[j];
        ht !== null && (w[j] = null, U[j].disconnect(ht));
      }
      I = null, J = null, b.reset(), t.setRenderTarget(v), S = null, x = null, _ = null, l = null, B = null, xt.stop(), s.isPresenting = !1, t.setPixelRatio(L), t.setSize(F.width, F.height, !1), s.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function(j) {
      c = j, s.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function(j) {
      d = j, s.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return p || h;
    }, this.setReferenceSpace = function(j) {
      p = j;
    }, this.getBaseLayer = function() {
      return x !== null ? x : S;
    }, this.getBinding = function() {
      return _;
    }, this.getFrame = function() {
      return E;
    }, this.getSession = function() {
      return l;
    }, this.setSession = async function(j) {
      if (l = j, l !== null) {
        if (v = t.getRenderTarget(), l.addEventListener("select", $), l.addEventListener("selectstart", $), l.addEventListener("selectend", $), l.addEventListener("squeeze", $), l.addEventListener("squeezestart", $), l.addEventListener("squeezeend", $), l.addEventListener("end", lt), l.addEventListener("inputsourceschange", pt), M.xrCompatible !== !0 && await i.makeXRCompatible(), L = t.getPixelRatio(), t.getSize(F), l.enabledFeatures !== void 0 && l.enabledFeatures.includes("layers")) {
          let Et = null, vt = null, Ht = null;
          M.depth && (Ht = M.stencil ? i.DEPTH24_STENCIL8 : i.DEPTH_COMPONENT24, Et = M.stencil ? Jr : Yr, vt = M.stencil ? Qr : Ps);
          const Lt = {
            colorFormat: i.RGBA8,
            depthFormat: Ht,
            scaleFactor: c
          };
          _ = new XRWebGLBinding(l, i), x = _.createProjectionLayer(Lt), l.updateRenderState({ layers: [x] }), t.setPixelRatio(1), t.setSize(x.textureWidth, x.textureHeight, !1), B = new zs(
            x.textureWidth,
            x.textureHeight,
            {
              format: fi,
              type: ga,
              depthTexture: new bx(x.textureWidth, x.textureHeight, vt, void 0, void 0, void 0, void 0, void 0, void 0, Et),
              stencilBuffer: M.stencil,
              colorSpace: t.outputColorSpace,
              samples: M.antialias ? 4 : 0,
              resolveDepthBuffer: x.ignoreDepthValues === !1
            }
          );
        } else {
          const Et = {
            antialias: M.antialias,
            alpha: !0,
            depth: M.depth,
            stencil: M.stencil,
            framebufferScaleFactor: c
          };
          S = new XRWebGLLayer(l, i, Et), l.updateRenderState({ baseLayer: S }), t.setPixelRatio(1), t.setSize(S.framebufferWidth, S.framebufferHeight, !1), B = new zs(
            S.framebufferWidth,
            S.framebufferHeight,
            {
              format: fi,
              type: ga,
              colorSpace: t.outputColorSpace,
              stencilBuffer: M.stencil
            }
          );
        }
        B.isXRRenderTarget = !0, this.setFoveation(m), p = null, h = await l.requestReferenceSpace(d), xt.setContext(l), xt.start(), s.isPresenting = !0, s.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (l !== null)
        return l.environmentBlendMode;
    }, this.getDepthTexture = function() {
      return b.getDepthTexture();
    };
    function pt(j) {
      for (let ht = 0; ht < j.removed.length; ht++) {
        const Et = j.removed[ht], vt = w.indexOf(Et);
        vt >= 0 && (w[vt] = null, U[vt].disconnect(Et));
      }
      for (let ht = 0; ht < j.added.length; ht++) {
        const Et = j.added[ht];
        let vt = w.indexOf(Et);
        if (vt === -1) {
          for (let Lt = 0; Lt < U.length; Lt++)
            if (Lt >= w.length) {
              w.push(Et), vt = Lt;
              break;
            } else if (w[Lt] === null) {
              w[Lt] = Et, vt = Lt;
              break;
            }
          if (vt === -1) break;
        }
        const Ht = U[vt];
        Ht && Ht.connect(Et);
      }
    }
    const z = new q(), tt = new q();
    function K(j, ht, Et) {
      z.setFromMatrixPosition(ht.matrixWorld), tt.setFromMatrixPosition(Et.matrixWorld);
      const vt = z.distanceTo(tt), Ht = ht.projectionMatrix.elements, Lt = Et.projectionMatrix.elements, ae = Ht[14] / (Ht[10] - 1), Ne = Ht[14] / (Ht[10] + 1), de = (Ht[9] + 1) / Ht[5], We = (Ht[9] - 1) / Ht[5], V = (Ht[8] - 1) / Ht[0], vn = (Lt[8] + 1) / Lt[0], fe = ae * V, pe = ae * vn, Yt = vt / (-V + vn), Ue = Yt * -V;
      if (ht.matrixWorld.decompose(j.position, j.quaternion, j.scale), j.translateX(Ue), j.translateZ(Yt), j.matrixWorld.compose(j.position, j.quaternion, j.scale), j.matrixWorldInverse.copy(j.matrixWorld).invert(), Ht[10] === -1)
        j.projectionMatrix.copy(ht.projectionMatrix), j.projectionMatrixInverse.copy(ht.projectionMatrixInverse);
      else {
        const Xt = ae + Yt, N = Ne + Yt, R = fe - Ue, it = pe + (vt - Ue), dt = de * Ne / N * Xt, St = We * Ne / N * Xt;
        j.projectionMatrix.makePerspective(R, it, dt, St, Xt, N), j.projectionMatrixInverse.copy(j.projectionMatrix).invert();
      }
    }
    function yt(j, ht) {
      ht === null ? j.matrixWorld.copy(j.matrix) : j.matrixWorld.multiplyMatrices(ht.matrixWorld, j.matrix), j.matrixWorldInverse.copy(j.matrixWorld).invert();
    }
    this.updateCamera = function(j) {
      if (l === null) return;
      let ht = j.near, Et = j.far;
      b.texture !== null && (b.depthNear > 0 && (ht = b.depthNear), b.depthFar > 0 && (Et = b.depthFar)), T.near = G.near = O.near = ht, T.far = G.far = O.far = Et, (I !== T.near || J !== T.far) && (l.updateRenderState({
        depthNear: T.near,
        depthFar: T.far
      }), I = T.near, J = T.far), O.layers.mask = j.layers.mask | 2, G.layers.mask = j.layers.mask | 4, T.layers.mask = O.layers.mask | G.layers.mask;
      const vt = j.parent, Ht = T.cameras;
      yt(T, vt);
      for (let Lt = 0; Lt < Ht.length; Lt++)
        yt(Ht[Lt], vt);
      Ht.length === 2 ? K(T, O, G) : T.projectionMatrix.copy(O.projectionMatrix), Mt(j, T, vt);
    };
    function Mt(j, ht, Et) {
      Et === null ? j.matrix.copy(ht.matrixWorld) : (j.matrix.copy(Et.matrixWorld), j.matrix.invert(), j.matrix.multiply(ht.matrixWorld)), j.matrix.decompose(j.position, j.quaternion, j.scale), j.updateMatrixWorld(!0), j.projectionMatrix.copy(ht.projectionMatrix), j.projectionMatrixInverse.copy(ht.projectionMatrixInverse), j.isPerspectiveCamera && (j.fov = op * 2 * Math.atan(1 / j.projectionMatrix.elements[5]), j.zoom = 1);
    }
    this.getCamera = function() {
      return T;
    }, this.getFoveation = function() {
      if (!(x === null && S === null))
        return m;
    }, this.setFoveation = function(j) {
      m = j, x !== null && (x.fixedFoveation = j), S !== null && S.fixedFoveation !== void 0 && (S.fixedFoveation = j);
    }, this.hasDepthSensing = function() {
      return b.texture !== null;
    }, this.getDepthSensingMesh = function() {
      return b.getMesh(T);
    };
    let P = null;
    function st(j, ht) {
      if (g = ht.getViewerPose(p || h), E = ht, g !== null) {
        const Et = g.views;
        S !== null && (t.setRenderTargetFramebuffer(B, S.framebuffer), t.setRenderTarget(B));
        let vt = !1;
        Et.length !== T.cameras.length && (T.cameras.length = 0, vt = !0);
        for (let Lt = 0; Lt < Et.length; Lt++) {
          const ae = Et[Lt];
          let Ne = null;
          if (S !== null)
            Ne = S.getViewport(ae);
          else {
            const We = _.getViewSubImage(x, ae);
            Ne = We.viewport, Lt === 0 && (t.setRenderTargetTextures(
              B,
              We.colorTexture,
              x.ignoreDepthValues ? void 0 : We.depthStencilTexture
            ), t.setRenderTarget(B));
          }
          let de = C[Lt];
          de === void 0 && (de = new ui(), de.layers.enable(Lt), de.viewport = new Je(), C[Lt] = de), de.matrix.fromArray(ae.transform.matrix), de.matrix.decompose(de.position, de.quaternion, de.scale), de.projectionMatrix.fromArray(ae.projectionMatrix), de.projectionMatrixInverse.copy(de.projectionMatrix).invert(), de.viewport.set(Ne.x, Ne.y, Ne.width, Ne.height), Lt === 0 && (T.matrix.copy(de.matrix), T.matrix.decompose(T.position, T.quaternion, T.scale)), vt === !0 && T.cameras.push(de);
        }
        const Ht = l.enabledFeatures;
        if (Ht && Ht.includes("depth-sensing")) {
          const Lt = _.getDepthInformation(Et[0]);
          Lt && Lt.isValid && Lt.texture && b.init(t, Lt, l.renderState);
        }
      }
      for (let Et = 0; Et < U.length; Et++) {
        const vt = w[Et], Ht = U[Et];
        vt !== null && Ht !== void 0 && Ht.update(vt, ht, p || h);
      }
      P && P(j, ht), ht.detectedPlanes && s.dispatchEvent({ type: "planesdetected", data: ht }), E = null;
    }
    const xt = new Rx();
    xt.setAnimationLoop(st), this.setAnimationLoop = function(j) {
      P = j;
    }, this.dispose = function() {
    };
  }
}
const As = /* @__PURE__ */ new Gi(), sR = /* @__PURE__ */ new Xe();
function rR(r, t) {
  function i(M, v) {
    M.matrixAutoUpdate === !0 && M.updateMatrix(), v.value.copy(M.matrix);
  }
  function s(M, v) {
    v.color.getRGB(M.fogColor.value, xx(r)), v.isFog ? (M.fogNear.value = v.near, M.fogFar.value = v.far) : v.isFogExp2 && (M.fogDensity.value = v.density);
  }
  function l(M, v, B, U, w) {
    v.isMeshBasicMaterial || v.isMeshLambertMaterial ? c(M, v) : v.isMeshToonMaterial ? (c(M, v), _(M, v)) : v.isMeshPhongMaterial ? (c(M, v), g(M, v)) : v.isMeshStandardMaterial ? (c(M, v), x(M, v), v.isMeshPhysicalMaterial && S(M, v, w)) : v.isMeshMatcapMaterial ? (c(M, v), E(M, v)) : v.isMeshDepthMaterial ? c(M, v) : v.isMeshDistanceMaterial ? (c(M, v), b(M, v)) : v.isMeshNormalMaterial ? c(M, v) : v.isLineBasicMaterial ? (h(M, v), v.isLineDashedMaterial && d(M, v)) : v.isPointsMaterial ? m(M, v, B, U) : v.isSpriteMaterial ? p(M, v) : v.isShadowMaterial ? (M.color.value.copy(v.color), M.opacity.value = v.opacity) : v.isShaderMaterial && (v.uniformsNeedUpdate = !1);
  }
  function c(M, v) {
    M.opacity.value = v.opacity, v.color && M.diffuse.value.copy(v.color), v.emissive && M.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity), v.map && (M.map.value = v.map, i(v.map, M.mapTransform)), v.alphaMap && (M.alphaMap.value = v.alphaMap, i(v.alphaMap, M.alphaMapTransform)), v.bumpMap && (M.bumpMap.value = v.bumpMap, i(v.bumpMap, M.bumpMapTransform), M.bumpScale.value = v.bumpScale, v.side === ti && (M.bumpScale.value *= -1)), v.normalMap && (M.normalMap.value = v.normalMap, i(v.normalMap, M.normalMapTransform), M.normalScale.value.copy(v.normalScale), v.side === ti && M.normalScale.value.negate()), v.displacementMap && (M.displacementMap.value = v.displacementMap, i(v.displacementMap, M.displacementMapTransform), M.displacementScale.value = v.displacementScale, M.displacementBias.value = v.displacementBias), v.emissiveMap && (M.emissiveMap.value = v.emissiveMap, i(v.emissiveMap, M.emissiveMapTransform)), v.specularMap && (M.specularMap.value = v.specularMap, i(v.specularMap, M.specularMapTransform)), v.alphaTest > 0 && (M.alphaTest.value = v.alphaTest);
    const B = t.get(v), U = B.envMap, w = B.envMapRotation;
    U && (M.envMap.value = U, As.copy(w), As.x *= -1, As.y *= -1, As.z *= -1, U.isCubeTexture && U.isRenderTargetTexture === !1 && (As.y *= -1, As.z *= -1), M.envMapRotation.value.setFromMatrix4(sR.makeRotationFromEuler(As)), M.flipEnvMap.value = U.isCubeTexture && U.isRenderTargetTexture === !1 ? -1 : 1, M.reflectivity.value = v.reflectivity, M.ior.value = v.ior, M.refractionRatio.value = v.refractionRatio), v.lightMap && (M.lightMap.value = v.lightMap, M.lightMapIntensity.value = v.lightMapIntensity, i(v.lightMap, M.lightMapTransform)), v.aoMap && (M.aoMap.value = v.aoMap, M.aoMapIntensity.value = v.aoMapIntensity, i(v.aoMap, M.aoMapTransform));
  }
  function h(M, v) {
    M.diffuse.value.copy(v.color), M.opacity.value = v.opacity, v.map && (M.map.value = v.map, i(v.map, M.mapTransform));
  }
  function d(M, v) {
    M.dashSize.value = v.dashSize, M.totalSize.value = v.dashSize + v.gapSize, M.scale.value = v.scale;
  }
  function m(M, v, B, U) {
    M.diffuse.value.copy(v.color), M.opacity.value = v.opacity, M.size.value = v.size * B, M.scale.value = U * 0.5, v.map && (M.map.value = v.map, i(v.map, M.uvTransform)), v.alphaMap && (M.alphaMap.value = v.alphaMap, i(v.alphaMap, M.alphaMapTransform)), v.alphaTest > 0 && (M.alphaTest.value = v.alphaTest);
  }
  function p(M, v) {
    M.diffuse.value.copy(v.color), M.opacity.value = v.opacity, M.rotation.value = v.rotation, v.map && (M.map.value = v.map, i(v.map, M.mapTransform)), v.alphaMap && (M.alphaMap.value = v.alphaMap, i(v.alphaMap, M.alphaMapTransform)), v.alphaTest > 0 && (M.alphaTest.value = v.alphaTest);
  }
  function g(M, v) {
    M.specular.value.copy(v.specular), M.shininess.value = Math.max(v.shininess, 1e-4);
  }
  function _(M, v) {
    v.gradientMap && (M.gradientMap.value = v.gradientMap);
  }
  function x(M, v) {
    M.metalness.value = v.metalness, v.metalnessMap && (M.metalnessMap.value = v.metalnessMap, i(v.metalnessMap, M.metalnessMapTransform)), M.roughness.value = v.roughness, v.roughnessMap && (M.roughnessMap.value = v.roughnessMap, i(v.roughnessMap, M.roughnessMapTransform)), v.envMap && (M.envMapIntensity.value = v.envMapIntensity);
  }
  function S(M, v, B) {
    M.ior.value = v.ior, v.sheen > 0 && (M.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen), M.sheenRoughness.value = v.sheenRoughness, v.sheenColorMap && (M.sheenColorMap.value = v.sheenColorMap, i(v.sheenColorMap, M.sheenColorMapTransform)), v.sheenRoughnessMap && (M.sheenRoughnessMap.value = v.sheenRoughnessMap, i(v.sheenRoughnessMap, M.sheenRoughnessMapTransform))), v.clearcoat > 0 && (M.clearcoat.value = v.clearcoat, M.clearcoatRoughness.value = v.clearcoatRoughness, v.clearcoatMap && (M.clearcoatMap.value = v.clearcoatMap, i(v.clearcoatMap, M.clearcoatMapTransform)), v.clearcoatRoughnessMap && (M.clearcoatRoughnessMap.value = v.clearcoatRoughnessMap, i(v.clearcoatRoughnessMap, M.clearcoatRoughnessMapTransform)), v.clearcoatNormalMap && (M.clearcoatNormalMap.value = v.clearcoatNormalMap, i(v.clearcoatNormalMap, M.clearcoatNormalMapTransform), M.clearcoatNormalScale.value.copy(v.clearcoatNormalScale), v.side === ti && M.clearcoatNormalScale.value.negate())), v.dispersion > 0 && (M.dispersion.value = v.dispersion), v.iridescence > 0 && (M.iridescence.value = v.iridescence, M.iridescenceIOR.value = v.iridescenceIOR, M.iridescenceThicknessMinimum.value = v.iridescenceThicknessRange[0], M.iridescenceThicknessMaximum.value = v.iridescenceThicknessRange[1], v.iridescenceMap && (M.iridescenceMap.value = v.iridescenceMap, i(v.iridescenceMap, M.iridescenceMapTransform)), v.iridescenceThicknessMap && (M.iridescenceThicknessMap.value = v.iridescenceThicknessMap, i(v.iridescenceThicknessMap, M.iridescenceThicknessMapTransform))), v.transmission > 0 && (M.transmission.value = v.transmission, M.transmissionSamplerMap.value = B.texture, M.transmissionSamplerSize.value.set(B.width, B.height), v.transmissionMap && (M.transmissionMap.value = v.transmissionMap, i(v.transmissionMap, M.transmissionMapTransform)), M.thickness.value = v.thickness, v.thicknessMap && (M.thicknessMap.value = v.thicknessMap, i(v.thicknessMap, M.thicknessMapTransform)), M.attenuationDistance.value = v.attenuationDistance, M.attenuationColor.value.copy(v.attenuationColor)), v.anisotropy > 0 && (M.anisotropyVector.value.set(v.anisotropy * Math.cos(v.anisotropyRotation), v.anisotropy * Math.sin(v.anisotropyRotation)), v.anisotropyMap && (M.anisotropyMap.value = v.anisotropyMap, i(v.anisotropyMap, M.anisotropyMapTransform))), M.specularIntensity.value = v.specularIntensity, M.specularColor.value.copy(v.specularColor), v.specularColorMap && (M.specularColorMap.value = v.specularColorMap, i(v.specularColorMap, M.specularColorMapTransform)), v.specularIntensityMap && (M.specularIntensityMap.value = v.specularIntensityMap, i(v.specularIntensityMap, M.specularIntensityMapTransform));
  }
  function E(M, v) {
    v.matcap && (M.matcap.value = v.matcap);
  }
  function b(M, v) {
    const B = t.get(v).light;
    M.referencePosition.value.setFromMatrixPosition(B.matrixWorld), M.nearDistance.value = B.shadow.camera.near, M.farDistance.value = B.shadow.camera.far;
  }
  return {
    refreshFogUniforms: s,
    refreshMaterialUniforms: l
  };
}
function oR(r, t, i, s) {
  let l = {}, c = {}, h = [];
  const d = r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);
  function m(B, U) {
    const w = U.program;
    s.uniformBlockBinding(B, w);
  }
  function p(B, U) {
    let w = l[B.id];
    w === void 0 && (E(B), w = g(B), l[B.id] = w, B.addEventListener("dispose", M));
    const F = U.program;
    s.updateUBOMapping(B, F);
    const L = t.render.frame;
    c[B.id] !== L && (x(B), c[B.id] = L);
  }
  function g(B) {
    const U = _();
    B.__bindingPointIndex = U;
    const w = r.createBuffer(), F = B.__size, L = B.usage;
    return r.bindBuffer(r.UNIFORM_BUFFER, w), r.bufferData(r.UNIFORM_BUFFER, F, L), r.bindBuffer(r.UNIFORM_BUFFER, null), r.bindBufferBase(r.UNIFORM_BUFFER, U, w), w;
  }
  function _() {
    for (let B = 0; B < d; B++)
      if (h.indexOf(B) === -1)
        return h.push(B), B;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function x(B) {
    const U = l[B.id], w = B.uniforms, F = B.__cache;
    r.bindBuffer(r.UNIFORM_BUFFER, U);
    for (let L = 0, O = w.length; L < O; L++) {
      const G = Array.isArray(w[L]) ? w[L] : [w[L]];
      for (let C = 0, T = G.length; C < T; C++) {
        const I = G[C];
        if (S(I, L, C, F) === !0) {
          const J = I.__offset, $ = Array.isArray(I.value) ? I.value : [I.value];
          let lt = 0;
          for (let pt = 0; pt < $.length; pt++) {
            const z = $[pt], tt = b(z);
            typeof z == "number" || typeof z == "boolean" ? (I.__data[0] = z, r.bufferSubData(r.UNIFORM_BUFFER, J + lt, I.__data)) : z.isMatrix3 ? (I.__data[0] = z.elements[0], I.__data[1] = z.elements[1], I.__data[2] = z.elements[2], I.__data[3] = 0, I.__data[4] = z.elements[3], I.__data[5] = z.elements[4], I.__data[6] = z.elements[5], I.__data[7] = 0, I.__data[8] = z.elements[6], I.__data[9] = z.elements[7], I.__data[10] = z.elements[8], I.__data[11] = 0) : (z.toArray(I.__data, lt), lt += tt.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          r.bufferSubData(r.UNIFORM_BUFFER, J, I.__data);
        }
      }
    }
    r.bindBuffer(r.UNIFORM_BUFFER, null);
  }
  function S(B, U, w, F) {
    const L = B.value, O = U + "_" + w;
    if (F[O] === void 0)
      return typeof L == "number" || typeof L == "boolean" ? F[O] = L : F[O] = L.clone(), !0;
    {
      const G = F[O];
      if (typeof L == "number" || typeof L == "boolean") {
        if (G !== L)
          return F[O] = L, !0;
      } else if (G.equals(L) === !1)
        return G.copy(L), !0;
    }
    return !1;
  }
  function E(B) {
    const U = B.uniforms;
    let w = 0;
    const F = 16;
    for (let O = 0, G = U.length; O < G; O++) {
      const C = Array.isArray(U[O]) ? U[O] : [U[O]];
      for (let T = 0, I = C.length; T < I; T++) {
        const J = C[T], $ = Array.isArray(J.value) ? J.value : [J.value];
        for (let lt = 0, pt = $.length; lt < pt; lt++) {
          const z = $[lt], tt = b(z), K = w % F, yt = K % tt.boundary, Mt = K + yt;
          w += yt, Mt !== 0 && F - Mt < tt.storage && (w += F - Mt), J.__data = new Float32Array(tt.storage / Float32Array.BYTES_PER_ELEMENT), J.__offset = w, w += tt.storage;
        }
      }
    }
    const L = w % F;
    return L > 0 && (w += F - L), B.__size = w, B.__cache = {}, this;
  }
  function b(B) {
    const U = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof B == "number" || typeof B == "boolean" ? (U.boundary = 4, U.storage = 4) : B.isVector2 ? (U.boundary = 8, U.storage = 8) : B.isVector3 || B.isColor ? (U.boundary = 16, U.storage = 12) : B.isVector4 ? (U.boundary = 16, U.storage = 16) : B.isMatrix3 ? (U.boundary = 48, U.storage = 48) : B.isMatrix4 ? (U.boundary = 64, U.storage = 64) : B.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", B), U;
  }
  function M(B) {
    const U = B.target;
    U.removeEventListener("dispose", M);
    const w = h.indexOf(U.__bindingPointIndex);
    h.splice(w, 1), r.deleteBuffer(l[U.id]), delete l[U.id], delete c[U.id];
  }
  function v() {
    for (const B in l)
      r.deleteBuffer(l[B]);
    h = [], l = {}, c = {};
  }
  return {
    bind: m,
    update: p,
    dispose: v
  };
}
class lR {
  constructor(t = {}) {
    const {
      canvas: i = FM(),
      context: s = null,
      depth: l = !0,
      stencil: c = !1,
      alpha: h = !1,
      antialias: d = !1,
      premultipliedAlpha: m = !0,
      preserveDrawingBuffer: p = !1,
      powerPreference: g = "default",
      failIfMajorPerformanceCaveat: _ = !1,
      reverseDepthBuffer: x = !1
    } = t;
    this.isWebGLRenderer = !0;
    let S;
    if (s !== null) {
      if (typeof WebGLRenderingContext < "u" && s instanceof WebGLRenderingContext)
        throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
      S = s.getContextAttributes().alpha;
    } else
      S = h;
    const E = new Uint32Array(4), b = new Int32Array(4);
    let M = null, v = null;
    const B = [], U = [];
    this.domElement = i, this.debug = {
      /**
       * Enables error checking and reporting when shader programs are being compiled
       * @type {boolean}
       */
      checkShaderErrors: !0,
      /**
       * Callback for custom error reporting.
       * @type {?Function}
       */
      onShaderError: null
    }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this._outputColorSpace = Si, this.toneMapping = Ja, this.toneMappingExposure = 1;
    const w = this;
    let F = !1, L = 0, O = 0, G = null, C = -1, T = null;
    const I = new Je(), J = new Je();
    let $ = null;
    const lt = new ve(0);
    let pt = 0, z = i.width, tt = i.height, K = 1, yt = null, Mt = null;
    const P = new Je(0, 0, z, tt), st = new Je(0, 0, z, tt);
    let xt = !1;
    const j = new Rp();
    let ht = !1, Et = !1;
    this.transmissionResolutionScale = 1;
    const vt = new Xe(), Ht = new Xe(), Lt = new q(), ae = new Je(), Ne = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    let de = !1;
    function We() {
      return G === null ? K : 1;
    }
    let V = s;
    function vn(D, Y) {
      return i.getContext(D, Y);
    }
    try {
      const D = {
        alpha: !0,
        depth: l,
        stencil: c,
        antialias: d,
        premultipliedAlpha: m,
        preserveDrawingBuffer: p,
        powerPreference: g,
        failIfMajorPerformanceCaveat: _
      };
      if ("setAttribute" in i && i.setAttribute("data-engine", `three.js r${_p}`), i.addEventListener("webglcontextlost", _t, !1), i.addEventListener("webglcontextrestored", Ut, !1), i.addEventListener("webglcontextcreationerror", Nt, !1), V === null) {
        const Y = "webgl2";
        if (V = vn(Y, D), V === null)
          throw vn(Y) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
    } catch (D) {
      throw console.error("THREE.WebGLRenderer: " + D.message), D;
    }
    let fe, pe, Yt, Ue, Xt, N, R, it, dt, St, Q, Tt, wt, Bt, xe, Ct, Gt, jt, Wt, It, te, oe, ze, W;
    function Dt() {
      fe = new _1(V), fe.init(), oe = new $A(V, fe), pe = new f1(V, fe, t, oe), Yt = new QA(V, fe), pe.reverseDepthBuffer && x && Yt.buffers.depth.setReversed(!0), Ue = new y1(V), Xt = new IA(), N = new JA(V, fe, Yt, Xt, pe, oe, Ue), R = new d1(w), it = new g1(w), dt = new RE(V), ze = new c1(V, dt), St = new v1(V, dt, Ue, ze), Q = new M1(V, St, dt, Ue), Wt = new S1(V, pe, N), Ct = new h1(Xt), Tt = new BA(w, R, it, fe, pe, ze, Ct), wt = new rR(w, Xt), Bt = new HA(), xe = new YA(fe), jt = new l1(w, R, it, Yt, Q, S, m), Gt = new ZA(w, Q, pe), W = new oR(V, Ue, pe, Yt), It = new u1(V, fe, Ue), te = new x1(V, fe, Ue), Ue.programs = Tt.programs, w.capabilities = pe, w.extensions = fe, w.properties = Xt, w.renderLists = Bt, w.shadowMap = Gt, w.state = Yt, w.info = Ue;
    }
    Dt();
    const ut = new aR(w, V);
    this.xr = ut, this.getContext = function() {
      return V;
    }, this.getContextAttributes = function() {
      return V.getContextAttributes();
    }, this.forceContextLoss = function() {
      const D = fe.get("WEBGL_lose_context");
      D && D.loseContext();
    }, this.forceContextRestore = function() {
      const D = fe.get("WEBGL_lose_context");
      D && D.restoreContext();
    }, this.getPixelRatio = function() {
      return K;
    }, this.setPixelRatio = function(D) {
      D !== void 0 && (K = D, this.setSize(z, tt, !1));
    }, this.getSize = function(D) {
      return D.set(z, tt);
    }, this.setSize = function(D, Y, rt = !0) {
      if (ut.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      z = D, tt = Y, i.width = Math.floor(D * K), i.height = Math.floor(Y * K), rt === !0 && (i.style.width = D + "px", i.style.height = Y + "px"), this.setViewport(0, 0, D, Y);
    }, this.getDrawingBufferSize = function(D) {
      return D.set(z * K, tt * K).floor();
    }, this.setDrawingBufferSize = function(D, Y, rt) {
      z = D, tt = Y, K = rt, i.width = Math.floor(D * rt), i.height = Math.floor(Y * rt), this.setViewport(0, 0, D, Y);
    }, this.getCurrentViewport = function(D) {
      return D.copy(I);
    }, this.getViewport = function(D) {
      return D.copy(P);
    }, this.setViewport = function(D, Y, rt, ot) {
      D.isVector4 ? P.set(D.x, D.y, D.z, D.w) : P.set(D, Y, rt, ot), Yt.viewport(I.copy(P).multiplyScalar(K).round());
    }, this.getScissor = function(D) {
      return D.copy(st);
    }, this.setScissor = function(D, Y, rt, ot) {
      D.isVector4 ? st.set(D.x, D.y, D.z, D.w) : st.set(D, Y, rt, ot), Yt.scissor(J.copy(st).multiplyScalar(K).round());
    }, this.getScissorTest = function() {
      return xt;
    }, this.setScissorTest = function(D) {
      Yt.setScissorTest(xt = D);
    }, this.setOpaqueSort = function(D) {
      yt = D;
    }, this.setTransparentSort = function(D) {
      Mt = D;
    }, this.getClearColor = function(D) {
      return D.copy(jt.getClearColor());
    }, this.setClearColor = function() {
      jt.setClearColor.apply(jt, arguments);
    }, this.getClearAlpha = function() {
      return jt.getClearAlpha();
    }, this.setClearAlpha = function() {
      jt.setClearAlpha.apply(jt, arguments);
    }, this.clear = function(D = !0, Y = !0, rt = !0) {
      let ot = 0;
      if (D) {
        let X = !1;
        if (G !== null) {
          const At = G.texture.format;
          X = At === Tp || At === bp || At === Ep;
        }
        if (X) {
          const At = G.texture.type, Ot = At === ga || At === Ps || At === ul || At === Qr || At === yp || At === Sp, zt = jt.getClearColor(), Ft = jt.getClearAlpha(), ne = zt.r, ie = zt.g, Zt = zt.b;
          Ot ? (E[0] = ne, E[1] = ie, E[2] = Zt, E[3] = Ft, V.clearBufferuiv(V.COLOR, 0, E)) : (b[0] = ne, b[1] = ie, b[2] = Zt, b[3] = Ft, V.clearBufferiv(V.COLOR, 0, b));
        } else
          ot |= V.COLOR_BUFFER_BIT;
      }
      Y && (ot |= V.DEPTH_BUFFER_BIT), rt && (ot |= V.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), V.clear(ot);
    }, this.clearColor = function() {
      this.clear(!0, !1, !1);
    }, this.clearDepth = function() {
      this.clear(!1, !0, !1);
    }, this.clearStencil = function() {
      this.clear(!1, !1, !0);
    }, this.dispose = function() {
      i.removeEventListener("webglcontextlost", _t, !1), i.removeEventListener("webglcontextrestored", Ut, !1), i.removeEventListener("webglcontextcreationerror", Nt, !1), jt.dispose(), Bt.dispose(), xe.dispose(), Xt.dispose(), R.dispose(), it.dispose(), Q.dispose(), ze.dispose(), W.dispose(), Tt.dispose(), ut.dispose(), ut.removeEventListener("sessionstart", io), ut.removeEventListener("sessionend", ao), Ni.stop();
    };
    function _t(D) {
      D.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), F = !0;
    }
    function Ut() {
      console.log("THREE.WebGLRenderer: Context Restored."), F = !1;
      const D = Ue.autoReset, Y = Gt.enabled, rt = Gt.autoUpdate, ot = Gt.needsUpdate, X = Gt.type;
      Dt(), Ue.autoReset = D, Gt.enabled = Y, Gt.autoUpdate = rt, Gt.needsUpdate = ot, Gt.type = X;
    }
    function Nt(D) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", D.statusMessage);
    }
    function ee(D) {
      const Y = D.target;
      Y.removeEventListener("dispose", ee), Ke(Y);
    }
    function Ke(D) {
      hn(D), Xt.remove(D);
    }
    function hn(D) {
      const Y = Xt.get(D).programs;
      Y !== void 0 && (Y.forEach(function(rt) {
        Tt.releaseProgram(rt);
      }), D.isShaderMaterial && Tt.releaseShaderCache(D));
    }
    this.renderBufferDirect = function(D, Y, rt, ot, X, At) {
      Y === null && (Y = Ne);
      const Ot = X.isMesh && X.matrixWorld.determinant() < 0, zt = ro(D, Y, rt, ot, X);
      Yt.setMaterial(ot, Ot);
      let Ft = rt.index, ne = 1;
      if (ot.wireframe === !0) {
        if (Ft = St.getWireframeAttribute(rt), Ft === void 0) return;
        ne = 2;
      }
      const ie = rt.drawRange, Zt = rt.attributes.position;
      let Me = ie.start * ne, Ee = (ie.start + ie.count) * ne;
      At !== null && (Me = Math.max(Me, At.start * ne), Ee = Math.min(Ee, (At.start + At.count) * ne)), Ft !== null ? (Me = Math.max(Me, 0), Ee = Math.min(Ee, Ft.count)) : Zt != null && (Me = Math.max(Me, 0), Ee = Math.min(Ee, Zt.count));
      const qe = Ee - Me;
      if (qe < 0 || qe === 1 / 0) return;
      ze.setup(X, ot, zt, rt, Ft);
      let Re, se = It;
      if (Ft !== null && (Re = dt.get(Ft), se = te, se.setIndex(Re)), X.isMesh)
        ot.wireframe === !0 ? (Yt.setLineWidth(ot.wireframeLinewidth * We()), se.setMode(V.LINES)) : se.setMode(V.TRIANGLES);
      else if (X.isLine) {
        let Qt = ot.linewidth;
        Qt === void 0 && (Qt = 1), Yt.setLineWidth(Qt * We()), X.isLineSegments ? se.setMode(V.LINES) : X.isLineLoop ? se.setMode(V.LINE_LOOP) : se.setMode(V.LINE_STRIP);
      } else X.isPoints ? se.setMode(V.POINTS) : X.isSprite && se.setMode(V.TRIANGLES);
      if (X.isBatchedMesh)
        if (X._multiDrawInstances !== null)
          se.renderMultiDrawInstances(X._multiDrawStarts, X._multiDrawCounts, X._multiDrawCount, X._multiDrawInstances);
        else if (fe.get("WEBGL_multi_draw"))
          se.renderMultiDraw(X._multiDrawStarts, X._multiDrawCounts, X._multiDrawCount);
        else {
          const Qt = X._multiDrawStarts, dn = X._multiDrawCounts, Te = X._multiDrawCount, Wn = Ft ? dt.get(Ft).bytesPerElement : 1, Ai = Xt.get(ot).currentProgram.getUniforms();
          for (let In = 0; In < Te; In++)
            Ai.setValue(V, "_gl_DrawID", In), se.render(Qt[In] / Wn, dn[In]);
        }
      else if (X.isInstancedMesh)
        se.renderInstances(Me, qe, X.count);
      else if (rt.isInstancedBufferGeometry) {
        const Qt = rt._maxInstanceCount !== void 0 ? rt._maxInstanceCount : 1 / 0, dn = Math.min(rt.instanceCount, Qt);
        se.renderInstances(Me, qe, dn);
      } else
        se.render(Me, qe);
    };
    function Ae(D, Y, rt) {
      D.transparent === !0 && D.side === da && D.forceSinglePass === !1 ? (D.side = ti, D.needsUpdate = !0, $e(D, Y, rt), D.side = ts, D.needsUpdate = !0, $e(D, Y, rt), D.side = da) : $e(D, Y, rt);
    }
    this.compile = function(D, Y, rt = null) {
      rt === null && (rt = D), v = xe.get(rt), v.init(Y), U.push(v), rt.traverseVisible(function(X) {
        X.isLight && X.layers.test(Y.layers) && (v.pushLight(X), X.castShadow && v.pushShadow(X));
      }), D !== rt && D.traverseVisible(function(X) {
        X.isLight && X.layers.test(Y.layers) && (v.pushLight(X), X.castShadow && v.pushShadow(X));
      }), v.setupLights();
      const ot = /* @__PURE__ */ new Set();
      return D.traverse(function(X) {
        if (!(X.isMesh || X.isPoints || X.isLine || X.isSprite))
          return;
        const At = X.material;
        if (At)
          if (Array.isArray(At))
            for (let Ot = 0; Ot < At.length; Ot++) {
              const zt = At[Ot];
              Ae(zt, rt, X), ot.add(zt);
            }
          else
            Ae(At, rt, X), ot.add(At);
      }), U.pop(), v = null, ot;
    }, this.compileAsync = function(D, Y, rt = null) {
      const ot = this.compile(D, Y, rt);
      return new Promise((X) => {
        function At() {
          if (ot.forEach(function(Ot) {
            Xt.get(Ot).currentProgram.isReady() && ot.delete(Ot);
          }), ot.size === 0) {
            X(D);
            return;
          }
          setTimeout(At, 10);
        }
        fe.get("KHR_parallel_shader_compile") !== null ? At() : setTimeout(At, 10);
      });
    };
    let En = null;
    function bi(D) {
      En && En(D);
    }
    function io() {
      Ni.stop();
    }
    function ao() {
      Ni.start();
    }
    const Ni = new Rx();
    Ni.setAnimationLoop(bi), typeof self < "u" && Ni.setContext(self), this.setAnimationLoop = function(D) {
      En = D, ut.setAnimationLoop(D), D === null ? Ni.stop() : Ni.start();
    }, ut.addEventListener("sessionstart", io), ut.addEventListener("sessionend", ao), this.render = function(D, Y) {
      if (Y !== void 0 && Y.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (F === !0) return;
      if (D.matrixWorldAutoUpdate === !0 && D.updateMatrixWorld(), Y.parent === null && Y.matrixWorldAutoUpdate === !0 && Y.updateMatrixWorld(), ut.enabled === !0 && ut.isPresenting === !0 && (ut.cameraAutoUpdate === !0 && ut.updateCamera(Y), Y = ut.getCamera()), D.isScene === !0 && D.onBeforeRender(w, D, Y, G), v = xe.get(D, U.length), v.init(Y), U.push(v), Ht.multiplyMatrices(Y.projectionMatrix, Y.matrixWorldInverse), j.setFromProjectionMatrix(Ht), Et = this.localClippingEnabled, ht = Ct.init(this.clippingPlanes, Et), M = Bt.get(D, B.length), M.init(), B.push(M), ut.enabled === !0 && ut.isPresenting === !0) {
        const At = w.xr.getDepthSensingMesh();
        At !== null && ns(At, Y, -1 / 0, w.sortObjects);
      }
      ns(D, Y, 0, w.sortObjects), M.finish(), w.sortObjects === !0 && M.sort(yt, Mt), de = ut.enabled === !1 || ut.isPresenting === !1 || ut.hasDepthSensing() === !1, de && jt.addToRenderList(M, D), this.info.render.frame++, ht === !0 && Ct.beginShadows();
      const rt = v.state.shadowsArray;
      Gt.render(rt, D, Y), ht === !0 && Ct.endShadows(), this.info.autoReset === !0 && this.info.reset();
      const ot = M.opaque, X = M.transmissive;
      if (v.setupLights(), Y.isArrayCamera) {
        const At = Y.cameras;
        if (X.length > 0)
          for (let Ot = 0, zt = At.length; Ot < zt; Ot++) {
            const Ft = At[Ot];
            so(ot, X, D, Ft);
          }
        de && jt.render(D);
        for (let Ot = 0, zt = At.length; Ot < zt; Ot++) {
          const Ft = At[Ot];
          Hs(M, D, Ft, Ft.viewport);
        }
      } else
        X.length > 0 && so(ot, X, D, Y), de && jt.render(D), Hs(M, D, Y);
      G !== null && O === 0 && (N.updateMultisampleRenderTarget(G), N.updateRenderTargetMipmap(G)), D.isScene === !0 && D.onAfterRender(w, D, Y), ze.resetDefaultState(), C = -1, T = null, U.pop(), U.length > 0 ? (v = U[U.length - 1], ht === !0 && Ct.setGlobalState(w.clippingPlanes, v.state.camera)) : v = null, B.pop(), B.length > 0 ? M = B[B.length - 1] : M = null;
    };
    function ns(D, Y, rt, ot) {
      if (D.visible === !1) return;
      if (D.layers.test(Y.layers)) {
        if (D.isGroup)
          rt = D.renderOrder;
        else if (D.isLOD)
          D.autoUpdate === !0 && D.update(Y);
        else if (D.isLight)
          v.pushLight(D), D.castShadow && v.pushShadow(D);
        else if (D.isSprite) {
          if (!D.frustumCulled || j.intersectsSprite(D)) {
            ot && ae.setFromMatrixPosition(D.matrixWorld).applyMatrix4(Ht);
            const Ot = Q.update(D), zt = D.material;
            zt.visible && M.push(D, Ot, zt, rt, ae.z, null);
          }
        } else if ((D.isMesh || D.isLine || D.isPoints) && (!D.frustumCulled || j.intersectsObject(D))) {
          const Ot = Q.update(D), zt = D.material;
          if (ot && (D.boundingSphere !== void 0 ? (D.boundingSphere === null && D.computeBoundingSphere(), ae.copy(D.boundingSphere.center)) : (Ot.boundingSphere === null && Ot.computeBoundingSphere(), ae.copy(Ot.boundingSphere.center)), ae.applyMatrix4(D.matrixWorld).applyMatrix4(Ht)), Array.isArray(zt)) {
            const Ft = Ot.groups;
            for (let ne = 0, ie = Ft.length; ne < ie; ne++) {
              const Zt = Ft[ne], Me = zt[Zt.materialIndex];
              Me && Me.visible && M.push(D, Ot, Me, rt, ae.z, Zt);
            }
          } else zt.visible && M.push(D, Ot, zt, rt, ae.z, null);
        }
      }
      const At = D.children;
      for (let Ot = 0, zt = At.length; Ot < zt; Ot++)
        ns(At[Ot], Y, rt, ot);
    }
    function Hs(D, Y, rt, ot) {
      const X = D.opaque, At = D.transmissive, Ot = D.transparent;
      v.setupLightsView(rt), ht === !0 && Ct.setGlobalState(w.clippingPlanes, rt), ot && Yt.viewport(I.copy(ot)), X.length > 0 && is(X, Y, rt), At.length > 0 && is(At, Y, rt), Ot.length > 0 && is(Ot, Y, rt), Yt.buffers.depth.setTest(!0), Yt.buffers.depth.setMask(!0), Yt.buffers.color.setMask(!0), Yt.setPolygonOffset(!1);
    }
    function so(D, Y, rt, ot) {
      if ((rt.isScene === !0 ? rt.overrideMaterial : null) !== null)
        return;
      v.state.transmissionRenderTarget[ot.id] === void 0 && (v.state.transmissionRenderTarget[ot.id] = new zs(1, 1, {
        generateMipmaps: !0,
        type: fe.has("EXT_color_buffer_half_float") || fe.has("EXT_color_buffer_float") ? hl : ga,
        minFilter: Ls,
        samples: 4,
        stencilBuffer: c,
        resolveDepthBuffer: !1,
        resolveStencilBuffer: !1,
        colorSpace: De.workingColorSpace
      }));
      const At = v.state.transmissionRenderTarget[ot.id], Ot = ot.viewport || I;
      At.setSize(Ot.z * w.transmissionResolutionScale, Ot.w * w.transmissionResolutionScale);
      const zt = w.getRenderTarget();
      w.setRenderTarget(At), w.getClearColor(lt), pt = w.getClearAlpha(), pt < 1 && w.setClearColor(16777215, 0.5), w.clear(), de && jt.render(rt);
      const Ft = w.toneMapping;
      w.toneMapping = Ja;
      const ne = ot.viewport;
      if (ot.viewport !== void 0 && (ot.viewport = void 0), v.setupLightsView(ot), ht === !0 && Ct.setGlobalState(w.clippingPlanes, ot), is(D, rt, ot), N.updateMultisampleRenderTarget(At), N.updateRenderTargetMipmap(At), fe.has("WEBGL_multisampled_render_to_texture") === !1) {
        let ie = !1;
        for (let Zt = 0, Me = Y.length; Zt < Me; Zt++) {
          const Ee = Y[Zt], qe = Ee.object, Re = Ee.geometry, se = Ee.material, Qt = Ee.group;
          if (se.side === da && qe.layers.test(ot.layers)) {
            const dn = se.side;
            se.side = ti, se.needsUpdate = !0, Ti(qe, rt, ot, Re, se, Qt), se.side = dn, se.needsUpdate = !0, ie = !0;
          }
        }
        ie === !0 && (N.updateMultisampleRenderTarget(At), N.updateRenderTargetMipmap(At));
      }
      w.setRenderTarget(zt), w.setClearColor(lt, pt), ne !== void 0 && (ot.viewport = ne), w.toneMapping = Ft;
    }
    function is(D, Y, rt) {
      const ot = Y.isScene === !0 ? Y.overrideMaterial : null;
      for (let X = 0, At = D.length; X < At; X++) {
        const Ot = D[X], zt = Ot.object, Ft = Ot.geometry, ne = ot === null ? Ot.material : ot, ie = Ot.group;
        zt.layers.test(rt.layers) && Ti(zt, Y, rt, Ft, ne, ie);
      }
    }
    function Ti(D, Y, rt, ot, X, At) {
      D.onBeforeRender(w, Y, rt, ot, X, At), D.modelViewMatrix.multiplyMatrices(rt.matrixWorldInverse, D.matrixWorld), D.normalMatrix.getNormalMatrix(D.modelViewMatrix), X.onBeforeRender(w, Y, rt, ot, D, At), X.transparent === !0 && X.side === da && X.forceSinglePass === !1 ? (X.side = ti, X.needsUpdate = !0, w.renderBufferDirect(rt, Y, ot, X, D, At), X.side = ts, X.needsUpdate = !0, w.renderBufferDirect(rt, Y, ot, X, D, At), X.side = da) : w.renderBufferDirect(rt, Y, ot, X, D, At), D.onAfterRender(w, Y, rt, ot, X, At);
    }
    function $e(D, Y, rt) {
      Y.isScene !== !0 && (Y = Ne);
      const ot = Xt.get(D), X = v.state.lights, At = v.state.shadowsArray, Ot = X.state.version, zt = Tt.getParameters(D, X.state, At, Y, rt), Ft = Tt.getProgramCacheKey(zt);
      let ne = ot.programs;
      ot.environment = D.isMeshStandardMaterial ? Y.environment : null, ot.fog = Y.fog, ot.envMap = (D.isMeshStandardMaterial ? it : R).get(D.envMap || ot.environment), ot.envMapRotation = ot.environment !== null && D.envMap === null ? Y.environmentRotation : D.envMapRotation, ne === void 0 && (D.addEventListener("dispose", ee), ne = /* @__PURE__ */ new Map(), ot.programs = ne);
      let ie = ne.get(Ft);
      if (ie !== void 0) {
        if (ot.currentProgram === ie && ot.lightsStateVersion === Ot)
          return Vi(D, zt), ie;
      } else
        zt.uniforms = Tt.getUniforms(D), D.onBeforeCompile(zt, w), ie = Tt.acquireProgram(zt, Ft), ne.set(Ft, ie), ot.uniforms = zt.uniforms;
      const Zt = ot.uniforms;
      return (!D.isShaderMaterial && !D.isRawShaderMaterial || D.clipping === !0) && (Zt.clippingPlanes = Ct.uniform), Vi(D, zt), ot.needsLights = Tu(D), ot.lightsStateVersion = Ot, ot.needsLights && (Zt.ambientLightColor.value = X.state.ambient, Zt.lightProbe.value = X.state.probe, Zt.directionalLights.value = X.state.directional, Zt.directionalLightShadows.value = X.state.directionalShadow, Zt.spotLights.value = X.state.spot, Zt.spotLightShadows.value = X.state.spotShadow, Zt.rectAreaLights.value = X.state.rectArea, Zt.ltc_1.value = X.state.rectAreaLTC1, Zt.ltc_2.value = X.state.rectAreaLTC2, Zt.pointLights.value = X.state.point, Zt.pointLightShadows.value = X.state.pointShadow, Zt.hemisphereLights.value = X.state.hemi, Zt.directionalShadowMap.value = X.state.directionalShadowMap, Zt.directionalShadowMatrix.value = X.state.directionalShadowMatrix, Zt.spotShadowMap.value = X.state.spotShadowMap, Zt.spotLightMatrix.value = X.state.spotLightMatrix, Zt.spotLightMap.value = X.state.spotLightMap, Zt.pointShadowMap.value = X.state.pointShadowMap, Zt.pointShadowMatrix.value = X.state.pointShadowMatrix), ot.currentProgram = ie, ot.uniformsList = null, ie;
    }
    function bn(D) {
      if (D.uniformsList === null) {
        const Y = D.currentProgram.getUniforms();
        D.uniformsList = cu.seqWithValue(Y.seq, D.uniforms);
      }
      return D.uniformsList;
    }
    function Vi(D, Y) {
      const rt = Xt.get(D);
      rt.outputColorSpace = Y.outputColorSpace, rt.batching = Y.batching, rt.batchingColor = Y.batchingColor, rt.instancing = Y.instancing, rt.instancingColor = Y.instancingColor, rt.instancingMorph = Y.instancingMorph, rt.skinning = Y.skinning, rt.morphTargets = Y.morphTargets, rt.morphNormals = Y.morphNormals, rt.morphColors = Y.morphColors, rt.morphTargetsCount = Y.morphTargetsCount, rt.numClippingPlanes = Y.numClippingPlanes, rt.numIntersection = Y.numClipIntersection, rt.vertexAlphas = Y.vertexAlphas, rt.vertexTangents = Y.vertexTangents, rt.toneMapping = Y.toneMapping;
    }
    function ro(D, Y, rt, ot, X) {
      Y.isScene !== !0 && (Y = Ne), N.resetTextureUnits();
      const At = Y.fog, Ot = ot.isMeshStandardMaterial ? Y.environment : null, zt = G === null ? w.outputColorSpace : G.isXRRenderTarget === !0 ? G.texture.colorSpace : $r, Ft = (ot.isMeshStandardMaterial ? it : R).get(ot.envMap || Ot), ne = ot.vertexColors === !0 && !!rt.attributes.color && rt.attributes.color.itemSize === 4, ie = !!rt.attributes.tangent && (!!ot.normalMap || ot.anisotropy > 0), Zt = !!rt.morphAttributes.position, Me = !!rt.morphAttributes.normal, Ee = !!rt.morphAttributes.color;
      let qe = Ja;
      ot.toneMapped && (G === null || G.isXRRenderTarget === !0) && (qe = w.toneMapping);
      const Re = rt.morphAttributes.position || rt.morphAttributes.normal || rt.morphAttributes.color, se = Re !== void 0 ? Re.length : 0, Qt = Xt.get(ot), dn = v.state.lights;
      if (ht === !0 && (Et === !0 || D !== T)) {
        const tn = D === T && ot.id === C;
        Ct.setState(ot, D, tn);
      }
      let Te = !1;
      ot.version === Qt.__version ? (Qt.needsLights && Qt.lightsStateVersion !== dn.state.version || Qt.outputColorSpace !== zt || X.isBatchedMesh && Qt.batching === !1 || !X.isBatchedMesh && Qt.batching === !0 || X.isBatchedMesh && Qt.batchingColor === !0 && X.colorTexture === null || X.isBatchedMesh && Qt.batchingColor === !1 && X.colorTexture !== null || X.isInstancedMesh && Qt.instancing === !1 || !X.isInstancedMesh && Qt.instancing === !0 || X.isSkinnedMesh && Qt.skinning === !1 || !X.isSkinnedMesh && Qt.skinning === !0 || X.isInstancedMesh && Qt.instancingColor === !0 && X.instanceColor === null || X.isInstancedMesh && Qt.instancingColor === !1 && X.instanceColor !== null || X.isInstancedMesh && Qt.instancingMorph === !0 && X.morphTexture === null || X.isInstancedMesh && Qt.instancingMorph === !1 && X.morphTexture !== null || Qt.envMap !== Ft || ot.fog === !0 && Qt.fog !== At || Qt.numClippingPlanes !== void 0 && (Qt.numClippingPlanes !== Ct.numPlanes || Qt.numIntersection !== Ct.numIntersection) || Qt.vertexAlphas !== ne || Qt.vertexTangents !== ie || Qt.morphTargets !== Zt || Qt.morphNormals !== Me || Qt.morphColors !== Ee || Qt.toneMapping !== qe || Qt.morphTargetsCount !== se) && (Te = !0) : (Te = !0, Qt.__version = ot.version);
      let Wn = Qt.currentProgram;
      Te === !0 && (Wn = $e(ot, Y, X));
      let Ai = !1, In = !1, xn = !1;
      const Be = Wn.getUniforms(), Fn = Qt.uniforms;
      if (Yt.useProgram(Wn.program) && (Ai = !0, In = !0, xn = !0), ot.id !== C && (C = ot.id, In = !0), Ai || T !== D) {
        Yt.buffers.depth.getReversed() ? (vt.copy(D.projectionMatrix), GM(vt), VM(vt), Be.setValue(V, "projectionMatrix", vt)) : Be.setValue(V, "projectionMatrix", D.projectionMatrix), Be.setValue(V, "viewMatrix", D.matrixWorldInverse);
        const Tn = Be.map.cameraPosition;
        Tn !== void 0 && Tn.setValue(V, Lt.setFromMatrixPosition(D.matrixWorld)), pe.logarithmicDepthBuffer && Be.setValue(
          V,
          "logDepthBufFC",
          2 / (Math.log(D.far + 1) / Math.LN2)
        ), (ot.isMeshPhongMaterial || ot.isMeshToonMaterial || ot.isMeshLambertMaterial || ot.isMeshBasicMaterial || ot.isMeshStandardMaterial || ot.isShaderMaterial) && Be.setValue(V, "isOrthographic", D.isOrthographicCamera === !0), T !== D && (T = D, In = !0, xn = !0);
      }
      if (X.isSkinnedMesh) {
        Be.setOptional(V, X, "bindMatrix"), Be.setOptional(V, X, "bindMatrixInverse");
        const tn = X.skeleton;
        tn && (tn.boneTexture === null && tn.computeBoneTexture(), Be.setValue(V, "boneTexture", tn.boneTexture, N));
      }
      X.isBatchedMesh && (Be.setOptional(V, X, "batchingTexture"), Be.setValue(V, "batchingTexture", X._matricesTexture, N), Be.setOptional(V, X, "batchingIdTexture"), Be.setValue(V, "batchingIdTexture", X._indirectTexture, N), Be.setOptional(V, X, "batchingColorTexture"), X._colorsTexture !== null && Be.setValue(V, "batchingColorTexture", X._colorsTexture, N));
      const Ln = rt.morphAttributes;
      if ((Ln.position !== void 0 || Ln.normal !== void 0 || Ln.color !== void 0) && Wt.update(X, rt, Wn), (In || Qt.receiveShadow !== X.receiveShadow) && (Qt.receiveShadow = X.receiveShadow, Be.setValue(V, "receiveShadow", X.receiveShadow)), ot.isMeshGouraudMaterial && ot.envMap !== null && (Fn.envMap.value = Ft, Fn.flipEnvMap.value = Ft.isCubeTexture && Ft.isRenderTargetTexture === !1 ? -1 : 1), ot.isMeshStandardMaterial && ot.envMap === null && Y.environment !== null && (Fn.envMapIntensity.value = Y.environmentIntensity), In && (Be.setValue(V, "toneMappingExposure", w.toneMappingExposure), Qt.needsLights && bu(Fn, xn), At && ot.fog === !0 && wt.refreshFogUniforms(Fn, At), wt.refreshMaterialUniforms(Fn, ot, K, tt, v.state.transmissionRenderTarget[D.id]), cu.upload(V, bn(Qt), Fn, N)), ot.isShaderMaterial && ot.uniformsNeedUpdate === !0 && (cu.upload(V, bn(Qt), Fn, N), ot.uniformsNeedUpdate = !1), ot.isSpriteMaterial && Be.setValue(V, "center", X.center), Be.setValue(V, "modelViewMatrix", X.modelViewMatrix), Be.setValue(V, "normalMatrix", X.normalMatrix), Be.setValue(V, "modelMatrix", X.matrixWorld), ot.isShaderMaterial || ot.isRawShaderMaterial) {
        const tn = ot.uniformsGroups;
        for (let Tn = 0, Gs = tn.length; Tn < Gs; Tn++) {
          const Yn = tn[Tn];
          W.update(Yn, Wn), W.bind(Yn, Wn);
        }
      }
      return Wn;
    }
    function bu(D, Y) {
      D.ambientLightColor.needsUpdate = Y, D.lightProbe.needsUpdate = Y, D.directionalLights.needsUpdate = Y, D.directionalLightShadows.needsUpdate = Y, D.pointLights.needsUpdate = Y, D.pointLightShadows.needsUpdate = Y, D.spotLights.needsUpdate = Y, D.spotLightShadows.needsUpdate = Y, D.rectAreaLights.needsUpdate = Y, D.hemisphereLights.needsUpdate = Y;
    }
    function Tu(D) {
      return D.isMeshLambertMaterial || D.isMeshToonMaterial || D.isMeshPhongMaterial || D.isMeshStandardMaterial || D.isShadowMaterial || D.isShaderMaterial && D.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return L;
    }, this.getActiveMipmapLevel = function() {
      return O;
    }, this.getRenderTarget = function() {
      return G;
    }, this.setRenderTargetTextures = function(D, Y, rt) {
      Xt.get(D.texture).__webglTexture = Y, Xt.get(D.depthTexture).__webglTexture = rt;
      const ot = Xt.get(D);
      ot.__hasExternalTextures = !0, ot.__autoAllocateDepthBuffer = rt === void 0, ot.__autoAllocateDepthBuffer || fe.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), ot.__useRenderToTexture = !1);
    }, this.setRenderTargetFramebuffer = function(D, Y) {
      const rt = Xt.get(D);
      rt.__webglFramebuffer = Y, rt.__useDefaultFramebuffer = Y === void 0;
    };
    const ml = V.createFramebuffer();
    this.setRenderTarget = function(D, Y = 0, rt = 0) {
      G = D, L = Y, O = rt;
      let ot = !0, X = null, At = !1, Ot = !1;
      if (D) {
        const Ft = Xt.get(D);
        if (Ft.__useDefaultFramebuffer !== void 0)
          Yt.bindFramebuffer(V.FRAMEBUFFER, null), ot = !1;
        else if (Ft.__webglFramebuffer === void 0)
          N.setupRenderTarget(D);
        else if (Ft.__hasExternalTextures)
          N.rebindTextures(D, Xt.get(D.texture).__webglTexture, Xt.get(D.depthTexture).__webglTexture);
        else if (D.depthBuffer) {
          const Zt = D.depthTexture;
          if (Ft.__boundDepthTexture !== Zt) {
            if (Zt !== null && Xt.has(Zt) && (D.width !== Zt.image.width || D.height !== Zt.image.height))
              throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
            N.setupDepthRenderbuffer(D);
          }
        }
        const ne = D.texture;
        (ne.isData3DTexture || ne.isDataArrayTexture || ne.isCompressedArrayTexture) && (Ot = !0);
        const ie = Xt.get(D).__webglFramebuffer;
        D.isWebGLCubeRenderTarget ? (Array.isArray(ie[Y]) ? X = ie[Y][rt] : X = ie[Y], At = !0) : D.samples > 0 && N.useMultisampledRTT(D) === !1 ? X = Xt.get(D).__webglMultisampledFramebuffer : Array.isArray(ie) ? X = ie[rt] : X = ie, I.copy(D.viewport), J.copy(D.scissor), $ = D.scissorTest;
      } else
        I.copy(P).multiplyScalar(K).floor(), J.copy(st).multiplyScalar(K).floor(), $ = xt;
      if (rt !== 0 && (X = ml), Yt.bindFramebuffer(V.FRAMEBUFFER, X) && ot && Yt.drawBuffers(D, X), Yt.viewport(I), Yt.scissor(J), Yt.setScissorTest($), At) {
        const Ft = Xt.get(D.texture);
        V.framebufferTexture2D(V.FRAMEBUFFER, V.COLOR_ATTACHMENT0, V.TEXTURE_CUBE_MAP_POSITIVE_X + Y, Ft.__webglTexture, rt);
      } else if (Ot) {
        const Ft = Xt.get(D.texture), ne = Y;
        V.framebufferTextureLayer(V.FRAMEBUFFER, V.COLOR_ATTACHMENT0, Ft.__webglTexture, rt, ne);
      } else if (D !== null && rt !== 0) {
        const Ft = Xt.get(D.texture);
        V.framebufferTexture2D(V.FRAMEBUFFER, V.COLOR_ATTACHMENT0, V.TEXTURE_2D, Ft.__webglTexture, rt);
      }
      C = -1;
    }, this.readRenderTargetPixels = function(D, Y, rt, ot, X, At, Ot) {
      if (!(D && D.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let zt = Xt.get(D).__webglFramebuffer;
      if (D.isWebGLCubeRenderTarget && Ot !== void 0 && (zt = zt[Ot]), zt) {
        Yt.bindFramebuffer(V.FRAMEBUFFER, zt);
        try {
          const Ft = D.texture, ne = Ft.format, ie = Ft.type;
          if (!pe.textureFormatReadable(ne)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          if (!pe.textureTypeReadable(ie)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          Y >= 0 && Y <= D.width - ot && rt >= 0 && rt <= D.height - X && V.readPixels(Y, rt, ot, X, oe.convert(ne), oe.convert(ie), At);
        } finally {
          const Ft = G !== null ? Xt.get(G).__webglFramebuffer : null;
          Yt.bindFramebuffer(V.FRAMEBUFFER, Ft);
        }
      }
    }, this.readRenderTargetPixelsAsync = async function(D, Y, rt, ot, X, At, Ot) {
      if (!(D && D.isWebGLRenderTarget))
        throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
      let zt = Xt.get(D).__webglFramebuffer;
      if (D.isWebGLCubeRenderTarget && Ot !== void 0 && (zt = zt[Ot]), zt) {
        const Ft = D.texture, ne = Ft.format, ie = Ft.type;
        if (!pe.textureFormatReadable(ne))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
        if (!pe.textureTypeReadable(ie))
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
        if (Y >= 0 && Y <= D.width - ot && rt >= 0 && rt <= D.height - X) {
          Yt.bindFramebuffer(V.FRAMEBUFFER, zt);
          const Zt = V.createBuffer();
          V.bindBuffer(V.PIXEL_PACK_BUFFER, Zt), V.bufferData(V.PIXEL_PACK_BUFFER, At.byteLength, V.STREAM_READ), V.readPixels(Y, rt, ot, X, oe.convert(ne), oe.convert(ie), 0);
          const Me = G !== null ? Xt.get(G).__webglFramebuffer : null;
          Yt.bindFramebuffer(V.FRAMEBUFFER, Me);
          const Ee = V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE, 0);
          return V.flush(), await HM(V, Ee, 4), V.bindBuffer(V.PIXEL_PACK_BUFFER, Zt), V.getBufferSubData(V.PIXEL_PACK_BUFFER, 0, At), V.deleteBuffer(Zt), V.deleteSync(Ee), At;
        } else
          throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
      }
    }, this.copyFramebufferToTexture = function(D, Y = null, rt = 0) {
      D.isTexture !== !0 && (Gr("WebGLRenderer: copyFramebufferToTexture function signature has changed."), Y = arguments[0] || null, D = arguments[1]);
      const ot = Math.pow(2, -rt), X = Math.floor(D.image.width * ot), At = Math.floor(D.image.height * ot), Ot = Y !== null ? Y.x : 0, zt = Y !== null ? Y.y : 0;
      N.setTexture2D(D, 0), V.copyTexSubImage2D(V.TEXTURE_2D, rt, 0, 0, Ot, zt, X, At), Yt.unbindTexture();
    };
    const as = V.createFramebuffer(), oo = V.createFramebuffer();
    this.copyTextureToTexture = function(D, Y, rt = null, ot = null, X = 0, At = null) {
      D.isTexture !== !0 && (Gr("WebGLRenderer: copyTextureToTexture function signature has changed."), ot = arguments[0] || null, D = arguments[1], Y = arguments[2], At = arguments[3] || 0, rt = null), At === null && (X !== 0 ? (Gr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."), At = X, X = 0) : At = 0);
      let Ot, zt, Ft, ne, ie, Zt, Me, Ee, qe;
      const Re = D.isCompressedTexture ? D.mipmaps[At] : D.image;
      if (rt !== null)
        Ot = rt.max.x - rt.min.x, zt = rt.max.y - rt.min.y, Ft = rt.isBox3 ? rt.max.z - rt.min.z : 1, ne = rt.min.x, ie = rt.min.y, Zt = rt.isBox3 ? rt.min.z : 0;
      else {
        const Ln = Math.pow(2, -X);
        Ot = Math.floor(Re.width * Ln), zt = Math.floor(Re.height * Ln), D.isDataArrayTexture ? Ft = Re.depth : D.isData3DTexture ? Ft = Math.floor(Re.depth * Ln) : Ft = 1, ne = 0, ie = 0, Zt = 0;
      }
      ot !== null ? (Me = ot.x, Ee = ot.y, qe = ot.z) : (Me = 0, Ee = 0, qe = 0);
      const se = oe.convert(Y.format), Qt = oe.convert(Y.type);
      let dn;
      Y.isData3DTexture ? (N.setTexture3D(Y, 0), dn = V.TEXTURE_3D) : Y.isDataArrayTexture || Y.isCompressedArrayTexture ? (N.setTexture2DArray(Y, 0), dn = V.TEXTURE_2D_ARRAY) : (N.setTexture2D(Y, 0), dn = V.TEXTURE_2D), V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL, Y.flipY), V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL, Y.premultiplyAlpha), V.pixelStorei(V.UNPACK_ALIGNMENT, Y.unpackAlignment);
      const Te = V.getParameter(V.UNPACK_ROW_LENGTH), Wn = V.getParameter(V.UNPACK_IMAGE_HEIGHT), Ai = V.getParameter(V.UNPACK_SKIP_PIXELS), In = V.getParameter(V.UNPACK_SKIP_ROWS), xn = V.getParameter(V.UNPACK_SKIP_IMAGES);
      V.pixelStorei(V.UNPACK_ROW_LENGTH, Re.width), V.pixelStorei(V.UNPACK_IMAGE_HEIGHT, Re.height), V.pixelStorei(V.UNPACK_SKIP_PIXELS, ne), V.pixelStorei(V.UNPACK_SKIP_ROWS, ie), V.pixelStorei(V.UNPACK_SKIP_IMAGES, Zt);
      const Be = D.isDataArrayTexture || D.isData3DTexture, Fn = Y.isDataArrayTexture || Y.isData3DTexture;
      if (D.isDepthTexture) {
        const Ln = Xt.get(D), tn = Xt.get(Y), Tn = Xt.get(Ln.__renderTarget), Gs = Xt.get(tn.__renderTarget);
        Yt.bindFramebuffer(V.READ_FRAMEBUFFER, Tn.__webglFramebuffer), Yt.bindFramebuffer(V.DRAW_FRAMEBUFFER, Gs.__webglFramebuffer);
        for (let Yn = 0; Yn < Ft; Yn++)
          Be && (V.framebufferTextureLayer(V.READ_FRAMEBUFFER, V.COLOR_ATTACHMENT0, Xt.get(D).__webglTexture, X, Zt + Yn), V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER, V.COLOR_ATTACHMENT0, Xt.get(Y).__webglTexture, At, qe + Yn)), V.blitFramebuffer(ne, ie, Ot, zt, Me, Ee, Ot, zt, V.DEPTH_BUFFER_BIT, V.NEAREST);
        Yt.bindFramebuffer(V.READ_FRAMEBUFFER, null), Yt.bindFramebuffer(V.DRAW_FRAMEBUFFER, null);
      } else if (X !== 0 || D.isRenderTargetTexture || Xt.has(D)) {
        const Ln = Xt.get(D), tn = Xt.get(Y);
        Yt.bindFramebuffer(V.READ_FRAMEBUFFER, as), Yt.bindFramebuffer(V.DRAW_FRAMEBUFFER, oo);
        for (let Tn = 0; Tn < Ft; Tn++)
          Be ? V.framebufferTextureLayer(V.READ_FRAMEBUFFER, V.COLOR_ATTACHMENT0, Ln.__webglTexture, X, Zt + Tn) : V.framebufferTexture2D(V.READ_FRAMEBUFFER, V.COLOR_ATTACHMENT0, V.TEXTURE_2D, Ln.__webglTexture, X), Fn ? V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER, V.COLOR_ATTACHMENT0, tn.__webglTexture, At, qe + Tn) : V.framebufferTexture2D(V.DRAW_FRAMEBUFFER, V.COLOR_ATTACHMENT0, V.TEXTURE_2D, tn.__webglTexture, At), X !== 0 ? V.blitFramebuffer(ne, ie, Ot, zt, Me, Ee, Ot, zt, V.COLOR_BUFFER_BIT, V.NEAREST) : Fn ? V.copyTexSubImage3D(dn, At, Me, Ee, qe + Tn, ne, ie, Ot, zt) : V.copyTexSubImage2D(dn, At, Me, Ee, ne, ie, Ot, zt);
        Yt.bindFramebuffer(V.READ_FRAMEBUFFER, null), Yt.bindFramebuffer(V.DRAW_FRAMEBUFFER, null);
      } else
        Fn ? D.isDataTexture || D.isData3DTexture ? V.texSubImage3D(dn, At, Me, Ee, qe, Ot, zt, Ft, se, Qt, Re.data) : Y.isCompressedArrayTexture ? V.compressedTexSubImage3D(dn, At, Me, Ee, qe, Ot, zt, Ft, se, Re.data) : V.texSubImage3D(dn, At, Me, Ee, qe, Ot, zt, Ft, se, Qt, Re) : D.isDataTexture ? V.texSubImage2D(V.TEXTURE_2D, At, Me, Ee, Ot, zt, se, Qt, Re.data) : D.isCompressedTexture ? V.compressedTexSubImage2D(V.TEXTURE_2D, At, Me, Ee, Re.width, Re.height, se, Re.data) : V.texSubImage2D(V.TEXTURE_2D, At, Me, Ee, Ot, zt, se, Qt, Re);
      V.pixelStorei(V.UNPACK_ROW_LENGTH, Te), V.pixelStorei(V.UNPACK_IMAGE_HEIGHT, Wn), V.pixelStorei(V.UNPACK_SKIP_PIXELS, Ai), V.pixelStorei(V.UNPACK_SKIP_ROWS, In), V.pixelStorei(V.UNPACK_SKIP_IMAGES, xn), At === 0 && Y.generateMipmaps && V.generateMipmap(dn), Yt.unbindTexture();
    }, this.copyTextureToTexture3D = function(D, Y, rt = null, ot = null, X = 0) {
      return D.isTexture !== !0 && (Gr("WebGLRenderer: copyTextureToTexture3D function signature has changed."), rt = arguments[0] || null, ot = arguments[1] || null, D = arguments[2], Y = arguments[3], X = arguments[4] || 0), Gr('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'), this.copyTextureToTexture(D, Y, rt, ot, X);
    }, this.initRenderTarget = function(D) {
      Xt.get(D).__webglFramebuffer === void 0 && N.setupRenderTarget(D);
    }, this.initTexture = function(D) {
      D.isCubeTexture ? N.setTextureCube(D, 0) : D.isData3DTexture ? N.setTexture3D(D, 0) : D.isDataArrayTexture || D.isCompressedArrayTexture ? N.setTexture2DArray(D, 0) : N.setTexture2D(D, 0), Yt.unbindTexture();
    }, this.resetState = function() {
      L = 0, O = 0, G = null, Yt.reset(), ze.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return pa;
  }
  get outputColorSpace() {
    return this._outputColorSpace;
  }
  set outputColorSpace(t) {
    this._outputColorSpace = t;
    const i = this.getContext();
    i.drawingBufferColorspace = De._getDrawingBufferColorSpace(t), i.unpackColorSpace = De._getUnpackColorSpace();
  }
}
const Lv = { type: "change" }, Lp = { type: "start" }, Lx = { type: "end" }, $c = new Ap(), Nv = new ja(), cR = Math.cos(70 * IM.DEG2RAD), mn = new q(), $n = 2 * Math.PI, ke = {
  NONE: -1,
  ROTATE: 0,
  DOLLY: 1,
  PAN: 2,
  TOUCH_ROTATE: 3,
  TOUCH_PAN: 4,
  TOUCH_DOLLY_PAN: 5,
  TOUCH_DOLLY_ROTATE: 6
}, _d = 1e-6;
class Ov extends TE {
  constructor(t, i = null) {
    super(t, i), this.state = ke.NONE, this.enabled = !0, this.target = new q(), this.cursor = new q(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: Xr.ROTATE, MIDDLE: Xr.DOLLY, RIGHT: Xr.PAN }, this.touches = { ONE: Vr.ROTATE, TWO: Vr.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new q(), this._lastQuaternion = new es(), this._lastTargetPosition = new q(), this._quat = new es().setFromUnitVectors(t.up, new q(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new sv(), this._sphericalDelta = new sv(), this._scale = 1, this._panOffset = new q(), this._rotateStart = new $t(), this._rotateEnd = new $t(), this._rotateDelta = new $t(), this._panStart = new $t(), this._panEnd = new $t(), this._panDelta = new $t(), this._dollyStart = new $t(), this._dollyEnd = new $t(), this._dollyDelta = new $t(), this._dollyDirection = new q(), this._mouse = new $t(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = fR.bind(this), this._onPointerDown = uR.bind(this), this._onPointerUp = hR.bind(this), this._onContextMenu = xR.bind(this), this._onMouseWheel = mR.bind(this), this._onKeyDown = gR.bind(this), this._onTouchStart = _R.bind(this), this._onTouchMove = vR.bind(this), this._onMouseDown = dR.bind(this), this._onMouseMove = pR.bind(this), this._interceptControlDown = yR.bind(this), this._interceptControlUp = SR.bind(this), this.domElement !== null && this.connect(), this.update();
  }
  connect() {
    this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
  }
  disconnect() {
    this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "auto";
  }
  dispose() {
    this.disconnect();
  }
  getPolarAngle() {
    return this._spherical.phi;
  }
  getAzimuthalAngle() {
    return this._spherical.theta;
  }
  getDistance() {
    return this.object.position.distanceTo(this.target);
  }
  listenToKeyEvents(t) {
    t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
  }
  stopListenToKeyEvents() {
    this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
  }
  saveState() {
    this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
  }
  reset() {
    this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Lv), this.update(), this.state = ke.NONE;
  }
  update(t = null) {
    const i = this.object.position;
    mn.copy(i).sub(this.target), mn.applyQuaternion(this._quat), this._spherical.setFromVector3(mn), this.autoRotate && this.state === ke.NONE && this._rotateLeft(this._getAutoRotationAngle(t)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
    let s = this.minAzimuthAngle, l = this.maxAzimuthAngle;
    isFinite(s) && isFinite(l) && (s < -Math.PI ? s += $n : s > Math.PI && (s -= $n), l < -Math.PI ? l += $n : l > Math.PI && (l -= $n), s <= l ? this._spherical.theta = Math.max(s, Math.min(l, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (s + l) / 2 ? Math.max(s, this._spherical.theta) : Math.min(l, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
    let c = !1;
    if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
      this._spherical.radius = this._clampDistance(this._spherical.radius);
    else {
      const h = this._spherical.radius;
      this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), c = h != this._spherical.radius;
    }
    if (mn.setFromSpherical(this._spherical), mn.applyQuaternion(this._quatInverse), i.copy(this.target).add(mn), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
      let h = null;
      if (this.object.isPerspectiveCamera) {
        const d = mn.length();
        h = this._clampDistance(d * this._scale);
        const m = d - h;
        this.object.position.addScaledVector(this._dollyDirection, m), this.object.updateMatrixWorld(), c = !!m;
      } else if (this.object.isOrthographicCamera) {
        const d = new q(this._mouse.x, this._mouse.y, 0);
        d.unproject(this.object);
        const m = this.object.zoom;
        this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), c = m !== this.object.zoom;
        const p = new q(this._mouse.x, this._mouse.y, 0);
        p.unproject(this.object), this.object.position.sub(p).add(d), this.object.updateMatrixWorld(), h = mn.length();
      } else
        console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
      h !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(h).add(this.object.position) : ($c.origin.copy(this.object.position), $c.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot($c.direction)) < cR ? this.object.lookAt(this.target) : (Nv.setFromNormalAndCoplanarPoint(this.object.up, this.target), $c.intersectPlane(Nv, this.target))));
    } else if (this.object.isOrthographicCamera) {
      const h = this.object.zoom;
      this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), h !== this.object.zoom && (this.object.updateProjectionMatrix(), c = !0);
    }
    return this._scale = 1, this._performCursorZoom = !1, c || this._lastPosition.distanceToSquared(this.object.position) > _d || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > _d || this._lastTargetPosition.distanceToSquared(this.target) > _d ? (this.dispatchEvent(Lv), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
  }
  _getAutoRotationAngle(t) {
    return t !== null ? $n / 60 * this.autoRotateSpeed * t : $n / 60 / 60 * this.autoRotateSpeed;
  }
  _getZoomScale(t) {
    const i = Math.abs(t * 0.01);
    return Math.pow(0.95, this.zoomSpeed * i);
  }
  _rotateLeft(t) {
    this._sphericalDelta.theta -= t;
  }
  _rotateUp(t) {
    this._sphericalDelta.phi -= t;
  }
  _panLeft(t, i) {
    mn.setFromMatrixColumn(i, 0), mn.multiplyScalar(-t), this._panOffset.add(mn);
  }
  _panUp(t, i) {
    this.screenSpacePanning === !0 ? mn.setFromMatrixColumn(i, 1) : (mn.setFromMatrixColumn(i, 0), mn.crossVectors(this.object.up, mn)), mn.multiplyScalar(t), this._panOffset.add(mn);
  }
  // deltaX and deltaY are in pixels; right and down are positive
  _pan(t, i) {
    const s = this.domElement;
    if (this.object.isPerspectiveCamera) {
      const l = this.object.position;
      mn.copy(l).sub(this.target);
      let c = mn.length();
      c *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * c / s.clientHeight, this.object.matrix), this._panUp(2 * i * c / s.clientHeight, this.object.matrix);
    } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / s.clientWidth, this.object.matrix), this._panUp(i * (this.object.top - this.object.bottom) / this.object.zoom / s.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
  }
  _dollyOut(t) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _dollyIn(t) {
    this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
  }
  _updateZoomParameters(t, i) {
    if (!this.zoomToCursor)
      return;
    this._performCursorZoom = !0;
    const s = this.domElement.getBoundingClientRect(), l = t - s.left, c = i - s.top, h = s.width, d = s.height;
    this._mouse.x = l / h * 2 - 1, this._mouse.y = -(c / d) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
  }
  _clampDistance(t) {
    return Math.max(this.minDistance, Math.min(this.maxDistance, t));
  }
  //
  // event callbacks - update the object state
  //
  _handleMouseDownRotate(t) {
    this._rotateStart.set(t.clientX, t.clientY);
  }
  _handleMouseDownDolly(t) {
    this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
  }
  _handleMouseDownPan(t) {
    this._panStart.set(t.clientX, t.clientY);
  }
  _handleMouseMoveRotate(t) {
    this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const i = this.domElement;
    this._rotateLeft($n * this._rotateDelta.x / i.clientHeight), this._rotateUp($n * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
  }
  _handleMouseMoveDolly(t) {
    this._dollyEnd.set(t.clientX, t.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
  }
  _handleMouseMovePan(t) {
    this._panEnd.set(t.clientX, t.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
  }
  _handleMouseWheel(t) {
    this._updateZoomParameters(t.clientX, t.clientY), t.deltaY < 0 ? this._dollyIn(this._getZoomScale(t.deltaY)) : t.deltaY > 0 && this._dollyOut(this._getZoomScale(t.deltaY)), this.update();
  }
  _handleKeyDown(t) {
    let i = !1;
    switch (t.code) {
      case this.keys.UP:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp($n * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), i = !0;
        break;
      case this.keys.BOTTOM:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-$n * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), i = !0;
        break;
      case this.keys.LEFT:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft($n * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), i = !0;
        break;
      case this.keys.RIGHT:
        t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-$n * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), i = !0;
        break;
    }
    i && (t.preventDefault(), this.update());
  }
  _handleTouchStartRotate(t) {
    if (this._pointers.length === 1)
      this._rotateStart.set(t.pageX, t.pageY);
    else {
      const i = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + i.x), l = 0.5 * (t.pageY + i.y);
      this._rotateStart.set(s, l);
    }
  }
  _handleTouchStartPan(t) {
    if (this._pointers.length === 1)
      this._panStart.set(t.pageX, t.pageY);
    else {
      const i = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + i.x), l = 0.5 * (t.pageY + i.y);
      this._panStart.set(s, l);
    }
  }
  _handleTouchStartDolly(t) {
    const i = this._getSecondPointerPosition(t), s = t.pageX - i.x, l = t.pageY - i.y, c = Math.sqrt(s * s + l * l);
    this._dollyStart.set(0, c);
  }
  _handleTouchStartDollyPan(t) {
    this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
  }
  _handleTouchStartDollyRotate(t) {
    this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
  }
  _handleTouchMoveRotate(t) {
    if (this._pointers.length == 1)
      this._rotateEnd.set(t.pageX, t.pageY);
    else {
      const s = this._getSecondPointerPosition(t), l = 0.5 * (t.pageX + s.x), c = 0.5 * (t.pageY + s.y);
      this._rotateEnd.set(l, c);
    }
    this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
    const i = this.domElement;
    this._rotateLeft($n * this._rotateDelta.x / i.clientHeight), this._rotateUp($n * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd);
  }
  _handleTouchMovePan(t) {
    if (this._pointers.length === 1)
      this._panEnd.set(t.pageX, t.pageY);
    else {
      const i = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + i.x), l = 0.5 * (t.pageY + i.y);
      this._panEnd.set(s, l);
    }
    this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
  }
  _handleTouchMoveDolly(t) {
    const i = this._getSecondPointerPosition(t), s = t.pageX - i.x, l = t.pageY - i.y, c = Math.sqrt(s * s + l * l);
    this._dollyEnd.set(0, c), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
    const h = (t.pageX + i.x) * 0.5, d = (t.pageY + i.y) * 0.5;
    this._updateZoomParameters(h, d);
  }
  _handleTouchMoveDollyPan(t) {
    this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
  }
  _handleTouchMoveDollyRotate(t) {
    this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
  }
  // pointers
  _addPointer(t) {
    this._pointers.push(t.pointerId);
  }
  _removePointer(t) {
    delete this._pointerPositions[t.pointerId];
    for (let i = 0; i < this._pointers.length; i++)
      if (this._pointers[i] == t.pointerId) {
        this._pointers.splice(i, 1);
        return;
      }
  }
  _isTrackingPointer(t) {
    for (let i = 0; i < this._pointers.length; i++)
      if (this._pointers[i] == t.pointerId) return !0;
    return !1;
  }
  _trackPointer(t) {
    let i = this._pointerPositions[t.pointerId];
    i === void 0 && (i = new $t(), this._pointerPositions[t.pointerId] = i), i.set(t.pageX, t.pageY);
  }
  _getSecondPointerPosition(t) {
    const i = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
    return this._pointerPositions[i];
  }
  //
  _customWheelEvent(t) {
    const i = t.deltaMode, s = {
      clientX: t.clientX,
      clientY: t.clientY,
      deltaY: t.deltaY
    };
    switch (i) {
      case 1:
        s.deltaY *= 16;
        break;
      case 2:
        s.deltaY *= 100;
        break;
    }
    return t.ctrlKey && !this._controlActive && (s.deltaY *= 10), s;
  }
}
function uR(r) {
  this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(r.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(r) && (this._addPointer(r), r.pointerType === "touch" ? this._onTouchStart(r) : this._onMouseDown(r)));
}
function fR(r) {
  this.enabled !== !1 && (r.pointerType === "touch" ? this._onTouchMove(r) : this._onMouseMove(r));
}
function hR(r) {
  switch (this._removePointer(r), this._pointers.length) {
    case 0:
      this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(Lx), this.state = ke.NONE;
      break;
    case 1:
      const t = this._pointers[0], i = this._pointerPositions[t];
      this._onTouchStart({ pointerId: t, pageX: i.x, pageY: i.y });
      break;
  }
}
function dR(r) {
  let t;
  switch (r.button) {
    case 0:
      t = this.mouseButtons.LEFT;
      break;
    case 1:
      t = this.mouseButtons.MIDDLE;
      break;
    case 2:
      t = this.mouseButtons.RIGHT;
      break;
    default:
      t = -1;
  }
  switch (t) {
    case Xr.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseDownDolly(r), this.state = ke.DOLLY;
      break;
    case Xr.ROTATE:
      if (r.ctrlKey || r.metaKey || r.shiftKey) {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(r), this.state = ke.PAN;
      } else {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(r), this.state = ke.ROTATE;
      }
      break;
    case Xr.PAN:
      if (r.ctrlKey || r.metaKey || r.shiftKey) {
        if (this.enableRotate === !1) return;
        this._handleMouseDownRotate(r), this.state = ke.ROTATE;
      } else {
        if (this.enablePan === !1) return;
        this._handleMouseDownPan(r), this.state = ke.PAN;
      }
      break;
    default:
      this.state = ke.NONE;
  }
  this.state !== ke.NONE && this.dispatchEvent(Lp);
}
function pR(r) {
  switch (this.state) {
    case ke.ROTATE:
      if (this.enableRotate === !1) return;
      this._handleMouseMoveRotate(r);
      break;
    case ke.DOLLY:
      if (this.enableZoom === !1) return;
      this._handleMouseMoveDolly(r);
      break;
    case ke.PAN:
      if (this.enablePan === !1) return;
      this._handleMouseMovePan(r);
      break;
  }
}
function mR(r) {
  this.enabled === !1 || this.enableZoom === !1 || this.state !== ke.NONE || (r.preventDefault(), this.dispatchEvent(Lp), this._handleMouseWheel(this._customWheelEvent(r)), this.dispatchEvent(Lx));
}
function gR(r) {
  this.enabled !== !1 && this._handleKeyDown(r);
}
function _R(r) {
  switch (this._trackPointer(r), this._pointers.length) {
    case 1:
      switch (this.touches.ONE) {
        case Vr.ROTATE:
          if (this.enableRotate === !1) return;
          this._handleTouchStartRotate(r), this.state = ke.TOUCH_ROTATE;
          break;
        case Vr.PAN:
          if (this.enablePan === !1) return;
          this._handleTouchStartPan(r), this.state = ke.TOUCH_PAN;
          break;
        default:
          this.state = ke.NONE;
      }
      break;
    case 2:
      switch (this.touches.TWO) {
        case Vr.DOLLY_PAN:
          if (this.enableZoom === !1 && this.enablePan === !1) return;
          this._handleTouchStartDollyPan(r), this.state = ke.TOUCH_DOLLY_PAN;
          break;
        case Vr.DOLLY_ROTATE:
          if (this.enableZoom === !1 && this.enableRotate === !1) return;
          this._handleTouchStartDollyRotate(r), this.state = ke.TOUCH_DOLLY_ROTATE;
          break;
        default:
          this.state = ke.NONE;
      }
      break;
    default:
      this.state = ke.NONE;
  }
  this.state !== ke.NONE && this.dispatchEvent(Lp);
}
function vR(r) {
  switch (this._trackPointer(r), this.state) {
    case ke.TOUCH_ROTATE:
      if (this.enableRotate === !1) return;
      this._handleTouchMoveRotate(r), this.update();
      break;
    case ke.TOUCH_PAN:
      if (this.enablePan === !1) return;
      this._handleTouchMovePan(r), this.update();
      break;
    case ke.TOUCH_DOLLY_PAN:
      if (this.enableZoom === !1 && this.enablePan === !1) return;
      this._handleTouchMoveDollyPan(r), this.update();
      break;
    case ke.TOUCH_DOLLY_ROTATE:
      if (this.enableZoom === !1 && this.enableRotate === !1) return;
      this._handleTouchMoveDollyRotate(r), this.update();
      break;
    default:
      this.state = ke.NONE;
  }
}
function xR(r) {
  this.enabled !== !1 && r.preventDefault();
}
function yR(r) {
  r.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
function SR(r) {
  r.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
const MR = {
  1: [1, 1, 1],
  // H  - white
  2: [0.851, 1, 1],
  // He - light cyan
  5: [1, 0.71, 0.71],
  // B  - pink
  6: [0.565, 0.565, 0.565],
  // C  - gray
  7: [0.188, 0.314, 0.973],
  // N  - blue
  8: [1, 0.051, 0.051],
  // O  - red
  9: [0.565, 0.878, 0.314],
  // F  - green
  11: [0.671, 0.361, 0.949],
  // Na - purple
  12: [0.541, 1, 0],
  // Mg - green
  13: [0.749, 0.651, 0.651],
  // Al - gray-pink
  14: [0.941, 0.784, 0.627],
  // Si - tan
  15: [1, 0.502, 0],
  // P  - orange
  16: [1, 1, 0.188],
  // S  - yellow
  17: [0.122, 0.941, 0.122],
  // Cl - green
  18: [0.502, 0.82, 0.89],
  // Ar - light blue
  19: [0.561, 0.251, 0.831],
  // K  - purple
  20: [0.239, 1, 0],
  // Ca - green
  26: [0.878, 0.4, 0.2],
  // Fe - orange
  29: [0.784, 0.502, 0.2],
  // Cu - copper
  30: [0.49, 0.502, 0.69],
  // Zn - slate
  34: [1, 0.631, 0],
  // Se - orange
  35: [0.651, 0.161, 0.161],
  // Br - dark red
  53: [0.58, 0, 0.58]
  // I  - purple
}, ER = [0.75, 0.4, 0.75], fp = {
  1: 1.2,
  6: 1.7,
  7: 1.55,
  8: 1.52,
  9: 1.47,
  11: 2.27,
  12: 1.73,
  15: 1.8,
  16: 1.8,
  17: 1.75,
  19: 2.75,
  20: 2.31,
  26: 2.04,
  29: 1.4,
  30: 1.39
}, hp = 1.5, dp = 0.3, bR = 0.15, Pv = 1, zv = 2, Bv = 3, Iv = 4, Fv = 0.18, TR = 0.1, Hv = 0.2, AR = 0.08, RR = 0.1, CR = 0.06, wR = {
  1: "H",
  6: "C",
  7: "N",
  8: "O",
  9: "F",
  11: "Na",
  12: "Mg",
  15: "P",
  16: "S",
  17: "Cl",
  19: "K",
  20: "Ca",
  26: "Fe",
  29: "Cu",
  30: "Zn"
}, DR = {
  1: "Single",
  2: "Double",
  3: "Triple",
  4: "Aromatic"
};
function _u(r) {
  return MR[r] ?? ER;
}
function pp(r) {
  return fp[r] ?? hp;
}
function Np(r) {
  return wR[r] ?? `#${r}`;
}
const UR = (
  /* glsl */
  `precision highp float;

  // Three.js built-in uniforms (must declare explicitly for RawShaderMaterial)
  uniform mat4 modelViewMatrix;
  uniform mat4 projectionMatrix;
  uniform float uScaleMultiplier;

  // Per-vertex (quad corners)
  in vec3 position;

  // Per-instance
  in vec3 instanceCenter;
  in float instanceRadius;
  in vec3 instanceColor;

  out vec3 vColor;
  out vec2 vUv;
  out float vRadius;
  out vec3 vViewCenter;

  void main() {
    vColor = instanceColor;
    vUv = position.xy;
    float scaledRadius = instanceRadius * uScaleMultiplier;
    vRadius = scaledRadius;

    vec4 viewCenter = modelViewMatrix * vec4(instanceCenter, 1.0);
    vViewCenter = viewCenter.xyz;

    vec3 viewPos = viewCenter.xyz;
    viewPos.xy += position.xy * scaledRadius;

    gl_Position = projectionMatrix * vec4(viewPos, 1.0);
  }
`
), LR = (
  /* glsl */
  `precision highp float;

  in vec3 vColor;
  in vec2 vUv;
  in float vRadius;
  in vec3 vViewCenter;

  uniform mat4 projectionMatrix;
  uniform float uOpacity;

  out vec4 fragColor;

  void main() {
    float dist2 = dot(vUv, vUv);
    if (dist2 > 1.0) discard;

    float z = sqrt(1.0 - dist2);
    vec3 normal = vec3(vUv, z);

    // Correct depth
    vec3 fragViewPos = vViewCenter + normal * vRadius;
    vec4 clipPos = projectionMatrix * vec4(fragViewPos, 1.0);
    float ndcDepth = clipPos.z / clipPos.w;
    gl_FragDepth = ndcDepth * 0.5 + 0.5;

    // Hemisphere ambient: sky blue on top, warm brown on bottom
    vec3 skyColor = vec3(0.87, 0.92, 1.0);
    vec3 groundColor = vec3(0.6, 0.47, 0.27);
    float hemiMix = normal.y * 0.5 + 0.5;
    vec3 ambient = mix(groundColor, skyColor, hemiMix) * 0.35;

    // Dual-light diffuse
    vec3 lightDir1 = normalize(vec3(0.5, 0.5, 1.0));
    vec3 lightDir2 = normalize(vec3(-0.3, 0.3, 0.8));
    float diffuse1 = max(dot(normal, lightDir1), 0.0);
    float diffuse2 = max(dot(normal, lightDir2), 0.0);
    float diffuse = diffuse1 * 0.55 + diffuse2 * 0.2;

    // Specular (Blinn-Phong)
    vec3 viewDir = vec3(0.0, 0.0, 1.0);
    vec3 halfDir = normalize(lightDir1 + viewDir);
    float spec = pow(max(dot(normal, halfDir), 0.0), 64.0);

    // Fresnel rim
    float fresnel = pow(1.0 - z, 3.0) * 0.15;

    // Edge darkening (stronger for Speck-like depth)
    float edgeFactor = mix(0.7, 1.0, z);

    vec3 color = vColor * (ambient + diffuse) * edgeFactor
               + vec3(1.0) * spec * 0.3
               + vec3(0.15) * fresnel;
    fragColor = vec4(color, uOpacity);
  }
`
), NR = (
  /* glsl */
  `precision highp float;

  uniform mat4 modelViewMatrix;
  uniform mat4 projectionMatrix;
  uniform float uBondScaleMultiplier;
  uniform sampler2D uPositionTex;
  uniform int uPositionTexWidth;

  in vec3 position;
  in vec2 uv;

  in float instanceAtomA;
  in float instanceAtomB;
  in float instanceOffsetX;
  in float instanceOffsetY;
  in vec3 instanceColor;
  in float instanceRadius;
  in float instanceDashed;

  out vec3 vColor;
  out vec2 vCylUv;
  out float vDashed;

  vec3 getAtomPos(int idx) {
    int tx = idx % uPositionTexWidth;
    int ty = idx / uPositionTexWidth;
    return texelFetch(uPositionTex, ivec2(tx, ty), 0).rgb;
  }

  void main() {
    vColor = instanceColor;
    vCylUv = uv;
    vDashed = instanceDashed;

    int atomA = int(instanceAtomA + 0.5);
    int atomB = int(instanceAtomB + 0.5);
    vec3 posA = getAtomPos(atomA);
    vec3 posB = getAtomPos(atomB);

    vec3 start = posA;
    vec3 end = posB;

    // Apply perpendicular offset for double/triple/aromatic bonds
    if (instanceOffsetX != 0.0 || instanceOffsetY != 0.0) {
      vec3 bdir = normalize(posB - posA);
      vec3 perpX = cross(bdir, vec3(0.0, 1.0, 0.0));
      if (dot(perpX, perpX) < 0.001) {
        perpX = cross(bdir, vec3(1.0, 0.0, 0.0));
      }
      perpX = normalize(perpX);
      vec3 perpY = normalize(cross(bdir, perpX));
      vec3 offset = perpX * instanceOffsetX + perpY * instanceOffsetY;
      start += offset;
      end += offset;
    }

    vec4 viewStart = modelViewMatrix * vec4(start, 1.0);
    vec4 viewEnd = modelViewMatrix * vec4(end, 1.0);

    vec3 viewMid = (viewStart.xyz + viewEnd.xyz) * 0.5;
    vec3 axis = viewEnd.xyz - viewStart.xyz;
    float len = length(axis);
    vec3 dir = axis / max(len, 0.0001);

    vec3 side = normalize(cross(dir, vec3(0.0, 0.0, 1.0)));

    vec3 viewPos = viewMid
      + dir * (position.y * len * 0.5)
      + side * (position.x * instanceRadius * uBondScaleMultiplier);

    gl_Position = projectionMatrix * vec4(viewPos, 1.0);
  }
`
), OR = (
  /* glsl */
  `precision highp float;

  in vec3 vColor;
  in vec2 vCylUv;
  in float vDashed;

  uniform float uOpacity;

  out vec4 fragColor;

  void main() {
    // Dashed bond: discard alternate segments along bond length
    if (vDashed > 0.5) {
      if (sin(vCylUv.y * 30.0) < 0.0) discard;
    }

    float nx = vCylUv.x;
    float nz = sqrt(max(0.0, 1.0 - nx * nx));
    vec3 normal = vec3(nx, 0.0, nz);

    // Hemisphere ambient
    vec3 skyColor = vec3(0.87, 0.92, 1.0);
    vec3 groundColor = vec3(0.6, 0.47, 0.27);
    float hemiMix = normal.y * 0.5 + 0.5;
    vec3 ambient = mix(groundColor, skyColor, hemiMix) * 0.35;

    // Dual-light diffuse
    vec3 lightDir1 = normalize(vec3(0.5, 0.5, 1.0));
    vec3 lightDir2 = normalize(vec3(-0.3, 0.3, 0.8));
    float diffuse1 = max(dot(normal, lightDir1), 0.0);
    float diffuse2 = max(dot(normal, lightDir2), 0.0);
    float diffuse = diffuse1 * 0.55 + diffuse2 * 0.2;

    // Specular
    vec3 viewDir = vec3(0.0, 0.0, 1.0);
    vec3 halfDir = normalize(lightDir1 + viewDir);
    float spec = pow(max(dot(normal, halfDir), 0.0), 64.0);

    // Fresnel rim
    float fresnel = pow(1.0 - nz, 3.0) * 0.1;

    vec3 color = vColor * (ambient + diffuse)
               + vec3(1.0) * spec * 0.2
               + vec3(0.1) * fresnel;
    fragColor = vec4(color, uOpacity);
  }
`
);
class PR {
  constructor(t = 1e6) {
    Rt(this, "mesh");
    Rt(this, "geo");
    Rt(this, "material");
    Rt(this, "centerAttr");
    Rt(this, "radiusAttr");
    Rt(this, "colorAttr");
    Rt(this, "centerBuf");
    Rt(this, "radiusBuf");
    Rt(this, "colorBuf");
    Rt(this, "nAtoms", 0);
    Rt(this, "capacity");
    this.capacity = t, this.geo = new Ax();
    const i = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), s = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new Mn(i, 3)), this.geo.setIndex(new Mn(s, 1)), this.geo.instanceCount = 0, this.centerBuf = new Float32Array(t * 3), this.radiusBuf = new Float32Array(t), this.colorBuf = new Float32Array(t * 3), this.centerAttr = new kn(this.centerBuf, 3), this.radiusAttr = new kn(this.radiusBuf, 1), this.colorAttr = new kn(this.colorBuf, 3), this.centerAttr.setUsage(w0), this.radiusAttr.setUsage(Ns), this.colorAttr.setUsage(Ns), this.geo.setAttribute("instanceCenter", this.centerAttr), this.geo.setAttribute("instanceRadius", this.radiusAttr), this.geo.setAttribute("instanceColor", this.colorAttr), this.material = new Tx({
      glslVersion: fu,
      vertexShader: UR,
      fragmentShader: LR,
      uniforms: {
        uScaleMultiplier: { value: 1 },
        uOpacity: { value: 1 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Un(this.geo, this.material), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: i, positions: s, elements: l } = t;
    this.nAtoms = i, i > this.capacity && this.grow(i);
    for (let c = 0; c < i; c++) {
      const h = c * 3;
      this.centerBuf[h] = s[h], this.centerBuf[h + 1] = s[h + 1], this.centerBuf[h + 2] = s[h + 2], this.radiusBuf[c] = pp(l[c]) * dp;
      const [d, m, p] = _u(l[c]);
      this.colorBuf[h] = d, this.colorBuf[h + 1] = m, this.colorBuf[h + 2] = p;
    }
    this.centerAttr.needsUpdate = !0, this.radiusAttr.needsUpdate = !0, this.colorAttr.needsUpdate = !0, this.geo.instanceCount = i;
  }
  updatePositions(t) {
    this.centerBuf.set(t.subarray(0, this.nAtoms * 3)), this.centerAttr.needsUpdate = !0;
  }
  /** Update atom radius scale (O(1) via shader uniform). */
  setScale(t, i) {
    this.material.uniforms.uScaleMultiplier.value = t;
  }
  /** Set global atom opacity. */
  setOpacity(t) {
    this.material.uniforms.uOpacity.value = t, this.material.transparent = t < 1, this.material.depthWrite = t >= 1, this.material.needsUpdate = !0;
  }
  grow(t) {
    this.capacity = Math.max(t, this.capacity * 2);
    const i = new Float32Array(this.capacity * 3), s = new Float32Array(this.capacity), l = new Float32Array(this.capacity * 3);
    i.set(this.centerBuf), s.set(this.radiusBuf), l.set(this.colorBuf), this.centerBuf = i, this.radiusBuf = s, this.colorBuf = l, this.centerAttr = new kn(this.centerBuf, 3), this.radiusAttr = new kn(this.radiusBuf, 1), this.colorAttr = new kn(this.colorBuf, 3), this.centerAttr.setUsage(w0), this.radiusAttr.setUsage(Ns), this.colorAttr.setUsage(Ns), this.geo.setAttribute("instanceCenter", this.centerAttr), this.geo.setAttribute("instanceRadius", this.radiusAttr), this.geo.setAttribute("instanceColor", this.colorAttr);
  }
  dispose() {
    this.geo.dispose(), this.material.dispose();
  }
}
const zR = 4096;
class BR {
  constructor(t = 3e6) {
    Rt(this, "mesh");
    Rt(this, "geo");
    Rt(this, "bondMaterial");
    // Topology buffers (set at loadSnapshot, static per snapshot)
    Rt(this, "atomABuf");
    Rt(this, "atomBBuf");
    Rt(this, "offsetXBuf");
    Rt(this, "offsetYBuf");
    Rt(this, "colorBuf");
    Rt(this, "radiusBuf");
    Rt(this, "dashedBuf");
    // Position DataTexture (updated per frame)
    Rt(this, "positionTex");
    Rt(this, "positionTexData");
    Rt(this, "positionTexWidth", 1);
    Rt(this, "positionTexHeight", 1);
    Rt(this, "nAtoms", 0);
    Rt(this, "capacity");
    this.capacity = t, this.geo = new Ax();
    const i = new Float32Array([
      -1,
      -1,
      0,
      1,
      -1,
      0,
      1,
      1,
      0,
      -1,
      1,
      0
    ]), s = new Float32Array([
      -1,
      -1,
      1,
      -1,
      1,
      1,
      -1,
      1
    ]), l = new Uint16Array([0, 1, 2, 0, 2, 3]);
    this.geo.setAttribute("position", new Mn(i, 3)), this.geo.setAttribute("uv", new Mn(s, 2)), this.geo.setIndex(new Mn(l, 1)), this.geo.instanceCount = 0, this.atomABuf = new Float32Array(t), this.atomBBuf = new Float32Array(t), this.offsetXBuf = new Float32Array(t), this.offsetYBuf = new Float32Array(t), this.colorBuf = new Float32Array(t * 3), this.radiusBuf = new Float32Array(t), this.dashedBuf = new Float32Array(t), this.positionTexData = new Float32Array(4), this.positionTex = new cp(
      this.positionTexData,
      1,
      1,
      fi,
      Ei
    ), this.positionTex.minFilter = Dn, this.positionTex.magFilter = Dn, this.positionTex.generateMipmaps = !1, this.positionTex.needsUpdate = !0, this.registerAttributes(), this.bondMaterial = new Tx({
      glslVersion: fu,
      vertexShader: NR,
      fragmentShader: OR,
      uniforms: {
        uOpacity: { value: 1 },
        uBondScaleMultiplier: { value: 1 },
        uPositionTex: { value: this.positionTex },
        uPositionTexWidth: { value: 1 }
      },
      depthWrite: !0,
      depthTest: !0
    }), this.mesh = new Un(this.geo, this.bondMaterial), this.mesh.frustumCulled = !1;
  }
  loadSnapshot(t) {
    const { nAtoms: i, nBonds: s, positions: l, elements: c, bonds: h, bondOrders: d } = t;
    this.nAtoms = i, this.positionTexWidth = Math.min(i, zR), this.positionTexHeight = Math.max(1, Math.ceil(i / this.positionTexWidth)), this.positionTexData = new Float32Array(this.positionTexWidth * this.positionTexHeight * 4), this.copyPositionsToTexData(l), this.positionTex.dispose(), this.positionTex = new cp(
      this.positionTexData,
      this.positionTexWidth,
      this.positionTexHeight,
      fi,
      Ei
    ), this.positionTex.minFilter = Dn, this.positionTex.magFilter = Dn, this.positionTex.generateMipmaps = !1, this.positionTex.needsUpdate = !0, this.bondMaterial.uniforms.uPositionTex.value = this.positionTex, this.bondMaterial.uniforms.uPositionTexWidth.value = this.positionTexWidth;
    let m = 0;
    for (let g = 0; g < s; g++) {
      const _ = d ? d[g] : Pv;
      _ === zv ? m += 2 : _ === Bv ? m += 3 : _ === Iv ? m += 2 : m += 1;
    }
    m > this.capacity && this.grow(m);
    let p = 0;
    for (let g = 0; g < s; g++) {
      const _ = h[g * 2], x = h[g * 2 + 1], S = d ? d[g] : Pv, [E, b, M] = _u(c[_]), [v, B, U] = _u(c[x]), w = (E + v) * 0.5, F = (b + B) * 0.5, L = (M + U) * 0.5;
      if (S === zv)
        for (const O of [-1, 1])
          this.setTopology(
            p,
            _,
            x,
            O * Fv,
            0,
            TR,
            w,
            F,
            L,
            0
          ), p++;
      else if (S === Bv) {
        const O = [0, 2 * Math.PI / 3, 4 * Math.PI / 3];
        for (const G of O) {
          const C = Math.cos(G) * Hv, T = Math.sin(G) * Hv;
          this.setTopology(
            p,
            _,
            x,
            C,
            T,
            AR,
            w,
            F,
            L,
            0
          ), p++;
        }
      } else S === Iv ? (this.setTopology(
        p,
        _,
        x,
        0,
        0,
        RR,
        w,
        F,
        L,
        0
      ), p++, this.setTopology(
        p,
        _,
        x,
        Fv,
        0,
        CR,
        w,
        F,
        L,
        1
      ), p++) : (this.setTopology(
        p,
        _,
        x,
        0,
        0,
        bR,
        w,
        F,
        L,
        0
      ), p++);
    }
    this.registerAttributes(), this.geo.instanceCount = p;
  }
  updatePositions(t, i, s) {
    this.copyPositionsToTexData(t), this.positionTex.needsUpdate = !0;
  }
  setTopology(t, i, s, l, c, h, d, m, p, g) {
    this.atomABuf[t] = i, this.atomBBuf[t] = s, this.offsetXBuf[t] = l, this.offsetYBuf[t] = c;
    const _ = t * 3;
    this.colorBuf[_] = d, this.colorBuf[_ + 1] = m, this.colorBuf[_ + 2] = p, this.radiusBuf[t] = h, this.dashedBuf[t] = g;
  }
  copyPositionsToTexData(t) {
    const i = this.positionTexData, s = this.nAtoms;
    for (let l = 0; l < s; l++) {
      const c = l * 3, h = l * 4;
      i[h] = t[c], i[h + 1] = t[c + 1], i[h + 2] = t[c + 2];
    }
  }
  /** Recreate all instance attributes and re-register with geometry. */
  registerAttributes() {
    const t = new kn(this.atomABuf, 1), i = new kn(this.atomBBuf, 1), s = new kn(this.offsetXBuf, 1), l = new kn(this.offsetYBuf, 1), c = new kn(this.colorBuf, 3), h = new kn(this.radiusBuf, 1), d = new kn(this.dashedBuf, 1);
    this.geo.setAttribute("instanceAtomA", t), this.geo.setAttribute("instanceAtomB", i), this.geo.setAttribute("instanceOffsetX", s), this.geo.setAttribute("instanceOffsetY", l), this.geo.setAttribute("instanceColor", c), this.geo.setAttribute("instanceRadius", h), this.geo.setAttribute("instanceDashed", d);
  }
  grow(t) {
    this.capacity = Math.max(t, this.capacity * 2);
    const i = new Float32Array(this.capacity), s = new Float32Array(this.capacity), l = new Float32Array(this.capacity), c = new Float32Array(this.capacity), h = new Float32Array(this.capacity * 3), d = new Float32Array(this.capacity), m = new Float32Array(this.capacity);
    i.set(this.atomABuf), s.set(this.atomBBuf), l.set(this.offsetXBuf), c.set(this.offsetYBuf), h.set(this.colorBuf), d.set(this.radiusBuf), m.set(this.dashedBuf), this.atomABuf = i, this.atomBBuf = s, this.offsetXBuf = l, this.offsetYBuf = c, this.colorBuf = h, this.radiusBuf = d, this.dashedBuf = m, this.registerAttributes();
  }
  /** Set global bond opacity. */
  setOpacity(t) {
    this.bondMaterial.uniforms.uOpacity.value = t, this.bondMaterial.transparent = t < 1, this.bondMaterial.depthWrite = t >= 1, this.bondMaterial.needsUpdate = !0;
  }
  /** Set bond radius scale multiplier (O(1) via shader uniform). */
  setScale(t, i) {
    this.bondMaterial.uniforms.uBondScaleMultiplier.value = t;
  }
  dispose() {
    this.geo.dispose(), this.bondMaterial.dispose(), this.positionTex.dispose();
  }
}
class IR {
  constructor() {
    Rt(this, "mesh");
    Rt(this, "geometry");
    this.geometry = new Xn();
    const t = new Float32Array(72);
    this.geometry.setAttribute(
      "position",
      new Mn(t, 3)
    );
    const i = new Su({
      color: 6710886,
      transparent: !0,
      opacity: 0.5
    });
    this.mesh = new mE(this.geometry, i), this.mesh.frustumCulled = !1, this.mesh.visible = !1;
  }
  /**
   * Update the cell box from a 3x3 matrix (row-major Float32Array of length 9).
   * Cell vectors: va = box[0..2], vb = box[3..5], vc = box[6..8].
   */
  loadBox(t) {
    const i = new q(t[0], t[1], t[2]), s = new q(t[3], t[4], t[5]), l = new q(t[6], t[7], t[8]), c = new q(0, 0, 0), h = i.clone(), d = s.clone(), m = l.clone(), p = i.clone().add(s), g = i.clone().add(l), _ = s.clone().add(l), x = i.clone().add(s).add(l), S = [
      // Bottom face
      [c, h],
      [c, d],
      [h, p],
      [d, p],
      // Top face
      [m, g],
      [m, _],
      [g, x],
      [_, x],
      // Vertical edges
      [c, m],
      [h, g],
      [d, _],
      [p, x]
    ], E = this.geometry.getAttribute(
      "position"
    ), b = E.array;
    for (let M = 0; M < 12; M++) {
      const [v, B] = S[M];
      b[M * 6] = v.x, b[M * 6 + 1] = v.y, b[M * 6 + 2] = v.z, b[M * 6 + 3] = B.x, b[M * 6 + 4] = B.y, b[M * 6 + 5] = B.z;
    }
    E.needsUpdate = !0, this.geometry.computeBoundingSphere(), this.mesh.visible = !0;
  }
  setVisible(t) {
    this.mesh.visible = t;
  }
  dispose() {
    this.geometry.dispose(), this.mesh.material.dispose();
  }
}
const Gv = 8, Vv = [14496563, 3385907, 3368669], vd = 1e-4;
class FR {
  constructor() {
    Rt(this, "axesScene");
    Rt(this, "axesCamera");
    Rt(this, "arrowGroup");
    Rt(this, "visible", !0);
    /** Inset position in CSS pixels (bottom-left corner of the inset). */
    Rt(this, "posX", Gv);
    Rt(this, "posY", Gv);
    /** Last computed inset size (CSS pixels), cached for hit-testing. */
    Rt(this, "lastInsetSize", 60);
    this.axesScene = new Mx(), this.axesCamera = new ui(50, 1, 0.1, 100), this.axesCamera.position.set(0, 0, 3);
    const t = new ME(16777215, 0.6);
    this.axesScene.add(t);
    const i = new lu(16777215, 0.8);
    i.position.set(2, 2, 2), this.axesScene.add(i), this.arrowGroup = new Os(), this.axesScene.add(this.arrowGroup);
  }
  /**
   * Update from the 3x3 cell matrix (row-major Float32Array of length 9).
   */
  loadBox(t) {
    const i = new q(t[0], t[1], t[2]), s = new q(t[3], t[4], t[5]), l = new q(t[6], t[7], t[8]), c = i.length(), h = s.length(), d = l.length(), p = Math.abs(i.dot(s)) < vd * c * h && Math.abs(i.dot(l)) < vd * c * d && Math.abs(s.dot(l)) < vd * h * d ? ["x", "y", "z"] : ["a", "b", "c"], g = [i.normalize(), s.normalize(), l.normalize()];
    this.buildArrows(g, p);
  }
  buildArrows(t, i) {
    for (; this.arrowGroup.children.length > 0; ) {
      const s = this.arrowGroup.children[0];
      this.arrowGroup.remove(s), this.disposeObject(s);
    }
    for (let s = 0; s < 3; s++) {
      const l = new bE(
        t[s],
        new q(0, 0, 0),
        1,
        Vv[s],
        0.25,
        0.1
      );
      this.arrowGroup.add(l);
      const c = this.makeTextSprite(i[s], Vv[s]);
      c.position.copy(t[s]).multiplyScalar(1.25), c.scale.set(0.3, 0.3, 1), this.arrowGroup.add(c);
    }
  }
  makeTextSprite(t, i) {
    const l = document.createElement("canvas");
    l.width = 64, l.height = 64;
    const c = l.getContext("2d");
    if (!c)
      return new sd(new lp({ transparent: !0 }));
    c.clearRect(0, 0, 64, 64);
    const h = new ve(i);
    c.fillStyle = `rgb(${h.r * 255 | 0},${h.g * 255 | 0},${h.b * 255 | 0})`, c.font = "bold 48px Arial, sans-serif", c.textAlign = "center", c.textBaseline = "middle", c.fillText(t, 64 / 2, 64 / 2);
    const d = new gE(l), m = new lp({
      map: d,
      depthTest: !1,
      transparent: !0
    });
    return new sd(m);
  }
  // ── Hit-testing & drag ──────────────────────────────────────
  /**
   * Test whether a CSS-pixel coordinate (origin = top-left of container)
   * lies inside the axes inset.
   */
  hitTest(t, i, s) {
    if (!this.visible || this.arrowGroup.children.length === 0) return !1;
    const l = s - i;
    return t >= this.posX && t <= this.posX + this.lastInsetSize && l >= this.posY && l <= this.posY + this.lastInsetSize;
  }
  /**
   * Move the inset by a delta (CSS pixels), clamped to container bounds.
   */
  moveBy(t, i, s, l) {
    this.posX += t, this.posY -= i, this.clampPosition(s, l);
  }
  clampPosition(t, i) {
    const s = this.lastInsetSize, l = 4;
    this.posX = Math.max(l, Math.min(t - s - l, this.posX)), this.posY = Math.max(l, Math.min(i - s - l, this.posY));
  }
  // ── Rendering ───────────────────────────────────────────────
  /**
   * Render the axes inset.
   * Must be called AFTER the main scene render.
   */
  render(t, i, s, l) {
    if (!this.visible || this.arrowGroup.children.length === 0) return;
    this.axesCamera.quaternion.copy(i.quaternion), this.axesCamera.position.set(0, 0, 3).applyQuaternion(i.quaternion);
    const c = Math.min(s, l), h = Math.max(60, Math.min(140, Math.round(c * 0.12)));
    this.lastInsetSize = h, this.clampPosition(s, l);
    const d = t.autoClear;
    t.autoClear = !1, t.setViewport(this.posX, this.posY, h, h), t.setScissor(this.posX, this.posY, h, h), t.setScissorTest(!0), t.clearDepth(), t.render(this.axesScene, this.axesCamera), t.autoClear = d, t.setViewport(0, 0, s, l), t.setScissorTest(!1);
  }
  setVisible(t) {
    this.visible = t;
  }
  isVisible() {
    return this.visible;
  }
  disposeObject(t) {
    t.traverse((i) => {
      var s, l, c;
      (i instanceof Un || i instanceof fl) && ((s = i.geometry) == null || s.dispose(), Array.isArray(i.material) ? i.material.forEach((h) => h.dispose()) : (l = i.material) == null || l.dispose()), i instanceof sd && ((c = i.material.map) == null || c.dispose(), i.material.dispose());
    });
  }
  dispose() {
    for (; this.arrowGroup.children.length > 0; ) {
      const t = this.arrowGroup.children[0];
      this.arrowGroup.remove(t), this.disposeObject(t);
    }
  }
}
const HR = 500, GR = "bold 11px sans-serif", kv = -8;
class VR {
  constructor() {
    Rt(this, "canvas");
    Rt(this, "ctx");
    Rt(this, "labels", null);
    Rt(this, "elements", null);
    Rt(this, "nAtoms", 0);
    Rt(this, "positions", null);
    Rt(this, "tmpVec", new q());
    Rt(this, "lastWidth", 0);
    Rt(this, "lastHeight", 0);
    Rt(this, "lastPixelRatio", 1);
    this.canvas = document.createElement("canvas"), this.canvas.style.position = "absolute", this.canvas.style.top = "0", this.canvas.style.left = "0", this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.pointerEvents = "none", this.ctx = this.canvas.getContext("2d");
  }
  getCanvas() {
    return this.canvas;
  }
  setLabels(t) {
    this.labels = t;
  }
  setAtomData(t, i) {
    this.elements = t, this.nAtoms = i;
  }
  setPositions(t) {
    this.positions = t;
  }
  resize(t, i, s) {
    this.lastWidth = t, this.lastHeight = i, this.lastPixelRatio = s, this.canvas.width = Math.round(t * s), this.canvas.height = Math.round(i * s), this.ctx.setTransform(s, 0, 0, s, 0, 0);
  }
  render(t, i, s, l = 1) {
    if ((this.lastWidth !== i || this.lastHeight !== s || this.lastPixelRatio !== l) && this.resize(i, s, l), this.ctx.clearRect(0, 0, i, s), !this.labels || !this.positions || !this.elements || this.nAtoms === 0)
      return;
    const c = i / 2, h = s / 2, d = [];
    for (let p = 0; p < this.nAtoms; p++) {
      if (!this.labels[p] || (this.tmpVec.set(
        this.positions[p * 3],
        this.positions[p * 3 + 1],
        this.positions[p * 3 + 2]
      ), this.tmpVec.project(t), this.tmpVec.z < -1 || this.tmpVec.z > 1)) continue;
      const _ = this.tmpVec.x * c + c, x = -(this.tmpVec.y * h) + h;
      _ < -50 || _ > i + 50 || x < -20 || x > s + 20 || d.push({ sx: _, sy: x, z: this.tmpVec.z, idx: p });
    }
    d.sort((p, g) => p.z - g.z);
    const m = Math.min(d.length, HR);
    this.ctx.font = GR, this.ctx.textAlign = "center", this.ctx.textBaseline = "bottom";
    for (let p = 0; p < m; p++) {
      const { sx: g, sy: _, idx: x } = d[p], S = this.labels[x], E = this.elements[x], [b, M, v] = _u(E), B = 0.299 * b + 0.587 * M + 0.114 * v, U = B > 0.5 ? "#000000" : "#ffffff", w = B > 0.5 ? "#ffffff" : "#000000";
      this.ctx.strokeStyle = w, this.ctx.lineWidth = 2.5, this.ctx.lineJoin = "round", this.ctx.strokeText(S, g, _ + kv), this.ctx.fillStyle = U, this.ctx.fillText(S, g, _ + kv);
    }
  }
  dispose() {
    this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
  }
}
const Xv = 15158332, Wv = 0.04, kR = 0.1, xd = 0.2, XR = 6, WR = 8, YR = 1e-6, ll = new q(), qR = new q(0, 1, 0), yd = new es(), tu = new q(), eu = new q(), Rs = new Xe();
class jR {
  constructor(t = 1e5) {
    Rt(this, "mesh");
    Rt(this, "shaftMesh");
    Rt(this, "headMesh");
    Rt(this, "nAtoms", 0);
    Rt(this, "positions", null);
    Rt(this, "vectors", null);
    Rt(this, "arrowScale", 1);
    Rt(this, "capacity");
    this.capacity = t, this.mesh = new Os(), this.mesh.visible = !1;
    const i = new pl(
      Wv,
      Wv,
      1,
      XR
    );
    i.translate(0, 0.5, 0);
    const s = new Cp(kR, xd, WR);
    s.translate(0, xd / 2, 0);
    const l = new nv({
      color: Xv,
      transparent: !0,
      opacity: 0.85
    }), c = new nv({
      color: Xv,
      transparent: !0,
      opacity: 0.85
    });
    this.shaftMesh = new Q0(i, l, t), this.headMesh = new Q0(s, c, t), this.shaftMesh.count = 0, this.headMesh.count = 0, this.mesh.add(this.shaftMesh), this.mesh.add(this.headMesh);
  }
  setAtomPositions(t, i) {
    this.positions = t, this.nAtoms = i, this.vectors && this.update();
  }
  setVectors(t) {
    this.vectors = t, t ? (this.mesh.visible = !0, this.update()) : (this.mesh.visible = !1, this.shaftMesh.count = 0, this.headMesh.count = 0);
  }
  setScale(t) {
    this.arrowScale = t, this.vectors && this.update();
  }
  update() {
    if (!this.positions || !this.vectors) return;
    const t = Math.min(this.nAtoms, this.capacity);
    this.shaftMesh.count = t, this.headMesh.count = t;
    for (let i = 0; i < t; i++) {
      const s = this.positions[i * 3], l = this.positions[i * 3 + 1], c = this.positions[i * 3 + 2], h = this.vectors[i * 3], d = this.vectors[i * 3 + 1], m = this.vectors[i * 3 + 2], p = Math.sqrt(h * h + d * d + m * m);
      if (p < YR) {
        Rs.makeScale(0, 0, 0), this.shaftMesh.setMatrixAt(i, Rs), this.headMesh.setMatrixAt(i, Rs);
        continue;
      }
      ll.set(h / p, d / p, m / p), yd.setFromUnitVectors(qR, ll);
      const g = p * this.arrowScale, _ = Math.max(g - xd, g * 0.7);
      tu.set(s, l, c), eu.set(1, _, 1), Rs.compose(tu, yd, eu), this.shaftMesh.setMatrixAt(i, Rs), tu.set(
        s + ll.x * _,
        l + ll.y * _,
        c + ll.z * _
      ), eu.set(1, 1, 1), Rs.compose(tu, yd, eu), this.headMesh.setMatrixAt(i, Rs);
    }
    this.shaftMesh.instanceMatrix.needsUpdate = !0, this.headMesh.instanceMatrix.needsUpdate = !0;
  }
  dispose() {
    this.shaftMesh.geometry.dispose(), this.headMesh.geometry.dispose(), this.shaftMesh.material.dispose(), this.headMesh.material.dispose(), this.mesh.remove(this.shaftMesh), this.mesh.remove(this.headMesh);
  }
}
const qa = new Je();
class ZR {
  constructor() {
    Rt(this, "container", null);
    Rt(this, "renderer");
    Rt(this, "scene");
    Rt(this, "camera");
    Rt(this, "controls");
    Rt(this, "perspectiveMode", !1);
    Rt(this, "atomRenderer", null);
    Rt(this, "bondRenderer", null);
    Rt(this, "cellRenderer", null);
    Rt(this, "cellAxesRenderer", null);
    Rt(this, "labelOverlay", null);
    Rt(this, "arrowRenderer", null);
    Rt(this, "useImpostor", !1);
    Rt(this, "animationId", null);
    Rt(this, "snapshot", null);
    Rt(this, "lastExtent", 1);
    Rt(this, "lastExtentX", 1);
    Rt(this, "lastExtentY", 1);
    Rt(this, "currentPositions", null);
    /** Axes-inset drag state */
    Rt(this, "axesDragging", !1);
    Rt(this, "axesDragLastX", 0);
    Rt(this, "axesDragLastY", 0);
    Rt(this, "atomScale", 1);
    Rt(this, "atomOpacity", 1);
    Rt(this, "bondScale", 1);
    Rt(this, "bondOpacity", 1);
    Rt(this, "viewInsetLeft", 0);
    Rt(this, "viewInsetRight", 0);
    Rt(this, "dprMediaQuery", null);
    Rt(this, "dprChangeHandler", null);
    // Cached dimensions for frame-synchronous resize detection
    Rt(this, "lastContainerW", 0);
    Rt(this, "lastContainerH", 0);
    Rt(this, "lastDpr", 1);
    // (screen-space picking replaces Three.js raycasting)
    // Atom selection & measurement
    Rt(this, "selectedAtoms", []);
    Rt(this, "selectionGroup", new Os());
    Rt(this, "animate", () => {
      if (this.animationId = requestAnimationFrame(this.animate), this.container) {
        const s = this.container.clientWidth, l = this.container.clientHeight, c = Math.min(window.devicePixelRatio, 2);
        (s !== this.lastContainerW || l !== this.lastContainerH || c !== this.lastDpr) && (this.lastContainerW = s, this.lastContainerH = l, this.lastDpr = c, this.onResize());
      }
      this.controls.update(), this.renderer.render(this.scene, this.camera);
      const t = new $t();
      this.renderer.getSize(t);
      const i = this.renderer.getPixelRatio();
      if (this.cellAxesRenderer)
        try {
          this.cellAxesRenderer.render(
            this.renderer,
            this.camera,
            t.x,
            t.y
          );
        } catch (s) {
          console.warn("CellAxesRenderer render error:", s), this.cellAxesRenderer = null;
        }
      this.labelOverlay && this.labelOverlay.render(
        this.camera,
        t.x,
        t.y,
        i
      );
    });
  }
  /** Mount the viewer into a DOM element. */
  mount(t) {
    this.container = t, this.renderer = new lR({
      antialias: !0,
      alpha: !0,
      powerPreference: "high-performance",
      preserveDrawingBuffer: !0
    }), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)), this.renderer.setSize(t.clientWidth, t.clientHeight, !1), this.renderer.setClearColor(16777215, 1);
    const i = this.renderer.domElement;
    i.style.display = "block", i.style.position = "absolute", i.style.top = "0", i.style.left = "0", i.style.width = "100%", i.style.height = "100%", t.appendChild(i), this.labelOverlay = new VR(), t.appendChild(this.labelOverlay.getCanvas()), this.labelOverlay.resize(
      t.clientWidth,
      t.clientHeight,
      Math.min(window.devicePixelRatio, 2)
    ), this.scene = new Mx(), this.scene.background = new ve(16777215);
    const s = t.clientWidth / t.clientHeight, l = 50;
    this.camera = new Za(
      -l * s / 2,
      l * s / 2,
      l / 2,
      -l / 2,
      0.1,
      1e4
    ), this.camera.position.set(0, -50, 0), this.camera.up.set(0, 0, 1), this.controls = new Ov(this.camera, this.renderer.domElement), this.controls.enableDamping = !0, this.controls.dampingFactor = 0.1, this.controls.rotateSpeed = 0.8, this.controls.zoomSpeed = 1.2;
    const c = new xE(14544639, 10057540, 0.4);
    this.scene.add(c);
    const h = new lu(16777215, 0.8);
    h.position.set(50, 50, 50), this.scene.add(h);
    const d = new lu(16777215, 0.4);
    d.position.set(-30, 20, -20), this.scene.add(d);
    const m = new lu(16777215, 0.3);
    m.position.set(0, -30, -50), this.scene.add(m), this.scene.add(this.selectionGroup), new ResizeObserver(() => this.onResize()).observe(t), this.setupDprListener(), this.animate();
  }
  /** Load a molecular snapshot (topology + positions). */
  loadSnapshot(t) {
    if (this.snapshot = t, this.currentPositions = new Float32Array(t.positions), (this.atomRenderer === null || !this.useImpostor) && this.swapRenderers(!0), this.atomRenderer.loadSnapshot(t), this.bondRenderer.loadSnapshot(t), this.atomScale !== 1 && this.atomRenderer.setScale && this.atomRenderer.setScale(this.atomScale, t), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, t), this.labelOverlay && (this.labelOverlay.setAtomData(t.elements, t.nAtoms), this.labelOverlay.setPositions(t.positions)), this.arrowRenderer || (this.arrowRenderer = new jR(t.nAtoms), this.scene.add(this.arrowRenderer.mesh)), this.arrowRenderer.setAtomPositions(t.positions, t.nAtoms), t.box) {
      const i = t.box.some((s) => s !== 0);
      if (i && (this.cellRenderer || (this.cellRenderer = new IR(), this.scene.add(this.cellRenderer.mesh)), this.cellRenderer.loadBox(t.box)), i)
        try {
          this.cellAxesRenderer || (this.cellAxesRenderer = new FR()), this.cellAxesRenderer.loadBox(t.box);
        } catch (s) {
          console.warn("CellAxesRenderer init error:", s), this.cellAxesRenderer = null;
        }
    }
    this.fitToView(t);
  }
  /** Update positions from a trajectory frame. */
  updateFrame(t) {
    var i, s;
    !this.snapshot || !this.atomRenderer || !this.bondRenderer || ((!this.currentPositions || this.currentPositions.length < t.positions.length) && (this.currentPositions = new Float32Array(t.positions.length)), this.currentPositions.set(t.positions), this.atomRenderer.updatePositions(t.positions), (i = this.labelOverlay) == null || i.setPositions(t.positions), (s = this.arrowRenderer) == null || s.setAtomPositions(t.positions, t.nAtoms), this.bondRenderer.updatePositions(
      t.positions,
      this.snapshot.bonds,
      this.snapshot.nBonds
    ), this.selectedAtoms.length > 0 && this.updateSelectionVisuals());
  }
  /**
   * Replace bond data and re-render bonds without resetting the camera.
   * Used for per-frame bond recalculation (e.g. distance-based bonds).
   */
  updateBonds(t, i) {
    if (!this.snapshot || !this.bondRenderer) return;
    const s = this.currentPositions ?? this.snapshot.positions, l = {
      ...this.snapshot,
      nBonds: t.length / 2,
      bonds: t,
      bondOrders: i
    };
    this.snapshot = l, this.bondRenderer.loadSnapshot({
      ...l,
      positions: s
    }), this.bondScale !== 1 && this.bondRenderer.setScale && this.bondRenderer.setScale(this.bondScale, l);
  }
  /** Set per-atom labels for overlay display. */
  setLabels(t) {
    var i;
    (i = this.labelOverlay) == null || i.setLabels(t);
  }
  /** Set per-atom vector data for arrow display. */
  setVectors(t) {
    var i;
    (i = this.arrowRenderer) == null || i.setVectors(t);
  }
  /** Set arrow scale multiplier. */
  setVectorScale(t) {
    var i;
    (i = this.arrowRenderer) == null || i.setScale(t);
  }
  /** Set atom radius scale multiplier. */
  setAtomScale(t) {
    var i;
    this.atomScale = t, (i = this.atomRenderer) != null && i.setScale && this.snapshot && this.atomRenderer.setScale(t, this.snapshot);
  }
  /** Set atom opacity (independent of bonds). */
  setAtomOpacity(t) {
    var i, s;
    this.atomOpacity = t, (s = (i = this.atomRenderer) == null ? void 0 : i.setOpacity) == null || s.call(i, t);
  }
  /** Set bond radius scale multiplier. */
  setBondScale(t) {
    var i;
    this.bondScale = t, (i = this.bondRenderer) != null && i.setScale && this.snapshot && this.bondRenderer.setScale(t, this.snapshot);
  }
  /** Set bond opacity (independent of atoms). */
  setBondOpacity(t) {
    var i, s;
    this.bondOpacity = t, (s = (i = this.bondRenderer) == null ? void 0 : i.setOpacity) == null || s.call(i, t);
  }
  /** Toggle bond visibility. */
  setBondsVisible(t) {
    this.bondRenderer && (this.bondRenderer.mesh.visible = t);
  }
  /** Toggle simulation cell visibility. */
  setCellVisible(t) {
    this.cellRenderer && this.cellRenderer.setVisible(t);
  }
  /** Check if cell data exists. */
  hasCell() {
    return this.cellRenderer !== null && this.cellRenderer.mesh.visible;
  }
  /** Toggle cell axes indicator visibility. */
  setCellAxesVisible(t) {
    this.cellAxesRenderer && this.cellAxesRenderer.setVisible(t);
  }
  // ── Axes inset drag API ───────────────────────────────────
  /** Returns true if the CSS-pixel coordinate hits the axes inset. */
  hitTestAxesInset(t, i) {
    return !this.cellAxesRenderer || !this.container ? !1 : this.cellAxesRenderer.hitTest(
      t,
      i,
      this.container.clientHeight
    );
  }
  /** Begin an axes-inset drag at the given CSS coordinates. */
  startAxesDrag(t, i) {
    this.axesDragging = !0, this.axesDragLastX = t, this.axesDragLastY = i, this.controls.enabled = !1;
  }
  /** Continue an axes-inset drag. Returns true if currently dragging. */
  moveAxesDrag(t, i) {
    if (!this.axesDragging || !this.cellAxesRenderer || !this.container)
      return !1;
    const s = t - this.axesDragLastX, l = i - this.axesDragLastY;
    return this.axesDragLastX = t, this.axesDragLastY = i, this.cellAxesRenderer.moveBy(
      s,
      l,
      this.container.clientWidth,
      this.container.clientHeight
    ), !0;
  }
  /** End the axes-inset drag. */
  endAxesDrag() {
    this.axesDragging && (this.axesDragging = !1, this.controls.enabled = !0);
  }
  /** Whether an axes drag is in progress. */
  isAxesDragging() {
    return this.axesDragging;
  }
  /** Check if cell axes data exists. */
  hasCellAxes() {
    return this.cellAxesRenderer !== null;
  }
  /** Swap between InstancedMesh and Impostor renderers. */
  swapRenderers(t) {
    var l, c, h, d;
    this.atomRenderer && (this.scene.remove(this.atomRenderer.mesh), this.atomRenderer.dispose()), this.bondRenderer && (this.scene.remove(this.bondRenderer.mesh), this.bondRenderer.dispose()), this.useImpostor = t;
    const i = new PR(), s = new BR();
    this.atomRenderer = i, this.bondRenderer = s, this.scene.add(this.atomRenderer.mesh), this.scene.add(this.bondRenderer.mesh), this.atomOpacity !== 1 && ((c = (l = this.atomRenderer).setOpacity) == null || c.call(l, this.atomOpacity)), this.bondOpacity !== 1 && ((d = (h = this.bondRenderer).setOpacity) == null || d.call(h, this.bondOpacity));
  }
  /** Fit camera to show all atoms (or simulation cell if present). */
  fitToView(t) {
    const { positions: i, nAtoms: s } = t;
    let l = 0, c = 0, h = 0;
    for (let L = 0; L < s; L++)
      l += i[L * 3], c += i[L * 3 + 1], h += i[L * 3 + 2];
    let d, m, p, g = 1 / 0, _ = 1 / 0, x = 1 / 0, S = -1 / 0, E = -1 / 0, b = -1 / 0;
    if (t.box && t.box.some((L) => L !== 0)) {
      const L = t.box;
      d = (L[0] + L[3] + L[6]) / 2, m = (L[1] + L[4] + L[7]) / 2, p = (L[2] + L[5] + L[8]) / 2;
      const O = [L[0], L[1], L[2]], G = [L[3], L[4], L[5]], C = [L[6], L[7], L[8]];
      for (let T = 0; T <= 1; T++)
        for (let I = 0; I <= 1; I++)
          for (let J = 0; J <= 1; J++) {
            const $ = T * O[0] + I * G[0] + J * C[0], lt = T * O[1] + I * G[1] + J * C[1], pt = T * O[2] + I * G[2] + J * C[2];
            g = Math.min(g, $), _ = Math.min(_, lt), x = Math.min(x, pt), S = Math.max(S, $), E = Math.max(E, lt), b = Math.max(b, pt);
          }
    } else {
      d = s > 0 ? l / s : 0, m = s > 0 ? c / s : 0, p = s > 0 ? h / s : 0;
      for (let L = 0; L < s; L++) {
        const O = i[L * 3], G = i[L * 3 + 1], C = i[L * 3 + 2];
        g = Math.min(g, O), _ = Math.min(_, G), x = Math.min(x, C), S = Math.max(S, O), E = Math.max(E, G), b = Math.max(b, C);
      }
    }
    const v = S - g, B = E - _, U = b - x, w = Math.max(v, B, U);
    this.lastExtent = w, this.lastExtentX = v, this.lastExtentY = B, this.controls.target.set(d, m, p);
    const F = Math.max(w * 1.2, 0.1);
    this.camera.position.set(d, m - F, p), this.camera instanceof Za ? (this.camera.near = -F * 10, this.camera.far = F * 10, this.camera.zoom = 1, this.applyFrustumInsets()) : (this.camera.near = F * 0.01, this.camera.far = F * 10, this.camera.updateProjectionMatrix()), this.controls.update();
  }
  /** Reset view to fit all atoms. */
  resetView() {
    this.snapshot && this.fitToView(this.snapshot);
  }
  /** Set the rotation center (orbit target) to the given world coordinates. */
  setRotationCenter(t, i, s) {
    this.controls.target.set(t, i, s), this.controls.update();
  }
  /** Set pixel insets for overlay panels that occlude viewport edges. */
  setViewInsets(t, i) {
    this.viewInsetLeft = t, this.viewInsetRight = i, this.applyFrustumInsets();
  }
  /**
   * Recalculate the orthographic frustum so the model fits within the
   * visible area (accounting for overlay insets) and appears centered
   * in that visible area.
   */
  applyFrustumInsets() {
    if (!(this.camera instanceof Za) || !this.container) return;
    const t = this.container.clientWidth, i = this.container.clientHeight;
    if (t === 0 || i === 0) return;
    const s = this.viewInsetLeft, l = this.viewInsetRight, c = Math.max(t * 0.3, 100), d = Math.max(t - s - l, c) / i, p = Math.max(this.lastExtentY / 2, this.lastExtentX / (2 * d)) * 1.2, g = Math.max(p * 2, 0.1), _ = t / i, x = g * _ / 2;
    this.camera.left = -x, this.camera.right = x, this.camera.top = g / 2, this.camera.bottom = -g / 2;
    const S = 2 * x, E = (s - l) / (2 * t) * S;
    this.camera.left -= E, this.camera.right -= E, this.camera.updateProjectionMatrix();
  }
  /** Switch between orthographic and perspective projection. */
  setPerspective(t) {
    if (this.perspectiveMode === t || (this.perspectiveMode = t, !this.container)) return;
    const i = this.camera.position.clone(), s = this.controls.target.clone(), l = this.camera.up.clone(), c = this.container.clientWidth, h = this.container.clientHeight, d = c / h;
    t ? this.camera = new ui(50, d, 0.1, 1e4) : this.camera = new Za(
      -50 * d / 2,
      50 * d / 2,
      50 / 2,
      -50 / 2,
      0.1,
      1e4
    ), this.camera.position.copy(i), this.camera.up.copy(l);
    const m = this.controls.enableDamping, p = this.controls.dampingFactor, g = this.controls.rotateSpeed, _ = this.controls.zoomSpeed;
    this.controls.dispose(), this.controls = new Ov(this.camera, this.renderer.domElement), this.controls.enableDamping = m, this.controls.dampingFactor = p, this.controls.rotateSpeed = g, this.controls.zoomSpeed = _, this.controls.target.copy(s), this.controls.update(), this.snapshot && this.fitToView(this.snapshot);
  }
  /** Get the canvas element for event listener attachment. */
  getCanvas() {
    var t;
    return ((t = this.renderer) == null ? void 0 : t.domElement) ?? null;
  }
  /** Get a copy of current atom positions (public, for external use). */
  getCurrentPositionsCopy() {
    return this.snapshot ? new Float32Array(this.currentPositions ?? this.snapshot.positions) : null;
  }
  /** Get current atom positions (may reflect trajectory frame). */
  getCurrentPositions() {
    return this.currentPositions ?? this.snapshot.positions;
  }
  // ---- Raycasting ----
  /** Project a 3D point to screen coordinates. Returns {sx, sy, depth} in pixels. */
  projectToScreen(t, i, s, l, c) {
    qa.set(t, i, s, 1), qa.applyMatrix4(this.camera.matrixWorldInverse);
    const h = -qa.z;
    qa.applyMatrix4(this.camera.projectionMatrix);
    const d = (qa.x / qa.w * 0.5 + 0.5) * l, m = (-qa.y / qa.w * 0.5 + 0.5) * c;
    return { sx: d, sy: m, depth: h };
  }
  /** Estimate the screen-space radius (in pixels) of a sphere at the given depth. */
  screenRadius(t, i, s) {
    if (this.camera instanceof Za) {
      const h = (this.camera.top - this.camera.bottom) / this.camera.zoom, d = s / h;
      return t * d;
    }
    const l = this.camera.fov * Math.PI / 180, c = s / (2 * i * Math.tan(l / 2));
    return t * c;
  }
  /** Perform a pick at the given screen coordinates using CPU screen-space projection. */
  raycastAtPixel(t, i) {
    if (!this.container || !this.snapshot) return null;
    const s = this.container.getBoundingClientRect(), l = t - s.left, c = i - s.top, h = s.width, d = s.height, m = this.getCurrentPositions(), p = this.snapshot.elements, g = this.snapshot.nAtoms;
    let _ = -1, x = 1 / 0;
    for (let U = 0; U < g; U++) {
      const { sx: w, sy: F, depth: L } = this.projectToScreen(
        m[U * 3],
        m[U * 3 + 1],
        m[U * 3 + 2],
        h,
        d
      );
      if (L <= 0) continue;
      const O = pp(p[U]) * dp * this.atomScale, G = this.screenRadius(O, L, d), C = l - w, T = c - F;
      C * C + T * T <= G * G && L < x && (_ = U, x = L);
    }
    if (_ >= 0) {
      const U = _, w = p[U];
      return {
        kind: "atom",
        atomIndex: U,
        elementSymbol: Np(w),
        atomicNumber: w,
        position: [m[U * 3], m[U * 3 + 1], m[U * 3 + 2]],
        screenX: t,
        screenY: i
      };
    }
    const S = 8, E = this.snapshot.bonds, b = this.snapshot.nBonds, M = this.snapshot.bondOrders;
    let v = -1, B = 1 / 0;
    for (let U = 0; U < b; U++) {
      const w = E[U * 2], F = E[U * 2 + 1], L = (m[w * 3] + m[F * 3]) * 0.5, O = (m[w * 3 + 1] + m[F * 3 + 1]) * 0.5, G = (m[w * 3 + 2] + m[F * 3 + 2]) * 0.5, { sx: C, sy: T, depth: I } = this.projectToScreen(L, O, G, h, d);
      if (I <= 0) continue;
      const J = l - C, $ = c - T;
      J * J + $ * $ <= S * S && I < B && (v = U, B = I);
    }
    if (v >= 0) {
      const U = E[v * 2], w = E[v * 2 + 1], F = m[w * 3] - m[U * 3], L = m[w * 3 + 1] - m[U * 3 + 1], O = m[w * 3 + 2] - m[U * 3 + 2], G = Math.sqrt(F * F + L * L + O * O), C = M ? M[v] : 1;
      return {
        kind: "bond",
        atomA: U,
        atomB: w,
        bondOrder: C,
        bondLength: G,
        screenX: t,
        screenY: i
      };
    }
    return null;
  }
  // ---- Selection & Measurement ----
  /** Toggle atom selection (right-click). Returns new selection state. */
  toggleAtomSelection(t) {
    const i = this.selectedAtoms.indexOf(t);
    return i >= 0 ? this.selectedAtoms.splice(i, 1) : (this.selectedAtoms.length >= 4 && this.selectedAtoms.shift(), this.selectedAtoms.push(t)), this.updateSelectionVisuals(), { atoms: [...this.selectedAtoms] };
  }
  /** Set selected atoms directly (for external triggers). Returns new selection state. */
  setSelection(t) {
    return this.selectedAtoms = t.slice(0, 4), this.updateSelectionVisuals(), { atoms: [...this.selectedAtoms] };
  }
  /** Clear all selected atoms. */
  clearSelection() {
    this.selectedAtoms = [], this.updateSelectionVisuals();
  }
  /** Compute the current geometric measurement based on selected atoms. */
  getMeasurement() {
    if (!this.snapshot || this.selectedAtoms.length < 2) return null;
    const t = this.getCurrentPositions(), i = this.selectedAtoms;
    if (i.length === 2) {
      const s = this.computeDistance(t, i[0], i[1]);
      return { atoms: [...i], type: "distance", value: s, label: `${s.toFixed(3)} Å` };
    }
    if (i.length === 3) {
      const s = this.computeAngle(t, i[0], i[1], i[2]);
      return { atoms: [...i], type: "angle", value: s, label: `${s.toFixed(1)}°` };
    }
    if (i.length === 4) {
      const s = this.computeDihedral(t, i[0], i[1], i[2], i[3]);
      return { atoms: [...i], type: "dihedral", value: s, label: `${s.toFixed(1)}°` };
    }
    return null;
  }
  computeDistance(t, i, s) {
    const l = t[s * 3] - t[i * 3], c = t[s * 3 + 1] - t[i * 3 + 1], h = t[s * 3 + 2] - t[i * 3 + 2];
    return Math.sqrt(l * l + c * c + h * h);
  }
  computeAngle(t, i, s, l) {
    const c = t[i * 3] - t[s * 3], h = t[i * 3 + 1] - t[s * 3 + 1], d = t[i * 3 + 2] - t[s * 3 + 2], m = t[l * 3] - t[s * 3], p = t[l * 3 + 1] - t[s * 3 + 1], g = t[l * 3 + 2] - t[s * 3 + 2], _ = c * m + h * p + d * g, x = Math.sqrt(c * c + h * h + d * d), S = Math.sqrt(m * m + p * p + g * g);
    return Math.acos(Math.max(-1, Math.min(1, _ / (x * S)))) * (180 / Math.PI);
  }
  computeDihedral(t, i, s, l, c) {
    const h = t[s * 3] - t[i * 3], d = t[s * 3 + 1] - t[i * 3 + 1], m = t[s * 3 + 2] - t[i * 3 + 2], p = t[l * 3] - t[s * 3], g = t[l * 3 + 1] - t[s * 3 + 1], _ = t[l * 3 + 2] - t[s * 3 + 2], x = t[c * 3] - t[l * 3], S = t[c * 3 + 1] - t[l * 3 + 1], E = t[c * 3 + 2] - t[l * 3 + 2], b = d * _ - m * g, M = m * p - h * _, v = h * g - d * p, B = g * E - _ * S, U = _ * x - p * E, w = p * S - g * x, F = Math.sqrt(p * p + g * g + _ * _), L = p / F, O = g / F, G = _ / F, C = M * G - v * O, T = v * L - b * G, I = b * O - M * L, J = b * B + M * U + v * w, $ = C * B + T * U + I * w;
    return Math.atan2($, J) * (180 / Math.PI);
  }
  updateSelectionVisuals() {
    for (; this.selectionGroup.children.length > 0; ) {
      const s = this.selectionGroup.children[0];
      this.selectionGroup.remove(s), (s instanceof Un || s instanceof fl) && (s.geometry.dispose(), Array.isArray(s.material) ? s.material.forEach((l) => l.dispose()) : s.material.dispose());
    }
    if (!this.snapshot || this.selectedAtoms.length === 0) return;
    const t = this.getCurrentPositions(), i = this.snapshot.elements;
    for (const s of this.selectedAtoms) {
      const l = pp(i[s]) * dp * 1.6, c = new wp(l, 16, 16), h = new yu({
        color: 4359668,
        transparent: !0,
        opacity: 0.35,
        depthWrite: !1
      }), d = new Un(c, h);
      d.position.set(
        t[s * 3],
        t[s * 3 + 1],
        t[s * 3 + 2]
      ), this.selectionGroup.add(d);
    }
    if (this.selectedAtoms.length >= 2) {
      const s = this.selectedAtoms.map(
        (d) => new q(t[d * 3], t[d * 3 + 1], t[d * 3 + 2])
      ), l = new Xn().setFromPoints(s), c = new Su({
        color: 4359668,
        depthTest: !1
      }), h = new fl(l, c);
      h.renderOrder = 999, this.selectionGroup.add(h);
    }
  }
  setupDprListener() {
    const t = () => {
      var i;
      this.onResize(), (i = this.dprMediaQuery) == null || i.removeEventListener("change", t), this.dprMediaQuery = window.matchMedia(
        `(resolution: ${window.devicePixelRatio}dppx)`
      ), this.dprChangeHandler = t, this.dprMediaQuery.addEventListener("change", t);
    };
    this.dprMediaQuery = window.matchMedia(
      `(resolution: ${window.devicePixelRatio}dppx)`
    ), this.dprChangeHandler = t, this.dprMediaQuery.addEventListener("change", t);
  }
  onResize() {
    var l;
    if (!this.container) return;
    const t = this.container.clientWidth, i = this.container.clientHeight;
    if (t === 0 || i === 0) return;
    const s = Math.min(window.devicePixelRatio, 2);
    this.lastContainerW = t, this.lastContainerH = i, this.lastDpr = s, this.renderer.setPixelRatio(s), this.camera instanceof Za ? this.applyFrustumInsets() : (this.camera.aspect = t / i, this.camera.updateProjectionMatrix()), this.renderer.setSize(t, i, !1), (l = this.labelOverlay) == null || l.resize(t, i, s);
  }
  /** Clean up all resources. */
  dispose() {
    this.animationId !== null && cancelAnimationFrame(this.animationId), this.clearSelection(), this.atomRenderer && this.atomRenderer.dispose(), this.bondRenderer && this.bondRenderer.dispose(), this.cellRenderer && this.cellRenderer.dispose(), this.cellAxesRenderer && this.cellAxesRenderer.dispose(), this.arrowRenderer && this.arrowRenderer.dispose(), this.labelOverlay && this.labelOverlay.dispose(), this.dprMediaQuery && this.dprChangeHandler && this.dprMediaQuery.removeEventListener("change", this.dprChangeHandler), this.controls.dispose(), this.renderer.dispose(), this.container && this.renderer.domElement.parentNode && this.container.removeChild(this.renderer.domElement);
  }
}
function KR({
  snapshot: r,
  frame: t,
  atomLabels: i,
  atomVectors: s,
  onRendererReady: l,
  onHover: c,
  onAtomRightClick: h,
  onFrameUpdated: d
}) {
  const m = qt.useRef(null), p = qt.useRef(null), g = qt.useRef(c), _ = qt.useRef(h), x = qt.useRef(d);
  return g.current = c, _.current = h, x.current = d, qt.useEffect(() => {
    if (!m.current) return;
    const S = new ZR();
    return S.mount(m.current), p.current = S, l == null || l(S), () => {
      S.dispose(), p.current = null;
    };
  }, []), qt.useEffect(() => {
    const S = p.current, E = S == null ? void 0 : S.getCanvas();
    if (!E || !S) return;
    let b = null;
    const M = (C) => {
      b === null && (b = requestAnimationFrame(() => {
        var I;
        const T = S.raycastAtPixel(C.clientX, C.clientY);
        (I = g.current) == null || I.call(g, T), b = null;
      }));
    }, v = (C) => {
      var I;
      C.preventDefault();
      const T = S.raycastAtPixel(C.clientX, C.clientY);
      T && T.kind === "atom" && ((I = _.current) == null || I.call(_, T.atomIndex));
    }, B = () => {
      var C;
      (C = g.current) == null || C.call(g, null);
    }, U = (C) => {
      const T = S.raycastAtPixel(C.clientX, C.clientY);
      if (T && T.kind === "atom") {
        const I = S.getCurrentPositionsCopy();
        if (I) {
          const J = T.atomIndex;
          S.setRotationCenter(
            I[J * 3],
            I[J * 3 + 1],
            I[J * 3 + 2]
          );
        }
      }
    }, w = m.current, F = (C) => {
      const T = w.getBoundingClientRect();
      return { x: C.clientX - T.left, y: C.clientY - T.top };
    }, L = (C) => {
      var J, $;
      const { x: T, y: I } = F(C);
      S.hitTestAxesInset(T, I) && (C.preventDefault(), S.startAxesDrag(T, I), ($ = (J = C.target) == null ? void 0 : J.setPointerCapture) == null || $.call(J, C.pointerId));
    }, O = (C) => {
      if (S.isAxesDragging()) {
        const { x: T, y: I } = F(C);
        S.moveAxesDrag(T, I);
      }
    }, G = (C) => {
      S.endAxesDrag();
    };
    return E.addEventListener("mousemove", M), E.addEventListener("contextmenu", v), E.addEventListener("mouseleave", B), E.addEventListener("dblclick", U), E.addEventListener("pointerdown", L), E.addEventListener("pointermove", O), E.addEventListener("pointerup", G), E.addEventListener("pointercancel", G), () => {
      E.removeEventListener("mousemove", M), E.removeEventListener("contextmenu", v), E.removeEventListener("mouseleave", B), E.removeEventListener("dblclick", U), E.removeEventListener("pointerdown", L), E.removeEventListener("pointermove", O), E.removeEventListener("pointerup", G), E.removeEventListener("pointercancel", G), b !== null && cancelAnimationFrame(b);
    };
  }, []), qt.useEffect(() => {
    r && p.current && p.current.loadSnapshot(r);
  }, [r]), qt.useEffect(() => {
    var S;
    t && p.current && (p.current.updateFrame(t), (S = x.current) == null || S.call(x));
  }, [t]), qt.useEffect(() => {
    var S;
    (S = p.current) == null || S.setLabels(i ?? null);
  }, [i]), qt.useEffect(() => {
    var S;
    (S = p.current) == null || S.setVectors(s ?? null);
  }, [s]), /* @__PURE__ */ bt.jsx(
    "div",
    {
      ref: m,
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        background: "#ffffff"
      }
    }
  );
}
const fa = {
  fontSize: 10,
  fontWeight: 600,
  color: "#94a3b8",
  textTransform: "uppercase",
  letterSpacing: "0.06em",
  marginBottom: 6
}, vu = {
  background: "none",
  border: "1px solid #e2e8f0",
  borderRadius: 5,
  padding: "2px 10px",
  cursor: "pointer",
  fontSize: 11,
  fontWeight: 500,
  color: "#64748b",
  transition: "all 0.15s"
}, Yv = {
  ...vu,
  background: "rgba(59, 130, 246, 0.08)",
  borderColor: "rgba(59, 130, 246, 0.25)",
  color: "#3b82f6"
}, qv = {
  fontSize: 13,
  fontWeight: 600,
  color: "#1e293b",
  wordBreak: "break-all"
};
function jv(r, t) {
  const i = r.toLowerCase();
  return t.some((s) => i.endsWith(s));
}
function Zv({
  accept: r,
  exts: t,
  onFile: i,
  label: s,
  children: l
}) {
  const c = qt.useRef(null), h = qt.useCallback(
    (p) => {
      p.preventDefault(), p.stopPropagation();
      const _ = Array.from(p.dataTransfer.files).find((x) => jv(x.name, t));
      _ && i(_);
    },
    [t, i]
  ), d = qt.useCallback((p) => {
    p.preventDefault(), p.stopPropagation();
  }, []), m = qt.useCallback(
    (p) => {
      const g = p.target.files;
      if (!g) return;
      const _ = Array.from(g).find((x) => jv(x.name, t));
      _ && i(_), p.target.value = "";
    },
    [t, i]
  );
  return /* @__PURE__ */ bt.jsxs(
    "div",
    {
      onDrop: h,
      onDragOver: d,
      style: { minHeight: 0 },
      children: [
        l,
        /* @__PURE__ */ bt.jsx(
          "button",
          {
            onClick: () => {
              var p;
              return (p = c.current) == null ? void 0 : p.click();
            },
            style: { ...vu, marginTop: 6 },
            children: s
          }
        ),
        /* @__PURE__ */ bt.jsx(
          "input",
          {
            ref: c,
            type: "file",
            accept: r,
            onChange: m,
            style: { display: "none" }
          }
        )
      ]
    }
  );
}
function mp({
  options: r,
  value: t,
  onChange: i,
  disabledOptions: s
}) {
  return /* @__PURE__ */ bt.jsx(
    "div",
    {
      style: {
        display: "flex",
        borderRadius: 6,
        overflow: "hidden",
        border: "1px solid #e2e8f0",
        marginBottom: 6
      },
      children: r.map((l, c) => {
        const h = l.value === t, d = (s == null ? void 0 : s.has(l.value)) ?? !1;
        return /* @__PURE__ */ bt.jsx(
          "button",
          {
            onClick: h || d ? void 0 : () => i(l.value),
            style: {
              flex: 1,
              background: h ? "rgba(59,130,246,0.08)" : "none",
              border: "none",
              borderRight: c < r.length - 1 ? "1px solid #e2e8f0" : "none",
              padding: "4px 0",
              cursor: h || d ? "default" : "pointer",
              fontSize: 11,
              fontWeight: 500,
              color: d ? "#cbd5e1" : h ? "#3b82f6" : "#94a3b8",
              transition: "all 0.15s"
            },
            disabled: d,
            children: l.label
          },
          l.value
        );
      })
    }
  );
}
const QR = ".pdb,.gro,.xyz,.txt", JR = [".pdb", ".gro", ".xyz", ".txt"], $R = ".vec,.json,.jsonl", t2 = [".vec", ".json", ".jsonl"], Ir = {
  width: "100%",
  height: 4,
  cursor: "pointer",
  appearance: "none",
  WebkitAppearance: "none",
  borderRadius: 2,
  outline: "none"
}, Fr = {
  fontSize: 11,
  fontWeight: 500,
  color: "#3b82f6",
  minWidth: 36,
  textAlign: "right"
};
function e2({
  atomScale: r,
  onAtomScaleChange: t,
  atomOpacity: i,
  onAtomOpacityChange: s,
  bondScale: l,
  onBondScaleChange: c,
  bondOpacity: h,
  onBondOpacityChange: d,
  vdwScale: m,
  onVdwScaleChange: p,
  labels: g,
  vectors: _,
  vectorScale: x,
  onVectorScaleChange: S,
  perspective: E,
  onPerspectiveChange: b,
  hasCell: M,
  cellAxesVisible: v,
  onToggleCellAxes: B,
  collapsed: U,
  onToggleCollapse: w
}) {
  return U ? /* @__PURE__ */ bt.jsx(
    "div",
    {
      style: {
        position: "absolute",
        top: 12,
        right: 12,
        zIndex: 10
      },
      children: /* @__PURE__ */ bt.jsxs(
        "button",
        {
          onClick: w,
          style: {
            background: "rgba(255, 255, 255, 0.88)",
            backdropFilter: "blur(16px)",
            WebkitBackdropFilter: "blur(16px)",
            border: "1px solid rgba(226,232,240,0.6)",
            borderRadius: 10,
            padding: "8px 12px",
            cursor: "pointer",
            boxShadow: "0 1px 8px rgba(0,0,0,0.06)",
            display: "flex",
            alignItems: "center",
            gap: 8,
            fontSize: 13,
            fontWeight: 600,
            color: "#1e293b",
            letterSpacing: "-0.02em"
          },
          title: "Open appearance panel",
          children: [
            /* @__PURE__ */ bt.jsx("span", { style: { fontSize: 11, color: "#94a3b8", fontWeight: 400 }, children: "◀" }),
            "Appearance"
          ]
        }
      )
    }
  ) : /* @__PURE__ */ bt.jsxs(
    "div",
    {
      style: {
        position: "absolute",
        top: 12,
        right: 12,
        bottom: 60,
        width: 220,
        zIndex: 10,
        background: "rgba(255, 255, 255, 0.92)",
        backdropFilter: "blur(16px)",
        WebkitBackdropFilter: "blur(16px)",
        borderRadius: 12,
        boxShadow: "0 1px 8px rgba(0,0,0,0.06)",
        border: "1px solid rgba(226,232,240,0.6)",
        display: "flex",
        flexDirection: "column",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              padding: "10px 14px",
              display: "flex",
              alignItems: "center",
              justifyContent: "space-between",
              borderBottom: "1px solid rgba(226,232,240,0.6)",
              flexShrink: 0
            },
            children: [
              /* @__PURE__ */ bt.jsx(
                "span",
                {
                  style: {
                    fontWeight: 600,
                    color: "#1e293b",
                    fontSize: 13,
                    letterSpacing: "-0.02em"
                  },
                  children: "Appearance"
                }
              ),
              /* @__PURE__ */ bt.jsx(
                "button",
                {
                  onClick: w,
                  style: {
                    background: "none",
                    border: "none",
                    cursor: "pointer",
                    fontSize: 13,
                    color: "#94a3b8",
                    padding: "2px 4px"
                  },
                  title: "Collapse panel",
                  children: "▶"
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              flex: 1,
              overflowY: "auto",
              padding: "10px 14px",
              display: "flex",
              flexDirection: "column",
              gap: 14
            },
            children: [
              /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Atom Radius" }),
                /* @__PURE__ */ bt.jsxs(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      gap: 8
                    },
                    children: [
                      /* @__PURE__ */ bt.jsx(
                        "input",
                        {
                          type: "range",
                          min: "0.1",
                          max: "2.0",
                          step: "0.01",
                          value: r,
                          onChange: (F) => t(parseFloat(F.target.value)),
                          style: Ir
                        }
                      ),
                      /* @__PURE__ */ bt.jsx("span", { style: Fr, children: r.toFixed(2) })
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Atom Opacity" }),
                /* @__PURE__ */ bt.jsxs(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      gap: 8
                    },
                    children: [
                      /* @__PURE__ */ bt.jsx(
                        "input",
                        {
                          type: "range",
                          min: "0",
                          max: "1",
                          step: "0.01",
                          value: i,
                          onChange: (F) => s(parseFloat(F.target.value)),
                          style: Ir
                        }
                      ),
                      /* @__PURE__ */ bt.jsxs("span", { style: Fr, children: [
                        Math.round(i * 100),
                        "%"
                      ] })
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Bond Thickness" }),
                /* @__PURE__ */ bt.jsxs(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      gap: 8
                    },
                    children: [
                      /* @__PURE__ */ bt.jsx(
                        "input",
                        {
                          type: "range",
                          min: "0.1",
                          max: "3.0",
                          step: "0.01",
                          value: l,
                          onChange: (F) => c(parseFloat(F.target.value)),
                          style: Ir
                        }
                      ),
                      /* @__PURE__ */ bt.jsx("span", { style: Fr, children: l.toFixed(2) })
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Bond Opacity" }),
                /* @__PURE__ */ bt.jsxs(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      gap: 8
                    },
                    children: [
                      /* @__PURE__ */ bt.jsx(
                        "input",
                        {
                          type: "range",
                          min: "0",
                          max: "1",
                          step: "0.01",
                          value: h,
                          onChange: (F) => d(parseFloat(F.target.value)),
                          style: Ir
                        }
                      ),
                      /* @__PURE__ */ bt.jsxs("span", { style: Fr, children: [
                        Math.round(h * 100),
                        "%"
                      ] })
                    ]
                  }
                )
              ] }),
              m != null && p && /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "VDW Scale" }),
                /* @__PURE__ */ bt.jsxs(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      gap: 8
                    },
                    children: [
                      /* @__PURE__ */ bt.jsx(
                        "input",
                        {
                          type: "range",
                          min: "0.1",
                          max: "1.5",
                          step: "0.01",
                          value: m,
                          onChange: (F) => p(parseFloat(F.target.value)),
                          style: Ir
                        }
                      ),
                      /* @__PURE__ */ bt.jsx("span", { style: Fr, children: m.toFixed(2) })
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Labels" }),
                /* @__PURE__ */ bt.jsx(
                  mp,
                  {
                    options: [
                      { value: "none", label: "None" },
                      { value: "structure", label: "Structure" },
                      { value: "file", label: "File" }
                    ],
                    value: g.source,
                    onChange: g.onSourceChange,
                    disabledOptions: /* @__PURE__ */ new Set([
                      ...g.hasStructureLabels ? [] : ["structure"]
                    ])
                  }
                ),
                g.source === "file" && /* @__PURE__ */ bt.jsx(
                  Zv,
                  {
                    accept: QR,
                    exts: JR,
                    onFile: g.onUploadFile,
                    label: "Load labels...",
                    children: g.fileName && /* @__PURE__ */ bt.jsx("div", { style: qv, children: g.fileName })
                  }
                )
              ] }),
              _ && /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Vectors" }),
                /* @__PURE__ */ bt.jsx(
                  mp,
                  {
                    options: [
                      { value: "none", label: "None" },
                      { value: "demo", label: "Demo" },
                      { value: "file", label: "File" }
                    ],
                    value: _.source,
                    onChange: _.onSourceChange
                  }
                ),
                _.source === "file" && /* @__PURE__ */ bt.jsx(
                  Zv,
                  {
                    accept: $R,
                    exts: t2,
                    onFile: _.onUploadFile,
                    label: "Load vectors...",
                    children: _.fileName && /* @__PURE__ */ bt.jsx("div", { style: qv, children: _.fileName })
                  }
                ),
                _.source !== "none" && x != null && S && /* @__PURE__ */ bt.jsxs("div", { style: { marginTop: 8 }, children: [
                  /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Arrow Scale" }),
                  /* @__PURE__ */ bt.jsxs(
                    "div",
                    {
                      style: {
                        display: "flex",
                        alignItems: "center",
                        gap: 8
                      },
                      children: [
                        /* @__PURE__ */ bt.jsx(
                          "input",
                          {
                            type: "range",
                            min: "0.1",
                            max: "10.0",
                            step: "0.1",
                            value: x,
                            onChange: (F) => S(parseFloat(F.target.value)),
                            style: Ir
                          }
                        ),
                        /* @__PURE__ */ bt.jsx("span", { style: Fr, children: x.toFixed(1) })
                      ]
                    }
                  )
                ] })
              ] }),
              (b || M && B) && /* @__PURE__ */ bt.jsxs("div", { children: [
                /* @__PURE__ */ bt.jsx("div", { style: fa, children: "Display" }),
                /* @__PURE__ */ bt.jsxs("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
                  b && /* @__PURE__ */ bt.jsx(
                    "button",
                    {
                      onClick: () => b(!E),
                      style: E ? Yv : vu,
                      title: "Toggle perspective projection",
                      children: "Perspective"
                    }
                  ),
                  M && B && /* @__PURE__ */ bt.jsx(
                    "button",
                    {
                      onClick: B,
                      style: v ? Yv : vu,
                      title: "Toggle cell axes indicator",
                      children: "Cell Axes"
                    }
                  )
                ] })
              ] })
            ]
          }
        )
      ]
    }
  );
}
function n2({
  currentFrame: r,
  totalFrames: t,
  playing: i,
  fps: s,
  onSeek: l,
  onPlayPause: c,
  onFpsChange: h
}) {
  return t <= 1 ? null : /* @__PURE__ */ bt.jsxs(
    "div",
    {
      style: {
        position: "absolute",
        bottom: 0,
        left: 0,
        right: 0,
        padding: "10px 20px 14px",
        background: "rgba(255, 255, 255, 0.88)",
        backdropFilter: "blur(16px)",
        WebkitBackdropFilter: "blur(16px)",
        borderTop: "1px solid rgba(226,232,240,0.6)",
        boxShadow: "0 -1px 8px rgba(0,0,0,0.04)",
        display: "flex",
        alignItems: "center",
        gap: 12,
        zIndex: 10,
        fontSize: 13,
        color: "#64748b"
      },
      children: [
        /* @__PURE__ */ bt.jsx(
          "button",
          {
            onClick: c,
            style: {
              background: "none",
              border: "1px solid #e2e8f0",
              borderRadius: 8,
              width: 32,
              height: 32,
              cursor: "pointer",
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
              fontSize: 14,
              fontWeight: 500,
              color: "#64748b",
              flexShrink: 0,
              transition: "all 0.15s"
            },
            title: i ? "Pause" : "Play",
            children: i ? "⏸" : "▶"
          }
        ),
        /* @__PURE__ */ bt.jsxs(
          "span",
          {
            style: {
              minWidth: 80,
              textAlign: "center",
              fontVariantNumeric: "tabular-nums",
              fontWeight: 500,
              color: "#64748b",
              flexShrink: 0
            },
            children: [
              r + 1,
              " / ",
              t
            ]
          }
        ),
        /* @__PURE__ */ bt.jsx(
          "input",
          {
            type: "range",
            min: 0,
            max: t - 1,
            value: r,
            onChange: (d) => l(parseInt(d.target.value, 10)),
            style: {
              flex: 1,
              height: 4,
              cursor: "pointer",
              accentColor: "#3b82f6"
            }
          }
        ),
        /* @__PURE__ */ bt.jsxs(
          "select",
          {
            value: s,
            onChange: (d) => h(parseInt(d.target.value, 10)),
            style: {
              background: "rgba(255,255,255,0.8)",
              border: "1px solid #e2e8f0",
              borderRadius: 6,
              padding: "2px 6px",
              fontSize: 12,
              fontWeight: 500,
              color: "#64748b",
              cursor: "pointer",
              flexShrink: 0
            },
            children: [
              /* @__PURE__ */ bt.jsx("option", { value: 10, children: "10 fps" }),
              /* @__PURE__ */ bt.jsx("option", { value: 20, children: "20 fps" }),
              /* @__PURE__ */ bt.jsx("option", { value: 30, children: "30 fps" }),
              /* @__PURE__ */ bt.jsx("option", { value: 60, children: "60 fps" })
            ]
          }
        )
      ]
    }
  );
}
function i2({ info: r }) {
  if (!r) return null;
  const t = {
    position: "fixed",
    left: r.screenX + 14,
    top: r.screenY - 14,
    background: "rgba(15, 23, 42, 0.92)",
    backdropFilter: "blur(12px)",
    WebkitBackdropFilter: "blur(12px)",
    color: "#fff",
    padding: "8px 12px",
    borderRadius: 8,
    fontSize: 12,
    fontFamily: "system-ui, -apple-system, monospace",
    pointerEvents: "none",
    zIndex: 100,
    whiteSpace: "nowrap",
    boxShadow: "0 4px 12px rgba(0,0,0,0.2)"
  };
  return r.kind === "atom" ? /* @__PURE__ */ bt.jsxs("div", { style: t, children: [
    /* @__PURE__ */ bt.jsxs("div", { style: { fontWeight: 600 }, children: [
      r.elementSymbol,
      " (#",
      r.atomIndex,
      ")"
    ] }),
    /* @__PURE__ */ bt.jsxs("div", { style: { opacity: 0.7, fontSize: 11 }, children: [
      "(",
      r.position[0].toFixed(2),
      ", ",
      r.position[1].toFixed(2),
      ",",
      " ",
      r.position[2].toFixed(2),
      ") ",
      "Å"
    ] })
  ] }) : /* @__PURE__ */ bt.jsxs("div", { style: t, children: [
    /* @__PURE__ */ bt.jsx("div", { style: { fontWeight: 600 }, children: Np(0) ? `Atom ${r.atomA} — Atom ${r.atomB}` : `${r.atomA} — ${r.atomB}` }),
    /* @__PURE__ */ bt.jsxs("div", { style: { opacity: 0.7, fontSize: 11 }, children: [
      DR[r.bondOrder] ?? "Bond",
      " |",
      " ",
      r.bondLength.toFixed(2),
      " ",
      "Å"
    ] })
  ] });
}
const a2 = {
  distance: "Distance",
  angle: "Angle",
  dihedral: "Dihedral"
};
function s2({
  selection: r,
  measurement: t,
  elements: i,
  onClear: s
}) {
  return r.atoms.length === 0 ? null : /* @__PURE__ */ bt.jsxs(
    "div",
    {
      style: {
        position: "absolute",
        bottom: 60,
        right: 12,
        background: "rgba(255, 255, 255, 0.92)",
        backdropFilter: "blur(16px)",
        WebkitBackdropFilter: "blur(16px)",
        borderRadius: 10,
        padding: "12px 16px",
        fontSize: 13,
        color: "#1e293b",
        boxShadow: "0 4px 16px rgba(0,0,0,0.06)",
        border: "1px solid rgba(226,232,240,0.6)",
        zIndex: 15,
        minWidth: 180
      },
      children: [
        /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              display: "flex",
              justifyContent: "space-between",
              alignItems: "center",
              marginBottom: 6
            },
            children: [
              /* @__PURE__ */ bt.jsx("strong", { style: { letterSpacing: "-0.01em" }, children: "Selection" }),
              /* @__PURE__ */ bt.jsx(
                "button",
                {
                  onClick: s,
                  style: {
                    background: "none",
                    border: "none",
                    cursor: "pointer",
                    color: "#3b82f6",
                    fontSize: 12,
                    fontWeight: 500,
                    padding: "2px 4px"
                  },
                  children: "Clear"
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ bt.jsx("div", { style: { marginBottom: 6, fontSize: 12, color: "#64748b" }, children: r.atoms.map((l, c) => /* @__PURE__ */ bt.jsxs("span", { children: [
          c > 0 && " — ",
          /* @__PURE__ */ bt.jsx("strong", { children: i ? Np(i[l]) : "?" }),
          l
        ] }, l)) }),
        t && /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              padding: "6px 0",
              borderTop: "1px solid #e2e8f0",
              fontSize: 14,
              fontWeight: 600,
              color: "#3b82f6"
            },
            children: [
              a2[t.type],
              ": ",
              t.label
            ]
          }
        ),
        /* @__PURE__ */ bt.jsx("div", { style: { fontSize: 11, color: "#94a3b8", marginTop: 4 }, children: "Right-click atoms to select (max 4)" })
      ]
    }
  );
}
const r2 = 0.6, Kv = 0.4, Hr = 2;
function Sd(r, t, i, s = r2) {
  if (i < 2) return new Uint32Array(0);
  let l = 1 / 0, c = 1 / 0, h = 1 / 0, d = -1 / 0, m = -1 / 0, p = -1 / 0;
  for (let U = 0; U < i; U++) {
    const w = r[U * 3], F = r[U * 3 + 1], L = r[U * 3 + 2];
    w < l && (l = w), F < c && (c = F), L < h && (h = L), w > d && (d = w), F > m && (m = F), L > p && (p = L);
  }
  const g = Math.max(1, Math.floor((d - l) / Hr) + 1), _ = Math.max(1, Math.floor((m - c) / Hr) + 1), x = Math.max(1, Math.floor((p - h) / Hr) + 1), S = g * _ * x, E = new Array(S);
  for (let U = 0; U < S; U++) E[U] = [];
  for (let U = 0; U < i; U++) {
    const w = Math.min(Math.floor((r[U * 3] - l) / Hr), g - 1), F = Math.min(Math.floor((r[U * 3 + 1] - c) / Hr), _ - 1), L = Math.min(Math.floor((r[U * 3 + 2] - h) / Hr), x - 1);
    E[w * _ * x + F * x + L].push(U);
  }
  const b = [
    [0, 0, 1],
    [0, 1, -1],
    [0, 1, 0],
    [0, 1, 1],
    [1, -1, -1],
    [1, -1, 0],
    [1, -1, 1],
    [1, 0, -1],
    [1, 0, 0],
    [1, 0, 1],
    [1, 1, -1],
    [1, 1, 0],
    [1, 1, 1]
  ], M = Kv * Kv, v = [];
  function B(U, w) {
    const F = fp[t[U]] ?? hp, L = fp[t[w]] ?? hp, O = (F + L) * s, G = O * O, C = r[w * 3] - r[U * 3], T = r[w * 3 + 1] - r[U * 3 + 1], I = r[w * 3 + 2] - r[U * 3 + 2], J = C * C + T * T + I * I;
    if (J > M && J <= G) {
      const $ = U < w ? U : w, lt = U < w ? w : U;
      v.push($, lt);
    }
  }
  for (let U = 0; U < g; U++)
    for (let w = 0; w < _; w++)
      for (let F = 0; F < x; F++) {
        const L = U * _ * x + w * x + F, O = E[L];
        for (let G = 0; G < O.length; G++)
          for (let C = G + 1; C < O.length; C++)
            B(O[G], O[C]);
        for (const [G, C, T] of b) {
          const I = U + G, J = w + C, $ = F + T;
          if (I < 0 || I >= g || J < 0 || J >= _ || $ < 0 || $ >= x) continue;
          const lt = I * _ * x + J * x + $, pt = E[lt];
          for (const z of O)
            for (const tt of pt)
              B(z, tt);
        }
      }
  return new Uint32Array(v);
}
function o2({
  snapshot: r,
  frame: t,
  currentFrame: i,
  totalFrames: s,
  onSeek: l,
  selectedAtoms: c,
  onMeasurementChange: h
}) {
  const d = qt.useRef(null), m = qt.useRef(null), [p, g] = qt.useState(null), [_, x] = qt.useState({ atoms: [] }), [S, E] = qt.useState(null), [b, M] = qt.useState(!0), [v, B] = qt.useState(1), [U, w] = qt.useState(1), [F, L] = qt.useState(1), [O, G] = qt.useState(1), [C, T] = qt.useState(!0), [I, J] = qt.useState(!1), [$, lt] = qt.useState(!1), [pt, z] = qt.useState(30), [tt, K] = qt.useState("structure"), [yt, Mt] = qt.useState(0), P = qt.useRef("structure"), [st, xt] = qt.useState(0.6), j = qt.useRef(0.6), ht = qt.useCallback((Q) => {
    d.current = Q;
  }, []), Et = qt.useCallback(
    (Q) => {
      K(Q), P.current = Q;
      const Tt = d.current;
      if (!(!Tt || !r)) {
        if (Q === "none") {
          Tt.setBondsVisible(!1), Mt(0);
          return;
        }
        if (Tt.setBondsVisible(!0), Q === "structure")
          Tt.updateBonds(r.bonds, r.bondOrders), Mt(r.nBonds);
        else if (Q === "distance") {
          const wt = (t == null ? void 0 : t.positions) ?? r.positions, Bt = Sd(wt, r.elements, r.nAtoms, j.current);
          Tt.updateBonds(Bt, null), Mt(Bt.length / 2);
        }
      }
    },
    [r, t]
  );
  qt.useEffect(() => {
    r && tt === "structure" && Mt(r.nBonds);
  }, [r, tt]), qt.useEffect(() => {
    if (P.current !== "distance" || !r || !t) return;
    const Q = d.current;
    if (!Q) return;
    const Tt = Sd(t.positions, r.elements, r.nAtoms, j.current);
    Q.updateBonds(Tt, null), Mt(Tt.length / 2);
  }, [t, r]);
  const vt = qt.useCallback(() => {
    var Q;
    (Q = d.current) == null || Q.resetView();
  }, []), Ht = qt.useRef(h);
  Ht.current = h;
  const Lt = qt.useCallback((Q) => {
    var Tt;
    E(Q), (Tt = Ht.current) == null || Tt.call(Ht, Q);
  }, []), ae = qt.useCallback((Q) => {
    if (!d.current) return;
    const Tt = d.current.toggleAtomSelection(Q);
    x(Tt), Lt(d.current.getMeasurement());
  }, [Lt]), Ne = qt.useCallback(() => {
    var Q;
    (Q = d.current) == null || Q.clearSelection(), x({ atoms: [] }), Lt(null);
  }, [Lt]), de = qt.useCallback(() => {
    if (!d.current) return;
    const Q = d.current.getMeasurement();
    Lt(Q);
  }, [Lt]), We = qt.useRef("");
  qt.useEffect(() => {
    if (!c || !d.current) return;
    const Q = JSON.stringify(c);
    if (Q !== We.current)
      if (We.current = Q, c.length === 0)
        d.current.clearSelection(), x({ atoms: [] }), Lt(null);
      else {
        const Tt = d.current.setSelection(c);
        x(Tt), Lt(d.current.getMeasurement());
      }
  }, [c, Lt]);
  const V = qt.useCallback((Q) => {
    var Tt;
    B(Q), (Tt = d.current) == null || Tt.setAtomScale(Q);
  }, []), vn = qt.useCallback((Q) => {
    var Tt;
    w(Q), (Tt = d.current) == null || Tt.setAtomOpacity(Q);
  }, []), fe = qt.useCallback((Q) => {
    var Tt;
    L(Q), (Tt = d.current) == null || Tt.setBondScale(Q);
  }, []), pe = qt.useCallback((Q) => {
    var Tt;
    G(Q), (Tt = d.current) == null || Tt.setBondOpacity(Q);
  }, []), Yt = qt.useCallback((Q) => {
    if (xt(Q), j.current = Q, P.current !== "distance") return;
    const Tt = d.current;
    if (!Tt || !r) return;
    const wt = (t == null ? void 0 : t.positions) ?? r.positions, Bt = Sd(wt, r.elements, r.nAtoms, Q);
    Tt.updateBonds(Bt, null), Mt(Bt.length / 2);
  }, [r, t]), Ue = qt.useCallback(() => {
    T((Q) => {
      var wt;
      const Tt = !Q;
      return (wt = d.current) == null || wt.setCellAxesVisible(Tt), Tt;
    });
  }, []), Xt = qt.useCallback((Q) => {
    var Tt;
    J(Q), (Tt = d.current) == null || Tt.setPerspective(Q);
  }, []), N = qt.useCallback(() => {
    lt((Q) => Q ? (m.current && (clearInterval(m.current), m.current = null), !1) : (m.current = setInterval(() => {
      l(-1);
    }, 1e3 / pt), !0));
  }, [pt, l]), R = qt.useCallback(
    (Q) => {
      z(Q), m.current && (clearInterval(m.current), m.current = setInterval(() => {
        l(-1);
      }, 1e3 / Q));
    },
    [l]
  ), it = qt.useCallback(
    (Q) => {
      $ && (lt(!1), m.current && (clearInterval(m.current), m.current = null)), l(Q);
    },
    [l, $]
  ), dt = (r == null ? void 0 : r.box) != null && r.box.some((Q) => Q !== 0), St = {
    source: "none",
    onSourceChange: () => {
    },
    onUploadFile: () => {
    },
    fileName: null,
    hasStructureLabels: !1
  };
  return /* @__PURE__ */ bt.jsxs(
    "div",
    {
      style: {
        width: "100%",
        height: "100%",
        position: "relative",
        overflow: "hidden"
      },
      children: [
        /* @__PURE__ */ bt.jsx(
          KR,
          {
            snapshot: r,
            frame: t,
            onRendererReady: ht,
            onHover: g,
            onAtomRightClick: ae,
            onFrameUpdated: de
          }
        ),
        /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              position: "absolute",
              top: 8,
              left: 8,
              background: "rgba(255,255,255,0.88)",
              backdropFilter: "blur(8px)",
              WebkitBackdropFilter: "blur(8px)",
              borderRadius: 8,
              padding: "4px 12px",
              font: "13px system-ui, -apple-system, sans-serif",
              color: "#495057",
              zIndex: 10,
              display: "flex",
              alignItems: "center",
              gap: 8
            },
            children: [
              /* @__PURE__ */ bt.jsxs("span", { children: [
                /* @__PURE__ */ bt.jsx("strong", { children: "megane" }),
                r && /* @__PURE__ */ bt.jsxs(bt.Fragment, { children: [
                  "   ",
                  r.nAtoms.toLocaleString(),
                  " atoms /",
                  " ",
                  yt.toLocaleString(),
                  " bonds"
                ] })
              ] }),
              /* @__PURE__ */ bt.jsx(
                "button",
                {
                  onClick: vt,
                  style: {
                    background: "none",
                    border: "1px solid #e2e8f0",
                    borderRadius: 5,
                    padding: "2px 8px",
                    cursor: "pointer",
                    fontSize: 11,
                    fontWeight: 500,
                    color: "#64748b"
                  },
                  title: "Reset view",
                  children: "Reset"
                }
              )
            ]
          }
        ),
        r && /* @__PURE__ */ bt.jsxs(
          "div",
          {
            style: {
              position: "absolute",
              top: 8,
              left: "50%",
              transform: "translateX(-50%)",
              background: "rgba(255,255,255,0.88)",
              backdropFilter: "blur(8px)",
              WebkitBackdropFilter: "blur(8px)",
              borderRadius: 8,
              padding: "4px 8px",
              font: "12px system-ui, -apple-system, sans-serif",
              color: "#495057",
              zIndex: 10
            },
            children: [
              /* @__PURE__ */ bt.jsx("div", { style: { fontSize: 10, fontWeight: 600, color: "#94a3b8", marginBottom: 2 }, children: "Bonds" }),
              /* @__PURE__ */ bt.jsx(
                mp,
                {
                  options: [
                    { value: "none", label: "None" },
                    { value: "structure", label: "Structure" },
                    { value: "distance", label: "Distance" }
                  ],
                  value: tt,
                  onChange: Et
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ bt.jsx(
          e2,
          {
            atomScale: v,
            onAtomScaleChange: V,
            atomOpacity: U,
            onAtomOpacityChange: vn,
            bondScale: F,
            onBondScaleChange: fe,
            bondOpacity: O,
            onBondOpacityChange: pe,
            vdwScale: tt === "distance" ? st : void 0,
            onVdwScaleChange: tt === "distance" ? Yt : void 0,
            labels: St,
            perspective: I,
            onPerspectiveChange: Xt,
            hasCell: dt,
            cellAxesVisible: C,
            onToggleCellAxes: Ue,
            collapsed: b,
            onToggleCollapse: () => M((Q) => !Q)
          }
        ),
        s > 1 && /* @__PURE__ */ bt.jsx(
          n2,
          {
            currentFrame: i,
            totalFrames: s,
            playing: $,
            fps: pt,
            onSeek: it,
            onPlayPause: N,
            onFpsChange: R
          }
        ),
        /* @__PURE__ */ bt.jsx(i2, { info: p }),
        /* @__PURE__ */ bt.jsx(
          s2,
          {
            selection: _,
            measurement: S,
            elements: (r == null ? void 0 : r.elements) ?? null,
            onClear: Ne
          }
        )
      ]
    }
  );
}
const Qv = 1313293645, l2 = 0, c2 = 1, u2 = 1, f2 = 2;
function Jv(r) {
  const t = new DataView(r), i = t.getUint32(0, !0);
  if (i !== Qv)
    throw new Error(
      `Invalid magic: 0x${i.toString(16)}, expected 0x${Qv.toString(16)}`
    );
  return {
    msgType: t.getUint8(4),
    flags: t.getUint8(5)
  };
}
function h2(r) {
  const t = new DataView(r), i = t.getUint8(5);
  let s = 8;
  const l = t.getUint32(s, !0);
  s += 4;
  const c = t.getUint32(s, !0);
  s += 4;
  const h = new Float32Array(r, s, l * 3);
  s += l * 3 * 4;
  const d = new Uint8Array(r, s, l);
  s += l, s += (4 - s % 4) % 4;
  const m = new Uint32Array(r, s, c * 2);
  s += c * 2 * 4;
  let p = null;
  i & u2 && (p = new Uint8Array(r, s, c), s += c, s += (4 - s % 4) % 4);
  let g = null;
  return i & f2 && (g = new Float32Array(r, s, 9), s += 36), { nAtoms: l, nBonds: c, nFileBonds: c, positions: h, elements: d, bonds: m, bondOrders: p, box: g };
}
function d2(r) {
  const t = new DataView(r);
  let i = 8;
  const s = t.getUint32(i, !0);
  i += 4;
  const l = t.getUint32(i, !0);
  i += 4;
  const c = new Float32Array(r, i, l * 3);
  return { frameId: s, nAtoms: l, positions: c };
}
function p2({ model: r, el: t }) {
  const i = document.createElement("div");
  i.style.width = "100%", i.style.height = "500px", i.style.position = "relative", i.style.background = "#ffffff", i.style.borderRadius = "8px", i.style.overflow = "hidden", t.appendChild(i);
  let s = null, l = null, c = null, h = !1;
  function d() {
    const E = r.get("_snapshot_data");
    if (!E || E.byteLength === 0) return null;
    const b = new ArrayBuffer(E.byteLength);
    new Uint8Array(b).set(
      new Uint8Array(E.buffer, E.byteOffset, E.byteLength)
    );
    const { msgType: M } = Jv(b);
    return M === l2 ? h2(b) : null;
  }
  function m() {
    const E = r.get("_frame_data");
    if (!E || E.byteLength === 0) return null;
    const b = new ArrayBuffer(E.byteLength);
    new Uint8Array(b).set(
      new Uint8Array(E.buffer, E.byteOffset, E.byteLength)
    );
    const { msgType: M } = Jv(b);
    return M === c2 ? d2(b) : null;
  }
  function p(E) {
    const b = r.get("total_frames") || 0;
    if (E === -1) {
      const v = ((r.get("frame_index") || 0) + 1) % b;
      r.set("frame_index", v);
    } else
      r.set("frame_index", E);
    r.save_changes();
  }
  function g(E) {
    const b = E ? JSON.stringify(E) : "";
    r.set("_measurement_json", b), r.save_changes();
  }
  function _() {
    if (!s || h) return;
    const E = r.get("frame_index") || 0, b = r.get("total_frames") || 0, M = r.get("selected_atoms") || [];
    s.render(
      qt.createElement(o2, {
        snapshot: l,
        frame: c,
        currentFrame: E,
        totalFrames: b,
        onSeek: p,
        selectedAtoms: M,
        onMeasurementChange: g
      })
    );
  }
  function x() {
    return s || h ? !!s : i.clientWidth === 0 || i.clientHeight === 0 ? !1 : (s = qS.createRoot(i), l = d(), c = m(), _(), !0);
  }
  const S = new ResizeObserver(() => {
    !s && !h && x();
  });
  return S.observe(i), x(), r.on("change:_snapshot_data", () => {
    l = d(), s ? _() : x();
  }), r.on("change:_frame_data", () => {
    c = m(), _();
  }), r.on("change:frame_index", () => {
    _();
  }), r.on("change:total_frames", () => {
    _();
  }), r.on("change:selected_atoms", () => {
    _();
  }), () => {
    h = !0, S.disconnect(), s == null || s.unmount(), s = null;
  };
}
const g2 = { render: p2 };
export {
  g2 as default
};
