/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var V5 = function(e, t) {
  return V5 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
    r.__proto__ = n;
  } || function(r, n) {
    for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (r[a] = n[a]);
  }, V5(e, t);
};
function Ii(e, t) {
  if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
  function r() {
    this.constructor = e;
  }
  V5(e, t), e.prototype = t === null ? Object.create(t) : (r.prototype = t.prototype, new r());
}
var k = function() {
  return k = Object.assign || function(e) {
    for (var t, r = 1, n = arguments.length; r < n; r++) for (var a in t = arguments[r]) Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
    return e;
  }, k.apply(this, arguments);
};
function Be(e, t, r, n) {
  return new (r || (r = Promise))(function(a, i) {
    function o(c) {
      try {
        u(n.next(c));
      } catch (l) {
        i(l);
      }
    }
    function s(c) {
      try {
        u(n.throw(c));
      } catch (l) {
        i(l);
      }
    }
    function u(c) {
      var l;
      c.done ? a(c.value) : (l = c.value, l instanceof r ? l : new r(function(d) {
        d(l);
      })).then(o, s);
    }
    u((n = n.apply(e, [])).next());
  });
}
function Te(e, t) {
  var r, n, a, i, o = { label: 0, sent: function() {
    if (1 & a[0]) throw a[1];
    return a[1];
  }, trys: [], ops: [] };
  return i = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
    return this;
  }), i;
  function s(u) {
    return function(c) {
      return function(l) {
        if (r) throw new TypeError("Generator is already executing.");
        for (; o; ) try {
          if (r = 1, n && (a = 2 & l[0] ? n.return : l[0] ? n.throw || ((a = n.return) && a.call(n), 0) : n.next) && !(a = a.call(n, l[1])).done) return a;
          switch (n = 0, a && (l = [2 & l[0], a.value]), l[0]) {
            case 0:
            case 1:
              a = l;
              break;
            case 4:
              return o.label++, { value: l[1], done: !1 };
            case 5:
              o.label++, n = l[1], l = [0];
              continue;
            case 7:
              l = o.ops.pop(), o.trys.pop();
              continue;
            default:
              if (a = o.trys, !((a = a.length > 0 && a[a.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
                o = 0;
                continue;
              }
              if (l[0] === 3 && (!a || l[1] > a[0] && l[1] < a[3])) {
                o.label = l[1];
                break;
              }
              if (l[0] === 6 && o.label < a[1]) {
                o.label = a[1], a = l;
                break;
              }
              if (a && o.label < a[2]) {
                o.label = a[2], o.ops.push(l);
                break;
              }
              a[2] && o.ops.pop(), o.trys.pop();
              continue;
          }
          l = t.call(e, o);
        } catch (d) {
          l = [6, d], n = 0;
        } finally {
          r = a = 0;
        }
        if (5 & l[0]) throw l[1];
        return { value: l[0] ? l[1] : void 0, done: !0 };
      }([u, c]);
    };
  }
}
function q5(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, r = t && e[t], n = 0;
  if (r) return r.call(e);
  if (e && typeof e.length == "number") return { next: function() {
    return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
  } };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function k2(e, t) {
  var r = typeof Symbol == "function" && e[Symbol.iterator];
  if (!r) return e;
  var n, a, i = r.call(e), o = [];
  try {
    for (; (t === void 0 || t-- > 0) && !(n = i.next()).done; ) o.push(n.value);
  } catch (s) {
    a = { error: s };
  } finally {
    try {
      n && !n.done && (r = i.return) && r.call(i);
    } finally {
      if (a) throw a.error;
    }
  }
  return o;
}
function nt(e, t, r) {
  if (r || arguments.length === 2) for (var n, a = 0, i = t.length; a < i; a++) !n && a in t || (n || (n = Array.prototype.slice.call(t, 0, a)), n[a] = t[a]);
  return e.concat(n || Array.prototype.slice.call(t));
}
function tl(e) {
  return typeof e == "function";
}
function xO(e) {
  var t = e(function(r) {
    Error.call(r), r.stack = new Error().stack;
  });
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
var p4 = xO(function(e) {
  return function(t) {
    e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
` + t.map(function(r, n) {
      return n + 1 + ") " + r.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = t;
  };
});
function H5(e, t) {
  if (e) {
    var r = e.indexOf(t);
    0 <= r && e.splice(r, 1);
  }
}
var i3 = function() {
  function e(r) {
    this.initialTeardown = r, this.closed = !1, this._parentage = null, this._teardowns = null;
  }
  var t;
  return e.prototype.unsubscribe = function() {
    var r, n, a, i, o;
    if (!this.closed) {
      this.closed = !0;
      var s = this._parentage;
      if (s) if (this._parentage = null, Array.isArray(s)) try {
        for (var u = q5(s), c = u.next(); !c.done; c = u.next())
          c.value.remove(this);
      } catch (p) {
        r = { error: p };
      } finally {
        try {
          c && !c.done && (n = u.return) && n.call(u);
        } finally {
          if (r) throw r.error;
        }
      }
      else s.remove(this);
      var l = this.initialTeardown;
      if (tl(l)) try {
        l();
      } catch (p) {
        o = p instanceof p4 ? p.errors : [p];
      }
      var d = this._teardowns;
      if (d) {
        this._teardowns = null;
        try {
          for (var f = q5(d), m = f.next(); !m.done; m = f.next()) {
            var h = m.value;
            try {
              ww(h);
            } catch (p) {
              o = o ?? [], p instanceof p4 ? o = nt(nt([], k2(o)), k2(p.errors)) : o.push(p);
            }
          }
        } catch (p) {
          a = { error: p };
        } finally {
          try {
            m && !m.done && (i = f.return) && i.call(f);
          } finally {
            if (a) throw a.error;
          }
        }
      }
      if (o) throw new p4(o);
    }
  }, e.prototype.add = function(r) {
    var n;
    if (r && r !== this) if (this.closed) ww(r);
    else {
      if (r instanceof e) {
        if (r.closed || r._hasParent(this)) return;
        r._addParent(this);
      }
      (this._teardowns = (n = this._teardowns) !== null && n !== void 0 ? n : []).push(r);
    }
  }, e.prototype._hasParent = function(r) {
    var n = this._parentage;
    return n === r || Array.isArray(n) && n.includes(r);
  }, e.prototype._addParent = function(r) {
    var n = this._parentage;
    this._parentage = Array.isArray(n) ? (n.push(r), n) : n ? [n, r] : r;
  }, e.prototype._removeParent = function(r) {
    var n = this._parentage;
    n === r ? this._parentage = null : Array.isArray(n) && H5(n, r);
  }, e.prototype.remove = function(r) {
    var n = this._teardowns;
    n && H5(n, r), r instanceof e && r._removeParent(this);
  }, e.EMPTY = ((t = new e()).closed = !0, t), e;
}(), _O = i3.EMPTY;
function SO(e) {
  return e instanceof i3 || e && "closed" in e && tl(e.remove) && tl(e.add) && tl(e.unsubscribe);
}
function ww(e) {
  tl(e) ? e() : e.unsubscribe();
}
var AO = { onUnhandledError: null, onStoppedNotification: null, Promise: void 0, useDeprecatedSynchronousErrorHandling: !1, useDeprecatedNextContext: !1 }, BZ = { setTimeout: function() {
  for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
  return setTimeout.apply(void 0, nt([], k2(e)));
}, clearTimeout: function(e) {
  return clearTimeout(e);
}, delegate: void 0 };
function z2() {
}
function _2(e) {
  e();
}
var wO = function(e) {
  function t(r) {
    var n = e.call(this) || this;
    return n.isStopped = !1, r ? (n.destination = r, SO(r) && r.add(n)) : n.destination = OZ, n;
  }
  return Ii(t, e), t.create = function(r, n, a) {
    return new K5(r, n, a);
  }, t.prototype.next = function(r) {
    this.isStopped || this._next(r);
  }, t.prototype.error = function(r) {
    this.isStopped || (this.isStopped = !0, this._error(r));
  }, t.prototype.complete = function() {
    this.isStopped || (this.isStopped = !0, this._complete());
  }, t.prototype.unsubscribe = function() {
    this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
  }, t.prototype._next = function(r) {
    this.destination.next(r);
  }, t.prototype._error = function(r) {
    try {
      this.destination.error(r);
    } finally {
      this.unsubscribe();
    }
  }, t.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, t;
}(i3), K5 = function(e) {
  function t(r, n, a) {
    var i, o = e.call(this) || this;
    if (tl(r)) i = r;
    else if (r) {
      var s;
      i = r.next, n = r.error, a = r.complete, o && AO.useDeprecatedNextContext ? (s = Object.create(r)).unsubscribe = function() {
        return o.unsubscribe();
      } : s = r, i = i == null ? void 0 : i.bind(s), n = n == null ? void 0 : n.bind(s), a = a == null ? void 0 : a.bind(s);
    }
    return o.destination = { next: i ? h4(i) : z2, error: h4(n ?? CO), complete: a ? h4(a) : z2 }, o;
  }
  return Ii(t, e), t;
}(wO);
function h4(e, t) {
  return function() {
    for (var r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    try {
      e.apply(void 0, nt([], k2(r)));
    } catch (a) {
      (function(i) {
        BZ.setTimeout(function() {
          throw i;
        });
      })(a);
    }
  };
}
function CO(e) {
  throw e;
}
var OZ = { closed: !0, next: z2, error: CO, complete: z2 }, FZ = typeof Symbol == "function" && Symbol.observable || "@@observable";
function RZ(e) {
  return e;
}
var Cw = function() {
  function e(t) {
    t && (this._subscribe = t);
  }
  return e.prototype.lift = function(t) {
    var r = new e();
    return r.source = this, r.operator = t, r;
  }, e.prototype.subscribe = function(t, r, n) {
    var a, i = this, o = (a = t) && a instanceof wO || function(s) {
      return s && tl(s.next) && tl(s.error) && tl(s.complete);
    }(a) && SO(a) ? t : new K5(t, r, n);
    return _2(function() {
      var s = i, u = s.operator, c = s.source;
      o.add(u ? u.call(o, c) : c ? i._subscribe(o) : i._trySubscribe(o));
    }), o;
  }, e.prototype._trySubscribe = function(t) {
    try {
      return this._subscribe(t);
    } catch (r) {
      t.error(r);
    }
  }, e.prototype.forEach = function(t, r) {
    var n = this;
    return new (r = Ew(r))(function(a, i) {
      var o = new K5({ next: function(s) {
        try {
          t(s);
        } catch (u) {
          i(u), o.unsubscribe();
        }
      }, error: i, complete: a });
      n.subscribe(o);
    });
  }, e.prototype._subscribe = function(t) {
    var r;
    return (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t);
  }, e.prototype[FZ] = function() {
    return this;
  }, e.prototype.pipe = function() {
    for (var t, r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    return ((t = r).length === 0 ? RZ : t.length === 1 ? t[0] : function(a) {
      return t.reduce(function(i, o) {
        return o(i);
      }, a);
    })(this);
  }, e.prototype.toPromise = function(t) {
    var r = this;
    return new (t = Ew(t))(function(n, a) {
      var i;
      r.subscribe(function(o) {
        return i = o;
      }, function(o) {
        return a(o);
      }, function() {
        return n(i);
      });
    });
  }, e.create = function(t) {
    return new e(t);
  }, e;
}();
function Ew(e) {
  var t;
  return (t = e ?? AO.Promise) !== null && t !== void 0 ? t : Promise;
}
var LZ = xO(function(e) {
  return function() {
    e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
}), pa = function(e) {
  function t() {
    var r = e.call(this) || this;
    return r.closed = !1, r.observers = [], r.isStopped = !1, r.hasError = !1, r.thrownError = null, r;
  }
  return Ii(t, e), t.prototype.lift = function(r) {
    var n = new Dw(this, this);
    return n.operator = r, n;
  }, t.prototype._throwIfClosed = function() {
    if (this.closed) throw new LZ();
  }, t.prototype.next = function(r) {
    var n = this;
    _2(function() {
      var a, i;
      if (n._throwIfClosed(), !n.isStopped) {
        var o = n.observers.slice();
        try {
          for (var s = q5(o), u = s.next(); !u.done; u = s.next())
            u.value.next(r);
        } catch (c) {
          a = { error: c };
        } finally {
          try {
            u && !u.done && (i = s.return) && i.call(s);
          } finally {
            if (a) throw a.error;
          }
        }
      }
    });
  }, t.prototype.error = function(r) {
    var n = this;
    _2(function() {
      if (n._throwIfClosed(), !n.isStopped) {
        n.hasError = n.isStopped = !0, n.thrownError = r;
        for (var a = n.observers; a.length; ) a.shift().error(r);
      }
    });
  }, t.prototype.complete = function() {
    var r = this;
    _2(function() {
      if (r._throwIfClosed(), !r.isStopped) {
        r.isStopped = !0;
        for (var n = r.observers; n.length; ) n.shift().complete();
      }
    });
  }, t.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = null;
  }, Object.defineProperty(t.prototype, "observed", { get: function() {
    var r;
    return ((r = this.observers) === null || r === void 0 ? void 0 : r.length) > 0;
  }, enumerable: !1, configurable: !0 }), t.prototype._trySubscribe = function(r) {
    return this._throwIfClosed(), e.prototype._trySubscribe.call(this, r);
  }, t.prototype._subscribe = function(r) {
    return this._throwIfClosed(), this._checkFinalizedStatuses(r), this._innerSubscribe(r);
  }, t.prototype._innerSubscribe = function(r) {
    var n = this, a = n.hasError, i = n.isStopped, o = n.observers;
    return a || i ? _O : (o.push(r), new i3(function() {
      return H5(o, r);
    }));
  }, t.prototype._checkFinalizedStatuses = function(r) {
    var n = this, a = n.hasError, i = n.thrownError, o = n.isStopped;
    a ? r.error(i) : o && r.complete();
  }, t.prototype.asObservable = function() {
    var r = new Cw();
    return r.source = this, r;
  }, t.create = function(r, n) {
    return new Dw(r, n);
  }, t;
}(Cw), Dw = function(e) {
  function t(r, n) {
    var a = e.call(this) || this;
    return a.destination = r, a.source = n, a;
  }
  return Ii(t, e), t.prototype.next = function(r) {
    var n, a;
    (a = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || a === void 0 || a.call(n, r);
  }, t.prototype.error = function(r) {
    var n, a;
    (a = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || a === void 0 || a.call(n, r);
  }, t.prototype.complete = function() {
    var r, n;
    (n = (r = this.destination) === null || r === void 0 ? void 0 : r.complete) === null || n === void 0 || n.call(r);
  }, t.prototype._subscribe = function(r) {
    var n, a;
    return (a = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(r)) !== null && a !== void 0 ? a : _O;
  }, t;
}(pa), xd = function(e) {
  function t(r) {
    var n = e.call(this) || this;
    return n._value = r, n;
  }
  return Ii(t, e), Object.defineProperty(t.prototype, "value", { get: function() {
    return this.getValue();
  }, enumerable: !1, configurable: !0 }), t.prototype._subscribe = function(r) {
    var n = e.prototype._subscribe.call(this, r);
    return !n.closed && r.next(this._value), n;
  }, t.prototype.getValue = function() {
    var r = this, n = r.hasError, a = r.thrownError, i = r._value;
    if (n) throw a;
    return this._throwIfClosed(), i;
  }, t.prototype.next = function(r) {
    e.prototype.next.call(this, this._value = r);
  }, t;
}(pa), ga = function() {
  if (typeof window < "u" && window.performance) {
    var e = window.performance;
    return function() {
      return e.now();
    };
  }
  return typeof process < "u" && process.hrtime !== "undefined" && typeof process.hrtime == "function" ? function() {
    var t = process.hrtime();
    return 1e3 * t[0] + t[1] / 1e6;
  } : Date.now ? function() {
    return Date.now();
  } : function() {
    return +/* @__PURE__ */ new Date();
  };
}(), Cn = 1e-6;
function Yn(e, t, r) {
  return Math.abs(e - t) <= r;
}
var Wn, Ti, Rr, Fa, Mw, V0, Iw = Math.PI / 2, EO = Math.PI / 180;
function Kn(e) {
  return e * EO;
}
function Bi(e) {
  return e / EO;
}
function DO(e, t) {
  return e * t;
}
function Ee() {
  return Ee.zero();
}
function po(e, t, r) {
  return Math.max(t, Math.min(r, e));
}
function Na(e, t, r) {
  return e + (t - e) * r;
}
function S2(e, t, r, n, a, i) {
  var o = (r - e) * i, s = (n - t) * i, u = a * a;
  return (2 * t - 2 * r + o + s) * (a * u) + (-3 * t + 3 * r - 2 * o - s) * u + o * a + t;
}
function v4(e, t, r, n) {
  var a = 1 - n;
  return a * a * e + 2 * a * n * t + n * n * r;
}
function MO(e, t, r) {
  var n;
  return n = function(a, i, o) {
    return (a - i) / (o - i);
  }(r, e, t), (r = po(n, 0, 1)) * r * (3 - 2 * r);
}
function D() {
  return D.zero();
}
function ka() {
  return ka.zero();
}
function Ze() {
  return Ze.zero();
}
function jt() {
  return jt.zero();
}
function Gn() {
  return Gn.zero();
}
function kZ(e, t) {
  return e - t;
}
function $i(e, t) {
  e === void 0 && (e = 0), t === void 0 && (t = Number.MAX_SAFE_INTEGER);
  var r = e;
  return function() {
    var n = r;
    return r = (r + 1) % t, n;
  };
}
(function(e) {
  function t() {
    var p = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return p[0] = 0, p;
  }
  function r() {
    var p = t();
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function n(p) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function a(p) {
    for (var g = 0; g < 16; g++) p[g] = 0;
    return p;
  }
  e.zero = t, e.identity = r, e.setIdentity = n, e.setZero = a, e.ofRows = function(p) {
    for (var g = t(), v = 0; v < 4; v++) for (var y = p[v], _ = 0; _ < 4; _++) g[4 * _ + v] = y[_];
    return g;
  };
  var i = r();
  function o(p, g, v) {
    for (var y = 0; y < 16; y++) if (Math.abs(p[y] - g[y]) > v) return !1;
    return !0;
  }
  function s(p, g, v, y) {
    p[4 * v + g] = y;
  }
  function u(p, g) {
    return p[0] = g[0], p[1] = g[1], p[2] = g[2], p[3] = g[3], p[4] = g[4], p[5] = g[5], p[6] = g[6], p[7] = g[7], p[8] = g[8], p[9] = g[9], p[10] = g[10], p[11] = g[11], p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }
  function c(p, g) {
    var v = g[0], y = g[1], _ = g[2], S = g[3], b = g[4], x = g[5], A = g[6], w = g[7], C = g[8], M = g[9], T = g[10], N = g[11], I = g[12], P = g[13], O = g[14], F = g[15], R = v * x - y * b, G = v * A - _ * b, L = v * w - S * b, q = y * A - _ * x, K = y * w - S * x, X = _ * w - S * A, H = C * P - M * I, W = C * O - T * I, ee = C * F - N * I, $ = M * O - T * P, te = M * F - N * P, re = T * F - N * O, ie = R * re - G * te + L * $ + q * ee - K * W + X * H;
    return !!ie && (ie = 1 / ie, p[0] = (x * re - A * te + w * $) * ie, p[1] = (_ * te - y * re - S * $) * ie, p[2] = (P * X - O * K + F * q) * ie, p[3] = (T * K - M * X - N * q) * ie, p[4] = (A * ee - b * re - w * W) * ie, p[5] = (v * re - _ * ee + S * W) * ie, p[6] = (O * L - I * X - F * G) * ie, p[7] = (C * X - T * L + N * G) * ie, p[8] = (b * te - x * ee + w * H) * ie, p[9] = (y * ee - v * te - S * H) * ie, p[10] = (I * K - P * L + F * R) * ie, p[11] = (M * L - C * K - N * R) * ie, p[12] = (x * W - b * $ - A * H) * ie, p[13] = (v * $ - y * W + _ * H) * ie, p[14] = (P * G - I * q - O * R) * ie, p[15] = (C * q - M * G + T * R) * ie, !0);
  }
  function l(p, g, v) {
    var y = g[0], _ = g[1], S = g[2], b = g[3], x = g[4], A = g[5], w = g[6], C = g[7], M = g[8], T = g[9], N = g[10], I = g[11], P = g[12], O = g[13], F = g[14], R = g[15], G = v[0], L = v[1], q = v[2], K = v[3];
    return p[0] = G * y + L * x + q * M + K * P, p[1] = G * _ + L * A + q * T + K * O, p[2] = G * S + L * w + q * N + K * F, p[3] = G * b + L * C + q * I + K * R, G = v[4], L = v[5], q = v[6], K = v[7], p[4] = G * y + L * x + q * M + K * P, p[5] = G * _ + L * A + q * T + K * O, p[6] = G * S + L * w + q * N + K * F, p[7] = G * b + L * C + q * I + K * R, G = v[8], L = v[9], q = v[10], K = v[11], p[8] = G * y + L * x + q * M + K * P, p[9] = G * _ + L * A + q * T + K * O, p[10] = G * S + L * w + q * N + K * F, p[11] = G * b + L * C + q * I + K * R, G = v[12], L = v[13], q = v[14], K = v[15], p[12] = G * y + L * x + q * M + K * P, p[13] = G * _ + L * A + q * T + K * O, p[14] = G * S + L * w + q * N + K * F, p[15] = G * b + L * C + q * I + K * R, p;
  }
  function d(p, g, v) {
    var y = v[0], _ = v[1], S = v[2], b = Math.sqrt(y * y + _ * _ + S * S);
    if (Math.abs(b) < Cn) return n(p);
    y *= b = 1 / b, _ *= b, S *= b;
    var x = Math.sin(g), A = Math.cos(g), w = 1 - A;
    return p[0] = y * y * w + A, p[1] = _ * y * w + S * x, p[2] = S * y * w - _ * x, p[3] = 0, p[4] = y * _ * w - S * x, p[5] = _ * _ * w + A, p[6] = S * _ * w + y * x, p[7] = 0, p[8] = y * S * w + _ * x, p[9] = _ * S * w - y * x, p[10] = S * S * w + A, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  e.isIdentity = function(p, g) {
    return o(p, i, g === void 0 ? Cn : g);
  }, e.hasNaN = function(p) {
    for (var g = 0; g < 16; g++) if (isNaN(p[g])) return !0;
    return !1;
  }, e.areEqual = o, e.setValue = s, e.getValue = function(p, g, v) {
    return p[4 * v + g];
  }, e.toArray = function(p, g, v) {
    return g[v + 0] = p[0], g[v + 1] = p[1], g[v + 2] = p[2], g[v + 3] = p[3], g[v + 4] = p[4], g[v + 5] = p[5], g[v + 6] = p[6], g[v + 7] = p[7], g[v + 8] = p[8], g[v + 9] = p[9], g[v + 10] = p[10], g[v + 11] = p[11], g[v + 12] = p[12], g[v + 13] = p[13], g[v + 14] = p[14], g[v + 15] = p[15], g;
  }, e.fromArray = function(p, g, v) {
    return p[0] = g[v + 0], p[1] = g[v + 1], p[2] = g[v + 2], p[3] = g[v + 3], p[4] = g[v + 4], p[5] = g[v + 5], p[6] = g[v + 6], p[7] = g[v + 7], p[8] = g[v + 8], p[9] = g[v + 9], p[10] = g[v + 10], p[11] = g[v + 11], p[12] = g[v + 12], p[13] = g[v + 13], p[14] = g[v + 14], p[15] = g[v + 15], p;
  }, e.fromBasis = function(p, g, v, y) {
    return a(p), s(p, 0, 0, g[0]), s(p, 1, 0, g[1]), s(p, 2, 0, g[2]), s(p, 0, 1, v[0]), s(p, 1, 1, v[1]), s(p, 2, 1, v[2]), s(p, 0, 2, y[0]), s(p, 1, 2, y[1]), s(p, 2, 2, y[2]), s(p, 3, 3, 1), p;
  }, e.copy = u, e.clone = function(p) {
    return u(t(), p);
  }, e.getTranslation = function(p, g) {
    return p[0] = g[12], p[1] = g[13], p[2] = g[14], p;
  }, e.getScaling = function(p, g) {
    var v = g[0], y = g[1], _ = g[2], S = g[4], b = g[5], x = g[6], A = g[8], w = g[9], C = g[10];
    return p[0] = Math.sqrt(v * v + y * y + _ * _), p[1] = Math.sqrt(S * S + b * b + x * x), p[2] = Math.sqrt(A * A + w * w + C * C), p;
  }, e.getRotation = function(p, g) {
    var v = g[0] + g[5] + g[10], y = 0;
    return v > 0 ? (y = 2 * Math.sqrt(v + 1), p[3] = 0.25 * y, p[0] = (g[6] - g[9]) / y, p[1] = (g[8] - g[2]) / y, p[2] = (g[1] - g[4]) / y) : g[0] > g[5] && g[0] > g[10] ? (y = 2 * Math.sqrt(1 + g[0] - g[5] - g[10]), p[3] = (g[6] - g[9]) / y, p[0] = 0.25 * y, p[1] = (g[1] + g[4]) / y, p[2] = (g[8] + g[2]) / y) : g[5] > g[10] ? (y = 2 * Math.sqrt(1 + g[5] - g[0] - g[10]), p[3] = (g[8] - g[2]) / y, p[0] = (g[1] + g[4]) / y, p[1] = 0.25 * y, p[2] = (g[6] + g[9]) / y) : (y = 2 * Math.sqrt(1 + g[10] - g[0] - g[5]), p[3] = (g[1] - g[4]) / y, p[0] = (g[8] + g[2]) / y, p[1] = (g[6] + g[9]) / y, p[2] = 0.25 * y), p;
  }, e.extractRotation = function(p, g) {
    var v = 1 / Math.sqrt(g[0] * g[0] + g[1] * g[1] + g[2] * g[2]), y = 1 / Math.sqrt(g[4] * g[4] + g[5] * g[5] + g[6] * g[6]), _ = 1 / Math.sqrt(g[8] * g[8] + g[9] * g[9] + g[10] * g[10]);
    return p[0] = g[0] * v, p[1] = g[1] * v, p[2] = g[2] * v, p[3] = 0, p[4] = g[4] * y, p[5] = g[5] * y, p[6] = g[6] * y, p[7] = 0, p[8] = g[8] * _, p[9] = g[9] * _, p[10] = g[10] * _, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.transpose = function(p, g) {
    if (p === g) {
      var v = g[1], y = g[2], _ = g[3], S = g[6], b = g[7], x = g[11];
      p[1] = g[4], p[2] = g[8], p[3] = g[12], p[4] = v, p[6] = g[9], p[7] = g[13], p[8] = y, p[9] = S, p[11] = g[14], p[12] = _, p[13] = b, p[14] = x;
    } else p[0] = g[0], p[1] = g[4], p[2] = g[8], p[3] = g[12], p[4] = g[1], p[5] = g[5], p[6] = g[9], p[7] = g[13], p[8] = g[2], p[9] = g[6], p[10] = g[10], p[11] = g[14], p[12] = g[3], p[13] = g[7], p[14] = g[11], p[15] = g[15];
    return p;
  }, e.tryInvert = c, e.invert = function(p, g) {
    return c(p, g) || console.warn("non-invertible matrix.", g), p;
  }, e.mul = l, e.mulOffset = function(p, g, v, y, _, S) {
    var b = g[0 + _], x = g[1 + _], A = g[2 + _], w = g[3 + _], C = g[4 + _], M = g[5 + _], T = g[6 + _], N = g[7 + _], I = g[8 + _], P = g[9 + _], O = g[10 + _], F = g[11 + _], R = g[12 + _], G = g[13 + _], L = g[14 + _], q = g[15 + _], K = v[0 + S], X = v[1 + S], H = v[2 + S], W = v[3 + S];
    return p[0 + y] = K * b + X * C + H * I + W * R, p[1 + y] = K * x + X * M + H * P + W * G, p[2 + y] = K * A + X * T + H * O + W * L, p[3 + y] = K * w + X * N + H * F + W * q, K = v[4 + S], X = v[5 + S], H = v[6 + S], W = v[7 + S], p[4 + y] = K * b + X * C + H * I + W * R, p[5 + y] = K * x + X * M + H * P + W * G, p[6 + y] = K * A + X * T + H * O + W * L, p[7 + y] = K * w + X * N + H * F + W * q, K = v[8 + S], X = v[9 + S], H = v[10 + S], W = v[11 + S], p[8 + y] = K * b + X * C + H * I + W * R, p[9 + y] = K * x + X * M + H * P + W * G, p[10 + y] = K * A + X * T + H * O + W * L, p[11 + y] = K * w + X * N + H * F + W * q, K = v[12 + S], X = v[13 + S], H = v[14 + S], W = v[15 + S], p[12 + y] = K * b + X * C + H * I + W * R, p[13 + y] = K * x + X * M + H * P + W * G, p[14 + y] = K * A + X * T + H * O + W * L, p[15 + y] = K * w + X * N + H * F + W * q, p;
  }, e.mul3 = function(p, g, v, y) {
    return l(p, l(p, g, v), y);
  }, e.translate = function(p, g, v) {
    var y, _, S, b, x, A, w, C, M, T, N, I, P = v[0], O = v[1], F = v[2];
    return g === p ? (p[12] = g[0] * P + g[4] * O + g[8] * F + g[12], p[13] = g[1] * P + g[5] * O + g[9] * F + g[13], p[14] = g[2] * P + g[6] * O + g[10] * F + g[14], p[15] = g[3] * P + g[7] * O + g[11] * F + g[15]) : (y = g[0], _ = g[1], S = g[2], b = g[3], x = g[4], A = g[5], w = g[6], C = g[7], M = g[8], T = g[9], N = g[10], I = g[11], p[0] = y, p[1] = _, p[2] = S, p[3] = b, p[4] = x, p[5] = A, p[6] = w, p[7] = C, p[8] = M, p[9] = T, p[10] = N, p[11] = I, p[12] = y * P + x * O + M * F + g[12], p[13] = _ * P + A * O + T * F + g[13], p[14] = S * P + w * O + N * F + g[14], p[15] = b * P + C * O + I * F + g[15]), p;
  }, e.fromTranslation = function(p, g) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = g[0], p[13] = g[1], p[14] = g[2], p[15] = 1, p;
  }, e.setTranslation = function(p, g) {
    return p[12] = g[0], p[13] = g[1], p[14] = g[2], p;
  }, e.setAxes = function(p, g, v, y) {
    return p[0] = v[0], p[4] = v[1], p[8] = v[2], p[1] = y[0], p[5] = y[1], p[9] = y[2], p[2] = g[0], p[6] = g[1], p[10] = g[2], p;
  }, e.rotate = function(p, g, v, y) {
    var _ = y[0], S = y[1], b = y[2], x = Math.sqrt(_ * _ + S * S + b * b);
    if (Math.abs(x) < Cn) return r();
    _ *= x = 1 / x, S *= x, b *= x;
    var A = Math.sin(v), w = Math.cos(v), C = 1 - w, M = g[0], T = g[1], N = g[2], I = g[3], P = g[4], O = g[5], F = g[6], R = g[7], G = g[8], L = g[9], q = g[10], K = g[11], X = _ * _ * C + w, H = S * _ * C + b * A, W = b * _ * C - S * A, ee = _ * S * C - b * A, $ = S * S * C + w, te = b * S * C + _ * A, re = _ * b * C + S * A, ie = S * b * C - _ * A, oe = b * b * C + w;
    return p[0] = M * X + P * H + G * W, p[1] = T * X + O * H + L * W, p[2] = N * X + F * H + q * W, p[3] = I * X + R * H + K * W, p[4] = M * ee + P * $ + G * te, p[5] = T * ee + O * $ + L * te, p[6] = N * ee + F * $ + q * te, p[7] = I * ee + R * $ + K * te, p[8] = M * re + P * ie + G * oe, p[9] = T * re + O * ie + L * oe, p[10] = N * re + F * ie + q * oe, p[11] = I * re + R * ie + K * oe, g !== p && (p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15]), p;
  }, e.fromRotation = d, e.scale = function(p, g, v) {
    var y = v[0], _ = v[1], S = v[2];
    return p[0] = g[0] * y, p[1] = g[1] * y, p[2] = g[2] * y, p[3] = g[3] * y, p[4] = g[4] * _, p[5] = g[5] * _, p[6] = g[6] * _, p[7] = g[7] * _, p[8] = g[8] * S, p[9] = g[9] * S, p[10] = g[10] * S, p[11] = g[11] * S, p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }, e.scaleUniformly = function(p, g, v) {
    return p[0] = g[0] * v, p[1] = g[1] * v, p[2] = g[2] * v, p[3] = g[3] * v, p[4] = g[4] * v, p[5] = g[5] * v, p[6] = g[6] * v, p[7] = g[7] * v, p[8] = g[8] * v, p[9] = g[9] * v, p[10] = g[10] * v, p[11] = g[11] * v, p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }, e.fromScaling = function(p, g) {
    return p[0] = g[0], p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = g[1], p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = g[2], p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.fromUniformScaling = function(p, g) {
    return p[0] = g, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = g, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = g, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.fromMat3 = function(p, g) {
    return p[0] = g[0], p[1] = g[1], p[2] = g[2], p[4] = g[3], p[5] = g[4], p[6] = g[5], p[8] = g[6], p[9] = g[7], p[10] = g[8], p;
  }, e.makeTable = function(p) {
    for (var g = "", v = 0; v < 4; v++) {
      for (var y = 0; y < 4; y++) g += p[4 * y + v].toString(), y < 3 && (g += " ");
      v < 3 && (g += `
`);
    }
    return g;
  }, e.determinant = function(p) {
    var g = p[0], v = p[1], y = p[2], _ = p[3], S = p[4], b = p[5], x = p[6], A = p[7], w = p[8], C = p[9], M = p[10], T = p[11], N = p[12], I = p[13], P = p[14], O = p[15];
    return (g * b - v * S) * (M * O - T * P) - (g * x - y * S) * (C * O - T * I) + (g * A - _ * S) * (C * P - M * I) + (v * x - y * b) * (w * O - T * N) - (v * A - _ * b) * (w * P - M * N) + (y * A - _ * x) * (w * I - C * N);
  }, e.isRotationAndTranslation = function(p, g) {
    return function(v, y) {
      var _ = v[0], S = v[1], b = v[2], x = v[3], A = v[4], w = v[5], C = v[6], M = v[7], T = v[8], N = v[9], I = v[10], P = v[11], O = v[15];
      return !(!(Yn(O, 1, y) && Yn(x, 0, y) && Yn(M, 0, y) && Yn(P, 0, y)) || !Yn(Math.abs(_ * (w * I - C * N) - S * (A * I - C * T) + b * (A * N - w * T)), 1, y));
    }(p, g !== void 0 ? g : Cn);
  }, e.isTranslationAndUniformScaling = function(p, g) {
    return function(v, y) {
      var _ = v[0];
      return Yn(v[1], 0, y) && Yn(v[2], 0, y) && Yn(v[3], 0, y) && Yn(v[4], 0, y) && Yn(v[5], _, y) && Yn(v[6], 0, y) && Yn(v[7], 0, y) && Yn(v[8], 0, y) && Yn(v[9], 0, y) && Yn(v[10], _, y) && Yn(v[11], 0, y) && Yn(v[15], 1, y);
    }(p, g !== void 0 ? g : Cn);
  }, e.fromQuat = function(p, g) {
    var v = g[0], y = g[1], _ = g[2], S = g[3], b = v + v, x = y + y, A = _ + _, w = v * b, C = y * b, M = y * x, T = _ * b, N = _ * x, I = _ * A, P = S * b, O = S * x, F = S * A;
    return p[0] = 1 - M - I, p[1] = C + F, p[2] = T - O, p[3] = 0, p[4] = C - F, p[5] = 1 - w - I, p[6] = N + P, p[7] = 0, p[8] = T + O, p[9] = N - P, p[10] = 1 - w - M, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.perspective = function(p, g, v, y, _, S, b) {
    var x = 2 * S / (v - g), A = 2 * S / (y - _), w = (v + g) / (v - g), C = (y + _) / (y - _), M = -(b + S) / (b - S), T = -2 * b * S / (b - S);
    return p[0] = x, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = A, p[6] = 0, p[7] = 0, p[8] = w, p[9] = C, p[10] = M, p[11] = -1, p[12] = 0, p[13] = 0, p[14] = T, p[15] = 0, p;
  }, e.ortho = function(p, g, v, y, _, S, b) {
    var x = 1 / (v - g), A = 1 / (y - _), w = 1 / (b - S), C = (v + g) * x, M = (y + _) * A, T = (b + S) * w;
    return p[0] = 2 * x, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 2 * A, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = -2 * w, p[11] = 0, p[12] = -C, p[13] = -M, p[14] = -T, p[15] = 1, p;
  }, e.lookAt = function(p, g, v, y) {
    var _, S, b, x, A, w, C, M, T, N, I = g[0], P = g[1], O = g[2], F = y[0], R = y[1], G = y[2], L = v[0], q = v[1], K = v[2];
    return Math.abs(I - L) < Cn && Math.abs(P - q) < Cn && Math.abs(O - K) < Cn ? n(p) : (C = I - L, M = P - q, T = O - K, _ = R * (T *= N = 1 / Math.sqrt(C * C + M * M + T * T)) - G * (M *= N), S = G * (C *= N) - F * T, b = F * M - R * C, (N = Math.sqrt(_ * _ + S * S + b * b)) ? (_ *= N = 1 / N, S *= N, b *= N) : (_ = 0, S = 0, b = 0), x = M * b - T * S, A = T * _ - C * b, w = C * S - M * _, (N = Math.sqrt(x * x + A * A + w * w)) ? (x *= N = 1 / N, A *= N, w *= N) : (x = 0, A = 0, w = 0), p[0] = _, p[1] = x, p[2] = C, p[3] = 0, p[4] = S, p[5] = A, p[6] = M, p[7] = 0, p[8] = b, p[9] = w, p[10] = T, p[11] = 0, p[12] = -(_ * I + S * P + b * O), p[13] = -(x * I + A * P + w * O), p[14] = -(C * I + M * P + T * O), p[15] = 1, p);
  }, e.targetTo = function(p, g, v, y) {
    var _ = g[0], S = g[1], b = g[2], x = y[0], A = y[1], w = y[2], C = _ - v[0], M = S - v[1], T = b - v[2], N = C * C + M * M + T * T;
    N > 0 && (C *= N = 1 / Math.sqrt(N), M *= N, T *= N);
    var I = A * T - w * M, P = w * C - x * T, O = x * M - A * C;
    return (N = I * I + P * P + O * O) > 0 && (I *= N = 1 / Math.sqrt(N), P *= N, O *= N), p[0] = I, p[1] = P, p[2] = O, p[3] = 0, p[4] = M * O - T * P, p[5] = T * I - C * O, p[6] = C * P - M * I, p[7] = 0, p[8] = C, p[9] = M, p[10] = T, p[11] = 0, p[12] = _, p[13] = S, p[14] = b, p[15] = 1, p;
  }, e.fromPermutation = function(p, g) {
    a(p);
    for (var v = 0; v < 4; v++)
      s(p, v, g[v], 1);
    return p;
  }, e.getMaxScaleOnAxis = function(p) {
    var g = p[0] * p[0] + p[1] * p[1] + p[2] * p[2], v = p[4] * p[4] + p[5] * p[5] + p[6] * p[6], y = p[8] * p[8] + p[9] * p[9] + p[10] * p[10];
    return Math.sqrt(Math.max(g, v, y));
  };
  var f = [1, 0, 0], m = [0, 1, 0], h = [0, 0, 1];
  e.rotX90 = d(t(), Kn(90), f), e.rotX180 = d(t(), Kn(180), f), e.rotY90 = d(t(), Kn(90), m), e.rotY180 = d(t(), Kn(180), m), e.rotY270 = d(t(), Kn(270), m), e.rotZ90 = d(t(), Kn(90), h), e.rotZ180 = d(t(), Kn(180), h), e.rotXY90 = l(t(), e.rotX90, e.rotY90), e.rotZY90 = l(t(), e.rotZ90, e.rotY90), e.rotZYZ90 = l(t(), e.rotZY90, e.rotZ90), e.rotZ90X180 = l(t(), e.rotZ90, e.rotX180), e.rotY90Z180 = l(t(), e.rotY90, e.rotZ180), e.id = r();
})(Ee || (Ee = {})), function(e) {
  function t() {
    var N = [0.1, 0, 0];
    return N[0] = 0, N;
  }
  function r(N, I, P) {
    var O = t();
    return O[0] = N, O[1] = I, O[2] = P, O;
  }
  function n(N, I) {
    return N[0] = I[0], N[1] = I[1], N[2] = I[2], N;
  }
  function a(N, I, P) {
    return N[0] = I[0] + P[0], N[1] = I[1] + P[1], N[2] = I[2] + P[2], N;
  }
  function i(N, I, P) {
    return N[0] = I[0] - P[0], N[1] = I[1] - P[1], N[2] = I[2] - P[2], N;
  }
  function o(N, I, P) {
    return N[0] = I[0] * P, N[1] = I[1] * P, N[2] = I[2] * P, N;
  }
  function s(N, I, P, O) {
    return N[0] = I[0] + P[0] * O, N[1] = I[1] + P[1] * O, N[2] = I[2] + P[2] * O, N;
  }
  function u(N) {
    var I = N[0], P = N[1], O = N[2];
    return I * I + P * P + O * O;
  }
  function c(N, I) {
    return N[0] = -I[0], N[1] = -I[1], N[2] = -I[2], N;
  }
  function l(N, I) {
    var P = I[0], O = I[1], F = I[2], R = P * P + O * O + F * F;
    return R > 0 && (R = 1 / Math.sqrt(R), N[0] = I[0] * R, N[1] = I[1] * R, N[2] = I[2] * R), N;
  }
  function d(N, I) {
    return N[0] * I[0] + N[1] * I[1] + N[2] * I[2];
  }
  function f(N, I, P) {
    var O = I[0], F = I[1], R = I[2], G = P[0], L = P[1], q = P[2];
    return N[0] = F * q - R * L, N[1] = R * G - O * q, N[2] = O * L - F * G, N;
  }
  e.zero = t, e.clone = function(N) {
    var I = t();
    return I[0] = N[0], I[1] = N[1], I[2] = N[2], I;
  }, e.hasNaN = function(N) {
    return isNaN(N[0]) || isNaN(N[1]) || isNaN(N[2]);
  }, e.setNaN = function(N) {
    return N[0] = NaN, N[1] = NaN, N[2] = NaN, N;
  }, e.fromObj = function(N) {
    return r(N.x, N.y, N.z);
  }, e.toObj = function(N) {
    return { x: N[0], y: N[1], z: N[2] };
  }, e.fromArray = function(N, I, P) {
    return N[0] = I[P + 0], N[1] = I[P + 1], N[2] = I[P + 2], N;
  }, e.toArray = function(N, I, P) {
    return I[P + 0] = N[0], I[P + 1] = N[1], I[P + 2] = N[2], I;
  }, e.create = r, e.ofArray = function(N) {
    var I = t();
    return I[0] = N[0], I[1] = N[1], I[2] = N[2], I;
  }, e.set = function(N, I, P, O) {
    return N[0] = I, N[1] = P, N[2] = O, N;
  }, e.copy = n, e.add = a, e.sub = i, e.mul = function(N, I, P) {
    return N[0] = I[0] * P[0], N[1] = I[1] * P[1], N[2] = I[2] * P[2], N;
  }, e.div = function(N, I, P) {
    return N[0] = I[0] / P[0], N[1] = I[1] / P[1], N[2] = I[2] / P[2], N;
  }, e.scale = o, e.scaleAndAdd = s, e.scaleAndSub = function(N, I, P, O) {
    return N[0] = I[0] - P[0] * O, N[1] = I[1] - P[1] * O, N[2] = I[2] - P[2] * O, N;
  }, e.addScalar = function(N, I, P) {
    return N[0] = I[0] + P, N[1] = I[1] + P, N[2] = I[2] + P, N;
  }, e.subScalar = function(N, I, P) {
    return N[0] = I[0] - P, N[1] = I[1] - P, N[2] = I[2] - P, N;
  }, e.round = function(N, I) {
    return N[0] = Math.round(I[0]), N[1] = Math.round(I[1]), N[2] = Math.round(I[2]), N;
  }, e.ceil = function(N, I) {
    return N[0] = Math.ceil(I[0]), N[1] = Math.ceil(I[1]), N[2] = Math.ceil(I[2]), N;
  }, e.floor = function(N, I) {
    return N[0] = Math.floor(I[0]), N[1] = Math.floor(I[1]), N[2] = Math.floor(I[2]), N;
  }, e.trunc = function(N, I) {
    return N[0] = Math.trunc(I[0]), N[1] = Math.trunc(I[1]), N[2] = Math.trunc(I[2]), N;
  }, e.abs = function(N, I) {
    return N[0] = Math.abs(I[0]), N[1] = Math.abs(I[1]), N[2] = Math.abs(I[2]), N;
  }, e.min = function(N, I, P) {
    return N[0] = Math.min(I[0], P[0]), N[1] = Math.min(I[1], P[1]), N[2] = Math.min(I[2], P[2]), N;
  }, e.max = function(N, I, P) {
    return N[0] = Math.max(I[0], P[0]), N[1] = Math.max(I[1], P[1]), N[2] = Math.max(I[2], P[2]), N;
  }, e.distance = function(N, I) {
    var P = I[0] - N[0], O = I[1] - N[1], F = I[2] - N[2];
    return Math.sqrt(P * P + O * O + F * F);
  }, e.squaredDistance = function(N, I) {
    var P = I[0] - N[0], O = I[1] - N[1], F = I[2] - N[2];
    return P * P + O * O + F * F;
  }, e.magnitude = function(N) {
    var I = N[0], P = N[1], O = N[2];
    return Math.sqrt(I * I + P * P + O * O);
  }, e.squaredMagnitude = u, e.setMagnitude = function(N, I, P) {
    return o(N, l(N, I), P);
  }, e.negate = c, e.inverse = function(N, I) {
    return N[0] = 1 / I[0], N[1] = 1 / I[1], N[2] = 1 / I[2], N;
  }, e.normalize = l, e.dot = d, e.cross = f, e.lerp = function(N, I, P, O) {
    var F = I[0], R = I[1], G = I[2];
    return N[0] = F + O * (P[0] - F), N[1] = R + O * (P[1] - R), N[2] = G + O * (P[2] - G), N;
  };
  var m = t();
  function h(N, I) {
    var P = Math.sqrt(u(N) * u(I));
    if (P === 0) return Math.PI / 2;
    var O = d(N, I) / P;
    return Math.acos(po(O, -1, 1));
  }
  e.slerp = function(N, I, P, O) {
    var F = po(d(I, P), -1, 1), R = Math.acos(F) * O;
    return s(m, P, I, -F), l(m, m), a(N, o(N, I, Math.cos(R)), o(m, m, Math.sin(R)));
  }, e.hermite = function(N, I, P, O, F, R) {
    var G = R * R, L = G * (2 * R - 3) + 1, q = G * (R - 2) + R, K = G * (R - 1), X = G * (3 - 2 * R);
    return N[0] = I[0] * L + P[0] * q + O[0] * K + F[0] * X, N[1] = I[1] * L + P[1] * q + O[1] * K + F[1] * X, N[2] = I[2] * L + P[2] * q + O[2] * K + F[2] * X, N;
  }, e.bezier = function(N, I, P, O, F, R) {
    var G = 1 - R, L = G * G, q = R * R, K = L * G, X = 3 * R * L, H = 3 * q * G, W = q * R;
    return N[0] = I[0] * K + P[0] * X + O[0] * H + F[0] * W, N[1] = I[1] * K + P[1] * X + O[1] * H + F[1] * W, N[2] = I[2] * K + P[2] * X + O[2] * H + F[2] * W, N;
  }, e.quadraticBezier = function(N, I, P, O, F) {
    return N[0] = v4(I[0], P[0], O[0], F), N[1] = v4(I[1], P[1], O[1], F), N[2] = v4(I[2], P[2], O[2], F), N;
  }, e.spline = function(N, I, P, O, F, R, G) {
    return N[0] = S2(I[0], P[0], O[0], F[0], R, G), N[1] = S2(I[1], P[1], O[1], F[1], R, G), N[2] = S2(I[2], P[2], O[2], F[2], R, G), N;
  }, e.random = function(N, I) {
    var P = 2 * Math.random() * Math.PI, O = 2 * Math.random() - 1, F = Math.sqrt(1 - O * O) * I;
    return N[0] = Math.cos(P) * F, N[1] = Math.sin(P) * F, N[2] = O * I, N;
  }, e.transformMat4 = function(N, I, P) {
    var O = I[0], F = I[1], R = I[2], G = 1 / (P[3] * O + P[7] * F + P[11] * R + P[15] || 1);
    return N[0] = (P[0] * O + P[4] * F + P[8] * R + P[12]) * G, N[1] = (P[1] * O + P[5] * F + P[9] * R + P[13]) * G, N[2] = (P[2] * O + P[6] * F + P[10] * R + P[14]) * G, N;
  }, e.transformMat4Offset = function(N, I, P, O, F, R) {
    var G = I[0 + F], L = I[1 + F], q = I[2 + F], K = 1 / (P[3 + R] * G + P[7 + R] * L + P[11 + R] * q + P[15 + R] || 1);
    return N[0 + O] = (P[0 + R] * G + P[4 + R] * L + P[8 + R] * q + P[12 + R]) * K, N[1 + O] = (P[1 + R] * G + P[5 + R] * L + P[9 + R] * q + P[13 + R]) * K, N[2 + O] = (P[2 + R] * G + P[6 + R] * L + P[10 + R] * q + P[14 + R]) * K, N;
  }, e.transformMat3 = function(N, I, P) {
    var O = I[0], F = I[1], R = I[2];
    return N[0] = O * P[0] + F * P[3] + R * P[6], N[1] = O * P[1] + F * P[4] + R * P[7], N[2] = O * P[2] + F * P[5] + R * P[8], N;
  }, e.transformQuat = function(N, I, P) {
    var O = I[0], F = I[1], R = I[2], G = P[0], L = P[1], q = P[2], K = P[3], X = K * O + L * R - q * F, H = K * F + q * O - G * R, W = K * R + G * F - L * O, ee = -G * O - L * F - q * R;
    return N[0] = X * K + ee * -G + H * -q - W * -L, N[1] = H * K + ee * -L + W * -G - X * -q, N[2] = W * K + ee * -q + X * -L - H * -G, N;
  }, e.angle = h;
  var p = t(), g = t(), v = t(), y = t(), _ = t(), S = t(), b = t();
  e.dihedralAngle = function(N, I, P, O) {
    i(p, N, I), i(g, P, I), i(v, I, P), i(y, O, P), f(_, p, g), f(S, v, y);
    var F = h(_, S);
    return f(b, _, S), d(g, b) > 0 ? F : -F;
  }, e.directionFromSpherical = function(N, I, P, O) {
    return e.set(N, O * Math.cos(P) * Math.sin(I), O * Math.sin(P) * Math.sin(I), O * Math.cos(I));
  }, e.exactEquals = function(N, I) {
    return N[0] === I[0] && N[1] === I[1] && N[2] === I[2];
  }, e.equals = function(N, I) {
    var P = N[0], O = N[1], F = N[2], R = I[0], G = I[1], L = I[2];
    return Math.abs(P - R) <= Cn * Math.max(1, Math.abs(P), Math.abs(R)) && Math.abs(O - G) <= Cn * Math.max(1, Math.abs(O), Math.abs(G)) && Math.abs(F - L) <= Cn * Math.max(1, Math.abs(F), Math.abs(L));
  };
  var x = t();
  e.makeRotation = function(N, I, P) {
    var O = h(I, P);
    if (Math.abs(O) < 1e-4) return Ee.setIdentity(N);
    if (Math.abs(O - Math.PI) < Cn) return Ee.fromScaling(N, e.negUnit);
    var F = f(x, I, P);
    return Ee.fromRotation(N, O, F);
  }, e.isZero = function(N) {
    return N[0] === 0 && N[1] === 0 && N[2] === 0;
  }, e.projectPointOnVector = function(N, I, P, O) {
    return i(N, I, O), a(N, o(N, P, d(P, N) / u(P)), O);
  };
  var A = t();
  function w(N, I, P) {
    return o(N, P, d(P, I) / u(P));
  }
  e.projectPointOnPlane = function(N, I, P, O) {
    return l(A, P), i(N, I, O), i(N, I, o(A, A, d(N, A)));
  }, e.projectOnVector = w;
  var C = t();
  e.projectOnPlane = function(N, I, P) {
    return w(C, I, P), i(N, I, C);
  }, e.orthogonalize = function(N, I, P) {
    return l(N, f(N, f(N, I, P), I));
  }, e.matchDirection = function(N, I, P) {
    return d(I, P) > 0 ? n(N, I) : c(N, n(N, I)), N;
  };
  var M = t(), T = t();
  e.triangleNormal = function(N, I, P, O) {
    return i(M, P, I), i(T, O, I), l(N, f(N, M, T));
  }, e.toString = function(N, I) {
    return "[".concat(N[0].toPrecision(I), " ").concat(N[1].toPrecision(I), " ").concat(N[2].toPrecision(I), "]");
  }, e.origin = r(0, 0, 0), e.unit = r(1, 1, 1), e.negUnit = r(-1, -1, -1), e.unitX = r(1, 0, 0), e.unitY = r(0, 1, 0), e.unitZ = r(0, 0, 1), e.negUnitX = r(-1, 0, 0), e.negUnitY = r(0, -1, 0), e.negUnitZ = r(0, 0, -1);
}(D || (D = {})), function(e) {
  function t() {
    var b = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return b[0] = 0, b;
  }
  function r() {
    var b = t();
    return b[0] = 1, b[1] = 0, b[2] = 0, b[3] = 0, b[4] = 1, b[5] = 0, b[6] = 0, b[7] = 0, b[8] = 1, b;
  }
  function n(b, x) {
    return b[0] = x[0], b[1] = x[1], b[2] = x[2], b[3] = x[4], b[4] = x[5], b[5] = x[6], b[6] = x[8], b[7] = x[9], b[8] = x[10], b;
  }
  e.zero = t, e.identity = r, e.setIdentity = function(b) {
    return b[0] = 1, b[1] = 0, b[2] = 0, b[3] = 0, b[4] = 1, b[5] = 0, b[6] = 0, b[7] = 0, b[8] = 1, b;
  }, e.toArray = function(b, x, A) {
    return x[A + 0] = b[0], x[A + 1] = b[1], x[A + 2] = b[2], x[A + 3] = b[3], x[A + 4] = b[4], x[A + 5] = b[5], x[A + 6] = b[6], x[A + 7] = b[7], x[A + 8] = b[8], x;
  }, e.fromArray = function(b, x, A) {
    return b[0] = x[A + 0], b[1] = x[A + 1], b[2] = x[A + 2], b[3] = x[A + 3], b[4] = x[A + 4], b[5] = x[A + 5], b[6] = x[A + 6], b[7] = x[A + 7], b[8] = x[A + 8], b;
  }, e.fromMat4 = n, e.create = function(b, x, A, w, C, M, T, N, I) {
    var P = t();
    return P[0] = b, P[1] = x, P[2] = A, P[3] = w, P[4] = C, P[5] = M, P[6] = T, P[7] = N, P[8] = I, P;
  };
  var a = r();
  function i(b, x, A) {
    for (var w = 0; w < 9; w++) if (Math.abs(b[w] - x[w]) > A) return !1;
    return !0;
  }
  function o(b, x) {
    return b[0] = x[0], b[1] = x[1], b[2] = x[2], b[3] = x[3], b[4] = x[4], b[5] = x[5], b[6] = x[6], b[7] = x[7], b[8] = x[8], b;
  }
  function s(b, x) {
    if (b === x) {
      var A = x[1], w = x[2], C = x[5];
      b[1] = x[3], b[2] = x[6], b[3] = A, b[5] = x[7], b[6] = w, b[7] = C;
    } else b[0] = x[0], b[1] = x[3], b[2] = x[6], b[3] = x[1], b[4] = x[4], b[5] = x[7], b[6] = x[2], b[7] = x[5], b[8] = x[8];
    return b;
  }
  function u(b, x) {
    var A = x[0], w = x[1], C = x[2], M = x[3], T = x[4], N = x[5], I = x[6], P = x[7], O = x[8], F = O * T - N * P, R = -O * M + N * I, G = P * M - T * I, L = A * F + w * R + C * G;
    return L ? (L = 1 / L, b[0] = F * L, b[1] = (-O * w + C * P) * L, b[2] = (N * w - C * T) * L, b[3] = R * L, b[4] = (O * A - C * I) * L, b[5] = (-N * A + C * M) * L, b[6] = G * L, b[7] = (-P * A + w * I) * L, b[8] = (T * A - w * M) * L, b) : (console.warn("non-invertible matrix.", x), b);
  }
  function c(b) {
    var x = b[0], A = b[1], w = b[2], C = b[3], M = b[4], T = b[5], N = b[6], I = b[7], P = b[8];
    return x * (P * M - T * I) + A * (-P * C + T * N) + w * (I * C - M * N);
  }
  function l(b) {
    return b[0] + b[4] + b[8];
  }
  function d(b, x, A) {
    return b[0] = x[0] - A[0], b[1] = x[1] - A[1], b[2] = x[2] - A[2], b[3] = x[3] - A[3], b[4] = x[4] - A[4], b[5] = x[5] - A[5], b[6] = x[6] - A[6], b[7] = x[7] - A[7], b[8] = x[8] - A[8], b;
  }
  function f(b, x, A) {
    return b[0] = x[0] * A, b[1] = x[1] * A, b[2] = x[2] * A, b[3] = x[3] * A, b[4] = x[4] * A, b[5] = x[5] * A, b[6] = x[6] * A, b[7] = x[7] * A, b[8] = x[8] * A, b;
  }
  e.isIdentity = function(b, x) {
    return i(b, a, x === void 0 ? Cn : x);
  }, e.hasNaN = function(b) {
    for (var x = 0; x < 9; x++) if (isNaN(b[x])) return !0;
    return !1;
  }, e.clone = function(b) {
    return o(t(), b);
  }, e.areEqual = i, e.setValue = function(b, x, A, w) {
    b[3 * A + x] = w;
  }, e.getValue = function(b, x, A) {
    return b[3 * A + x];
  }, e.copy = o, e.transpose = s, e.invert = u, e.symmtricFromUpper = function(b, x) {
    return b === x ? (b[3] = x[1], b[6] = x[2], b[7] = x[5]) : (b[0] = x[0], b[1] = x[1], b[2] = x[2], b[3] = x[1], b[4] = x[4], b[5] = x[5], b[6] = x[2], b[7] = x[5], b[8] = x[8]), b;
  }, e.symmtricFromLower = function(b, x) {
    return b === x ? (b[1] = x[3], b[2] = x[6], b[5] = x[7]) : (b[0] = x[0], b[1] = x[3], b[2] = x[6], b[3] = x[3], b[4] = x[4], b[5] = x[7], b[6] = x[6], b[7] = x[7], b[8] = x[8]), b;
  }, e.determinant = c, e.trace = l, e.sub = d, e.add = function(b, x, A) {
    return b[0] = x[0] + A[0], b[1] = x[1] + A[1], b[2] = x[2] + A[2], b[3] = x[3] + A[3], b[4] = x[4] + A[4], b[5] = x[5] + A[5], b[6] = x[6] + A[6], b[7] = x[7] + A[7], b[8] = x[8] + A[8], b;
  }, e.mul = function(b, x, A) {
    var w = x[0], C = x[1], M = x[2], T = x[3], N = x[4], I = x[5], P = x[6], O = x[7], F = x[8], R = A[0], G = A[1], L = A[2], q = A[3], K = A[4], X = A[5], H = A[6], W = A[7], ee = A[8];
    return b[0] = R * w + G * T + L * P, b[1] = R * C + G * N + L * O, b[2] = R * M + G * I + L * F, b[3] = q * w + K * T + X * P, b[4] = q * C + K * N + X * O, b[5] = q * M + K * I + X * F, b[6] = H * w + W * T + ee * P, b[7] = H * C + W * N + ee * O, b[8] = H * M + W * I + ee * F, b;
  }, e.subScalar = function(b, x, A) {
    return b[0] = x[0] - A, b[1] = x[1] - A, b[2] = x[2] - A, b[3] = x[3] - A, b[4] = x[4] - A, b[5] = x[5] - A, b[6] = x[6] - A, b[7] = x[7] - A, b[8] = x[8] - A, b;
  }, e.addScalar = function(b, x, A) {
    return b[0] = x[0] + A, b[1] = x[1] + A, b[2] = x[2] + A, b[3] = x[3] + A, b[4] = x[4] + A, b[5] = x[5] + A, b[6] = x[6] + A, b[7] = x[7] + A, b[8] = x[8] + A, b;
  }, e.mulScalar = f;
  var m = Math.PI / 3, h = t();
  e.symmetricEigenvalues = function(b, x) {
    var A = x[1] * x[1] + x[2] * x[2] + x[5] * x[5];
    if (A === 0) b[0] = x[0], b[1] = x[4], b[2] = x[8];
    else {
      var w = l(x) / 3, C = x[0] - w, M = x[4] - w, T = x[8] - w, N = C * C + M * M + T * T + 2 * A, I = Math.sqrt(N / 6);
      f(h, e.Identity, w), d(h, x, h), f(h, h, 1 / I);
      var P = c(h) / 2, O = P <= -1 ? m : P >= 1 ? 0 : Math.acos(P) / 3;
      b[0] = w + 2 * I * Math.cos(O), b[2] = w + 2 * I * Math.cos(O + 2 * m), b[1] = 3 * w - b[0] - b[2];
    }
    return b;
  };
  var p = [0.1, 0, 0], g = [0.1, 0, 0], v = [0.1, 0, 0], y = [0.1, 0, 0], _ = [0.1, 0, 0], S = [0.1, 0, 0];
  e.eigenvector = function(b, x, A) {
    D.set(p, x[0] - A, x[1], x[2]), D.set(g, x[1], x[4] - A, x[5]), D.set(v, x[2], x[5], x[8] - A), D.cross(y, p, g), D.cross(_, p, v), D.cross(S, g, v);
    var w = D.dot(y, y), C = D.dot(_, _), M = D.dot(S, S), T = w, N = 0;
    return C > T && (T = C, N = 1), M > T && (N = 2), N === 0 ? D.scale(b, y, 1 / Math.sqrt(w)) : N === 1 ? D.scale(b, _, 1 / Math.sqrt(C)) : D.scale(b, S, 1 / Math.sqrt(M)), b;
  }, e.directionTransform = function(b, x) {
    return n(b, x), u(b, b), s(b, b), b;
  }, e.Identity = r();
}(ka || (ka = {})), function(e) {
  function t() {
    var r = [0.1, 0];
    return r[0] = 0, r;
  }
  e.zero = t, e.clone = function(r) {
    var n = t();
    return n[0] = r[0], n[1] = r[1], n;
  }, e.create = function(r, n) {
    var a = t();
    return a[0] = r, a[1] = n, a;
  }, e.hasNaN = function(r) {
    return isNaN(r[0]) || isNaN(r[1]);
  }, e.toArray = function(r, n, a) {
    return n[a + 0] = r[0], n[a + 1] = r[1], n;
  }, e.fromArray = function(r, n, a) {
    return r[0] = n[a + 0], r[1] = n[a + 1], r;
  }, e.copy = function(r, n) {
    return r[0] = n[0], r[1] = n[1], r;
  }, e.set = function(r, n, a) {
    return r[0] = n, r[1] = a, r;
  }, e.add = function(r, n, a) {
    return r[0] = n[0] + a[0], r[1] = n[1] + a[1], r;
  }, e.sub = function(r, n, a) {
    return r[0] = n[0] - a[0], r[1] = n[1] - a[1], r;
  }, e.mul = function(r, n, a) {
    return r[0] = n[0] * a[0], r[1] = n[1] * a[1], r;
  }, e.div = function(r, n, a) {
    return r[0] = n[0] / a[0], r[1] = n[1] / a[1], r;
  }, e.scale = function(r, n, a) {
    return r[0] = n[0] * a, r[1] = n[1] * a, r;
  }, e.round = function(r, n) {
    return r[0] = Math.round(n[0]), r[1] = Math.round(n[1]), r;
  }, e.ceil = function(r, n) {
    return r[0] = Math.ceil(n[0]), r[1] = Math.ceil(n[1]), r;
  }, e.floor = function(r, n) {
    return r[0] = Math.floor(n[0]), r[1] = Math.floor(n[1]), r;
  }, e.distance = function(r, n) {
    var a = n[0] - r[0], i = n[1] - r[1];
    return Math.sqrt(a * a + i * i);
  }, e.squaredDistance = function(r, n) {
    var a = n[0] - r[0], i = n[1] - r[1];
    return a * a + i * i;
  }, e.magnitude = function(r) {
    var n = r[0], a = r[1];
    return Math.sqrt(n * n + a * a);
  }, e.squaredMagnitude = function(r) {
    var n = r[0], a = r[1];
    return n * n + a * a;
  }, e.inverse = function(r, n) {
    return r[0] = 1 / n[0], r[1] = 1 / n[1], r;
  }, e.areEqual = function(r, n) {
    return r[0] === n[0] && r[1] === n[1];
  }, e.toString = function(r, n) {
    return "[".concat(r[0].toPrecision(n), " ").concat(r[1].toPrecision(n), "}]");
  }, e.normalize = function(r, n) {
    var a = n[0], i = n[1], o = a * a + i * i;
    return o > 0 && (o = 1 / Math.sqrt(o), r[0] = n[0] * o, r[1] = n[1] * o), r;
  };
}(Ze || (Ze = {})), function(e) {
  function t() {
    var n = [0.1, 0, 0, 0];
    return n[0] = 0, n;
  }
  function r(n, a) {
    return n[0] = a.center[0], n[1] = a.center[1], n[2] = a.center[2], n[3] = a.radius, n;
  }
  e.zero = t, e.clone = function(n) {
    var a = t();
    return a[0] = n[0], a[1] = n[1], a[2] = n[2], a[3] = n[3], a;
  }, e.create = function(n, a, i, o) {
    var s = t();
    return s[0] = n, s[1] = a, s[2] = i, s[3] = o, s;
  }, e.fromSphere = r, e.ofSphere = function(n) {
    return r(t(), n);
  }, e.hasNaN = function(n) {
    return isNaN(n[0]) || isNaN(n[1]) || isNaN(n[2]) || isNaN(n[3]);
  }, e.toArray = function(n, a, i) {
    return a[i + 0] = n[0], a[i + 1] = n[1], a[i + 2] = n[2], a[i + 3] = n[3], a;
  }, e.fromArray = function(n, a, i) {
    return n[0] = a[i + 0], n[1] = a[i + 1], n[2] = a[i + 2], n[3] = a[i + 3], n;
  }, e.toVec3Array = function(n, a, i) {
    a[i + 0] = n[0], a[i + 1] = n[1], a[i + 2] = n[2];
  }, e.fromVec3Array = function(n, a, i) {
    return n[0] = a[i + 0], n[1] = a[i + 1], n[2] = a[i + 2], n[3] = 0, n;
  }, e.copy = function(n, a) {
    return n[0] = a[0], n[1] = a[1], n[2] = a[2], n[3] = a[3], n;
  }, e.set = function(n, a, i, o, s) {
    return n[0] = a, n[1] = i, n[2] = o, n[3] = s, n;
  }, e.add = function(n, a, i) {
    return n[0] = a[0] + i[0], n[1] = a[1] + i[1], n[2] = a[2] + i[2], n[3] = a[3] + i[3], n;
  }, e.distance = function(n, a) {
    var i = a[0] - n[0], o = a[1] - n[1], s = a[2] - n[2], u = a[3] - n[3];
    return Math.sqrt(i * i + o * o + s * s + u * u);
  }, e.scale = function(n, a, i) {
    return n[0] = a[0] * i, n[1] = a[1] * i, n[2] = a[2] * i, n[4] = a[4] * i, n;
  }, e.round = function(n, a) {
    return n[0] = Math.round(a[0]), n[1] = Math.round(a[1]), n[2] = Math.round(a[2]), n[3] = Math.round(a[3]), n;
  }, e.ceil = function(n, a) {
    return n[0] = Math.ceil(a[0]), n[1] = Math.ceil(a[1]), n[2] = Math.ceil(a[2]), n[3] = Math.ceil(a[3]), n;
  }, e.floor = function(n, a) {
    return n[0] = Math.floor(a[0]), n[1] = Math.floor(a[1]), n[2] = Math.floor(a[2]), n[3] = Math.floor(a[3]), n;
  }, e.squaredDistance = function(n, a) {
    var i = a[0] - n[0], o = a[1] - n[1], s = a[2] - n[2], u = a[3] - n[3];
    return i * i + o * o + s * s + u * u;
  }, e.norm = function(n) {
    var a = n[0], i = n[1], o = n[2], s = n[3];
    return Math.sqrt(a * a + i * i + o * o + s * s);
  }, e.squaredNorm = function(n) {
    var a = n[0], i = n[1], o = n[2], s = n[3];
    return a * a + i * i + o * o + s * s;
  }, e.transformMat4 = function(n, a, i) {
    var o = a[0], s = a[1], u = a[2], c = a[3];
    return n[0] = i[0] * o + i[4] * s + i[8] * u + i[12] * c, n[1] = i[1] * o + i[5] * s + i[9] * u + i[13] * c, n[2] = i[2] * o + i[6] * s + i[10] * u + i[14] * c, n[3] = i[3] * o + i[7] * s + i[11] * u + i[15] * c, n;
  }, e.dot = function(n, a) {
    return n[0] * a[0] + n[1] * a[1] + n[2] * a[2] + n[3] * a[3];
  }, e.inverse = function(n, a) {
    return n[0] = 1 / a[0], n[1] = 1 / a[1], n[2] = 1 / a[2], n[3] = 1 / a[3], n;
  }, e.exactEquals = function(n, a) {
    return n[0] === a[0] && n[1] === a[1] && n[2] === a[2] && n[3] === a[3];
  }, e.equals = function(n, a) {
    var i = n[0], o = n[1], s = n[2], u = n[3], c = a[0], l = a[1], d = a[2], f = a[3];
    return Math.abs(i - c) <= Cn * Math.max(1, Math.abs(i), Math.abs(c)) && Math.abs(o - l) <= Cn * Math.max(1, Math.abs(o), Math.abs(l)) && Math.abs(s - d) <= Cn * Math.max(1, Math.abs(s), Math.abs(d)) && Math.abs(u - f) <= Cn * Math.max(1, Math.abs(u), Math.abs(f));
  }, e.toString = function(n, a) {
    return "[".concat(n[0].toPrecision(a), " ").concat(n[1].toPrecision(a), " ").concat(n[2].toPrecision(a), "  ").concat(n[3].toPrecision(a), "]");
  };
}(jt || (jt = {})), function(e) {
  function t() {
    var h = [0.1, 0, 0, 0];
    return h[0] = 0, h;
  }
  function r() {
    var h = t();
    return h[3] = 1, h;
  }
  function n(h, p, g) {
    g *= 0.5;
    var v = Math.sin(g);
    return h[0] = v * p[0], h[1] = v * p[1], h[2] = v * p[2], h[3] = Math.cos(g), h;
  }
  function a(h, p, g, v) {
    var y, _, S, b, x, A = p[0], w = p[1], C = p[2], M = p[3], T = g[0], N = g[1], I = g[2], P = g[3];
    return (_ = A * T + w * N + C * I + M * P) < 0 && (_ = -_, T = -T, N = -N, I = -I, P = -P), 1 - _ > 1e-6 ? (y = Math.acos(_), S = Math.sin(y), b = Math.sin((1 - v) * y) / S, x = Math.sin(v * y) / S) : (b = 1 - v, x = v), h[0] = b * A + x * T, h[1] = b * w + x * N, h[2] = b * C + x * I, h[3] = b * M + x * P, h;
  }
  function i(h, p) {
    var g, v = p[0] + p[4] + p[8];
    if (v > 0) g = Math.sqrt(v + 1), h[3] = 0.5 * g, g = 0.5 / g, h[0] = (p[5] - p[7]) * g, h[1] = (p[6] - p[2]) * g, h[2] = (p[1] - p[3]) * g;
    else {
      var y = 0;
      p[4] > p[0] && (y = 1), p[8] > p[3 * y + y] && (y = 2);
      var _ = (y + 1) % 3, S = (y + 2) % 3;
      g = Math.sqrt(p[3 * y + y] - p[3 * _ + _] - p[3 * S + S] + 1), h[y] = 0.5 * g, g = 0.5 / g, h[3] = (p[3 * _ + S] - p[3 * S + _]) * g, h[_] = (p[3 * _ + y] + p[3 * y + _]) * g, h[S] = (p[3 * S + y] + p[3 * y + S]) * g;
    }
    return h;
  }
  e.zero = t, e.identity = r, e.setIdentity = function(h) {
    h[0] = 0, h[1] = 0, h[2] = 0, h[3] = 1;
  }, e.hasNaN = function(h) {
    return isNaN(h[0]) || isNaN(h[1]) || isNaN(h[2]) || isNaN(h[3]);
  }, e.create = function(h, p, g, v) {
    var y = r();
    return y[0] = h, y[1] = p, y[2] = g, y[3] = v, y;
  }, e.setAxisAngle = n, e.getAxisAngle = function(h, p) {
    var g = 2 * Math.acos(p[3]), v = Math.sin(g / 2);
    return v !== 0 ? (h[0] = p[0] / v, h[1] = p[1] / v, h[2] = p[2] / v) : (h[0] = 1, h[1] = 0, h[2] = 0), g;
  }, e.multiply = function(h, p, g) {
    var v = p[0], y = p[1], _ = p[2], S = p[3], b = g[0], x = g[1], A = g[2], w = g[3];
    return h[0] = v * w + S * b + y * A - _ * x, h[1] = y * w + S * x + _ * b - v * A, h[2] = _ * w + S * A + v * x - y * b, h[3] = S * w - v * b - y * x - _ * A, h;
  }, e.rotateX = function(h, p, g) {
    g *= 0.5;
    var v = p[0], y = p[1], _ = p[2], S = p[3], b = Math.sin(g), x = Math.cos(g);
    return h[0] = v * x + S * b, h[1] = y * x + _ * b, h[2] = _ * x - y * b, h[3] = S * x - v * b, h;
  }, e.rotateY = function(h, p, g) {
    g *= 0.5;
    var v = p[0], y = p[1], _ = p[2], S = p[3], b = Math.sin(g), x = Math.cos(g);
    return h[0] = v * x - _ * b, h[1] = y * x + S * b, h[2] = _ * x + v * b, h[3] = S * x - y * b, h;
  }, e.rotateZ = function(h, p, g) {
    g *= 0.5;
    var v = p[0], y = p[1], _ = p[2], S = p[3], b = Math.sin(g), x = Math.cos(g);
    return h[0] = v * x + y * b, h[1] = y * x - v * b, h[2] = _ * x + S * b, h[3] = S * x - _ * b, h;
  }, e.calculateW = function(h, p) {
    var g = p[0], v = p[1], y = p[2];
    return h[0] = g, h[1] = v, h[2] = y, h[3] = Math.sqrt(Math.abs(1 - g * g - v * v - y * y)), h;
  }, e.slerp = a, e.invert = function(h, p) {
    var g = p[0], v = p[1], y = p[2], _ = p[3], S = g * g + v * v + y * y + _ * _, b = S ? 1 / S : 0;
    return h[0] = -g * b, h[1] = -v * b, h[2] = -y * b, h[3] = _ * b, h;
  }, e.conjugate = function(h, p) {
    return h[0] = -p[0], h[1] = -p[1], h[2] = -p[2], h[3] = p[3], h;
  }, e.fromMat3 = i;
  var o = [0, 0, 0];
  function s(h, p) {
    var g = p[0], v = p[1], y = p[2], _ = p[3], S = g * g + v * v + y * y + _ * _;
    return S > 0 && (S = 1 / Math.sqrt(S), h[0] = g * S, h[1] = v * S, h[2] = y * S, h[3] = _ * S), h;
  }
  e.fromUnitVec3 = function(h, p, g) {
    var v = D.dot(p, g) + 1;
    return v < Cn ? (v = 0, Math.abs(p[0]) > Math.abs(p[2]) ? D.set(o, -p[1], p[0], 0) : D.set(o, 0, -p[2], p[1])) : D.cross(o, p, g), h[0] = o[0], h[1] = o[1], h[2] = o[2], h[3] = v, s(h, h), h;
  }, e.clone = function(h) {
    var p = t();
    return p[0] = h[0], p[1] = h[1], p[2] = h[2], p[3] = h[3], p;
  }, e.toArray = function(h, p, g) {
    return p[g + 0] = h[0], p[g + 1] = h[1], p[g + 2] = h[2], p[g + 3] = h[3], p;
  }, e.fromArray = function(h, p, g) {
    return h[0] = p[g + 0], h[1] = p[g + 1], h[2] = p[g + 2], h[3] = p[g + 3], h;
  }, e.copy = function(h, p) {
    return h[0] = p[0], h[1] = p[1], h[2] = p[2], h[3] = p[3], h;
  }, e.set = function(h, p, g, v, y) {
    return h[0] = p, h[1] = g, h[2] = v, h[3] = y, h;
  }, e.exactEquals = function(h, p) {
    return h[0] === p[0] && h[1] === p[1] && h[2] === p[2] && h[3] === p[3];
  }, e.equals = function(h, p) {
    var g = h[0], v = h[1], y = h[2], _ = h[3], S = p[0], b = p[1], x = p[2], A = p[3];
    return Math.abs(g - S) <= Cn * Math.max(1, Math.abs(g), Math.abs(S)) && Math.abs(v - b) <= Cn * Math.max(1, Math.abs(v), Math.abs(b)) && Math.abs(y - x) <= Cn * Math.max(1, Math.abs(y), Math.abs(x)) && Math.abs(_ - A) <= Cn * Math.max(1, Math.abs(_), Math.abs(A));
  }, e.add = function(h, p, g) {
    return h[0] = p[0] + g[0], h[1] = p[1] + g[1], h[2] = p[2] + g[2], h[3] = p[3] + g[3], h;
  }, e.normalize = s;
  var u = [0, 0, 0], c = [1, 0, 0], l = [0, 1, 0];
  e.rotationTo = function(h, p, g) {
    var v = D.dot(p, g);
    return v < -0.999999 ? (D.cross(u, c, p), D.magnitude(u) < 1e-6 && D.cross(u, l, p), D.normalize(u, u), n(h, u, Math.PI), h) : v > 0.999999 ? (h[0] = 0, h[1] = 0, h[2] = 0, h[3] = 1, h) : (D.cross(u, p, g), h[0] = u[0], h[1] = u[1], h[2] = u[2], h[3] = 1 + v, s(h, h));
  };
  var d = t(), f = t();
  e.sqlerp = function(h, p, g, v, y, _) {
    return a(d, p, y, _), a(f, g, v, _), a(h, d, f, 2 * _ * (1 - _)), h;
  };
  var m = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  e.setAxes = function(h, p, g, v) {
    return m[0] = g[0], m[3] = g[1], m[6] = g[2], m[1] = v[0], m[4] = v[1], m[7] = v[2], m[2] = -p[0], m[5] = -p[1], m[8] = -p[2], s(h, i(h, m));
  }, e.toString = function(h, p) {
    return "[".concat(h[0].toPrecision(p), " ").concat(h[1].toPrecision(p), " ").concat(h[2].toPrecision(p), "  ").concat(h[3].toPrecision(p), "]");
  }, e.Identity = r();
}(Gn || (Gn = {})), function(e) {
  function t(o, s, u) {
    var c = function(g, v, y) {
      for (var _ = [], S = 0; S < v.length; S++) _[S] = v[v.length - S - 1];
      var b = [1];
      for (S = 1; S < g.length; S++) b[S] = g[_[S - 1]];
      return { dimensions: g, axisOrderFastToSlow: _, axisOrderSlowToFast: v, accessDimensions: b, defaultCtor: y || Float64Array };
    }(o, s, u), l = r(c), d = l.get, f = l.set, m = l.add, h = l.dataOffset, p = l.getCoords;
    return { rank: o.length, dimensions: o, axisOrderSlowToFast: s, create: n(c), get: d, set: f, add: m, dataOffset: h, getCoords: p };
  }
  function r(o) {
    var s = o.dimensions, u = o.axisOrderFastToSlow;
    switch (s.length) {
      case 1:
        return { get: function(I, P) {
          return I[P];
        }, set: function(I, P, O) {
          return I[P] = O;
        }, add: function(I, P, O) {
          return I[P] += O;
        }, dataOffset: function(I) {
          return I;
        }, getCoords: function(I, P) {
          return P[0] = I, P;
        } };
      case 2:
        if (u[0] === 0 && u[1] === 1) {
          var c = s[0];
          return { get: function(I, P, O) {
            return I[O * c + P];
          }, set: function(I, P, O, F) {
            return I[O * c + P] = F;
          }, add: function(I, P, O, F) {
            return I[O * c + P] += F;
          }, dataOffset: function(I, P) {
            return P * c + I;
          }, getCoords: function(I, P) {
            return P[0] = I % c, P[1] = Math.floor(I / c), P;
          } };
        }
        if (u[0] === 1 && u[1] === 0) {
          var l = s[1];
          return { get: function(I, P, O) {
            return I[P * l + O];
          }, set: function(I, P, O, F) {
            return I[P * l + O] = F;
          }, add: function(I, P, O, F) {
            return I[P * l + O] += F;
          }, dataOffset: function(I, P) {
            return I * l + P;
          }, getCoords: function(I, P) {
            return P[0] = Math.floor(I / l), P[1] = I % l, P;
          } };
        }
        throw new Error("bad axis order");
      case 3:
        if (u[0] === 0 && u[1] === 1 && u[2] === 2) {
          var d = s[0], f = s[1], m = d * f;
          return { get: function(I, P, O, F) {
            return I[P + O * d + F * m];
          }, set: function(I, P, O, F, R) {
            return I[P + O * d + F * m] = R;
          }, add: function(I, P, O, F, R) {
            return I[P + O * d + F * m] += R;
          }, dataOffset: function(I, P, O) {
            return I + P * d + O * m;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / d);
            return P[0] = I % d, P[1] = O % f, P[2] = Math.floor(O / f), P;
          } };
        }
        if (u[0] === 0 && u[1] === 2 && u[2] === 1) {
          var h = s[0], p = s[2], g = h * p;
          return { get: function(I, P, O, F) {
            return I[P + F * h + O * g];
          }, set: function(I, P, O, F, R) {
            return I[P + F * h + O * g] = R;
          }, add: function(I, P, O, F, R) {
            return I[P + F * h + O * g] += R;
          }, dataOffset: function(I, P, O) {
            return I + O * h + P * g;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / h);
            return P[0] = I % h, P[1] = Math.floor(O / p), P[2] = O % p, P;
          } };
        }
        if (u[0] === 1 && u[1] === 0 && u[2] === 2) {
          var v = s[1], y = s[0], _ = v * y;
          return { get: function(I, P, O, F) {
            return I[O + P * v + F * _];
          }, set: function(I, P, O, F, R) {
            return I[O + P * v + F * _] = R;
          }, add: function(I, P, O, F, R) {
            return I[O + P * v + F * _] += R;
          }, dataOffset: function(I, P, O) {
            return P + I * v + O * _;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / v);
            return P[0] = O % y, P[1] = I % v, P[2] = Math.floor(O / y), P;
          } };
        }
        if (u[0] === 1 && u[1] === 2 && u[2] === 0) {
          var S = s[1], b = s[2], x = S * b;
          return { get: function(I, P, O, F) {
            return I[O + F * S + P * x];
          }, set: function(I, P, O, F, R) {
            return I[O + F * S + P * x] = R;
          }, add: function(I, P, O, F, R) {
            return I[O + F * S + P * x] += R;
          }, dataOffset: function(I, P, O) {
            return P + O * S + I * x;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / S);
            return P[0] = Math.floor(O / b), P[1] = I % S, P[2] = O % b, P;
          } };
        }
        if (u[0] === 2 && u[1] === 0 && u[2] === 1) {
          var A = s[2], w = s[0], C = A * w;
          return { get: function(I, P, O, F) {
            return I[F + P * A + O * C];
          }, set: function(I, P, O, F, R) {
            return I[F + P * A + O * C] = R;
          }, add: function(I, P, O, F, R) {
            return I[F + P * A + O * C] += R;
          }, dataOffset: function(I, P, O) {
            return O + I * A + P * C;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / A);
            return P[0] = O % w, P[1] = Math.floor(O / w), P[2] = I % A, P;
          } };
        }
        if (u[0] === 2 && u[1] === 1 && u[2] === 0) {
          var M = s[2], T = s[1], N = M * T;
          return { get: function(I, P, O, F) {
            return I[F + O * M + P * N];
          }, set: function(I, P, O, F, R) {
            return I[F + O * M + P * N] = R;
          }, add: function(I, P, O, F, R) {
            return I[F + O * M + P * N] += R;
          }, dataOffset: function(I, P, O) {
            return O + P * M + I * N;
          }, getCoords: function(I, P) {
            var O = Math.floor(I / M);
            return P[0] = Math.floor(O / T), P[1] = O % T, P[2] = I % M, P;
          } };
        }
        throw new Error("bad axis order");
      default:
        return { get: function(I) {
          for (var P = [], O = 1; O < arguments.length; O++) P[O - 1] = arguments[O];
          return I[a(o, P)];
        }, set: function(I) {
          for (var P = [], O = 1; O < arguments.length; O++) P[O - 1] = arguments[O];
          return I[a(o, P)] = P[P.length - 1];
        }, add: function(I) {
          for (var P = [], O = 1; O < arguments.length; O++) P[O - 1] = arguments[O];
          return I[a(o, P)] += P[P.length - 1];
        }, dataOffset: function() {
          for (var I = [], P = 0; P < arguments.length; P++) I[P] = arguments[P];
          return a(o, I);
        }, getCoords: function(I, P) {
          return function(O, F, R) {
            for (var G = O.dimensions, L = O.axisOrderFastToSlow, q = G.length, K = F, X = 0; X < q; X++) {
              var H = G[L[X]];
              R[L[X]] = K % H, K = Math.floor(K / H);
            }
            return R[L[q + 1]] = K, R;
          }(o, I, P);
        } };
    }
  }
  function n(o) {
    for (var s = o.dimensions, u = 1, c = 0, l = s.length; c < l; c++) u *= s[c];
    return function(d) {
      return new (d || o.defaultCtor)(u);
    };
  }
  function a(o, s) {
    for (var u = o.accessDimensions, c = o.axisOrderFastToSlow, l = u.length - 1, d = u[l] * s[c[l]], f = l - 1; f >= 0; f--) d = (d + s[c[f]]) * u[f];
    return d;
  }
  function i(o, s) {
    for (var u = [], c = 0; c < o.length; c++) u[c] = o[s[c]];
    return u;
  }
  e.create = function(o, s) {
    return { space: o, data: s };
  }, e.Space = t, e.Data1 = function(o) {
    return o;
  }, e.Vector = function(o, s) {
    return t([o], [0], s);
  }, e.ColumnMajorMatrix = function(o, s, u) {
    return t([o, s], [1, 0], u);
  }, e.RowMajorMatrix = function(o, s, u) {
    return t([o, s], [0, 1], u);
  }, e.toMat4 = function(o, s, u) {
    if (s.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(4, s.dimensions[0]), l = Math.min(4, s.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) Ee.setValue(o, d, f, s.get(u, d, f));
    return o;
  }, e.toMat3 = function(o, s, u) {
    if (s.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(3, s.dimensions[0]), l = Math.min(3, s.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) ka.setValue(o, d, f, s.get(u, d, f));
    return o;
  }, e.toVec3 = function(o, s, u) {
    if (s.rank !== 1) throw new Error("Invalid tensor rank");
    for (var c = Math.min(3, s.dimensions[0]), l = 0; l < c; l++) o[l] = u[l];
    return o;
  }, e.toVec4 = function(o, s, u) {
    if (s.rank !== 1) throw new Error("Invalid tensor rank");
    for (var c = Math.min(4, s.dimensions[0]), l = 0; l < c; l++) o[l] = u[l];
    return o;
  }, e.areEqualExact = function(o, s) {
    var u = o.length;
    if (u !== s.length) return !1;
    for (var c = 0; c < u; c++) if (o[c] !== s[c]) return !1;
    return !0;
  }, e.invertAxisOrder = function(o) {
    for (var s = [], u = 0; u < o.length; u++) s[u] = o[o.length - u - 1];
    return s;
  }, e.convertToCanonicalAxisIndicesFastToSlow = function(o) {
    for (var s = new Int32Array(o.length), u = 0; u < o.length; u++) s[o[u]] = u;
    return function(c) {
      return i(c, s);
    };
  }, e.convertToCanonicalAxisIndicesSlowToFast = function(o) {
    for (var s = new Int32Array(o.length), u = 0; u < o.length; u++) s[o[o.length - u - 1]] = u;
    return function(c) {
      return i(c, s);
    };
  };
}(Wn || (Wn = {})), function(e) {
  e.create = function(t) {
    return t;
  }, e.has = function(t, r) {
    return !!(t & r);
  }, e.hasAll = function(t, r) {
    return !!r && (t & r) === r;
  };
}(Ti || (Ti = {})), function(e) {
  e.create = function(a) {
    return a === void 0 && (a = 512), { current: [], offset: 0, capacity: a, chunks: [] };
  }, e.getString = function(a) {
    return a.chunks.length ? (a.offset > 0 && (a.chunks[a.chunks.length] = a.current.length === a.offset ? a.current.join("") : a.current.slice(0, a.offset).join("")), a.chunks.join("")) : a.current.length === a.offset ? a.current.join("") : a.current.splice(0, a.offset).join("");
  }, e.getSize = function(a) {
    for (var i = 0, o = 0, s = a.chunks; o < s.length; o++)
      i += s[o].length;
    for (var u = 0; u < a.offset; u++) i += a.current[u].length;
    return i;
  }, e.getChunks = function(a) {
    return a.offset > 0 && (a.current.length === a.offset ? a.chunks[a.chunks.length] = a.current.join("") : a.chunks[a.chunks.length] = a.current.slice(0, a.offset).join(""), a.offset = 0), a.chunks;
  };
  var t = [];
  function r(a, i) {
    i > 0 && n(a, t[i]);
  }
  function n(a, i) {
    a.offset === a.capacity && (a.chunks[a.chunks.length] = a.current.join(""), a.offset = 0), a.current[a.offset++] = i;
  }
  (function() {
    for (var a = "", i = 0; i < 512; i++) t[i] = a, a += " ";
  })(), e.newline = function(a) {
    n(a, `
`);
  }, e.whitespace = r, e.whitespace1 = function(a) {
    n(a, " ");
  }, e.write = function(a, i) {
    i && (a.offset === a.capacity && (a.chunks[a.chunks.length] = a.current.join(""), a.offset = 0), a.current[a.offset++] = i);
  }, e.writeSafe = n, e.writePadLeft = function(a, i, o) {
    i ? (r(a, o - i.length), n(a, i)) : r(a, o);
  }, e.writePadRight = function(a, i, o) {
    if (i) {
      var s = o - i.length;
      n(a, i), r(a, s);
    } else r(a, o);
  }, e.writeInteger = function(a, i) {
    n(a, "" + i);
  }, e.writeIntegerAndSpace = function(a, i) {
    n(a, i + " ");
  }, e.writeIntegerPadLeft = function(a, i, o) {
    var s = "" + i;
    r(a, o - s.length), n(a, s);
  }, e.writeIntegerPadRight = function(a, i, o) {
    var s = "" + i, u = o - s.length;
    n(a, s), r(a, u);
  }, e.writeFloat = function(a, i, o) {
    n(a, "" + Math.round(o * i) / o);
  }, e.writeFloatPadLeft = function(a, i, o, s) {
    var u = "" + Math.round(o * i) / o;
    r(a, s - u.length), n(a, u);
  }, e.writeFloatPadRight = function(a, i, o, s) {
    var u = "" + Math.round(o * i) / o, c = s - u.length;
    n(a, u), r(a, c);
  };
}(Rr || (Rr = {})), function(e) {
  var t = typeof btoa < "u" ? btoa : function(n) {
    return Buffer.from(n).toString("base64");
  }, r = [];
  e.create22 = function() {
    for (var n = +/* @__PURE__ */ new Date() + ga(), a = 0; a < 16; a++) r[a] = String.fromCharCode((n + 255 * Math.random()) % 255 | 0), n = Math.floor(n / 255);
    return t(r.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }, e.createv4 = function() {
    var n = +/* @__PURE__ */ new Date() + ga(), a = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i) {
      var o = (n + 16 * Math.random()) % 16 | 0;
      return n = Math.floor(n / 16), (i === "x" ? o : 3 & o | 8).toString(16);
    });
    return a;
  }, e.is = function(n) {
    return typeof n == "string";
  };
}(Fa || (Fa = {})), function(e) {
  var t = function() {
    function u() {
      this.size = 0;
    }
    return u.prototype.has = function(c) {
      return !1;
    }, u.prototype.forEach = function(c, l) {
      return l;
    }, u;
  }(), r = function() {
    function u(c) {
      this.idx = c, this.size = 1;
    }
    return u.prototype.has = function(c) {
      return c === this.idx;
    }, u.prototype.forEach = function(c, l) {
      return c(this.idx, l), l;
    }, u;
  }(), n = function() {
    function u(c, l) {
      this.mask = c, this.size = l, this.length = c.length;
    }
    return u.prototype.has = function(c) {
      return c < this.length && !!this.mask[c];
    }, u.prototype._forEach = function(c, l) {
      for (var d = 0; d < this.length; d++) this.mask[d] && c(d, l);
    }, u.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, u;
  }(), a = function() {
    function u(c) {
      this.size = c;
    }
    return u.prototype.has = function(c) {
      return !0;
    }, u.prototype._forEach = function(c, l) {
      for (var d = 0; d < this.size; d++) c(d, l);
    }, u.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, u;
  }(), i = function() {
    function u(c) {
      this.set = c, this._flat = void 0, this.size = c.size;
    }
    return u.prototype.has = function(c) {
      return this.set.has(c);
    }, u.prototype._forEach = function(c, l) {
      for (var d = 0, f = this.flatten(); d < f.length; d++)
        c(f[d], l);
    }, u.prototype.flatten = function() {
      if (this._flat) return this._flat;
      var c = new Int32Array(this.size), l = 0;
      return this.set.forEach(function(d) {
        return c[l++] = d;
      }), function(d) {
        Array.prototype.sort.call(d, kZ);
      }(c), this._flat = c, this._flat;
    }, u.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, u;
  }();
  function o(u) {
    return new i(u);
  }
  function s(u, c) {
    return new n(u, c);
  }
  e.always = function(u) {
    return new a(u);
  }, e.never = new t(), e.ofSet = o, e.singleton = function(u) {
    return new r(u);
  }, e.ofUniqueIndices = function(u) {
    var c = u.length;
    if (c === 0) return new t();
    if (c === 1) return new r(u[0]);
    for (var l = 0, d = 0, f = u; d < f.length; d++)
      (g = f[d]) > l && (l = g);
    if (c === l) return new a(c);
    if (c / l < 1 / 12) {
      for (var m = /* @__PURE__ */ new Set(), h = 0, p = u; h < p.length; h++) {
        var g = p[h];
        m.add(g);
      }
      return new i(m);
    }
    for (var v = new Int8Array(l + 1), y = 0, _ = u; y < _.length; y++)
      v[g = _[y]] = 1;
    return new n(v, u.length);
  }, e.ofMask = s, e.hasAny = function(u, c) {
    for (var l = 0, d = c; l < d.length; l++) {
      var f = d[l];
      if (u.has(f)) return !0;
    }
    return !1;
  }, e.complement = function(u, c) {
    var l = 0, d = 0;
    if (c.forEach(function(h) {
      u.has(h) || (l++, h > d && (d = h));
    }), l / d < 1 / 12) {
      var f = /* @__PURE__ */ new Set();
      return c.forEach(function(h) {
        u.has(h) || f.add(h);
      }), o(f);
    }
    var m = new Uint8Array(d + 1);
    return c.forEach(function(h) {
      u.has(h) || (m[h] = 1);
    }), s(m, l);
  };
}(Mw || (Mw = {})), function(e) {
  e.create = function(t) {
    return { ref: t };
  }, e.set = function(t, r) {
    return t.ref = r, t;
  };
}(V0 || (V0 = {}));
var _d, U, zZ = $i(0, 2147483647);
function ui() {
  return ui.zero();
}
function Qu() {
  return Qu.zero();
}
function Qe(e) {
  return e;
}
function yr(e, t, r, n) {
  return { label: e, description: r, list: n, type: t };
}
function cm(e, t, r) {
  var n = {};
  for (var a in e) {
    var i = e[a];
    i = Qe.saturate(i, t), i = Qe.darken(i, -r), n[a] = i;
  }
  return n;
}
(function(e) {
  e.create = function(t, r) {
    return { id: zZ(), version: 0, value: t, metadata: r };
  }, e.withValue = function(t, r) {
    return { id: t.id, version: t.version + 1, value: r, metadata: t.metadata };
  };
})(_d || (_d = {})), function(e) {
  function t(r, n) {
    return V0.set(r, _d.withValue(r.ref, n));
  }
  e.create = function(r, n) {
    return V0.create(_d.create(r, n));
  }, e.update = t, e.set = function(r, n) {
    return V0.set(r, n);
  }, e.updateIfChanged = function(r, n) {
    return r.ref.value !== n ? t(r, n) : r;
  };
}(U || (U = {})), function(e) {
  function t() {
    var y = [0.1, 0, 0];
    return y[0] = 0, y;
  }
  function r(y, _) {
    var S = _[0], b = _[1], x = _[2], A = Math.sqrt(b * b + x * x), w = (Bi(Math.atan2(x, b)) + 360) % 360;
    return Math.round(1e4 * A) === 0 && (w = Number.NaN), y[0] = w, y[1] = A, y[2] = S, y;
  }
  function n(y, _, S) {
    return y[0] = _[0] - o * S, y[1] = _[1], y[2] = _[2], y;
  }
  e.zero = t, e.create = function(y, _, S) {
    var b = t();
    return b[0] = y, b[1] = _, b[2] = S, b;
  }, e.fromColor = function(y, _) {
    var S = Qe.toRgb(_), b = function(M, T, N) {
      M = g(M), T = g(T), N = g(N);
      var I = v((0.4124564 * M + 0.3575761 * T + 0.1804375 * N) / s), P = v((0.2126729 * M + 0.7151522 * T + 0.072175 * N) / u), O = v((0.0193339 * M + 0.119192 * T + 0.9503041 * N) / c);
      return [I, P, O];
    }(S[0], S[1], S[2]), x = b[0], A = b[1], w = b[2], C = 116 * A - 16;
    return y[0] = C < 0 ? 0 : C, y[1] = 500 * (x - A), y[2] = 200 * (A - w), y;
  }, e.fromHcl = function(y, _) {
    return Qu.toLab(y, _);
  }, e.toColor = function(y) {
    var _ = (y[0] + 16) / 116, S = isNaN(y[1]) ? _ : _ + y[1] / 500, b = isNaN(y[2]) ? _ : _ - y[2] / 200;
    _ = u * p(_);
    var x = h(3.2404542 * (S = s * p(S)) - 1.5371385 * _ - 0.4985314 * (b = c * p(b))), A = h(-0.969266 * S + 1.8760108 * _ + 0.041556 * b), w = h(0.0556434 * S - 0.2040259 * _ + 1.0572252 * b);
    return Qe.fromRgb(Math.round(po(x, 0, 255)), Math.round(po(A, 0, 255)), Math.round(po(w, 0, 255)));
  }, e.toHcl = r, e.copy = function(y, _) {
    return y[0] = _[0], y[1] = _[1], y[2] = _[2], y;
  }, e.darken = n, e.lighten = function(y, _, S) {
    return n(y, _, -S);
  };
  var a = [0, 0, 0];
  function i(y, _, S) {
    return r(a, _), Qu.toLab(y, Qu.saturate(a, a, S));
  }
  e.saturate = i, e.desaturate = function(y, _, S) {
    return i(y, _, -S);
  };
  var o = 18, s = 0.95047, u = 1, c = 1.08883, l = 0.137931034, d = 0.206896552, f = 0.12841855, m = 8856452e-9;
  function h(y) {
    return 255 * (y <= 304e-5 ? 12.92 * y : 1.055 * Math.pow(y, 1 / 2.4) - 0.055);
  }
  function p(y) {
    return y > d ? y * y * y : f * (y - l);
  }
  function g(y) {
    return (y /= 255) <= 0.04045 ? y / 12.92 : Math.pow((y + 0.055) / 1.055, 2.4);
  }
  function v(y) {
    return y > m ? Math.pow(y, 1 / 3) : y / f + l;
  }
}(ui || (ui = {})), function(e) {
  function t() {
    var c = [0.1, 0, 0];
    return c[0] = 0, c;
  }
  e.zero = t, e.create = function(c, l, d) {
    var f = t();
    return f[0] = c, f[1] = l, f[2] = d, f;
  };
  var r = [0, 0, 0];
  e.fromColor = function(c, l) {
    return ui.toHcl(c, ui.fromColor(r, l));
  }, e.fromLab = function(c, l) {
    return ui.toHcl(c, l);
  };
  var n = [0, 0, 0];
  function a(c, l) {
    var d = l[0], f = l[1], m = l[2];
    return isNaN(d) && (d = 0), d = Kn(d), c[0] = m, c[1] = Math.cos(d) * f, c[2] = Math.sin(d) * f, c;
  }
  function i(c, l, d) {
    return c[0] = l[0], c[1] = Math.max(0, l[1] + u * d), c[2] = l[2], c;
  }
  e.toColor = function(c) {
    return ui.toColor(a(n, c));
  }, e.toLab = a, e.copy = function(c, l) {
    return c[0] = l[0], c[1] = l[1], c[2] = l[2], c;
  }, e.saturate = i, e.desaturate = function(c, l, d) {
    return i(c, l, -d);
  };
  var o = [0, 0, 0];
  function s(c, l, d) {
    return a(o, l), ui.toHcl(c, ui.darken(o, o, d));
  }
  e.darken = s, e.lighten = function(c, l, d) {
    return s(c, l, -d);
  };
  var u = 18;
}(Qu || (Qu = {})), function(e) {
  function t(c, l, d) {
    return c << 16 | l << 8 | d;
  }
  function r(c, l, d) {
    return 255 * c << 16 | 255 * l << 8 | 255 * d;
  }
  e.toStyle = function(c) {
    return "rgb(".concat(c >> 16 & 255, ", ").concat(c >> 8 & 255, ", ").concat(255 & c, ")");
  }, e.toHexString = function(c) {
    return "0x" + ("000000" + c.toString(16)).slice(-6);
  }, e.toRgbString = function(c) {
    return "RGB: ".concat(e.toRgb(c).join(", "));
  }, e.toRgb = function(c) {
    return [c >> 16 & 255, c >> 8 & 255, 255 & c];
  }, e.toRgbNormalized = function(c) {
    return [(c >> 16 & 255) / 255, (c >> 8 & 255) / 255, (255 & c) / 255];
  }, e.fromRgb = t, e.fromNormalizedRgb = r, e.fromArray = function(c, l) {
    return t(c[l], c[l + 1], c[l + 2]);
  }, e.fromNormalizedArray = function(c, l) {
    return r(c[l], c[l + 1], c[l + 2]);
  }, e.toArray = function(c, l, d) {
    return l[d] = c >> 16 & 255, l[d + 1] = c >> 8 & 255, l[d + 2] = 255 & c, l;
  }, e.toArrayNormalized = function(c, l, d) {
    return l[d] = (c >> 16 & 255) / 255, l[d + 1] = (c >> 8 & 255) / 255, l[d + 2] = (255 & c) / 255, l;
  }, e.toVec3 = function(c, l) {
    return c[0] = l >> 16 & 255, c[1] = l >> 8 & 255, c[2] = 255 & l, c;
  }, e.toVec3Normalized = function(c, l) {
    return c[0] = (l >> 16 & 255) / 255, c[1] = (l >> 8 & 255) / 255, c[2] = (255 & l) / 255, c;
  }, e.interpolate = function(c, l, d) {
    var f = c >> 16 & 255, m = c >> 8 & 255, h = 255 & c;
    return f + ((l >> 16 & 255) - f) * d << 16 | m + ((l >> 8 & 255) - m) * d << 8 | h + ((255 & l) - h) * d;
  };
  var n = [0, 0, 0];
  function a(c, l) {
    return Qu.fromColor(n, c), Qu.toColor(Qu.saturate(n, n, l));
  }
  e.saturate = a, e.desaturate = function(c, l) {
    return a(c, -l);
  };
  var i = [0, 0, 0];
  function o(c, l) {
    return ui.fromColor(i, c), ui.toColor(ui.darken(i, i, l));
  }
  function s(c) {
    return c < 0.04045 ? 0.0773993808 * c : Math.pow(0.9478672986 * c + 0.0521327014, 2.4);
  }
  function u(c) {
    return c < 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 0.41666) - 0.055;
  }
  e.darken = o, e.lighten = function(c, l) {
    return o(c, -l);
  }, e.sRGBToLinear = function(c) {
    return r(s((c >> 16 & 255) / 255), s((c >> 8 & 255) / 255), s((255 & c) / 255));
  }, e.linearToSRGB = function(c) {
    return r(u((c >> 16 & 255) / 255), u((c >> 8 & 255) / 255), u((255 & c) / 255));
  };
}(Qe || (Qe = {}));
var UZ = function(e) {
  return e.toUpperCase();
};
function o8(e) {
  return e.toLowerCase().replace(/^\w|\s\w/g, UZ);
}
function ac(e) {
  return o8(function(t, r) {
    return r === void 0 && (r = " "), t.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, "$1".concat(r, "$2"));
  }(function(t) {
    return t.replace(/_/g, " ");
  }(function(t) {
    return t.replace(/-/g, " ");
  }(e))));
}
function fa(e, t, r, n) {
  var a = n.length;
  if (a > r - t) return !1;
  for (var i = 0; i < a; i++) if (e.charCodeAt(t + i) !== n.charCodeAt(i)) return !1;
  return !0;
}
function s8(e) {
  return e.replace(/<\/?[^>]+>/g, "");
}
var Ye, Uo = { "orange-red": yr("Orange-Red", "sequential", "Orange-Red, sequential color scheme from ColorBrewer 2.0", [16775148, 16705736, 16635038, 16628612, 16551257, 15689032, 14102559, 11730944, 8323072]), "purple-blue": yr("Purple-Blue", "sequential", "Purple-Blue, sequential color scheme from ColorBrewer 2.0", [16775163, 15525874, 13685222, 10927579, 7645647, 3576e3, 356528, 285325, 145496]), "blue-purple": yr("Blue-Purple", "sequential", "Blue-Purple, sequential color scheme from ColorBrewer 2.0", [16252157, 14740724, 12571622, 10403034, 9213638, 9202609, 8929693, 8458108, 5046347]), oranges: yr("Oranges", "sequential", "", [16774635, 16705230, 16634018, 16625259, 16616764, 15821075, 14239745, 10892803, 8333060]), "blue-green": yr("Blue-Green", "sequential", "", [16252157, 15070713, 13429990, 10082505, 6734500, 4304502, 2329413, 27948, 17435]), "yellow-orange-brown": yr("Yellow-Orange-Brown", "sequential", "", [16777189, 16775100, 16704401, 16696399, 16685353, 15495188, 13388802, 10040324, 6694150]), "yellow-green": yr("Yellow-Green", "sequential", "", [16777189, 16252089, 14282915, 11394446, 7915129, 4303709, 2327619, 26679, 17705]), reds: yr("Reds", "sequential", "", [16774640, 16703698, 16563105, 16552562, 16476746, 15678252, 13309981, 10817301, 6750221]), "red-purple": yr("Red-Purple", "sequential", "", [16775155, 16638173, 16565696, 16424885, 16214177, 14496919, 11403646, 7995767, 4784234]), greens: yr("Greens", "sequential", "", [16252149, 15070688, 13101504, 10607003, 7652470, 4303709, 2329413, 27948, 17435]), "yellow-green-blue": yr("Yellow-Green-Blue", "sequential", "", [16777177, 15595697, 13101492, 8375739, 4306628, 1937856, 2252456, 2438292, 531800]), purples: yr("Purples", "sequential", "", [16579581, 15724021, 14342891, 12369372, 10394312, 8420794, 6967715, 5515151, 4128893]), "green-blue": yr("Green-Blue", "sequential", "", [16252144, 14742491, 13429701, 11066805, 8113348, 5157843, 2854078, 551084, 540801]), greys: yr("Greys", "sequential", "", [16777215, 15790320, 14277081, 12434877, 9868950, 7566195, 5395026, 2434341, 0]), "yellow-orange-red": yr("Yellow-Orange-Red", "sequential", "", [16777164, 16772512, 16701814, 16691788, 16616764, 16535082, 14883356, 12386342, 8388646]), "purple-red": yr("Purple-Red", "sequential", "", [16250105, 15196655, 13941210, 13210823, 14640560, 15149450, 13505110, 9961539, 6750239]), blues: yr("Blues", "sequential", "", [16251903, 14609399, 13032431, 10406625, 7057110, 4362950, 2191797, 545180, 536683]), "purple-blue-green": yr("Purple-Blue-Green", "sequential", "", [16775163, 15524592, 13685222, 10927579, 6793679, 3576e3, 164234, 93273, 83510]), spectral: yr("Spectral", "diverging", "", [10355010, 13975119, 16018755, 16625249, 16703627, 16777151, 15136152, 11263396, 6734501, 3311805, 6180770]), "red-yellow-green": yr("Red-Yellow-Green", "diverging", "", [10813478, 14102567, 16018755, 16625249, 16703627, 16777151, 14282635, 10934634, 6733155, 1742928, 26679]), "red-blue": yr("Red-Blue", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16250871, 13755888, 9618910, 4428739, 2188972, 340065]), "pink-yellow-green": yr("Pink-Yellow-Green", "diverging", "", [9306450, 12917629, 14579630, 15840986, 16638191, 16250871, 15136208, 12116358, 8371265, 5083681, 2581529]), "purple-green": yr("Purple-Green", "diverging", "", [4194379, 7744131, 10055851, 12756431, 15193320, 16250871, 14282963, 10935200, 5942881, 1800247, 17435]), "red-yellow-blue": yr("Red-Yellow-Blue", "diverging", "Red-Yellow-Blue, diverging color scheme from ColorBrewer 2.0", [10813478, 14102567, 16018755, 16625249, 16703632, 16777151, 14742520, 11262441, 7646673, 4552116, 3225237]), "brown-white-green": yr("Brown-White-Green", "diverging", "", [5517317, 9195786, 12550445, 14664317, 16181443, 16119285, 13101797, 8441281, 3512207, 91742, 15408]), "red-grey": yr("Red-Grey", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16777215, 14737632, 12237498, 8882055, 5066061, 1710618]), "orange-purple": yr("Orange-Purple", "diverging", "", [8338184, 11753478, 14713364, 16627811, 16703670, 16250871, 14211819, 11709394, 8418220, 5515144, 2949195]), "set-2": yr("Set-2", "qualitative", "", [6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), accent: yr("Accent", "qualitative", "", [8374655, 12496596, 16629894, 16777113, 3697840, 15729279, 12540695, 6710886]), "set-1": yr("Set-1", "qualitative", "", [14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329]), "set-3": yr("Set-3", "qualitative", "", [9294791, 16777139, 12499674, 16482418, 8434131, 16626786, 11787881, 16567781, 14277081, 12353725, 13429701, 16772463]), "dark-2": yr("Dark-2", "qualitative", "", [1810039, 14245634, 7696563, 15149450, 6727198, 15117058, 10909213, 6710886]), paired: yr("Paired", "qualitative", "", [10931939, 2062516, 11722634, 3383340, 16489113, 14883356, 16629615, 16744192, 13284054, 6962586, 16777113, 11622696]), "pastel-2": yr("Pastel-2", "qualitative", "", [11789005, 16633260, 13358568, 16042724, 15136201, 16773806, 15852236, 13421772]), "pastel-1": yr("Pastel-1", "qualitative", "", [16495790, 11783651, 13429701, 14601188, 16701862, 16777164, 15063229, 16636652, 15921906]), "many-distinct": yr("Many-Distinct", "qualitative", "", [8948459, 11646160, 16116990, 6994595, 6727198, 15117058, 10909213, 6710886, 14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329, 6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), magma: yr("Magma", "sequential", "Perceptually uniform shades of black-red-white", [4329332, 4853881, 5378684, 5903742, 6363263, 6888576, 7413633, 7938689, 8463745, 8988801, 9513600, 10038655, 10563454, 11088508, 11613562, 12138360, 12728949, 13254258, 13714030, 14239338, 14699366, 15094114, 15489119, 15753309, 16017499, 16216411, 16350045, 16483424, 16551523, 16619368, 16621934, 16689780, 16692091, 16694402, 16696969, 16633746, 16636058, 16638371, 16575148, 16577461, 16514239]), inferno: yr("Inferno", "sequential", "Perceptually uniform shades of black-red-yellow", [4721514, 5246316, 5771373, 6296430, 6821486, 7346542, 7871597, 8396651, 8921450, 9446504, 9971557, 10496610, 10956127, 11481435, 12006486, 12466258, 12926285, 13386056, 13780802, 14241085, 14570295, 14965297, 15229227, 15558693, 15757342, 15956248, 16154897, 16288267, 16421638, 16489734, 16492043, 16494612, 16496926, 16368426, 16305463, 16111429, 15982678, 15853928, 15856253, 16119953, 16580260]), plasma: yr("Plasma", "sequential", "Perceptually uniform shades of blue-red-yellow", [1771148, 2426257, 3081365, 3671193, 4195228, 4784799, 5308834, 5833124, 6357158, 6815911, 7340200, 7864744, 8324007, 8783782, 9309348, 9769377, 10164126, 10624154, 11018902, 11413393, 11808141, 12137352, 12466307, 12795519, 13124730, 13453685, 13717361, 14046573, 14309992, 14573668, 14837344, 15035483, 15299159, 15497299, 15695438, 15893834, 16091974, 16224833, 16357693, 16425017, 16557877, 16625457, 16627245, 16629289, 16631334, 16567845, 16438820, 16310052, 16115494, 15921190, 15726625]), viridis: yr("Viridis", "sequential", "Perceptually uniform shades of blue-green-yellow", [4524123, 4656994, 4658793, 4726127, 4727668, 4663929, 4599933, 4535937, 4406404, 4276870, 4081800, 3952010, 3822475, 3627148, 3497356, 3302029, 3172237, 3042446, 2912654, 2782862, 2652814, 2523022, 2393229, 2328973, 2198924, 2069132, 2004874, 2005897, 2007175, 2139525, 2337154, 2666111, 3060348, 3520376, 4045684, 4570991, 5227369, 5883748, 6605661, 7392854, 8180303, 8967495, 9819967, 10672695, 11525166, 12443174, 13295646, 14148121, 15000344, 15852828, 16639780]), cividis: yr("Cividis", "sequential", "Perceptually uniform shades of blue-green-yellow, should look effectively identical to colorblind and non-colorblind users", [11367, 12400, 537456, 1455727, 2046574, 2571629, 3031404, 3425388, 3754092, 4148075, 4476779, 4805227, 5133932, 5396844, 5725549, 5988462, 6317166, 6580079, 6843249, 7171698, 7434867, 7697781, 7960951, 8289656, 8618104, 8881272, 9209976, 9538679, 9867127, 10195830, 10524533, 10853235, 11181938, 11510640, 11839343, 12168045, 12497002, 12891240, 13219941, 13548642, 13943134, 14271834, 14666326, 14995025, 15389516, 15718470, 16112703, 16507190, 16639799]), twilight: yr("Twilight", "sequential", "Perceptually uniform shades of white-blue-black-red-white, cyclic", [14670305, 14211037, 13554648, 12766675, 11847630, 10993866, 10139847, 9351365, 8628419, 8036290, 7509952, 7048895, 6718653, 6519739, 6386105, 6252470, 6184114, 6181293, 6112935, 6044831, 5976470, 5777291, 5447293, 5052270, 4592479, 4067665, 3674181, 3281211, 3150646, 3543352, 4067644, 4657728, 5379141, 6166345, 6953549, 7741007, 8463184, 9120336, 9777743, 10304079, 10830671, 11291984, 11687762, 12083541, 12348505, 12613471, 12878439, 13077872, 13211771, 13411209, 13545111, 13809830, 14074293, 14338756, 14537169, 14735067, 14801121]), turbo: yr("Turbo", "sequential", "Improved (smooth) rainbow colormap for visualization", [4866485, 4872413, 4354034, 3770361, 3120629, 2667241, 2475736, 2611140, 3073454, 3928216, 5109892, 6487408, 8126047, 9829201, 11531332, 13167162, 14605618, 15780908, 16693543, 16753699, 16748063, 16741916, 16146200, 15026195, 13644558, 12198408, 10818563, 9833728]), rainbow: yr("Rainbow", "sequential", "", [3367393, 3516485, 16383744, 15501073, 12526114]), "red-white-blue": yr("Red-White-Blue", "diverging", "", [12526114, 16777215, 3367393]) }, Tw = Object.keys(Uo).map(function(e) {
  return [e, Uo[e].label, o8(Uo[e].type)];
});
function ul(e) {
  return e in Uo ? Uo[e] : (console.warn("unknown color list named '".concat(e, "'")), Uo["red-yellow-blue"]);
}
function Pu(e) {
  return { kind: "table-legend", table: e };
}
function A2(e, t, r) {
  return e[t] - e[r];
}
function zf(e, t, r) {
  var n = e[t];
  e[t] = e[r], e[r] = n;
}
function IO(e, t, r, n) {
  var a = r + n >> 1;
  return t(e, r, n) > 0 ? t(e, r, a) > 0 ? t(e, a, n) > 0 ? a : n : r : t(e, n, a) > 0 ? t(e, a, r) > 0 ? a : r : n;
}
function GZ(e, t, r) {
  var n = e.cmp, a = e.swap, i = e.data, o = e.parts, s = t + 1, u = r;
  for (a(i, t, IO(i, n, t, r)); n(i, u, t) > 0; ) --u;
  for (var c = t + 1; c <= u; c++) {
    var l = n(i, c, t);
    if (l > 0) {
      for (a(i, c, u), --u; n(i, u, t) > 0; ) --u;
      c--;
    } else l === 0 && (a(i, c, s), s++);
  }
  for (c = t; c < s; c++) a(i, c, t + u - c);
  o[0] = u - s + t + 1, o[1] = u;
}
function VZ(e, t, r) {
  for (var n = e.data, a = e.cmp, i = e.swap, o = t + 1; o <= r; o++) for (var s = o - 1; s >= t && a(n, s, s + 1) > 0; ) i(n, s, s + 1), s -= 1;
}
function U2(e, t, r) {
  for (var n = e.parts; t < r; ) {
    if (r - t < 16) return void VZ(e, t, r);
    GZ(e, t, r);
    var a = n[0], i = n[1];
    a - t < r - i ? (U2(e, t, a - 1), t = i + 1) : (U2(e, i + 1, r), r = a - 1);
  }
}
function qZ(e, t, r, n) {
  var a = r + 1, i = n;
  zf(e, r, IO(e, A2, r, n));
  for (var o = e[r]; e[i] > o; ) --i;
  for (var s = r + 1; s <= i; s++) {
    var u = e[s];
    if (u > o) {
      for (zf(e, s, i), --i; e[i] > o; ) --i;
      s--;
    } else u === o && (zf(e, s, a), ++a);
  }
  for (s = r; s < a; s++) zf(e, s, r + i - s);
  t[0] = i - a + r + 1, t[1] = i;
}
function HZ(e, t, r) {
  for (var n = t + 1; n <= r; n++) {
    for (var a = e[n], i = n - 1; i >= t && e[i] > a; ) e[i + 1] = e[i], i -= 1;
    e[i + 1] = a;
  }
}
function X5(e, t, r, n) {
  for (; r < n; ) {
    if (n - r < 16) return void HZ(e, r, n);
    qZ(e, t, r, n);
    var a = t[0], i = t[1];
    a - r < n - i ? (X5(e, t, r, a - 1), r = i + 1) : (X5(e, t, i + 1, n), n = a - 1);
  }
}
function Du(e, t) {
  return t === void 0 && (t = A2), function(r, n, a, i) {
    return i === void 0 && (i = A2), i === A2 ? X5(r, [0, 0], n, a - 1) : U2({ data: r, cmp: i, swap: zf, parts: [0, 0] }, n, a - 1), r;
  }(e, 0, e.length, t);
}
function TO(e, t, r, n, a) {
  return U2({ data: e, cmp: n, swap: a, parts: [0, 0] }, t, r - 1), e;
}
function KZ(e, t, r) {
  return e[t].key < e[r].key ? -1 : 1;
}
function g4(e, t, r) {
  var n = r && r.start || 0, a = r && r.end || e.length;
  if (a - n <= 0) throw new Error("Can only bucket non-empty collections.");
  return function(i, o, s, u, c) {
    for (var l = /* @__PURE__ */ new Map(), d = [], f = o(i[0]), m = !0, h = u; h < c; h++) {
      var p = o(i[h]);
      if (l.has(p)) l.get(p).count++, f !== p && (m = !1);
      else {
        var g = { key: p, count: 1, offset: h };
        l.set(p, g), d[d.length] = g;
      }
      f = p;
    }
    var v = new Int32Array(d.length + 1);
    v[d.length] = c;
    var y = !0;
    if (s) {
      h = 1;
      for (var _ = d.length; h < _; h++) if (d[h - 1].key > d[h].key) {
        y = !1;
        break;
      }
    }
    if (m && y) {
      for (h = 0; h < d.length; h++) v[h] = d[h].offset;
      return v;
    }
    s && !y && TO(d, 0, d.length, KZ, zf);
    var S = 0;
    for (h = 0; h < d.length; h++) {
      var b = d[h];
      b.offset = S, S += b.count;
    }
    var x = new Int32Array(c - u);
    for (h = u; h < c; h++) p = o(i[h]), x[(g = l.get(p)).offset++] = i[h];
    for (h = 0, _ = x.length; h < _; h++) i[h + u] = x[h];
    for (v[0] = u, h = 1; h < d.length; h++) v[h] = d[h - 1].offset + u;
    return v;
  }(e, t, !(!r || !r.sort), n, a);
}
Tw.filter(function(e) {
  return Uo[e[0]].type === "diverging" || Uo[e[0]].type === "sequential";
}), Tw.filter(function(e) {
  return Uo[e[0]].type === "qualitative";
}), function(e) {
  function t(n) {
    var a = n.growBy * n.elementSize;
    n.currentSize = a, n.currentIndex = 0, n.currentChunk = new n.ctor(a), n.allocatedSize += a, n.chunks[n.chunks.length] = n.currentChunk;
  }
  function r(n, a) {
    var i = n.ctor, o = n.chunks, s = n.currentIndex;
    if (!o.length) return new i(0);
    if (o.length === 1 && (a || s === n.allocatedSize)) return o[0];
    for (var u = 0, c = 0, l = o.length - 1; c < l; c++) u += o[c].length;
    var d = new i(u += n.currentIndex), f = 0;
    if (d.buffer) for (c = 0, l = o.length - 1; c < l; c++) d.set(o[c], f), f += o[c].length;
    else for (c = 0, l = o.length - 1; c < l; c++) {
      for (var m = o[c], h = 0, p = m.length; h < p; h++) d[f + h] = m[h];
      f += m.length;
    }
    var g = o[o.length - 1];
    if (d.buffer && s >= n.currentSize) d.set(g, f);
    else for (h = 0, p = g.length; h < p; h++) d[f + h] = g[h];
    return d;
  }
  e.is = function(n) {
    return n.creator && n.chunkSize;
  }, e.add4 = function(n, a, i, o, s) {
    n.currentIndex >= n.currentSize && t(n);
    var u = n.currentChunk, c = n.currentIndex;
    return u[c] = a, u[c + 1] = i, u[c + 2] = o, u[c + 3] = s, n.currentIndex += 4, n.elementCount++;
  }, e.add3 = function(n, a, i, o) {
    n.currentIndex >= n.currentSize && t(n);
    var s = n.currentChunk, u = n.currentIndex;
    return s[u] = a, s[u + 1] = i, s[u + 2] = o, n.currentIndex += 3, n.elementCount++;
  }, e.add2 = function(n, a, i) {
    n.currentIndex >= n.currentSize && t(n);
    var o = n.currentChunk, s = n.currentIndex;
    return o[s] = a, o[s + 1] = i, n.currentIndex += 2, n.elementCount++;
  }, e.add = function(n, a) {
    return n.currentIndex >= n.currentSize && t(n), n.currentChunk[n.currentIndex] = a, n.currentIndex += 1, n.elementCount++;
  }, e.addRepeat = function(n, a, i) {
    for (var o = 0; o < a; o++) n.currentIndex >= n.currentSize && t(n), n.currentChunk[n.currentIndex++] = i, n.elementCount++;
    return n.elementCount;
  }, e.addMany = function(n, a) {
    for (var i = n.elementSize, o = 0, s = a.length; o < s; o += i) {
      n.currentIndex >= n.currentSize && t(n);
      for (var u = n.currentChunk, c = 0; c < i; c++) u[n.currentIndex++] = a[o + c];
      n.elementCount++;
    }
    return n.elementCount;
  }, e.compact = function(n, a) {
    return a === void 0 && (a = !1), r(n, a);
  }, e._compact = r, e.create = function(n, a, i, o) {
    var s = { ctor: n, elementSize: a, growBy: Math.max(1, Math.ceil(i)), allocatedSize: 0, elementCount: 0, currentSize: 0, currentChunk: void 0, currentIndex: 0, chunks: [] };
    if (o === void 0) return s;
    if (typeof o == "number") return s.currentChunk = new n(o * a), s.allocatedSize = o * a, s.currentSize = s.currentChunk.length, s.chunks[0] = s.currentChunk, s;
    var u = o;
    if (u.length % a != 0) throw new Error("initialChunk length must be a multiple of the element size.");
    return s.currentChunk = u, s.allocatedSize = u.length, s.currentSize = u.length, s.chunks[0] = u, s;
  };
}(Ye || (Ye = {}));
var pe, Yr, j5, ya, XZ = function() {
  function e(t, r) {
    this.getHash = t, this.areEqual = r, this.id = 0, this.byHash = /* @__PURE__ */ new Map(), this.groups = [];
  }
  return e.prototype.createGroup = function(t, r) {
    var n = this.id++, a = [t];
    return this.groups[n] = a, { id: n, keys: a, value: r };
  }, e.prototype.add = function(t, r) {
    var n = this.getHash(r);
    if (this.byHash.has(n)) {
      for (var a = this.byHash.get(n), i = 0, o = a.length; i < o; i++) {
        var s = a[i];
        if (this.areEqual(r, s.value)) return s.keys[s.keys.length] = t, s.value;
      }
      var u = this.createGroup(t, r);
      return a[a.length] = u, u.value;
    }
    return u = this.createGroup(t, r), this.byHash.set(n, [u]), u.value;
  }, e;
}();
function NO(e) {
  var t = e ^ e >> 4;
  return t = (3735928559 ^ t) + (t << 5), t ^= t >> 11;
}
function d1(e, t) {
  var r = 23;
  return r = 31 * (r = 31 * r + e | 0) + t | 0, r = (3735928559 ^ (r ^= r >> 4)) + (r << 5), r ^= r >> 11;
}
function Y5(e) {
  for (var t = 0, r = 0, n = e.length; r < n; r++) t = (t << 5) - t + e.charCodeAt(r++) | 0;
  return t;
}
function eu(e, t) {
  return (e + t) * (e + t + 1) / 2 + t;
}
function G2(e, t) {
  return e < t ? eu(e, t) : eu(t, e);
}
function Zi(e) {
  for (var t = 2166136261, r = 0, n = e.length; r < n; ++r) t ^= e[r], t += (t << 1) + (t << 4) + (t << 7) + (t << 8) + (t << 24);
  return t >>> 0;
}
function V2(e, t) {
  return { start: t && t.start !== void 0 ? Math.max(Math.min(t.start, e - 1), 0) : 0, end: t && t.end !== void 0 ? Math.min(t.end, e) : e };
}
function Nh(e, t) {
  var r = t && t.array !== void 0 ? t.array : Array, n = V2(e, t), a = n.start, i = n.end;
  return { array: new r(i - a), start: a, end: i };
}
function ci(e, t, r) {
  var n = Nh(e, r);
  return function(a, i, o) {
    for (var s = 0, u = i.length; s < u; s++) i[s] = a(o + s);
    return i;
  }(t, n.array, n.start);
}
function u8(e) {
  return !!e.buffer && typeof e.byteLength == "number" && typeof e.BYTES_PER_ELEMENT == "number";
}
function q2(e, t) {
  var r = e.constructor, n = e.buffer, a = e.length, i = e.byteOffset, o = e.BYTES_PER_ELEMENT, s = V2(a, t), u = s.start, c = s.end;
  return u === 0 && c === a ? e : new r(n, i + o * u, Math.min(a, c - u));
}
function Pf(e, t, r) {
  for (; t < r && e.charCodeAt(t) === 32; ) t++;
  return Bd(e, t, r);
}
function Bd(e, t, r) {
  var n = t, a = 0, i = 1;
  for (e.charCodeAt(n) === 45 ? (i = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < r; n++) {
    var o = e.charCodeAt(n) - 48;
    if (o > 9 || o < 0) return i * a | 0;
    a = 10 * a + o | 0;
  }
  return i * a;
}
function Nw(e, t, r, n) {
  return t.charCodeAt(r) === 43 && r++, e * Math.pow(10, Bd(t, r, n));
}
function Hf(e, t, r) {
  var n = t, a = 1, i = 0, o = 0, s = 1;
  for (e.charCodeAt(n) === 45 ? (a = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < r; ) {
    var u = e.charCodeAt(n) - 48;
    if (!(u >= 0 && u < 10)) {
      if (u === -2) {
        for (++n; n < r; ) {
          if (!((u = e.charCodeAt(n) - 48) >= 0 && u < 10)) return u === 53 || u === 21 ? Nw(a * (i + o / s), e, n + 1, r) : a * (i + o / s);
          o = 10 * o + u, s *= 10, ++n;
        }
        return a * (i + o / s);
      }
      if (u === 53 || u === 21) return Nw(a * i, e, n + 1, r);
      break;
    }
    i = 10 * i + u, ++n;
  }
  return a * i;
}
function Pw(e, t, r, n) {
  return { schema: r, __array: void 0, isDefined: n === 0, rowCount: t, value: function(a) {
    return e;
  }, valueKind: function(a) {
    return n;
  }, toArray: function(a) {
    for (var i = Nh(t, a).array, o = 0, s = i.length; o < s; o++) i[o] = e;
    return i;
  }, areValuesEqual: function(a, i) {
    return !0;
  } };
}
function Xv(e) {
  var t = e.value, r = e.valueKind, n = e.areValuesEqual, a = e.rowCount;
  return { schema: e.schema, __array: void 0, isDefined: !0, rowCount: a, value: t, valueKind: r || function(i) {
    return 0;
  }, toArray: function(i) {
    for (var o = Nh(a, i), s = o.array, u = o.start, c = 0, l = s.length; c < l; c++) s[c] = t(c + u);
    return s;
  }, areValuesEqual: n || function(i, o) {
    return t(i) === t(o);
  } };
}
function Xc(e) {
  var t = e.array, r = e.schema, n = e.valueKind, a = t.length, i = r.valueType === "str" ? function(s) {
    var u = t[s];
    return typeof u == "string" ? u : "" + u;
  } : function(s) {
    return t[s];
  }, o = u8(t);
  return { schema: r, __array: t, isDefined: !0, rowCount: a, value: i, valueKind: n || function(s) {
    return 0;
  }, toArray: r.valueType === "str" ? function(s) {
    for (var u = V2(a, s), c = u.start, l = u.end, d = new (s && s.array !== void 0 ? s.array : t.constructor)(l - c), f = 0, m = l - c; f < m; f++) {
      var h = t[c + f];
      d[f] = typeof h == "string" ? h : "" + h;
    }
    return d;
  } : o ? function(s) {
    return q2(t, s);
  } : function(s) {
    var u = V2(a, s), c = u.start, l = u.end;
    if (c === 0 && l === t.length) return t;
    for (var d = new (s && s.array !== void 0 ? s.array : t.constructor)(l - c), f = 0, m = l - c; f < m; f++) d[f] = t[c + f];
    return d;
  }, areValuesEqual: function(s, u) {
    return t[s] === t[u];
  } };
}
function jZ(e, t, r) {
  return e.isDefined ? t === 0 && r === e.rowCount ? e : e.__array && u8(e.__array) ? function(n, a, i) {
    var o = q2(n.__array, { start: a, end: i }), s = n.valueKind;
    return Xc({ array: o, schema: n.schema, valueKind: function(u) {
      return s(a + u);
    } });
  }(e, t, r) : function(n, a, i) {
    var o = n.value, s = n.valueKind, u = n.areValuesEqual, c = a === 0 ? o : function(d) {
      return o(d + a);
    }, l = i - a;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: l, value: c, valueKind: a === 0 ? s : function(d) {
      return s(d + a);
    }, toArray: function(d) {
      for (var f = Nh(l, d).array, m = 0, h = f.length; m < h; m++) f[m] = o(m + a);
      return f;
    }, areValuesEqual: a === 0 ? u : function(d, f) {
      return u(d + a, f + a);
    } };
  }(e, t, r) : pe.Undefined(r - t, e.schema);
}
function YZ(e, t, r) {
  return e.rowCount === 0 || r && function(n, a) {
    if (n.length !== a) return !1;
    for (var i = 0, o = n.length; i < o; i++) if (n[i] !== i) return !1;
    return !0;
  }(t, e.rowCount) ? e : e.__array && typeof e.value(0) == typeof e.__array[0] ? function(n, a) {
    for (var i = n.__array, o = new i.constructor(a.length), s = 0, u = a.length; s < u; s++) o[s] = i[a[s]];
    var c = n.valueKind;
    return Xc({ array: o, schema: n.schema, valueKind: function(l) {
      return c(a[l]);
    } });
  }(e, t) : function(n, a) {
    var i = n.value, o = n.valueKind, s = n.areValuesEqual, u = function(l) {
      return i(a[l]);
    }, c = a.length;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: c, value: u, valueKind: function(l) {
      return o(a[l]);
    }, toArray: function(l) {
      for (var d = Nh(c, l).array, f = 0, m = d.length; f < m; f++) d[f] = i(a[f]);
      return d;
    }, areValuesEqual: function(l, d) {
      return s(a[l], a[d]);
    } };
  }(e, t);
}
function c8(e) {
  if (Array.from) return Array.from(e);
  for (var t = []; ; ) {
    var r = e.next(), n = r.done, a = r.value;
    if (n) break;
    t[t.length] = a;
  }
  return t;
}
function W5(e, t, r) {
  for (var n = t - e + 1, a = new Int32Array(n), i = 0; i < n; i++) a[i] = i + e;
  return a;
}
function WZ(e, t) {
  for (var r = new (function(i) {
    var o = i.constructor;
    if (!o) throw new Error("data does not define a constructor and it should");
    return o;
  }(e))(t.length), n = 0, a = t.length; n < a; n++) r[n] = e[t[n]];
  return r;
}
(function(e) {
  var t;
  function r(a, i) {
    return Pw(i.T, a, i, 1);
  }
  function n(a) {
    return Xv(a);
  }
  (function(a) {
    function i(o, s) {
      return s === void 0 && (s = a.float), { "@type": "tensor", T: o.create(), space: o, valueType: "tensor", baseType: s };
    }
    a.str = { "@type": "str", T: "", valueType: "str" }, a.int = { "@type": "int", T: 0, valueType: "int" }, a.coord = { "@type": "coord", T: 0, valueType: "float" }, a.float = { "@type": "float", T: 0, valueType: "float" }, a.Str = function(o) {
      return o === void 0 && (o = ""), { "@type": "str", T: o, valueType: "str" };
    }, a.Int = function(o) {
      return o === void 0 && (o = 0), { "@type": "int", T: o, valueType: "int" };
    }, a.Float = function(o) {
      return o === void 0 && (o = 0), { "@type": "float", T: o, valueType: "float" };
    }, a.Tensor = i, a.Vector = function(o, s) {
      return s === void 0 && (s = a.float), i(Wn.Vector(o, s["@type"] === "int" ? Int32Array : Float64Array), s);
    }, a.Matrix = function(o, s, u) {
      return u === void 0 && (u = a.float), i(Wn.ColumnMajorMatrix(o, s, u["@type"] === "int" ? Int32Array : Float64Array), u);
    }, a.Aliased = function(o, s) {
      return s !== void 0 ? k(k({}, o), { T: s }) : o;
    }, a.List = function(o, s, u) {
      return u === void 0 && (u = []), { "@type": "list", T: u, separator: o, itemParse: s, valueType: "list" };
    };
  })(t = e.Schema || (e.Schema = {})), e.is = function(a) {
    return !!a && !!a.schema && !!a.value;
  }, e.Undefined = r, e.ofConst = function(a, i, o) {
    return Pw(a, i, o, 0);
  }, e.ofLambda = n, e.range = function(a, i) {
    return n({ value: function(o) {
      return o + a;
    }, rowCount: Math.max(i - a + 1, 0), schema: t.int });
  }, e.ofArray = function(a) {
    return Xc(a);
  }, e.ofIntArray = function(a) {
    return Xc({ array: a, schema: t.int });
  }, e.ofFloatArray = function(a) {
    return Xc({ array: a, schema: t.float });
  }, e.ofStringArray = function(a) {
    return Xc({ array: a, schema: t.str });
  }, e.ofStringAliasArray = function(a) {
    return Xc({ array: a, schema: t.Aliased(t.str) });
  }, e.ofStringListArray = function(a, i) {
    return i === void 0 && (i = ","), Xc({ array: a, schema: t.List(i, function(o) {
      return o;
    }) });
  }, e.ofIntTokens = function(a) {
    var i = a.count, o = a.data, s = a.indices;
    return Xv({ value: function(u) {
      return Bd(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: i, schema: t.int });
  }, e.ofFloatTokens = function(a) {
    var i = a.count, o = a.data, s = a.indices;
    return Xv({ value: function(u) {
      return Hf(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: i, schema: t.float });
  }, e.ofStringTokens = function(a) {
    var i = a.count, o = a.data, s = a.indices;
    return Xv({ value: function(u) {
      var c = o.substring(s[2 * u], s[2 * u + 1]);
      return c === "." || c === "?" ? "" : c;
    }, rowCount: i, schema: t.str });
  }, e.window = function(a, i, o) {
    return jZ(a, i, o);
  }, e.view = function(a, i, o) {
    return o === void 0 && (o = !0), YZ(a, i, o);
  }, e.createFirstIndexMap = function(a) {
    return function(i) {
      for (var o = /* @__PURE__ */ new Map(), s = 0, u = i.rowCount; s < u; s++) {
        var c = i.value(s);
        o.has(c) || o.set(i.value(s), s);
      }
      return o;
    }(a);
  }, e.createIndexer = function(a) {
    return function(i) {
      for (var o = /* @__PURE__ */ new Map(), s = 0, u = i.rowCount; s < u; s++) {
        var c = i.value(s);
        o.has(c) || o.set(i.value(s), s);
      }
      return function(l) {
        return o.has(l) ? o.get(l) : -1;
      };
    }(a);
  }, e.mapToArray = function(a, i, o) {
    return function(s, u, c) {
      for (var l = new c(s.rowCount), d = 0, f = s.rowCount; d < f; d++) l[d] = u(s.value(d));
      return l;
    }(a, i, o || Array);
  }, e.areEqual = function(a, i) {
    return function(o, s) {
      return o === s || o.rowCount === s.rowCount && o.isDefined === s.isDefined && o.schema.valueType === s.schema.valueType && (o.__array && s.__array ? function(u, c) {
        for (var l = u.__array, d = c.__array, f = 0, m = u.rowCount; f < m; f++) if (l[f] !== d[f]) return !1;
        return !0;
      }(o, s) : function(u, c) {
        for (var l = u.value, d = c.value, f = 0, m = u.rowCount; f < m; f++) if (l(f) !== d(f)) return !1;
        return !0;
      }(o, s));
    }(a, i);
  }, e.indicesOf = function(a, i) {
    return function(o, s) {
      for (var u = [], c = o.value, l = 0, d = o.rowCount; l < d; l++) s(c(l)) && (u[u.length] = l);
      return u;
    }(a, i);
  }, e.asArrayColumn = function(a, i) {
    return a.__array ? a : a.isDefined ? Xc({ array: a.toArray({ array: i }), schema: a.schema, valueKind: a.valueKind }) : r(a.rowCount, a.schema);
  }, e.copyToArray = function(a, i, o) {
    if (o === void 0 && (o = 0), a.isDefined) {
      var s = a.__array;
      if (s) for (var u = 0, c = s.length; u < c; u++) i[o + u] = s[u];
      else for (u = 0, c = a.rowCount; u < c; u++) i[o + u] = a.value(u);
    }
  }, e.isIdentity = function(a) {
    for (var i = 0, o = a.rowCount; i < o; i++) if (i !== a.value(i)) return !1;
    return !0;
  };
})(pe || (pe = {})), function(e) {
  function t(n, a, i) {
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(a);
    o._rowCount = i.length, o._columns = s, o._schema = a;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      o[l] = pe.view(n[l], i);
    }
    return o;
  }
  function r(n, a) {
    for (var i = /* @__PURE__ */ Object.create(null), o = n._columns, s = 0; s < o.length; s++) {
      var u = o[s];
      i[u] = n[u].value(a);
    }
    return i;
  }
  e.is = function(n) {
    return n && typeof n._rowCount == "number" && !!n._columns && !!n._schema;
  }, e.pickColumns = function(n, a, i) {
    i === void 0 && (i = {});
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = a._rowCount, o._columns = s, o._schema = n;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      if (a[l]) o[l] = a[l];
      else {
        if (!i[l]) throw Error("Cannot find column '".concat(l, "'."));
        o[l] = i[l];
      }
    }
    return o;
  }, e.ofColumns = function(n, a) {
    var i = Object.keys(a), o = a[i[0]].rowCount;
    return k({ _rowCount: o, _columns: i, _schema: n }, a);
  }, e.ofPartialColumns = function(n, a, i) {
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = i, o._columns = s, o._schema = n;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      o[l] = l in a ? a[l] : pe.Undefined(i, n[l]);
    }
    return o;
  }, e.ofUndefinedColumns = function(n, a) {
    var i = /* @__PURE__ */ Object.create(null), o = Object.keys(n);
    i._rowCount = a, i._columns = o, i._schema = n;
    for (var s = 0, u = o; s < u.length; s++) {
      var c = u[s];
      i[c] = pe.Undefined(a, n[c]);
    }
    return i;
  }, e.ofRows = function(n, a) {
    var i = /* @__PURE__ */ Object.create(null), o = a.length, s = Object.keys(n);
    i._rowCount = o, i._columns = s, i._schema = n;
    for (var u = function(d) {
      i[d] = pe.ofLambda({ rowCount: o, schema: n[d], value: function(f) {
        return a[f][d];
      }, valueKind: function(f) {
        return a[f][d] === void 0 ? 1 : 0;
      } });
    }, c = 0, l = s; c < l.length; c++)
      u(l[c]);
    return i;
  }, e.ofArrays = function(n, a) {
    var i, o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = 0, o._columns = s, o._schema = n;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      a[l] !== void 0 ? (o[l] = pe.ofArray({ array: a[l], schema: n[l] }), o._rowCount = (i = a[l]) === null || i === void 0 ? void 0 : i.length) : o[l] = pe.Undefined(o._rowCount, n[l]);
    }
    return o;
  }, e.view = t, e.pick = function(n, a, i) {
    for (var o = [], s = 0, u = n._rowCount; s < u; ++s) i(s) && o.push(s);
    return t(n, a, o);
  }, e.window = function(n, a, i, o) {
    if (i === 0 && o === n._rowCount) return n;
    var s = /* @__PURE__ */ Object.create(null), u = Object.keys(a);
    s._rowCount = o - i, s._columns = u, s._schema = a;
    for (var c = 0, l = u; c < l.length; c++) {
      var d = l[c];
      s[d] = pe.window(n[d], i, o);
    }
    return s;
  }, e.concat = function(n, a) {
    var i = /* @__PURE__ */ Object.create(null), o = Object.keys(a);
    i._rowCount = 0;
    for (var s = 0, u = n; s < u.length; s++) {
      var c = u[s];
      i._rowCount += c._rowCount;
    }
    for (var l = {}, d = 0, f = o; d < f.length; d++)
      l[f[d]] = new Array(i._rowCount);
    i._columns = o, i._schema = a;
    for (var m = 0, h = 0, p = n; h < p.length; h++) {
      c = p[h];
      for (var g = 0, v = o; g < v.length; g++) {
        var y = v[g];
        pe.copyToArray(c[y], l[y], m);
      }
      m += c._rowCount;
    }
    for (var _ = 0, S = o; _ < S.length; _++)
      i[y = S[_]] = pe.ofArray({ array: l[y], schema: a[y] });
    return i;
  }, e.columnToArray = function(n, a, i) {
    n[a] = pe.asArrayColumn(n[a], i);
  }, e.sort = function(n, a) {
    for (var i = new Int32Array(n._rowCount), o = 0, s = i.length; o < s; o++) i[o] = o;
    Du(i, function(m, h, p) {
      return a(h, p);
    });
    var u = !0;
    for (o = 0, s = i.length; o < s; o++) if (i[o] !== o) {
      u = !1;
      break;
    }
    if (u) return n;
    var c = /* @__PURE__ */ Object.create(null);
    c._rowCount = n._rowCount, c._columns = n._columns, c._schema = n._schema;
    for (var l = 0, d = n._columns; l < d.length; l++) {
      var f = d[l];
      c[f] = pe.view(n[f], i, !1);
    }
    return c;
  }, e.areEqual = function(n, a) {
    if (n._rowCount !== a._rowCount || n._columns.length !== a._columns.length) return !1;
    for (var i = 0, o = n._columns; i < o.length; i++)
      if (!a[c = o[i]]) return !1;
    for (var s = 0, u = n._columns; s < u.length; s++) {
      var c = u[s];
      if (!pe.areEqual(n[c], a[c])) return !1;
    }
    return !0;
  }, e.getRow = r, e.pickRow = function(n, a) {
    for (var i = 0, o = n._rowCount; i < o; ++i) if (a(i)) return r(n, i);
  }, e.getRows = function(n) {
    for (var a = [], i = n._rowCount, o = 0; o < i; o++) a[o] = r(n, o);
    return a;
  }, e.toArrays = function(n) {
    for (var a = {}, i = n._columns, o = 0; o < i.length; o++) {
      var s = i[o];
      a[s] = n[s].toArray();
    }
    return a;
  }, e.formatToString = function(n) {
    var a = Rr.create(), i = n._columns, o = n._rowCount, s = 1;
    Rr.write(a, "|");
    for (var u = 0; u < i.length; u++) Rr.write(a, i[u]), Rr.write(a, "|"), s += i[u].length + 1;
    Rr.newline(a), Rr.write(a, new Array(s + 1).join("-")), Rr.newline(a);
    for (var c = 0; c < o; c++) {
      for (Rr.write(a, "|"), u = 0; u < i.length; u++) {
        var l = n[i[u]];
        l.valueKind(c) === 0 ? (Rr.write(a, l.value(c)), Rr.write(a, "|")) : Rr.write(a, ".|");
      }
      Rr.newline(a);
    }
    return Rr.getString(a);
  };
}(Yr || (Yr = {})), function(e) {
  e.ofTables = function(t, r, n) {
    var a = Object.keys(n), i = /* @__PURE__ */ Object.create(null), o = [];
    i._name = t, i._tableNames = o, i._schema = r;
    for (var s = 0, u = a; s < u.length; s++) {
      var c = u[s];
      Yr.is(n[c]) && (i[c] = n[c], o[o.length] = c);
    }
    return i;
  }, e.getTablesAsRows = function(t) {
    for (var r = {}, n = 0, a = t._tableNames; n < a.length; n++) {
      var i = a[n];
      r[i] = Yr.getRows(t[i]);
    }
    return r;
  };
}(j5 || (j5 = {})), function(e) {
  e.Zero = 0;
  var t, r, n = (t = new ArrayBuffer(8), r = new ArrayBuffer(8), { _int32: new Int32Array(t), _float64: new Float64Array(t), _int32_1: new Int32Array(r), _float64_1: new Float64Array(r) }), a = n._int32, i = n._float64, o = n._int32_1, s = n._float64_1;
  e.is = function(u) {
    return typeof u == "number";
  }, e.create = function(u, c) {
    return a[0] = u, a[1] = c, i[0];
  }, e.diff = function(u) {
    return i[0] = u, a[1] - a[0];
  }, e.fst = function(u) {
    return i[0] = u, a[0];
  }, e.snd = function(u) {
    return i[0] = u, a[1];
  }, e.areEqual = function(u, c) {
    return i[0] = u, s[0] = c, a[0] === o[0] && a[1] === o[1];
  }, e.compare = function(u, c) {
    i[0] = u, s[0] = c;
    var l = a[0] - o[0];
    return l !== 0 ? l : a[1] - o[1];
  }, e.compareInArray = function(u, c, l) {
    i[0] = u[c], s[0] = u[l];
    var d = a[0] - o[0];
    return d !== 0 ? d : a[1] - o[1];
  }, e.hashCode = function(u) {
    return i[0] = u, d1(a[0], a[1]);
  }, e.toString = function(u) {
    return i[0] = u, "(".concat(a[0], ", ").concat(a[1], ")");
  };
}(ya || (ya = {}));
var PO = ya.Zero;
function Bw(e, t) {
  return t < e ? ya.create(e, e) : ya.create(e, t + 1);
}
function l8(e, t) {
  return t <= e ? ya.create(e, e) : ya.create(e, t);
}
function ZZ(e) {
  return e < 0 ? ya.create(0, 0) : ya.create(0, e);
}
var QZ = ya.is, cl = ya.fst, zd = ya.snd, H2 = ya.fst;
function K2(e) {
  return ya.snd(e) - 1;
}
var Kf = ya.diff, $Z = ya.hashCode, JZ = ya.toString;
function eQ(e, t) {
  return ya.fst(e) <= t && t < ya.snd(e);
}
function tQ(e, t) {
  var r = cl(e);
  return t >= r && t < zd(e) ? t - r : -1;
}
function rQ(e, t) {
  return ya.fst(e) + t;
}
var Fe, nQ = ya.areEqual;
function BO(e, t) {
  var r = Kf(e), n = Kf(t);
  return r === 0 && n === 0 || r > 0 && n > 0 && K2(e) >= H2(t) && H2(e) <= K2(t);
}
function aQ(e, t) {
  return Kf(e) ? !Kf(t) || cl(e) <= cl(t) && zd(e) >= zd(t) : Kf(t) === 0;
}
function Z5(e, t) {
  var r = cl(e);
  if (t <= r) return 0;
  var n = zd(e);
  return t >= n ? n - r : t - r;
}
function iQ(e, t, r) {
  var n = cl(r), a = cl(e);
  if (t <= n + a) return n;
  var i = zd(r);
  return t >= i + a ? i : t - a;
}
function OO(e, t, r) {
  return l8(Z5(e, t), Z5(e, r + 1));
}
function oQ(e, t) {
  return BO(e, t) ? l8(Math.max(cl(e), cl(t)), Math.min(zd(e), zd(t))) : PO;
}
function sQ(e, t) {
  return Kf(OO(e, H2(t), K2(t)));
}
(function(e) {
  e.Empty = PO, e.ofSingleton = function(t) {
    return Bw(t, t);
  }, e.ofRange = Bw, e.ofBounds = l8, e.ofLength = ZZ, e.is = QZ, e.has = eQ, e.indexOf = tQ, e.getAt = rQ, e.start = cl, e.end = zd, e.min = H2, e.max = K2, e.size = Kf, e.hashCode = $Z, e.toString = JZ, e.areEqual = nQ, e.areIntersecting = BO, e.isSubInterval = aQ, e.findPredecessorIndex = Z5, e.findPredecessorIndexInInterval = iQ, e.findRange = OO, e.intersectionSize = sQ, e.intersect = oQ;
})(Fe || (Fe = {}));
var ah = [];
function uQ(e) {
  return [e];
}
function cQ(e) {
  return e;
}
function lQ(e) {
  return Du(e), e;
}
function Ow(e, t) {
  if (t < e) return [];
  for (var r = new Int32Array(t - e + 1), n = e; n <= t; n++) r[n - e] = n;
  return r;
}
function dQ(e) {
  return e && (Array.isArray(e) || !!e.buffer);
}
function FO(e) {
  return e[e.length - 1] - e[0] + 1 === e.length;
}
function Q5(e) {
  return e[0];
}
function $5(e) {
  return e[e.length - 1] + 1;
}
function fQ(e) {
  return e[0];
}
function mQ(e) {
  return e[e.length - 1];
}
function RO(e) {
  return e.length;
}
function pQ(e) {
  var t = e.length;
  return t ? t > 2 ? function(r, n, a, i) {
    var o = 23;
    return o = 31 * (o = 31 * (o = 31 * (o = 31 * o + r | 0) + n | 0) + a | 0) + i | 0, o = (3735928559 ^ (o ^= o >> 4)) + (o << 5), o ^ o >> 11;
  }(t, e[0], e[t - 1], e[t >> 1]) : function(r, n, a) {
    var i = 23;
    return i = 31 * (i = 31 * (i = 31 * i + r | 0) + n | 0) + a | 0, i = (3735928559 ^ (i ^= i >> 4)) + (i << 5), i ^ i >> 11;
  }(t, e[0], e[t - 1]) : 0;
}
function hQ(e) {
  var t = e.length;
  return t > 5 ? "[".concat(e[0], ", ").concat(e[1], ", ..., ").concat(e[t - 1], "], length ").concat(t) : "[".concat(e.join(", "), "]");
}
function LO(e, t) {
  var r = e.length;
  return r === 0 ? -1 : e[0] <= t && t <= e[r - 1] ? UO(e, t, 0, r) : -1;
}
function vQ(e, t, r) {
  return kO(e, t, Fe.start(r), Fe.end(r));
}
function kO(e, t, r, n) {
  return e.length === 0 || n <= r ? -1 : e[r] <= t && t <= e[n - 1] ? UO(e, t, r, n) : -1;
}
function gQ(e, t) {
  return LO(e, t) >= 0;
}
function zO(e, t) {
  if (e === t) return !0;
  var r = e.length;
  if (r !== t.length || e[0] !== t[0] || e[r - 1] !== t[r - 1]) return !1;
  if (FO(e)) return !0;
  r--;
  for (var n = 1; n < r; n++) if (e[n] !== t[n]) return !1;
  return !0;
}
function Uf(e, t) {
  var r = e.length;
  return t <= e[0] ? 0 : t > e[r - 1] ? r : GO(e, t, 0, r);
}
function yQ(e, t, r) {
  var n = Fe.start(r), a = Fe.end(r), i = e[n];
  return t <= i ? n : a > n && t > e[a - 1] ? a : t - i <= 11 ? function(o, s, u, c) {
    for (var l = u; l < c; l++) if (s <= o[l]) return l;
    return c;
  }(e, t, n + 1, a) : GO(e, t, n, a);
}
function bQ(e, t, r) {
  return Fe.ofBounds(Uf(e, t), Uf(e, r + 1));
}
function UO(e, t, r, n) {
  for (var a = r, i = n - 1; a <= i; ) {
    if (a + 11 > i) {
      for (var o = a; o <= i; o++) if (t === e[o]) return o;
      return -1;
    }
    var s = a + i >> 1, u = e[s];
    if (t < u) i = s - 1;
    else {
      if (!(t > u)) return s;
      a = s + 1;
    }
  }
  return -1;
}
function GO(e, t, r, n) {
  for (var a = r, i = n - 1; a < i; ) {
    if (a + 11 > i) {
      for (var o = a; o <= i; o++) if (t <= e[o]) return o;
      return i + 1;
    }
    var s = a + i >> 1, u = e[s];
    if (t < u) i = s - 1;
    else {
      if (!(t > u)) return s;
      a = s + 1;
    }
  }
  return a > i ? i + 1 : e[a] >= t ? a : a + 1;
}
function xQ(e, t) {
  if (e === t) return !0;
  for (var r = lm(e, t), n = r.startI, a = r.startJ, i = r.endI, o = r.endJ; n < i && a < o; ) {
    var s = e[n], u = t[a];
    if (s < u) n++;
    else {
      if (!(s > u)) return !0;
      a++;
    }
  }
  return !1;
}
function _Q(e, t) {
  if (e === t) return !0;
  var r = t.length, n = lm(e, t), a = n.startI, i = n.startJ, o = n.endI, s = n.endJ;
  if (s - i < r || o - a < r) return !1;
  for (var u = 0; a < o && i < s; ) {
    var c = e[a], l = t[i];
    c < l ? a++ : c > l ? i++ : (a++, i++, u++);
  }
  return u === r;
}
function VO(e, t) {
  if (e === t) return e;
  var r = e.length, n = t.length;
  if (r === 0) return t;
  if (n === 0) return e;
  if (e[0] > t[0]) return VO(t, e);
  var a = lm(e, t), i = a.startI, o = a.startJ, s = a.endI, u = a.endJ, c = d8(e, t, i, o, s, u);
  if (c === r && c === n || c === n) return e;
  if (c === r) return t;
  var l = new Int32Array(r + n - c), d = 0, f = 0, m = 0;
  for (d = 0; d < i; d++) l[m++] = e[d];
  for (; f < u && e[i] > t[f]; ) l[m++] = t[f++];
  for (; d < s && f < u; ) {
    var h = e[d], p = t[f];
    h < p ? (l[m++] = h, d++) : h > p ? (l[m++] = p, f++) : (l[m++] = h, d++, f++);
  }
  for (; d < s; d++) l[m++] = e[d];
  for (; f < u; f++) l[m++] = t[f];
  for (; d < r; d++) l[m++] = e[d];
  for (; f < n; f++) l[m++] = t[f];
  return l;
}
function SQ(e, t) {
  if (e === t) return RO(e);
  var r = lm(e, t);
  return d8(e, t, r.startI, r.startJ, r.endI, r.endJ);
}
function d8(e, t, r, n, a, i) {
  for (var o = r, s = n, u = 0; o < a && s < i; ) {
    var c = e[o], l = t[s];
    c < l ? o++ : c > l ? s++ : (o++, s++, u++);
  }
  return u;
}
function AQ(e, t) {
  if (e === t) return e;
  var r = lm(e, t), n = r.startI, a = r.startJ, i = r.endI, o = r.endJ, s = d8(e, t, n, a, i, o), u = e.length, c = t.length;
  if (!s) return ah;
  if (s === u && s === c || s === c) return t;
  if (s === u) return e;
  for (var l = new Int32Array(s), d = 0, f = n, m = a; f < i && m < o; ) {
    var h = e[f], p = t[m];
    h < p ? f++ : (h > p || (l[d++] = h, f++), m++);
  }
  return l;
}
function wQ(e, t) {
  if (e === t) return ah;
  for (var r = e.length, n = lm(e, t), a = n.startI, i = n.startJ, o = n.endI, s = n.endJ, u = a, c = i, l = 0; u < o && c < s; )
    (h = e[u]) < (p = t[c]) ? u++ : h > p ? c++ : (u++, c++, l++);
  if (!l) return e;
  if (l >= r) return ah;
  for (var d = new Int32Array(r - l), f = 0, m = 0; m < a; m++) d[f++] = e[m];
  for (u = a, c = i; u < o && c < s; ) {
    var h, p;
    (h = e[u]) < (p = t[c]) ? (d[f++] = h, u++) : (h > p || u++, c++);
  }
  for (; u < r; u++) d[f++] = e[u];
  return d;
}
function CQ(e) {
  if (e.length < 2) return e;
  for (var t = 1, r = 0, n = e.length - 1; r < n; r++) e[r] !== e[r + 1] && t++;
  if (t === e.length) return e;
  var a = new Int32Array(t), i = 0;
  for (r = 0, n = e.length - 1; r < n; r++) e[r] !== e[r + 1] && (a[i++] = e[r]);
  return a[i] = e[e.length - 1], a;
}
function EQ(e, t) {
  if (zO(e, t)) return W5(0, e.length - 1);
  for (var r = lm(e, t), n = r.startI, a = r.startJ, i = r.endI, o = r.endJ, s = n, u = a, c = 0; s < i && u < o; )
    (m = e[s]) < (h = t[u]) ? s++ : m > h ? u++ : (s++, u++, c++);
  var l = e.length;
  if (!c) return ah;
  if (c === l) return W5(0, e.length - 1);
  var d = new Int32Array(c), f = 0;
  for (s = n, u = a; s < i && u < o; ) {
    var m, h;
    (m = e[s]) < (h = t[u]) ? s++ : (m > h || (d[f++] = s, s++), u++);
  }
  return d;
}
var $e, Ic = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
function lm(e, t) {
  var r = e.length, n = t.length, a = r / n;
  return r >= 128 || n >= 128 || a <= 0.34 || a >= 2.99 ? (Ic.startI = Uf(e, Q5(t)), Ic.startJ = Uf(t, Q5(e)), Ic.endI = Uf(e, $5(t)), Ic.endJ = Uf(t, $5(e))) : (Ic.startI = 0, Ic.startJ = 0, Ic.endI = r, Ic.endJ = n), Ic;
}
(function(e) {
  e.Empty = ah, e.ofUnsortedArray = lQ, e.ofSingleton = uQ, e.ofSortedArray = cQ, e.ofRange = Ow, e.ofBounds = function(t, r) {
    return Ow(t, r - 1);
  }, e.is = dQ, e.isRange = FO, e.has = gQ, e.indexOf = LO, e.indexOfInInterval = vQ, e.indexOfInRange = kO, e.start = Q5, e.end = $5, e.min = fQ, e.max = mQ, e.size = RO, e.hashCode = pQ, e.toString = hQ, e.areEqual = zO, e.areIntersecting = xQ, e.isSubset = _Q, e.union = VO, e.intersect = AQ, e.subtract = wQ, e.findPredecessorIndex = Uf, e.findPredecessorIndexInInterval = yQ, e.findRange = bQ, e.intersectionSize = SQ, e.deduplicate = CQ, e.indicesOf = EQ;
})($e || ($e = {}));
var We, rc = Fe.Empty, DQ = Fe.ofSingleton, MQ = Fe.ofRange, IQ = Fe.ofBounds;
function Cu(e) {
  return e.length ? $e.isRange(e) ? Fe.ofRange(e[0], e[e.length - 1]) : e : rc;
}
function Xf(e) {
  return Fe.is(e) ? Fe.size(e) : $e.size(e);
}
function TQ(e, t) {
  return Fe.is(e) ? Fe.has(e, t) : $e.has(e, t);
}
function NQ(e, t) {
  return Fe.is(e) ? Fe.indexOf(e, t) : $e.indexOf(e, t);
}
function J5(e, t) {
  return Fe.is(e) ? Fe.getAt(e, t) : e[t];
}
function Bp(e) {
  return Fe.is(e) ? Fe.min(e) : $e.min(e);
}
function Op(e) {
  return Fe.is(e) ? Fe.max(e) : $e.max(e);
}
function PQ(e) {
  return Fe.is(e) ? Fe.start(e) : $e.start(e);
}
function BQ(e) {
  return Fe.is(e) ? Fe.end(e) : $e.end(e);
}
function OQ(e) {
  return Fe.is(e) ? Fe.hashCode(e) : $e.hashCode(e);
}
function FQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? Fe.areEqual(e, t) : Fw(e, t) : Fe.is(t) ? Fw(t, e) : $e.areEqual(e, t);
}
function RQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? Fe.areIntersecting(e, t) : Rw(t, e) : Fe.is(t) ? Rw(e, t) : $e.areIntersecting(e, t);
}
function LQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? Fe.isSubInterval(e, t) : function(r, n) {
    var a = Fe.min(r), i = Fe.max(r);
    if (i - a + 1 == 0) return !1;
    var o = $e.min(n), s = $e.max(n);
    return o >= a && s <= i;
  }(e, t) : Fe.is(t) ? function(r, n) {
    var a = Fe.min(n), i = Fe.max(n);
    if (i - a + 1 == 0) return !0;
    var o = $e.min(r), s = $e.max(r);
    if (a < o || i > s) return !1;
    var u = $e.findRange(r, a, i);
    return Fe.size(u) === Fe.size(n);
  }(e, t) : $e.isSubset(e, t);
}
function kQ(e, t) {
  return Fe.is(e) ? Fe.findPredecessorIndex(e, t) : $e.findPredecessorIndex(e, t);
}
function zQ(e, t, r) {
  return Fe.is(e) ? Fe.findPredecessorIndexInInterval(e, t, r) : $e.findPredecessorIndexInInterval(e, t, r);
}
function UQ(e, t, r) {
  return Fe.is(e) ? Fe.findRange(e, t, r) : $e.findRange(e, t, r);
}
function GQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? Fe.intersectionSize(e, t) : kw(t, e) : Fe.is(t) ? kw(e, t) : $e.intersectionSize(e, t);
}
function VQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? function(r, n) {
    if (Fe.areEqual(r, n)) return r;
    var a = Fe.size(r), i = Fe.size(n);
    if (!i) return r;
    if (!a) return n;
    var o, s, u, c, l = Fe.min(r), d = Fe.min(n);
    if (function(h, p) {
      var g = Xf(h), v = Xf(p);
      return g === 0 && v === 0 || g > 0 && v > 0 && Op(h) >= Bp(p) && Bp(h) <= Op(p);
    }(r, n)) return Fe.ofRange(Math.min(l, d), Math.max(Fe.max(r), Fe.max(n)));
    l < d ? (o = a, s = l, u = i, c = d) : (o = i, s = d, u = a, c = l);
    for (var f = new Int32Array(a + i), m = 0; m < o; m++) f[m] = m + s;
    for (m = 0; m < u; m++) f[m + o] = m + c;
    return Cu(f);
  }(e, t) : Lw(t, e) : Fe.is(t) ? Lw(e, t) : Cu($e.union(e, t));
}
function qQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? Fe.intersect(e, t) : zw(t, e) : Fe.is(t) ? zw(e, t) : Cu($e.intersect(e, t));
}
function HQ(e, t) {
  return Fe.is(e) ? Fe.is(t) ? function(r, n) {
    if (Fe.areEqual(r, n)) return rc;
    if (!Fe.areIntersecting(r, n)) return r;
    var a = Fe.min(r), i = Fe.max(r), o = Fe.min(n), s = Fe.max(n);
    if (i < a || s < o) return r;
    if (Fe.isSubInterval(n, r)) return rc;
    if (Fe.isSubInterval(r, n)) {
      var u = o - a, c = i - s;
      if (u <= 0) return Fe.ofRange(s + 1, s + c);
      if (c <= 0) return Fe.ofRange(a, a + u - 1);
      for (var l = new Int32Array(u + c), d = 0, f = 0; f < u; f++) l[d++] = a + f;
      for (f = 1; f <= c; f++) l[d++] = s + f;
      return Cu(l);
    }
    return a < o ? Fe.ofRange(a, o - 1) : Fe.ofRange(s + 1, i);
  }(e, t) : function(r, n) {
    var a = Fe.min(r), i = Fe.max(r);
    if (i < a) return r;
    var o = i - a + 1, s = $e.findRange(n, a, i), u = Fe.start(s), c = Fe.end(s), l = c - u;
    if (l === 0) return r;
    var d = o - l;
    if (d <= 0) return rc;
    for (var f = new Int32Array(d), m = n.length - 1, h = n[Math.min(u, m)], p = n[Math.min(c, m)], g = 0, v = a; v < h; v++) f[g++] = v;
    for (v = h; v <= p; v++) $e.indexOfInInterval(n, v, s) < 0 && (f[g++] = v);
    for (v = p + 1; v <= i; v++) f[g++] = v;
    return Cu(f);
  }(e, t) : Fe.is(t) ? function(r, n) {
    var a = Fe.min(n), i = Fe.max(n);
    if (i < a) return r;
    var o = $e.findRange(r, a, i), s = Fe.start(o), u = Fe.end(o), c = r.length - (u - s);
    if (c <= 0) return rc;
    if (c === r.length) return r;
    for (var l = new Int32Array(c), d = 0, f = 0; f < s; f++) l[d++] = r[f];
    f = u;
    for (var m = r.length; f < m; f++) l[d++] = r[f];
    return Cu(l);
  }(e, t) : Cu($e.subtract(e, t));
}
function Fw(e, t) {
  return Fe.size(e) === $e.size(t) && Fe.start(e) === $e.start(t) && Fe.end(e) === $e.end(t);
}
function Rw(e, t) {
  return e.length !== 0 && Fe.size($e.findRange(e, Fe.min(t), Fe.max(t))) !== 0;
}
function KQ(e, t) {
  return Xf(e) ? !Xf(t) || Bp(e) <= Bp(t) && Op(e) >= Op(t) : Xf(t) === 0;
}
function Lw(e, t) {
  var r = Fe.size(t);
  if (!r) return e;
  if (KQ(t, e)) return t;
  for (var n = Fe.min(t), a = Fe.max(t), i = $e.findRange(e, n, a), o = Fe.start(i), s = Fe.end(i), u = new Int32Array(o + (e.length - s) + r), c = 0, l = 0; l < o; l++) u[c++] = e[l];
  for (l = n; l <= a; l++) u[c++] = l;
  l = s;
  for (var d = e.length; l < d; l++) u[c++] = e[l];
  return Cu(u);
}
function kw(e, t) {
  if (!Fe.size(t)) return 0;
  var r = $e.findRange(e, Fe.min(t), Fe.max(t));
  return Fe.end(r) - Fe.start(r);
}
function zw(e, t) {
  if (!Fe.size(t)) return rc;
  var r = $e.findRange(e, Fe.min(t), Fe.max(t)), n = Fe.start(r), a = Fe.end(r), i = a - n;
  if (!i) return rc;
  if (i === e.length) return e;
  for (var o = new Int32Array(i), s = 0, u = n; u < a; u++) o[s++] = e[u];
  return Cu(o);
}
function XQ(e, t, r) {
  if (t === r) return e;
  var n = Xf(e), a = t.length, i = r.length;
  if (n === 0 || a === 0 || i === 0) return rc;
  for (var o = $e.findPredecessorIndex(r, t[Bp(e)]), s = $e.findPredecessorIndex(r, t[Op(e)] + 1), u = 0, c = 0, l = 0, d = o; l < n && d < s; )
    (m = t[J5(e, l)]) < (h = r[d]) ? l++ : (m > h || (u++, l++), d++);
  if (u === 0) return rc;
  if (u === a && u === i) return e;
  var f = new Int32Array(u);
  for (c = 0, l = 0, d = o; l < n && d < s; ) {
    var m, h;
    (m = t[J5(e, l)]) < (h = r[d]) ? l++ : (m > h || (f[c++] = d, l++), d++);
  }
  return Cu(f);
}
function qO(e) {
  for (var t = $e.ofSortedArray(e), r = $e.max(t), n = new Int32Array(r), a = 0, i = e.length - 1; a < i; a++) for (var o = e[a], s = e[a + 1]; o < s; o++) n[o] = a;
  return { offsets: t, index: n, count: e.length - 1 };
}
function jQ(e, t) {
  for (var r = Fe.start(t), n = new Int32Array(e.length + 1), a = 0, i = e.length; a < i; a++) n[a] = e[a] - r;
  return n[e.length] = Fe.end(t) - r, qO(n);
}
function YQ(e) {
  return e.count;
}
function WQ(e, t) {
  return e.index[t];
}
function ZQ(e, t, r) {
  var n = e.offsets, a = r >= We.max(n) ? -1 : We.findPredecessorIndex(n, r - 1);
  return We.findRange(t, We.getAt(n, a), We.getAt(n, a + 1) - 1);
}
(function(e) {
  e.Empty = rc, e.ofSingleton = DQ, e.ofRange = MQ, e.ofBounds = IQ, e.ofSortedArray = Cu, e.has = TQ, e.indexOf = NQ, e.getAt = J5, e.min = Bp, e.max = Op, e.start = PQ, e.end = BQ, e.size = Xf, e.hashCode = OQ, e.areEqual = FQ, e.areIntersecting = RQ, e.isSubset = LQ, e.union = VQ, e.intersect = qQ, e.indexedIntersect = XQ, e.subtract = HQ, e.findPredecessorIndex = kQ, e.findPredecessorIndexInInterval = zQ, e.findRange = UQ, e.intersectionSize = GQ, e.forEach = function(t, r, n) {
    return function(a, i, o) {
      if (Fe.is(a)) for (var s = Fe.min(a), u = s, c = Fe.max(a); u <= c; u++) i(u, u - s, o);
      else for (u = 0, c = a.length; u < c; u++) i(a[u], u, o);
      return o;
    }(t, r, n);
  }, e.forEachSegment = function(t, r, n, a) {
    return function(i, o, s, u) {
      if (Fe.is(i)) for (var c = 0, l = Fe.min(i), d = Fe.max(i); l <= d; l++) {
        for (var f = o(l), m = l + 1; m < d && o(m) === f; ) m++;
        l = m - 1, s(f, c, u), c++;
      }
      else for (c = 0, l = 0, d = i.length; l < d; l++) {
        for (f = o(i[l]), m = l + 1; m < d && o(i[m]) === f; ) m++;
        l = m - 1, s(f, c, u), c++;
      }
      return u;
    }(t, r, n, a);
  }, e.isInterval = function(t) {
    return Fe.is(t);
  }, e.isSortedArray = function(t) {
    return !Fe.is(t);
  }, e.toArray = function(t) {
    var r = [];
    return e.forEach(t, function(n) {
      return r.push(n);
    }), r;
  }, e.toString = function(t) {
    return function(r) {
      return Fe.is(r) ? Fe.toString(r) : $e.toString(r);
    }(t);
  };
})(We || (We = {}));
var nr, QQ = function() {
  function e(t, r, n, a) {
    this.segments = t, this.segmentMap = r, this.set = n, this.segmentMin = 0, this.segmentMax = 0, this.setRange = Fe.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = a, this.updateSegmentRange();
  }
  return e.prototype.move = function() {
    for (; this.hasNext; ) {
      if (this.updateValue()) {
        this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && Fe.size(this.setRange) > 0;
        break;
      }
      this.updateSegmentRange();
    }
    return this.value;
  }, e.prototype.updateValue = function() {
    var t = this.segments[this.segmentMin + 1], r = We.findPredecessorIndexInInterval(this.set, t, this.setRange);
    return this.value.start = Fe.start(this.setRange), this.value.end = r, this.setRange = Fe.ofBounds(r, Fe.end(this.setRange)), r > this.value.start;
  }, e.prototype.updateSegmentRange = function() {
    var t = Fe.min(this.setRange), r = Fe.max(this.setRange);
    r < t ? this.hasNext = !1 : (this.segmentMin = this.segmentMap[We.getAt(this.set, t)], this.segmentMax = this.segmentMap[We.getAt(this.set, r)], this.hasNext = this.segmentMax >= this.segmentMin);
  }, e.prototype.setSegment = function(t) {
    this.setRange = Fe.ofBounds(t.start, t.end), this.updateSegmentRange();
  }, e;
}();
function $Q(e, t, r) {
  var n = r !== void 0 ? Fe.ofBounds(r.start, r.end) : Fe.ofBounds(0, We.size(t));
  return new QQ(e.offsets, e.index, t, n);
}
(function(e) {
  e.create = qO, e.ofOffsets = jQ, e.count = YQ, e.getSegment = WQ, e.projectValue = ZQ, e.transientSegments = $Q;
})(nr || (nr = {}));
var uc, JQ = function() {
  function e(t) {
    this.head = t > 0 ? 0 : -1, this.prev = new Int32Array(t), this.next = new Int32Array(t);
    for (var r = 0; r < t; r++) this.next[r] = r + 1, this.prev[r] = r - 1;
    this.prev[0] = -1, this.next[t - 1] = -1;
  }
  return e.prototype.remove = function(t) {
    var r = this.prev, n = this.next, a = r[t], i = n[t];
    a >= 0 && (n[a] = i, r[t] = -1), i >= 0 && (r[i] = a, n[t] = -1), t === this.head && (this.head = a < 0 ? i : a);
  }, e.prototype.has = function(t) {
    return this.prev[t] >= 0 || this.next[t] >= 0 || this.head === t;
  }, e;
}();
(function(e) {
  function t() {
    return /* @__PURE__ */ new Map();
  }
  e.Empty = /* @__PURE__ */ new Map(), e.keyArray = function(r) {
    return c8(r.keys());
  }, e.Mutable = t, e.asImmutable = function(r) {
    return r;
  }, e.copy = function(r) {
    for (var n = t(), a = r.keys(); ; ) {
      var i = a.next(), o = i.done, s = i.value;
      if (o) break;
      n.set(s, r.get(s));
    }
    return n;
  }, e.addFrom = function(r, n) {
    for (var a = n.keys(); ; ) {
      var i = a.next(), o = i.done, s = i.value;
      if (o) break;
      r.set(s, n.get(s));
    }
    return r;
  };
})(uc || (uc = {}));
var X2, e$ = function() {
  function e(t) {
    this.xs = [], this.index = -1, this.length = 0, this.hasNext = !1, this.length = t.length, this.hasNext = t.length > 0, this.xs = t, this.index = -1, this.lastValue = t.length > 0 ? t[0] : void 0;
  }
  return e.prototype.move = function() {
    return ++this.index, this.lastValue = this.xs[this.index], this.hasNext = this.index < this.length - 1, this.lastValue;
  }, e;
}(), Uw = function() {
  function e(t, r) {
    this.max = r, this.value = 0, this.hasNext = !1, this.value = t - 1, this.hasNext = r >= t;
  }
  return e.prototype.move = function() {
    return ++this.value, this.hasNext = this.value < this.max, this.value;
  }, e;
}(), t$ = function() {
  function e(t) {
    this.value = t, this.hasNext = !0;
  }
  return e.prototype.move = function() {
    return this.hasNext = !1, this.value;
  }, e;
}(), r$ = function() {
  function e(t, r) {
    this.base = t, this.f = r, this.hasNext = !1, this.hasNext = t.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.f(this.base.move());
    return this.hasNext = this.base.hasNext, t;
  }, e;
}(), n$ = function() {
  function e(t, r) {
    this.base = t, this.p = r, this.hasNext = this.findNext();
  }
  return e.prototype.move = function() {
    var t = this.next;
    return this.hasNext = this.findNext(), t;
  }, e.prototype.findNext = function() {
    for (; this.base.hasNext; ) if (this.next = this.base.move(), this.p(this.next)) return !0;
    return !1;
  }, e;
}();
(function(e) {
  e.Empty = new Uw(0, -1), e.Array = function(t) {
    return new e$(t);
  }, e.Value = function(t) {
    return new t$(t);
  }, e.Range = function(t, r) {
    return new Uw(t, r);
  }, e.map = function(t, r) {
    return new r$(t, r);
  }, e.filter = function(t, r) {
    return new n$(t, r);
  }, e.forEach = function(t, r, n) {
    for (; t.hasNext; )
      if (r(t.move(), n)) return n;
    return n;
  };
})(X2 || (X2 = {}));
var cc, bo, a$ = { domain: [0, 1], reverse: !1, listOrName: "red-yellow-blue", minLabel: "", maxLabel: "" };
function f8(e) {
  return Object.keys(e);
}
function Ja(e) {
  throw new Error("unreachable");
}
function m8(e) {
  return typeof (e == null ? void 0 : e.then) == "function";
}
(function(e) {
  e.create = function(t) {
    var r = k(k({}, a$), t), n = r.domain, a = r.reverse, i = r.listOrName, o = typeof i == "string" ? ul(i).list : i, s = a ? o.slice().reverse() : o, u = s.length - 1, c = 0, l = 0, d = 0;
    function f(b, x) {
      c = (d = x) - (l = b) || 1;
    }
    f(n[0], n[1]);
    var m, h = Pa(t.minLabel, l.toString()), p = Pa(t.maxLabel, d.toString()), g = s.every(function(b) {
      return Array.isArray(b);
    });
    if (g) {
      var v = nt([], s, !0);
      v.sort(function(b, x) {
        return b[1] - x[1];
      });
      var y = v.map(function(b) {
        return b[0];
      }), _ = $e.ofSortedArray(v.map(function(b) {
        return b[1];
      })), S = y.length - 1;
      m = function(b) {
        var x = po((b - l) / c, 0, 1), A = $e.findPredecessorIndex(_, x);
        if (A === 0) return y[l];
        if (A > S) return y[S];
        var w = _[A - 1], C = po((x - w) / (_[A] - w), 0, 1);
        return Qe.interpolate(y[A - 1], y[A], C);
      };
    } else m = function(b) {
      var x = Math.min(s.length - 1, Math.max(0, (b - l) / c * u)), A = Math.floor(x), w = s[A], C = s[Math.ceil(x)];
      return Qe.interpolate(w, C, x - A);
    };
    return { color: m, colorToArray: function(b, x, A) {
      Qe.toArray(m(b), x, A);
    }, normalizedColorToArray: function(b, x, A) {
      Qe.toArrayNormalized(m(b), x, A);
    }, setDomain: f, get legend() {
      return /* @__PURE__ */ function(b, x, A) {
        return { kind: "scale-legend", minLabel: b, maxLabel: x, colors: A };
      }(h, p, s);
    } };
  };
})(cc || (cc = {})), function(e) {
  e.toArray = function(t) {
    return c8(t.values());
  }, e.isSuperset = function(t, r) {
    var n = !0;
    return r.forEach(function(a) {
      t.has(a) || (n = !1);
    }), n;
  }, e.add = function(t) {
    for (var r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
    for (var a = 0; a < r.length; a++) r[a].forEach(function(i) {
      return t.add(i);
    });
    return t;
  }, e.union = function(t, r) {
    var n = new Set(t);
    return r.forEach(function(a) {
      return n.add(a);
    }), n;
  }, e.unionMany = function() {
    for (var t = [], r = 0; r < arguments.length; r++) t[r] = arguments[r];
    if (t.length === 0) return /* @__PURE__ */ new Set();
    t.length === 1 && new Set(t[0]);
    for (var n = new Set(t[0]), a = 1, i = t.length; a < i; a++) t[a].forEach(function(o) {
      return n.add(o);
    });
    return n;
  }, e.unionManyArrays = function(t) {
    if (t.length === 0) return /* @__PURE__ */ new Set();
    for (var r = new Set(t[0]), n = 1; n < t.length; n++) for (var a = 0, i = t[n]; a < i.length; a++) {
      var o = i[a];
      r.add(o);
    }
    return r;
  }, e.intersection = function(t, r) {
    var n = /* @__PURE__ */ new Set();
    return r.forEach(function(a) {
      t.has(a) && n.add(a);
    }), n;
  }, e.areIntersecting = function(t, r) {
    var n = !1;
    return r.forEach(function(a) {
      t.has(a) && (n = !0);
    }), n;
  }, e.intersectionSize = function(t, r) {
    var n = 0;
    return r.forEach(function(a) {
      t.has(a) && (n += 1);
    }), n;
  }, e.difference = function(t, r) {
    var n = new Set(t);
    return r.forEach(function(a) {
      return n.delete(a);
    }), n;
  }, e.differenceSize = function(t, r) {
    var n = t.size;
    return t.forEach(function(a) {
      r.has(a) && (n -= 1);
    }), n;
  }, e.areEqual = function(t, r) {
    if (t.size !== r.size) return !1;
    var n = !0;
    return r.forEach(function(a) {
      t.has(a) || (n = !1);
    }), n;
  };
}(bo || (bo = {}));
var p8 = function() {
};
function ho(e, t) {
  var r = e.length;
  if (r !== t.length) return !1;
  for (var n = 0; n < r; n++) if (e[n] !== t[n]) return !1;
  return !0;
}
var HO = Object.prototype.hasOwnProperty;
function Ud(e, t) {
  if (e === t) return !0;
  var r = Array.isArray(e), n = Array.isArray(t);
  if (r && n) {
    if (e.length !== t.length) return !1;
    for (var a = 0; a < e.length; a++) if (!Ud(e[a], t[a])) return !1;
    return !0;
  }
  if (r !== n) return !1;
  if (e && t && typeof e == "object" && typeof t == "object") {
    var i = Object.keys(e);
    if (i.length !== Object.keys(t).length) return !1;
    var o = e instanceof Date, s = t instanceof Date;
    if (o && s) return e.getTime() === t.getTime();
    if (o !== s) return !1;
    var u = e instanceof RegExp, c = t instanceof RegExp;
    if (u && c) return e.toString() === t.toString();
    if (u !== c) return !1;
    for (a = 0; a < i.length; a++) if (!HO.call(t, i[a])) return !1;
    for (a = 0; a < i.length; a++) if (!Ud(e[i[a]], t[i[a]])) return !1;
    return !0;
  }
  return !1;
}
function e6(e, t) {
  if (e === t) return !0;
  var r = Array.isArray(e), n = Array.isArray(t);
  return r && n ? i$(e, t) : r === n && !(!e || !t || typeof e != "object" || typeof t != "object") && KO(e, t);
}
function KO(e, t) {
  if (e === t) return !0;
  if (!e || !t) return !1;
  var r = Object.keys(e);
  if (Object.keys(t).length !== r.length) return !1;
  for (var n = 0, a = r; n < a.length; n++) {
    var i = a[n];
    if (!HO.call(e, i) || e[i] !== t[i]) return !1;
  }
  return !0;
}
function i$(e, t) {
  if (e === t) return !0;
  if (!e || !t || e.length !== t.length) return !1;
  for (var r = 0, n = e.length; r < n; ++r) if (e[r] !== t[r]) return !1;
  return !0;
}
function Pa(e, t) {
  return e !== void 0 ? e : t;
}
function y4(e) {
  if (typeof e == "object") {
    if ("buttons" in e) return e.buttons;
    if ("which" in e) {
      var t = e.which;
      if (t === 2) return 4;
      if (t === 3) return 2;
      if (t > 0) return 1 << t - 1;
    }
  }
  return 0;
}
function Gw(e) {
  if (typeof e == "object" && "button" in e) {
    var t = e.button;
    if (t === 1) return 4;
    if (t === 2) return 2;
    if (t >= 0) return 1 << t;
  }
  return 0;
}
var Fp, $f, Vw = { noScroll: !0, noMiddleClickScroll: !0, noContextMenu: !0, noPinchZoom: !0, noTextSelect: !0, preventGestures: !1, mask: function(e, t) {
  return !0;
}, pixelScale: 1 };
function qw() {
  return { drag: new pa(), interactionEnd: new pa(), click: new pa(), move: new pa(), wheel: new pa(), pinch: new pa(), gesture: new pa(), resize: new pa(), leave: new pa(), enter: new pa(), modifiers: new pa(), key: new pa() };
}
(function(e) {
  function t(r) {
    return r === void 0 && (r = {}), { shift: !!r.shift, alt: !!r.alt, control: !!r.control, meta: !!r.meta };
  }
  e.None = t(), e.areEqual = function(r, n) {
    return r.shift === n.shift && r.alt === n.alt && r.control === n.control && r.meta === n.meta;
  }, e.size = function(r) {
    if (!r) return 0;
    var n = 0;
    return r.shift && n++, r.alt && n++, r.control && n++, r.meta && n++, n;
  }, e.create = t;
})(Fp || (Fp = {})), function(e) {
  e.has = Ti.has, e.create = Ti.create;
}($f || ($f = {}));
var t6, o$ = ["Backspace", "Delete"];
function Za() {
  return Za.zero();
}
(function(e) {
  e.create = function(t) {
    t === void 0 && (t = {});
    var r = k(k({}, Vw), t), n = r.noScroll, a = r.noContextMenu;
    return k(k({ noScroll: n, noContextMenu: a, width: 0, height: 0, pixelRatio: 1 }, qw()), { dispose: p8 });
  }, e.fromElement = function(t, r) {
    r === void 0 && (r = {});
    var n = k(k({}, Vw), r), a = n.noScroll, i = n.noMiddleClickScroll, o = n.noContextMenu, s = n.noPinchZoom, u = n.noTextSelect, c = n.mask, l = n.pixelScale, d = n.preventGestures, f = t.clientWidth * x(), m = t.clientHeight * x(), h = 0, p = 0, g = Ze(), v = Ze(), y = Ze(), _ = Ze(), S = Ze(), b = { shift: !1, alt: !1, control: !1, meta: !1 };
    function x() {
      return window.devicePixelRatio * l;
    }
    function A() {
      return k({}, b);
    }
    var w, C, M = 0, T = !1, N = $f.create(0), I = 0, P = !1, O = qw(), F = O.drag, R = O.interactionEnd, G = O.wheel, L = O.pinch, q = O.gesture, K = O.click, X = O.move, H = O.leave, W = O.enter, ee = O.resize, $ = O.modifiers, te = O.key;
    return t.addEventListener("contextmenu", re, !1), t.addEventListener("wheel", de, !1), t.addEventListener("mousedown", ue, !1), window.addEventListener("mousemove", be, !1), window.addEventListener("mouseup", Se, !1), t.addEventListener("mouseenter", Xe, !1), t.addEventListener("mouseleave", je, !1), t.addEventListener("touchstart", ce, !1), t.addEventListener("touchmove", le, !1), t.addEventListener("touchend", _e, !1), t.addEventListener("gesturechange", Ie, !1), t.addEventListener("gesturestart", Ae, !1), t.addEventListener("gestureend", Ue, !1), window.addEventListener("blur", oe), window.addEventListener("keyup", he, !1), window.addEventListener("keydown", se, !1), window.addEventListener("keypress", ge, !1), window.addEventListener("resize", ht, !1), k(k({ get noScroll() {
      return a;
    }, set noScroll(Le) {
      a = Le;
    }, get noContextMenu() {
      return o;
    }, set noContextMenu(Le) {
      o = Le;
    }, get width() {
      return f;
    }, get height() {
      return m;
    }, get pixelRatio() {
      return x();
    } }, O), { dispose: function() {
      T || (T = !0, t.removeEventListener("contextmenu", re, !1), t.removeEventListener("wheel", de, !1), t.removeEventListener("mousedown", ue, !1), window.removeEventListener("mousemove", be, !1), window.removeEventListener("mouseup", Se, !1), t.removeEventListener("mouseenter", Xe, !1), t.removeEventListener("mouseleave", je, !1), t.removeEventListener("touchstart", ce, !1), t.removeEventListener("touchmove", le, !1), t.removeEventListener("touchend", _e, !1), t.removeEventListener("gesturechange", Ie, !1), t.removeEventListener("gesturestart", Ae, !1), t.removeEventListener("gestureend", Ue, !1), window.removeEventListener("blur", oe), window.removeEventListener("keyup", he, !1), window.removeEventListener("keydown", se, !1), window.removeEventListener("keypress", ge, !1), window.removeEventListener("resize", ht, !1));
    } });
    function re(Le) {
      c(Le.clientX, Le.clientY) && o && Le.preventDefault();
    }
    function ie(Le) {
      b.alt = Le.altKey, b.shift = Le.shiftKey, b.control = Le.ctrlKey, b.meta = Le.metaKey;
    }
    function oe() {
      (N || b.shift || b.alt || b.meta || b.control) && (N = 0, b.shift = b.alt = b.control = b.meta = !1);
    }
    function se(Le) {
      var j = !1;
      !b.alt && Le.altKey && (j = !0, b.alt = !0), !b.shift && Le.shiftKey && (j = !0, b.shift = !0), !b.control && Le.ctrlKey && (j = !0, b.control = !0), !b.meta && Le.metaKey && (j = !0, b.meta = !0), j && P && $.next(A());
    }
    function he(Le) {
      var j = !1;
      b.alt && !Le.altKey && (j = !0, b.alt = !1), b.shift && !Le.shiftKey && (j = !0, b.shift = !1), b.control && !Le.ctrlKey && (j = !0, b.control = !1), b.meta && !Le.metaKey && (j = !0, b.meta = !1), j && P && $.next(A()), o$.includes(Le.key) && ge(Le);
    }
    function ge(Le) {
      te.next({ key: Le.key, modifiers: A() });
    }
    function De(Le) {
      var j = Le.touches[0], xe = Le.touches[1];
      return { clientX: (j.clientX + xe.clientX) / 2, clientY: (j.clientY + xe.clientY) / 2, pageX: (j.pageX + xe.pageX) / 2, pageY: (j.pageY + xe.pageY) / 2 };
    }
    function ae(Le) {
      var j = Le.touches[0].pageX - Le.touches[1].pageX, xe = Le.touches[0].pageY - Le.touches[1].pageY;
      return Math.sqrt(j * j + xe * xe);
    }
    function ce(Le) {
      if (Le.preventDefault(), Le.touches.length === 1) N = I = 1, J(Le.touches[0]);
      else if (Le.touches.length === 2) {
        N = 0, I = 2, J(De(Le));
        var j = ae(Le);
        h = j, L.next({ distance: j, fraction: 1, fractionDelta: 0, delta: 0, isStart: !0, buttons: N, button: I, modifiers: A() });
      } else Le.touches.length === 3 && (N = I = 8, J(De(Le)));
    }
    function _e(Le) {
      Ne();
    }
    function le(Le) {
      if (I = 0, s && (Le.preventDefault(), Le.stopPropagation(), Le.originalEvent && (Le.originalEvent.preventDefault(), Le.originalEvent.stopPropagation())), Le.touches.length === 1) N = 1, Z(Le.touches[0]);
      else if (Le.touches.length === 2) {
        var j = ae(Le), xe = h - j;
        if (Math.abs(xe) < 4) N = 2, Z(De(Le));
        else {
          N = 4, ie(Le);
          var ke = h / j;
          L.next({ delta: xe, fraction: ke, fractionDelta: p - ke, distance: j, isStart: !1, buttons: N, button: I, modifiers: A() }), p = ke;
        }
        h = j;
      } else Le.touches.length === 3 && (N = 8, Z(De(Le)));
    }
    function ue(Le) {
      ie(Le), N = y4(Le), I = Gw(Le), i && N === 4 && Le.preventDefault, J(Le);
    }
    function be(Le) {
      ie(Le), N = y4(Le), I = 0, Z(Le);
    }
    function Se(Le) {
      ie(Le), N = y4(Le), I = Gw(Le), function(j) {
        if (M = 0, !!c(j.clientX, j.clientY) && (dt(y, j), Ze.distance(y, g) < 4)) {
          var xe = j.pageX, ke = j.pageY, Je = y[0], Ct = y[1];
          K.next({ x: Je, y: Ct, pageX: xe, pageY: ke, buttons: N, button: I, modifiers: A() });
        }
      }(Le), Ne();
    }
    function Ne() {
      R.next(void 0);
    }
    function J(Le) {
      c(Le.clientX, Le.clientY) && (dt(v, Le), Ze.copy(g, v), xt(v) && (M = 1));
    }
    function Z(Le) {
      var j;
      dt(y, Le);
      var xe, ke = Le.pageX, Je = Le.pageY, Ct = y[0], At = y[1], Or = xt(y);
      if (X.next({ x: Ct, y: At, pageX: ke, pageY: Je, buttons: N, button: I, modifiers: A(), inside: Or }), M !== 0 && (u && ((j = Le.preventDefault) === null || j === void 0 || j.call(Le)), Ze.div(_, Ze.sub(_, y, v), ((xe = S)[0] = t.clientWidth, xe[1] = t.clientHeight, xe)), !(Ze.magnitude(_) < Cn))) {
        var qn = M === 1;
        if (!qn || c(Le.clientX, Le.clientY)) {
          var Xn = _[0], kn = _[1];
          F.next({ x: Ct, y: At, dx: Xn, dy: kn, pageX: ke, pageY: Je, buttons: N, button: I, modifiers: A(), isStart: qn }), Ze.copy(v, y), M = 2;
        }
      }
    }
    function de(Le) {
      if (c(Le.clientX, Le.clientY)) {
        dt(y, Le);
        var j = Le.pageX, xe = Le.pageY, ke = y[0], Je = y[1];
        a && Le.preventDefault();
        var Ct = function(At) {
          var Or = 10, qn = 40, Xn = 800, kn = 0, fn = 0, la = 0, mn = 0, pn = 0;
          return "detail" in At && (fn = At.detail), "wheelDelta" in At && (fn = -At.wheelDelta / 120), "wheelDeltaY" in At && (fn = -At.wheelDeltaY / 120), "wheelDeltaX" in At && (kn = -At.wheelDeltaX / 120), "axis" in At && At.axis === At.HORIZONTAL_AXIS && (kn = fn, fn = 0), la = kn * Or, mn = fn * Or, "deltaY" in At && (mn = At.deltaY), "deltaX" in At && (la = At.deltaX), "deltaZ" in At && (pn = At.deltaZ), (la || mn || pn) && At.deltaMode && (At.deltaMode === 1 ? (la *= qn, mn *= qn, pn *= qn) : (la *= Xn, mn *= Xn, pn *= Xn)), la && !kn && (kn = la < 1 ? -1 : 1), mn && !fn && (fn = mn < 1 ? -1 : 1), { spinX: kn, spinY: fn, dx: la, dy: mn, dz: pn };
        }(Le);
        N = I = 4, (Ct.dx || Ct.dy || Ct.dz) && G.next(k(k({ x: ke, y: Je, pageX: j, pageY: xe }, Ct), { buttons: N, button: I, modifiers: A() }));
      }
    }
    function ye(Le) {
      var j, xe;
      d && (Le.preventDefault(), (j = Le.stopImmediatePropagation) === null || j === void 0 || j.call(Le), (xe = Le.stopPropagation) === null || xe === void 0 || xe.call(Le));
    }
    function Ae(Le) {
      ye(Le), w = Le.scale, C = Le.rotation, q.next({ scale: Le.scale, rotation: Le.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0 });
    }
    function Ce(Le, j) {
      q.next({ scale: Le.scale, rotation: Le.rotation, deltaRotation: C - Le.rotation, deltaScale: w - Le.scale, isEnd: j }), C = Le.rotation, w = Le.scale;
    }
    function Ie(Le) {
      ye(Le), Ce(Le);
    }
    function Ue(Le) {
      ye(Le), Ce(Le, !0);
    }
    function Xe(Le) {
      P = !0, W.next(void 0);
    }
    function je(Le) {
      P = !1, H.next(void 0);
    }
    function ht(Le) {
      ee.next({});
    }
    function xt(Le) {
      if (t instanceof Window || t instanceof Document || t === document.body) return !0;
      var j = t.getBoundingClientRect();
      return Le[0] >= 0 && Le[1] >= 0 && Le[0] < j.width && Le[1] < j.height;
    }
    function dt(Le, j) {
      f = t.clientWidth * x(), m = t.clientHeight * x();
      var xe = j.clientX || 0, ke = j.clientY || 0, Je = t.getBoundingClientRect();
      return Le[0] = xe - Je.left, Le[1] = ke - Je.top, Le;
    }
  };
})(t6 || (t6 = {})), function(e) {
  e.zero = function() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }, e.create = function(t, r, n, a) {
    return { x: t, y: r, width: n, height: a };
  }, e.clone = function(t) {
    return k({}, t);
  }, e.copy = function(t, r) {
    return Object.assign(t, r);
  }, e.set = function(t, r, n, a, i) {
    return t.x = r, t.y = n, t.width = a, t.height = i, t;
  }, e.toVec4 = function(t, r) {
    return t[0] = r.x, t[1] = r.y, t[2] = r.width, t[3] = r.height, t;
  }, e.equals = function(t, r) {
    return t.x === r.x && t.y === r.y && t.width === r.width && t.height === r.height;
  };
}(Za || (Za = {}));
var Vu = jt();
function C0(e, t, r, n) {
  var a = r.x, i = r.y, o = r.width, s = r.height, u = t[0] - a, c = s - t[1] - 1 - i, l = t[2];
  return e[0] = 2 * u / o - 1, e[1] = 2 * c / s - 1, e[2] = 2 * l - 1, D.transformMat4(e, e, n);
}
var XO = Object.prototype.hasOwnProperty;
function s$(e, t) {
  if (!e) return !t;
  if (!t) return !1;
  var r = Object.keys(e);
  if (Object.keys(t).length !== r.length) return !1;
  for (var n = 0, a = r; n < a.length; n++) {
    var i = a[n];
    if (!XO.call(e, i) || e[i] !== t[i]) return !1;
  }
  return !0;
}
function ll(e) {
  if (e === null || typeof e != "object") return e;
  if (e instanceof Array) {
    for (var t = [], r = 0, n = e.length; r < n; r++) t[r] = ll(e[r]);
    return t;
  }
  if (typeof e == "object" && !("prototype" in e)) {
    t = {};
    for (var a in e) XO.call(e, a) && (t[a] = ll(e[a]));
    return t;
  }
  throw new Error(`Can't clone, type "`.concat(typeof e, '" unsupported'));
}
function jO(e, t) {
  if (e) for (var r = 0, n = Object.keys(e); r < n.length; r++) {
    var a = n[r];
    t(e[a], a);
  }
}
var r6 = typeof setImmediate < "u" ? typeof window < "u" ? { setImmediate: function(e) {
  for (var t, r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
  return (t = window).setImmediate.apply(t, nt([e], r, !1));
}, clearImmediate: function(e) {
  return window.clearImmediate(e);
} } : { setImmediate, clearImmediate } : function() {
  var e, t, r, n, a, i, o, s, u = (e = typeof window < "u" && window, t = typeof self < "u" && typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope && self, r = typeof global < "u" && global, e || r || t), c = {}, l = typeof document < "u" ? document : void 0, d = 1;
  function f(h) {
    delete c[h];
  }
  function m(h) {
    var p = c[h];
    f(h), function(g) {
      var v = g.callback, y = g.args;
      switch (y.length) {
        case 0:
          v();
          break;
        case 1:
          v(y[0]);
          break;
        case 2:
          v(y[0], y[1]);
          break;
        case 3:
          v(y[0], y[1], y[2]);
          break;
        default:
          v.apply(void 0, y);
      }
    }(p);
  }
  return typeof process < "u" && {}.toString.call(process) === "[object process]" ? n = function(h) {
    process.nextTick(function() {
      m(h);
    });
  } : function() {
    if (u && u.postMessage && !u.importScripts) {
      var h = !0, p = u.onmessage;
      return u.onmessage = function() {
        h = !1;
      }, u.postMessage("", "*"), u.onmessage = p, h;
    }
  }() ? (o = "setImmediate$" + Math.random() + "$", s = function(h) {
    h.source === u && typeof h.data == "string" && h.data.indexOf(o) === 0 && m(+h.data.slice(o.length));
  }, window.addEventListener ? window.addEventListener("message", s, !1) : window.attachEvent("onmessage", s), n = function(h) {
    window.postMessage(o + h, "*");
  }) : typeof MessageChannel < "u" ? ((i = new MessageChannel()).port1.onmessage = function(h) {
    m(h.data);
  }, n = function(h) {
    i.port2.postMessage(h);
  }) : l && "onreadystatechange" in l.createElement("script") ? (a = l.documentElement, n = function(h) {
    var p = l.createElement("script");
    p.onreadystatechange = function() {
      m(h), p.onreadystatechange = null, a.removeChild(p), p = null;
    }, a.appendChild(p);
  }) : n = function(h) {
    setTimeout(m, 0, h);
  }, { setImmediate: function(h) {
    for (var p = [], g = 1; g < arguments.length; g++) p[g - 1] = arguments[g];
    typeof h != "function" && (h = new Function("" + h));
    var v = { callback: h, args: p };
    return c[d] = v, n(d), d++;
  }, clearImmediate: f };
}();
function u$(e) {
  r6.setImmediate(e);
}
var q0, h8 = { setImmediate: r6.setImmediate, clearImmediate: r6.clearImmediate, immediatePromise: function() {
  return new Promise(u$);
}, delay: function(e, t) {
  return t === void 0 && (t = void 0), new Promise(function(r) {
    return setTimeout(r, e, t);
  });
} }, YO = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), zr = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), b4 = typeof performance < "u" && !!performance.mark && performance.measure && !YO;
function c$(e, t, r) {
  r === void 0 && (r = 250);
  var n = function(a, i, o) {
    var s = { abortRequested: !1, treeAborted: !1, reason: "" };
    return { updateRateMs: o, lastNotified: ga(), observer: i, abortToken: s, taskId: a.id, root: { progress: WO(a), children: [] }, tryAbort: l$(s) };
  }(e, t, r);
  return v8(e, new d$(n, n.root));
}
function WO(e) {
  return { taskId: e.id, taskName: e.name, message: "", startedTime: 0, canAbort: !0, isIndeterminate: !0, current: 0, max: 0 };
}
function l$(e) {
  return function(t) {
    e.abortRequested = !0, e.reason = t || e.reason;
  };
}
function ZO(e) {
  return { progress: k({}, e.progress), children: e.children.map(ZO) };
}
function QO(e) {
  return e.progress.canAbort && e.children.every(QO);
}
function v8(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          q0.markStart(e), t.node.progress.startedTime = ga(), a.label = 1;
        case 1:
          return a.trys.push([1, 3, , 7]), [4, e.f(t)];
        case 2:
          return r = a.sent(), q0.markEnd(e), q0.measure(e), t.info.abortToken.abortRequested && $O(t.info), [2, r];
        case 3:
          return n = a.sent(), sr.isAbort(n) ? (t.isAborted = !0, t.node.children.length > 0 ? [4, new Promise(function(i) {
            t.onChildrenFinished = i;
          })] : [3, 5]) : [3, 6];
        case 4:
          a.sent(), a.label = 5;
        case 5:
          e.onAbort && e.onAbort(), a.label = 6;
        case 6:
          throw n;
        case 7:
          return [2];
      }
    });
  });
}
function $O(e) {
  throw e.abortToken.treeAborted || (e.abortToken.treeAborted = !0, JO(e.root), eF(e, ga())), sr.Aborted(e.abortToken.reason);
}
function JO(e) {
  var t = e.progress;
  t.isIndeterminate = !0, t.canAbort = !1, t.message = "Aborting...";
  for (var r = 0, n = e.children; r < n.length; r++)
    JO(n[r]);
}
function eF(e, t) {
  e.lastNotified = t;
  var r = function(n) {
    return { root: ZO(n.root), canAbort: QO(n.root), requestAbort: n.tryAbort };
  }(e);
  e.observer(r);
}
(function(e) {
  function t(n) {
    return "startTask".concat(n.id);
  }
  function r(n) {
    return "endTask".concat(n.id);
  }
  e.markStart = function(n) {
    b4 && performance.mark(t(n));
  }, e.markEnd = function(n) {
    b4 && performance.mark(r(n));
  }, e.measure = function(n) {
    b4 && performance.measure("✳️ ".concat(n.name), t(n), r(n));
  };
})(q0 || (q0 = {}));
var sr, Hw, Kw, d$ = function() {
  function e(t, r) {
    this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = r, this.info = t;
  }
  return e.prototype.checkAborted = function() {
    this.info.abortToken.abortRequested && (this.isAborted = !0, $O(this.info));
  }, Object.defineProperty(e.prototype, "shouldUpdate", { get: function() {
    return this.checkAborted(), ga() - this.lastUpdatedTime > this.info.updateRateMs;
  }, enumerable: !1, configurable: !0 }), e.prototype.updateProgress = function(t) {
    if (this.checkAborted(), t) {
      var r = this.node.progress;
      typeof t == "string" ? (r.message = t, r.isIndeterminate = !0) : (t.canAbort !== void 0 && (r.canAbort = t.canAbort), t.message !== void 0 && (r.message = t.message), t.current !== void 0 && (r.current = t.current), t.max !== void 0 && (r.max = t.max), r.isIndeterminate = r.current === void 0 || r.max === void 0, t.isIndeterminate !== void 0 && (r.isIndeterminate = t.isIndeterminate));
    }
  }, e.prototype.update = function(t, r) {
    if (this.lastUpdatedTime = ga(), this.updateProgress(t), !r) return eF(this.info, this.lastUpdatedTime), this.checkAborted(), h8.immediatePromise();
  }, e.prototype.runChild = function(t, r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c;
      return Te(this, function(l) {
        switch (l.label) {
          case 0:
            this.updateProgress(r), n = { progress: WO(t), children: [] }, (a = this.node.children).push(n), i = new e(this.info, n), l.label = 1;
          case 1:
            return l.trys.push([1, 3, 4, 5]), [4, v8(t, i)];
          case 2:
            return [2, l.sent()];
          case 3:
            if (o = l.sent(), sr.isAbort(o) && this.isAborted) return [2, void 0];
            throw o;
          case 4:
            if ((s = a.indexOf(n)) >= 0) {
              for (u = s, c = a.length - 1; u < c; u++) a[u] = a[u + 1];
              a.pop();
            }
            return a.length === 0 && this.onChildrenFinished && this.onChildrenFinished(), [7];
          case 5:
            return [2];
        }
      });
    });
  }, e;
}(), fs = new (function() {
  function e() {
    this.shouldUpdate = !1, this.isSynchronous = !0;
  }
  return e.prototype.update = function(t, r) {
  }, e;
}())();
function ih(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s, u, c, l, d;
    return Te(this, function(f) {
      switch (f.label) {
        case 0:
          if (i = Math.max(t, 0), o = 0, s = 0, e.isSynchronous) return n(Number.MAX_SAFE_INTEGER, r), [2, r];
          u = ga(), c = 0, l = 0, f.label = 1;
        case 1:
          return (c = n(i, r)) > 0 ? (o += c, d = ga() - u, l += d, s += d, e.shouldUpdate ? [4, a(e, r, o)] : [3, 3]) : [3, 4];
        case 2:
          f.sent(), i = Math.round(l * o / s) + 1, u = ga(), l = 0, f.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return e.shouldUpdate ? [4, a(e, r, o)] : [3, 6];
        case 5:
          f.sent(), f.label = 6;
        case 6:
          return [2, r];
      }
    });
  });
}
function Sd(e, t) {
  return e[t] | e[t + 1] << 8;
}
function Rf(e, t) {
  return 16777216 * e[t + 3] + (e[t + 2] << 16 | e[t + 1] << 8 | e[t]);
}
function f$(e) {
  return e.length < 2 ? "0" + e : e;
}
function m$(e, t, r) {
  for (var n, a = "", i = 0; i < r; i++) a += "%" + f$(e[t + i].toString(16));
  try {
    n = decodeURIComponent(a);
  } catch {
    return function(s, u, c) {
      for (var l = "", d = 0; d < c; d++) l += String.fromCharCode(s[u + d]);
      return l;
    }(e, t, r);
  }
  return n;
}
(function(e) {
  var t = function() {
    function i(o, s, u) {
      this.name = o, this.f = s, this.onAbort = u, this.id = a();
    }
    return i.prototype.run = function(o, s) {
      return s === void 0 && (s = 250), o ? c$(this, o, s) : this.f(fs);
    }, i.prototype.runAsChild = function(o, s) {
      return o.isSynchronous ? this.f(fs) : function(u, c, l) {
        return u.runChild(c, l);
      }(o, this, s);
    }, i.prototype.runInContext = function(o) {
      return o.isSynchronous ? this.f(fs) : function(s, u) {
        return v8(u, s);
      }(o, this);
    }, i;
  }();
  function r(i) {
    var o = i;
    return !!i && typeof o.id == "number" && typeof o.name == "string" && !!o.run;
  }
  function n(i, o, s) {
    return new t(i, o, s);
  }
  e.is = r, e.isAbort = function(i) {
    return !!i && !!i.isAborted;
  }, e.Aborted = function(i) {
    return { isAborted: !0, reason: i, toString: function() {
      return "Aborted".concat(i ? ": " + i : "");
    } };
  }, e.create = n, e.constant = function(i, o) {
    var s = this;
    return n(i, function(u) {
      return Be(s, 0, void 0, function() {
        return Te(this, function(c) {
          return [2, o];
        });
      });
    });
  }, e.empty = function() {
    var i = this;
    return n("", function(o) {
      return Be(i, 0, void 0, function() {
        return Te(this, function(s) {
          return [2];
        });
      });
    });
  }, e.fail = function(i, o) {
    var s = this;
    return n(i, function(u) {
      return Be(s, 0, void 0, function() {
        return Te(this, function(c) {
          throw new Error(o);
        });
      });
    });
  }, e.resolveInContext = function(i, o) {
    return r(i) ? o ? i.runInContext(o) : i.run() : i;
  };
  var a = $i(0, 1073741823);
})(sr || (sr = {})), function(e) {
  e.Synchronous = fs;
}(Hw || (Hw = {})), function(e) {
  function t(r, n) {
    n === void 0 && (n = "");
    var a = r.progress;
    if (!r.children.length) return a.isIndeterminate ? "".concat(n).concat(a.taskName, ": ").concat(a.message) : "".concat(n).concat(a.taskName, ": [").concat(a.current, "/").concat(a.max, "] ").concat(a.message);
    var i = n + "  |_ ", o = r.children.map(function(s) {
      return t(s, i);
    });
    return a.isIndeterminate ? "".concat(n).concat(a.taskName, ": ").concat(a.message, `
`).concat(o.join(`
`)) : "".concat(n).concat(a.taskName, ": [").concat(a.current, "/").concat(a.max, "] ").concat(a.message, `
`).concat(o.join(`
`));
  }
  e.format = function(r) {
    return t(r.root);
  };
}(Kw || (Kw = {}));
var p$ = function() {
  for (var e = new Uint32Array(256), t = 0; t < 256; t++) {
    for (var r = t, n = 0; n < 8; n++) 1 & r ? r = 3988292384 ^ r >>> 1 : r >>>= 1;
    e[t] = r;
  }
  return e;
}();
function h$(e, t, r) {
  return 4294967295 ^ function(n, a, i, o) {
    for (var s = 0; s < o; s++) n = p$[255 & (n ^ a[i + s])] ^ n >>> 8;
    return n;
  }(4294967295, e, t, r);
}
var Ts, zm, tr = (Ts = Uint16Array, zm = Uint32Array, { next_code: new Ts(16), bl_count: new Ts(16), ordr: [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], of0: [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 999, 999, 999], exb: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0], ldef: new Ts(32), df0: [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 65535, 65535], dxb: [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0], ddef: new zm(32), flmap: new Ts(512), fltree: [], fdmap: new Ts(32), fdtree: [], lmap: new Ts(32768), ltree: [], ttree: [], dmap: new Ts(32768), dtree: [], imap: new Ts(512), itree: [], rev15: new Ts(32768), lhst: new zm(286), dhst: new zm(30), ihst: new zm(19), lits: new zm(15e3), strt: new Ts(65536), prev: new Ts(32768) });
function H0(e, t, r) {
  for (var n = e.length, a = tr.rev15, i = 0; i < n; i += 2) if (e[i + 1] !== 0) for (var o = i >> 1, s = e[i + 1], u = o << 4 | s, c = t - s, l = e[i] << c, d = l + (1 << c); l !== d; )
    r[a[l] >>> 15 - t] = u, l++;
}
function K0(e, t) {
  for (var r = e.length, n = tr.bl_count, a = 0; a <= t; a++) n[a] = 0;
  for (a = 1; a < r; a += 2) n[e[a]]++;
  var i = tr.next_code, o = 0;
  n[0] = 0;
  for (var s = 1; s <= t; s++) o = o + n[s - 1] << 1, i[s] = o;
  for (var u = 0; u < r; u += 2) {
    var c = e[u + 1];
    c !== 0 && (e[u] = i[c], i[c]++);
  }
}
function Xw(e, t) {
  for (var r = tr.rev15, n = 15 - t, a = 0; a < e.length; a += 2) {
    var i = e[a] << t - e[a + 1];
    e[a] = r[i] >>> n;
  }
}
function v$(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          if (t[0] === 3 && t[1] === 0) return [2, r || new Uint8Array(0)];
          n = function(i, o) {
            var s = o === void 0;
            return o === void 0 && (o = new Uint8Array(i.length >>> 2 << 3)), { data: i, buf: o, noBuf: s, BFINAL: 0, off: 0, pos: 0 };
          }(t, r), a.label = 1;
        case 1:
          return n.BFINAL !== 0 ? [3, 4] : e.shouldUpdate ? [4, e.update({ message: "Inflating blocks...", current: n.pos, max: t.length })] : [3, 3];
        case 2:
          a.sent(), a.label = 3;
        case 3:
          return function(i, o) {
            for (var s = i.data, u = i.noBuf, c = i.buf, l = i.BFINAL, d = i.off, f = i.pos, m = 0; l === 0 && m < o; ) {
              var h = void 0, p = void 0, g = 0, v = 0;
              l = _4(s, f, 1), m += 1;
              var y = _4(s, f + 1, 2);
              if (f += 3, y !== 0) {
                if (u && (c = x4(c, d + (1 << 17))), y === 1) h = tr.flmap, p = tr.fdmap, g = 511, v = 31;
                else {
                  if (y !== 2) throw new Error("unknown BTYPE ".concat(y));
                  var _ = pd(s, f, 5) + 257, S = pd(s, f + 5, 5) + 1, b = pd(s, f + 10, 4) + 4;
                  f += 14;
                  for (var x = 0; x < 38; x += 2) tr.itree[x] = 0, tr.itree[x + 1] = 0;
                  var A = 1;
                  for (x = 0; x < b; x++) {
                    var w = pd(s, f + 3 * x, 3);
                    tr.itree[1 + (tr.ordr[x] << 1)] = w, w > A && (A = w);
                  }
                  f += 3 * b, K0(tr.itree, A), H0(tr.itree, A, tr.imap), h = tr.lmap, p = tr.dmap, f = g$(tr.imap, (1 << A) - 1, _ + S, s, f, tr.ttree);
                  var C = jw(tr.ttree, 0, _, tr.ltree);
                  g = (1 << C) - 1;
                  var M = jw(tr.ttree, _, S, tr.dtree);
                  v = (1 << M) - 1, K0(tr.ltree, C), H0(tr.ltree, C, h), K0(tr.dtree, M), H0(tr.dtree, M, p);
                }
                for (; ; ) {
                  var T = h[n6(s, f) & g];
                  f += 15 & T;
                  var N = T >>> 4;
                  if (!(N >>> 8)) c[d++] = N;
                  else {
                    if (N === 256) break;
                    var I = d + N - 254;
                    if (N > 264) {
                      var P = tr.ldef[N - 257];
                      I = d + (P >>> 3) + pd(s, f, 7 & P), f += 7 & P;
                    }
                    var O = p[n6(s, f) & v];
                    f += 15 & O;
                    var F = O >>> 4, R = tr.ddef[F], G = (R >>> 4) + _4(s, f, 15 & R);
                    for (f += 15 & R, u && (c = x4(c, d + (1 << 17))); d < I; ) c[d] = c[d++ - G], c[d] = c[d++ - G], c[d] = c[d++ - G], c[d] = c[d++ - G];
                    d = I;
                  }
                }
              } else {
                7 & f && (f += 8 - (7 & f));
                var L = 4 + (f >>> 3), q = s[L - 4] | s[L - 3] << 8;
                u && (c = x4(c, d + q)), c.set(new Uint8Array(s.buffer, s.byteOffset + L, q), d), f = L + q << 3, d += q;
              }
            }
            i.buf = c, i.BFINAL = l, i.off = d, i.pos = f;
          }(n, 100), [3, 1];
        case 4:
          return [2, n.buf.length === n.off ? n.buf : n.buf.slice(0, n.off)];
      }
    });
  });
}
function x4(e, t) {
  var r = e.length;
  if (t <= r) return e;
  var n = new Uint8Array(Math.max(r << 1, t));
  return n.set(e, 0), n;
}
function g$(e, t, r, n, a, i) {
  for (var o = 0; o < r; ) {
    var s = e[n6(n, a) & t];
    a += 15 & s;
    var u = s >>> 4;
    if (u <= 15) i[o] = u, o++;
    else {
      var c = 0, l = 0;
      u === 16 ? (l = 3 + pd(n, a, 2), a += 2, c = i[o - 1]) : u === 17 ? (l = 3 + pd(n, a, 3), a += 3) : u === 18 && (l = 11 + pd(n, a, 7), a += 7);
      for (var d = o + l; o < d; ) i[o] = c, o++;
    }
  }
  return a;
}
function jw(e, t, r, n) {
  for (var a = 0, i = 0, o = n.length >>> 1; i < r; ) {
    var s = e[i + t];
    n[i << 1] = 0, n[1 + (i << 1)] = s, s > a && (a = s), i++;
  }
  for (; i < o; ) n[i << 1] = 0, n[1 + (i << 1)] = 0, i++;
  return a;
}
function pd(e, t, r) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8) >>> (7 & t) & (1 << r) - 1;
}
function _4(e, t, r) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t) & (1 << r) - 1;
}
function n6(e, t) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t);
}
function tF(e, t, r) {
  return r === void 0 && (r = !1), Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c, l, d, f, m, h, p;
    return Te(this, function(g) {
      switch (g.label) {
        case 0:
          for (n = /* @__PURE__ */ Object.create(null), a = new Uint8Array(t), i = a.length - 4; Rf(a, i) !== 101010256; ) i--;
          o = i, o += 4, s = Sd(a, o += 4), o += 2, o += 2, u = Rf(a, o += 4), o += 4, o = u, c = 0, g.label = 1;
        case 1:
          return c < s ? (o += 4, o += 4, o += 4, o += 4, l = Rf(a, o += 4), d = Rf(a, o += 4), f = Sd(a, o += 4), m = Sd(a, o + 2), h = Sd(a, o + 4), o += 6, p = Rf(a, o += 8), o += 4, o += f + m + h, [4, y$(e, a, p, n, l, d, r)]) : [3, 4];
        case 2:
          g.sent(), g.label = 3;
        case 3:
          return c++, [3, 1];
        case 4:
          return [2, n];
      }
    });
  });
}
function y$(e, t, r, n, a, i, o) {
  return Be(this, 0, void 0, function() {
    var s, u, c, l, d, f;
    return Te(this, function(m) {
      switch (m.label) {
        case 0:
          return r += 4, r += 2, s = Sd(t, r += 2), r += 2, r += 4, r += 4, u = Sd(t, r += 8), c = Sd(t, r += 2), l = m$(t, r += 2, u), r += u, r += c, o ? (n[l] = { size: i, csize: a }, [2]) : (d = new Uint8Array(t.buffer, r), s !== 0 ? [3, 1] : (n[l] = new Uint8Array(d.buffer.slice(r, r + a)), [3, 4]));
        case 1:
          return s !== 8 ? [3, 3] : (f = new Uint8Array(i), [4, rF(e, d, f)]);
        case 2:
          return m.sent(), n[l] = f, [3, 4];
        case 3:
          throw new Error("unknown compression method: ".concat(s));
        case 4:
          return [2];
      }
    });
  });
}
function rF(e, t, r) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(n) {
      return [2, v$(e, t, r)];
    });
  });
}
function b$(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c, l, d;
    return Te(this, function(f) {
      switch (f.label) {
        case 0:
          if (n = t[3], a = 10, 4 & n && (i = Sd(t, a), a += i), 8 & n) {
            for (o = a; t[o] !== 0; ) ++o;
            a = o + 1;
          }
          if (16 & n) {
            for (o = a; t[o] !== 0; ) ++o;
            a = o + 1;
          }
          return 1 & n && (a += 2), s = function(m) {
            return 0 | m;
          }(Rf(t, t.length - 8)), u = Rf(t, t.length - 4), r === void 0 && (r = new Uint8Array(u)), c = new Uint8Array(t.buffer, t.byteOffset + a, t.length - a - 8), [4, rF(e, c, r)];
        case 1:
          return l = f.sent(), d = h$(l, 0, l.length), s !== d && console.error("ungzip: checksums don't match"), [2, l];
      }
    });
  });
}
function jv(e, t, r) {
  for (var n = 0, a = r.length; n < a; n++) {
    var i = r.charCodeAt(n);
    if (i < 128) e[t++] = i >>> 0 & 127;
    else if (i < 2048) e[t++] = i >>> 6 & 31 | 192, e[t++] = i >>> 0 & 63 | 128;
    else if (i < 65536) e[t++] = i >>> 12 & 15 | 224, e[t++] = i >>> 6 & 63 | 128, e[t++] = i >>> 0 & 63 | 128;
    else {
      if (!(i < 1114112)) throw new Error("bad codepoint " + i);
      e[t++] = i >>> 18 & 7 | 240, e[t++] = i >>> 12 & 63 | 128, e[t++] = i >>> 6 & 63 | 128, e[t++] = i >>> 0 & 63 | 128;
    }
  }
}
(function() {
  for (var e = 0; e < 32768; e++) {
    var t = e;
    t = (4278255360 & (t = (4042322160 & (t = (3435973836 & (t = (2863311530 & t) >>> 1 | (1431655765 & t) << 1)) >>> 2 | (858993459 & t) << 2)) >>> 4 | (252645135 & t) << 4)) >>> 8 | (16711935 & t) << 8, tr.rev15[e] = (t >>> 16 | t << 16) >>> 17;
  }
  function r(n, a, i) {
    for (; a-- != 0; ) n.push(0, i);
  }
  for (e = 0; e < 32; e++) tr.ldef[e] = tr.of0[e] << 3 | tr.exb[e], tr.ddef[e] = tr.df0[e] << 4 | tr.dxb[e];
  r(tr.fltree, 144, 8), r(tr.fltree, 112, 9), r(tr.fltree, 24, 7), r(tr.fltree, 8, 8), K0(tr.fltree, 9), H0(tr.fltree, 9, tr.flmap), Xw(tr.fltree, 9), r(tr.fdtree, 32, 5), K0(tr.fdtree, 5), H0(tr.fdtree, 5, tr.fdmap), Xw(tr.fdtree, 5), r(tr.itree, 19, 0), r(tr.ltree, 286, 0), r(tr.dtree, 30, 0), r(tr.ttree, 320, 0);
})();
var x$ = function() {
  for (var e = [], t = 0; t < 1024; t++) e[t] = String.fromCharCode(t);
  return e;
}();
function nF(e) {
  throw new Error(e);
}
var Yw = typeof TextDecoder < "u" ? new TextDecoder() : void 0;
function aF(e, t, r) {
  if (Yw) {
    var n = t || r !== e.length ? e.subarray(t, t + r) : e;
    return Yw.decode(n);
  }
  return function(a, i, o) {
    for (var s = x$, u = void 0, c = 0, l = [], d = i, f = i + o; d < f; d++) {
      var m = a[d];
      128 & m ? (224 & m) == 192 ? l[c++] = s[(15 & m) << 6 | 63 & a[++d]] : (240 & m) == 224 ? l[c++] = String.fromCharCode((15 & m) << 12 | (63 & a[++d]) << 6 | 63 & a[++d]) : (248 & m) == 240 ? l[c++] = String.fromCharCode((7 & m) << 18 | (63 & a[++d]) << 12 | (63 & a[++d]) << 6 | 63 & a[++d]) : nF("Invalid byte " + m.toString(16)) : l[c++] = s[m], c === 512 && ((u = u || [])[u.length] = l.join(""), c = 0);
    }
    return u ? (c > 0 && (u[u.length] = l.slice(0, c).join("")), u.join("")) : l.slice(0, c).join("");
  }(e, t, r);
}
function iF(e) {
  for (var t = 0, r = 0, n = e.length; r < n; r++) {
    var a = e.charCodeAt(r);
    a < 128 ? t += 1 : a < 2048 ? t += 2 : a < 65536 ? t += 3 : a < 1114112 ? t += 4 : nF("bad codepoint " + a);
  }
  return t;
}
var Su, _$ = XMLHttpRequest;
function Yv(e, t) {
  return function(r, n) {
    var a = this, i = void 0;
    return sr.create("Read File", function(o) {
      return Be(a, 0, void 0, function() {
        var s, u;
        return Te(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, , 5, 6]), i = new FileReader(), s = n === "zip" ? Su.None : (l = r.name, /\.gz$/i.test(l) ? Su.Gzip : /\.zip$/i.test(l) ? Su.Zip : Su.None), n === "binary" || n === "zip" || s !== Su.None ? i.readAsArrayBuffer(r) : i.readAsText(r), [4, o.update({ message: "Opening file...", canAbort: !0 })];
            case 1:
              return c.sent(), [4, oF(o, "Reading...", i)];
            case 2:
              return u = c.sent(), [4, o.update({ message: "Processing file...", canAbort: !1 })];
            case 3:
              return c.sent(), [4, w$(o, u, n, s)];
            case 4:
              return [2, c.sent()];
            case 5:
              return i = void 0, [7];
            case 6:
              return [2];
          }
          var l;
        });
      });
    }, function() {
      i && i.abort();
    });
  }(e, t);
}
function Ww(e) {
  return typeof e == "string" ? Qw(e, e, "string") : Qw(e.title, e.url, e.type || "string", e.body, e.headers);
}
function Zw(e) {
  return e ? "Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server." : "Failed to open file.";
}
function oF(e, t, r) {
  return new Promise(function(n, a) {
    if (function(s) {
      if (s instanceof FileReader) return s.readyState === FileReader.DONE;
      if (s instanceof XMLHttpRequest) return s.readyState === XMLHttpRequest.DONE;
      throw new Error("unknown data type");
    }(r)) {
      var i = r.error;
      i != null ? a(i ?? Zw(r instanceof XMLHttpRequest)) : n(r);
    } else {
      var o = !1;
      r.onerror = function(s) {
        if (!o) {
          var u = s.target.error;
          a(u ?? Zw(r instanceof XMLHttpRequest));
        }
      }, r.onprogress = function(s) {
        if (e.shouldUpdate && !o) try {
          s.lengthComputable ? e.update({ message: t, isIndeterminate: !1, current: s.loaded, max: s.total }) : e.update({ message: "".concat(t, " ").concat((s.loaded / 1024 / 1024).toFixed(2), " MB"), isIndeterminate: !0 });
        } catch (u) {
          o = !0, a(u);
        }
      }, r.onload = function(s) {
        n(r);
      };
    }
  });
}
(function(e) {
  e[e.None = 0] = "None", e[e.Gzip = 1] = "Gzip", e[e.Zip = 2] = "Zip";
})(Su || (Su = {}));
var S$ = /^(__MACOSX|.DS_Store)/;
function A$(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          switch (r) {
            case Su.None:
              return [3, 1];
            case Su.Gzip:
              return [3, 2];
            case Su.Zip:
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return [2, t];
        case 2:
          return [2, b$(e, t)];
        case 3:
          return [4, tF(e, t.buffer)];
        case 4:
          if (n = i.sent(), a = Object.keys(n).filter(function(o) {
            return !S$.test(o);
          }), a.length !== 1) throw new Error("can only decompress zip files with a single entry");
          return [2, n[a[0]]];
        case 5:
          return [2];
      }
    });
  });
}
function w$(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          if (a = t.result, (i = a instanceof ArrayBuffer ? new Uint8Array(a) : a) === null) throw new Error("no data given");
          if (n === Su.None) return [3, 4];
          if (!(i instanceof Uint8Array)) throw new Error("need Uint8Array for decompression");
          return [4, A$(e, i, n)];
        case 1:
          return o = s.sent(), r !== "string" ? [3, 3] : [4, e.update({ message: "Decoding text..." })];
        case 2:
          return s.sent(), i = aF(o, 0, o.length), [3, 4];
        case 3:
          i = o, s.label = 4;
        case 4:
          return r === "binary" && i instanceof Uint8Array ? [2, i] : [3, 5];
        case 5:
          return r === "zip" && i instanceof Uint8Array ? [4, tF(e, i.buffer)] : [3, 7];
        case 6:
          return [2, s.sent()];
        case 7:
          if (r === "string" && typeof i == "string") return [2, i];
          if (r === "xml" && typeof i == "string") return [2, new DOMParser().parseFromString(i, "application/xml")];
          if (r === "json" && typeof i == "string") return [2, JSON.parse(i)];
          s.label = 8;
        case 8:
          throw new Error("could not get requested response data '".concat(r, "'"));
      }
    });
  });
}
var gu, S4 = function() {
  function e() {
  }
  return e.get = function() {
    return this.pool.length ? this.pool.pop() : new _$();
  }, e.emptyFunc = function() {
  }, e.deposit = function(t) {
    this.pool.length < this.poolSize && (t.onabort = e.emptyFunc, t.onerror = e.emptyFunc, t.onload = e.emptyFunc, t.onprogress = e.emptyFunc, this.pool.push(t));
  }, e.pool = [], e.poolSize = 15, e;
}();
function Qw(e, t, r, n, a) {
  var i = this, o = void 0;
  return sr.create(e || "Download", function(s) {
    return Be(i, 0, void 0, function() {
      var u, c, l, d, f, m, h;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            if ((o = S4.get()).open(n ? "post" : "get", t, !0), a) for (u = 0, c = a; u < c.length; u++) l = c[u], d = l[0], f = l[1], o.setRequestHeader(d, f);
            return o.responseType = function(g) {
              switch (g) {
                case "json":
                  return "json";
                case "xml":
                  return "document";
                case "string":
                  return "text";
                case "binary":
                case "zip":
                  return "arraybuffer";
              }
            }(r), o.send(n), [4, s.update({ message: "Waiting for server...", canAbort: !0 })];
          case 1:
            return p.sent(), [4, oF(s, "Downloading...", o)];
          case 2:
            return m = p.sent(), o = void 0, [4, s.update({ message: "Parsing response...", canAbort: !1 })];
          case 3:
            return p.sent(), h = function(g, v) {
              if (g.status >= 200 && g.status < 400) {
                var y = g.response;
                if (S4.deposit(g), (v === "binary" || v === "zip") && y instanceof ArrayBuffer) return new Uint8Array(y);
                if (v === "string" && typeof y == "string" || v === "xml" && y instanceof XMLDocument || v === "json" && typeof y == "object") return y;
                throw new Error("could not get requested response data '".concat(v, "'"));
              }
              throw S4.deposit(g), new Error("Download failed with status code ".concat(g.status));
            }(m, r), [2, h];
        }
      });
    });
  }, function() {
    o && (o.abort(), o = void 0);
  });
}
(function(e) {
  function t(r, n) {
    return k({ kind: "url", id: Fa.create22(), url: r }, n);
  }
  e.Url = t, e.File = function(r) {
    return { kind: "file", id: Fa.create22(), name: r.name, file: r };
  }, e.isUrl = function(r) {
    return (r == null ? void 0 : r.kind) === "url";
  }, e.isFile = function(r) {
    return (r == null ? void 0 : r.kind) === "file";
  }, e.Wrapper = function(r, n, a) {
    return { data: r, dispose: function() {
      a.release(n);
    } };
  }, e.getUrl = function(r) {
    return typeof r == "string" ? r : r.url;
  }, e.getUrlAsset = function(r, n, a) {
    return typeof n == "string" ? r.tryFindUrl(n, a) || t(n, { body: a }) : n;
  };
})(gu || (gu = {}));
var V, $c = function() {
  function e() {
    this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "assets", { get: function() {
    return c8(this._assets.values());
  }, enumerable: !1, configurable: !0 }), e.prototype.tryFindUrl = function(t, r) {
    for (var n = this.assets.values(); ; ) {
      var a = n.next();
      if (a.done) return;
      var i = a.value.asset;
      if (gu.isUrl(i) && i.url === t && (i.body || "") === (r || "")) return i;
    }
  }, e.prototype.set = function(t, r) {
    this._assets.set(t.id, { asset: t, file: r, refCount: 0 });
  }, e.prototype.get = function(t) {
    return this._assets.get(t);
  }, e.prototype.remove = function(t) {
    this._assets.delete(t);
  }, e.prototype.resolve = function(t, r, n) {
    var a = this;
    return n === void 0 && (n = !0), gu.isUrl(t) ? sr.create("Download ".concat(t.title || t.url), function(i) {
      return Be(a, 0, void 0, function() {
        var o, s, u, c, l, d, f, m, h;
        return Te(this, function(p) {
          switch (p.label) {
            case 0:
              return this._assets.has(t.id) ? ((o = this._assets.get(t.id)).refCount++, u = (s = gu).Wrapper, [4, Yv(o.file, r).runInContext(i)]) : [3, 2];
            case 1:
              return [2, u.apply(s, [p.sent(), t, this])];
            case 2:
              return n ? [3, 4] : (l = (c = gu).Wrapper, [4, Ww(k(k({}, t), { type: r })).runInContext(i)]);
            case 3:
              return [2, l.apply(c, [p.sent(), t, this])];
            case 4:
              return [4, Ww(k(k({}, t), { type: "binary" })).runInContext(i)];
            case 5:
              return d = p.sent(), f = new File([d], "raw-data"), this._assets.set(t.id, { asset: t, file: f, refCount: 1 }), h = (m = gu).Wrapper, [4, Yv(f, r).runInContext(i)];
            case 6:
              return [2, h.apply(m, [p.sent(), t, this])];
          }
        });
      });
    }) : sr.create("Read ".concat(t.name), function(i) {
      return Be(a, 0, void 0, function() {
        var o, s, u, c, l;
        return Te(this, function(d) {
          switch (d.label) {
            case 0:
              return this._assets.has(t.id) ? (o = this._assets.get(t.id), t.file = o.file, o.refCount++, u = (s = gu).Wrapper, [4, Yv(o.file, r).runInContext(i)]) : [3, 2];
            case 1:
              return [2, u.apply(s, [d.sent(), t, this])];
            case 2:
              if (!(t.file instanceof File)) throw new Error("Cannot resolve file asset '".concat(t.name, "' (").concat(t.id, ")"));
              return n && this._assets.set(t.id, { asset: t, file: t.file, refCount: 1 }), l = (c = gu).Wrapper, [4, Yv(t.file, r).runInContext(i)];
            case 3:
              return [2, l.apply(c, [d.sent(), t, this])];
          }
        });
      });
    });
  }, e.prototype.release = function(t) {
    var r = this._assets.get(t.id);
    r && (r.refCount--, r.refCount <= 0 && this._assets.delete(t.id));
  }, e;
}();
function j2(e) {
  for (var t = -1 / 0, r = 0, n = e.length; r < n; ++r) e[r] > t && (t = e[r]);
  return t;
}
function C$(e) {
  for (var t = 1 / 0, r = 0, n = e.length; r < n; ++r) e[r] < t && (t = e[r]);
  return t;
}
function as(e) {
  for (var t = 1 / 0, r = -1 / 0, n = 0, a = e.length; n < a; ++n) e[n] < t && (t = e[n]), e[n] > r && (r = e[n]);
  return [t, r];
}
function w2(e, t, r) {
  t === void 0 && (t = 1), r === void 0 && (r = 0);
  for (var n = e.length, a = 0, i = r; i < n; i += t) a += e[i];
  return a;
}
function E$(e, t, r) {
  return t === void 0 && (t = 1), r === void 0 && (r = 0), w2(e, t, r) / (e.length / t);
}
function D$(e) {
  for (var t = e.length, r = 0, n = 0; n < t; ++n) {
    var a = e[n];
    r += a * a;
  }
  return Math.sqrt(r / t);
}
function lc(e, t) {
  for (var r = 0, n = t ? Math.min(t, e.length) : e.length; r < n; ++r) e[r] = r;
  return e;
}
function js(e, t) {
  return !(e.indexOf(t) >= 0) && (e.push(t), !0);
}
function C2(e, t) {
  var r = e.indexOf(t);
  if (r < 0) return !1;
  for (var n = r, a = e.length - 1; n < a; n++) e[n] = e[n + 1];
  return e.pop(), !0;
}
function Y2(e, t) {
  for (var r = 0, n = 0, a = e.length; n < a; ++n) t.includes(e[n]) && (r += 1);
  return r;
}
(function(e) {
  function t(b, x) {
    return x && (x.label && (b.label = x.label), x.description && (b.description = x.description), x.legend && (b.legend = x.legend), x.fieldLabels && (b.fieldLabels = x.fieldLabels), x.isHidden && (b.isHidden = x.isHidden), x.shortLabel && (b.shortLabel = x.shortLabel), x.twoColumns && (b.twoColumns = x.twoColumns), x.isEssential && (b.isEssential = x.isEssential), x.category && (b.category = x.category), x.hideIf && (b.hideIf = x.hideIf), x.help && (b.help = x.help)), b;
  }
  function r(b, x, A) {
    return t({ type: "select", defaultValue: S(b, x), options: x, cycle: A == null ? void 0 : A.cycle }, A);
  }
  function n(b, x) {
    return x && (x.min !== void 0 && (b.min = x.min), x.max !== void 0 && (b.max = x.max), x.step !== void 0 && (b.step = x.step)), b;
  }
  function a(b, x) {
    var A = t({ type: "group", defaultValue: (x == null ? void 0 : x.customDefault) || s(b), params: b }, x);
    return x != null && x.presets && (A.presets = x.presets), x != null && x.isExpanded && (A.isExpanded = x.isExpanded), x != null && x.isFlat && (A.isFlat = x.isFlat), x != null && x.pivot && (A.pivot = x.pivot), A;
  }
  function i() {
    return s(this.element);
  }
  function o() {
    throw new Error("getValue not set. Fix runtime.");
  }
  function s(b) {
    for (var x = {}, A = 0, w = Object.keys(b); A < w.length; A++) {
      var C = w[A];
      b[C].isOptional || (x[C] = b[C].defaultValue);
    }
    return x;
  }
  function u(b, x) {
    return function() {
      return b(x);
    };
  }
  function c(b, x, A) {
    if (x) {
      if (b.type === "value-ref") (w = x).ref ? w.getValue = u(b.resolveRef, w.ref) : w.getValue = function() {
        throw new Error("Unset ref in ValueRef value.");
      };
      else if (b.type === "data-ref")
        (w = x).ref ? w.getValue = u(A, w.ref) : w.getValue = function() {
          throw new Error("Unset ref in ValueRef value.");
        };
      else if (b.type === "group") f(b.params, x, A);
      else if (b.type === "mapped") {
        var w = x;
        c(b.map(w.name), w.params, A);
      } else if (b.type === "object-list") {
        if (!d(b.element)) return;
        for (var C = 0, M = x; C < M.length; C++) {
          var T = M[C];
          f(b.element, T, A);
        }
      }
    }
  }
  function l(b) {
    if (b.type === "value-ref" || b.type === "data-ref") return !0;
    if (b.type === "group") {
      if (d(b.params)) return !0;
    } else if (b.type === "mapped") for (var x = 0, A = b.select.options; x < A.length; x++) {
      var w = A[x][0];
      if (l(b.map(w))) return !0;
    }
    else if (b.type === "object-list") return d(b.element);
    return !1;
  }
  function d(b) {
    for (var x = 0, A = Object.keys(b); x < A.length; x++)
      if (l(b[A[x]])) return !0;
    return !1;
  }
  function f(b, x, A) {
    for (var w = 0, C = Object.keys(b); w < C.length; w++) {
      var M = C[w];
      c(b[M], x == null ? void 0 : x[M], A);
    }
  }
  function m(b, x, A) {
    if (x === A) return !0;
    if (typeof x != "object" || typeof A != "object") return !1;
    for (var w = 0, C = Object.keys(b); w < C.length; w++) {
      var M = C[w];
      if (!h(b[M], x[M], A[M])) return !1;
    }
    return !0;
  }
  function h(b, x, A) {
    if (x === A) return !0;
    if (b.type === "group") return m(b.params, x, A);
    if (b.type === "mapped") {
      var w = A;
      return (N = x).name === w.name && h(b.map(N.name), N.params, w.params);
    }
    if (b.type === "multi-select") {
      if (w = A, (N = x).length !== w.length) return !1;
      if (N.length < 10) {
        for (var C = 0, M = N.length; C < M; C++) if (N[C] !== w[C] && w.indexOf(N[C]) < 0) return !1;
      } else {
        var T = new Set(w);
        for (C = 0, M = N.length; C < M; C++) if (N[C] !== w[C] && !T.has(N[C])) return !1;
      }
      return !0;
    }
    if (b.type === "interval") return x[0] === A[0] && x[1] === A[1];
    if (b.type === "line-graph") {
      if (w = A, (N = x).length !== w.length) return !1;
      for (C = 0, M = N.length; C < M; C++) if (!Ze.areEqual(N[C], w[C])) return !1;
      return !0;
    }
    if (b.type === "vec3") return D.equals(x, A);
    if (b.type === "mat4") return Ee.areEqual(x, A, Cn);
    if (b.type === "script")
      return w = A, (N = x).language === w.language && N.expression === w.expression;
    if (b.type === "object-list") {
      w = A;
      var N, I = (N = x).length;
      if (I !== w.length) return !1;
      for (C = 0; C < I; C++) if (!m(b.element, N[C], w[C])) return !1;
      return !0;
    }
    return typeof x == "object" && typeof A == "object" && KO(x, A);
  }
  function p(b, x, A) {
    if (x === void 0) return k({}, A);
    if (A === void 0) return k({}, x);
    for (var w = /* @__PURE__ */ Object.create(null), C = 0, M = Object.keys(b); C < M.length; C++) {
      var T = M[C];
      w[T] = g(b[T], x[T], A[T]);
    }
    return w;
  }
  function g(b, x, A) {
    if (x === void 0) return typeof A != "object" || Array.isArray(A) ? A : k({}, A);
    if (A === void 0) return typeof x != "object" || Array.isArray(x) ? x : k({}, x);
    if (b.type === "group") return p(b.params, x, A);
    if (b.type === "mapped") {
      var w = x, C = A;
      if (w.name !== C.name) return k({}, C);
      var M = b.map(C.name);
      return { name: C.name, params: g(M, w.params, C.params) };
    }
    return b.type === "value" ? A : typeof x == "object" && typeof A == "object" ? Array.isArray(A) ? A : k(k({}, x), A) : A;
  }
  function v(b, x) {
    for (var A = 0, w = b.options; A < w.length; A++)
      if (w[A][0] === x) return !0;
    return !1;
  }
  function y(b, x, A) {
    if (x == null) return A ? b.defaultValue : void 0;
    if (b.type === "value") return x;
    if (b.type === "group") {
      for (var w = /* @__PURE__ */ Object.create(null), C = 0, M = Object.keys(b.params); C < M.length; C++) {
        var T = M[C], N = b.params[T];
        x[T] === void 0 ? A && (w[T] = N.defaultValue) : w[T] = y(N, x[T], A);
      }
      return w;
    }
    if (b.type === "mapped") {
      var I = x;
      return typeof I.name != "string" ? b.defaultValue : I.params === void 0 ? A ? b.defaultValue : void 0 : v(b.select, I.name) ? (N = b.map(I.name), { name: I.name, params: y(N, I.params, A) }) : b.defaultValue;
    }
    return b.type === "select" ? v(b, x) ? x : b.defaultValue : b.type === "multi-select" ? Array.isArray(x) ? (w = x.filter(function(P) {
      return v(this, P);
    }, b), x.length > 0 && w.length === 0 ? b.defaultValue : w) : b.defaultValue : b.type === "object-list" ? Array.isArray(x) ? x.map(function(P) {
      return _(b.element, P, A ? "all" : "skip");
    }) : b.defaultValue : x;
  }
  function _(b, x, A) {
    if (typeof x != "object" || x === null) return A ? s(b) : x;
    for (var w = /* @__PURE__ */ Object.create(null), C = 0, M = Object.keys(b); C < M.length; C++) {
      var T = M[C], N = b[T];
      x[T] === void 0 ? A === "all" && (w[T] = N.defaultValue) : w[T] = y(N, x[T], A !== "skip");
    }
    return w;
  }
  function S(b, x) {
    for (var A = 0, w = x; A < w.length; A++)
      if (w[A][0] === b) return b;
    return x.length > 0 ? x[0][0] : void 0;
  }
  e.Essential = { isEssential: !0 }, e.Optional = function(b) {
    var x = k({}, b);
    return x.isOptional = !0, x;
  }, e.Value = function(b, x) {
    return t({ type: "value", defaultValue: b }, x);
  }, e.Select = r, e.MultiSelect = function(b, x, A) {
    var w = t({ type: "multi-select", defaultValue: b, options: x }, A);
    return A != null && A.emptyValue && (w.emptyValue = A.emptyValue), w;
  }, e.Boolean = function(b, x) {
    return t({ type: "boolean", defaultValue: b }, x);
  }, e.Text = function(b, x) {
    return b === void 0 && (b = ""), t({ type: "text", defaultValue: b }, x);
  }, e.Color = function(b, x) {
    var A = t({ type: "color", defaultValue: b }, x);
    return x != null && x.isExpanded && (A.isExpanded = x.isExpanded), A;
  }, e.ColorList = function(b, x) {
    var A;
    if (typeof b == "string") {
      var w = ul(b);
      A = { kind: w.type !== "qualitative" ? "interpolate" : "set", colors: w.list };
    } else A = b;
    return t({ type: "color-list", presetKind: (x == null ? void 0 : x.presetKind) || "all", defaultValue: A, offsets: !!(x != null && x.offsets) }, x);
  }, e.Vec3 = function(b, x, A) {
    return t(n({ type: "vec3", defaultValue: b }, x), A);
  }, e.Mat4 = function(b, x) {
    return t({ type: "mat4", defaultValue: b }, x);
  }, e.Url = function(b, x) {
    return t({ type: "url", defaultValue: typeof b == "string" ? gu.Url(b) : gu.Url(b.url, { body: b.body }) }, x);
  }, e.File = function(b) {
    var x = t({ type: "file", defaultValue: null }, b);
    return b != null && b.accept && (x.accept = b.accept), x;
  }, e.FileList = function(b) {
    var x = t({ type: "file-list", defaultValue: null }, b);
    return b != null && b.accept && (x.accept = b.accept), x;
  }, e.Numeric = function(b, x, A) {
    var w = t(n({ type: "number", defaultValue: b }, x), A);
    return A != null && A.immediateUpdate && (w.immediateUpdate = !0), w;
  }, e.Interval = function(b, x, A) {
    return t(n({ type: "interval", defaultValue: b }, x), A);
  }, e.LineGraph = function(b, x) {
    return t({ type: "line-graph", defaultValue: b }, x);
  }, e.Group = a, e.EmptyGroup = function(b) {
    return a({}, b);
  }, e.Mapped = function(b, x, A, w) {
    var C = S(b, x);
    return t({ type: "mapped", defaultValue: { name: C, params: A(C).defaultValue }, select: r(C, x, w), map: A }, w);
  }, e.MappedStatic = function(b, x, A) {
    var w = A != null && A.options ? A.options : Object.keys(x).map(function(M) {
      return [M, x[M].label || ac(M)];
    }), C = S(b, w);
    return t({ type: "mapped", defaultValue: { name: C, params: x[C].defaultValue }, select: r(C, w, A), map: function(M) {
      return x[M];
    } }, A);
  }, e.ObjectList = function(b, x, A) {
    return t({ type: "object-list", element: b, getLabel: x, ctor: i, defaultValue: (A == null ? void 0 : A.defaultValue) || [] }, A);
  }, e.ValueRef = function(b, x, A) {
    var w;
    return t({ type: "value-ref", defaultValue: { ref: (w = A == null ? void 0 : A.defaultRef) !== null && w !== void 0 ? w : "", getValue: o }, getOptions: b, resolveRef: x }, A);
  }, e.DataRef = function(b) {
    var x;
    return t({ type: "data-ref", defaultValue: { ref: (x = b == null ? void 0 : b.defaultRef) !== null && x !== void 0 ? x : "", getValue: o } }, b);
  }, e.Converted = function(b, x, A) {
    return { type: "converted", defaultValue: x(A.defaultValue), converted: A, fromValue: b, toValue: x };
  }, e.Conditioned = function(b, x, A, w, C) {
    var M = Object.keys(x).map(function(T) {
      return [T, T];
    });
    return t({ type: "conditioned", select: r(A(b), M, C), defaultValue: b, conditionParams: x, conditionForValue: A, conditionedValue: w }, C);
  }, e.Script = function(b, x) {
    return t({ type: "script", defaultValue: b }, x);
  }, e.For = function(b) {
    return 0;
  }, e.getDefaultValues = s, e.resolveRefs = f, e.setDefaultValues = function(b, x) {
    for (var A = 0, w = Object.keys(b); A < w.length; A++) {
      var C = w[A];
      b[C].isOptional || (b[C].defaultValue = x[C]);
    }
  }, e.clone = function(b) {
    return ll(b);
  }, e.validate = function(b, x) {
  }, e.areEqual = m, e.isParamEqual = h, e.merge = p, e.mergeParam = g, e.normalizeParams = _, e.objectToOptions = function(b, x) {
    for (var A = [], w = 0, C = Object.keys(b); w < C.length; w++) {
      var M = C[w];
      if (x) {
        var T = x(M, b[M]);
        A.push(typeof T == "string" ? [M, T] : [M, T[0], T[1]]);
      } else typeof b[M] == "string" ? A.push([M, b[M]]) : A.push([M, x === null ? M : ac(M)]);
    }
    return A;
  }, e.arrayToOptions = function(b, x) {
    for (var A = [], w = 0, C = b; w < C.length; w++) {
      var M = C[w];
      x ? A.push([M, x(M)]) : A.push([M, x === null ? M : ac(M)]);
    }
    return A;
  }, e.optionLabel = function(b, x) {
    for (var A = 0, w = b.options; A < w.length; A++) {
      var C = w[A];
      if (C[0] === x) return C[1];
    }
    return "";
  };
})(V || (V = {}));
var a6, i6 = { backgroundColor: V.Color(Qe(0), { description: "Background color of the 3D canvas" }), pickingAlphaThreshold: V.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "The minimum opacity value needed for an object to be pickable." }), interiorDarkening: V.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), interiorColorFlag: V.Boolean(!0, { label: "Use Interior Color" }), interiorColor: V.Color(Qe.fromNormalizedRgb(0.3, 0.3, 0.3)), highlightColor: V.Color(Qe.fromNormalizedRgb(1, 0.4, 0.6)), selectColor: V.Color(Qe.fromNormalizedRgb(0.2, 1, 0.1)), highlightStrength: V.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), selectStrength: V.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), markerPriority: V.Select(1, [[1, "Highlight"], [2, "Select"]]), xrayEdgeFalloff: V.Numeric(1, { min: 0, max: 3, step: 0.1 }), light: V.ObjectList({ inclination: V.Numeric(180, { min: 0, max: 180, step: 1 }), azimuth: V.Numeric(0, { min: 0, max: 360, step: 1 }), color: V.Color(Qe.fromNormalizedRgb(1, 1, 1)), intensity: V.Numeric(0.6, { min: 0, max: 1, step: 0.01 }) }, function(e) {
  return Qe.toHexString(e.color);
}, { defaultValue: [{ inclination: 180, azimuth: 0, color: Qe.fromNormalizedRgb(1, 1, 1), intensity: 0.6 }] }), ambientColor: V.Color(Qe.fromNormalizedRgb(1, 1, 1)), ambientIntensity: V.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), invalidColor: V.Color(Qe(16410214)), invalidStrength: V.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) }, $w = D(), A4 = D();
function Jw(e, t) {
  for (var r = t || { direction: new Array(15).fill(0), color: new Array(15).fill(0) }, n = r.direction, a = r.color, i = 0, o = e.length; i < o; ++i) {
    var s = e[i];
    D.directionFromSpherical($w, Kn(s.inclination), Kn(s.azimuth), 1), D.toArray($w, n, 3 * i), D.scale(A4, Qe.toVec3Normalized(A4, s.color), s.intensity), D.toArray(A4, a, 3 * i);
  }
  return { count: e.length, direction: n, color: a };
}
function ha(e, t, r) {
  return t === void 0 && (t = ""), r === void 0 && (r = ""), ha.create(e, t, r);
}
(function(e) {
  e.create = function(t, r) {
    r === void 0 && (r = {});
    var n = t.gl, a = t.state, i = t.stats, o = V.merge(i6, V.getDefaultValues(i6), r), s = Jw(o.light), u = Za(), c = Ze.create(n.drawingBufferWidth, n.drawingBufferHeight), l = Qe.toVec3Normalized(D(), o.backgroundColor), d = !1, f = t.resources.texture("image-depth", "depth", "ushort", "nearest"), m = [["tDepth", f]], h = Ee(), p = Ee(), g = Ee(), v = Ee(), y = Ee(), _ = Ee(), S = Ee(), b = D(), x = Ze(), A = D();
    D.scale(A, Qe.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity);
    var w = { uModel: U.create(Ee.identity()), uView: U.create(h), uInvView: U.create(p), uModelView: U.create(g), uInvModelView: U.create(v), uInvProjection: U.create(y), uProjection: U.create(Ee()), uModelViewProjection: U.create(_), uInvModelViewProjection: U.create(S), uIsOrtho: U.create(1), uViewOffset: U.create(x), uPixelRatio: U.create(t.pixelRatio), uViewport: U.create(Za.toVec4(jt(), u)), uDrawingBufferSize: U.create(c), uCameraPosition: U.create(D()), uCameraDir: U.create(b), uNear: U.create(1), uFar: U.create(1e4), uFogNear: U.create(1), uFogFar: U.create(1e4), uFogColor: U.create(l), uRenderWboit: U.create(!1), uMarkingDepthTest: U.create(!1), uPickType: U.create(0), uMarkingType: U.create(0), uTransparentBackground: U.create(!1), uLightDirection: U.create(s.direction), uLightColor: U.create(s.color), uAmbientColor: U.create(A), uPickingAlphaThreshold: U.create(o.pickingAlphaThreshold), uInteriorDarkening: U.create(o.interiorDarkening), uInteriorColorFlag: U.create(o.interiorColorFlag), uInteriorColor: U.create(Qe.toVec3Normalized(D(), o.interiorColor)), uHighlightColor: U.create(Qe.toVec3Normalized(D(), o.highlightColor)), uSelectColor: U.create(Qe.toVec3Normalized(D(), o.selectColor)), uHighlightStrength: U.create(o.highlightStrength), uSelectStrength: U.create(o.selectStrength), uMarkerPriority: U.create(o.markerPriority), uXrayEdgeFalloff: U.create(o.xrayEdgeFalloff), uInvalidColor: U.create(Qe.toVec3Normalized(D(), o.invalidColor)), uInvalidStrength: U.create(o.invalidStrength) }, C = Object.entries(w), M = !0, T = function(O, F) {
      if (!O.state.disposed && O.state.visible && (O.state.pickable || F !== "pick")) {
        var R = !1;
        O.values.dLightCount.ref.value !== s.count && (U.update(O.values.dLightCount, s.count), R = !0), R && O.update();
        var G = O.getProgram(F);
        if (a.currentProgramId !== G.id && (M = !0, G.use()), M && (G.setUniforms(C), M = !1), O.values.dGeometryType.ref.value === "directVolume") {
          if (F !== "colorWboit" && F !== "colorBlended") return;
          a.disable(n.CULL_FACE), a.frontFace(n.CCW), F === "colorBlended" && (a.disable(n.DEPTH_TEST), a.depthMask(!1));
        } else O.values.uDoubleSided ? O.values.uDoubleSided.ref.value || O.values.hasReflection.ref.value ? a.disable(n.CULL_FACE) : a.enable(n.CULL_FACE) : a.disable(n.CULL_FACE), O.values.dFlipSided && O.values.dFlipSided.ref.value ? (a.frontFace(n.CW), a.cullFace(n.FRONT)) : (a.frontFace(n.CCW), a.cullFace(n.BACK));
        O.render(F, m);
      }
    }, N = function(O, F, R, G, L) {
      (function(W, ee, $) {
        for (var te = 0, re = W.length; te < re; ++te) if (W[te][0] === ee) return void (W[te][1] = $);
        W.push([ee, $]);
      })(m, "tDepth", R || f), U.update(w.uModel, O.view), U.update(w.uModelView, Ee.mul(g, O.view, F.view)), U.update(w.uInvModelView, Ee.invert(v, g)), U.update(w.uModelViewProjection, Ee.mul(_, g, F.projection)), U.update(w.uInvModelViewProjection, Ee.invert(S, _)), U.updateIfChanged(w.uRenderWboit, G), U.updateIfChanged(w.uMarkingDepthTest, L), a.enable(n.SCISSOR_TEST), a.colorMask(!0, !0, !0, !0);
      var q = u.x, K = u.y, X = u.width, H = u.height;
      n.viewport(q, K, X, H), n.scissor(q, K, X, H), M = !0, a.currentRenderItemId = -1;
    }, I = function(O, F, R) {
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, R, !1, !1);
      for (var G = O.renderables, L = 0, q = G.length; L < q; ++L) {
        var K = G[L];
        K.state.opaque && T(K, "colorBlended");
      }
    }, P = function(O, F, R) {
      a.enable(n.DEPTH_TEST), N(O, F, R, !1, !1);
      var G = O.renderables;
      d ? a.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA) : a.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), a.enable(n.BLEND), a.depthMask(!0);
      for (var L = 0, q = G.length; L < q; ++L)
        !(K = G[L]).state.opaque && K.state.writeDepth && T(K, "colorBlended");
      for (a.depthMask(!1), L = 0, q = G.length; L < q; ++L) {
        var K;
        (K = G[L]).state.opaque || K.state.writeDepth || T(K, "colorBlended");
      }
    };
    return { clear: function(O, F) {
      a.enable(n.SCISSOR_TEST), a.enable(n.DEPTH_TEST), a.colorMask(!0, !0, !0, !0), a.depthMask(!0), d && !F ? a.clearColor(0, 0, 0, 0) : O ? a.clearColor(l[0], l[1], l[2], 1) : a.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT | n.DEPTH_BUFFER_BIT);
    }, clearDepth: function() {
      a.enable(n.SCISSOR_TEST), a.enable(n.DEPTH_TEST), a.depthMask(!0), n.clear(n.DEPTH_BUFFER_BIT);
    }, update: function(O) {
      U.update(w.uView, O.view), U.update(w.uInvView, Ee.invert(p, O.view)), U.update(w.uProjection, O.projection), U.update(w.uInvProjection, Ee.invert(y, O.projection)), U.updateIfChanged(w.uIsOrtho, O.state.mode === "orthographic" ? 1 : 0), U.update(w.uViewOffset, O.viewOffset.enabled ? Ze.set(x, 16 * O.viewOffset.offsetX, 16 * O.viewOffset.offsetY) : Ze.set(x, 0, 0)), U.update(w.uCameraPosition, O.state.position), U.update(w.uCameraDir, D.normalize(b, D.sub(b, O.state.target, O.state.position))), U.updateIfChanged(w.uFar, O.far), U.updateIfChanged(w.uNear, O.near), U.updateIfChanged(w.uFogFar, O.fogFar), U.updateIfChanged(w.uFogNear, O.fogNear), U.updateIfChanged(w.uTransparentBackground, d);
    }, renderPick: function(O, F, R, G, L) {
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, G, !1, !1), U.updateIfChanged(w.uPickType, L);
      for (var q = O.renderables, K = 0, X = q.length; K < X; ++K) q[K].state.colorOnly || T(q[K], R);
    }, renderDepth: function(O, F, R) {
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, R, !1, !1);
      for (var G = O.renderables, L = 0, q = G.length; L < q; ++L) T(G[L], "depth");
    }, renderMarkingDepth: function(O, F, R) {
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, R, !1, !1), U.updateIfChanged(w.uMarkingType, 1);
      for (var G = O.renderables, L = 0, q = G.length; L < q; ++L)
        G[L].values.markerAverage.ref.value !== 1 && T(G[L], "marking");
    }, renderMarkingMask: function(O, F, R) {
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, R, !1, !!R), U.updateIfChanged(w.uMarkingType, 2);
      for (var G = O.renderables, L = 0, q = G.length; L < q; ++L)
        G[L].values.markerAverage.ref.value > 0 && T(G[L], "marking");
    }, renderBlended: function(O, F, R) {
      I(O, F, R), P(O, F, R);
    }, renderBlendedOpaque: I, renderBlendedTransparent: P, renderBlendedVolumeOpaque: function(O, F, R) {
      var G;
      a.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), a.enable(n.BLEND), N(O, F, R, !1, !1);
      for (var L = O.renderables, q = 0, K = L.length; q < K; ++q) {
        var X = L[q];
        po(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) !== 1 || X.values.transparencyAverage.ref.value === 1 || !((G = X.values.dXrayShaded) === null || G === void 0) && G.ref.value || T(X, "colorBlended");
      }
    }, renderBlendedVolumeTransparent: function(O, F, R) {
      var G;
      a.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), a.enable(n.BLEND), N(O, F, R, !1, !1);
      for (var L = O.renderables, q = 0, K = L.length; q < K; ++q) {
        var X = L[q];
        (po(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) < 1 || X.values.transparencyAverage.ref.value > 0 || !((G = X.values.dXrayShaded) === null || G === void 0) && G.ref.value) && T(X, "colorBlended");
      }
    }, renderWboitOpaque: function(O, F, R) {
      var G, L;
      a.disable(n.BLEND), a.enable(n.DEPTH_TEST), a.depthMask(!0), N(O, F, R, !1, !1);
      for (var q = O.renderables, K = 0, X = q.length; K < X; ++K) {
        var H = q[K];
        po(H.values.alpha.ref.value * H.state.alphaFactor, 0, 1) !== 1 || H.values.transparencyAverage.ref.value === 1 || H.values.dGeometryType.ref.value === "directVolume" || ((G = H.values.dPointStyle) === null || G === void 0 ? void 0 : G.ref.value) === "fuzzy" || !((L = H.values.dXrayShaded) === null || L === void 0) && L.ref.value || T(H, "colorWboit");
      }
    }, renderWboitTransparent: function(O, F, R) {
      var G, L;
      N(O, F, R, !0, !1);
      for (var q = O.renderables, K = 0, X = q.length; K < X; ++K) {
        var H = q[K];
        (po(H.values.alpha.ref.value * H.state.alphaFactor, 0, 1) < 1 || H.values.transparencyAverage.ref.value > 0 || H.values.dGeometryType.ref.value === "directVolume" || ((G = H.values.dPointStyle) === null || G === void 0 ? void 0 : G.ref.value) === "fuzzy" || H.values.uBackgroundColor || !((L = H.values.dXrayShaded) === null || L === void 0) && L.ref.value) && T(H, "colorWboit");
      }
    }, setProps: function(O) {
      O.backgroundColor !== void 0 && O.backgroundColor !== o.backgroundColor && (o.backgroundColor = O.backgroundColor, Qe.toVec3Normalized(l, o.backgroundColor), U.update(w.uFogColor, D.copy(w.uFogColor.ref.value, l))), O.pickingAlphaThreshold !== void 0 && O.pickingAlphaThreshold !== o.pickingAlphaThreshold && (o.pickingAlphaThreshold = O.pickingAlphaThreshold, U.update(w.uPickingAlphaThreshold, o.pickingAlphaThreshold)), O.interiorDarkening !== void 0 && O.interiorDarkening !== o.interiorDarkening && (o.interiorDarkening = O.interiorDarkening, U.update(w.uInteriorDarkening, o.interiorDarkening)), O.interiorColorFlag !== void 0 && O.interiorColorFlag !== o.interiorColorFlag && (o.interiorColorFlag = O.interiorColorFlag, U.update(w.uInteriorColorFlag, o.interiorColorFlag)), O.interiorColor !== void 0 && O.interiorColor !== o.interiorColor && (o.interiorColor = O.interiorColor, U.update(w.uInteriorColor, Qe.toVec3Normalized(w.uInteriorColor.ref.value, o.interiorColor))), O.highlightColor !== void 0 && O.highlightColor !== o.highlightColor && (o.highlightColor = O.highlightColor, U.update(w.uHighlightColor, Qe.toVec3Normalized(w.uHighlightColor.ref.value, o.highlightColor))), O.selectColor !== void 0 && O.selectColor !== o.selectColor && (o.selectColor = O.selectColor, U.update(w.uSelectColor, Qe.toVec3Normalized(w.uSelectColor.ref.value, o.selectColor))), O.highlightStrength !== void 0 && O.highlightStrength !== o.highlightStrength && (o.highlightStrength = O.highlightStrength, U.update(w.uHighlightStrength, o.highlightStrength)), O.selectStrength !== void 0 && O.selectStrength !== o.selectStrength && (o.selectStrength = O.selectStrength, U.update(w.uSelectStrength, o.selectStrength)), O.markerPriority !== void 0 && O.markerPriority !== o.markerPriority && (o.markerPriority = O.markerPriority, U.update(w.uMarkerPriority, o.markerPriority)), O.xrayEdgeFalloff !== void 0 && O.xrayEdgeFalloff !== o.xrayEdgeFalloff && (o.xrayEdgeFalloff = O.xrayEdgeFalloff, U.update(w.uXrayEdgeFalloff, o.xrayEdgeFalloff)), O.light === void 0 || Ud(O.light, o.light) || (o.light = O.light, Object.assign(s, Jw(O.light, s)), U.update(w.uLightDirection, s.direction), U.update(w.uLightColor, s.color)), O.ambientColor !== void 0 && O.ambientColor !== o.ambientColor && (o.ambientColor = O.ambientColor, D.scale(A, Qe.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity), U.update(w.uAmbientColor, A)), O.ambientIntensity !== void 0 && O.ambientIntensity !== o.ambientIntensity && (o.ambientIntensity = O.ambientIntensity, D.scale(A, Qe.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity), U.update(w.uAmbientColor, A)), O.invalidColor !== void 0 && O.invalidColor !== o.invalidColor && (o.invalidColor = O.invalidColor, U.update(w.uInvalidColor, Qe.toVec3Normalized(w.uInvalidColor.ref.value, o.invalidColor))), O.invalidStrength !== void 0 && O.invalidStrength !== o.invalidStrength && (o.invalidStrength = O.invalidStrength, U.update(w.uInvalidStrength, o.invalidStrength));
    }, setViewport: function(O, F, R, G) {
      n.viewport(O, F, R, G), n.scissor(O, F, R, G), O === u.x && F === u.y && R === u.width && G === u.height || (Za.set(u, O, F, R, G), U.update(w.uViewport, jt.set(w.uViewport.ref.value, O, F, R, G)));
    }, setTransparentBackground: function(O) {
      d = O;
    }, setDrawingBufferSize: function(O, F) {
      O === c[0] && F === c[1] || U.update(w.uDrawingBufferSize, Ze.set(c, O, F));
    }, setPixelRatio: function(O) {
      U.update(w.uPixelRatio, O);
    }, props: o, get stats() {
      return { programCount: t.stats.resourceCounts.program, shaderCount: t.stats.resourceCounts.shader, attributeCount: t.stats.resourceCounts.attribute, elementsCount: t.stats.resourceCounts.elements, framebufferCount: t.stats.resourceCounts.framebuffer, renderbufferCount: t.stats.resourceCounts.renderbuffer, textureCount: t.stats.resourceCounts.texture, vertexArrayCount: t.stats.resourceCounts.vertexArray, drawCount: i.drawCount, instanceCount: i.instanceCount, instancedDrawCount: i.instancedDrawCount };
    }, dispose: function() {
    } };
  };
})(a6 || (a6 = {})), function(e) {
  function t(n) {
    return n.triggers.map(r.format).join(" or ");
  }
  function r(n, a) {
    return r.create(n, a);
  }
  e.create = function(n, a, i) {
    return a === void 0 && (a = ""), i === void 0 && (i = ""), { triggers: n, action: a, description: i };
  }, e.Empty = { triggers: [], action: "", description: "" }, e.isEmpty = function(n) {
    return n.triggers.length === 0 || n.triggers.every(function(a) {
      return a.buttons === void 0 && a.modifiers === void 0;
    });
  }, e.match = function(n, a, i) {
    return n.triggers.some(function(o) {
      return r.match(o, a, i);
    });
  }, e.formatTriggers = t, e.format = function(n, a) {
    return a === void 0 && (a = ""), function(i, o) {
      var s = Object.keys(o), u = Object.values(o);
      return new (Function.bind.apply(Function, nt(nt([void 0], s, !1), ["return `".concat(i, "`;")], !1)))().apply(void 0, u);
    }(n.description || ac(a), { triggers: "<i>" + t(n) + "</i>" });
  }, e.Trigger = r, function(n) {
    n.create = function(a, i) {
      return { buttons: a, modifiers: i };
    }, n.Empty = {}, n.match = function(a, i, o) {
      var s = a.buttons, u = a.modifiers;
      return s !== void 0 && (s === i || $f.has(s, i)) && (!u || Fp.areEqual(u, o));
    }, n.format = function(a) {
      var i = [], o = function(u) {
        var c = [];
        return u === void 0 ? c.push("any mouse button") : u === 0 ? c.push("mouse hover") : (Wv.has(u, 1) && c.push("left mouse button"), Wv.has(u, 2) && c.push("right mouse button"), Wv.has(u, 4) && c.push("wheel/middle mouse button"), Wv.has(u, 8) && c.push("three fingers")), c.join(" + ");
      }(a.buttons);
      o && i.push(o);
      var s = function(u, c) {
        var l = [];
        return u && (u.alt && l.push("alt key"), u.control && l.push("control key"), u.meta && l.push("meta/command key"), u.shift && l.push("shift key")), l.join(" + ");
      }(a.modifiers);
      return s && i.push(s), i.join(" + ");
    };
  }(r = e.Trigger || (e.Trigger = {}));
}(ha || (ha = {}));
var xo, Wv = $f;
(function(e) {
  e.create = function() {
    var t = new M$(), r = function() {
      return t.create();
    };
    return r.dispose = function() {
      return t.dispose();
    }, r.behavior = function(n) {
      return t.behavior(n);
    }, r;
  };
})(xo || (xo = {}));
var o6, M$ = function() {
  function e() {
    this._eventList = [], this._disposed = !1;
  }
  return e.prototype.create = function() {
    var t = new pa();
    return this._eventList.push(t), t;
  }, e.prototype.behavior = function(t) {
    var r = new xd(t);
    return this._eventList.push(r), r;
  }, e.prototype.dispose = function() {
    if (!this._disposed) {
      for (var t = 0, r = this._eventList; t < r.length; t++)
        r[t].complete();
      this._disposed = !0;
    }
  }, e;
}(), ql = Fp, Hl = ha.Trigger, I$ = { dragRotate: ha([Hl(1, ql.create())], "Rotate", "Drag using ${triggers}"), dragRotateZ: ha([Hl(1, ql.create({ shift: !0 }))], "Rotate around z-axis", "Drag using ${triggers}"), dragPan: ha([Hl(2, ql.create()), Hl(1, ql.create({ control: !0 }))], "Pan", "Drag using ${triggers}"), dragZoom: ha.Empty, dragFocus: ha([Hl(8, ql.create())], "Focus", "Drag using ${triggers}"), dragFocusZoom: ha([Hl(4, ql.create())], "Focus and zoom", "Drag using ${triggers}"), scrollZoom: ha([Hl(4, ql.create())], "Zoom", "Scroll using ${triggers}"), scrollFocus: ha([Hl(4, ql.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"), scrollFocusZoom: ha.Empty }, sF = { noScroll: V.Boolean(!0, { isHidden: !0 }), rotateSpeed: V.Numeric(5, { min: 1, max: 10, step: 1 }), zoomSpeed: V.Numeric(7, { min: 1, max: 15, step: 1 }), panSpeed: V.Numeric(1, { min: 0.1, max: 5, step: 0.1 }), animate: V.MappedStatic("off", { off: V.EmptyGroup(), spin: V.Group({ speed: V.Numeric(1, { min: -20, max: 20, step: 1 }) }, { description: "Spin the 3D scene around the x-axis in view space" }), rock: V.Group({ speed: V.Numeric(0.3, { min: -5, max: 5, step: 0.1 }), angle: V.Numeric(10, { min: 0, max: 90, step: 1 }, { description: "How many degrees to rotate in each direction." }) }, { description: "Rock the 3D scene around the x-axis in view space" }) }), staticMoving: V.Boolean(!0, { isHidden: !0 }), dynamicDampingFactor: V.Numeric(0.2, {}, { isHidden: !0 }), minDistance: V.Numeric(0.01, {}, { isHidden: !0 }), maxDistance: V.Numeric(1e150, {}, { isHidden: !0 }), gestureScaleFactor: V.Numeric(1, {}, { isHidden: !0 }), maxWheelDelta: V.Numeric(0.02, {}, { isHidden: !0 }), bindings: V.Value(I$, { isHidden: !0 }), autoAdjustMinMaxDistance: V.MappedStatic("on", { off: V.EmptyGroup(), on: V.Group({ minDistanceFactor: V.Numeric(0), minDistancePadding: V.Numeric(5), maxDistanceFactor: V.Numeric(10), maxDistanceMin: V.Numeric(20) }) }, { isHidden: !0 }) };
(function(e) {
  e.create = function(t, r, n) {
    n === void 0 && (n = {});
    var a = xo.create(), i = k(k({}, V.getDefaultValues(sF)), n), o = Za.clone(r.viewport), s = !1, u = a.behavior(!1), c = a.behavior([]), l = a.behavior(!1), d = t.drag.subscribe(function(ue) {
      var be = ue.x, Se = ue.y, Ne = ue.pageX, J = ue.pageY, Z = ue.buttons, de = ue.modifiers, ye = ue.isStart, Ae = he(be, Se);
      if (!(u.value && c.value.includes("drag") && (l.value || Z !== 1)) && !(ye && Ae) && !(!ye && !g)) {
        g = !0, le();
        var Ce = ha.match(i.bindings.dragRotate, Z, de), Ie = ha.match(i.bindings.dragRotateZ, Z, de), Ue = ha.match(i.bindings.dragPan, Z, de), Xe = ha.match(i.bindings.dragZoom, Z, de), je = ha.match(i.bindings.dragFocus, Z, de), ht = ha.match(i.bindings.dragFocusZoom, Z, de);
        if (function(dt, Le) {
          Ze.set(q, (dt - 0.5 * o.width - o.x) / (0.5 * o.width), (o.height + 2 * (o.y - Le)) / o.width);
        }(Ne, J), function(dt, Le) {
          Ze.set(L, (dt - o.x) / o.width, (Le - o.y) / o.height);
        }(Ne, J), ye && (Ce && (Ze.copy(S, q), Ze.copy(_, S)), Ie && (Ze.copy(w, q), Ze.copy(A, w)), (Xe || ht) && (Ze.copy(M, L), Ze.copy(T, M)), je && (Ze.copy(N, L), Ze.copy(I, N)), Ue && (Ze.copy(P, L), Ze.copy(O, P))), Ce && Ze.copy(S, q), Ie && Ze.copy(w, q), (Xe || ht) && Ze.copy(T, L), je && Ze.copy(I, L), ht) {
          var xt = D.distance(r.state.position, r.state.target);
          r.setState({ radius: xt / 5 });
        }
        Ue && Ze.copy(O, L);
      }
    }), f = t.interactionEnd.subscribe(function() {
      g = !1;
    }), m = t.wheel.subscribe(function(ue) {
      var be = ue.x, Se = ue.y, Ne = ue.spinX, J = ue.spinY, Z = ue.dz, de = ue.buttons, ye = ue.modifiers;
      if (!he(be, Se)) {
        var Ae = function() {
          for (var Ce = [], Ie = 0; Ie < arguments.length; Ie++) Ce[Ie] = arguments[Ie];
          for (var Ue = 0, Xe = 0, je = 0, ht = Ce.length; je < ht; ++je) {
            var xt = Ce[je], dt = Math.abs(xt);
            dt > Xe && (Ue = xt, Xe = dt);
          }
          return Ue;
        }(0.075 * Ne, 0.075 * J, 1e-4 * Z);
        Ae < -i.maxWheelDelta ? Ae = -i.maxWheelDelta : Ae > i.maxWheelDelta && (Ae = i.maxWheelDelta), ha.match(i.bindings.scrollZoom, de, ye) && (T[1] += Ae), ha.match(i.bindings.scrollFocus, de, ye) && (I[1] += Ae);
      }
    }), h = t.pinch.subscribe(function(ue) {
      var be = ue.fractionDelta, Se = ue.buttons, Ne = ue.modifiers;
      ha.match(i.bindings.scrollZoom, Se, Ne) && (g = !0, T[1] += i.gestureScaleFactor * be);
    }), p = t.gesture.subscribe(function(ue) {
      var be = ue.deltaScale;
      g = !0, T[1] += i.gestureScaleFactor * be;
    }), g = !1, v = D(), y = D(), _ = Ze(), S = Ze(), b = D(), x = 0, A = Ze(), w = Ze(), C = 0, M = Ze(), T = Ze(), N = Ze(), I = Ze(), P = Ze(), O = Ze(), F = D.clone(r.target), R = D.clone(r.position), G = D.clone(r.up), L = Ze(), q = Ze();
    function K() {
      var ue = t.width / t.height;
      return i.rotateSpeed * t.pixelRatio * ue;
    }
    var X = D(), H = Gn(), W = D(), ee = D(), $ = D(), te = D(), re = Gn(), ie = Ze(), oe = D(), se = D();
    function he(ue, be) {
      return ue *= t.pixelRatio, be *= t.pixelRatio, ue > o.x + o.width || t.height - be > o.y + o.height || ue < o.x || t.height - be < o.y;
    }
    var ge = -1;
    function De(ue) {
      var be, Se, Ne, J, Z;
      ge !== ue && (ge > 0 && (i.animate.name === "spin" ? function(de) {
        if (!(i.animate.name !== "spin" || i.animate.params.speed === 0 || g)) {
          var ye = i.animate.params.speed / 1e3;
          ae[0] = 60 * Math.min(Math.abs(de), 125) / 1e3 * ye, Ze.add(S, _, ae);
        }
      }(ue - ge) : i.animate.name === "rock" && function(de) {
        if (!(i.animate.name !== "rock" || i.animate.params.speed === 0 || g)) {
          var ye = de / 1e3 * i.animate.params.speed, Ae = Kn(i.animate.params.angle) / K(), Ce = Math.sin(ce * Math.PI * 2) * Ae, Ie = Math.sin((ce + ye) * Math.PI * 2) * Ae;
          _e[0] = Ie - Ce, Ze.add(S, _, _e), (ce += ye) >= 1 && (ce = 0);
        }
      }(ue - ge)), D.sub(y, r.position, r.target), function() {
        var de = S[0] - _[0], ye = S[1] - _[1];
        D.set(te, de, ye, 0);
        var Ae = D.magnitude(te) * K();
        Ae ? (D.sub(y, r.position, r.target), D.normalize(W, y), D.normalize(ee, r.up), D.normalize($, D.cross($, ee, W)), D.setMagnitude(ee, ee, ye), D.setMagnitude($, $, de), D.add(te, ee, $), D.normalize(X, D.cross(X, te, y)), Gn.setAxisAngle(H, X, Ae), D.transformQuat(y, y, H), D.transformQuat(r.up, r.up, H), D.copy(b, X), x = Ae) : !i.staticMoving && x && (x *= Math.sqrt(1 - i.dynamicDampingFactor), D.sub(y, r.position, r.target), Gn.setAxisAngle(H, b, x), D.transformQuat(y, y, H), D.transformQuat(r.up, r.up, H)), Ze.copy(_, S);
      }(), be = w[0] - A[0], Se = w[1] - A[1], (Ne = i.rotateSpeed * (-be + Se) * -0.05) ? (D.sub(y, r.position, r.target), Gn.setAxisAngle(re, y, Ne), D.transformQuat(r.up, r.up, re), C = Ne) : !i.staticMoving && C && (C *= Math.sqrt(1 - i.dynamicDampingFactor), D.sub(y, r.position, r.target), Gn.setAxisAngle(re, y, C), D.transformQuat(r.up, r.up, re)), Ze.copy(A, w), (J = 1 + (T[1] - M[1]) * i.zoomSpeed) !== 1 && J > 0 && D.scale(y, y, J), i.staticMoving ? Ze.copy(M, T) : M[1] += (T[1] - M[1]) * i.dynamicDampingFactor, function() {
        var de = (I[1] - N[1]) * i.zoomSpeed;
        if (de !== 0) {
          var ye = Math.max(1, r.state.radius + r.state.radius * de);
          r.setState({ radius: ye });
        }
        i.staticMoving ? Ze.copy(N, I) : N[1] += (I[1] - N[1]) * i.dynamicDampingFactor;
      }(), function() {
        if (Ze.sub(ie, Ze.copy(ie, O), P), Ze.squaredMagnitude(ie)) {
          var de = t.pixelRatio * i.panSpeed;
          ie[0] *= 1 / r.zoom * r.viewport.width * de, ie[1] *= 1 / r.zoom * r.viewport.height * de, D.cross(se, D.copy(se, y), r.up), D.setMagnitude(se, se, ie[0]), D.setMagnitude(oe, r.up, ie[1]), D.add(se, se, oe), D.add(r.position, r.position, se), D.add(r.target, r.target, se), i.staticMoving ? Ze.copy(P, O) : (Ze.sub(ie, O, P), Ze.scale(ie, ie, i.dynamicDampingFactor), Ze.add(P, P, ie));
        }
      }(), D.add(r.position, r.target, y), Z = Math.min(Math.max(1e3 * r.state.radiusMax, 0.01), i.maxDistance), D.squaredMagnitude(y) > Z * Z && (D.setMagnitude(y, y, Z), D.add(r.position, r.target, y), Ze.copy(M, T), Ze.copy(N, I)), D.squaredMagnitude(y) < i.minDistance * i.minDistance && (D.setMagnitude(y, y, i.minDistance), D.add(r.position, r.target, y), Ze.copy(M, T), Ze.copy(N, I)), D.squaredDistance(v, r.position) > Cn && D.copy(v, r.position), ge = ue);
    }
    var ae = Ze.create(5e-3, 0), ce = 0, _e = Ze.create(5e-3, 0);
    function le() {
      ce = 0;
    }
    return { viewport: o, get isAnimating() {
      return i.animate.name !== "off";
    }, get props() {
      return i;
    }, setProps: function(ue) {
      var be;
      ((be = ue.animate) === null || be === void 0 ? void 0 : be.name) === "rock" && i.animate.name !== "rock" && le(), Object.assign(i, ue);
    }, get isEditing() {
      return u.value;
    }, get disabledInteraction() {
      return c.value;
    }, get isLockCamera() {
      return l.value;
    }, start: function(ue) {
      ge = -1, De(ue);
    }, update: De, reset: function() {
      D.copy(r.target, F), D.copy(r.position, R), D.copy(r.up, G), D.sub(y, r.position, r.target), D.copy(v, r.position);
    }, dispose: function() {
      s || (s = !0, d.unsubscribe(), m.unsubscribe(), h.unsubscribe(), p.unsubscribe(), f.unsubscribe());
    }, setEditState: function(ue) {
      u.next(ue);
    }, setLockCameraState: function(ue) {
      l.next(ue);
    }, setDisabledInteractionState: function(ue) {
      c.next(ue);
    } };
  };
})(o6 || (o6 = {}));
var uF = $i(), T$ = { apply_fog: `
float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
float fogAlpha = (1.0 - fogFactor) * gl_FragColor.a;
float preFogAlpha = gl_FragColor.a;
if (!uTransparentBackground) {
    if (gl_FragColor.a < 1.0) {
        // transparent objects are blended with background color
        gl_FragColor.a = fogAlpha;
    } else {
        // mix opaque objects with background color
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor, fogFactor);
    }
} else {
    // pre-multiplied alpha expected for transparent background
    gl_FragColor.rgb *= fogAlpha;
    gl_FragColor.a = fogAlpha;
}
`, apply_interior_color: `
if (interior) {
    if (uInteriorColorFlag) {
        gl_FragColor.rgb = uInteriorColor;
    } else {
        gl_FragColor.rgb *= 1.0 - uInteriorDarkening;
    }
}
`, apply_light_color: `
#ifdef dIgnoreLight
    gl_FragColor = material;
#else
    #ifdef bumpEnabled
        if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0) {
            vec3 bumpNormal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);
            #ifdef enabledFragDepth
                if (!isNaN(bumpNormal.x) && !isNaN(bumpNormal.y) && !isNaN(bumpNormal.z)) {
                    normal = bumpNormal;
                }
            #else
                normal = bumpNormal;
            #endif
        }
    #endif

    vec4 color = material;

    ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));

    PhysicalMaterial physicalMaterial;
    physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);
    #ifdef enabledFragDepth
        physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);
    #else
        vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));
        float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);
        physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);
    #endif
    physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);
    physicalMaterial.specularF90 = 1.0;

    GeometricContext geometry;
    geometry.position = -vViewPosition;
    geometry.normal = normal;
    geometry.viewDir = normalize(vViewPosition);

    IncidentLight directLight;
    #pragma unroll_loop_start
    for (int i = 0; i < dLightCount; ++i) {
        directLight.direction = uLightDirection[i];
        directLight.color = uLightColor[i] * PI; // * PI for punctual light
        RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);
    }
    #pragma unroll_loop_end

    vec3 irradiance = uAmbientColor * PI; // * PI for punctual light
    RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);

    // indirect specular only metals
    vec3 radiance = uAmbientColor * metalness;
    vec3 iblIrradiance = uAmbientColor * metalness;
    vec3 clearcoatRadiance = vec3(0.0);
    RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);

    vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;

    gl_FragColor = vec4(outgoingLight, color.a);
#endif

#ifdef dXrayShaded
    gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);
#endif
`, apply_marker_color: `
if (marker > 0.0) {
    if (marker == 4.0) {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uInvalidColor, uInvalidStrength);
        gl_FragColor.a = max(gl_FragColor.a, uInvalidStrength * 0.002); // for direct-volume rendering
    } else if ((uMarkerPriority == 1 && marker != 2.0 && marker != 6.0) || (uMarkerPriority != 1 && (marker == 1.0 || marker == 5.0 || marker == 8.0))) {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uHighlightColor, uHighlightStrength);
        gl_FragColor.a = max(gl_FragColor.a, uHighlightStrength * 0.002); // for direct-volume rendering
    } else {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uSelectColor, uSelectStrength);
        gl_FragColor.a = max(gl_FragColor.a, uSelectStrength * 0.002); // for direct-volume rendering
    }
}
`, assign_clipping_varying: `
#if dClipObjectCount != 0 && defined(dClipping)
    vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;
#endif
`, assign_color_varying: `
#if defined(dRenderVariant_color)
    #if defined(dColorType_attribute)
        vColor.rgb = aColor;
    #elif defined(dColorType_instance)
        vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb;
    #elif defined(dColorType_group)
        vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
    #elif defined(dColorType_groupInstance)
        vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;
    #elif defined(dColorType_vertex)
        vColor.rgb = readFromTexture(tColor, VertexID, uColorTexDim).rgb;
    #elif defined(dColorType_vertexInstance)
        vColor.rgb = readFromTexture(tColor, int(aInstance) * uVertexCount + VertexID, uColorTexDim).rgb;
    #elif defined(dColorType_volume)
        vec3 cgridPos = (uColorGridTransform.w * (position - uColorGridTransform.xyz)) / uColorGridDim;
        vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;
    #elif defined(dColorType_volumeInstance)
        vec3 cgridPos = (uColorGridTransform.w * (vModelPosition - uColorGridTransform.xyz)) / uColorGridDim;
        vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;
    #endif

    #ifdef dUsePalette
        vPaletteV = ((vColor.r * 256.0 * 256.0 * 255.0 + vColor.g * 256.0 * 255.0 + vColor.b * 255.0) - 1.0) / 16777215.0;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_groupInstance)
            vOverpaint = readFromTexture(tOverpaint, aInstance * float(uGroupCount) + group, uOverpaintTexDim);
        #elif defined(dOverpaintType_vertexInstance)
            vOverpaint = readFromTexture(tOverpaint, int(aInstance) * uVertexCount + VertexID, uOverpaintTexDim);
        #elif defined(dOverpaintType_volumeInstance)
            vec3 ogridPos = (uOverpaintGridTransform.w * (vModelPosition - uOverpaintGridTransform.xyz)) / uOverpaintGridDim;
            vOverpaint = texture3dFrom2dLinear(tOverpaintGrid, ogridPos, uOverpaintGridDim, uOverpaintTexDim);
        #endif

        // pre-mix to avoid darkening due to empty overpaint
        #ifdef dColorType_uniform
            vOverpaint.rgb = mix(uColor.rgb, vOverpaint.rgb, vOverpaint.a);
        #else
            vOverpaint.rgb = mix(vColor.rgb, vOverpaint.rgb, vOverpaint.a);
        #endif
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_groupInstance)
            vSubstance = readFromTexture(tSubstance, aInstance * float(uGroupCount) + group, uSubstanceTexDim);
        #elif defined(dSubstanceType_vertexInstance)
            vSubstance = readFromTexture(tSubstance, int(aInstance) * uVertexCount + VertexID, uSubstanceTexDim);
        #elif defined(dSubstanceType_volumeInstance)
            vec3 sgridPos = (uSubstanceGridTransform.w * (vModelPosition - uSubstanceGridTransform.xyz)) / uSubstanceGridDim;
            vSubstance = texture3dFrom2dLinear(tSubstanceGrid, sgridPos, uSubstanceGridDim, uSubstanceTexDim);
        #endif

        // pre-mix to avoid artifacts due to empty substance
        vSubstance.rgb = mix(vec3(uMetalness, uRoughness, uBumpiness), vSubstance.rgb, vSubstance.a);
    #endif
#elif defined(dRenderVariant_pick)
    if (uPickType == 1) {
        vColor = vec4(packIntToRGB(float(uObjectId)), 1.0);
    } else if (uPickType == 2) {
        vColor = vec4(packIntToRGB(aInstance), 1.0);
    } else {
        vColor = vec4(packIntToRGB(group), 1.0);
    }
#endif

#ifdef dTransparency
    vGroup = group;

    #if defined(dTransparencyType_groupInstance)
        vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + group, uTransparencyTexDim).a;
    #elif defined(dTransparencyType_vertexInstance)
        vTransparency = readFromTexture(tTransparency, int(aInstance) * uVertexCount + VertexID, uTransparencyTexDim).a;
    #elif defined(dTransparencyType_volumeInstance)
        vec3 tgridPos = (uTransparencyGridTransform.w * (vModelPosition - uTransparencyGridTransform.xyz)) / uTransparencyGridDim;
        vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a;
    #endif
#endif
`, assign_group: `
#ifdef dGeometryType_textureMesh
    float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb);
#else
    float group = aGroup;
#endif
`, assign_marker_varying: `
#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;
#endif
`, assign_material_color: `
#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    float marker = uMarker;
    if (uMarker == -1.0) {
        marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win
    }
#endif

#if defined(dRenderVariant_color)
    #if defined(dUsePalette)
        vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);
    #elif defined(dColorType_uniform)
        vec4 material = vec4(uColor, uAlpha);
    #elif defined(dColorType_varying)
        vec4 material = vec4(vColor.rgb, uAlpha);
    #endif

    // mix material with overpaint
    #if defined(dOverpaint)
        material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);
    #endif

    float metalness = uMetalness;
    float roughness = uRoughness;
    float bumpiness = uBumpiness;
    #ifdef dSubstance
        metalness = mix(metalness, vSubstance.r, vSubstance.a);
        roughness = mix(roughness, vSubstance.g, vSubstance.a);
        bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);
    #endif
#elif defined(dRenderVariant_pick)
    vec4 material = vColor;
#elif defined(dRenderVariant_depth)
    #ifdef enabledFragDepth
        vec4 material = packDepthToRGBA(gl_FragDepthEXT);
    #else
        vec4 material = packDepthToRGBA(gl_FragCoord.z);
    #endif
#elif defined(dRenderVariant_marking)
    vec4 material;
    if(uMarkingType == 1) {
        if (marker > 0.0)
            discard;
        #ifdef enabledFragDepth
            material = packDepthToRGBA(gl_FragDepthEXT);
        #else
            material = packDepthToRGBA(gl_FragCoord.z);
        #endif
    } else {
        if (marker == 0.0)
            discard;
        float depthTest = 1.0;
        if (uMarkingDepthTest) {
            depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;
        }
        bool isHighlight = intMod(marker, 2.0) > 0.1;
        float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
        float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
        if (fogFactor == 1.0)
            discard;
        material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);
    }
#endif

// apply screendoor transparency
#if defined(dTransparency)
    float ta = 1.0 - vTransparency;
    #if defined(dRenderVariant_colorWboit)
        if (vTransparency < 0.2) ta = 1.0; // hard cutoff looks better with wboit
    #endif

    #if defined(dRenderVariant_pick)
        if (ta < uPickingAlphaThreshold)
            discard; // ignore so the element below can be picked
    #else
        #if defined(dRenderVariant_colorBlended)
            float at = 0.0;

            // shift by view-offset during multi-sample rendering to allow for blending
            vec2 coord = gl_FragCoord.xy + uViewOffset * 0.25;

            const mat4 thresholdMatrix = mat4(
                1.0 / 17.0,  9.0 / 17.0,  3.0 / 17.0, 11.0 / 17.0,
                13.0 / 17.0,  5.0 / 17.0, 15.0 / 17.0,  7.0 / 17.0,
                4.0 / 17.0, 12.0 / 17.0,  2.0 / 17.0, 10.0 / 17.0,
                16.0 / 17.0,  8.0 / 17.0, 14.0 / 17.0,  6.0 / 17.0
            );
            int ci = int(intMod(coord.x, 4.0));
            int ri = int(intMod(coord.y, 4.0));
            #if __VERSION__ == 100
                vec4 i = vec4(float(ci * 4 + ri));
                vec4 v = thresholdMatrix[0] * vec4(equal(i, vec4(0.0, 1.0, 2.0, 3.0))) +
                    thresholdMatrix[1] * vec4(equal(i, vec4(4.0, 5.0, 6.0, 7.0))) +
                    thresholdMatrix[2] * vec4(equal(i, vec4(8.0, 9.0, 10.0, 11.0))) +
                    thresholdMatrix[3] * vec4(equal(i, vec4(12.0, 13.0, 14.0, 15.0)));
                at = v.x + v.y + v.z + v.w;
            #else
                at = thresholdMatrix[ci][ri];
            #endif

            if (ta < 0.99 && (ta < 0.01 || ta < at)) {
                discard;
            }
        #elif defined(dRenderVariant_colorWboit)
            material.a *= ta;
        #endif
    #endif
#endif
`, assign_position: `
mat4 model = uModel * aTransform;
mat4 modelView = uView * model;
#ifdef dGeometryType_textureMesh
    vec3 position = readFromTexture(tPosition, VertexID, uGeoTexDim).xyz;
#else
    vec3 position = aPosition;
#endif
vec4 position4 = vec4(position, 1.0);
// for accessing tColorGrid in vert shader and for clipping in frag shader
vModelPosition = (model * position4).xyz;
vec4 mvPosition = modelView * position4;
vViewPosition = mvPosition.xyz;
gl_Position = uProjection * mvPosition;
`, assign_size: `
#if defined(dSizeType_uniform)
    float size = uSize;
#elif defined(dSizeType_attribute)
    float size = aSize;
#elif defined(dSizeType_instance)
    float size = unpackRGBToInt(readFromTexture(tSize, aInstance, uSizeTexDim).rgb);
#elif defined(dSizeType_group)
    float size = unpackRGBToInt(readFromTexture(tSize, group, uSizeTexDim).rgb);
#elif defined(dSizeType_groupInstance)
    float size = unpackRGBToInt(readFromTexture(tSize, aInstance * float(uGroupCount) + group, uSizeTexDim).rgb);
#endif

#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
    size /= 100.0; // NOTE factor also set in TypeScript
#endif

size *= uSizeFactor;
`, check_picking_alpha: `
float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
float alpha = (1.0 - fogFactor) * uAlpha;
if (uAlpha < uPickingAlphaThreshold || alpha < 0.1)
    discard; // ignore so the element below can be picked
`, clip_instance: `
#if defined(dClipVariant_instance) && dClipObjectCount != 0
    int flag = 0;
    #if defined(dClipping)
        flag = int(floor(vClipping * 255.0 + 0.5));
    #endif

    vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0);
    if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w), flag))
        // move out of [ -w, +w ] to 'discard' in vert shader
        gl_Position.z = 2.0 * gl_Position.w;
#endif
`, clip_pixel: `
#if defined(dClipVariant_pixel) && dClipObjectCount != 0
    #if defined(dClipping)
        int clippingFlag = int(floor(vClipping * 255.0 + 0.5));
    #else
        int clippingFlag = 0;
    #endif

    if (clipTest(vec4(vModelPosition, 0.0), clippingFlag))
        discard;
#endif
`, color_frag_params: `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;
#ifdef bumpEnabled
    uniform float uBumpFrequency;
    uniform float uBumpAmplitude;
#endif

#if defined(dRenderVariant_color)
    #if defined(dColorType_uniform)
        uniform vec3 uColor;
    #elif defined(dColorType_varying)
        varying vec4 vColor;
    #endif

    #ifdef dUsePalette
        uniform sampler2D tPalette;
        varying float vPaletteV;
    #endif

    #ifdef dOverpaint
        varying vec4 vOverpaint;
    #endif

    #ifdef dSubstance
        varying vec4 vSubstance;
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100
        varying vec4 vColor;
    #else
        flat in vec4 vColor;
    #endif
#endif

#ifdef dTransparency
    varying float vGroup;
    varying float vTransparency;
#endif
`, color_vert_params: `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;

#if defined(dRenderVariant_color)
    #if defined(dColorType_uniform)
        uniform vec3 uColor;
    #elif defined(dColorType_attribute)
        varying vec4 vColor;
        attribute vec3 aColor;
    #elif defined(dColorType_texture)
        varying vec4 vColor;
        uniform vec2 uColorTexDim;
        uniform sampler2D tColor;
    #elif defined(dColorType_grid)
        varying vec4 vColor;
        uniform vec2 uColorTexDim;
        uniform vec3 uColorGridDim;
        uniform vec4 uColorGridTransform;
        uniform sampler2D tColorGrid;
    #endif

    #ifdef dUsePalette
        varying float vPaletteV;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)
            varying vec4 vOverpaint;
            uniform vec2 uOverpaintTexDim;
            uniform sampler2D tOverpaint;
        #elif defined(dOverpaintType_volumeInstance)
            varying vec4 vOverpaint;
            uniform vec2 uOverpaintTexDim;
            uniform vec3 uOverpaintGridDim;
            uniform vec4 uOverpaintGridTransform;
            uniform sampler2D tOverpaintGrid;
        #endif
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance)
            varying vec4 vSubstance;
            uniform vec2 uSubstanceTexDim;
            uniform sampler2D tSubstance;
        #elif defined(dSubstanceType_volumeInstance)
            varying vec4 vSubstance;
            uniform vec2 uSubstanceTexDim;
            uniform vec3 uSubstanceGridDim;
            uniform vec4 uSubstanceGridTransform;
            uniform sampler2D tSubstanceGrid;
        #endif
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100
        varying vec4 vColor;
    #else
        flat out vec4 vColor;
    #endif
#endif

#ifdef dTransparency
    varying float vGroup;
    #if defined(dTransparencyType_groupInstance) || defined(dTransparencyType_vertexInstance)
        varying float vTransparency;
        uniform vec2 uTransparencyTexDim;
        uniform sampler2D tTransparency;
    #elif defined(dTransparencyType_volumeInstance)
        varying float vTransparency;
        uniform vec2 uTransparencyTexDim;
        uniform vec3 uTransparencyGridDim;
        uniform vec4 uTransparencyGridTransform;
        uniform sampler2D tTransparencyGrid;
    #endif
#endif
`, common_clip: `
#if dClipObjectCount != 0
    vec3 quaternionTransform(vec4 q, vec3 v) {
        vec3 t = 2.0 * cross(q.xyz, v);
        return v + q.w * t + cross(q.xyz, t);
    }

    vec4 computePlane(vec3 normal, vec3 inPoint) {
        return vec4(normalize(normal), -dot(normal, inPoint));
    }

    float planeSD(vec4 plane, vec3 center) {
        return -dot(plane.xyz, center - plane.xyz * -plane.w);
    }

    float sphereSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        return (
            length(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position) / size) - 1.0
        ) * min(min(size.x, size.y), size.z);
    }

    float cubeSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 d = abs(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position)) - size;
        return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));
    }

    float cylinderSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);

        vec2 d = abs(vec2(length(t.xz), t.y)) - size.xy;
        return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
    }

    float infiniteConeSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);

        float q = length(t.xy);
        return dot(size.xy, vec2(q, t.z));
    }

    float getSignedDistance(vec3 center, int type, vec3 position, vec4 rotation, vec3 scale) {
        if (type == 1) {
            vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0));
            vec4 plane = computePlane(normal, position);
            return planeSD(plane, center);
        } else if (type == 2) {
            return sphereSD(position, rotation, scale * 0.5, center);
        } else if (type == 3) {
            return cubeSD(position, rotation, scale * 0.5, center);
        } else if (type == 4) {
            return cylinderSD(position, rotation, scale * 0.5, center);
        } else if (type == 5) {
            return infiniteConeSD(position, rotation, scale * 0.5, center);
        } else {
            return 0.1;
        }
    }

    #if __VERSION__ == 100
        // 8-bit
        int bitwiseAnd(int a, int b) {
            int d = 128;
            int result = 0;
            for (int i = 0; i < 8; ++i) {
                if (d <= 0) break;
                if (a >= d && b >= d) result += d;
                if (a >= d) a -= d;
                if (b >= d) b -= d;
                d /= 2;
            }
            return result;
        }

        bool hasBit(int mask, int bit) {
            return bitwiseAnd(mask, bit) == 0;
        }
    #else
        bool hasBit(int mask, int bit) {
            return (mask & bit) == 0;
        }
    #endif

    // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0)
    bool clipTest(vec4 sphere, int flag) {
        #pragma unroll_loop_start
        for (int i = 0; i < dClipObjectCount; ++i) {
            if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) {
                // TODO take sphere radius into account?
                bool test = getSignedDistance(sphere.xyz, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i]) <= 0.0;
                if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) {
                    return true;
                }
            }
        }
        #pragma unroll_loop_end
        return false;
    }
#endif
`, common_frag_params: `
uniform int uObjectId;
uniform int uInstanceCount;
uniform int uGroupCount;

uniform int uPickType;
uniform int uMarkingType;

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];

    #if defined(dClipping)
        #if __VERSION__ == 100
            varying float vClipping;
        #else
            flat in float vClipping;
        #endif
    #endif
#endif

uniform vec3 uHighlightColor;
uniform vec3 uSelectColor;
uniform float uHighlightStrength;
uniform float uSelectStrength;
uniform int uMarkerPriority;
uniform vec3 uInvalidColor;
uniform float uInvalidStrength;

#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    uniform float uMarker;
    #if __VERSION__ == 100
        varying float vMarker;
    #else
        flat in float vMarker;
    #endif
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

uniform vec2 uViewOffset;

uniform float uNear;
uniform float uFar;
uniform float uIsOrtho;

uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

uniform float uAlpha;
uniform float uPickingAlphaThreshold;
uniform bool uTransparentBackground;

uniform bool uDoubleSided;
uniform float uInteriorDarkening;
uniform bool uInteriorColorFlag;
uniform vec3 uInteriorColor;
bool interior;

uniform float uXrayEdgeFalloff;

uniform mat4 uProjection;

uniform bool uRenderWboit;
uniform bool uMarkingDepthTest;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

float getDepth(const in vec2 coords) {
    // always packed due to merged depth from primitives and volumes
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

float calcDepth(const in vec3 pos) {
    vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;
    return 0.5 + 0.5 * clipZW.x / clipZW.y;
}

// "Bump Mapping Unparametrized Surfaces on the GPU" Morten S. Mikkelsen
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
vec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {
    vec3 sigmaS = dFdx(position);
    vec3 sigmaT = dFdy(position);

    vec3 r1 = cross(sigmaT, normal);
    vec3 r2 = cross(normal, sigmaS);
    float det = dot(sigmaS, r1);

    float bs = dFdx(height);
    float bt = dFdy(height);

    vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);
    return normalize(abs(det) * normal - scale * surfGrad);
}

float hash(in float h) {
    return fract(sin(h) * 43758.5453123);
}

float noise(in vec3 x) {
    vec3 p = floor(x);
    vec3 f = fract(x);
    f = f * f * (3.0 - 2.0 * f);

    float n = p.x + p.y * 157.0 + 113.0 * p.z;
    return mix(
        mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),
            mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),
        mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),
            mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
}

float fbm(in vec3 p) {
    float f = 0.0;
    f += 0.5 * noise(p);
    p *= 2.01;
    f += 0.25 * noise(p);
    p *= 2.02;
    f += 0.125 * noise(p);

    return f;
}
`, common_vert_params: `
uniform mat4 uProjection, uModel, uView;
uniform vec3 uCameraPosition;

uniform int uObjectId;
uniform int uVertexCount;
uniform int uInstanceCount;
uniform int uGroupCount;
uniform vec4 uInvariantBoundingSphere;

uniform bool uDoubleSided;
uniform int uPickType;

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];

    #if defined(dClipping)
        uniform vec2 uClippingTexDim;
        uniform sampler2D tClipping;
        #if __VERSION__ == 100
            varying float vClipping;
        #else
            flat out float vClipping;
        #endif
    #endif
#endif

#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    uniform float uMarker;
    uniform vec2 uMarkerTexDim;
    uniform sampler2D tMarker;
    #if __VERSION__ == 100
        varying float vMarker;
    #else
        flat out float vMarker;
    #endif
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

#if __VERSION__ == 100
    attribute float aVertex;
    #define VertexID int(aVertex)
#else
    // not using gl_VertexID but aVertex to ensure there is an active attribute with divisor 0
    // since FF 85 this is not needed anymore but lets keep it for backwards compatibility
    // https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
    // see also note in src/mol-gl/webgl/render-item.ts
    attribute float aVertex;
    #define VertexID int(aVertex)
    // #define VertexID gl_VertexID
#endif
`, common: `
// TODO find a better place for these convenience defines

#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)
    #define dRenderVariant_color
#endif

#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)
    #define dColorType_texture
#endif

#if defined(dColorType_volume) || defined(dColorType_volumeInstance)
    #define dColorType_grid
#endif

#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)
    #define dColorType_varying
#endif

//

#define PI 3.14159265
#define RECIPROCAL_PI 0.31830988618
#define EPSILON 1e-6

#define saturate(a) clamp(a, 0.0, 1.0)

#if __VERSION__ == 100
    #define round(x) floor((x) + 0.5)
#endif

float intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }
vec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }
float intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }
int imod(const in int a, const in int b) { return a - b * (a / b); }

float pow2(const in float x) { return x * x; }

vec3 packIntToRGB(in float value) {
    value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;
    vec3 c = vec3(0.0);
    c.b = mod(value, 256.0);
    value = floor(value / 256.0);
    c.g = mod(value, 256.0);
    value = floor(value / 256.0);
    c.r = mod(value, 256.0);
    return c / 255.0;
}
float unpackRGBToInt(const in vec3 rgb) {
    return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;
}

vec2 packUnitIntervalToRG(const in float v) {
    vec2 enc;
    enc.xy = vec2(fract(v * 256.0), v);
    enc.y -= enc.x * (1.0 / 256.0);
    enc.xy *=  256.0 / 255.0;

    return enc;
}

float unpackRGToUnitInterval(const in vec2 enc) {
    return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));
}

vec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {
    vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);
    p = invProjection * p;
    return p.xyz / p.w;
}

const float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)
const float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)
const vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0,  256.0);
const vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);
const float ShiftRight8 = 1.0 / 256.0;

vec4 packDepthToRGBA(const in float v) {
    vec4 r = vec4(fract(v * PackFactors), v);
    r.yzw -= r.xyz * ShiftRight8; // tidy overflow
    return r * PackUpscale;
}
float unpackRGBAToDepth(const in vec4 v) {
    return dot(v, UnpackFactors);
}

vec4 sRGBToLinear(const in vec4 c) {
    return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);
}
vec4 linearTosRGB(const in vec4 c) {
    return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);
}

float linearizeDepth(const in float depth, const in float near, const in float far) {
    return (2.0 * near) / (far + near - depth * (far - near));
}

float perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {
    return (near * far) / ((far - near) * invClipZ - far);
}

float orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {
    return linearClipZ * (near - far) - near;
}

float depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {
    return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);
}

#if __VERSION__ == 100
    // transpose

    float transpose(const in float m) {
        return m;
    }

    mat2 transpose2(const in mat2 m) {
        return mat2(
            m[0][0], m[1][0],
            m[0][1], m[1][1]
        );
    }

    mat3 transpose3(const in mat3 m) {
        return mat3(
            m[0][0], m[1][0], m[2][0],
            m[0][1], m[1][1], m[2][1],
            m[0][2], m[1][2], m[2][2]
        );
    }

    mat4 transpose4(const in mat4 m) {
        return mat4(
            m[0][0], m[1][0], m[2][0], m[3][0],
            m[0][1], m[1][1], m[2][1], m[3][1],
            m[0][2], m[1][2], m[2][2], m[3][2],
            m[0][3], m[1][3], m[2][3], m[3][3]
        );
    }

    // inverse

    float inverse(const in float m) {
        return 1.0 / m;
    }

    mat2 inverse2(const in mat2 m) {
        return mat2(m[1][1],-m[0][1],
                -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);
    }

    mat3 inverse3(const in mat3 m) {
        float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
        float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
        float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];

        float b01 = a22 * a11 - a12 * a21;
        float b11 = -a22 * a10 + a12 * a20;
        float b21 = a21 * a10 - a11 * a20;

        float det = a00 * b01 + a01 * b11 + a02 * b21;

        return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
                    b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
                    b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
    }

    mat4 inverse4(const in mat4 m) {
        float
            a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],
            a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],
            a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],
            a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],

            b00 = a00 * a11 - a01 * a10,
            b01 = a00 * a12 - a02 * a10,
            b02 = a00 * a13 - a03 * a10,
            b03 = a01 * a12 - a02 * a11,
            b04 = a01 * a13 - a03 * a11,
            b05 = a02 * a13 - a03 * a12,
            b06 = a20 * a31 - a21 * a30,
            b07 = a20 * a32 - a22 * a30,
            b08 = a20 * a33 - a23 * a30,
            b09 = a21 * a32 - a22 * a31,
            b10 = a21 * a33 - a23 * a31,
            b11 = a22 * a33 - a23 * a32,

            det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;

        return mat4(
            a11 * b11 - a12 * b10 + a13 * b09,
            a02 * b10 - a01 * b11 - a03 * b09,
            a31 * b05 - a32 * b04 + a33 * b03,
            a22 * b04 - a21 * b05 - a23 * b03,
            a12 * b08 - a10 * b11 - a13 * b07,
            a00 * b11 - a02 * b08 + a03 * b07,
            a32 * b02 - a30 * b05 - a33 * b01,
            a20 * b05 - a22 * b02 + a23 * b01,
            a10 * b10 - a11 * b08 + a13 * b06,
            a01 * b08 - a00 * b10 - a03 * b06,
            a30 * b04 - a31 * b02 + a33 * b00,
            a21 * b02 - a20 * b04 - a23 * b00,
            a11 * b07 - a10 * b09 - a12 * b06,
            a00 * b09 - a01 * b07 + a02 * b06,
            a31 * b01 - a30 * b03 - a32 * b00,
            a20 * b03 - a21 * b01 + a22 * b00) / det;
    }

    #define isNaN(x) ((x) != (x))
    #define isInf(x) ((x) == (x) + 1.0)
#else
    #define transpose2(m) transpose(m)
    #define transpose3(m) transpose(m)
    #define transpose4(m) transpose(m)

    #define inverse2(m) inverse(m)
    #define inverse3(m) inverse(m)
    #define inverse4(m) inverse(m)

    #define isNaN isnan
    #define isInf isinf
#endif
`, float_to_rgba: `
    // floatToRgba adapted from https://github.com/equinor/glsl-float-to-rgba
    // MIT License, Copyright (c) 2020 Equinor

    float shiftRight (float v, float amt) {
    v = floor(v) + 0.5;
    return floor(v / exp2(amt));
    }
    float shiftLeft (float v, float amt) {
        return floor(v * exp2(amt) + 0.5);
    }
    float maskLast (float v, float bits) {
        return mod(v, shiftLeft(1.0, bits));
    }
    float extractBits (float num, float from, float to) {
        from = floor(from + 0.5); to = floor(to + 0.5);
        return maskLast(shiftRight(num, from), to - from);
    }

    vec4 floatToRgba(float texelFloat, bool littleEndian) {
        if (texelFloat == 0.0) return vec4(0.0, 0.0, 0.0, 0.0);
        float sign = texelFloat > 0.0 ? 0.0 : 1.0;
        texelFloat = abs(texelFloat);
        float exponent = floor(log2(texelFloat));
        float biased_exponent = exponent + 127.0;
        float fraction = ((texelFloat / exp2(exponent)) - 1.0) * 8388608.0;
        float t = biased_exponent / 2.0;
        float last_bit_of_biased_exponent = fract(t) * 2.0;
        float remaining_bits_of_biased_exponent = floor(t);
        float byte4 = extractBits(fraction, 0.0, 8.0) / 255.0;
        float byte3 = extractBits(fraction, 8.0, 16.0) / 255.0;
        float byte2 = (last_bit_of_biased_exponent * 128.0 + extractBits(fraction, 16.0, 23.0)) / 255.0;
        float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;
        return (
            littleEndian
                ? vec4(byte4, byte3, byte2, byte1)
                : vec4(byte1, byte2, byte3, byte4)
        );
    }
`, light_frag_params: `
#if dLightCount != 0
    uniform vec3 uLightDirection[dLightCount];
    uniform vec3 uLightColor[dLightCount];
#endif
uniform vec3 uAmbientColor;

struct PhysicalMaterial {
    vec3 diffuseColor;
    float roughness;
    vec3 specularColor;
    float specularF90;
};

struct IncidentLight {
    vec3 color;
    vec3 direction;
};

struct ReflectedLight {
    vec3 directDiffuse;
    vec3 directSpecular;
    vec3 indirectDiffuse;
    vec3 indirectSpecular;
};

struct GeometricContext {
    vec3 position;
    vec3 normal;
    vec3 viewDir;
};

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) {
    // Original approximation by Christophe Schlick '94
    // float fresnel = pow( 1.0 - dotVH, 5.0 );
    // Optimized variant (presented by Epic at SIGGRAPH '13)
    // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
    float fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH);
    return f0 * (1.0 - fresnel) + (f90 * fresnel);
}

// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
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);
}

// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
float D_GGX(const in float alpha, const in float dotNH) {
    float a2 = pow2(alpha);
    float denom = pow2(dotNH) * (a2 - 1.0) + 1.0; // avoid alpha = 0 with dotNH = 1
    return RECIPROCAL_PI * a2 / pow2(denom);
}

// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
vec3 BRDF_GGX(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness) {
    float alpha = pow2(roughness); // UE4's 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);
}

// Analytical approximation of the DFG LUT, one half of the
// split-sum approximation used in indirect specular lighting.
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
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;
}

// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
// Approximates multiscattering in order to preserve energy.
// http://www.jcgt.org/published/0008/01/03/
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) {
    vec2 fab = DFGApprox(normal, viewDir, roughness);
    vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
    float Ess = fab.x + fab.y;
    float Ems = 1.0 - Ess;
    vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619; // 1/21
    vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);
    singleScatter += FssEss;
    multiScatter += Fms * Ems;
}

void RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
    float dotNL = saturate(dot(geometry.normal, directLight.direction));
    vec3 irradiance = dotNL * directLight.color;
    reflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);
    reflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);
}

void RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
    // Both indirect specular and indirect diffuse light accumulate here
    vec3 singleScattering = vec3(0.0);
    vec3 multiScattering = vec3(0.0);
    vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
    computeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);
    vec3 diffuse = material.diffuseColor * (1.0 - ( singleScattering + multiScattering));
    reflectedLight.indirectSpecular += radiance * singleScattering;
    reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
    reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
`, matrix_scale: `
float matrixScale(in mat4 m){
    vec4 r = m[0];
    return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
}
`, normal_frag_params: `
varying vec3 vNormal;
`, read_from_texture: `
vec4 readFromTexture(const in sampler2D tex, const in float i, const in vec2 dim) {
    float x = intMod(i, dim.x);
    float y = floor(intDiv(i, dim.x));
    vec2 uv = (vec2(x, y) + 0.5) / dim;
    return texture2D(tex, uv);
}

vec4 readFromTexture(const in sampler2D tex, const in int i, const in vec2 dim) {
    int x = imod(i, int(dim.x));
    int y = i / int(dim.x);
    vec2 uv = (vec2(x, y) + 0.5) / dim;
    return texture2D(tex, uv);
}
`, rgba_to_float: `
    // rgbaToFloat adapted from https://github.com/ihmeuw/glsl-rgba-to-float
    // BSD 3-Clause License
    //
    // Copyright (c) 2019, Institute for Health Metrics and Evaluation All rights reserved.
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    //  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    //  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    //  - Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
    // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    // OF THE POSSIBILITY OF SUCH DAMAGE.

    ivec4 floatsToBytes(vec4 inputFloats, bool littleEndian) {
        ivec4 bytes = ivec4(inputFloats * 255.0);
        return (
            littleEndian
                ? bytes.abgr
                : bytes
        );
    }

    // Break the four bytes down into an array of 32 bits.
    void bytesToBits(const in ivec4 bytes, out bool bits[32]) {
        for (int channelIndex = 0; channelIndex < 4; ++channelIndex) {
            float acc = float(bytes[channelIndex]);
            for (int indexInByte = 7; indexInByte >= 0; --indexInByte) {
                float powerOfTwo = exp2(float(indexInByte));
                bool bit = acc >= powerOfTwo;
                bits[channelIndex * 8 + (7 - indexInByte)] = bit;
                acc = mod(acc, powerOfTwo);
            }
        }
    }

    // Compute the exponent of the 32-bit float.
    float getExponent(bool bits[32]) {
        const int startIndex = 1;
        const int bitStringLength = 8;
        const int endBeforeIndex = startIndex + bitStringLength;
        float acc = 0.0;
        int pow2 = bitStringLength - 1;
        for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {
            acc += float(bits[bitIndex]) * exp2(float(pow2--));
        }
        return acc;
    }

    // Compute the mantissa of the 32-bit float.
    float getMantissa(bool bits[32], bool subnormal) {
        const int startIndex = 9;
        const int bitStringLength = 23;
        const int endBeforeIndex = startIndex + bitStringLength;
        // Leading/implicit/hidden bit convention:
        // If the number is not subnormal (with exponent 0), we add a leading 1 digit.
        float acc = float(!subnormal) * exp2(float(bitStringLength));
        int pow2 = bitStringLength - 1;
        for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {
            acc += float(bits[bitIndex]) * exp2(float(pow2--));
        }
        return acc;
    }

    // Parse the float from its 32 bits.
    float bitsToFloat(bool bits[32]) {
        float signBit = float(bits[0]) * -2.0 + 1.0;
        float exponent = getExponent(bits);
        bool subnormal = abs(exponent - 0.0) < 0.01;
        float mantissa = getMantissa(bits, subnormal);
        float exponentBias = 127.0;
        return signBit * mantissa * exp2(exponent - exponentBias - 23.0);
    }

    float rgbaToFloat(vec4 texelRGBA, bool littleEndian) {
        ivec4 rgbaBytes = floatsToBytes(texelRGBA, littleEndian);
        bool bits[32];
        bytesToBits(rgbaBytes, bits);
        return bitsToFloat(bits);
    }
`, size_vert_params: `
#if defined(dSizeType_uniform)
    uniform float uSize;
#elif defined(dSizeType_attribute)
    attribute float aSize;
#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
    uniform vec2 uSizeTexDim;
    uniform sampler2D tSize;
#endif

uniform float uSizeFactor;
`, texture3d_from_1d_trilinear: `
vec4 texture3dFrom1dTrilinear(const in sampler2D tex, const in vec3 pos, const in vec3 gridDim, const in vec2 texDim, const in float offset) {
    float gdYZ = gridDim.z * gridDim.y;
    float gdZ = gridDim.z;
    vec3 p0 = floor(pos * gridDim);
    vec3 p1 = ceil(pos * gridDim);
    vec3 pd = (pos * gridDim - p0) / (p1 - p0);
    vec4 s000 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s100 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s001 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s101 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s010 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s110 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s011 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s111 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s00 = mix(s000, s100, pd.x);
    vec4 s01 = mix(s001, s101, pd.x);
    vec4 s10 = mix(s010, s110, pd.x);
    vec4 s11 = mix(s011, s111, pd.x);
    vec4 s0 = mix(s00, s10, pd.y);
    vec4 s1 = mix(s01, s11, pd.y);
    return mix(s0, s1, pd.z);
}
`, texture3d_from_2d_linear: `
vec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice0 = floor(pos.z * gridDim.z);
    float column0 = intMod(zSlice0 * gridDim.x, texDim.x) / gridDim.x;
    float row0 = floor(intDiv(zSlice0 * gridDim.x, texDim.x));
    vec2 coord0 = (vec2(column0 * gridDim.x, row0 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    vec4 color0 = texture2D(tex, coord0);

    float zSlice1 = zSlice0 + 1.0;
    float column1 = intMod(zSlice1 * gridDim.x, texDim.x) / gridDim.x;
    float row1 = floor(intDiv(zSlice1 * gridDim.x, texDim.x));
    vec2 coord1 = (vec2(column1 * gridDim.x, row1 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    vec4 color1 = texture2D(tex, coord1);

    float delta0 = abs((pos.z * gridDim.z) - zSlice0);
    return mix(color0, color1, delta0);
}
`, texture3d_from_2d_nearest: `
vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x;
    float row = floor(intDiv(zSlice * gridDim.x, texDim.x));
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    return texture2D(tex, coord);
}
`, wboit_write: `
#if defined(dRenderVariant_colorWboit)
    if (!uRenderWboit) {
        if (preFogAlpha < 1.0) {
            discard;
        }
    } else if (uRenderWboit) {
        // the 'fragmentDepth > 0.99' check is to handle precision issues with packed depth
        if (preFogAlpha != 1.0 && !interior && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) {
            float alpha = gl_FragColor.a;
            float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);
            gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);
            // extra alpha is to handle pre-multiplied alpha
            #ifndef dGeometryType_directVolume
                gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);
            #else
                gl_FragData[1] = vec4(alpha * alpha * wboitWeight);
            #endif
        } else {
            discard;
        }
    }
#endif
` }, N$ = /^(?!\/\/)\s*#include\s+(\S+)/gm, P$ = /#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, B$ = /[ \t]*\/\/.*\n/g, O$ = /[ \t]*\/\*[\s\S]*?\*\//g, F$ = /\n{2,}/g;
function e9(e) {
  return e.replace(N$, function(t, r) {
    var n = T$[r];
    if (!n) throw new Error("empty chunk, '".concat(r, "'"));
    return n;
  }).trim().replace(B$, `
`).replace(O$, `
`).replace(F$, `
`);
}
function R$(e, t, r, n) {
  for (var a = "", i = parseInt(t); i < parseInt(r); ++i) a += n.replace(/\[\s*i\s*\]/g, "[".concat(i, "]")).replace(/UNROLLED_LOOP_INDEX/g, "".concat(i));
  return a;
}
function t9(e, t) {
  return function(r) {
    return r.replace(P$, R$);
  }(function(r, n) {
    return n.dLightCount && (r = r.replace(/dLightCount/g, "".concat(n.dLightCount.ref.value))), n.dClipObjectCount && (r = r.replace(/dClipObjectCount/g, "".concat(n.dClipObjectCount.ref.value))), r;
  }(e, t));
}
function Rn(e, t, r, n, a, i) {
  return n === void 0 && (n = {}), a === void 0 && (a = {}), { id: uF(), name: e, vert: e9(t), frag: e9(r), extensions: n, outTypes: a, ignoreDefine: i };
}
function Ph(e, t, r) {
  var n;
  return t.startsWith("color") ? e === "dLightCount" && !!(!((n = r.dIgnoreLight) === null || n === void 0) && n.ref.value) : ["dColorType", "dUsePalette", "dLightCount", "dOverpaintType", "dOverpaint", "dSubstanceType", "dSubstance"].includes(e);
}
function o3(e, t, r) {
  return e === "dLightCount" || Ph(e, t, r);
}
var L$ = Rn("points", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform float uPixelRatio;
uniform vec4 uViewport;

attribute vec3 aPosition;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

void main(){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_position
    #include assign_size

    #ifdef dPointSizeAttenuation
        gl_PointSize = size * uPixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 5.0;
    #else
        gl_PointSize = size * uPixelRatio;
    #endif
    gl_PointSize = max(1.0, gl_PointSize);

    gl_Position = uProjection * mvPosition;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

const vec2 center = vec2(0.5);
const float radius = 0.5;

void main(){
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;
    #include assign_material_color

    #if defined(dPointStyle_circle)
        float dist = distance(gl_PointCoord, center);
        if (dist > radius) discard;
    #elif defined(dPointStyle_fuzzy)
        float dist = distance(gl_PointCoord, center);
        float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist);
        if (fuzzyAlpha < 0.0001) discard;
    #endif

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        gl_FragColor = material;

        #if defined(dPointStyle_fuzzy)
            gl_FragColor.a *= fuzzyAlpha;
        #endif

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, o3), k$ = Rn("spheres", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;
uniform mat4 uInvProjection;

attribute vec3 aPosition;
attribute vec2 aMapping;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

varying float vRadius;
varying float vRadiusSq;
varying vec3 vPoint;
varying vec3 vPointViewPosition;

#include matrix_scale

const mat4 D = mat4(
    1.0, 0.0, 0.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    0.0, 0.0, 1.0, 0.0,
    0.0, 0.0, 0.0, -1.0
);

/**
 * Compute point size and center using the technique described in:
 * "GPU-Based Ray-Casting of Quadratic Surfaces" http://dl.acm.org/citation.cfm?id=2386396
 * by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.
 */
void quadraticProjection(const in float radius, const in vec3 position){
    vec2 xbc, ybc;

    mat4 T = mat4(
        radius, 0.0, 0.0, 0.0,
        0.0, radius, 0.0, 0.0,
        0.0, 0.0, radius, 0.0,
        position.x, position.y, position.z, 1.0
    );

    mat4 R = transpose4(uProjection * uModelView * aTransform * T);
    float A = dot(R[3], D * R[3]);
    float B = -2.0 * dot(R[0], D * R[3]);
    float C = dot(R[0], D * R[0]);
    xbc[0] = (-B - sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    xbc[1] = (-B + sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    float sx = abs(xbc[0] - xbc[1]) * 0.5;

    A = dot(R[3], D * R[3]);
    B = -2.0 * dot(R[1], D * R[3]);
    C = dot(R[1], D * R[1]);
    ybc[0] = (-B - sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    ybc[1] = (-B + sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    float sy = abs(ybc[0] - ybc[1]) * 0.5;

    gl_Position.xy = vec2(0.5 * (xbc.x + xbc.y), 0.5 * (ybc.x + ybc.y));
    gl_Position.xy -= aMapping * vec2(sx, sy);
    gl_Position.xy *= gl_Position.w;
}


void main(void){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    vRadius = size * matrixScale(uModelView);

    vec4 position4 = vec4(aPosition, 1.0);
    vec4 mvPosition = uModelView * aTransform * position4;
    mvPosition.z -= vRadius; // avoid clipping, added again in fragment shader

    gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);
    quadraticProjection(size, aPosition);

    vRadiusSq = vRadius * vRadius;
    vec4 vPoint4 = uInvProjection * gl_Position;
    vPoint = vPoint4.xyz / vPoint4.w;
    vPointViewPosition = -mvPosition.xyz / mvPosition.w;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include common_clip

uniform mat4 uInvView;

varying float vRadius;
varying float vRadiusSq;
varying vec3 vPoint;
varying vec3 vPointViewPosition;

vec3 cameraPos;
vec3 cameraNormal;

bool Impostor(out vec3 cameraPos, out vec3 cameraNormal){
    vec3 cameraSpherePos = -vPointViewPosition;
    cameraSpherePos.z += vRadius;

    vec3 rayOrigin = mix(vec3(0.0, 0.0, 0.0), vPoint, uIsOrtho);
    vec3 rayDirection = mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);
    vec3 cameraSphereDir = mix(cameraSpherePos, rayOrigin - cameraSpherePos, uIsOrtho);

    float B = dot(rayDirection, cameraSphereDir);
    float det = B * B + vRadiusSq - dot(cameraSphereDir, cameraSphereDir);

    if (det < 0.0){
        discard;
        return false;
    }

    float sqrtDet = sqrt(det);
    float posT = mix(B + sqrtDet, B + sqrtDet, uIsOrtho);
    float negT = mix(B - sqrtDet, sqrtDet - B, uIsOrtho);

    cameraPos = rayDirection * negT + rayOrigin;


    if (calcDepth(cameraPos) <= 0.0) {
        cameraPos = rayDirection * posT + rayOrigin;
        interior = true;
    } else {
        interior = false;
    }

    cameraNormal = normalize(cameraPos - cameraSpherePos);
    cameraNormal *= float(!interior) * 2.0 - 1.0;

    return !interior;
}

void main(void){
    #include clip_pixel

    bool flag = Impostor(cameraPos, cameraNormal);
    if (!uDoubleSided) {
        if (interior) discard;
    }

    vec3 vViewPosition = cameraPos;
    gl_FragDepthEXT = calcDepth(vViewPosition);
    if (!flag && gl_FragDepthEXT >= 0.0) {
        gl_FragDepthEXT = 0.0 + (0.0000001 / vRadius);
    }

    vec3 vModelPosition = (uInvView * vec4(vViewPosition, 1.0)).xyz;

    if (gl_FragDepthEXT < 0.0) discard;
    if (gl_FragDepthEXT > 1.0) discard;

    float fragmentDepth = gl_FragDepthEXT;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        vec3 normal = -cameraNormal;
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { fragDepth: "required", drawBuffers: "optional" }, {}, Ph), z$ = Rn("cylinders", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;

attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

attribute vec3 aMapping;
attribute vec3 aStart;
attribute vec3 aEnd;
attribute float aScale;
attribute float aCap;

varying mat4 vTransform;
varying vec3 vStart;
varying vec3 vEnd;
varying float vSize;
varying float vCap;

uniform float uIsOrtho;
uniform vec3 uCameraDir;

void main() {
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    mat4 modelTransform = uModel * aTransform;

    vTransform = aTransform;
    vStart = (modelTransform * vec4(aStart, 1.0)).xyz;
    vEnd = (modelTransform * vec4(aEnd, 1.0)).xyz;
    vSize = size * aScale;
    vCap = aCap;

    vModelPosition = (vStart + vEnd) * 0.5;
    vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);
    vec3 dir = vEnd - vStart;
    // ensure cylinder 'dir' is pointing towards the camera
    if(dot(camDir, dir) < 0.0) dir = -dir;

    vec3 left = cross(camDir, dir);
    vec3 up = cross(left, dir);
    left = vSize * normalize(left);
    up = vSize * normalize(up);

    // move vertex in object-space from center to corner
    vModelPosition += aMapping.x * dir + aMapping.y * left + aMapping.z * up;

    vec4 mvPosition = uView * vec4(vModelPosition, 1.0);
    vViewPosition = mvPosition.xyz;
    gl_Position = uProjection * mvPosition;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

uniform mat4 uView;

varying mat4 vTransform;
varying vec3 vStart;
varying vec3 vEnd;
varying float vSize;
varying float vCap;

uniform vec3 uCameraDir;
uniform vec3 uCameraPosition;
uniform mat4 uInvView;

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include common_clip

// adapted from https://www.shadertoy.com/view/4lcSRn
// The MIT License, Copyright 2016 Inigo Quilez
bool CylinderImpostor(
    in vec3 rayOrigin, in vec3 rayDir,
    in vec3 start, in vec3 end, in float radius,
    out vec4 intersection, out bool interior
){
    vec3 ba = end - start;
    vec3 oc = rayOrigin - start;

    float baba = dot(ba, ba);
    float bard = dot(ba, rayDir);
    float baoc = dot(ba, oc);

    float k2 = baba - bard*bard;
    float k1 = baba * dot(oc, rayDir) - baoc * bard;
    float k0 = baba * dot(oc, oc) - baoc * baoc - radius * radius * baba;

    float h = k1 * k1 - k2 * k0;
    if (h < 0.0) return false;

    bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;
    bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;

    // body outside
    h = sqrt(h);
    float t = (-k1 - h) / k2;
    float y = baoc + t * bard;
    if (y > 0.0 && y < baba) {
        interior = false;
        intersection = vec4(t, (oc + t * rayDir - ba * y / baba) / radius);
        return true;
    }

    if (topCap && y < 0.0) {
        // top cap
        t = -baoc / bard;
        if (abs(k1 + k2 * t) < h) {
            interior = false;
            intersection = vec4(t, ba * sign(y) / baba);
            return true;
        }
    } else if(bottomCap && y >= 0.0) {
        // bottom cap
        t = (baba - baoc) / bard;
        if (abs(k1 + k2 * t) < h) {
            interior = false;
            intersection = vec4(t, ba * sign(y) / baba);
            return true;
        }
    }

    if (uDoubleSided) {
        // body inside
        h = -h;
        t = (-k1 - h) / k2;
        y = baoc + t * bard;
        if (y > 0.0 && y < baba) {
            interior = true;
            intersection = vec4(t, (oc + t * rayDir - ba * y / baba) / radius);
            return true;
        }

        // TODO: handle inside caps???
    }

    return false;
}

void main() {
    #include clip_pixel

    vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);

    vec4 intersection;
    bool interior;
    bool hit = CylinderImpostor(vModelPosition, rayDir, vStart, vEnd, vSize, intersection, interior);
    if (!hit) discard;

    vec3 vViewPosition = vModelPosition + intersection.x * rayDir;
    vViewPosition = (uView * vec4(vViewPosition, 1.0)).xyz;
    gl_FragDepthEXT = calcDepth(vViewPosition);

    vec3 vModelPosition = (uInvView * vec4(vViewPosition, 1.0)).xyz;

    if (gl_FragDepthEXT < 0.0) discard;
    if (gl_FragDepthEXT > 1.0) discard;

    float fragmentDepth = gl_FragDepthEXT;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        mat3 normalMatrix = transpose3(inverse3(mat3(uView)));
        vec3 normal = normalize(normalMatrix * -normalize(intersection.yzw));
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { fragDepth: "required", drawBuffers: "optional" }, {}, Ph), U$ = Rn("text", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;

attribute vec3 aPosition;
attribute vec2 aMapping;
attribute float aDepth;
attribute vec2 aTexCoord;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

uniform float uOffsetX;
uniform float uOffsetY;
uniform float uOffsetZ;

// uniform bool ortho;
uniform float uPixelRatio;
uniform vec4 uViewport;

varying vec2 vTexCoord;

#include matrix_scale

void main(void){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    vTexCoord = aTexCoord;

    float scale = matrixScale(uModelView);

    float offsetX = uOffsetX * scale;
    float offsetY = uOffsetY * scale;
    float offsetZ = (uOffsetZ + aDepth * 0.95) * scale;

    vec4 position4 = vec4(aPosition, 1.0);
    vec4 mvPosition = uModelView * aTransform * position4;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    // TODO
    // #ifdef FIXED_SIZE
    //     if (ortho) {
    //         scale /= pixelRatio * ((uViewport.w / 2.0) / -uCameraPosition.z) * 0.1;
    //     } else {
    //         scale /= pixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 0.1;
    //     }
    // #endif

    vec4 mvCorner = vec4(mvPosition.xyz, 1.0);

    if (vTexCoord.x == 10.0) { // indicates background plane
        // move a bit to the back, taking distance to camera into account to avoid z-fighting
        offsetZ -= 0.001 * distance(uCameraPosition, (uProjection * mvCorner).xyz);
    }

    mvCorner.xy += aMapping * size * scale;
    mvCorner.x += offsetX;
    mvCorner.y += offsetY;

    // TODO
    // if(ortho){
    //     mvCorner.xyz += normalize(-uCameraPosition) * offsetZ;
    // } else {
    //     mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;
    // }
    mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;

    gl_Position = uProjection * mvCorner;

    vViewPosition = -mvCorner.xyz;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

uniform sampler2D tFont;

uniform vec3 uBorderColor;
uniform float uBorderWidth;
uniform vec3 uBackgroundColor;
uniform float uBackgroundOpacity;

varying vec2 vTexCoord;

const float smoothness = 32.0;
const float gamma = 2.2;

void main2(){
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

void main(){
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;
    #include assign_material_color

    if (vTexCoord.x > 1.0) {
        gl_FragColor = vec4(uBackgroundColor, uBackgroundOpacity * material.a);
    } else {
        // retrieve signed distance
        float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;

        // perform adaptive anti-aliasing of the edges
        float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);
        float a = smoothstep(0.5 - w, 0.5 + w, sdf);

        // gamma correction for linear attenuation
        a = pow(a, 1.0 / gamma);

        if (a < 0.5) discard;
        material.a *= a;

        // add border
        float t = 0.5 + uBorderWidth;
        if (uBorderWidth > 0.0 && sdf < t) {
            material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));
        }

        gl_FragColor = material;
    }

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, o3), G$ = Rn("lines", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform float uPixelRatio;
uniform vec4 uViewport;

attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

attribute vec2 aMapping;
attribute vec3 aStart;
attribute vec3 aEnd;

void trimSegment(const in vec4 start, inout vec4 end) {
    // trim end segment so it terminates between the camera plane and the near plane
    // conservative estimate of the near plane
    float a = uProjection[2][2];  // 3rd entry in 3rd column
    float b = uProjection[3][2];  // 3rd entry in 4th column
    float nearEstimate = -0.5 * b / a;
    float alpha = (nearEstimate - start.z) / (end.z - start.z);
    end.xyz = mix(start.xyz, end.xyz, alpha);
}

void main(){
    float aspect = uViewport.z / uViewport.w;

    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    mat4 modelView = uView * uModel * aTransform;

    // camera space
    vec4 start = modelView * vec4(aStart, 1.0);
    vec4 end = modelView * vec4(aEnd, 1.0);

    // assign position
    vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0);
    vec4 mvPosition = modelView * position4;
    vViewPosition = mvPosition.xyz;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
    // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
    // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
    // perhaps there is a more elegant solution -- WestLangley
    bool perspective = (uProjection[2][3] == -1.0); // 4th entry in the 3rd column
    if (perspective) {
        if (start.z < 0.0 && end.z >= 0.0) {
            trimSegment(start, end);
        } else if (end.z < 0.0 && start.z >= 0.0) {
            trimSegment(end, start);
        }
    }

    // clip space
    vec4 clipStart = uProjection * start;
    vec4 clipEnd = uProjection * end;

    // ndc space
    vec2 ndcStart = clipStart.xy / clipStart.w;
    vec2 ndcEnd = clipEnd.xy / clipEnd.w;

    // direction
    vec2 dir = ndcEnd - ndcStart;

    // account for clip-space aspect ratio
    dir.x *= aspect;
    dir = normalize(dir);

    // perpendicular to dir
    vec2 offset = vec2(dir.y, - dir.x);

    // undo aspect ratio adjustment
    dir.x /= aspect;
    offset.x /= aspect;

    // sign flip
    if (aMapping.x < 0.0) offset *= -1.0;

    // calculate linewidth
    float linewidth;
    #ifdef dLineSizeAttenuation
        linewidth = size * uPixelRatio * ((uViewport.w / 2.0) / -start.z) * 5.0;
    #else
        linewidth = size * uPixelRatio;
    #endif
    linewidth = max(1.0, linewidth);

    // adjust for linewidth
    offset *= linewidth;

    // adjust for clip-space to screen-space conversion
    offset /= uViewport.w;

    // select end
    vec4 clip = (aMapping.y < 0.5) ? clipStart : clipEnd;

    // back to clip space
    offset *= clip.w;
    clip.xy += offset;
    gl_Position = clip;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

void main(){
    #include clip_pixel

    bool interior = false;
    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        gl_FragColor = material;

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, o3), r9 = Rn("mesh", `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include common_clip
#include texture3d_from_2d_linear

#ifdef dGeometryType_textureMesh
    uniform vec2 uGeoTexDim;
    uniform sampler2D tPosition;
    uniform sampler2D tGroup;
    uniform sampler2D tNormal;
#else
    attribute vec3 aPosition;
    attribute float aGroup;
    attribute vec3 aNormal;
#endif
attribute mat4 aTransform;
attribute float aInstance;

varying vec3 vNormal;

void main(){
    #include assign_group
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_position
    #include assign_color_varying
    #include clip_instance

    #ifdef dGeometryType_textureMesh
        vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;
    #else
        vec3 normal = aNormal;
    #endif
    mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));
    vec3 transformedNormal = normalize(normalMatrix * normalize(normal));
    #if defined(dFlipSided)
        if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR
            transformedNormal = -transformedNormal;
        }
    #endif
    vNormal = transformedNormal;
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include normal_frag_params
#include common_clip

void main() {
    #include clip_pixel

    // Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)
    vec3 fdx = dFdx(vViewPosition);
    vec3 fdy = dFdy(vViewPosition);
    vec3 faceNormal = normalize(cross(fdx,fdy));
    bool frontFacing = dot(vNormal, faceNormal) > 0.0;

    #if defined(dFlipSided)
        interior = frontFacing;
    #else
        interior = !frontFacing;
    #endif

    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        #if defined(dFlatShaded)
            vec3 normal = -faceNormal;
        #else
            vec3 normal = -normalize(vNormal);
            if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;
        #endif
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, Ph), V$ = Rn("direct-volume", `
precision highp float;

attribute vec3 aPosition;
attribute mat4 aTransform;
attribute float aInstance;

uniform mat4 uModelView;
uniform mat4 uProjection;
uniform vec4 uInvariantBoundingSphere;

varying vec3 vOrigPos;
varying float vInstance;
varying vec4 vBoundingSphere;
varying mat4 vTransform;

uniform vec3 uBboxSize;
uniform vec3 uBboxMin;
uniform vec3 uBboxMax;
uniform vec3 uGridDim;
uniform mat4 uTransform;

uniform mat4 uUnitToCartn;

void main() {
    vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0);
    vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord;

    vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz;
    vInstance = aInstance;
    vBoundingSphere = vec4(
        (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,
        uInvariantBoundingSphere.w
    );
    vTransform = aTransform;

    gl_Position = uProjection * mvPosition;

    // move z position to near clip plane (but not too close to get precision issues)
    gl_Position.z = gl_Position.w - 0.01;
}
`, `
precision highp float;
precision highp int;

#include common
#include light_frag_params

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];
#endif
#include common_clip

#include read_from_texture
#include texture3d_from_1d_trilinear
#include texture3d_from_2d_nearest
#include texture3d_from_2d_linear

uniform mat4 uProjection, uTransform, uModelView, uModel, uView;
uniform vec3 uCameraDir;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

varying vec3 vOrigPos;
varying float vInstance;
varying vec4 vBoundingSphere;
varying mat4 vTransform;

uniform mat4 uInvView;
uniform vec3 uGridDim;
uniform vec3 uBboxSize;
uniform sampler2D tTransferTex;
uniform float uTransferScale;
uniform float uStepScale;
uniform float uJumpLength;

uniform int uObjectId;
uniform int uVertexCount;
uniform int uInstanceCount;
uniform int uGroupCount;

uniform vec3 uHighlightColor;
uniform vec3 uSelectColor;
uniform float uHighlightStrength;
uniform float uSelectStrength;
uniform int uMarkerPriority;

uniform vec3 uInvalidColor;
uniform float uInvalidStrength;

uniform float uMarker;
uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;

uniform float uMetalness;
uniform float uRoughness;

uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

uniform float uAlpha;
uniform float uPickingAlphaThreshold;
uniform bool uTransparentBackground;
uniform float uXrayEdgeFalloff;

uniform float uInteriorDarkening;
uniform bool uInteriorColorFlag;
uniform vec3 uInteriorColor;

uniform bool uRenderWboit;
uniform bool uDoubleSided;

uniform float uNear;
uniform float uFar;
uniform float uIsOrtho;

uniform vec3 uCellDim;
uniform vec3 uCameraPosition;
uniform mat4 uCartnToUnit;

#if __VERSION__ != 100
    // for webgl1 this is given as a 'define'
    uniform int uMaxSteps;
#endif

#if defined(dGridTexType_2d)
    precision highp sampler2D;
    uniform sampler2D tGridTex;
    uniform vec3 uGridTexDim;
#elif defined(dGridTexType_3d)
    precision highp sampler3D;
    uniform sampler3D tGridTex;
#endif

#if defined(dColorType_uniform)
    uniform vec3 uColor;
#elif defined(dColorType_texture)
    uniform vec2 uColorTexDim;
    uniform sampler2D tColor;
#endif

#ifdef dOverpaint
    #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)
        uniform vec2 uOverpaintTexDim;
        uniform sampler2D tOverpaint;
    #endif
#endif

#ifdef dUsePalette
    uniform sampler2D tPalette;
#endif

#if defined(dGridTexType_2d)
    vec4 textureVal(vec3 pos) {
        return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);
    }
    vec4 textureGroup(vec3 pos) {
        return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);
    }
#elif defined(dGridTexType_3d)
    vec4 textureVal(vec3 pos) {
        return texture(tGridTex, pos + (vec3(0.5) / uGridDim));
    }
    vec4 textureGroup(vec3 pos) {
        return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);
    }
#endif

float calcDepth(const in vec3 pos) {
    vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;
    return 0.5 + 0.5 * clipZW.x / clipZW.y;
}

float transferFunction(float value) {
    return texture2D(tTransferTex, vec2(value, 0.0)).a;
}

float getDepth(const in vec2 coords) {
    #ifdef depthTextureSupport
        if (!uRenderWboit) {
            // in case of opaque volumes (and depth texture support)
            return texture2D(tDepth, coords).r;
        } else {
            return unpackRGBAToDepth(texture2D(tDepth, coords));
        }
    #else
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #endif
}

const float gradOffset = 0.5;

vec3 v3m4(vec3 p, mat4 m) {
    return (m * vec4(p, 1.0)).xyz;
}

float preFogAlphaBlended = 0.0;

vec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {
    mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));
    mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);
    #if defined(dClipVariant_pixel) && dClipObjectCount != 0
        mat4 modelTransform = uModel * vTransform * uTransform;
    #endif
    mat4 modelViewTransform = uModelView * vTransform * uTransform;

    vec3 scaleVol = vec3(1.0) / uGridDim;
    vec3 pos = startLoc;
    vec4 cell;
    float prevValue = -1.0;
    float value = 0.0;
    vec4 src = vec4(0.0);
    vec4 dst = vec4(0.0);
    float fragmentDepth;

    vec3 posMin = vec3(0.0);
    vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;

    vec3 unitPos;

    vec3 nextPos;
    float nextValue;

    vec4 material;
    vec4 overpaint;
    float metalness = uMetalness;
    float roughness = uRoughness;

    vec3 gradient = vec3(1.0);
    vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);
    vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);
    vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);

    float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);
    float maxDistSq = maxDist * maxDist;

    for (int i = 0; i < uMaxSteps; ++i) {
        // break when beyond bounding-sphere or far-plane
        vec3 distVec = startLoc - pos;
        if (dot(distVec, distVec) > maxDistSq) break;

        unitPos = v3m4(pos, cartnToUnit);

        // continue when outside of grid
        if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||
            unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z
        ) {
            prevValue = value;
            pos += step;
            continue;
        }

        cell = textureVal(unitPos);
        value = cell.a; // current voxel value

        if (uJumpLength > 0.0 && value < 0.01) {
            nextPos = pos + rayDir * uJumpLength;
            nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;
            if (nextValue < 0.01) {
                prevValue = nextValue;
                pos = nextPos;
                continue;
            }
        }

        vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);
        if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))
            break;

        #if defined(dClipVariant_pixel) && dClipObjectCount != 0
            vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);
            if (clipTest(vec4(vModelPosition, 0.0), 0)) {
                prevValue = value;
                pos += step;
                continue;
            }
        #endif

        vec3 vViewPosition = mvPosition.xyz;
        material.a = transferFunction(value);

        #ifdef dPackedGroup
            float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);
        #else
            vec3 g = floor(unitPos * uGridDim + 0.5);
            // note that we swap x and z because the texture is flipped around y
            #if defined(dAxisOrder_012)
                float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210
            #elif defined(dAxisOrder_021)
                float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120
            #elif defined(dAxisOrder_102)
                float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201
            #elif defined(dAxisOrder_120)
                float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021
            #elif defined(dAxisOrder_201)
                float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102
            #elif defined(dAxisOrder_210)
                float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012
            #endif
        #endif

        #if defined(dColorType_direct) && defined(dUsePalette)
            material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb;
        #elif defined(dColorType_uniform)
            material.rgb = uColor;
        #elif defined(dColorType_instance)
            material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb;
        #elif defined(dColorType_group)
            material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
        #elif defined(dColorType_groupInstance)
            material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;
        #elif defined(dColorType_vertex)
            material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, 0.0).rgb;
        #elif defined(dColorType_vertexInstance)
            material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;
        #endif

        #ifdef dOverpaint
            #if defined(dOverpaintType_groupInstance)
                overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);
            #elif defined(dOverpaintType_vertexInstance)
                overpaint = texture3dFrom1dTrilinear(tOverpaint, isoPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));
            #endif

            material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);
        #endif

        if (material.a >= 0.01) {
            #ifdef dPackedGroup
                // compute gradient by central differences
                gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;
                gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;
                gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;
            #else
                gradient = cell.xyz * 2.0 - 1.0;
            #endif
            vec3 normal = -normalize(normalMatrix * normalize(gradient));
            #include apply_light_color
        } else {
            gl_FragColor.rgb = material.rgb;
        }

        gl_FragColor.a = material.a * uAlpha * uTransferScale;

        float marker = uMarker;
        if (uMarker == -1.0) {
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }
        #include apply_marker_color

        preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;
        fragmentDepth = calcDepth(mvPosition.xyz);
        #include apply_fog

        src = gl_FragColor;

        if (!uTransparentBackground) {
            // done in 'apply_fog' otherwise
            src.rgb *= src.a;
        }
        dst = (1.0 - dst.a) * src + dst; // standard blending

        // break if the color is opaque enough
        if (dst.a > 0.95)
            break;

        pos += step;
    }

    return dst;
}

// TODO: support float texture for higher precision values???
// TODO: support clipping exclusion texture support

void main() {
    if (gl_FrontFacing)
        discard;

    vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);
    vec3 step = rayDir * uStepScale;

    float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;
    float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);
    vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);
    gl_FragColor = raymarch(start, step, rayDir);

    float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);
    float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);
    bool interior = false;
    #include wboit_write
}
`, { fragDepth: "optional", drawBuffers: "optional" }, {}, Ph), q$ = Rn("image", `
precision highp float;
precision highp int;

#include common
#include common_vert_params

attribute vec3 aPosition;
attribute vec2 aUv;
attribute mat4 aTransform;
attribute float aInstance;

varying vec2 vUv;
varying float vInstance;

void main() {
    #include assign_position

    vUv = aUv;
    vInstance = aInstance;
}
`, `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_frag_params
#include common_clip

uniform vec2 uImageTexDim;
uniform sampler2D tImageTex;
uniform sampler2D tGroupTex;

uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;

varying vec2 vUv;
varying float vInstance;

#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)
    #define dInterpolation_cubic
#endif

#if defined(dInterpolation_cubic)
    #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)
        #if defined(dInterpolation_catmulrom)
            const float B = 0.0;
            const float C = 0.5;
        #elif defined(dInterpolation_mitchell)
            const float B = 0.333;
            const float C = 0.333;
        #endif

        float cubicFilter(float x){
            float f = x;
            if (f < 0.0) {
                f = -f;
            }
            if (f < 1.0) {
                return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +
                    (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +
                    (6.0 - 2.0 * B)) / 6.0;
            }else if (f >= 1.0 && f < 2.0){
                return ((-B - 6.0 * C) * ( f * f * f)
                    + (6.0 * B + 30.0 * C) * (f * f) +
                    (-(12.0 * B) - 48.0 * C) * f +
                    8.0 * B + 24.0 * C) / 6.0;
            }else{
                return 0.0;
            }
        }
    #elif defined(dInterpolation_bspline)
        float cubicFilter(float x) {
            float f = x;
            if (f < 0.0) {
                f = -f;
            }
            if (f >= 0.0 && f <= 1.0){
                return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);
            } else if (f > 1.0 && f <= 2.0) {
                return 1.0 / 6.0 * pow((2.0 - f), 3.0);
            }
            return 1.0;
        }
    #endif

    vec4 biCubic(sampler2D tex, vec2 texCoord) {
        vec2 texelSize = 1.0 / uImageTexDim;
        texCoord -= texelSize / 2.0;
        vec4 nSum = vec4(0.0);
        float nDenom = 0.0;
        vec2 cell = fract(texCoord * uImageTexDim);
        for (float m = -1.0; m <= 2.0; ++m) {
            for (float n = -1.0; n <= 2.0; ++n) {
                vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));
                float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);
                nSum += vecData * c;
                nDenom += c;
            }
        }
        return nSum / nDenom;
    }
#endif

void main() {
    #include clip_pixel

    #if defined(dInterpolation_cubic)
        vec4 imageData = biCubic(tImageTex, vUv);
    #else
        vec4 imageData = texture2D(tImageTex, vUv);
    #endif
    imageData.a = clamp(imageData.a, 0.0, 1.0);
    if (imageData.a > 0.9) imageData.a = 1.0;

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;

    #if defined(dRenderVariant_pick)
        if (imageData.a < 0.3)
            discard;
        if (uPickType == 1) {
            gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);
        } else if (uPickType == 2) {
            gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);
        } else {
            gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);
        }
    #elif defined(dRenderVariant_depth)
        if (imageData.a < 0.05)
            discard;
        gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
    #elif defined(dRenderVariant_marking)
        float marker = uMarker;
        if (uMarker == -1.0) {
            float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }
        if (uMarkingType == 1) {
            if (marker > 0.0 || imageData.a < 0.05)
                discard;
            gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
        } else {
            if (marker == 0.0 || imageData.a < 0.05)
                discard;
            float depthTest = 1.0;
            if (uMarkingDepthTest) {
                depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;
            }
            bool isHighlight = intMod(marker, 2.0) > 0.1;
            gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);
        }
    #elif defined(dRenderVariant_color)
        if (imageData.a < 0.05)
            discard;
        gl_FragColor = imageData;
        gl_FragColor.a *= uAlpha;

        float marker = uMarker;
        if (uMarker == -1.0) {
            float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, o3);
function n9(e, t) {
  var r;
  if (e === void 0) return "";
  var n = ((r = e.dRenderVariant) === null || r === void 0 ? void 0 : r.ref.value) || "", a = [];
  for (var i in e) if (!(t != null && t(i, n, e))) {
    var o = e[i].ref.value;
    o !== void 0 && (typeof o == "string" ? a.push("#define ".concat(i, "_").concat(o)) : typeof o == "number" ? a.push("#define ".concat(i, " ").concat(o)) : typeof o == "boolean" ? o && a.push("#define ".concat(i)) : Ja());
  }
  return a.join(`
`) + `
`;
}
var H$ = `#version 300 es
#define attribute in
#define varying out
#define texture2D texture
`, K$ = `
#define varying in
#define texture2D texture
#define texture2DLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth

#define depthTextureSupport
`;
function X$(e, t, r, n) {
  var a = n9(r, n.ignoreDefine), i = n9(r, n.ignoreDefine), o = lr(e) ? H$ : "", s = lr(e) ? function(c, l, d, f) {
    var m = ["#version 300 es", "layout(location = 0) out highp ".concat(f[0] || "vec4", " out_FragData0;")];
    if (d.fragDepth && m.push("#define enabledFragDepth"), d.drawBuffers) {
      m.push("#define requiredDrawBuffers");
      for (var h = 1, p = c.getParameter(c.MAX_DRAW_BUFFERS); h < p; ++h) m.push("layout(location = ".concat(h, ") out highp ").concat(f[h] || "vec4", " out_FragData").concat(h, ";"));
    }
    return d.shaderTextureLod && m.push("#define enabledShaderTextureLod"), m.push(K$), m.join(`
`) + `
`;
  }(e, 0, n.extensions, n.outTypes) : function(c, l) {
    var d = ["#extension GL_OES_standard_derivatives : enable"];
    if (l.fragDepth) {
      if (c.fragDepth) d.push("#extension GL_EXT_frag_depth : enable"), d.push("#define enabledFragDepth");
      else if (l.fragDepth === "required") throw new Error("required 'GL_EXT_frag_depth' extension not available");
    }
    if (l.drawBuffers) {
      if (c.drawBuffers) d.push("#extension GL_EXT_draw_buffers : require"), d.push("#define requiredDrawBuffers"), d.push("#define gl_FragColor gl_FragData[0]");
      else if (l.drawBuffers === "required") throw new Error("required 'GL_EXT_draw_buffers' extension not available");
    }
    if (l.shaderTextureLod) {
      if (c.shaderTextureLod) d.push("#extension GL_EXT_shader_texture_lod : enable"), d.push("#define enabledShaderTextureLod");
      else if (l.shaderTextureLod === "required") throw new Error("required 'GL_EXT_shader_texture_lod' extension not available");
    }
    return c.depthTexture && d.push("#define depthTextureSupport"), d.join(`
`) + `
`;
  }(t, n.extensions), u = lr(e) ? function(c) {
    return c.replace(/gl_FragData\[([0-9]+)\]/g, "out_FragData$1");
  }(n.frag) : n.frag;
  return { id: uF(), name: n.name, vert: "".concat(o).concat(a).concat(t9(n.vert, r)), frag: "".concat(s).concat(i).concat(t9(u, r)), extensions: n.extensions, outTypes: n.outTypes };
}
function j$(e, t) {
  switch (t) {
    case "b":
    case "b[]":
      return e.BOOL;
    case "f":
    case "f[]":
      return e.FLOAT;
    case "i":
    case "i[]":
      return e.INT;
    case "v2":
    case "v2[]":
      return e.FLOAT_VEC2;
    case "v3":
    case "v3[]":
      return e.FLOAT_VEC3;
    case "v4":
    case "v4[]":
      return e.FLOAT_VEC4;
    case "m3":
    case "m3[]":
      return e.FLOAT_MAT3;
    case "m4":
    case "m4[]":
      return e.FLOAT_MAT4;
    default:
      console.error("unknown uniform kind '".concat(t, "'"));
  }
}
function Y$(e, t, r) {
  e.uniform1f(t, r);
}
function W$(e, t, r) {
  e.uniform1fv(t, r);
}
function Z$(e, t, r) {
  e.uniform1i(t, r);
}
function Q$(e, t, r) {
  e.uniform1iv(t, r);
}
function $$(e, t, r) {
  e.uniform2fv(t, r);
}
function J$(e, t, r) {
  e.uniform3fv(t, r);
}
function eJ(e, t, r) {
  e.uniform4fv(t, r);
}
function tJ(e, t, r) {
  e.uniformMatrix3fv(t, !1, r);
}
function rJ(e, t, r) {
  e.uniformMatrix4fv(t, !1, r);
}
function a9(e) {
  switch (e) {
    case "f":
      return Y$;
    case "f[]":
      return W$;
    case "i":
    case "t":
    case "b":
      return Z$;
    case "i[]":
    case "t[]":
    case "b[]":
      return Q$;
    case "v2":
    case "v2[]":
      return $$;
    case "v3":
    case "v3[]":
      return J$;
    case "v4":
    case "v4[]":
      return eJ;
    case "m3":
    case "m3[]":
      return tJ;
    case "m4":
    case "m4[]":
      return rJ;
  }
}
var nJ = $i();
function i9(e) {
  var t = e.createBuffer();
  if (t === null) throw new Error("Could not create WebGL buffer");
  return t;
}
function o9(e, t, r, n) {
  var a = i9(e), i = function(f, m) {
    switch (m) {
      case "static":
        return f.STATIC_DRAW;
      case "dynamic":
        return f.DYNAMIC_DRAW;
      case "stream":
        return f.STREAM_DRAW;
    }
  }(e, r), o = function(f, m) {
    switch (m) {
      case "attribute":
        return f.ARRAY_BUFFER;
      case "elements":
        return f.ELEMENT_ARRAY_BUFFER;
      case "uniform":
        return f.UNIFORM_BUFFER;
    }
  }(e, n), s = function(f, m) {
    return m instanceof Uint8Array ? f.UNSIGNED_BYTE : m instanceof Int8Array ? f.BYTE : m instanceof Uint16Array ? f.UNSIGNED_SHORT : m instanceof Int16Array ? f.SHORT : m instanceof Uint32Array ? f.UNSIGNED_INT : m instanceof Int32Array ? f.INT : m instanceof Float32Array ? f.FLOAT : void Ja();
  }(e, t), u = t.BYTES_PER_ELEMENT, c = t.length;
  function l(f) {
    e.bindBuffer(o, a), e.bufferData(o, f, i);
  }
  l(t);
  var d = !1;
  return { id: nJ(), _usageHint: i, _bufferType: o, _dataType: s, _bpe: u, length: c, getBuffer: function() {
    return a;
  }, updateData: l, updateSubData: function(f, m, h) {
    e.bindBuffer(o, a), h - m === f.length ? e.bufferSubData(o, 0, f) : e.bufferSubData(o, m * u, f.subarray(m, m + h));
  }, reset: function() {
    a = i9(e), l(t);
  }, destroy: function() {
    d || (e.deleteBuffer(a), d = !0);
  } };
}
function aJ(e, t, r) {
  switch (t) {
    case "int32":
      switch (r) {
        case 1:
          return e.INT;
        case 2:
          return e.INT_VEC2;
        case 3:
          return e.INT_VEC3;
        case 4:
          return e.INT_VEC4;
      }
      break;
    case "float32":
      switch (r) {
        case 1:
          return e.FLOAT;
        case 2:
          return e.FLOAT_VEC2;
        case 3:
          return e.FLOAT_VEC3;
        case 4:
          return e.FLOAT_VEC4;
        case 16:
          return e.FLOAT_MAT4;
      }
  }
  throw new Error("unknown attribute type for kind '".concat(t, "' and itemSize '").concat(r, "'"));
}
var iJ = $i();
function s6(e) {
  var t = e.createProgram();
  if (t === null) throw new Error("Could not create WebGL program");
  return t;
}
function oJ(e, t, r, n, a) {
  var i, o, s = a.defineValues, u = a.shaderCode, c = a.schema, l = s6(e), d = iJ(), f = X$(e, r, s, u), m = n("vert", f.vert), h = n("frag", f.frag);
  function p() {
    m.attach(l), h.attach(l), e.linkProgram(l), zr && function(v, y) {
      if (!v.getProgramParameter(y, v.LINK_STATUS)) throw new Error(`Could not compile WebGL program. 

`.concat(v.getProgramInfoLog(y)));
    }(e, l), i = function(v, y, _) {
      var S = {};
      return Object.keys(_).forEach(function(b) {
        var x = _[b];
        if (x.type === "attribute") {
          var A = v.getAttribLocation(y, b);
          S[b] = A;
        } else x.type !== "uniform" && x.type !== "texture" || (A = v.getUniformLocation(y, b), S[b] = A);
      }), S;
    }(e, l, c), o = function(v) {
      var y = {};
      return Object.keys(v).forEach(function(_) {
        var S = v[_];
        S.type === "uniform" ? y[_] = a9(S.kind) : S.type === "texture" && (y[_] = a9("t"));
      }), y;
    }(c), zr && (function(v, y, _) {
      for (var S = v.getProgramParameter(y, v.ACTIVE_ATTRIBUTES), b = 0; b < S; ++b) {
        var x = v.getActiveAttrib(y, b);
        if (x) {
          var A = x.name, w = x.type;
          if (A.startsWith("__activeAttribute") || A === "gl_InstanceID" || A === "gl_VertexID") continue;
          var C = _[A];
          if (C === void 0) throw new Error("missing 'uniform' or 'texture' with name '".concat(A, "' in schema"));
          if (C.type !== "attribute") throw new Error("'".concat(A, "' must be of type 'attribute' but is '").concat(C.type, "'"));
          if (aJ(v, C.kind, C.itemSize) !== w) throw new Error("unexpected attribute type for ".concat(A));
        }
      }
    }(e, l, c), function(v, y, _) {
      for (var S = v.getProgramParameter(y, v.ACTIVE_UNIFORMS), b = 0; b < S; ++b) {
        var x = v.getActiveUniform(y, b);
        if (x) {
          var A = x.name, w = x.type;
          if (A.startsWith("__activeUniform")) continue;
          var C = _[A.replace(/[[0-9]+\]$/, "")];
          if (C === void 0) throw new Error("missing 'uniform' or 'texture' with name '".concat(A, "' in schema"));
          if (C.type === "uniform") {
            if (j$(v, C.kind) !== w) throw new Error("unexpected uniform type for ".concat(A));
          } else {
            if (C.type !== "texture") throw new Error("'".concat(A, "' must be of type 'uniform' or 'texture' but is '").concat(C.type, "'"));
            if (C.kind === "image-float32" || C.kind === "image-uint8") {
              if (w !== v.SAMPLER_2D) throw new Error("unexpected sampler type for '".concat(A, "'"));
            } else if ((C.kind === "volume-float32" || C.kind === "volume-uint8") && w !== v.SAMPLER_3D) throw new Error("unexpected sampler type for '".concat(A, "'"));
          }
        }
      }
    }(e, l, c));
  }
  p();
  var g = !1;
  return { id: d, use: function() {
    t.currentProgramId = d, e.useProgram(l);
  }, setUniforms: function(v) {
    for (var y = 0, _ = v.length; y < _; ++y) {
      var S = v[y], b = S[0], x = S[1];
      if (x) {
        var A = i[b];
        A !== null && o[b](e, A, x.ref.value);
      }
    }
  }, bindAttributes: function(v) {
    t.clearVertexAttribsState();
    for (var y = 0, _ = v.length; y < _; ++y) {
      var S = v[y], b = S[0], x = S[1], A = i[b];
      A !== -1 && x.bind(A);
    }
    t.disableUnusedVertexAttribs();
  }, bindTextures: function(v, y) {
    for (var _ = 0, S = v.length; _ < S; ++_) {
      var b = v[_], x = b[0], A = b[1], w = i[x];
      w != null && (A.bind(_ + y), o[x](e, w, _ + y));
    }
  }, reset: function() {
    l = s6(e), p();
  }, destroy: function() {
    g || (m.destroy(), h.destroy(), e.deleteProgram(l), g = !0);
  } };
}
var sJ = $i();
function W2(e, t) {
  var r = t.type, n = t.source, a = e.createShader(r === "vert" ? e.VERTEX_SHADER : e.FRAGMENT_SHADER);
  if (a === null) throw new Error("Error creating ".concat(r, " shader"));
  if (e.shaderSource(a, n), e.compileShader(a), zr && e.getShaderParameter(a, e.COMPILE_STATUS) === !1) throw console.warn("'".concat(r, "' shader info log '").concat(e.getShaderInfoLog(a), `'
`).concat(function(i) {
    for (var o = i.split(`
`), s = 0; s < o.length; ++s) o[s] = s + 1 + ": " + o[s];
    return o.join(`
`);
  }(n))), new Error("Error compiling ".concat(r, " shader"));
  return a;
}
function uJ(e, t) {
  var r = W2(e, t);
  return { id: sJ(), attach: function(n) {
    e.attachShader(n, r);
  }, reset: function() {
    r = W2(e, t);
  }, destroy: function() {
    e.deleteShader(r);
  } };
}
function lr(e) {
  return typeof WebGL2RenderingContext < "u" && e instanceof WebGL2RenderingContext;
}
var cJ = `
attribute vec4 aPosition;

void main() {
    gl_Position = aPosition;
}`, lJ = `
precision mediump float;
uniform vec4 uColor;
uniform sampler2D uTexture;

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, dJ = new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]);
function s9(e, t) {
  var r = W2(e, { type: "vert", source: cJ }), n = W2(e, { type: "frag", source: lJ });
  if (!r || !n) return !1;
  var a = s6(e);
  e.attachShader(a, r), e.attachShader(a, n), e.linkProgram(a), e.useProgram(a);
  var i = e.getAttribLocation(a, "aPosition"), o = e.getUniformLocation(a, "uColor");
  if (!o) return zr && console.log("error getting 'uColor' uniform location"), !1;
  var s = e.createBuffer();
  e.bindBuffer(e.ARRAY_BUFFER, s), e.bufferData(e.ARRAY_BUFFER, dJ, e.STATIC_DRAW), e.enableVertexAttribArray(i), e.vertexAttribPointer(i, 2, e.FLOAT, !1, 0, 0);
  var u = e.createTexture(), c = new Uint8Array([255, 255, 255, 255]);
  e.bindTexture(e.TEXTURE_2D, u), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, c);
  var l = e.createTexture();
  e.bindTexture(e.TEXTURE_2D, l), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, t, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST);
  var d = e.createFramebuffer();
  if (e.bindFramebuffer(e.FRAMEBUFFER, d), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, l, 0), e.checkFramebufferStatus(e.FRAMEBUFFER) !== e.FRAMEBUFFER_COMPLETE) return zr && console.log("error creating framebuffer for '".concat(t, "'")), !1;
  e.bindTexture(e.TEXTURE_2D, u), e.uniform4fv(o, [0, 10, 20, 1]), e.drawArrays(e.TRIANGLES, 0, 6), e.bindTexture(e.TEXTURE_2D, l), e.bindFramebuffer(e.FRAMEBUFFER, null), e.clearColor(1, 0, 0, 1), e.clear(e.COLOR_BUFFER_BIT), e.uniform4fv(o, [0, 0.1, 0.05, 1]), e.drawArrays(e.TRIANGLES, 0, 6);
  var f = new Uint8Array(4);
  if (e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, f), f[0] !== 0 || f[1] < 248 || f[2] < 248 || f[3] < 254) return zr && console.log("not able to actually render to '".concat(t, "' texture")), !1;
  if (t === e.FLOAT) {
    e.bindFramebuffer(e.FRAMEBUFFER, d);
    var m = new Float32Array(4);
    e.readPixels(0, 0, 1, 1, e.RGBA, e.FLOAT, m);
    var h = e.getError();
    if (h) return zr && console.log("error reading float pixels: '".concat(fF(e, h), "'")), !1;
  }
  return !0;
}
var jf, cF = $i();
function g8(e) {
  var t = e.checkFramebufferStatus(e.FRAMEBUFFER);
  if (t !== e.FRAMEBUFFER_COMPLETE) {
    var r = function(n, a) {
      switch (a) {
        case n.FRAMEBUFFER_COMPLETE:
          return "complete";
        case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
          return "incomplete attachment";
        case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
          return "incomplete missing attachment";
        case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
          return "incomplete dimensions";
        case n.FRAMEBUFFER_UNSUPPORTED:
          return "unsupported";
      }
      if (lr(n)) switch (a) {
        case n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
          return "incomplete multisample";
        case n.RENDERBUFFER_SAMPLES:
          return "renderbuffer samples";
      }
      return "unknown error";
    }(e, t);
    throw new Error("Framebuffer status: ".concat(r));
  }
}
function u9(e) {
  var t = e.createFramebuffer();
  if (t === null) throw new Error("Could not create WebGL framebuffer");
  return t;
}
function c9(e) {
  var t = function(v) {
    if (lr(v)) return { drawArraysInstanced: v.drawArraysInstanced.bind(v), drawElementsInstanced: v.drawElementsInstanced.bind(v), vertexAttribDivisor: v.vertexAttribDivisor.bind(v), VERTEX_ATTRIB_ARRAY_DIVISOR: v.VERTEX_ATTRIB_ARRAY_DIVISOR };
    var y = v.getExtension("ANGLE_instanced_arrays");
    return y === null ? null : { drawArraysInstanced: y.drawArraysInstancedANGLE.bind(y), drawElementsInstanced: y.drawElementsInstancedANGLE.bind(y), vertexAttribDivisor: y.vertexAttribDivisorANGLE.bind(y), VERTEX_ATTRIB_ARRAY_DIVISOR: y.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE };
  }(e);
  if (t === null) throw new Error('Could not find support for "instanced_arrays"');
  var r = function(v) {
    return lr(v) ? {} : v.getExtension("OES_element_index_uint");
  }(e);
  if (r === null) throw new Error('Could not find support for "element_index_uint"');
  var n = function(v) {
    if (lr(v)) return { FRAGMENT_SHADER_DERIVATIVE_HINT: v.FRAGMENT_SHADER_DERIVATIVE_HINT };
    var y = v.getExtension("OES_standard_derivatives");
    return y === null ? null : { FRAGMENT_SHADER_DERIVATIVE_HINT: y.FRAGMENT_SHADER_DERIVATIVE_HINT_OES };
  }(e);
  if (n === null) throw new Error('Could not find support for "standard_derivatives"');
  var a = function(v) {
    return lr(v) ? {} : v.getExtension("OES_texture_float");
  }(e);
  zr && a === null && console.log('Could not find support for "texture_float"');
  var i = function(v) {
    return v.getExtension("OES_texture_float_linear");
  }(e);
  zr && i === null && console.log('Could not find support for "texture_float_linear"');
  var o = function(v) {
    if (lr(v)) return { HALF_FLOAT: v.HALF_FLOAT };
    var y = v.getExtension("OES_texture_half_float");
    return y === null ? null : { HALF_FLOAT: y.HALF_FLOAT_OES };
  }(e);
  zr && o === null && console.log('Could not find support for "texture_half_float"');
  var s = function(v) {
    return v.getExtension("OES_texture_half_float_linear");
  }(e);
  zr && s === null && console.log('Could not find support for "texture_half_float_linear"');
  var u = function(v) {
    if (lr(v)) return { UNSIGNED_INT_24_8: v.UNSIGNED_INT_24_8 };
    var y = v.getExtension("WEBGL_depth_texture");
    return y === null ? null : { UNSIGNED_INT_24_8: y.UNSIGNED_INT_24_8_WEBGL };
  }(e);
  zr && u === null && console.log('Could not find support for "depth_texture"');
  var c = function(v) {
    if (lr(v)) return { MIN: v.MIN, MAX: v.MAX };
    var y = v.getExtension("EXT_blend_minmax");
    return y === null ? null : { MIN: y.MIN_EXT, MAX: y.MAX_EXT };
  }(e);
  zr && c === null && console.log('Could not find support for "blend_minmax"');
  var l = function(v) {
    if (lr(v)) return { VERTEX_ARRAY_BINDING: v.VERTEX_ARRAY_BINDING, bindVertexArray: v.bindVertexArray.bind(v), createVertexArray: v.createVertexArray.bind(v), deleteVertexArray: v.deleteVertexArray.bind(v), isVertexArray: v.isVertexArray.bind(v) };
    var y = v.getExtension("OES_vertex_array_object");
    return y === null ? null : { VERTEX_ARRAY_BINDING: y.VERTEX_ARRAY_BINDING_OES, bindVertexArray: y.bindVertexArrayOES.bind(y), createVertexArray: y.createVertexArrayOES.bind(y), deleteVertexArray: y.deleteVertexArrayOES.bind(y), isVertexArray: y.isVertexArrayOES.bind(y) };
  }(e);
  zr && l === null && console.log('Could not find support for "vertex_array_object"');
  var d = function(v) {
    return lr(v) ? {} : v.getExtension("EXT_frag_depth");
  }(e);
  zr && d === null && console.log('Could not find support for "frag_depth"');
  var f = function(v) {
    if (lr(v)) return v.getExtension("EXT_color_buffer_float") === null ? null : (v.getExtension("EXT_float_blend"), { RGBA32F: v.RGBA32F });
    var y = v.getExtension("WEBGL_color_buffer_float");
    return y === null ? (v.getExtension("OES_texture_float"), s9(v, v.FLOAT) ? { RGBA32F: 34836 } : null) : (v.getExtension("EXT_float_blend"), { RGBA32F: y.RGBA32F_EXT });
  }(e);
  zr && f === null && console.log('Could not find support for "color_buffer_float"');
  var m = function(v) {
    if (lr(v)) return v.getExtension("EXT_color_buffer_half_float") === null ? null : (v.getExtension("EXT_float_blend"), { RGBA16F: v.RGBA16F });
    var y = v.getExtension("EXT_color_buffer_half_float");
    return y === null ? (v.getExtension("OES_texture_half_float"), s9(v, 36193) ? { RGBA16F: 34842 } : null) : (v.getExtension("EXT_float_blend"), { RGBA16F: y.RGBA16F_EXT });
  }(e);
  zr && m === null && console.log('Could not find support for "color_buffer_half_float"');
  var h = function(v) {
    if (lr(v)) return { drawBuffers: v.drawBuffers.bind(v), COLOR_ATTACHMENT0: v.COLOR_ATTACHMENT0, COLOR_ATTACHMENT1: v.COLOR_ATTACHMENT1, COLOR_ATTACHMENT2: v.COLOR_ATTACHMENT2, COLOR_ATTACHMENT3: v.COLOR_ATTACHMENT3, COLOR_ATTACHMENT4: v.COLOR_ATTACHMENT4, COLOR_ATTACHMENT5: v.COLOR_ATTACHMENT5, COLOR_ATTACHMENT6: v.COLOR_ATTACHMENT6, COLOR_ATTACHMENT7: v.COLOR_ATTACHMENT7, DRAW_BUFFER0: v.DRAW_BUFFER0, DRAW_BUFFER1: v.DRAW_BUFFER1, DRAW_BUFFER2: v.DRAW_BUFFER2, DRAW_BUFFER3: v.DRAW_BUFFER3, DRAW_BUFFER4: v.DRAW_BUFFER4, DRAW_BUFFER5: v.DRAW_BUFFER5, DRAW_BUFFER6: v.DRAW_BUFFER6, DRAW_BUFFER7: v.DRAW_BUFFER7, MAX_COLOR_ATTACHMENTS: v.MAX_COLOR_ATTACHMENTS, MAX_DRAW_BUFFERS: v.MAX_DRAW_BUFFERS };
    var y = v.getExtension("WEBGL_draw_buffers");
    return y === null ? null : { drawBuffers: y.drawBuffersWEBGL.bind(y), COLOR_ATTACHMENT0: y.COLOR_ATTACHMENT0_WEBGL, COLOR_ATTACHMENT1: y.COLOR_ATTACHMENT1_WEBGL, COLOR_ATTACHMENT2: y.COLOR_ATTACHMENT2_WEBGL, COLOR_ATTACHMENT3: y.COLOR_ATTACHMENT3_WEBGL, COLOR_ATTACHMENT4: y.COLOR_ATTACHMENT4_WEBGL, COLOR_ATTACHMENT5: y.COLOR_ATTACHMENT5_WEBGL, COLOR_ATTACHMENT6: y.COLOR_ATTACHMENT6_WEBGL, COLOR_ATTACHMENT7: y.COLOR_ATTACHMENT7_WEBGL, DRAW_BUFFER0: y.DRAW_BUFFER0_WEBGL, DRAW_BUFFER1: y.DRAW_BUFFER1_WEBGL, DRAW_BUFFER2: y.DRAW_BUFFER2_WEBGL, DRAW_BUFFER3: y.DRAW_BUFFER3_WEBGL, DRAW_BUFFER4: y.DRAW_BUFFER4_WEBGL, DRAW_BUFFER5: y.DRAW_BUFFER5_WEBGL, DRAW_BUFFER6: y.DRAW_BUFFER6_WEBGL, DRAW_BUFFER7: y.DRAW_BUFFER7_WEBGL, MAX_COLOR_ATTACHMENTS: y.MAX_COLOR_ATTACHMENTS_WEBGL, MAX_DRAW_BUFFERS: y.MAX_DRAW_BUFFERS_WEBGL };
  }(e);
  zr && h === null && console.log('Could not find support for "draw_buffers"');
  var p = function(v) {
    return lr(v) ? {} : v.getExtension("EXT_shader_texture_lod");
  }(e);
  zr && p === null && console.log('Could not find support for "shader_texture_lod"');
  var g = function(v) {
    if (lr(v)) return { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: v.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, SRGB8_ALPHA8: v.SRGB8_ALPHA8, SRGB8: v.SRGB8, SRGB: v.SRGB };
    var y = v.getExtension("EXT_sRGB");
    return y === null ? null : { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: y.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT, SRGB8_ALPHA8: y.SRGB8_ALPHA8_EXT, SRGB8: y.SRGB_ALPHA_EXT, SRGB: y.SRGB_EXT };
  }(e);
  return zr && g === null && console.log('Could not find support for "sRGB"'), { instancedArrays: t, standardDerivatives: n, textureFloat: a, textureFloatLinear: i, textureHalfFloat: o, textureHalfFloatLinear: s, elementIndexUint: r, depthTexture: u, blendMinMax: c, vertexArrayObject: l, fragDepth: d, colorBufferFloat: f, colorBufferHalfFloat: m, drawBuffers: h, shaderTextureLod: p, sRGB: g };
}
function l9(e, t, r) {
  var n = /* @__PURE__ */ new Map();
  return { get: function(a) {
    var i, o, s = e(a), u = n.get(s);
    return u || (i = t(a), o === void 0 && (o = 0), u = { value: i, usageCount: o }, n.set(s, u)), u.usageCount += 1, function(c) {
      return { free: function() {
        c.usageCount -= 1;
      }, value: c.value };
    }(u);
  }, clear: function() {
    n.forEach(function(a, i) {
      a.usageCount <= 0 && (a.usageCount < 0 && console.warn("Reference usageCount below zero."), r(a.value), n.delete(i));
    });
  }, get count() {
    return n.size;
  }, dispose: function() {
    n.forEach(function(a) {
      return r(a.value);
    }), n.clear();
  } };
}
(function(e) {
  e.create = function(t, r, n) {
    return { array: t, width: r, height: n };
  }, e.flipY = function(t) {
    for (var r = t.array, n = t.width, a = t.height, i = 4 * n, o = 0, s = a / 2; o < s; ++o) for (var u = 0, c = i; u < c; ++u) {
      var l = o * i + u, d = (a - o - 1) * i + u, f = r[l];
      r[l] = r[d], r[d] = f;
    }
    return t;
  }, e.divideByAlpha = function(t) {
    for (var r = t.array, n = r instanceof Uint8Array ? 255 : 1, a = 0, i = r.length; a < i; a += 4) {
      var o = r[a + 3] / n;
      o !== 0 ? (r[a] /= o, r[a + 1] /= o, r[a + 2] /= o) : (r[a] = 0, r[a + 1] = 0, r[a + 2] = 0);
    }
    return t;
  };
})(jf || (jf = {}));
var fJ = $i();
function d9(e) {
  var t = e.createRenderbuffer();
  if (t === null) throw new Error("Could not create WebGL renderbuffer");
  return t;
}
function mJ(e, t, r, n, a) {
  var i = d9(e), o = function() {
    return e.bindRenderbuffer(e.RENDERBUFFER, i);
  }, s = function(d, f) {
    switch (f) {
      case "depth16":
        return d.DEPTH_COMPONENT16;
      case "stencil8":
        return d.STENCIL_INDEX8;
      case "rgba4":
        return d.RGBA4;
      case "depth-stencil":
        return d.DEPTH_STENCIL;
      case "depth32f":
        if (lr(d)) return d.DEPTH_COMPONENT32F;
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    }
  }(e, t), u = function(d, f) {
    switch (f) {
      case "depth":
        return d.DEPTH_ATTACHMENT;
      case "stencil":
        return d.STENCIL_ATTACHMENT;
      case "depth-stencil":
        return d.DEPTH_STENCIL_ATTACHMENT;
      case "color0":
        return d.COLOR_ATTACHMENT0;
    }
  }(e, r);
  function c() {
    o(), e.renderbufferStorage(e.RENDERBUFFER, s, n, a);
  }
  c();
  var l = !1;
  return { id: fJ(), bind: o, attachFramebuffer: function(d) {
    d.bind(), o(), e.framebufferRenderbuffer(e.FRAMEBUFFER, u, e.RENDERBUFFER, i), zr && g8(e);
  }, setSize: function(d, f) {
    n = d, a = f, c();
  }, reset: function() {
    i = d9(e), c();
  }, destroy: function() {
    l || (e.deleteRenderbuffer(i), l = !0);
  } };
}
var lF = $i();
function f9(e, t, r) {
  switch (t) {
    case "alpha":
      return lr(e) && r === "float" ? e.RED : lr(e) && r === "int" ? e.RED_INTEGER : e.ALPHA;
    case "rgb":
      return lr(e) && r === "int" ? e.RGB_INTEGER : e.RGB;
    case "rgba":
      return lr(e) && r === "int" ? e.RGBA_INTEGER : e.RGBA;
    case "depth":
      return e.DEPTH_COMPONENT;
  }
}
function m9(e, t) {
  switch (t) {
    case "nearest":
      return e.NEAREST;
    case "linear":
      return e.LINEAR;
  }
}
function Zv(e, t, r) {
  switch (r) {
    case "depth":
      return e.DEPTH_ATTACHMENT;
    case "stencil":
      return e.STENCIL_ATTACHMENT;
    case "color0":
    case 0:
      return e.COLOR_ATTACHMENT0;
  }
  if (t.drawBuffers) switch (r) {
    case "color1":
    case 1:
      return t.drawBuffers.COLOR_ATTACHMENT1;
    case "color2":
    case 2:
      return t.drawBuffers.COLOR_ATTACHMENT2;
    case "color3":
    case 3:
      return t.drawBuffers.COLOR_ATTACHMENT3;
    case "color4":
    case 4:
      return t.drawBuffers.COLOR_ATTACHMENT4;
    case "color5":
    case 5:
      return t.drawBuffers.COLOR_ATTACHMENT5;
    case "color6":
    case 6:
      return t.drawBuffers.COLOR_ATTACHMENT6;
    case "color7":
    case 7:
      return t.drawBuffers.COLOR_ATTACHMENT7;
  }
  throw new Error("unknown texture attachment");
}
function p9(e) {
  return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement;
}
function h9(e, t, r) {
  return t === r.TEXTURE_3D;
}
function v9(e) {
  var t = e.createTexture();
  if (t === null) throw new Error("Could not create WebGL texture");
  return t;
}
function u6(e, t, r, n, a, i) {
  var o = lF(), s = v9(e);
  if (r.endsWith("float32") && a !== "float" || r.endsWith("float16") && a !== "fp16" || r.endsWith("uint8") && a !== "ubyte" || r.endsWith("int32") && a !== "int" || r.endsWith("depth") && a !== "ushort" && a !== "float") throw new Error("texture kind '".concat(r, "' and type '").concat(a, "' are incompatible"));
  var u = function(b, x) {
    switch (x) {
      case "image-uint8":
      case "image-float32":
      case "image-float16":
      case "image-depth":
        return b.TEXTURE_2D;
    }
    if (lr(b)) switch (x) {
      case "image-int32":
        return b.TEXTURE_2D;
      case "volume-uint8":
      case "volume-float32":
      case "volume-float16":
        return b.TEXTURE_3D;
    }
    throw new Error("unknown texture kind '".concat(x, "'"));
  }(e, r), c = m9(e, i), l = f9(e, n, a), d = function(b, x, A) {
    if (lr(b)) switch (x) {
      case "alpha":
        switch (A) {
          case "ubyte":
            return b.ALPHA;
          case "float":
            return b.R32F;
          case "fp16":
            return b.R16F;
          case "int":
            return b.R32I;
        }
      case "rgb":
        switch (A) {
          case "ubyte":
            return b.RGB;
          case "float":
            return b.RGB32F;
          case "fp16":
            return b.RGB16F;
          case "int":
            return b.RGB32I;
        }
      case "rgba":
        switch (A) {
          case "ubyte":
            return b.RGBA;
          case "float":
            return b.RGBA32F;
          case "fp16":
            return b.RGBA16F;
          case "int":
            return b.RGBA32I;
        }
      case "depth":
        switch (A) {
          case "ushort":
            return b.DEPTH_COMPONENT16;
          case "float":
            return b.DEPTH_COMPONENT32F;
        }
    }
    return f9(b, x, A);
  }(e, n, a), f = function(b, x, A) {
    switch (A) {
      case "ubyte":
        return b.UNSIGNED_BYTE;
      case "ushort":
        return b.UNSIGNED_SHORT;
      case "float":
        return b.FLOAT;
      case "fp16":
        if (x.textureHalfFloat) return x.textureHalfFloat.HALF_FLOAT;
        throw new Error('extension "texture_half_float" unavailable');
      case "int":
        if (lr(b)) return b.INT;
        throw new Error('texture type "int" requires webgl2');
    }
  }(e, t, a);
  function m() {
    e.bindTexture(u, s), e.texParameteri(u, e.TEXTURE_MAG_FILTER, c), e.texParameteri(u, e.TEXTURE_MIN_FILTER, c), e.texParameteri(u, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(u, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.bindTexture(u, null);
  }
  m();
  var h, p = 0, g = 0, v = 0, y = !1;
  function _(b, x, A) {
    if (b === 0 || x === 0 || lr(e) && u === e.TEXTURE_3D && A === 0) throw new Error("empty textures are not allowed");
    if (p !== b || g !== x || v !== (A || 0)) if (p = b, g = x, v = A || 0, e.bindTexture(u, s), u === e.TEXTURE_2D) e.texImage2D(u, 0, d, p, g, 0, l, f, null);
    else {
      if (!lr(e) || u !== e.TEXTURE_3D || v === void 0) throw new Error("unknown texture target");
      e.texImage3D(u, 0, d, p, g, v, 0, l, f, null);
    }
  }
  function S(b, x) {
    if (x === void 0 && (x = !1), b.width === 0 || b.height === 0 || !p9(b) && lr(e) && h9(0, u, e) && b.depth === 0) throw new Error("empty textures are not allowed");
    if (e.bindTexture(u, s), e.pixelStorei(e.UNPACK_ALIGNMENT, 1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.NONE), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), p9(b)) p = b.width, g = b.height, e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.bindTexture(e.TEXTURE_2D, s), e.texImage2D(e.TEXTURE_2D, 0, d, l, f, b);
    else if (function(w, C, M) {
      return C === M.TEXTURE_2D;
    }(0, u, e)) {
      var A = b.filter ? m9(e, b.filter) : c;
      e.texParameteri(u, e.TEXTURE_MAG_FILTER, A), e.texParameteri(u, e.TEXTURE_MIN_FILTER, A), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !!b.flipY), x ? e.texSubImage2D(u, 0, 0, 0, b.width, b.height, l, f, b.array) : (p = b.width, g = b.height, e.texImage2D(u, 0, d, p, g, 0, l, f, b.array));
    } else {
      if (!lr(e) || !h9(0, u, e)) throw new Error("unknown texture target");
      e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), x ? e.texSubImage3D(u, 0, 0, 0, 0, b.width, b.height, b.depth, l, f, b.array) : (p = b.width, g = b.height, v = b.depth, e.texImage3D(u, 0, d, p, g, v, 0, l, f, b.array));
    }
    e.bindTexture(u, null), h = b;
  }
  return _(1, 1, lr(e) && u === e.TEXTURE_3D ? 1 : 0), { id: o, target: u, format: l, internalFormat: d, type: f, filter: c, getWidth: function() {
    return p;
  }, getHeight: function() {
    return g;
  }, getDepth: function() {
    return v;
  }, getByteCount: function() {
    return function(b, x, A, w, C) {
      var M = function(T) {
        switch (T) {
          case "alpha":
            return 1;
          case "rgb":
            return 3;
          case "rgba":
          case "depth":
            return 4;
        }
      }(b) * function(T) {
        switch (T) {
          case "ubyte":
            return 1;
          case "ushort":
          case "fp16":
            return 2;
          case "float":
          case "int":
            return 4;
        }
      }(x);
      return M * A * w * (C || 1);
    }(n, a, p, g, v);
  }, define: _, load: S, bind: function(b) {
    e.activeTexture(e.TEXTURE0 + b), e.bindTexture(u, s);
  }, unbind: function(b) {
    e.activeTexture(e.TEXTURE0 + b), e.bindTexture(u, null);
  }, attachFramebuffer: function(b, x, A) {
    if (b.bind(), u === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, Zv(e, t, x), e.TEXTURE_2D, s, 0);
    else {
      if (!lr(e) || u !== e.TEXTURE_3D) throw new Error("unknown/unsupported texture target");
      if (A === void 0) throw new Error("need `layer` to attach 3D texture");
      e.framebufferTextureLayer(e.FRAMEBUFFER, Zv(e, t, x), s, 0, A);
    }
  }, detachFramebuffer: function(b, x) {
    if (b.bind(), u === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, Zv(e, t, x), e.TEXTURE_2D, null, 0);
    else {
      if (!lr(e) || u !== e.TEXTURE_3D) throw new Error("unknown texture target");
      e.framebufferTextureLayer(e.FRAMEBUFFER, Zv(e, t, x), null, 0, 0);
    }
  }, reset: function() {
    s = v9(e), m();
    var b = [p, g, v];
    p = 0, g = 0, v = 0, _(b[0], b[1], b[2]), h && S(h);
  }, destroy: function() {
    y || (e.deleteTexture(s), y = !0);
  } };
}
function g9(e, t, r) {
  var n = new Image();
  n.onload = function() {
    r.load(n), U.update(t, r);
  }, n.src = e;
}
function ko(e) {
  var t, r = (t = e == null ? void 0 : e.TEXTURE_2D) !== null && t !== void 0 ? t : 3553;
  return { id: lF(), target: r, format: 0, internalFormat: 0, type: 0, filter: 0, getWidth: function() {
    return 0;
  }, getHeight: function() {
    return 0;
  }, getDepth: function() {
    return 0;
  }, getByteCount: function() {
    return 0;
  }, define: function() {
  }, load: function() {
  }, bind: function(n) {
    e && (e.activeTexture(e.TEXTURE0 + n), e.bindTexture(r, null));
  }, unbind: function(n) {
    e && (e.activeTexture(e.TEXTURE0 + n), e.bindTexture(r, null));
  }, attachFramebuffer: function() {
  }, detachFramebuffer: function() {
  }, reset: function() {
  }, destroy: function() {
  } };
}
var pJ = $i();
function y9(e) {
  var t = e.vertexArrayObject;
  if (!t) throw new Error("VertexArrayObject not supported");
  var r = t.createVertexArray();
  if (!r) throw new Error("Could not create WebGL vertex array");
  return r;
}
function b9(e) {
  var t = e.vertexArrayObject;
  if (t === null) throw new Error("VertexArrayObject not supported");
  return t;
}
function x9(e) {
  return k(k({}, e.value), { destroy: function() {
    e.free();
  } });
}
function hJ(e, t, r, n) {
  var a = { attribute: /* @__PURE__ */ new Set(), elements: /* @__PURE__ */ new Set(), framebuffer: /* @__PURE__ */ new Set(), program: /* @__PURE__ */ new Set(), renderbuffer: /* @__PURE__ */ new Set(), shader: /* @__PURE__ */ new Set(), texture: /* @__PURE__ */ new Set(), vertexArray: /* @__PURE__ */ new Set() };
  function i(c, l) {
    return a[c].add(l), r.resourceCounts[c] += 1, k(k({}, l), { destroy: function() {
      l.destroy(), a[c].delete(l), r.resourceCounts[c] -= 1;
    } });
  }
  var o = l9(function(c) {
    return JSON.stringify(c);
  }, function(c) {
    return i("shader", uJ(e, c));
  }, function(c) {
    c.destroy();
  });
  function s(c, l) {
    return x9(o.get({ type: c, source: l }));
  }
  var u = l9(function(c) {
    var l, d = [c.shaderCode.id], f = ((l = c.defineValues.dRenderVariant) === null || l === void 0 ? void 0 : l.ref.value) || "";
    return Object.keys(c.defineValues).forEach(function(m) {
      var h, p;
      !((p = (h = c.shaderCode).ignoreDefine) === null || p === void 0) && p.call(h, m, f, c.defineValues) || d.push(Y5(m), function(g) {
        return typeof g == "boolean" ? g ? 1 : 0 : typeof g == "number" ? 1e4 * g : Y5(g);
      }(c.defineValues[m].ref.value));
    }), Zi(d).toString();
  }, function(c) {
    return i("program", oJ(e, t, n, s, c));
  }, function(c) {
    c.destroy();
  });
  return { attribute: function(c, l, d, f) {
    return i("attribute", function(m, h, p, g, v, y, _) {
      _ === void 0 && (_ = "dynamic");
      var S = p.instancedArrays, b = o9(m, g, _, "attribute"), x = b._bufferType, A = b._dataType, w = b._bpe;
      return k(k({}, b), { bind: function(C) {
        if (m.bindBuffer(x, b.getBuffer()), v === 16) for (var M = 0; M < 4; ++M) h.enableVertexAttrib(C + M), m.vertexAttribPointer(C + M, 4, A, !1, 16 * w, 4 * M * w), S.vertexAttribDivisor(C + M, y);
        else h.enableVertexAttrib(C), m.vertexAttribPointer(C, v, A, !1, 0, 0), S.vertexAttribDivisor(C, y);
      } });
    }(e, t, n, c, l, d, f));
  }, elements: function(c, l) {
    return i("elements", function(d, f, m) {
      m === void 0 && (m = "static");
      var h = o9(d, f, m, "elements");
      return k(k({}, h), { bind: function() {
        d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, h.getBuffer());
      } });
    }(e, c, l));
  }, framebuffer: function() {
    return i("framebuffer", function(c) {
      var l = u9(c), d = !1;
      return { id: cF(), bind: function() {
        return c.bindFramebuffer(c.FRAMEBUFFER, l);
      }, reset: function() {
        l = u9(c);
      }, destroy: function() {
        d || (c.deleteFramebuffer(l), d = !0);
      } };
    }(e));
  }, program: function(c, l, d) {
    return x9(u.get({ defineValues: c, shaderCode: l, schema: d }));
  }, renderbuffer: function(c, l, d, f) {
    return i("renderbuffer", mJ(e, c, l, d, f));
  }, shader: s, texture: function(c, l, d, f) {
    return i("texture", u6(e, n, c, l, d, f));
  }, vertexArray: function(c, l, d) {
    return i("vertexArray", function(f, m, h, p, g) {
      var v = pJ(), y = y9(m), _ = b9(m);
      function S() {
        _.bindVertexArray(y), g && g.bind(), h.bindAttributes(p), _.bindVertexArray(null);
      }
      S();
      var b = !1;
      return { id: v, bind: function() {
        _.bindVertexArray(y);
      }, update: S, reset: function() {
        y = y9(m), _ = b9(m), S();
      }, destroy: function() {
        b || (g && (_.bindVertexArray(y), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, null)), _.deleteVertexArray(y), b = !0);
      } };
    }(e, n, c, l, d));
  }, getByteCounts: function() {
    var c = 0;
    a.texture.forEach(function(f) {
      c += f.getByteCount();
    });
    var l = 0;
    a.attribute.forEach(function(f) {
      l += 4 * f.length;
    });
    var d = 0;
    return a.elements.forEach(function(f) {
      d += 4 * f.length;
    }), { texture: c, attribute: l, elements: d };
  }, reset: function() {
    a.attribute.forEach(function(c) {
      return c.reset();
    }), a.elements.forEach(function(c) {
      return c.reset();
    }), a.framebuffer.forEach(function(c) {
      return c.reset();
    }), a.renderbuffer.forEach(function(c) {
      return c.reset();
    }), a.shader.forEach(function(c) {
      return c.reset();
    }), a.program.forEach(function(c) {
      return c.reset();
    }), a.vertexArray.forEach(function(c) {
      return c.reset();
    }), a.texture.forEach(function(c) {
      return c.reset();
    });
  }, destroy: function() {
    a.attribute.forEach(function(c) {
      return c.destroy();
    }), a.elements.forEach(function(c) {
      return c.destroy();
    }), a.framebuffer.forEach(function(c) {
      return c.destroy();
    }), a.renderbuffer.forEach(function(c) {
      return c.destroy();
    }), a.shader.forEach(function(c) {
      return c.destroy();
    }), a.program.forEach(function(c) {
      return c.destroy();
    }), a.vertexArray.forEach(function(c) {
      return c.destroy();
    }), a.texture.forEach(function(c) {
      return c.destroy();
    }), o.clear(), u.clear();
  } };
}
var dF = $i();
function fF(e, t) {
  switch (t) {
    case e.NO_ERROR:
      return "no error";
    case e.INVALID_ENUM:
      return "invalid enum";
    case e.INVALID_VALUE:
      return "invalid value";
    case e.INVALID_OPERATION:
      return "invalid operation";
    case e.INVALID_FRAMEBUFFER_OPERATION:
      return "invalid framebuffer operation";
    case e.OUT_OF_MEMORY:
      return "out of memory";
    case e.CONTEXT_LOST_WEBGL:
      return "context lost";
  }
  return "unknown error";
}
function mF(e) {
  var t = e.getError();
  if (t !== e.NO_ERROR) throw new Error("WebGL error: '".concat(fF(e, t), "'"));
}
function Qv(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null);
}
var pF = new Uint8Array(4);
function hF(e, t, r) {
  e.getSyncParameter(t, e.SYNC_STATUS) === e.SIGNALED ? (e.deleteSync(t), r()) : h8.setImmediate(hF, e, t, r);
}
function _9(e, t) {
  var r = e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE, 0);
  r ? h8.setImmediate(hF, e, r, t) : (console.warn("Could not create a WebGLSync object"), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, pF), t());
}
var Z2, S9, A9 = !1;
function w9(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, pF);
}
function w4(e, t, r, n, a, i) {
  if (zr && g8(e), i instanceof Uint8Array) e.readPixels(t, r, n, a, e.RGBA, e.UNSIGNED_BYTE, i);
  else if (i instanceof Float32Array) e.readPixels(t, r, n, a, e.RGBA, e.FLOAT, i);
  else {
    if (!(i instanceof Int32Array && lr(e))) throw new Error("unsupported readPixels buffer type");
    e.readPixels(t, r, n, a, e.RGBA_INTEGER, e.INT, i);
  }
  zr && mF(e);
}
function vJ(e, t) {
  var r = this;
  t === void 0 && (t = {});
  var n = c9(e), a = function(v) {
    var y = {}, _ = v.getParameter(v.FRONT_FACE), S = v.getParameter(v.CULL_FACE_MODE), b = v.getParameter(v.DEPTH_WRITEMASK), x = v.getParameter(v.COLOR_WRITEMASK), A = v.getParameter(v.COLOR_CLEAR_VALUE), w = v.getParameter(v.BLEND_SRC_RGB), C = v.getParameter(v.BLEND_DST_RGB), M = v.getParameter(v.BLEND_SRC_ALPHA), T = v.getParameter(v.BLEND_DST_ALPHA), N = v.getParameter(v.BLEND_EQUATION_RGB), I = v.getParameter(v.BLEND_EQUATION_ALPHA), P = v.getParameter(v.MAX_VERTEX_ATTRIBS), O = [], F = function() {
      for (var R = 0; R < P; ++R) O[R] = 0;
    };
    return F(), { currentProgramId: -1, currentMaterialId: -1, currentRenderItemId: -1, enable: function(R) {
      y[R] !== !0 && (v.enable(R), y[R] = !0);
    }, disable: function(R) {
      y[R] !== !1 && (v.disable(R), y[R] = !1);
    }, frontFace: function(R) {
      R !== _ && (v.frontFace(R), _ = R);
    }, cullFace: function(R) {
      R !== S && (v.cullFace(R), S = R);
    }, depthMask: function(R) {
      R !== b && (v.depthMask(R), b = R);
    }, colorMask: function(R, G, L, q) {
      R === x[0] && G === x[1] && L === x[2] && q === x[3] || (v.colorMask(R, G, L, q), x[0] = R, x[1] = G, x[2] = L, x[3] = q);
    }, clearColor: function(R, G, L, q) {
      R === A[0] && G === A[1] && L === A[2] && q === A[3] || (v.clearColor(R, G, L, q), A[0] = R, A[1] = G, A[2] = L, A[3] = q);
    }, blendFunc: function(R, G) {
      R === w && G === C && R === M && G === T || (v.blendFunc(R, G), w = R, C = G, M = R, T = G);
    }, blendFuncSeparate: function(R, G, L, q) {
      R === w && G === C && L === M && q === T || (v.blendFuncSeparate(R, G, L, q), w = R, C = G, M = L, T = q);
    }, blendEquation: function(R) {
      R === N && R === I || (v.blendEquation(R), N = R, I = R);
    }, blendEquationSeparate: function(R, G) {
      R === N && G === I || (v.blendEquationSeparate(R, G), N = R, I = G);
    }, enableVertexAttrib: function(R) {
      v.enableVertexAttribArray(R), O[R] = 1;
    }, clearVertexAttribsState: F, disableUnusedVertexAttribs: function() {
      for (var R = 0; R < P; ++R) O[R] === 0 && v.disableVertexAttribArray(R);
    }, reset: function() {
      y = {}, _ = v.getParameter(v.FRONT_FACE), S = v.getParameter(v.CULL_FACE_MODE), b = v.getParameter(v.DEPTH_WRITEMASK), x = v.getParameter(v.COLOR_WRITEMASK), A = v.getParameter(v.COLOR_CLEAR_VALUE), w = v.getParameter(v.BLEND_SRC_RGB), C = v.getParameter(v.BLEND_DST_RGB), M = v.getParameter(v.BLEND_SRC_ALPHA), T = v.getParameter(v.BLEND_DST_ALPHA), N = v.getParameter(v.BLEND_EQUATION_RGB), I = v.getParameter(v.BLEND_EQUATION_ALPHA), P = v.getParameter(v.MAX_VERTEX_ATTRIBS), O.length = 0;
      for (var R = 0; R < P; ++R) O[R] = 0;
    } };
  }(e), i = { resourceCounts: { attribute: 0, elements: 0, framebuffer: 0, program: 0, renderbuffer: 0, shader: 0, texture: 0, vertexArray: 0 }, drawCount: 0, instanceCount: 0, instancedDrawCount: 0 }, o = hJ(e, a, i, n), s = { maxTextureSize: e.getParameter(e.MAX_TEXTURE_SIZE), max3dTextureSize: lr(e) ? e.getParameter(e.MAX_3D_TEXTURE_SIZE) : 0, maxRenderbufferSize: e.getParameter(e.MAX_RENDERBUFFER_SIZE), maxDrawBuffers: n.drawBuffers ? e.getParameter(n.drawBuffers.MAX_DRAW_BUFFERS) : 0, maxTextureImageUnits: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS) };
  if (s.maxVertexTextureImageUnits < 8) throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');
  var u, c = !1, l = new xd(0);
  if (lr(e)) {
    var d = e.createBuffer(), f = void 0, m = void 0, h = !1, p = function() {
      e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.getBufferSubData(e.PIXEL_PACK_BUFFER, 0, f), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), h = !1, m(), m = void 0, f = void 0;
    };
    u = function(v, y, _, S, b) {
      return new Promise(function(x, A) {
        h ? A("Can not call multiple readPixelsAsync at the same time") : (h = !0, e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.bufferData(e.PIXEL_PACK_BUFFER, _ * S * 4, e.STREAM_READ), e.readPixels(v, y, _, S, e.RGBA, e.UNSIGNED_BYTE, 0), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), m = x, f = b, _9(e, p));
      });
    };
  } else u = function(v, y, _, S, b) {
    return Be(r, 0, void 0, function() {
      return Te(this, function(x) {
        return w4(e, v, y, _, S, b), [2];
      });
    });
  };
  var g = /* @__PURE__ */ new Set();
  return { gl: e, isWebGL2: lr(e), get pixelRatio() {
    return (typeof window < "u" && window.devicePixelRatio || 1) * (t.pixelScale || 1);
  }, extensions: n, state: a, stats: i, resources: o, get maxTextureSize() {
    return s.maxTextureSize;
  }, get max3dTextureSize() {
    return s.max3dTextureSize;
  }, get maxRenderbufferSize() {
    return s.maxRenderbufferSize;
  }, get maxDrawBuffers() {
    return s.maxDrawBuffers;
  }, get maxTextureImageUnits() {
    return s.maxTextureImageUnits;
  }, namedComputeRenderables: /* @__PURE__ */ Object.create(null), namedFramebuffers: /* @__PURE__ */ Object.create(null), namedTextures: /* @__PURE__ */ Object.create(null), get isContextLost() {
    return c || e.isContextLost();
  }, contextRestored: l, setContextLost: function() {
    c = !0;
  }, handleContextRestored: function(v) {
    Object.assign(n, c9(e)), a.reset(), a.currentMaterialId = -1, a.currentProgramId = -1, a.currentRenderItemId = -1, o.reset(), g.forEach(function(y) {
      return y.reset();
    }), v == null || v(), c = !1, l.next(ga());
  }, createRenderTarget: function(v, y, _, S, b) {
    var x = function(A, w, C, M, T, N, I) {
      T === void 0 && (T = !0), N === void 0 && (N = "uint8"), I === void 0 && (I = "nearest");
      var P = w.framebuffer(), O = N === "fp16" ? w.texture("image-float16", "rgba", "fp16", I) : N === "float32" ? w.texture("image-float32", "rgba", "float", I) : w.texture("image-uint8", "rgba", "ubyte", I), F = T ? lr(A) ? w.renderbuffer("depth32f", "depth", C, M) : w.renderbuffer("depth16", "depth", C, M) : null;
      function R() {
        O.define(C, M), O.attachFramebuffer(P, "color0"), F && F.attachFramebuffer(P);
      }
      R();
      var G = !1;
      return { id: dF(), texture: O, framebuffer: P, getWidth: function() {
        return C;
      }, getHeight: function() {
        return M;
      }, bind: function() {
        P.bind();
      }, setSize: function(L, q) {
        C === L && M === q || (C = L, M = q, O.define(C, M), F && F.setSize(C, M));
      }, reset: function() {
        R();
      }, destroy: function() {
        G || (O.destroy(), P.destroy(), F && F.destroy(), G = !0);
      } };
    }(e, o, v, y, _, S, b);
    return g.add(x), k(k({}, x), { destroy: function() {
      x.destroy(), g.delete(x);
    } });
  }, unbindFramebuffer: function() {
    return Qv(e);
  }, readPixels: function(v, y, _, S, b) {
    w4(e, v, y, _, S, b);
  }, readPixelsAsync: u, waitForGpuCommandsComplete: function() {
    return function(v) {
      return new Promise(function(y) {
        lr(v) ? _9(v, y) : (A9 || (console.info("Sync object not supported in WebGL"), A9 = !0), w9(v), y());
      });
    }(e);
  }, waitForGpuCommandsCompleteSync: function() {
    return w9(e);
  }, getDrawingBufferPixelData: function() {
    return function(v) {
      var y = v.drawingBufferWidth, _ = v.drawingBufferHeight, S = new Uint8Array(y * _ * 4);
      return Qv(v), v.viewport(0, 0, y, _), w4(v, 0, 0, y, _, S), jf.flipY(jf.create(S, y, _));
    }(e);
  }, clear: function(v, y, _, S) {
    Qv(e), a.enable(e.SCISSOR_TEST), a.depthMask(!0), a.colorMask(!0, !0, !0, !0), a.clearColor(v, y, _, S), e.viewport(0, 0, e.drawingBufferWidth, e.drawingBufferHeight), e.scissor(0, 0, e.drawingBufferWidth, e.drawingBufferHeight), e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
  }, destroy: function(v) {
    var y, _;
    o.destroy(), function(S) {
      for (var b = S.getParameter(S.MAX_TEXTURE_IMAGE_UNITS), x = 0; x < b; ++x) S.activeTexture(S.TEXTURE0 + x), S.bindTexture(S.TEXTURE_2D, null), S.bindTexture(S.TEXTURE_CUBE_MAP, null), lr(S) && (S.bindTexture(S.TEXTURE_2D_ARRAY, null), S.bindTexture(S.TEXTURE_3D, null));
      var A = S.createBuffer();
      S.bindBuffer(S.ARRAY_BUFFER, A);
      var w = S.getParameter(S.MAX_VERTEX_ATTRIBS);
      for (x = 0; x < w; ++x) S.vertexAttribPointer(x, 1, S.FLOAT, !1, 0, 0);
      S.bindBuffer(S.ARRAY_BUFFER, null), S.bindBuffer(S.ELEMENT_ARRAY_BUFFER, null), S.bindRenderbuffer(S.RENDERBUFFER, null), Qv(S);
    }(e), v != null && v.doNotForceWebGLContextLoss || ((y = e.getExtension("WEBGL_lose_context")) === null || y === void 0 || y.loseContext(), (_ = e.getExtension("STACKGL_destroy_context")) === null || _ === void 0 || _.destroy());
  } };
}
function C4(e, t) {
  return { value: e, unit: t };
}
function Tu(e) {
  return e;
}
(function(e) {
  e.create = function(o, s, u) {
    var c = !!o[0].cell, l = !!o[0].velocities, d = !!o[0].forces;
    return { id: Fa.create22(), frames: o, hasCell: c, hasVelocities: l, hasForces: d, deltaTime: s, timeOffset: u };
  }, e.getAtomicConformation = function(o, s, u) {
    var c = o.x, l = o.y, d = o.z;
    return o.xyzOrdering.frozen ? u ? o.xyzOrdering.isIdentity ? (c = a(c, u), l = a(l, u), d = a(d, u)) : ho(o.xyzOrdering.index, u) || (c = n(c, o.xyzOrdering.index, u), l = n(l, o.xyzOrdering.index, u), d = n(d, o.xyzOrdering.index, u)) : o.xyzOrdering.isIdentity || (c = i(c, o.xyzOrdering.index), l = i(l, o.xyzOrdering.index), d = i(d, o.xyzOrdering.index)) : u && (o.xyzOrdering.isIdentity ? (o.xyzOrdering.isIdentity = !1, o.xyzOrdering.index = u, r(c, u), r(l, u), r(d, u)) : ho(o.xyzOrdering.index, u) || (c = n(c, o.xyzOrdering.index, u), l = n(l, o.xyzOrdering.index, u), d = n(d, o.xyzOrdering.index, u))), o.xyzOrdering.frozen = !0, { id: Fa.create22(), atomId: s, occupancy: pe.ofConst(1, o.elementCount, pe.Schema.int), B_iso_or_equiv: pe.ofConst(0, o.elementCount, pe.Schema.float), xyzDefined: !0, x: c, y: l, z: d };
  };
  var t = [0.123];
  function r(o, s) {
    for (var u = t, c = 0, l = o.length; c < l; c++) u[c] = o[s[c]];
    for (c = 0, l = o.length; c < l; c++) o[c] = u[c];
  }
  function n(o, s, u) {
    for (var c = new Float32Array(o.length), l = 0, d = o.length; l < d; l++) c[l] = o[s[u[l]]];
    return c;
  }
  function a(o, s) {
    for (var u = new Float32Array(o.length), c = 0, l = o.length; c < l; c++) u[c] = o[s[c]];
    return u;
  }
  function i(o, s) {
    for (var u = new Float32Array(o.length), c = 0, l = o.length; c < l; c++) u[s[c]] = o[c];
    return u;
  }
})(Z2 || (Z2 = {})), function(e) {
  e.create = function(t, r, n, a) {
    return { id: Fa.create22(), label: t, basic: r, sourceData: a, bonds: n };
  };
}(S9 || (S9 = {})), function(e) {
  e.getUUID = function(t) {
    return t.__key || (t.__key = Fa.create22()), t.__key;
  };
}(Tu || (Tu = {}));
var Ho, f1 = function() {
  function e() {
    this._list = [], this._set = /* @__PURE__ */ new Set(), this._refs = /* @__PURE__ */ new Map(), this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "all", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    this._set.has(t) || (this._list.push(t), this._set.add(t));
  }, e.prototype.reference = function(t, r) {
    var n = this._refs.get(t) || 0;
    n += r ? 1 : -1, this._refs.set(t, Math.max(n, 0));
  }, e.prototype.hasReference = function(t) {
    return (this._refs.get(t) || 0) > 0;
  }, e.prototype.has = function(t) {
    return this._set.has(t);
  }, e.prototype.assets = function(t, r) {
    var n = this._assets.get(t);
    if (n) for (var a = 0, i = n; a < i.length; a++)
      i[a].dispose();
    r ? this._assets.set(t, r) : this._assets.delete(t);
  }, e.prototype.dispose = function() {
    this._assets.forEach(function(t) {
      for (var r = 0, n = t; r < n.length; r++)
        n[r].dispose();
    });
  }, e;
}();
function vF(e, t, r, n, a) {
  for (var i = e.b, o = e.offset, s = [], u = 0, c = t.length; u < c; ++u) for (var l = t[u], d = o[l], f = o[l + 1]; d < f; ++d) {
    var m = i[d];
    if (!a.has(m)) {
      if ($e.has(r, m)) return !0;
      a.add(m), s[s.length] = m;
    }
  }
  return n > 1 && vF(e, s, r, n - 1, a);
}
(function(e) {
  e.areEqual = function(s, u) {
    if (s === u) return !0;
    if (s.vertexCount !== u.vertexCount || s.edgeCount !== u.edgeCount) return !1;
    for (var c = s.a, l = s.b, d = s.offset, f = u.a, m = u.b, h = u.offset, p = 0, g = s.a.length; p < g; p++) if (c[p] !== f[p]) return !1;
    for (p = 0, g = s.b.length; p < g; p++) if (l[p] !== m[p]) return !1;
    for (p = 0, g = s.offset.length; p < g; p++) if (d[p] !== h[p]) return !1;
    for (var v = 0, y = Object.keys(s.edgeProps); v < y.length; v++) {
      var _ = y[v], S = s.edgeProps[_], b = u.edgeProps[_];
      if (!b) return !1;
      for (p = 0, g = S.length; p < g; p++) if (S[p] !== b[p]) return !1;
    }
    return !0;
  };
  var t = function() {
    function s(u, c, l, d, f, m) {
      this.offset = u, this.a = c, this.b = l, this.edgeCount = d, this.props = m, this.vertexCount = u.length - 1, this.edgeProps = f || {};
    }
    return s.prototype.getEdgeIndex = function(u, c) {
      var l, d;
      u < c ? (l = u, d = c) : (l = c, d = u);
      for (var f = this.offset[l], m = this.offset[l + 1]; f < m; f++) if (this.b[f] === d) return f;
      return -1;
    }, s.prototype.getDirectedEdgeIndex = function(u, c) {
      for (var l = this.offset[u], d = this.offset[u + 1]; l < d; l++) if (this.b[l] === c) return l;
      return -1;
    }, s.prototype.getVertexEdgeCount = function(u) {
      return this.offset[u + 1] - this.offset[u];
    }, s;
  }();
  function r(s, u, c, l, d, f) {
    return new t(s, u, c, l, d, f);
  }
  e.create = r;
  var n = function() {
    function s(u, c, l) {
      this.vertexCount = u, this.xs = c, this.ys = l, this.current = 0, this.curA = 0, this.curB = 0, this.edgeCount = c.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      for (var d = new Int32Array(this.vertexCount), f = 0, m = this.xs.length; f < m; f++) d[this.xs[f]]++;
      for (f = 0, m = this.ys.length; f < m; f++) d[this.ys[f]]++;
      var h = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = h, h += d[f];
      this.offsets[this.vertexCount] = h, this.slotCount = h, this.a = new Int32Array(h), this.b = new Int32Array(h);
    }
    return s.prototype.createGraph = function(u, c) {
      return r(this.offsets, this.a, this.b, this.edgeCount, u, c);
    }, s.prototype.addNextEdge = function() {
      var u = this.xs[this.current], c = this.ys[this.current], l = this.offsets[u] + this.bucketFill[u], d = this.offsets[c] + this.bucketFill[c];
      this.a[l] = u, this.b[l] = c, this.bucketFill[u]++, this.a[d] = c, this.b[d] = u, this.bucketFill[c]++, this.current++, this.curA = l, this.curB = d;
    }, s.prototype.addAllEdges = function() {
      for (var u = 0; u < this.edgeCount; u++) this.addNextEdge();
    }, s.prototype.assignProperty = function(u, c) {
      u[this.curA] = c, u[this.curB] = c;
    }, s;
  }();
  e.EdgeBuilder = n;
  var a = function() {
    function s(u, c, l) {
      this.vertexCount = u, this.xs = c, this.ys = l, this.current = 0, this.curA = 0, this.edgeCount = c.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      for (var d = new Int32Array(this.vertexCount), f = 0, m = this.xs.length; f < m; f++) d[this.xs[f]]++;
      var h = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = h, h += d[f];
      this.offsets[this.vertexCount] = h, this.slotCount = h, this.a = new Int32Array(h), this.b = new Int32Array(h);
    }
    return s.prototype.createGraph = function(u) {
      return r(this.offsets, this.a, this.b, this.edgeCount, u);
    }, s.prototype.addNextEdge = function() {
      var u = this.xs[this.current], c = this.ys[this.current], l = this.offsets[u] + this.bucketFill[u];
      this.a[l] = u, this.b[l] = c, this.bucketFill[u]++, this.current++, this.curA = l;
    }, s.prototype.addAllEdges = function() {
      for (var u = 0; u < this.edgeCount; u++) this.addNextEdge();
    }, s.prototype.assignProperty = function(u, c) {
      u[this.curA] = c;
    }, s;
  }();
  e.DirectedEdgeBuilder = a;
  var i = function() {
    function s(u) {
      this.vertexCount = u, this.xs = [], this.ys = [], this.included = /* @__PURE__ */ new Set();
    }
    return s.prototype.addEdge = function(u, c) {
      var l = u, d = c;
      u > c && (l = c, d = u);
      var f = eu(l, d);
      return !this.included.has(f) && (this.included.add(f), this.xs[this.xs.length] = l, this.ys[this.ys.length] = d, !0);
    }, s.prototype.getGraph = function() {
      return o(this.vertexCount, this.xs, this.ys);
    }, s.prototype.getEdgeBuiler = function() {
      return new n(this.vertexCount, this.xs, this.ys);
    }, s;
  }();
  function o(s, u, c) {
    var l = new e.EdgeBuilder(s, u, c);
    return l.addAllEdges(), l.createGraph({});
  }
  e.UniqueEdgeBuilder = i, e.fromVertexPairs = o, e.induceByVertices = function(s, u) {
    for (var c = s.b, l = s.offset, d = s.vertexCount, f = s.edgeProps, m = new Int32Array(d), h = 0, p = u.length; h < p; h++) m[u[h]] = h + 1;
    var g = 0;
    for (h = 0; h < d; h++) if (m[h] !== 0) for (var v = l[h], y = l[h + 1]; v < y; v++) c[v] > h && m[c[v]] !== 0 && g++;
    var _ = new Int32Array(u.length + 1), S = new Int32Array(2 * g), b = new Int32Array(2 * g), x = new Int32Array(2 * g), A = 0, w = 0;
    for (h = 0; h < d; h++) if (m[h] !== 0) {
      var C = m[h] - 1;
      for (v = l[h], y = l[h + 1]; v < y; v++) {
        var M = m[c[v]];
        M !== 0 && (b[A] = C, x[A] = M - 1, S[A] = v, A++);
      }
      _[++w] = A;
    }
    for (var T = {}, N = 0, I = Object.keys(f); N < I.length; N++) {
      var P = I[N];
      T[P] = WZ(f[P], S);
    }
    return r(_, b, x, g, T);
  }, e.connectedComponents = function(s) {
    var u = s.vertexCount;
    if (u === 0) return { componentCount: 0, componentIndex: new Int32Array(0) };
    if (s.edgeCount === 0) {
      for (var c = new Int32Array(u), l = 0, d = u; l < d; l++) c[l] = l;
      return { componentCount: u, componentIndex: c };
    }
    var f = new Int32Array(u);
    for (l = 0, d = u; l < d; l++) f[l] = -1;
    var m = 0;
    f[0] = m;
    var h = s.offset, p = s.b, g = [0], v = function(A) {
      return new JQ(A);
    }(u);
    for (v.remove(0); g.length > 0; ) {
      for (var y = g.pop(), _ = f[y], S = h[y], b = h[y + 1]; S < b; S++) {
        var x = p[S];
        v.has(x) && (v.remove(x), g.push(x), f[x] = _);
      }
      g.length === 0 && v.head >= 0 && (g.push(v.head), f[v.head] = ++m, v.remove(v.head));
    }
    return { componentCount: u, componentIndex: f };
  }, e.areVertexSetsConnected = function(s, u, c, l) {
    if ($e.areIntersecting(u, c)) return !0;
    if (l < 1) return !1;
    for (var d = /* @__PURE__ */ new Set(), f = 0, m = u.length; f < m; ++f) d.add(u[f]);
    return vF(s, u, c, l, d);
  };
})(Ho || (Ho = {}));
var ic, Ra, mt, Cp, gJ = function() {
  function e() {
    this.map = /* @__PURE__ */ new Map(), this.applicable = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, r, n) {
    this.map.set(t, r), n && this.applicable.set(t, n);
  }, e.prototype.remove = function(t) {
    this.map.delete(t), this.applicable.delete(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.isApplicable = function(t) {
    var r = this.applicable.get(t.sourceData.kind);
    return !r || r(t);
  }, e;
}();
function yJ(e, t, r, n) {
  for (var a = new Ho.EdgeBuilder(n, e, t), i = new Int32Array(a.slotCount), o = new Int8Array(a.slotCount), s = new Array(a.slotCount), u = new Array(a.slotCount), c = 0, l = a.edgeCount; c < l; c++) a.addNextEdge(), a.assignProperty(i, r.key ? r.key[c] : -1), a.assignProperty(o, r.order ? r.order[c] : 1), a.assignProperty(s, r.distance ? r.distance[c] : -1), a.assignProperty(u, r.flag ? r.flag[c] : 1);
  return a.createGraph({ key: i, order: o, distance: s, flag: u });
}
function tn(e) {
  return function(t) {
    return function(r, n) {
      var a = r.data, i = r.indices, o = r.count, s = n.valueType, u = s === "str" ? function(c) {
        return a.substring(i[2 * c], i[2 * c + 1]);
      } : s === "int" ? function(c) {
        return Bd(a, i[2 * c], i[2 * c + 1]) || 0;
      } : function(c) {
        return Hf(a, i[2 * c], i[2 * c + 1]) || 0;
      };
      return { schema: n, __array: void 0, isDefined: !0, rowCount: o, value: u, valueKind: function(c) {
        return 0;
      }, toArray: function(c) {
        return ci(o, u, c);
      }, areValuesEqual: gF(r) };
    }(e, t);
  };
}
function gF(e) {
  var t = e.data, r = e.indices;
  return function(n, a) {
    var i = r[2 * n], o = r[2 * a], s = r[2 * n + 1] - i;
    if (s !== r[2 * a + 1] - o) return !1;
    for (var u = 0; u < s; u++) if (t.charCodeAt(u + i) !== t.charCodeAt(u + o)) return !1;
    return !0;
  };
}
function bJ(e) {
  for (var t = e.count, r = e.indices, n = 0; n < t; ++n) if (r[2 * n] !== r[2 * n + 1]) return !1;
  return !0;
}
function yF(e, t) {
  return { name: t, blocks: e };
}
function y8(e, t, r, n) {
  return n === void 0 && (n = []), { categoryNames: e, header: r, categories: t, saveFrames: n, getField: function(a) {
    var i = a.split("."), o = i[0], s = i[1];
    return t[o].getField(s || "");
  } };
}
function Mi(e, t, r, n) {
  return { rowCount: t, name: e, fieldNames: nt([], r, !0), getField: function(a) {
    return n[a];
  } };
}
function Bf(e, t, r) {
  return function(n, a, i) {
    for (var o = /* @__PURE__ */ Object.create(null), s = 0, u = Object.keys(n); s < u.length; s++) {
      var c = u[s];
      o[c] = SJ(c, n[c], a, i);
    }
    return j5.ofTables(a.header, n, o);
  }(e, t, r);
}
function E4(e, t, r, n) {
  return { schema: e, __array: t.__array, isDefined: t.isDefined, rowCount: t.rowCount, value: r, valueKind: t.valueKind, areValuesEqual: t.areValuesEqual, toArray: n };
}
function xJ(e, t, r) {
  var n = e.space, a = t.fieldNames.includes("".concat(r, "[0]")) || t.fieldNames.includes("".concat(r, "[0][0]")) || t.fieldNames.includes("".concat(r, "[0][0][0]")), i = a ? 0 : 1, o = t.fieldNames.includes("".concat(r, "_1")) || t.fieldNames.includes("".concat(r, "_11")) || t.fieldNames.includes("".concat(r, "_111")) ? "underscore" : "brackets", s = function(l, d, f, m) {
    var h = f ? 0 : 1;
    switch (d) {
      case 1:
        return m === "brackets" ? function(p) {
          return "".concat(l, "[").concat(p + h, "]");
        } : function(p) {
          return "".concat(l, "_").concat(p + h);
        };
      case 2:
        return m === "brackets" ? function(p, g) {
          return "".concat(l, "[").concat(p + h, "][").concat(g + h, "]");
        } : function(p, g) {
          return "".concat(l, "_").concat(p + h).concat(g + h);
        };
      case 3:
        return m === "brackets" ? function(p, g, v) {
          return "".concat(l, "[").concat(p + h, "][").concat(g + h, "][").concat(v + h, "]");
        } : function(p, g, v) {
          return "".concat(l, "_").concat(p + h).concat(g + h).concat(v + h);
        };
      default:
        throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    }
  }(r, n.rank, a, o), u = t.getField(s(i, i, i)) || pe.Undefined(t.rowCount, e), c = function(l) {
    return function(d, f, m, h) {
      var p = f.create();
      if (f.rank === 1) for (var g = f.dimensions[0], v = 0; v < g; v++) {
        var y = d.getField(h(v));
        f.set(p, v, y ? y.float(m) : 0);
      }
      else if (f.rank === 2) {
        g = f.dimensions[0];
        var _ = f.dimensions[1];
        for (v = 0; v < g; v++) for (var S = 0; S < _; S++) y = d.getField(h(v, S)), f.set(p, v, S, y ? y.float(m) : 0);
      } else {
        if (f.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
        var b = f.dimensions[0], x = f.dimensions[1], A = f.dimensions[2];
        for (v = 0; v < b; v++) for (S = 0; S < x; S++) for (var w = 0; w < A; w++) y = d.getField(h(v, S, w)), f.set(p, v, S, w, y ? y.float(m) : 0);
      }
      return p;
    }(t, n, l, s);
  };
  return { schema: e, __array: void 0, isDefined: u.isDefined, rowCount: t.rowCount, value: c, valueKind: u.valueKind, areValuesEqual: function(l, d) {
    return Wn.areEqualExact(c(l), c(d));
  }, toArray: function(l) {
    return ci(t.rowCount, c, l);
  } };
}
(function(e) {
  e.create = function(t, r) {
    var n = t.name, a = new gJ();
    return { descriptor: t, formatRegistry: a, isApplicable: function(i) {
      return a.isApplicable(i);
    }, get: function(i) {
      var o = r != null && r.asDynamic ? i._dynamicPropertyData : i._staticPropertyData;
      if (o[n]) return o[n];
      if (!i.customProperties.has(t)) {
        var s = a.get(i.sourceData.kind);
        if (s) return o[n] = s(i), i.customProperties.add(t), o[n];
      }
    }, set: function(i, o) {
      r != null && r.asDynamic ? i._dynamicPropertyData[n] = o : i._staticPropertyData[n] = o;
    }, delete: function(i) {
      r != null && r.asDynamic ? delete i._dynamicPropertyData[n] : delete i._staticPropertyData[n];
    } };
  };
})(ic || (ic = {})), function(e) {
  e.Descriptor = { name: "index_pair_bonds" }, e.Provider = ic.create(e.Descriptor, { asDynamic: !0 }), e.DefaultProps = { maxDistance: -1 }, e.fromData = function(t, r) {
    r === void 0 && (r = {});
    var n = k(k({}, e.DefaultProps), r), a = t.pairs, i = t.count;
    return { bonds: yJ(a.indexA.toArray(), a.indexB.toArray(), { key: a.key && a.key.toArray(), order: a.order && a.order.toArray(), distance: a.distance && a.distance.toArray(), flag: a.flag && a.flag.toArray() }, i), maxDistance: n.maxDistance };
  };
}(Ra || (Ra = {})), function(e) {
  function t(r, n) {
    var a = Object.keys(n);
    return { rowCount: a.length > 0 ? n[a[0]].rowCount : 0, name: r, fieldNames: a, getField: function(i) {
      return n[i];
    } };
  }
  e.empty = function(r) {
    return { rowCount: 0, name: r, fieldNames: [], getField: function(n) {
    } };
  }, e.ofFields = t, e.ofTable = function(r, n) {
    for (var a = {}, i = 0, o = n._columns; i < o.length; i++) {
      var s = o[i];
      a[s] = mt.ofColumn(n[s]);
    }
    return t(r, a);
  };
}(Mi || (Mi = {})), function(e) {
  function t(n) {
    var a = n.length, i = function(u) {
      var c = n[u];
      return c && c !== "." && c !== "?" ? c : "";
    }, o = function(u) {
      var c = n[u];
      return Bd(c, 0, c.length) || 0;
    }, s = function(u) {
      var c = n[u];
      return Hf(c, 0, c.length) || 0;
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: a, str: i, int: o, float: s, valueKind: function(u) {
      var c = n[u], l = c.length;
      if (l > 1) return 0;
      if (l === 0) return 1;
      var d = c.charCodeAt(0);
      return d === 46 ? 1 : d === 63 ? 2 : 0;
    }, areValuesEqual: function(u, c) {
      return n[u] === n[c];
    }, toStringArray: function(u) {
      return u ? ci(a, i, u) : n;
    }, toIntArray: function(u) {
      return ci(a, o, u);
    }, toFloatArray: function(u) {
      return ci(a, s, u);
    } };
  }
  function r(n) {
    var a, i, o, s = n.rowCount, u = n.valueKind, c = n.areValuesEqual, l = n.isDefined;
    switch (n.schema.valueType) {
      case "float":
      case "int":
        a = function(f) {
          return "" + n.value(f);
        }, i = n.value, o = n.value;
        break;
      case "str":
        a = n.value, i = function(f) {
          var m = n.value(f);
          return Bd(m, 0, m.length) || 0;
        }, o = function(f) {
          var m = n.value(f);
          return Hf(m, 0, m.length) || 0;
        };
        break;
      case "list":
        var d = n.schema.separator;
        a = function(f) {
          return n.value(f).join(d);
        }, i = function(f) {
          return NaN;
        }, o = function(f) {
          return NaN;
        };
        break;
      default:
        throw new Error("unsupported valueType '".concat(n.schema.valueType, "'"));
    }
    return { __array: void 0, binaryEncoding: void 0, isDefined: l, rowCount: s, str: a, int: i, float: o, valueKind: u, areValuesEqual: c, toStringArray: function(f) {
      return ci(s, a, f);
    }, toIntArray: function(f) {
      return ci(s, i, f);
    }, toFloatArray: function(f) {
      return ci(s, o, f);
    } };
  }
  e.ofString = function(n) {
    return t([n]);
  }, e.ofStrings = t, e.ofNumbers = function(n) {
    var a = n.length, i = function(u) {
      return "" + n[u];
    }, o = function(u) {
      return n[u];
    }, s = function(u) {
      return !u || u.array && n instanceof u.array ? n : ci(a, o, u);
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: a, str: i, int: o, float: o, valueKind: function(u) {
      return 0;
    }, areValuesEqual: function(u, c) {
      return n[u] === n[c];
    }, toStringArray: function(u) {
      return ci(a, i, u);
    }, toIntArray: s, toFloatArray: s };
  }, e.ofTokens = function(n) {
    var a = n.data, i = n.indices, o = n.count, s = function(l) {
      var d = a.substring(i[2 * l], i[2 * l + 1]);
      return d === "." || d === "?" ? "" : d;
    }, u = function(l) {
      return Bd(a, i[2 * l], i[2 * l + 1]) || 0;
    }, c = function(l) {
      return Hf(a, i[2 * l], i[2 * l + 1]) || 0;
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: o, str: s, int: u, float: c, valueKind: function(l) {
      var d = i[2 * l], f = i[2 * l + 1] - d;
      if (f > 1) return 0;
      if (f === 0) return 1;
      var m = a.charCodeAt(d);
      return m === 46 ? 1 : m === 63 ? 2 : 0;
    }, areValuesEqual: gF(n), toStringArray: function(l) {
      return ci(o, s, l);
    }, toIntArray: function(l) {
      return ci(o, u, l);
    }, toFloatArray: function(l) {
      return ci(o, c, l);
    } };
  }, e.ofColumn = r, e.ofUndefined = function(n, a) {
    return r(pe.Undefined(n, a));
  };
}(mt || (mt = {})), function(e) {
  function t(r) {
    return r.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
  }
  e.canonical = t, e.equal = function(r, n) {
    return t(r) === t(n);
  }, e.create = function(r, n, a) {
    a === void 0 && (a = !1);
    var i = "".concat(r).concat(n ? ".".concat(n) : "");
    return a ? t(i) : i;
  };
}(Cp || (Cp = {}));
var Mn, bF = function(e, t, r) {
  this._isDefined = r;
  var n = Object.keys(t);
  this._rowCount = e.rowCount, this._columns = n, this._schema = t;
  for (var a = /* @__PURE__ */ Object.create(null), i = function(c) {
    Object.defineProperty(o, c, { get: function() {
      if (a[c]) return a[c];
      var l = t[c];
      if (l.valueType === "list") a[c] = function(m, h, p) {
        var g = m.separator, v = m.itemParse, y = h.getField(p), _ = y ? function(S) {
          return y.str(S).split(g).map(function(b) {
            return v(b.trim());
          }).filter(function(b) {
            return !!b;
          });
        } : function(S) {
          return [];
        };
        return { schema: m, __array: void 0, isDefined: !!y, rowCount: h.rowCount, value: _, valueKind: y ? y.valueKind : function() {
          return 1;
        }, areValuesEqual: function(S, b) {
          return ho(_(S), _(b));
        }, toArray: function(S) {
          return ci(h.rowCount, _, S);
        } };
      }(l, e, c);
      else if (l.valueType === "tensor") a[c] = xJ(l, e, c);
      else {
        var d = function(m) {
          switch (m.valueType) {
            case "str":
              return function(h, p, g) {
                return E4(m, h, h.str, h.toStringArray);
              };
            case "int":
              return function(h, p, g) {
                return E4(m, h, h.int, h.toIntArray);
              };
            case "float":
              return function(h, p, g) {
                return E4(m, h, h.float, h.toFloatArray);
              };
            case "list":
              throw new Error("Use createListColumn instead.");
            case "tensor":
              throw new Error("Use createTensorColumn instead.");
          }
        }(l), f = e.getField(c);
        a[c] = f ? d(f, e, c) : pe.Undefined(e.rowCount, l);
      }
      return a[c];
    }, enumerable: !0, configurable: !1 });
  }, o = this, s = 0, u = n; s < u.length; s++) i(u[s]);
};
function _J(e, t, r, n) {
  var a = Cp.create(t, e), i = Cp.canonical(a);
  if (i in r) return r[i];
  if (n && a in n) for (var o = 0, s = n[a]; o < s.length; o++) {
    var u = s[o], c = Cp.canonical(u);
    if (c in r) return r[c];
  }
}
function SJ(e, t, r, n) {
  var a = r.categories[e];
  if (n) {
    for (var i = function(m) {
      for (var h = /* @__PURE__ */ Object.create(null), p = 0, g = Object.keys(m.categories); p < g.length; p++) for (var v = g[p], y = 0, _ = m.categories[v].fieldNames; y < _.length; y++) {
        var S = _[y];
        h[Cp.create(v, S, !0)] = m.categories[v].getField(S);
      }
      return h;
    }(r), o = /* @__PURE__ */ Object.create(null), s = [], u = 0, c = 0, l = Object.keys(t); c < l.length; c++) {
      var d = l[c], f = _J(d, e, i, n);
      f && (o[d] = f, s.push(d), u = f.rowCount);
    }
    a = { rowCount: u, name: e, fieldNames: nt([], s, !0), getField: function(m) {
      return o[m];
    } };
  }
  return new bF(a || Mi.empty(e), t, !!a);
}
function D4(e, t, r) {
  for (var n = new Float32Array(e), a = 0; a < n.length; a++) n[a] = t + r * a;
  return n;
}
function AJ(e) {
  return 0;
}
function M4(e) {
  return function(t) {
    return e[t];
  };
}
function s3(e) {
  return e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
}
function wJ(e, t) {
  var r = e.matrix, n = t.x, a = t.y, i = t.z, o = r[0], s = r[4], u = r[8], c = r[12];
  return s3(r) ? function(l) {
    return o * n[l] + s * a[l] + u * i[l] + c;
  } : function(l) {
    var d = n[l], f = a[l], m = i[l], h = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + s * f + u * m + c) / h;
  };
}
function CJ(e, t) {
  var r = e.matrix, n = t.x, a = t.y, i = t.z, o = r[1], s = r[5], u = r[9], c = r[13];
  return s3(r) ? function(l) {
    return o * n[l] + s * a[l] + u * i[l] + c;
  } : function(l) {
    var d = n[l], f = a[l], m = i[l], h = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + s * f + u * m + c) / h;
  };
}
function EJ(e, t) {
  var r = e.matrix, n = t.x, a = t.y, i = t.z, o = r[2], s = r[6], u = r[10], c = r[14];
  return s3(r) ? function(l) {
    return o * n[l] + s * a[l] + u * i[l] + c;
  } : function(l) {
    var d = n[l], f = a[l], m = i[l], h = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + s * f + u * m + c) / h;
  };
}
(function(e) {
  function t(o, s, u) {
    var c = u || {}, l = c.assembly, d = c.ncsId, f = c.hkl, m = c.spgrOp, h = f ? D.clone(f) : D();
    m = Pa(m, -1), d = d || -1;
    var p = Ee.isIdentity(s), g = function(v, y) {
      if (!v) return "";
      if (v.assembly) return function(A) {
        return !!A && !!A.matrix && !!A.inverse && typeof A.name == "string";
      }(v) ? v.suffix : y ? "" : "_".concat(v.assembly.operId);
      if (v.spgrOp !== void 0 && v.hkl !== void 0 && v.spgrOp !== -1) {
        var _ = v.hkl, S = _[0], b = _[1], x = _[2];
        return "-".concat(v.spgrOp + 1, "_").concat(5 + S).concat(5 + b).concat(5 + x);
      }
      return v.ncsId !== -1 ? "_".concat(v.ncsId) : "";
    }(u, p);
    return p ? { name: o, assembly: l, matrix: s, inverse: Ee.identity(), isIdentity: !0, hkl: h, spgrOp: m, ncsId: d, suffix: g } : (Ee.isRotationAndTranslation(s, e.RotationTranslationEpsilon) || console.warn("Symmetry operator (".concat(o, ") should be a composition of rotation and translation.")), { name: o, assembly: l, matrix: s, inverse: Ee.invert(Ee(), s), isIdentity: !1, hkl: h, spgrOp: m, ncsId: d, suffix: g });
  }
  e.DefaultName = "1_555", e.Default = t(e.DefaultName, Ee.identity()), e.RotationTranslationEpsilon = 5e-3, e.create = t, e.checkIfRotationAndTranslation = function(o, s) {
    for (var u = Ee.identity(), c = 0; c < 3; c++) for (var l = 0; l < 3; l++) Ee.setValue(u, c, l, ka.getValue(o, c, l));
    return Ee.setTranslation(u, s), Ee.isRotationAndTranslation(u, e.RotationTranslationEpsilon);
  }, e.ofRotationAndOffset = function(o, s, u, c) {
    for (var l = Ee.identity(), d = 0; d < 3; d++) for (var f = 0; f < 3; f++) Ee.setValue(l, d, f, ka.getValue(s, d, f));
    return Ee.setTranslation(l, u), t(o, l, { ncsId: c });
  };
  var r = Gn.identity(), n = Gn(), a = Gn(), i = D();
  e.lerpFromIdentity = function(o, s, u) {
    var c = s.inverse;
    if (s.isIdentity) return Ee.copy(o, c);
    var l = 1 - u;
    Ee.getRotation(n, c), Gn.slerp(n, r, n, l);
    var d = Gn.getAxisAngle(i, n);
    return Ee.fromRotation(o, d, i), Ee.setValue(o, 0, 3, l * Ee.getValue(c, 0, 3)), Ee.setValue(o, 1, 3, l * Ee.getValue(c, 1, 3)), Ee.setValue(o, 2, 3, l * Ee.getValue(c, 2, 3)), o;
  }, e.slerp = function(o, s, u, c) {
    if (Math.abs(c) <= 1e-5) return Ee.copy(o, s);
    if (Math.abs(c - 1) <= 1e-5) return Ee.copy(o, u);
    Ee.getRotation(n, s), Ee.getRotation(a, u), Gn.slerp(a, n, a, c);
    var l = Gn.getAxisAngle(i, a);
    return Ee.fromRotation(o, l, i), Ee.setValue(o, 0, 3, Na(Ee.getValue(s, 0, 3), Ee.getValue(u, 0, 3), c)), Ee.setValue(o, 1, 3, Na(Ee.getValue(s, 1, 3), Ee.getValue(u, 1, 3), c)), Ee.setValue(o, 2, 3, Na(Ee.getValue(s, 2, 3), Ee.getValue(u, 2, 3), c)), o;
  }, e.compose = function(o, s) {
    var u = Ee.mul(Ee(), s.matrix, o.matrix);
    return t(s.name, u, s);
  }, e.createMapping = function(o, s, u) {
    var c = e.createCoordinateMapper(e.Default, s), l = o.isIdentity ? c : e.createCoordinateMapper(o, s), d = function(f, m) {
      return f.isIdentity ? { x: M4(m.x), y: M4(m.y), z: M4(m.z) } : { x: wJ(f, m), y: CJ(f, m), z: EJ(f, m) };
    }(o, s);
    return { operator: o, coordinates: s, invariantPosition: c, position: l, x: d.x, y: d.y, z: d.z, r: u || AJ };
  }, e.createCoordinateMapper = function(o, s) {
    return o.isIdentity ? function(u) {
      var c = u.x, l = u.y, d = u.z;
      return function(f, m) {
        return m[0] = c[f], m[1] = l[f], m[2] = d[f], m;
      };
    }(s) : function(u, c) {
      var l = u.matrix, d = c.x, f = c.y, m = c.z;
      return s3(l) ? function(h, p) {
        var g = d[h], v = f[h], y = m[h];
        return p[0] = l[0] * g + l[4] * v + l[8] * y + l[12], p[1] = l[1] * g + l[5] * v + l[9] * y + l[13], p[2] = l[2] * g + l[6] * v + l[10] * y + l[14], p;
      } : function(h, p) {
        return p[0] = d[h], p[1] = f[h], p[2] = m[h], D.transformMat4(p, p, l), p;
      };
    }(o, s);
  };
})(Mn || (Mn = {}));
var I4 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0.5], [1, 0, 0, 0.5], [-1, 0, 0, 0.5], [0, 0, 1, 0.5], [0, -1, 0, 0.5], [0, 0, -1, 0.5], [1, 0, 0, 0.25], [0, -1, 0, 0.25], [0, 0, 1, 0.25], [-1, 0, 0, 0.25], [0, 1, 0, 0.25], [0, -1, 0, 0.75], [0, 0, 1, 0.75], [0, 1, 0, 0.75], [1, 0, 0, 0.75], [-1, 0, 0, 0.75], [0, 0, -1, 0.25], [0, 0, -1, 0.75], [1, -1, 0, 0], [-1, 1, 0, 0], [0, 0, 1, 1 / 3], [0, 0, 1, 2 / 3], [1, 0, 0, 2 / 3], [0, 1, 0, 1 / 3], [0, -1, 0, 2 / 3], [1, -1, 0, 1 / 3], [-1, 1, 0, 2 / 3], [-1, 0, 0, 1 / 3], [1, 0, 0, 1 / 3], [0, 1, 0, 2 / 3], [0, -1, 0, 1 / 3], [1, -1, 0, 2 / 3], [-1, 1, 0, 1 / 3], [-1, 0, 0, 2 / 3], [0, 0, -1, 1 / 3], [0, 0, -1, 2 / 3], [0, 0, 1, 5 / 6], [0, 0, 1, 1 / 6], [0, 0, -1, 5 / 6], [0, 0, -1, 1 / 6]], DJ = [[0, 1, 2], [3, 4, 5], [3, 1, 5], [3, 6, 5], [7, 6, 2], [8, 6, 5], [0, 4, 2], [0, 4, 9], [7, 10, 2], [7, 10, 9], [0, 10, 2], [8, 10, 5], [3, 1, 11], [3, 6, 11], [0, 10, 9], [8, 6, 11], [3, 4, 2], [0, 4, 5], [3, 4, 9], [7, 10, 5], [8, 4, 9], [8, 10, 9], [8, 10, 2], [0, 6, 9], [3, 10, 9], [0, 10, 11], [7, 1, 9], [8, 1, 11], [7, 4, 11], [7, 6, 9], [7, 10, 11], [3, 10, 2], [8, 1, 5], [0, 4, 11], [3, 1, 2], [3, 1, 9], [7, 4, 2], [8, 1, 2], [8, 1, 9], [3, 6, 9], [7, 4, 9], [8, 6, 2], [8, 6, 9], [3, 6, 2], [12, 13, 14], [15, 16, 14], [12, 17, 18], [15, 19, 18], [20, 13, 18], [21, 16, 18], [20, 17, 14], [21, 19, 14], [0, 1, 5], [8, 10, 11], [7, 6, 11], [7, 6, 5], [8, 4, 2], [7, 4, 5], [7, 1, 5], [7, 1, 11], [0, 10, 5], [0, 1, 11], [0, 6, 11], [0, 6, 5], [3, 10, 11], [8, 4, 11], [15, 13, 22], [12, 16, 22], [15, 17, 23], [12, 19, 23], [21, 13, 23], [20, 16, 23], [21, 17, 22], [20, 19, 22], [4, 0, 2], [1, 3, 2], [4, 0, 14], [1, 3, 18], [4, 0, 9], [1, 3, 9], [4, 0, 18], [1, 3, 14], [10, 7, 9], [6, 8, 9], [4, 7, 14], [6, 3, 18], [10, 0, 18], [1, 8, 14], [1, 3, 5], [4, 0, 5], [6, 8, 11], [10, 7, 11], [1, 3, 11], [4, 0, 11], [10, 7, 2], [6, 8, 2], [3, 10, 22], [7, 1, 23], [8, 4, 23], [0, 6, 22], [1, 0, 5], [4, 3, 5], [1, 0, 23], [4, 3, 22], [10, 7, 14], [6, 8, 18], [8, 6, 22], [7, 10, 23], [4, 3, 11], [1, 0, 11], [1, 0, 22], [4, 3, 23], [10, 7, 18], [6, 8, 14], [8, 6, 23], [7, 10, 22], [6, 7, 11], [10, 8, 11], [8, 1, 23], [0, 10, 22], [3, 6, 22], [7, 4, 23], [4, 3, 2], [1, 0, 2], [10, 8, 2], [6, 7, 2], [4, 3, 9], [1, 0, 9], [10, 8, 9], [6, 7, 9], [4, 8, 14], [6, 0, 18], [10, 3, 18], [1, 7, 14], [4, 8, 18], [6, 0, 14], [10, 3, 14], [1, 7, 18], [6, 7, 5], [10, 8, 5], [6, 8, 5], [10, 7, 5], [8, 1, 22], [0, 10, 23], [3, 6, 23], [7, 4, 22], [4, 24, 2], [25, 3, 2], [4, 24, 26], [25, 3, 27], [4, 24, 27], [25, 3, 26], [28, 29, 26], [30, 31, 26], [32, 33, 26], [34, 35, 27], [36, 37, 27], [38, 39, 27], [2, 0, 1], [1, 2, 0], [1, 25, 5], [24, 0, 5], [39, 36, 40], [35, 38, 40], [37, 34, 40], [33, 30, 41], [29, 32, 41], [31, 28, 41], [5, 3, 4], [4, 5, 3], [25, 1, 5], [0, 24, 5], [24, 4, 5], [3, 25, 5], [4, 3, 41], [25, 1, 40], [24, 4, 41], [3, 25, 40], [4, 3, 40], [25, 1, 41], [24, 4, 40], [3, 25, 41], [35, 34, 40], [37, 36, 40], [39, 38, 40], [29, 28, 41], [31, 30, 41], [33, 32, 41], [3, 5, 4], [5, 4, 3], [25, 1, 2], [0, 24, 2], [24, 4, 2], [3, 25, 2], [25, 1, 9], [0, 24, 9], [24, 4, 9], [3, 25, 9], [30, 33, 26], [32, 29, 26], [28, 31, 26], [36, 39, 27], [38, 35, 27], [34, 37, 27], [0, 2, 1], [2, 1, 0], [30, 33, 42], [32, 29, 42], [28, 31, 42], [36, 39, 43], [38, 35, 43], [34, 37, 43], [7, 9, 6], [9, 6, 7], [25, 1, 11], [0, 24, 11], [24, 4, 11], [3, 25, 11], [35, 34, 44], [37, 36, 44], [39, 38, 44], [29, 28, 45], [31, 30, 45], [33, 32, 45], [8, 11, 10], [11, 10, 8], [1, 25, 2], [24, 0, 2], [1, 25, 42], [24, 0, 43], [1, 25, 43], [24, 0, 42], [1, 25, 27], [24, 0, 26], [1, 25, 26], [24, 0, 27], [1, 25, 9], [24, 0, 9], [4, 24, 5], [25, 3, 5], [4, 24, 11], [25, 3, 11], [1, 0, 40], [4, 3, 44], [0, 24, 45], [1, 0, 41], [4, 3, 45], [0, 24, 44], [0, 24, 40], [0, 24, 41], [2, 3, 4], [5, 3, 1], [5, 0, 4], [4, 2, 3], [1, 5, 3], [4, 5, 0], [2, 7, 6], [2, 8, 10], [5, 8, 6], [5, 7, 10], [1, 9, 7], [4, 9, 8], [1, 11, 8], [4, 11, 7], [9, 0, 6], [9, 3, 10], [11, 3, 6], [11, 0, 10], [6, 2, 7], [10, 2, 8], [6, 5, 8], [10, 5, 7], [9, 7, 1], [9, 8, 4], [11, 8, 1], [11, 7, 4], [6, 9, 0], [10, 9, 3], [6, 11, 3], [10, 11, 0], [9, 7, 6], [9, 8, 10], [11, 8, 6], [11, 7, 10], [6, 9, 7], [10, 9, 8], [6, 11, 8], [10, 11, 7], [2, 3, 10], [5, 8, 1], [11, 0, 4], [10, 2, 3], [1, 5, 8], [4, 11, 0], [5, 0, 1], [2, 0, 4], [2, 3, 1], [1, 5, 0], [4, 2, 0], [1, 2, 3], [11, 8, 10], [11, 7, 6], [9, 7, 10], [9, 8, 6], [10, 11, 8], [6, 11, 7], [10, 9, 7], [6, 9, 8], [5, 8, 10], [5, 7, 6], [2, 7, 10], [2, 8, 6], [4, 11, 8], [1, 11, 7], [4, 9, 7], [1, 9, 8], [11, 3, 10], [11, 0, 6], [9, 0, 10], [9, 3, 6], [10, 5, 8], [6, 5, 7], [10, 2, 7], [6, 2, 8], [11, 8, 4], [11, 7, 1], [9, 7, 4], [9, 8, 1], [10, 11, 3], [6, 11, 0], [10, 9, 0], [6, 9, 3], [22, 15, 13], [22, 12, 16], [14, 12, 13], [14, 15, 16], [13, 22, 15], [16, 22, 12], [13, 14, 12], [16, 14, 15], [22, 21, 17], [22, 20, 19], [14, 20, 17], [14, 21, 19], [13, 23, 21], [16, 23, 20], [13, 18, 20], [16, 18, 21], [23, 15, 17], [23, 12, 19], [18, 12, 17], [18, 15, 19], [17, 22, 21], [19, 22, 20], [17, 14, 20], [19, 14, 21], [23, 21, 13], [23, 20, 16], [18, 20, 13], [18, 21, 16], [17, 23, 15], [19, 23, 12], [17, 18, 12], [19, 18, 15], [5, 0, 6], [2, 7, 4], [9, 3, 1], [6, 5, 0], [4, 2, 7], [1, 9, 3], [0, 2, 4], [3, 2, 1], [0, 5, 1], [2, 1, 3], [2, 4, 0], [5, 1, 0], [7, 9, 10], [8, 9, 6], [7, 11, 6], [9, 6, 8], [9, 10, 7], [11, 6, 7], [1, 7, 11], [4, 8, 11], [1, 8, 9], [4, 7, 9], [0, 9, 10], [3, 9, 6], [3, 11, 10], [0, 11, 6], [2, 6, 8], [2, 10, 7], [5, 6, 7], [5, 10, 8], [6, 0, 11], [10, 3, 11], [6, 3, 9], [10, 0, 9], [7, 2, 10], [8, 2, 6], [8, 5, 10], [7, 5, 6], [9, 1, 8], [9, 4, 7], [11, 1, 7], [11, 4, 8], [7, 9, 4], [8, 9, 1], [8, 11, 4], [7, 11, 1], [9, 6, 3], [9, 10, 0], [11, 6, 0], [11, 10, 3], [19, 12, 23], [13, 15, 22], [16, 21, 18], [17, 20, 14], [20, 14, 17], [21, 18, 16], [15, 22, 13], [12, 23, 19], [18, 16, 21], [14, 17, 20], [23, 19, 12], [22, 13, 15], [19, 20, 22], [13, 21, 23], [16, 15, 14], [17, 12, 18], [20, 18, 13], [21, 14, 19], [15, 23, 17], [12, 22, 16], [18, 19, 15], [14, 13, 12], [23, 16, 20], [22, 17, 21], [16, 12, 22], [17, 15, 23], [19, 21, 14], [13, 20, 18], [12, 14, 13], [15, 18, 19], [21, 22, 17], [20, 23, 16], [14, 16, 15], [18, 17, 12], [22, 19, 20], [23, 13, 21], [16, 20, 23], [17, 21, 22], [19, 15, 18], [13, 12, 14], [12, 18, 17], [15, 14, 16], [21, 23, 13], [20, 22, 19], [14, 19, 21], [18, 13, 20], [22, 16, 12], [23, 17, 15], [19, 12, 22], [17, 21, 23], [16, 15, 18], [13, 20, 14], [20, 14, 13], [15, 18, 16], [21, 23, 17], [12, 22, 19], [18, 16, 15], [14, 13, 20], [22, 19, 12], [23, 17, 21], [3, 2, 4], [3, 5, 1], [0, 5, 4], [2, 4, 3], [5, 1, 3], [5, 4, 0], [1, 7, 9], [4, 8, 9], [1, 8, 11], [4, 7, 11], [0, 9, 6], [3, 9, 10], [3, 11, 6], [0, 11, 10], [2, 6, 7], [2, 10, 8], [5, 6, 8], [5, 10, 7], [6, 0, 9], [10, 3, 9], [6, 3, 11], [10, 0, 11], [7, 2, 6], [8, 2, 10], [8, 5, 6], [7, 5, 10], [9, 1, 7], [9, 4, 8], [11, 1, 8], [11, 4, 7], [7, 9, 1], [8, 9, 4], [8, 11, 1], [7, 11, 4], [9, 6, 0], [9, 10, 3], [11, 6, 3], [11, 10, 0], [8, 9, 10], [8, 11, 6], [7, 11, 10], [9, 10, 8], [11, 6, 8], [11, 10, 7], [6, 0, 2], [10, 3, 2], [6, 3, 5], [10, 0, 5], [7, 2, 1], [8, 2, 4], [8, 5, 1], [7, 5, 4], [9, 1, 0], [9, 4, 3], [11, 1, 3], [11, 4, 0], [1, 7, 2], [4, 8, 2], [1, 8, 5], [4, 7, 5], [0, 9, 1], [3, 9, 4], [3, 11, 1], [0, 11, 4], [2, 6, 0], [2, 10, 3], [5, 6, 3], [5, 10, 0], [0, 2, 6], [3, 2, 10], [3, 5, 6], [0, 5, 10], [2, 1, 7], [2, 4, 8], [5, 1, 8], [5, 4, 7], [16, 12, 14], [13, 21, 18], [19, 15, 23], [17, 20, 22], [12, 14, 16], [21, 18, 13], [15, 23, 19], [20, 22, 17], [14, 16, 12], [18, 13, 21], [23, 19, 15], [22, 17, 20], [19, 20, 18], [17, 15, 14], [16, 21, 22], [13, 12, 23], [20, 18, 19], [15, 14, 17], [21, 22, 16], [12, 23, 13], [18, 19, 20], [14, 17, 15], [22, 16, 21], [23, 13, 12], [6, 0, 5], [10, 3, 5], [6, 3, 2], [10, 0, 2], [7, 2, 4], [8, 2, 1], [8, 5, 4], [7, 5, 1], [9, 1, 3], [9, 4, 0], [11, 1, 0], [11, 4, 3], [1, 7, 5], [4, 8, 5], [1, 8, 2], [4, 7, 2], [0, 9, 4], [3, 9, 1], [3, 11, 4], [0, 11, 1], [2, 6, 3], [2, 10, 0], [5, 6, 0], [5, 10, 3], [0, 2, 10], [3, 2, 6], [3, 5, 10], [0, 5, 6], [2, 1, 8], [2, 4, 7], [5, 1, 7], [5, 4, 8], [21, 17, 23], [20, 16, 22], [12, 13, 18], [15, 19, 14], [23, 21, 17], [22, 20, 16], [18, 12, 13], [14, 15, 19], [17, 23, 21], [16, 22, 20], [13, 18, 12], [19, 14, 15], [21, 13, 22], [20, 19, 23], [12, 17, 14], [15, 16, 18], [23, 15, 13], [22, 12, 19], [18, 20, 17], [14, 21, 16], [17, 22, 15], [16, 23, 12], [13, 14, 20], [19, 18, 21], [15, 17, 22], [12, 16, 23], [20, 13, 14], [21, 19, 18], [22, 21, 13], [23, 20, 19], [14, 12, 17], [18, 15, 16], [13, 23, 15], [19, 22, 12], [17, 18, 20], [16, 14, 21], [15, 13, 23], [12, 19, 22], [20, 17, 18], [21, 16, 14], [22, 15, 17], [23, 12, 16], [14, 20, 13], [18, 21, 19], [13, 22, 21], [19, 23, 20], [17, 14, 12], [16, 18, 15], [6, 5, 3], [4, 9, 3], [9, 3, 4], [5, 7, 4], [4, 5, 7], [5, 3, 6]], MJ = [[0], [0, 1], [0, 2], [0, 3], [0, 2, 4, 5], [0, 6], [0, 7], [0, 6, 4, 8], [0, 7, 4, 9], [0, 6, 2, 1], [0, 3, 1, 10], [0, 6, 2, 1, 4, 8, 5, 11], [0, 12, 1, 7], [0, 1, 13, 14], [0, 12, 1, 7, 4, 15, 11, 9], [0, 16, 2, 17], [0, 18, 12, 17], [0, 16, 5, 19], [0, 20, 13, 19], [0, 18, 12, 17, 4, 21, 15, 19], [0, 16, 2, 17, 4, 22, 5, 19], [0, 16, 2, 17, 23, 24, 13, 25, 26, 20, 27, 28, 4, 22, 5, 19], [0, 16, 17, 2, 29, 21, 30, 15], [0, 20, 13, 19, 29, 31, 32, 33], [0, 16, 6, 34], [0, 18, 7, 34], [0, 16, 7, 35], [0, 16, 36, 37], [0, 18, 36, 38], [0, 16, 14, 39], [0, 20, 40, 34], [0, 16, 8, 41], [0, 18, 8, 42], [0, 16, 9, 42], [0, 16, 6, 34, 4, 22, 8, 41], [0, 18, 7, 34, 4, 21, 9, 41], [0, 16, 7, 35, 4, 22, 9, 42], [0, 16, 6, 34, 23, 24, 14, 39], [0, 16, 10, 43, 23, 24, 7, 35], [0, 16, 36, 37, 23, 24, 9, 42], [0, 16, 8, 41, 23, 24, 40, 38], [0, 16, 6, 34, 23, 24, 14, 39, 26, 20, 40, 38, 4, 22, 8, 41], [0, 16, 44, 45, 23, 24, 46, 47, 26, 20, 48, 49, 4, 22, 50, 51], [0, 16, 6, 34, 29, 21, 9, 42], [0, 16, 8, 41, 29, 21, 7, 35], [0, 16, 36, 37, 29, 21, 14, 39], [0, 16, 2, 17, 1, 52, 6, 34], [0, 16, 2, 17, 53, 54, 9, 42], [0, 16, 12, 33, 1, 52, 7, 35], [0, 16, 2, 17, 11, 55, 8, 41], [0, 56, 2, 57, 1, 58, 6, 37], [0, 56, 15, 25, 1, 58, 9, 39], [0, 20, 27, 17, 1, 59, 40, 34], [0, 56, 12, 28, 1, 58, 7, 38], [0, 16, 5, 19, 1, 52, 8, 41], [0, 22, 13, 28, 1, 55, 14, 38], [0, 18, 13, 60, 1, 61, 14, 43], [0, 16, 15, 30, 1, 52, 9, 42], [0, 16, 5, 19, 11, 55, 6, 34], [0, 21, 12, 19, 1, 54, 7, 41], [0, 20, 13, 19, 1, 59, 14, 41], [0, 20, 3, 30, 1, 59, 10, 42], [0, 18, 12, 17, 1, 61, 7, 34, 4, 21, 15, 19, 11, 54, 9, 41], [0, 24, 13, 17, 1, 62, 14, 34, 4, 20, 27, 19, 11, 59, 40, 41], [0, 16, 2, 17, 1, 52, 6, 34, 4, 22, 5, 19, 11, 55, 8, 41], [0, 16, 12, 33, 1, 52, 7, 35, 4, 22, 15, 30, 11, 55, 9, 42], [0, 31, 3, 17, 1, 63, 10, 34, 4, 56, 32, 19, 11, 58, 36, 41], [0, 22, 2, 19, 64, 59, 14, 38, 4, 16, 5, 17, 65, 62, 40, 39], [0, 16, 2, 17, 1, 52, 6, 34, 23, 24, 13, 25, 64, 62, 14, 39, 26, 20, 27, 28, 65, 59, 40, 38, 4, 22, 5, 19, 11, 55, 8, 41], [0, 16, 2, 17, 66, 67, 44, 45, 23, 24, 13, 25, 68, 69, 46, 47, 26, 20, 27, 28, 70, 71, 48, 49, 4, 22, 5, 19, 72, 73, 50, 51], [0, 16, 2, 17, 1, 52, 6, 34, 29, 21, 15, 30, 53, 54, 9, 42], [0, 16, 5, 19, 1, 52, 8, 41, 29, 21, 12, 33, 53, 54, 7, 35], [0, 20, 13, 19, 1, 59, 14, 41, 29, 31, 32, 33, 53, 63, 36, 35], [0, 31, 3, 17, 1, 63, 10, 34, 29, 20, 27, 30, 53, 59, 40, 42], [0, 16, 74, 75], [0, 18, 76, 77], [0, 16, 78, 79], [0, 18, 80, 81], [0, 16, 74, 75, 29, 21, 82, 83], [0, 21, 84, 85, 29, 16, 86, 87], [0, 16, 88, 89], [0, 16, 88, 89, 29, 21, 90, 91], [0, 16, 74, 75, 1, 52, 88, 89], [0, 16, 78, 79, 1, 52, 92, 93], [0, 16, 94, 95, 11, 55, 88, 89], [0, 16, 82, 83, 53, 54, 88, 89], [0, 16, 74, 75, 1, 52, 88, 89, 29, 21, 82, 83, 53, 54, 90, 91], [0, 21, 84, 85, 96, 97, 88, 91, 29, 16, 86, 87, 98, 99, 90, 89], [0, 16, 74, 75, 2, 17, 100, 101], [0, 16, 94, 95, 5, 19, 100, 101], [0, 18, 76, 77, 2, 33, 102, 103], [0, 18, 104, 105, 106, 107, 100, 108], [0, 16, 78, 79, 2, 17, 109, 108], [0, 16, 82, 83, 15, 30, 100, 101], [0, 18, 80, 81, 2, 33, 110, 111], [0, 18, 112, 113, 114, 115, 100, 108], [0, 16, 74, 75, 2, 17, 100, 101, 29, 21, 82, 83, 15, 30, 116, 117], [0, 21, 84, 85, 118, 119, 116, 101, 29, 16, 86, 87, 120, 121, 100, 117], [0, 16, 74, 75, 6, 34, 122, 123], [0, 16, 74, 75, 8, 41, 124, 125], [0, 16, 78, 79, 7, 35, 122, 123], [0, 16, 82, 83, 9, 42, 122, 123], [0, 16, 74, 75, 7, 35, 126, 127], [0, 16, 74, 75, 9, 42, 128, 129], [0, 16, 78, 79, 6, 34, 126, 127], [0, 16, 78, 79, 8, 41, 128, 129], [0, 16, 74, 75, 6, 34, 122, 123, 29, 21, 82, 83, 9, 42, 128, 129], [0, 16, 74, 75, 7, 35, 126, 127, 29, 21, 82, 83, 8, 41, 124, 125], [0, 21, 84, 85, 6, 42, 130, 131, 29, 16, 86, 87, 9, 34, 132, 133], [0, 21, 84, 85, 7, 41, 134, 135, 29, 16, 86, 87, 8, 35, 136, 137], [0, 16, 89, 88, 2, 17, 122, 123], [0, 16, 89, 88, 12, 33, 126, 127], [0, 16, 89, 88, 5, 19, 124, 125], [0, 16, 89, 88, 15, 30, 128, 129], [0, 16, 88, 89, 6, 34, 100, 101], [0, 16, 89, 88, 7, 35, 109, 108], [0, 16, 89, 88, 8, 41, 138, 139], [0, 16, 89, 88, 9, 42, 116, 117], [0, 16, 89, 88, 6, 34, 100, 101, 29, 21, 91, 90, 9, 42, 116, 117], [0, 16, 89, 88, 7, 35, 109, 108, 29, 21, 91, 90, 8, 41, 138, 139], [0, 16, 89, 88, 2, 17, 122, 123, 29, 21, 91, 90, 15, 30, 128, 129], [0, 16, 89, 88, 118, 121, 132, 131, 29, 21, 91, 90, 120, 119, 130, 133], [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123], [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127], [0, 16, 74, 75, 2, 17, 100, 101, 11, 55, 140, 141, 8, 41, 124, 125], [0, 16, 74, 75, 2, 17, 100, 101, 53, 54, 90, 91, 9, 42, 128, 129], [0, 16, 74, 75, 5, 19, 138, 139, 1, 52, 88, 89, 8, 41, 124, 125], [0, 16, 74, 75, 15, 30, 116, 117, 1, 52, 88, 89, 9, 42, 128, 129], [0, 16, 94, 95, 5, 19, 100, 101, 11, 55, 88, 89, 6, 34, 124, 125], [0, 16, 94, 95, 15, 30, 109, 108, 11, 55, 88, 89, 7, 35, 128, 129], [0, 16, 78, 79, 2, 17, 109, 108, 1, 52, 92, 93, 6, 34, 126, 127], [0, 16, 78, 79, 12, 33, 100, 101, 1, 52, 92, 93, 7, 35, 122, 123], [0, 16, 82, 83, 12, 33, 138, 139, 53, 54, 88, 89, 8, 41, 126, 127], [0, 16, 82, 83, 2, 17, 116, 117, 53, 54, 88, 89, 9, 42, 122, 123], [0, 16, 78, 79, 5, 19, 116, 117, 1, 52, 92, 93, 8, 41, 128, 129], [0, 16, 82, 83, 15, 30, 100, 101, 1, 52, 90, 91, 9, 42, 122, 123], [0, 16, 82, 83, 15, 30, 100, 101, 53, 54, 88, 89, 6, 34, 128, 129], [0, 16, 82, 83, 5, 19, 109, 108, 53, 54, 88, 89, 7, 35, 124, 125], [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123, 29, 21, 82, 83, 15, 30, 116, 117, 53, 54, 90, 91, 9, 42, 128, 129], [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127, 29, 21, 82, 83, 5, 19, 138, 139, 53, 54, 90, 91, 8, 41, 124, 125], [0, 21, 84, 85, 118, 119, 116, 101, 96, 97, 88, 91, 9, 34, 132, 133, 29, 16, 86, 87, 120, 121, 100, 117, 98, 99, 90, 89, 6, 42, 130, 131], [0, 21, 84, 85, 142, 143, 138, 108, 96, 97, 88, 91, 8, 35, 136, 137, 29, 16, 86, 87, 144, 145, 109, 139, 98, 99, 90, 89, 7, 41, 134, 135], [0, 146, 147], [0, 148, 149], [0, 150, 151], [0, 146, 147, 152, 153, 154, 155, 156, 157], [0, 158, 159], [0, 146, 147, 1, 160, 161], [0, 146, 147, 1, 160, 161, 152, 153, 154, 162, 163, 164, 155, 156, 157, 165, 166, 167], [0, 158, 159, 1, 168, 169], [0, 146, 147, 101, 170, 171], [0, 146, 147, 100, 172, 173], [0, 148, 149, 174, 175, 171], [0, 148, 149, 100, 176, 177], [0, 150, 151, 178, 179, 171], [0, 150, 151, 100, 180, 181], [0, 146, 147, 100, 172, 173, 152, 153, 154, 182, 183, 184, 155, 156, 157, 185, 186, 187], [0, 158, 159, 101, 188, 189], [0, 146, 147, 122, 190, 191], [0, 146, 147, 123, 192, 193], [0, 146, 147, 126, 194, 195], [0, 146, 147, 127, 196, 197], [0, 146, 147, 122, 190, 191, 152, 153, 154, 198, 199, 200, 155, 156, 157, 201, 202, 203], [0, 158, 159, 123, 204, 205], [0, 146, 147, 126, 194, 195, 152, 153, 154, 206, 207, 208, 155, 156, 157, 209, 210, 211], [0, 158, 159, 129, 212, 213], [0, 146, 147, 101, 170, 171, 1, 160, 161, 123, 192, 193], [0, 146, 147, 108, 214, 215, 1, 160, 161, 127, 196, 197], [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191], [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195], [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191, 152, 153, 154, 182, 183, 184, 162, 163, 164, 198, 199, 200, 155, 156, 157, 185, 186, 187, 165, 166, 167, 201, 202, 203], [0, 158, 159, 101, 188, 189, 1, 168, 169, 123, 204, 205], [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195, 152, 153, 154, 218, 219, 220, 162, 163, 164, 206, 207, 208, 155, 156, 157, 221, 222, 223, 165, 166, 167, 209, 210, 211], [0, 158, 159, 117, 224, 225, 1, 168, 169, 129, 212, 213], [0, 146, 147, 16, 226, 227], [0, 148, 149, 18, 228, 229], [0, 150, 151, 18, 230, 231], [0, 150, 151, 16, 232, 233], [0, 148, 149, 16, 234, 235], [0, 146, 147, 18, 236, 237], [0, 146, 147, 52, 238, 239], [0, 146, 147, 16, 226, 227, 1, 160, 161, 52, 238, 239], [0, 146, 147, 18, 236, 237, 1, 160, 161, 61, 240, 241], [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171], [0, 148, 149, 18, 228, 229, 242, 172, 181, 243, 214, 244], [0, 150, 151, 18, 230, 231, 245, 172, 177, 246, 214, 247], [0, 150, 151, 16, 232, 233, 245, 172, 177, 174, 170, 248], [0, 148, 149, 16, 234, 235, 242, 172, 181, 178, 170, 249], [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215], [0, 146, 147, 16, 226, 227, 122, 190, 191, 123, 192, 193], [0, 146, 147, 16, 226, 227, 126, 194, 195, 127, 196, 197], [0, 146, 147, 18, 236, 237, 126, 194, 195, 123, 192, 193], [0, 146, 147, 18, 236, 237, 122, 190, 191, 127, 196, 197], [0, 146, 147, 52, 238, 239, 122, 190, 191, 101, 170, 171], [0, 146, 147, 61, 240, 241, 126, 194, 195, 101, 170, 171], [0, 146, 147, 52, 238, 239, 100, 172, 173, 123, 192, 193], [0, 146, 147, 61, 240, 241, 100, 172, 173, 127, 196, 197], [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171, 1, 160, 161, 52, 239, 238, 122, 190, 191, 123, 192, 193], [0, 146, 147, 16, 226, 227, 109, 216, 217, 108, 214, 215, 1, 160, 161, 52, 239, 238, 126, 194, 195, 127, 196, 197], [0, 146, 147, 18, 236, 237, 109, 216, 217, 101, 170, 171, 1, 160, 161, 61, 241, 240, 126, 194, 195, 123, 192, 193], [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215, 1, 160, 161, 61, 241, 240, 122, 190, 191, 127, 196, 197], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 66, 67, 44, 45, 332, 333, 334, 335, 336, 337, 338, 339, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 68, 69, 46, 47, 340, 341, 342, 343, 344, 345, 346, 347, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 70, 71, 48, 49, 348, 349, 350, 351, 352, 353, 354, 355, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 72, 73, 50, 51, 356, 357, 358, 359, 360, 361, 362, 363], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 125, 124, 140, 141, 504, 505, 506, 507, 508, 509, 510, 511], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 127, 126, 92, 93, 542, 543, 544, 545, 546, 547, 548, 549], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 481, 480, 483, 482, 486, 487, 484, 485, 491, 490, 489, 488, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 493, 492, 495, 494, 498, 499, 496, 497, 503, 502, 501, 500, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 124, 125, 141, 140, 506, 507, 504, 505, 511, 510, 509, 508], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 519, 518, 521, 520, 524, 525, 522, 523, 529, 528, 527, 526, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 531, 530, 533, 532, 536, 537, 534, 535, 541, 540, 539, 538, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 109, 108, 79, 78, 598, 599, 600, 601, 602, 603, 604, 605, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 126, 127, 93, 92, 544, 545, 542, 543, 549, 548, 547, 546], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 66, 69, 50, 49, 332, 349, 342, 359, 336, 361, 354, 347, 493, 123, 483, 140, 498, 507, 204, 485, 503, 490, 509, 205, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 68, 67, 48, 51, 340, 357, 334, 351, 344, 353, 362, 339, 124, 480, 89, 494, 506, 499, 484, 474, 511, 478, 501, 488, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 70, 73, 46, 45, 348, 333, 358, 343, 352, 345, 338, 363, 122, 492, 141, 482, 475, 487, 496, 505, 479, 510, 489, 500, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 72, 71, 44, 47, 356, 341, 350, 335, 360, 337, 346, 355, 481, 125, 495, 88, 486, 476, 504, 497, 491, 502, 477, 508], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 531, 129, 521, 92, 536, 545, 212, 523, 541, 528, 547, 213, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 126, 518, 91, 532, 544, 537, 522, 512, 549, 516, 539, 526, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 128, 530, 93, 520, 513, 525, 534, 543, 517, 548, 527, 538, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 519, 127, 533, 90, 524, 514, 542, 535, 529, 540, 515, 546], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 551, 550, 553, 552, 556, 557, 554, 555, 561, 560, 559, 558, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369, 563, 562, 565, 564, 568, 569, 566, 567, 573, 572, 571, 570], [0, 16], [0, 18], [0, 16, 26, 20], [0, 2, 23, 13], [0, 3, 4, 32], [0, 2, 29, 15], [0, 3, 29, 27], [0, 52], [0, 63], [0, 52, 26, 59], [0, 63, 26, 54], [0, 52, 16, 1], [0, 18, 1, 61], [0, 52, 16, 1, 26, 59, 20, 65], [0, 31, 1, 63], [0, 1, 24, 62], [0, 15, 1, 9], [0, 5, 1, 8], [0, 31, 1, 63, 26, 21, 65, 54], [0, 2, 57, 56], [0, 60, 3, 16], [0, 22, 57, 3], [0, 2, 28, 20], [0, 17, 13, 24], [0, 20, 19, 13, 4, 24, 17, 27], [0, 22, 57, 3, 4, 16, 60, 32], [0, 22, 57, 3, 23, 20, 30, 12, 26, 24, 33, 15, 4, 16, 60, 32], [0, 22, 57, 3, 29, 18, 27, 25], [0, 22, 3, 57, 1, 55, 10, 37], [0, 22, 385, 396, 3, 57, 109, 117], [0, 22, 57, 3, 159, 279, 654, 655, 158, 274, 656, 657, 29, 18, 25, 27, 284, 658, 262, 269, 280, 659, 257, 267]], oh = { "P 1": 0, "P -1": 1, "P 1 2 1": 2, "P 1 21 1": 3, "C 1 2 1": 4, "P 1 m 1": 5, "P 1 c 1": 6, "C 1 m 1": 7, "C 1 c 1": 8, "P 1 2/m 1": 9, "P 1 21/m 1": 10, "C 1 2/m 1": 11, "P 1 2/c 1": 12, "P 1 21/c 1": 13, "C 1 2/c 1": 14, "P 2 2 2": 15, "P 2 2 21": 16, "P 21 21 2": 17, "P 21 21 21": 18, "C 2 2 21": 19, "C 2 2 2": 20, "F 2 2 2": 21, "I 2 2 2": 22, "I 21 21 21": 23, "P m m 2": 24, "P m c 21": 25, "P c c 2": 26, "P m a 2": 27, "P c a 21": 28, "P n c 2": 29, "P m n 21": 30, "P b a 2": 31, "P n a 21": 32, "P n n 2": 33, "C m m 2": 34, "C m c 21": 35, "C c c 2": 36, "A m m 2": 37, "A b m 2": 38, "A m a 2": 39, "A b a 2": 40, "F m m 2": 41, "F d d 2": 42, "I m m 2": 43, "I b a 2": 44, "I m a 2": 45, "P 2/m 2/m 2/m": 46, "P m m m": 46, "P 2/n 2/n 2/n": 47, "P n n n": 47, "P 2/c 2/c 2/m": 48, "P c c m": 48, "P 2/b 2/a 2/n": 49, "P b a n": 49, "P 21/m 2/m 2/a": 50, "P m m a": 50, "P 2/n 21/n 2/a": 51, "P n n a": 51, "P 2/m 2/n 21/a": 52, "P m n a": 52, "P 21/c 2/c 2/a": 53, "P c c a": 53, "P 21/b 21/a 2/m": 54, "P b a m": 54, "P 21/c 21/c 2/n": 55, "P c c n": 55, "P 2/b 21/c 21/m": 56, "P b c m": 56, "P 21/n 21/n 2/m": 57, "P n n m": 57, "P 21/m 21/m 2/n": 58, "P m m n": 58, "P 21/b 2/c 21/n": 59, "P b c n": 59, "P 21/b 21/c 21/a": 60, "P b c a": 60, "P 21/n 21/m 21/a": 61, "P n m a": 61, "C 2/m 2/c 21/m": 62, "C m c m": 62, "C 2/m 2/c 21/a": 63, "C m c a": 63, "C 2/m 2/m 2/m": 64, "C m m m": 64, "C 2/c 2/c 2/m": 65, "C c c m": 65, "C 2/m 2/m 2/a": 66, "C m m a": 66, "C 2/c 2/c 2/a": 67, "C c c a": 67, "F 2/m 2/m 2/m": 68, "F m m m": 68, "F 2/d 2/d 2/d": 69, "F d d d": 69, "I 2/m 2/m 2/m": 70, "I m m m": 70, "I 2/b 2/a 2/m": 71, "I b a m": 71, "I 21/b 21/c 21/a": 72, "I b c a": 72, "I 21/m 21/m 21/a": 73, "I m m a": 73, "P 4": 74, "P 41": 75, "P 42": 76, "P 43": 77, "I 4": 78, "I 41": 79, "P -4": 80, "I -4": 81, "P 4/m": 82, "P 42/m": 83, "P 4/n": 84, "P 42/n": 85, "I 4/m": 86, "I 41/a": 87, "P 4 2 2": 88, "P 4 21 2": 89, "P 41 2 2": 90, "P 41 21 2": 91, "P 42 2 2": 92, "P 42 21 2": 93, "P 43 2 2": 94, "P 43 21 2": 95, "I 4 2 2": 96, "I 41 2 2": 97, "P 4 m m": 98, "P 4 b m": 99, "P 42 c m": 100, "P 42 n m": 101, "P 4 c c": 102, "P 4 n c": 103, "P 42 m c": 104, "P 42 b c": 105, "I 4 m m": 106, "I 4 c m": 107, "I 41 m d": 108, "I 41 c d": 109, "P -4 2 m": 110, "P -4 2 c": 111, "P -4 21 m": 112, "P -4 21 c": 113, "P -4 m 2": 114, "P -4 c 2": 115, "P -4 b 2": 116, "P -4 n 2": 117, "I -4 m 2": 118, "I -4 c 2": 119, "I -4 2 m": 120, "I -4 2 d": 121, "P 4/m 2/m 2/m": 122, "P4/m m m": 122, "P 4/m 2/c 2/c": 123, "P4/m c c": 123, "P 4/n 2/b 2/m": 124, "P4/n b m": 124, "P 4/n 2/n 2/c": 125, "P4/n n c": 125, "P 4/m 21/b 2/m": 126, "P4/m b m": 126, "P 4/m 21/n 2/c": 127, "P4/m n c": 127, "P 4/n 21/m 2/m": 128, "P4/n m m": 128, "P 4/n 2/c 2/c": 129, "P4/n c c": 129, "P 42/m 2/m 2/c": 130, "P42/m m c": 130, "P 42/m 2/c 2/m": 131, "P42/m c m": 131, "P 42/n 2/b 2/c": 132, "P42/n b c": 132, "P 42/n 2/n 2/m": 133, "P42/n n m": 133, "P 42/m 21/b 2/c": 134, "P42/m b c": 134, "P 42/m 21/n 2/m": 135, "P42/m n m": 135, "P 42/n 21/m 2/c": 136, "P42/n m c": 136, "P 42/n 21/c 2/m": 137, "P42/n c m": 137, "I 4/m 2/m 2/m": 138, "I4/m m m": 138, "I 4/m 2/c 2/m": 139, "I4/m c m": 139, "I 41/a 2/m 2/d": 140, "I41/a m d": 140, "I 41/a 2/c 2/d": 141, "I41/a c d": 141, "P 3": 142, "P 31": 143, "P 32": 144, "H 3": 145, "R 3": 146, "P -3": 147, "H -3": 148, "R -3": 149, "P 3 1 2": 150, "P 3 2 1": 151, "P 31 1 2": 152, "P 31 2 1": 153, "P 32 1 2": 154, "P 32 2 1": 155, "H 3 2": 156, "R 3 2": 157, "P 3 m 1": 158, "P 3 1 m": 159, "P 3 c 1": 160, "P 3 1 c": 161, "H 3 m": 162, "R 3 m": 163, "H 3 c": 164, "R 3 c": 165, "P -3 1 2/m": 166, "P -3 1 m": 166, "P -3 1 2/c": 167, "P -3 1 c": 167, "P -3 2/m 1": 168, "P -3 m 1": 168, "P -3 2/c 1": 169, "P -3 c 1": 169, "H -3 2/m": 170, "H -3 m": 170, "R -3 2/m": 171, "R -3 m": 171, "H -3 2/c": 172, "H -3 c": 172, "R -3 2/c": 173, "R -3 c": 173, "P 6": 174, "P 61": 175, "P 65": 176, "P 62": 177, "P 64": 178, "P 63": 179, "P -6": 180, "P 6/m": 181, "P 63/m": 182, "P 6 2 2": 183, "P 61 2 2": 184, "P 65 2 2": 185, "P 62 2 2": 186, "P 64 2 2": 187, "P 63 2 2": 188, "P 6 m m": 189, "P 6 c c": 190, "P 63 c m": 191, "P 63 m c": 192, "P -6 m 2": 193, "P -6 c 2": 194, "P -6 2 m": 195, "P -6 2 c": 196, "P 6/m 2/m 2/m": 197, "P 6/m m m": 197, "P 6/m 2/c 2/c": 198, "P 6/m c c": 198, "P 63/m 2/c 2/m": 199, "P 63/m c m": 199, "P 63/m 2/m 2/c": 200, "P 63/m m c": 200, "P 2 3": 201, "F 2 3": 202, "I 2 3": 203, "P 21 3": 204, "I 21 3": 205, "P 2/m -3": 206, "P m -3": 206, "P 2/n -3": 207, "P n -3": 207, "F 2/m -3": 208, "F m -3": 208, "F 2/d -3": 209, "F d -3": 209, "I 2/m -3": 210, "I m -3": 210, "P 21/a -3": 211, "P a -3": 211, "I 21/a -3": 212, "I a -3": 212, "P 4 3 2": 213, "P 42 3 2": 214, "F 4 3 2": 215, "F 41 3 2": 216, "I 4 3 2": 217, "P 43 3 2": 218, "P 41 3 2": 219, "I 41 3 2": 220, "P -4 3 m": 221, "F -4 3 m": 222, "I -4 3 m": 223, "P -4 3 n": 224, "F -4 3 c": 225, "I -4 3 d": 226, "P 4/m -3 2/m": 227, "P m -3 m": 227, "P 4/n -3 2/n": 228, "P n -3 n": 228, "P 42/m -3 2/n": 229, "P m -3 n": 229, "P 42/n -3 2/m": 230, "P n -3 m": 230, "F 4/m -3 2/m": 231, "F m -3 m": 231, "F 4/m -3 2/c": 232, "F m -3 c": 232, "F 41/d -3 2/m": 233, "F d -3 m": 233, "F 41/d -3 2/c": 234, "F d -3 c": 234, "I 4/m -3 2/m": 235, "I m -3 m": 235, "I 41/a -3 2/d": 236, "I a -3 d": 236, "P 1 1 2": 237, "P 1 1 21": 238, "B 1 1 2": 239, "B 2": 239, "A 1 2 1": 240, "C 1 21 1": 241, "I 1 2 1": 242, "I 2": 242, "I 1 21 1": 243, "P 1 1 m": 244, "P 1 1 b": 245, "B 1 1 m": 246, "B 1 1 b": 247, "P 1 1 2/m": 248, "P 1 1 21/m": 249, "B 1 1 2/m": 250, "P 1 1 2/b": 251, "P 1 1 21/b": 252, "P 1 21/n 1": 253, "P 1 21/a 1": 254, "B 1 1 2/b": 255, "P 21 2 2": 256, "P 2 21 2": 257, "P 21 21 2 (a)": 258, "P 21 2 21": 259, "P 2 21 21": 260, "C 2 2 21a)": 261, "C 2 2 2a": 262, "F 2 2 2a": 263, "I 2 2 2a": 264, "P 21/m 21/m 2/n a": 265, "P 42 21 2a": 266, "I 2 3a": 267 };
function IJ(e) {
  if (e < 146) return e + 1;
  if (e === 146) return 1146;
  if (e < 149) return e + 1 - 1;
  if (e === 149) return 1148;
  if (e < 157) return e + 1 - 2;
  if (e === 157) return 1155;
  if (e < 163) return e + 1 - 3;
  if (e === 163) return 1160;
  if (e < 165) return e + 1 - 4;
  if (e === 165) return 1161;
  if (e < 171) return e + 1 - 5;
  if (e === 171) return 1166;
  if (e < 173) return e + 1 - 6;
  if (e === 173) return 1167;
  if (e < 237) return e + 1 - 7;
  if (e === 237) return 1003;
  if (e === 238) return 1004;
  if (e === 239) return 1005;
  if (e === 240) return 2005;
  if (e === 241) return 3005;
  if (e === 242) return 4005;
  if (e === 243) return 5005;
  if (e === 244) return 1006;
  if (e === 245) return 1007;
  if (e === 246) return 1008;
  if (e === 247) return 1009;
  if (e === 248) return 1010;
  if (e === 249) return 1011;
  if (e === 250) return 1012;
  if (e === 251) return 1013;
  if (e === 252) return 1014;
  if (e === 253) return 2014;
  if (e === 254) return 3014;
  if (e === 255) return 1015;
  if (e === 256) return 1017;
  if (e === 257) return 2017;
  if (e === 258) return 1018;
  if (e === 259) return 2018;
  if (e === 260) return 3018;
  if (e === 261) return 1020;
  if (e === 262) return 1021;
  if (e === 263) return 1022;
  if (e === 264) return 1023;
  if (e === 265) return 1059;
  if (e === 266) return 1094;
  if (e === 267) return 1197;
  throw new Error("unknown spacegroup index '".concat(e, "'"));
}
var tu, Fo, Gd, Ca, xF = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = Object.keys(oh); t < r.length; t++) {
    var n = r[t];
    e[oh[n]] = n;
  }
  return e;
}(), TJ = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = Object.keys(oh); t < r.length; t++) {
    var n = r[t], a = oh[n];
    e[a] = IJ(a);
  }
  return e;
}();
function C9(e) {
  var t = typeof e == "number" ? function(r) {
    switch (r) {
      case 1146:
        return 146;
      case 1148:
        return 149;
      case 1155:
        return 157;
      case 1160:
        return 163;
      case 1161:
        return 165;
      case 1166:
        return 171;
      case 1167:
        return 173;
      case 1003:
        return 237;
      case 1004:
        return 238;
      case 1005:
        return 239;
      case 2005:
        return 240;
      case 3005:
        return 241;
      case 4005:
        return 242;
      case 5005:
        return 243;
      case 1006:
        return 244;
      case 1007:
        return 245;
      case 1008:
        return 246;
      case 1009:
        return 247;
      case 1010:
        return 248;
      case 1011:
        return 249;
      case 1012:
        return 250;
      case 1013:
        return 251;
      case 1014:
        return 252;
      case 2014:
        return 253;
      case 3014:
        return 254;
      case 1015:
        return 255;
      case 1017:
        return 256;
      case 2017:
        return 257;
      case 1018:
        return 258;
      case 2018:
        return 259;
      case 3018:
        return 260;
      case 1020:
        return 261;
      case 1021:
        return 262;
      case 1022:
        return 263;
      case 1023:
        return 264;
      case 1059:
        return 265;
      case 1094:
        return 266;
      case 1197:
        return 267;
    }
    var n = 0;
    return r > 146 && ++n, r > 148 && ++n, r > 155 && ++n, r > 160 && ++n, r > 161 && ++n, r > 166 && ++n, r > 167 && ++n, r - 1 + n;
  }(e) : oh[e];
  return t === void 0 || xF[t] === void 0 ? -1 : t;
}
function Yc() {
  return Yc.empty();
}
function T4(e, t, r, n) {
  n = e[t], e[t] = e[r], e[r] = n;
}
function NJ(e, t) {
  return (e = Math.abs(e)) > (t = Math.abs(t)) ? (t /= e, e * Math.sqrt(1 + t * t)) : t > 0 ? (e /= t, t * Math.sqrt(1 + e * e)) : 0;
}
(function(e) {
  function t(r, n, a) {
    var i = C9(r);
    if (i < 0) return console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero;
    var o = n[0] * n[1] * n[2], s = a[0], u = a[1], c = a[2], l = n[0], d = n[1], f = n[2], m = Math.cos(u), h = (Math.cos(s) - Math.cos(u) * Math.cos(c)) / Math.sin(c), p = Math.sqrt(1 - m * m - h * h), g = [l, 0, 0], v = [Math.cos(c) * d, Math.sin(c) * d, 0], y = [m * f, h * f, p * f], _ = Ee.ofRows([[g[0], v[0], y[0], 0], [0, v[1], y[1], 0], [0, 0, y[2], 0], [0, 0, 0, 1]]);
    return { index: i, size: n, volume: o, anglesInRadians: a, toFractional: Ee.invert(Ee.zero(), _), fromFractional: _ };
  }
  e.Zero = t("P 1", D.create(1, 1, 1), D.create(Math.PI / 2, Math.PI / 2, Math.PI / 2)), e.isZero = function(r) {
    return !r || r.index === 0 && r.size[0] === 1 && r.size[1] === 1 && r.size[1] === 1;
  }, e.create = t, e.createMaterial = function(r, n, a, i, o, s) {
    var u = C9(r);
    return u < 0 ? (console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero) : { index: u, size: n, volume: i, anglesInRadians: a, toFractional: o, fromFractional: s };
  };
})(tu || (tu = {})), function(e) {
  function t(f) {
    var m = MJ[f.index].map(function(h) {
      return g = I4[(p = DJ[h])[0]], v = I4[p[1]], y = I4[p[2]], Ee.ofRows([g, v, y, [0, 0, 0, 1]]);
      var p, g, v, y;
    });
    return { name: xF[f.index], num: TJ[f.index], cell: f, operators: m };
  }
  e.ZeroP1 = t(tu.Zero), e.create = t;
  var r = D(), n = Ee();
  function a(f, m, h, p, g, v) {
    return D.set(r, h, p, g), Ee.fromTranslation(n, r), Ee.mul(v, Ee.mul(v, Ee.mul(v, f.cell.fromFractional, n), f.operators[m]), f.cell.toFractional);
  }
  e.setOperatorMatrix = a, e.getSymmetryOperator = function(f, m, h, p, g) {
    var v = a(f, m, h, p, g, Ee.zero());
    return Mn.create("".concat(m + 1, "_").concat(5 + h).concat(5 + p).concat(5 + g), v, { hkl: D.create(h, p, g), spgrOp: m });
  };
  var i = D(), o = D(), s = D(), u = D();
  function c(f, m, h) {
    var p = [];
    if (f > 0 ? p.push("+X") : f < 0 && p.push("-X"), m > 0 ? p.push("+Y") : m < 0 && p.push("-Y"), h > 0 ? p.push("+Z") : h < 0 && p.push("-Z"), p.length === 1) return p[0].charAt(0) === "+" ? p[0].substr(1) : p[0];
    if (p.length === 2) {
      var g = p[0].charAt(0), v = p[1].charAt(0);
      if (g === "+") return "".concat(p[0].substr(1)).concat(p[1]);
      if (v === "+") return "".concat(p[1].substr(1)).concat(p[0]);
    }
    throw new Error("unknown rotation '".concat(p, "', ").concat(f, " ").concat(m, " ").concat(h));
  }
  function l(f) {
    switch (f) {
      case 0.5:
        return "1/2";
      case 1 / 4:
        return "1/4";
      case 3 / 4:
        return "3/4";
      case 1 / 3:
        return "1/3";
      case 2 / 3:
        return "2/3";
      case 1 / 6:
        return "1/6";
      case 5 / 6:
        return "5/6";
    }
    return "";
  }
  function d(f, m) {
    return m === "" ? f : f.length > 2 ? "".concat(f, "+").concat(m) : f.charAt(0) === "-" ? "".concat(m).concat(f) : "".concat(m, "+").concat(f);
  }
  e.getSymmetryOperatorRef = function(f, m, h, p, g, v) {
    var y = Ee.zero();
    D.set(r, h, p, g), D.floor(i, v), Ee.copy(y, f.operators[m]), D.floor(o, D.transformMat4(o, v, y)), Ee.getTranslation(u, y), D.sub(u, u, o), D.add(u, u, i), D.add(u, u, r), Ee.setTranslation(y, u), Ee.mul(y, f.cell.fromFractional, y), Ee.mul(y, y, f.cell.toFractional), D.sub(s, o, i);
    var _ = h - s[0], S = p - s[1], b = g - s[2];
    return Mn.create("".concat(m + 1, "_").concat(5 + _).concat(5 + S).concat(5 + b), y, { hkl: D.create(_, S, b), spgrOp: m });
  }, e.getOperatorXyz = function(f) {
    return [d(c(f[0], f[4], f[8]), l(f[12])), d(c(f[1], f[5], f[9]), l(f[13])), d(c(f[2], f[6], f[10]), l(f[14]))].join(",");
  };
}(Fo || (Fo = {})), function(e) {
  e.add = function(t, r, n) {
    t.squaredDistances[t.count] = n, t.indices[t.count++] = r;
  }, e.reset = function(t) {
    t.count = 0;
  }, e.create = function() {
    return { count: 0, indices: [], squaredDistances: [] };
  }, e.copy = function(t, r) {
    for (var n = 0; n < r.count; ++n) t.indices[n] = r.indices[n], t.squaredDistances[n] = r.squaredDistances[n];
    return t.count = r.count, t;
  };
}(Gd || (Gd = {})), function(e) {
  function t() {
    return { origin: D(), dirA: D(), dirB: D(), dirC: D() };
  }
  function r(o, s) {
    return D.copy(o.origin, s.origin), D.copy(o.dirA, s.dirA), D.copy(o.dirB, s.dirB), D.copy(o.dirC, s.dirC), o;
  }
  function n(o, s) {
    return D.set(o, 2 * D.magnitude(s.dirA), 2 * D.magnitude(s.dirB), 2 * D.magnitude(s.dirC));
  }
  e.create = function(o, s, u, c) {
    return { origin: o, dirA: s, dirB: u, dirC: c };
  }, e.empty = t, e.copy = r, e.clone = function(o) {
    return r(t(), o);
  }, e.size = n;
  var a = D();
  e.volume = function(o) {
    return n(a, o), a[0] * a[1] * a[2];
  }, e.normalize = function(o, s) {
    return D.copy(o.origin, s.origin), D.normalize(o.dirA, s.dirA), D.normalize(o.dirB, s.dirB), D.normalize(o.dirC, s.dirC), o;
  };
  var i = ka();
  e.transform = function(o, s, u) {
    D.transformMat4(o.origin, s.origin, u);
    var c = ka.directionTransform(i, u);
    return D.transformMat3(o.dirA, s.dirA, c), D.transformMat3(o.dirB, s.dirB, c), D.transformMat3(o.dirC, s.dirC, c), o;
  }, e.scale = function(o, s, u) {
    return D.scale(o.dirA, s.dirA, u), D.scale(o.dirB, s.dirB, u), D.scale(o.dirC, s.dirC, u), o;
  };
}(Yc || (Yc = {})), function(e) {
  e.create = function(t, r, n) {
    n === void 0 && (n = Float32Array);
    var a = t * r;
    return { data: new n(a), size: a, cols: t, rows: r };
  }, e.get = function(t, r, n) {
    return t.data[t.rows * n + r];
  }, e.set = function(t, r, n, a) {
    return t.data[t.rows * n + r] = a, t;
  }, e.add = function(t, r, n, a) {
    return t.data[t.rows * n + r] += a, t;
  }, e.makeZero = function(t) {
    return t.data.fill(0), t;
  }, e.clone = function(t) {
    return { data: t.data.slice(), size: t.size, cols: t.cols, rows: t.rows };
  }, e.fromArray = function(t, r, n) {
    return { data: t, size: r * n, cols: r, rows: n };
  }, e.transpose = function(t, r) {
    if (t.cols !== r.rows || t.rows !== r.cols) throw new Error("transpose: matrix dimensions incompatible");
    if (t.data === r.data) throw new Error("transpose: matrices share memory");
    for (var n = r.rows, a = r.cols, i = r.data, o = t.data, s = 0, u = 0, c = 0; s < n; c += 1, u += a, ++s) for (var l = c, d = 0; d < a; l += n, d++) o[l] = i[u + d];
    return t;
  }, e.multiplyABt = function(t, r, n) {
    for (var a = r.cols, i = r.rows, o = n.rows, s = r.data, u = n.data, c = t.data, l = 0, d = 0, f = 0; l < i; d += a, l++) for (var m = 0, h = 0; h < o; f++, h++) {
      for (var p = 0, g = d, v = 0; v < a; g++, m++, v++) p += s[g] * u[m];
      c[f] = p;
    }
    return t;
  }, e.meanRows = function(t) {
    for (var r = t.rows, n = t.cols, a = t.data, i = new Array(n), o = 0; o < n; ++o) i[o] = 0;
    for (var s = 0, u = 0; s < r; ++s) for (o = 0; o < n; ++o, ++u) i[o] += a[u];
    for (o = 0; o < n; ++o) i[o] /= r;
    return i;
  }, e.subRows = function(t, r) {
    for (var n = t.rows, a = t.cols, i = t.data, o = 0, s = 0; o < n; ++o) for (var u = 0; u < a; ++u, ++s) i[s] -= r[u];
    return t;
  };
}(Ca || (Ca = {}));
var Od, PJ = 1192092896e-16, BJ = 1e-37;
function OJ(e, t, r, n) {
  var a = 0, i = 0, o = e.rows, s = e.cols, u = o, c = s;
  u < c && (a = 1, i = u, u = c, c = i);
  var l = Ca.create(u, u), d = Ca.create(1, c), f = Ca.create(c, c);
  if (a === 0) Ca.transpose(l, e);
  else {
    for (i = 0; i < s * o; i++) l.data[i] = e.data[i];
    for (; i < c * u; i++) l.data[i] = 0;
  }
  if (function(m, h, p, g, v, y, _, S) {
    for (var b = 2 * PJ, x = BJ, A = 0, w = 0, C = 0, M = 0, T = Math.max(y, 30), N = 0, I = 0, P = 0, O = 0, F = 0, R = 0, G = 0, L = 0, q = 0, K = 0, X = 0, H = 0, W = 0, ee = 0, $ = 0, te = 0, re = 0, ie = 4660, oe = 0, se = 0, he = 0, ge = new Float64Array(_ << 3); A < _; A++) {
      for (C = 0, X = 0; C < y; C++) X += (L = m[A * h + C]) * L;
      if (ge[A] = X, g) {
        for (C = 0; C < _; C++) g[A * v + C] = 0;
        g[A * v + A] = 1;
      }
    }
    for (; M < T; M++) {
      for (F = 0, A = 0; A < _ - 1; A++) for (w = A + 1; w < _; w++) {
        for (N = A * h | 0, I = w * h | 0, $ = ge[A], te = 0, re = ge[w], C = 2, te += m[N] * m[I], te += m[N + 1] * m[I + 1]; C < y; C++) te += m[N + C] * m[I + C];
        if (!(Math.abs(te) <= b * Math.sqrt($ * re))) {
          for (W = NJ(te *= 2, H = $ - re), H < 0 ? (ee = 0.5 * (W - H), R = te / (W * (G = Math.sqrt(ee / W)) * 2)) : G = te / (W * (R = Math.sqrt((W + H) / (2 * W))) * 2), $ = 0, re = 0, C = 2, q = R * m[N] + G * m[I], K = -G * m[N] + R * m[I], m[N] = q, m[I] = K, $ += q * q, re += K * K, q = R * m[N + 1] + G * m[I + 1], K = -G * m[N + 1] + R * m[I + 1], m[N + 1] = q, m[I + 1] = K, $ += q * q, re += K * K; C < y; C++) q = R * m[N + C] + G * m[I + C], K = -G * m[N + C] + R * m[I + C], m[N + C] = q, m[I + C] = K, $ += q * q, re += K * K;
          if (ge[A] = $, ge[w] = re, F = 1, g) for (O = w * v | 0, C = 2, q = R * g[P = A * v | 0] + G * g[O], K = -G * g[P] + R * g[O], g[P] = q, g[O] = K, q = R * g[P + 1] + G * g[O + 1], K = -G * g[P + 1] + R * g[O + 1], g[P + 1] = q, g[O + 1] = K; C < _; C++) q = R * g[P + C] + G * g[O + C], K = -G * g[P + C] + R * g[O + C], g[P + C] = q, g[O + C] = K;
        }
      }
      if (F === 0) break;
    }
    for (A = 0; A < _; A++) {
      for (C = 0, X = 0; C < y; C++) X += (L = m[A * h + C]) * L;
      ge[A] = Math.sqrt(X);
    }
    for (A = 0; A < _ - 1; A++) {
      for (w = A, C = A + 1; C < _; C++) ge[w] < ge[C] && (w = C);
      if (A !== w && (T4(ge, A, w, X), g)) {
        for (C = 0; C < y; C++) T4(m, A * h + C, w * h + C, L);
        for (C = 0; C < _; C++) T4(g, A * v + C, w * v + C, L);
      }
    }
    for (A = 0; A < _; A++) p[A] = ge[A];
    if (g) for (A = 0; A < S; A++) {
      for (X = A < _ ? ge[A] : 0; X <= x; ) {
        for (se = 1 / y, C = 0; C < y; C++) oe = 256 & (ie = 214013 * ie + 2531011) >> 16 ? se : -se, m[A * h + C] = oe;
        for (M = 0; M < 2; M++) for (w = 0; w < A; w++) {
          for (X = 0, C = 0; C < y; C++) X += m[A * h + C] * m[w * h + C];
          for (he = 0, C = 0; C < y; C++) L = m[A * h + C] - X * m[w * h + C], m[A * h + C] = L, he += Math.abs(L);
          for (he = he ? 1 / he : 0, C = 0; C < y; C++) m[A * h + C] *= he;
        }
        for (X = 0, C = 0; C < y; C++) X += (L = m[A * h + C]) * L;
        X = Math.sqrt(X);
      }
      for (G = 1 / X, C = 0; C < y; C++) m[A * h + C] *= G;
    }
  }(l.data, u, d.data, f.data, c, u, c, u), t) {
    for (i = 0; i < c; i++) t.data[i] = d.data[i];
    for (; i < s; i++) t.data[i] = 0;
  }
  a === 0 ? (r && Ca.transpose(r, l), n && Ca.transpose(n, f)) : (r && Ca.transpose(r, f), n && Ca.transpose(n, l));
}
function Ve() {
  return Ve.zero();
}
function on() {
  return on.zero();
}
function Jf(e, t, r) {
  return new FJ(e, t, r);
}
(function(e) {
  function t(s) {
    if (s.length === 3) return Yc.create(D.fromArray(D(), s, 0), D.create(1, 0, 0), D.create(0, 1, 0), D.create(0, 1, 0));
    var u = Ca.fromArray(s, 3, s.length / 3), c = u.rows, l = c / 3, d = Ca.create(3, 3), f = Ca.create(1, 3), m = Ca.create(3, 3), h = Ca.create(3, 3), p = Ca.meanRows(u), g = Ca.subRows(Ca.clone(u), p), v = Ca.transpose(Ca.create(c, 3), g);
    Ca.multiplyABt(d, v, v), OJ(d, f, m, h);
    var y = D.create(p[0], p[1], p[2]), _ = D.create(m.data[0], m.data[3], m.data[6]), S = D.create(m.data[1], m.data[4], m.data[7]), b = D.create(m.data[2], m.data[5], m.data[8]);
    return D.scale(_, _, Math.sqrt(f.data[0] / l)), D.scale(S, S, Math.sqrt(f.data[1] / l)), D.scale(b, b, Math.sqrt(f.data[2] / l)), Yc.create(y, _, S, b);
  }
  e.ofPositions = function(s) {
    var u = t(s);
    return { momentsAxes: u, boxAxes: o(s, u) };
  }, e.calculateMomentsAxes = t;
  var r = D(), n = D(), a = D(), i = D();
  function o(s, u) {
    if (s.length === 3) return Yc.clone(u);
    for (var c = -1 / 0, l = -1 / 0, d = -1 / 0, f = -1 / 0, m = -1 / 0, h = -1 / 0, p = D(), g = D(), v = u.origin, y = D.normalize(n, u.dirA), _ = D.normalize(a, u.dirB), S = D.normalize(i, u.dirC), b = 0, x = s.length; b < x; b += 3) {
      D.projectPointOnVector(p, D.fromArray(p, s, b), y, v);
      var A = D.dot(y, D.normalize(g, D.sub(g, p, v))), w = D.distance(p, v);
      A > 0 ? w > c && (c = w) : w > l && (l = w), D.projectPointOnVector(p, D.fromArray(p, s, b), _, v);
      var C = D.dot(_, D.normalize(g, D.sub(g, p, v))), M = D.distance(p, v);
      C > 0 ? M > d && (d = M) : M > f && (f = M), D.projectPointOnVector(p, D.fromArray(p, s, b), S, v);
      var T = D.dot(S, D.normalize(g, D.sub(g, p, v))), N = D.distance(p, v);
      T > 0 ? N > m && (m = N) : N > h && (h = N);
    }
    var I = D.setMagnitude(D(), y, (c + l) / 2), P = D.setMagnitude(D(), _, (d + f) / 2), O = D.setMagnitude(D(), S, (m + h) / 2), F = D(), R = function(G, L, q) {
      D.copy(r, v), D.scaleAndAdd(r, r, y, G), D.scaleAndAdd(r, r, _, L), D.scaleAndAdd(r, r, S, q), D.add(F, F, r);
    };
    return R(c, d, m), R(c, d, -h), R(c, -f, -h), R(c, -f, m), R(-l, -f, -h), R(-l, -f, m), R(-l, d, m), R(-l, d, -h), D.scale(F, F, 1 / 8), Yc.create(F, I, P, O);
  }
  e.calculateBoxAxes = o;
})(Od || (Od = {})), function(e) {
  function t(s) {
    return s.extrema !== void 0;
  }
  function r(s, u) {
    return { center: s, radius: u };
  }
  function n(s, u) {
    var c;
    return s.extrema !== void 0 ? (s.extrema.length = 0, (c = s.extrema).push.apply(c, u)) : s.extrema = u, s;
  }
  e.hasExtrema = t, e.create = r, e.zero = function() {
    return { center: D(), radius: 0 };
  }, e.clone = function(s) {
    var u = r(D.clone(s.center), s.radius);
    return t(s) && (u.extrema = s.extrema.map(function(c) {
      return D.clone(c);
    })), u;
  }, e.set = function(s, u, c) {
    return D.copy(s.center, u), s.radius = c, s;
  }, e.copy = function(s, u) {
    return D.copy(s.center, u.center), s.radius = u.radius, t(u) && n(s, u.extrema.map(function(c) {
      return D.clone(c);
    })), s;
  }, e.setExtrema = n, e.computeBounding = function(s) {
    for (var u = s.x, c = s.y, l = s.z, d = s.indices, f = 0, m = 0, h = 0, p = 0, g = We.size(d), v = 0; v < g; v++)
      f += u[y = We.getAt(d, v)], m += c[y], h += l[y];
    for (g > 0 && (f /= g, m /= g, h /= g), v = 0; v < g; v++) {
      var y, _ = u[y = We.getAt(d, v)] - f, S = c[y] - m, b = l[y] - h, x = _ * _ + S * S + b * b;
      x > p && (p = x);
    }
    return { center: D.create(f, m, h), radius: Math.sqrt(p) };
  }, e.transform = function(s, u, c) {
    return D.transformMat4(s.center, u.center, c), s.radius = u.radius * Ee.getMaxScaleOnAxis(c), t(u) && n(s, u.extrema.map(function(l) {
      return D.transformMat4(D(), l, c);
    })), s;
  }, e.translate = function(s, u, c) {
    return D.add(s.center, u.center, c), t(u) && n(s, u.extrema.map(function(l) {
      return D.add(D(), l, c);
    })), s;
  }, e.toArray = function(s, u, c) {
    D.toArray(s.center, u, c), u[c + 3] = s.radius;
  }, e.fromArray = function(s, u, c) {
    return D.fromArray(s.center, u, c), s.radius = u[c + 3], s;
  }, e.fromBox3D = function(s, u) {
    return D.scale(s.center, D.add(s.center, u.max, u.min), 0.5), s.radius = D.distance(s.center, u.max), e.setExtrema(s, [D.create(u.min[0], u.min[1], u.min[2]), D.create(u.max[0], u.max[1], u.max[2]), D.create(u.max[0], u.min[1], u.min[2]), D.create(u.min[0], u.max[1], u.max[2]), D.create(u.min[0], u.min[1], u.max[2]), D.create(u.max[0], u.min[1], u.max[2]), D.create(u.max[0], u.max[1], u.min[2]), D.create(u.min[0], u.max[1], u.min[2])]), s;
  }, e.fromAxes3D = function(s, u) {
    return D.copy(s.center, u.origin), s.radius = Math.max(D.magnitude(u.dirA), D.magnitude(u.dirB), D.magnitude(u.dirC)), s;
  };
  var a = D();
  e.fromDimensionsAndTransform = function(s, u, c) {
    var l = u[0], d = u[1], f = u[2], m = D.create(0, 0, 0);
    D.transformMat4(m, m, c);
    var h = D.create(l, d, f);
    D.transformMat4(h, h, c);
    var p = D.create(l, 0, 0);
    D.transformMat4(p, p, c);
    var g = D.create(0, d, f);
    D.transformMat4(g, g, c);
    var v = D.create(0, 0, f);
    D.transformMat4(v, v, c);
    var y = D.create(l, 0, f);
    D.transformMat4(y, y, c);
    var _ = D.create(l, d, 0);
    D.transformMat4(_, _, c);
    var S = D.create(0, d, 0);
    D.transformMat4(S, S, c), D.add(a, m, h), D.scale(a, a, 0.5);
    var b = Math.max(D.distance(m, h), D.distance(p, g));
    return e.set(s, a, b / 2), e.setExtrema(s, [m, h, p, g, v, y, _, S]), s;
  };
  var i = D();
  e.addVec3 = function(s, u, c) {
    return D.distance(u.center, c) < u.radius ? e.copy(s, u) : (D.sub(i, u.center, c), D.sub(i, u.center, i), D.setMagnitude(i, i, u.radius), D.scale(s.center, D.add(i, i, c), 0.5), s.radius = D.distance(s.center, c), s);
  }, e.expandBySphere = function(s, u, c) {
    return D.copy(s.center, u.center), s.radius = Math.max(u.radius, D.distance(u.center, c.center) + c.radius), t(u) && t(c) && n(s, nt(nt([], u.extrema.map(function(l) {
      return D.clone(l);
    }), !0), c.extrema.map(function(l) {
      return D.clone(l);
    }), !0)), s;
  };
  var o = D();
  e.expand = function(s, u, c) {
    var l, d;
    if (D.copy(s.center, u.center), s.radius = u.radius + c, u.radius < 1e-12 || ((d = (l = u.extrema) === null || l === void 0 ? void 0 : l.length) !== null && d !== void 0 ? d : 0) <= 1) return s.extrema = void 0, s;
    if (t(u)) {
      for (var f = new Float32Array(3 * u.extrema.length), m = 0; m < u.extrema.length; m++) D.toArray(u.extrema[m], f, 3 * m);
      var h = Od.calculateMomentsAxes(f);
      Yc.scale(h, Yc.normalize(h, h), c), n(s, u.extrema.map(function(p) {
        D.normalize(o, D.sub(o, p, u.center));
        var g = D.clone(p), v = D.dot(o, h.dirA) < 0 ? -1 : 1;
        D.scaleAndAdd(g, g, h.dirA, v);
        var y = D.dot(o, h.dirB) < 0 ? -1 : 1;
        D.scaleAndAdd(g, g, h.dirB, y);
        var _ = D.dot(o, h.dirC) < 0 ? -1 : 1;
        return D.scaleAndAdd(g, g, h.dirC, _), D.distance(s.center, g) > s.radius && (u.extrema.length >= 14 && D.normalize(o, D.sub(o, g, u.center)), D.scaleAndAdd(g, s.center, o, s.radius)), g;
      }));
    }
    return s;
  }, e.exactEquals = function(s, u) {
    return s.radius === u.radius && D.exactEquals(s.center, u.center);
  }, e.equals = function(s, u) {
    var c = s.radius, l = u.radius;
    return Math.abs(c - l) <= Cn * Math.max(1, Math.abs(c), Math.abs(l)) && D.equals(s.center, u.center);
  }, e.includes = function(s, u) {
    if (t(u)) {
      for (var c = 0, l = u.extrema; c < l.length; c++) {
        var d = l[c];
        if (D.distance(s.center, d) > s.radius) return !1;
      }
      return !0;
    }
    return D.distance(s.center, u.center) + u.radius <= s.radius;
  }, e.overlaps = function(s, u) {
    return D.distance(s.center, u.center) <= s.radius + u.radius;
  }, e.distance = function(s, u) {
    return D.distance(s.center, u.center) - s.radius + u.radius;
  };
}(Ve || (Ve = {})), function(e) {
  function t() {
    return { min: D(), max: D() };
  }
  function r(c, l) {
    return D.copy(c.min, l.min), D.copy(c.max, l.max), c;
  }
  function n(c, l) {
    e.setEmpty(c);
    for (var d = 0, f = l.length; d < f; d++) e.add(c, l[d]);
    return c;
  }
  function a(c, l) {
    return D.sub(c, l.max, l.min);
  }
  e.create = function(c, l) {
    return { min: c, max: l };
  }, e.zero = t, e.copy = r, e.clone = function(c) {
    return r(t(), c);
  }, e.fromSphere3D = function(c, l) {
    if (Ve.hasExtrema(l) && l.extrema.length >= 14) return n(c, l.extrema);
    var d = D.create(l.radius, l.radius, l.radius);
    return D.sub(c.min, l.center, d), D.add(c.max, l.center, d), c;
  }, e.fromVec3Array = n, e.computeBounding = function(c) {
    for (var l = D.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), d = D.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), f = c.x, m = c.y, h = c.z, p = c.indices, g = 0, v = We.size(p); g < v; g++) {
      var y = We.getAt(p, g);
      l[0] = Math.min(f[y], l[0]), l[1] = Math.min(m[y], l[1]), l[2] = Math.min(h[y], l[2]), d[0] = Math.max(f[y], d[0]), d[1] = Math.max(m[y], d[1]), d[2] = Math.max(h[y], d[2]);
    }
    return { min: l, max: d };
  }, e.size = a;
  var i = D();
  function o(c) {
    return D.set(c.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), D.set(c.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), c;
  }
  function s(c, l) {
    return D.min(c.min, c.min, l), D.max(c.max, c.max, l), c;
  }
  e.volume = function(c) {
    return a(i, c), i[0] * i[1] * i[2];
  }, e.setEmpty = o, e.add = s, e.expand = function(c, l, d) {
    return D.sub(c.min, l.min, d), D.add(c.max, l.max, d), c;
  }, e.scale = function(c, l, d) {
    return D.scale(c.min, l.min, d), D.scale(c.max, l.max, d), c;
  };
  var u = D();
  e.transform = function(c, l, d) {
    var f = l.min, m = f[0], h = f[1], p = f[2], g = l.max, v = g[0], y = g[1], _ = g[2];
    return o(c), s(c, D.transformMat4(u, D.set(u, m, h, p), d)), s(c, D.transformMat4(u, D.set(u, m, h, _), d)), s(c, D.transformMat4(u, D.set(u, m, y, p), d)), s(c, D.transformMat4(u, D.set(u, m, y, _), d)), s(c, D.transformMat4(u, D.set(u, v, h, p), d)), s(c, D.transformMat4(u, D.set(u, v, h, _), d)), s(c, D.transformMat4(u, D.set(u, v, y, p), d)), s(c, D.transformMat4(u, D.set(u, v, y, _), d)), c;
  }, e.containsVec3 = function(c, l) {
    return !(l[0] < c.min[0] || l[0] > c.max[0] || l[1] < c.min[1] || l[1] > c.max[1] || l[2] < c.min[2] || l[2] > c.max[2]);
  };
}(on || (on = {}));
var lt, FJ = function() {
  function e(t, r, n) {
    var a = function(i, o, s) {
      var u, c, l = on.expand(on(), o.box, D.create(0.5, 0.5, 0.5)), d = i.indices, f = on.size(D.zero(), l), m = We.size(d), h = typeof s == "number" ? s : 32, p = Array.isArray(s) && s;
      if (p) c = [Math.ceil(f[0] / p[0]), Math.ceil(f[1] / p[1]), Math.ceil(f[2] / p[2])], u = p;
      else if (m > 0) {
        var g = Math.ceil(m / h), v = Math.pow(g / (f[0] * f[1] * f[2]), 1 / 3);
        c = [Math.ceil(f[0] * v), Math.ceil(f[1] * v), Math.ceil(f[2] * v)], u = [f[0] / c[0], f[1] / c[1], f[2] / c[2]];
      } else u = f, c = [1, 1, 1];
      var y = { x: i.x, y: i.y, z: i.z, indices: d, radius: i.radius }, _ = { size: c, data: y, expandedBox: l, boundingBox: o.box, boundingSphere: o.sphere, elementCount: m, delta: u };
      return function(S) {
        for (var b = S.expandedBox, x = S.size, A = x[0], w = x[1], C = x[2], M = S.data, T = M.x, N = M.y, I = M.z, P = M.radius, O = M.indices, F = S.elementCount, R = S.delta, G = A * w * C, L = b.min, q = L[0], K = L[1], X = L[2], H = 0, W = 0, ee = new Uint32Array(G), $ = new Int32Array(F), te = 0; te < F; te++) {
          var re = We.getAt(O, te), ie = (Math.floor((T[re] - q) / R[0]) * w + Math.floor((N[re] - K) / R[1])) * C + Math.floor((I[re] - X) / R[2]);
          (ee[ie] += 1) === 1 && (W += 1), $[te] = ie;
        }
        if (P) for (te = 0; te < F; te++)
          P[re = We.getAt(O, te)] > H && (H = P[re]);
        for (var oe = new Int32Array(W), se = (re = 0, 0); re < G; re++) {
          var he = ee[re];
          he > 0 && (ee[re] = se + 1, oe[se] = he, se += 1);
        }
        var ge = new Uint32Array(W);
        for (re = 1; re < W; ++re) ge[re] += ge[re - 1] + oe[re - 1];
        var De = new Int32Array(W), ae = new Int32Array(F);
        for (re = 0; re < F; re++) {
          var ce = ee[$[re]];
          if (ce > 0) {
            var _e = ce - 1;
            ae[ge[_e] + De[_e]] = re, De[_e] += 1;
          }
        }
        return { size: S.size, bucketArray: ae, bucketCounts: oe, bucketOffset: ge, grid: ee, delta: R, min: S.expandedBox.min, data: S.data, maxRadius: H, expandedBox: S.expandedBox, boundingBox: S.boundingBox, boundingSphere: S.boundingSphere };
      }(_);
    }(t, r, n);
    this.ctx = { grid: a, x: 0.1, y: 0.1, z: 0.1, radius: 0.1, isCheck: !1 }, this.boundary = { box: a.boundingBox, sphere: a.boundingSphere }, this.buckets = { offset: a.bucketOffset, count: a.bucketCounts, array: a.bucketArray }, this.result = Gd.create();
  }
  return e.prototype.find = function(t, r, n, a, i) {
    this.ctx.x = t, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = a, this.ctx.isCheck = !1;
    var o = i ?? this.result;
    return E9(this.ctx, o), o;
  }, e.prototype.check = function(t, r, n, a) {
    return this.ctx.x = t, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = a, this.ctx.isCheck = !0, E9(this.ctx, this.result);
  }, e;
}();
function E9(e, t) {
  var r = e.grid, n = r.min, a = r.size, i = a[0], o = a[1], s = a[2], u = r.bucketOffset, c = r.bucketCounts, l = r.bucketArray, d = r.grid, f = r.data, m = f.x, h = f.y, p = f.z, g = f.indices, v = f.radius, y = r.delta, _ = r.maxRadius, S = e.radius, b = e.isCheck, x = e.x, A = e.y, w = e.z, C = S + _, M = C * C;
  Gd.reset(t);
  var T = Math.max(0, Math.floor((x - C - n[0]) / y[0])), N = Math.max(0, Math.floor((A - C - n[1]) / y[1])), I = Math.max(0, Math.floor((w - C - n[2]) / y[2])), P = Math.min(i - 1, Math.floor((x + C - n[0]) / y[0])), O = Math.min(o - 1, Math.floor((A + C - n[1]) / y[1])), F = Math.min(s - 1, Math.floor((w + C - n[2]) / y[2]));
  if (T > P || N > O || I > F) return !1;
  for (var R = T; R <= P; R++) for (var G = N; G <= O; G++) for (var L = I; L <= F; L++) {
    var q = d[(R * o + G) * s + L];
    if (q !== 0) for (var K = q - 1, X = u[K], H = X + c[K], W = X; W < H; W++) {
      var ee = We.getAt(g, l[W]), $ = m[ee] - x, te = h[ee] - A, re = p[ee] - w, ie = $ * $ + te * te + re * re;
      if (ie <= M) {
        if (_ > 0 && Math.sqrt(ie) - v[ee] > S) continue;
        if (b) return !0;
        Gd.add(t, l[W], ie);
      }
    }
  }
  return t.count > 0;
}
(function(e) {
  function t(a, i, o) {
    return { kind: "element-location", structure: a, unit: i, element: o || 0 };
  }
  e.create = t, e.clone = function(a) {
    return t(a.structure, a.unit, a.element);
  }, e.set = function(a, i, o, s) {
    return i && (a.structure = i), o && (a.unit = o), s !== void 0 && (a.element = s), a;
  }, e.copy = function(a, i) {
    return a.unit = i.unit, a.element = i.element, a;
  }, e.is = function(a) {
    return !!a && a.kind === "element-location";
  }, e.areEqual = function(a, i) {
    return a.unit === i.unit && a.element === i.element;
  };
  var r = D.zero(), n = D.zero();
  e.distance = function(a, i) {
    return a.unit.conformation.position(a.element, r), i.unit.conformation.position(i.element, n), D.distance(r, n);
  }, e.residueIndex = function(a) {
    return a.unit.model.atomicHierarchy.residueAtomSegments.index[a.element];
  }, e.chainIndex = function(a) {
    return a.unit.model.atomicHierarchy.chainAtomSegments.index[a.element];
  };
})(lt || (lt = {}));
var RJ = function() {
  function e(t, r) {
    this.getHash = t, this.areEqual = r, this.size = 0, this.byHash = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t) {
    var r = this.getHash(t);
    if (this.byHash.has(r)) {
      for (var n = this.byHash.get(r), a = 0, i = n.length; a < i; a++) if (this.areEqual(t, n[a])) return !1;
      return n[n.length] = t, this.size++, !0;
    }
    return this.byHash.set(r, [t]), this.size++, !0;
  }, e.prototype.has = function(t) {
    var r = this.getHash(t);
    if (!this.byHash.has(r)) return !1;
    for (var n = this.byHash.get(r), a = 0, i = n.length; a < i; a++) if (this.areEqual(t, n[a])) return !0;
    return !1;
  }, e;
}();
function b8(e, t) {
  return new RJ(e, t);
}
function D9() {
  return new LJ();
}
function M9(e) {
  return { previous: null, next: null, inList: !0, value: e };
}
var Sn, Oe, mi, Dt, wr, LJ = function() {
  function e() {
    this.count = 0, this.first = null, this.last = null;
  }
  return e.prototype.addFirst = function(t) {
    var r = M9(t);
    return r.inList = !0, this.first && (this.first.previous = r), r.next = this.first, this.first = r, this.count++, this.last || (this.last = r), r;
  }, e.prototype.addLast = function(t) {
    var r = M9(t);
    return this.last !== null && (this.last.next = r), r.previous = this.last, this.last = r, this.first === null && (this.first = r), r.inList = !0, this.count++, r;
  }, e.prototype.removeFirst = function() {
    var t = this.first;
    if (t) return this.remove(t), t.value;
  }, e.prototype.removeLast = function() {
    var t = this.last;
    if (t) return this.remove(t), t.value;
  }, e.prototype.remove = function(t) {
    t.inList && (t.inList = !1, t.previous !== null ? t.previous.next = t.next : t.previous === null && (this.first = t.next), t.next !== null ? t.next.previous = t.previous : t.next === null && (this.last = t.previous), t.next = null, t.previous = null, this.count--);
  }, e.prototype.find = function(t) {
    for (var r = this.first; r !== null; ) {
      if (r.value === t) return r;
      r = r.next;
    }
  }, e;
}();
function ot(e, t) {
  var r = t || {}, n = r.description, a = n === void 0 ? void 0 : n, i = r.isOptional, o = i !== void 0 && i, s = r.isRest, u = s !== void 0 && s, c = r.defaultValue;
  return { type: e, isOptional: o, isRest: u, defaultValue: c === void 0 ? void 0 : c, description: a };
}
function E0(e, t, r, n) {
  var a = function(i) {
    return mi.Apply(mi.Symbol(a.id), i);
  };
  return a.info = { namespace: "", name: e, description: n }, a.id = "", a.args = t, a.type = r, a;
}
function Q2(e) {
  var t = e;
  return typeof t == "function" && !!t.info && !!t.args && typeof t.info.namespace == "string" && !!t.type;
}
function Bt(e, t, r) {
  return E0("", e, t, r);
}
function _F(e) {
  AF("", "", e);
}
function SF(e) {
  var t = [];
  return wF(e, t), t;
}
function I9(e) {
  var t = /([a-z])([A-Z])([a-z]|$)/g;
  return e.replace(t, function(r, n, a, i) {
    return "".concat(n, "-").concat(a.toLocaleLowerCase()).concat(i);
  }).replace(t, function(r, n, a, i) {
    return "".concat(n, "-").concat(a.toLocaleLowerCase()).concat(i);
  });
}
function AF(e, t, r) {
  if (Q2(r)) return r.info.namespace = e, r.info.name = r.info.name || I9(t), void (r.id = "".concat(r.info.namespace, ".").concat(r.info.name));
  for (var n = "".concat(r["@namespace"] || I9(t)), a = e ? "".concat(e, ".").concat(n) : n, i = 0, o = Object.keys(r); i < o.length; i++) {
    var s = o[i];
    (typeof r[s] == "object" || Q2(r[s])) && AF(a, s, r[s]);
  }
}
function wF(e, t) {
  if (Q2(e)) t.push(e);
  else for (var r = 0, n = Object.keys(e); r < n.length; r++) {
    var a = n[r];
    (typeof e[a] == "object" || Q2(e[a])) && wF(e[a], t);
  }
}
function Ha(e, t) {
  return Bt(Dt.Dictionary({ 0: ot(e) }), e, t);
}
function Kl(e, t) {
  return Bt(Dt.List(e, { nonEmpty: !0 }), e, t);
}
function qu(e, t, r) {
  return Bt(Dt.Dictionary({ 0: ot(e), 1: ot(e) }), t, r);
}
(function(e) {
  e.create = function() {
    return { keys: /* @__PURE__ */ new Set(), array: [] };
  }, e.add = function(t, r, n) {
    var a = t.keys, i = t.array;
    return !a.has(r) && (a.add(r), i[i.length] = n, !0);
  }, e.has = function(t, r) {
    return t.keys.has(r);
  };
})(Sn || (Sn = {})), function(e) {
  function t(n, a, i) {
    return { kind: "value", namespace: n, name: a, parent: i };
  }
  function r(n, a, i, o) {
    for (var s = /* @__PURE__ */ Object.create(null), u = 0, c = o; u < c.length; u++)
      s[c[u]] = !0;
    return { kind: "oneof", namespace: n, name: a, type: i, values: s };
  }
  e.Variable = function(n, a, i) {
    return { kind: "variable", name: n, type: a, isConstraint: i };
  }, e.Value = t, e.Container = function(n, a, i, o) {
    return { kind: "container", namespace: n, name: a, child: i, alias: o };
  }, e.Union = function(n) {
    return { kind: "union", types: n };
  }, e.OneOf = r, e.Any = { kind: "any" }, e.AnyValue = { kind: "any-value" }, e.Num = t("", "Number"), e.Str = t("", "String"), e.Bool = r("", "Bool", e.Str, ["true", "false"]), e.oneOfValues = function(n) {
    var a = n.values;
    return Object.keys(a).sort();
  };
}(Oe || (Oe = {})), function(e) {
  function t(n) {
    return !!n && !!n.head && typeof n == "object";
  }
  function r(n) {
    return !!n && typeof n.name == "string";
  }
  e.Symbol = function(n) {
    return { name: n };
  }, e.Apply = function(n, a) {
    return a ? { head: n, args: a } : { head: n };
  }, e.isArgumentsArray = function(n) {
    return !!n && Array.isArray(n);
  }, e.isArgumentsMap = function(n) {
    return !!n && !Array.isArray(n);
  }, e.isLiteral = function(n) {
    return !t(n) && !r(n);
  }, e.isApply = t, e.isSymbol = r;
}(mi || (mi = {})), function(e) {
  function t(r) {
    return { kind: "dictionary", map: r, "@type": 0 };
  }
  e.None = t({}), e.Dictionary = t, e.List = function(r, n) {
    var a = (n || {}).nonEmpty;
    return { kind: "list", type: r, nonEmpty: a !== void 0 && a, "@type": 0 };
  };
}(Dt || (Dt = {})), function(e) {
  e.AnyVar = Oe.Variable("a", Oe.Any), e.AnyValueVar = Oe.Variable("a", Oe.Any), e.ConstrainedVar = Oe.Variable("a", Oe.Any, !0), e.Regex = Oe.Value("Core", "Regex"), e.Set = function(t) {
    return Oe.Container("Core", "Set", t || e.AnyValueVar);
  }, e.List = function(t) {
    return Oe.Container("Core", "List", t || e.AnyVar);
  }, e.Fn = function(t, r) {
    return Oe.Container("Core", "Fn", t || e.AnyVar, r);
  }, e.Flags = function(t, r) {
    return Oe.Container("Core", "Flags", t, r);
  }, e.BitFlags = e.Flags(Oe.Num, "BitFlags");
}(wr || (wr = {})), Dt.Dictionary({ 0: ot(Oe.Num), 1: ot(Oe.Num) }), ot(Oe.Str);
var x8 = { "@header": "Language Primitives", type: { "@header": "Types", bool: Bt(Dt.Dictionary({ 0: ot(Oe.AnyValue) }), Oe.Bool, "Convert a value to boolean."), num: Bt(Dt.Dictionary({ 0: ot(Oe.AnyValue) }), Oe.Num, "Convert a value to number."), str: Bt(Dt.Dictionary({ 0: ot(Oe.AnyValue) }), Oe.Str, "Convert a value to string."), regex: Bt(Dt.Dictionary({ 0: ot(Oe.Str, { description: "Expression" }), 1: ot(Oe.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" }) }), wr.Regex, "Creates a regular expression from a string using the ECMAscript syntax."), list: Bt(Dt.List(wr.AnyVar), wr.List()), set: Bt(Dt.List(wr.AnyValueVar), wr.Set()), bitflags: Bt(Dt.Dictionary({ 0: ot(Oe.Num) }), wr.BitFlags, "Interpret a number as bitflags."), compositeKey: Bt(Dt.List(Oe.AnyValue), Oe.AnyValue) }, logic: { "@header": "Logic", not: Ha(Oe.Bool), and: Kl(Oe.Bool), or: Kl(Oe.Bool) }, ctrl: { "@header": "Control", eval: Bt(Dt.Dictionary({ 0: ot(wr.Fn(wr.AnyVar)) }), wr.AnyVar, "Evaluate a function."), fn: Bt(Dt.Dictionary({ 0: ot(wr.AnyVar) }), wr.Fn(wr.AnyVar), 'Wrap an expression to a "lazy" function.'), if: Bt(Dt.Dictionary({ 0: ot(Oe.Bool, { description: "Condition" }), 1: ot(Oe.Variable("a", Oe.Any), { description: "If true" }), 2: ot(Oe.Variable("b", Oe.Any), { description: "If false" }) }), Oe.Union([Oe.Variable("a", Oe.Any), Oe.Variable("b", Oe.Any)])), assoc: Bt(Dt.Dictionary({ 0: ot(Oe.Str, { description: "Name" }), 1: ot(Oe.Variable("a", Oe.Any), { description: "Value to assign" }) }), Oe.Variable("a", Oe.Any)) }, rel: { "@header": "Relational", eq: qu(Oe.Variable("a", Oe.AnyValue, !0), Oe.Bool), neq: qu(Oe.Variable("a", Oe.AnyValue, !0), Oe.Bool), lt: qu(Oe.Num, Oe.Bool), lte: qu(Oe.Num, Oe.Bool), gr: qu(Oe.Num, Oe.Bool), gre: qu(Oe.Num, Oe.Bool), inRange: Bt(Dt.Dictionary({ 0: ot(Oe.Num, { description: "Value to test" }), 1: ot(Oe.Num, { description: "Minimum value" }), 2: ot(Oe.Num, { description: "Maximum value" }) }), Oe.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.") }, math: { "@header": "Math", add: Kl(Oe.Num), sub: Kl(Oe.Num), mult: Kl(Oe.Num), div: qu(Oe.Num, Oe.Num), pow: qu(Oe.Num, Oe.Num), mod: qu(Oe.Num, Oe.Num), min: Kl(Oe.Num), max: Kl(Oe.Num), floor: Ha(Oe.Num), ceil: Ha(Oe.Num), roundInt: Ha(Oe.Num), abs: Ha(Oe.Num), sqrt: Ha(Oe.Num), cbrt: Ha(Oe.Num), sin: Ha(Oe.Num), cos: Ha(Oe.Num), tan: Ha(Oe.Num), asin: Ha(Oe.Num), acos: Ha(Oe.Num), atan: Ha(Oe.Num), sinh: Ha(Oe.Num), cosh: Ha(Oe.Num), tanh: Ha(Oe.Num), exp: Ha(Oe.Num), log: Ha(Oe.Num), log10: Ha(Oe.Num), atan2: qu(Oe.Num, Oe.Num) }, str: { "@header": "Strings", concat: Kl(Oe.Str), match: Bt(Dt.Dictionary({ 0: ot(wr.Regex), 1: ot(Oe.Str) }), Oe.Bool) }, list: { "@header": "Lists", getAt: Bt(Dt.Dictionary({ 0: ot(wr.List()), 1: ot(Oe.Num) }), wr.AnyVar), equal: Bt(Dt.Dictionary({ 0: ot(wr.List()), 1: ot(wr.List()) }), Oe.Bool) }, set: { "@header": "Sets", has: Bt(Dt.Dictionary({ 0: ot(wr.Set(wr.ConstrainedVar)), 1: ot(wr.ConstrainedVar) }), Oe.Bool, "Check if the the 1st argument includes the value of the 2nd."), isSubset: Bt(Dt.Dictionary({ 0: ot(wr.Set(wr.ConstrainedVar)), 1: ot(wr.Set(wr.ConstrainedVar)) }), Oe.Bool, "Check if the the 1st argument is a subset of the 2nd.") }, flags: { "@header": "Flags", hasAny: Bt(Dt.Dictionary({ 0: ot(wr.Flags(wr.ConstrainedVar)), 1: ot(wr.Flags(wr.ConstrainedVar)) }), Oe.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."), hasAll: Bt(Dt.Dictionary({ 0: ot(wr.Flags(wr.ConstrainedVar)), 1: ot(wr.Flags(wr.ConstrainedVar)) }), Oe.Bool, "Check if the the 1st argument has all 2nd one's flags.") } };
_F(x8);
var bt, kJ = SF(x8);
function br(e, t) {
  return Bt(Dt.Dictionary({ 0: ot(bt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), e, t);
}
function Y1(e, t) {
  return Bt(Dt.None, e, t);
}
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = kJ; t < r.length; t++) {
    var n = r[t];
    e[n.id] = n;
  }
})(), function(e) {
  e.ElementSymbol = Oe.Value("Structure", "ElementSymbol"), e.AtomName = Oe.Value("Structure", "AtomName"), e.BondFlag = Oe.OneOf("Structure", "BondFlag", Oe.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), e.BondFlags = wr.Flags(e.BondFlag, "BondFlags"), e.SecondaryStructureFlag = Oe.OneOf("Structure", "SecondaryStructureFlag", Oe.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), e.SecondaryStructureFlags = wr.Flags(e.SecondaryStructureFlag, "SecondaryStructureFlag"), e.RingFingerprint = Oe.Value("Structure", "RingFingerprint"), e.EntityType = Oe.OneOf("Structure", "EntityType", Oe.Str, ["polymer", "non-polymer", "water", "branched"]), e.EntitySubtype = Oe.OneOf("Structure", "EntitySubtype", Oe.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), e.ObjectPrimitive = Oe.OneOf("Structure", "ObjectPrimitive", Oe.Str, ["atomistic", "sphere", "gaussian", "other"]), e.ResidueId = Oe.Value("Structure", "ResidueId"), e.ElementSet = Oe.Value("Structure", "ElementSet"), e.ElementSelection = Oe.Value("Structure", "ElementSelection"), e.ElementReference = Oe.Value("Structure", "ElementReference"), e.ElementSelectionQuery = wr.Fn(e.ElementSelection, "ElementSelectionQuery");
}(bt || (bt = {}));
var we = { core: x8, structureQuery: { "@header": "Structure Queries", type: { "@header": "Types", elementSymbol: Bt(Dt.Dictionary({ 0: ot(Oe.Str) }), bt.ElementSymbol, "Create element symbol representation from a string value."), atomName: Bt(Dt.Dictionary({ 0: ot(Oe.AnyValue) }), bt.AtomName, "Convert a value to an atom name."), entityType: Bt(Dt.Dictionary({ 0: ot(bt.EntityType) }), bt.EntityType, "Create normalized representation of entity type: ".concat(Oe.oneOfValues(bt.EntityType).join(", "), ".")), bondFlags: Bt(Dt.List(bt.BondFlag), bt.BondFlags, "Create bond flags representation from a list of strings. Allowed flags: ".concat(Oe.oneOfValues(bt.BondFlag).join(", "), ".")), ringFingerprint: Bt(Dt.List(bt.ElementSymbol, { nonEmpty: !0 }), bt.RingFingerprint, "Create ring fingerprint from the supplied atom element list."), secondaryStructureFlags: Bt(Dt.List(bt.SecondaryStructureFlag), bt.SecondaryStructureFlags, "Create secondary structure flags representation from a list of strings. Allowed flags: ".concat(Oe.oneOfValues(bt.SecondaryStructureFlag).join(", "), ".")), authResidueId: Bt(Dt.Dictionary({ 0: ot(Oe.Str, { description: "auth_asym_id" }), 1: ot(Oe.Num, { description: "auth_seq_id" }), 2: ot(Oe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), bt.ResidueId, 'Residue identifier based on "auth_" annotation.'), labelResidueId: Bt(Dt.Dictionary({ 0: ot(Oe.Str, { description: "label_entity_id" }), 1: ot(Oe.Str, { description: "label_asym_id" }), 2: ot(Oe.Num, { description: "label_seq_id" }), 3: ot(Oe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), bt.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`) }, slot: { "@header": "Iteration Slots", element: Bt(Dt.None, bt.ElementReference, "A reference to the current element."), elementSetReduce: Bt(Dt.None, Oe.Variable("a", Oe.AnyValue, !0), "Current value of the element set reducer.") }, generator: { "@header": "Generators", all: Bt(Dt.None, bt.ElementSelectionQuery, "The entire structure."), atomGroups: Bt(Dt.Dictionary({ "entity-test": ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }), "chain-test": ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }), "residue-test": ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }), "atom-test": ot(Oe.Bool, { isOptional: !0, defaultValue: !0 }), "group-by": ot(Oe.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" }) }), bt.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."), bondedAtomicPairs: Bt(Dt.Dictionary({ 0: ot(Oe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." }) }), bt.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."), rings: Bt(Dt.Dictionary({ fingerprint: ot(bt.RingFingerprint, { isOptional: !0 }), "only-aromatic": ot(Oe.Bool, { isOptional: !0, defaultValue: !1 }) }), bt.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."), queryInSelection: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), query: ot(bt.ElementSelectionQuery), "in-complement": ot(Oe.Bool, { isOptional: !0, defaultValue: !1 }) }), bt.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."), empty: Bt(Dt.None, bt.ElementSelectionQuery, "Nada.") }, modifier: { "@header": "Selection Modifications", queryEach: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), query: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Query every atom set in the input selection separately."), intersectBy: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), by: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."), exceptBy: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), by: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."), unionBy: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), by: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."), union: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."), cluster: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), "min-distance": ot(Oe.Num, { isOptional: !0, defaultValue: 0 }), "max-distance": ot(Oe.Num), "min-size": ot(Oe.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }), "max-size": ot(Oe.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 }) }), bt.ElementSelectionQuery, "Combines atom sets that have mutual distance in the interval [min-radius, max-radius]. Minimum/maximum size determines how many atom sets can be combined."), includeSurroundings: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), radius: ot(Oe.Num), "atom-radius": ot(Oe.Num, { isOptional: !0, defaultValue: 0, description: "Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding." }), "as-whole-residues": ot(Oe.Bool, { isOptional: !0 }) }), bt.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."), surroundingLigands: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), radius: ot(Oe.Num), "include-water": ot(Oe.Bool, { isOptional: !0, defaultValue: !0 }) }), bt.ElementSelectionQuery, "Find all ligands components around the source query."), includeConnected: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), "bond-test": ot(Oe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), "layer-count": ot(Oe.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }), "fixed-point": ot(Oe.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }), "as-whole-residues": ot(Oe.Bool, { isOptional: !0 }) }), bt.ElementSelectionQuery, "Pick all atom sets that are connected to the target."), wholeResidues: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Expand the selection to whole residues."), expandProperty: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), property: ot(Oe.AnyValue) }), bt.ElementSelectionQuery, "To each atom set in the selection, add all atoms that have the same property value that was already present in the set.") }, filter: { "@header": "Selection Filters", pick: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), test: ot(Oe.Bool) }), bt.ElementSelectionQuery, "Pick all atom sets that satisfy the test."), first: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Take the 1st atom set in the sequence."), withSameAtomProperties: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), source: ot(bt.ElementSelectionQuery), property: ot(Oe.Any) }), bt.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."), intersectedBy: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), by: ot(bt.ElementSelectionQuery) }), bt.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."), within: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), target: ot(bt.ElementSelectionQuery), "min-radius": ot(Oe.Num, { isOptional: !0, defaultValue: 0 }), "max-radius": ot(Oe.Num), "atom-radius": ot(Oe.Num, { isOptional: !0, defaultValue: 0, description: "Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding." }), invert: ot(Oe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." }) }), bt.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."), isConnectedTo: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery), target: ot(bt.ElementSelectionQuery), "bond-test": ot(Oe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), disjunct: ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "If true, there must exist a bond to an atom that lies outside the given atom set to pass test." }), invert: ot(Oe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." }) }), bt.ElementSelectionQuery, "Pick all atom sets that are connected to the target.") }, combinator: { "@header": "Selection Combinators", intersect: Bt(Dt.List(bt.ElementSelectionQuery), bt.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."), merge: Bt(Dt.List(bt.ElementSelectionQuery), bt.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."), distanceCluster: Bt(Dt.Dictionary({ matrix: ot(wr.List(wr.List(Oe.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }), selections: ot(wr.List(bt.ElementSelectionQuery), { description: "A list of held selections." }) }), bt.ElementSelectionQuery, "Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.") }, atomSet: { "@header": "Atom Sets", atomCount: Bt(Dt.None, Oe.Num), countQuery: Bt(Dt.Dictionary({ 0: ot(bt.ElementSelectionQuery) }), Oe.Num, "Counts the number of occurences of a specific query inside the current atom set."), reduce: Bt(Dt.Dictionary({ initial: ot(Oe.Variable("a", Oe.AnyValue, !0), { description: "Initial value assigned to slot.atom-set-reduce. Current atom is set to the 1st atom of the current set for this." }), value: ot(Oe.Variable("a", Oe.AnyValue, !0), { description: "Expression executed for each atom in the set" }) }), Oe.Variable("a", Oe.AnyValue, !0), "Execute the value expression for each atom in the current atom set and return the result. Works the same way as Array.reduce in JavaScript (``result = value(value(...value(initial)))``)"), propertySet: Bt(Dt.Dictionary({ 0: ot(wr.ConstrainedVar) }), wr.Set(wr.ConstrainedVar), "Returns a set with all values of the given property in the current atom set.") }, atomProperty: { "@header": "Atom Properties", core: { "@header": "Core Properties", elementSymbol: br(bt.ElementSymbol), vdw: br(Oe.Num, "Van der Waals radius"), mass: br(Oe.Num, "Atomic weight"), atomicNumber: br(Oe.Num, "Atomic number"), x: br(Oe.Num, "Cartesian X coordinate"), y: br(Oe.Num, "Cartesian Y coordinate"), z: br(Oe.Num, "Cartesian Z coordinate"), atomKey: br(Oe.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."), bondCount: Bt(Dt.Dictionary({ 0: ot(bt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }), flags: ot(bt.BondFlags, { isOptional: !0, defaultValue: "covalent" }) }), Oe.Num, "Number of bonds (by default only covalent bonds are counted)."), sourceIndex: br(Oe.Num, "Index of the atom/element in the input file."), operatorName: br(Oe.Str, "Name of the symmetry operator applied to this element."), modelIndex: br(Oe.Num, "Index of the model in the input file."), modelLabel: br(Oe.Str, "Label/header of the model in the input file.") }, topology: { connectedComponentKey: br(Oe.AnyValue, "Unique value for each connected component.") }, macromolecular: { "@header": "Macromolecular Properties (derived from the mmCIF format)", authResidueId: br(bt.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"), labelResidueId: br(bt.ResidueId, "type.label-residue-id symbol executed on current atom's residue"), residueKey: br(Oe.AnyValue, "Unique value for each tuple ``(label_entity_id,auth_asym_id, auth_seq_id, pdbx_PDB_ins_code)``, main use case is grouping of atoms"), chainKey: br(Oe.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"), entityKey: br(Oe.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"), isHet: br(Oe.Bool, "Equivalent to atom_site.group_PDB !== ATOM"), id: br(Oe.Num, "_atom_site.id"), label_atom_id: br(bt.AtomName), label_alt_id: br(Oe.Str), label_comp_id: br(Oe.Str), label_asym_id: br(Oe.Str), label_entity_id: br(Oe.Str), label_seq_id: br(Oe.Num), auth_atom_id: br(bt.AtomName), auth_comp_id: br(Oe.Str), auth_asym_id: br(Oe.Str), auth_seq_id: br(Oe.Num), pdbx_PDB_ins_code: br(Oe.Str), pdbx_formal_charge: br(Oe.Num), occupancy: br(Oe.Num), B_iso_or_equiv: br(Oe.Num), entityType: br(bt.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"), entitySubtype: br(bt.EntitySubtype, "Subtype of the entity as defined in mmCIF _entity_poly.type and _pdbx_entity_branch.type (other, polypeptide(D), polypeptide(L), polydeoxyribonucleotide, polyribonucleotide, polydeoxyribonucleotide/polyribonucleotide hybrid, cyclic-pseudo-peptide, peptide nucleic acid, oligosaccharide)"), entityPrdId: br(Oe.Str, "The PRD ID of the entity."), entityDescription: br(wr.List(Oe.Str)), objectPrimitive: br(bt.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"), secondaryStructureKey: br(Oe.AnyValue, "Unique value for each secondary structure element."), secondaryStructureFlags: br(bt.SecondaryStructureFlags), isModified: br(Oe.Bool, "True if the atom belongs to modification of a standard residue."), modifiedParentName: br(Oe.Str, "'3-letter' code of the modifed parent residue."), isNonStandard: br(Oe.Bool, "True if this is a non-standard residue."), chemCompType: br(Oe.Str, "Type of the chemical component as defined in mmCIF.") } }, bondProperty: { "@header": "Bond Properties", flags: Y1(bt.BondFlags), order: Y1(Oe.Num), length: Y1(Oe.Num), atomA: Y1(bt.ElementReference), atomB: Y1(bt.ElementReference) } }, internal: { "@header": "Internal Queries", generator: { "@header": "Generators", bundleElement: Bt(Dt.Dictionary({ groupedUnits: ot(Oe.Any), set: ot(Oe.Any), ranges: ot(Oe.Any) }), Oe.Any), bundle: Bt(Dt.Dictionary({ elements: ot(Oe.Any) }), bt.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."), current: Bt(Dt.None, bt.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.") } } };
_F(we);
var zt, zJ = SF(we);
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = zJ; t < r.length; t++) {
    var n = r[t];
    e[n.id] = n;
  }
})(), function(e) {
  e.core = we.core, e.struct = we.structureQuery, e.internal = we.internal, e.atomName = function(u) {
    return e.struct.type.atomName([u]);
  }, e.es = function(u) {
    return e.struct.type.elementSymbol([u]);
  }, e.list = function() {
    for (var u = [], c = 0; c < arguments.length; c++) u[c] = arguments[c];
    return e.core.type.list(u);
  }, e.set = function() {
    for (var u = [], c = 0; c < arguments.length; c++) u[c] = arguments[c];
    return e.core.type.set(u);
  }, e.re = function(u, c) {
    return e.core.type.regex([u, c]);
  }, e.fn = function(u) {
    return e.core.ctrl.fn([u]);
  }, e.evaluate = function(u) {
    return e.core.ctrl.eval([u]);
  };
  var t = e.struct.atomProperty.core, r = e.struct.atomProperty.macromolecular, n = e.struct.atomProperty.topology;
  function a(u) {
    return t[u]();
  }
  function i(u) {
    return n[u]();
  }
  function o(u) {
    return r[u]();
  }
  e.acp = a, e.atp = i, e.ammp = o;
  var s = e.struct.atomSet.propertySet;
  e.acpSet = function(u) {
    return s([a(u)]);
  }, e.atpSet = function(u) {
    return s([i(u)]);
  }, e.ammpSet = function(u) {
    return s([o(u)]);
  };
}(zt || (zt = {}));
var Ns, Ps, UJ = /* @__PURE__ */ new Set(["145", "147", "149", "289", "291", "293", "445", "475", "491", "510", "604", "045", "05L", "07E", "07Y", "08U", "09X", "0AT", "0BD", "0H0", "0HX", "0LP", "0MK", "0NZ", "0TS", "0UB", "0V4", "0WK", "0XY", "0YT", "10M", "12E", "14T", "15L", "16F", "16G", "16O", "17T", "18D", "18O", "18T", "1AR", "1BW", "1CF", "1FT", "1GL", "1GN", "1JB", "1LL", "1NA", "1S3", "1S4", "1SD", "1X4", "20S", "20X", "22O", "22S", "23V", "24S", "25E", "26M", "26O", "26Q", "26R", "26V", "26W", "26Y", "27C", "2DG", "2DR", "2F8", "2FG", "2FL", "2FP", "2GL", "2GS", "2H5", "2HA", "2M4", "2M5", "2M8", "2OS", "2WP", "2WS", "32O", "34V", "38J", "3BU", "3CM", "3DO", "3DY", "3FM", "3GR", "3HD", "3J3", "3J4", "3LJ", "3LR", "3MF", "3MG", "3MK", "3R3", "3S6", "3SA", "3YW", "40J", "42D", "44S", "46D", "46M", "46Z", "48Z", "49A", "49S", "49T", "49V", "4AM", "4CQ", "4GC", "4GL", "4GP", "4JA", "4N2", "4NN", "4QY", "4R1", "4RS", "4SG", "4U0", "4U1", "4U2", "4UZ", "4V5", "50A", "51N", "56N", "57S", "5DI", "5GF", "5GO", "5II", "5KQ", "5KS", "5KT", "5KV", "5L2", "5L3", "5LS", "5LT", "5MM", "5N6", "5QP", "5RP", "5SA", "5SP", "5TH", "5TJ", "5TK", "5TM", "61J", "62I", "64K", "66O", "6BG", "6C2", "6DM", "6GB", "6GP", "6GR", "6K3", "6KH", "6KL", "6KS", "6KU", "6KW", "6LA", "6LS", "6LW", "6MJ", "6MN", "6PG", "6PY", "6PZ", "6S2", "6SA", "6UD", "6Y6", "6YR", "6ZC", "73E", "79J", "7CV", "7D1", "7GP", "7JZ", "7K2", "7K3", "7NU", "7SA", "83Y", "89Y", "8B7", "8B9", "8EX", "8GA", "8GG", "8GP", "8LM", "8LR", "8OQ", "8PK", "8S0", "8YV", "95Z", "96O", "9AM", "9C1", "9CD", "9GP", "9KJ", "9MR", "9OK", "9PG", "9QG", "9QZ", "9S7", "9SG", "9SJ", "9SM", "9SP", "9T1", "9T7", "9VP", "9WJ", "9WN", "9WZ", "9YW", "A0K", "A1Q", "A2G", "A5C", "A6P", "AAL", "AAO", "ABC", "ABD", "ABE", "ABF", "ABL", "AC1", "ACG", "ACR", "ACX", "ADA", "ADG", "ADR", "AF1", "AFD", "AFL", "AFO", "AFP", "AFR", "AGC", "AGH", "AGL", "AGR", "AH2", "AH8", "AHG", "AHM", "AHR", "AIG", "ALL", "ALX", "AMG", "AMN", "AMU", "AMV", "ANA", "AOG", "AOS", "AQA", "ARA", "ARB", "ARE", "ARI", "ARW", "ASC", "ASG", "ASO", "AXP", "AXR", "AY9", "AZC", "B0D", "B16", "B1H", "B1N", "B2G", "B4G", "B6D", "B7G", "B8D", "B9D", "BBK", "BBV", "BCD", "BCW", "BDF", "BDG", "BDP", "BDR", "BDZ", "BEM", "BFN", "BFP", "BG6", "BG8", "BGC", "BGL", "BGN", "BGP", "BGS", "BHG", "BM3", "BM7", "BMA", "BMX", "BND", "BNG", "BNX", "BO1", "BOG", "BQY", "BRI", "BS7", "BTG", "BTU", "BWG", "BXF", "BXP", "BXX", "BXY", "BZD", "C3B", "C3G", "C3X", "C4B", "C4W", "C4X", "C5X", "CAP", "CBF", "CBI", "CBK", "CDR", "CE5", "CE6", "CE8", "CEG", "CEX", "CEY", "CEZ", "CGF", "CJB", "CKB", "CKP", "CNP", "CR1", "CR6", "CRA", "CT3", "CTO", "CTR", "CTT", "D0N", "D1M", "D5E", "D6G", "DAF", "DAG", "DAN", "DDA", "DDB", "DDL", "DEG", "DEL", "DFR", "DFX", "DG0", "DGC", "DGD", "DGM", "DGO", "DGS", "DGU", "DIG", "DJB", "DJE", "DK4", "DKX", "DKZ", "DL6", "DLD", "DLF", "DLG", "DMU", "DNO", "DO8", "DOM", "DP5", "DPC", "DQQ", "DQR", "DR2", "DR3", "DR4", "DR5", "DRI", "DSR", "DT6", "DVC", "DYM", "E3M", "E4P", "E5G", "EAG", "EBG", "EBQ", "EEN", "EEQ", "EGA", "EJT", "EMP", "EMZ", "EPG", "EQP", "EQV", "ERE", "ERI", "ETT", "EUS", "F1P", "F1X", "F55", "F58", "F6P", "F8X", "FBP", "FCA", "FCB", "FCT", "FDP", "FDQ", "FFC", "FFX", "FIF", "FIX", "FK9", "FKD", "FMF", "FMO", "FNG", "FNY", "FRU", "FSA", "FSI", "FSM", "FSR", "FSW", "FU4", "FUB", "FUC", "FUD", "FUF", "FUL", "FUY", "FVQ", "FX1", "FYJ", "G0S", "G16", "G1P", "G20", "G28", "G2F", "G3F", "G3I", "G4D", "G4S", "G6D", "G6P", "G6S", "G7P", "G8Z", "GAA", "GAC", "GAD", "GAF", "GAL", "GAT", "GBH", "GC1", "GC4", "GC9", "GCB", "GCD", "GCN", "GCO", "GCS", "GCT", "GCU", "GCV", "GCW", "GDA", "GDL", "GE1", "GE3", "GFP", "GIV", "GL0", "GL1", "GL2", "GL4", "GL5", "GL6", "GL7", "GL9", "GLA", "GLB", "GLC", "GLD", "GLF", "GLG", "GLO", "GLP", "GLS", "GLT", "GLW", "GM0", "GMB", "GMH", "GMT", "GMZ", "GN1", "GN4", "GNS", "GNX", "GP0", "GP1", "GP4", "GPH", "GPK", "GPM", "GPO", "GPQ", "GPU", "GPV", "GPW", "GQ1", "GRF", "GRX", "GS1", "GS4", "GS9", "GSA", "GSD", "GTE", "GTH", "GTK", "GTM", "GTR", "GU0", "GU1", "GU2", "GU3", "GU4", "GU5", "GU6", "GU8", "GU9", "GUF", "GUL", "GUP", "GUZ", "GXL", "GXV", "GYE", "GYG", "GYP", "GYU", "GYV", "GZL", "H1M", "H1S", "H2P", "H3S", "H53", "H6Q", "H6Z", "HBZ", "HD4", "HDL", "HMS", "HNV", "HNW", "HSG", "HSH", "HSJ", "HSQ", "HSR", "HSU", "HSX", "HSY", "HSZ", "HTG", "HTM", "I57", "IAB", "IDC", "IDF", "IDG", "IDR", "IDS", "IDT", "IDU", "IDX", "IDY", "IEM", "IN1", "IPT", "ISD", "ISL", "ISX", "IXD", "J5B", "JFZ", "JHM", "JLT", "JRV", "JS2", "JSV", "JV4", "JVA", "JVS", "JZR", "K5B", "K99", "KBA", "KBG", "KD5", "KDA", "KDB", "KDD", "KDE", "KDF", "KDM", "KDN", "KDO", "KDR", "KFN", "KG1", "KGM", "KHP", "KME", "KO1", "KO2", "KOT", "KTU", "L1L", "L6S", "L6T", "LAG", "LAH", "LAI", "LAK", "LAO", "LAT", "LB2", "LBS", "LBT", "LCN", "LDY", "LEC", "LER", "LFC", "LFR", "LGC", "LGU", "LKA", "LKS", "LM2", "LMO", "LMT", "LMU", "LNV", "LOG", "LOX", "LPK", "LRH", "LSM", "LTG", "LTM", "LVO", "LVZ", "LXB", "LXC", "LXZ", "LZ0", "M1F", "M1P", "M2F", "M3M", "M3N", "M55", "M6D", "M6P", "M7B", "M7P", "M8C", "MA1", "MA2", "MA3", "MA8", "MAB", "MAF", "MAG", "MAL", "MAN", "MAT", "MAV", "MAW", "MBE", "MBF", "MBG", "MCU", "MDA", "MDP", "MFA", "MFB", "MFU", "MG5", "MGA", "MGC", "MGL", "MGS", "MJJ", "MLB", "MLR", "MMA", "MMN", "MN0", "MNA", "MQG", "MQT", "MRH", "MRP", "MSX", "MTT", "MUB", "MUG", "MUR", "MVP", "MXY", "MXZ", "MYG", "N1L", "N9S", "NA1", "NAA", "NAG", "NBG", "NBX", "NBY", "NDG", "NED", "NFG", "NG1", "NG6", "NGA", "NGB", "NGC", "NGE", "NGF", "NGK", "NGL", "NGR", "NGS", "NGY", "NGZ", "NHF", "NLC", "NM6", "NM9", "NNG", "NPF", "NSQ", "NT1", "NTF", "NTO", "NTP", "NXD", "NYT", "O1G", "OAK", "OEL", "OI7", "OPM", "ORP", "OSU", "OTG", "OTN", "OTU", "OX2", "P53", "P6P", "P8E", "PA1", "PA5", "PAV", "PDX", "PH5", "PKM", "PNA", "PNG", "PNJ", "PNW", "PPC", "PRP", "PSG", "PSJ", "PSV", "PTQ", "PUF", "PZU", "QDK", "QIF", "QKH", "QPS", "QV4", "R1P", "R1X", "R2B", "R2G", "R5P", "RAA", "RAE", "RAF", "RAM", "RAO", "RAT", "RB5", "RBL", "RCD", "RDP", "REL", "RER", "RF5", "RG1", "RGG", "RHA", "RHC", "RI2", "RIB", "RIP", "RM4", "RNS", "RNT", "ROB", "ROR", "RP3", "RP5", "RP6", "RPA", "RR7", "RRJ", "RRY", "RST", "RTG", "RTV", "RUB", "RUG", "RUU", "RV7", "RVG", "RVM", "RWI", "RY7", "RZM", "S6P", "S7P", "S81", "SA0", "SCG", "SCR", "SDD", "SDY", "SEJ", "SF6", "SF9", "SFJ", "SFU", "SG4", "SG5", "SG6", "SG7", "SGA", "SGC", "SGD", "SGN", "SGS", "SHB", "SHD", "SHG", "SI3", "SIA", "SID", "SIO", "SIZ", "SLB", "SLM", "SLT", "SMD", "SN5", "SNG", "SOE", "SOG", "SOL", "SOR", "SR1", "SSG", "SSH", "STW", "STZ", "SUC", "SUP", "SUS", "SWE", "SZZ", "T68", "T6D", "T6P", "T6T", "TA6", "TAG", "TCB", "TCG", "TDG", "TEU", "TF0", "TFU", "TGA", "TGK", "TGR", "TGY", "TH1", "TM5", "TM6", "TM9", "TMR", "TMX", "TNX", "TOA", "TOC", "TQY", "TRE", "TRV", "TS8", "TT7", "TTV", "TTZ", "TU4", "TUG", "TUJ", "TUP", "TUR", "TVD", "TVG", "TVM", "TVS", "TVV", "TVY", "TW7", "TWA", "TWD", "TWG", "TWJ", "TWY", "TXB", "TYV", "U1Y", "U2A", "U2D", "U63", "U8V", "U97", "U9A", "U9D", "U9G", "U9J", "U9M", "UAP", "UCD", "UDC", "UEA", "V3M", "V3P", "V71", "VG1", "VJ1", "VJ4", "VKN", "VTB", "W9T", "WIA", "WOO", "WUN", "WZ1", "WZ2", "WZ4", "X0X", "X1P", "X1X", "X2F", "X2Y", "X34", "X4S", "X5S", "X6X", "X6Y", "XBP", "XDP", "XDX", "XGP", "XIL", "XKJ", "XLF", "XLS", "XMM", "XS2", "XUL", "XXM", "XXR", "XXX", "XYB", "XYF", "XYL", "XYP", "XYS", "XYT", "XYZ", "YDR", "YIO", "YJM", "YKR", "YO5", "YX0", "YX1", "YYB", "YYH", "YYJ", "YYK", "YYM", "YYQ", "YYR", "YZ0", "Z0F", "Z15", "Z16", "Z2D", "Z2T", "Z3K", "Z3L", "Z3Q", "Z3U", "Z4K", "Z4R", "Z4S", "Z4U", "Z4V", "Z4W", "Z4Y", "Z57", "Z5J", "Z5L", "Z61", "Z6H", "Z6J", "Z6W", "Z8H", "Z8T", "Z9D", "Z9E", "Z9H", "Z9K", "Z9L", "Z9M", "Z9N", "Z9W", "ZB0", "ZB1", "ZB2", "ZB3", "ZCD", "ZCZ", "ZD0", "ZDC", "ZDM", "ZDO", "ZEE", "ZEL", "ZGE", "ZMR", "UMQ", "SQD"]), wt = { Blue: 37052, Green: 42577, Yellow: 16765952, Orange: 16021792, Pink: 16162465, Purple: 10830745, LightBlue: 9424105, Brown: 10582605, Red: 15539236, Secondary: 15854817 };
(Ns = {})[0] = "Hexose", Ns[1] = "HexNAc", Ns[2] = "Hexosamine", Ns[3] = "Hexuronate", Ns[4] = "Deoxyhexose", Ns[5] = "DeoxyhexNAc", Ns[6] = "Di-deoxyhexose", Ns[7] = "Pentose", Ns[8] = "Deoxynonulosonate", Ns[9] = "Di-deoxynonulosonate", Ns[10] = "Unknown", Ns[11] = "Assigned", (Ps = {})[0] = 0, Ps[1] = 1, Ps[2] = 2, Ps[3] = 3, Ps[4] = 4, Ps[5] = 5, Ps[6] = 6, Ps[7] = 7, Ps[8] = 8, Ps[9] = 9, Ps[10] = 10, Ps[11] = 11;
var Xl, CF = { abbr: "Unk", name: "Unknown", color: wt.Secondary, type: 10 }, $2 = [{ abbr: "Glc", name: "Glucose", color: wt.Blue, type: 0 }, { abbr: "Man", name: "Mannose", color: wt.Green, type: 0 }, { abbr: "Gal", name: "Galactose", color: wt.Yellow, type: 0 }, { abbr: "Gul", name: "Gulose", color: wt.Orange, type: 0 }, { abbr: "Alt", name: "Altrose", color: wt.Pink, type: 0 }, { abbr: "All", name: "Allose", color: wt.Purple, type: 0 }, { abbr: "Tal", name: "Talose", color: wt.LightBlue, type: 0 }, { abbr: "Ido", name: "Idose", color: wt.Brown, type: 0 }, { abbr: "GlcNAc", name: "N-Acetyl Glucosamine", color: wt.Blue, type: 1 }, { abbr: "ManNAc", name: "N-Acetyl Mannosamine", color: wt.Green, type: 1 }, { abbr: "GalNAc", name: "N-Acetyl Galactosamine", color: wt.Yellow, type: 1 }, { abbr: "GulNAc", name: "N-Acetyl Gulosamine", color: wt.Orange, type: 1 }, { abbr: "AltNAc", name: "N-Acetyl Altrosamine", color: wt.Pink, type: 1 }, { abbr: "AllNAc", name: "N-Acetyl Allosamine", color: wt.Purple, type: 1 }, { abbr: "TalNAc", name: "N-Acetyl Talosamine", color: wt.LightBlue, type: 1 }, { abbr: "IdoNAc", name: "N-Acetyl Idosamine", color: wt.Brown, type: 1 }, { abbr: "GlcN", name: "Glucosamine", color: wt.Blue, type: 2 }, { abbr: "ManN", name: "Mannosamine", color: wt.Green, type: 2 }, { abbr: "GalN", name: "Galactosamine", color: wt.Yellow, type: 2 }, { abbr: "GulN", name: "Gulosamine", color: wt.Orange, type: 2 }, { abbr: "AltN", name: "Altrosamine", color: wt.Pink, type: 2 }, { abbr: "AllN", name: "Allosamine", color: wt.Purple, type: 2 }, { abbr: "TalN", name: "Talosamine", color: wt.LightBlue, type: 2 }, { abbr: "IdoN", name: "Idosamine", color: wt.Brown, type: 2 }, { abbr: "GlcA", name: "Glucuronic Acid", color: wt.Blue, type: 3 }, { abbr: "ManA", name: "Mannuronic Acid", color: wt.Green, type: 3 }, { abbr: "GalA", name: "Galacturonic Acid", color: wt.Yellow, type: 3 }, { abbr: "GulA", name: "Guluronic Acid", color: wt.Orange, type: 3 }, { abbr: "AltA", name: "Altruronic Acid", color: wt.Pink, type: 3 }, { abbr: "AllA", name: "Alluronic Acid", color: wt.Purple, type: 3 }, { abbr: "TalA", name: "Taluronic Acid", color: wt.LightBlue, type: 3 }, { abbr: "IdoA", name: "Iduronic Acid", color: wt.Brown, type: 3 }, { abbr: "Qui", name: "Quinovose", color: wt.Blue, type: 4 }, { abbr: "Rha", name: "Rhamnose", color: wt.Green, type: 4 }, { abbr: "6dGul", name: "6-Deoxy Gulose", color: wt.Orange, type: 4 }, { abbr: "6dAlt", name: "6-Deoxy Altrose", color: wt.Pink, type: 4 }, { abbr: "6dTal", name: "6-Deoxy Talose", color: wt.LightBlue, type: 4 }, { abbr: "Fuc", name: "Fucose", color: wt.Red, type: 4 }, { abbr: "QuiNAc", name: "N-Acetyl Quinovosamine", color: wt.Blue, type: 5 }, { abbr: "RhaNAc", name: "N-Acetyl Rhamnosamine", color: wt.Green, type: 5 }, { abbr: "6dAltNAc", name: "N-Acetyl 6-Deoxy Altrosamine", color: wt.Pink, type: 5 }, { abbr: "6dTalNAc", name: "N-Acetyl 6-Deoxy Talosamine", color: wt.LightBlue, type: 5 }, { abbr: "FucNAc", name: "N-Acetyl Fucosamine", color: wt.Red, type: 5 }, { abbr: "Oli", name: "Olivose", color: wt.Blue, type: 6 }, { abbr: "Tyv", name: "Tyvelose", color: wt.Green, type: 6 }, { abbr: "Abe", name: "Abequose", color: wt.Orange, type: 6 }, { abbr: "Par", name: "Paratose", color: wt.Pink, type: 6 }, { abbr: "Dig", name: "Digitoxose", color: wt.Purple, type: 6 }, { abbr: "Col", name: "Colitose", color: wt.LightBlue, type: 6 }, { abbr: "Ara", name: "Arabinose", color: wt.Green, type: 7 }, { abbr: "Lyx", name: "Lyxose", color: wt.Yellow, type: 7 }, { abbr: "Xyl", name: "Xylose", color: wt.Orange, type: 7 }, { abbr: "Rib", name: "Ribose", color: wt.Pink, type: 7 }, { abbr: "Kdn", name: "Keto-Deoxy Nonulonic Acid", color: wt.Green, type: 8 }, { abbr: "Neu5Ac", name: "N-Acetyl Neuraminic Acid", color: wt.Purple, type: 8 }, { abbr: "Neu5Gc", name: "N-Glycolyl Neuraminic Acid", color: wt.LightBlue, type: 8 }, { abbr: "Neu", name: "Neuraminic Acid", color: wt.Brown, type: 8 }, { abbr: "Sia", name: "Sialic acid", color: wt.Red, type: 8 }, { abbr: "Pse", name: "Pseudaminic Acid", color: wt.Green, type: 9 }, { abbr: "Leg", name: "Legionaminic Acid", color: wt.Yellow, type: 9 }, { abbr: "Aci", name: "Acinetaminic Acid", color: wt.Pink, type: 9 }, { abbr: "4eLeg", name: "4-Epilegionaminic Acid", color: wt.LightBlue, type: 9 }, { abbr: "Bac", name: "Bacillosamine", color: wt.Blue, type: 10 }, { abbr: "LDmanHep", name: "L-Glycero-D-Manno Heptose", color: wt.Green, type: 10 }, { abbr: "Kdo", name: "Keto-Deoxy Octulonic Acid", color: wt.Yellow, type: 10 }, { abbr: "Dha", name: "3-Deoxy Lyxo-Heptulosaric Acid", color: wt.Orange, type: 10 }, { abbr: "DDmanHep", name: "D-Glycero-D-Manno-Heptose", color: wt.Pink, type: 10 }, { abbr: "MurNAc", name: "N-Acetyl Muramic Acid", color: wt.Purple, type: 10 }, { abbr: "MurNGc", name: "N-Glycolyl Muramic Acid", color: wt.LightBlue, type: 10 }, { abbr: "Mur", name: "Muramic Acid", color: wt.Brown, type: 10 }, { abbr: "Api", name: "Apicose", color: wt.Green, type: 11 }, { abbr: "Fru", name: "Fructose", color: wt.Green, type: 11 }, { abbr: "Tag", name: "Tagatose", color: wt.Yellow, type: 11 }, { abbr: "Sor", name: "Sorbose", color: wt.Orange, type: 11 }, { abbr: "Psi", name: "Psicose", color: wt.Pink, type: 11 }], GJ = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, r = $2.length; t < r; ++t) {
    var n = $2[t];
    e.set(n.abbr, n);
  }
  return e;
}(), VJ = [["Glc-family", wt.Blue], ["Man-family", wt.Green], ["Gal-family", wt.Yellow], ["Gul-family", wt.Orange], ["Alt-family", wt.Pink], ["All-family", wt.Purple], ["Tal-family", wt.LightBlue], ["Ido-family", wt.Brown], ["Fuc-family", wt.Red], ["Generic/Unknown/Secondary", wt.Secondary]], qJ = { Glc: ["GLC", "BGC", "Z8T", "TRE", "MLR"], Man: ["MAN", "BMA"], Gal: ["GLA", "GAL", "GZL", "GXL", "GIV"], Gul: ["4GL", "GL0", "GUP", "Z8H"], Alt: ["Z6H", "3MK", "SHD"], All: ["AFD", "ALL", "WOO", "Z2D"], Tal: ["ZEE", "A5C", "SDY"], Ido: ["ZCD", "Z0F", "4N2"], GlcNAc: ["NDG", "NAG", "NGZ"], ManNAc: ["BM3", "BM7"], GalNAc: ["A2G", "NGA", "YYQ"], GulNAc: ["LXB"], AltNAc: [], AllNAc: ["NAA"], TalNAc: [], IdoNAc: ["LXZ", "HSQ"], GlcN: ["PA1", "GCS"], ManN: ["95Z"], GalN: ["X6X", "1GN"], GulN: [], AltN: [], AllN: [], TalN: [], IdoN: [], GlcA: ["GCU", "BDP"], ManA: ["MAV", "BEM"], GalA: ["ADA", "GTR", "GTK"], GulA: ["LGU"], AltA: [], AllA: [], TalA: ["X1X", "X0X"], IdoA: ["IDR"], Qui: ["G6D", "YYK"], Rha: ["RAM", "RM4", "XXR"], "6dGul": ["66O"], "6dAlt": [], "6dTal": [], Fuc: ["FUC", "FUL", "FCA", "FCB", "GYE"], QuiNAc: ["Z9W"], RhaNAc: [], "6dAltNAc": [], "6dTalNAc": [], FucNAc: ["49T"], Oli: ["DDA", "RAE", "Z5J"], Tyv: ["TYV"], Abe: ["ABE"], Par: ["PZU"], Dig: ["Z3U"], Col: [], Ara: ["64K", "ARA", "ARB", "AHR", "FUB", "BXY", "BXX", "SEJ"], Lyx: ["LDY", "Z4W"], Xyl: ["XYS", "XYP", "XYZ", "HSY", "LXC"], Rib: ["YYM", "RIP", "RIB", "BDR", "0MK", "Z6J", "32O"], Kdn: ["KDM", "KDN"], Neu5Ac: ["SIA", "SLB"], Neu5Gc: ["NGC", "NGE"], Neu: [], Sia: [], Pse: [], Leg: [], Aci: [], "4eLeg": [], Bac: [], LDmanHep: ["GMH"], Kdo: ["KDO"], Dha: [], DDmanHep: ["289"], MurNAc: ["MUB", "AMU"], MurNGc: [], Mur: ["1S4", "MUR"], Api: ["XXM"], Fru: ["BDF", "Z9N", "FRU", "LFR"], Tag: ["T6T"], Sor: ["SOE", "UEA"], Psi: ["PSV", "SF6", "SF9", "TTV"] }, HJ = { Glc: ["AGLC", "BGLC"], GlcNAc: ["AGLCNA", "BGLCNA", "BGLCN0"], GlcA: ["AGLCA", "BGLCA", "BGLCA0"], Man: ["AMAN", "BMAN"], Rha: ["ARHM", "BRHM"], Ara: ["AARB", "BARB"], Gal: ["AGAL", "BGAL"], GalNAc: ["AGALNA", "BGALNA"], Gul: ["AGUL", "BGUL"], Alt: ["AALT", "BALT"], All: ["AALL", "BALL"], Tal: ["ATAL", "BTAL"], Ido: ["AIDO", "BIDO"], IdoA: ["AIDOA", "BIDOA"], Fuc: ["AFUC", "BFUC"], Lyx: ["ALYF", "BLYF"], Xyl: ["AXYL", "BXYL", "AXYF", "BXYF"], Rib: ["ARIB", "BRIB"], Fru: ["AFRU", "BFRU"], Neu5Ac: ["ANE5AC", "BNE5AC"] }, Fd = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, r = $2.length; t < r; ++t) {
    var n = $2[t], a = qJ[n.abbr];
    if (a) for (var i = 0, o = a.length; i < o; ++i) e.set(a[i], n);
    var s = HJ[n.abbr];
    if (s) for (i = 0, o = s.length; i < o; ++i) e.set(s[i], n);
  }
  return UJ.forEach(function(u) {
    e.has(u) || e.set(u, CF);
  }), e;
}(), EF = /* @__PURE__ */ new Set(["DAPC", "DBPC", "DFPC", "DGPC", "DIPC", "DLPC", "DNPC", "DOPC", "DPPC", "DRPC", "DTPC", "DVPC", "DXPC", "DYPC", "LPPC", "PAPC", "PEPC", "PGPC", "PIPC", "POPC", "PRPC", "PUPC", "DAPE", "DBPE", "DFPE", "DGPE", "DIPE", "DLPE", "DNPE", "DOPE", "DPPE", "DRPE", "DTPE", "DUPE", "DVPE", "DXPE", "DYPE", "LPPE", "PAPE", "PGPE", "PIPE", "POPE", "PQPE", "PRPE", "PUPE", "DAPS", "DBPS", "DFPS", "DGPS", "DIPS", "DLPS", "DNPS", "DOPS", "DPPS", "DRPS", "DTPS", "DUPS", "DVPS", "DXPS", "DYPS", "LPPS", "PAPS", "PGPS", "PIPS", "POPS", "PQPS", "PRPS", "PUPS", "DAPG", "DBPG", "DFPG", "DGPG", "DIPG", "DLPG", "DNPG", "DOPG", "DPPG", "DRPG", "DTPG", "DVPG", "DXPG", "DYPG", "LPPG", "PAPG", "PGPG", "PIPG", "POPG", "PRPG", "DAPA", "DBPA", "DFPA", "DGPA", "DIPA", "DLPA", "DNPA", "DOPA", "DPPA", "DRPA", "DTPA", "DVPA", "DXPA", "DYPA", "LPPA", "PAPA", "PGPA", "PIPA", "POPA", "PRPA", "PUPA", "DPP", "DPPI", "PAPI", "PIPI", "POP", "POPI", "PUPI", "PVP", "PVPI", "PADG", "PIDG", "PODG", "PUDG", "PVDG", "APC", "CPC", "IPC", "LPC", "OPC", "PPC", "TPC", "UPC", "VPC", "BNSM", "DBSM", "DPSM", "DXSM", "PGSM", "PNSM", "POSM", "PVSM", "XNSM", "DPCE", "DXCE", "PNCE", "XNCE", "DMPC"]), Bh = /* @__PURE__ */ new Set(["118", "119", "543", "1AL", "1CU", "2FK", "2HP", "2OF", "3CO", "3MT", "3NI", "3OF", "3P8", "4MO", "4PU", "4TI", "6MO", "ACT", "AG", "AL", "ALF", "AM", "ATH", "AU", "AU3", "AUC", "AZI", "BA", "BCT", "BEF", "BF4", "BO4", "BR", "BS3", "BSY", "CA", "CAC", "CD", "CD1", "CD3", "CD5", "CE", "CF", "CHT", "CL", "CO", "CO3", "CO5", "CON", "CR", "CS", "CSB", "CU", "CU1", "CU3", "CUA", "CUZ", "CYN", "DME", "DMI", "DSC", "DTI", "DY", "E4N", "EDR", "EMC", "ER3", "EU", "EU3", "F", "FE", "FE2", "FPO", "GA", "GD3", "GEP", "HAI", "HG", "HGC", "IN", "IOD", "IR", "IR3", "IRI", "IUM", "K", "KO4", "LA", "LCO", "LCP", "LI", "LU", "MAC", "MG", "MH2", "MH3", "MLI", "MMC", "MN", "MN3", "MN5", "MN6", "MO1", "MO2", "MO3", "MO4", "MO5", "MO6", "MOO", "MOS", "MOW", "MW1", "MW2", "MW3", "NA", "NA2", "NA5", "NA6", "NAO", "NAW", "ND", "NET", "NH4", "NI", "NI1", "NI2", "NI3", "NO2", "NO3", "NRU", "O4M", "OAA", "OC1", "OC2", "OC3", "OC4", "OC5", "OC6", "OC7", "OC8", "OCL", "OCM", "OCN", "OCO", "OF1", "OF2", "OF3", "OH", "OS", "OS4", "OXL", "PB", "PBM", "PD", "PDV", "PER", "PI", "PO3", "PO4", "PR", "PT", "PT4", "PTN", "RB", "RH3", "RHD", "RU", "SB", "SCN", "SE4", "SEK", "SM", "SMO", "SO3", "SO4", "SR", "T1A", "TB", "TBA", "TCN", "TEA", "TH", "THE", "TL", "TMA", "TRA", "UNX", "V", "VN3", "VO4", "W", "WO5", "Y1", "YB", "YB2", "YH", "YT3", "ZCM", "ZN", "ZN2", "ZN3", "ZNO", "ZO3", "ZR", "NCO", "OHX"]), KJ = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = [], r = 65; r <= 90; r++) t[t.length] = String.fromCharCode(r);
  for (r = 97; r <= 122; r++) t[t.length] = String.fromCharCode(r);
  for (r = 48; r <= 57; r++) t[t.length] = String.fromCharCode(r);
  for (var n = 0, a = t; n < a.length; n++) {
    var i = a[n];
    e[i] = i.toUpperCase();
    for (var o = 0, s = t; o < s.length; o++) {
      var u = s[o];
      e[i + u] = (i + u).toUpperCase();
      for (var c = 0, l = t; c < l.length; c++) {
        var d = l[c];
        e[i + u + d] = (i + u + d).toUpperCase();
      }
    }
  }
  return e;
}();
function Rp(e) {
  return KJ[e] || e.toUpperCase();
}
new Map([[1, "H"], [2, "He"], [3, "Li"], [4, "Be"], [5, "B"], [6, "C"], [7, "N"], [8, "O"], [9, "F"], [10, "Ne"], [11, "Na"], [12, "Mg"], [13, "Al"], [14, "Si"], [15, "P"], [16, "S"], [17, "Cl"], [18, "Ar"], [19, "K"], [20, "Ca"], [21, "Sc"], [22, "Ti"], [23, "V"], [24, "Cr"], [25, "Mn"], [26, "Fe"], [27, "Co"], [28, "Ni"], [29, "Cu"], [30, "Zn"], [31, "Ga"], [32, "Ge"], [33, "As"], [34, "Se"], [35, "Br"], [36, "Kr"], [37, "Rb"], [38, "Sr"], [39, "Y"], [40, "Zr"], [41, "Nb"], [42, "Mo"], [43, "Tc"], [44, "Ru"], [45, "Rh"], [46, "Pd"], [47, "Ag"], [48, "Cd"], [49, "In"], [50, "Sn"], [51, "Sb"], [52, "Te"], [53, "I"], [54, "Xe"], [55, "Cs"], [56, "Ba"], [57, "La"], [58, "Ce"], [59, "Pr"], [60, "Nd"], [61, "Pm"], [62, "Sm"], [63, "Eu"], [64, "Gd"], [65, "Tb"], [66, "Dy"], [67, "Ho"], [68, "Er"], [69, "Tm"], [70, "Yb"], [71, "Lu"], [72, "Hf"], [73, "Ta"], [74, "W"], [75, "Re"], [76, "Os"], [77, "Ir"], [78, "Pt"], [79, "Au"], [80, "Hg"], [81, "Tl"], [82, "Pb"], [83, "Bi"], [84, "Po"], [85, "At"], [86, "Rn"], [87, "Fr"], [88, "Ra"], [89, "Ac"], [90, "Th"], [91, "Pa"], [92, "U"], [93, "Np"], [94, "Pu"], [95, "Am"], [96, "Cm"], [97, "Bk"], [98, "Cf"], [99, "Es"], [100, "Fm"], [101, "Md"], [102, "No"], [103, "Lr"], [104, "Rf"], [105, "Db"], [106, "Sg"], [107, "Bh"], [108, "Hs"], [109, "Mt"], [110, "Ds"], [111, "Rg"], [112, "Cn"], [113, "Uut"], [114, "Fl"], [115, "Uup"], [116, "Lv"], [117, "Uus"], [118, "Uuo"]].map(function(e) {
  return [e[0], Rp(e[1])];
}));
var Er, pr, XJ = ((Xl = {})[0] = { trace: /* @__PURE__ */ new Set(), directionFrom: /* @__PURE__ */ new Set(), directionTo: /* @__PURE__ */ new Set(), backboneStart: /* @__PURE__ */ new Set(), backboneEnd: /* @__PURE__ */ new Set(), coarseBackbone: /* @__PURE__ */ new Set() }, Xl[1] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O", "OC1", "O1", "OX1", "OXT", "OT1"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["C"]), coarseBackbone: /* @__PURE__ */ new Set(["CA", "BB", "CA1"]) }, Xl[2] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["CD"]), coarseBackbone: /* @__PURE__ */ new Set(["CA"]) }, Xl[3] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["CG"]), coarseBackbone: /* @__PURE__ */ new Set(["CA"]) }, Xl[4] = { trace: /* @__PURE__ */ new Set(["O3'", "O3*"]), directionFrom: /* @__PURE__ */ new Set(["C4'", "C4*"]), directionTo: /* @__PURE__ */ new Set(["C3'", "C3*"]), backboneStart: /* @__PURE__ */ new Set(["P"]), backboneEnd: /* @__PURE__ */ new Set(["O3'", "O3*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, Xl[5] = { trace: /* @__PURE__ */ new Set(["O3'", "O3*"]), directionFrom: /* @__PURE__ */ new Set(["C3'", "C3*"]), directionTo: /* @__PURE__ */ new Set(["C1'", "C1*"]), backboneStart: /* @__PURE__ */ new Set(["P"]), backboneEnd: /* @__PURE__ */ new Set(["O3'", "O3*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, Xl[6] = { trace: /* @__PURE__ */ new Set(["N4'", "N4*"]), directionFrom: /* @__PURE__ */ new Set(["N4'", "N4*"]), directionTo: /* @__PURE__ */ new Set(["C7'", "C7*"]), backboneStart: /* @__PURE__ */ new Set(["N1'", "N1*"]), backboneEnd: /* @__PURE__ */ new Set(["C'", "C*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, Xl), _8 = /* @__PURE__ */ new Set(["CA", "C", "N", "O", "O1", "O2", "OC1", "OC2", "OT1", "OT2", "OX1", "OXT", "H", "H1", "H2", "H3", "HA", "HN", "HXT", "BB"]), jJ = /* @__PURE__ */ new Set(["P", "OP1", "OP2", "HOP2", "HOP3", "O2'", "O3'", "O4'", "O5'", "C1'", "C2'", "C3'", "C4'", "C5'", "H1'", "H2'", "H2''", "HO2'", "H3'", "H4'", "H5'", "H5''", "HO3'", "HO5'", "O2*", "O3*", "O4*", "O5*", "C1*", "C2*", "C3*", "C4*", "C5*"]), DF = /* @__PURE__ */ new Set(["D-PEPTIDE LINKING", "D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "D-GAMMA-PEPTIDE, C-DELTA LINKING", "D-BETA-PEPTIDE, C-GAMMA LINKING"]), MF = /* @__PURE__ */ new Set(["L-PEPTIDE LINKING", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS", "L-GAMMA-PEPTIDE, C-DELTA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), YJ = /* @__PURE__ */ new Set(["D-GAMMA-PEPTIDE, C-DELTA LINKING", "L-GAMMA-PEPTIDE, C-DELTA LINKING"]), WJ = /* @__PURE__ */ new Set(["D-BETA-PEPTIDE, C-GAMMA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), ZJ = /* @__PURE__ */ new Set(["D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS"]), IF = /* @__PURE__ */ new Set(["PEPTIDE LINKING", "PEPTIDE-LIKE"]), QJ = bo.unionMany(DF, MF, IF), TF = /* @__PURE__ */ new Set(["DNA LINKING", "L-DNA LINKING", "DNA OH 5 PRIME TERMINUS", "DNA OH 3 PRIME TERMINUS"]), NF = /* @__PURE__ */ new Set(["RNA LINKING", "L-RNA LINKING", "RNA OH 5 PRIME TERMINUS", "RNA OH 3 PRIME TERMINUS"]), PF = /* @__PURE__ */ new Set(["D-SACCHARIDE, BETA LINKING", "L-SACCHARIDE, BETA LINKING", "D-SACCHARIDE, ALPHA LINKING", "L-SACCHARIDE, ALPHA LINKING", "L-SACCHARIDE", "D-SACCHARIDE", "SACCHARIDE", "D-SACCHARIDE 1,4 AND 1,4 LINKING", "L-SACCHARIDE 1,4 AND 1,4 LINKING", "D-SACCHARIDE 1,4 AND 1,6 LINKING", "L-SACCHARIDE 1,4 AND 1,6 LINKING"]), $J = /* @__PURE__ */ new Set(["NON-POLYMER", "OTHER"]), JJ = /* @__PURE__ */ new Set(["ION"]), eee = /* @__PURE__ */ new Set(["LIPID"]), m1 = /* @__PURE__ */ new Set(["SOL", "WAT", "HOH", "H2O", "W", "DOD", "D3O", "TIP", "TIP3", "TIP4", "SPC"]), BF = /* @__PURE__ */ new Set(["HIS", "ARG", "LYS", "ILE", "PHE", "LEU", "TRP", "ALA", "MET", "PRO", "CYS", "ASN", "VAL", "GLY", "SER", "GLN", "TYR", "ASP", "GLU", "THR", "SEC", "PYL", "UNK", "MSE", "SEP", "TPO", "PTR", "PCA", "HSD", "HSE", "HSP", "LSN", "ASPP", "GLUP", "HID", "HIE", "HIP", "LYN", "ASH", "GLH", "ACE", "NME"]), OF = /* @__PURE__ */ new Set(["DAL", "DAR", "DSG", "DAS", "DCY", "DGL", "DGN", "DHI", "DIL", "DLE", "DLY", "MED", "DPN", "DPR", "DSN", "DTH", "DTR", "DTY", "DVA", "DNE"]), Oh = bo.unionMany(BF, OF), u3 = /* @__PURE__ */ new Set(["A", "C", "T", "G", "I", "U", "N"]), c3 = /* @__PURE__ */ new Set(["DA", "DC", "DT", "DG", "DI", "DU", "DN"]), S8 = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), tee = /* @__PURE__ */ new Set(["A", "G", "I", "DA", "DG", "DI", "APN", "GPN"]), ree = /* @__PURE__ */ new Set(["C", "T", "U", "DC", "DT", "DU", "CPN", "TPN"]), A8 = bo.unionMany(u3, c3, S8), FF = function(e) {
  return tee.has(e.toUpperCase());
}, RF = function(e) {
  return ree.has(e.toUpperCase());
}, w8 = bo.unionMany(Oh, A8);
function Fh(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), S8.has(t) ? 8 : QJ.has(e) ? 5 : NF.has(e) ? 6 : TF.has(e) ? 7 : PF.has(e) ? 9 : m1.has(t) ? 2 : Bh.has(t) ? 3 : EF.has(t) ? 4 : $J.has(e) ? Fd.has(t) ? 9 : Oh.has(t) ? 5 : u3.has(t) ? 6 : c3.has(t) ? 7 : 1 : 0;
}
function nee(e, t) {
  return e = e.toUpperCase(), t === 5 ? YJ.has(e) ? 2 : WJ.has(e) ? 3 : ZJ.has(e) ? 0 : 1 : t === 6 ? 4 : t === 7 ? 5 : t === 8 ? 6 : 0;
}
function LF(e) {
  return e = e.toUpperCase(), Oh.has(e) ? "peptide linking" : u3.has(e) ? "RNA linking" : c3.has(e) ? "DNA linking" : Fd.has(e) ? "saccharide" : "other";
}
function aee(e) {
  return e = e.toUpperCase(), m1.has(e) ? "water" : w8.has(e) ? "polymer" : Fd.has(e) ? "branched" : "non-polymer";
}
function iee(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), MF.has(t) ? "polypeptide(L)" : DF.has(t) ? "polypeptide(D)" : NF.has(t) ? "polyribonucleotide" : TF.has(t) ? "polydeoxyribonucleotide" : PF.has(t) || Fd.has(e) ? "oligosaccharide" : S8.has(e) ? "peptide nucleic acid" : BF.has(e) ? "polypeptide(L)" : OF.has(e) ? "polypeptide(D)" : u3.has(e) ? "polyribonucleotide" : c3.has(e) ? "polydeoxyribonucleotide" : JJ.has(t) || Bh.has(e) ? "ion" : eee.has(t) || EF.has(e) ? "lipid" : IF.has(t) ? "peptide-like" : "other";
}
function C8(e) {
  return p1(e) || kF(e);
}
function p1(e) {
  return e === 7 || e === 6 || e === 8;
}
function kF(e) {
  return e === 5;
}
(function(e) {
  e.is = Ti.has, e.create = Ti.create, e.SecondaryStructureMmcif = { HELX_LH_27_P: 1058, HELX_LH_3T_P: 2082, HELX_LH_AL_P: 4130, HELX_LH_A_N: 524321, HELX_LH_B_N: 1048609, HELX_LH_GA_P: 8226, HELX_LH_N: 33, HELX_LH_OM_P: 16418, HELX_LH_OT_N: 131105, HELX_LH_OT_P: 546, HELX_LH_P: 34, HELX_LH_PI_P: 32802, HELX_LH_PP_P: 65570, HELX_LH_Z_N: 262177, HELX_N: 1, HELX_OT_N: 1, HELX_OT_P: 2, HELX_P: 2, HELX_RH_27_P: 1090, HELX_RH_3T_P: 2114, HELX_RH_AL_P: 4162, HELX_RH_A_N: 524353, HELX_RH_B_N: 1048641, HELX_RH_GA_P: 8258, HELX_RH_N: 65, HELX_RH_OM_P: 16450, HELX_RH_OT_N: 131137, HELX_RH_OT_P: 578, HELX_RH_P: 66, HELX_RH_PI_P: 32834, HELX_RH_PP_P: 65602, HELX_RH_Z_N: 262209, STRN: 4194308, TURN_OT_P: 33554448, TURN_P: 16, TURN_TY1P_P: 67109136, TURN_TY1_P: 67109008, TURN_TY2P_P: 134218e3, TURN_TY2_P: 134217872, TURN_TY3P_P: 268435728, TURN_TY3_P: 268435600 }, e.SecondaryStructurePdb = { 1: 4162, 2: 16450, 3: 32834, 4: 8258, 5: 2114, 6: 4130, 7: 16418, 8: 8226, 9: 1026, 10: 65538 }, e.SecondaryStructureStride = { H: 4098, G: 2050, I: 32770, E: 8388612, B: 4194308, T: 16, C: 536870912 }, e.SecondaryStructureDssp = { H: 4098, B: 4194308, E: 8388612, G: 2050, I: 32770, T: 16, S: 8 };
})(Er || (Er = {})), function(e) {
  function t(r) {
    switch (r) {
      case "covalent":
        return 1;
      case "metal-coordination":
        return 2;
      case "hydrogen-bond":
        return 4;
      case "disulfide":
        return 8;
      case "aromatic":
        return 16;
      case "computed":
        return 32;
    }
  }
  e.is = Ti.has, e.create = function(r) {
    return Ti.create(r);
  }, e.isCovalent = function(r) {
    return !!(1 & r);
  }, e.isAll = function(r) {
    return r === Math.pow(2, 6) - 1;
  }, e.Names = { covalent: 1, "metal-coordination": 2, "hydrogen-bond": 4, disulfide: 8, aromatic: 16, computed: 32 }, e.isName = function(r) {
    return r in e.Names;
  }, e.fromName = t, e.fromNames = function(r) {
    for (var n = 0, a = 0, i = r.length; a < i; ++a) n |= t(r[a]);
    return n;
  };
}(pr || (pr = {}));
var N4 = { ALA: [0.17, 0.5, 0.33], ARG: [0.81, 1.81, 1], ASN: [0.42, 0.85, 0.43], ASP: [1.23, 3.64, 2.41], ASH: [-0.07, 0.43, 0.5], CYS: [-0.24, -0.02, 0.22], GLN: [0.58, 0.77, 0.19], GLU: [2.02, 3.63, 1.61], GLH: [-0.01, 0.11, 0.12], GLY: [0.01, 1.15, 1.14], HIS: [0.17, 0.11, -0.06], ILE: [-0.31, -1.12, -0.81], LEU: [-0.56, -1.25, -0.69], LYS: [0.99, 2.8, 1.81], MET: [-0.23, -0.67, -0.44], PHE: [-1.13, -1.71, -0.58], PRO: [0.45, 0.14, -0.31], SER: [0.13, 0.46, 0.33], THR: [0.14, 0.25, 0.11], TRP: [-1.85, -2.09, -0.24], TYR: [-0.94, -0.71, 0.23], VAL: [0.07, -0.46, -0.53], HSD: [0.17, 0.11, -0.06], HSE: [0.17, 0.11, -0.06], HSP: [0.96, 2.33, 1.37], HID: [0.17, 0.11, -0.06], HIE: [0.17, 0.11, -0.06], HIP: [0.96, 2.33, 1.37] }, Lp = function() {
  function e() {
    this.count = 0, this.center = D(), this.radiusSq = 0;
  }
  return e.prototype.reset = function() {
    D.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
  }, e.prototype.includeStep = function(t) {
    D.add(this.center, this.center, t), this.count++;
  }, e.prototype.finishedIncludeStep = function() {
    this.count !== 0 && D.scale(this.center, this.center, 1 / this.count);
  }, e.prototype.radiusStep = function(t) {
    var r = D.squaredDistance(t, this.center);
    r > this.radiusSq && (this.radiusSq = r);
  }, e.prototype.radiusSphereStep = function(t, r) {
    var n = D.distance(t, this.center) + r, a = n * n;
    a > this.radiusSq && (this.radiusSq = a);
  }, e.prototype.getSphere = function(t) {
    return t || (t = Ve()), D.copy(t.center, this.center), t.radius = Math.sqrt(this.radiusSq), t;
  }, e.prototype.getCount = function() {
    return this.count;
  }, e;
}();
(function(e) {
  var t = new e(), r = D(), n = D();
  e.fromArrays = function(a, i) {
    var o = a.x, s = a.y, u = a.z;
    t.reset();
    for (var c = o.length, l = 0; l < c; l++) D.set(r, o[l], s[l], u[l]), t.includeStep(r);
    for (t.finishedIncludeStep(), l = 0; l < c; l++) D.set(r, o[l], s[l], u[l]), t.radiusStep(r);
    return D.copy(i.center, t.center), i.radius = Math.sqrt(t.radiusSq), i;
  }, e.fromProvider = function(a, i, o) {
    t.reset();
    for (var s = 0; s < a; s++) i(s, r), t.includeStep(r);
    for (t.finishedIncludeStep(), s = 0; s < a; s++) i(s, r), t.radiusStep(r);
    return D.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  }, e.fromPairProvider = function(a, i, o) {
    t.reset();
    for (var s = 0; s < a; s++) i(s, r, n), t.includeStep(r), t.includeStep(n);
    for (t.finishedIncludeStep(), s = 0; s < a; s++) i(s, r, n), t.radiusStep(r), t.radiusStep(n);
    return D.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  };
})(Lp || (Lp = {}));
var em = function() {
  function e(t) {
    this.map = t;
    var r = 0, n = [], a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
    this.map.forEach(function(o) {
      o.forEach(function(s) {
        r += s.edgeCount, s.connectedIndices.forEach(function(u) {
          s.getEdges(u).forEach(function(c) {
            var l = s.unitA, d = s.unitB, f = e.getEdgeKey(u, l, c.indexB, d);
            a.set(f, n.length);
            var m = e.getVertexKey(u, l), h = i.get(m);
            h === void 0 ? i.set(m, [n.length]) : h.push(n.length), n.push(k(k({}, c), { indexA: u, unitA: l, unitB: d }));
          });
        });
      });
    }), this.edgeCount = r, this.edges = n, this.edgeKeyIndex = a, this.vertexKeyIndex = i;
  }
  return e.prototype.getConnectedUnits = function(t) {
    return this.map.has(t) ? this.map.get(t) : zF;
  }, e.prototype.getEdgeIndex = function(t, r, n, a) {
    var i = e.getEdgeKey(t, r, n, a), o = this.edgeKeyIndex.get(i);
    return o !== void 0 ? o : -1;
  }, e.prototype.hasEdge = function(t, r, n, a) {
    return this.getEdgeIndex(t, r, n, a) !== -1;
  }, e.prototype.getEdge = function(t, r, n, a) {
    var i = this.getEdgeIndex(t, r, n, a);
    return i !== -1 ? this.edges[i] : void 0;
  }, e.prototype.getEdgeIndices = function(t, r) {
    return this.vertexKeyIndex.get(e.getVertexKey(t, r)) || [];
  }, e;
}();
(function(e) {
  var t = function() {
    function a(i, o, s, u, c) {
      this.unitA = i, this.unitB = o, this.edgeCount = s, this.connectedIndices = u, this.edgeMap = c;
    }
    return a.prototype.hasEdges = function(i) {
      return this.edgeMap.has(i);
    }, a.prototype.getEdges = function(i) {
      return this.edgeMap.has(i) ? this.edgeMap.get(i) : zF;
    }, Object.defineProperty(a.prototype, "areUnitsOrdered", { get: function() {
      return this.unitA < this.unitB;
    }, enumerable: !1, configurable: !0 }), a;
  }();
  function r(a, i, o) {
    a.has(i) ? a.get(i).push(o) : a.set(i, [o]);
  }
  e.UnitPairEdges = t, e.getEdgeKey = function(a, i, o, s) {
    return "".concat(a, "|").concat(i, "|").concat(o, "|").concat(s);
  }, e.getVertexKey = function(a, i) {
    return "".concat(a, "|").concat(i);
  };
  var n = function() {
    function a() {
      this.map = /* @__PURE__ */ new Map();
    }
    return a.prototype.startUnitPair = function(i, o) {
      this.uA = i, this.uB = o, this.mapAB = /* @__PURE__ */ new Map(), this.mapBA = /* @__PURE__ */ new Map(), this.linkedA = Sn.create(), this.linkedB = Sn.create(), this.linkCount = 0;
    }, a.prototype.finishUnitPair = function() {
      this.linkCount !== 0 && (r(this.map, this.uA, new t(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), r(this.map, this.uB, new t(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA)));
    }, a.prototype.add = function(i, o, s) {
      r(this.mapAB, i, { indexB: o, props: s }), r(this.mapBA, o, { indexB: i, props: s }), Sn.add(this.linkedA, i, i), Sn.add(this.linkedB, o, o), this.linkCount += 1;
    }, a.prototype.getMap = function() {
      return this.map;
    }, a;
  }();
  e.Builder = n;
})(em || (em = {}));
var c6, zF = [];
(function(e) {
  e.Empty = Ho.create([], [], [], 0, { flags: [], order: [] });
})(c6 || (c6 = {}));
var J2 = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return Ii(t, e), t.prototype.getBondFromLocation = function(r) {
    return Ke.isAtomic(r.aUnit) && Ke.isAtomic(r.bUnit) ? this.getEdge(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : void 0;
  }, t.prototype.getBondIndexFromLocation = function(r) {
    return Ke.isAtomic(r.aUnit) && Ke.isAtomic(r.bUnit) ? this.getEdgeIndex(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : -1;
  }, t;
}(em);
(function(e) {
  var t = function(r) {
    function n() {
      return r !== null && r.apply(this, arguments) || this;
    }
    return Ii(n, r), n;
  }(em.UnitPairEdges);
  e.UnitPairBonds = t;
})(J2 || (J2 = {}));
var UF = { forceCompute: !1, noCompute: !1, maxRadius: 4 }, sh = { H: 0, h: 0, D: 0, d: 0, T: 0, t: 0, He: 2, HE: 2, he: 2, Li: 3, LI: 3, li: 3, Be: 4, BE: 4, be: 4, B: 5, b: 5, C: 6, c: 6, N: 7, n: 7, O: 8, o: 8, F: 9, f: 9, Ne: 10, NE: 10, ne: 10, Na: 11, NA: 11, na: 11, Mg: 12, MG: 12, mg: 12, Al: 13, AL: 13, al: 13, Si: 14, SI: 14, si: 14, P: 15, p: 15, S: 16, s: 16, Cl: 17, CL: 17, cl: 17, Ar: 18, AR: 18, ar: 18, K: 19, k: 19, Ca: 20, CA: 20, ca: 20, Sc: 21, SC: 21, sc: 21, Ti: 22, TI: 22, ti: 22, V: 23, v: 23, Cr: 24, CR: 24, cr: 24, Mn: 25, MN: 25, mn: 25, Fe: 26, FE: 26, fe: 26, Co: 27, CO: 27, co: 27, Ni: 28, NI: 28, ni: 28, Cu: 29, CU: 29, cu: 29, Zn: 30, ZN: 30, zn: 30, Ga: 31, GA: 31, ga: 31, Ge: 32, GE: 32, ge: 32, As: 33, AS: 33, as: 33, Se: 34, SE: 34, se: 34, Br: 35, BR: 35, br: 35, Kr: 36, KR: 36, kr: 36, Rb: 37, RB: 37, rb: 37, Sr: 38, SR: 38, sr: 38, Y: 39, y: 39, Zr: 40, ZR: 40, zr: 40, Nb: 41, NB: 41, nb: 41, Mo: 42, MO: 42, mo: 42, Tc: 43, TC: 43, tc: 43, Ru: 44, RU: 44, ru: 44, Rh: 45, RH: 45, rh: 45, Pd: 46, PD: 46, pd: 46, Ag: 47, AG: 47, ag: 47, Cd: 48, CD: 48, cd: 48, In: 49, IN: 49, in: 49, Sn: 50, SN: 50, sn: 50, Sb: 51, SB: 51, sb: 51, Te: 52, TE: 52, te: 52, I: 53, i: 53, Xe: 54, XE: 54, xe: 54, Cs: 55, CS: 55, cs: 55, Ba: 56, BA: 56, ba: 56, La: 57, LA: 57, la: 57, Ce: 58, CE: 58, ce: 58, Pr: 59, PR: 59, pr: 59, Nd: 60, ND: 60, nd: 60, Pm: 61, PM: 61, pm: 61, Sm: 62, SM: 62, sm: 62, Eu: 63, EU: 63, eu: 63, Gd: 64, GD: 64, gd: 64, Tb: 65, TB: 65, tb: 65, Dy: 66, DY: 66, dy: 66, Ho: 67, HO: 67, ho: 67, Er: 68, ER: 68, er: 68, Tm: 69, TM: 69, tm: 69, Yb: 70, YB: 70, yb: 70, Lu: 71, LU: 71, lu: 71, Hf: 72, HF: 72, hf: 72, Ta: 73, TA: 73, ta: 73, W: 74, w: 74, Re: 75, RE: 75, re: 75, Os: 76, OS: 76, os: 76, Ir: 77, IR: 77, ir: 77, Pt: 78, PT: 78, pt: 78, Au: 79, AU: 79, au: 79, Hg: 80, HG: 80, hg: 80, Tl: 81, TL: 81, tl: 81, Pb: 82, PB: 82, pb: 82, Bi: 83, BI: 83, bi: 83, Po: 84, PO: 84, po: 84, At: 85, AT: 85, at: 85, Rn: 86, RN: 86, rn: 86, Fr: 87, FR: 87, fr: 87, Ra: 88, RA: 88, ra: 88, Ac: 89, AC: 89, ac: 89, Th: 90, TH: 90, th: 90, Pa: 91, PA: 91, pa: 91, U: 92, u: 92, Np: 93, NP: 93, np: 93, Pu: 94, PU: 94, pu: 94, Am: 95, AM: 95, am: 95, Cm: 96, CM: 96, cm: 96, Bk: 97, BK: 97, bk: 97, Cf: 98, CF: 98, cf: 98, Es: 99, ES: 99, es: 99, Fm: 100, FM: 100, fm: 100, Md: 101, MD: 101, md: 101, No: 102, NO: 102, no: 102, Lr: 103, LR: 103, lr: 103, Rf: 104, RF: 104, rf: 104, Db: 105, DB: 105, db: 105, Sg: 106, SG: 106, sg: 106, Bh: 107, BH: 107, bh: 107, Hs: 108, HS: 108, hs: 108, Mt: 109, MT: 109, mt: 109, NH: 113 }, oee = { 0: 1.42, 1: 1.42, 3: 2.7, 4: 2.7, 6: 1.75, 7: 1.6, 8: 1.52, 11: 2.7, 12: 2.7, 13: 2.7, 14: 1.9, 15: 2, 16: 1.9, 17: 1.8, 19: 2.7, 20: 2.7, 21: 2.7, 22: 2.7, 23: 2.7, 24: 2.7, 25: 2.7, 26: 2.7, 27: 2.7, 28: 2.7, 29: 2.7, 30: 2.7, 31: 2.7, 33: 2.68, 37: 2.7, 38: 2.7, 39: 2.7, 40: 2.7, 41: 2.7, 42: 2.7, 43: 2.7, 44: 2.7, 45: 2.7, 46: 2.7, 47: 2.7, 48: 2.7, 49: 2.7, 50: 2.7, 55: 2.7, 56: 2.7, 57: 2.7, 58: 2.7, 59: 2.7, 60: 2.7, 61: 2.7, 62: 2.7, 63: 2.7, 64: 2.7, 65: 2.7, 66: 2.7, 67: 2.7, 68: 2.7, 69: 2.7, 70: 2.7, 71: 2.7, 72: 2.7, 73: 2.7, 74: 2.7, 75: 2.7, 76: 2.7, 77: 2.7, 78: 2.7, 79: 2.7, 80: 2.7, 81: 2.7, 82: 2.7, 83: 2.7, 87: 2.7, 88: 2.7, 89: 2.7, 90: 2.7, 91: 2.7, 92: 2.7, 93: 2.7, 94: 2.7, 95: 2.7, 96: 2.7, 97: 2.7, 98: 2.7, 99: 2.7, 100: 2.7, 101: 2.7, 102: 2.7, 103: 2.7, 104: 2.7, 105: 2.7, 106: 2.7, 107: 2.7, 108: 2.7, 109: 2.88 }, GF = { 0: 0.8, 20: 1.31, 27: 1.2, 35: 1.15, 44: 1.25, 54: 1, 60: 1.84, 72: 1.88, 84: 1.75, 85: 1.56, 86: 1.76, 98: 1.6, 99: 1.68, 100: 1.63, 112: 1.6, 113: 1.59, 114: 1.36, 129: 1.45, 135: 1.47, 144: 1.6, 152: 1.45, 170: 1.4, 180: 1.55, 202: 2.4, 222: 2.24, 224: 1.91, 225: 1.98, 243: 2.02, 269: 2, 293: 1.9, 316: 1.8, 420: 2.37, 480: 2.3, 512: 2.3, 544: 2.3, 612: 2.1, 629: 1.54, 665: 1, 813: 2.6, 854: 2.27, 894: 1.93, 896: 2.1, 937: 2.05, 938: 2.06, 981: 1.62, 1258: 2.68, 1309: 2.33, 1484: 1, 1763: 2.14, 1823: 2.48, 1882: 2.1, 1944: 1.72, 2380: 2.34, 3367: 2.44, 3733: 2.11, 3819: 2.6, 3821: 2.36, 4736: 2.75, 5724: 2.73, 5959: 2.63, 6519: 2.84, 6750: 2.87, 8991: 2.81 }, VF = { 14: 1.71649, 20: 1.59646, 27: 1.2, 35: 1.2, 44: 1.2, 54: 1.1, 60: 1.85846, 62: 2.66213, 73: 2.10649, 74: 2.60087, 77: 2.79942, 84: 1.89002, 85: 1.93846, 86: 1.98749, 87: 2.34276, 90: 2.24293, 98: 1.79202, 99: 1.82746, 100: 1.88749, 104: 1.90646, 112: 1.8826, 113: 1.97249, 114: 1.76646, 119: 1.82002, 128: 1.81746, 129: 1.76002, 135: 1.45998, 144: 1.7, 145: 1.82646, 152: 1.42998, 170: 1.5, 182: 3.12942, 201: 2.95693, 202: 2.56293, 205: 2.55649, 206: 3.02481, 209: 3.21942, 221: 2.80398, 222: 2.41824, 223: 2.24646, 224: 2.23302, 225: 2.37646, 226: 2.43649, 227: 2.91814, 230: 2.69295, 243: 2.29093, 244: 2.1074, 245: 2.12002, 246: 1.93998, 247: 2.27646, 248: 2.36649, 252: 2.24291, 266: 2.00146, 267: 1.99002, 268: 1.97146, 269: 2.15002, 270: 2.19646, 275: 1.76642, 290: 1.93002, 291: 2.08646, 292: 2.28849, 293: 2.11002, 299: 1.73642, 315: 2.01002, 316: 1.8, 317: 2.20646, 324: 1.67642, 341: 1.95002, 342: 2.16646, 350: 1.70642, 366: 3.47942, 368: 2.14646, 370: 3.41942, 377: 1.68642, 393: 3.00293, 394: 3.57685, 397: 3.25142, 398: 3.00295, 405: 1.9278, 420: 2.6, 421: 2.69646, 422: 2.89293, 423: 3.39412, 425: 3.11142, 426: 2.83062, 427: 2.54291, 434: 1.44998, 450: 2.58002, 451: 2.66646, 452: 2.79293, 455: 2.70495, 456: 2.42029, 457: 2.08642, 464: 1.81649, 480: 2.48381, 481: 2.47602, 482: 2.48846, 486: 2.32291, 487: 2.35391, 488: 2.38329, 495: 2.13293, 512: 2.57646, 513: 2.38002, 518: 2.86293, 519: 2.84939, 520: 2.5152, 527: 1.55998, 544: 2.2, 545: 2.28746, 551: 2.87293, 552: 2.44293, 553: 2.56193, 554: 2.25191, 560: 1.59998, 578: 2.37002, 585: 2.45293, 586: 2.51652, 587: 2.48193, 588: 2.19691, 612: 2.14296, 614: 3.44942, 620: 2.41093, 621: 2.44693, 622: 2.36293, 629: 1.58998, 649: 3.79285, 650: 3.41295, 656: 2.36293, 657: 2.40493, 658: 2.30649, 659: 2.32649, 685: 3.65976, 686: 3.31295, 687: 2.96291, 693: 2.35293, 694: 2.28149, 695: 2.49295, 723: 3.23295, 724: 2.88391, 725: 2.51642, 731: 2.20249, 732: 2.47295, 733: 2.43293, 736: 2.60649, 737: 3.2433, 740: 3.43645, 762: 2.92291, 763: 2.74646, 764: 2.46642, 770: 2.46295, 771: 2.41693, 772: 1.96, 774: 2.42646, 775: 2.57649, 776: 3.11654, 779: 2.87295, 802: 3.02293, 803: 2.82293, 804: 2.42642, 810: 2.38293, 811: 2.18646, 812: 1.92998, 813: 2.38646, 814: 2.40646, 815: 2.50649, 819: 2.46649, 843: 3.15293, 844: 2.72491, 845: 2.39642, 851: 2.14646, 852: 2.09802, 854: 2.01998, 855: 2.33646, 860: 2.29004, 885: 2.80293, 886: 2.93293, 887: 2.42642, 893: 2.01002, 894: 2.24546, 895: 2.1, 896: 2.26002, 902: 1.90642, 928: 2.84593, 929: 2.83793, 930: 2.36642, 936: 2.15646, 937: 2.16102, 945: 1.83701, 972: 2.86293, 973: 2.65293, 974: 2.31998, 980: 2.08002, 981: 2.35646, 1017: 2.74593, 1018: 2.58649, 1019: 2.65649, 1023: 3.64942, 1025: 2.20646, 1027: 3.79645, 1034: 1.65998, 1063: 2.62649, 1064: 2.76095, 1065: 2.86293, 1068: 3.09293, 1069: 3.71593, 1071: 2.67549, 1072: 3.43945, 1073: 3.09295, 1080: 1.59998, 1110: 2.75295, 1111: 2.80293, 1112: 2.46998, 1114: 2.75646, 1115: 3.03293, 1116: 3.57715, 1118: 3.37645, 1119: 2.98095, 1120: 2.77649, 1127: 1.51998, 1158: 2.72293, 1159: 2.61946, 1160: 2.36998, 1161: 2.66002, 1162: 2.72646, 1163: 2.99293, 1166: 2.88195, 1167: 2.62549, 1168: 2.65004, 1175: 1.65642, 1207: 2.52646, 1208: 2.56702, 1209: 2.29998, 1210: 2.61002, 1211: 2.65646, 1215: 2.51049, 1216: 3.09651, 1217: 2.46046, 1224: 2.52295, 1257: 2.49002, 1258: 2.84649, 1259: 2.69646, 1260: 2.55002, 1265: 2.99651, 1266: 2.45329, 1267: 2.4735, 1274: 1.87642, 1308: 2.61646, 1309: 2.81649, 1310: 2.44293, 1316: 2.35646, 1317: 2.3475, 1325: 2.00642, 1360: 2.57002, 1361: 2.21998, 1368: 2.2998, 1369: 2.22446, 1370: 2.2626, 1377: 2.81998, 1411: 3.94942, 1413: 2.33296, 1415: 3.50645, 1421: 2.24219, 1422: 2.22646, 1423: 2.2626, 1424: 2.33649, 1430: 1.87998, 1464: 3.48295, 1465: 4.00186, 1468: 3.97645, 1469: 3.43295, 1475: 2.57646, 1476: 2.24946, 1477: 2.40451, 1518: 3.04291, 1519: 3.42295, 1520: 3.8513, 1522: 3.86664, 1523: 3.51295, 1524: 3.17649, 1530: 2.16646, 1531: 2.39849, 1532: 2.00642, 1573: 2.87642, 1574: 3.00291, 1575: 3.36995, 1578: 3.37295, 1579: 3.08649, 1580: 3.02004, 1586: 2.34649, 1587: 2.81139, 1588: 2.82295, 1592: 3.42496, 1595: 3.55942, 1629: 2.54642, 1630: 2.53642, 1631: 2.94291, 1635: 3.00649, 1636: 2.91004, 1637: 2.61642, 1643: 2.76939, 1644: 2.76695, 1645: 2.18642, 1648: 2.81649, 1649: 3.37676, 1652: 3.08295, 1686: 2.49642, 1687: 2.48642, 1688: 3.20293, 1693: 3.33651, 1694: 2.74, 1695: 2.54701, 1701: 2.67395, 1702: 2.46491, 1703: 2.7152, 1705: 2.65646, 1706: 2.70649, 1710: 2.77293, 1744: 2.51642, 1745: 2.44642, 1746: 2.87329, 1752: 2.76291, 1753: 2.80067, 1760: 2.35491, 1761: 2.82146, 1762: 2.56446, 1763: 2.25998, 1764: 2.55646, 1769: 2.34644, 1803: 2.50642, 1804: 2.47642, 1805: 2.97293, 1812: 2.80447, 1814: 2.33998, 1820: 2.63793, 1821: 2.45237, 1822: 2.16998, 1823: 2.16998, 1829: 2.62649, 1863: 2.43642, 1864: 2.43642, 1865: 3.05293, 1873: 2.56002, 1874: 2.6426, 1875: 2.43998, 1881: 2.35646, 1882: 2.3334, 1924: 2.28998, 1925: 2.39642, 1926: 2.8952, 1935: 2.70646, 1936: 2.19998, 1937: 2.46998, 1943: 2.22002, 1944: 2.47646, 1986: 2.71895, 1987: 2.18998, 1988: 2.33642, 1998: 2.62646, 1999: 2.69649, 2e3: 2.37642, 2006: 3.18295, 2007: 2.63451, 2008: 3.94942, 2015: 2.56649, 2049: 2.95293, 2050: 2.76295, 2051: 2.80649, 2062: 2.65649, 2063: 3.08839, 2064: 3.20295, 2068: 3.95459, 2070: 2.62649, 2071: 3.53642, 2072: 3.33295, 2079: 2.18898, 2112: 2.6, 2113: 2.38998, 2114: 2.93293, 2115: 2.89295, 2127: 3.05939, 2128: 3.16695, 2129: 2.68642, 2132: 3.24293, 2133: 3.88251, 2135: 3.49942, 2136: 3.14795, 2137: 3.05293, 2144: 2.13, 2178: 2.47998, 2179: 3.41295, 2180: 2.86293, 2193: 3.09295, 2194: 2.93291, 2195: 2.60642, 2197: 2.93646, 2198: 3.17293, 2201: 3.05095, 2202: 2.90983, 2203: 2.78549, 2210: 2.51649, 2245: 2.70002, 2246: 2.6426, 2260: 3.52939, 2261: 3.15293, 2262: 2.56998, 2263: 2.84002, 2264: 2.86646, 2268: 2.79293, 2269: 2.86393, 2270: 2.90649, 2277: 2.09, 2312: 2.98649, 2313: 2.34998, 2328: 3.13111, 2329: 3.05, 2330: 2.56998, 2331: 2.76002, 2336: 2.75452, 2337: 2.74449, 2338: 3.01293, 2345: 2.11898, 2380: 2.93649, 2381: 2.80646, 2397: 2.80646, 2398: 2.79002, 2399: 2.44998, 2405: 2.62945, 2406: 2.8587, 2414: 2.06, 2450: 2.78002, 2467: 2.73906, 2468: 2.40998, 2475: 2.73452, 2477: 3.02351, 2484: 2.45649, 2522: 4.04645, 2538: 3.33295, 2540: 3.64194, 2546: 2.55233, 2547: 2.88251, 2548: 2.95549, 2555: 2.42649, 2593: 4.13773, 2594: 3.62295, 2608: 4.23284, 2611: 4.24942, 2612: 3.48295, 2618: 2.60649, 2619: 2.94249, 2620: 2.42, 2627: 2.42649, 2665: 4.05498, 2666: 3.58295, 2667: 3.24649, 2680: 3.62295, 2681: 4.11717, 2683: 3.91042, 2684: 3.66195, 2685: 3.32293, 2691: 2.83549, 2692: 2.76651, 2693: 2.80649, 2700: 1.93642, 2739: 3.54295, 2740: 3.21649, 2741: 3.07004, 2753: 3.20291, 2754: 3.58295, 2757: 3.55295, 2758: 3.35593, 2759: 3.00644, 2765: 3.15651, 2766: 2.65549, 2767: 2.38, 2774: 1.91642, 2814: 3.15649, 2815: 3.03004, 2816: 2.69642, 2824: 3.14729, 2827: 2.95642, 2828: 3.15291, 2832: 3.33452, 2833: 3.36293, 2834: 3.28649, 2840: 2.54249, 2841: 2.65651, 2842: 2.41898, 2849: 1.80998, 2890: 2.98004, 2891: 2.66642, 2892: 2.62701, 2902: 2.72642, 2903: 3.08291, 2908: 3.25293, 2909: 3.20649, 2916: 2.52944, 2917: 2.67047, 2918: 2.36, 2925: 1.79998, 2967: 3.07646, 2968: 2.59701, 2975: 3.13629, 2978: 2.67642, 2979: 2.66642, 2985: 3.12749, 2986: 3.42712, 2993: 2.56159, 2994: 2.63651, 2995: 2.74649, 3045: 2.8535, 3047: 2.40998, 3055: 2.70642, 3056: 3.19293, 3063: 3.22493, 3065: 3.23649, 3071: 2.51049, 3072: 2.60649, 3073: 2.84851, 3080: 1.80998, 3125: 2.69451, 3126: 2.41998, 3133: 2.68642, 3134: 3.23293, 3142: 3.41233, 3143: 3.15649, 3144: 2.85898, 3150: 2.51649, 3151: 2.74551, 3152: 2.71649, 3159: 1.44998, 3204: 2.30998, 3205: 2.37998, 3206: 2.34998, 3212: 2.61642, 3213: 3.1552, 3222: 3.08749, 3223: 3.37949, 3224: 2.81, 3230: 2.50649, 3231: 2.57749, 3232: 2.24642, 3239: 1.41998, 3285: 2.7126, 3286: 2.26998, 3287: 2.45642, 3292: 2.47998, 3293: 2.52878, 3303: 3.32549, 3304: 3.13649, 3305: 3.19649, 3311: 2.48249, 3312: 2.37946, 3313: 2.16642, 3320: 1.86642, 3367: 2.80649, 3368: 3.2, 3369: 3.29295, 3373: 2.87649, 3374: 3.00649, 3385: 3.06349, 3386: 3.11649, 3387: 2.77, 3393: 3.18291, 3394: 2.74646, 3395: 2.10998, 3402: 2.35644, 3450: 2.37642, 3451: 3.26295, 3452: 2.66642, 3455: 3.16293, 3456: 3.01795, 3468: 3.04349, 3469: 2.823, 3470: 2.79898, 3476: 2.2539, 3477: 2.20102, 3478: 2.10998, 3485: 2.27644, 3534: 3.21295, 3535: 2.62642, 3536: 2.77642, 3538: 2.58998, 3539: 3.07293, 3552: 3.01945, 3553: 3.13547, 3554: 2.75, 3560: 2.03, 3561: 2.3426, 3569: 2.12642, 3619: 3.05329, 3620: 2.96646, 3621: 2.64998, 3622: 2.60998, 3623: 2.91646, 3637: 3.05159, 3638: 3.27651, 3639: 3.13649, 3645: 2.16002, 3646: 2.23, 3647: 2.10998, 3648: 2.36649, 3705: 3.2152, 3706: 3.05646, 3707: 3.10646, 3708: 2.54998, 3723: 2.99944, 3724: 3.05649, 3725: 3.13649, 3731: 2.07746, 3732: 2.27746, 3733: 2.41649, 3792: 2.96646, 3793: 2.57998, 3794: 3.03646, 3810: 2.98944, 3811: 3.03649, 3812: 3.11649, 3818: 2.15002, 3819: 2.40649, 3820: 2.3826, 3880: 2.90002, 3881: 2.58998, 3898: 2.98249, 3899: 3.03649, 3900: 2.63642, 3906: 2.54002, 3907: 2.34646, 3908: 2.17642, 3971: 4.15942, 3987: 2.96944, 3988: 2.64642, 3989: 2.62642, 3995: 2.34646, 3996: 2.86939, 3997: 2.59644, 4057: 4.28802, 4060: 4.21655, 4061: 3.69, 4077: 2.75646, 4078: 2.8439, 4079: 2.50998, 4085: 2.88293, 4086: 3.36945, 4087: 3.0967, 4147: 3.73295, 4148: 4.33462, 4150: 4.06942, 4151: 3.74295, 4152: 3.51293, 4168: 2.6739, 4169: 2.43998, 4170: 2.50998, 4176: 3.26942, 4177: 3.04096, 4178: 2.56329, 4185: 2.67649, 4238: 3.40649, 4239: 3.74295, 4242: 3.74295, 4243: 3.45293, 4244: 3.08644, 4260: 2.47, 4261: 2.61998, 4268: 2.92045, 4269: 2.6608, 4330: 3.17004, 4331: 3.37649, 4335: 3.43293, 4336: 3.04644, 4337: 3.35649, 4353: 3.44712, 4354: 2.56002, 4355: 2.50998, 4361: 2.55291, 4362: 2.64646, 4370: 2.27644, 4423: 2.85642, 4424: 3.19004, 4429: 3.40452, 4430: 3.32649, 4447: 2.54002, 4448: 2.42998, 4449: 2.23998, 4455: 2.83646, 4517: 2.79701, 4518: 3.1439, 4524: 3.27649, 4525: 3.42293, 4542: 2.56746, 4543: 2.76649, 4544: 2.18998, 4613: 2.74701, 4620: 3.37293, 4622: 3.30649, 4638: 2.75646, 4639: 2.8326, 4640: 2.57642, 4708: 2.58998, 4717: 3.18233, 4718: 3.27649, 4719: 2.93898, 4735: 2.88295, 4736: 3.42093, 4737: 3.01644, 4805: 2.59998, 4806: 2.52998, 4815: 3.26649, 4816: 2.89898, 4817: 3.18, 4833: 3.24939, 4834: 3.66442, 4835: 2.94644, 4842: 2.7326, 4843: 2.94649, 4903: 2.52998, 4904: 2.52998, 4914: 3.46549, 4915: 2.85, 4916: 3.26649, 4932: 3.72942, 4933: 3.40395, 4934: 2.78642, 4940: 2.58646, 4941: 2.77349, 5002: 2.66642, 5003: 2.96649, 5014: 3.19945, 5015: 3.23649, 5016: 3.14, 5032: 3.39295, 5033: 3.13291, 5040: 2.68945, 5041: 2.63383, 5042: 2.78649, 5102: 3.45295, 5103: 2.53642, 5115: 3.18649, 5116: 2.81, 5117: 2.87898, 5133: 3.04291, 5141: 2.54437, 5142: 2.94295, 5203: 2.84642, 5204: 3.46295, 5217: 3.16945, 5218: 2.84898, 5219: 3.18, 5243: 2.80293, 5244: 2.63646, 5305: 2.91642, 5306: 3.19291, 5320: 3.20159, 5321: 3.18649, 5322: 3.22649, 5346: 2.59233, 5347: 2.68329, 5408: 2.82998, 5409: 3.52293, 5424: 3.14945, 5425: 3.18649, 5426: 3.19649, 5450: 2.58233, 5451: 2.71649, 5512: 2.80998, 5513: 3.21646, 5529: 3.13945, 5530: 3.16649, 5531: 3.19649, 5555: 2.61945, 5556: 2.79291, 5618: 3.13702, 5635: 3.12945, 5636: 3.16649, 5637: 2.71642, 5655: 3.33649, 5661: 2.68291, 5662: 2.64329, 5724: 2.4, 5742: 3.11945, 5743: 2.67642, 5744: 2.70642, 5760: 3.08646, 5761: 3.24649, 5768: 2.54233, 5769: 2.63291, 5833: 4.4631, 5850: 2.62642, 5851: 2.66642, 5852: 2.58998, 5868: 3.15945, 5870: 2.94644, 5876: 2.53233, 5877: 2.70139, 5941: 4.40942, 5942: 3.94295, 5959: 2.60642, 5960: 2.55998, 5961: 2.61998, 5977: 3.01437, 5978: 3.25293, 6051: 3.99295, 6052: 3.65293, 6069: 2.49998, 6070: 2.54998, 6087: 3.24452, 6088: 3.2, 6162: 3.64293, 6163: 3.22644, 6180: 2.70002, 6182: 2.58998, 6198: 3.07233, 6199: 3.3, 6274: 3.62452, 6275: 3.50649, 6292: 2.72002, 6293: 2.55998, 6294: 2.30998, 6310: 3.05233, 6387: 3.49649, 6388: 3.60293, 6405: 2.49998, 6406: 2.23998, 6407: 2.26998, 6423: 3.08945, 6501: 3.59452, 6519: 2.94191, 6520: 2.22998, 6521: 2.65642, 6537: 3.18291, 6617: 3.46649, 6634: 2.77646, 6635: 2.82642, 6636: 3.09644, 6652: 3.02291, 6732: 3.44649, 6733: 3.08898, 6750: 3.09293, 6751: 3.00644, 6752: 3.02644, 6768: 3.01291, 6849: 3.69549, 6850: 3.24, 6867: 3.80942, 6868: 3.55295, 6869: 2.87642, 6967: 3.41945, 6968: 3.42649, 6985: 3.62451, 6986: 3.5, 7086: 3.40945, 7087: 3.22, 7104: 3.17993, 7206: 3.39945, 7207: 3.03898, 7327: 3.44159, 7328: 3.22, 7449: 3.38945, 7450: 3.37649, 7494: 3.08895, 7572: 3.37945, 7573: 3.36649, 7616: 2.99195, 7696: 3.37945, 7697: 3.35649, 7716: 3.40649, 7821: 3.36945, 7822: 2.87642, 7839: 3.22726, 7840: 3.36649, 7947: 2.83642, 7948: 2.85642, 7965: 3.31945, 7967: 3.02644, 8074: 2.81642, 8075: 2.75998, 8092: 3.18437, 8093: 3.00644, 8202: 2.70998, 8203: 2.74998, 8220: 3.39452, 8331: 2.65998, 8349: 3.21233, 8462: 2.75998, 8479: 3.19233, 8592: 2.70998, 8593: 2.49998, 8610: 3.22944, 8628: 3.48195, 8724: 2.41998, 8725: 2.45998, 8857: 3.21295, 8858: 2.76642, 8875: 3.15233, 8991: 3.33293, 8992: 3.23644, 9009: 3.14233, 9126: 3.94142, 9127: 3.14644, 9262: 3.69562, 9263: 3.02642, 9399: 3.38291, 10243: 3.54649, 10386: 3.56649, 10532: 3.16644, 10677: 3.62452, 10824: 3.44233, 10972: 3.43233, 12960: 3.1952 }, T9 = 2.001, ey = function() {
  for (var e = /* @__PURE__ */ new Set(), t = 0, r = ["LI", "NA", "K", "RB", "CS", "FR", "BE", "MG", "CA", "SR", "BA", "RA", "AL", "GA", "IN", "SN", "TL", "PB", "BI", "SC", "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "Y", "ZR", "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "LA", "HF", "TA", "W", "RE", "OS", "IR", "PT", "AU", "HG", "AC", "RF", "DB", "SG", "BH", "HS", "MT", "CE", "PR", "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK", "CF", "ES", "FM", "MD", "NO", "LR"]; t < r.length; t++) {
    var n = r[t];
    e.add(sh[n]);
  }
  return e;
}();
function qF(e, t) {
  return e < t ? (e + t) * (e + t + 1) / 2 + t : (e + t) * (e + t + 1) / 2 + e;
}
function Ad(e) {
  var t = sh[e];
  return t === void 0 ? -1 : t;
}
function bp(e) {
  if (e < 0) return T9;
  var t = oee[e];
  return t === void 0 ? T9 : t;
}
function l6(e, t, r, n, a) {
  var i = function(o, s, u) {
    if (o < 0 || s < 0) return -1;
    var c = (u ? VF : GF)[qF(o, s)];
    return c === void 0 ? -1 : c;
  }(e, t, a);
  return i > 0 ? i : t < 0 ? r : (r + n) / 1.95;
}
var see = sh.H;
function wd(e) {
  return e === see;
}
var uee = /* @__PURE__ */ new Map([["HIS|CD2|CG", 2], ["HIS|CE1|ND1", 2], ["ARG|CZ|NH2", 2], ["PHE|CE1|CZ", 2], ["PHE|CD2|CE2", 2], ["PHE|CD1|CG", 2], ["TRP|CD1|CG", 2], ["TRP|CD2|CE2", 2], ["TRP|CE3|CZ3", 2], ["TRP|CH2|CZ2", 2], ["ASN|CG|OD1", 2], ["GLN|CD|OE1", 2], ["TYR|CD1|CG", 2], ["TYR|CD2|CE2", 2], ["TYR|CE1|CZ", 2], ["ASP|CG|OD1", 2], ["GLU|CD|OE1", 2], ["G|C8|N7", 2], ["G|C4|C5", 2], ["G|C2|N3", 2], ["G|C6|O6", 2], ["C|C4|N3", 2], ["C|C5|C6", 2], ["C|C2|O2", 2], ["A|C2|N3", 2], ["A|C6|N1", 2], ["A|C4|C5", 2], ["A|C8|N7", 2], ["U|C5|C6", 2], ["U|C2|O2", 2], ["U|C4|O4", 2], ["DG|C8|N7", 2], ["DG|C4|C5", 2], ["DG|C2|N3", 2], ["DG|C6|O6", 2], ["DC|C4|N3", 2], ["DC|C5|C6", 2], ["DC|C2|O2", 2], ["DA|C2|N3", 2], ["DA|C6|N1", 2], ["DA|C4|C5", 2], ["DA|C8|N7", 2], ["DT|C5|C6", 2], ["DT|C2|O2", 2], ["DT|C4|O4", 2]]);
function cee(e, t, r) {
  var n;
  return t = (n = t < r ? [t, r] : [r, t])[0], r = n[1], Oh.has(e) && t === "C" && r === "O" || A8.has(e) && t === "OP1" && r === "P" ? 2 : uee.get("".concat(e, "|").concat(t, "|").concat(r)) || 1;
}
var lee = /* @__PURE__ */ new Map([["LYS|NZ|RET|C15", 2]]);
function HF(e, t, r, n) {
  var a, i;
  return e > r && (e = (a = [r, e])[0], r = a[1], t = (i = [n, t])[0], n = i[1]), lee.get("".concat(e, "|").concat(t, "|").concat(r, "|").concat(n)) || 1;
}
var Wd = pe.Schema, Q = Wd.str, Pe = Wd.int, Qt = Wd.float, P4 = Wd.coord, _t = Wd.Aliased, jl = Wd.Matrix, $v = Wd.Vector, mf = Wd.List, ur = { atom_site: { auth_asym_id: Q, auth_atom_id: Q, auth_comp_id: Q, auth_seq_id: Pe, B_iso_or_equiv: Qt, Cartn_x: P4, Cartn_y: P4, Cartn_z: P4, group_PDB: _t(Q), id: Pe, label_alt_id: Q, label_asym_id: Q, label_atom_id: Q, label_comp_id: Q, label_entity_id: Q, label_seq_id: Pe, occupancy: Qt, type_symbol: Q, pdbx_PDB_ins_code: Q, pdbx_PDB_model_num: Pe, pdbx_formal_charge: Pe, pdbx_label_index: Pe, pdbx_sifts_xref_db_name: Q, pdbx_sifts_xref_db_acc: Q, pdbx_sifts_xref_db_num: Q, pdbx_sifts_xref_db_res: Q, ihm_model_id: Pe, cdr: Pe, em_confidence: Q }, atom_site_anisotrop: { id: Pe, type_symbol: Q, U: jl(3, 3), U_esd: jl(3, 3), pdbx_auth_seq_id: Q, pdbx_auth_asym_id: Q, pdbx_auth_atom_id: Q, pdbx_auth_comp_id: Q, pdbx_label_seq_id: Pe, pdbx_label_alt_id: Q, pdbx_label_asym_id: Q, pdbx_label_atom_id: Q, pdbx_label_comp_id: Q, pdbx_PDB_ins_code: Q }, atom_sites: { entry_id: Q, fract_transf_matrix: jl(3, 3), fract_transf_vector: $v(3) }, audit_author: { name: Q, pdbx_ordinal: Pe, identifier_ORCID: Q }, audit_conform: { dict_location: Q, dict_name: Q, dict_version: Q }, cell: { angle_alpha: Qt, angle_beta: Qt, angle_gamma: Qt, entry_id: Q, length_a: Qt, length_b: Qt, length_c: Qt, Z_PDB: Pe, pdbx_unique_axis: Q }, chem_comp: { formula: Q, formula_weight: Qt, id: Q, mon_nstd_flag: _t(Q), name: Q, type: _t(Q), pdbx_synonyms: mf(";", function(e) {
  return e;
}) }, chem_comp_bond: { atom_id_1: Q, atom_id_2: Q, comp_id: Q, value_order: _t(Q), pdbx_ordinal: Pe, pdbx_stereo_config: _t(Q), pdbx_aromatic_flag: _t(Q) }, citation: { book_publisher: Q, country: Q, id: Q, journal_abbrev: Q, journal_id_ASTM: Q, journal_id_CSD: Q, journal_id_ISSN: Q, journal_volume: Q, page_first: Q, page_last: Q, title: Q, year: Pe, pdbx_database_id_DOI: Q, pdbx_database_id_PubMed: Pe }, citation_author: { citation_id: Q, name: Q, ordinal: Pe }, database_2: { database_id: _t(Q), database_code: Q }, entity: { details: Q, formula_weight: Qt, id: Q, src_method: _t(Q), type: _t(Q), pdbx_description: mf(",", function(e) {
  return e;
}), pdbx_number_of_molecules: Pe, pdbx_mutation: Q, pdbx_fragment: Q, pdbx_ec: mf(",", function(e) {
  return e;
}) }, entity_poly: { entity_id: Q, nstd_linkage: _t(Q), nstd_monomer: _t(Q), type: _t(Q), pdbx_strand_id: mf(",", function(e) {
  return e;
}), pdbx_seq_one_letter_code: Q, pdbx_seq_one_letter_code_can: Q, pdbx_target_identifier: Q }, entity_poly_seq: { entity_id: Q, hetero: _t(Q), mon_id: Q, num: Pe }, entry: { id: Q }, exptl: { entry_id: Q, method: _t(Q) }, software: { classification: Q, date: Q, description: Q, name: Q, type: _t(Q), version: Q, pdbx_ordinal: Pe }, struct: { entry_id: Q, title: Q, pdbx_descriptor: Q }, struct_asym: { details: Q, entity_id: Q, id: Q, pdbx_modified: Q, pdbx_blank_PDB_chainid_flag: _t(Q) }, struct_conf: { beg_label_asym_id: Q, beg_label_comp_id: Q, beg_label_seq_id: Pe, beg_auth_asym_id: Q, beg_auth_comp_id: Q, beg_auth_seq_id: Pe, conf_type_id: _t(Q), details: Q, end_label_asym_id: Q, end_label_comp_id: Q, end_label_seq_id: Pe, end_auth_asym_id: Q, end_auth_comp_id: Q, end_auth_seq_id: Pe, id: Q, pdbx_beg_PDB_ins_code: Q, pdbx_end_PDB_ins_code: Q, pdbx_PDB_helix_class: Q, pdbx_PDB_helix_length: Pe, pdbx_PDB_helix_id: Q }, struct_conn: { conn_type_id: _t(Q), details: Q, id: Q, ptnr1_label_asym_id: Q, ptnr1_label_atom_id: Q, ptnr1_label_comp_id: Q, ptnr1_label_seq_id: Pe, ptnr1_auth_asym_id: Q, ptnr1_auth_comp_id: Q, ptnr1_auth_seq_id: Pe, ptnr1_symmetry: Q, ptnr2_label_asym_id: Q, ptnr2_label_atom_id: Q, ptnr2_label_comp_id: Q, ptnr2_label_seq_id: Pe, ptnr2_auth_asym_id: Q, ptnr2_auth_comp_id: Q, ptnr2_auth_seq_id: Pe, ptnr2_symmetry: Q, pdbx_ptnr1_PDB_ins_code: Q, pdbx_ptnr1_label_alt_id: Q, pdbx_ptnr1_standard_comp_id: Q, pdbx_ptnr2_PDB_ins_code: Q, pdbx_ptnr2_label_alt_id: Q, pdbx_ptnr3_PDB_ins_code: Q, pdbx_ptnr3_label_alt_id: Q, pdbx_ptnr3_label_asym_id: Q, pdbx_ptnr3_label_atom_id: Q, pdbx_ptnr3_label_comp_id: Q, pdbx_ptnr3_label_seq_id: Pe, pdbx_PDB_id: Q, pdbx_dist_value: Qt, pdbx_value_order: _t(Q) }, struct_conn_type: { criteria: Q, id: _t(Q), reference: Q }, struct_keywords: { entry_id: Q, text: mf(",", function(e) {
  return e;
}), pdbx_keywords: Q }, struct_ncs_oper: { code: _t(Q), details: Q, id: Pe, matrix: jl(3, 3), vector: $v(3) }, struct_sheet_range: { beg_label_asym_id: Q, beg_label_comp_id: Q, beg_label_seq_id: Pe, end_label_asym_id: Q, end_label_comp_id: Q, end_label_seq_id: Pe, beg_auth_asym_id: Q, beg_auth_comp_id: Q, beg_auth_seq_id: Pe, end_auth_asym_id: Q, end_auth_comp_id: Q, end_auth_seq_id: Pe, id: Q, sheet_id: Q, pdbx_beg_PDB_ins_code: Q, pdbx_end_PDB_ins_code: Q }, struct_site: { details: Q, id: Q, pdbx_num_residues: Pe, pdbx_evidence_code: Q, pdbx_auth_asym_id: Q, pdbx_auth_comp_id: Q, pdbx_auth_seq_id: Q, pdbx_auth_ins_code: Q }, struct_site_gen: { details: Q, id: Q, label_alt_id: Q, label_asym_id: Q, label_atom_id: Q, label_comp_id: Q, label_seq_id: Pe, auth_asym_id: Q, auth_comp_id: Q, auth_seq_id: Q, site_id: Q, symmetry: Q, pdbx_auth_ins_code: Q, pdbx_num_res: Pe }, symmetry: { entry_id: Q, cell_setting: _t(Q), Int_Tables_number: Pe, space_group_name_Hall: Q, "space_group_name_H-M": Q }, pdbx_database_status: { status_code: _t(Q), status_code_sf: _t(Q), status_code_mr: _t(Q), entry_id: Q, recvd_initial_deposition_date: Q, SG_entry: _t(Q), deposit_site: _t(Q), process_site: _t(Q), status_code_cs: _t(Q), methods_development_category: _t(Q), pdb_format_compatible: _t(Q) }, pdbx_nonpoly_scheme: { asym_id: Q, entity_id: Q, mon_id: Q, pdb_strand_id: Q, ndb_seq_num: Q, pdb_seq_num: Q, auth_seq_num: Q, pdb_mon_id: Q, auth_mon_id: Q, pdb_ins_code: Q }, pdbx_database_related: { db_name: Q, details: Q, db_id: Q, content_type: _t(Q) }, pdbx_entity_nonpoly: { entity_id: Q, comp_id: Q, name: Q }, pdbx_chem_comp_synonyms: { name: Q, comp_id: Q, provenance: _t(Q) }, pdbx_chem_comp_identifier: { comp_id: Q, identifier: Q, type: _t(Q), program: Q, program_version: Q }, pdbx_unobs_or_zero_occ_residues: { id: Pe, polymer_flag: _t(Q), occupancy_flag: _t(Pe), PDB_model_num: Pe, auth_asym_id: Q, auth_comp_id: Q, auth_seq_id: Q, PDB_ins_code: Q, label_asym_id: Q, label_comp_id: Q, label_seq_id: Pe }, pdbx_struct_mod_residue: { id: Pe, auth_asym_id: Q, auth_comp_id: Q, auth_seq_id: Pe, PDB_ins_code: Q, label_asym_id: Q, label_comp_id: Q, label_seq_id: Pe, parent_comp_id: Q, details: Q }, pdbx_struct_oper_list: { id: Q, type: _t(Q), name: Q, symmetry_operation: Q, matrix: jl(3, 3), vector: $v(3) }, pdbx_struct_assembly: { method_details: Q, oligomeric_details: Q, oligomeric_count: Pe, details: Q, id: Q }, pdbx_struct_assembly_gen: { asym_id_list: mf(",", function(e) {
  return e;
}), assembly_id: Q, oper_expression: Q }, pdbx_reference_entity_list: { prd_id: Q, ref_entity_id: Q, type: _t(Q), details: Q, component_id: Pe }, pdbx_reference_entity_link: { link_id: Pe, prd_id: Q, details: Q, ref_entity_id_1: Q, ref_entity_id_2: Q, entity_seq_num_1: Pe, entity_seq_num_2: Pe, comp_id_1: Q, comp_id_2: Q, atom_id_1: Q, atom_id_2: Q, value_order: _t(Q), component_1: Pe, component_2: Pe, link_class: _t(Q) }, pdbx_reference_entity_poly_link: { link_id: Pe, prd_id: Q, ref_entity_id: Q, component_id: Pe, entity_seq_num_1: Pe, entity_seq_num_2: Pe, comp_id_1: Q, comp_id_2: Q, atom_id_1: Q, atom_id_2: Q, value_order: _t(Q) }, pdbx_molecule: { prd_id: Q, instance_id: Pe, asym_id: Q }, pdbx_molecule_features: { prd_id: Q, class: _t(Q), type: _t(Q), name: Q, details: Q }, entity_src_nat: { entity_id: Q, pdbx_organism_scientific: Q, pdbx_plasmid_name: Q, pdbx_src_id: Pe, pdbx_beg_seq_num: Pe, pdbx_end_seq_num: Pe }, entity_src_gen: { entity_id: Q, pdbx_gene_src_gene: mf(",", function(e) {
  return e;
}), pdbx_gene_src_scientific_name: Q, plasmid_name: Q, pdbx_src_id: Pe, pdbx_beg_seq_num: Pe, pdbx_end_seq_num: Pe }, pdbx_entity_src_syn: { organism_scientific: Q, entity_id: Q, pdbx_src_id: Pe, pdbx_beg_seq_num: Pe, pdbx_end_seq_num: Pe }, pdbx_entity_branch_descriptor: { entity_id: Q, descriptor: Q, type: _t(Q), program: Q, program_version: Q, ordinal: Pe }, pdbx_entity_instance_feature: { details: Q, feature_type: _t(Q), auth_asym_id: Q, asym_id: Q, auth_seq_num: Q, seq_num: Pe, comp_id: Q, auth_comp_id: Q, ordinal: Pe }, pdbx_entity_branch_list: { entity_id: Q, hetero: _t(Q), comp_id: Q, num: Pe }, pdbx_entity_branch_link: { link_id: Pe, details: Q, entity_id: Q, entity_branch_list_num_1: Pe, entity_branch_list_num_2: Pe, comp_id_1: Q, comp_id_2: Q, atom_id_1: Q, leaving_atom_id_1: Q, atom_stereo_config_1: _t(Q), atom_id_2: Q, leaving_atom_id_2: Q, atom_stereo_config_2: _t(Q), value_order: _t(Q) }, pdbx_entity_branch: { entity_id: Q, type: _t(Q) }, pdbx_branch_scheme: { entity_id: Q, hetero: _t(Q), asym_id: Q, mon_id: Q, num: Pe, pdb_asym_id: Q, pdb_seq_num: Q, pdb_mon_id: Q, auth_asym_id: Q, auth_seq_num: Q, auth_mon_id: Q }, pdbx_chem_comp_related: { comp_id: Q, related_comp_id: Q, relationship_type: _t(Q), details: Q }, ihm_starting_model_details: { starting_model_id: Q, entity_id: Q, entity_description: Q, asym_id: Q, entity_poly_segment_id: Pe, starting_model_source: _t(Q), starting_model_auth_asym_id: Q, starting_model_sequence_offset: Pe, dataset_list_id: Pe }, ihm_starting_comparative_models: { id: Pe, starting_model_id: Q, starting_model_auth_asym_id: Q, starting_model_seq_id_begin: Pe, starting_model_seq_id_end: Pe, template_auth_asym_id: Q, template_seq_id_begin: Pe, template_seq_id_end: Pe, template_sequence_identity: Qt, template_sequence_identity_denominator: _t(Pe), template_dataset_list_id: Pe, alignment_file_id: Pe }, ihm_starting_model_seq_dif: { id: Pe, entity_id: Q, asym_id: Q, seq_id: Pe, comp_id: Q, starting_model_id: Q, db_asym_id: Q, db_seq_id: Pe, db_comp_id: Q, details: Q }, ihm_model_representation: { id: Pe, name: Q, details: Q }, ihm_model_representation_details: { id: Pe, representation_id: Pe, entity_poly_segment_id: Pe, entity_id: Q, entity_description: Q, entity_asym_id: Q, model_object_primitive: _t(Q), starting_model_id: Q, model_mode: _t(Q), model_granularity: _t(Q), model_object_count: Pe }, ihm_struct_assembly_details: { id: Pe, assembly_id: Pe, parent_assembly_id: Pe, entity_description: Q, entity_id: Q, asym_id: Q, entity_poly_segment_id: Pe }, ihm_struct_assembly: { id: Pe, name: Q, description: Q }, ihm_modeling_protocol: { id: Pe, num_steps: Pe, protocol_name: Q }, ihm_modeling_protocol_details: { id: Pe, protocol_id: Pe, step_id: Pe, struct_assembly_id: Pe, dataset_group_id: Pe, struct_assembly_description: Q, step_name: Q, step_method: Q, num_models_begin: Pe, num_models_end: Pe, multi_scale_flag: _t(Q), multi_state_flag: _t(Q), ordered_flag: _t(Q), script_file_id: Pe, software_id: Pe }, ihm_multi_state_modeling: { state_id: Pe, state_group_id: Pe, population_fraction: Qt, population_fraction_sd: Qt, state_type: Q, state_name: Q, experiment_type: _t(Q), details: Q }, ihm_modeling_post_process: { id: Pe, protocol_id: Pe, analysis_id: Pe, step_id: Pe, type: _t(Q), feature: _t(Q), num_models_begin: Pe, num_models_end: Pe }, ihm_ensemble_info: { ensemble_id: Pe, ensemble_name: Q, post_process_id: Pe, model_group_id: Pe, ensemble_clustering_method: _t(Q), ensemble_clustering_feature: _t(Q), num_ensemble_models: Pe, num_ensemble_models_deposited: Pe, ensemble_precision_value: Qt, ensemble_file_id: Pe }, ihm_model_list: { model_id: Pe, model_name: Q, assembly_id: Pe, protocol_id: Pe, representation_id: Pe }, ihm_model_group: { id: Pe, name: Q, details: Q }, ihm_model_group_link: { model_id: Pe, group_id: Pe }, ihm_model_representative: { id: Pe, model_group_id: Pe, model_id: Pe, selection_criteria: _t(Q) }, ihm_dataset_list: { id: Pe, data_type: _t(Q), database_hosted: _t(Q) }, ihm_dataset_group: { id: Pe, name: Q, application: _t(Q), details: Q }, ihm_dataset_group_link: { dataset_list_id: Pe, group_id: Pe }, ihm_related_datasets: { dataset_list_id_derived: Pe, dataset_list_id_primary: Pe }, ihm_dataset_related_db_reference: { id: Pe, dataset_list_id: Pe, db_name: _t(Q), accession_code: Q, version: Q, details: Q }, ihm_external_reference_info: { reference_id: Pe, reference_provider: Q, reference_type: _t(Q), reference: Q, refers_to: _t(Q), associated_url: Q }, ihm_external_files: { id: Pe, reference_id: Pe, file_path: Q, content_type: _t(Q), file_size_bytes: Qt, details: Q }, ihm_dataset_external_reference: { id: Pe, dataset_list_id: Pe, file_id: Pe }, ihm_localization_density_files: { id: Pe, file_id: Pe, ensemble_id: Pe, entity_id: Q, entity_poly_segment_id: Pe, asym_id: Q }, ihm_predicted_contact_restraint: { id: Pe, group_id: Pe, entity_id_1: Q, entity_id_2: Q, asym_id_1: Q, asym_id_2: Q, comp_id_1: Q, comp_id_2: Q, seq_id_1: Pe, seq_id_2: Pe, rep_atom_1: _t(Q), rep_atom_2: _t(Q), distance_lower_limit: Qt, distance_upper_limit: Qt, probability: Qt, restraint_type: _t(Q), model_granularity: _t(Q), dataset_list_id: Pe, software_id: Pe }, ihm_cross_link_list: { id: Pe, group_id: Pe, entity_description_1: Q, entity_description_2: Q, entity_id_1: Q, entity_id_2: Q, comp_id_1: Q, comp_id_2: Q, seq_id_1: Pe, seq_id_2: Pe, linker_type: _t(Q), dataset_list_id: Pe }, ihm_cross_link_restraint: { id: Pe, group_id: Pe, entity_id_1: Q, entity_id_2: Q, asym_id_1: Q, asym_id_2: Q, comp_id_1: Q, comp_id_2: Q, seq_id_1: Pe, seq_id_2: Pe, atom_id_1: Q, atom_id_2: Q, restraint_type: _t(Q), conditional_crosslink_flag: _t(Q), model_granularity: _t(Q), distance_threshold: Qt, psi: Qt, sigma_1: Qt, sigma_2: Qt }, ihm_cross_link_result_parameters: { id: Pe, restraint_id: Pe, model_id: Pe, psi: Qt, sigma_1: Qt, sigma_2: Qt }, ihm_2dem_class_average_restraint: { id: Pe, dataset_list_id: Pe, number_raw_micrographs: Pe, pixel_size_width: Qt, pixel_size_height: Qt, image_resolution: Qt, image_segment_flag: _t(Q), number_of_projections: Pe, struct_assembly_id: Pe, details: Q }, ihm_2dem_class_average_fitting: { id: Pe, restraint_id: Pe, model_id: Pe, cross_correlation_coefficient: Qt, rot_matrix: jl(3, 3), tr_vector: $v(3) }, ihm_3dem_restraint: { id: Pe, dataset_list_id: Pe, model_id: Pe, struct_assembly_id: Pe, fitting_method: Q, number_of_gaussians: Pe, cross_correlation_coefficient: Qt }, ihm_sas_restraint: { id: Pe, dataset_list_id: Pe, model_id: Pe, struct_assembly_id: Pe, profile_segment_flag: _t(Q), fitting_atom_type: Q, fitting_method: Q, fitting_state: _t(Q), radius_of_gyration: Qt, chi_value: Qt, details: Q }, ihm_starting_model_coord: { ordinal_id: Pe, starting_model_id: Q, group_PDB: _t(Q), id: Pe, type_symbol: Q, entity_id: Q, atom_id: Q, comp_id: Q, seq_id: Pe, asym_id: Q, Cartn_x: Qt, Cartn_y: Qt, Cartn_z: Qt, B_iso_or_equiv: Qt }, ihm_sphere_obj_site: { id: Pe, entity_id: Q, seq_id_begin: Pe, seq_id_end: Pe, asym_id: Q, Cartn_x: Qt, Cartn_y: Qt, Cartn_z: Qt, object_radius: Qt, rmsf: Qt, model_id: Pe }, ihm_gaussian_obj_site: { id: Pe, entity_id: Q, seq_id_begin: Pe, seq_id_end: Pe, asym_id: Q, mean_Cartn_x: Qt, mean_Cartn_y: Qt, mean_Cartn_z: Qt, weight: Qt, covariance_matrix: jl(3, 3), model_id: Pe }, ihm_gaussian_obj_ensemble: { id: Pe, entity_id: Q, seq_id_begin: Pe, seq_id_end: Pe, asym_id: Q, mean_Cartn_x: Qt, mean_Cartn_y: Qt, mean_Cartn_z: Qt, weight: Qt, covariance_matrix: jl(3, 3), ensemble_id: Pe }, ihm_feature_list: { feature_id: Pe, feature_type: _t(Q), entity_type: _t(Q) }, ihm_poly_residue_feature: { ordinal_id: Pe, feature_id: Pe, entity_id: Q, asym_id: Q, comp_id_begin: Q, comp_id_end: Q, seq_id_begin: Pe, seq_id_end: Pe }, ihm_derived_distance_restraint: { id: Pe, group_id: Pe, feature_id_1: Pe, feature_id_2: Pe, group_conditionality: _t(Q), random_exclusion_fraction: Qt, distance_upper_limit: Qt, restraint_type: _t(Q), dataset_list_id: Pe }, ma_model_list: { ordinal_id: Pe, model_id: Pe, model_group_id: Pe, model_name: Q, model_group_name: Q, model_type: _t(Q), data_id: Pe }, ma_target_entity: { entity_id: Q, data_id: Pe, origin: _t(Q) }, ma_target_entity_instance: { asym_id: Q, entity_id: Q, details: Q }, ma_target_ref_db_details: { target_entity_id: Q, db_name: _t(Q), db_code: Q, db_accession: Q, seq_db_isoform: Q, seq_db_align_begin: Q, seq_db_align_end: Q, ncbi_taxonomy_id: Q, organism_scientific: Q }, ma_data: { id: Pe, content_type: _t(Q), content_type_other_details: Q, name: Q }, ma_software_group: { ordinal_id: Pe, group_id: Pe, software_id: Pe }, ma_qa_metric: { id: Pe, name: Q, type: _t(Q), mode: _t(Q), software_group_id: Pe }, ma_qa_metric_global: { ordinal_id: Pe, model_id: Pe, metric_id: Pe, metric_value: Qt }, ma_qa_metric_local: { ordinal_id: Pe, model_id: Pe, label_asym_id: Q, label_seq_id: Pe, label_comp_id: Q, metric_id: Pe, metric_value: Qt } }, dee = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function ty(e) {
  for (var t = e.data, r = e.encoding.length - 1; r >= 0; r--) t = fee(t, e.encoding[r]);
  return t;
}
function fee(e, t) {
  switch (t.kind) {
    case "ByteArray":
      switch (t.type) {
        case 4:
          return e;
        case 1:
          return function(r) {
            return new Int8Array(r.buffer, r.byteOffset);
          }(e);
        case 2:
          return function(r) {
            return Um(r, 2, Int16Array);
          }(e);
        case 5:
          return function(r) {
            return Um(r, 2, Uint16Array);
          }(e);
        case 3:
          return function(r) {
            return Um(r, 4, Int32Array);
          }(e);
        case 6:
          return function(r) {
            return Um(r, 4, Uint32Array);
          }(e);
        case 32:
          return function(r) {
            return Um(r, 4, Float32Array);
          }(e);
        case 33:
          return function(r) {
            return Um(r, 8, Float64Array);
          }(e);
        default:
          Ja(t.type);
      }
    case "FixedPoint":
      return function(r, n) {
        for (var a = r.length, i = P9(n.srcType, a), o = 1 / n.factor, s = 0; s < a; s++) i[s] = o * r[s];
        return i;
      }(e, t);
    case "IntervalQuantization":
      return function(r, n) {
        for (var a = r.length, i = P9(n.srcType, a), o = (n.max - n.min) / (n.numSteps - 1), s = n.min, u = 0; u < a; u++) i[u] = s + o * r[u];
        return i;
      }(e, t);
    case "RunLength":
      return function(r, n) {
        for (var a = N9(n.srcType, n.srcSize), i = 0, o = 0, s = r.length; o < s; o += 2) for (var u = r[o], c = r[o + 1], l = 0; l < c; ++l) a[i++] = u;
        return a;
      }(e, t);
    case "Delta":
      return function(r, n) {
        var a = r.length, i = N9(n.srcType, a);
        if (!a) return r;
        i[0] = r[0] + (0 | n.origin);
        for (var o = 1; o < a; ++o) i[o] = r[o] + i[o - 1];
        return i;
      }(e, t);
    case "IntegerPacking":
      return function(r, n) {
        return r.length === n.srcSize ? r : n.isUnsigned ? function(a, i) {
          for (var o = i.byteCount === 1 ? 255 : 65535, s = a.length, u = new Int32Array(i.srcSize), c = 0, l = 0; c < s; ) {
            for (var d = 0, f = a[c]; f === o; ) d += f, f = a[++c];
            d += f, u[l] = d, c++, l++;
          }
          return u;
        }(r, n) : function(a, i) {
          for (var o = i.byteCount === 1 ? 127 : 32767, s = -o - 1, u = a.length, c = new Int32Array(i.srcSize), l = 0, d = 0; l < u; ) {
            for (var f = 0, m = a[l]; m === o || m === s; ) f += m, m = a[++l];
            f += m, c[d] = f, l++, d++;
          }
          return c;
        }(r, n);
      }(e, t);
    case "StringArray":
      return function(r, n) {
        var a = ty({ encoding: n.offsetEncoding, data: n.offsets }), i = ty({ encoding: n.dataEncoding, data: r }), o = n.stringData, s = new Array(a.length);
        s[0] = "";
        for (var u = 1, c = a.length; u < c; u++) s[u] = o.substring(a[u - 1], a[u]);
        var l = 0, d = new Array(i.length);
        for (u = 0, c = i.length; u < c; u++) d[l++] = s[i[u] + 1];
        return d;
      }(e, t);
  }
}
function N9(e, t) {
  switch (e) {
    case 1:
      return new Int8Array(t);
    case 2:
      return new Int16Array(t);
    case 3:
      return new Int32Array(t);
    case 4:
      return new Uint8Array(t);
    case 5:
      return new Uint16Array(t);
    case 6:
      return new Uint32Array(t);
    default:
      Ja();
  }
}
function P9(e, t) {
  switch (e) {
    case 32:
      return new Float32Array(t);
    case 33:
      return new Float64Array(t);
    default:
      Ja();
  }
}
function Um(e, t, r) {
  return new r(dee ? e.buffer : function(n, a) {
    for (var i = new ArrayBuffer(n.length), o = new Uint8Array(i), s = 0, u = n.length; s < u; s += a) for (var c = 0; c < a; c++) o[s + a - c - 1] = n[s + c];
    return i;
  }(e, t));
}
var ld, D0, d6;
function mee(e, t, r) {
  var n, a = 1;
  for (n = 0; n < t; n++) {
    var i = a * e;
    if (Math.abs(Math.round(i) - i) <= r) return n;
    a *= 10;
  }
  return -1;
}
function B9(e, t) {
  return parseFloat(e.toPrecision(t));
}
function f6(e) {
  return D0.classify(e);
}
(function(e) {
  e.getDataType = function(t) {
    return t instanceof Int8Array ? 1 : t instanceof Int16Array ? 2 : t instanceof Int32Array ? 3 : t instanceof Uint8Array ? 4 : t instanceof Uint16Array ? 5 : t instanceof Uint32Array ? 6 : t instanceof Float32Array ? 32 : t instanceof Float64Array ? 33 : 3;
  }, e.isSignedIntegerDataType = function(t) {
    if (t instanceof Int8Array || t instanceof Int16Array || t instanceof Int32Array) return !0;
    for (var r = 0, n = t.length; r < n; r++) if (r < 0) return !1;
    return !0;
  };
})(ld || (ld = {})), function(e) {
  function t(l, d) {
    return l >= 0 ? Math.ceil((l + 1) / d) : Math.ceil((l + 1) / (-d - 1));
  }
  function r(l, d, f) {
    var m = l.limit8, h = l.limit16;
    d.pack8 += t(f, m), d.pack16 += t(f, h), d.count += 1;
  }
  function n(l, d) {
    l.pack8 += t(d, 127), l.pack16 += t(d, 32767), l.count += 1;
  }
  function a(l) {
    return 4 * l.count < 2 * l.pack16 ? { length: 4 * l.count, elem: 4 } : 2 * l.pack16 < l.pack8 ? { length: 2 * l.pack16, elem: 2 } : { length: l.pack8, elem: 1 };
  }
  function i(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 0, h = l.length; m < h; m++) r(d, f, l[m]);
    return k(k({}, a(f)), { kind: "pack" });
  }
  function o(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = l[0], h = 1, p = l.length; h < p; h++) n(f, l[h] - m), m = l[h];
    return k(k({}, a(f)), { kind: "delta" });
  }
  function s(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 1, h = 1, p = l.length; h < p; h++) l[h - 1] !== l[h] ? (r(d, f, l[h - 1]), r(d, f, m), m = 1) : m++;
    return r(d, f, l[l.length - 1]), r(d, f, m), k(k({}, a(f)), { kind: "rle" });
  }
  function u(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 1, h = 0, p = 0, g = 1, v = l.length; g < v; g++) {
      var y = l[g] - h;
      p !== y ? (n(f, p), n(f, m), m = 1) : m++, p = y, h = l[g];
    }
    return n(f, p), n(f, m), k(k({}, a(f)), { kind: "delta-rle" });
  }
  function c(l) {
    var d = function(m) {
      for (var h = !1, p = 0, g = m.length; p < g; p++) if (m[p] < 0) {
        h = !0;
        break;
      }
      return h ? { signed: h, limit8: 127, limit16: 32767 } : { signed: h, limit8: 255, limit16: 65535 };
    }(l), f = [i(l, d), s(l, d), o(l), u(l)];
    return f.sort(function(m, h) {
      return m.length - h.length;
    }), f;
  }
  e.getSize = c, e.classify = function(l) {
    if (l.length < 2) return mr.by(mr.byteArray);
    switch (c(l)[0].kind) {
      case "pack":
        return mr.by(mr.integerPacking);
      case "rle":
        return mr.by(mr.runLength).and(mr.integerPacking);
      case "delta":
        return mr.by(mr.delta).and(mr.integerPacking);
      case "delta-rle":
        return mr.by(mr.delta).and(mr.runLength).and(mr.integerPacking);
      default:
        Ja();
    }
  };
}(D0 || (D0 = {})), function(e) {
  e.classify = function(t) {
    var r = function(d, f, m) {
      for (var h = 1, p = 0, g = 0, v = d.length; g < v; g++) {
        if (h >= 0) {
          var y = mee(d[g], f, m);
          y < 0 ? h = -1 : y > h && (h = y);
        }
        var _ = Math.abs(d[g]);
        if (_ > m) {
          var S = Math.floor(Math.log10(Math.abs(_))) + 1;
          S > p && (p = S);
        }
      }
      return { mantissaDigits: h, integerDigits: p };
    }(t, 4, 1e-6), n = r.mantissaDigits, a = r.integerDigits;
    if (n < 0 || n + a > 10) return mr.by(mr.byteArray);
    if (n === 0) return D0.classify(t);
    for (var i = function(d) {
      for (var f = 1, m = 0; m < d; m++) f *= 10;
      return f;
    }(n), o = new Int32Array(t.length), s = 0, u = t.length; s < u; s++) o[s] = Math.round(i * t[s]);
    var c = D0.getSize(o)[0], l = mr.by(mr.fixedPoint(i));
    switch (c.kind) {
      case "pack":
        return l.and(mr.integerPacking);
      case "rle":
        return l.and(mr.runLength).and(mr.integerPacking);
      case "delta":
        return l.and(mr.delta).and(mr.integerPacking);
      case "delta-rle":
        return l.and(mr.delta).and(mr.runLength).and(mr.integerPacking);
      default:
        Ja();
    }
  };
}(d6 || (d6 = {}));
var Cd, mr, m6, ds, p6, O9 = function() {
  function e(t) {
    this.providers = t;
  }
  return e.prototype.and = function(t) {
    return new e(this.providers.concat([t]));
  }, e.prototype.encode = function(t) {
    for (var r = [], n = 0, a = this.providers; n < a.length; n++) {
      var i = (0, a[n])(t);
      if (!i.encodings.length) throw new Error("Encodings must be non-empty.");
      t = i.data;
      for (var o = 0, s = i.encodings; o < s.length; o++) {
        var u = s[o];
        r.push(u);
      }
    }
    if (!(t instanceof Uint8Array)) throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
    return { encoding: r, data: t };
  }, e;
}();
function B4(e) {
  return function(t, r) {
    return r[e].value(t);
  };
}
function pee(e) {
  return function(t, r) {
    return r[e].value(t).join(r[e].schema.separator);
  };
}
function O4(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  return function(n, a) {
    var i;
    return (i = a[e].schema.space).get.apply(i, nt([a[e].value(n)], t, !1));
  };
}
function M0(e) {
  return function(t, r) {
    return r[e].valueKind(t);
  };
}
function hee(e, t) {
  var r = [], n = M0(e);
  if (t.rank === 1) for (var a = t.dimensions[0], i = 0; i < a; i++) {
    var o = "".concat(e, "[").concat(i + 1, "]");
    r.push({ name: o, type: 2, value: O4(e, i), valueKind: n });
  }
  else if (t.rank === 2) {
    a = t.dimensions[0];
    var s = t.dimensions[1];
    for (i = 0; i < a; i++) for (var u = 0; u < s; u++) {
      var c = "".concat(e, "[").concat(i + 1, "][").concat(u + 1, "]");
      r.push({ name: c, type: 2, value: O4(e, i, u), valueKind: n });
    }
  } else {
    if (t.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    var l = t.dimensions[0], d = t.dimensions[1], f = t.dimensions[2];
    for (i = 0; i < l; i++) for (u = 0; u < d; u++) for (var m = 0; m < f; m++) {
      var h = "".concat(e, "[").concat(i + 1, "][").concat(u + 1, "][").concat(m + 1, "]");
      r.push({ name: h, type: 2, value: O4(e, i, u, m), valueKind: n });
    }
  }
  return r;
}
function F9(e) {
  for (var t = [], r = 0, n = Object.keys(e); r < n.length; r++) {
    var a = n[r], i = e[a];
    i.valueType === "int" ? t.push({ name: a, type: 1, value: B4(a), valueKind: M0(a) }) : i.valueType === "float" ? t.push({ name: a, type: 2, value: B4(a), valueKind: M0(a) }) : i.valueType === "str" ? t.push({ name: a, type: 0, value: B4(a), valueKind: M0(a) }) : i.valueType === "list" ? t.push({ name: a, type: 0, value: pee(a), valueKind: M0(a) }) : i.valueType === "tensor" ? t.push.apply(t, hee(a, i.space)) : Ja(i.valueType);
  }
  return t;
}
function h6(e) {
  return e.fields.some(function(t) {
    return !!t.shouldInclude;
  }) ? e.fields.filter(function(t) {
    return !t.shouldInclude || e.source.some(function(r) {
      return t.shouldInclude(r.data);
    });
  }) : e.fields;
}
function KF(e, t) {
  var r = e.instance(t), n = r.source.filter(function(o) {
    return o.rowCount > 0;
  });
  if (!n.length) return { instance: r, rowCount: 0, source: [] };
  var a = n.reduce(function(o, s) {
    return o + s.rowCount;
  }, 0), i = n.map(function(o) {
    return { data: o.data, keys: function() {
      return o.keys ? o.keys() : X2.Range(0, o.rowCount - 1);
    }, rowCount: o.rowCount };
  });
  return { instance: r, rowCount: a, source: i };
}
(function(e) {
  function t(n) {
    return new O9([n]);
  }
  function r(n) {
    switch (n.kind) {
      case "ByteArray":
        return mr.byteArray;
      case "FixedPoint":
        return mr.fixedPoint(n.factor);
      case "IntervalQuantization":
        return mr.intervalQuantizaiton(n.min, n.max, n.numSteps);
      case "RunLength":
        return mr.runLength;
      case "Delta":
        return mr.delta;
      case "IntegerPacking":
        return mr.integerPacking;
      case "StringArray":
        return mr.stringArray;
    }
  }
  e.by = t, e.fromEncoding = function(n) {
    for (var a = t(r(n[0])), i = 1; i < n.length; i++) a = a.and(r(n[i]));
    return a;
  };
})(Cd || (Cd = {})), function(e) {
  var t, r;
  e.by = function(s) {
    return new O9([s]);
  };
  var n = ((t = {})[2] = function(s, u, c) {
    s.setInt16(2 * u, c, !0);
  }, t[5] = function(s, u, c) {
    s.setUint16(2 * u, c, !0);
  }, t[3] = function(s, u, c) {
    s.setInt32(4 * u, c, !0);
  }, t[6] = function(s, u, c) {
    s.setUint32(4 * u, c, !0);
  }, t[32] = function(s, u, c) {
    s.setFloat32(4 * u, c, !0);
  }, t[33] = function(s, u, c) {
    s.setFloat64(8 * u, c, !0);
  }, t), a = ((r = {})[2] = 2, r[5] = 2, r[3] = 4, r[6] = 4, r[32] = 4, r[33] = 8, r);
  function i(s) {
    var u = ld.getDataType(s);
    if (u === 1) return function(h) {
      return { encodings: [{ kind: "ByteArray", type: 1 }], data: new Uint8Array(h.buffer, h.byteOffset) };
    }(s);
    if (u === 4) return /* @__PURE__ */ function(h) {
      return { encodings: [{ kind: "ByteArray", type: 4 }], data: h };
    }(s);
    for (var c = new Uint8Array(s.length * a[u]), l = n[u], d = new DataView(c.buffer), f = 0, m = s.length; f < m; f++) l(d, f, s[f]);
    return { encodings: [{ kind: "ByteArray", type: u }], data: c };
  }
  function o(s, u) {
    for (var c = -u - 1, l = 0, d = 0, f = s.length; d < f; d++) {
      var m = s[d];
      m === 0 ? l += 1 : m > 0 ? (l += Math.ceil(m / u), m % u == 0 && (l += 1)) : (l += Math.ceil(m / c), m % c == 0 && (l += 1));
    }
    return l;
  }
  e.byteArray = i, e.fixedPoint = function(s) {
    return function(u) {
      return function(c, l) {
        for (var d = ld.getDataType(c), f = new Int32Array(c.length), m = 0, h = c.length; m < h; m++) f[m] = Math.round(c[m] * l);
        return { encodings: [{ kind: "FixedPoint", factor: l, srcType: d }], data: f };
      }(u, s);
    };
  }, e.intervalQuantizaiton = function(s, u, c, l) {
    return l === void 0 && (l = Int32Array), function(d) {
      return function(f, m, h, p, g) {
        var v = ld.getDataType(f);
        if (!f.length) return { encodings: [{ kind: "IntervalQuantization", min: m, max: h, numSteps: p, srcType: v }], data: new Int32Array(0) };
        if (h < m) {
          var y = m;
          m = h, h = y;
        }
        for (var _ = (h - m) / (p - 1), S = new g(f.length), b = 0, x = f.length; b < x; b++) {
          var A = f[b];
          S[b] = A <= m ? 0 : A >= h ? p - 1 : 0 | Math.round((A - m) / _);
        }
        return { encodings: [{ kind: "IntervalQuantization", min: m, max: h, numSteps: p, srcType: v }], data: S };
      }(d, s, u, c, l);
    };
  }, e.runLength = function(s) {
    var u = ld.getDataType(s);
    if (u === void 0 && (s = new Int32Array(s), u = 3), !s.length) return { encodings: [{ kind: "RunLength", srcType: u, srcSize: 0 }], data: new Int32Array(0) };
    for (var c = 2, l = 1, d = s.length; l < d; l++) s[l - 1] !== s[l] && (c += 2);
    var f = new Int32Array(c), m = 0, h = 1;
    for (l = 1, d = s.length; l < d; l++) s[l - 1] !== s[l] ? (f[m] = s[l - 1], f[m + 1] = h, h = 1, m += 2) : ++h;
    return f[m] = s[s.length - 1], f[m + 1] = h, { encodings: [{ kind: "RunLength", srcType: u, srcSize: s.length }], data: f };
  }, e.delta = function(s) {
    if (!ld.isSignedIntegerDataType(s)) throw new Error("Only signed integer types can be encoded using delta encoding.");
    var u = ld.getDataType(s);
    if (u === void 0 && (s = new Int32Array(s), u = 3), !s.length) return { encodings: [{ kind: "Delta", origin: 0, srcType: u }], data: new s.constructor(0) };
    var c = new s.constructor(s.length), l = s[0];
    c[0] = s[0];
    for (var d = 1, f = s.length; d < f; d++) c[d] = s[d] - s[d - 1];
    return c[0] = 0, { encodings: [{ kind: "Delta", origin: l, srcType: u }], data: c };
  }, e.integerPacking = function(s) {
    var u = function(c) {
      var l = function(m) {
        for (var h = 0, p = m.length; h < p; h++) if (m[h] < 0) return !0;
        return !1;
      }(c), d = o(c, l ? 127 : 255), f = o(c, l ? 32767 : 65535);
      return 4 * c.length < 2 * f ? { isSigned: l, size: c.length, bytesPerElement: 4 } : 2 * f < d ? { isSigned: l, size: f, bytesPerElement: 2 } : { isSigned: l, size: d, bytesPerElement: 1 };
    }(s);
    return u.bytesPerElement === 4 ? i(s) : function(c, l) {
      for (var d = l.isSigned ? l.bytesPerElement === 1 ? 127 : 32767 : l.bytesPerElement === 1 ? 255 : 65535, f = -d - 1, m = c.length, h = l.isSigned ? l.bytesPerElement === 1 ? new Int8Array(l.size) : new Int16Array(l.size) : l.bytesPerElement === 1 ? new Uint8Array(l.size) : new Uint16Array(l.size), p = 0, g = 0; g < m; g++) {
        var v = c[g];
        if (v >= 0) for (; v >= d; ) h[p] = d, ++p, v -= d;
        else for (; v <= f; ) h[p] = f, ++p, v -= f;
        h[p] = v, ++p;
      }
      var y = i(h);
      return { encodings: [{ kind: "IntegerPacking", byteCount: l.bytesPerElement, isUnsigned: !l.isSigned, srcSize: m }, y.encodings[0]], data: y.data };
    }(s, u);
  }, e.stringArray = function(s) {
    var u = /* @__PURE__ */ Object.create(null), c = [], l = new Int32Array(s.length), d = Ye.create(Int32Array, 1, Math.min(1024, s.length < 32 ? s.length + 1 : Math.round(s.length / 8) + 1));
    Ye.add(d, 0);
    for (var f = 0, m = 0, h = 0, p = s; h < p.length; h++) {
      var g = p[h];
      if (g != null) {
        var v = u[g];
        v === void 0 && (f += g.length, c[v = c.length] = g, u[g] = v, Ye.add(d, f)), l[m++] = v;
      } else l[m++] = -1;
    }
    var y = Ye.compact(d), _ = f6(y).encode(y), S = f6(l).encode(l);
    return { encodings: [{ kind: "StringArray", dataEncoding: S.encoding, stringData: c.join(""), offsetEncoding: _.encoding, offsets: _.data }], data: S.data };
  };
}(mr || (mr = {})), function(e) {
  function t(n, a, i) {
    return { name: n, type: 1, value: a, valueKind: i && i.valueKind, defaultFormat: i ? { encoder: i.encoder, typedArray: i.typedArray } : void 0, shouldInclude: i && i.shouldInclude };
  }
  e.str = function(n, a, i) {
    return { name: n, type: 0, value: a, valueKind: i && i.valueKind, defaultFormat: i && i.encoder ? { encoder: i.encoder } : void 0, shouldInclude: i && i.shouldInclude };
  }, e.int = t, e.float = function(n, a, i) {
    return { name: n, type: 2, value: a, valueKind: i && i.valueKind, defaultFormat: i ? { encoder: i.encoder, typedArray: i.typedArray, digitCount: i.digitCount !== void 0 ? i.digitCount : void 0 } : void 0, shouldInclude: i && i.shouldInclude };
  }, e.index = function(n) {
    return t(n, function(a, i, o) {
      return o + 1;
    }, { typedArray: Int32Array, encoder: mr.by(mr.delta).and(mr.runLength).and(mr.integerPacking) });
  };
  var r = function() {
    function n() {
      this.fields = [];
    }
    return n.prototype.index = function(a) {
      return this.fields.push(e.index(a)), this;
    }, n.prototype.str = function(a, i, o) {
      return this.fields.push(e.str(a, i, o)), this;
    }, n.prototype.int = function(a, i, o) {
      return this.fields.push(e.int(a, i, o)), this;
    }, n.prototype.vec = function(a, i, o) {
      for (var s = 0; s < i.length; s++) this.fields.push(e.int("".concat(a, "[").concat(s + 1, "]"), i[s], o));
      return this;
    }, n.prototype.float = function(a, i, o) {
      return this.fields.push(e.float(a, i, o)), this;
    }, n.prototype.many = function(a) {
      for (var i = 0; i < a.length; i++) this.fields.push(a[i]);
      return this;
    }, n.prototype.add = function(a) {
      return this.fields.push(a), this;
    }, n.prototype.getFields = function() {
      return this.fields;
    }, n;
  }();
  e.Builder = r, e.build = function() {
    return new r();
  };
}(m6 || (m6 = {})), function(e) {
  e.Empty = { fields: [], source: [] }, e.filterOf = function(t) {
    for (var r = [], n = [], a = [], i = [], o = 0, s = t.split(/[\r\n]+/); o < s.length; o++) {
      var u = s[o];
      if ((u = u.trim()).length !== 0) {
        var c = /^!/.test(u);
        c && (u = u.substr(1));
        var l = u.split(/\./), d = l[1], f = c ? d ? i : n : d ? a : r;
        f[f.length] = u, d && !r.includes(l[0]) && (r[r.length] = l[0]);
      }
    }
    var m = a.map(function(h) {
      return h.split(".")[0];
    });
    return { includeCategory: function(h) {
      return !n.includes(h) && (r.length <= 0 || r.indexOf(h) !== -1);
    }, includeField: function(h, p) {
      var g = h + "." + p;
      return !i.includes(g) && (!m.includes(h) || a.includes(g));
    } };
  }, e.DefaultFilter = { includeCategory: function(t) {
    return !0;
  }, includeField: function(t, r) {
    return !0;
  } }, e.DefaultFormatter = { getFormat: function(t, r) {
  } }, e.ofTable = function(t, r) {
    return r ? { fields: F9(t._schema), source: [{ data: t, rowCount: r.length, keys: function() {
      return X2.Array(r);
    } }] } : { fields: F9(t._schema), source: [{ data: t, rowCount: t._rowCount }] };
  };
}(ds || (ds = {})), function(e) {
  function t(r, n, a) {
    r.startDataBlock(n);
    for (var i = function(u) {
      r.writeCategory({ name: u, instance: function() {
        return ds.ofTable(a[u]);
      } });
    }, o = 0, s = a._tableNames; o < s.length; o++)
      i(s[o]);
  }
  e.writeDatabase = t, e.writeDatabaseCollection = function(r, n) {
    for (var a = 0, i = Object.keys(n); a < i.length; a++) {
      var o = i[a];
      t(r, o, n[o]);
    }
  };
}(p6 || (p6 = {}));
var vee = function() {
  function e() {
    this.builder = Rr.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = ds.DefaultFilter, this.formatter = ds.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || ds.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || ds.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlockCreated = !0, Rr.write(this.builder, "data_".concat((t || "").replace(/[ \n\t]/g, "").toUpperCase(), `
#
`));
  }, e.prototype.writeCategory = function(t, r, n) {
    if (this.encoded) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlockCreated) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(t.name)) {
      var a = KF(t, r), i = a.instance, o = a.rowCount, s = a.source;
      o && (o === 1 ? function(u, c, l, d, f, m) {
        var h = h6(c), p = l[0], g = p.data, v = h.reduce(function(x, A) {
          return f.includeField(u.name, A.name) ? Math.max(x, A.name.length) : 0;
        }, 0);
        if (v !== 0) {
          v += u.name.length + 6;
          for (var y = p.keys().move(), _ = L9(u.name, c.fields, m), S = 0; S < h.length; S++) {
            var b = h[S];
            f.includeField(u.name, b.name) && (Rr.writePadRight(d, "_".concat(u.name, ".").concat(b.name), v), R9(d, g, y, b, _[S], 0) || Rr.newline(d));
          }
          Rr.write(d, `#
`);
        }
      }(t, i, s, this.builder, this.filter, this.formatter) : function(u, c, l, d, f, m) {
        var h = h6(c), p = f === ds.DefaultFilter ? h : h.filter(function(T) {
          return f.includeField(u.name, T.name);
        }), g = p.length;
        if (g !== 0) {
          var v = L9(u.name, p, m);
          k9(d, "loop_");
          for (var y = 0; y < g; y++) k9(d, "_".concat(u.name, ".").concat(p[y].name));
          for (var _ = 0, S = 0; S < l.length; S++) {
            var b = l[S], x = b.data;
            if (b.rowCount !== 0) for (var A = b.keys(); A.hasNext; ) {
              for (var w = A.move(), C = !1, M = 0; M < g; M++) C = R9(d, x, w, p[M], v[M], _);
              C || Rr.newline(d), _++;
            }
          }
          Rr.write(d, `#
`);
        }
      }(t, i, s, this.builder, this.filter, this.formatter));
    }
  }, e.prototype.encode = function() {
    this.encoded = !0;
  }, e.prototype.writeTo = function(t) {
    for (var r = Rr.getChunks(this.builder), n = 0, a = r.length; n < a; n++) t.writeString(r[n]);
  }, e.prototype.getSize = function() {
    return Rr.getSize(this.builder);
  }, e.prototype.getData = function() {
    return Rr.getString(this.builder);
  }, e;
}();
function R9(e, t, r, n, a, i) {
  var o, s = n.valueKind, u = s ? s(r, t) : 0;
  if (u !== 0) u === 1 ? function(d) {
    Rr.writeSafe(d, ". ");
  }(e) : function(d) {
    Rr.writeSafe(d, "? ");
  }(e);
  else {
    var c = n.value(r, t, i), l = n.type;
    if (l === 0) return typeof (o = c) == "string" && o.indexOf(`
`) >= 0 ? (Jv(e, c), !0) : function(d, f) {
      if (!f) return Rr.writeSafe(d, ". "), !1;
      for (var m = f.charCodeAt(0), h = !1, p = 0, g = !1, v = !1, y = 0, _ = f.length - 1; y <= _; y++)
        switch (f.charCodeAt(y)) {
          case 9:
          case 32:
            h = !0;
            break;
          case 10:
            return Jv(d, f), !0;
          case 34:
            if (y && y === _) break;
            if (g) return Jv(d, f), !0;
            v = !0, h = !0, p = 0;
            break;
          case 39:
            if (y && y === _) break;
            if (v) return Jv(d, f), !0;
            g = !0, h = !0, p = 1;
        }
      return h || m !== 35 && m !== 36 && m !== 59 && m !== 91 && m !== 93 && m !== 95 || (h = !0), h ? (Rr.writeSafe(d, p ? '"' : "'"), Rr.writeSafe(d, f), Rr.writeSafe(d, p ? '" ' : "' ")) : (Rr.writeSafe(d, f), Rr.writeSafe(d, " ")), !1;
    }(e, c);
    l === 1 ? function(d, f) {
      Rr.writeInteger(d, f), Rr.whitespace1(d);
    }(e, c) : function(d, f, m) {
      Rr.writeFloat(d, f, m), Rr.whitespace1(d);
    }(e, c, a);
  }
  return !1;
}
function L9(e, t, r) {
  for (var n, a = [], i = 0, o = t; i < o.length; i++) {
    var s = o[i], u = r.getFormat(e, s.name);
    u && u.digitCount !== void 0 ? a[a.length] = s.type === 2 ? Math.pow(10, Math.max(0, Math.min(u.digitCount, 15))) : 0 : a[a.length] = s.type === 2 ? Math.pow(10, (n = s).defaultFormat && n.defaultFormat.digitCount !== void 0 ? Math.max(0, Math.min(n.defaultFormat.digitCount, 16)) : 6) : 0;
  }
  return a;
}
function k9(e, t) {
  Rr.write(e, t), Rr.newline(e);
}
function Jv(e, t) {
  Rr.writeSafe(e, `
;` + t), Rr.writeSafe(e, `
;
`);
}
function gee(e) {
  var t = new ArrayBuffer(E2(e)), r = new DataView(t), n = new Uint8Array(t);
  return D2(e, r, n, 0), n;
}
function E2(e) {
  var t = typeof e;
  if (t === "string") {
    var r = iF(e);
    if (r < 32) return 1 + r;
    if (r < 256) return 2 + r;
    if (r < 65536) return 3 + r;
    if (r < 4294967296) return 5 + r;
  }
  if (e instanceof Uint8Array) {
    var n = e.byteLength;
    if (n < 256) return 2 + n;
    if (n < 65536) return 3 + n;
    if (n < 4294967296) return 5 + n;
  }
  if (t === "number") {
    if (Math.floor(e) !== e) return 9;
    if (e >= 0) {
      if (e < 128) return 1;
      if (e < 256) return 2;
      if (e < 65536) return 3;
      if (e < 4294967296) return 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32) return 1;
    if (e >= -128) return 2;
    if (e >= -32768) return 3;
    if (e >= -2147483648) return 5;
    throw new Error("Number too small -0x" + e.toString(16).substr(1));
  }
  if (t === "boolean" || e == null) return 1;
  if (t === "object") {
    var a, i = 0;
    if (Array.isArray(e)) {
      a = e.length;
      for (var o = 0; o < a; o++) i += E2(e[o]);
    } else {
      var s = Object.keys(e);
      for (a = s.length, o = 0; o < a; o++) {
        var u = s[o];
        i += E2(u) + E2(e[u]);
      }
    }
    if (a < 16) return 1 + i;
    if (a < 65536) return 3 + i;
    if (a < 4294967296) return 5 + i;
    throw new Error("Array or object too long 0x" + a.toString(16));
  }
  throw new Error("Unknown type " + t);
}
function D2(e, t, r, n) {
  var a = typeof e;
  if (a === "string") {
    var i = iF(e);
    if (i < 32) return t.setUint8(n, 160 | i), jv(r, n + 1, e), 1 + i;
    if (i < 256) return t.setUint8(n, 217), t.setUint8(n + 1, i), jv(r, n + 2, e), 2 + i;
    if (i < 65536) return t.setUint8(n, 218), t.setUint16(n + 1, i), jv(r, n + 3, e), 3 + i;
    if (i < 4294967296) return t.setUint8(n, 219), t.setUint32(n + 1, i), jv(r, n + 5, e), 5 + i;
  }
  if (e instanceof Uint8Array) {
    var o = e.byteLength, s = new Uint8Array(t.buffer);
    if (o < 256) return t.setUint8(n, 196), t.setUint8(n + 1, o), s.set(e, n + 2), 2 + o;
    if (o < 65536) return t.setUint8(n, 197), t.setUint16(n + 1, o), s.set(e, n + 3), 3 + o;
    if (o < 4294967296) return t.setUint8(n, 198), t.setUint32(n + 1, o), s.set(e, n + 5), 5 + o;
  }
  if (a === "number") {
    if (!isFinite(e)) throw new Error("Number not finite: " + e);
    if (Math.floor(e) !== e) return t.setUint8(n, 203), t.setFloat64(n + 1, e), 9;
    if (e >= 0) {
      if (e < 128) return t.setUint8(n, e), 1;
      if (e < 256) return t.setUint8(n, 204), t.setUint8(n + 1, e), 2;
      if (e < 65536) return t.setUint8(n, 205), t.setUint16(n + 1, e), 3;
      if (e < 4294967296) return t.setUint8(n, 206), t.setUint32(n + 1, e), 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32) return t.setInt8(n, e), 1;
    if (e >= -128) return t.setUint8(n, 208), t.setInt8(n + 1, e), 2;
    if (e >= -32768) return t.setUint8(n, 209), t.setInt16(n + 1, e), 3;
    if (e >= -2147483648) return t.setUint8(n, 210), t.setInt32(n + 1, e), 5;
    throw new Error("Number too small -0x" + (-e).toString(16).substr(1));
  }
  if (e == null) return t.setUint8(n, 192), 1;
  if (a === "boolean") return t.setUint8(n, e ? 195 : 194), 1;
  if (a === "object") {
    var u, c = 0, l = Array.isArray(e), d = void 0;
    if ((u = l ? e.length : (d = Object.keys(e)).length) < 16 ? (t.setUint8(n, u | (l ? 144 : 128)), c = 1) : u < 65536 ? (t.setUint8(n, l ? 220 : 222), t.setUint16(n + 1, u), c = 3) : u < 4294967296 && (t.setUint8(n, l ? 221 : 223), t.setUint32(n + 1, u), c = 5), l) for (var f = 0; f < u; f++) c += D2(e[f], t, r, n + c);
    else {
      f = 0;
      for (var m = d.length; f < m; f++) {
        var h = d[f];
        c += D2(h, t, r, n + c), c += D2(e[h], t, r, n + c);
      }
    }
    return c;
  }
  throw new Error("Unknown type " + a);
}
var Xa, uh, oc, yee = function() {
  function e(t, r, n) {
    this.autoClassify = n, this.dataBlocks = [], this.filter = ds.DefaultFilter, this.formatter = ds.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = r, this.data = { encoder: t, version: "0.3.0", dataBlocks: this.dataBlocks };
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || ds.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || ds.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlocks.push({ header: (t || "").replace(/[ \n\t]/g, "").toUpperCase(), categories: [] });
  }, e.prototype.writeCategory = function(t, r, n) {
    if (!this.data) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlocks.length) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(t.name)) {
      var a = KF(t, r), i = a.instance, o = a.rowCount, s = a.source;
      if (o) {
        for (var u = { name: "_" + t.name, columns: [], rowCount: o }, c = 0, l = h6(i); c < l.length; c++) {
          var d = l[c];
          if (this.filter.includeField(t.name, d.name)) {
            var f = this.formatter.getFormat(t.name, d.name);
            u.columns.push(xee(t.name, d, s, o, f, this.binaryEncodingProvider, this.autoClassify));
          }
        }
        u.columns.length && this.dataBlocks[this.dataBlocks.length - 1].categories.push(u);
      }
    }
  }, e.prototype.encode = function() {
    this.encodedData || (this.encodedData = gee(this.data), this.data = null, this.dataBlocks = null);
  }, e.prototype.writeTo = function(t) {
    t.writeBinary(this.encodedData);
  }, e.prototype.getData = function() {
    return this.encode(), this.encodedData;
  }, e.prototype.getSize = function() {
    return this.encodedData.length;
  }, e;
}();
function bee(e, t) {
  return e === 0 ? Cd.by(mr.stringArray) : e === 1 ? f6(t) : (r = t, d6.classify(r));
  var r;
}
function xee(e, t, r, n, a, i, o) {
  var s = function(p, g, v, y) {
    for (var _ = p.type === 0, S = new g(v), b = new Uint8Array(v), x = p.valueKind, A = p.value, w = !0, C = 0, M = 0; M < y.length; M++) for (var T = y[M].data, N = y[M].keys(); N.hasNext; ) {
      var I = N.move(), P = x ? x(I, T) : 0;
      if (P !== 0) b[C] = P, _ && (S[C] = ""), w = !1;
      else {
        var O = A(I, T, C);
        typeof O != "string" || O ? b[C] = 0 : (b[C] = 1, w = !1), S[C] = O;
      }
      C++;
    }
    return { array: S, allPresent: w, mask: b };
  }(t, function(p, g) {
    return g && g.typedArray ? g.typedArray : p.defaultFormat && p.defaultFormat.typedArray ? p.defaultFormat.typedArray : p.type === 0 ? Array : p.type === 1 ? Int32Array : Float64Array;
  }(t, a), n, r), u = s.array, c = s.allPresent, l = s.mask, d = function(p, g, v, y) {
    return v && v.encoder ? v.encoder : g.defaultFormat && g.defaultFormat.encoder ? g.defaultFormat.encoder : y ? y.get(p, g.name) : void 0;
  }(e, t, a, i);
  d || (d = o ? bee(t.type, u) : function(p) {
    return p === 0 ? Cd.by(mr.stringArray) : Cd.by(mr.byteArray);
  }(t.type));
  var f = d.encode(u), m = void 0;
  if (!c) {
    var h = Cd.by(mr.runLength).and(mr.byteArray).encode(l);
    m = h.data.length < l.length ? h : Cd.by(mr.byteArray).encode(l);
  }
  return { name: t.name, data: f, mask: m };
}
function eg(e, t, r, n, a, i) {
  for (var o = new Ho.EdgeBuilder(a, e, t), s = new Uint16Array(o.slotCount), u = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(s, n[c]), o.assignProperty(u, r[c]);
  return o.createGraph({ flags: s, order: u }, { canRemap: i });
}
(function(e) {
  e.Encoder = p6, e.Category = ds, e.Field = m6, e.Encoding = mr, e.createEncoder = function(n) {
    var a = n || {}, i = a.binary, o = i !== void 0 && i, s = a.encoderName;
    return o ? new yee(s === void 0 ? "mol*" : s, n ? n.binaryEncodingPovider : void 0, !!n && !!n.binaryAutoClassifyEncoding) : new vee();
  }, e.fields = function() {
    return e.Field.build();
  };
  var t = e.Encoding;
  function r(n) {
    var a = n.precision;
    if (a !== void 0) {
      var i = Math.pow(10, a), o = t.by(t.fixedPoint(i));
      switch (n.encoding) {
        case "pack":
          return o.and(t.integerPacking);
        case "rle":
          return o.and(t.runLength).and(t.integerPacking);
        case "delta":
          return o.and(t.delta).and(t.integerPacking);
        case "delta-rle":
          return o.and(t.delta).and(t.runLength).and(t.integerPacking);
      }
    } else switch (n.encoding) {
      case "pack":
        return t.by(t.integerPacking);
      case "rle":
        return t.by(t.runLength).and(t.integerPacking);
      case "delta":
        return t.by(t.delta).and(t.integerPacking);
      case "delta-rle":
        return t.by(t.delta).and(t.runLength).and(t.integerPacking);
    }
    throw new Error("cannot be reached");
  }
  e.Encodings = { deltaRLE: t.by(t.delta).and(t.runLength).and(t.integerPacking), fixedPoint2: t.by(t.fixedPoint(100)).and(t.delta).and(t.integerPacking), fixedPoint3: t.by(t.fixedPoint(1e3)).and(t.delta).and(t.integerPacking) }, e.categoryInstance = function(n, a) {
    return { fields: n, source: [a] };
  }, e.createEncodingProviderFromCifFrame = function(n) {
    return { get: function(a, i) {
      var o = n.categories[a];
      if (o) {
        var s = o.getField(i);
        return s && s.binaryEncoding ? Cd.fromEncoding(s.binaryEncoding) : void 0;
      }
    } };
  }, e.createEncodingProviderFromJsonConfig = function(n) {
    return { get: function(a, i) {
      for (var o = 0; o < n.length; o++) {
        var s = n[o];
        if (s.categoryName === a && s.columnName === i) return r(s);
      }
    } };
  };
})(Xa || (Xa = {})), function(e) {
  e.Descriptor = { name: "chem_comp_bond", cifExport: { prefix: "", categories: [{ name: "chem_comp_bond", instance: function(r) {
    var n = e.Provider.get(r.firstModel);
    if (!n) return Xa.Category.Empty;
    var a = n.data;
    if (!a) return Xa.Category.Empty;
    for (var i = r.structures[0].uniqueResidueNames, o = a.comp_id, s = a._rowCount, u = [], c = 0; c < s; c++) i.has(o.value(c)) && (u[u.length] = c);
    return Xa.Category.ofTable(a, u);
  } }] } }, e.Provider = ic.create(e.Descriptor), e.chemCompBondFromTable = function(r, n) {
    return Yr.pick(n, ur.chem_comp_bond, function(a) {
      return r.properties.chemicalComponentMap.has(n.comp_id.value(a));
    });
  }, e.getEntriesFromChemCompBond = function(r) {
    var n = /* @__PURE__ */ new Map();
    function a(S) {
      if (n.has(S)) return n.get(S);
      var b = new t(S);
      return n.set(S, b), b;
    }
    for (var i = r.comp_id, o = r.atom_id_1, s = r.atom_id_2, u = r.value_order, c = r.pdbx_aromatic_flag, l = r._rowCount, d = a(i.value(0)), f = 0; f < l; f++) {
      var m = i.value(f), h = o.value(f), p = s.value(f), g = u.value(f), v = c.value(f) === "Y";
      d.id !== m && (d = a(m));
      var y = 1, _ = 1;
      switch (v && (y |= 16), g.toLowerCase()) {
        case "delo":
          y |= 16;
          break;
        case "doub":
          _ = 2;
          break;
        case "trip":
          _ = 3;
          break;
        case "quad":
          _ = 4;
      }
      d.add(h, p, _, y);
    }
    return n;
  };
  var t = function() {
    function r(n) {
      this.id = n, this.map = /* @__PURE__ */ new Map();
    }
    return r.prototype.add = function(n, a, i, o, s) {
      s === void 0 && (s = !0);
      var u = this.map.get(n);
      if (u !== void 0)
        u.get(a) === void 0 && u.set(a, { order: i, flags: o });
      else {
        var c = /* @__PURE__ */ new Map();
        c.set(a, { order: i, flags: o }), this.map.set(n, c);
      }
      s && this.add(a, n, i, o, !1);
    }, r;
  }();
  e.Entry = t;
}(uh || (uh = {})), function(e) {
  function t(r, n) {
    for (var a = r.units, i = 0, o = a.length; i < o; i++) if ($e.indexOf(a[i].elements, n) >= 0) return !0;
    return !1;
  }
  e.Descriptor = { name: "struct_conn", cifExport: { prefix: "", categories: [{ name: "struct_conn", instance: function(r) {
    var n = e.Provider.get(r.firstModel);
    if (!n || n.entries.length === 0) return Xa.Category.Empty;
    for (var a = r.structures[0], i = [], o = 0, s = n.entries; o < s.length; o++) {
      var u = s[o];
      t(a, u.partnerA.atomIndex) && t(a, u.partnerB.atomIndex) && (i[i.length] = u.rowIndex);
    }
    return Xa.Category.ofTable(n.data, i);
  } }] } }, e.Provider = ic.create(e.Descriptor), e.isExhaustive = function(r) {
    var n = e.Provider.get(r);
    return !!n && n.data.id.rowCount / r.atomicConformation.atomId.rowCount > 0.95;
  }, e.getAtomIndexFromEntries = function(r) {
    for (var n = /* @__PURE__ */ new Map(), a = 0, i = r; a < i.length; a++) {
      var o = i[a], s = o.partnerA.atomIndex, u = o.partnerB.atomIndex;
      n.has(s) ? n.get(s).push(o) : n.set(s, [o]), n.has(u) ? n.get(u).push(o) : n.set(u, [o]);
    }
    return n;
  }, e.getEntriesFromStructConn = function(r, n) {
    for (var a = r.conn_type_id, i = r.pdbx_dist_value, o = r.pdbx_value_order, s = { label_asym_id: r.ptnr1_label_asym_id, label_seq_id: r.ptnr1_label_seq_id, auth_seq_id: r.ptnr1_auth_seq_id, label_atom_id: r.ptnr1_label_atom_id, label_alt_id: r.pdbx_ptnr1_label_alt_id, ins_code: r.pdbx_ptnr1_PDB_ins_code, symmetry: r.ptnr1_symmetry }, u = { label_asym_id: r.ptnr2_label_asym_id, label_seq_id: r.ptnr2_label_seq_id, auth_seq_id: r.ptnr2_auth_seq_id, label_atom_id: r.ptnr2_label_atom_id, label_alt_id: r.pdbx_ptnr2_label_alt_id, ins_code: r.pdbx_ptnr2_PDB_ins_code, symmetry: r.ptnr2_symmetry }, c = function(v, y) {
      if (y.label_asym_id.valueKind(v) === 0) {
        var _ = y.label_asym_id.value(v), S = n.atomicHierarchy.index.findEntity(_);
        if (!(S < 0)) {
          var b = n.atomicHierarchy.index.findResidue(n.entities.data.id.value(S), _, y.auth_seq_id.value(v), y.ins_code.value(v));
          if (!(b < 0)) {
            var x = y.label_atom_id.value(v);
            if (x) {
              var A = n.atomicHierarchy.index.findAtomOnResidue(b, x, y.label_alt_id.value(v));
              if (!(A < 0)) return { residueIndex: b, atomIndex: A, symmetry: y.symmetry.value(v) };
            }
          }
        }
      }
    }, l = [], d = 0; d < r._rowCount; d++) {
      var f = c(d, s), m = c(d, u);
      if (f !== void 0 && m !== void 0) {
        var h = a.value(d), p = 0, g = 1;
        switch ((o.value(d) || "").toLowerCase()) {
          case "sing":
            g = 1;
            break;
          case "doub":
            g = 2;
            break;
          case "trip":
            g = 3;
            break;
          case "quad":
            g = 4;
            break;
          default:
            g = HF(r.ptnr1_label_comp_id.value(d), r.ptnr1_label_atom_id.value(d), r.ptnr2_label_comp_id.value(d), r.ptnr2_label_atom_id.value(d));
        }
        switch (h) {
          case "covale":
            p = 1;
            break;
          case "disulf":
            p = 9;
            break;
          case "hydrog":
            p = 4;
            break;
          case "metalc":
            p = 2;
        }
        l.push({ rowIndex: d, flags: p, order: g, distance: i.value(d), partnerA: f, partnerB: m });
      }
    }
    return l;
  };
}(oc || (oc = {}));
var z9 = D(), U9 = D();
function _ee(e, t, r) {
  return e.conformation.position(t, z9), e.conformation.position(r, U9), D.distance(z9, U9);
}
var See = /* @__PURE__ */ new Set();
function Aee(e, t) {
  var r = k(k({}, UF), t);
  return r.noCompute || yn.isCoarseGrained(e.model) ? c6.Empty : yn.isMaterial(e.model) && (r.isMaterial = !0, Ra.Provider.get(e.model)) ? function(n) {
    var a = Ra.Provider.get(n.model);
    return a ? eg(Array.from(a.bonds.a || []), Array.from(a.bonds.b || []), Array.from(a.bonds.edgeProps.order || []), Array.from(a.bonds.edgeProps.flag || []), a.bonds.vertexCount, !1) : eg([], [], [], [], 0, !1);
  }(e) : !r.forceCompute && Ra.Provider.get(e.model) ? function(n) {
    for (var a = Ra.Provider.get(n.model), i = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, s = n.elements.length, u = a.bonds, c = u.offset, l = u.b, d = u.edgeProps, f = d.order, m = d.distance, h = d.flag, p = n.model.atomicHierarchy.atomSourceIndex, g = yn.getInvertedAtomSourceIndex(n.model).invertedIndex, v = [], y = [], _ = [], S = [], b = 0; b < s; b++) for (var x = i[b], A = Ad(o.value(x)), w = wd(A), C = p.value(x), M = c[C], T = c[C + 1]; M < T; ++M) {
      var N = g[l[M]];
      if (!(x >= N)) {
        var I = $e.indexOf(n.elements, N);
        if (!(I < 0)) {
          var P = Ad(o.value(N)), O = m[M], F = _ee(n, x, N), R = !1;
          n.model.sourceData.kind === "mol" || n.model.sourceData.kind === "sdf" || n.model.sourceData.kind === "mol2" ? R = !0 : O >= 0 ? R = Yn(F, O, 0.3) : A === -1 || P === -1 ? R = !0 : w && wd(P) && (R = !1), R && (v[v.length] = b, y[y.length] = I, S[S.length] = f[M], _[_.length] = h[M]);
        }
      }
    }
    return eg(v, y, S, _, s, !1);
  }(e) : function(n, a) {
    for (var i = a.maxRadius, o = a.isMaterial, s = n.model.atomicConformation, u = s.x, c = s.y, l = s.z, d = n.elements.length, f = n.elements, m = n.residueIndex, h = n.chainIndex, p = n.model.atomicHierarchy.atoms, g = p.type_symbol, v = p.label_atom_id, y = p.label_alt_id, _ = p.label_comp_id, S = n.model.atomicHierarchy.residues.label_seq_id, b = n.model.atomicHierarchy.index, x = n.model.sequence.byEntityKey, A = n.lookup3d, w = oc.Provider.get(n.model), C = uh.Provider.get(n.model), M = oc.isExhaustive(n.model), T = [], N = [], I = [], P = [], O = -1, F = void 0, R = !0, G = !0, L = !0, q = See, K = 0; K < d; K++) {
      var X = f[K], H = g.value(X);
      R && H !== "H" && H !== "O" && (R = !1);
      var W = a.forceCompute ? void 0 : w && w.byAtomIndex.get(X), ee = !1;
      if (W) for (var $ = 0, te = W; $ < te.length; $++) {
        var re = te[$], ie = re.partnerA, oe = re.partnerB;
        if (ie.symmetry === oe.symmetry) {
          var se = ie.atomIndex === X ? oe : ie;
          (Ce = $e.indexOf(n.elements, se.atomIndex)) < 0 || f[Ce] < X || (T[T.length] = K, N[N.length] = Ce, I[I.length] = re.flags, P[P.length] = re.order, ee || q.clear(), ee = !0, q.add(Ce));
        }
      }
      if (!M) {
        var he = m[X], ge = S.value(he), De = _.value(X);
        if (!a.forceCompute && he !== O) if (C && C.entries.has(De)) {
          var ae = x[b.getEntityFromChain(h[X])];
          F = ae && ae.sequence.microHet.has(ge) ? void 0 : C.entries.get(De).map;
        } else F = void 0;
        O = he;
        for (var ce = Ad(H), _e = v.value(X), le = F ? F.get(_e) : void 0, ue = A.find(u[X], c[X], l[X], i), be = ue.indices, Se = ue.count, Ne = ue.squaredDistances, J = wd(ce), Z = bp(ce), de = y.value(X), ye = ey.has(ce), Ae = 0; Ae < Se; Ae++) {
          var Ce = be[Ae];
          if (!ee || !q.has(Ce)) {
            var Ie = f[Ce];
            if (!(Ie <= X)) {
              var Ue = y.value(Ie);
              if (!de || !Ue || de === Ue) {
                var Xe = Ad(g.value(Ie)), je = wd(Xe);
                if (!J || !je) {
                  var ht = (ye || ey.has(Xe)) && !(J || je), xt = m[Ie];
                  if (he === xt && le) {
                    var dt = le.get(v.value(Ie));
                    if (dt) {
                      T[T.length] = K, N[N.length] = Ce, P[P.length] = dt.order;
                      var Le = dt.flags;
                      ht && (o ? Le = 33 : (1 | Le && (Le ^= 1), Le |= 2)), I[I.length] = Le;
                    }
                  } else {
                    var j = Math.sqrt(Ne[Ae]);
                    if (j !== 0 && j <= l6(ce, Xe, Z, bp(Xe), o)) {
                      T[T.length] = K, N[N.length] = Ce, P[P.length] = cee(De, _e, v.value(Ie)), I[I.length] = 32 | (ht && !o ? 2 : 1);
                      var xe = S.value(xt);
                      ge === xe && (G = !1), Math.abs(ge - xe) > 1 && (L = !1);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    return eg(T, N, P, I, d, R || G && L);
  }(e, r);
}
var G9 = D(), V9 = D();
function q9(e, t, r, n) {
  return e.conformation.position(t, G9), r.conformation.position(n, V9), D.distance(G9, V9);
}
var wee = Ee(), pf = D(), Pt, Cee = k(k({}, UF), { ignoreWater: !0, ignoreIon: !0 });
function Eee(e, t) {
  var r = new em.Builder(), n = e.models.some(function(a) {
    return Ra.Provider.get(a);
  });
  return t.noCompute || e.isCoarseGrained && !n || st.eachUnitPair(e, function(a, i) {
    (function(o, s, u, c) {
      var l = u.maxRadius, d = o.elements, f = o.residueIndex, m = o.model.atomicConformation, h = m.x, p = m.y, g = m.z, v = s.elements, y = s.residueIndex, _ = o.elements.length, S = o.model.atomicHierarchy.atoms, b = S.type_symbol, x = S.label_alt_id, A = S.label_atom_id, w = S.label_comp_id, C = s.model.atomicHierarchy.atoms, M = C.type_symbol, T = C.label_alt_id, N = C.label_atom_id, I = C.label_comp_id, P = o.model.atomicHierarchy.residues.auth_seq_id, O = s.model.atomicHierarchy.residues.auth_seq_id, F = o.model.atomicConformation.occupancy, R = s.model.atomicConformation.occupancy, G = F.isDefined && R.isDefined, L = o.model === s.model && oc.Provider.get(o.model), q = !u.forceCompute && o.model === s.model && Ra.Provider.get(o.model), K = o.model.atomicHierarchy.atomSourceIndex, X = (q ? yn.getInvertedAtomSourceIndex(s.model) : { invertedIndex: void 0 }).invertedIndex, H = o.model === s.model && oc.isExhaustive(o.model), W = Ee.mul(wee, s.conformation.operator.inverse, o.conformation.operator.matrix), ee = !Ee.isIdentity(W), $ = s.boundary.sphere, te = $.center, re = $.radius, ie = (re + l) * (re + l);
      c.startUnitPair(o.id, s.id);
      for (var oe = 0; oe < _; oe++) {
        var se = d[oe];
        if (D.set(pf, h[se], p[se], g[se]), ee && D.transformMat4(pf, pf, W), !(D.squaredDistance(pf, te) > ie)) if (u.forceCompute || !q) {
          var he = u.forceCompute ? void 0 : L && L.byAtomIndex.get(se);
          if (he && he.length) {
            for (var ge = !1, De = 0, ae = he; De < ae.length; De++) {
              var ce = ae[De], _e = ce.partnerA, le = ce.partnerB, ue = _e.atomIndex === se ? le : _e;
              (mn = $e.indexOf(s.elements, ue.atomIndex)) < 0 || q9(o, se, s, ue.atomIndex) > l || (c.add(oe, mn, { order: ce.order, flag: ce.flags }), ge = !0);
            }
            if (ge) continue;
          }
          if (!H) {
            var be = F.value(se), Se = s.lookup3d.find(pf[0], pf[1], pf[2], l), Ne = Se.indices, J = Se.count, Z = Se.squaredDistances;
            if (J !== 0) for (var de = Ad(b.value(se)), ye = wd(de), Ae = bp(de), Ce = x.value(se), Ie = ey.has(de), Ue = A.value(se), Xe = w.value(f[se]), je = 0; je < J; je++) {
              pn = v[mn = Ne[je]];
              var ht = T.value(pn);
              if (!(Ce && ht && Ce !== ht || G && R.value(pn) < 1 && be < 1 && P.value(se) === O.value(pn))) {
                var xt = wd(xa = Ad(M.value(pn)));
                if (!ye || !xt) {
                  var dt = (Ie || ey.has(xa)) && !(ye || xt);
                  if (!dt && (zn = Math.sqrt(Z[je])) !== 0 && zn <= l6(de, xa, Ae, bp(xa))) {
                    var Le = N.value(pn), j = I.value(y[pn]);
                    c.add(oe, mn, { order: HF(Xe, j, Ue, Le), flag: 32 | (dt ? 2 : 1) });
                  }
                }
              }
            }
          }
        } else for (var xe = q.maxDistance, ke = q.bonds, Je = ke.offset, Ct = ke.b, At = ke.edgeProps, Or = At.order, qn = At.distance, Xn = At.flag, kn = K.value(se), fn = Je[kn], la = Je[kn + 1]; fn < la; ++fn) {
          var mn, pn = X[Ct[fn]];
          if (!((mn = $e.indexOf(s.elements, pn)) < 0)) {
            var ba = Ad(b.value(se)), xa = Ad(b.value(pn)), to = qn[fn], zn = q9(o, se, s, pn), An = !1;
            to >= 0 ? An = Yn(zn, to, 0.3) : xe >= 0 ? An = zn < xe : (An = zn < l6(ba, xa, bp(ba), bp(xa)), wd(ba) && wd(xa) && (An = !1)), An && c.add(oe, mn, { order: Or[fn], flag: Xn[fn] });
          }
        }
      }
      c.finishUnitPair();
    })(a, i, t, r);
  }, { maxRadius: t.maxRadius, validUnit: function(a) {
    return Ke.isAtomic(a);
  }, validUnitPair: function(a, i) {
    return t.validUnitPair(e, a, i);
  } }), new J2(r.getMap());
}
function Dee(e, t) {
  var r = k(k({}, Cee), t);
  return Eee(e, k(k({}, r), { validUnitPair: t && t.validUnitPair || function(n, a, i) {
    var o = a.model.atomicHierarchy.derived.residue.moleculeType, s = i.model.atomicHierarchy.derived.residue.moleculeType, u = !(Ke.isAtomic(a) && o[a.residueIndex[a.elements[0]]] === 2 || Ke.isAtomic(i) && s[i.residueIndex[i.elements[0]]] === 2), c = a.model === i.model, l = !Ke.isAtomic(a) || o[a.residueIndex[a.elements[0]]] !== 3 || c && H9(a), d = !Ke.isAtomic(i) || s[i.residueIndex[i.elements[0]]] !== 3 || c && H9(i), f = l && d;
    return st.validUnitPair(n, a, i) && (u || !r.ignoreWater) && (f || !r.ignoreIon);
  } }));
}
function H9(e) {
  if (!Ke.isAtomic(e)) return !1;
  var t = e.elements, r = oc.Provider.get(e.model);
  if (r) {
    for (var n = 0, a = t.length; n < a; n++) if (r.byAtomIndex.get(t[n])) return !0;
  }
  return !1;
}
function Mee(e) {
  for (var t = function(i) {
    for (var o = nr.transientSegments(i.model.atomicHierarchy.residueAtomSegments, i.elements), s = 0; o.hasNext; ) {
      var u = o.move();
      s = Math.max(s, u.end - u.start);
    }
    return s;
  }(e), r = function(i, o) {
    return { startVertex: 0, endVertex: 0, count: 0, isRingAtom: new Int32Array(o), marked: new Int32Array(o), queue: new Int32Array(o), pred: new Int32Array(o), depth: new Int32Array(o), left: new Int32Array(5), right: new Int32Array(5), color: new Int32Array(o), currentColor: 0, currentAltLoc: "", hasAltLoc: !1, rings: [], currentRings: [], unit: i, bonds: i.bonds, altLoc: i.model.atomicHierarchy.atoms.label_alt_id };
  }(e, t), n = nr.transientSegments(e.model.atomicHierarchy.residueAtomSegments, e.elements); n.hasNext; ) {
    var a = n.move();
    Iee(r, a.start, a.end);
  }
  return r.rings;
}
function K9(e) {
  e.count = e.endVertex - e.startVertex;
  for (var t = e.isRingAtom, r = e.pred, n = e.color, a = e.depth, i = e.marked, o = 0; o < e.count; o++) t[o] = 0, r[o] = -1, i[o] = -1, n[o] = 0, a[o] = 0;
  e.currentColor = 0, e.currentAltLoc = "", e.hasAltLoc = !1;
}
function X9(e) {
  for (var t = e.depth, r = 0; r < e.count; r++) t[r] = e.count + 1;
}
function j9(e, t) {
  var r = e.bonds.offset, n = e.startVertex + t, a = r[n], i = r[n + 1] - a;
  return !(i <= 1 || e.isRingAtom[t] && i === 2);
}
function Iee(e, t, r) {
  if (e.startVertex = t, e.endVertex = r, !(e.endVertex - e.startVertex < 3)) {
    e.currentRings = [];
    for (var n = e.unit.elements, a = [], i = e.startVertex; i < e.endVertex; i++)
      js(a, u = e.altLoc.value(n[i]));
    C2(a, "");
    var o = 1;
    if (a.length === 0)
      for (K9(e), i = 0; i < e.count; i++) j9(e, i) && (X9(e), o = Y9(e, i, o));
    else for (var s = 0; s < a.length; s++)
      for (K9(e), e.hasAltLoc = !0, e.currentAltLoc = a[s], i = 0; i < e.count; i++) {
        var u;
        j9(e, i) && ((u = e.altLoc.value(n[e.startVertex + i])) && u !== e.currentAltLoc || (X9(e), o = Y9(e, i, o)));
      }
    i = 0;
    for (var c = e.currentRings.length; i < c; i++) e.rings.push(e.currentRings[i]);
  }
}
function Tee(e, t, r, n) {
  if (r < t) return !1;
  for (var a = e.pred, i = e.color, o = e.left, s = e.right, u = ++e.currentColor, c = t, l = 0; l < 5 && (i[c] = u, !((c = a[c]) < 0)); l++) ;
  var d = 0, f = 0, m = !1, h = 0;
  for (c = r, l = 0; l < 5; l++) {
    if (i[c] === u) {
      h = c, m = !0;
      break;
    }
    if (s[f++] = c, (c = a[c]) < 0) break;
  }
  if (!m) return !1;
  for (c = t, l = 0; l < 5 && (o[d++] = c, h !== c) && !((c = a[c]) < 0); l++) ;
  var p = d + f;
  if (p < 3) return !1;
  var g = new Int32Array(p), v = 0;
  for (l = 0; l < d; l++) g[v++] = e.startVertex + o[l], n[o[l]] = 1;
  for (l = f - 1; l >= 0; l--) g[v++] = e.startVertex + s[l], n[s[l]] = 1;
  Du(g);
  for (var y = 0, _ = e.currentRings.length; y < _; y++) {
    var S = e.currentRings[y];
    if (g.length === S.length) {
      if ($e.areEqual(g, S)) return !1;
    } else if (g.length > S.length && $e.isSubset(g, S)) return !1;
  }
  return e.currentRings.push($e.ofSortedArray(g)), !0;
}
function Y9(e, t, r) {
  var n = e.bonds, a = e.startVertex, i = e.endVertex, o = e.isRingAtom, s = e.marked, u = e.queue, c = e.pred, l = e.depth, d = e.unit.elements, f = n.b, m = n.edgeProps.flags, h = n.offset;
  s[t] = r, l[t] = 0, u[0] = t;
  for (var p = 0, g = 1; p < g; ) for (var v = u[p++], y = l[v], _ = a + v, S = h[_], b = h[_ + 1], x = S; x < b; x++) {
    var A = f[x];
    if (!(A < a || A >= i) && pr.isCovalent(m[x])) {
      if (e.hasAltLoc) {
        var w = e.altLoc.value(d[A]);
        if (w && e.currentAltLoc !== w) continue;
      }
      var C = A - a;
      if (s[C] !== r) {
        var M = Math.min(l[C], y + 1);
        M > 5 || (l[C] = M, s[C] = r, u[g++] = C, c[C] = v);
      } else if (c[C] !== v && c[v] !== C && Tee(e, v, C, o)) return r + 1;
    }
  }
  return r + 1;
}
function W9(e) {
  for (var t = e.length, r = new Int32Array(2 * t), n = 0; n < r.length; n++) r[n] = -1;
  for (var a = "", i = "", o = 0, s = 1; s < r.length; s++) {
    for (n = r[s - o - 1]; n !== -1 && (a = e[s % t]) !== (i = e[(o + n + 1) % t]); ) a < i && (o = s - n - 1), n = r[n];
    n === -1 && (a = e[s % t]) !== (i = e[(o + n + 1) % t]) ? (a < i && (o = s), r[s - o] = -1) : r[s - o] = n + 1;
  }
  return o;
}
function Z9(e, t) {
  var r, n = e.length, a = [];
  for (r = 0; r < n - 1; r++) a.push(e[(r + t) % n]), a.push("-");
  return a.push(e[(r + t) % n]), a.join("");
}
function XF(e, t) {
  switch (e.kind) {
    case 0:
      return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[t]];
    case 1:
    case 2:
      var r = function(a, i) {
        var o = a.coarseElements.entityKey[i], s = a.model.sequence.byEntityKey[o].sequence, u = a.coarseElements.seq_id_begin.value(i);
        return s.compId.value(u - 1);
      }(e, t), n = e.model.properties.chemicalComponentMap.get(r);
      if (n) return Fh(n.type, r);
  }
  return 0;
}
(function(e) {
  function t(i, o, s, u, c, l) {
    return { kind: "bond-location", aStructure: i, aUnit: o, aIndex: s, bStructure: u, bUnit: c, bIndex: l };
  }
  function r(i, o) {
    return i.aStructure.label === o.aStructure.label && i.bStructure.label === o.bStructure.label && i.aIndex === o.aIndex && i.bIndex === o.bIndex && i.aUnit.id === o.aUnit.id && i.bUnit.id === o.bUnit.id;
  }
  function n(i, o) {
    return { kind: "bond-loci", structure: i, bonds: o };
  }
  e.Location = t, e.isLocation = function(i) {
    return !!i && i.kind === "bond-location";
  }, e.areLocationsEqual = r, e.Loci = n, e.isLoci = function(i) {
    return !!i && i.kind === "bond-loci";
  }, e.areLociEqual = function(i, o) {
    if (i.structure !== o.structure || i.bonds.length !== o.bonds.length) return !1;
    for (var s = 0, u = i.bonds.length; s < u; ++s) if (!r(i.bonds[s], o.bonds[s])) return !1;
    return !0;
  }, e.isLociEmpty = function(i) {
    return i.bonds.length === 0;
  }, e.remapLoci = function(i, o) {
    if (o === i.structure) return i;
    var s = [];
    return i.bonds.forEach(function(u) {
      var c = o.unitMap.get(u.aUnit.id);
      if (c) {
        var l = o.unitMap.get(u.bUnit.id);
        if (l) {
          var d = u.aUnit.elements[u.aIndex], f = $e.indexOf(c.elements, d);
          if (f !== -1) {
            var m = u.bUnit.elements[u.bIndex], h = $e.indexOf(l.elements, m);
            h !== -1 && s.push(t(i.structure, c, f, i.structure, l, h));
          }
        }
      }
    }), n(o, s);
  }, e.toStructureElementLoci = function(i) {
    for (var o = [], s = /* @__PURE__ */ new Map(), u = 0, c = i.bonds; u < c.length; u++) {
      var l = c[u], d = l.aIndex, f = l.aUnit, m = l.bIndex, h = l.bUnit;
      f === h ? s.has(f.id) ? s.get(f.id).push(d, m) : s.set(f.id, [d, m]) : (s.has(f.id) ? s.get(f.id).push(d) : s.set(f.id, [d]), s.has(h.id) ? s.get(h.id).push(m) : s.set(h.id, [m]));
    }
    return s.forEach(function(p, g) {
      o.push({ unit: i.structure.unitMap.get(g), indices: $e.deduplicate($e.ofUnsortedArray(p)) });
    }), et(i.structure, o);
  }, e.toFirstStructureElementLoci = function(i) {
    var o = i.bonds[0], s = o.aUnit, u = o.aIndex;
    return et(i.structure, [{ unit: s, indices: We.ofSingleton(u) }]);
  }, e.getType = function(i, o) {
    if (o.aUnit === o.bUnit) {
      var s = o.aUnit.bonds, u = s.getEdgeIndex(o.aIndex, o.bIndex);
      return u < 0 ? pr.create(0) : pr.create(s.edgeProps.flags[u]);
    }
    var c = i.interUnitBonds.getBondFromLocation(o);
    return c ? pr.create(c.props.flag) : pr.create(0);
  }, e.getOrder = function(i, o) {
    if (o.aUnit === o.bUnit) {
      var s = o.aUnit.bonds, u = s.getEdgeIndex(o.aIndex, o.bIndex);
      return u < 0 ? 0 : s.edgeProps.order[u];
    }
    var c = i.interUnitBonds.getBondFromLocation(o);
    return c ? c.props.order : 0;
  }, e.getIntraUnitBondCount = function(i) {
    for (var o = 0, s = 0, u = i.units.length; s < u; ++s) {
      var c = i.units[s];
      Ke.isAtomic(c) && (o += c.bonds.edgeCount);
    }
    return o;
  };
  var a = function() {
    function i() {
      this.current = {}, this.hasNext = !1;
    }
    return i.prototype.move = function() {
      return this.advance(), this.current;
    }, i.prototype.setElement = function(o, s, u) {
      this.structure = o, this.unit = s, this.index = u, this.interBondIndices = o.interUnitBonds.getEdgeIndices(u, s.id), this.interBondCount = this.interBondIndices.length, this.interBondIndex = 0, this.intraBondEnd = s.bonds.offset[u + 1], this.intraBondIndex = s.bonds.offset[u], this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }, i.prototype.advance = function() {
      if (this.intraBondIndex < this.intraBondEnd) this.current.otherUnit = this.unit, this.current.otherIndex = this.unit.bonds.b[this.intraBondIndex], this.current.type = this.unit.bonds.edgeProps.flags[this.intraBondIndex], this.current.order = this.unit.bonds.edgeProps.order[this.intraBondIndex], this.intraBondIndex += 1;
      else {
        if (!(this.interBondIndex < this.interBondCount)) return void (this.hasNext = !1);
        var o = this.structure.interUnitBonds.edges[this.interBondIndex];
        this.current.otherUnit = this.structure.unitMap.get(o.unitA !== this.unit.id ? o.unitA : o.unitB), this.current.otherIndex = o.indexA !== this.index ? o.indexA : o.indexB, this.current.type = o.props.flag, this.current.order = o.props.order, this.interBondIndex += 1;
      }
      this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }, i;
  }();
  e.ElementBondIterator = a, e.getBoundingSphere = function(i, o) {
    return Lp.fromPairProvider(i.bonds.length, function(s, u, c) {
      var l = i.bonds[s], d = l.aUnit, f = l.aIndex, m = l.bUnit, h = l.bIndex;
      d.conformation.position(d.elements[f], u), m.conformation.position(m.elements[h], c);
    }, o);
  };
})(Pt || (Pt = {}));
var Nee = /* @__PURE__ */ new Set();
function Ed(e, t) {
  var r = XJ[e];
  if (r !== void 0) {
    var n = r[t];
    if (n !== void 0) return n;
  }
  return Nee;
}
var Q9 = D.zero();
function jF(e, t) {
  for (var r = e.conformation.position, n = new Float32Array(3 * t.length), a = e.elements, i = 0, o = t.length; i < o; ++i) r(a[t[i]], Q9), D.toArray(Q9, n, 3 * i);
  return n;
}
var Js, cn, ry = function() {
  function e(t, r) {
    this.unit = r, this.all = t;
  }
  return Object.defineProperty(e.prototype, "index", { get: function() {
    return this._index || (this._index = function(t, r) {
      for (var n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = 0, o = t.length; i < o; i++) for (var s = 0, u = (m = t[i]).length; s < u; s++) {
        var c = m[s];
        n.has(c) ? n.get(c).push(i) : n.set(c, [i]);
      }
      for (var l = 0, d = r.length; l < d; l++) for (s = 0, u = (m = t[i = r[l]]).length; s < u; s++) c = m[s], a.has(c) ? a.get(c).push(i) : a.set(c, [i]);
      var f = new Ho.UniqueEdgeBuilder(t.length);
      for (i = 0, o = t.length; i < o; i++) {
        var m;
        for (s = 0, u = (m = t[i]).length; s < u; s++) {
          c = m[s];
          var h = n.get(c);
          if (h.length !== 1) for (var p = 0, g = h.length; p < g; p++) {
            var v = h[p];
            i >= v || f.addEdge(i, v);
          }
        }
      }
      var y = Ho.connectedComponents(f.getGraph()), _ = y.componentIndex, S = [];
      for (s = 0; s < y.componentCount; s++) S[s] = [];
      for (i = 0, o = t.length; i < o; i++) S[_[i]].push(i);
      return { elementRingIndices: n, elementAromaticRingIndices: a, ringComponentIndex: _, ringComponents: S };
    }(this.all, this.aromaticRings)), this._index;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "byFingerprint", { get: function() {
    return this._byFingerprint || (this._byFingerprint = function(t, r) {
      for (var n = /* @__PURE__ */ new Map(), a = 0, i = 0, o = r.length; i < o; i++) {
        var s = r[i], u = Js.fingerprint(t, s);
        n.has(u) ? n.get(u).push(a) : n.set(u, [a]), a++;
      }
      return n;
    }(this.unit, this.all)), this._byFingerprint;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "elementRingIndices", { get: function() {
    return this.index.elementRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "elementAromaticRingIndices", { get: function() {
    return this.index.elementAromaticRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ringComponentIndex", { get: function() {
    return this.index.ringComponentIndex;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ringComponents", { get: function() {
    return this.index.ringComponents;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "aromaticRings", { get: function() {
    return this._aromaticRings || (this._aromaticRings = function(t, r) {
      for (var n = [], a = 0, i = r.length; a < i; ++a) Js.isAromatic(t, r[a]) && n.push(a);
      return n;
    }(this.unit, this.all)), this._aromaticRings;
  }, enumerable: !1, configurable: !0 }), e;
}();
function Pee(e, t) {
  for (var r = e.elements, n = e.model.atomicHierarchy.residueAtomSegments.index, a = n[r[t[0]]], i = 1, o = t.length; i < o; i++) if (a !== n[r[t[i]]]) return -1;
  return a;
}
function Bee(e, t, r) {
  var n = e.byFingerprint.get(t);
  if (n) for (var a = 0, i = n.length; a < i; a++) {
    var o = n[a], s = Pee(e.unit, e.all[o]);
    s >= 0 && (r.has(s) ? r.get(s).push(o) : r.set(s, [o]));
  }
}
function Oee(e) {
  for (var t = [], r = e.elements, n = e.model.coarseHierarchy, a = n.spheres, i = n.gaussians, o = Ke.isSpheres(e) ? a.polymerRanges : i.polymerRanges, s = cn.transientSegments(o, r); s.hasNext; ) for (var u = s.move(), c = u.start, l = u.end, d = c; d < l; ++d) t.push(r[d]);
  return $e.ofSortedArray(t);
}
function Fee(e) {
  for (var t = [], r = e.elements, n = e.model.coarseHierarchy, a = n.spheres, i = n.gaussians, o = Ke.isSpheres(e) ? a.gapRanges : i.gapRanges, s = cn.transientSegments(o, r); s.hasNext; ) {
    var u = s.move(), c = u.start, l = u.end;
    t.push(r[c], r[l - 1]);
  }
  return $e.ofSortedArray(t);
}
(function(e) {
  function t(n) {
    return function(a) {
      for (var i = a.length, o = new Array(i), s = 0; s < i; s++) o[s] = a[i - s - 1];
      var u = W9(a), c = W9(o), l = !1;
      for (s = 0; s < i; s++) {
        var d = a[(s + u) % i], f = o[(s + c) % i];
        if (d !== f) {
          l = d < f;
          break;
        }
      }
      return l ? Z9(a, u) : Z9(o, c);
    }(n);
  }
  e.fingerprint = function(n, a) {
    for (var i = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, s = [], u = 0, c = a.length; u < c; u++) s[s.length] = o.value(i[a[u]]);
    return t(s);
  }, e.elementFingerprint = t;
  var r = /* @__PURE__ */ new Set(["B", "C", "N", "O", "SI", "P", "S", "GE", "AS", "SN", "SB", "BI"]);
  e.isAromatic = function(n, a) {
    var i = n.elements, o = n.bonds, s = o.b, u = o.offset, c = o.edgeProps.flags, l = n.model.atomicHierarchy.atoms, d = l.type_symbol;
    if (l.label_comp_id.value(n.elements[a[0]]) === "PRO") return !1;
    for (var f = 0, m = !1, h = 0, p = a.length; h < p; ++h) {
      var g = a[h];
      !m && r.has(d.value(i[g])) && (m = !0);
      for (var v = u[g], y = u[g + 1]; v < y; ++v) pr.is(16, c[v]) && $e.has(a, s[v]) && (f += 1);
    }
    if (f === 2 * a.length) return !0;
    if (!m || a.length < 5) return !1;
    var _ = Od.calculateMomentsAxes(jF(n, a));
    return D.magnitude(_.dirC) < 0.05;
  }, e.getAltId = function(n, a) {
    for (var i = n.model.atomicHierarchy.atoms.label_alt_id, o = n.elements, s = 0, u = a.length; s < u; ++s) {
      var c = o[a[s]], l = i.value(c);
      if (l) return l;
    }
    return "";
  };
})(Js || (Js = {})), function(e) {
  e.create = function(t) {
    var r = Mee(t);
    return new e(r, t);
  }, e.byFingerprintAndResidue = function(t, r) {
    for (var n = /* @__PURE__ */ new Map(), a = 0, i = r.length; a < i; a++)
      Bee(t, r[a], n);
    return n;
  };
}(ry || (ry = {})), function(e) {
  function t(l) {
    return l[l.length - 1];
  }
  function r(l) {
    return l.length / 2;
  }
  function n(l, d) {
    return l[2 * d];
  }
  function a(l, d) {
    return l[2 * d + 1] + 1;
  }
  function i(l, d) {
    return l[2 * d];
  }
  function o(l, d) {
    return l[2 * d + 1];
  }
  function s(l, d) {
    return u(l, d, 0);
  }
  function u(l, d, f) {
    if (i(l, f) > We.max(d) || t(l) < We.min(d)) return -1;
    for (var m = f, h = r(l); m < h; ++m) {
      var p = Fe.ofRange(i(l, m), o(l, m));
      if (We.areIntersecting(p, d)) return m;
    }
    return -1;
  }
  e.ofSortedRanges = function(l) {
    return $e.ofSortedArray(l);
  }, e.start = function(l) {
    return l[0];
  }, e.end = function(l) {
    return l[l.length - 1] + 1;
  }, e.min = function(l) {
    return l[0];
  }, e.max = t, e.size = function(l) {
    for (var d = 0, f = 0, m = l.length; f < m; f += 2) d += l[f + 1] - l[f] + 1;
    return d;
  }, e.count = r, e.startAt = n, e.endAt = a, e.minAt = i, e.maxAt = o, e.areEqual = function(l, d) {
    if (l.length !== d.length) return !1;
    for (var f = 0, m = l.length; f < m; ++f) if (l[f] !== d[f]) return !1;
    return !0;
  }, e.forEach = function(l, d) {
    for (var f = 0, m = 0, h = l.length; m < h; m += 2) for (var p = l[m], g = l[m + 1]; p <= g; ++p) d(p, f), ++f;
  }, e.has = function(l, d) {
    return s(l, d) !== -1;
  }, e.hasFrom = function(l, d, f) {
    return u(l, d, f) !== -1;
  }, e.firstIntersectionIndex = s, e.firstIntersectionIndexFrom = u, e.transientSegments = function(l, d) {
    return new c(l, d);
  };
  var c = function() {
    function l(d, f) {
      this.ranges = d, this.set = f, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = s(d, f), this.hasNext = this.curIndex !== -1;
    }
    return l.prototype.updateValue = function() {
      this.value.index = this.curIndex, this.value.start = We.findPredecessorIndex(this.set, n(this.ranges, this.curIndex)), this.value.end = We.findPredecessorIndex(this.set, a(this.ranges, this.curIndex));
    }, l.prototype.move = function() {
      return this.hasNext && (this.updateValue(), this.curIndex = u(this.ranges, this.set, this.curIndex + 1), this.hasNext = this.curIndex !== -1), this.value;
    }, l;
  }();
  e.Iterator = c;
}(cn || (cn = {}));
var $9 = D.zero();
function J9(e) {
  var t = function(r) {
    for (var n = r.conformation.invariantPosition, a = r.elements, i = new Float32Array(3 * a.length), o = 0, s = a.length; o < s; o++) n(a[o], $9), D.toArray($9, i, 3 * o);
    return i;
  }(e);
  return Od.ofPositions(t);
}
var iu = function() {
  function e(t) {
    this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new Lp(), this.dir = function(r) {
      var n;
      switch (r) {
        case "6":
          n = nt([], tg, !0);
          break;
        case "14":
          n = nt(nt([], tg, !0), F4, !0);
          break;
        case "26":
          n = nt(nt(nt([], tg, !0), F4, !0), eC, !0);
          break;
        case "98":
          n = nt(nt(nt(nt(nt(nt([], tg, !0), F4, !0), eC, !0), Ree, !0), Lee, !0), kee, !0);
      }
      return n.map(function(a) {
        var i = D.create(a[0], a[1], a[2]);
        return D.normalize(i, i);
      });
    }(t), this.reset();
  }
  return e.prototype.computeExtrema = function(t, r) {
    var n = D.dot(this.dir[t], r);
    n < this.minDist[t] && (this.minDist[t] = n, D.copy(this.extrema[2 * t], r)), n > this.maxDist[t] && (this.maxDist[t] = n, D.copy(this.extrema[2 * t + 1], r));
  }, e.prototype.computeSphereExtrema = function(t, r, n) {
    var a = D.dot(this.dir[t], r);
    a - n < this.minDist[t] && (this.minDist[t] = a - n, D.scaleAndSub(this.extrema[2 * t], r, this.dir[t], n)), a + n > this.maxDist[t] && (this.maxDist[t] = a + n, D.scaleAndAdd(this.extrema[2 * t + 1], r, this.dir[t], n));
  }, e.prototype.includeSphere = function(t) {
    if (Ve.hasExtrema(t) && t.extrema.length > 1) for (var r = 0, n = t.extrema; r < n.length; r++) {
      var a = n[r];
      this.includePosition(a);
    }
    else this.includePositionRadius(t.center, t.radius);
  }, e.prototype.includePosition = function(t) {
    for (var r = 0, n = this.dir.length; r < n; ++r) this.computeExtrema(r, t);
  }, e.prototype.includePositionRadius = function(t, r) {
    for (var n = 0, a = this.dir.length; n < a; ++n) this.computeSphereExtrema(n, t, r);
  }, e.prototype.finishedIncludeStep = function() {
    for (var t = 0; t < this.extrema.length; t++) this.centroidHelper.includeStep(this.extrema[t]);
    this.centroidHelper.finishedIncludeStep();
  }, e.prototype.radiusSphere = function(t) {
    if (Ve.hasExtrema(t) && t.extrema.length > 1) for (var r = 0, n = t.extrema; r < n.length; r++) {
      var a = n[r];
      this.radiusPosition(a);
    }
    else this.radiusPositionRadius(t.center, t.radius);
  }, e.prototype.radiusPosition = function(t) {
    this.centroidHelper.radiusStep(t);
  }, e.prototype.radiusPositionRadius = function(t, r) {
    this.centroidHelper.radiusSphereStep(t, r);
  }, e.prototype.getSphere = function(t) {
    return Ve.setExtrema(this.centroidHelper.getSphere(t), nt([], this.extrema, !0));
  }, e.prototype.getBox = function(t) {
    return on.fromVec3Array(t || on(), this.extrema);
  }, e.prototype.reset = function() {
    for (var t = 0, r = this.dir.length; t < r; ++t) this.minDist[t] = 1 / 0, this.maxDist[t] = -1 / 0, this.extrema[2 * t] = D(), this.extrema[2 * t + 1] = D();
    this.centroidHelper.reset();
  }, e;
}(), tg = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], F4 = [[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]], eC = [[1, 1, 0], [1, -1, 0], [1, 0, 1], [1, 0, -1], [0, 1, 1], [0, 1, -1]], Ree = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [2, 0, 1], [1, 2, 0], [2, 1, 0], [0, 1, -2], [0, 2, -1], [1, 0, -2], [2, 0, -1], [1, -2, 0], [2, -1, 0]], Lee = [[1, 1, 2], [2, 1, 1], [1, 2, 1], [1, -1, 2], [1, 1, -2], [1, -1, -2], [2, -1, 1], [2, 1, -1], [2, -1, -1], [1, -2, 1], [1, 2, -1], [1, -2, -1]], kee = [[2, 2, 1], [1, 2, 2], [2, 1, 2], [2, -2, 1], [2, 2, -1], [2, -2, -1], [1, -2, 2], [1, 2, -2], [1, -2, -2], [2, -1, 2], [2, 1, -2], [2, -1, -2]], tC = D.set, zee = new iu("14"), Uee = new iu("98"), rg = D();
function kp(e) {
  var t = e.x, r = e.y, n = e.z, a = e.radius, i = e.indices, o = We.size(i);
  if (o > 25e4) {
    var s = on.computeBounding(e);
    return { box: s, sphere: Ve.fromBox3D(Ve(), s) };
  }
  var u = function(m) {
    return m > 1e4 ? zee : Uee;
  }(o);
  u.reset();
  for (var c = 0; c < o; c++) {
    var l = We.getAt(i, c);
    tC(rg, t[l], r[l], n[l]), u.includePositionRadius(rg, a && a[l] || 0);
  }
  for (u.finishedIncludeStep(), c = 0; c < o; c++)
    l = We.getAt(i, c), tC(rg, t[l], r[l], n[l]), u.radiusPositionRadius(rg, a && a[l] || 0);
  var d = u.getSphere();
  if (!a && Ve.hasExtrema(d) && o <= d.extrema.length) {
    var f = [];
    for (c = 0; c < o; c++)
      l = We.getAt(i, c), f.push(D.create(t[l], r[l], n[l]));
    Ve.setExtrema(d, f);
  }
  return { box: u.getBox(), sphere: d };
}
var ny, pi, Ke, ay, Gee = function() {
  function e() {
    this.data = /* @__PURE__ */ new Map();
  }
  return e.prototype.get = function(t) {
    var r = $e.hashCode(t);
    if (this.data.has(r)) for (var n = 0, a = this.data.get(r); n < a.length; n++) {
      var i = a[n], o = i[0], s = i[1];
      if ($e.areEqual(t, o)) return s;
    }
  }, e.prototype.set = function(t, r) {
    var n = $e.hashCode(t);
    if (this.data.has(n)) {
      for (var a = this.data.get(n), i = 0, o = a; i < o.length; i++) {
        var s = o[i];
        if ($e.areEqual(t, s[0])) return void (s[1] = r);
      }
      a.push([t, r]);
    } else this.data.set(n, [[t, r]]);
  }, e.get = function(t) {
    return t._dynamicPropertyData.ElementSetIntraBondCache || (t._dynamicPropertyData.ElementSetIntraBondCache = new e()), t._dynamicPropertyData.ElementSetIntraBondCache;
  }, e;
}(), v6 = function() {
  function e(t, r, n) {
    this.operatorsProvider = n, this.id = t, this.details = r;
  }
  return Object.defineProperty(e.prototype, "operatorGroups", { get: function() {
    return this._operators || (this._operators = this.operatorsProvider()), this._operators;
  }, enumerable: !1, configurable: !0 }), e;
}();
function Vee(e, t, r) {
  if (!e._rowCount) return [];
  for (var n = function(o) {
    for (var s = o.id, u = o.matrix, c = o.vector, l = o._schema, d = /* @__PURE__ */ new Map(), f = 0, m = o._rowCount; f < m; f++) {
      var h = Wn.toMat4(Ee(), l.matrix.space, u.value(f)), p = Wn.toVec3(D(), l.vector.space, c.value(f));
      Ee.setTranslation(h, p), Ee.setValue(h, 3, 3, 1), d.set(s.value(f), h);
    }
    return d;
  }(r), a = [], i = 0; i < e._rowCount; i++) a[a.length] = qee(e, t, i, n);
  return a;
}
function qee(e, t, r, n) {
  for (var a = e.id.value(r), i = e.details.value(r), o = [], s = t.assembly_id, u = t.oper_expression, c = t.asym_id_list, l = 0, d = t._rowCount; l < d; l++) s.value(l) === a && (o[o.length] = { assemblyId: a, expression: u.value(l), asymIds: c.value(l) });
  return v6.create(a, i, /* @__PURE__ */ function(f, m) {
    return function() {
      for (var h = [], p = 0, g = 0; g < f.length; g++) {
        var v = f[g], y = Hee(Xee(v.expression)), _ = Kee(m, y, p, v.assemblyId), S = Pn.generators.atoms({ chainTest: Pn.pred.and(Pn.pred.eq(function(b) {
          return at.unit.operator_name(b.element);
        }, Mn.DefaultName), Pn.pred.inSet(function(b) {
          return at.chain.label_asym_id(b.element);
        }, v.asymIds)) });
        h[h.length] = { selector: S, operators: _ }, p += _.length;
      }
      return h;
    };
  }(o, n));
}
function Hee(e) {
  for (var t = [], r = [], n = 0; n < e.length; n++) r[n] = "";
  return YF(e, t, e.length - 1, r), t;
}
function YF(e, t, r, n) {
  if (r < 0) t[t.length] = n.slice(0);
  else for (var a = e[r], i = a.length, o = 0; o < i; o++) n[r] = a[o], YF(e, t, r - 1, n);
}
function Kee(e, t, r, n) {
  for (var a = [], i = r, o = 0, s = t; o < s.length; o++) {
    for (var u = s[o], c = Ee.identity(), l = 0; l < u.length; l++) Ee.mul(c, c, e.get(u[l]));
    i++, a[a.length] = Mn.create("ASM_".concat(i), c, { assembly: { id: n, operId: i, operList: u } });
  }
  return a;
}
function Xee(e) {
  for (var t, r = /\(?([^\(\)]+)\)?]*/g, n = [], a = []; t = r.exec(e); ) n[n.length] = t[1];
  return n.forEach(function(i) {
    var o = [];
    i.split(",").forEach(function(s) {
      var u = s.indexOf("-");
      if (u > 0) for (var c = parseInt(s.substring(0, u)), l = parseInt(s.substr(u + 1)), d = c; d <= l; d++) o[o.length] = d.toString();
      else o[o.length] = s.trim();
    }), a[a.length] = o;
  }), a;
}
function jee(e) {
  if (e._rowCount !== 0) {
    for (var t = e.id, r = e.matrix, n = e.vector, a = ur.struct_ncs_oper.matrix.space, i = ur.struct_ncs_oper.vector.space, o = [], s = 0; s < e._rowCount; s++) {
      var u = Wn.toMat3(ka(), a, r.value(s)), c = Wn.toVec3(D(), i, n.value(s));
      if (Mn.checkIfRotationAndTranslation(u, c) && (e.code.value(s) !== "given" || ka.isIdentity(u) || D.isZero(c))) {
        var l = t.value(s);
        o[o.length] = Mn.ofRotationAndOffset("ncs_".concat(l), u, c, l);
      }
    }
    return o;
  }
}
function Yee(e) {
  var t = e.bonds, r = t.b, n = t.edgeProps, a = t.offset;
  n.order;
  for (var i = n.flags, o = e.rings.elementAromaticRingIndices, s = [], u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = function(y, _, S) {
    var b = s.length;
    s.push($e.ofUnsortedArray([y, _, S])), u.set(G2(y, _), S), c.has(y) ? c.get(y).push(b) : c.set(y, [b]);
  }, d = 0; d < e.elements.length; d++)
    if (!o.has(d) && !(a[d + 1] - a[d] + 1 < 2)) {
      for (var f = [], m = a[d], h = a[d + 1]; m < h; m++) {
        var p = i[m];
        pr.is(p, 16) && f.push(r[m]);
      }
      if (f.length >= 2) {
        l(d, f[0], f[1]);
        for (var g = 1, v = f.length; g < v; g++) l(d, f[g], f[0]);
      }
    }
  return { getThirdElement: function(y, _) {
    return u.get(G2(y, _));
  }, getTripletIndices: function(y) {
    return c.get(y);
  }, triplets: s };
}
function WF() {
  return { result: ay.create(), closeUnitsResult: Gd.create(), unitGroupResult: Gd.create() };
}
(function(e) {
  e.create = function(t, r, n) {
    return new e(t, r, n);
  };
})(v6 || (v6 = {})), function(e) {
  e.Default = { assemblies: [], spacegroup: Fo.ZeroP1, isNonStandardCrystalFrame: !1 }, e.findAssembly = function(t, r) {
    var n = r.toLocaleLowerCase(), a = pi.Provider.get(t);
    return a ? function(i, o) {
      for (var s = 0, u = i.length; s < u; s++) if (o(i[s])) return i[s];
    }(a.assemblies, function(i) {
      return i.id.toLowerCase() === n;
    }) : void 0;
  }, e.getUnitcellLabel = function(t) {
    var r = t.spacegroup, n = r.cell, a = r.name, i = r.num, o = n.size, s = n.anglesInRadians, u = o[0].toFixed(2), c = o[1].toFixed(2), l = o[2].toFixed(2), d = Bi(s[0]).toFixed(2), f = Bi(s[1]).toFixed(2), m = Bi(s[2]).toFixed(2), h = [];
    return h.push("Unit Cell <b>".concat(a, "</b> #").concat(i)), h.push("".concat(u, "×").concat(c, "×").concat(l, " Å")), h.push("α=".concat(d, "° β=").concat(f, "° γ=").concat(m, "°")), h.join(" | ");
  };
}(ny || (ny = {})), function(e) {
  e.Descriptor = { name: "model_symmetry" }, e.Provider = ic.create(e.Descriptor), e.fromData = function(t) {
    var r = Vee(t.pdbx_struct_assembly, t.pdbx_struct_assembly_gen, t.pdbx_struct_oper_list), n = function(a, i) {
      if (a._rowCount === 0 || i._rowCount === 0) return Fo.ZeroP1;
      var o = i.length_a.value(0), s = i.length_b.value(0), u = i.length_c.value(0);
      if (o === 0 || s === 0 || u === 0) return Fo.ZeroP1;
      var c = i.angle_alpha.value(0), l = i.angle_beta.value(0), d = i.angle_gamma.value(0);
      if (c === 0 || l === 0 || d === 0) return Fo.ZeroP1;
      var f = function(h) {
        var p = h.Int_Tables_number.value(0), g = h["space_group_name_H-M"].value(0);
        return h.Int_Tables_number.isDefined ? h["space_group_name_H-M"].isDefined ? g : p : g;
      }(a), m = tu.create(f, D.create(o, s, u), D.scale(D(), D.create(c, l, d), Math.PI / 180));
      return Fo.create(m);
    }(t.symmetry, t.cell);
    return { assemblies: r, spacegroup: n, isNonStandardCrystalFrame: (t.atom_sites._rowCount, !1), ncsOperators: jee(t.struct_ncs_oper) };
  }, e.fromCell = function(t, r) {
    var n = tu.create("P 1", t, r);
    return { assemblies: [], spacegroup: Fo.create(n), isNonStandardCrystalFrame: !1 };
  };
}(pi || (pi = {})), function(e) {
  function t(v) {
    for (var y = [], _ = 0, S = v.length; _ < S; _++) y.push(v[_].id);
    return Zi(y);
  }
  function r(v) {
    var y = {};
    return { elements: v[0].elements, units: v, get unitIndexMap() {
      return y.unitIndexMap || (y.unitIndexMap = function(_) {
        for (var S = uc.Mutable(), b = 0, x = _.length; b < x; b++) S.set(_[b].id, b);
        return S;
      }(v)), y.unitIndexMap;
    }, hashCode: n(v[0]), transformHash: t(v) };
  }
  function n(v) {
    return d1(v.invariantId, $e.hashCode(v.elements));
  }
  var a;
  e.isAtomic = function(v) {
    return v.kind === 0;
  }, e.isCoarse = function(v) {
    return v.kind === 1 || v.kind === 2;
  }, e.isSpheres = function(v) {
    return v.kind === 1;
  }, e.isGaussians = function(v) {
    return v.kind === 2;
  }, e.create = function(v, y, _, S, b, x, A, w, C) {
    switch (b) {
      case 0:
        return new i(v, y, _, S, x, w, Mn.createMapping(A, x.atomicConformation, void 0), C ?? o());
      case 1:
        return f(v, y, _, S, x, 1, w, Mn.createMapping(A, x.coarseConformation.spheres, function(M) {
          var T = M.coarseConformation.spheres.radius;
          return function(N) {
            return T[N];
          };
        }(x)), C ?? c());
      case 2:
        return f(v, y, _, S, x, 2, w, Mn.createMapping(A, x.coarseConformation.gaussians, function(M) {
          return 0;
        }), C ?? c());
    }
  }, e.SymmetryGroup = r, function(v) {
    v.areInvariantElementsEqual = function(y, _) {
      return y.hashCode === _.hashCode && $e.areEqual(y.elements, _.elements);
    }, v.getUnitSymmetryGroupsIndexMap = function(y) {
      for (var _ = uc.Mutable(), S = 0, b = y.length; S < b; ++S) for (var x = y[S], A = 0, w = x.units.length; A < w; ++A) _.set(x.units[A].id, S);
      return _;
    };
  }(r = e.SymmetryGroup || (e.SymmetryGroup = {})), e.conformationId = function(v) {
    return e.isAtomic(v) ? v.model.atomicConformation.id : v.model.coarseConformation.id;
  }, e.hashUnit = n, (a = e.Traits || (e.Traits = {})).is = Ti.has, a.create = Ti.create;
  var i = function() {
    function v(y, _, S, b, x, A, w, C) {
      this.kind = 0, this.objectPrimitive = "atomistic", this.id = y, this.invariantId = _, this.chainGroupId = S, this.traits = b, this.model = x, this.elements = A, this.conformation = w, this.residueIndex = x.atomicHierarchy.residueAtomSegments.index, this.chainIndex = x.atomicHierarchy.chainAtomSegments.index, this.props = C;
    }
    return v.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : new v(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, y, this.conformation, o());
    }, v.prototype.applyOperator = function(y, _, S) {
      S === void 0 && (S = !1);
      var b = S ? _ : Mn.compose(this.conformation.operator, _);
      return new v(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, Mn.createMapping(b, this.model.atomicConformation, this.conformation.r), this.props);
    }, v.prototype.remapModel = function(y, _, S) {
      var b, x;
      S || (S = k(k({}, this.props), { bonds: _ && !(!((x = (b = this.props.bonds) === null || b === void 0 ? void 0 : b.props) === null || x === void 0) && x.canRemap) ? void 0 : m(this, this.props.bonds, y, _) }), e.isSameConformation(this, y) || (S.boundary = void 0, S.lookup3d = void 0, S.principalAxes = void 0));
      var A = this.conformation.operator, w = pi.Provider.get(y);
      if (A.spgrOp !== -1 && w && w !== pi.Provider.get(this.model)) {
        var C = A.hkl, M = C[0], T = C[1], N = C[2], I = w.spacegroup.cell.toFractional, P = D.transformMat4(D(), yn.getCenter(y), I);
        A = Fo.getSymmetryOperatorRef(w.spacegroup, A.spgrOp, M, T, N, P);
      }
      var O = this.model.atomicConformation !== y.atomicConformation || A !== this.conformation.operator ? Mn.createMapping(A, y.atomicConformation) : this.conformation;
      return new v(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.elements, O, S);
    }, Object.defineProperty(v.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.model.atomicConformation, _ = y.x, S = y.y, b = y.z;
      return this.props.boundary = kp({ x: _, y: S, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.model.atomicConformation, _ = y.x, S = y.y, b = y.z;
      return this.props.lookup3d = Jf({ x: _, y: S, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = J9(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "bonds", { get: function() {
      if (this.props.bonds) return this.props.bonds;
      var y = Gee.get(this.model), _ = y.get(this.elements);
      return _ || (_ = Aee(this), y.set(this.elements, _)), this.props.bonds = _, this.props.bonds;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "rings", { get: function() {
      return this.props.rings || (this.props.rings = ry.create(this)), this.props.rings;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "resonance", { get: function() {
      return this.props.resonance || (this.props.resonance = function(y) {
        return { delocalizedTriplets: Yee(y) };
      }(this)), this.props.resonance;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = function(y) {
        for (var _ = [], S = y.elements, b = y.model, x = y.model.atomicHierarchy.residueAtomSegments, A = b.atomicHierarchy.derived.residue.traceElementIndex, w = cn.transientSegments(y.model.atomicRanges.polymerRanges, S), C = nr.transientSegments(x, S); w.hasNext; ) {
          var M = w.move();
          for (C.setSegment(M); C.hasNext; ) {
            var T = C.move(), N = T.start, I = T.end, P = T.index;
            if (We.areIntersecting(Fe.ofRange(S[N], S[I - 1]), S)) {
              var O = A[P];
              _.push(O === -1 ? x.offsets[P] : O);
            }
          }
        }
        return $e.ofSortedArray(_);
      }(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = function(y) {
        for (var _ = [], S = y.elements, b = y.model, x = y.residueIndex, A = y.model.atomicHierarchy.residueAtomSegments, w = b.atomicHierarchy.derived.residue.traceElementIndex, C = cn.transientSegments(y.model.atomicRanges.gapRanges, y.elements); C.hasNext; ) {
          var M = C.move(), T = x[S[M.start]], N = x[S[M.end - 1]], I = w[T], P = w[N];
          _.push(I === -1 ? A.offsets[T] : I), _.push(P === -1 ? A.offsets[N] : P);
        }
        return $e.ofSortedArray(_);
      }(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "nucleotideElements", { get: function() {
      return this.props.nucleotideElements || (this.props.nucleotideElements = function(y) {
        for (var _ = [], S = y.elements, b = y.model, x = b.atomicHierarchy, A = x.chainAtomSegments, w = x.residueAtomSegments, C = b.atomicHierarchy.derived.residue, M = C.moleculeType, T = C.traceElementIndex, N = nr.transientSegments(A, S), I = nr.transientSegments(w, S); N.hasNext; ) for (I.setSegment(N.move()); I.hasNext; ) {
          var P = I.move().index;
          if (p1(M[P])) {
            var O = T[P];
            _.push(O === -1 ? w.offsets[P] : O);
          }
        }
        return $e.ofSortedArray(_);
      }(this)), this.props.nucleotideElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "proteinElements", { get: function() {
      return this.props.proteinElements || (this.props.proteinElements = function(y) {
        for (var _ = [], S = y.elements, b = y.model, x = b.atomicHierarchy, A = x.chainAtomSegments, w = x.residueAtomSegments, C = b.atomicHierarchy.derived.residue, M = C.moleculeType, T = C.traceElementIndex, N = nr.transientSegments(A, S), I = nr.transientSegments(w, S); N.hasNext; ) for (I.setSegment(N.move()); I.hasNext; ) {
          var P = I.move().index;
          if (kF(M[P])) {
            var O = T[P];
            _.push(O === -1 ? w.offsets[P] : O);
          }
        }
        return $e.ofSortedArray(_);
      }(this)), this.props.proteinElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "residueCount", { get: function() {
      if (this.props.residueCount !== void 0) return this.props.residueCount;
      for (var y = 0, _ = nr.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements); _.hasNext; ) _.move(), y += 1;
      return this.props.residueCount = y, this.props.residueCount;
    }, enumerable: !1, configurable: !0 }), v.prototype.getResidueIndex = function(y) {
      return this.residueIndex[this.elements[y]];
    }, v;
  }();
  function o() {
    return {};
  }
  e.Atomic = i;
  var s = function() {
    function v(y, _, S, b, x, A, w, C, M) {
      this.kind = A, this.objectPrimitive = A === 1 ? "sphere" : "gaussian", this.id = y, this.invariantId = _, this.chainGroupId = S, this.traits = b, this.model = x, this.elements = w, this.conformation = C, this.coarseElements = A === 1 ? x.coarseHierarchy.spheres : x.coarseHierarchy.gaussians, this.coarseConformation = A === 1 ? x.coarseConformation.spheres : x.coarseConformation.gaussians, this.props = M;
    }
    return v.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : f(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, y, this.conformation, c());
    }, v.prototype.applyOperator = function(y, _, S) {
      S === void 0 && (S = !1);
      var b = S ? _ : Mn.compose(this.conformation.operator, _);
      return f(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, Mn.createMapping(b, this.getCoarseConformation(), this.conformation.r), this.props);
    }, v.prototype.remapModel = function(y, _, S) {
      var b = this.getCoarseConformation(), x = u(this.kind, y);
      S || (S = k({}, this.props), e.isSameConformation(this, y) || (S.boundary = void 0, S.lookup3d = void 0, S.principalAxes = void 0));
      var A = b !== x ? Mn.createMapping(this.conformation.operator, x) : this.conformation;
      return new v(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.kind, this.elements, A, S);
    }, Object.defineProperty(v.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.getCoarseConformation(), _ = y.x, S = y.y, b = y.z;
      return this.props.boundary = kp({ x: _, y: S, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.getCoarseConformation(), _ = y.x, S = y.y, b = y.z;
      return this.props.lookup3d = Jf({ x: _, y: S, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = J9(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = Oee(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = Fee(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), v.prototype.getCoarseConformation = function() {
      return u(this.kind, this.model);
    }, v;
  }();
  function u(v, y) {
    return v === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function c() {
    return {};
  }
  var l = function(v) {
    function y() {
      return v !== null && v.apply(this, arguments) || this;
    }
    return Ii(y, v), y;
  }(s);
  e.Spheres = l;
  var d = function(v) {
    function y() {
      return v !== null && v.apply(this, arguments) || this;
    }
    return Ii(y, v), y;
  }(s);
  function f(v, y, _, S, b, x, A, w, C) {
    return new s(v, y, _, S, b, x, A, w, C);
  }
  function m(v, y, _, S) {
    var b;
    if (y) {
      if (v.model.atomicConformation.id === _.atomicConformation.id) return y;
      var x = Ra.Provider.get(v.model);
      if (x) {
        var A = Ra.Provider.get(_);
        return A && x !== A ? void 0 : y;
      }
      return !((b = y.props) === null || b === void 0) && b.canRemap || !S || h(v, _) ? y : void 0;
    }
  }
  function h(v, y) {
    var _ = yn.CoordinatesHistory.get(yn.getRoot(y));
    if (_) return _.areEqual(v.elements, v.kind, y);
    for (var S = v.elements, b = v.conformation.coordinates, x = b.x, A = b.y, w = b.z, C = p(v.kind, y), M = C.x, T = C.y, N = C.z, I = 0, P = S.length; I < P; I++) {
      var O = S[I];
      if (x[O] !== M[O] || A[O] !== T[O] || w[O] !== N[O]) return !1;
    }
    return !0;
  }
  function p(v, y) {
    return v === 0 ? y.atomicConformation : v === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function g(v, y) {
    return v === 0 ? y.atomicHierarchy : v === 1 ? y.coarseHierarchy.spheres : y.coarseHierarchy.gaussians;
  }
  e.Gaussians = d, e.areSameChainOperatorGroup = function(v, y) {
    return v.chainGroupId === y.chainGroupId && v.conformation.operator.name === y.conformation.operator.name;
  }, e.areOperatorsEqual = function(v, y) {
    return Ee.areEqual(v.conformation.operator.matrix, y.conformation.operator.matrix, 1e-6);
  }, e.areConformationsEqual = function(v, y) {
    return !!$e.areEqual(v.elements, y.elements) && h(v, y.model);
  }, e.isSameConformation = h, e.getModelConformationOfKind = p, e.getConformation = function(v) {
    return p(v.kind, v.model);
  }, e.getModelHierarchyOfKind = g, e.getHierarchy = function(v) {
    return g(v.kind, v.model);
  };
}(Ke || (Ke = {})), function(e) {
  e.add = function(t, r, n, a) {
    t.indices[t.count] = n, t.units[t.count] = r, t.squaredDistances[t.count] = a, t.count++;
  }, e.create = function() {
    return { count: 0, indices: [], units: [], squaredDistances: [] };
  }, e.copy = function(t, r) {
    for (var n = 0; n < r.count; ++n) t.indices[n] = r.indices[n], t.units[n] = r.units[n], t.squaredDistances[n] = r.squaredDistances[n];
    return t.count = r.count, t;
  };
}(ay || (ay = {}));
var St, vo, Wee = function() {
  function e(t) {
    this.structure = t, this.pivot = D(), this.findContext = WF();
    for (var r = t.units, n = t.boundary, a = r.length, i = new Float32Array(a), o = new Float32Array(a), s = new Float32Array(a), u = new Float32Array(a), c = D(), l = 0; l < a; l++) {
      var d = r[l], f = d.boundary.sphere;
      D.transformMat4(c, f.center, d.conformation.operator.matrix), i[l] = c[0], o[l] = c[1], s[l] = c[2], u[l] = f.radius;
    }
    var m = { x: i, y: o, z: s, radius: u, indices: We.ofBounds(0, a) };
    this.unitLookup = Jf(m, n);
  }
  return e.prototype.findUnitIndices = function(t, r, n, a) {
    return this.unitLookup.find(t, r, n, a);
  }, e.prototype.find = function(t, r, n, a, i) {
    return this._find(t, r, n, a, i ?? this.findContext);
  }, e.prototype._find = function(t, r, n, a, i) {
    Gd.reset(i.result);
    var o = this.structure.units, s = this.unitLookup.find(t, r, n, a, i.closeUnitsResult);
    if (s.count === 0) return i.result;
    for (var u = 0, c = s.count; u < c; u++) {
      var l = o[s.indices[u]];
      D.set(this.pivot, t, r, n), l.conformation.operator.isIdentity || D.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      for (var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], a, i.unitGroupResult), f = 0, m = d.count; f < m; f++) ay.add(i.result, l, d.indices[f], d.squaredDistances[f]);
    }
    return i.result;
  }, e.prototype.findIntoBuilder = function(t, r, n, a, i) {
    var o = this.structure.units, s = this.unitLookup.find(t, r, n, a);
    if (s.count !== 0) for (var u = 0, c = s.count; u < c; u++) {
      var l = o[s.indices[u]];
      D.set(this.pivot, t, r, n), l.conformation.operator.isIdentity || D.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], a);
      if (d.count !== 0) {
        var f = l.elements;
        i.beginUnit(l.id);
        for (var m = 0, h = d.count; m < h; m++) i.addElement(f[d.indices[m]]);
        i.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderIf = function(t, r, n, a, i, o) {
    var s = this.structure.units, u = this.unitLookup.find(t, r, n, a);
    if (u.count !== 0) for (var c = lt.create(this.structure), l = 0, d = u.count; l < d; l++) {
      var f = s[u.indices[l]];
      D.set(this.pivot, t, r, n), f.conformation.operator.isIdentity || D.transformMat4(this.pivot, this.pivot, f.conformation.operator.inverse);
      var m = f.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], a);
      if (m.count !== 0) {
        var h = f.elements;
        c.unit = f, i.beginUnit(f.id);
        for (var p = 0, g = m.count; p < g; p++) c.element = h[m.indices[p]], o(c) && i.addElement(c.element);
        i.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderWithRadius = function(t, r, n, a, i, o, s, u) {
    var c = this.structure.units, l = this.unitLookup.find(t, r, n, o);
    if (l.count !== 0) for (var d = lt.create(this.structure), f = a + i + o, m = 0, h = l.count; m < h; m++) {
      var p = c[l.indices[m]];
      D.set(this.pivot, t, r, n), p.conformation.operator.isIdentity || D.transformMat4(this.pivot, this.pivot, p.conformation.operator.inverse);
      var g = p.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], f);
      if (g.count !== 0) {
        var v = p.elements;
        d.unit = p, u.beginUnit(p.id);
        for (var y = 0, _ = g.count; y < _; y++) {
          d.element = v[g.indices[y]];
          var S = s(d);
          Math.sqrt(g.squaredDistances[y]) - a - S > o || u.addElement(v[g.indices[y]]);
        }
        u.commitUnit();
      }
    }
  }, e.prototype.check = function(t, r, n, a) {
    var i = this.structure.units, o = this.unitLookup.find(t, r, n, a);
    if (o.count === 0) return !1;
    for (var s = 0, u = o.count; s < u; s++) {
      var c = i[o.indices[s]];
      if (D.set(this.pivot, t, r, n), c.conformation.operator.isIdentity || D.transformMat4(this.pivot, this.pivot, c.conformation.operator.inverse), c.lookup3d.check(this.pivot[0], this.pivot[1], this.pivot[2], a)) return !0;
    }
    return !1;
  }, Object.defineProperty(e.prototype, "boundary", { get: function() {
    return this.structure.boundary;
  }, enumerable: !1, configurable: !0 }), e;
}();
function iy(e, t) {
  if (t.length === 0) return st.Empty;
  if (t.length === 1) return t[0];
  for (var r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), a = 0, i = t; a < i.length; a++) for (var o = i[a].units, s = 0, u = o.length; s < u; s++) {
    var c = o[s];
    if (r.has(c.id)) {
      if (n.has(c.id)) continue;
      var l = $e.union(r.get(c.id), c.elements);
      r.set(c.id, l), l.length === e.unitMap.get(c.id).elements.length && n.add(c.id);
    } else r.set(c.id, c.elements), c.elements.length === e.unitMap.get(c.id).elements.length && n.add(c.id);
  }
  var d = e.subsetBuilder(!0);
  return r.forEach(Zee, d), d.getStructure();
}
function Zee(e, t) {
  this.setUnit(t, e);
}
function E8(e, t) {
  if (e === t) return !0;
  var r, n;
  e.units.length < t.units.length ? (r = e, n = t) : (r = t, n = e);
  for (var a = r.units, i = n.unitMap, o = 0, s = a.length; o < s; o++) {
    var u = a[o];
    if (i.has(u.id)) {
      var c = i.get(u.id);
      if ($e.areIntersecting(u.elements, c.elements)) return !0;
    }
  }
  return !1;
}
function ZF(e, t) {
  if (e === t) return st.Empty;
  if (!E8(e, t)) return e;
  for (var r = e.units, n = t.unitMap, a = [], i = 0, o = r.length; i < o; i++) {
    var s = r[i];
    if (n.has(s.id)) {
      var u = n.get(s.id), c = $e.subtract(s.elements, u.elements);
      c.length > 0 && (a[a.length] = s.getChild(c));
    } else a[a.length] = s;
  }
  return st.create(a, { parent: e.parent || t.parent });
}
function g6(e) {
  return pr.isCovalent(e.atomicBond.type);
}
function QF(e, t, r) {
  return { groupedUnits: e, ranges: t, set: r };
}
function $F(e) {
  return function(t) {
    var r = { hash: t.inputStructure.hashCode, elements: e };
    return St.Sequence(t.inputStructure, [vo.toStructure(r, t.inputStructure)]);
  };
}
(function(e) {
  function t(l, d) {
    return { kind: "singletons", source: l, structure: d };
  }
  function r(l, d) {
    return { kind: "sequence", source: l, structures: d };
  }
  function n(l) {
    return t(l, st.Empty);
  }
  function a(l) {
    return l.kind === "singletons";
  }
  function i(l) {
    return a(l) ? l.structure.units.length === 0 : l.structures.length === 0;
  }
  function o(l) {
    return i(l) ? st.Empty : a(l) ? l.structure : iy(l.source, l.structures);
  }
  function s(l, d, f) {
    return d.length === 0 ? n(l) : f ? t(l, iy(l, d)) : r(l, d);
  }
  e.Singletons = t, e.Sequence = r, e.Empty = n, e.isSingleton = a, e.isEmpty = i, e.structureCount = function(l) {
    return a(l) ? l.structure.elementCount : l.structures.length;
  }, e.unionStructure = o, e.toLociWithCurrentUnits = function(l) {
    for (var d = [], f = l.source.unitMap, m = 0, h = o(l).units; m < h.length; m++) {
      var p = h[m];
      p === f.get(p.id) ? d[d.length] = { unit: p, indices: We.ofBounds(0, p.elements.length) } : d[d.length] = { unit: p, indices: We.ofSortedArray($e.indicesOf(f.get(p.id).elements, p.elements)) };
    }
    return et(l.source, d);
  }, e.toLociWithSourceUnits = function(l) {
    for (var d = [], f = l.source.unitMap, m = 0, h = o(l).units; m < h.length; m++) {
      var p = h[m];
      if (f.has(p.id)) {
        var g = f.get(p.id);
        d[d.length] = g === p ? { unit: g, indices: We.ofBounds(0, g.elements.length) } : { unit: g, indices: We.ofSortedArray($e.indicesOf(g.elements, p.elements)) };
      }
    }
    return et(l.source, d);
  };
  var u = function() {
    function l(d) {
      this.source = d, this.structures = [], this.allSingletons = !0;
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return s(this.source, this.structures, this.allSingletons);
    }, l;
  }(), c = function() {
    function l(d) {
      this.structure = d, this.structures = [], this.allSingletons = !0, this.uniqueSets = b8(st.hashCode, st.areUnitIdsAndIndicesEqual);
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && this.uniqueSets.add(d) && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return s(this.structure, this.structures, this.allSingletons);
    }, l;
  }();
  e.LinearBuilder = function(l) {
    return new u(l);
  }, e.UniqueBuilder = function(l) {
    return new c(l);
  }, e.forEach = function(l, d) {
    var f = 0;
    if (e.isSingleton(l)) for (var m = 0, h = l.structure.units; m < h.length; m++) for (var p = h[m], g = p.elements, v = 0, y = g.length; v < y; v++)
      d(st.create([p.getChild($e.ofSingleton(g[v]))], { parent: l.source }), f++);
    else for (var _ = 0, S = l.structures; _ < S.length; _++)
      d(S[_], f++);
  }, e.withInputStructure = function(l, d) {
    return a(l) ? t(d, l.structure) : r(d, l.structures);
  };
})(St || (St = {})), function(e) {
  function t(a) {
    for (var i = [], o = 0, s = a.elements; o < s.length; o++) {
      var u = (_ = s[o]).unit, c = _.indices;
      if (We.size(c) !== 0) {
        var l = [], d = [];
        if (We.isInterval(c)) We.size(c) === 1 ? d.push(Fe.min(c)) : l.push(Fe.min(c), Fe.max(c));
        else for (var f = 0, m = c.length; f < m; ) {
          var h = f;
          for (f++; f < m && c[f - 1] + 1 === c[f]; ) f++;
          var p = f;
          if (p - h > 2) l.push(c[h], c[p - 1]);
          else for (var g = h; g < p; g++) d[d.length] = c[g];
        }
        i.push({ unit: u, set: $e.ofSortedArray(d), ranges: cn.ofSortedRanges(l) });
      }
    }
    for (var v = /* @__PURE__ */ new Map(), y = (f = 0, i.length); f < y; ++f) {
      var _, S, b = d1(Zi((_ = i[f]).ranges), Zi(_.set));
      v.has(b) ? (S = v.get(b).groupedUnits).has(_.unit.invariantId) ? S.get(_.unit.invariantId).push(_.unit.id) : S.set(_.unit.invariantId, [_.unit.id]) : ((S = /* @__PURE__ */ new Map()).set(_.unit.invariantId, [_.unit.id]), v.set(b, { groupedUnits: S, set: _.set, ranges: _.ranges }));
    }
    var x = [];
    return v.forEach(function(A) {
      var w = [];
      A.groupedUnits.forEach(function(C) {
        return w.push($e.ofUnsortedArray(C));
      }), w.sort(function(C, M) {
        return C[0] - M[0];
      }), x.push({ groupedUnits: w, set: A.set, ranges: A.ranges });
    }), { hash: a.structure.hashCode, elements: x };
  }
  function r(a, i) {
    for (var o = [], s = 0, u = a.length; s < u; ++s) {
      var c = a[s];
      i.unitMap.has(c) && o.push(i.unitMap.get(c));
    }
    return o;
  }
  function n(a) {
    return zt.internal.generator.bundleElement({ groupedUnits: zt.core.type.list(a.groupedUnits.map(function(i) {
      return zt.core.type.list(i);
    })), ranges: zt.core.type.list(a.ranges), set: zt.core.type.list(a.set) });
  }
  e.Empty = { hash: -1, elements: [] }, e.fromSubStructure = function(a, i) {
    return t(St.toLociWithSourceUnits(St.Singletons(a, i)));
  }, e.fromSelection = function(a) {
    return t(St.toLociWithSourceUnits(a));
  }, e.fromLoci = t, e.toLoci = function(a, i) {
    a.hash !== -1 && (a.hash, i.hashCode);
    for (var o = [], s = 0, u = a.elements; s < u.length; s++) for (var c = u[s], l = function(m) {
      var h = r(m, i);
      if (h.length === 0) return "continue";
      var p = void 0;
      if (c.ranges.length === 0) p = c.set;
      else if (c.set.length === 0) if (c.ranges.length === 2) p = Fe.ofRange(c.ranges[0], c.ranges[1]);
      else {
        var g = new Int32Array(cn.size(c.ranges));
        cn.forEach(c.ranges, function(x, A) {
          return g[A] = x;
        }), p = $e.ofSortedArray(g);
      }
      else {
        var v = cn.size(c.ranges), y = new Int32Array(c.set.length + v);
        cn.forEach(c.ranges, function(x, A) {
          return y[A] = x;
        }), y.set(c.set, v), p = $e.ofUnsortedArray(y);
      }
      for (var _ = 0, S = h; _ < S.length; _++) {
        var b = S[_];
        o.push({ unit: b, indices: p });
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return et(i, o);
  }, e.toStructure = function(a, i) {
    a.hash !== -1 && (a.hash, i.hashCode);
    for (var o = [], s = 0, u = a.elements; s < u.length; s++) for (var c = u[s], l = function(m) {
      var h = r(m, i);
      if (h.length === 0) return "continue";
      var p = h[0].elements, g = cn.size(c.ranges), v = c.set.length, y = new Int32Array(v + g), _ = void 0;
      if (g === 0) {
        for (var S = 0, b = v; S < b; ++S) y[S] = p[c.set[S]];
        _ = $e.ofSortedArray(y);
      } else if (v === 0) cn.forEach(c.ranges, function(C, M) {
        return y[M] = p[C];
      }), _ = $e.ofSortedArray(y);
      else if ($e.min(c.set) > cn.max(c.ranges)) {
        for (cn.forEach(c.ranges, function(C, M) {
          return y[M] = p[C];
        }), S = 0, b = v; S < b; ++S) y[S + g] = p[c.set[S]];
        _ = $e.ofSortedArray(y);
      } else if (cn.min(c.ranges) > $e.max(c.set)) {
        for (S = 0, b = v; S < b; ++S) y[S] = p[c.set[S]];
        cn.forEach(c.ranges, function(C, M) {
          return y[M + v] = p[C];
        }), _ = $e.ofSortedArray(y);
      } else {
        for (cn.forEach(c.ranges, function(C, M) {
          return y[M] = p[C];
        }), S = 0, b = v; S < b; ++S) y[S + g] = p[c.set[S]];
        _ = $e.ofUnsortedArray(y);
      }
      for (var x = 0, A = h; x < A.length; x++) {
        var w = A[x];
        o.push(w.getChild(_));
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return st.create(o, { parent: i });
  }, e.toExpression = function(a) {
    return zt.internal.generator.bundle({ elements: zt.core.type.list(a.elements.map(n)) });
  }, e.areEqual = function(a, i) {
    if (a.elements.length !== i.elements.length) return !1;
    for (var o = 0, s = a.elements.length; o < s; ++o) {
      var u = a.elements[o], c = i.elements[o];
      if (u.groupedUnits.length !== c.groupedUnits.length) return !1;
      for (var l = 0, d = c.groupedUnits.length; l < d; ++l) if (!$e.areEqual(u.groupedUnits[l], c.groupedUnits[l])) return !1;
      if (!$e.areEqual(u.set, c.set) || !cn.areEqual(u.ranges, c.ranges)) return !1;
    }
    return !0;
  };
}(vo || (vo = {}));
var rC, Qee = Object.freeze({ __proto__: null, atomicHet: function() {
  return function(e) {
    for (var t = e.inputStructure, r = lt.create(t), n = [], a = 0, i = t.units; a < i.length; a++) {
      var o = i[a];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        if (r.element = s[0], at.entity.type(r) !== "water") {
          if (at.entity.type(r) === "polymer") {
            for (var u = nr.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
            if (c >= 8) continue;
          }
          n.push(o);
        }
      }
    }
    return St.Singletons(t, st.create(n, { parent: t }));
  };
}, atomicSequence: function() {
  return function(e) {
    for (var t = e.inputStructure, r = lt.create(t), n = [], a = 0, i = t.units; a < i.length; a++) {
      var o = i[a];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        if (r.element = s[0], at.entity.type(r) === "polymer") {
          for (var u = nr.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
          c < 8 || n.push(o);
        }
      }
    }
    return St.Singletons(t, st.create(n, { parent: t }));
  };
}, bundleElementImpl: QF, bundleGenerator: $F, defaultBondTest: g6, spheres: function() {
  return function(e) {
    for (var t = e.inputStructure, r = [], n = 0, a = t.units; n < a.length; n++) {
      var i = a[n];
      i.kind === 1 && r.push(i);
    }
    return St.Singletons(t, st.create(r, { parent: t }));
  };
}, water: function() {
  return function(e) {
    for (var t = e.inputStructure, r = lt.create(t), n = [], a = 0, i = t.units; a < i.length; a++) {
      var o = i[a];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        r.element = s[0], at.entity.type(r) === "water" && n.push(o);
      }
    }
    return St.Singletons(t, st.create(n, { parent: t }));
  };
} }), tm = function() {
  function e(t, r) {
    this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = ga(), this.element = lt.create(void 0), this.currentStructure = void 0, this.atomicBond = new nC(), this.currentSelection = void 0, this.inputStructure = t, this.timeoutMs = r && r.timeoutMs || 0, this.currentSelection = r && r.currentSelection;
  }
  return e.prototype.pushCurrentElement = function() {
    return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = lt.create(void 0), this.element;
  }, e.prototype.popCurrentElement = function() {
    this.element = this.currentElementStack.pop();
  }, e.prototype.pushCurrentBond = function() {
    return this.atomicBond && this.currentAtomicBondStack.push(this.atomicBond), this.atomicBond = new nC(), this.atomicBond;
  }, e.prototype.popCurrentBond = function() {
    this.currentAtomicBondStack.length > 0 ? this.atomicBond = this.currentAtomicBondStack.pop() : this.atomicBond = void 0;
  }, e.prototype.pushCurrentStructure = function() {
    this.currentStructure && this.currentStructureStack.push(this.currentStructure);
  }, e.prototype.popCurrentStructure = function() {
    this.currentStructureStack.length ? this.currentStructure = this.currentStructureStack.pop() : this.currentStructure = void 0;
  }, e.prototype.pushInputStructure = function(t) {
    this.inputStructureStack.push(this.inputStructure), this.inputStructure = t;
  }, e.prototype.popInputStructure = function() {
    if (this.inputStructureStack.length === 0) throw new Error("Must push before pop.");
    this.inputStructure = this.inputStructureStack.pop();
  }, e.prototype.throwIfTimedOut = function() {
    if (this.timeoutMs !== 0 && ga() - this.timeCreated > this.timeoutMs) throw new Error("The query took too long to execute (> ".concat(this.timeoutMs / 1e3, "s)."));
  }, e.prototype.tryGetCurrentSelection = function() {
    if (!this.currentSelection) throw new Error("The current selection is not assigned.");
    return this.currentSelection;
  }, e;
}(), nC = function() {
  function e() {
    this.a = lt.create(void 0), this.aIndex = 0, this.b = lt.create(void 0), this.bIndex = 0, this.type = 0, this.order = 0, this.testFn = g6;
  }
  return e.prototype.setStructure = function(t) {
    this.a.structure = t, this.b.structure = t;
  }, e.prototype.setTestFn = function(t) {
    this.testFn = t || g6;
  }, e.prototype.test = function(t, r) {
    return !!this.testFn(t) || !!r && (this.swap(), this.testFn(t));
  }, e.prototype.swap = function() {
    var t = this.aIndex;
    this.aIndex = this.bIndex, this.bIndex = t;
    var r = this.a.unit;
    this.a.unit = this.b.unit, this.b.unit = r;
    var n = this.a.element;
    this.a.element = this.b.element, this.b.element = n;
  }, Object.defineProperty(e.prototype, "length", { get: function() {
    return lt.distance(this.a, this.b);
  }, enumerable: !1, configurable: !0 }), e;
}();
(function(e) {
  e.run = function(t, r, n) {
    return t(new tm(r, n));
  };
})(rC || (rC = {}));
var R4 = function() {
  function e(t) {
    this.source = t, this.set = b8(st.hashCode, st.areUnitIdsAndIndicesEqual), this.structures = [], this.allSingletons = !0;
  }
  return e.prototype.add = function(t) {
    t.elementCount && (t.elementCount !== 1 && (this.allSingletons = !1), this.set.add(t) && (this.structures[this.structures.length] = t));
  }, e.prototype.getSelection = function() {
    return this.allSingletons ? St.Singletons(this.source, iy(this.source, this.structures)) : St.Sequence(this.source, this.structures);
  }, e;
}(), $ee = function() {
  function e(t) {
    this.source = t, this.builders = [], this.builderMap = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, r, n) {
    var a = this.builderMap.get(t);
    a || (a = this.source.subsetBuilder(!0), this.builders[this.builders.length] = a, this.builderMap.set(t, a)), a.addToUnit(r, n);
  }, e.prototype.allSingletons = function() {
    for (var t = 0, r = this.builders.length; t < r; t++) if (this.builders[t].elementCount > 1) return !1;
    return !0;
  }, e.prototype.singletonSelection = function() {
    for (var t = this.source.subsetBuilder(!0), r = lt.create(this.source), n = 0, a = this.builders.length; n < a; n++) this.builders[n].setSingletonLocation(r), t.addToUnit(r.unit.id, r.element);
    return St.Singletons(this.source, t.getStructure());
  }, e.prototype.fullSelection = function() {
    for (var t = new Array(this.builders.length), r = 0, n = this.builders.length; r < n; r++) t[r] = this.builders[r].getStructure();
    return St.Sequence(this.source, t);
  }, e.prototype.getSelection = function() {
    return this.builders.length === 0 ? St.Empty(this.source) : this.allSingletons() ? this.singletonSelection() : this.fullSelection();
  }, e;
}(), y6 = function(e) {
  return St.Sequence(e.inputStructure, []);
}, JF = function(e) {
  return St.Singletons(e.inputStructure, e.inputStructure);
};
function Yl(e) {
  return !0;
}
function Jee(e) {
  return 0;
}
function L4(e) {
  if (!(e && (e.atomTest || e.residueTest || e.chainTest || e.entityTest || e.unitTest || e.groupBy))) return JF;
  if (e.atomTest && !e.residueTest && !e.chainTest && !e.entityTest && !e.unitTest && !e.groupBy) return t = e.atomTest, function(n) {
    var a = n.inputStructure, i = a.units, o = n.pushCurrentElement(), s = a.subsetBuilder(!0);
    o.structure = a;
    for (var u = 0, c = i; u < c.length; u++) {
      var l = c[u];
      o.unit = l;
      var d = l.elements;
      s.beginUnit(l.id);
      for (var f = 0, m = d.length; f < m; f++) o.element = d[f], t(n) && s.addElement(o.element);
      s.commitUnit(), n.throwIfTimedOut();
    }
    return n.popCurrentElement(), St.Singletons(a, s.getStructure());
  };
  var t, r = { unitTest: e.unitTest || Yl, entityTest: e.entityTest || Yl, chainTest: e.chainTest || Yl, residueTest: e.residueTest || Yl, atomTest: e.atomTest || Yl, groupBy: e.groupBy || Jee };
  return e.groupBy ? function(n) {
    var a = n.unitTest, i = n.entityTest, o = n.chainTest, s = n.residueTest, u = n.atomTest, c = n.groupBy;
    return function(l) {
      var d = l.inputStructure, f = d.units, m = l.pushCurrentElement(), h = new $ee(d);
      m.structure = d;
      for (var p = 0, g = f; p < g.length; p++) {
        var v = g[p];
        if (m.unit = v, a(l)) {
          var y = v.elements, _ = v.model;
          if (v.kind === 0) for (var S = nr.transientSegments(_.atomicHierarchy.chainAtomSegments, y), b = nr.transientSegments(_.atomicHierarchy.residueAtomSegments, y); S.hasNext; ) {
            var x = S.move();
            if (m.element = y[x.start], i(l) && o(l)) for (b.setSegment(x); b.hasNext; ) {
              var A = b.move();
              if (m.element = y[A.start], s(l)) for (var w = A.start, C = A.end; w < C; w++) m.element = y[w], u(l) && h.add(c(l), v.id, m.element);
            }
          }
          else {
            var M = _.coarseHierarchy.spheres.chainElementSegments;
            for (S = nr.transientSegments(M, y); S.hasNext; )
              if (x = S.move(), m.element = y[x.start], i(l) && o(l)) for (w = x.start, C = x.end; w < C; w++) m.element = y[w], s(l) && h.add(c(l), v.id, m.element);
          }
          l.throwIfTimedOut();
        }
      }
      return l.popCurrentElement(), h.getSelection();
    };
  }(r) : function(n) {
    var a = n.unitTest, i = n.entityTest, o = n.chainTest, s = n.residueTest, u = n.atomTest;
    return function(c) {
      var l = c.inputStructure, d = l.units, f = c.pushCurrentElement(), m = l.subsetBuilder(!0), h = s === Yl && u === Yl, p = u === Yl;
      f.structure = l;
      for (var g = 0, v = d; g < v.length; g++) {
        var y = v[g];
        if (f.unit = y, a(c)) {
          var _ = y.elements, S = y.model;
          if (m.beginUnit(y.id), y.kind === 0) for (var b = nr.transientSegments(y.model.atomicHierarchy.chainAtomSegments, _), x = nr.transientSegments(y.model.atomicHierarchy.residueAtomSegments, _); b.hasNext; ) {
            var A = b.move();
            if (f.element = _[A.start], i(c) && o(c)) if (h) m.addElementRange(_, A.start, A.end);
            else for (x.setSegment(A); x.hasNext; ) {
              var w = x.move();
              if (f.element = _[w.start], s(c)) if (p) m.addElementRange(_, w.start, w.end);
              else for (var C = w.start, M = w.end; C < M; C++) f.element = _[C], u(c) && m.addElement(f.element);
            }
          }
          else {
            var T = S.coarseHierarchy.spheres.chainElementSegments;
            for (b = nr.transientSegments(T, _); b.hasNext; )
              if (A = b.move(), f.element = _[A.start], i(c) && o(c)) if (h) m.addElementRange(_, A.start, A.end);
              else for (C = A.start, M = A.end; C < M; C++) f.element = _[C], s(c) && m.addElement(f.element);
          }
          m.commitUnit(), c.throwIfTimedOut();
        }
      }
      return c.popCurrentElement(), St.Singletons(l, m.getStructure());
    };
  }(r);
}
function k4(e, t, r) {
  for (var n = new Int32Array(t.length), a = 0, i = t.length; a < i; a++) n[a] = e.elements[t[a]];
  return st.create([e.getChild($e.ofSortedArray(n))], { parent: r });
}
var pt, za, ete = Object.freeze({ __proto__: null, all: JF, atoms: L4, bondedAtomicPairs: function(e) {
  return function(t) {
    var r = t.inputStructure, n = r.interUnitBonds, a = St.UniqueBuilder(t.inputStructure);
    t.pushCurrentBond();
    var i = t.atomicBond;
    i.setTestFn(e), i.setStructure(r);
    for (var o = 0, s = r.units; o < s.length; o++) {
      var u = s[o];
      if (u.kind === 0) {
        var c = u.bonds, l = c.offset, d = c.b, f = c.edgeProps, m = f.flags, h = f.order;
        i.a.unit = u, i.b.unit = u;
        for (var p = 0, g = u.elements.length; p < g; p++) {
          i.aIndex = p, i.a.element = u.elements[p];
          for (var v = l[p], y = l[p + 1]; v < y; v++)
            i.bIndex = d[v], i.b.element = u.elements[d[v]], i.type = m[v], i.order = h[v], i.test(t, !1) && ((b = r.subsetBuilder(!1)).beginUnit(u.id), b.addElement(i.a.element), b.addElement(i.b.element), b.commitUnit(), a.add(b.getStructure()));
        }
      }
    }
    for (var _ = 0, S = n.edges; _ < S.length; _++) {
      var b, x = S[_];
      i.a.unit = r.unitMap.get(x.unitA), i.a.element = i.a.unit.elements[x.indexA], i.aIndex = x.indexA, i.b.unit = r.unitMap.get(x.unitA), i.b.element = i.b.unit.elements[x.indexB], i.bIndex = x.indexB, i.order = x.props.order, i.type = x.props.flag, i.test(t, !1) && ((b = r.subsetBuilder(!1)).addToUnit(i.a.unit.id, i.a.element), b.addToUnit(i.b.unit.id, i.b.element), a.add(b.getStructure()));
    }
    return t.popCurrentBond(), a.getSelection();
  };
}, chains: function(e) {
  return L4(k(k({}, e), { groupBy: function(t) {
    return at.chain.key(t.element);
  } }));
}, none: y6, querySelection: function(e, t, r) {
  return r === void 0 && (r = !1), function(n) {
    var a = e(n);
    if (St.structureCount(a) === 0) return a;
    var i = r ? ZF(n.inputStructure, St.unionStructure(a)) : St.unionStructure(a);
    if (i.elementCount === 0) return St.Empty(n.inputStructure);
    n.throwIfTimedOut(), n.pushInputStructure(i);
    var o = t(n);
    return n.popInputStructure(), St.withInputStructure(o, n.inputStructure);
  };
}, residues: function(e) {
  return L4(k(k({}, e), { groupBy: function(t) {
    return at.residue.key(t.element);
  } }));
}, rings: function(e, t) {
  return function(r) {
    var n = r.inputStructure.units, a = St.LinearBuilder(r.inputStructure);
    if (e && e.length !== 0) {
      for (var i = Sn.create(), o = 0; o < e.length; o++) Sn.add(i, e[o], e[o]);
      for (var s = 0, u = n; s < u.length; s++)
        if (v = u[s], Ke.isAtomic(v)) for (var c = v.rings, l = 0, d = i.array; l < d.length; l++) {
          var f = d[l];
          if (c.byFingerprint.has(f)) for (var m = 0, h = c.byFingerprint.get(f); m < h.length; m++)
            S = h[m], t && !c.aromaticRings.includes(S) || a.add(k4(v, c.all[S], r.inputStructure));
        }
    } else for (var p = 0, g = n; p < g.length; p++) {
      var v = g[p];
      if (Ke.isAtomic(v)) if (t) for (var y = 0, _ = v.rings.aromaticRings; y < _.length; y++) {
        var S = _[y];
        a.add(k4(v, v.rings.all[S], r.inputStructure));
      }
      else for (var b = 0, x = v.rings.all; b < x.length; b++) {
        var S = x[b];
        a.add(k4(v, S, r.inputStructure));
      }
    }
    return a.getSelection();
  };
} }), l3 = function() {
  function e(t) {
    this.parent = t, this.ids = [], this.unitMap = uc.Mutable(), this.parentId = -1, this.currentUnit = Sn.create(), this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, r) {
    var n = this.unitMap.get(t);
    if (n) Sn.add(n, r, r) && this.elementCount++;
    else {
      var a = Sn.create();
      Sn.add(a, r, r), this.unitMap.set(t, a), this.ids[this.ids.length] = t, this.elementCount++;
    }
  }, e.prototype.has = function(t, r) {
    var n = this.unitMap.get(t);
    return !!n && Sn.has(n, r);
  }, e.prototype.beginUnit = function(t) {
    this.parentId = t, this.unitMap.has(t) ? this.currentUnit = this.unitMap.get(t) : this.currentUnit = this.currentUnit.array.length > 0 ? Sn.create() : this.currentUnit;
  }, e.prototype.addElement = function(t) {
    Sn.add(this.currentUnit, t, t) && this.elementCount++;
  }, e.prototype.commitUnit = function() {
    this.currentUnit.array.length === 0 || this.unitMap.has(this.parentId) || (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
  }, e.prototype.getStructure = function() {
    if (this.isEmpty) return st.Empty;
    var t = [];
    Du(this.ids);
    for (var r = Gp.UnitEquivalenceBuilder(), n = 0, a = this.ids.length; n < a; n++) {
      var i = this.ids[n], o = this.parent.unitMap.get(i), s = this.unitMap.get(i).array, u = s.length;
      if (s.length !== o.elements.length) {
        u > 1 && Du(s);
        var c = o.getChild($e.ofSortedArray(s)), l = r.add(c.id, c);
        c !== l && (c = l.applyOperator(c.id, c.conformation.operator, !0)), t[t.length] = c;
      } else t[t.length] = o, r.add(o.id, o);
    }
    return st.create(t, { parent: this.parent });
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function ft(e) {
  return { data: e, position: 0, length: e.length, lineNumber: 1, tokenStart: 0, tokenEnd: 0 };
}
function aC(e) {
  for (; e.position < e.length; ) switch (e.data.charCodeAt(e.position)) {
    case 9:
    case 10:
    case 13:
    case 32:
      return void (e.tokenEnd = e.position);
    default:
      ++e.position;
  }
  e.tokenEnd = e.position;
}
function iC(e) {
  return !(e.length - e.position < 2) && e.data.charCodeAt(e.position + 1) === 39 && e.data.charCodeAt(e.position + 2) === 39;
}
function tte(e, t, r) {
  var n, a = r - t, i = e.tokenStart - t, o = e.tokenEnd - e.tokenStart;
  if (o < a) return !1;
  for (n = t; n < r; ++n) if (e.data.charCodeAt(n) !== e.data.charCodeAt(n + i)) return !1;
  return a === o || e.data.charCodeAt(n + i) === 46;
}
function eR(e) {
  var t;
  for (t = e.tokenStart; t < e.tokenEnd; ++t) if (e.data.charCodeAt(t) === 46) return t;
  return t;
}
function tR(e, t) {
  return e.data.substring(e.tokenStart, t);
}
function b6(e) {
  return e.data.substring(e.tokenStart, e.tokenEnd);
}
function oC(e) {
  var t = function(n) {
    for (var a = 10; n.position < n.length; ) {
      var i = n.data.charCodeAt(n.position);
      switch (i) {
        case 9:
        case 32:
          a = i, ++n.position;
          break;
        case 10:
          a !== 13 && ++n.lineNumber, a = i, ++n.position;
          break;
        case 13:
          a = i, ++n.position, ++n.lineNumber;
          break;
        default:
          return a;
      }
    }
    return a;
  }(e);
  if (e.position >= e.length) e.tokenType = 6;
  else {
    e.tokenStart = e.position, e.tokenEnd = e.position, e.isEscaped = !1;
    var r = e.data.charCodeAt(e.position);
    switch (r) {
      case 35:
        (function(n) {
          for (; n.position < n.length; ) {
            var a = n.data.charCodeAt(n.position);
            if (a === 10 || a === 13) return;
            ++n.position;
          }
        })(e), e.tokenType = 5;
        break;
      case 39:
        if (iC(e)) {
          (function(n) {
            for (n.position += 3; n.position < n.length; ) {
              if (n.data.charCodeAt(n.position) === 39 && iC(n)) return n.tokenStart += 3, n.tokenEnd = n.position, n.isEscaped = !0, void (n.position += 3);
              ++n.position;
            }
            n.tokenEnd = n.position;
          })(e), e.tokenType = 3;
          break;
        }
      case 34:
        (function(n, a) {
          var i, o;
          for (++n.position; n.position < n.length; ) if ((o = n.data.charCodeAt(n.position)) === a) switch (i = n.data.charCodeAt(n.position + 1)) {
            case 9:
            case 10:
            case 13:
            case 32:
              return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
            default:
              if (i === void 0) return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
              ++n.position;
          }
          else {
            if (o === 10 || o === 13) return void (n.tokenEnd = n.position);
            ++n.position;
          }
          n.tokenEnd = n.position;
        })(e, r), e.tokenType = 3;
        break;
      case 59:
        t === 10 || t === 13 ? function(n) {
          for (var a, i = 59, o = n.position + 1; o < n.length; ) {
            if ((a = n.data.charCodeAt(o)) === 59 && (i === 10 || i === 13)) {
              for (n.position = o + 1, n.tokenStart++, o--, a = n.data.charCodeAt(o); a === 10 || a === 13; ) o--, a = n.data.charCodeAt(o);
              return n.tokenEnd = o + 1, void (n.isEscaped = !0);
            }
            (a === 13 || a === 10 && i !== 13) && n.lineNumber++, i = a, ++o;
          }
          n.position = o;
        }(e) : aC(e), e.tokenType = 3;
        break;
      default:
        e.isImportGet ? function(n) {
          for (; n.position < n.length; ) {
            if (n.data.charCodeAt(n.position) === 93) return ++n.position, n.tokenEnd = n.position, void (n.isImportGet = !1);
            ++n.position;
          }
        }(e) : aC(e), e.isEscaped ? e.tokenType = 3 : e.data.charCodeAt(e.tokenStart) === 95 ? (e.inSaveFrame && function(n) {
          return n.tokenEnd - n.tokenStart == 11 && n.data.charCodeAt(n.tokenStart + 1) === 105 && n.data.charCodeAt(n.tokenStart + 2) === 109 && n.data.charCodeAt(n.tokenStart + 3) === 112 && n.data.charCodeAt(n.tokenStart + 4) === 111 && n.data.charCodeAt(n.tokenStart + 5) === 114 && n.data.charCodeAt(n.tokenStart + 6) === 116 && n.data.charCodeAt(n.tokenStart + 7) === 46 && n.data.charCodeAt(n.tokenStart + 8) === 103 && n.data.charCodeAt(n.tokenStart + 9) === 101 && n.data.charCodeAt(n.tokenStart + 10) === 116;
        }(e) && (e.isImportGet = !0), e.tokenType = 4) : e.tokenEnd - e.tokenStart >= 5 && e.data.charCodeAt(e.tokenStart + 4) === 95 ? function(n) {
          var a = n.data.charCodeAt(n.tokenStart);
          return !(a !== 68 && a !== 100 || (a = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && a !== 97 || (a = n.data.charCodeAt(n.tokenStart + 2)) !== 84 && a !== 116 || (a = n.data.charCodeAt(n.tokenStart + 3)) !== 65 && a !== 97);
        }(e) ? e.tokenType = 0 : function(n) {
          var a = n.data.charCodeAt(n.tokenStart);
          return !(a !== 83 && a !== 115 || (a = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && a !== 97 || (a = n.data.charCodeAt(n.tokenStart + 2)) !== 86 && a !== 118 || (a = n.data.charCodeAt(n.tokenStart + 3)) !== 69 && a !== 101);
        }(e) ? e.tokenType = 1 : function(n) {
          if (n.tokenEnd - n.tokenStart != 5) return !1;
          var a = n.data.charCodeAt(n.tokenStart);
          return !(a !== 76 && a !== 108 || (a = n.data.charCodeAt(n.tokenStart + 1)) !== 79 && a !== 111 || (a = n.data.charCodeAt(n.tokenStart + 2)) !== 79 && a !== 111 || (a = n.data.charCodeAt(n.tokenStart + 3)) !== 80 && a !== 112);
        }(e) ? e.tokenType = 2 : e.tokenType = 3 : e.tokenType = 3;
    }
  }
}
function hd(e) {
  for (oC(e); e.tokenType === 5; ) oC(e);
}
function ng() {
  return { categoryNames: [], categoryData: /* @__PURE__ */ Object.create(null) };
}
function x6(e, t) {
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, a = e; n < a.length; n++) {
    var i = a[n], o = t[i];
    r[i] = Mi(o.name, o.rowCount, o.fieldNames, o.fields);
  }
  return r;
}
function sC(e, t, r) {
  return y8(e.categoryNames, x6(e.categoryNames, e.categoryData), t, r);
}
function _6(e, t, r, n, a) {
  var i;
  if (t in e.categoryData) {
    var o = e.categoryData[t];
    (i = o.fieldNames).push.apply(i, n), Object.assign(o.fields, a);
  } else e.categoryData[t] = { name: t, rowCount: r, fieldNames: n, fields: a }, e.categoryNames.push(t);
}
function rte(e, t) {
  for (var r = t.tokenizer, n = t.tokens, a = t.fieldCount, i = t.tokenCount, o = 0; r.tokenType === 3 && o < e; ) pt.add(n[i++ % a], r.tokenStart, r.tokenEnd), hd(r), o++;
  return t.tokenCount = i, o;
}
function nte(e, t) {
  return e.update({ message: "Parsing...", current: t.tokenizer.position, max: t.tokenizer.data.length });
}
function ate(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f;
    return Te(this, function(m) {
      switch (m.label) {
        case 0:
          for (r = e.lineNumber, hd(e), n = tR(e, eR(e)), a = function(h) {
            var p;
            for (p = h.tokenStart; p < h.tokenEnd; ++p) if (h.data.charCodeAt(p) === 46) return !1;
            return !0;
          }(e), i = []; e.tokenType === 4; ) i[i.length] = a ? b6(e) : b6(e).substring(n.length + 1), hd(e);
          for (o = n === "_atom_site" ? e.data.length / 100 | 0 : 32, s = [], u = i.length, f = 0; f < u; f++) s[f] = pt.create(e.data, o);
          return c = { fieldCount: u, tokenCount: 0, tokenizer: e, tokens: s }, [4, ih(e.runtimeCtx, 1e6, c, rte, nte)];
        case 1:
          if (m.sent(), c.tokenCount % u != 0) return [2, { hasError: !0, errorLine: e.lineNumber, errorMessage: "The number of values for loop starting at line ".concat(r, " is not a multiple of the number of columns.") }];
          if (l = c.tokenCount / u | 0, a) for (f = 0; f < u; f++) d = { "": mt.ofTokens(s[f]) }, _6(t, i[f].substr(1), l, [""], d);
          else {
            for (d = /* @__PURE__ */ Object.create(null), f = 0; f < u; f++) d[i[f]] = mt.ofTokens(s[f]);
            _6(t, n.substr(1), l, i, d);
          }
          return [2, { hasError: !1, errorLine: 0, errorMessage: "" }];
      }
    });
  });
}
function Gm(e, t) {
  return za.error(t, e);
}
function ite(e) {
  return za.success(e);
}
function ote(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d;
    return Te(this, function(f) {
      switch (f.label) {
        case 0:
          r = [], n = function(p, g) {
            return { data: p, length: p.length, position: 0, tokenStart: 0, tokenEnd: 0, tokenType: 6, lineNumber: 1, isEscaped: !1, isImportGet: !1, inSaveFrame: !1, runtimeCtx: g };
          }(e, t), a = "", i = ng(), o = [], s = ng(), m = s.categoryNames, h = x6(s.categoryNames, s.categoryData), u = { categoryNames: m, header: "", categories: h }, c = "", t.update({ message: "Parsing...", current: 0, max: e.length }), hd(n), f.label = 1;
        case 1:
          return n.tokenType === 6 ? [3, 7] : (l = n.tokenType) !== 0 ? [3, 2] : n.inSaveFrame ? [2, Gm(n.lineNumber, "Unexpected data block inside a save frame.")] : (i.categoryNames.length > 0 && r.push(sC(i, a, o)), a = e.substring(n.tokenStart + 5, n.tokenEnd), i = ng(), o = [], hd(n), [3, 6]);
        case 2:
          if (l !== 1) return [3, 3];
          if (n.tokenEnd - n.tokenStart == 5) s.categoryNames.length > 0 && (o[o.length] = function(p, g) {
            return y8(p.categoryNames, x6(p.categoryNames, p.categoryData), g);
          }(s, c)), n.inSaveFrame = !1;
          else {
            if (n.inSaveFrame) return [2, Gm(n.lineNumber, "Save frames cannot be nested.")];
            n.inSaveFrame = !0, c = e.substring(n.tokenStart + 5, n.tokenEnd), s = ng();
          }
          return hd(n), [3, 6];
        case 3:
          return l !== 2 ? [3, 5] : [4, ate(n, n.inSaveFrame ? s : i)];
        case 4:
          return (d = f.sent()).hasError ? [2, Gm(d.errorLine, d.errorMessage)] : [3, 6];
        case 5:
          if (l !== 4) return console.log(n.tokenType, ft.getTokenString(n)), [2, Gm(n.lineNumber, "Unexpected token. Expected data_, loop_, or data name.")];
          if (d = function(p, g) {
            for (var v = p.tokenStart, y = eR(p), _ = tR(p, y), S = /* @__PURE__ */ Object.create(null), b = [], x = !0; x; ) {
              if (p.tokenType !== 4 || !tte(p, v, y)) {
                x = !1;
                break;
              }
              var A = b6(p).substring(_.length + 1);
              if (hd(p), p.tokenType !== 3) return { hasError: !0, errorLine: p.lineNumber, errorMessage: "Expected value." };
              S[A] = mt.ofTokens({ data: p.data, indices: [p.tokenStart, p.tokenEnd], count: 1 }), b[b.length] = A, hd(p);
            }
            return _6(g, _.substr(1), 1, b, S), { hasError: !1, errorLine: 0, errorMessage: "" };
          }(n, n.inSaveFrame ? s : i), d.hasError) return [2, Gm(d.errorLine, d.errorMessage)];
          f.label = 6;
        case 6:
          return [3, 1];
        case 7:
          return n.inSaveFrame ? [2, Gm(n.lineNumber, "Unfinished save frame (".concat(u.header, ")."))] : ((i.categoryNames.length > 0 || o.length > 0) && r.push(sC(i, a, o)), [2, ite(yF(r))]);
      }
      var m, h;
    });
  });
}
function ste(e) {
  var t = this;
  return sr.create("Parse CIF", function(r) {
    return Be(t, 0, void 0, function() {
      return Te(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, ote(e, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
function z4(e, t) {
  for (var r = {}, n = 0; n < t; n++)
    r[oy(e)] = oy(e);
  return r;
}
function U4(e, t) {
  for (var r = new Uint8Array(t), n = e.offset, a = 0; a < t; a++) r[a] = e.buffer[a + n];
  return e.offset += t, r;
}
function ag(e, t) {
  var r = aF(e.buffer, e.offset, t);
  return e.offset += t, r;
}
function G4(e, t) {
  for (var r = new Array(t), n = 0; n < t; n++) r[n] = oy(e);
  return r;
}
function oy(e) {
  var t, r, n = e.buffer[e.offset];
  if (!(128 & n)) return e.offset++, n;
  if ((240 & n) == 128) return r = 15 & n, e.offset++, z4(e, r);
  if ((240 & n) == 144) return r = 15 & n, e.offset++, G4(e, r);
  if ((224 & n) == 160) return r = 31 & n, e.offset++, ag(e, r);
  if (!(224 & ~n)) return t = e.dataView.getInt8(e.offset), e.offset++, t;
  switch (n) {
    case 192:
      return e.offset++, null;
    case 194:
      return e.offset++, !1;
    case 195:
      return e.offset++, !0;
    case 196:
      return r = e.dataView.getUint8(e.offset + 1), e.offset += 2, U4(e, r);
    case 197:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, U4(e, r);
    case 198:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, U4(e, r);
    case 202:
      return t = e.dataView.getFloat32(e.offset + 1), e.offset += 5, t;
    case 203:
      return t = e.dataView.getFloat64(e.offset + 1), e.offset += 9, t;
    case 204:
      return t = e.buffer[e.offset + 1], e.offset += 2, t;
    case 205:
      return t = e.dataView.getUint16(e.offset + 1), e.offset += 3, t;
    case 206:
      return t = e.dataView.getUint32(e.offset + 1), e.offset += 5, t;
    case 208:
      return t = e.dataView.getInt8(e.offset + 1), e.offset += 2, t;
    case 209:
      return t = e.dataView.getInt16(e.offset + 1), e.offset += 3, t;
    case 210:
      return t = e.dataView.getInt32(e.offset + 1), e.offset += 5, t;
    case 217:
      return r = e.dataView.getUint8(e.offset + 1), e.offset += 2, ag(e, r);
    case 218:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, ag(e, r);
    case 219:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, ag(e, r);
    case 220:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, G4(e, r);
    case 221:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, G4(e, r);
    case 222:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, z4(e, r);
    case 223:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, z4(e, r);
  }
  throw new Error("Unknown type 0x" + n.toString(16));
}
function ute(e) {
  for (var t = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), n = 0, a = e.columns; n < a.length; n++) {
    var i = a[n];
    t[i.name] = i;
  }
  return { rowCount: e.rowCount, name: e.name.substr(1), fieldNames: e.columns.map(function(o) {
    return o.name;
  }), getField: function(o) {
    var s = t[o];
    if (s) return r[o] || (r[o] = function(u) {
      var c = u.mask ? ty(u.mask) : void 0, l = ty(u.data), d = u8(l), f = d ? c ? function(v) {
        return c[v] === 0 ? "" + l[v] : "";
      } : function(v) {
        return "" + l[v];
      } : c ? function(v) {
        return c[v] === 0 ? l[v] : "";
      } : function(v) {
        return l[v];
      }, m = d ? function(v) {
        return l[v];
      } : function(v) {
        var y = l[v];
        return Bd(y, 0, y.length);
      }, h = d ? function(v) {
        return l[v];
      } : function(v) {
        var y = l[v];
        return Hf(y, 0, y.length);
      }, p = c ? function(v) {
        return c[v];
      } : function(v) {
        return 0;
      }, g = l.length;
      return { __array: l, binaryEncoding: u.data.encoding, isDefined: !0, rowCount: g, str: f, int: m, float: h, valueKind: p, areValuesEqual: function(v, y) {
        return l[v] === l[y];
      }, toStringArray: function(v) {
        return ci(g, f, v);
      }, toIntArray: d ? function(v) {
        return q2(l, v);
      } : function(v) {
        return ci(g, m, v);
      }, toFloatArray: d ? function(v) {
        return q2(l, v);
      } : function(v) {
        return ci(g, h, v);
      } };
    }(s)), r[o];
  } };
}
function cte(e) {
  var t = this;
  return sr.create("Parse BinaryCIF", function(r) {
    return Be(t, 0, void 0, function() {
      var n, a, i;
      return Te(this, function(o) {
        n = [0, 3];
        try {
          return a = oy({ buffer: s = e, offset: 0, dataView: new DataView(s.buffer) }), function(u, c) {
            for (var l = 0; l < 2; l++) if (u[l] > c[l]) return !1;
            return !0;
          }(n, a.version.match(/(\d)\.(\d)\.\d/).slice(1).map(function(u) {
            return +u;
          })) ? (i = yF(a.dataBlocks.map(function(u) {
            for (var c = /* @__PURE__ */ Object.create(null), l = 0, d = u.categories; l < d.length; l++) {
              var f = d[l];
              c[f.name.substr(1)] = ute(f);
            }
            return y8(u.categories.map(function(m) {
              return m.name.substr(1);
            }), c, u.header);
          })), [2, za.success(i)]) : [2, za.error("Unsupported format version. Current ".concat(a.version, ", required ").concat(n.join("."), "."))];
        } catch (u) {
          return [2, za.error("" + u)];
        }
        var s;
        return [2];
      });
    });
  });
}
(function(e) {
  function t(o) {
    return o.data.substring(o.tokenStart, o.tokenEnd);
  }
  function r(o) {
    for (var s = o.data; o.position < o.length; ) switch (s.charCodeAt(o.position)) {
      case 10:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, !0;
      case 13:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, s.charCodeAt(o.position) === 10 && ++o.position, !0;
      default:
        ++o.position;
    }
    return o.tokenEnd = o.position, o.tokenStart !== o.tokenEnd;
  }
  function n(o) {
    return o.tokenStart = o.position, r(o);
  }
  function a(o, s, u) {
    for (var c = 0, l = 0; l < s; l++) {
      if (!n(o)) return c;
      pt.addUnchecked(u, o.tokenStart, o.tokenEnd), c++;
    }
    return c;
  }
  function i(o, s, u) {
    for (var c = o.data, l = s, d = u - 1, f = c.charCodeAt(l); (f === 9 || f === 32) && l <= d; ) f = c.charCodeAt(++l);
    for (f = c.charCodeAt(d); (f === 9 || f === 32) && d >= l; ) f = c.charCodeAt(--d);
    return o.tokenStart = l, o.tokenEnd = d + 1, o.position = u, o;
  }
  e.getTokenString = t, e.reset = function(o) {
    o.position = 0, o.lineNumber = 1, o.tokenStart = 0, o.tokenEnd = 0;
  }, e.eatLine = r, e.markStart = function(o) {
    o.tokenStart = o.position;
  }, e.markLine = n, e.readLine = function(o) {
    return n(o), t(o);
  }, e.readLineTrim = function(o) {
    n(o);
    var s = o.position;
    return i(o, o.tokenStart, o.tokenEnd), o.position = s, t(o);
  }, e.markLines = function(o, s) {
    var u = pt.create(o.data, 2 * s);
    return a(o, s, u), u;
  }, e.readLines = function(o, s) {
    for (var u = [], c = 0; c < s; c++) u.push(e.readLine(o));
    return u;
  }, e.readLinesAsync = function(o, s, u, c) {
    return c === void 0 && (c = 1e5), Be(this, 0, void 0, function() {
      var l, d, f;
      return Te(this, function(m) {
        switch (m.label) {
          case 0:
            return l = o.length, d = pt.create(o.data, 2 * s), f = 0, [4, ih(u, c, o, function(h, p) {
              var g = Math.min(s - f, h);
              return a(p, g, d), f += g, g;
            }, function(h, p) {
              return h.update({ message: "Parsing...", current: p.position, max: l });
            })];
          case 1:
            return m.sent(), [2, d];
        }
      });
    });
  }, e.readAllLines = function(o) {
    for (var s = e(o), u = pt.create(s.data, Math.max(o.length / 80, 2)); n(s); ) pt.add(u, s.tokenStart, s.tokenEnd);
    return u;
  }, e.readAllLinesAsync = function(o, s, u) {
    return u === void 0 && (u = 1e5), Be(this, 0, void 0, function() {
      var c, l;
      return Te(this, function(d) {
        switch (d.label) {
          case 0:
            return c = e(o), l = pt.create(c.data, Math.max(o.length / 80, 2)), [4, ih(s, u, c, function(f, m) {
              return function(h, p, g) {
                for (var v = 0, y = 0; y < p; y++) {
                  if (!n(h)) return v;
                  pt.add(g, h.tokenStart, h.tokenEnd), v++;
                }
              }(m, f, l), m.position < m.length ? f : 0;
            }, function(f, m) {
              return f.update({ message: "Parsing...", current: m.position, max: length });
            })];
          case 1:
            return d.sent(), [2, l];
        }
      });
    });
  }, e.eatValue = function(o) {
    for (; o.position < o.length; ) switch (o.data.charCodeAt(o.position)) {
      case 9:
      case 10:
      case 13:
      case 32:
        return void (o.tokenEnd = o.position);
      default:
        ++o.position;
    }
    o.tokenEnd = o.position;
  }, e.skipWhitespace = function(o) {
    for (var s = -1; o.position < o.length; ) {
      var u = o.data.charCodeAt(o.position);
      switch (u) {
        case 9:
        case 32:
          s = u, ++o.position;
          break;
        case 10:
          s !== 13 && ++o.lineNumber, s = u, ++o.position;
          break;
        case 13:
          s = u, ++o.position, ++o.lineNumber;
          break;
        default:
          return s;
      }
    }
    return s;
  }, e.trim = i;
})(ft || (ft = {})), function(e) {
  function t(r, n, a) {
    var i = r;
    i.offset > i.indicesLenMinus2 && function(o) {
      var s = new Uint32Array(1.61 * o.indices.length | 0);
      s.set(o.indices), o.indices = s, o.indicesLenMinus2 = s.length - 2 | 0;
    }(i), i.indices[i.offset++] = n, i.indices[i.offset++] = a, r.count++;
  }
  e.add = t, e.addToken = function(r, n) {
    t(r, n.tokenStart, n.tokenEnd);
  }, e.addUnchecked = function(r, n, a) {
    r.indices[r.offset++] = n, r.indices[r.offset++] = a, r.count++;
  }, e.create = function(r, n) {
    return { data: r, indicesLenMinus2: (n = Math.max(10, n)) - 2 | 0, count: 0, offset: 0, indices: new Uint32Array(n) };
  };
}(pt || (pt = {})), function(e) {
  e.error = function(n, a) {
    return a === void 0 && (a = -1), new t(n, a);
  }, e.success = function(n, a) {
    return a === void 0 && (a = []), new r(n, a);
  };
  var t = function() {
    function n(a, i) {
      this.message = a, this.line = i, this.isError = !0;
    }
    return n.prototype.toString = function() {
      return this.line >= 0 ? "[Line ".concat(this.line, "] ").concat(this.message) : this.message;
    }, n;
  }();
  e.Error = t;
  var r = function(n, a) {
    this.result = n, this.warnings = a, this.isError = !1;
  };
  e.Success = r;
}(za || (za = {}));
var h1 = pe.Schema, Nr = h1.str, lte = h1.float, uC = h1.List, rs = h1.Aliased, W1 = h1.int, Vm = h1.coord, dte = { chem_comp: { formula: Nr, formula_weight: lte, id: Nr, mon_nstd_parent_comp_id: uC(",", function(e) {
  return e;
}), name: Nr, one_letter_code: Nr, three_letter_code: Nr, type: rs(Nr), pdbx_synonyms: uC(";", function(e) {
  return e;
}), pdbx_type: Nr, pdbx_ambiguous_flag: Nr, pdbx_replaced_by: Nr, pdbx_replaces: Nr, pdbx_formal_charge: W1, pdbx_model_coordinates_details: Nr, pdbx_model_coordinates_db_code: Nr, pdbx_ideal_coordinates_details: Nr, pdbx_ideal_coordinates_missing_flag: rs(Nr), pdbx_model_coordinates_missing_flag: rs(Nr), pdbx_initial_date: Nr, pdbx_modified_date: Nr, pdbx_release_status: rs(Nr), pdbx_processing_site: rs(Nr) }, chem_comp_atom: { alt_atom_id: Nr, atom_id: Nr, charge: W1, model_Cartn_x: Vm, model_Cartn_y: Vm, model_Cartn_z: Vm, comp_id: Nr, type_symbol: Nr, pdbx_align: W1, pdbx_ordinal: W1, pdbx_model_Cartn_x_ideal: Vm, pdbx_model_Cartn_y_ideal: Vm, pdbx_model_Cartn_z_ideal: Vm, pdbx_stereo_config: rs(Nr), pdbx_aromatic_flag: rs(Nr), pdbx_leaving_atom_flag: rs(Nr) }, chem_comp_bond: { atom_id_1: Nr, atom_id_2: Nr, comp_id: Nr, value_order: rs(Nr), pdbx_ordinal: W1, pdbx_stereo_config: rs(Nr), pdbx_aromatic_flag: rs(Nr) }, pdbx_chem_comp_descriptor: { comp_id: Nr, descriptor: Nr, type: rs(Nr), program: Nr, program_version: Nr }, pdbx_chem_comp_identifier: { comp_id: Nr, identifier: Nr, type: rs(Nr), program: Nr, program_version: Nr } }, d3 = pe.Schema, Rt = d3.str, fte = d3.float, oo = d3.Aliased, Bs = d3.int, mte = { pdbx_reference_molecule: { prd_id: Rt, formula_weight: fte, formula: Rt, type: oo(Rt), type_evidence_code: Rt, class: oo(Rt), class_evidence_code: Rt, name: Rt, represent_as: oo(Rt), chem_comp_id: Rt, compound_details: Rt, description: Rt, representative_PDB_id_code: Rt, release_status: oo(Rt), replaces: Rt, replaced_by: Rt }, pdbx_reference_entity_list: { prd_id: Rt, ref_entity_id: Rt, type: oo(Rt), details: Rt, component_id: Bs }, pdbx_reference_entity_nonpoly: { prd_id: Rt, ref_entity_id: Rt, name: Rt, chem_comp_id: Rt }, pdbx_reference_entity_link: { link_id: Bs, prd_id: Rt, details: Rt, ref_entity_id_1: Rt, ref_entity_id_2: Rt, entity_seq_num_1: Bs, entity_seq_num_2: Bs, comp_id_1: Rt, comp_id_2: Rt, atom_id_1: Rt, atom_id_2: Rt, value_order: oo(Rt), component_1: Bs, component_2: Bs, link_class: oo(Rt) }, pdbx_reference_entity_poly_link: { link_id: Bs, prd_id: Rt, ref_entity_id: Rt, component_id: Bs, entity_seq_num_1: Bs, entity_seq_num_2: Bs, comp_id_1: Rt, comp_id_2: Rt, atom_id_1: Rt, atom_id_2: Rt, value_order: oo(Rt) }, pdbx_reference_entity_poly: { prd_id: Rt, ref_entity_id: Rt, type: oo(Rt), db_code: Rt, db_name: Rt }, pdbx_reference_entity_poly_seq: { prd_id: Rt, ref_entity_id: Rt, mon_id: Rt, parent_mon_id: Rt, num: Bs, observed: oo(Rt), hetero: oo(Rt) }, pdbx_reference_entity_sequence: { prd_id: Rt, ref_entity_id: Rt, type: oo(Rt), NRP_flag: oo(Rt), one_letter_codes: Rt }, pdbx_reference_entity_src_nat: { prd_id: Rt, ref_entity_id: Rt, ordinal: Bs, organism_scientific: Rt, taxid: Rt, db_code: Rt, db_name: Rt }, pdbx_prd_audit: { prd_id: Rt, date: Rt, processing_site: oo(Rt), action_type: oo(Rt) } }, rR = pe.Schema, ma = rR.str, pte = { datablock: { id: ma, description: ma }, dictionary: { title: ma, datablock_id: ma, version: ma }, dictionary_history: { version: ma, update: ma, revision: ma }, sub_category: { id: ma, description: ma }, category_group_list: { id: ma, parent_id: ma, description: ma }, item_type_list: { code: ma, primitive_code: ma, construct: ma, detail: ma }, item_units_list: { code: ma, detail: ma }, item_units_conversion: { from_code: ma, to_code: ma, operator: ma, factor: rR.float } }, Rh = pe.Schema, I0 = Rh.str, ig = Rh.int, Tc = Rh.float, og = Rh.Aliased, dd = Rh.Vector;
og(I0), og(I0), og(I0), og(I0), dd(3), dd(3);
var S6, rm, hte = { volume_data_3d_info: { name: I0, axis_order: dd(3, ig), origin: dd(3), dimensions: dd(3), sample_rate: ig, sample_count: dd(3, ig), spacegroup_number: ig, spacegroup_cell_size: dd(3), spacegroup_cell_angles: dd(3), mean_source: Tc, mean_sampled: Tc, sigma_source: Tc, sigma_sampled: Tc, min_source: Tc, min_sampled: Tc, max_source: Tc, max_sampled: Tc }, volume_data_3d: { values: Tc } }, f3 = pe.Schema, Qn = f3.float, V4 = f3.int, vn = f3.str, vte = { cell: { angle_alpha: Qn, angle_beta: Qn, angle_gamma: Qn, formula_units_z: V4, length_a: Qn, length_b: Qn, length_c: Qn, volume: Qn }, chemical: { melting_point: Qn, name_common: vn, name_systematic: vn }, chemical_formula: { moiety: vn, sum: vn, weight: Qn }, space_group: { crystal_system: vn, it_number: V4, "name_h-m_full": vn }, space_group_symop: { operation_xyz: vn }, geom_bond: { atom_site_label_1: vn, atom_site_label_2: vn, distance: Qn, publ_flag: vn, site_symmetry_1: vn, site_symmetry_2: vn, valence: Qn }, audit: { block_doi: vn }, database_code: { cod: vn, csd: vn, depnum_ccdc_archive: vn, depnum_ccdc_fiz: vn, icsd: vn, mdf: vn, nbs: vn }, atom_site: { adp_type: vn, calc_flag: vn, disorder_assembly: vn, disorder_group: vn, fract_x: Qn, fract_y: Qn, fract_z: Qn, label: vn, occupancy: Qn, refinement_flags: vn, site_symmetry_multiplicity: V4, type_symbol: vn, u_iso_or_equiv: Qn }, atom_site_aniso: { label: vn, u_11: Qn, u: (0, f3.Matrix)(3, 3), u_12: Qn, u_13: Qn, u_22: Qn, u_23: Qn, u_33: Qn }, atom_type: { description: vn, symbol: vn }, atom_type_scat: { dispersion_imag: Qn, dispersion_real: Qn, source: vn } }, gte = { "cell.formula_units_z": ["cell_formula_units_Z"], "space_group.it_number": ["space_group_IT_number", "symmetry_Int_Tables_number"], "space_group.name_h-m_full": ["symmetry_space_group_name_H-M"], "space_group_symop.operation_xyz": ["symmetry_equiv_pos_as_xyz"], "geom_bond.atom_site_label_1": ["geom_bond_atom_site_id_1"], "geom_bond.atom_site_label_2": ["geom_bond_atom_site_id_2"], "geom_bond.distance": ["geom_bond_dist"], "audit.block_doi": ["audit_block_DOI"], "database_code.cod": ["database_code_COD"], "database_code.csd": ["database_code_CSD"], "database_code.depnum_ccdc_archive": ["database_code_depnum_CCDC_archive"], "database_code.depnum_ccdc_fiz": ["database_code_depnum_CCDC_fiz"], "database_code.icsd": ["database_code_ICSD"], "database_code.mdf": ["database_code_MDF"], "database_code.nbs": ["database_code_NBS"], "atom_site.adp_type": ["atom_site_ADP_type", "atom_site_thermal_displace_type"], "atom_site.label": ["atom_site_id"], "atom_site.site_symmetry_multiplicity": ["atom_site_symmetry_multiplicity"], "atom_site.u_iso_or_equiv": ["atom_site_U_iso_or_equiv"], "atom_site_aniso.label": ["atom_site_anisotrop_id"], "atom_site_aniso.u_11": ["atom_site_aniso_U_11", "atom_site_anisotrop_U_11"], "atom_site_aniso.u_12": ["atom_site_aniso_U_12", "atom_site_anisotrop_U_12"], "atom_site_aniso.u_13": ["atom_site_aniso_U_13", "atom_site_anisotrop_U_13"], "atom_site_aniso.u_22": ["atom_site_aniso_U_22", "atom_site_anisotrop_U_22"], "atom_site_aniso.u_23": ["atom_site_aniso_U_23", "atom_site_anisotrop_U_23"], "atom_site_aniso.u_33": ["atom_site_aniso_U_33", "atom_site_anisotrop_U_33"] }, nR = function(e) {
  return typeof e == "string" ? ste(e) : cte(e);
}, aR = { mmCIF: function(e) {
  return Bf(ur, e);
}, CCD: function(e) {
  return Bf(dte, e);
}, BIRD: function(e) {
  return Bf(mte, e);
}, dic: function(e) {
  return Bf(pte, e);
}, cifCore: function(e) {
  return Bf(vte, e, gte);
}, densityServer: function(e) {
  return Bf(hte, e);
} }, yte = { type_symbol: pe.Schema.Aliased(ur.atom_site.type_symbol), label_atom_id: ur.atom_site.label_atom_id, auth_atom_id: ur.atom_site.auth_atom_id, label_alt_id: ur.atom_site.label_alt_id, label_comp_id: ur.atom_site.label_comp_id, auth_comp_id: ur.atom_site.auth_comp_id, pdbx_formal_charge: ur.atom_site.pdbx_formal_charge, cdr: ur.atom_site.cdr, B_iso_or_equiv: ur.atom_site.B_iso_or_equiv, em_confidence: ur.atom_site.em_confidence }, bte = { group_PDB: ur.atom_site.group_PDB, label_seq_id: ur.atom_site.label_seq_id, auth_seq_id: ur.atom_site.auth_seq_id, pdbx_PDB_ins_code: ur.atom_site.pdbx_PDB_ins_code }, xte = { label_asym_id: ur.atom_site.label_asym_id, auth_asym_id: ur.atom_site.auth_asym_id, label_entity_id: ur.atom_site.label_entity_id };
(function(e) {
  e.EmptyResidueKey = function() {
    return { label_entity_id: "", label_asym_id: "", auth_seq_id: 0, pdbx_PDB_ins_code: void 0 };
  };
})(S6 || (S6 = {})), function(e) {
  function t(n, a) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[a]];
  }
  function r(n, a) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[a + 1] - 1] + 1;
  }
  e.chainStartResidueIndex = t, e.chainEndResidueIndexExcl = r, e.chainResidueCount = function(n, a) {
    return r(n, a) - t(n, a);
  };
}(rm || (rm = {}));
var ch, zp = { H: 1, D: 1, T: 1, HE: 2, LI: 3, BE: 4, B: 5, C: 6, N: 7, O: 8, F: 9, NE: 10, NA: 11, MG: 12, AL: 13, SI: 14, P: 15, S: 16, CL: 17, AR: 18, K: 19, CA: 20, SC: 21, TI: 22, V: 23, CR: 24, MN: 25, FE: 26, CO: 27, NI: 28, CU: 29, ZN: 30, GA: 31, GE: 32, AS: 33, SE: 34, BR: 35, KR: 36, RB: 37, SR: 38, Y: 39, ZR: 40, NB: 41, MO: 42, TC: 43, RU: 44, RH: 45, PD: 46, AG: 47, CD: 48, IN: 49, SN: 50, SB: 51, TE: 52, I: 53, XE: 54, CS: 55, BA: 56, LA: 57, CE: 58, PR: 59, ND: 60, PM: 61, SM: 62, EU: 63, GD: 64, TB: 65, DY: 66, HO: 67, ER: 68, TM: 69, YB: 70, LU: 71, HF: 72, TA: 73, W: 74, RE: 75, OS: 76, IR: 77, PT: 78, AU: 79, HG: 80, TL: 81, PB: 82, BI: 83, PO: 84, AT: 85, RN: 86, FR: 87, RA: 88, AC: 89, TH: 90, PA: 91, U: 92, NP: 93, PU: 94, AM: 95, CM: 96, BK: 97, CF: 98, ES: 99, FM: 100, MD: 101, NO: 102, LR: 103, RF: 104, DB: 105, SG: 106, BH: 107, HS: 108, MT: 109 }, _te = { 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2, 28: 2, 29: 2, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2, 77: 2, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2, 90: 2.4, 91: 2, 92: 2.3, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2, 101: 2, 102: 2, 103: 2, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2 }, Ste = { 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.18, 11: 22.99, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.63, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.6, 53: 127.6, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.5, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.07, 97: 247.07, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.11, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156 }, Ate = 1.7, wte = 0;
function m3(e) {
  var t = zp[e];
  return t === void 0 ? Ate : _te[t];
}
function lh(e) {
  var t = zp[e];
  return t === void 0 ? wte : t;
}
function iR(e, t, r, n) {
  return { type: e, key: t, elements: r, getIndex: n };
}
function Cte(e, t, r, n, a, i) {
  for (var o = e.residues, s = o.auth_seq_id, u = o.label_seq_id, c = o.pdbx_PDB_ins_code, l = r.endSeqId, d = r.endInsCode, f = r.key, m = r.type, h = t === "label" ? u : s, p = n; p < a; ) {
    var g = h.value(p);
    if (i.type[p] = m, i.key[p] = f, g > l || g === l && c.value(p) === d) break;
    p++;
  }
}
(function(e) {
  e.Descriptor = { name: "model_secondary_structure" }, e.Provider = ic.create(e.Descriptor), e.fromStruct = function(t, r, n) {
    var a = /* @__PURE__ */ new Map(), i = [{ kind: "none" }], o = function(c, l) {
      if (c._rowCount > 0) {
        if (c.beg_label_seq_id.valueKind(0) !== 0 || c.end_label_seq_id.valueKind(0) !== 0) return "auth";
      } else if (l && (l.beg_label_seq_id.valueKind(0) !== 0 || l.end_label_seq_id.valueKind(0) !== 0)) return "auth";
      return "label";
    }(t, r);
    (function(c, l, d, f) {
      if (c._rowCount)
        for (var m = c.beg_label_asym_id, h = c.beg_label_seq_id, p = c.beg_auth_seq_id, g = c.pdbx_beg_PDB_ins_code, v = c.end_label_seq_id, y = c.end_auth_seq_id, _ = c.pdbx_end_PDB_ins_code, S = c.pdbx_PDB_helix_class, b = c.conf_type_id, x = c.details, A = l === "label" ? h : p, w = l === "label" ? v : y, C = 0, M = c._rowCount; C < M; C++) {
          var T = Er.create(S.valueKind(C) === 0 ? Er.SecondaryStructurePdb[S.value(C)] : b.valueKind(C) === 0 ? Er.SecondaryStructureMmcif[b.value(C)] : 536870912), N = { kind: "helix", flags: T, type_id: b.valueKind(C) === 0 ? b.value(C) : "HELIX_P", helix_class: S.value(C), details: x.valueKind(C) === 0 ? x.value(C) : void 0 }, I = { startSeqId: A.value(C), startInsCode: g.value(C), endSeqId: w.value(C), endInsCode: _.value(C), type: T, key: f.length };
          f[f.length] = N;
          var P = m.value(C);
          if (d.has(P)) {
            var O = d.get(P);
            O.has(I.startSeqId) ? O.get(I.startSeqId).push(I) : O.set(I.startSeqId, [I]);
          } else d.set(P, /* @__PURE__ */ new Map([[I.startSeqId, [I]]]));
        }
    })(t, o, a, i), function(c, l, d, f, m) {
      if (c._rowCount)
        for (var h = c.beg_label_asym_id, p = c.beg_label_seq_id, g = c.beg_auth_seq_id, v = c.pdbx_beg_PDB_ins_code, y = c.end_label_seq_id, _ = c.end_auth_seq_id, S = c.pdbx_end_PDB_ins_code, b = c.sheet_id, x = l === "label" ? p : g, A = l === "label" ? y : _, w = /* @__PURE__ */ new Map(), C = f + 1, M = 0, T = c._rowCount; M < T; M++) {
          var N = b.value(M), I = void 0;
          w.has(N) ? I = w.get(N) : (I = C++, w.set(N, I));
          var P = Er.create(8388612), O = { kind: "sheet", flags: P, sheet_id: N, symmetry: void 0 }, F = { startSeqId: x.value(M), startInsCode: v.value(M), endSeqId: A.value(M), endInsCode: S.value(M), type: P, key: m.length };
          m[m.length] = O;
          var R = h.value(M);
          if (d.has(R)) {
            var G = d.get(R);
            G.has(F.startSeqId) ? G.get(F.startSeqId).push(F) : G.set(F.startSeqId, [F]);
          } else d.set(R, /* @__PURE__ */ new Map([[F.startSeqId, [F]]]));
        }
    }(r, o, a, t._rowCount, i);
    var s = n.residues._rowCount, u = { type: new Int32Array(s), key: new Int32Array(s), elements: i };
    return a.size > 0 && function(c, l, d, f) {
      for (var m = c.chainAtomSegments.count, h = c.chains.label_asym_id, p = c.residues, g = p.auth_seq_id, v = p.label_seq_id, y = p.pdbx_PDB_ins_code, _ = l === "label" ? v : g, S = 0; S < m; S++) {
        var b = rm.chainStartResidueIndex(c, S), x = rm.chainEndResidueIndexExcl(c, S), A = h.value(S);
        if (d.has(A)) for (var w = d.get(A), C = b; C < x; C++) {
          var M = _.value(C);
          if (w.has(M)) for (var T = 0, N = w.get(M); T < N.length; T++) {
            var I = N[T], P = y.value(C);
            I.startInsCode === P && Cte(c, l, I, C, x, f);
          }
        }
      }
    }(n, o, a, u), iR(u.type, u.key, u.elements, function(c) {
      return c;
    });
  };
})(ch || (ch = {}));
var Rd, X0, Ete = { U: ur.atom_site_anisotrop.U, U_esd: ur.atom_site_anisotrop.U_esd };
(function(e) {
  e.Schema = Ete, e.Descriptor = { name: "atom_site_anisotrop", cifExport: { prefix: "", categories: [{ name: "atom_site_anisotrop", instance: function(t) {
    return e.Provider.get(t.firstModel) && Dn.is(t.firstModel.sourceData) ? Xa.Category.ofTable(t.firstModel.sourceData.data.db.atom_site_anisotrop) : Xa.Category.Empty;
  } }] } }, e.Provider = ic.create(e.Descriptor), e.getElementToAnsiotrop = function(t, r) {
    var n = new Int32Array(t.rowCount);
    n.fill(-1);
    for (var a = 0, i = t.rowCount; a < i; a++) n[t.value(a)] = a;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), a = 0, i = r.rowCount; a < i; ++a) {
      var s = n[r.value(a)];
      s !== -1 && (o[s] = a);
    }
    return o;
  }, e.getElementToAnsiotropFromLabel = function(t, r) {
    for (var n = {}, a = 0, i = t.rowCount; a < i; a++) n[t.value(a)] = a;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), a = 0, i = r.rowCount; a < i; ++a) {
      var s = n[r.value(a)];
      s !== void 0 && (o[s] = a);
    }
    return o;
  };
})(Rd || (Rd = {})), function(e) {
  var t, r = "molstar_global_model_transform_info";
  function n(a) {
    return e.Provider.get(a);
  }
  e.Schema = ((t = {})[r] = { matrix: pe.Schema.Matrix(4, 4, pe.Schema.float) }, t), e.Descriptor = Tu({ name: r, cifExport: { categories: [{ name: r, instance: function(a) {
    var i = n(a.firstModel);
    if (!i) return Xa.Category.Empty;
    var o = Yr.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: i }]);
    return Xa.Category.ofTable(o);
  } }], prefix: "molstar" } }), e.Provider = ic.create(e.Descriptor), e.attach = function(a, i) {
    a.customProperties.has(e.Descriptor) || a.customProperties.add(e.Descriptor), e.Provider.set(a, i);
  }, e.get = n, e.fromMmCif = function(a) {
    if (Dn.is(a.sourceData)) {
      var i = a.sourceData.data.frame.categories[r];
      if (i) {
        var o, s = (o = e.Schema[r], new bF(i, o, !0));
        if (s._rowCount !== 0) return s.matrix.value(0);
      }
    }
  }, e.hasData = function(a) {
    if (!Dn.is(a.sourceData)) return !1;
    var i = a.sourceData.data.frame.categories[r];
    return !!i && i.rowCount > 0;
  }, e.writeMmCif = function(a, i) {
    a.writeCategory({ name: r, instance: function() {
      var o = Yr.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: i }]);
      return Xa.Category.ofTable(o);
    } });
  };
}(X0 || (X0 = {})), ur.atom_site.label_comp_id, ur.atom_site.label_seq_id, ur.atom_site.pdbx_PDB_ins_code, ur.atom_site.label_asym_id, ur.atom_site.label_entity_id, ur.atom_site.auth_atom_id, ur.atom_site.auth_seq_id, ur.atom_site.auth_asym_id, k(k({}, ur.chem_comp_bond), { molstar_protonation_variant: pe.Schema.Str() });
var Dte = k(k({}, ur.chem_comp), { type: pe.Schema.Aliased(pe.Schema.str) });
function Mte(e, t) {
  var r = t.ihm_model_group, n = t.ihm_model_group_link, a = Yr.pickRow(n, function(o) {
    return n.model_id.value(o) === e;
  });
  if (a) {
    var i = Yr.pickRow(r, function(o) {
      return r.id.value(o) === a.group_id;
    });
    if (i) return i.name;
  }
  return "";
}
function cC(e) {
  for (var t = 0, r = e.rowCount; t < r; t++) if (e.valueKind(t) === 0) return !0;
  return !1;
}
function sg(e, t, r) {
  e[t].isDefined && cC(e[t]) || (e[t] = e[r]), e[r].isDefined && cC(e[r]) || (e[r] = e[t]);
}
var Dn, Go = { entry: ur.entry, struct: ur.struct, struct_asym: ur.struct_asym, ihm_model_list: ur.ihm_model_list, ihm_model_group: ur.ihm_model_group, ihm_model_group_link: ur.ihm_model_group_link, entity: ur.entity, entity_poly: ur.entity_poly, entity_poly_seq: ur.entity_poly_seq, pdbx_entity_branch: ur.pdbx_entity_branch, chem_comp: Dte, pdbx_chem_comp_identifier: ur.pdbx_chem_comp_identifier, atom_site: ur.atom_site, ihm_sphere_obj_site: ur.ihm_sphere_obj_site, ihm_gaussian_obj_site: ur.ihm_gaussian_obj_site, pdbx_unobs_or_zero_occ_residues: ur.pdbx_unobs_or_zero_occ_residues, pdbx_molecule: ur.pdbx_molecule };
function Zd(e, t) {
  t === void 0 && (t = !1);
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, a = Object.keys(Go); n < a.length; n++) {
    var i = a[n];
    r[i] = i in e ? e[i] : Yr.ofUndefinedColumns(Go[i], 0);
  }
  return t && (r.atom_site = function(o) {
    var s = Yr.ofColumns(o._schema, o);
    return sg(s, "label_atom_id", "auth_atom_id"), sg(s, "label_comp_id", "auth_comp_id"), sg(s, "label_seq_id", "auth_seq_id"), sg(s, "label_asym_id", "auth_asym_id"), s;
  }(r.atom_site)), r;
}
function oR(e) {
  var t = Dn.fromFrame(e), r = Zd(t.data.db, !0);
  return sr.create("Create mmCIF Model", function(n) {
    return bl(r, t, n);
  });
}
pi.Provider.formatRegistry.add("mmCIF", function(e) {
  if (Dn.is(e.sourceData)) return pi.fromData(e.sourceData.data.db);
}), ch.Provider.formatRegistry.add("mmCIF", function(e) {
  if (Dn.is(e.sourceData)) {
    var t = e.sourceData.data.db, r = t.struct_conf, n = t.struct_sheet_range;
    return ch.fromStruct(r, n, e.atomicHierarchy);
  }
}), Rd.Provider.formatRegistry.add("mmCIF", function(e) {
  if (Dn.is(e.sourceData)) {
    var t = e.sourceData.data.db.atom_site_anisotrop;
    return { data: Yr.ofColumns(Rd.Schema, t), elementToAnsiotrop: Rd.getElementToAnsiotrop(e.atomicConformation.atomId, t.id) };
  }
}, function(e) {
  return !!Dn.is(e.sourceData) && e.sourceData.data.db.atom_site_anisotrop.U.isDefined;
}), uh.Provider.formatRegistry.add("mmCIF", function(e) {
  if (Dn.is(e.sourceData)) {
    var t = e.sourceData.data.db.chem_comp_bond;
    if (t._rowCount !== 0) return { data: t, entries: uh.getEntriesFromChemCompBond(t) };
  }
}), oc.Provider.formatRegistry.add("mmCIF", function(e) {
  if (Dn.is(e.sourceData)) {
    var t = e.sourceData.data.db.struct_conn;
    if (t._rowCount !== 0) {
      var r = oc.getEntriesFromStructConn(t, e);
      return { data: t, byAtomIndex: oc.getAtomIndexFromEntries(r), entries: r };
    }
  }
}), X0.Provider.formatRegistry.add("mmCIF", X0.fromMmCif, X0.hasData), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mmCIF";
  }, e.fromFrame = function(t, r, n) {
    return r || (r = aR.mmCIF(t)), { kind: "mmCIF", name: r._name, data: { db: r, frame: t, source: n } };
  };
}(Dn || (Dn = {}));
var Wt, Ite = 9, ug = -27.888, Tte = -0.5, lC = -9.9;
function Nte(e, t, r, n) {
  var a = D.distance(e, n), i = D.distance(t, n), o = D.distance(t, r), s = D.distance(e, r), u = ug / a - ug / i + (ug / o - ug / s);
  return u < lC ? lC : u;
}
function Pte(e, t, r) {
  for (var n = t.residueIndices, a = t.cIndices, i = t.hIndices, o = t.nIndices, s = t.oIndices, u = e.model.atomicHierarchy.index, c = e.conformation.invariantPosition, l = e.model.atomicHierarchy.derived.residue.traceElementIndex, d = n.length, f = [], m = [], h = [], p = D(), g = D(), v = D(), y = D(), _ = D(), S = D(), b = D(), x = 0, A = n.length; x < A; ++x) {
    var w = x, C = n[x], M = s[w], T = a[w], N = l[C];
    if (M !== -1 && T !== -1 && u.findAtomOnResidue(C, "OXT") === -1) {
      c(M, p), c(T, g), c(N, v);
      for (var I = r.find(v[0], v[1], v[2], Ite), P = I.indices, O = I.count, F = 0; F < O; ++F) {
        var R = P[F];
        if (R !== w && R - 1 !== w && R + 1 !== w) {
          var G = o[R];
          if (G !== -1) {
            c(G, y);
            var L = i[R];
            if (L === -1) {
              if (R === 0) continue;
              var q = R - 1, K = s[q], X = a[q];
              if (K === -1 || X === -1) continue;
              c(K, b), c(X, S), D.sub(_, S, b);
              var H = D.distance(b, S);
              D.scaleAndAdd(_, y, _, 1 / H);
            } else c(L, _);
            var W = Nte(p, g, y, _);
            W > Tte || (f[f.length] = w, m[m.length] = R, h[h.length] = W);
          }
        }
      }
    }
  }
  return function(ee, $, te, re) {
    for (var ie = new Ho.DirectedEdgeBuilder(ee, $, te), oe = new Float32Array(ie.slotCount), se = 0, he = ie.edgeCount; se < he; se++) ie.addNextEdge(), ie.assignProperty(oe, re[se]);
    return ie.createGraph({ energies: re });
  }(d, f, m, h);
}
(function(e) {
  e.is = Ti.has, e.create = Ti.create;
})(Wt || (Wt = {}));
var cg = function(e, t, r) {
  this.partner1 = Math.min(e, t), this.partner2 = Math.max(e, t), this.type = r;
};
function Bte(e, t) {
  if (t.type !== e.type || t.partner1 !== e.firstEnd + 1) return !1;
  if (t.type === 0) {
    if (t.partner2 === e.secondEnd + 1) return !0;
  } else if (t.partner2 === e.secondStart - 1) return !0;
  return !1;
}
function Ote(e, t) {
  return e.type === t.type && t.firstStart - e.firstEnd < 6 && e.firstStart < t.firstStart && t.nextLadder === 0 && (e.type === 0 ? dC(e, t) : dC(t, e));
}
function dC(e, t) {
  return t.secondStart - e.secondEnd > 0 && (t.secondStart - e.secondEnd < 6 && t.firstStart - e.firstEnd < 3 || t.secondStart - e.secondEnd < 3);
}
function fC(e) {
  return Wt.is(e, 8) || Wt.is(e, 1) || Wt.is(e, 16);
}
var Up, Fte = { oldDefinition: V.Boolean(!0, { description: "Whether to use the old DSSP convention for the annotation of turns and helices, causes them to be two residues shorter" }), oldOrdering: V.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" }) };
function sR(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x;
    return Te(this, function(A) {
      for (r = function(w) {
        for (var C = w.model.atomicHierarchy.index, M = w.proteinElements, T = w.residueIndex, N = M.length, I = new Uint32Array(N), P = new Int32Array(N), O = new Int32Array(N), F = new Int32Array(N), R = new Int32Array(N), G = 0; G < N; ++G) {
          var L = T[M[G]];
          I[G] = L, P[G] = C.findAtomOnResidue(L, "C"), O[G] = C.findAtomOnResidue(L, "H"), F[G] = C.findAtomOnResidue(L, "O"), R[G] = C.findAtomOnResidue(L, "N");
        }
        return { residueIndices: $e.ofSortedArray(I), cIndices: P, hIndices: O, oIndices: F, nIndices: R };
      }(e), n = r.residueIndices, a = function(w, C) {
        for (var M = w.model.atomicConformation, T = M.x, N = M.y, I = M.z, P = w.model.atomicHierarchy.derived.residue.traceElementIndex, O = new Uint32Array(C.length), F = 0, R = C.length; F < R; ++F) O[F] = P[C[F]];
        var G = { x: T, y: N, z: I, indices: $e.ofSortedArray(O) };
        return Jf(G, kp(G));
      }(e, n), i = Pte(e, r, a), o = n.length, s = new Uint32Array(o), u = function(w, C) {
        var M = C.cIndices, T = C.nIndices, N = C.residueIndices, I = w.conformation.position, P = w.model.atomicHierarchy.index, O = w.model.atomicHierarchy.derived.residue.traceElementIndex, F = N.length, R = function(oe, se) {
          return oe === -1 ? D.setNaN(se) : I(oe, se);
        }, G = D(), L = D(), q = D(), K = D(), X = D(), H = D(), W = D(), ee = D(), $ = D();
        if (F === 0) return { phi: new Float32Array(0), psi: new Float32Array(0) };
        var te = new Float32Array(F - 1), re = new Float32Array(F - 1);
        R(-1, G), R(-1, L), R(-1, q), R(M[0], K), R(O[N[0]], X), R(T[0], H), R(M[1], W), R(O[N[1]], ee), R(T[1], $);
        for (var ie = 0; ie < F - 1; ++ie) P.findAtomOnResidue(N[ie], "OXT") === -1 && (te[ie] = Bi(D.dihedralAngle(G, H, X, K)), re[ie] = Bi(D.dihedralAngle(H, X, K, $)), G = K, L = X, q = H, K = W, X = ee, H = $, R(M[ie + 1], W), R(O[N[ie + 1]], ee), R(T[ie + 1], $));
        return { phi: te, psi: re };
      }(e, r), c = [], l = [], d = t.oldDefinition ? kte : Ute, f = t.oldOrdering ? zte : Gte, function(w) {
        for (var C = w.proteinInfo, M = w.hbonds, T = w.flags, N = [1024, 2048, 4096, 128, 256, 512], I = 0; I < 3; I++) for (var P = 0, O = C.residueIndices.length - 1; P < O; ++P) if (M.getDirectedEdgeIndex(P, P + I + 3) !== -1) if (T[P] |= N[I + 3] | N[I], w.params.oldDefinition) for (var F = 1; F < I + 3; ++F) T[P + F] |= 64 | N[I + 3];
        else for (F = 0; F <= I + 3; ++F) T[P + F] |= 64 | N[I + 3];
      }(m = { params: t, getResidueFlag: d, getFlagName: f, unit: e, proteinInfo: r, flags: s, hbonds: i, torsionAngles: u, ladders: c, bridges: l }), function(w) {
        for (var C = w.proteinInfo, M = w.flags, T = C.residueIndices.length, N = [1024, 2048, 4096, 128, 256, 512], I = [0, 0, 0, 8, 1, 16], P = w.params.oldOrdering ? [4, 3, 5] : [3, 4, 5], O = 0; O < P.length; O++) for (var F = P[O], R = 1, G = T - F; R < G; R++) {
          var L = Wt.create(M[R]), q = Wt.create(M[R - 1]), K = Wt.create(M[R + 1]);
          if (w.params.oldOrdering) {
            if (F === 3 && (Wt.is(L, 1) || Wt.is(K, 1)) || F === 5 && (Wt.is(L, 1) || Wt.is(L, 8) || Wt.is(K, 1) || Wt.is(K, 8))) continue;
          } else if (F === 4 && (Wt.is(L, 8) || Wt.is(K, 8)) || F === 5 && (Wt.is(L, 1) || Wt.is(L, 8) || Wt.is(K, 1) || Wt.is(K, 8))) continue;
          if (Wt.is(L, N[F]) && Wt.is(L, N[F - 3]) && Wt.is(q, N[F]) && Wt.is(q, N[F - 3])) if (w.params.oldDefinition) for (var X = 0; X < F; X++) M[R + X] |= I[F];
          else for (X = -1; X <= F; X++) M[R + X] |= I[F];
        }
      }(m), function(w) {
        var C = w.unit, M = w.flags, T = w.proteinInfo, N = C.conformation.position, I = C.model.atomicHierarchy.derived.residue.traceElementIndex, P = T.residueIndices, O = T.nIndices, F = P.length, R = function(ae, ce) {
          return ae === -1 ? D.setNaN(ce) : N(ae, ce);
        }, G = D(), L = D(), q = D(), K = D(), X = D(), H = D(), W = D();
        e: for (var ee = 2; ee < F - 2; ee++) {
          for (var $ = 0; $ < 4; $++) {
            var te = ee + $ - 2;
            if (R(I[te], K), R(O[te + 1], X), D.squaredDistance(K, X) > 6.25) continue e;
          }
          var re = P[ee - 2], ie = P[ee], oe = P[ee + 2], se = I[re], he = I[ie], ge = I[oe];
          R(se, G), R(he, L), R(ge, q), D.sub(H, G, L), D.sub(W, L, q);
          var De = Bi(D.angle(H, W));
          De && De > 70 && (M[ee] |= 32);
        }
      }(m), function(w) {
        for (var C, M, T = w.proteinInfo, N = w.hbonds, I = w.flags, P = w.bridges, O = N.offset, F = N.b, R = 0, G = T.residueIndices.length; R < G; ++R) for (var L = O[R], q = O[R + 1]; L < q; L++) {
          var K = F[L];
          R > K || ((C = R + 1) !== (M = K) && N.getDirectedEdgeIndex(M, C + 1) !== -1 && (I[C] |= 2, I[M] |= 2, P[P.length] = new cg(C, M, 0)), (C = R) !== (M = K - 1) && N.getDirectedEdgeIndex(M - 1, C) !== -1 && (I[C] |= 2, I[M] |= 2, P[P.length] = new cg(M, C, 0)), (C = R) !== (M = K) && N.getDirectedEdgeIndex(M, C) !== -1 && (I[C] |= 2, I[M] |= 2, P[P.length] = new cg(M, C, 1)), (C = R + 1) !== (M = K - 1) && N.getDirectedEdgeIndex(M - 1, C + 1) !== -1 && (I[C] |= 2, I[M] |= 2, P[P.length] = new cg(M, C, 1)));
        }
        P.sort(function(X, H) {
          return X.partner1 > H.partner1 ? 1 : X.partner1 < H.partner1 ? -1 : 0;
        });
      }(m), function(w) {
        for (var C = w.bridges, M = w.ladders, T = 0; T < C.length; T++) {
          for (var N = C[T], I = !1, P = 0; P < M.length; P++) {
            var O = M[P];
            Bte(O, N) && (I = !0, O.firstEnd++, N.type === 0 ? O.secondEnd++ : O.secondStart--);
          }
          I || (M[M.length] = { previousLadder: 0, nextLadder: 0, firstStart: N.partner1, firstEnd: N.partner1, secondStart: N.partner2, secondEnd: N.partner2, type: N.type });
        }
        for (var F = 0; F < M.length; F++) for (var R = M[F], G = F; G < M.length; G++) {
          var L = M[G];
          Ote(R, L) && (R.nextLadder = G, L.previousLadder = F);
        }
      }(m), function(w) {
        for (var C = w.ladders, M = w.flags, T = 0; T < C.length; T++) {
          for (var N = C[T], I = N.firstStart; I <= N.firstEnd; I++) {
            var P = N.firstStart - I, O = N.secondStart - P;
            N.firstStart !== N.firstEnd ? (M[I] |= 4, M[O] |= 4) : (!fC(M[I]) && Wt.is(M[I], 4) && (M[I] |= 2), !fC(M[O]) && Wt.is(M[O], 4) && (M[O] |= 2));
          }
          if (N.nextLadder !== 0) {
            var F = C[N.nextLadder];
            for (I = N.firstStart; I <= F.firstEnd; I++) M[I] |= 4;
            if (N.type === 0) for (I = N.secondStart; I <= F.secondEnd; I++) M[I] |= 4;
            else for (I = F.secondEnd; I <= N.secondStart; I++) M[I] |= 4;
          }
        }
      }(m), h = function(w, C) {
        for (var M = new Uint32Array(w.length), T = 0, N = w.length; T < N; ++T) {
          var I = Wt.create(w[T]);
          M[T] = C(I);
        }
        return M;
      }(s, d), p = new Uint32Array(o), g = [], v = [], y = function(w) {
        return $e.indexOf(n, w);
      }, _ = 0, S = n.length; _ < S; ++_) b = h[_], p[_] = b, x = d(s[_]), v.length !== 0 && x === v[v.length - 1].flags || (v[v.length] = Rte(Lte(b), s[_], d)), g[_] = v.length - 1;
      return [2, iR(p, g, v, y)];
    });
  });
}
function Rte(e, t, r) {
  return e === "helix" ? { kind: "helix", flags: r(t) } : e === "sheet" ? { kind: "sheet", flags: r(t) } : e === "turn" || e === "bend" ? { kind: "turn", flags: r(t) } : { kind: "none" };
}
function Lte(e) {
  return e === Er.SecondaryStructureDssp.H || e === Er.SecondaryStructureDssp.G || e === Er.SecondaryStructureDssp.I ? "helix" : e === Er.SecondaryStructureDssp.B || e === Er.SecondaryStructureDssp.E ? "sheet" : e === Er.SecondaryStructureDssp.T ? "turn" : e === Er.SecondaryStructureDssp.S ? "bend" : "none";
}
function kte(e) {
  return Wt.is(e, 1) ? Er.SecondaryStructureDssp.H : Wt.is(e, 4) ? Er.SecondaryStructureDssp.E : Wt.is(e, 2) ? Er.SecondaryStructureDssp.B : Wt.is(e, 8) ? Er.SecondaryStructureDssp.G : Wt.is(e, 16) ? Er.SecondaryStructureDssp.I : Wt.is(e, 64) ? Er.SecondaryStructureDssp.T : Wt.is(e, 32) ? Er.SecondaryStructureDssp.S : 0;
}
function zte(e) {
  return Wt.is(e, 1) ? "H" : Wt.is(e, 4) ? "E" : Wt.is(e, 2) ? "B" : Wt.is(e, 8) ? "G" : Wt.is(e, 16) ? "I" : Wt.is(e, 64) ? "T" : Wt.is(e, 32) ? "S" : "-";
}
function Ute(e) {
  return Wt.is(e, 16) ? Er.SecondaryStructureDssp.I : Wt.is(e, 1) ? Er.SecondaryStructureDssp.H : Wt.is(e, 4) ? Er.SecondaryStructureDssp.E : Wt.is(e, 2) ? Er.SecondaryStructureDssp.B : Wt.is(e, 8) ? Er.SecondaryStructureDssp.G : Wt.is(e, 64) ? Er.SecondaryStructureDssp.T : Wt.is(e, 32) ? Er.SecondaryStructureDssp.S : 0;
}
function Gte(e) {
  return Wt.is(e, 16) ? "I" : Wt.is(e, 1) ? "H" : Wt.is(e, 4) ? "E" : Wt.is(e, 2) ? "B" : Wt.is(e, 8) ? "G" : Wt.is(e, 64) ? "T" : Wt.is(e, 32) ? "S" : "-";
}
function uR(e) {
  var t = "model";
  if (e) {
    t = "model";
    for (var r = 0, n = e.models.length; r < n; ++r) {
      var a = e.models[r];
      if (!yn.isFromPdbArchive(a) && !yn.hasSecondaryStructure(a)) {
        t = "dssp";
        break;
      }
    }
  }
  return { type: V.MappedStatic(t, { model: V.EmptyGroup({ label: "Model" }), dssp: V.Group(Fte, { label: "DSSP", isFlat: !0 }) }, { options: [["model", "Model"], ["dssp", "DSSP"]] }) };
}
(function(e) {
  function t(r) {
    var n = this, a = r.descriptor.name, i = r.type === "root" ? "inheritedPropertyData" : "currentPropertyData", o = function(u) {
      return a in u[i] || (u[i][a] = { props: k({}, V.getDefaultValues(r.getParams(u))), data: _d.create(void 0) }), u[i][a];
    }, s = function(u, c, l) {
      var d = o(u);
      u[i][a] = { props: c, data: _d.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(u) {
      var c = V.clone(r.getParams(u));
      return V.setDefaultValues(c, o(u).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), Be(n, 0, void 0, function() {
        var f, m, h, p, g, v;
        return Te(this, function(y) {
          switch (y.label) {
            case 0:
              return d && c.customPropertyDescriptors.reference(r.descriptor, !0), r.type === "root" && (c = c.root), f = o(c.root).props, m = o(c), h = V.merge(r.defaultParams, f, l), m.data.value && V.areEqual(r.defaultParams, m.props, h) ? [2] : [4, r.obtain(u, c, h)];
            case 1:
              return p = y.sent(), g = p.value, v = p.assets, c.customPropertyDescriptors.add(r.descriptor), c.customPropertyDescriptors.assets(r.descriptor, v), s(c, h, g), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customPropertyDescriptors.reference(r.descriptor, c);
    }, get: function(u) {
      return o(u).data;
    }, set: function(u, c, l) {
      c === void 0 && (c = {}), r.type === "root" && (u = u.root);
      var d = o(u), f = V.merge(r.defaultParams, d.props, c);
      V.areEqual(r.defaultParams, d.props, f) || (s(u, f, l), u.customPropertyDescriptors.assets(r.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(r, n, a) {
    var i = this, o = { value: V.Value(a, { isHidden: !0 }) };
    return t({ label: ac(r), descriptor: Tu({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: V.Value(a, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return Be(i, 0, void 0, function() {
        return Te(this, function(l) {
          return [2, k(k({}, V.getDefaultValues(o)), c)];
        });
      });
    } });
  };
})(Up || (Up = {}));
var mC = uR(), Oi = Up.createProvider({ label: "Secondary Structure", descriptor: Tu({ name: "molstar_computed_secondary_structure" }), type: "root", defaultParams: mC, getParams: uR, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, r) {
  return Be(void 0, 0, void 0, function() {
    var n, a, i;
    return Te(this, function(o) {
      switch (o.label) {
        case 0:
          switch (n = k(k({}, V.getDefaultValues(mC)), r), n.type.name) {
            case "dssp":
              return [3, 1];
            case "model":
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return a = {}, [4, Vte(t, n.type.params)];
        case 2:
          return [2, (a.value = o.sent(), a)];
        case 3:
          return i = {}, [4, qte(t)];
        case 4:
          return [2, (i.value = o.sent(), i)];
        case 5:
          return [2];
      }
    });
  });
} });
function Vte(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          r = /* @__PURE__ */ new Map(), n = 0, a = e.unitSymmetryGroups.length, s.label = 1;
        case 1:
          return n < a ? (i = e.unitSymmetryGroups[n].units[0], !Ke.isAtomic(i) || yn.isCoarseGrained(i.model) ? [3, 3] : [4, sR(i, t)]) : [3, 4];
        case 2:
          o = s.sent(), r.set(i.invariantId, o), s.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, r];
      }
    });
  });
}
function qte(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i;
    return Te(this, function(o) {
      switch (o.label) {
        case 0:
          t = /* @__PURE__ */ new Map(), r = 0, n = e.unitSymmetryGroups.length, o.label = 1;
        case 1:
          return r < n ? (a = e.unitSymmetryGroups[r].units[0], Ke.isAtomic(a) ? yn.isFromPdbArchive(a.model) || yn.hasSecondaryStructure(a.model) ? [3, 3] : [4, sR(a, { oldDefinition: !0, oldOrdering: !0 })] : [3, 4]) : [3, 5];
        case 2:
          return i = o.sent(), t.set(a.invariantId, i), [3, 4];
        case 3:
          (i = ch.Provider.get(a.model)) && t.set(a.invariantId, i), o.label = 4;
        case 4:
          return ++r, [3, 1];
        case 5:
          return [2, t];
      }
    });
  });
}
function Bn() {
  throw new Error("Property only available for atomic models.");
}
function Nc(e) {
  throw e ? new Error("Property only available for coarse models (".concat(e, ").")) : new Error("Property only available for coarse models.");
}
var T0 = { key: function(e) {
  return e.element;
}, x: function(e) {
  return e.unit.conformation.x(e.element);
}, y: function(e) {
  return e.unit.conformation.y(e.element);
}, z: function(e) {
  return e.unit.conformation.z(e.element);
}, id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicConformation.atomId.value(e.element) : Bn();
}, occupancy: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicConformation.occupancy.value(e.element) : Bn();
}, B_iso_or_equiv: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicConformation.B_iso_or_equiv.value(e.element) : Bn();
}, sourceIndex: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atomSourceIndex.value(e.element) : e.element;
}, type_symbol: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element) : Bn();
}, label_atom_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_atom_id.value(e.element) : Bn();
}, auth_atom_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_atom_id.value(e.element) : Bn();
}, label_alt_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_alt_id.value(e.element) : Bn();
}, label_comp_id: D8, auth_comp_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_comp_id.value(e.element) : Bn();
}, pdbx_formal_charge: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.element) : Bn();
}, vdw_radius: function(e) {
  return Ke.isAtomic(e.unit) ? m3(e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element)) : Bn();
}, cdr: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.cdr.value(e.element) : Bn();
}, em_confidence: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.em_confidence.value(e.element) : Bn();
} };
function D8(e) {
  return Ke.isAtomic(e.unit) || Bn(), e.unit.model.atomicHierarchy.atoms.label_comp_id.value(e.element);
}
function A6(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.label_seq_id.value(e.unit.residueIndex[e.element]) : Bn();
}
function pC(e) {
  Ke.isAtomic(e.unit) || Bn();
  var t = e.unit.model.sequence.byEntityKey[co(e)];
  return t && t.sequence.microHet.get(A6(e)) || [D8(e)];
}
var Hte = { key: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.residueIndex[e.element] : Bn();
}, group_PDB: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.group_PDB.value(e.unit.residueIndex[e.element]) : Bn();
}, label_seq_id: A6, auth_seq_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.auth_seq_id.value(e.unit.residueIndex[e.element]) : Bn();
}, pdbx_PDB_ins_code: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.unit.residueIndex[e.element]) : Bn();
}, isNonStandard: function(e) {
  return Ke.isAtomic(e.unit) ? pC(e).some(function(t) {
    return e.unit.model.properties.chemicalComponentMap.get(t).mon_nstd_flag[0] === "n";
  }) : Bn();
}, hasMicroheterogeneity: function(e) {
  Ke.isAtomic(e.unit) || Bn();
  var t = e.unit.model.sequence.byEntityKey[co(e)];
  return t && t.sequence.microHet.has(A6(e));
}, microheterogeneityCompIds: pC, secondary_structure_type: function(e) {
  var t;
  Ke.isAtomic(e.unit) || Bn();
  var r = (t = Oi.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return r ? r.type[r.getIndex(e.unit.residueIndex[e.element])] : 536870912;
}, secondary_structure_key: function(e) {
  var t;
  Ke.isAtomic(e.unit) || Bn();
  var r = (t = Oi.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return r ? r.key[r.getIndex(e.unit.residueIndex[e.element])] : -1;
}, chem_comp_type: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.properties.chemicalComponentMap.get(D8(e)).type : Bn();
} }, Kte = { key: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.chainIndex[e.element] : Bn();
}, label_asym_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_asym_id.value(e.unit.chainIndex[e.element]) : Bn();
}, auth_asym_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.auth_asym_id.value(e.unit.chainIndex[e.element]) : Bn();
}, label_entity_id: function(e) {
  return Ke.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_entity_id.value(e.unit.chainIndex[e.element]) : Bn();
} }, Xte = { key: T0.key, entityKey: function(e) {
  return Ke.isCoarse(e.unit) ? e.unit.coarseElements.entityKey[e.element] : Nc();
}, x: T0.x, y: T0.y, z: T0.z, asym_id: function(e) {
  return Ke.isCoarse(e.unit) ? e.unit.coarseElements.asym_id.value(e.element) : Nc();
}, entity_id: function(e) {
  return Ke.isCoarse(e.unit) ? e.unit.coarseElements.entity_id.value(e.element) : Nc();
}, seq_id_begin: function(e) {
  return Ke.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_begin.value(e.element) : Nc();
}, seq_id_end: function(e) {
  return Ke.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_end.value(e.element) : Nc();
}, sphere_radius: function(e) {
  return Ke.isSpheres(e.unit) ? e.unit.coarseConformation.radius[e.element] : Nc("spheres");
}, sphere_rmsf: function(e) {
  return Ke.isSpheres(e.unit) ? e.unit.coarseConformation.rmsf[e.element] : Nc("spheres");
}, gaussian_weight: function(e) {
  return Ke.isGaussians(e.unit) ? e.unit.coarseConformation.weight[e.element] : Nc("gaussians");
}, gaussian_covariance_matrix: function(e) {
  return Ke.isGaussians(e.unit) ? e.unit.coarseConformation.covariance_matrix[e.element] : Nc("gaussians");
} };
function co(e) {
  switch (e.unit.kind) {
    case 0:
      return e.unit.model.atomicHierarchy.index.getEntityFromChain(e.unit.chainIndex[e.element]);
    case 1:
      return e.unit.model.coarseHierarchy.spheres.entityKey[e.element];
    case 2:
      return e.unit.model.coarseHierarchy.gaussians.entityKey[e.element];
  }
}
var jte = { key: co, id: function(e) {
  return e.unit.model.entities.data.id.value(co(e));
}, type: function(e) {
  return e.unit.model.entities.data.type.value(co(e));
}, src_method: function(e) {
  return e.unit.model.entities.data.src_method.value(co(e));
}, pdbx_description: function(e) {
  return e.unit.model.entities.data.pdbx_description.value(co(e));
}, formula_weight: function(e) {
  return e.unit.model.entities.data.formula_weight.value(co(e));
}, pdbx_number_of_molecules: function(e) {
  return e.unit.model.entities.data.pdbx_number_of_molecules.value(co(e));
}, details: function(e) {
  return e.unit.model.entities.data.details.value(co(e));
}, pdbx_mutation: function(e) {
  return e.unit.model.entities.data.pdbx_mutation.value(co(e));
}, pdbx_fragment: function(e) {
  return e.unit.model.entities.data.pdbx_fragment.value(co(e));
}, pdbx_ec: function(e) {
  return e.unit.model.entities.data.pdbx_ec.value(co(e));
}, subtype: function(e) {
  return e.unit.model.entities.subtype.value(co(e));
}, prd_id: function(e) {
  var t, r;
  return (r = (t = e.unit.model.entities.prd_id) === null || t === void 0 ? void 0 : t.value(co(e))) !== null && r !== void 0 ? r : "";
} }, Yte = [], Wte = { id: function(e) {
  return e.unit.id;
}, chainGroupId: function(e) {
  return e.unit.chainGroupId;
}, multiChain: function(e) {
  return Ke.Traits.is(e.unit.traits, 1);
}, object_primitive: function(e) {
  return e.unit.objectPrimitive;
}, operator_name: function(e) {
  return e.unit.conformation.operator.name;
}, model_index: function(e) {
  return e.unit.model.modelNum;
}, model_label: function(e) {
  return e.unit.model.label;
}, model_entry_id: function(e) {
  return e.unit.model.entryId;
}, hkl: function(e) {
  return e.unit.conformation.operator.hkl;
}, spgrOp: function(e) {
  return e.unit.conformation.operator.spgrOp;
}, model_num: function(e) {
  return e.unit.model.modelNum;
}, pdbx_struct_assembly_id: function(e) {
  var t;
  return ((t = e.unit.conformation.operator.assembly) === null || t === void 0 ? void 0 : t.id) || Mn.DefaultName;
}, pdbx_struct_oper_list_ids: function(e) {
  var t;
  return ((t = e.unit.conformation.operator.assembly) === null || t === void 0 ? void 0 : t.operList) || Yte;
}, struct_ncs_oper_id: function(e) {
  return e.unit.conformation.operator.ncsId;
} }, at = { constant: { true: function(e) {
  return !0;
}, false: function(e) {
  return !1;
}, zero: function(e) {
  return 0;
} }, atom: T0, residue: Hte, chain: Kte, entity: jte, unit: Wte, coarse: Xte }, j0 = function() {
  function e(t) {
    var r;
    this.index = /* @__PURE__ */ new Map(), this.checkOperator = !1, this.checkOperator = (r = t == null ? void 0 : t.checkOperator) !== null && r !== void 0 && r;
  }
  return e.prototype.add = function(t) {
    var r = this.index.get(t.label_asym_id);
    r || (r = /* @__PURE__ */ new Map(), this.index.set(t.label_asym_id, r));
    var n = r.get(t.label_seq_id);
    return n || (n = [], r.set(t.label_seq_id, n)), !this._find(t, n) && (n.push(t), !0);
  }, e.prototype.hasLabelAsymId = function(t) {
    return this.index.has(t);
  }, e.prototype.has = function(t) {
    var r, n, a = hC(t);
    if (this.index.has(a)) {
      var i = this.index.get(a), o = vC(t);
      if (i.has(o)) for (var s = i.get(o), u = gC(t), c = yC(t), l = bC(t), d = (r = xC(t)) !== null && r !== void 0 ? r : "1_555", f = 0, m = s; f < m.length; f++) {
        var h = m[f];
        if (h.label_comp_id === u && h.label_alt_id === c && h.ins_code === l && (!this.checkOperator || ((n = h.operator_name) !== null && n !== void 0 ? n : "1_555") === d)) return h;
      }
    }
  }, e.getLabel = function(t, r) {
    var n;
    return r === void 0 && (r = !1), "".concat(t.label_asym_id, " ").concat(t.label_comp_id, " ").concat(t.label_seq_id, ":").concat(t.ins_code, ":").concat(t.label_alt_id).concat(r ? " " + ((n = t.operator_name) !== null && n !== void 0 ? n : "1_555") : "");
  }, e.getEntryFromLocation = function(t) {
    var r;
    return { label_asym_id: hC(t), label_comp_id: gC(t), label_seq_id: vC(t), label_alt_id: yC(t), ins_code: bC(t), operator_name: (r = xC(t)) !== null && r !== void 0 ? r : "1_555" };
  }, e.prototype._find = function(t, r) {
    for (var n, a, i = 0, o = r; i < o.length; i++) {
      var s = o[i];
      if (s.label_comp_id === t.label_comp_id && s.label_alt_id === t.label_alt_id && s.ins_code === t.ins_code && (!this.checkOperator || ((n = s.operator_name) !== null && n !== void 0 ? n : "1_555") === ((a = t.operator_name) !== null && a !== void 0 ? a : "1_555"))) return !0;
    }
    return !1;
  }, e;
}(), hC = at.chain.label_asym_id, vC = at.residue.label_seq_id, gC = at.atom.label_comp_id, yC = at.atom.label_alt_id, bC = at.residue.pdbx_PDB_ins_code, xC = at.unit.operator_name;
function Ep(e, t, r) {
  for (var n = t.subsetBuilder(!0), a = 0, i = r.units; a < i.length; a++) {
    var o = i[a];
    if (o.kind === 0) {
      var s = o.model.atomicHierarchy.residueAtomSegments, u = t.unitMap.get(o.id).elements, c = o.elements;
      n.beginUnit(o.id);
      for (var l = nr.transientSegments(s, c); l.hasNext; ) for (var d = l.move().index, f = s.offsets[d], m = s.offsets[d + 1]; f < m; f++) $e.has(u, f) && n.addElement(f);
      n.commitUnit(), e.throwIfTimedOut();
    } else n.setUnit(o.id, o.elements);
  }
  return n.getStructure();
}
function q4(e, t, r, n) {
  for (var a = new l3(t), i = t.lookup3d, o = n.radius, s = 0, u = r.units; s < u.length; s++) {
    for (var c = u[s], l = c.conformation, d = l.x, f = l.y, m = l.z, h = c.elements, p = 0, g = h.length; p < g; p++) {
      var v = h[p];
      i.findIntoBuilder(d(v), f(v), m(v), o, a);
    }
    e.throwIfTimedOut();
  }
  return n.wholeResidues ? Ep(e, t, a.getStructure()) : a.getStructure();
}
function _C(e, t, r, n) {
  var a = new l3(t), i = t.lookup3d, o = n.elementRadius, s = n.elementRadiusClosure, u = n.sourceMaxRadius, c = n.radius;
  e.pushCurrentElement(), e.element.structure = r;
  for (var l = 0, d = r.units; l < d.length; l++) {
    var f = d[l];
    e.element.unit = f;
    for (var m = f.conformation, h = m.x, p = m.y, g = m.z, v = f.elements, y = 0, _ = v.length; y < _; y++) {
      var S = v[y];
      e.element.element = S;
      var b = o(e);
      i.findIntoBuilderWithRadius(h(S), p(S), g(S), b, u, c, s, a);
    }
    e.throwIfTimedOut();
  }
  return e.popCurrentElement(), n.wholeResidues ? Ep(e, t, a.getStructure()) : a.getStructure();
}
function Zte(e, t) {
  return function(r) {
    return e.element.structure = r.structure, e.element.unit = r.unit, e.element.element = r.element, t(e);
  };
}
function Qte(e, t) {
  var r = 0;
  e.element.structure = e.inputStructure;
  for (var n = 0, a = e.inputStructure.units; n < a.length; n++) {
    var i = a[n];
    e.element.unit = i;
    for (var o = i.elements, s = 0, u = o.length; s < u; s++) {
      var c = o[s];
      e.element.element = c;
      var l = t(e);
      l > r && (r = l);
    }
  }
  return e.throwIfTimedOut(), r;
}
function SC(e, t, r) {
  var n = function(a, i) {
    for (var o = a.inputStructure, s = o.interUnitBonds, u = new l3(o), c = a.atomicBond, l = 0, d = i.units; l < d.length; l++) {
      var f = d[l];
      if (f.kind === 0) {
        var m = o.unitMap.get(f.id), h = m.bonds, p = h.offset, g = h.b, v = h.edgeProps, y = v.flags, _ = v.order;
        for (c.setStructure(o), c.a.unit = m, c.b.unit = m, q = 0, K = f.elements.length; q < K; q++) {
          u.addToUnit(f.id, f.elements[q]);
          for (var S = $e.indexOf(m.elements, f.elements[q]), b = p[S], x = p[S + 1]; b < x; b++) {
            var A = g[b], w = m.elements[A];
            $e.has(f.elements, w) || u.has(f.id, w) || (c.aIndex = S, c.a.element = f.elements[q], c.bIndex = A, c.b.element = w, c.type = y[b], c.order = _[b], c.test(a, !0) && u.addToUnit(f.id, w));
          }
        }
        for (var C = 0, M = s.getConnectedUnits(m.id); C < M.length; C++) for (var T = M[C], N = i.unitMap.get(T.unitB), I = o.unitMap.get(T.unitB), P = 0, O = T.connectedIndices; P < O.length; P++) {
          var F = O[P];
          if ($e.has(f.elements, m.elements[F])) for (var R = 0, G = T.getEdges(F); R < G.length; R++) {
            var L = G[R];
            w = I.elements[L.indexB], N && $e.has(N.elements, w) || u.has(T.unitB, w) || (c.a.unit = m, c.aIndex = F, c.a.element = m.elements[F], c.b.unit = I, c.bIndex = L.indexB, c.b.element = w, c.type = L.props.flag, c.order = L.props.order, c.test(a, !0) && u.addToUnit(T.unitB, w));
          }
        }
      } else {
        u.beginUnit(f.id);
        for (var q = 0, K = f.elements.length; q < K; q++) u.addElement(f.elements[q]);
        u.commitUnit();
      }
    }
    return u.getStructure();
  }(e, r);
  return t ? Ep(e, e.inputStructure, n) : n;
}
var $te = at.entity.type;
function Jte(e) {
  return $te(e) === "water";
}
var sy, uy, ere = function() {
  function e() {
    this.vertices = /* @__PURE__ */ new Map(), this.edges = /* @__PURE__ */ new Map();
  }
  return e.prototype.addVertex = function(t, r) {
    this.vertices.has(r) || (this.vertices.set(r, t), this.edges.set(r, []));
  }, e.prototype.addEdge = function(t, r) {
    var n = j0.getLabel(t), a = j0.getLabel(r);
    this.addVertex(t, n), this.addVertex(r, a), js(this.edges.get(n), a), js(this.edges.get(a), n);
  }, e.prototype.addComponent = function(t, r) {
    var n = j0.getLabel(t);
    if (this.vertices.has(n)) {
      var a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = [n];
      for (i.add(n), r.add(t); o.length > 0; ) {
        var s = o.pop();
        a.add(s);
        for (var u = this.vertices.get(s), c = 0, l = this.edges.get(s); c < l.length; c++) {
          var d = l[c];
          if (!a.has(d) && (o.push(d), !i.has(d))) {
            i.add(d);
            var f = this.vertices.get(d);
            u.operator_name === f.operator_name ? r.add(k(k({}, f), { operator_name: t.operator_name })) : r.add(f);
          }
        }
      }
    } else r.add(t);
  }, e;
}(), tre = Object.freeze({ __proto__: null, exceptBy: function(e, t) {
  return function(r) {
    var n = e(r);
    if (St.structureCount(n) === 0) return n;
    var a = t(r);
    if (St.structureCount(a) === 0) return n;
    var i = St.unionStructure(a), o = St.UniqueBuilder(r.inputStructure);
    return St.forEach(n, function(s, u) {
      var c = ZF(s, i);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, expandProperty: function(e, t) {
  return function(r) {
    var n = e(r), a = /* @__PURE__ */ new Map(), i = [];
    r.pushCurrentElement(), St.forEach(n, function(S, b) {
      r.element.structure = S;
      for (var x = 0, A = S.units; x < A.length; x++) {
        var w = A[x];
        r.element.unit = w;
        for (var C = w.elements, M = 0, T = C.length; M < T; M++) {
          r.element.element = C[M];
          var N = t(r), I = void 0;
          a.has(N) ? I = a.get(N) : (I = Sn.create(), a.set(N, I)), Sn.add(I, b, b);
        }
      }
      i[b] = r.inputStructure.subsetBuilder(!0), b % 10 == 0 && r.throwIfTimedOut();
    }), r.element.structure = r.inputStructure;
    for (var o = 0, s = r.inputStructure.units; o < s.length; o++) {
      var u = s[o];
      r.element.unit = u;
      for (var c = u.elements, l = 0, d = c.length; l < d; l++) {
        r.element.element = c[l];
        var f = t(r);
        if (a.has(f)) for (var m = a.get(f).array, h = 0, p = m.length; h < p; h++) i[m[h]].addToUnit(u.id, c[l]);
      }
    }
    r.popCurrentElement();
    for (var g = St.UniqueBuilder(r.inputStructure), v = 0, y = i; v < y.length; v++) {
      var _ = y[v];
      g.add(_.getStructure());
    }
    return g.getSelection();
  };
}, includeConnected: function(e) {
  var t = e.query, r = e.layerCount, n = e.wholeResidues, a = e.bondTest, i = e.fixedPoint, o = Math.max(r, 0);
  return function(s) {
    var u = St.UniqueBuilder(s.inputStructure), c = t(s);
    return s.pushCurrentBond(), s.atomicBond.setTestFn(a), St.forEach(c, function(l, d) {
      var f = l;
      if (i) for (; ; ) {
        var m = f.elementCount;
        if ((f = SC(s, n, f)).elementCount === m) break;
      }
      else for (var h = 0; h < o; h++) f = SC(s, n, f);
      u.add(f), d % 10 == 0 && s.throwIfTimedOut();
    }), s.popCurrentBond(), u.getSelection();
  };
}, includeSurroundings: function(e, t) {
  return function(r) {
    var n = e(r);
    if (t.elementRadius) {
      var a = k(k({}, t), { elementRadius: t.elementRadius, elementRadiusClosure: Zte(r, t.elementRadius), sourceMaxRadius: Qte(r, t.elementRadius) });
      if (St.isSingleton(n)) {
        var i = _C(r, r.inputStructure, n.structure, a);
        return St.Singletons(r.inputStructure, i);
      }
      for (var o = new R4(r.inputStructure), s = 0, u = n.structures; s < u.length; s++) {
        var c = u[s];
        o.add(_C(r, r.inputStructure, c, a));
      }
      return o.getSelection();
    }
    if (St.isSingleton(n))
      return i = q4(r, r.inputStructure, n.structure, t), St.Singletons(r.inputStructure, i);
    o = new R4(r.inputStructure);
    for (var l = 0, d = n.structures; l < d.length; l++)
      c = d[l], o.add(q4(r, r.inputStructure, c, t));
    return o.getSelection();
  };
}, intersectBy: function(e, t) {
  return function(r) {
    var n = e(r);
    if (St.structureCount(n) === 0) return n;
    var a = t(r);
    if (St.structureCount(a) === 0) return St.Empty(r.inputStructure);
    var i = St.unionStructure(a), o = St.UniqueBuilder(r.inputStructure);
    return St.forEach(n, function(s, u) {
      var c = function(l, d) {
        if (l === d) return l;
        if (!E8(l, d)) return st.Empty;
        var f, m;
        l.units.length < d.units.length ? (f = l, m = d) : (f = d, m = l);
        for (var h = f.units, p = m.unitMap, g = [], v = 0, y = h.length; v < y; v++) {
          var _ = h[v];
          if (p.has(_.id)) {
            var S = p.get(_.id);
            if ($e.areIntersecting(_.elements, S.elements)) {
              var b = $e.intersect(_.elements, S.elements);
              g[g.length] = _.getChild(b);
            }
          }
        }
        return st.create(g, { parent: l.parent || d.parent });
      }(i, s);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, querySelection: function(e, t) {
  return function(r) {
    var n = e(r);
    if (St.structureCount(n) === 0) return n;
    var a = St.UniqueBuilder(r.inputStructure), i = function(o) {
      return a.add(o);
    };
    return St.forEach(n, function(o, s) {
      r.pushInputStructure(o), St.forEach(t(r), i), r.popInputStructure(), s % 10 == 0 && r.throwIfTimedOut();
    }), a.getSelection();
  };
}, surroundingLigands: function(e) {
  var t = e.query, r = e.radius, n = e.includeWater;
  return function(a) {
    for (var i = St.unionStructure(t(a)), o = Ep(a, a.inputStructure, q4(a, a.inputStructure, i, { radius: r })), s = function(X) {
      var H = X.models[0], W = /* @__PURE__ */ new Set();
      if (!Dn.is(H.sourceData)) return W;
      for (var ee = H.sourceData.data.db.pdbx_molecule, $ = ee._rowCount, te = ee.asym_id, re = 0; re < $; re++) W.add(te.value(re));
      return W;
    }(a.inputStructure), u = function(X) {
      var H, W, ee = X.models[0], $ = new ere();
      if (!Dn.is(ee.sourceData)) return $;
      for (var te = ee.sourceData.data.db.struct_conn, re = te.conn_type_id, ie = te.ptnr1_label_asym_id, oe = te.ptnr1_label_comp_id, se = te.ptnr1_label_seq_id, he = te.ptnr1_symmetry, ge = te.pdbx_ptnr1_label_alt_id, De = te.pdbx_ptnr1_PDB_ins_code, ae = te.ptnr2_label_asym_id, ce = te.ptnr2_label_comp_id, _e = te.ptnr2_label_seq_id, le = te.ptnr2_symmetry, ue = te.pdbx_ptnr2_label_alt_id, be = te.pdbx_ptnr2_PDB_ins_code, Se = 0; Se < te._rowCount; Se++) {
        var Ne = re.value(Se);
        if (Ne === "covale" || Ne === "metalc") {
          var J = { label_asym_id: ie.value(Se), label_comp_id: oe.value(Se), label_seq_id: se.value(Se), label_alt_id: ge.value(Se), ins_code: De.value(Se), operator_name: (H = he.value(Se)) !== null && H !== void 0 ? H : "1_555" }, Z = { label_asym_id: ae.value(Se), label_comp_id: ce.value(Se), label_seq_id: _e.value(Se), label_alt_id: ue.value(Se), ins_code: be.value(Se), operator_name: (W = le.value(Se)) !== null && W !== void 0 ? W : "1_555" };
          $.addEdge(J, Z);
        }
      }
      return $;
    }(a.inputStructure), c = lt.create(o), l = /* @__PURE__ */ new Map(), d = new j0({ checkOperator: !0 }), f = 0, m = o.units; f < m.length; f++)
      if ((P = m[f]).kind === 0) {
        c.unit = P;
        for (var h = P.elements, p = nr.transientSegments(P.model.atomicHierarchy.chainAtomSegments, h), g = nr.transientSegments(P.model.atomicHierarchy.residueAtomSegments, h); p.hasNext; ) {
          var v = p.move();
          c.element = h[v.start];
          var y = at.chain.label_asym_id(c), _ = at.unit.operator_name(c);
          if (s.has(y)) l.has(y) ? js(l.get(y), _) : l.set(y, [_]);
          else {
            var S = at.entity.type(c);
            if (S !== "water" && S !== "polymer") for (g.setSegment(v); g.hasNext; ) {
              var b = g.move();
              c.element = h[b.start], u.addComponent(j0.getEntryFromLocation(c), d);
            }
          }
        }
        a.throwIfTimedOut();
      }
    for (var x = a.inputStructure.subsetBuilder(!0), A = 0, w = a.inputStructure.units; A < w.length; A++)
      if ((P = w[A]).kind === 0) {
        for (c.unit = P, h = P.elements, p = nr.transientSegments(P.model.atomicHierarchy.chainAtomSegments, h), g = nr.transientSegments(P.model.atomicHierarchy.residueAtomSegments, h), x.beginUnit(P.id); p.hasNext; )
          if (v = p.move(), c.element = h[v.start], y = at.chain.label_asym_id(c), _ = at.unit.operator_name(c), l.has(y) && l.get(y).indexOf(_) >= 0) x.addElementRange(h, v.start, v.end);
          else if (d.hasLabelAsymId(y)) for (g.setSegment(v); g.hasNext; )
            b = g.move(), c.element = h[b.start], d.has(c) && x.addElementRange(h, b.start, b.end);
        x.commitUnit(), a.throwIfTimedOut();
      }
    var C = iy(a.inputStructure, [x.getStructure(), i]);
    if (n) {
      for (var M = new l3(a.inputStructure), T = a.inputStructure.lookup3d, N = 0, I = C.units; N < I.length; N++) {
        for (var P, O = (P = I[N]).conformation, F = O.x, R = O.y, G = O.z, L = 0, q = (h = P.elements).length; L < q; L++) {
          var K = h[L];
          T.findIntoBuilderIf(F(K), R(K), G(K), r, M, Jte), M.addToUnit(P.id, K);
        }
        a.throwIfTimedOut();
      }
      return St.Sequence(a.inputStructure, [M.getStructure()]);
    }
    return St.Sequence(a.inputStructure, [C]);
  };
}, union: function(e) {
  return function(t) {
    var r = St.LinearBuilder(t.inputStructure);
    return r.add(St.unionStructure(e(t))), r.getSelection();
  };
}, wholeResidues: function(e) {
  return function(t) {
    var r = e(t);
    if (St.isSingleton(r)) return St.Singletons(t.inputStructure, Ep(t, t.inputStructure, r.structure));
    for (var n = new R4(t.inputStructure), a = 0, i = r.structures; a < i.length; a++) {
      var o = i[a];
      n.add(Ep(t, t.inputStructure, o));
    }
    return n.getSelection();
  };
} });
function H4(e, t, r) {
  var n = e.currentStructure.units, a = e.pushCurrentElement();
  a.structure = e.currentStructure;
  for (var i = 0, o = n; i < o.length; i++) {
    var s = o[i];
    a.unit = s;
    var u = s.elements, c = void 0;
    if (c = Ke.isAtomic(s) ? t.atomic : t.coarse) {
      for (var l = 0, d = u.length; l < d; l++) a.element = u[l], r.add(c(e));
      e.throwIfTimedOut();
    }
  }
  return e.popCurrentElement(), r;
}
(function(e) {
  var t = D.zero();
  function r(i, o, s, u, c, l, d) {
    var f = o.elements, m = o.conformation.position, h = t;
    i.element.unit = o;
    for (var p = !1, g = 0, v = f.length; g < v; g++) {
      var y = f[g];
      i.element.element = y;
      var _ = Math.max(0, D.distance(s, m(y, h)) - u - d(i));
      if (_ < c) return 0;
      _ < l && (p = !0);
    }
    return p ? 1 : 2;
  }
  function n(i, o, s, u, c, l, d) {
    for (var f = o.units, m = !1, h = 0, p = f.length; h < p; h++) {
      var g = r(i, f[h], s, u, c, l, d);
      if (g === 0) return 0;
      g === 1 && (m = !0);
    }
    return m ? 1 : 2;
  }
  e.toPoint = n;
  var a = D.zero();
  e.check = function(i, o, s, u, c, l) {
    if (o.elementCount === 0 || s.elementCount === 0) return 0;
    var d = o.units, f = !1;
    i.element.structure = o;
    for (var m = 0, h = d.length; m < h; m++) {
      var p = d[m], g = p.elements, v = p.conformation.position;
      i.element.unit = p;
      for (var y = 0, _ = g.length; y < _; y++) {
        var S = g[y];
        i.element.element = S;
        var b = n(i, s, v(S, a), l(i), u, c, l);
        if (b === 0) return 0;
        b === 1 && (f = !0);
      }
    }
    return f;
  };
})(sy || (sy = {})), function(e) {
  var t = D.zero();
  function r(i, o, s, u, c, l) {
    var d = o.elements, f = o.conformation.position, m = t;
    i.element.unit = o;
    for (var h = 0, p = d.length; h < p; h++) {
      var g = d[h];
      if (i.element.element = g, Math.max(0, D.distance(s, f(g, m)) - u - l(i)) <= c) return !0;
    }
    return !1;
  }
  function n(i, o, s, u, c, l) {
    for (var d = o.units, f = 0, m = d.length; f < m; f++) if (r(i, d[f], s, u, c, l)) return !0;
    return !1;
  }
  e.toPoint = n;
  var a = D.zero();
  e.check = function(i, o, s, u, c) {
    if (o.elementCount === 0 || s.elementCount === 0) return 0;
    var l = o.units;
    i.element.structure = o;
    for (var d = 0, f = l.length; d < f; d++) {
      var m = l[d];
      i.element.unit = m;
      for (var h = m.elements, p = m.conformation.position, g = 0, v = h.length; g < v; g++) {
        var y = h[g];
        if (i.element.element = y, n(i, s, p(y, a), c(i), u, c)) return !0;
      }
    }
    return !1;
  };
}(uy || (uy = {}));
var rre = Object.freeze({ __proto__: null, areIntersectedBy: function(e, t) {
  return function(r) {
    var n = St.unionStructure(t(r)), a = St.LinearBuilder(r.inputStructure);
    return St.forEach(e(r), function(i, o) {
      E8(n, i) && a.add(i), o % 10 && r.throwIfTimedOut();
    }), a.getSelection();
  };
}, first: function(e) {
  return function(t) {
    var r = e(t), n = St.LinearBuilder(t.inputStructure);
    if (r.kind === "singletons") {
      if (r.structure.elementCount > 0) {
        var a = r.structure.units[0], i = st.create([a.getChild($e.ofSingleton(a.elements[0]))], { parent: t.inputStructure });
        n.add(i);
      }
    } else r.structures.length > 0 && n.add(r.structures[0]);
    return n.getSelection();
  };
}, getCurrentStructureProperties: H4, isConnectedTo: function(e) {
  var t = e.query, r = e.target, n = e.disjunct, a = e.invert, i = e.bondTest;
  return function(o) {
    var s = r(o);
    if (St.isEmpty(s)) return s;
    var u = t(o);
    if (St.isEmpty(u)) return u;
    var c = { queryCtx: o, input: o.inputStructure, disjunct: n, target: St.unionStructure(s) }, l = St.LinearBuilder(o.inputStructure);
    return o.pushCurrentBond(), o.atomicBond.setTestFn(i), St.forEach(u, function(d, f) {
      (function(m, h) {
        var p = m.queryCtx, g = m.input, v = m.target, y = m.disjunct, _ = p.atomicBond, S = g.interUnitBonds;
        _.setStructure(g);
        for (var b = 0, x = h.units; b < x.length; b++) {
          var A = x[b];
          if (Ke.isAtomic(A)) for (var w = g.unitMap.get(A.id), C = w.bonds, M = C.offset, T = C.b, N = C.edgeProps, I = N.flags, P = N.order, O = S.getConnectedUnits(A.id), F = O.length, R = A.elements, G = w.elements, L = 0, q = R.length; L < q; L++) {
            var K = $e.indexOf(G, R[L]);
            _.a.unit = w, _.b.unit = w;
            for (var X = M[K], H = M[K + 1]; X < H; X++) if (_.b.element = w.elements[T[X]], (!y || !$e.has(A.elements, _.b.element)) && v.hasElement(_.b) && (_.aIndex = K, _.a.element = R[L], _.bIndex = T[X], _.type = I[X], _.order = P[X], _.test(p, !0))) return !0;
            for (var W = 0; W < F; W++) for (var ee = O[W], $ = g.unitMap.get(ee.unitB), te = $.elements, re = ee.getEdges(K), ie = 0, oe = re.length; ie < oe; ie++) {
              var se = re[ie];
              if (_.b.unit = $, _.b.element = te[se.indexB], v.hasElement(_.b) && (!y || !h.hasElement(_.b)) && (_.a.unit = w, _.aIndex = K, _.a.element = R[L], _.bIndex = se.indexB, _.type = se.props.flag, _.order = se.props.order, _.test(p, !0))) return !0;
            }
          }
        }
        return !1;
      }(c, d) || a) && l.add(d), f % 5 == 0 && o.throwIfTimedOut();
    }), o.popCurrentBond(), l.getSelection();
  };
}, pick: function(e, t) {
  return function(r) {
    var n = e(r), a = St.LinearBuilder(r.inputStructure);
    return r.pushCurrentElement(), St.forEach(n, function(i, o) {
      r.currentStructure = i, t(r) && a.add(i), o % 100 && r.throwIfTimedOut();
    }), r.popCurrentStructure(), a.getSelection();
  };
}, withSameAtomProperties: function(e, t, r) {
  return function(n) {
    var a = e(n), i = function(s, u, c) {
      var l = /* @__PURE__ */ new Set(), d = u(s);
      return s.pushCurrentElement(), St.forEach(d, function(f, m) {
        s.currentStructure = f, H4(s, c, l), m % 10 && s.throwIfTimedOut();
      }), s.popCurrentElement(), l;
    }(n, t, r), o = St.LinearBuilder(n.inputStructure);
    return n.pushCurrentStructure(), St.forEach(a, function(s, u) {
      n.currentStructure = s;
      var c = H4(n, r, /* @__PURE__ */ new Set());
      bo.isSuperset(c, i) && o.add(s), u % 10 && n.throwIfTimedOut();
    }), n.popCurrentStructure(), o.getSelection();
  };
}, within: function(e) {
  return function(t) {
    var r = { queryCtx: t, selection: e.query(t), target: e.target(t), maxRadius: e.maxRadius, minRadius: e.minRadius ? Math.max(0, e.minRadius) : 0, elementRadius: e.elementRadius, invert: !!e.invert };
    return r.minRadius === 0 && e.minRadius === void 0 ? function(n) {
      var a = n.queryCtx, i = n.selection, o = n.target, s = n.maxRadius, u = n.invert, c = St.unionStructure(o).lookup3d, l = St.LinearBuilder(a.inputStructure), d = D.zero();
      return St.forEach(i, function(f, m) {
        for (var h = f.units, p = !1, g = 0, v = h.length; g < v; g++) {
          for (var y = h[g], _ = y.elements, S = y.conformation, b = S.position, x = S.r, A = 0, w = _.length; A < w; A++) {
            var C = _[A];
            if (b(C, d), c.check(d[0], d[1], d[2], s + x(C))) {
              p = !0;
              break;
            }
          }
          if (p) break;
        }
        u && (p = !p), p && l.add(f), m % 10 == 0 && a.throwIfTimedOut();
      }), l.getSelection();
    }(r) : r.minRadius === 0 ? function(n) {
      var a = n.queryCtx, i = n.selection, o = n.target, s = n.maxRadius, u = n.invert, c = n.elementRadius, l = St.unionStructure(o), d = St.LinearBuilder(a.inputStructure);
      return a.pushCurrentElement(), St.forEach(i, function(f, m) {
        var h = function(p, g, v, y, _) {
          return g.elementCount === 0 || v.elementCount === 0 || (g.elementCount <= v.elementCount ? uy.check(p, g, v, y, _) : uy.check(p, v, g, y, _));
        }(a, l, f, s, c);
        u && (h = !h), h && d.add(f), m % 10 == 0 && a.throwIfTimedOut();
      }), a.popCurrentElement(), d.getSelection();
    }(r) : function(n) {
      var a = n.queryCtx, i = n.selection, o = n.target, s = n.minRadius, u = n.maxRadius, c = n.invert, l = n.elementRadius, d = St.unionStructure(o), f = St.LinearBuilder(a.inputStructure);
      return a.pushCurrentElement(), St.forEach(i, function(m, h) {
        var p = function(g, v, y, _, S, b) {
          return v.elementCount === 0 || y.elementCount === 0 || (v.elementCount <= y.elementCount ? sy.check(g, v, y, _, S, b) : sy.check(g, y, v, _, S, b));
        }(a, d, m, s, u, l);
        c && (p = !p), p && f.add(m), h % 10 == 0 && a.throwIfTimedOut();
      }), a.popCurrentElement(), f.getSelection();
    }(r);
  };
} }), w6, nre = Object.freeze({ __proto__: null, intersect: function(e) {
  return e.length === 0 ? y6 : e.length === 1 ? e[0] : function(t) {
    for (var r = [], n = 0; n < e.length; n++) r.push(e[n](t));
    var a = 0, i = St.structureCount(r[0]);
    for (n = 1; n < r.length; n++) {
      var o = St.structureCount(r[n]);
      o < i && (a = n, i = o);
    }
    t.throwIfTimedOut();
    var s = b8(function(l) {
      return l.hashCode;
    }, st.areUnitIdsAndIndicesEqual);
    St.forEach(r[a], function(l) {
      return s.add(l);
    });
    for (var u = St.UniqueBuilder(t.inputStructure), c = 0; c < r.length; c++) c !== a && (St.forEach(r[c], function(l) {
      s.has(l) && u.add(l);
    }), t.throwIfTimedOut());
    return u.getSelection();
  };
}, merge: function(e) {
  return e.length === 0 ? y6 : e.length === 1 ? e[0] : function(t) {
    for (var r = St.UniqueBuilder(t.inputStructure), n = function(i) {
      St.forEach(e[i](t), function(o, s) {
        r.add(o), i % 100 && t.throwIfTimedOut();
      });
    }, a = 0; a < e.length; a++) n(a);
    return r.getSelection();
  };
} });
(function(e) {
  function t(n) {
    return !0;
  }
  function r(n) {
    return !1;
  }
  e.eq = function(n, a) {
    return function(i) {
      return n(i) === a;
    };
  }, e.lt = function(n, a) {
    return function(i) {
      return n(i) < a;
    };
  }, e.lte = function(n, a) {
    return function(i) {
      return n(i) <= a;
    };
  }, e.gt = function(n, a) {
    return function(i) {
      return n(i) > a;
    };
  }, e.gte = function(n, a) {
    return function(i) {
      return n(i) >= a;
    };
  }, e.inSet = function(n, a) {
    if (function(s) {
      return !!s && !!s.has;
    }(a)) return function(s) {
      return a.has(n(s));
    };
    if (a.length === 0) return r;
    for (var i = /* @__PURE__ */ new Set(), o = 0; o < a.length; o++) i.add(a[o]);
    return function(s) {
      return i.has(n(s));
    };
  }, e.and = function() {
    for (var n = [], a = 0; a < arguments.length; a++) n[a] = arguments[a];
    switch (n.length) {
      case 0:
        return t;
      case 1:
        return n[0];
      case 2:
        var i = n[0], o = n[1];
        return function(M) {
          return i(M) && o(M);
        };
      case 3:
        var s = n[0], u = n[1], c = n[2];
        return function(M) {
          return s(M) && u(M) && c(M);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], m = n[3];
        return function(M) {
          return l(M) && d(M) && f(M) && m(M);
        };
      case 5:
        var h = n[0], p = n[1], g = n[2], v = n[3], y = n[4];
        return function(M) {
          return h(M) && p(M) && g(M) && v(M) && y(M);
        };
      case 6:
        var _ = n[0], S = n[1], b = n[2], x = n[3], A = n[4], w = n[5];
        return function(M) {
          return _(M) && S(M) && b(M) && x(M) && A(M) && w(M);
        };
      default:
        var C = n.length;
        return function(M) {
          for (var T = 0; T < C; T++) if (!n[T]) return !1;
          return !0;
        };
    }
  }, e.or = function() {
    for (var n = [], a = 0; a < arguments.length; a++) n[a] = arguments[a];
    switch (n.length) {
      case 0:
        return r;
      case 1:
        return n[0];
      case 2:
        var i = n[0], o = n[1];
        return function(M) {
          return i(M) || o(M);
        };
      case 3:
        var s = n[0], u = n[1], c = n[2];
        return function(M) {
          return s(M) || u(M) || c(M);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], m = n[3];
        return function(M) {
          return l(M) || d(M) || f(M) || m(M);
        };
      case 5:
        var h = n[0], p = n[1], g = n[2], v = n[3], y = n[4];
        return function(M) {
          return h(M) || p(M) || g(M) || v(M) || y(M);
        };
      case 6:
        var _ = n[0], S = n[1], b = n[2], x = n[3], A = n[4], w = n[5];
        return function(M) {
          return _(M) || S(M) || b(M) || x(M) || A(M) || w(M);
        };
      default:
        var C = n.length;
        return function(M) {
          for (var T = 0; T < C; T++) if (n[T]) return !0;
          return !1;
        };
    }
  };
})(w6 || (w6 = {}));
var Gp, Pn = { generators: ete, filters: rre, modifiers: tre, combinators: nre, pred: w6, internal: Qee };
function cR(e, t, r, n, a, i) {
  var o = e.spacegroup, s = e.ncsOperators, u = [], c = o.cell.toFractional, l = D.transformMat4(D(), i, c), d = Fo.getSymmetryOperatorRef(o, t, r, n, a, l);
  if (s && s.length) for (var f = 0, m = s.length; f < m; ++f) {
    var h = s[f], p = Ee.mul(Ee(), d.matrix, h.matrix), g = Mn.create("".concat(d.name, " ").concat(h.name), p, { assembly: d.assembly, ncsId: h.ncsId, hkl: d.hkl, spgrOp: d.spgrOp });
    u.push(g);
  }
  else u.push(d);
  return u;
}
function AC(e, t, r, n) {
  var a = e.spacegroup, i = e.ncsOperators, o = i && i.length || 0, s = [];
  !o && t[0] <= 0 && r[0] >= 0 && t[1] <= 0 && r[1] >= 0 && t[2] <= 0 && r[2] >= 0 && (s[0] = Fo.getSymmetryOperator(a, 0, 0, 0, 0));
  for (var u = 0; u < a.operators.length; u++) for (var c = t[0]; c <= r[0]; c++) for (var l = t[1]; l <= r[1]; l++) for (var d = t[2]; d <= r[2]; d++) (o || u !== 0 || c !== 0 || l !== 0 || d !== 0) && s.push.apply(s, cR(e, u, c, l, d, n));
  return s;
}
function wC(e, t) {
  for (var r = st.Builder({ label: e.label, dynamicBonds: e.dynamicBonds }), n = e.units, a = 0, i = t; a < i.length; a++) for (var o = i[a], s = 0, u = n; s < u.length; s++) {
    var c = u[s];
    r.addWithOperator(c, o);
  }
  return r.getStructure();
}
(function(e) {
  function t(n, a) {
    return n.invariantId === a.invariantId && n.model.id === a.model.id && $e.areEqual(n.elements, a.elements);
  }
  function r() {
    return function(n, a) {
      return new XZ(n, a);
    }(Ke.hashUnit, t);
  }
  e.buildAssembly = function(n, a) {
    var i = this;
    return sr.create("Build Assembly", function(o) {
      return Be(i, 0, void 0, function() {
        var s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x;
        return Te(this, function(A) {
          if ((s = n.models).length !== 1) throw new Error("Can only build assemblies from structures based on 1 model.");
          if (!(u = ny.findAssembly(s[0], a))) throw new Error("Assembly '".concat(a, "' is not defined."));
          for (c = Mn.create(u.id, Ee.identity(), { assembly: { id: u.id, operId: 0, operList: [] } }), l = st.Builder({ coordinateSystem: c, label: n.label, dynamicBonds: n.dynamicBonds }), d = new tm(n), f = 0, m = u.operatorGroups; f < m.length; f++) if (h = m[f], p = h.selector(d), St.structureCount(p) !== 0) for (g = St.unionStructure(p).units, v = 0, y = h.operators; v < y.length; v++) for (_ = y[v], S = 0, b = g; S < b.length; S++) x = b[S], l.addWithOperator(x, _);
          return [2, l.getStructure()];
        });
      });
    });
  }, e.buildSymmetryAssembly = function(n, a, i) {
    var o = this;
    return sr.create("Build Symmetry Assembly", function(s) {
      return Be(o, 0, void 0, function() {
        var u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F;
        return Te(this, function(R) {
          if ((u = n.models).length !== 1) throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
          for (c = D(), l = st.Builder({ label: n.label, representativeModel: u[0], dynamicBonds: n.dynamicBonds }), d = new tm(n), f = 0, m = a; f < m.length; f++) if (h = m[f], G = h.asymIds, p = Pn.generators.atoms({ chainTest: Pn.pred.and(Pn.pred.eq(function(L) {
            return at.unit.operator_name(L.element);
          }, Mn.DefaultName), Pn.pred.inSet(function(L) {
            return at.chain.label_asym_id(L.element);
          }, G)) }), g = p(d), St.structureCount(g) !== 0) for (v = St.unionStructure(g).units, y = 0, _ = h.operators; y < _.length; y++) for (S = _[y], b = S.index, x = S.shift, A = x[0], w = x[1], C = x[2], M = cR(i, b, A, w, C, c), T = 0, N = v; T < N.length; T++) for (I = N[T], P = 0, O = M; P < O.length; P++) F = O[P], l.addWithOperator(I, F);
          var G;
          return [2, l.getStructure()];
        });
      });
    });
  }, e.builderSymmetryMates = function(n, a) {
    return sr.create("Find Symmetry Mates", function(i) {
      return function(o, s, u) {
        return Be(this, 0, void 0, function() {
          function c(O, F) {
            return "".concat(O.invariantId, "|").concat(F.name);
          }
          var l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P;
          return Te(this, function(O) {
            switch (O.label) {
              case 0:
                if ((l = s.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
                return (d = pi.Provider.get(l[0])) ? (f = d.spacegroup, tu.isZero(f.cell) ? [2, s] : o.shouldUpdate ? [4, o.update("Initialing...")] : [3, 2]) : [2, s];
              case 1:
                O.sent(), O.label = 2;
              case 2:
                m = yn.getCenter(l[0]), h = function(F, R) {
                  return F._operators_333 && D.equals(R, F._operators_333.ref) || (F._operators_333 = { ref: D.clone(R), operators: AC(F, D.create(-3, -3, -3), D.create(3, 3, 3), R) }), F._operators_333.operators;
                }(d, m), p = s.lookup3d, g = /* @__PURE__ */ new Set(), v = st.Builder({ label: s.label, dynamicBonds: s.dynamicBonds }), y = s.units, _ = D.zero(), S = 0, b = h, O.label = 3;
              case 3:
                if (!(S < b.length)) return [3, 6];
                for (x = b[S], A = 0, w = y; A < w.length; A++) for (C = w[A], M = C.lookup3d.boundary.sphere, D.transformMat4(_, M.center, x.matrix), T = p.findUnitIndices(_[0], _[1], _[2], M.radius + u), N = 0, I = T.count; N < I; N++) y[T.indices[N]].lookup3d.check(_[0], _[1], _[2], M.radius + u) && (P = c(C, x), g.has(P) || (v.addWithOperator(C, x), g.add(P)));
                return o.shouldUpdate ? [4, o.update("Building symmetry...")] : [3, 5];
              case 4:
                O.sent(), O.label = 5;
              case 5:
                return S++, [3, 3];
              case 6:
                return [2, v.getStructure()];
            }
          });
        });
      }(i, n, a);
    });
  }, e.buildSymmetryRange = function(n, a, i) {
    return sr.create("Build Symmetry", function(o) {
      return function(s, u, c, l) {
        return Be(this, 0, void 0, function() {
          var d, f, m, h, p;
          return Te(this, function(g) {
            if ((d = u.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
            return (f = pi.Provider.get(d[0])) ? (m = f.spacegroup, tu.isZero(m.cell) ? [2, u] : (h = yn.getCenter(d[0]), p = AC(f, c, l, h), [2, wC(u, p)])) : [2, u];
          });
        });
      }(0, n, a, i);
    });
  }, e.buildNcs = function(n) {
    return sr.create("Build NCS", function(a) {
      return function(i, o) {
        return Be(this, 0, void 0, function() {
          var s, u, c;
          return Te(this, function(l) {
            if ((s = o.models).length !== 1) throw new Error("Can only build NCS from structures based on 1 model.");
            return (u = pi.Provider.get(s[0])) && (c = u.ncsOperators) && c.length ? [2, wC(o, c)] : [2, o];
          });
        });
      }(0, n);
    });
  }, e.areUnitsEquivalent = t, e.UnitEquivalenceBuilder = r, e.computeTransformGroups = function(n) {
    for (var a = r(), i = 0, o = n.units; i < o.length; i++) {
      var s = o[i];
      a.add(s.id, s);
    }
    for (var u = [], c = 0, l = a.groups; c < l.length; c++) {
      var d = l[c];
      u.push(Ke.SymmetryGroup(d.map(function(f) {
        return n.unitMap.get(f);
      })));
    }
    return u;
  }, e.areTransformGroupsEquivalent = function(n, a) {
    if (n.length !== a.length) return !1;
    for (var i = 0, o = n.length; i < o; ++i) {
      var s = n[i].units, u = a[i].units;
      if (s.length !== u.length || n[i].hashCode !== a[i].hashCode) return !1;
      for (var c = 0, l = s.length; c < l; c++) if (s[c].conformation !== u[c].conformation) return !1;
    }
    return !0;
  };
})(Gp || (Gp = {}));
var are = function() {
  function e(t, r) {
    this.parent = t, this.isSorted = r, this.ids = [], this.unitMap = uc.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, r) {
    var n = this.unitMap.get(t);
    n ? n[n.length] = r : (this.unitMap.set(t, [r]), this.ids[this.ids.length] = t), this.elementCount++;
  }, e.prototype.beginUnit = function(t) {
    this.parentId = t, this.currentUnit = this.currentUnit.length > 0 ? [] : this.currentUnit;
  }, e.prototype.addElement = function(t) {
    this.currentUnit[this.currentUnit.length] = t, this.elementCount++;
  }, e.prototype.addElementRange = function(t, r, n) {
    for (var a = r; a < n; a++) this.currentUnit[this.currentUnit.length] = t[a], this.elementCount++;
  }, e.prototype.commitUnit = function() {
    this.currentUnit.length !== 0 && (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
  }, e.prototype.setUnit = function(t, r) {
    this.ids[this.ids.length] = t, this.unitMap.set(t, r), this.elementCount += r.length;
  }, e.prototype._getStructure = function(t) {
    if (this.isEmpty) return st.Empty;
    var r = [];
    Du(this.ids);
    for (var n = Gp.UnitEquivalenceBuilder(), a = 0, i = this.ids.length; a < i; a++) {
      var o = this.ids[a], s = this.parent.unitMap.get(o), u = this.unitMap.get(o), c = !1;
      t && (this.isSorted || Du(u), u = $e.deduplicate($e.ofSortedArray(this.currentUnit)), c = !0);
      var l = u.length;
      if (u.length !== s.elements.length) {
        !this.isSorted && !c && l > 1 && Du(u);
        var d = s.getChild($e.ofSortedArray(u)), f = n.add(d.id, d);
        d !== f && (d = f.applyOperator(d.id, d.conformation.operator, !0)), r[r.length] = d;
      } else r[r.length] = s, n.add(s.id, s);
    }
    return st.create(r, { parent: this.parent });
  }, e.prototype.getStructure = function() {
    return this._getStructure(!1);
  }, e.prototype.getStructureDeduplicate = function() {
    return this._getStructure(!0);
  }, e.prototype.setSingletonLocation = function(t) {
    var r = this.ids[0];
    t.unit = this.parent.unitMap.get(r), t.element = this.unitMap.get(r)[0];
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function CC(e, t) {
  for (var r = 1; t--; ) r *= e--;
  return r;
}
var ire = function() {
  function e(t, r) {
    this.array = t, this.hasNext = !1, this.index = (1 << r) - 1, this.size = function(n, a) {
      return a > n ? 0 : CC(n, a) / CC(a, a);
    }(t.length, r), this.maxIndex = 1 << t.length, this.value = new Array(r), this.hasNext = r > 0 && r <= t.length;
  }
  return e.prototype.move = function() {
    if (this.hasNext) {
      for (var t = 0, r = 0, n = this.index; n; n >>>= 1, t++) 1 & n && (this.value[r++] = this.array[t]);
      this.index = function(a) {
        var i = a & -a, o = a + i;
        return o | ((o & -o) / i >> 1) - 1;
      }(this.index), this.hasNext = this.index < this.maxIndex;
    }
    return this.value;
  }, e;
}();
function lR(e, t) {
  for (var r = [], n = new ire(e, t); n.hasNext; ) r.push(n.move().slice());
  return r;
}
var hf = [], ore = { links: hf, terminalLinks: hf, elements: hf, partialElements: hf, getElementIndices: function() {
  return hf;
}, getLinkIndices: function() {
  return hf;
}, getTerminalLinkIndices: function() {
  return hf;
} }, Ta = Rp("C"), N0 = Rp("O"), sre = [Js.elementFingerprint([Ta, Ta, Ta, N0]), Js.elementFingerprint([Ta, Ta, Ta, Ta, N0]), Js.elementFingerprint([Ta, Ta, Ta, Ta, Ta, N0]), Js.elementFingerprint([Ta, Ta, Ta, Ta, Ta, Ta, N0])];
function ure(e, t) {
  for (var r = -1, n = -1, a = -1, i = -1, o = e.elements, s = e.model.atomicHierarchy.atoms, u = s.type_symbol, c = s.label_atom_id, l = e.bonds, d = l.b, f = l.offset, m = 0, h = t.length; m < h; ++m) {
    var p = o[t[m]];
    if (u.value(p) === Ta) {
      for (var g = 0, v = 0, y = f[t[m]], _ = f[t[m] + 1]; y < _; ++y) {
        var S = o[d[y]], b = u.value(S);
        b === N0 ? ++g : b === Ta && ++v;
      }
      if (g === 2) {
        r = p;
        break;
      }
      g === 1 && v === 1 ? n = p : c.value(p).startsWith("C1") ? a = p : i = p;
    }
  }
  return r !== -1 ? r : n !== -1 ? n : a !== -1 ? a : i !== -1 ? i : o[t[0]];
}
function cre(e, t, r, n) {
  var a = t.conformation.position;
  return D.normalize(e, D.sub(e, n, a(r, e))), e;
}
function EC(e, t) {
  var r = e.elements;
  return e.model.atomicHierarchy.atoms.label_atom_id.value(r[t]);
}
function lre(e, t) {
  if (t && t.length) {
    for (var r = e.unit, n = e.all, a = /* @__PURE__ */ new Set(), i = lR(lc(new Array(t.length)), 2), o = 0, s = i.length; o < s; ++o) {
      var u = i[o], c = n[t[u[0]]], l = n[t[u[1]]];
      $e.areIntersecting(c, l) && Js.getAltId(r, c) === Js.getAltId(r, l) && (a.add(t[u[0]]), a.add(t[u[1]]));
    }
    if (a.size) {
      var d = [];
      for (o = 0, s = t.length; o < s; ++o) a.has(t[o]) || d.push(t[o]);
      return d;
    }
    return t;
  }
}
function dre(e, t) {
  return t.properties.saccharideComponentMap.get(e);
}
function fre(e) {
  if (e.models.reduce(function(he, ge) {
    return he + ge.properties.saccharideComponentMap.size;
  }, 0) === 0) return ore;
  var t = [], r = [], n = [], a = [], i = /* @__PURE__ */ new Map();
  function o(he, ge, De) {
    return "".concat(he, "|").concat(ge, "|").concat(De);
  }
  function s(he, ge) {
    i.has(he) ? i.get(he).push(ge) : i.set(he, [ge]);
  }
  function u(he, ge) {
    D.sub(n[he].geometry.direction, n[ge].geometry.center, n[he].geometry.center), D.normalize(n[he].geometry.direction, n[he].geometry.direction);
  }
  var c = D.zero();
  function l(he, ge, De) {
    var ae = De.conformation.position, ce = n[he].geometry;
    D.sub(ce.direction, ae(De.elements[ge], c), ce.center), D.normalize(ce.direction, ce.direction);
  }
  for (var d = 0, f = e.units.length; d < f; ++d) {
    var m = e.units[d];
    if (Ke.isAtomic(m)) for (var h = m.model, p = m.rings, g = h.atomicHierarchy, v = g.chainAtomSegments, y = g.residueAtomSegments, _ = g.atoms.label_comp_id, S = nr.transientSegments(v, m.elements), b = nr.transientSegments(y, m.elements), x = void 0; S.hasNext; ) for (b.setSegment(S.move()); b.hasNext; ) {
      var A = b.move().index, w = dre(_.value(y.offsets[A]), h);
      if (w) {
        x || (x = ry.byFingerprintAndResidue(p, sre));
        var C = lre(p, x.get(A));
        if (C && C.length) {
          for (var M = [], T = 0, N = C.length; T < N; ++T) {
            var I = p.all[C[T]], P = ure(m, I), O = Od.calculateMomentsAxes(jF(m, I)), F = D.copy(D.zero(), O.origin), R = D.copy(D.zero(), O.dirC), G = cre(D.zero(), m, P, F);
            D.orthogonalize(G, R, G);
            var L = Js.getAltId(m, I), q = n.length;
            M.push(q), s(o(A, m.id, L), q), L && s(o(A, m.id, ""), q), n.push({ geometry: { center: F, normal: R, direction: G }, component: w, ringIndex: C[T], altId: L, unit: m, residueIndex: A });
          }
          var K = lR(lc(new Array(C.length)), 2);
          for (T = 0, N = K.length; T < N; ++T) {
            var X = K[T], H = p.all[C[X[0]]], W = p.all[C[X[1]]];
            if (Ho.areVertexSetsConnected(m.bonds, H, W, 3)) {
              var ee = M[X[0]], $ = M[X[1]];
              n[ee].altId === n[$].altId && (u(ee, $), u($, ee), t.push({ carbohydrateIndexA: ee, carbohydrateIndexB: $ }), t.push({ carbohydrateIndexA: $, carbohydrateIndexB: ee }));
            }
          }
        } else a.push({ unit: m, residueIndex: A, component: w });
      }
    }
  }
  function te(he, ge) {
    return i.get(o(he.getResidueIndex(ge), he.id, function(De, ae) {
      var ce = De.elements;
      return De.model.atomicHierarchy.atoms.label_alt_id.value(ce[ae]);
    }(he, ge))) || [];
  }
  for (d = 0, f = n.length; d < f; ++d) {
    var re = n[d];
    for (m = re.unit, T = d + 1; T < f; ++T) {
      var ie = n[T];
      if (m === ie.unit && re.residueIndex !== ie.residueIndex) {
        var oe = m.rings.all[re.ringIndex], se = m.rings.all[ie.ringIndex];
        Ho.areVertexSetsConnected(m.bonds, oe, se, 3) && (u(d, T), u(T, d), t.push({ carbohydrateIndexA: d, carbohydrateIndexB: T }), t.push({ carbohydrateIndexA: T, carbohydrateIndexB: d }));
      }
    }
  }
  for (d = 0, f = e.units.length; d < f; ++d)
    m = e.units[d], Ke.isAtomic(m) && e.interUnitBonds.getConnectedUnits(m.id).forEach(function(he) {
      he.connectedIndices.forEach(function(ge) {
        he.getEdges(ge).forEach(function(De) {
          var ae = De.props, ce = De.indexB;
          if (pr.isCovalent(ae.flag)) {
            var _e = e.unitMap.get(he.unitA), le = e.unitMap.get(he.unitB), ue = te(_e, ge), be = te(le, ce);
            if (ue.length > 0 && be.length > 0) for (var Se = ue.length, Ne = be.length, J = 0, Z = Math.max(Se, Ne); J < Z; ++J) {
              var de = ue[Math.min(J, Se - 1)], ye = be[Math.min(J, Ne - 1)];
              ((Ie = EC(_e, ge)).startsWith("O1") || Ie.startsWith("C1")) && u(de, ye), t.push({ carbohydrateIndexA: de, carbohydrateIndexB: ye });
            }
            else if (be.length === 0) for (var Ae = 0, Ce = ue; Ae < Ce.length; Ae++) {
              var Ie;
              de = Ce[Ae], ((Ie = EC(_e, ge)).startsWith("O1") || Ie.startsWith("C1")) && l(de, ce, le), r.push({ carbohydrateIndex: de, elementIndex: ce, elementUnit: le, fromCarbohydrate: !0 });
            }
            else if (ue.length === 0) for (var Ue = 0, Xe = be; Ue < Xe.length; Ue++)
              ye = Xe[Ue], r.push({ carbohydrateIndex: ye, elementIndex: ge, elementUnit: _e, fromCarbohydrate: !1 });
          }
        });
      });
    });
  return k({ links: t, terminalLinks: r, elements: n, partialElements: a }, function(he, ge, De) {
    function ae(Je, Ct) {
      return eu(Je.id, Ct);
    }
    function ce(Je, Ct, At) {
      var Or = [], qn = Je.get(ae(Ct, At));
      if (qn !== void 0) for (var Xn = 0, kn = qn; Xn < kn.length; Xn++)
        js(Or, kn[Xn]);
      return Or;
    }
    for (var _e = /* @__PURE__ */ new Map(), le = 0, ue = he.length; le < ue; ++le) for (var be = he[le], Se = be.unit, Ne = be.ringIndex, J = 0, Z = (Le = Se.rings.all[Ne]).length; J < Z; ++J) {
      var de = ae(Se, Se.elements[Le[J]]);
      (xe = _e.get(de)) === void 0 ? _e.set(de, [le]) : xe.push(le);
    }
    function ye(Je, Ct) {
      return ce(_e, Je, Ct);
    }
    var Ae = /* @__PURE__ */ new Map();
    for (le = 0, ue = ge.length; le < ue; ++le) {
      var Ce = he[ge[le].carbohydrateIndexA];
      for (Se = Ce.unit, Ne = Ce.ringIndex, J = 0, Z = (Le = Se.rings.all[Ne]).length; J < Z; ++J)
        de = ae(Se, Se.elements[Le[J]]), (xe = Ae.get(de)) === void 0 ? Ae.set(de, [le]) : xe.push(le);
    }
    function Ie(Je, Ct) {
      return ce(Ae, Je, Ct);
    }
    var Ue = /* @__PURE__ */ new Map();
    for (le = 0, ue = De.length; le < ue; ++le) {
      var Xe = De[le], je = Xe.fromCarbohydrate, ht = Xe.carbohydrateIndex, xt = Xe.elementUnit, dt = Xe.elementIndex;
      if (je) {
        var Le, j = he[ht];
        for (Se = j.unit, Ne = j.ringIndex, J = 0, Z = (Le = Se.rings.all[Ne]).length; J < Z; ++J)
          de = ae(Se, Se.elements[Le[J]]), (xe = Ue.get(de)) === void 0 ? Ue.set(de, [le]) : xe.push(le);
      } else {
        var xe;
        de = ae(xt, xt.elements[dt]), (xe = Ue.get(de)) === void 0 ? Ue.set(de, [le]) : xe.push(le);
      }
    }
    function ke(Je, Ct) {
      return ce(Ue, Je, Ct);
    }
    return { getElementIndices: ye, getLinkIndices: Ie, getTerminalLinkIndices: ke };
  }(n, t, r));
}
var lg = Ve(), mre = new iu("14"), pre = new iu("98");
function hre(e) {
  var t = e.units, r = function(u) {
    return u > 500 ? mre : pre;
  }(t.length);
  r.reset();
  for (var n = 0, a = t.length; n < a; n++) {
    var i = (o = t[n]).boundary;
    (s = o.conformation.operator).isIdentity ? r.includeSphere(i.sphere) : (Ve.transform(lg, i.sphere, s.matrix), r.includeSphere(lg));
  }
  for (r.finishedIncludeStep(), n = 0, a = t.length; n < a; n++) {
    var o, s;
    i = (o = t[n]).boundary, (s = o.conformation.operator).isIdentity ? r.radiusSphere(i.sphere) : (Ve.transform(lg, i.sphere, s.matrix), r.radiusSphere(lg));
  }
  return { box: r.getBox(), sphere: r.getSphere() };
}
var st = function() {
  function e(t, r, n, a, i) {
    this.units = t, this.unitMap = r, this.unitIndexMap = n, this.state = a, this._child = i == null ? void 0 : i.child, this._target = i == null ? void 0 : i.target, this._proxy = void 0;
  }
  return e.prototype.subsetBuilder = function(t) {
    return new are(this, t);
  }, Object.defineProperty(e.prototype, "elementCount", { get: function() {
    return this.state.elementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "bondCount", { get: function() {
    return this.state.bondCount === -1 && (this.state.bondCount = this.interUnitBonds.edgeCount + Pt.getIntraUnitBondCount(this)), this.state.bondCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasCustomProperties", { get: function() {
    return !!this.state.customProps && this.state.customProps.all.length > 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "customPropertyDescriptors", { get: function() {
    return this.state.customProps || (this.state.customProps = new f1()), this.state.customProps;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentPropertyData", { get: function() {
    return this.state.propertyData || (this.state.propertyData = /* @__PURE__ */ Object.create(null)), this.state.propertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "inheritedPropertyData", { get: function() {
    return this.parent ? this.parent.currentPropertyData : this.currentPropertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerResidueCount", { get: function() {
    return this.state.polymerResidueCount === -1 && (this.state.polymerResidueCount = function(t) {
      for (var r = t.units, n = 0, a = 0, i = r.length; a < i; a++) n += r[a].polymerElements.length;
      return n;
    }(this)), this.state.polymerResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerGapCount", { get: function() {
    return this.state.polymerGapCount === -1 && (this.state.polymerGapCount = function(t) {
      for (var r = t.units, n = 0, a = 0, i = r.length; a < i; a++) n += r[a].gapElements.length / 2;
      return n;
    }(this)), this.state.polymerGapCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerUnitCount", { get: function() {
    return this.state.polymerUnitCount === -1 && (this.state.polymerUnitCount = function(t) {
      for (var r = t.units, n = 0, a = 0, i = r.length; a < i; a++) r[a].polymerElements.length > 0 && (n += 1);
      return n;
    }(this)), this.state.polymerUnitCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueElementCount", { get: function() {
    return this.state.uniqueElementCount === -1 && (this.state.uniqueElementCount = function(t) {
      for (var r = t.unitSymmetryGroups, n = 0, a = 0, i = r.length; a < i; a++) n += r[a].elements.length;
      return n;
    }(this)), this.state.uniqueElementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "atomicResidueCount", { get: function() {
    return this.state.atomicResidueCount === -1 && (this.state.atomicResidueCount = function(t) {
      for (var r = t.units, n = 0, a = 0, i = r.length; a < i; a++) {
        var o = r[a];
        if (Ke.isAtomic(o)) for (var s = o.elements, u = o.residueIndex, c = -1, l = -1, d = 0, f = s.length; d < f; ++d) (c = u[s[d]]) !== l && (n += 1, l = c);
      }
      return n;
    }(this)), this.state.atomicResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarseGrained", { get: function() {
    return this.models.some(function(t) {
      return yn.isCoarseGrained(t);
    });
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.units.length === 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hashCode", { get: function() {
    return this.state.hashCode !== -1 ? this.state.hashCode : this.computeHash();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "transformHash", { get: function() {
    return this.state.transformHash !== -1 || (this.state.transformHash = Zi(this.units.map(function(t) {
      return t.id;
    }))), this.state.transformHash;
  }, enumerable: !1, configurable: !0 }), e.prototype.computeHash = function() {
    for (var t = 23, r = 0, n = this.units.length; r < n; r++) {
      var a = this.units[r];
      t = 31 * (t = 31 * t + a.id | 0) + $e.hashCode(a.elements) | 0;
    }
    return (t = NO(t = 31 * t + this.elementCount | 0)) === -1 && (t = 0), this.state.hashCode = t, t;
  }, e.prototype.elementLocations = function() {
    return new e.ElementLocationIterator(this);
  }, Object.defineProperty(e.prototype, "root", { get: function() {
    var t;
    return (t = this.state.parent) !== null && t !== void 0 ? t : this;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "parent", { get: function() {
    return this.state.parent;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "coordinateSystem", { get: function() {
    return this.state.coordinateSystem;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "label", { get: function() {
    return this.state.label;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "boundary", { get: function() {
    return this.state.boundary || (this.state.boundary = hre(this)), this.state.boundary;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "lookup3d", { get: function() {
    return this.state.lookup3d || (this.state.lookup3d = new Wee(this)), this.state.lookup3d;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "interUnitBonds", { get: function() {
    return this.state.interUnitBonds || (this.parent && this.state.dynamicBonds === this.parent.state.dynamicBonds && this.parent.state.interUnitBonds && this.parent.state.interUnitBonds.edgeCount === 0 ? this.state.interUnitBonds = new J2(/* @__PURE__ */ new Map()) : this.state.interUnitBonds = Dee(this, { ignoreWater: !this.dynamicBonds, ignoreIon: !this.dynamicBonds })), this.state.interUnitBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dynamicBonds", { get: function() {
    return this.state.dynamicBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "unitSymmetryGroups", { get: function() {
    return this.state.unitSymmetryGroups || (this.state.unitSymmetryGroups = Gp.computeTransformGroups(this)), this.state.unitSymmetryGroups;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "unitSymmetryGroupsIndexMap", { get: function() {
    return this.state.unitSymmetryGroupsIndexMap || (this.state.unitSymmetryGroupsIndexMap = Ke.SymmetryGroup.getUnitSymmetryGroupsIndexMap(this.unitSymmetryGroups)), this.state.unitSymmetryGroupsIndexMap;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "carbohydrates", { get: function() {
    return this.state.carbohydrates || (this.state.carbohydrates = fre(this)), this.state.carbohydrates;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "models", { get: function() {
    return this.state.models || (this.state.models = function(t) {
      for (var r = t.units, n = Sn.create(), a = 0, i = r; a < i.length; a++) {
        var o = i[a];
        Sn.add(n, o.model.id, o.model);
      }
      return n.array;
    }(this)), this.state.models;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueResidueNames", { get: function() {
    return this.state.uniqueResidueNames || (this.state.uniqueResidueNames = function(t) {
      for (var r = at.residue.microheterogeneityCompIds, n = /* @__PURE__ */ new Set(), a = lt.create(t), i = 0, o = t.unitSymmetryGroups; i < o.length; i++) {
        var s = o[i].units[0];
        if (Ke.isAtomic(s)) {
          var u = nr.transientSegments(s.model.atomicHierarchy.residueAtomSegments, s.elements);
          for (a.unit = s; u.hasNext; ) {
            var c = u.move();
            a.element = s.elements[c.start];
            for (var l = 0, d = r(a); l < d.length; l++) {
              var f = d[l];
              n.add(f);
            }
          }
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueElementSymbols", { get: function() {
    return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = function(t) {
      for (var r = at.atom.type_symbol, n = /* @__PURE__ */ new Set(), a = lt.create(t), i = 0, o = t.unitSymmetryGroups; i < o.length; i++) {
        var s = o[i].units[0];
        if (Ke.isAtomic(s)) {
          a.unit = s;
          for (var u = 0, c = s.elements.length; u < c; ++u) a.element = s.elements[u], n.add(r(a));
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "entityIndices", { get: function() {
    return this.state.entityIndices || (this.state.entityIndices = function(t) {
      for (var r = t.units, n = lt.create(t), a = Sn.create(), i = 0, o = r; i < o.length; i++) {
        var s = o[i], u = s.kind === 0 ? at.entity.key : at.coarse.entityKey;
        n.unit = s;
        for (var c = s.elements, l = nr.transientSegments(s.model.atomicHierarchy.chainAtomSegments, c); l.hasNext; ) {
          var d = l.move();
          n.element = c[d.start];
          var f = u(n);
          Sn.add(a, f, f);
        }
      }
      return Du(a.array), a.array;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueAtomicResidueIndices", { get: function() {
    return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = function(t) {
      for (var r = /* @__PURE__ */ new Map(), n = [], a = t.unitSymmetryGroups, i = 0, o = a; i < o.length; i++) {
        var s = o[i].units[0];
        if (Ke.isAtomic(s)) {
          var u = void 0;
          r.has(s.model.id) ? u = r.get(s.model.id) : (u = Sn.create(), n.push(s.model.id), r.set(s.model.id, u));
          for (var c = nr.transientSegments(s.model.atomicHierarchy.residueAtomSegments, s.elements); c.hasNext; ) {
            var l = c.move();
            Sn.add(u, l.index, l.index);
          }
        }
      }
      for (var d = /* @__PURE__ */ new Map(), f = 0, m = n; f < m.length; f++) {
        var h = m[f], p = r.get(h).array;
        Du(p), d.set(h, p);
      }
      return d;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isAtomic", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (!Ke.isAtomic(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasAtomic", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (Ke.isAtomic(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarse", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (!Ke.isCoarse(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasCoarse", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (Ke.isCoarse(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "serialMapping", { get: function() {
    return this.state.serialMapping || (this.state.serialMapping = function(t) {
      for (var r = t.units, n = t.elementCount, a = t.unitIndexMap, i = new Uint32Array(r.length), o = new Uint32Array(n), s = new Uint32Array(n), u = 0, c = 0, l = r.length; u < l; ++u) {
        i[u] = c;
        for (var d = r[u].elements, f = 0, m = d.length; f < m; ++f) {
          var h = c + f;
          o[h] = u, s[h] = d[f];
        }
        c += d.length;
      }
      return { cumulativeUnitElementCount: i, unitIndices: o, elementIndices: s, getSerialIndex: function(p, g) {
        return i[a.get(p.id)] + We.indexOf(p.elements, g);
      } };
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "model", { get: function() {
    if (this.state.model) return this.state.model;
    if (this.state.representativeModel) return this.state.representativeModel;
    if (this.state.masterModel) return this.state.masterModel;
    var t = this.models;
    if (t.length > 1) throw new Error("The structure is based on multiple models and has neither a master- nor a representative-model.");
    return this.state.model = t[0], this.state.model;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "masterModel", { get: function() {
    return this.state.masterModel;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "representativeModel", { get: function() {
    return this.state.representativeModel;
  }, enumerable: !1, configurable: !0 }), e.prototype.hasElement = function(t) {
    return !!this.unitMap.has(t.unit.id) && $e.has(this.unitMap.get(t.unit.id).elements, t.element);
  }, e.prototype.getModelIndex = function(t) {
    return this.models.indexOf(t);
  }, e.prototype.remapModel = function(t) {
    for (var r = this.state, n = r.dynamicBonds, a = r.interUnitBonds, i = r.parent, o = [], s = 0, u = this.unitSymmetryGroups; s < u.length; s++) {
      var c = u[s], l = c.units[0].remapModel(t, n);
      o.push(l);
      for (var d = 1, f = c.units.length; d < f; ++d) {
        var m = c.units[d];
        o.push(m.remapModel(t, n, l.props));
      }
    }
    return e.create(o, { parent: i == null ? void 0 : i.remapModel(t), label: this.label, interUnitBonds: n ? void 0 : a, dynamicBonds: n });
  }, e.prototype.asParent = function() {
    if (this._proxy) return this._proxy;
    if (this.parent) {
      var t = this.parent.coordinateSystem.isIdentity ? this.parent : e.transform(this.parent, this.parent.coordinateSystem.inverse), r = this.coordinateSystem.isIdentity ? t : e.transform(t, this.coordinateSystem.matrix);
      this._proxy = new e(r.units, r.unitMap, r.unitIndexMap, k(k({}, r.state), { dynamicBonds: this.dynamicBonds }), { child: this, target: this.parent });
    } else this._proxy = this;
    return this._proxy;
  }, Object.defineProperty(e.prototype, "child", { get: function() {
    return this._child;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    var t;
    return (t = this._target) !== null && t !== void 0 ? t : this;
  }, enumerable: !1, configurable: !0 }), e;
}();
function vre(e, t, r) {
  return e[t].id - e[r].id;
}
(function(e) {
  function t(v) {
    return { kind: "structure-loci", structure: v };
  }
  function r(v, y) {
    y === void 0 && (y = {});
    for (var _ = uc.Mutable(), S = uc.Mutable(), b = 0, x = !0, A = v.length > 0 ? v[0].id : 0, w = 0, C = v.length; w < C; w++) {
      var M = v[w];
      _.set(M.id, M), b += M.elements.length, M.id < A && (x = !1), A = M.id;
    }
    for (x || TO(v, 0, v.length, vre, zf), w = 0, C = v.length; w < C; w++) S.set(v[w].id, w);
    var T = { hashCode: -1, transformHash: -1, elementCount: b, bondCount: -1, uniqueElementCount: -1, atomicResidueCount: -1, polymerResidueCount: -1, polymerGapCount: -1, polymerUnitCount: -1, dynamicBonds: !1, coordinateSystem: Mn.Default, label: "" };
    return y.parent && (T.parent = y.parent.parent || y.parent), y.interUnitBonds && (T.interUnitBonds = y.interUnitBonds), y.dynamicBonds ? T.dynamicBonds = y.dynamicBonds : y.parent && (T.dynamicBonds = y.parent.dynamicBonds), y.coordinateSystem ? T.coordinateSystem = y.coordinateSystem : y.parent && (T.coordinateSystem = y.parent.coordinateSystem), y.label ? T.label = y.label : y.parent && (T.label = y.parent.label), y.masterModel ? T.masterModel = y.masterModel : y.parent && (T.masterModel = y.parent.masterModel), y.representativeModel ? T.representativeModel = y.representativeModel : y.parent && (T.representativeModel = y.parent.representativeModel), new e(v, _, S, T);
  }
  function n(v, y) {
    y === void 0 && (y = {});
    for (var _ = v.atomicHierarchy.chainAtomSegments, S = v.atomicHierarchy.index, b = v.atomicHierarchy.chains.auth_asym_id, x = v.atomicChainOperatorMappinng, A = new o(k({ label: v.label }, y)), w = 0; w < _.count; w++) {
      var C = x.get(w) || Mn.Default, M = _.offsets[w];
      rm.chainResidueCount(v.atomicHierarchy, w), _.offsets[w + 1], _.offsets[w];
      var T = !1;
      if (a(v, w)) for (; w + 1 < _.count && a(v, w + 1) && x.get(w) === x.get(w + 1); )
        T = !0, w++;
      else for (; w + 1 < _.count && _.offsets[w + 1] - _.offsets[w] == 1 && _.offsets[w + 2] - _.offsets[w + 1] == 1 && !(S.getEntityFromChain(w) !== S.getEntityFromChain(w + 1) || b.value(w) !== b.value(w + 1) || x.get(w) !== x.get(w + 1)); )
        T = !0, w++;
      var N = $e.ofBounds(M, _.offsets[w + 1]);
      A.addUnit(0, v, C, N, T ? 1 : 0);
    }
    var I = v.coarseHierarchy;
    return I.isDefined && (I.spheres.count > 0 && i(A, v, v.coarseHierarchy.spheres, 1), I.gaussians.count > 0 && i(A, v, v.coarseHierarchy.gaussians, 2)), A.getStructure();
  }
  function a(v, y) {
    var _ = v.atomicHierarchy.index.getEntityFromChain(y);
    return v.entities.data.type.value(_) === "water";
  }
  function i(v, y, _, S) {
    for (var b = _.chainElementSegments, x = 0; x < b.count; x++) {
      var A = $e.ofBounds(b.offsets[x], b.offsets[x + 1]);
      v.addUnit(S, y, Mn.Default, A, 0);
    }
  }
  e.Empty = r([]), e.Loci = t, e.toStructureElementLoci = function(v) {
    for (var y = [], _ = 0, S = v.units; _ < S.length; _++) {
      var b = S[_];
      y.push({ unit: b, indices: Fe.ofBounds(0, b.elements.length) });
    }
    return et(v, y);
  }, e.toSubStructureElementLoci = function(v, y) {
    return St.toLociWithSourceUnits(St.Singletons(v, y));
  }, e.isLoci = function(v) {
    return !!v && v.kind === "structure-loci";
  }, e.areLociEqual = function(v, y) {
    return v.structure === y.structure;
  }, e.isLociEmpty = function(v) {
    return v.structure.isEmpty;
  }, e.remapLoci = function(v, y) {
    return y === v.structure ? v : t(y);
  }, e.create = r, e.ofTrajectory = function(v, y) {
    return Be(this, 0, void 0, function() {
      var _, S, b, x, A, w, C, M, T, N, I, P, O;
      return Te(this, function(F) {
        switch (F.label) {
          case 0:
            if (v.frameCount === 0) return [2, e.Empty];
            _ = [], S = void 0, b = 0, x = 0, A = v.frameCount, F.label = 1;
          case 1:
            return x < A ? [4, sr.resolveInContext(v.getFrameAtIndex(x), y)] : [3, 4];
          case 2:
            for (w = F.sent(), S || (S = w), C = n(w), M = 0, T = C.units.length; M < T; ++M) N = C.units[M], I = N.invariantId + b, P = N.chainGroupId + b, O = Ke.create(_.length, I, P, N.traits, N.kind, N.model, N.conformation.operator, N.elements), _.push(O);
            b = _.length, F.label = 3;
          case 3:
            return ++x, [3, 1];
          case 4:
            return [2, r(_, { representativeModel: S, label: S.label })];
        }
      });
    });
  }, e.ofModel = n, e.transform = function(v, y) {
    if (Ee.isIdentity(y)) return v;
    if (!Ee.isRotationAndTranslation(y, Mn.RotationTranslationEpsilon)) throw new Error("Only rotation/translation combination can be applied.");
    for (var _ = [], S = 0, b = v.units; S < b.length; S++) {
      var x = b[S], A = x.conformation.operator, w = Mn.create(A.name, y, A);
      _.push(x.applyOperator(x.id, w));
    }
    var C = v.coordinateSystem;
    return r(_, { parent: v, coordinateSystem: Mn.compose(Mn.create(C.name, y, C), C) });
  };
  var o = function() {
    function v(y) {
      y === void 0 && (y = {}), this.props = y, this.units = [], this.invariantId = $i(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = D(), this.singleElementUnits = /* @__PURE__ */ new Map();
    }
    return v.prototype.beginChainGroup = function() {
      this.chainGroupId++, this.inChainGroup = !0;
    }, v.prototype.endChainGroup = function() {
      this.inChainGroup = !1;
    }, v.prototype.addUnit = function(y, _, S, b, x, A) {
      A === void 0 && (A = this.invariantId());
      var w = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, C = Ke.create(A, A, w, x, y, _, S, b);
      return this.add(C);
    }, v.prototype.add = function(y) {
      if (y.elements.length === 1) {
        y.conformation.position(y.elements[0], this.p);
        var _ = [y.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
        if (this.singleElementUnits.has(_)) return this.singleElementUnits.get(_);
        this.singleElementUnits.set(_, y);
      }
      return this.units.push(y), y;
    }, v.prototype.addWithOperator = function(y, _, S) {
      return S === void 0 && (S = !1), this.add(y.applyOperator(this.units.length, _, S));
    }, v.prototype.getStructure = function() {
      return r(this.units, this.props);
    }, Object.defineProperty(v.prototype, "isEmpty", { get: function() {
      return this.units.length === 0;
    }, enumerable: !1, configurable: !0 }), v;
  }();
  function s(v, y) {
    if (v === y) return !0;
    if (v.elementCount !== y.elementCount) return !1;
    var _ = v.units.length;
    if (_ !== y.units.length) return !1;
    for (var S = 0; S < _; S++) if (v.units[S].id !== y.units[S].id) return !1;
    return !0;
  }
  function u(v, y) {
    return v === y || v.hashCode === y.hashCode && Gp.areTransformGroupsEquivalent(v.unitSymmetryGroups, y.unitSymmetryGroups);
  }
  e.StructureBuilder = o, e.Builder = function(v) {
    return v === void 0 && (v = {}), new o(v);
  }, e.hashCode = function(v) {
    return v.hashCode;
  }, e.conformationHash = function(v) {
    return Y5(v.units.map(function(y) {
      return Ke.conformationId(y);
    }).join("|"));
  }, e.areUnitIdsEqual = s, e.areUnitIdsAndIndicesEqual = function(v, y) {
    if (!s(v, y)) return !1;
    for (var _ = 0, S = v.units.length; _ < S; _++) if (!$e.areEqual(v.units[_].elements, y.units[_].elements)) return !1;
    return !0;
  }, e.areHierarchiesEqual = function(v, y) {
    if (v.hashCode !== y.hashCode) return !1;
    var _ = v.models.length;
    if (_ !== y.models.length) return !1;
    for (var S = 0; S < _; S++) if (!yn.areHierarchiesEqual(v.models[S], y.models[S])) return !1;
    return !0;
  }, e.areEquivalent = u, e.areRootsEquivalent = function(v, y) {
    return u(v.root, y.root);
  }, e.areRootsEqual = function(v, y) {
    return v.root === y.root;
  };
  var c = function() {
    function v(y) {
      this.structure = y, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = lt.create(y), this.hasNext = y.elementCount > 0, this.hasNext && (this.elements = y.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = y.units[0]);
    }
    return v.prototype.move = function() {
      return this.advance(), this.current.element = this.elements[this.idx], this.current;
    }, v.prototype.advance = function() {
      if (this.idx < this.maxIdx) return this.idx++, void (this.idx === this.maxIdx && (this.hasNext = this.unitIndex + 1 < this.structure.units.length));
      this.idx = 0, this.unitIndex++, this.unitIndex >= this.structure.units.length ? this.hasNext = !1 : (this.current.unit = this.structure.units[this.unitIndex], this.elements = this.current.unit.elements, this.maxIdx = this.elements.length - 1, this.maxIdx === 0 && (this.hasNext = this.unitIndex + 1 < this.structure.units.length));
    }, v;
  }();
  e.ElementLocationIterator = c;
  var l = D();
  function d(v, y, _) {
    for (var S = v.elements, b = v.conformation, x = b.position, A = b.r, w = l, C = Number.MAX_VALUE, M = 0, T = S.length; M < T; M++) {
      var N = S[M], I = D.distance(y, x(N, w)) - _ - A(N);
      I < C && (C = I);
    }
    return C;
  }
  function f(v, y, _) {
    for (var S = v.units, b = Number.MAX_VALUE, x = 0, A = S.length; x < A; x++) {
      var w = d(S[x], y, _);
      w < b && (b = w);
    }
    return b;
  }
  e.minDistanceToPoint = f;
  var m, h = D();
  function p(v) {
    return v.unitSymmetryGroups.filter(function(y) {
      return y.units[0].polymerElements.length > 0;
    });
  }
  e.distance = function(v, y) {
    if (v.elementCount === 0 || y.elementCount === 0) return 0;
    for (var _ = v.units, S = Number.MAX_VALUE, b = 0, x = _.length; b < x; b++) for (var A = _[b], w = A.elements, C = A.conformation, M = C.position, T = C.r, N = 0, I = w.length; N < I; N++) {
      var P = w[N], O = f(y, M(P, h), T(P));
      O < S && (S = O);
    }
    return S;
  }, e.elementDescription = function(v) {
    return v.elementCount === 1 ? "1 element" : "".concat(v.elementCount, " elements");
  }, e.validUnitPair = function(v, y, _) {
    return !0;
  }, e.eachUnitPair = function(v, y, _) {
    var S = _.maxRadius, b = _.validUnit, x = _.validUnitPair;
    if (v.units.some(function(F) {
      return b(F);
    })) for (var A = v.lookup3d, w = D(), C = 0, M = v.units; C < M.length; C++) {
      var T = M[C];
      if (b(T)) {
        var N = T.boundary.sphere;
        D.transformMat4(w, N.center, T.conformation.operator.matrix);
        for (var I = A.findUnitIndices(w[0], w[1], w[2], N.radius + S + 9999), P = 0; P < I.count; P++) {
          var O = v.units[I.indices[P]];
          !b(O) || T.id >= O.id || !x(T, O) || (O.elements.length >= T.elements.length ? y(T, O) : y(O, T));
        }
      }
    }
  }, e.eachAtomicHierarchyElement = function(v, y) {
    for (var _ = y.chain, S = y.residue, b = y.atom, x = lt.create(v), A = 0, w = v.units; A < w.length; A++) {
      var C = w[A];
      if (C.kind === 0) {
        x.unit = C;
        for (var M = C.elements, T = nr.transientSegments(C.model.atomicHierarchy.chainAtomSegments, M), N = nr.transientSegments(C.model.atomicHierarchy.residueAtomSegments, M); T.hasNext; ) {
          var I = T.move();
          if (_ && (x.element = M[I.start], _(x)), S || b) for (N.setSegment(I); N.hasNext; ) {
            var P = N.move();
            if (S && (x.element = M[P.start], S(x)), b) for (var O = P.start, F = P.end; O < F; O++) x.element = M[O], b(x);
          }
        }
      }
    }
  }, e.DefaultSizeThresholds = { smallResidueCount: 10, mediumResidueCount: 5e3, largeResidueCount: 3e4, highSymmetryUnitCount: 10, fiberResidueCount: 15 }, function(v) {
    v[v.Small = 0] = "Small", v[v.Medium = 1] = "Medium", v[v.Large = 2] = "Large", v[v.Huge = 3] = "Huge", v[v.Gigantic = 4] = "Gigantic";
  }(m = e.Size || (e.Size = {})), e.getSize = function(v, y, _) {
    y === void 0 && (y = {}), _ === void 0 && (_ = 1);
    var S = k(k({}, e.DefaultSizeThresholds), y);
    return v.polymerResidueCount >= S.largeResidueCount * _ ? function(b, x) {
      var A = p(b);
      return A.length >= 1 && A[0].units.length > x.highSymmetryUnitCount;
    }(v, S) ? m.Huge : m.Gigantic : function(b, x) {
      var A = p(b);
      return A.length === 1 && A[0].units.length > 2 && A[0].units[0].polymerElements.length < x.fiberResidueCount;
    }(v, S) || v.polymerResidueCount < S.smallResidueCount * _ ? m.Small : v.polymerResidueCount < S.mediumResidueCount * _ ? m.Medium : m.Large;
  }, e.Index = Up.createSimple("index", "root");
  var g = "__PrincipalAxes__";
  e.getPrincipalAxes = function(v) {
    if (v.currentPropertyData[g]) return v.currentPropertyData[g];
    var y = et.getPrincipalAxes(e.toStructureElementLoci(v));
    return v.currentPropertyData[g] = y, y;
  };
})(st || (st = {}));
var nm, gre = ya.diff;
function et(e, t) {
  return { kind: "element-loci", structure: e, elements: t };
}
function yre(e) {
  return Ke.isAtomic(e.unit) ? e.unit.residueIndex[e.element] : -1;
}
function bre(e) {
  return Ke.isAtomic(e.unit) ? e.unit.chainIndex[e.element] : -1;
}
function xre(e) {
  return at.entity.key(e);
}
(function(e) {
  function t(S) {
    for (var b = 0, x = S.elements; b < x.length; b++) {
      var A = x[b];
      if (We.size(A.indices) > 0) return !1;
    }
    return !0;
  }
  function r(S) {
    for (var b = 0, x = 0, A = S.elements; x < A.length; x++) {
      var w = A[x].indices;
      b += typeof w == "number" ? gre(w) : w.length;
    }
    return b;
  }
  function n(S) {
    return t(S) ? S : e(S.structure, [{ unit: S.elements[0].unit, indices: We.ofSingleton(We.start(S.elements[0].indices)) }]);
  }
  function a(S) {
    return S.length > 3 && $e.isRange(S) ? Fe.ofRange(S[0], S[S.length - 1]) : $e.ofSortedArray(S);
  }
  function i(S, b) {
    for (var x = [], A = /* @__PURE__ */ new Set(), w = 0, C = S.elements; w < C.length; w++) {
      var M = C[w];
      if (s(M)) x[x.length] = M;
      else if (M.unit.kind === 0) {
        for (var T = M.unit.elements, N = M.unit.model.atomicHierarchy, I = M.unit.model.atomicHierarchy.atoms.label_alt_id, P = N.residueAtomSegments, O = P.index, F = P.offsets, R = [], G = M.indices, L = We.size(G), q = 0; q < L; ) {
          A.clear();
          var K = T[We.getAt(G, q)], X = O[K];
          for (A.add(I.value(K)), q++; q < L; ) {
            var H = T[We.getAt(G, q)];
            if (O[H] !== X) break;
            A.add(I.value(H)), q++;
          }
          for (var W = A.has(""), ee = F[X], $ = F[X + 1]; ee < $; ee++) {
            var te = We.indexOf(T, ee);
            if (te >= 0) {
              var re = I.value(ee);
              b && !W && re && !A.has(re) || (R[R.length] = te);
            }
          }
        }
        x[x.length] = { unit: M.unit, indices: a(R) };
      } else x[x.length] = M;
    }
    return e(S.structure, x);
  }
  function o(S) {
    switch (S.kind) {
      case 0:
        return S.model.atomicHierarchy.chainAtomSegments;
      case 1:
        return S.model.coarseHierarchy.spheres.chainElementSegments;
      case 2:
        return S.model.coarseHierarchy.gaussians.chainElementSegments;
    }
  }
  function s(S) {
    return S.unit.elements.length === We.size(S.indices);
  }
  function u(S, b, x) {
    for (var A = o(S).index, w = S.elements, C = 0, M = 0, T = w.length; M < T; M++) {
      var N = A[w[M]];
      b.has(N) && C++;
    }
    if (C !== S.elements.length) {
      var I = new Int32Array(C);
      for (C = 0, M = 0, T = w.length; M < T; M++)
        N = A[w[M]], b.has(N) && (I[C++] = M);
      I.length > 0 && (x[x.length] = { unit: S, indices: a(I) });
    } else x[x.length] = { unit: S, indices: Fe.ofBounds(0, C) };
  }
  function c(S, b, x, A, w) {
    for (var C = o(S.elements[0].unit).index, M = /* @__PURE__ */ new Set(), T = b; T < x; T++) for (var N = S.elements[T], I = N.indices, P = N.unit.elements, O = 0, F = We.size(I); O < F; O++) M.add(C[P[We.getAt(I, O)]]);
    if (A) for (var R = S.elements[0].unit, G = 0, L = S.structure.units; G < L.length; G++) {
      var q = L[G];
      Ke.areSameChainOperatorGroup(q, R) && u(q, M, w);
    }
    else for (T = b; T < x; T++) u(S.elements[T].unit, M, w);
  }
  function l(S) {
    for (var b = [], x = 0, A = S.elements.length; x < A; x++) {
      var w = S.elements[x];
      if (Ke.Traits.is(w.unit.traits, 2)) {
        for (var C = x; x < A && Ke.areSameChainOperatorGroup(S.elements[x].unit, w.unit); ) x++;
        var M = x;
        x--, c(S, C, M, !0, b);
      } else s(w) ? b[b.length] = w : c(S, x, x + 1, !1, b);
    }
    return e(S.structure, b);
  }
  function d(S) {
    return "".concat(S.unit.model.id, "|").concat(at.entity.id(S));
  }
  function f(S, b) {
    for (var x = [], A = 0, w = We.size(b); A < w; ++A) x.push(S[We.getAt(b, A)]);
    return $e.ofSortedArray(x);
  }
  function m(S, b) {
    return $e.isRange(S) && $e.areEqual(S, b) ? Fe.ofLength(S.length) : a($e.indicesOf(S, b));
  }
  e.is = function(S) {
    return !!S && S.kind === "element-loci";
  }, e.areEqual = function(S, b) {
    if (S.structure !== b.structure || S.elements.length !== b.elements.length) return !1;
    for (var x = 0, A = S.elements.length; x < A; ++x) {
      var w = S.elements[x], C = b.elements[x];
      if (w.unit.id !== C.unit.id || !We.areEqual(w.indices, C.indices)) return !1;
    }
    return !0;
  }, e.isEmpty = t, e.isWholeStructure = function(S) {
    return r(S) === S.structure.elementCount;
  }, e.size = r, e.all = function(S) {
    return e(S, S.units.map(function(b) {
      return { unit: b, indices: We.ofBounds(0, b.elements.length) };
    }));
  }, e.none = function(S) {
    return e(S, []);
  }, e.getFirstLocation = function(S, b) {
    if (!t(S)) {
      var x = S.elements[0].unit, A = x.elements[We.getAt(S.elements[0].indices, 0)];
      return b ? (b.structure = S.structure, b.unit = S.elements[0].unit, b.element = A, b) : lt.create(S.structure, x, A);
    }
  }, e.firstElement = n, e.firstResidue = function(S) {
    return t(S) ? S : i(n(S));
  }, e.firstChain = function(S) {
    return t(S) ? S : l(n(S));
  }, e.toStructure = function(S) {
    for (var b = [], x = function(C) {
      var M = C.unit, T = C.indices, N = new Int32Array(We.size(T));
      We.forEach(T, function(I, P) {
        return N[P] = M.elements[I];
      }), b.push(M.getChild($e.ofSortedArray(N)));
    }, A = 0, w = S.elements; A < w.length; A++)
      x(w[A]);
    return st.create(b, { parent: S.structure.parent });
  }, e.remap = function(S, b) {
    if (b === S.structure) return S;
    var x = [];
    return S.elements.forEach(function(A) {
      if (b.unitMap.has(A.unit.id)) {
        var w = b.unitMap.get(A.unit.id), C = We.indexedIntersect(A.indices, A.unit.elements, w.elements);
        We.size(C) > 0 && x.push({ unit: w, indices: C });
      }
    }), e(b, x);
  }, e.union = function S(b, x) {
    if (b.elements.length > x.elements.length) return S(x, b);
    if (e.isEmpty(b)) return x;
    for (var A = /* @__PURE__ */ new Map(), w = 0, C = b.elements; w < C.length; w++) {
      var M = C[w];
      A.set(M.unit.id, M.indices);
    }
    for (var T = [], N = 0, I = x.elements; N < I.length; N++)
      M = I[N], A.has(M.unit.id) ? (T[T.length] = { unit: M.unit, indices: We.union(A.get(M.unit.id), M.indices) }, A.delete(M.unit.id)) : T[T.length] = M;
    return A.forEach(function(P, O) {
      T[T.length] = { unit: b.structure.unitMap.get(O), indices: P };
    }), e(b.structure, T);
  }, e.subtract = function(S, b) {
    for (var x = /* @__PURE__ */ new Map(), A = 0, w = b.elements; A < w.length; A++) {
      var C = w[A];
      x.set(C.unit.id, C.indices);
    }
    for (var M = [], T = 0, N = S.elements; T < N.length; T++)
      if (C = N[T], x.has(C.unit.id)) {
        var I = We.subtract(C.indices, x.get(C.unit.id));
        if (We.size(I) === 0) continue;
        M[M.length] = { unit: C.unit, indices: I };
      } else M[M.length] = C;
    return e(S.structure, M);
  }, e.intersect = function(S, b) {
    for (var x = /* @__PURE__ */ new Map(), A = 0, w = S.elements; A < w.length; A++) {
      var C = w[A];
      x.set(C.unit.id, C.indices);
    }
    for (var M = [], T = 0, N = b.elements; T < N.length; T++)
      if (C = N[T], x.has(C.unit.id)) {
        var I = We.intersect(x.get(C.unit.id), C.indices);
        We.size(I) !== 0 && (M[M.length] = { unit: C.unit, indices: I });
      }
    return e(S.structure, M);
  }, e.areIntersecting = function S(b, x) {
    if (b.elements.length > x.elements.length) return S(x, b);
    if (e.isEmpty(b)) return e.isEmpty(x);
    for (var A = /* @__PURE__ */ new Map(), w = 0, C = b.elements; w < C.length; w++) {
      var M = C[w];
      A.set(M.unit.id, M.indices);
    }
    for (var T = 0, N = x.elements; T < N.length; T++)
      if (M = N[T], A.has(M.unit.id) && We.areIntersecting(A.get(M.unit.id), M.indices)) return !0;
    return !1;
  }, e.isSubset = function(S, b) {
    if (e.isEmpty(S)) return e.isEmpty(b);
    for (var x = /* @__PURE__ */ new Map(), A = 0, w = S.elements; A < w.length; A++) {
      var C = w[A];
      x.set(C.unit.id, C.indices);
    }
    for (var M = !1, T = 0, N = b.elements; T < N.length; T++)
      if (C = N[T], x.has(C.unit.id)) {
        if (!We.isSubset(x.get(C.unit.id), C.indices)) return !1;
        M = !0;
      }
    return M;
  }, e.extendToWholeResidues = i, e.extendToWholeChains = l, e.extendToWholeEntities = function(S) {
    for (var b = [], x = lt.create(S.structure), A = /* @__PURE__ */ new Set(), w = S.structure.units, C = 0, M = S.elements.length; C < M; C++) {
      var T = S.elements[C];
      x.unit = T.unit, x.element = T.unit.elements[0], A.add(d(x));
    }
    C = 0;
    for (var N = w.length; C < N; ++C) {
      var I = w[C];
      if (x.unit = I, x.element = I.elements[0], A.has(d(x))) {
        var P = We.ofBounds(0, I.elements.length);
        b[b.length] = { unit: I, indices: P };
      }
    }
    return e(S.structure, b);
  }, e.extendToWholeModels = function(S) {
    for (var b = [], x = /* @__PURE__ */ new Set(), A = S.structure.units, w = 0, C = S.elements.length; w < C; w++) {
      var M = S.elements[w];
      x.add(M.unit.model.id);
    }
    w = 0;
    for (var T = A.length; w < T; ++w) {
      var N = A[w];
      if (x.has(N.model.id)) {
        var I = We.ofBounds(0, N.elements.length);
        b[b.length] = { unit: N, indices: I };
      }
    }
    return e(S.structure, b);
  }, e.extendToAllInstances = function(S) {
    for (var b = [], x = /* @__PURE__ */ new Map(), A = 0, w = S.elements.length; A < w; A++) {
      var C = S.elements[A], M = C.unit.model, T = f(C.unit.elements, C.indices);
      x.has(M) ? x.set(M, $e.union(T, x.get(M))) : x.set(M, T);
    }
    A = 0;
    for (var N = S.structure.units.length; A < N; ++A) {
      var I = S.structure.units[A];
      if (T = x.get(I.model)) {
        var P = m(I.elements, T);
        We.size(P) && (b[b.length] = { unit: I, indices: P });
      }
    }
    return e(S.structure, b);
  }, e.extendToWholeOperators = function(S) {
    for (var b = [], x = /* @__PURE__ */ new Set(), A = S.structure.units, w = 0, C = S.elements.length; w < C; w++) {
      var M = S.elements[w];
      x.add(M.unit.conformation.operator.name);
    }
    w = 0;
    for (var T = A.length; w < T; ++w) {
      var N = A[w];
      if (x.has(N.conformation.operator.name)) {
        var I = We.ofBounds(0, N.elements.length);
        b[b.length] = { unit: N, indices: I };
      }
    }
    return e(S.structure, b);
  };
  var h = new iu("98"), p = D();
  e.getBoundary = function(S, b) {
    h.reset();
    for (var x = 0, A = S.elements; x < A.length; x++) for (var w = (F = A[x]).indices, C = F.unit.conformation.position, M = F.unit.conformation.r, T = F.unit.elements, N = 0, I = We.size(w); N < I; N++)
      C(R = T[We.getAt(w, N)], p), b && D.transformMat4(p, p, b), h.includePositionRadius(p, M(R));
    h.finishedIncludeStep();
    for (var P = 0, O = S.elements; P < O.length; P++) {
      var F;
      for (w = (F = O[P]).indices, C = F.unit.conformation.position, M = F.unit.conformation.r, T = F.unit.elements, N = 0, I = We.size(w); N < I; N++) {
        var R;
        C(R = T[We.getAt(w, N)], p), b && D.transformMat4(p, p, b), h.radiusPositionRadius(p, M(R));
      }
    }
    return { box: h.getBox(), sphere: h.getSphere() };
  };
  var g = D();
  function v(S, b, x) {
    x === void 0 && (x = 0);
    for (var A = x, w = 0, C = S.elements; w < C.length; w++) {
      for (var M = C[w], T = M.indices, N = M.unit.conformation.position, I = M.unit.elements, P = We.size(T), O = 0; O < P; O++)
        N(I[We.getAt(T, O)], g), D.toArray(g, b, A + 3 * O);
      A += 3 * P;
    }
    return b;
  }
  function y(S, b) {
    return Ke.isAtomic(S) ? S.model.atomicHierarchy.atomSourceIndex.value(b) : b;
  }
  function _(S, b, x, A, w) {
    Du(b);
    for (var C = [], M = [], T = 0, N = b.length; T < N; ) {
      var I = T;
      for (T++; T < N && b[T - 1] + 1 === b[T]; ) T++;
      var P = T;
      if (P - I > 12) C[C.length] = b[I], C[C.length] = b[P - 1];
      else for (var O = I; O < P; O++) M[M.length] = b[O];
    }
    return x ? { atom: { set: M, ranges: C }, chain: { opName: [S] }, entity: { modelLabel: A, modelIndex: w } } : { atom: { set: M, ranges: C }, chain: { opName: [S] } };
  }
  e.toPositionsArray = v, e.getPrincipalAxes = function(S) {
    var b = r(S), x = v(S, new Float32Array(3 * b));
    return Od.ofPositions(x);
  }, e.getPrincipalAxesMany = function(S) {
    var b = 0;
    S.forEach(function(w) {
      b += r(w);
    });
    var x = new Float32Array(3 * b), A = 0;
    return S.forEach(function(w) {
      v(w, x, A), A += 3 * r(w);
    }), Od.ofPositions(x);
  }, e.toExpression = function(S) {
    var b;
    if (e.isEmpty(S)) return zt.struct.generator.empty();
    for (var x = S.structure.models, A = /* @__PURE__ */ new Map(), w = 0, C = S.elements; w < C.length; w++) {
      var M = (q = C[w]).indices, T = q.unit.elements, N = q.unit.conformation.operator.name, I = void 0;
      A.has(N) ? I = A.get(N).xs : (I = Sn.create(), A.set(N, { modelLabel: q.unit.model.label, modelIndex: q.unit.model.modelNum, xs: I }));
      for (var P = 0, O = We.size(M); P < O; P++) {
        var F = y(q.unit, T[We.getAt(M, P)]);
        Sn.add(I, F, F);
      }
    }
    for (var R = [], G = A.keys(); ; ) {
      var L = G.next();
      if (L.done) break;
      var q = A.get(L.value);
      R.push(_(L.value, q.xs.array, x.length > 1, q.modelLabel, q.modelIndex));
    }
    for (var K = /* @__PURE__ */ new Map(), X = (P = 0, R.length); P < X; ++P) {
      var H = R[P], W = d1(Zi(H.atom.ranges), Zi(H.atom.set));
      N = "".concat(W, "|").concat(H.entity ? H.entity.modelLabel + H.entity.modelIndex : ""), K.has(N) ? (b = K.get(N).chain.opName).push.apply(b, H.chain.opName) : K.set(N, H);
    }
    var ee = [];
    return K.forEach(function($) {
      var te = $.atom, re = te.ranges, ie = te.set, oe = $.chain.opName, se = zt.struct.atomProperty.core.operatorName(), he = zt.struct.atomProperty.core.sourceIndex(), ge = [];
      ie.length > 0 && (ge[ge.length] = zt.core.set.has([zt.core.type.set(ie), he]));
      for (var De = 0, ae = re.length / 2; De < ae; De++) ge[ge.length] = zt.core.rel.inRange([he, re[2 * De], re[2 * De + 1]]);
      if ($.entity) {
        var ce = $.entity, _e = ce.modelLabel, le = ce.modelIndex;
        ee.push(zt.struct.generator.atomGroups({ "atom-test": ge.length > 1 ? zt.core.logic.or(ge) : ge[0], "chain-test": oe.length > 1 ? zt.core.set.has([zt.core.type.set(oe), se]) : zt.core.rel.eq([se, oe[0]]), "entity-test": zt.core.logic.and([zt.core.rel.eq([zt.struct.atomProperty.core.modelLabel(), _e]), zt.core.rel.eq([zt.struct.atomProperty.core.modelIndex(), le])]) }));
      } else ee.push(zt.struct.generator.atomGroups({ "atom-test": ge.length > 1 ? zt.core.logic.or(ge) : ge[0], "chain-test": oe.length > 1 ? zt.core.set.has([zt.core.type.set(oe), se]) : zt.core.rel.eq([se, oe[0]]) }));
    }), zt.struct.modifier.union([ee.length === 1 ? ee[0] : zt.struct.combinator.merge(ee.map(function($) {
      return zt.struct.modifier.union([$]);
    }))]);
  };
})(et || (et = {})), function(e) {
  function t() {
    return { elementCount: 0, conformationCount: 0, residueCount: 0, chainCount: 0, unitCount: 0, structureCount: 0, firstElementLoc: lt.create(void 0), firstConformationLoc: lt.create(void 0), firstResidueLoc: lt.create(void 0), firstChainLoc: lt.create(void 0), firstUnitLoc: lt.create(void 0), firstStructureLoc: lt.create(void 0) };
  }
  function r(o, s, u) {
    var c = o.get(s) || 0;
    o.set(s, c + u);
  }
  function n(o, s, u) {
    var c = u.indices, l = u.unit, d = l.elements, f = We.size(c), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
    if (f > 0 && lt.set(o.firstElementLoc, s, l, d[We.start(c)]), f === d.length) o.unitCount += 1, o.unitCount === 1 && lt.set(o.firstUnitLoc, s, l, d[We.start(c)]);
    else if (f === 1) {
      if (Ke.Traits.is(l.traits, 1)) return;
      o.elementCount += 1, o.elementCount === 1 && lt.set(o.firstElementLoc, s, l, d[We.start(c)]);
    } else if (Ke.isAtomic(l)) for (var p = l.model.atomicHierarchy.residueAtomSegments, g = p.index, v = p.offsets, y = l.model.atomicHierarchy.atoms.label_alt_id, _ = 0, S = function() {
      m.clear();
      var b = 0, x = d[We.getAt(c, _)], A = g[x];
      for (r(m, y.value(x), 1), ++_, ++b; _ < f; ) {
        var w = d[We.getAt(c, _)];
        if (g[w] !== A) break;
        r(m, y.value(w), 1), ++_, ++b;
      }
      if (v[A + 1] - v[A] === b) o.residueCount += 1, o.residueCount === 1 && lt.set(o.firstResidueLoc, s, l, v[A]);
      else {
        h.clear();
        for (var C = v[A], M = v[A + 1]; C < M; ++C) r(h, y.value(C), 1);
        h.get("") === m.get("") && m.forEach(function(T, N) {
          if (h.get(N) === T) {
            if (N !== "" && (o.conformationCount += 1, o.conformationCount === 1)) {
              for (var I = v[A], P = v[A + 1]; I < P; ++I) if (N === y.value(I)) {
                lt.set(o.firstConformationLoc, s, l, I);
                break;
              }
            }
            b -= T;
          }
        }), o.elementCount += b;
      }
    }; _ < f; ) S();
    else o.elementCount += f, o.elementCount === 1 && lt.set(o.firstElementLoc, s, l, d[We.start(c)]);
  }
  function a(o, s, u) {
    var c = u.indices, l = u.unit, d = We.size(c);
    if (d !== 0) {
      var f = l.elements;
      if (Ke.Traits.is(l.traits, 1)) {
        var m = Ke.isAtomic(l) ? l.model.atomicHierarchy.chainAtomSegments : Ke.isSpheres(l) ? l.model.coarseHierarchy.spheres.chainElementSegments : Ke.isGaussians(l) ? l.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
        if (m) for (var h = m.index, p = m.offsets, g = 0; g < d; ) {
          var v = 0, y = f[We.getAt(c, g)], _ = h[y];
          for (++g, ++v; g < d && h[f[We.getAt(c, g)]] === _; )
            ++g, ++v;
          p[_ + 1] - p[_] === v ? (o.chainCount += 1, o.chainCount === 1 && lt.set(o.firstChainLoc, s, l, p[_])) : d === 1 && (o.elementCount += 1, o.elementCount === 1 && lt.set(o.firstElementLoc, s, l, y));
        }
        else console.warn("StructureElement loci stats: unknown unit type");
      } else d === f.length && (o.chainCount += 1, o.chainCount === 1 && lt.set(o.firstChainLoc, s, l, f[We.start(c)]));
    }
  }
  function i(o, s, u, c, l) {
    var d = u[c], f = Ke.isAtomic(d.unit) ? d.unit.model.atomicHierarchy.chainAtomSegments : Ke.isSpheres(d.unit) ? d.unit.model.coarseHierarchy.spheres.chainElementSegments : Ke.isGaussians(d.unit) ? d.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (f) {
      for (var m = f.index, h = f.offsets, p = /* @__PURE__ */ new Map(), g = c; g < l; g++) {
        var v = (d = u[g]).indices, y = d.unit;
        if ((w = We.size(v)) !== 0) {
          var _ = y.elements;
          if (Ke.Traits.is(y.traits, 1)) for (var S = 0; S < w; ) {
            var b = 0, x = m[C = _[We.getAt(v, S)]];
            for (++S, ++b; S < w && m[_[We.getAt(v, S)]] === x; )
              ++S, ++b;
            r(p, x, b);
          }
          else r(p, m[C = _[We.start(v)]], _.length);
        }
      }
      var A = -1;
      if (p.forEach(function(M, T) {
        h[T + 1] - h[T] === M && (o.chainCount += 1, o.chainCount === 1 && (A = T));
      }), !(A < 0)) for (g = c; g < l; g++) {
        var w;
        if (v = (d = u[g]).indices, y = d.unit, (w = We.size(v)) !== 0) for (_ = y.elements, S = 0; S < w; ) {
          var C;
          if ((x = m[C = _[We.getAt(v, S)]]) === A) return void lt.set(o.firstChainLoc, s, y, C);
        }
      }
    } else console.warn("StructureElement loci stats: unknown unit type");
  }
  e.create = t, e.ofLoci = function(o) {
    var s = t();
    if (et.isEmpty(o)) return s;
    var u = !1;
    if (et.isWholeStructure(o)) {
      if (s.structureCount += 1, s.structureCount === 1) {
        var c = o.elements[0], l = c.unit, d = c.indices;
        lt.set(s.firstStructureLoc, o.structure, l, l.elements[We.min(d)]);
      }
    } else for (var f = 0, m = o.elements; f < m.length; f++) {
      var h = m[f];
      n(s, o.structure, h), Ke.Traits.is(h.unit.traits, 2) ? u = !0 : a(s, o.structure, h);
    }
    if (u) {
      for (var p = 0, g = o.elements.length; p < g; p++)
        if (h = o.elements[p], Ke.Traits.is(h.unit.traits, 2)) {
          for (var v = p; p < g && Ke.areSameChainOperatorGroup(o.elements[p].unit, h.unit); ) p++;
          var y = p;
          p--, y - v == 1 ? a(s, o.structure, h) : i(s, o.structure, o.elements, v, y);
        }
    }
    return s;
  }, e.add = function(o, s, u) {
    return s.elementCount === 1 && u.elementCount === 0 ? lt.copy(o.firstElementLoc, s.firstElementLoc) : s.elementCount === 0 && u.elementCount === 1 && lt.copy(o.firstElementLoc, u.firstElementLoc), s.conformationCount === 1 && u.conformationCount === 0 ? lt.copy(o.firstConformationLoc, s.firstConformationLoc) : s.conformationCount === 0 && u.conformationCount === 1 && lt.copy(o.firstConformationLoc, u.firstConformationLoc), s.residueCount === 1 && u.residueCount === 0 ? lt.copy(o.firstResidueLoc, s.firstResidueLoc) : s.residueCount === 0 && u.residueCount === 1 && lt.copy(o.firstResidueLoc, u.firstResidueLoc), s.chainCount === 1 && u.chainCount === 0 ? lt.copy(o.firstChainLoc, s.firstChainLoc) : s.chainCount === 0 && u.chainCount === 1 && lt.copy(o.firstChainLoc, u.firstChainLoc), s.unitCount === 1 && u.unitCount === 0 ? lt.copy(o.firstUnitLoc, s.firstUnitLoc) : s.unitCount === 0 && u.unitCount === 1 && lt.copy(o.firstUnitLoc, u.firstUnitLoc), s.structureCount === 1 && u.structureCount === 0 ? lt.copy(o.firstStructureLoc, s.firstStructureLoc) : s.structureCount === 0 && u.structureCount === 1 && lt.copy(o.firstStructureLoc, u.firstStructureLoc), o.elementCount = s.elementCount + u.elementCount, o.conformationCount = s.conformationCount + u.conformationCount, o.residueCount = s.residueCount + u.residueCount, o.chainCount = s.chainCount + u.chainCount, o.unitCount = s.unitCount + u.unitCount, o.structureCount = s.structureCount + u.structureCount, o;
  };
}(nm || (nm = {}));
var Dp, DC;
(function(e) {
  function t(r) {
    var n = this, a = r.descriptor.name, i = r.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", o = function(u) {
      return a in u[i] || (u[i][a] = { props: k({}, V.getDefaultValues(r.getParams(u))), data: _d.create(void 0) }), u[i][a];
    }, s = function(u, c, l) {
      var d = o(u);
      u[i][a] = { props: c, data: _d.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(u) {
      var c = V.clone(r.getParams(u));
      return V.setDefaultValues(c, o(u).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), Be(n, 0, void 0, function() {
        var f, m, h, p, g;
        return Te(this, function(v) {
          switch (v.label) {
            case 0:
              return d && c.customProperties.reference(r.descriptor, !0), f = o(c), m = V.merge(r.defaultParams, f.props, l), f.data.value && V.areEqual(r.defaultParams, f.props, m) ? [2] : [4, r.obtain(u, c, m)];
            case 1:
              return h = v.sent(), p = h.value, g = h.assets, c.customProperties.add(r.descriptor), c.customProperties.assets(r.descriptor, g), s(c, m, p), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customProperties.reference(r.descriptor, c);
    }, get: function(u) {
      var c;
      return (c = o(u)) === null || c === void 0 ? void 0 : c.data;
    }, set: function(u, c) {
      c === void 0 && (c = {});
      var l = o(u), d = V.merge(r.defaultParams, l.props, c);
      V.areEqual(r.defaultParams, l.props, d) || (s(u, d, void 0), u.customProperties.assets(r.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(r, n, a) {
    var i = this, o = { value: V.Value(a, { isHidden: !0 }) };
    return t({ label: ac(r), descriptor: Tu({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: V.Value(a, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return Be(i, 0, void 0, function() {
        var l;
        return Te(this, function(d) {
          return [2, { value: (l = c.value) !== null && l !== void 0 ? l : a }];
        });
      });
    } });
  };
})(Dp || (Dp = {})), function(e) {
  var t = this;
  function r(a) {
    if (!Dn.is(a.sourceData)) return !1;
    var i = a.sourceData.data.db.atom_site, o = i.pdbx_sifts_xref_db_name, s = i.pdbx_sifts_xref_db_acc, u = i.pdbx_sifts_xref_db_num, c = i.pdbx_sifts_xref_db_res;
    return o.isDefined && s.isDefined && u.isDefined && c.isDefined;
  }
  function n(a) {
    if (Dn.is(a.sourceData)) {
      var i = a.sourceData.data.db.atom_site, o = i.pdbx_sifts_xref_db_name, s = i.pdbx_sifts_xref_db_acc, u = i.pdbx_sifts_xref_db_num, c = i.pdbx_sifts_xref_db_res;
      if (o.isDefined && s.isDefined && u.isDefined && c.isDefined) {
        for (var l = a.atomicHierarchy.atomSourceIndex, d = a.atomicHierarchy.residueAtomSegments, f = d.count, m = d.offsets, h = new Array(f), p = new Array(f), g = new Array(f), v = new Array(f), y = 0; y < f; y++) {
          var _ = l.value(m[y]);
          o.valueKind(_) === 0 ? (h[y] = o.value(_), p[y] = s.value(_), g[y] = u.value(_), v[y] = c.value(_)) : (h[y] = "", p[y] = "", g[y] = "", v[y] = "");
        }
        return { dbName: h, accession: p, num: g, residue: v };
      }
    }
  }
  e.Provider = Dp.createProvider({ label: "SIFTS Mapping", descriptor: Tu({ name: "sifts_sequence_mapping" }), type: "static", defaultParams: {}, getParams: function() {
    return {};
  }, isApplicable: function(a) {
    return r(a);
  }, obtain: function(a, i) {
    return Be(t, 0, void 0, function() {
      return Te(this, function(o) {
        return [2, { value: n(i) }];
      });
    });
  } }), e.isAvailable = r, e.getKey = function(a) {
    var i = a.unit.model, o = e.Provider.get(i).value;
    if (!o) return "";
    var s = a.unit.elements[a.element], u = i.atomicHierarchy.residueAtomSegments.index[s];
    return o.accession[u];
  }, e.getLabel = function(a) {
    var i = a.unit.model, o = e.Provider.get(i).value;
    if (o) {
      var s = a.unit.elements[a.element], u = i.atomicHierarchy.residueAtomSegments.index[s], c = o.dbName[u];
      if (c) return "".concat(c, " ").concat(o.accession[u], " ").concat(o.num[u], " ").concat(o.residue[u]);
    }
  };
}(DC || (DC = {})), Xa.Field;
Xa.Encodings;
Xa.Field;
Xa.Category;
Xa.Category;
var MC;
Xa.Category;
(function(e) {
  e.create = function(t) {
    var r = Array.isArray(t) ? t : [t];
    return { structures: r, firstModel: r[0].model, cache: /* @__PURE__ */ Object.create(null) };
  };
})(MC || (MC = {}));
var IC;
(function(e) {
  e.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
})(IC || (IC = {}));
var _re = { molstar_atom_site_operator_mapping: { label_asym_id: pe.Schema.Str(), auth_asym_id: pe.Schema.Str(), operator_name: pe.Schema.Str(), suffix: pe.Schema.Str(), assembly_id: pe.Schema.Str(), assembly_operator_id: pe.Schema.Int(), symmetry_operator_index: pe.Schema.Int(), symmetry_hkl: pe.Schema.Vector(3), ncs_id: pe.Schema.Int() } }, TC = function(e, t) {
  return t[e].operator.assembly === void 0 ? 1 : 0;
}, K4 = function(e, t) {
  return t[e].operator.spgrOp === -1 ? 1 : 0;
};
Xa.fields().str("label_asym_id", function(e, t) {
  return t[e].label_asym_id;
}).str("auth_asym_id", function(e, t) {
  return t[e].auth_asym_id;
}).str("operator_name", function(e, t) {
  return t[e].operator.name;
}).str("suffix", function(e, t) {
  return t[e].operator.suffix;
}).str("assembly_id", function(e, t) {
  var r;
  return ((r = t[e].operator.assembly) === null || r === void 0 ? void 0 : r.id) || "";
}, { valueKind: TC }).int("assembly_operator_id", function(e, t) {
  var r;
  return ((r = t[e].operator.assembly) === null || r === void 0 ? void 0 : r.operId) || 0;
}, { valueKind: TC }).int("symmetry_operator_index", function(e, t) {
  return t[e].operator.spgrOp;
}, { valueKind: K4 }).vec("symmetry_hkl", [function(e, t) {
  return t[e].operator.hkl[0];
}, function(e, t) {
  return t[e].operator.hkl[1];
}, function(e, t) {
  return t[e].operator.hkl[2];
}], { valueKind: K4 }).int("ncs_id", function(e, t) {
  return t[e].operator.ncsId;
}, { valueKind: K4 }).getFields();
function Y0(e, t) {
  return t ? t.length === 1 ? eu(t.charCodeAt(0), e) : t.length === 2 ? eu(t.charCodeAt(0), eu(t.charCodeAt(1), e)) : "".concat(e, " ").concat(t) : e;
}
function Sre(e, t, r, n) {
  if (e.has(t))
    (a = e.get(t)).has(r) || a.set(r, n);
  else {
    var a = /* @__PURE__ */ new Map();
    e.set(t, a), a.set(r, n);
  }
}
function Are(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
var Z1 = S6.EmptyResidueKey(), wre = function() {
  function e(t) {
    this.map = t, this.entityIndex = t.entities.getEntityIndex, this.residueOffsets = this.map.segments.residueAtomSegments.offsets;
  }
  return e.prototype.getEntityFromChain = function(t) {
    return this.map.chain_index_entity_index[t];
  }, e.prototype.findEntity = function(t) {
    var r = this.map.label_asym_id.get(t);
    return r !== void 0 ? r : -1;
  }, e.prototype.findChainLabel = function(t) {
    var r = this.entityIndex(t.label_entity_id);
    if (r < 0 || !this.map.entity_index_label_asym_id.has(r)) return -1;
    var n = this.map.entity_index_label_asym_id.get(r);
    return n && n.has(t.label_asym_id) ? n.get(t.label_asym_id) : -1;
  }, e.prototype.findChainAuth = function(t) {
    if (!this.map.auth_asym_id_auth_seq_id.has(t.auth_asym_id)) return -1;
    var r = this.map.auth_asym_id_auth_seq_id.get(t.auth_asym_id);
    return r.has(t.auth_seq_id) ? r.get(t.auth_seq_id) : -1;
  }, e.prototype.findResidue = function(t, r, n, a) {
    var i;
    arguments.length === 1 ? i = t : (Z1.label_entity_id = t, Z1.label_asym_id = r, Z1.auth_seq_id = n, Z1.pdbx_PDB_ins_code = a, i = Z1);
    var o = this.findChainLabel(i);
    if (o < 0) return -1;
    var s = this.map.chain_index_auth_seq_id.get(o), u = Y0(i.auth_seq_id, i.pdbx_PDB_ins_code || "");
    return s.has(u) ? s.get(u) : -1;
  }, e.prototype.findResidueAuth = function(t) {
    var r = this.findChainAuth(t);
    if (r < 0) return -1;
    var n = this.map.chain_index_auth_seq_id.get(r), a = Y0(t.auth_seq_id, t.pdbx_PDB_ins_code || "");
    return n.has(a) ? n.get(a) : -1;
  }, e.prototype.findResidueInsertion = function(t) {
    var r = this.findChainLabel(t);
    if (r < 0) return -1;
    var n = this.map.chain_index_label_seq_id.get(r), a = Y0(t.label_seq_id, t.pdbx_PDB_ins_code || "");
    if (n.has(a)) return n.get(a);
    var i = $e.findPredecessorIndex(this.map.label_seq_id, t.label_seq_id), o = rm.chainStartResidueIndex(this.map.segments, r);
    if (i < o) return o;
    var s = rm.chainEndResidueIndexExcl(this.map.segments, r) - 1;
    return i >= s ? s : i;
  }, e.prototype.findAtom = function(t) {
    var r = this.findResidue(t);
    return r < 0 ? -1 : t.label_alt_id === void 0 ? X4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, t.label_atom_id) : j4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, this.map.label_alt_id, t.label_atom_id, t.label_alt_id);
  }, e.prototype.findAtomAuth = function(t) {
    var r = this.findResidueAuth(t);
    return r < 0 ? -1 : t.label_alt_id === void 0 ? X4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, t.auth_atom_id) : j4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, this.map.label_alt_id, t.auth_atom_id, t.label_alt_id);
  }, e.prototype.findAtomOnResidue = function(t, r, n) {
    return n === void 0 ? X4(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, r) : j4(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, this.map.label_alt_id, r, n);
  }, e.prototype.findAtomsOnResidue = function(t, r) {
    return function(n, a, i, o) {
      for (var s = n; s < a; s++) if (o.has(i.value(s))) return s;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, r);
  }, e.prototype.findElementOnResidue = function(t, r) {
    return function(n, a, i, o) {
      for (var s = n; s < a; s++) if (i.value(s) === o) return s;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.type_symbol, r);
  }, e;
}();
function X4(e, t, r, n) {
  for (var a = e; a < t; a++) if (r.value(a) === n) return a;
  return -1;
}
function j4(e, t, r, n, a, i) {
  for (var o = e; o < t; o++) if (r.value(o) === a && n.value(o) === i) return o;
  return -1;
}
function Cre(e, t, r) {
  for (var n = function(M, T, N) {
    return { entities: M, segments: N, label_seq_id: $e.ofSortedArray(T.residues.label_seq_id.toArray({ array: Int32Array })), label_atom_id: T.atoms.label_atom_id, auth_atom_id: T.atoms.auth_atom_id, label_alt_id: T.atoms.label_alt_id, type_symbol: T.atoms.type_symbol, chain_index_entity_index: new Int32Array(T.chains._rowCount), entity_index_label_asym_id: /* @__PURE__ */ new Map(), chain_index_label_seq_id: /* @__PURE__ */ new Map(), auth_asym_id_auth_seq_id: /* @__PURE__ */ new Map(), chain_index_auth_seq_id: /* @__PURE__ */ new Map(), label_asym_id: /* @__PURE__ */ new Map() };
  }(t, e, r), a = e.residues, i = a.label_seq_id, o = a.auth_seq_id, s = a.pdbx_PDB_ins_code, u = e.chains, c = u.label_entity_id, l = u.label_asym_id, d = u.auth_asym_id, f = Fe.ofBounds(0, e.atoms._rowCount), m = nr.transientSegments(r.chainAtomSegments, f); m.hasNext; ) {
    var h = m.move(), p = h.index, g = t.getEntityIndex(c.value(p));
    g < 0 && Are(c.value(p)), n.chain_index_entity_index[p] = g;
    var v = d.value(p), y = n.auth_asym_id_auth_seq_id.get(v);
    y || (y = /* @__PURE__ */ new Map(), n.auth_asym_id_auth_seq_id.set(v, y));
    var _ = l.value(p);
    n.label_asym_id.has(_) || n.label_asym_id.set(_, g), Sre(n.entity_index_label_asym_id, g, _, p);
    var S = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
    n.chain_index_label_seq_id.set(p, S), n.chain_index_auth_seq_id.set(p, b);
    for (var x = nr.transientSegments(r.residueAtomSegments, f, h); x.hasNext; ) {
      var A = x.move().index, w = o.value(A), C = s.value(A);
      S.set(Y0(i.value(A), C), A), b.set(Y0(w, C), A), y.set(w, p);
    }
  }
  return new wre(n);
}
function Ere(e, t, r, n, a, i) {
  var o = function(f) {
    if (f._rowCount === 0) return { residues: [], chains: [] };
    for (var m = f._rowCount, h = [0], p = [0], g = f.label_entity_id, v = f.label_asym_id, y = f.label_seq_id, _ = f.auth_seq_id, S = f.pdbx_PDB_ins_code, b = 1; b < m; b++) {
      var x = !g.areValuesEqual(b - 1, b) || !v.areValuesEqual(b - 1, b);
      (x || !y.areValuesEqual(b - 1, b) || !_.areValuesEqual(b - 1, b) || !S.areValuesEqual(b - 1, b)) && (h[h.length] = b), x && (p[p.length] = b);
    }
    return { residues: h, chains: p };
  }(e), s = function(f, m, h) {
    var p = Yr.ofColumns(yte, { type_symbol: pe.ofArray({ array: pe.mapToArray(f.type_symbol, Rp), schema: pe.Schema.Aliased(pe.Schema.str) }), label_atom_id: f.label_atom_id, auth_atom_id: f.auth_atom_id, label_alt_id: f.label_alt_id, label_comp_id: f.label_comp_id, auth_comp_id: f.auth_comp_id, pdbx_formal_charge: f.pdbx_formal_charge, cdr: f.cdr, B_iso_or_equiv: f.B_iso_or_equiv, em_confidence: f.em_confidence }), g = Yr.view(f, bte, h.residues), v = Yr.view(f, xte, h.chains);
    if (!g.label_seq_id.isDefined) {
      for (var y = new Int32Array(g.label_seq_id.rowCount), _ = h.residues, S = h.chains, b = 0, x = 0, A = 0, w = y.length; A < w; ++A) _[A] >= S[b + 1] && (b += 1, x = 0), y[A] = ++x;
      g.label_seq_id = pe.ofIntArray(y);
    }
    return Yr.columnToArray(g, "label_seq_id", Int32Array), Yr.columnToArray(g, "auth_seq_id", Int32Array), { atoms: p, residues: g, chains: v, atomSourceIndex: m };
  }(e, t, o), u = function(f, m) {
    var h = /* @__PURE__ */ new Map();
    if (!Dn.is(m)) return h;
    var p = Bf(_re, m.data.frame).molstar_atom_site_operator_mapping;
    if (p._rowCount === 0) return h;
    for (var g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), y = 0; y < p._rowCount; y++) {
      var _ = p.assembly_operator_id.valueKind(y) === 0 ? { id: p.assembly_id.value(y), operList: [], operId: p.assembly_operator_id.value(y) } : void 0, S = Mn.create(p.operator_name.value(y), Ee.identity(), { assembly: _, spgrOp: p.symmetry_operator_index.valueKind(y) === 0 ? p.symmetry_operator_index.value(y) : void 0, hkl: D.ofArray(p.symmetry_hkl.value(y)), ncsId: p.ncs_id.value(y) }), b = p.suffix.value(y), x = p.label_asym_id.value(y);
      g.set("".concat(x).concat(b), { name: x, operator: S });
      var A = p.auth_asym_id.value(y);
      v.set("".concat(A).concat(b), A);
    }
    var w = f.chains, C = w.label_asym_id, M = w.auth_asym_id, T = new Array(C.rowCount), N = new Array(C.rowCount);
    for (y = 0; y < C.rowCount; y++) if (x = C.value(y), A = M.value(y), g.has(x)) {
      var I = g.get(x), P = I.name;
      S = I.operator, h.set(y, S), T[y] = P, N[y] = v.get(A) || A;
    } else T[y] = x, N[y] = A;
    return f.chains.label_asym_id = pe.ofArray({ array: T, valueKind: f.chains.label_asym_id.valueKind, schema: f.chains.label_asym_id.schema }), f.chains.auth_asym_id = pe.ofArray({ array: N, valueKind: f.chains.auth_asym_id.valueKind, schema: f.chains.auth_asym_id.schema }), h;
  }(s, a);
  if (i && function(f, m) {
    return Yr.areEqual(f.chains, m.chains) && Yr.areEqual(f.residues, m.residues) && Yr.areEqual(f.atoms, m.atoms);
  }(i.atomicHierarchy, s)) return { sameAsPrevious: !0, hierarchy: i.atomicHierarchy, chainOperatorMapping: u };
  var c = { residueAtomSegments: nr.ofOffsets(o.residues, Fe.ofBounds(0, e._rowCount)), chainAtomSegments: nr.ofOffsets(o.chains, Fe.ofBounds(0, e._rowCount)) }, l = Cre(s, r, c), d = function(f, m, h, p) {
    for (var g = f.atoms, v = g.label_comp_id, y = g.type_symbol, _ = g._rowCount, S = f.residues._rowCount, b = m.residueAtomSegments.offsets, x = new Uint8Array(_), A = 0; A < _; ++A) x[A] = lh(y.value(A));
    var w = new Int32Array(S), C = new Int32Array(S), M = new Int32Array(S), T = new Uint8Array(S), N = new Uint8Array(S), I = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map();
    for (A = 0; A < S; ++A) {
      var O = v.value(b[A]), F = p, R = void 0, G = void 0;
      if (I.has(O)) R = I.get(O), G = P.get(O);
      else {
        var L = void 0;
        F.has(O) ? L = F.get(O).type : (YO || console.info("chemComp not found", O), L = LF(O)), G = nee(L, R = Fh(L, O)), I.set(O, R), P.set(O, G);
      }
      T[A] = R, N[A] = G;
      var q = Ed(G, "trace"), K = h.findAtomsOnResidue(A, q);
      if (K === -1) {
        var X = Ed(G, "coarseBackbone");
        (K = h.findAtomsOnResidue(A, X)) === -1 && C8(R) && (K = h.findElementOnResidue(A, Rp("C")));
      }
      w[A] = K;
      var H = Ed(G, "directionFrom");
      C[A] = h.findAtomsOnResidue(A, H);
      var W = Ed(G, "directionTo");
      M[A] = h.findAtomsOnResidue(A, W);
    }
    return { atom: { atomicNumber: x }, residue: { traceElementIndex: w, directionFromElementIndex: C, directionToElementIndex: M, moleculeType: T, polymerType: N } };
  }(s, c, l, n);
  return { sameAsPrevious: !1, hierarchy: k(k(k({}, s), c), { index: l, derived: d }), chainOperatorMapping: u };
}
function dR(e, t, r, n, a, i) {
  var o = Ere(e, t, r, n, a, i), s = o.sameAsPrevious, u = o.hierarchy, c = o.chainOperatorMapping, l = function(d) {
    return { id: Fa.create22(), atomId: d.id, occupancy: d.occupancy.isDefined ? d.occupancy : pe.ofConst(1, d._rowCount, pe.Schema.float), B_iso_or_equiv: d.B_iso_or_equiv, xyzDefined: d.Cartn_x.isDefined && d.Cartn_y.isDefined && d.Cartn_z.isDefined, x: d.Cartn_x.toArray({ array: Float32Array }), y: d.Cartn_y.toArray({ array: Float32Array }), z: d.Cartn_z.toArray({ array: Float32Array }) };
  }(e);
  return { sameAsPrevious: s, hierarchy: u, conformation: l, chainOperatorMapping: c };
}
var C6, NC = { chainKey: [], entityKey: [], findSequenceKey: function() {
  return -1;
}, findChainKey: function() {
  return -1;
}, getEntityFromChain: function() {
  return -1;
}, count: 0, entity_id: pe.Undefined(0, pe.Schema.str), asym_id: pe.Undefined(0, pe.Schema.str), seq_id_begin: pe.Undefined(0, pe.Schema.int), seq_id_end: pe.Undefined(0, pe.Schema.int), chainElementSegments: nr.create([]), polymerRanges: cn.ofSortedRanges([]), gapRanges: cn.ofSortedRanges([]) };
function Dre(e, t, r) {
  if (e.has(t)) return e.get(t);
  var n = r.index++;
  return e.set(t, n), n;
}
function Mre(e, t) {
  if (e.has(t)) return e.get(t);
  var r = /* @__PURE__ */ new Map();
  return e.set(t, r), r;
}
function Ire(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
function PC(e, t) {
  for (var r = e.entity_id, n = e.asym_id, a = e.seq_id_begin, i = e.seq_id_end, o = e.count, s = e.chainElementSegments, u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = { index: 0 }, d = new Int32Array(o), f = new Int32Array(o), m = new Int32Array(s.count), h = 0; h < o; h++) f[h] = t.getEntityIndex(r.value(h)), f[h] < 0 && Ire(r.value(h));
  for (var p = 0; p < s.count; p++) {
    var g = s.offsets[p], v = s.offsets[p + 1], y = f[g];
    m[p] = y;
    var _ = Dre(Mre(c, y), n.value(g), l);
    for (h = g; h < v; h++) d[h] = _;
    var S = [], b = [];
    for (h = g; h < v; h++) {
      var x = a.value(h), A = i.value(h);
      S.push(h), b.push(x, A);
    }
    var w = { elementIndices: S, seqRanges: cn.ofSortedRanges(b) };
    u.set(_, w);
  }
  var C = function(T, N, I) {
    var P = T.getEntityIndex;
    return { findChainKey: function(O, F) {
      var R = P(O);
      if (R < 0) return -1;
      var G = N.get(R);
      return G.has(F) ? G.get(F) : -1;
    }, findSequenceKey: function(O, F, R) {
      var G = P(O);
      if (G < 0) return -1;
      var L = N.get(G);
      if (L === void 0) return -1;
      var q = L.get(F);
      if (q === void 0) return -1;
      var K = I.get(q), X = K.elementIndices, H = K.seqRanges, W = cn.firstIntersectionIndex(H, We.ofSingleton(R));
      return W !== -1 ? X[W] : -1;
    } };
  }(t, c, u), M = C.findChainKey;
  return { chainKey: d, entityKey: f, findSequenceKey: C.findSequenceKey, findChainKey: M, getEntityFromChain: function(T) {
    return m[T];
  } };
}
function BC(e, t) {
  for (var r = [], n = [], a = nr.transientSegments(e.chainElementSegments, Fe.ofBounds(0, e.count)), i = e.seq_id_begin, o = e.seq_id_end; a.hasNext; ) for (var s = a.move(), u = s.start, c = s.end, l = -1, d = -1, f = u; f < c; ++f) {
    var m = o.value(f);
    f === u ? (l = f, d = o.value(f)) : i.value(f) - d > 1 && (r.push(l, f - 1), n.push(f - 1, f), l = f), f === c - 1 && r.push(l, f), d = m;
  }
  return { polymerRanges: cn.ofSortedRanges(r), gapRanges: cn.ofSortedRanges(n) };
}
(function(e) {
  e.Empty = { isDefined: !1, spheres: NC, gaussians: NC };
})(C6 || (C6 = {}));
var fR = { hierarchy: C6.Empty, conformation: void 0 };
function Tre(e, t) {
  var r = e.ihm_sphere_obj_site, n = e.ihm_gaussian_obj_site;
  if (r._rowCount === 0 && n._rowCount === 0) return fR;
  var a = OC(r), i = function(f) {
    return { x: f.Cartn_x.toArray({ array: Float32Array }), y: f.Cartn_y.toArray({ array: Float32Array }), z: f.Cartn_z.toArray({ array: Float32Array }), radius: f.object_radius.toArray({ array: Float32Array }), rmsf: f.rmsf.toArray({ array: Float32Array }) };
  }(r), o = PC(a, e.entities), s = BC(a), u = OC(n), c = function(f) {
    for (var m = Go.ihm_gaussian_obj_site.covariance_matrix.space, h = [], p = f.covariance_matrix, g = 0, v = p.rowCount; g < v; g++) h[g] = Wn.toMat3(ka(), m, p.value(g));
    return { x: f.mean_Cartn_x.toArray({ array: Float32Array }), y: f.mean_Cartn_y.toArray({ array: Float32Array }), z: f.mean_Cartn_z.toArray({ array: Float32Array }), weight: f.weight.toArray({ array: Float32Array }), covariance_matrix: h };
  }(n), l = PC(u, e.entities), d = BC(u);
  return { hierarchy: { isDefined: !0, spheres: k(k(k({}, a), o), s), gaussians: k(k(k({}, u), l), d) }, conformation: { id: Fa.create22(), spheres: i, gaussians: c } };
}
function OC(e) {
  var t = e.entity_id, r = e.seq_id_begin, n = e.seq_id_end, a = e.asym_id;
  return k({ count: t.rowCount, entity_id: t, asym_id: a, seq_id_begin: r, seq_id_end: n }, function(i, o, s) {
    for (var u = [0], c = 1, l = i.rowCount; c < l; c++) !i.areValuesEqual(c - 1, c) && (u[u.length] = c);
    return { chainElementSegments: nr.ofOffsets(u, Fe.ofBounds(0, i.rowCount)) };
  }(a));
}
var P0, E6, Nre = { HIS: "H", ARG: "R", LYS: "K", ILE: "I", PHE: "F", LEU: "L", TRP: "W", ALA: "A", MET: "M", PRO: "P", CYS: "C", ASN: "N", VAL: "V", GLY: "G", SER: "S", GLN: "Q", TYR: "Y", ASP: "D", GLU: "E", THR: "T", SEC: "U", PYL: "O", HSD: "H", HSE: "H", HSP: "H", LSN: "K", ASPP: "D", GLUP: "E", HID: "H", HIE: "H", HIP: "H", LYN: "K", ASH: "D", GLH: "E", ACE: "ACE", NME: "NME" }, Pre = { DA: "A", DC: "C", DG: "G", DT: "T", DU: "U" }, Bre = { A: "A", C: "C", G: "G", T: "T", U: "U" };
function FC(e) {
  return Nre[e] || "X";
}
function RC(e) {
  return Bre[e] || "X";
}
function LC(e) {
  return Pre[e] || "X";
}
function mR(e, t, r, n) {
  if (!e.entity_poly_seq || !e.entity_poly_seq._rowCount) return E6.fromHierarchy(t, r, n);
  for (var a = e.entity_poly_seq, i = a.entity_id, o = a.num, s = a.mon_id, u = {}, c = [], l = i.rowCount, d = 0; d < l; ) {
    for (var f = d; d < l - 1 && i.areValuesEqual(d, d + 1); ) d++;
    d++;
    var m = i.value(f), h = pe.window(s, f, d), p = pe.window(o, f, d), g = t.getEntityIndex(m);
    u[g] = { entityId: m, sequence: P0.ofResidueNames(h, p) }, c.push(u[g]);
  }
  return { byEntityKey: u, sequences: c };
}
function pR(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a, i, o, s, u, c, l, d, f, m, h;
    return Te(this, function(p) {
      switch (p.label) {
        case 0:
          return a = W5(r, n - 1), i = t.label_entity_id, o = t.label_asym_id, s = t.label_seq_id, u = g4(a, i.value), e.shouldUpdate ? [4, e.update()] : [3, 2];
        case 1:
          p.sent(), p.label = 2;
        case 2:
          c = 0, l = u.length - 1, p.label = 3;
        case 3:
          if (!(c < l)) return [3, 10];
          d = g4(a, o.value, { start: u[c], end: u[c + 1] }), f = 0, m = d.length - 1, p.label = 4;
        case 4:
          return f < m ? (h = d[f], s.valueKind(h) !== 0 ? [3, 6] : (g4(a, s.value, { sort: !0, start: h, end: d[f + 1] }), e.shouldUpdate ? [4, e.update()] : [3, 6])) : [3, 7];
        case 5:
          p.sent(), p.label = 6;
        case 6:
          return f++, [3, 4];
        case 7:
          return e.shouldUpdate ? [4, e.update()] : [3, 9];
        case 8:
          p.sent(), p.label = 9;
        case 9:
          return c++, [3, 3];
        case 10:
          return function(g) {
            for (var v = 0, y = g.length; v < y; v++) if (g[v] !== v) return !1;
            return !0;
          }(a) && a.length === t._rowCount ? [2, { atom_site: t, sourceIndex: pe.ofIntArray(a) }] : [2, { atom_site: Yr.view(t, t._schema, a), sourceIndex: pe.ofIntArray(a) }];
      }
    });
  });
}
function kC(e, t, r, n, a) {
  var i = a.residue, o = i.polymerType, s = i.traceElementIndex, u = i.directionFromElementIndex, c = i.directionToElementIndex, l = o[e], d = o[t];
  if (l === 0 || d === 0 || s[e] === -1 || s[t] === -1) return !1;
  var f = n.findAtomsOnResidue(e, Ed(l, "backboneStart")), m = n.findAtomsOnResidue(t, Ed(d, "backboneEnd"));
  f !== -1 && m !== -1 || (f = n.findAtomsOnResidue(e, Ed(l, "coarseBackbone")), m = n.findAtomsOnResidue(t, Ed(d, "coarseBackbone")));
  var h = r.x, p = r.y, g = r.z, v = D.create(h[f], p[f], g[f]), y = D.create(h[m], p[m], g[m]), _ = u[e] === -1 || c[e] === -1 || u[t] === -1 || c[t] === -1;
  return D.distance(v, y) < (_ ? 10 : 3);
}
function hR(e, t, r, n) {
  for (var a, i, o, s, u = [], c = [], l = /* @__PURE__ */ new Map(), d = nr.transientSegments(e.chainAtomSegments, Fe.ofBounds(0, e.atoms._rowCount)), f = nr.transientSegments(e.residueAtomSegments, Fe.ofBounds(0, e.atoms._rowCount)), m = e.index, h = e.derived, p = e.residues.label_seq_id, g = e.chains.label_entity_id, v = h.residue, y = v.moleculeType, _ = v.traceElementIndex; d.hasNext; ) {
    var S = d.move();
    f.setSegment(S), a = -1, i = -1, o = -1, s = -1;
    var b = t.getEntityIndex(g.value(S.index)), x = n.byEntityKey[b], A = x ? x.sequence.seqId.value(x.sequence.seqId.rowCount - 1) : -1, w = e.residueAtomSegments.index[S.start], C = e.residueAtomSegments.index[S.end - 1], M = p.value(w), T = p.value(C);
    for (M === 1 && T === A && r.xyzDefined && kC(w, C, r, m, h) && (l.set(w, C), l.set(C, w)); f.hasNext; ) {
      var N = f.move(), I = N.index, P = p.value(I);
      if (C8(y[I]) && _[I] !== -1) if (s !== -1) if (P !== a + 1) u.push(s, o - 1), c.push(i, N.end - 1), s = N.start;
      else if (f.hasNext) {
        var O = e.residueAtomSegments.index[N.start], F = e.residueAtomSegments.index[o - 1];
        r.xyzDefined && !kC(O, F, r, e.index, h) && (u.push(s, o - 1), c.push(i, N.end - 1), s = N.start);
      } else u.push(s, N.end - 1);
      else s = N.start;
      else s !== -1 && (u.push(s, o - 1), s = -1);
      i = N.start, o = N.end, a = P;
    }
  }
  return { polymerRanges: cn.ofSortedRanges(u), gapRanges: cn.ofSortedRanges(c), cyclicPolymerMap: l };
}
function vR(e) {
  var t = /* @__PURE__ */ new Map();
  return function(r) {
    if (t.has(r)) return t.get(r);
    var n = e(r);
    return t.set(r, n), n;
  };
}
function Ore(e) {
  for (var t = /* @__PURE__ */ new Map(), r = function(s, u, c) {
    return "".concat(s, "|").concat(u, "|").concat(c);
  }, n = e.pdbx_unobs_or_zero_occ_residues, a = 0, i = n._rowCount; a < i; ++a) {
    var o = r(n.PDB_model_num.value(a), n.label_asym_id.value(a), n.label_seq_id.value(a));
    t.set(o, { polymer_flag: n.polymer_flag.value(a), occupancy_flag: n.occupancy_flag.value(a) });
  }
  return { has: function(s, u, c) {
    return t.has(r(s, u, c));
  }, get: function(s, u, c) {
    return t.get(r(s, u, c));
  }, size: t.size };
}
function Fre(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.chem_comp._rowCount > 0) for (var r = e.chem_comp.id, n = 0, a = r.rowCount; n < a; ++n) t.set(r.value(n), Yr.getRow(e.chem_comp, n));
  else gR(e).forEach(function(i) {
    t.set(i, function(o) {
      return { formula: "", formula_weight: 0, id: o, name: o, mon_nstd_flag: w8.has(o) ? "y" : "n", pdbx_synonyms: [], type: LF(o) };
    }(i));
  });
  return t;
}
function Rre(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.pdbx_chem_comp_identifier._rowCount > 0) {
    for (var r = e.pdbx_chem_comp_identifier, n = r.comp_id, a = r.type, i = r.identifier, o = 0, s = n.rowCount; o < s; ++o) if (a.value(o) === "SNFG CARBOHYDRATE SYMBOL" || a.value(o) === "SNFG CARB SYMBOL") {
      var u = i.value(o), c = GJ.get(u);
      c ? t.set(n.value(o), c) : console.warn("Unknown SNFG name '".concat(u, "'"));
    }
  }
  if (e.chem_comp._rowCount > 0) {
    var l = e.chem_comp, d = l.id;
    for (a = l.type, o = 0, s = d.rowCount; o < s; ++o) {
      var f = d.value(o);
      if (!t.has(f)) {
        var m = a.value(o);
        Fd.has(f) ? t.set(f, Fd.get(f)) : Fh(m, f) === 9 && t.set(f, CF);
      }
    }
  } else {
    var h = gR(e);
    Fd.forEach(function(p, g) {
      !t.has(g) && h.has(g) && t.set(g, p);
    });
  }
  return t;
}
(function(e) {
  e.getSequenceString = function(n) {
    var a = n.code.toArray();
    return (a instanceof Array ? a : Array.from(a)).join("");
  }, e.ofResidueNames = function(n, a) {
    if (a.rowCount === 0) throw new Error("cannot be empty");
    var i = function(o) {
      for (var s = 0, u = Math.min(o.rowCount, 10); s < u; s++) {
        var c = o.value(s) || "";
        if (FC(c) !== "X") return "protein";
        if (RC(c) !== "X") return "RNA";
        if (LC(c) !== "X") return "DNA";
      }
      return "generic";
    }(n);
    return new t(i, n, a);
  };
  var t = function() {
    function n(a, i, o) {
      this.kind = a, this.microHet = /* @__PURE__ */ new Map();
      for (var s = function(b, x) {
        var A;
        switch (b) {
          case "protein":
            A = FC;
            break;
          case "DNA":
            A = LC;
            break;
          case "RNA":
            A = RC;
            break;
          case "generic":
            A = function() {
              return "X";
            };
            break;
          default:
            Ja();
        }
        return A;
      }(a), u = [], c = [], l = [], d = /* @__PURE__ */ new Map(), f = 0, m = /* @__PURE__ */ new Map(), h = 0, p = o.rowCount; h < p; ++h) {
        var g = o.value(h);
        if (m.has(g)) d.has(g) ? d.get(g).push(i.value(h)) : d.set(g, [c[m.get(g)], i.value(h)]);
        else {
          m.set(g, f);
          var v = i.value(h);
          c[f] = v, l[f] = g, u[f] = s(v), f += 1;
        }
      }
      var y = [];
      for (h = 0, p = f; h < p; ++h) {
        var _ = d.get(l[h]);
        if (_) {
          var S = _.map(function(b) {
            var x = s(b);
            return x === "X" ? b : x;
          });
          y[h] = "(".concat(S.join("|"), ")");
        } else y[h] = u[h] === "X" ? c[h] : u[h];
      }
      this.length = f, this.code = pe.ofStringArray(u), this.compId = pe.ofStringArray(c), this.seqId = pe.ofIntArray(l), this.label = pe.ofStringArray(y), this.microHet = d, this.indexMap = m;
    }
    return n.prototype.index = function(a) {
      return this.indexMap.get(a);
    }, n;
  }();
  e.ofSequenceRanges = function(n, a) {
    return new r("generic", n, a);
  };
  var r = function() {
    function n(a, i, o) {
      this.kind = a, this.seqIdStart = i, this.seqIdEnd = o, this.microHet = /* @__PURE__ */ new Map();
      for (var s = 0, u = Number.MAX_SAFE_INTEGER, c = 0, l = this.seqIdStart.rowCount; c < l; c++) {
        var d = this.seqIdStart.value(c), f = this.seqIdEnd.value(c);
        d < u && (u = d), s < f && (s = f);
      }
      var m = s - u + 1;
      this.code = pe.ofConst("X", m, pe.Schema.str), this.label = pe.ofConst("", m, pe.Schema.str), this.seqId = pe.ofLambda({ value: function(h) {
        return h + u + 1;
      }, rowCount: m, schema: pe.Schema.int }), this.compId = pe.ofConst("", m, pe.Schema.str), this.length = m, this.minSeqId = u;
    }
    return n.prototype.index = function(a) {
      return a - this.minSeqId;
    }, n;
  }();
})(P0 || (P0 = {})), function(e) {
  var t = { byEntityKey: {}, sequences: [] };
  function r() {
    for (var o = [], s = 0; s < arguments.length; s++) o[s] = arguments[s];
    for (var u = [], c = {}, l = 0, d = o.length; l < d; ++l) u.push.apply(u, o[l].sequences), Object.assign(c, o[l].byEntityKey);
    return { sequences: u, byEntityKey: c };
  }
  function n(o, s) {
    var u = s.atoms.label_comp_id, c = s.residues.label_seq_id, l = s.chainAtomSegments, d = s.residueAtomSegments, f = l.count, m = l.offsets, h = {}, p = [];
    if (f === 1 && m[0] === 0 && m[1] === 0) return { byEntityKey: h, sequences: p };
    for (var g = 0, v = s.chains._rowCount; g < v; g++) {
      var y = s.index.getEntityFromChain(g);
      if (h[y] === void 0 && o.data.type.value(y) === "polymer") {
        var _ = g;
        for (g++; g < v && y === s.index.getEntityFromChain(g) && o.data.type.value(y) !== "polymer"; ) g++;
        g--;
        for (var S = d.index[m[_]], b = d.index[m[g + 1] - 1] + 1, x = pe.window(c, S, b), A = [], w = S; w < b; ++w) A.push(u.value(d.offsets[w]));
        var C = pe.ofStringArray(A);
        h[y] = { entityId: o.data.id.value(y), sequence: P0.ofResidueNames(C, x) }, p.push(h[y]);
      }
    }
    return { byEntityKey: h, sequences: p };
  }
  function a(o, s) {
    return r(i(o, s.spheres), i(o, s.gaussians));
  }
  function i(o, s) {
    var u = s.chainElementSegments, c = s.seq_id_begin, l = s.seq_id_end, d = u.count, f = u.offsets, m = {}, h = [];
    if (d === 1 && f[0] === 0 && f[1] === 0) return { byEntityKey: m, sequences: h };
    for (var p = 0, g = d; p < g; p++) {
      var v = s.getEntityFromChain(p);
      if (m[v] === void 0) {
        var y = p;
        for (p++; p < g && v === s.getEntityFromChain(p); ) p++;
        p--;
        var _ = f[y], S = f[p + 1] - 1, b = pe.window(c, _, S), x = pe.window(l, _, S);
        m[v] = { entityId: o.data.id.value(v), sequence: P0.ofSequenceRanges(b, x) }, h.push(m[v]);
      }
    }
    return { byEntityKey: m, sequences: h };
  }
  e.fromHierarchy = function(o, s, u) {
    return r(n(o, s), u.isDefined ? a(o, u) : t);
  }, e.fromAtomicHierarchy = n, e.fromCoarseHierarchy = a, e.fromCoarseElements = i;
}(E6 || (E6 = {}));
var gR = vR(function(e) {
  for (var t = /* @__PURE__ */ new Set(), r = e.atom_site, n = r.label_comp_id, a = r.auth_comp_id, i = n.isDefined ? n : a, o = 0, s = i.rowCount; o < s; ++o) t.add(i.value(o));
  return t;
});
function yR(e, t) {
  for (var r = /* @__PURE__ */ new Map(), n = e.chains, a = n.auth_asym_id, i = n.label_asym_id, o = n.label_entity_id, s = 0, u = e.chains._rowCount; s < u; s++) {
    var c = i.value(s);
    r.set(c, { id: c, auth_id: a.value(s), entity_id: o.value(s) });
  }
  if (t != null && t.struct_asym._rowCount) for (var l = t.struct_asym, d = (c = l.id, l.entity_id), f = (s = 0, c.rowCount); s < f; ++s) {
    var m = c.value(s);
    r.has(m) || r.set(m, { id: m, auth_id: "", entity_id: d.value(s) });
  }
  return r;
}
var Lre = pe.Schema.Aliased(pe.Schema.Str(""));
function bR(e) {
  var t;
  if (e.entity.id.isDefined) t = e.entity;
  else {
    for (var r = /* @__PURE__ */ new Set(), n = [], a = [], i = e.atom_site, o = i.label_entity_id, s = i.label_comp_id, u = 0, c = e.atom_site._rowCount; u < c; u++) {
      var l = o.value(u);
      r.has(l) || (n.push(l), a.push(aee(s.value(u))), r.add(l));
    }
    var d = e.ihm_sphere_obj_site.entity_id;
    for (u = 0, c = e.ihm_sphere_obj_site._rowCount; u < c; u++)
      l = d.value(u), r.has(l) || (n.push(l), a.push("polymer"), r.add(l));
    var f = e.ihm_gaussian_obj_site.entity_id;
    for (u = 0, c = e.ihm_gaussian_obj_site._rowCount; u < c; u++)
      l = f.value(u), r.has(l) || (n.push(l), a.push("polymer"), r.add(l));
    t = Yr.ofPartialColumns(Go.entity, { id: pe.ofArray({ array: n, schema: Go.entity.id }), type: pe.ofArray({ array: a, schema: Go.entity.type }) }, n.length);
  }
  var m = pe.createIndexer(t.id), h = new Array(t._rowCount);
  h.fill("other");
  var p = /* @__PURE__ */ new Set(), g = !1;
  if (e.entity_poly && e.entity_poly.type.isDefined) {
    var v = e.entity_poly, y = v.entity_id, _ = v.type, S = v._rowCount;
    for (u = 0; u < S; ++u)
      h[m(l = y.value(u))] = _.value(u), p.add(l);
  } else g = !0;
  if (e.pdbx_entity_branch && e.pdbx_entity_branch.entity_id.isDefined) {
    var b = e.pdbx_entity_branch;
    for (y = b.entity_id, _ = b.type, S = b._rowCount, u = 0; u < S; ++u)
      h[m(l = y.value(u))] = _.value(u), p.add(l);
  } else g = !0;
  if (p.size < h.length && (g = !0), g) {
    var x = /* @__PURE__ */ new Map();
    if (e.chem_comp) {
      var A = e.chem_comp, w = A.id;
      for (_ = A.type, u = 0, c = e.chem_comp._rowCount; u < c; u++) x.set(w.value(u), _.value(u));
    }
    if (e.atom_site) {
      var C = e.atom_site;
      for (o = C.label_entity_id, s = C.label_comp_id, u = 0, c = e.atom_site._rowCount; u < c; u++)
        if (l = o.value(u), !p.has(l)) {
          var M = s.value(u), T = x.get(M) || "";
          h[m(l)] = iee(M, T), p.add(l);
        }
    }
  }
  return { data: t, subtype: pe.ofArray({ array: h, schema: Lre }), getEntityIndex: m };
}
function xR(e, t, r) {
  var n;
  if (!e.pdbx_molecule || !e.pdbx_molecule.prd_id.isDefined) return t;
  var a = new Array(t.data._rowCount);
  a.fill("");
  for (var i = e.pdbx_molecule, o = i.asym_id, s = i.prd_id, u = i._rowCount, c = 0; c < u; ++c) {
    var l = o.value(c), d = (n = r.get(l)) === null || n === void 0 ? void 0 : n.entity_id;
    d !== void 0 && (a[t.getEntityIndex(d)] = s.value(c));
  }
  var f = pe.ofArray({ array: a, schema: pe.Schema.str });
  return k(k({}, t), { prd_id: f });
}
var yn, zC, dh = function() {
  function e(t) {
    this.frames = t, this.frameCount = t.length, this.representative = t[0], this.duration = t.length;
  }
  return e.prototype.getFrameAtIndex = function(t) {
    return this.frames[t];
  }, e;
}();
function bl(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          return n = function(u, c) {
            return { missingResidues: Ore(u), chemicalComponentMap: Fre(u), saccharideComponentMap: Rre(u) };
          }(e), e.ihm_model_list._rowCount > 0 ? [4, zre(r, e, n, t)] : [3, 2];
        case 1:
          return i = s.sent(), [3, 4];
        case 2:
          return [4, kre(r, e, n, t)];
        case 3:
          i = s.sent(), s.label = 4;
        case 4:
          for (a = i, o = 0; o < a.length; o++) yn.TrajectoryInfo.set(a[o], { index: o, size: a.length });
          return [2, new dh(a)];
      }
    });
  });
}
function _R(e, t) {
  var r = e.rowCount;
  if (!e.isDefined) return r;
  for (var n = t + 1; n < r && e.areValuesEqual(t, n); ) n++;
  return n;
}
function kre(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a, i, o, s, u, c, l, d, f;
    return Te(this, function(m) {
      switch (m.label) {
        case 0:
          if (a = [], !t.atom_site) return [3, 3];
          i = t.atom_site.id.rowCount, o = bR(t), s = 0, m.label = 1;
        case 1:
          return s < i ? (u = _R(t.atom_site.pdbx_PDB_model_num, s), [4, pR(e, t.atom_site, s, u)]) : [3, 3];
        case 2:
          return c = m.sent(), l = c.atom_site, d = c.sourceIndex, f = function(h, p, g, v, y, _, S) {
            var b = dR(p, g, v, y.chemicalComponentMap, _, S), x = p.pdbx_PDB_model_num.value(0);
            if (S && b.sameAsPrevious) return k(k({}, S), { id: Fa.create22(), modelNum: x, atomicConformation: b.conformation, _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
            var A = fR, w = mR(h, v, b.hierarchy, A.hierarchy), C = hR(b.hierarchy, v, b.conformation, w), M = yR(b.hierarchy), T = h.entry.id.valueKind(0) === 0 ? h.entry.id.value(0) : _.name, N = [];
            return T && N.push(T), h.struct.title.valueKind(0) === 0 && N.push(h.struct.title.value(0)), { id: Fa.create22(), entryId: T, label: N.join(" | "), entry: T, sourceData: _, modelNum: x, parent: void 0, entities: xR(h, v, M), sequence: w, atomicHierarchy: b.hierarchy, atomicConformation: b.conformation, atomicRanges: C, atomicChainOperatorMappinng: b.chainOperatorMapping, coarseHierarchy: A.hierarchy, coarseConformation: A.conformation, properties: k(k({}, y), { structAsymMap: M }), customProperties: new f1(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, l, d, o, r, n, a.length > 0 ? a[a.length - 1] : void 0), a.push(f), s = u, [3, 1];
        case 3:
          return [2, a];
      }
    });
  });
}
function Y4(e, t) {
  for (var r = /* @__PURE__ */ new Map(), n = e._rowCount, a = 0; a < n; ) {
    var i = _R(t, a), o = t.value(a);
    r.set(o, { table: Yr.window(e, e._schema, a, i), start: a, end: i }), a = i;
  }
  return r;
}
function zre(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x;
    return Te(this, function(A) {
      switch (A.label) {
        case 0:
          if (a = bR(t), i = t.atom_site.ihm_model_id.isDefined ? t.atom_site.ihm_model_id : t.atom_site.pdbx_PDB_model_num, o = Y4(t.atom_site, i), s = Y4(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site.model_id), u = Y4(t.ihm_gaussian_obj_site, t.ihm_gaussian_obj_site.model_id), c = [], !t.ihm_model_list) return [3, 6];
          l = t.ihm_model_list, d = l.model_id, f = l.model_name, m = 0, A.label = 1;
        case 1:
          return m < t.ihm_model_list._rowCount ? (h = d.value(m), p = void 0, g = void 0, o.has(h) ? (v = o.get(h), [4, pR(e, t.atom_site, v.start, v.end)]) : [3, 3]) : [3, 6];
        case 2:
          return y = A.sent(), _ = y.atom_site, S = y.sourceIndex, p = _, g = S, [3, 4];
        case 3:
          p = Yr.window(t.atom_site, t.atom_site._schema, 0, 0), g = pe.ofIntArray([]), A.label = 4;
        case 4:
          b = { model_id: h, model_name: f.value(m), model_group_name: Mte(h, t), entities: a, atom_site: p, atom_site_sourceIndex: g, ihm_sphere_obj_site: s.has(h) ? s.get(h).table : Yr.window(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site._schema, 0, 0), ihm_gaussian_obj_site: u.has(h) ? u.get(h).table : Yr.window(t.ihm_gaussian_obj_site, t.ihm_gaussian_obj_site._schema, 0, 0) }, x = function(w, C, M, T) {
            var N = dR(C.atom_site, C.atom_site_sourceIndex, C.entities, M.chemicalComponentMap, T), I = Tre(C, M.chemicalComponentMap), P = mR(w, C.entities, N.hierarchy, I.hierarchy), O = hR(N.hierarchy, C.entities, N.conformation, P), F = w.entry.id.valueKind(0) === 0 ? w.entry.id.value(0) : T.name, R = [];
            F && R.push(F), w.struct.title.valueKind(0) === 0 && R.push(w.struct.title.value(0)), C.model_name && R.push(C.model_name), C.model_group_name && R.push(C.model_group_name);
            var G = yR(N.hierarchy, w);
            return { id: Fa.create22(), entryId: F, label: R.join(" | "), entry: F, sourceData: T, modelNum: C.model_id, parent: void 0, entities: xR(w, C.entities, G), sequence: P, atomicHierarchy: N.hierarchy, atomicConformation: N.conformation, atomicRanges: O, atomicChainOperatorMappinng: N.chainOperatorMapping, coarseHierarchy: I.hierarchy, coarseConformation: I.conformation, properties: k(k({}, M), { structAsymMap: G }), customProperties: new f1(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, b, r, n), c.push(x), A.label = 5;
        case 5:
          return m++, [3, 1];
        case 6:
          return [2, c];
      }
    });
  });
}
function W4(e) {
  for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.length; r < n; r++) t.set(r, e[r]);
  return t;
}
(function(e) {
  function t(v, y) {
    for (var _ = [], S = y.frames, b = v.atomicHierarchy.atomSourceIndex, x = pe.isIdentity(b) ? void 0 : b.toArray({ array: Int32Array }), A = u(v), w = 0, C = S.length; w < C; ++w) {
      var M = S[w], T = k(k({}, v), { id: Fa.create22(), modelNum: w, atomicConformation: Z2.getAtomicConformation(M, v.atomicConformation.atomId, x), customProperties: new f1(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
      if (M.cell) {
        var N = pi.fromCell(M.cell.size, M.cell.anglesInRadians);
        pi.Provider.set(T, N);
      }
      e.TrajectoryInfo.set(T, { index: w, size: S.length }), e.CoarseGrained.set(T, A), _.push(T);
    }
    return { trajectory: _, srcIndexArray: x };
  }
  e.trajectoryFromModelAndCoordinates = function(v, y) {
    return new dh(t(v, y).trajectory);
  }, e.trajectoryFromTopologyAndCoordinates = function(v, y) {
    var _ = this;
    return sr.create("Create Trajectory", function(S) {
      return Be(_, 0, void 0, function() {
        var b, x, A, w, C, M, T, N, I, P;
        return Te(this, function(O) {
          switch (O.label) {
            case 0:
              return [4, bl(v.basic, v.sourceData, S)];
            case 1:
              if ((b = O.sent()).frameCount === 0) throw new Error("found no model");
              for (x = b.representative, A = t(x, y).trajectory, w = { pairs: v.bonds, count: x.atomicHierarchy.atoms._rowCount }, C = Ra.fromData(w), M = u(x), T = 0, N = 0, I = A; N < I.length; N++) P = I[N], Ra.Provider.set(P, C), e.TrajectoryInfo.set(P, { index: T++, size: A.length }), e.CoarseGrained.set(P, M);
              return [2, new dh(A)];
          }
        });
      });
    });
  };
  var r = "__Center__";
  e.getCenter = function(v) {
    if (v._dynamicPropertyData[r]) return v._dynamicPropertyData[r];
    var y = function(_, S) {
      var b = [], x = [], A = [];
      _.x.length && (b.push.apply(b, as(_.x)), x.push.apply(x, as(_.y)), A.push.apply(A, as(_.z))), S && (S.spheres.x.length && (b.push.apply(b, as(S.spheres.x)), x.push.apply(x, as(S.spheres.y)), A.push.apply(A, as(S.spheres.z))), S.gaussians.x.length && (b.push.apply(b, as(S.gaussians.x)), x.push.apply(x, as(S.gaussians.y)), A.push.apply(A, as(S.gaussians.z))));
      var w = as(b), C = w[0], M = w[1], T = as(x), N = T[0], I = T[1], P = as(A), O = P[0], F = C + (M - C) / 2, R = N + (I - N) / 2, G = O + (P[1] - O) / 2;
      return D.create(F, R, G);
    }(v.atomicConformation, v.coarseConformation);
    return v._dynamicPropertyData[r] = y, y;
  };
  var n = "__InvertedAtomSrcIndex__";
  e.getInvertedAtomSourceIndex = function(v) {
    if (v._staticPropertyData[n]) return v._staticPropertyData[n];
    var y = function(_) {
      for (var S = new Int32Array(_.rowCount), b = !1, x = 0, A = _.rowCount; x < A; x++) {
        var w = _.value(x);
        w !== x && (b = !1), S[w] = x;
      }
      return { isIdentity: b, invertedIndex: S };
    }(v.atomicHierarchy.atomSourceIndex);
    return v._staticPropertyData[n] = y, y;
  };
  var a = "__TrajectoryInfo__";
  e.TrajectoryInfo = { get: function(v) {
    return v._dynamicPropertyData[a] || { index: 0, size: 1 };
  }, set: function(v, y) {
    return v._dynamicPropertyData[a] = y;
  } };
  var i = "__AsymIdCount__";
  e.AsymIdCount = { get: function(v) {
    if (v._dynamicPropertyData[i]) return v._dynamicPropertyData[i];
    var y = function(_) {
      var S = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
      return _.properties.structAsymMap.forEach(function(x, A) {
        var w = x.auth_id;
        S.add(w), b.add(A);
      }), { auth: S.size, label: b.size };
    }(v);
    return v._dynamicPropertyData[i] = y, y;
  } }, e.AsymIdOffset = Dp.createSimple("asym_id_offset", "static"), e.Index = Dp.createSimple("index", "static"), e.getRoot = function(v) {
    return v.parent || v;
  }, e.areHierarchiesEqual = function(v, y) {
    return v.atomicHierarchy === y.atomicHierarchy && v.coarseHierarchy === y.coarseHierarchy;
  };
  var o = "__CoordinatesHistory__";
  e.CoordinatesHistory = { get: function(v) {
    return v._staticPropertyData[o];
  }, set: function(v, y) {
    return v._staticPropertyData[o] = y;
  } };
  var s = "__CoarseGrained__";
  function u(v) {
    var y = e.CoarseGrained.get(v);
    if (y === void 0) {
      for (var _ = 0, S = v.atomicHierarchy.derived.residue.polymerType, b = 0; b < S.length; ++b) S[b] !== 0 && (_ += 1);
      var x = !1, A = !1, w = v.atomicHierarchy.atoms, C = w.label_atom_id, M = w._rowCount;
      for (b = 0; b < M; ++b) {
        var T = C.value(b);
        if (x || T !== "BB" || (x = !0), A || T !== "SC1" || (A = !0), x && A) break;
      }
      y = x && A || !(!_ || !M) && M / _ < 3, e.CoarseGrained.set(v, y);
    }
    return y;
  }
  function c(v) {
    return !!Dn.is(v.sourceData) && (v.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || v.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null);
  }
  e.CoarseGrained = { get: function(v) {
    return v._staticPropertyData[s];
  }, set: function(v, y) {
    return v._staticPropertyData[s] = y;
  } }, e.isCoarseGrained = u, e.isMaterial = function(v) {
    var y, _;
    return !!(!((_ = (y = v.sourceData) === null || y === void 0 ? void 0 : y.data) === null || _ === void 0) && _.isMaterial);
  }, e.isMaterialCrystal = function(v) {
    var y, _, S, b = (y = v.sourceData) === null || y === void 0 ? void 0 : y.data;
    return !(b != null && b.isMaterial) && !!(!((S = (_ = b == null ? void 0 : b.molecules) === null || _ === void 0 ? void 0 : _[0]) === null || S === void 0) && S.cell);
  }, e.hasCarbohydrate = function(v) {
    return v.properties.saccharideComponentMap.size > 0;
  }, e.hasProtein = function(v) {
    for (var y = v.entities.subtype, _ = 0, S = y.rowCount; _ < S; ++_) if (y.value(_).startsWith("polypeptide")) return !0;
    return !1;
  }, e.hasNucleic = function(v) {
    for (var y = v.entities.subtype, _ = 0, S = y.rowCount; _ < S; ++_) {
      var b = y.value(_);
      if (b.endsWith("ribonucleotide hybrid") || b.endsWith("ribonucleotide")) return !0;
    }
    return !1;
  }, e.isFromPdbArchive = function(v) {
    if (!Dn.is(v.sourceData)) return !1;
    for (var y = v.sourceData.data.db, _ = 0, S = y.database_2.database_id.rowCount; _ < S; ++_) if (y.database_2.database_id.value(_) === "PDB") return !0;
    return !1;
  }, e.hasPdbId = c, e.hasSecondaryStructure = function(v) {
    if (!Dn.is(v.sourceData)) return !1;
    var y = v.sourceData.data.db;
    return y.struct_conf.id.isDefined || y.struct_sheet_range.id.isDefined;
  };
  var l = D.create(1.5707963, 1.5707963, 1.5707963), d = D.create(1, 1, 1);
  function f(v) {
    if (!Dn.is(v.sourceData)) return !1;
    for (var y = v.sourceData.data.db, _ = 0; _ < y.exptl.method.rowCount; _++)
      if (y.exptl.method.value(_).toUpperCase().indexOf("DIFFRACTION") >= 0) return !0;
    return !1;
  }
  function m(v) {
    if (!Dn.is(v.sourceData)) return !1;
    for (var y = v.sourceData.data.db, _ = 0; _ < y.exptl.method.rowCount; _++)
      if (y.exptl.method.value(_).toUpperCase().indexOf("MICROSCOPY") >= 0) return !0;
    return !1;
  }
  function h(v) {
    if (!Dn.is(v.sourceData) || !f(v)) return !1;
    var y = v.sourceData.data.db.pdbx_database_status.status_code_sf;
    return y.isDefined && y.value(0) === "REL";
  }
  function p(v) {
    if (!Dn.is(v.sourceData)) return !1;
    for (var y = v.sourceData.data.db, _ = y.pdbx_database_related, S = _.db_name, b = _.content_type, x = 0, A = y.pdbx_database_related._rowCount; x < A; ++x) if (S.value(x).toUpperCase() === "EMDB" && b.value(x) === "associated EM volume") return !0;
    return !1;
  }
  function g(v) {
    return !!Dn.is(v.sourceData) && (h(v) || p(v));
  }
  e.hasCrystalSymmetry = function(v) {
    var y, _ = (y = pi.Provider.get(v)) === null || y === void 0 ? void 0 : y.spacegroup;
    return !(!_ || _.num === 1 && D.equals(_.cell.anglesInRadians, l) && D.equals(_.cell.size, d));
  }, e.isFromXray = f, e.isFromEm = m, e.isFromNmr = function(v) {
    if (!Dn.is(v.sourceData)) return !1;
    for (var y = v.sourceData.data.db, _ = 0; _ < y.exptl.method.rowCount; _++)
      if (y.exptl.method.value(_).toUpperCase().indexOf("NMR") >= 0) return !0;
    return !1;
  }, e.hasXrayMap = h, e.hasEmMap = p, e.hasDensityMap = g, e.probablyHasDensityMap = function(v) {
    if (!Dn.is(v.sourceData)) return !1;
    var y = v.sourceData.data.db;
    return g(v) || c(v) && (!y.exptl.method.isDefined || f(v) && (!y.pdbx_database_status.status_code_sf.isDefined || y.pdbx_database_status.status_code_sf.valueKind(0) === 2) || m(v) && !y.pdbx_database_related.db_name.isDefined);
  };
})(yn || (yn = {})), function(e) {
  e.getCifDataSource = function(n, a, i) {
    if (!a) return { rowCount: 0 };
    if (i && i[a.id]) return i[a.id];
    var o = a.getElements(n), s = { data: o, rowCount: o.elements.length };
    return i && (i[a.id] = s), s;
  }, e.fromAtomMap = function(n) {
    return new UC(n);
  }, e.fromAtomArray = function(n) {
    return new UC(W4(n));
  };
  var t = function(n) {
    return n.atomicHierarchy.residueAtomSegments;
  };
  e.fromResidueMap = function(n) {
    return new dg("residue", n, t, 0);
  }, e.fromResidueArray = function(n) {
    return new dg("residue", W4(n), t, 0);
  };
  var r = function(n) {
    return n.atomicHierarchy.chainAtomSegments;
  };
  e.fromChainMap = function(n) {
    return new dg("chain", n, r, 0);
  }, e.fromChainArray = function(n) {
    return new dg("chain", W4(n), r, 0);
  }, e.fromEntityMap = function(n) {
    return new Ure(n);
  };
}(zC || (zC = {}));
var dg = function() {
  function e(t, r, n, a) {
    this.level = t, this.map = r, this.segmentGetter = n, this.id = Fa.create22(), this.kind = a;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    var r = t.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = /* @__PURE__ */ new Set(), a = t.unitSymmetryGroups, i = [], o = this.segmentGetter(r[0]), s = 0, u = a; s < u.length; s++) {
      var c = u[s].units[0];
      if (c.kind === this.kind) for (var l = nr.transientSegments(o, c.elements); l.hasNext; ) {
        var d = l.move();
        this.has(d.index) && !n.has(d.index) && (n.add(d.index), i[i.length] = lt.create(t, c, c.elements[d.start]));
      }
    }
    return i.sort(function(f, m) {
      return f.element - m.element;
    }), i;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.segmentGetter(t.model).index, a = this.getStructureElements(t);
    return { elements: a, property: function(i) {
      return r.get(n[a[i].element]);
    } };
  }, e;
}(), UC = function() {
  function e(t) {
    this.map = t, this.id = Fa.create22(), this.level = "atom", this.kind = 0;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    if (t.models.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var r = /* @__PURE__ */ new Set(), n = [], a = 0, i = t.unitSymmetryGroups; a < i.length; a++) {
      var o = i[a].units[0];
      if (o.kind === this.kind) for (var s = o.elements, u = 0, c = s.length; u < c; u++) {
        var l = s[u];
        this.has(l) && !r.has(l) && (r.add(s[u]), n[n.length] = lt.create(t, o, l));
      }
    }
    return n.sort(function(d, f) {
      return d.element - f.element;
    }), n;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.getStructureElements(t);
    return { elements: n, property: function(a) {
      return r.get(n[a].element);
    } };
  }, e;
}(), Ure = function() {
  function e(t) {
    this.map = t, this.id = Fa.create22(), this.level = "entity", this.kind = 0;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    var r = t.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = r[0].atomicHierarchy.index, a = /* @__PURE__ */ new Set(), i = t.unitSymmetryGroups, o = [], s = r[0].atomicHierarchy.chainAtomSegments, u = 0, c = i; u < c.length; u++) {
      var l = c[u].units[0];
      if (l.kind === this.kind) for (var d = nr.transientSegments(s, l.elements); d.hasNext; ) {
        var f = d.move(), m = n.getEntityFromChain(f.index);
        this.has(m) && !a.has(m) && (a.add(m), o[o.length] = lt.create(t, l, l.elements[f.start]));
      }
    }
    return o.sort(function(h, p) {
      return h.element - p.element;
    }), o;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.getStructureElements(t), a = t.model.atomicHierarchy.chainAtomSegments.index, i = t.model.atomicHierarchy.index;
    return { elements: n, property: function(o) {
      return r.get(i.getEntityFromChain(a[n[o].element]));
    } };
  }, e;
}(), fg = Qe(13421772), GC = {}, Gre = { name: "carbohydrate-symbol", label: "Carbohydrate Symbol", category: "Residue Property", factory: function e(t, r) {
  var n;
  if (t.structure) {
    var a = t.structure.carbohydrates, i = a.elements, o = a.getElementIndices, s = function(u, c) {
      if (!Ke.isAtomic(u)) return fg;
      var l = o(u, c);
      return l.length > 0 ? i[l[0]].component.color : fg;
    };
    n = function(u, c) {
      return c ? wt.Secondary : lt.is(u) ? s(u.unit, u.element) : Pt.isLocation(u) ? s(u.aUnit, u.aUnit.elements[u.aIndex]) : fg;
    };
  } else n = function() {
    return fg;
  };
  return { factory: e, granularity: "group", color: n, props: r, description: "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).", legend: Pu(VJ) };
}, getParams: function(e) {
  return GC;
}, defaultValues: V.getDefaultValues(GC), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return yn.hasCarbohydrate(t);
  });
} }, SR = Qe(14539007), Vre = "Gives everything the same, uniform color.", cy = { value: V.Color(SR) };
function Lh(e, t) {
  var r = Pa(t.value, SR);
  return { factory: Lh, granularity: "uniform", color: function() {
    return r;
  }, props: t, description: Vre, legend: Pu([["uniform", r]]) };
}
var qre = { name: "uniform", label: "Uniform", category: "Miscellaneous", factory: Lh, getParams: function(e) {
  return cy;
}, defaultValues: V.getDefaultValues(cy), isApplicable: function(e) {
  return !0;
} }, VC = { value: V.Numeric(1, { min: 0, max: 20, step: 0.1 }) };
function M8(e, t) {
  var r = t.value;
  return { factory: M8, granularity: "uniform", size: function() {
    return r;
  }, props: t, description: "Gives everything the same, uniform size." };
}
var Hre = { name: "uniform", label: "Uniform", category: "", factory: M8, getParams: function(e) {
  return VC;
}, defaultValues: V.getDefaultValues(VC), isApplicable: function(e) {
  return !0;
} }, qC = { scale: V.Numeric(1, { min: 0.1, max: 5, step: 0.1 }) };
function Z4(e, t) {
  return Ke.isAtomic(e) ? m3(e.model.atomicHierarchy.atoms.type_symbol.value(t)) : Ke.isSpheres(e) ? e.model.coarseConformation.spheres.radius[t] : 0;
}
var Kre = { name: "physical", label: "Physical", category: "", factory: function e(t, r) {
  var n = r.scale === void 0 ? 1 : r.scale;
  return { factory: e, granularity: "group", size: function(a) {
    return lt.is(a) ? n * Z4(a.unit, a.element) : Pt.isLocation(a) ? n * Math.min(Z4(a.aUnit, a.aUnit.elements[a.aIndex]), Z4(a.bUnit, a.bUnit.elements[a.bIndex])) : 1 * n;
  }, props: r, description: "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres." };
}, getParams: function(e) {
  return qC;
}, defaultValues: V.getDefaultValues(qC), isApplicable: function(e) {
  return !!e.structure;
} }, Ro = D();
function Vp(e, t, r, n) {
  for (var a = 0, i = 3 * n; a < i; a += 3) D.fromArray(Ro, t, r + a), D.transformMat4(Ro, Ro, e), D.toArray(Ro, t, r + a);
}
var HC = D(), Q4 = D(), KC = D(), Os = D(), XC = D();
function AR(e, t, r, n, a) {
  for (var i = 0, o = 3 * a; i < o; i += 3) {
    var s = 3 * t[i], u = 3 * t[i + 1], c = 3 * t[i + 2];
    D.fromArray(HC, e, s), D.fromArray(Q4, e, u), D.fromArray(KC, e, c), D.sub(Os, KC, Q4), D.sub(XC, HC, Q4), D.cross(Os, Os, XC), r[s] += Os[0], r[s + 1] += Os[1], r[s + 2] += Os[2], r[u] += Os[0], r[u + 1] += Os[1], r[u + 2] += Os[2], r[c] += Os[0], r[c + 1] += Os[1], r[c + 2] += Os[2];
  }
  return function(l, d) {
    for (var f = 0, m = 3 * d; f < m; f += 3) {
      var h = l[f], p = l[f + 1], g = l[f + 2], v = 1 / Math.sqrt(h * h + p * p + g * g);
      l[f] = h * v, l[f + 1] = p * v, l[f + 2] = g * v;
    }
    return l;
  }(r, n);
}
function v1(e, t, r) {
  r === void 0 && (r = 1);
  for (var n = j2(e), a = new Int32Array(n + 2), i = new Int32Array(t), o = new Int32Array(t), s = 0, u = t * r; s < u; s += r) ++o[e[s]];
  var c = 0;
  for (s = 0; s < t; s++) a[s] = c, c += o[s];
  a[t] = c;
  var l = new Int32Array(c);
  for (s = 0, u = t * r; s < u; s += r) {
    var d = e[s];
    l[a[d] + i[d]] = s, ++i[d];
  }
  return { indices: l, offsets: a };
}
function Oa(e, t, r, n) {
  var a = function(u, c) {
    u = Math.max(u, 2);
    var l = Math.sqrt(u), d = Math.ceil(l), f = (d += (c - d % c) % c) > 0 ? Math.ceil(u / d) : 0;
    return { width: d, height: f, length: d * f * c };
  }(e, t), i = a.length, o = a.width, s = a.height;
  return { array: n = n && n.length >= i ? n : new r(i), width: o, height: s };
}
var Ks = D(), Xre = new iu("14"), jre = new iu("98");
function wR(e) {
  return e > 1e5 ? Xre : jre;
}
function Vd(e, t, r) {
  var n = 3 * r, a = wR(t);
  a.reset();
  for (var i = 0, o = 3 * t; i < o; i += n) D.fromArray(Ks, e, i), a.includePosition(Ks);
  for (a.finishedIncludeStep(), i = 0, o = 3 * t; i < o; i += n) D.fromArray(Ks, e, i), a.radiusPosition(Ks);
  var s = a.getSphere();
  if (t <= 98) {
    var u = [];
    for (i = 0, o = 3 * t; i < o; i += n) u.push(D.fromArray(D(), e, i));
    Ve.setExtrema(s, u);
  }
  return s;
}
var $4 = Ee();
function ja(e, t, r) {
  if (r === 1) {
    Ee.fromArray($4, t, 0);
    var n = Ve.clone(e);
    return Ee.isIdentity($4) ? n : Ve.transform(n, n, $4);
  }
  var a = wR(r);
  a.reset();
  var i = e.center, o = e.radius, s = e.extrema;
  if (s && r < 50) {
    for (var u = 0, c = r; u < c; ++u) for (var l = 0, d = s; l < d.length; l++) {
      var f = d[l];
      D.transformMat4Offset(Ks, f, t, 0, 0, 16 * u), a.includePosition(Ks);
    }
    for (a.finishedIncludeStep(), u = 0, c = r; u < c; ++u) for (var m = 0, h = s; m < h.length; m++)
      f = h[m], D.transformMat4Offset(Ks, f, t, 0, 0, 16 * u), a.radiusPosition(Ks);
  } else {
    for (u = 0, c = r; u < c; ++u) D.transformMat4Offset(Ks, i, t, 0, 0, 16 * u), a.includePositionRadius(Ks, o);
    for (a.finishedIncludeStep(), u = 0, c = r; u < c; ++u) D.transformMat4Offset(Ks, i, t, 0, 0, 16 * u), a.radiusPositionRadius(Ks, o);
  }
  return a.getSphere();
}
var _i = new Uint8Array(772);
function CR(e, t) {
  if (t === 0) return 0;
  var r = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), n = t - 4 >> 2, a = 4 * n, i = 0;
  if (n < 0) for (var o = 0; o < t; ++o) i += e[o] && 1;
  else {
    for (o = 0; o < n; ++o) {
      var s = r[o];
      i += _i[65535 & s] + _i[s >> 16];
    }
    for (o = a; o < t; ++o) i += e[o] && 1;
  }
  return i / t;
}
function ru(e, t) {
  var r = Oa(Math.max(1, e), 1, Uint8Array, t && t.tMarker.ref.value.array), n = CR(r.array, e), a = n === 0 ? 0 : -1;
  return t ? (U.updateIfChanged(t.uMarker, 0), U.update(t.tMarker, r), U.update(t.uMarkerTexDim, Ze.create(r.width, r.height)), U.updateIfChanged(t.markerAverage, n), U.updateIfChanged(t.markerStatus, a), t) : { uMarker: U.create(0), tMarker: U.create(r), uMarkerTexDim: U.create(Ze.create(r.width, r.height)), markerAverage: U.create(n), markerStatus: U.create(a) };
}
_i[1] = 1, _i[2] = 1, _i[3] = 1, _i[256] = 1, _i[512] = 1, _i[768] = 1, _i[257] = 2, _i[513] = 2, _i[769] = 2, _i[258] = 2, _i[514] = 2, _i[770] = 2, _i[259] = 2, _i[515] = 2, _i[771] = 2;
var dc = { kind: "null-location" };
function ca(e, t, r, n, a, i) {
  if (a === void 0 && (a = !1), i === void 0 && (i = function() {
    return !1;
  }), e % r != 0) throw new Error("incompatible groupCount and stride");
  var o = { location: dc, index: 0, groupIndex: 0, instanceIndex: 0, isSecondary: !1 }, s = o.groupIndex < e, u = !1, c = 0, l = 0, d = !1;
  return { get hasNext() {
    return s;
  }, get isNextNewInstance() {
    return u;
  }, groupCount: e, instanceCount: t, count: e * t, stride: r, nonInstanceable: a, move: function() {
    return s && (o.groupIndex = c, o.instanceIndex = l, o.index = l * e + c, o.location = n(c, d ? -1 : l), o.isSecondary = i(c, d ? -1 : l), (c += r) === e ? (++l, u = !0, l < t && (c = 0)) : u = !1, s = c < e), o;
  }, reset: function() {
    o.location = dc, o.index = 0, o.groupIndex = 0, o.instanceIndex = 0, o.isSecondary = !1, s = o.groupIndex < e, u = !1, c = 0, l = 0, d = !1;
  }, skipInstance: function() {
    s && o.instanceIndex === l && (++l, c = 0, s = l < t);
  }, voidInstances: function() {
    d = !0;
  } };
}
function am(e) {
  return { kind: "position-location", position: D() };
}
function hs(e, t, r, n) {
  var a = function(i, o, s, u) {
    switch (vi.getGranularity(i, s.granularity)) {
      case "uniform":
        return function(c, l, d) {
          return function(f, m) {
            return m ? (U.update(m.uColor, Qe.toVec3Normalized(m.uColor.ref.value, f)), U.updateIfChanged(m.dColorType, "uniform"), m) : { uColor: U.create(Qe.toVec3Normalized(D(), f)), tColor: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: U.create(ko()), tPalette: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: U.create(Ze.create(1, 1)), uColorGridDim: U.create(D.create(1, 1, 1)), uColorGridTransform: U.create(jt.create(0, 0, 0, 1)), dColorType: U.create("uniform"), dUsePalette: U.create(!1) };
          }(l(dc, !1), d);
        }(0, s.color, u);
      case "instance":
        return function(c, l, d) {
          var f = c.instanceCount, m = Oa(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var h = c.move(), p = h.location, g = h.isSecondary, v = h.instanceIndex;
            Qe.toArray(l(p, g), m.array, 3 * v), c.skipInstance();
          }
          return Q1(m, "instance", d);
        }(i, s.color, u);
      case "group":
        return function(c, l, d) {
          var f = c.groupCount, m = Oa(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext && !c.isNextNewInstance; ) {
            var h = c.move(), p = h.location, g = h.isSecondary, v = h.groupIndex;
            Qe.toArray(l(p, g), m.array, 3 * v);
          }
          return Q1(m, "group", d);
        }(i, s.color, u);
      case "groupInstance":
        return function(c, l, d) {
          var f = c.groupCount, m = c.instanceCount, h = m * f, p = Oa(Math.max(1, h), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var g = c.move(), v = g.location, y = g.isSecondary, _ = g.index;
            Qe.toArray(l(v, y), p.array, 3 * _);
          }
          return Q1(p, "groupInstance", d);
        }(i, s.color, u);
      case "vertex":
        return function(c, l, d) {
          var f = c.groupCount, m = c.stride, h = Oa(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(), c.voidInstances(); c.hasNext && !c.isNextNewInstance; ) for (var p = c.move(), g = p.location, v = p.isSecondary, y = p.groupIndex, _ = l(g, v), S = 0; S < m; ++S) Qe.toArray(_, h.array, 3 * (y + S));
          return Q1(h, "vertex", d);
        }(o, s.color, u);
      case "vertexInstance":
        return function(c, l, d) {
          var f = c.groupCount, m = c.instanceCount, h = c.stride, p = m * f, g = Oa(Math.max(1, p), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) for (var v = c.move(), y = v.location, _ = v.isSecondary, S = v.index, b = l(y, _), x = 0; x < h; ++x) Qe.toArray(b, g.array, 3 * (S + x));
          return Q1(g, "vertexInstance", d);
        }(o, s.color, u);
      case "volume":
        return jC(s.grid, "volume", u);
      case "volumeInstance":
        return jC(s.grid, "volumeInstance", u);
      case "direct":
        return function(c) {
          return c ? (U.updateIfChanged(c.dColorType, "direct"), c) : { uColor: U.create(D()), tColor: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: U.create(ko()), tPalette: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: U.create(Ze.create(1, 1)), uColorGridDim: U.create(D.create(1, 1, 1)), uColorGridTransform: U.create(jt.create(0, 0, 0, 1)), dColorType: U.create("direct"), dUsePalette: U.create(!1) };
        }(u);
    }
  }(e, t, r, n);
  return r.palette ? (U.updateIfChanged(a.dUsePalette, !0), function(i, o) {
    var s = !0, u = o.ref.value;
    if (i.colors.length !== u.width || u.filter !== i.filter) s = !1;
    else for (var c = u.array, l = 0, d = 0, f = i.colors; d < f.length; d++) {
      var m = f[d], h = Qe.toRgb(m), p = h[0], g = h[1], v = h[2];
      if (c[l++] !== p || c[l++] !== g || c[l++] !== v) {
        s = !1;
        break;
      }
    }
    if (!s) {
      for (var y = new Uint8Array(3 * i.colors.length), _ = 0, S = 0, b = i.colors; S < b.length; S++) {
        m = b[S];
        var x = Qe.toRgb(m);
        p = x[0], g = x[1], v = x[2], y[_++] = p, y[_++] = g, y[_++] = v;
      }
      U.update(o, { array: y, height: 1, width: i.colors.length, filter: i.filter });
    }
  }(r.palette, a.tPalette)) : U.updateIfChanged(a.dUsePalette, !1), a;
}
function Q1(e, t, r) {
  return r ? (U.update(r.tColor, e), U.update(r.uColorTexDim, Ze.create(e.width, e.height)), U.updateIfChanged(r.dColorType, t), r) : { uColor: U.create(D()), tColor: U.create(e), tColorGrid: U.create(ko()), tPalette: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: U.create(Ze.create(e.width, e.height)), uColorGridDim: U.create(D.create(1, 1, 1)), uColorGridTransform: U.create(jt.create(0, 0, 0, 1)), dColorType: U.create(t), dUsePalette: U.create(!1) };
}
function jC(e, t, r) {
  var n = e.colors, a = e.dimension, i = e.transform, o = n.getWidth(), s = n.getHeight();
  return r ? (U.update(r.tColorGrid, n), U.update(r.uColorTexDim, Ze.create(o, s)), U.update(r.uColorGridDim, D.clone(a)), U.update(r.uColorGridTransform, jt.clone(i)), U.updateIfChanged(r.dColorType, t), r) : { uColor: U.create(D()), tColor: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: U.create(n), tPalette: U.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: U.create(Ze.create(o, s)), uColorGridDim: U.create(D.clone(a)), uColorGridTransform: U.create(jt.clone(i)), dColorType: U.create(t), dUsePalette: U.create(!1) };
}
var YC = ka(), Yre = Ee();
function I8(e, t, r) {
  var n = function(u, c) {
    for (var l = 0; l < c; l++) if (ka.fromMat4(YC, Ee.fromArray(Yre, u, 16 * l)), ka.determinant(YC) < 0) return !0;
    return !1;
  }(e, t);
  if (r) {
    U.update(r.matrix, r.matrix.ref.value);
    var a = r.transform.ref.value.length >= 16 * t ? r.transform.ref.value : new Float32Array(16 * t);
    a.set(e), U.update(r.transform, a), U.updateIfChanged(r.uInstanceCount, t), U.updateIfChanged(r.instanceCount, t);
    var i = r.aTransform.ref.value.length >= 16 * t ? r.aTransform.ref.value : new Float32Array(16 * t);
    U.update(r.aTransform, i);
    var o = r.extraTransform.ref.value.length >= 16 * t ? r.extraTransform.ref.value : new Float32Array(16 * t);
    U.update(r.extraTransform, D6(o, t));
    var s = r.aInstance.ref.value.length >= t ? r.aInstance.ref.value : new Float32Array(t);
    U.update(r.aInstance, lc(s, t)), U.update(r.hasReflection, n);
  } else r = { aTransform: U.create(new Float32Array(16 * t)), matrix: U.create(Ee.identity()), transform: U.create(new Float32Array(e)), extraTransform: U.create(D6(new Float32Array(16 * t), t)), uInstanceCount: U.create(t), instanceCount: U.create(t), aInstance: U.create(lc(new Float32Array(t))), hasReflection: U.create(n) };
  return ER(r), r;
}
var T8 = new Float32Array(16);
function N8(e) {
  return I8(new Float32Array(T8), 1, e);
}
function D6(e, t) {
  for (var r = 0; r < t; r++) e.set(T8, 16 * r);
  return e;
}
function ER(e) {
  for (var t = e.aTransform.ref.value, r = e.instanceCount.ref.value, n = e.matrix.ref.value, a = e.transform.ref.value, i = e.extraTransform.ref.value, o = 0; o < r; o++) {
    var s = 16 * o;
    Ee.mulOffset(t, i, a, s, s, s), Ee.mulOffset(t, n, t, s, 0, s);
  }
  U.update(e.aTransform, t);
}
Ee.toArray(Ee.identity(), T8, 0);
var $t = { 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, cornflower: 6591981, 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, laserlemon: 16777044, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrod: 16448210, 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, maroon2: 8323072, maroon3: 11546720, 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, purple2: 8323199, purple3: 10494192, 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 };
function qp(e) {
  return k(k({}, qp.Zero), e);
}
function W0() {
}
(function() {
  var e = /* @__PURE__ */ new Map();
  Object.keys($t).forEach(function(t) {
    e.set($t[t], t);
  });
})(), function(e) {
  e.Zero = { metalness: 0, roughness: 0, bumpiness: 0 }, e.toArray = function(t, r, n) {
    return r[n] = 255 * t.metalness, r[n + 1] = 255 * t.roughness, r[n + 2] = 255 * t.bumpiness, r;
  }, e.toString = function(t) {
    var r = t.metalness, n = t.roughness, a = t.bumpiness;
    return "M ".concat(r.toFixed(2), " | R ").concat(n.toFixed(2), " | B ").concat(a.toFixed(2));
  }, e.getParam = function(t) {
    return V.Group({ metalness: V.Numeric(0, { min: 0, max: 1, step: 0.01 }), roughness: V.Numeric(1, { min: 0, max: 1, step: 0.01 }), bumpiness: V.Numeric(0, { min: 0, max: 1, step: 0.01 }) }, k(k({}, t), { presets: [[{ metalness: 0, roughness: 1, bumpiness: 0 }, "Matte"], [{ metalness: 0, roughness: 0.2, bumpiness: 0 }, "Plastic"], [{ metalness: 0, roughness: 0.6, bumpiness: 0 }, "Glossy"], [{ metalness: 1, roughness: 0.6, bumpiness: 0 }, "Metallic"]] }));
  };
}(qp || (qp = {})), function(e) {
  e.Type = { none: 0, plane: 1, sphere: 2, cube: 3, cylinder: 4, infiniteCone: 5 }, e.Params = { variant: V.Select("pixel", V.arrayToOptions(["instance", "pixel"])), objects: V.ObjectList({ type: V.Select("plane", V.objectToOptions(e.Type, function(i) {
    return ac(i);
  })), invert: V.Boolean(!1), position: V.Vec3(D()), rotation: V.Group({ axis: V.Vec3(D.create(1, 0, 0)), angle: V.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" }) }, { isExpanded: !0 }), scale: V.Vec3(D.create(1, 1, 1)) }, function(i) {
    return ac(i.type);
  }) };
  var t = Gn(), r = Gn(), n = D(), a = D();
  e.getClip = function(i, o) {
    for (var s = (o == null ? void 0 : o.objects) || { count: 0, type: new Array(5).fill(1), invert: new Array(5).fill(!1), position: new Array(15).fill(0), rotation: new Array(20).fill(0), scale: new Array(15).fill(1) }, u = s.type, c = s.invert, l = s.position, d = s.rotation, f = s.scale, m = 0, h = i.objects.length; m < h; ++m) {
      var p = i.objects[m];
      u[m] = e.Type[p.type], c[m] = p.invert, D.toArray(p.position, l, 3 * m), Gn.toArray(Gn.setAxisAngle(t, p.rotation.axis, Kn(p.rotation.angle)), d, 4 * m), D.toArray(p.scale, f, 3 * m);
    }
    return { variant: i.variant, objects: { count: i.objects.length, type: u, invert: c, position: l, rotation: d, scale: f } };
  }, e.areEqual = function(i, o) {
    if (i.variant !== o.variant || i.objects.count !== o.objects.count) return !1;
    for (var s = i.objects, u = o.objects, c = 0, l = s.count; c < l; ++c)
      if (s.invert[c] !== u.invert[c] || s.type[c] !== u.type[c] || (D.fromArray(n, s.position, 3 * c), D.fromArray(a, u.position, 3 * c), !D.equals(n, a)) || (D.fromArray(n, s.scale, 3 * c), D.fromArray(a, u.scale, 3 * c), !D.equals(n, a)) || (Gn.fromArray(t, s.rotation, 4 * c), Gn.fromArray(r, u.rotation, 4 * c), !Gn.equals(t, r))) return !1;
    return !0;
  };
}(W0 || (W0 = {}));
var yt, Wre = Object.keys({ custom: {}, auto: {}, highest: {}, higher: {}, high: {}, medium: {}, low: {}, lower: {}, lowest: {} }), Zre = V.arrayToOptions(Wre), Qre = { smoothColors: V.MappedStatic("auto", { auto: V.Group({}), on: V.Group({ resolutionFactor: V.Numeric(2, { min: 0.5, max: 6, step: 0.1 }), sampleStride: V.Numeric(3, { min: 1, max: 12, step: 1 }) }), off: V.Group({}) }) };
function J4(e) {
  return !!e.smoothColors;
}
function Of(e, t, r) {
  if ((e.name === "on" || e.name === "auto" && t) && r && r < 3) {
    var n = 3;
    return e.name === "on" ? (r *= e.params.resolutionFactor, n = e.params.sampleStride) : (r *= 2 - MO(0, 1.1, r), (r = Math.max(0.5, r)) > 1.2 && (n = 2)), { resolution: r, stride: n };
  }
}
function WC(e, t, r) {
  return e.fill(0, 4 * t, 4 * r), !0;
}
(function(e) {
  e.MaterialCategory = { category: "Material" }, e.ShadingCategory = { category: "Shading" }, e.CustomQualityParamInfo = { category: "Custom Quality", hideIf: function(t) {
    return t.quality !== void 0 && t.quality !== "custom";
  } }, e.Params = { alpha: V.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), quality: V.Select("auto", Zre, { isEssential: !0, description: "Visual/rendering quality of the representation." }), material: qp.getParam(), clip: V.Group(W0.Params) }, e.createSimple = function(t, r, n) {
    return t === void 0 && (t = $t.grey), r === void 0 && (r = 1), n || (n = N8()), { transform: n, locationIterator: ca(1, n.instanceCount.ref.value, 1, function() {
      return dc;
    }, !1, function() {
      return !1;
    }), theme: { color: Lh(0, { value: t }), size: M8(0, { value: r }) } };
  }, e.createValues = function(t, r) {
    var n = W0.getClip(t.clip);
    return { alpha: U.create(t.alpha), uAlpha: U.create(t.alpha), uVertexCount: U.create(r.vertexCount), uGroupCount: U.create(r.groupCount), drawCount: U.create(r.drawCount), uMetalness: U.create(t.material.metalness), uRoughness: U.create(t.material.roughness), uBumpiness: U.create(t.material.bumpiness), dLightCount: U.create(1), dClipObjectCount: U.create(n.objects.count), dClipVariant: U.create(n.variant), uClipObjectType: U.create(n.objects.type), uClipObjectInvert: U.create(n.objects.invert), uClipObjectPosition: U.create(n.objects.position), uClipObjectRotation: U.create(n.objects.rotation), uClipObjectScale: U.create(n.objects.scale) };
  }, e.updateValues = function(t, r) {
    U.updateIfChanged(t.alpha, r.alpha), U.updateIfChanged(t.uMetalness, r.material.metalness), U.updateIfChanged(t.uRoughness, r.material.roughness), U.updateIfChanged(t.uBumpiness, r.material.bumpiness);
    var n = W0.getClip(r.clip);
    U.update(t.dClipObjectCount, n.objects.count), U.update(t.dClipVariant, n.variant), U.update(t.uClipObjectType, n.objects.type), U.update(t.uClipObjectInvert, n.objects.invert), U.update(t.uClipObjectPosition, n.objects.position), U.update(t.uClipObjectRotation, n.objects.rotation), U.update(t.uClipObjectScale, n.objects.scale);
  }, e.createRenderableState = function(t) {
    t === void 0 && (t = {});
    var r = t.alpha === void 0 || t.alpha === 1;
    return { disposed: !1, visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, opaque: r, writeDepth: r };
  }, e.updateRenderableState = function(t, r) {
    t.opaque = r.alpha * t.alphaFactor >= 1, t.writeDepth = t.opaque;
  };
})(yt || (yt = {}));
var $re = { array: new Uint8Array(4), width: 1, height: 1 };
function rl(e) {
  return { tOverpaint: U.create($re), uOverpaintTexDim: U.create(Ze.create(1, 1)), dOverpaint: U.create(!1), tOverpaintGrid: U.create(ko()), uOverpaintGridDim: U.create(D.create(1, 1, 1)), uOverpaintGridTransform: U.create(jt.create(0, 0, 0, 1)), dOverpaintType: U.create("groupInstance") };
}
function ZC(e, t) {
  for (var r = 0, n = 0; n < t; ++n) r += e[n];
  return r / (255 * t);
}
var Jre = { array: new Uint8Array(1), width: 1, height: 1 };
function nl(e) {
  return { tTransparency: U.create(Jre), uTransparencyTexDim: U.create(Ze.create(1, 1)), dTransparency: U.create(!1), transparencyAverage: U.create(0), tTransparencyGrid: U.create(ko()), uTransparencyGridDim: U.create(D.create(1, 1, 1)), uTransparencyGridTransform: U.create(jt.create(0, 0, 0, 1)), dTransparencyType: U.create("groupInstance") };
}
var ene = { array: new Uint8Array(1), width: 1, height: 1 };
function al(e) {
  return { tClipping: U.create(ene), uClippingTexDim: U.create(Ze.create(1, 1)), dClipping: U.create(!1) };
}
function QC(e, t, r) {
  return e.fill(0, 4 * t, 4 * r), !0;
}
var Xt, tne = { array: new Uint8Array(4), width: 1, height: 1 };
function il(e) {
  return { tSubstance: U.create(tne), uSubstanceTexDim: U.create(Ze.create(1, 1)), dSubstance: U.create(!1), tSubstanceGrid: U.create(ko()), uSubstanceGridDim: U.create(D.create(1, 1, 1)), uSubstanceGridTransform: U.create(jt.create(0, 0, 0, 1)), dSubstanceType: U.create("groupInstance") };
}
function ex(e, t, r) {
  return e = po(Math.round(e), 0, 16777215) + 1, t[r + 2] = e % 256, e = Math.floor(e / 256), t[r + 1] = e % 256, e = Math.floor(e / 256), t[r] = e % 256, t;
}
function P8(e, t, r) {
  return 256 * Math.floor(e) * 256 + 256 * Math.floor(t) + Math.floor(r) - 1;
}
(function(e) {
  function t(m, h, p, g, v, y, _) {
    return _ ? function(S, b, x, A, w, C, M) {
      return M.vertexCount = w, M.triangleCount = C, U.update(M.vertexBuffer, S), U.update(M.indexBuffer, b), U.update(M.normalBuffer, x), U.update(M.groupBuffer, A), M;
    }(m, h, p, g, v, y, _) : function(S, b, x, A, w, C) {
      var M, T = Ve(), N = -1, I = -1, P = { kind: "mesh", vertexCount: w, triangleCount: C, vertexBuffer: U.create(S), indexBuffer: U.create(b), normalBuffer: U.create(x), groupBuffer: U.create(A), get boundingSphere() {
        var O = n(P);
        if (O !== N) {
          var F = Vd(P.vertexBuffer.ref.value, P.vertexCount, 1);
          Ve.copy(T, F), N = O;
        }
        return T;
      }, get groupMapping() {
        return P.groupBuffer.ref.version !== I && (M = v1(P.groupBuffer.ref.value, P.vertexCount), I = P.groupBuffer.ref.version), M;
      }, setBoundingSphere: function(O) {
        Ve.copy(T, O), N = n(P);
      }, meta: {} };
      return P;
    }(m, h, p, g, v, y);
  }
  function r(m) {
    return t(m ? m.vertexBuffer.ref.value : new Float32Array(0), m ? m.indexBuffer.ref.value : new Uint32Array(0), m ? m.normalBuffer.ref.value : new Float32Array(0), m ? m.groupBuffer.ref.value : new Float32Array(0), 0, 0, m);
  }
  function n(m) {
    return Zi([m.vertexCount, m.triangleCount, m.vertexBuffer.ref.version, m.indexBuffer.ref.version, m.normalBuffer.ref.version, m.groupBuffer.ref.version]);
  }
  e.create = t, e.createEmpty = r, e.computeNormals = function(m) {
    var h = m.vertexCount, p = m.triangleCount, g = m.vertexBuffer.ref.value, v = m.indexBuffer.ref.value, y = m.normalBuffer.ref.value.length >= 3 * h ? m.normalBuffer.ref.value : new Float32Array(3 * h);
    y === m.normalBuffer.ref.value && y.fill(0, 0, 3 * h), AR(g, v, y, h, p), U.update(m.normalBuffer, y);
  }, e.checkForDuplicateVertices = function(m, h) {
    h === void 0 && (h = 3);
    for (var p = m.vertexBuffer.ref.value, g = /* @__PURE__ */ new Map(), v = function(w, C) {
      return "".concat(w[0].toFixed(C), "|").concat(w[1].toFixed(C), "|").concat(w[2].toFixed(C));
    }, y = 0, _ = D(), S = 0, b = m.vertexCount; S < b; ++S) {
      D.fromArray(_, p, 3 * S);
      var x = v(_, h), A = g.get(x);
      A !== void 0 ? (y += 1, g.set(x, A + 1)) : g.set(x, 1);
    }
    return y;
  };
  var a = ka();
  function i(m) {
    for (var h = m.vertexCount, p = m.triangleCount, g = m.indexBuffer.ref.value, v = [], y = 0; y < h; ++y) v[y] = [];
    for (y = 0; y < p; ++y) {
      var _ = g[3 * y], S = g[3 * y + 1], b = g[3 * y + 2];
      js(v[_], S), js(v[_], b), js(v[S], _), js(v[S], b), js(v[b], _), js(v[b], S);
    }
    return v;
  }
  function o(m) {
    for (var h = m.triangleCount, p = m.indexBuffer.ref.value, g = /* @__PURE__ */ new Map(), v = function(x, A) {
      var w = G2(x, A), C = g.get(w) || 0;
      g.set(w, C + 1);
    }, y = 0; y < h; ++y) {
      var _ = p[3 * y], S = p[3 * y + 1], b = p[3 * y + 2];
      v(_, S), v(_, b), v(S, b);
    }
    return g;
  }
  function s(m) {
    var h = /* @__PURE__ */ new Set(), p = [0, 0];
    return m.forEach(function(g, v) {
      g === 1 && (function(y, _) {
        var S = Math.floor((Math.sqrt(8 * _ + 1) - 1) / 2), b = _ - (S * S + S) / 2;
        y[0] = S - b, y[1] = b;
      }(p, v), h.add(p[0]), h.add(p[1]));
    }), h;
  }
  function u(m, h, p) {
    var g = /* @__PURE__ */ new Map(), v = function(y, _) {
      g.has(y) ? js(g.get(y), _) : g.set(y, [_]);
    };
    return h.forEach(function(y) {
      for (var _ = 0, S = m[y]; _ < S.length; _++) {
        var b = S[_];
        h.has(b) && p.get(G2(y, b)) === 1 && v(y, b);
      }
    }), g;
  }
  function c(m, h, p, g) {
    for (var v, y = m.vertexBuffer, _ = m.indexBuffer, S = m.normalBuffer, b = m.triangleCount, x = y.ref.value, A = _.ref.value, w = S.ref.value, C = Ye.create(Uint32Array, 3, 1024, b), M = 0, T = 0; T < b; ++T) Ye.add3(C, A[3 * T], A[3 * T + 1], A[3 * T + 2]), M += 1;
    var N = D(), I = D(), P = D(), O = D(), F = D(), R = D(), G = D(), L = D(), q = D(), K = D(), X = Kn(120), H = /* @__PURE__ */ new Set(), W = Array.from(p.keys()).filter(function(ce) {
      return p.get(ce).length < 2;
    }).map(function(ce) {
      var _e = p.get(ce);
      return D.fromArray(N, x, 3 * ce), D.fromArray(I, x, 3 * _e[0]), D.fromArray(P, x, 3 * _e[1]), D.sub(F, I, N), D.sub(R, P, N), [ce, D.angle(F, R)];
    });
    W.sort(function(ce, _e) {
      return ce[1] - _e[1];
    });
    for (var ee = 0, $ = W; ee < $.length; ee++) {
      var te = $[ee], re = te[0], ie = te[1];
      if (!(H.has(re) || ie > X)) {
        var oe = p.get(re);
        if ((!h[oe[0]].includes(oe[1]) || !((v = p.get(oe[0])) === null || v === void 0) && v.includes(oe[1])) && (D.fromArray(N, x, 3 * re), D.fromArray(I, x, 3 * oe[0]), D.fromArray(P, x, 3 * oe[1]), D.sub(F, I, N), D.sub(R, P, N), D.add(L, F, R), !(D.squaredDistance(N, I) >= g))) {
          for (var se = !1, he = 0, ge = h[re]; he < ge.length; he++) {
            var De = ge[he];
            if (!oe.includes(De) && (D.fromArray(O, x, 3 * De), D.sub(G, O, N), D.dot(L, G) < 0)) {
              se = !0;
              break;
            }
          }
          se && (D.fromArray(q, w, 3 * re), D.triangleNormal(K, N, I, P), D.dot(K, q) > 0 ? Ye.add3(C, re, oe[0], oe[1]) : Ye.add3(C, oe[1], oe[0], re), H.add(re), H.add(oe[0]), H.add(oe[1]), M += 1);
        }
      }
    }
    var ae = Ye.compact(C);
    return m.triangleCount = M, U.update(_, ae), m;
  }
  function l(m, h) {
    var p = m.vertexCount, g = h.instanceCount.ref.value, v = am(), y = v.position, _ = m.vertexBuffer.ref.value, S = h.aTransform.ref.value;
    return ca(p, g, 1, function(b, x) {
      return x < 0 ? D.fromArray(y, _, 3 * b) : D.transformMat4Offset(y, _, S, 0, 3 * b, 16 * x), v;
    });
  }
  function d(m, h, p, g, v) {
    var y = p.instanceCount, _ = p.groupCount, S = hs(p, l(m, h), g.color), b = ru(y * _), x = rl(), A = nl(), w = il(), C = al(), M = { drawCount: 3 * m.triangleCount, vertexCount: m.vertexCount, groupCount: _, instanceCount: y }, T = Ve.clone(m.boundingSphere), N = ja(T, h.aTransform.ref.value, y);
    return k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("mesh"), aPosition: m.vertexBuffer, aNormal: m.normalBuffer, aGroup: m.groupBuffer, elements: m.indexBuffer, boundingSphere: U.create(N), invariantBoundingSphere: U.create(T), uInvariantBoundingSphere: U.create(jt.ofSphere(T)) }, S), b), x), A), w), C), h), yt.createValues(v, M)), { uDoubleSided: U.create(v.doubleSided), dFlatShaded: U.create(v.flatShaded), dFlipSided: U.create(v.flipSided), dIgnoreLight: U.create(v.ignoreLight), dXrayShaded: U.create(v.xrayShaded), uBumpFrequency: U.create(v.bumpFrequency), uBumpAmplitude: U.create(v.bumpAmplitude), meta: U.create(m.meta) });
  }
  function f(m, h) {
    yt.updateRenderableState(m, h), m.opaque = m.opaque && !h.xrayShaded, m.writeDepth = m.opaque;
  }
  e.transform = function(m, h) {
    var p = m.vertexBuffer.ref.value;
    Vp(h, p, 0, m.vertexCount), Ee.isTranslationAndUniformScaling(h) || function(g, v, y, _) {
      for (var S = 0, b = 3 * _; S < b; S += 3) D.fromArray(Ro, v, y + S), D.transformMat3(Ro, Ro, g), D.toArray(Ro, v, y + S);
    }(ka.directionTransform(a, h), m.normalBuffer.ref.value, 0, m.vertexCount), U.update(m.vertexBuffer, p);
  }, e.getOriginalData = function(m) {
    return ("kind" in m ? m.meta : m.meta.ref.value).originalData;
  }, e.uniformTriangleGroup = function(m, h) {
    h === void 0 && (h = !0);
    var p = m.indexBuffer, g = m.vertexBuffer, v = m.groupBuffer, y = m.normalBuffer, _ = m.triangleCount, S = m.vertexCount, b = p.ref.value, x = g.ref.value, A = v.ref.value, w = y.ref.value, C = Ye.create(Uint32Array, 3, 1024, _), M = Ye.create(Float32Array, 3, 1024, x);
    M.currentIndex = 3 * S, M.elementCount = S;
    var T = Ye.create(Float32Array, 3, 1024, w);
    T.currentIndex = 3 * S, T.elementCount = S;
    var N = Ye.create(Float32Array, 1, 1024, A);
    N.currentIndex = S, N.elementCount = S;
    var I = D(), P = D(), O = D(), F = D(), R = D(), G = D();
    function L(ue) {
      D.fromArray(I, x, 3 * ue), D.fromArray(F, w, 3 * ue), Ye.add3(M, I[0], I[1], I[2]), Ye.add3(T, F[0], F[1], F[2]);
    }
    function q(ue, be) {
      D.fromArray(I, x, 3 * ue), D.fromArray(P, x, 3 * be), D.scale(I, D.add(I, I, P), 0.5), D.fromArray(F, w, 3 * ue), D.fromArray(R, w, 3 * be), D.scale(F, D.add(F, F, R), 0.5), Ye.add3(M, I[0], I[1], I[2]), Ye.add3(T, F[0], F[1], F[2]);
    }
    function K(ue, be, Se) {
      D.fromArray(I, x, 3 * ue), D.fromArray(P, x, 3 * be), D.fromArray(O, x, 3 * Se), D.scale(I, D.add(I, D.add(I, I, P), O), 1 / 3), D.fromArray(F, w, 3 * ue), D.fromArray(R, w, 3 * be), D.fromArray(G, w, 3 * Se), D.scale(F, D.add(F, D.add(F, F, R), G), 1 / 3), Ye.add3(M, I[0], I[1], I[2]), Ye.add3(T, F[0], F[1], F[2]);
    }
    function X(ue, be, Se, Ne, J) {
      ++W, L(ue), q(ue, be), q(ue, Se), Ye.add3(C, H, H + 1, H + 2);
      for (var Z = 0; Z < 3; ++Z) Ye.add(N, Ne);
      for (H += 3, W += 2, L(be), L(Se), q(ue, be), q(ue, Se), Ye.add3(C, H, H + 1, H + 3), Ye.add3(C, H, H + 3, H + 2), Z = 0; Z < 4; ++Z) Ye.add(N, J);
      H += 4;
    }
    var H = S, W = 0;
    if (h) for (var ee = 0, $ = _; ee < $; ++ee) {
      var te = b[3 * ee], re = b[3 * ee + 1], ie = b[3 * ee + 2], oe = A[te], se = A[re], he = A[ie];
      if (oe === se && oe === he) ++W, Ye.add3(C, te, re, ie);
      else if (oe === se) X(ie, te, re, he, oe);
      else if (oe === he) X(re, ie, te, se, he);
      else if (se === he) X(te, re, ie, oe, se);
      else {
        W += 2, L(te), q(te, re), q(te, ie), K(te, re, ie), Ye.add3(C, H, H + 1, H + 3), Ye.add3(C, H, H + 3, H + 2);
        for (var ge = 0; ge < 4; ++ge) Ye.add(N, oe);
        for (H += 4, W += 2, L(re), q(re, ie), q(re, te), K(te, re, ie), Ye.add3(C, H, H + 1, H + 3), Ye.add3(C, H, H + 3, H + 2), ge = 0; ge < 4; ++ge) Ye.add(N, se);
        for (H += 4, W += 2, L(ie), q(ie, re), q(ie, te), K(te, re, ie), Ye.add3(C, H + 3, H + 1, H), Ye.add3(C, H + 2, H + 3, H), ge = 0; ge < 4; ++ge) Ye.add(N, he);
        H += 4;
      }
    }
    else for (ee = 0, $ = _; ee < $; ++ee)
      if (te = b[3 * ee], re = b[3 * ee + 1], ie = b[3 * ee + 2], oe = A[te], se = A[re], he = A[ie], oe !== se || oe !== he) {
        ++W, L(te), L(re), L(ie), Ye.add3(C, H, H + 1, H + 2);
        var De = se === he ? se : oe;
        for (ge = 0; ge < 3; ++ge) Ye.add(N, De);
        H += 3;
      } else ++W, Ye.add3(C, te, re, ie);
    var ae = Ye.compact(C), ce = Ye.compact(M), _e = Ye.compact(T), le = Ye.compact(N);
    return m.vertexCount = H, m.triangleCount = W, U.update(g, ce), U.update(v, le), U.update(p, ae), U.update(y, _e), m.meta.originalData = { indexBuffer: b, vertexCount: S, triangleCount: _ }, m;
  }, e.smoothEdges = function(m, h) {
    (function(S, b) {
      for (var x = S.indexBuffer, A = S.triangleCount, w = x.ref.value, C = Ye.create(Uint32Array, 3, 1024, A), M = 0, T = 0; T < A; ++T) {
        var N = w[3 * T], I = w[3 * T + 1], P = w[3 * T + 2];
        b[N].length !== 2 && b[I].length !== 2 && b[P].length !== 2 && (Ye.add3(C, N, I, P), M += 1);
      }
      var O = Ye.compact(C);
      S.triangleCount = M, U.update(x, O);
    })(m, i(m));
    for (var p = 0; p < 10; ++p) {
      var g = m.triangleCount, v = o(m), y = i(m);
      if (c(m, y, u(y, s(v), v), h.maxNewEdgeLength * h.maxNewEdgeLength), m.triangleCount === g) break;
    }
    var _ = o(m);
    return function(S, b, x) {
      for (var A = x.iterations, w = x.lambda, C = D(), M = D(), T = D(), N = D(), I = -w, P = new Float32Array(S.vertexBuffer.ref.value.length), O = function(R) {
        var G = S.vertexBuffer.ref.value;
        P.set(G), b.forEach(function(q, K) {
          if (q.length === 2) {
            D.fromArray(C, G, 3 * K), D.fromArray(M, G, 3 * q[0]), D.fromArray(T, G, 3 * q[1]);
            var X = 1 / D.distance(C, M), H = 1 / D.distance(C, T);
            D.scale(M, M, X), D.scale(T, T, H), D.add(N, M, T), D.scale(N, N, 1 / (X + H)), D.sub(N, N, C), D.scale(N, N, R), D.add(N, C, N), D.toArray(N, P, 3 * K);
          }
        });
        var L = S.vertexBuffer.ref.value;
        U.update(S.vertexBuffer, P), P = L;
      }, F = 0; F < A; ++F) O(w), O(I);
    }(m, u(i(m), s(_), _), { iterations: h.iterations, lambda: 0.5 }), m;
  }, e.Params = k(k({}, yt.Params), { doubleSided: V.Boolean(!1, yt.CustomQualityParamInfo), flipSided: V.Boolean(!1, yt.ShadingCategory), flatShaded: V.Boolean(!1, yt.ShadingCategory), ignoreLight: V.Boolean(!1, yt.ShadingCategory), xrayShaded: V.Boolean(!1, yt.ShadingCategory), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), bumpAmplitude: V.Numeric(1, { min: 0, max: 5, step: 0.1 }, yt.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: d, createValuesSimple: function(m, h, p, g, v) {
    var y = yt.createSimple(p, g, v), _ = k(k({}, V.getDefaultValues(e.Params)), h);
    return d(m, y.transform, y.locationIterator, y.theme, _);
  }, updateValues: function(m, h) {
    yt.updateValues(m, h), U.updateIfChanged(m.uDoubleSided, h.doubleSided), U.updateIfChanged(m.dFlatShaded, h.flatShaded), U.updateIfChanged(m.dFlipSided, h.flipSided), U.updateIfChanged(m.dIgnoreLight, h.ignoreLight), U.updateIfChanged(m.dXrayShaded, h.xrayShaded), U.updateIfChanged(m.uBumpFrequency, h.bumpFrequency), U.updateIfChanged(m.uBumpAmplitude, h.bumpAmplitude);
  }, updateBoundingSphere: function(m, h) {
    var p = Ve.clone(h.boundingSphere), g = ja(p, m.aTransform.ref.value, m.instanceCount.ref.value);
    Ve.equals(g, m.boundingSphere.ref.value) || U.update(m.boundingSphere, g), Ve.equals(p, m.invariantBoundingSphere.ref.value) || (U.update(m.invariantBoundingSphere, p), U.update(m.uInvariantBoundingSphere, jt.fromSphere(m.uInvariantBoundingSphere.ref.value, p)));
  }, createRenderableState: function(m) {
    var h = yt.createRenderableState(m);
    return f(h, m), h;
  }, updateRenderableState: f, createPositionIterator: l };
})(Xt || (Xt = {}));
var tx = 255 / 256, rx = D.create(16777216, 65536, 256), rne = jt.create(tx / rx[0], tx / rx[1], tx / rx[2], 0.99609375), $C = jt();
function xl(e, t, r) {
  switch (vi.getGranularity(e, t.granularity)) {
    case "uniform":
      return function(n, a, i) {
        return function(o, s) {
          return s ? (U.update(s.uSize, o), U.updateIfChanged(s.dSizeType, "uniform"), s) : k(k({ uSize: U.create(o) }, { tSize: U.create(nne), uSizeTexDim: U.create(Ze.create(1, 1)) }), { dSizeType: U.create("uniform") });
        }(a(dc), i);
      }(0, t.size, r);
    case "group":
      return function(n, a, i) {
        var o = n.groupCount, s = Oa(Math.max(1, o), 3, Uint8Array, i && i.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var u = n.move();
          ex(a(u.location) * M2, s.array, 3 * u.groupIndex);
        }
        return nx(s, "group", i);
      }(e, t.size, r);
    case "groupInstance":
      return function(n, a, i) {
        var o = n.groupCount, s = n.instanceCount, u = s * o, c = Oa(Math.max(1, u), 3, Uint8Array, i && i.tSize.ref.value.array);
        for (n.reset(); n.hasNext; ) {
          var l = n.move();
          ex(a(l.location) * M2, c.array, 3 * l.index);
        }
        return nx(c, "groupInstance", i);
      }(e, t.size, r);
    case "instance":
      return function(n, a, i) {
        var o = n.instanceCount, s = Oa(Math.max(1, o), 3, Uint8Array, i && i.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var u = n.move();
          ex(a(u.location) * M2, s.array, 3 * u.instanceIndex), n.skipInstance();
        }
        return nx(s, "instance", i);
      }(e, t.size, r);
  }
}
var M2 = 100;
function fh(e) {
  switch (e.dSizeType.ref.value) {
    case "uniform":
      return e.uSize.ref.value;
    case "instance":
    case "group":
    case "groupInstance":
      for (var t = 0, r = e.tSize.ref.value.array, n = 0, a = r.length; n < a; n += 3) {
        var i = P8(r[n], r[n + 1], r[n + 2]);
        t < i && (t = i);
      }
      return t / M2;
  }
}
var im, nne = { array: new Uint8Array(3), width: 1, height: 1 };
function nx(e, t, r) {
  return r ? (U.update(r.tSize, e), U.update(r.uSizeTexDim, Ze.create(e.width, e.height)), U.updateIfChanged(r.dSizeType, t), r) : { uSize: U.create(0), tSize: U.create(e), uSizeTexDim: U.create(Ze.create(e.width, e.height)), dSizeType: U.create(t) };
}
function JC(e, t, r, n, a, i, o) {
  for (var s = 0; s < t; s++) {
    for (var u = 0; u < r; u++) n[u] = e[u * t + s];
    for (eE(n, a, i, o, r), u = 0; u < r; u++) e[u * t + s] = a[u];
  }
  for (u = 0; u < r; u++) {
    for (s = 0; s < t; s++) n[s] = e[u * t + s];
    for (eE(n, a, i, o, t), s = 0; s < t; s++) e[u * t + s] = Math.sqrt(a[s]);
  }
}
function eE(e, t, r, n, a) {
  r[0] = 0, n[0] = Number.MIN_SAFE_INTEGER, n[1] = Number.MAX_SAFE_INTEGER;
  for (var i = 1, o = 0; i < a; i++) {
    for (var s = (e[i] + i * i - (e[r[o]] + r[o] * r[o])) / (2 * i - 2 * r[o]); s <= n[o]; ) o--, s = (e[i] + i * i - (e[r[o]] + r[o] * r[o])) / (2 * i - 2 * r[o]);
    r[++o] = i, n[o] = s, n[o + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (i = 0, o = 0; i < a; i++) {
    for (; n[o + 1] < i; ) o++;
    t[i] = (i - r[o]) * (i - r[o]) + e[r[o]];
  }
}
(function(e) {
  function t(s, u, c, l) {
    return l ? function(d, f, m, h) {
      return h.pointCount = m, U.update(h.centerBuffer, d), U.update(h.groupBuffer, f), h;
    }(s, u, c, l) : function(d, f, m) {
      var h, p = Ve(), g = -1, v = -1, y = { kind: "points", pointCount: m, centerBuffer: U.create(d), groupBuffer: U.create(f), get boundingSphere() {
        var _ = n(y);
        if (_ !== g) {
          var S = Vd(y.centerBuffer.ref.value, y.pointCount, 1);
          Ve.copy(p, S), g = _;
        }
        return p;
      }, get groupMapping() {
        return y.groupBuffer.ref.version !== v && (h = v1(y.groupBuffer.ref.value, y.pointCount), v = y.groupBuffer.ref.version), h;
      }, setBoundingSphere: function(_) {
        Ve.copy(p, _), g = n(y);
      } };
      return y;
    }(s, u, c);
  }
  function r(s) {
    return t(s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return Zi([s.pointCount, s.centerBuffer.ref.version, s.groupBuffer.ref.version]);
  }
  function a(s, u) {
    var c = s.pointCount, l = u.instanceCount.ref.value, d = am(), f = d.position, m = s.centerBuffer.ref.value, h = u.aTransform.ref.value;
    return ca(c, l, 1, function(p, g) {
      return g < 0 ? D.fromArray(f, m, 3 * p) : D.transformMat4Offset(f, m, h, 0, 3 * p, 16 * g), d;
    });
  }
  function i(s, u, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, h = hs(c, a(s, u), l.color), p = xl(c, l.size), g = ru(f * m), v = rl(), y = nl(), _ = il(), S = al(), b = { drawCount: s.pointCount, vertexCount: s.pointCount, groupCount: m, instanceCount: f }, x = Ve.clone(s.boundingSphere), A = ja(x, u.aTransform.ref.value, f);
    return k(k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("points"), aPosition: s.centerBuffer, aGroup: s.groupBuffer, boundingSphere: U.create(A), invariantBoundingSphere: U.create(x), uInvariantBoundingSphere: U.create(jt.ofSphere(x)) }, h), p), g), v), y), _), S), u), yt.createValues(d, b)), { uSizeFactor: U.create(d.sizeFactor), dPointSizeAttenuation: U.create(d.pointSizeAttenuation), dPointStyle: U.create(d.pointStyle) });
  }
  function o(s, u) {
    yt.updateRenderableState(s, u), s.opaque = s.opaque && u.pointStyle !== "fuzzy", s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = r, e.transform = function(s, u) {
    var c = s.centerBuffer.ref.value;
    Vp(u, c, 0, s.pointCount), U.update(s.centerBuffer, c);
  }, e.StyleTypes = { square: "Square", circle: "Circle", fuzzy: "Fuzzy" }, e.StyleTypeNames = Object.keys(e.StyleTypes), e.Params = k(k({}, yt.Params), { sizeFactor: V.Numeric(3, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: V.Boolean(!1), pointStyle: V.Select("square", V.objectToOptions(e.StyleTypes)) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(s, u, c, l, d) {
    var f = yt.createSimple(c, l, d), m = k(k({}, V.getDefaultValues(e.Params)), u);
    return i(s, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(s, u) {
    yt.updateValues(s, u), U.updateIfChanged(s.uSizeFactor, u.sizeFactor), U.updateIfChanged(s.dPointSizeAttenuation, u.pointSizeAttenuation), U.updateIfChanged(s.dPointStyle, u.pointStyle);
  }, updateBoundingSphere: function(s, u) {
    var c = Ve.clone(u.boundingSphere), l = ja(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    Ve.equals(l, s.boundingSphere.ref.value) || U.update(s.boundingSphere, l), Ve.equals(c, s.invariantBoundingSphere.ref.value) || (U.update(s.invariantBoundingSphere, c), U.update(s.uInvariantBoundingSphere, jt.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = yt.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: a };
})(im || (im = {}));
var ax = {}, vs, DR = { fontFamily: V.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]), fontQuality: V.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]), fontStyle: V.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]), fontVariant: V.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]), fontWeight: V.Select("normal", [["normal", "Normal"], ["bold", "Bold"]]) }, ane = function() {
  function e(t) {
    t === void 0 && (t = {}), this.mapped = {}, this.scratchW = 0, this.scratchH = 0, this.currentX = 0, this.currentY = 0, this.cutoff = 0.5;
    var r = k(k({}, V.getDefaultValues(DR)), t);
    this.props = r;
    var n = 32 * (r.fontQuality + 1);
    this.buffer = n / 8, this.radius = n / 3, this.lineHeight = Math.round(n + 2 * this.buffer + this.radius), this.maxWidth = Math.round(0.75 * this.lineHeight), this.texture = Oa(350 * this.lineHeight * this.maxWidth, 1, Uint8Array), this.scratchCanvas = document.createElement("canvas"), this.scratchCanvas.width = this.maxWidth, this.scratchCanvas.height = this.lineHeight, this.scratchContext = this.scratchCanvas.getContext("2d"), this.scratchContext.font = "".concat(r.fontStyle, " ").concat(r.fontVariant, " ").concat(r.fontWeight, " ").concat(n, "px ").concat(r.fontFamily), this.scratchContext.fillStyle = "black", this.scratchContext.textBaseline = "middle", this.scratchData = new Uint8Array(this.lineHeight * this.maxWidth), this.gridOuter = new Float64Array(this.lineHeight * this.maxWidth), this.gridInner = new Float64Array(this.lineHeight * this.maxWidth), this.f = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.d = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.z = new Float64Array(Math.max(this.lineHeight, this.maxWidth) + 1), this.v = new Int16Array(Math.max(this.lineHeight, this.maxWidth)), this.middle = Math.ceil(this.lineHeight / 2), this.placeholder = this.get("�");
  }
  return e.prototype.get = function(t) {
    if (this.mapped[t] === void 0) {
      this.draw(t);
      var r = this.texture, n = r.array, a = r.width, i = r.height, o = this.scratchData;
      if (this.currentX + this.scratchW > a && (this.currentX = 0, this.currentY += this.scratchH), this.currentY + this.scratchH > i) return console.warn("canvas to small"), this.placeholder;
      this.mapped[t] = { x: this.currentX, y: this.currentY, w: this.scratchW, h: this.scratchH, nw: this.scratchW / this.lineHeight, nh: this.scratchH / this.lineHeight };
      for (var s = 0; s < this.scratchH; ++s) for (var u = 0; u < this.scratchW; ++u) n[a * (this.currentY + s) + this.currentX + u] = o[s * this.scratchW + u];
      this.currentX += this.scratchW;
    }
    return this.mapped[t];
  }, e.prototype.draw = function(t) {
    var r = this.lineHeight, n = this.scratchContext, a = this.scratchData, i = n.measureText(t), o = Math.min(this.maxWidth, Math.ceil(i.width + 2 * this.buffer)), s = o * r;
    n.clearRect(0, 0, o, r), n.fillText(t, this.buffer, this.middle);
    for (var u = n.getImageData(0, 0, o, r), c = 0; c < s; c++) {
      var l = u.data[4 * c + 3] / 255;
      this.gridOuter[c] = l === 1 ? 0 : l === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - l), 2), this.gridInner[c] = l === 1 ? Number.MAX_SAFE_INTEGER : l === 0 ? 0 : Math.pow(Math.max(0, l - 0.5), 2);
    }
    for (JC(this.gridOuter, o, r, this.f, this.d, this.v, this.z), JC(this.gridInner, o, r, this.f, this.d, this.v, this.z), c = 0; c < s; c++) {
      var d = this.gridOuter[c] - this.gridInner[c];
      a[c] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));
    }
    this.scratchW = o, this.scratchH = r;
  }, e;
}();
function tE(e, t, r, n) {
  for (var a = 0, i = 0, o = 0, s = 4 * r; o < s; ++o) {
    var u = 2 * o, c = Math.abs(e[u]);
    c > a && (a = c);
    var l = Math.abs(e[u + 1]);
    l > a && (a = l);
    var d = Math.abs(t[o]);
    d > i && (i = d);
  }
  return Math.max(i, n + n * a);
}
(function(e) {
  function t(s, u, c, l, d, f, m, h, p) {
    return p ? function(g, v, y, _, S, b, x, A, w) {
      return w.charCount = A, U.update(w.fontTexture, g), U.update(w.centerBuffer, v), U.update(w.mappingBuffer, y), U.update(w.depthBuffer, _), U.update(w.indexBuffer, S), U.update(w.groupBuffer, b), U.update(w.tcoordBuffer, x), w;
    }(s, u, c, l, d, f, m, h, p) : function(g, v, y, _, S, b, x, A) {
      var w, C = Ve(), M = -1, T = -1, N = { kind: "text", charCount: A, fontTexture: U.create(g), centerBuffer: U.create(v), mappingBuffer: U.create(y), depthBuffer: U.create(_), indexBuffer: U.create(S), groupBuffer: U.create(b), tcoordBuffer: U.create(x), get boundingSphere() {
        var I = n(N);
        if (I !== M) {
          var P = Vd(N.centerBuffer.ref.value, 4 * N.charCount, 4);
          Ve.copy(C, P), M = I;
        }
        return C;
      }, get groupMapping() {
        return N.groupBuffer.ref.version !== T && (w = v1(N.groupBuffer.ref.value, N.charCount, 4), T = N.groupBuffer.ref.version), w;
      }, setBoundingSphere: function(I) {
        Ve.copy(C, I), M = n(N);
      } };
      return N;
    }(s, u, c, l, d, f, m, h);
  }
  function r(s) {
    return t(s ? s.fontTexture.ref.value : Oa(0, 1, Uint8Array), s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.depthBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), s ? s.tcoordBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return Zi([s.charCount, s.fontTexture.ref.version, s.centerBuffer.ref.version, s.mappingBuffer.ref.version, s.depthBuffer.ref.version, s.indexBuffer.ref.version, s.groupBuffer.ref.version, s.tcoordBuffer.ref.version]);
  }
  function a(s, u) {
    var c = 4 * s.charCount, l = u.instanceCount.ref.value, d = am(), f = d.position, m = s.centerBuffer.ref.value, h = u.aTransform.ref.value;
    return ca(c, l, 4, function(p, g) {
      return g < 0 ? D.fromArray(f, m, 3 * p) : D.transformMat4Offset(f, m, h, 0, 3 * p, 16 * g), d;
    });
  }
  function i(s, u, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, h = hs(c, a(s, u), l.color), p = xl(c, l.size), g = ru(f * m), v = rl(), y = nl(), _ = il(), S = al(), b = { drawCount: 2 * s.charCount * 3, vertexCount: 4 * s.charCount, groupCount: m, instanceCount: f }, x = tE(s.mappingBuffer.ref.value, s.depthBuffer.ref.value, s.charCount, fh(p)), A = Ve.expand(Ve(), s.boundingSphere, x), w = ja(A, u.aTransform.ref.value, f);
    return k(k(k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("text"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aDepth: s.depthBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: U.create(w), invariantBoundingSphere: U.create(A), uInvariantBoundingSphere: U.create(jt.ofSphere(A)) }, h), p), g), v), y), _), S), u), { aTexCoord: s.tcoordBuffer, tFont: s.fontTexture, padding: U.create(x) }), yt.createValues(d, b)), { uSizeFactor: U.create(d.sizeFactor), uBorderWidth: U.create(po(d.borderWidth, 0, 0.5)), uBorderColor: U.create(Qe.toArrayNormalized(d.borderColor, D.zero(), 0)), uOffsetX: U.create(d.offsetX), uOffsetY: U.create(d.offsetY), uOffsetZ: U.create(d.offsetZ), uBackgroundColor: U.create(Qe.toArrayNormalized(d.backgroundColor, D.zero(), 0)), uBackgroundOpacity: U.create(d.backgroundOpacity) });
  }
  function o(s, u) {
    yt.updateRenderableState(s, u), s.pickable = !1, s.opaque = !1, s.writeDepth = !0;
  }
  e.create = t, e.createEmpty = r, e.Params = k(k(k({}, yt.Params), DR), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), borderWidth: V.Numeric(0, { min: 0, max: 0.5, step: 0.01 }), borderColor: V.Color($t.grey), offsetX: V.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetY: V.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetZ: V.Numeric(0, { min: 0, max: 10, step: 0.1 }), background: V.Boolean(!1), backgroundMargin: V.Numeric(0.2, { min: 0, max: 1, step: 0.01 }), backgroundColor: V.Color($t.grey), backgroundOpacity: V.Numeric(1, { min: 0, max: 1, step: 0.01 }), tether: V.Boolean(!1), tetherLength: V.Numeric(1, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: V.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), attachment: V.Select("middle-center", [["bottom-left", "bottom-left"], ["bottom-center", "bottom-center"], ["bottom-right", "bottom-right"], ["middle-left", "middle-left"], ["middle-center", "middle-center"], ["middle-right", "middle-right"], ["top-left", "top-left"], ["top-center", "top-center"], ["top-right", "top-right"]]) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(s, u, c, l, d) {
    var f = yt.createSimple(c, l, d), m = k(k({}, V.getDefaultValues(e.Params)), u);
    return i(s, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(s, u) {
    yt.updateValues(s, u), U.updateIfChanged(s.uSizeFactor, u.sizeFactor), U.updateIfChanged(s.uBorderWidth, u.borderWidth), Qe.fromNormalizedArray(s.uBorderColor.ref.value, 0) !== u.borderColor && (Qe.toArrayNormalized(u.borderColor, s.uBorderColor.ref.value, 0), U.update(s.uBorderColor, s.uBorderColor.ref.value)), U.updateIfChanged(s.uOffsetX, u.offsetX), U.updateIfChanged(s.uOffsetY, u.offsetY), U.updateIfChanged(s.uOffsetZ, u.offsetZ), Qe.fromNormalizedArray(s.uBackgroundColor.ref.value, 0) !== u.backgroundColor && (Qe.toArrayNormalized(u.backgroundColor, s.uBackgroundColor.ref.value, 0), U.update(s.uBackgroundColor, s.uBackgroundColor.ref.value)), U.updateIfChanged(s.uBackgroundOpacity, u.backgroundOpacity);
  }, updateBoundingSphere: function(s, u) {
    var c = tE(s.aMapping.ref.value, s.aDepth.ref.value, u.charCount, fh(s)), l = Ve.expand(Ve(), u.boundingSphere, c), d = ja(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    Ve.equals(d, s.boundingSphere.ref.value) || U.update(s.boundingSphere, d), Ve.equals(l, s.invariantBoundingSphere.ref.value) || (U.update(s.invariantBoundingSphere, l), U.update(s.uInvariantBoundingSphere, jt.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), U.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = yt.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: a };
})(vs || (vs = {}));
var hi, Ur, Hu = D(), Ku = D(), vf = D(), rE = Ye.add, mg = Ye.add3;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var a = Ye.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t), i = Ye.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : t), o = Ye.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : t), s = function(c, l, d, f, m, h, p) {
      for (var g = 0; g < 4; ++g) mg(i, c, l, d), mg(o, f, m, h), rE(a, p);
    }, u = function(c, l, d, f) {
      var m = D.distance(c, l), h = Math.floor(d / 2), p = 1 / d;
      D.sub(vf, l, c);
      for (var g = 0; g < h; ++g) {
        var v = p * (2 * g + 1);
        D.setMagnitude(vf, vf, m * v), D.add(Hu, c, vf), D.setMagnitude(vf, vf, m * p * (2 * (g + 1))), D.add(Ku, c, vf), s(Hu[0], Hu[1], Hu[2], Ku[0], Ku[1], Ku[2], f);
      }
    };
    return { add: s, addVec: function(c, l, d) {
      for (var f = 0; f < 4; ++f) mg(i, c[0], c[1], c[2]), mg(o, l[0], l[1], l[2]), rE(a, d);
    }, addFixedCountDashes: u, addFixedLengthDashes: function(c, l, d, f) {
      var m = D.distance(c, l);
      u(c, l, m / d, f);
    }, addCage: function(c, l, d) {
      for (var f = l.vertices, m = l.edges, h = 0, p = m.length; h < p; h += 2) D.fromArray(Hu, f, 3 * m[h]), D.fromArray(Ku, f, 3 * m[h + 1]), D.transformMat4(Hu, Hu, c), D.transformMat4(Ku, Ku, c), s(Hu[0], Hu[1], Hu[2], Ku[0], Ku[1], Ku[2], d);
    }, getLines: function() {
      var c = a.elementCount / 4, l = Ye.compact(a, !0), d = Ye.compact(i, !0), f = Ye.compact(o, !0), m = n && c <= n.lineCount ? n.mappingBuffer.ref.value : new Float32Array(8 * c), h = n && c <= n.lineCount ? n.indexBuffer.ref.value : new Uint32Array(6 * c);
      return (!n || c > n.lineCount) && function(p, g, v) {
        for (var y = 0; y < p; ++y) {
          var _ = 8 * y;
          g[_] = -1, g[_ + 1] = -1, g[_ + 2] = 1, g[_ + 3] = -1, g[_ + 4] = -1, g[_ + 5] = 1, g[_ + 6] = 1, g[_ + 7] = 1;
        }
        for (y = 0; y < p; ++y) {
          var S = 4 * y, b = 6 * y;
          v[b] = S, v[b + 1] = S + 1, v[b + 2] = S + 2, v[b + 3] = S + 1, v[b + 4] = S + 3, v[b + 5] = S + 2;
        }
      }(c, m, h), Ur.create(m, h, l, d, f, c, n);
    } };
  };
})(hi || (hi = {})), function(e) {
  function t(o, s, u, c, l, d, f) {
    return f ? function(m, h, p, g, v, y, _) {
      return y > _.lineCount && (U.update(_.mappingBuffer, m), U.update(_.indexBuffer, h)), _.lineCount = y, U.update(_.groupBuffer, p), U.update(_.startBuffer, g), U.update(_.endBuffer, v), _;
    }(o, s, u, c, l, d, f) : function(m, h, p, g, v, y) {
      var _, S = Ve(), b = -1, x = -1, A = { kind: "lines", lineCount: y, mappingBuffer: U.create(m), indexBuffer: U.create(h), groupBuffer: U.create(p), startBuffer: U.create(g), endBuffer: U.create(v), get boundingSphere() {
        var w = n(A);
        if (w !== b) {
          var C = Vd(A.startBuffer.ref.value, 4 * A.lineCount, 4), M = Vd(A.endBuffer.ref.value, 4 * A.lineCount, 4);
          Ve.expandBySphere(S, C, M), b = w;
        }
        return S;
      }, get groupMapping() {
        return A.groupBuffer.ref.version !== x && (_ = v1(A.groupBuffer.ref.value, A.lineCount, 4), x = A.groupBuffer.ref.version), _;
      }, setBoundingSphere: function(w) {
        Ve.copy(S, w), b = n(A);
      } };
      return A;
    }(o, s, u, c, l, d);
  }
  function r(o) {
    return t(o ? o.mappingBuffer.ref.value : new Float32Array(0), o ? o.indexBuffer.ref.value : new Uint32Array(0), o ? o.groupBuffer.ref.value : new Float32Array(0), o ? o.startBuffer.ref.value : new Float32Array(0), o ? o.endBuffer.ref.value : new Float32Array(0), 0, o);
  }
  function n(o) {
    return Zi([o.lineCount, o.mappingBuffer.ref.version, o.indexBuffer.ref.version, o.groupBuffer.ref.version, o.startBuffer.ref.version, o.endBuffer.ref.version]);
  }
  function a(o, s) {
    var u = 4 * o.lineCount, c = s.instanceCount.ref.value, l = am(), d = l.position, f = o.startBuffer.ref.value, m = o.endBuffer.ref.value, h = s.aTransform.ref.value;
    return ca(u, c, 2, function(p, g) {
      var v = p % 4 == 0 ? f : m;
      return g < 0 ? D.fromArray(d, v, 3 * p) : D.transformMat4Offset(d, v, h, 0, 3 * p, 16 * g), l;
    });
  }
  function i(o, s, u, c, l) {
    var d = u.instanceCount, f = u.groupCount, m = hs(u, a(o, s), c.color), h = xl(u, c.size), p = ru(d * f), g = rl(), v = nl(), y = il(), _ = al(), S = { drawCount: 2 * o.lineCount * 3, vertexCount: 4 * o.lineCount, groupCount: f, instanceCount: d }, b = Ve.clone(o.boundingSphere), x = ja(b, s.aTransform.ref.value, d);
    return k(k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("lines"), aMapping: o.mappingBuffer, aGroup: o.groupBuffer, aStart: o.startBuffer, aEnd: o.endBuffer, elements: o.indexBuffer, boundingSphere: U.create(x), invariantBoundingSphere: U.create(b), uInvariantBoundingSphere: U.create(jt.ofSphere(b)) }, m), h), p), g), v), y), _), s), yt.createValues(l, S)), { uSizeFactor: U.create(l.sizeFactor), dLineSizeAttenuation: U.create(l.lineSizeAttenuation), uDoubleSided: U.create(!0), dFlipSided: U.create(!1) });
  }
  e.create = t, e.createEmpty = r, e.fromMesh = function(o, s) {
    for (var u = o.vertexBuffer.ref.value, c = o.indexBuffer.ref.value, l = o.groupBuffer.ref.value, d = hi.create(3 * o.triangleCount, o.triangleCount / 10, s), f = 0, m = 3 * o.triangleCount; f < m; f += 3) {
      var h = c[f], p = c[f + 1], g = c[f + 2], v = u[3 * h], y = u[3 * h + 1], _ = u[3 * h + 2], S = u[3 * p], b = u[3 * p + 1], x = u[3 * p + 2], A = u[3 * g], w = u[3 * g + 1], C = u[3 * g + 2];
      d.add(v, y, _, S, b, x, l[h]), d.add(v, y, _, A, w, C, l[h]), d.add(S, b, x, A, w, C, l[p]);
    }
    return d.getLines();
  }, e.transform = function(o, s) {
    var u = o.startBuffer.ref.value;
    Vp(s, u, 0, 4 * o.lineCount), U.update(o.startBuffer, u);
    var c = o.endBuffer.ref.value;
    Vp(s, c, 0, 4 * o.lineCount), U.update(o.endBuffer, c);
  }, e.Params = k(k({}, yt.Params), { sizeFactor: V.Numeric(2, { min: 0, max: 10, step: 0.1 }), lineSizeAttenuation: V.Boolean(!1) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(o, s, u, c, l) {
    var d = yt.createSimple(u, c, l), f = k(k({}, V.getDefaultValues(e.Params)), s);
    return i(o, d.transform, d.locationIterator, d.theme, f);
  }, updateValues: function(o, s) {
    yt.updateValues(o, s), U.updateIfChanged(o.uSizeFactor, s.sizeFactor), U.updateIfChanged(o.dLineSizeAttenuation, s.lineSizeAttenuation);
  }, updateBoundingSphere: function(o, s) {
    var u = Ve.clone(s.boundingSphere), c = ja(u, o.aTransform.ref.value, o.instanceCount.ref.value);
    Ve.equals(c, o.boundingSphere.ref.value) || U.update(o.boundingSphere, c), Ve.equals(u, o.invariantBoundingSphere.ref.value) || (U.update(o.invariantBoundingSphere, u), U.update(o.uInvariantBoundingSphere, jt.fromSphere(o.uInvariantBoundingSphere.ref.value, u)));
  }, createRenderableState: yt.createRenderableState, updateRenderableState: yt.updateRenderableState, createPositionIterator: a };
}(Ur || (Ur = {}));
var nE = D(), aE = D(), iE = D();
function MR(e, t) {
  for (var r = t.length, n = kh(r / 3), a = 0; a < r; a += 3) D.fromArray(nE, e, 3 * t[a]), D.fromArray(aE, e, 3 * t[a + 1]), D.fromArray(iE, e, 3 * t[a + 2]), n.add(nE, aE, iE);
  return n.getPrimitive();
}
var pg = D();
function kh(e, t) {
  t === void 0 && (t = 3 * e);
  var r = new Float32Array(3 * t), n = new Float32Array(3 * t), a = new Uint32Array(3 * e), i = 0, o = 0;
  return { add: function(s, u, c) {
    D.toArray(s, r, i), D.toArray(u, r, i + 3), D.toArray(c, r, i + 6), D.triangleNormal(pg, s, u, c);
    for (var l = 0; l < 3; ++l) D.toArray(pg, n, i + 3 * l), a[o + l] = i / 3 + l;
    i += 9, o += 3;
  }, addQuad: function(s, u, c, l) {
    D.toArray(s, r, i), D.toArray(u, r, i + 3), D.toArray(c, r, i + 6), D.toArray(l, r, i + 9), D.triangleNormal(pg, s, u, c);
    for (var d = 0; d < 4; ++d) D.toArray(pg, n, i + 3 * d);
    var f = i / 3;
    a[o] = f, a[o + 1] = f + 1, a[o + 2] = f + 2, a[o + 3] = f + 2, a[o + 4] = f + 3, a[o + 5] = f, i += 12, o += 6;
  }, getPrimitive: function() {
    return { vertices: r, normals: n, indices: a };
  } };
}
var qm = D(), ine = ka();
function p3(e, t) {
  for (var r = e.vertices, n = e.normals, a = ka.directionTransform(ine, t), i = 0, o = r.length; i < o; i += 3) D.transformMat4(qm, D.fromArray(qm, r, i), t), D.toArray(qm, r, i), D.transformMat3(qm, D.fromArray(qm, n, i), a), D.toArray(qm, n, i);
  return e;
}
function h3(e, t, r) {
  r === void 0 && (r = -1);
  for (var n = new Float32Array(3 * e), a = r === -1 ? e <= 4 ? Math.sqrt(2) / 2 : 0.6 : r, i = t ? 1 : 0, o = 0, s = e; o < s; ++o) {
    var u = (2 * o + i) / e * Math.PI;
    n[3 * o] = Math.cos(u) * a, n[3 * o + 1] = Math.sin(u) * a, n[3 * o + 2] = 0;
  }
  return n;
}
function v3(e) {
  return { vertices: new Float32Array(e.vertices), edges: new Uint32Array(e.edges) };
}
var ix = D.zero();
function g3(e, t) {
  for (var r = e.vertices, n = 0, a = r.length; n < a; n += 3) D.transformMat4(ix, D.fromArray(ix, r, n), t), D.toArray(ix, r, n);
  return e;
}
var ox, sx, Oo, ux, cx, dr, Hm = D(), Km = D(), Xm = D(), jm = D(), $n = h3(4, !0);
function IR() {
  return ox || (ox = function(e) {
    for (var t = kh(12, 24), r = 0; r < 4; ++r) {
      var n = (r + 1) % 4;
      D.set(Hm, $n[3 * r], $n[3 * r + 1], -0.5), D.set(Km, $n[3 * n], $n[3 * n + 1], -0.5), D.set(Xm, $n[3 * n], $n[3 * n + 1], 0.5), D.set(jm, $n[3 * r], $n[3 * r + 1], 0.5), t.addQuad(Hm, Km, Xm, jm);
    }
    return D.set(Hm, $n[0], $n[1], -0.5), D.set(Km, $n[3], $n[4], -0.5), D.set(Xm, $n[6], $n[7], -0.5), D.set(jm, $n[9], $n[10], -0.5), t.addQuad(jm, Xm, Km, Hm), D.set(Hm, $n[0], $n[1], 0.5), D.set(Km, $n[3], $n[4], 0.5), D.set(Xm, $n[6], $n[7], 0.5), D.set(jm, $n[9], $n[10], 0.5), t.addQuad(Hm, Km, Xm, jm), t.getPrimitive();
  }()), ox;
}
function TR() {
  return sx || (sx = /* @__PURE__ */ function(e, t) {
    return { vertices: e, edges: t };
  }([0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5], [0, 4, 1, 5, 2, 6, 3, 7, 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4])), sx;
}
function oE(e) {
  return e.map(function(t) {
    return { x: t[0], alpha: t[1] };
  });
}
function sE(e, t) {
  for (var r, n, a, i, o, s, u = nt(nt([{ x: 0, alpha: 0 }, { x: 0, alpha: 0 }], e, !0), [{ x: 1, alpha: 0 }, { x: 1, alpha: 0 }], !1), c = t ? t.ref.value.array : new Uint8Array(256), l = 0, d = e.length + 1, f = 0; f < d; ++f) {
    r = u[f + 1].x, n = u[f + 2].x, a = u[f].alpha, i = u[f + 1].alpha, o = u[f + 2].alpha, s = u[f + 3].alpha;
    for (var m = Math.round(256 * (n - r)), h = 0; h < m; ++h) {
      var p = h / m;
      c[l] = Math.max(0, 255 * S2(a, i, o, s, p, 0.5)), ++l;
    }
  }
  var g = { array: c, width: 256, height: 1 };
  return t ? (U.update(t, g), t) : U.create(g);
}
function uE(e, t, r, n) {
  var a = (n - r) / t;
  a === 0 && (a = 1);
  for (var i = new Int32Array(t), o = 0, s = e.length; o < s; o++) {
    var u = Math.floor((e[o] - r) / a);
    u >= t ? u = t - 1 : u < 0 && (u = 0), i[u]++;
  }
  return { min: r, max: n, binWidth: a, counts: i };
}
(function(e) {
  e.One = { transform: { kind: "matrix", matrix: Ee.identity() }, cells: Wn.create(Wn.Space([1, 1, 1], [0, 1, 2]), Wn.Data1([0])), stats: { min: 0, max: 0, mean: 0, sigma: 0 } };
  var t = Ee.zero(), r = Ee.zero();
  e.getGridToCartesianTransform = function(n) {
    if (n.transform.kind === "matrix") return Ee.copy(Ee(), n.transform.matrix);
    if (n.transform.kind === "spacegroup") {
      var a = n.cells.space, i = Ee.fromScaling(t, D.div(D.zero(), on.size(D.zero(), n.transform.fractionalBox), D.ofArray(a.dimensions))), o = Ee.fromTranslation(r, n.transform.fractionalBox.min);
      return Ee.mul3(Ee.zero(), n.transform.cell.fromFractional, o, i);
    }
    return Ee.identity();
  }, e.areEquivalent = function(n, a) {
    return n === a;
  }, e.isEmpty = function(n) {
    return n.cells.data.length === 0;
  }, e.getBoundingSphere = function(n, a) {
    a || (a = Ve());
    var i = n.cells.space.dimensions, o = e.getGridToCartesianTransform(n);
    return Ve.fromDimensionsAndTransform(a, i, o);
  }, e.getHistogram = function(n, a) {
    var i = n._historams;
    return i || (i = n._historams = {}), i[a] || (i[a] = function(o, s, u) {
      if (u) return uE(o, s, u.min, u.max);
      var c = as(o);
      return uE(o, s, c[0], c[1]);
    }(n.cells.data, a, { min: n.stats.min, max: n.stats.max })), i[a];
  };
})(Oo || (Oo = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "cube";
  }, e.create = function(t) {
    return { kind: "cube", name: t.name, data: t };
  };
}(ux || (ux = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "dscif";
  }, e.create = function(t) {
    return { kind: "dscif", name: t._name, data: t };
  };
}(cx || (cx = {})), function(e) {
  var t;
  e.is = function(i) {
    var o, s, u, c;
    return ((c = (u = (s = (o = i == null ? void 0 : i.grid) === null || o === void 0 ? void 0 : o.cells) === null || s === void 0 ? void 0 : s.space) === null || u === void 0 ? void 0 : u.dimensions) === null || c === void 0 ? void 0 : c.length) && (i == null ? void 0 : i.sourceData) && (i == null ? void 0 : i.customProperties) && (i == null ? void 0 : i._propertyData);
  }, function(i) {
    function o(s, u) {
      return s.kind === "absolute" ? s : { kind: "absolute", absoluteValue: i.calcAbsolute(u, s.relativeValue) };
    }
    i.areSame = function(s, u, c) {
      return Yn(o(s, c).absoluteValue, o(u, c).absoluteValue, c.sigma / 100);
    }, i.absolute = function(s) {
      return { kind: "absolute", absoluteValue: s };
    }, i.relative = function(s) {
      return { kind: "relative", relativeValue: s };
    }, i.calcAbsolute = function(s, u) {
      return u * s.sigma + s.mean;
    }, i.calcRelative = function(s, u) {
      return s.sigma === 0 ? 0 : (u - s.mean) / s.sigma;
    }, i.toAbsolute = o, i.toRelative = function(s, u) {
      return s.kind === "relative" ? s : { kind: "relative", relativeValue: i.calcRelative(u, s.absoluteValue) };
    }, i.toString = function(s) {
      return s.kind === "relative" ? "".concat(s.relativeValue.toFixed(2), " σ") : "".concat(s.absoluteValue.toPrecision(4));
    };
  }(t = e.IsoValue || (e.IsoValue = {})), e.adjustedIsoValue = function(i, o, s) {
    if (s === "relative") return t.relative(o);
    var u = t.absolute(o);
    if (cx.is(i.sourceData)) {
      var c = { min: i.sourceData.data.volume_data_3d_info.min_source.value(0), max: i.sourceData.data.volume_data_3d_info.max_source.value(0), mean: i.sourceData.data.volume_data_3d_info.mean_source.value(0), sigma: i.sourceData.data.volume_data_3d_info.sigma_source.value(0) };
      return e.IsoValue.toRelative(u, c);
    }
    return u;
  };
  var r, n = { min: -1, max: 1, mean: 0, sigma: 0.1 };
  function a(i, o) {
    var s = o || n, u = s.min, c = s.max, l = s.mean, d = s.sigma, f = (u - l) / d, m = (c - l) / d, h = i;
    return i.kind === "absolute" ? i.absoluteValue < u ? h = e.IsoValue.absolute(u) : i.absoluteValue > c && (h = e.IsoValue.absolute(c)) : i.relativeValue < f ? h = e.IsoValue.relative(f) : i.relativeValue > m && (h = e.IsoValue.relative(m)), V.Conditioned(h, { absolute: V.Converted(function(p) {
      return e.IsoValue.toAbsolute(p, Oo.One.stats).absoluteValue;
    }, function(p) {
      return e.IsoValue.absolute(p);
    }, V.Numeric(l, { min: u, max: c, step: B9(d / 100, 2) })), relative: V.Converted(function(p) {
      return e.IsoValue.toRelative(p, Oo.One.stats).relativeValue;
    }, function(p) {
      return e.IsoValue.relative(p);
    }, V.Numeric(Math.min(1, m), { min: f, max: m, step: B9(Math.round((c - u) / d) / 100, 2) })) }, function(p) {
      return p.kind === "absolute" ? "absolute" : "relative";
    }, function(p, g) {
      return g === "absolute" ? e.IsoValue.toAbsolute(p, s) : e.IsoValue.toRelative(p, s);
    }, { isEssential: !0 });
  }
  e.createIsoValueParam = a, e.IsoValueParam = a(e.IsoValue.relative(2)), e.One = { label: "", grid: Oo.One, sourceData: { kind: "", name: "", data: {} }, customProperties: new f1(), _propertyData: /* @__PURE__ */ Object.create(null) }, e.areEquivalent = function(i, o) {
    return Oo.areEquivalent(i.grid, o.grid);
  }, e.isEmpty = function(i) {
    return Oo.isEmpty(i.grid);
  }, e.isOrbitals = function(i) {
    return !!ux.is(i.sourceData) && i.sourceData.data.header.orbitals;
  }, e.Loci = function(i) {
    return { kind: "volume-loci", volume: i };
  }, e.isLoci = function(i) {
    return !!i && i.kind === "volume-loci";
  }, e.areLociEqual = function(i, o) {
    return i.volume === o.volume;
  }, e.isLociEmpty = function(i) {
    return Oo.isEmpty(i.volume.grid);
  }, e.getBoundingSphere = function(i, o) {
    return Oo.getBoundingSphere(i.grid, o);
  }, (r = e.Isosurface || (e.Isosurface = {})).Loci = function(i, o) {
    return { kind: "isosurface-loci", volume: i, isoValue: o };
  }, r.isLoci = function(i) {
    return !!i && i.kind === "isosurface-loci";
  }, r.areLociEqual = function(i, o) {
    return i.volume === o.volume && e.IsoValue.areSame(i.isoValue, o.isoValue, i.volume.grid.stats);
  }, r.isLociEmpty = function(i) {
    return i.volume.grid.cells.data.length === 0;
  }, r.getBoundingSphere = function(i, o, s) {
    return e.getBoundingSphere(i, s);
  }, function(i) {
    i.Loci = function(u, c) {
      return { kind: "cell-loci", volume: u, indices: c };
    }, i.isLoci = function(u) {
      return !!u && u.kind === "cell-loci";
    }, i.areLociEqual = function(u, c) {
      return u.volume === c.volume && We.areEqual(u.indices, c.indices);
    }, i.isLociEmpty = function(u) {
      return We.size(u.indices) === 0;
    };
    var o = new iu("98"), s = D();
    i.getBoundingSphere = function(u, c, l) {
      o.reset();
      for (var d = Oo.getGridToCartesianTransform(u.grid), f = u.grid.cells.space.getCoords, m = 0, h = We.size(c); m < h; m++)
        f(We.getAt(c, m), s), D.transformMat4(s, s, d), o.includePosition(s);
      for (o.finishedIncludeStep(), m = 0, h = We.size(c); m < h; m++)
        f(We.getAt(c, m), s), D.transformMat4(s, s, d), o.radiusPosition(s);
      var p = o.getSphere(l);
      return Ve.expand(p, p, 10 * Ee.getMaxScaleOnAxis(d));
    };
  }(e.Cell || (e.Cell = {}));
}(dr || (dr = {}));
var ly, Nu, qd, lx = IR();
function rn(e, t, r) {
  return { type: "attribute", kind: e, itemSize: t, divisor: r };
}
function ze(e, t) {
  return { type: "uniform", kind: e, variant: t };
}
function Kt(e, t, r, n) {
  return { type: "texture", kind: e, format: t, dataType: r, filter: n };
}
function dm(e) {
  return { type: "elements", kind: e };
}
function Ht(e, t) {
  return { type: "define", kind: e, options: t };
}
function va(e) {
  return { type: "value", kind: e };
}
(function(e) {
  function t(u, c, l, d, f, m, h, p, g, v) {
    return v ? function(y, _, S, b, x, A, w, C, M, T) {
      var N = A.getWidth(), I = A.getHeight(), P = A.getDepth();
      return U.update(T.gridDimension, _), U.update(T.gridTexture, A), U.update(T.gridTextureDim, D.set(T.gridTextureDim.ref.value, N, I, P)), U.update(T.gridStats, jt.set(T.gridStats.ref.value, w.min, w.max, w.mean, w.sigma)), U.update(T.bboxMin, y.min), U.update(T.bboxMax, y.max), U.update(T.bboxSize, D.sub(T.bboxSize.ref.value, y.max, y.min)), U.update(T.transform, S), U.update(T.cellDim, x), U.update(T.unitToCartn, b), U.update(T.cartnToUnit, Ee.invert(Ee(), b)), U.updateIfChanged(T.packedGroup, C), U.updateIfChanged(T.axisOrder, D.fromArray(T.axisOrder.ref.value, M, 0)), T;
    }(u, c, l, d, f, m, h, p, g, v) : function(y, _, S, b, x, A, w, C, M) {
      var T = Ve(), N = -1, I = A.getWidth(), P = A.getHeight(), O = A.getDepth(), F = { kind: "direct-volume", gridDimension: U.create(_), gridTexture: U.create(A), gridTextureDim: U.create(D.create(I, P, O)), gridStats: U.create(jt.create(w.min, w.max, w.mean, w.sigma)), bboxMin: U.create(y.min), bboxMax: U.create(y.max), bboxSize: U.create(D.sub(D(), y.max, y.min)), transform: U.create(S), cellDim: U.create(x), unitToCartn: U.create(b), cartnToUnit: U.create(Ee.invert(Ee(), b)), get boundingSphere() {
        var R = r(F);
        if (R !== N) {
          var G = function(L, q) {
            return Ve.fromDimensionsAndTransform(Ve(), L, q);
          }(F.gridDimension.ref.value, F.transform.ref.value);
          Ve.copy(T, G), N = R;
        }
        return T;
      }, packedGroup: U.create(C), axisOrder: U.create(M), setBoundingSphere: function(R) {
        Ve.copy(T, R), N = r(F);
      } };
      return F;
    }(u, c, l, d, f, m, h, p, g);
  }
  function r(u) {
    return Zi([u.bboxSize.ref.version, u.gridDimension.ref.version, u.gridTexture.ref.version, u.transform.ref.version, u.gridStats.ref.version]);
  }
  function n(u) {
    return t(on(), D(), Ee.identity(), Ee.identity(), D(), ko(), Oo.One.stats, !1, D.create(0, 1, 2), u);
  }
  function a(u, c) {
    return Math.ceil(D.magnitude(u) * c);
  }
  function i(u, c) {
    return Math.min.apply(Math, u) * (1 / c);
  }
  function o(u) {
    return 1 / u;
  }
  function s(u, c, l, d, f) {
    var m = u.gridTexture, h = u.gridTextureDim, p = u.gridStats, g = u.bboxSize, v = u.bboxMin, y = u.bboxMax, _ = u.gridDimension, S = u.transform, b = l.instanceCount, x = l.groupCount, A = hs(l, e.Utils.createPositionIterator(u, c), d.color), w = ru(b * x), C = rl(), M = nl(), T = il(), N = al(), I = _.ref.value, P = I[0], O = I[1], F = I[2], R = { drawCount: lx.indices.length, vertexCount: P * O * F, groupCount: x, instanceCount: b }, G = Ve.clone(u.boundingSphere), L = ja(G, c.aTransform.ref.value, b), q = sE(oE(f.controlPoints));
    return k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("directVolume") }, A), w), C), M), T), N), c), yt.createValues(f, R)), { aPosition: U.create(lx.vertices), elements: U.create(lx.indices), boundingSphere: U.create(L), invariantBoundingSphere: U.create(G), uInvariantBoundingSphere: U.create(jt.ofSphere(G)), uBboxMin: v, uBboxMax: y, uBboxSize: g, uMaxSteps: U.create(a(_.ref.value, f.stepsPerCell)), uStepScale: U.create(i(u.cellDim.ref.value, f.stepsPerCell)), uJumpLength: U.create(f.jumpLength), uTransform: S, uGridDim: _, tTransferTex: q, uTransferScale: U.create(o(f.stepsPerCell)), dGridTexType: U.create(m.ref.value.getDepth() > 0 ? "3d" : "2d"), uGridTexDim: h, tGridTex: m, uGridStats: p, uCellDim: u.cellDim, uCartnToUnit: u.cartnToUnit, uUnitToCartn: u.unitToCartn, dPackedGroup: u.packedGroup, dAxisOrder: U.create(u.axisOrder.ref.value.join("")), dIgnoreLight: U.create(f.ignoreLight), dXrayShaded: U.create(f.xrayShaded) });
  }
  e.create = t, e.createEmpty = n, e.Params = k(k({}, yt.Params), { ignoreLight: V.Boolean(!1, yt.ShadingCategory), xrayShaded: V.Boolean(!1, yt.ShadingCategory), controlPoints: V.LineGraph([Ze.create(0.19, 0), Ze.create(0.2, 0.05), Ze.create(0.25, 0.05), Ze.create(0.26, 0), Ze.create(0.79, 0), Ze.create(0.8, 0.05), Ze.create(0.85, 0.05), Ze.create(0.86, 0)], { isEssential: !0 }), stepsPerCell: V.Numeric(3, { min: 1, max: 10, step: 1 }), jumpLength: V.Numeric(0, { min: 0, max: 20, step: 0.1 }) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: s, createValuesSimple: function(u, c, l, d, f) {
    var m = yt.createSimple(l, d, f), h = k(k({}, V.getDefaultValues(e.Params)), c);
    return s(u, m.transform, m.locationIterator, m.theme, h);
  }, updateValues: function(u, c) {
    yt.updateValues(u, c), U.updateIfChanged(u.dIgnoreLight, c.ignoreLight), U.updateIfChanged(u.dXrayShaded, c.xrayShaded), sE(oE(c.controlPoints), u.tTransferTex), U.updateIfChanged(u.uMaxSteps, a(u.uGridDim.ref.value, c.stepsPerCell)), U.updateIfChanged(u.uStepScale, i(u.uCellDim.ref.value, c.stepsPerCell)), U.updateIfChanged(u.uTransferScale, o(c.stepsPerCell)), U.updateIfChanged(u.uJumpLength, c.jumpLength);
  }, updateBoundingSphere: function(u, c) {
    var l = Ve.clone(c.boundingSphere), d = ja(l, u.aTransform.ref.value, u.instanceCount.ref.value);
    Ve.equals(d, u.boundingSphere.ref.value) || U.update(u.boundingSphere, d), Ve.equals(l, u.invariantBoundingSphere.ref.value) || (U.update(u.invariantBoundingSphere, l), U.update(u.uInvariantBoundingSphere, jt.fromSphere(u.uInvariantBoundingSphere.ref.value, l)));
  }, createRenderableState: function(u) {
    var c = yt.createRenderableState(u);
    return c.opaque = !1, c.writeDepth = !1, c;
  }, updateRenderableState: function(u, c) {
    yt.updateRenderableState(u, c), u.opaque = !1, u.writeDepth = !1;
  }, createPositionIterator: function(u, c) {
    var l = u.transform.ref.value, d = u.gridDimension.ref.value, f = d[0], m = d[1], h = d[2], p = f * m * h, g = c.instanceCount.ref.value, v = am(), y = v.position, _ = c.aTransform.ref.value;
    return ca(p, g, 1, function(S, b) {
      var x = Math.floor(S / h);
      return y[0] = Math.floor(x / m), y[1] = x % m, y[2] = S % h, D.transformMat4(y, y, l), b >= 0 && D.transformMat4Offset(y, y, _, 0, 0, 16 * b), v;
    });
  } };
})(ly || (ly = {})), function(e) {
  function t(s, u, c, l, d, f) {
    return f ? function(m, h, p, g, v, y) {
      return v > y.sphereCount && (U.update(y.mappingBuffer, h), U.update(y.indexBuffer, p)), y.sphereCount = v, U.update(y.centerBuffer, m), U.update(y.groupBuffer, g), y;
    }(s, u, c, l, d, f) : function(m, h, p, g, v) {
      var y, _ = Ve(), S = -1, b = -1, x = { kind: "spheres", sphereCount: v, centerBuffer: U.create(m), mappingBuffer: U.create(h), indexBuffer: U.create(p), groupBuffer: U.create(g), get boundingSphere() {
        var A = n(x);
        if (A !== S) {
          var w = Vd(x.centerBuffer.ref.value, 4 * x.sphereCount, 4);
          Ve.copy(_, w), S = A;
        }
        return _;
      }, get groupMapping() {
        return x.groupBuffer.ref.version !== b && (y = v1(x.groupBuffer.ref.value, x.sphereCount, 4), b = x.groupBuffer.ref.version), y;
      }, setBoundingSphere: function(A) {
        Ve.copy(_, A), S = n(x);
      } };
      return x;
    }(s, u, c, l, d);
  }
  function r(s) {
    return t(s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return Zi([s.sphereCount, s.centerBuffer.ref.version, s.mappingBuffer.ref.version, s.indexBuffer.ref.version, s.groupBuffer.ref.version]);
  }
  function a(s, u) {
    var c = 4 * s.sphereCount, l = u.instanceCount.ref.value, d = am(), f = d.position, m = s.centerBuffer.ref.value, h = u.aTransform.ref.value;
    return ca(c, l, 4, function(p, g) {
      return g < 0 ? D.fromArray(f, m, 3 * p) : D.transformMat4Offset(f, m, h, 0, 3 * p, 16 * g), d;
    });
  }
  function i(s, u, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, h = hs(c, a(s, u), l.color), p = xl(c, l.size), g = ru(f * m), v = rl(), y = nl(), _ = il(), S = al(), b = { drawCount: 2 * s.sphereCount * 3, vertexCount: 4 * s.sphereCount, groupCount: m, instanceCount: f }, x = s.boundingSphere.radius ? fh(p) * d.sizeFactor : 0, A = Ve.expand(Ve(), s.boundingSphere, x), w = ja(A, u.aTransform.ref.value, f);
    return k(k(k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("spheres"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: U.create(w), invariantBoundingSphere: U.create(A), uInvariantBoundingSphere: U.create(jt.ofSphere(A)) }, h), p), g), v), y), _), S), u), { padding: U.create(x) }), yt.createValues(d, b)), { uSizeFactor: U.create(d.sizeFactor), uDoubleSided: U.create(d.doubleSided), dIgnoreLight: U.create(d.ignoreLight), dXrayShaded: U.create(d.xrayShaded), uBumpFrequency: U.create(d.bumpFrequency), uBumpAmplitude: U.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    yt.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = r, e.Params = k(k({}, yt.Params), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), doubleSided: V.Boolean(!1, yt.CustomQualityParamInfo), ignoreLight: V.Boolean(!1, yt.ShadingCategory), xrayShaded: V.Boolean(!1, yt.ShadingCategory), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), bumpAmplitude: V.Numeric(1, { min: 0, max: 5, step: 0.1 }, yt.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(s, u, c, l, d) {
    var f = yt.createSimple(c, l, d), m = k(k({}, V.getDefaultValues(e.Params)), u);
    return i(s, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(s, u) {
    yt.updateValues(s, u), U.updateIfChanged(s.uSizeFactor, u.sizeFactor), U.updateIfChanged(s.uDoubleSided, u.doubleSided), U.updateIfChanged(s.dIgnoreLight, u.ignoreLight), U.updateIfChanged(s.dXrayShaded, u.xrayShaded), U.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), U.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = u.boundingSphere.radius ? fh(s) * s.uSizeFactor.ref.value : 0, l = Ve.expand(Ve(), u.boundingSphere, c), d = ja(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    Ve.equals(d, s.boundingSphere.ref.value) || U.update(s.boundingSphere, d), Ve.equals(l, s.invariantBoundingSphere.ref.value) || (U.update(s.invariantBoundingSphere, l), U.update(s.uInvariantBoundingSphere, jt.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), U.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = yt.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: a };
}(Nu || (Nu = {})), function(e) {
  var t = function() {
    function i() {
      this.index = 0, this.textures = [];
    }
    return i.prototype.get = function() {
      return this.textures[this.index];
    }, i.prototype.set = function(o, s, u) {
      this.textures[this.index] = Object.assign(this.textures[this.index] || {}, { vertex: o, group: s, normal: u }), this.index = (this.index + 1) % 2;
    }, i.prototype.destroy = function() {
      for (var o = 0, s = this.textures; o < s.length; o++) {
        var u = s[o];
        u.vertex.destroy(), u.group.destroy(), u.normal.destroy();
      }
    }, i;
  }();
  function r(i, o, s, u, c, l, d) {
    var f = s.getWidth(), m = s.getHeight();
    return d ? (d.vertexCount = i, d.groupCount = o, U.update(d.geoTextureDim, Ze.set(d.geoTextureDim.ref.value, f, m)), U.update(d.vertexTexture, s), U.update(d.groupTexture, u), U.update(d.normalTexture, c), d.doubleBuffer.set(s, u, c), Ve.copy(d.boundingSphere, l), d) : { kind: "texture-mesh", vertexCount: i, groupCount: o, geoTextureDim: U.create(Ze.create(f, m)), vertexTexture: U.create(s), groupTexture: U.create(u), normalTexture: U.create(c), doubleBuffer: new t(), boundingSphere: Ve.clone(l), meta: {} };
  }
  function n(i) {
    return r(0, 0, i ? i.vertexTexture.ref.value : ko(), i ? i.groupTexture.ref.value : ko(), i ? i.normalTexture.ref.value : ko(), i ? i.boundingSphere : Ve(), i);
  }
  function a(i, o, s, u, c) {
    var l = s.instanceCount, d = s.groupCount, f = hs(s, e.Utils.createPositionIterator(i, o), u.color), m = ru(l * d), h = rl(), p = nl(), g = il(), v = al(), y = { drawCount: i.vertexCount, vertexCount: i.vertexCount, groupCount: d, instanceCount: l }, _ = Ve.clone(i.boundingSphere), S = ja(_, o.aTransform.ref.value, l);
    return k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("textureMesh"), uGeoTexDim: i.geoTextureDim, tPosition: i.vertexTexture, tGroup: i.groupTexture, tNormal: i.normalTexture, boundingSphere: U.create(S), invariantBoundingSphere: U.create(_), uInvariantBoundingSphere: U.create(jt.ofSphere(_)) }, f), m), h), p), g), v), o), yt.createValues(c, y)), { uDoubleSided: U.create(c.doubleSided), dFlatShaded: U.create(c.flatShaded), dFlipSided: U.create(c.flipSided), dIgnoreLight: U.create(c.ignoreLight), dXrayShaded: U.create(c.xrayShaded), uBumpFrequency: U.create(c.bumpFrequency), uBumpAmplitude: U.create(c.bumpAmplitude), meta: U.create(i.meta) });
  }
  e.DoubleBuffer = t, e.create = r, e.createEmpty = n, e.Params = k(k({}, yt.Params), { doubleSided: V.Boolean(!1, yt.CustomQualityParamInfo), flipSided: V.Boolean(!1, yt.ShadingCategory), flatShaded: V.Boolean(!1, yt.ShadingCategory), ignoreLight: V.Boolean(!1, yt.ShadingCategory), xrayShaded: V.Boolean(!1, yt.ShadingCategory), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), bumpAmplitude: V.Numeric(1, { min: 0, max: 5, step: 0.1 }, yt.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: a, createValuesSimple: function(i, o, s, u, c) {
    var l = yt.createSimple(s, u, c), d = k(k({}, V.getDefaultValues(e.Params)), o);
    return a(i, l.transform, l.locationIterator, l.theme, d);
  }, updateValues: function(i, o) {
    yt.updateValues(i, o), U.updateIfChanged(i.uDoubleSided, o.doubleSided), U.updateIfChanged(i.dFlatShaded, o.flatShaded), U.updateIfChanged(i.dFlipSided, o.flipSided), U.updateIfChanged(i.dIgnoreLight, o.ignoreLight), U.updateIfChanged(i.dXrayShaded, o.xrayShaded), U.updateIfChanged(i.uBumpFrequency, o.bumpFrequency), U.updateIfChanged(i.uBumpAmplitude, o.bumpAmplitude);
  }, updateBoundingSphere: function(i, o) {
    var s = Ve.clone(o.boundingSphere), u = ja(s, i.aTransform.ref.value, i.instanceCount.ref.value);
    Ve.equals(u, i.boundingSphere.ref.value) || U.update(i.boundingSphere, u), Ve.equals(s, i.invariantBoundingSphere.ref.value) || (U.update(i.invariantBoundingSphere, s), U.update(i.uInvariantBoundingSphere, jt.fromSphere(i.uInvariantBoundingSphere.ref.value, s)));
  }, createRenderableState: yt.createRenderableState, updateRenderableState: yt.updateRenderableState, createPositionIterator: function() {
    return ca(1, 1, 1, function() {
      return dc;
    });
  } };
}(qd || (qd = {}));
var Pc = { uModel: ze("m4"), uView: ze("m4"), uInvView: ze("m4"), uModelView: ze("m4"), uInvModelView: ze("m4"), uProjection: ze("m4"), uInvProjection: ze("m4"), uModelViewProjection: ze("m4"), uInvModelViewProjection: ze("m4"), uIsOrtho: ze("f"), uPixelRatio: ze("f"), uViewport: ze("v4"), uViewOffset: ze("v2"), uDrawingBufferSize: ze("v2"), uCameraPosition: ze("v3"), uCameraDir: ze("v3"), uNear: ze("f"), uFar: ze("f"), uFogNear: ze("f"), uFogFar: ze("f"), uFogColor: ze("v3"), uTransparentBackground: ze("b"), uLightDirection: ze("v3[]"), uLightColor: ze("v3[]"), uAmbientColor: ze("v3"), uPickingAlphaThreshold: ze("f"), uInteriorDarkening: ze("f"), uInteriorColorFlag: ze("b"), uInteriorColor: ze("v3"), uHighlightColor: ze("v3"), uSelectColor: ze("v3"), uHighlightStrength: ze("f"), uSelectStrength: ze("f"), uMarkerPriority: ze("i"), uXrayEdgeFalloff: ze("f"), uRenderWboit: ze("b"), uMarkingDepthTest: ze("b"), uMarkingType: ze("i"), uPickType: ze("i"), uInvalidColor: ze("v3"), uInvalidStrength: ze("f") }, Bc = { tDepth: Kt("texture", "depth", "ushort", "nearest") }, Oc = { uObjectId: ze("i") }, one = { uColor: ze("v3", "material"), uColorTexDim: ze("v2"), uColorGridDim: ze("v3"), uColorGridTransform: ze("v4"), tColor: Kt("image-uint8", "rgb", "ubyte", "nearest"), tPalette: Kt("image-uint8", "rgb", "ubyte", "nearest"), tColorGrid: Kt("texture", "rgb", "ubyte", "linear"), dColorType: Ht("string", ["uniform", "attribute", "instance", "group", "groupInstance", "vertex", "vertexInstance", "volume", "volumeInstance", "direct"]), dUsePalette: Ht("boolean") }, zh = { uSize: ze("f", "material"), uSizeTexDim: ze("v2"), tSize: Kt("image-uint8", "rgb", "ubyte", "nearest"), dSizeType: Ht("string", ["uniform", "attribute", "instance", "group", "groupInstance"]), uSizeFactor: ze("f") }, sne = { uMarker: ze("f"), uMarkerTexDim: ze("v2"), tMarker: Kt("image-uint8", "alpha", "ubyte", "nearest"), markerAverage: va("number"), markerStatus: va("number") }, une = { uOverpaintTexDim: ze("v2"), tOverpaint: Kt("image-uint8", "rgba", "ubyte", "nearest"), dOverpaint: Ht("boolean"), uOverpaintGridDim: ze("v3"), uOverpaintGridTransform: ze("v4"), tOverpaintGrid: Kt("texture", "rgba", "ubyte", "linear"), dOverpaintType: Ht("string", ["groupInstance", "volumeInstance"]) }, cne = { uTransparencyTexDim: ze("v2"), tTransparency: Kt("image-uint8", "alpha", "ubyte", "nearest"), dTransparency: Ht("boolean"), transparencyAverage: va("number"), uTransparencyGridDim: ze("v3"), uTransparencyGridTransform: ze("v4"), tTransparencyGrid: Kt("texture", "alpha", "ubyte", "linear"), dTransparencyType: Ht("string", ["groupInstance", "volumeInstance"]) }, lne = { uSubstanceTexDim: ze("v2"), tSubstance: Kt("image-uint8", "rgba", "ubyte", "nearest"), dSubstance: Ht("boolean"), uSubstanceGridDim: ze("v3"), uSubstanceGridTransform: ze("v4"), tSubstanceGrid: Kt("texture", "rgba", "ubyte", "linear"), dSubstanceType: Ht("string", ["groupInstance", "volumeInstance"]) }, dne = { uClippingTexDim: ze("v2"), tClipping: Kt("image-uint8", "alpha", "ubyte", "nearest"), dClipping: Ht("boolean") }, _l = k(k(k(k(k(k(k({ dGeometryType: Ht("string", ["cylinders", "directVolume", "image", "lines", "mesh", "points", "spheres", "text", "textureMesh"]) }, one), sne), une), cne), lne), dne), { dLightCount: Ht("number"), dClipObjectCount: Ht("number"), dClipVariant: Ht("string", ["instance", "pixel"]), uClipObjectType: ze("i[]"), uClipObjectInvert: ze("b[]"), uClipObjectPosition: ze("v3[]"), uClipObjectRotation: ze("v4[]"), uClipObjectScale: ze("v3[]"), aInstance: rn("float32", 1, 1), aTransform: rn("float32", 16, 1), uAlpha: ze("f", "material"), uMetalness: ze("f", "material"), uRoughness: ze("f", "material"), uBumpiness: ze("f", "material"), uVertexCount: ze("i"), uInstanceCount: ze("i"), uGroupCount: ze("i"), uInvariantBoundingSphere: ze("v4"), drawCount: va("number"), instanceCount: va("number"), alpha: va("number"), matrix: va("m4"), transform: va("float32"), extraTransform: va("float32"), hasReflection: va("boolean"), boundingSphere: va("sphere"), invariantBoundingSphere: va("sphere") }), Yi = `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

void main(void) {
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, fne = $i(), B8 = Object.keys({ colorBlended: "", colorWboit: "", pick: "", depth: "", marking: "" }), y3 = B8.filter(function(e) {
  return e !== "colorWboit";
}), mne = B8.filter(function(e) {
  return e !== "colorBlended";
}), pne = Object.keys({ compute: "" });
function cE(e, t, r, n, a) {
  return r = k(k({}, r), { dRenderVariant: U.create(t) }), a.dRenderVariant === void 0 && Object.defineProperty(a, "dRenderVariant", { value: Ht("string") }), e.resources.program(r, n, a);
}
function Fc(e, t, r, n, a, i, o) {
  return NR(e, t, r, n, a, i, o);
}
function Ua(e, t, r, n, a, i) {
  return i === void 0 && (i = -1), NR(e, t, r, n, a, i, pne);
}
function NR(e, t, r, n, a, i, o) {
  var s = fne(), u = e.stats, c = e.state, l = e.resources, d = e.extensions, f = d.instancedArrays, m = d.vertexArrayObject;
  if (a.uVertexCount) {
    var h = a.uVertexCount.ref.value;
    a.aVertex = U.create(lc(new Float32Array(h))), n.aVertex = rn("float32", 1, 0);
  }
  for (var p = function(ie, oe) {
    var se = {}, he = {}, ge = {}, De = {}, ae = {}, ce = {};
    return Object.keys(ie).forEach(function(_e) {
      var le = ie[_e];
      le.type === "attribute" && (se[_e] = oe[_e]), le.type === "define" && (he[_e] = oe[_e]), le.type === "texture" && oe[_e] !== void 0 && (ge[_e] = oe[_e]), le.type === "uniform" && oe[_e] !== void 0 && (le.variant === "material" ? ae[_e] = oe[_e] : le.variant === "buffered" ? ce[_e] = oe[_e] : De[_e] = oe[_e]);
    }), { attributeValues: se, defineValues: he, textureValues: ge, uniformValues: De, materialUniformValues: ae, bufferedUniformValues: ce };
  }(n, a), g = p.attributeValues, v = p.defineValues, y = p.textureValues, _ = p.uniformValues, S = p.materialUniformValues, b = p.bufferedUniformValues, x = Object.entries(_), A = Object.entries(S), w = Object.entries(b), C = Object.entries(function(ie) {
    var oe = {};
    return Object.keys(ie).forEach(function(se) {
      oe[se] = U.create(ll(ie[se].ref.value));
    }), oe;
  }(b)), M = Object.entries(v), T = function(ie) {
    var oe = {};
    return Object.keys(ie).forEach(function(se) {
      oe[se] = ie[se].ref.version;
    }), oe;
  }(a), N = function(ie, oe) {
    var se = ie.gl;
    switch (oe) {
      case "points":
        return se.POINTS;
      case "lines":
        return se.LINES;
      case "line-strip":
        return se.LINE_STRIP;
      case "line-loop":
        return se.LINE_LOOP;
      case "triangles":
        return se.TRIANGLES;
      case "triangle-strip":
        return se.TRIANGLE_STRIP;
      case "triangle-fan":
        return se.TRIANGLE_FAN;
    }
  }(e, t), I = {}, P = 0, O = o; P < O.length; P++) {
    var F = O[P];
    I[F] = cE(e, F, v, r, n);
  }
  var R, G = function(ie, oe, se) {
    var he = ie.resources, ge = [];
    return Object.keys(oe).forEach(function(De) {
      var ae = oe[De];
      if (ae.type === "texture") {
        var ce = se[De];
        if (ce) if (ae.kind === "texture") ge[ge.length] = [De, ce.ref.value];
        else {
          var _e = he.texture(ae.kind, ae.format, ae.dataType, ae.filter);
          _e.load(ce.ref.value), ge[ge.length] = [De, _e];
        }
      }
    }), ge;
  }(e, n, y), L = function(ie, oe, se) {
    var he = [];
    return Object.keys(oe).forEach(function(ge) {
      var De = oe[ge];
      De.type === "attribute" && (he[he.length] = [ge, ie.resources.attribute(se[ge].ref.value, De.itemSize, De.divisor)]);
    }), he;
  }(e, n, g), q = a.elements;
  q && q.ref.value && (R = l.elements(q.ref.value));
  for (var K = {}, X = 0, H = o; X < H.length; X++)
    F = H[X], K[F] = m ? l.vertexArray(I[F], L, R) : null;
  var W = a.drawCount.ref.value, ee = a.instanceCount.ref.value;
  u.drawCount += W, u.instanceCount += ee, u.instancedDrawCount += ee * W;
  var $ = { attributes: !1, defines: !1, elements: !1, textures: !1 }, te = !1, re = -1;
  return { id: s, materialId: i, getProgram: function(ie) {
    return I[ie];
  }, render: function(ie, oe) {
    if (W !== 0 && ee !== 0 && !e.isContextLost) {
      var se = I[ie];
      if (se.id === re && c.currentRenderItemId === s) se.setUniforms(x), oe && oe.length > 0 ? (se.bindTextures(oe, 0), se.bindTextures(G, oe.length)) : se.bindTextures(G, 0);
      else {
        var he = K[ie];
        se.id === c.currentProgramId && se.id === re && i !== -1 && i === c.currentMaterialId || (se.id !== c.currentProgramId && se.use(), se.setUniforms(A), c.currentMaterialId = i, re = se.id), se.setUniforms(x), se.setUniforms(C), oe && oe.length > 0 ? (se.bindTextures(oe, 0), se.bindTextures(G, oe.length)) : se.bindTextures(G, 0), he ? (he.bind(), R && R.bind()) : (R && R.bind(), se.bindAttributes(L)), c.currentRenderItemId = s;
      }
      if (zr) try {
        g8(e.gl);
      } catch (ge) {
        throw new Error("Framebuffer error rendering item id ".concat(s, ": '").concat(ge, "'"));
      }
      if (R ? f.drawElementsInstanced(N, W, R._dataType, 0, ee) : f.drawArraysInstanced(N, 0, W, ee), zr) try {
        mF(e.gl);
      } catch (ge) {
        throw new Error("Draw error rendering item id ".concat(s, ": '").concat(ge, "'"));
      }
    }
  }, update: function() {
    if (function(Ie) {
      Ie.attributes = !1, Ie.defines = !1, Ie.elements = !1, Ie.textures = !1;
    }($), a.aVertex) {
      var ie = a.uVertexCount.ref.value;
      a.aVertex.ref.value.length < ie && U.update(a.aVertex, lc(new Float32Array(ie)));
    }
    for (var oe = 0, se = M.length; oe < se; ++oe) {
      var he = M[oe], ge = he[0];
      (Z = he[1]).ref.version !== T[ge] && ($.defines = !0, T[ge] = Z.ref.version);
    }
    if ($.defines) for (var De = 0, ae = o; De < ae.length; De++)
      ge = ae[De], I[ge].destroy(), I[ge] = cE(e, ge, v, r, n);
    for (a.drawCount.ref.version !== T.drawCount && (u.drawCount += a.drawCount.ref.value - W, u.instancedDrawCount += ee * a.drawCount.ref.value - ee * W, W = a.drawCount.ref.value, T.drawCount = a.drawCount.ref.version), a.instanceCount.ref.version !== T.instanceCount && (u.instanceCount += a.instanceCount.ref.value - ee, u.instancedDrawCount += a.instanceCount.ref.value * W - ee * W, ee = a.instanceCount.ref.value, T.instanceCount = a.instanceCount.ref.version), oe = 0, se = L.length; oe < se; ++oe) {
      var ce = L[oe], _e = (ge = ce[0], ce[1]);
      if ((Z = g[ge]).ref.version !== T[ge]) {
        if (_e.length >= Z.ref.value.length) _e.updateSubData(Z.ref.value, 0, _e.length);
        else {
          _e.destroy();
          var le = n[ge], ue = le.itemSize, be = le.divisor;
          L[oe][1] = l.attribute(Z.ref.value, ue, be), $.attributes = !0;
        }
        T[ge] = Z.ref.version;
      }
    }
    if (R && a.elements.ref.version !== T.elements && (R.length >= a.elements.ref.value.length ? R.updateSubData(a.elements.ref.value, 0, R.length) : (R.destroy(), R = l.elements(a.elements.ref.value), $.elements = !0), T.elements = a.elements.ref.version), $.attributes || $.defines || $.elements) for (var Se = 0, Ne = o; Se < Ne.length; Se++) {
      ge = Ne[Se];
      var J = K[ge];
      J && J.destroy(), K[ge] = m ? l.vertexArray(I[ge], L, R) : null;
    }
    for (oe = 0, se = G.length; oe < se; ++oe) {
      var Z, de = G[oe], ye = (ge = de[0], de[1]);
      (Z = y[ge]).ref.version !== T[ge] && (n[ge].kind !== "texture" ? (ye.load(Z.ref.value), $.textures = !0) : G[oe][1] = Z.ref.value, T[ge] = Z.ref.version);
    }
    for (oe = 0, se = w.length; oe < se; ++oe) {
      var Ae = w[oe], Ce = (ge = Ae[0], Ae[1]);
      Ce.ref.version !== T[ge] && (U.update(C[oe][1], ll(Ce.ref.value)), T[ge] = Ce.ref.version);
    }
    return $;
  }, destroy: function() {
    if (!te) {
      for (var ie = 0, oe = o; ie < oe.length; ie++) {
        var se = oe[ie];
        I[se].destroy();
        var he = K[se];
        he && he.destroy();
      }
      G.forEach(function(ge) {
        var De = ge[0], ae = ge[1];
        n[De].kind !== "texture" && ae.destroy();
      }), L.forEach(function(ge) {
        return ge[0], ge[1].destroy();
      }), R && R.destroy(), u.drawCount -= W, u.instanceCount -= ee, u.instancedDrawCount -= ee * W, te = !0;
    }
  } };
}
var PR = $i();
function Rc(e, t, r) {
  return { id: PR(), materialId: e.materialId, values: t, state: r, render: function(n, a) {
    t.uAlpha && t.alpha && U.updateIfChanged(t.uAlpha, po(t.alpha.ref.value * r.alphaFactor, 0, 1)), e.render(n, a);
  }, getProgram: function(n) {
    return e.getProgram(n);
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
function Ga(e, t) {
  return { id: PR(), values: t, render: function() {
    return e.render("compute");
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
var BR = new Float32Array([1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1]), ei = { drawCount: va("number"), instanceCount: va("number"), aPosition: rn("float32", 2, 0), uQuadScale: ze("v2") }, Qa = { drawCount: U.create(6), instanceCount: U.create(1), aPosition: U.create(BR), uQuadScale: U.create(Ze.create(1, 1)) }, hne = k(k({}, ei), { tColor: Kt("texture", "rgba", "ubyte", "nearest"), uTexSize: ze("v2") }), vne = Rn("copy", Yi, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSize;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    gl_FragColor = texture2D(tColor, coords);
}
`);
function M6(e, t) {
  var r = k(k({}, Qa), { tColor: U.create(t), uTexSize: U.create(Ze.create(t.getWidth(), t.getHeight())) }), n = k({}, hne);
  return Ga(Ua(e, "triangles", vne, n, r), r);
}
var dx, Wi, vi, lE = new Uint32Array([0, 1, 2, 1, 3, 2]), gne = new Float32Array([0, 1, 0, 0, 1, 1, 1, 0]), OR = { nearest: "Nearest", catmulrom: "Catmulrom (Cubic)", mitchell: "Mitchell (Cubic)", bspline: "B-Spline (Cubic)" }, yne = Object.keys(OR);
(function(e) {
  function t(a, i, o, s) {
    return s ? function(u, c, l, d) {
      var f = u.width, m = u.height;
      return U.update(d.imageTexture, u), U.update(d.imageTextureDim, Ze.set(d.imageTextureDim.ref.value, f, m)), U.update(d.cornerBuffer, c), U.update(d.groupTexture, l), d;
    }(a, i, o, s) : function(u, c, l) {
      var d = Ve(), f = -1, m = u.width, h = u.height, p = { kind: "image", imageTexture: U.create(u), imageTextureDim: U.create(Ze.create(m, h)), cornerBuffer: U.create(c), groupTexture: U.create(l), get boundingSphere() {
        var g = function(y) {
          return Zi([y.cornerBuffer.ref.version]);
        }(p);
        if (g !== f) {
          var v = function(y) {
            for (var _ = D(), S = [], b = 0, x = y.length; b < x; b += 3) {
              var A = D.fromArray(D(), y, b);
              S.push(A), D.add(_, _, A);
            }
            D.scale(_, _, 1 / (y.length / 3));
            for (var w = 0, C = 0, M = S; C < M.length; C++) {
              A = M[C];
              var T = D.distance(_, A);
              T > w && (w = T);
            }
            var N = Ve.create(_, w);
            return Ve.setExtrema(N, S), N;
          }(p.cornerBuffer.ref.value);
          Ve.copy(d, v), f = g;
        }
        return d;
      } };
      return p;
    }(a, i, o);
  }
  function r(a) {
    return t(Oa(0, 4, Uint8Array), a ? a.cornerBuffer.ref.value : new Float32Array(24), Oa(0, 4, Uint8Array), a);
  }
  function n(a, i, o, s, u) {
    var c = o.instanceCount, l = o.groupCount, d = hs(o, e.Utils.createPositionIterator(a, i), s.color), f = ru(c * l), m = rl(), h = nl(), p = il(), g = al(), v = { drawCount: lE.length, vertexCount: BR.length / 3, groupCount: l, instanceCount: c }, y = Ve.clone(a.boundingSphere), _ = ja(y, i.aTransform.ref.value, c);
    return k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("image") }, d), f), m), h), p), g), i), yt.createValues(u, v)), { aPosition: a.cornerBuffer, aUv: U.create(gne), elements: U.create(lE), aGroup: U.create(lc(new Float32Array(4))), boundingSphere: U.create(_), invariantBoundingSphere: U.create(y), uInvariantBoundingSphere: U.create(jt.ofSphere(y)), dInterpolation: U.create(u.interpolation), uImageTexDim: a.imageTextureDim, tImageTex: a.imageTexture, tGroupTex: a.groupTexture });
  }
  e.create = t, e.createEmpty = r, e.Params = k(k({}, yt.Params), { interpolation: V.Select("bspline", V.objectToOptions(OR)) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: n, createValuesSimple: function(a, i, o, s, u) {
    var c = yt.createSimple(o, s, u), l = k(k({}, V.getDefaultValues(e.Params)), i);
    return n(a, c.transform, c.locationIterator, c.theme, l);
  }, updateValues: function(a, i) {
    yt.updateValues(a, i), U.updateIfChanged(a.dInterpolation, i.interpolation);
  }, updateBoundingSphere: function(a, i) {
    var o = Ve.clone(i.boundingSphere), s = ja(o, a.aTransform.ref.value, a.instanceCount.ref.value);
    Ve.equals(s, a.boundingSphere.ref.value) || U.update(a.boundingSphere, s), Ve.equals(o, a.invariantBoundingSphere.ref.value) || (U.update(a.invariantBoundingSphere, o), U.update(a.uInvariantBoundingSphere, jt.fromSphere(a.uInvariantBoundingSphere.ref.value, o)));
  }, createRenderableState: function(a) {
    var i = yt.createRenderableState(a);
    return i.opaque = !1, i;
  }, updateRenderableState: function(a, i) {
    yt.updateRenderableState(a, i), a.opaque = !1;
  }, createPositionIterator: function() {
    return ca(1, 1, 1, function() {
      return dc;
    });
  } };
})(dx || (dx = {})), function(e) {
  function t(s, u, c, l, d, f, m, h, p) {
    return p ? function(g, v, y, _, S, b, x, A, w) {
      return A > w.cylinderCount && (U.update(w.mappingBuffer, g), U.update(w.indexBuffer, v)), w.cylinderCount = A, U.update(w.groupBuffer, y), U.update(w.startBuffer, _), U.update(w.endBuffer, S), U.update(w.scaleBuffer, b), U.update(w.capBuffer, x), w;
    }(s, u, c, l, d, f, m, h, p) : function(g, v, y, _, S, b, x, A) {
      var w, C = Ve(), M = -1, T = -1, N = { kind: "cylinders", cylinderCount: A, mappingBuffer: U.create(g), indexBuffer: U.create(v), groupBuffer: U.create(y), startBuffer: U.create(_), endBuffer: U.create(S), scaleBuffer: U.create(b), capBuffer: U.create(x), get boundingSphere() {
        var I = n(N);
        if (I !== M) {
          var P = Vd(N.startBuffer.ref.value, 6 * N.cylinderCount, 6), O = Vd(N.endBuffer.ref.value, 6 * N.cylinderCount, 6);
          Ve.expandBySphere(C, P, O), M = I;
        }
        return C;
      }, get groupMapping() {
        return N.groupBuffer.ref.version !== T && (w = v1(N.groupBuffer.ref.value, N.cylinderCount, 6), T = N.groupBuffer.ref.version), w;
      }, setBoundingSphere: function(I) {
        Ve.copy(C, I), M = n(N);
      } };
      return N;
    }(s, u, c, l, d, f, m, h);
  }
  function r(s) {
    return t(s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), s ? s.startBuffer.ref.value : new Float32Array(0), s ? s.endBuffer.ref.value : new Float32Array(0), s ? s.scaleBuffer.ref.value : new Float32Array(0), s ? s.capBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return Zi([s.cylinderCount, s.mappingBuffer.ref.version, s.indexBuffer.ref.version, s.groupBuffer.ref.version, s.startBuffer.ref.version, s.endBuffer.ref.version, s.scaleBuffer.ref.version, s.capBuffer.ref.version]);
  }
  function a(s, u) {
    var c = 6 * s.cylinderCount, l = u.instanceCount.ref.value, d = am(), f = d.position, m = s.startBuffer.ref.value, h = s.endBuffer.ref.value, p = u.aTransform.ref.value;
    return ca(c, l, 2, function(g, v) {
      var y = g % 6 == 0 ? m : h;
      return v < 0 ? D.fromArray(f, y, 3 * g) : D.transformMat4Offset(f, y, p, 0, 3 * g, 16 * v), d;
    });
  }
  function i(s, u, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, h = hs(c, a(s, u), l.color), p = xl(c, l.size), g = ru(f * m), v = rl(), y = nl(), _ = il(), S = al(), b = { drawCount: 4 * s.cylinderCount * 3, vertexCount: 6 * s.cylinderCount, groupCount: m, instanceCount: f }, x = fh(p) * d.sizeFactor, A = Ve.clone(s.boundingSphere), w = ja(A, u.aTransform.ref.value, f);
    return k(k(k(k(k(k(k(k(k(k(k({ dGeometryType: U.create("cylinders"), aMapping: s.mappingBuffer, aGroup: s.groupBuffer, aStart: s.startBuffer, aEnd: s.endBuffer, aScale: s.scaleBuffer, aCap: s.capBuffer, elements: s.indexBuffer, boundingSphere: U.create(w), invariantBoundingSphere: U.create(A), uInvariantBoundingSphere: U.create(jt.ofSphere(A)) }, h), p), g), v), y), _), S), u), { padding: U.create(x) }), yt.createValues(d, b)), { uSizeFactor: U.create(d.sizeFactor * d.sizeAspectRatio), uDoubleSided: U.create(d.doubleSided), dIgnoreLight: U.create(d.ignoreLight), dXrayShaded: U.create(d.xrayShaded), uBumpFrequency: U.create(d.bumpFrequency), uBumpAmplitude: U.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    yt.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = r, e.transform = function(s, u) {
    var c = s.startBuffer.ref.value;
    Vp(u, c, 0, 6 * s.cylinderCount), U.update(s.startBuffer, c);
    var l = s.endBuffer.ref.value;
    Vp(u, l, 0, 6 * s.cylinderCount), U.update(s.endBuffer, l);
  }, e.Params = k(k({}, yt.Params), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), sizeAspectRatio: V.Numeric(1, { min: 0, max: 3, step: 0.01 }), doubleSided: V.Boolean(!1, yt.CustomQualityParamInfo), ignoreLight: V.Boolean(!1, yt.ShadingCategory), xrayShaded: V.Boolean(!1, yt.ShadingCategory), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), bumpAmplitude: V.Numeric(1, { min: 0, max: 5, step: 0.1 }, yt.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(s, u, c, l, d) {
    var f = yt.createSimple(c, l, d), m = k(k({}, V.getDefaultValues(e.Params)), u);
    return i(s, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(s, u) {
    yt.updateValues(s, u), U.updateIfChanged(s.uSizeFactor, u.sizeFactor * u.sizeAspectRatio), U.updateIfChanged(s.uDoubleSided, u.doubleSided), U.updateIfChanged(s.dIgnoreLight, u.ignoreLight), U.updateIfChanged(s.dXrayShaded, u.xrayShaded), U.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), U.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = Ve.clone(u.boundingSphere), l = ja(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    Ve.equals(l, s.boundingSphere.ref.value) || U.update(s.boundingSphere, l), Ve.equals(c, s.invariantBoundingSphere.ref.value) || (U.update(s.invariantBoundingSphere, c), U.update(s.uInvariantBoundingSphere, jt.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = yt.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: a };
}(Wi || (Wi = {})), function(e) {
  function t(r) {
    switch (r.kind) {
      case "mesh":
        return 3 * r.triangleCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 2 * r.sphereCount * 3;
      case "cylinders":
        return 4 * r.cylinderCount * 3;
      case "text":
        return 2 * r.charCount * 3;
      case "lines":
        return 2 * r.lineCount * 3;
      case "direct-volume":
        return 36;
      case "image":
        return 6;
      case "texture-mesh":
        return r.vertexCount;
    }
  }
  e.getDrawCount = t, e.getVertexCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "texture-mesh":
        return r.vertexCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 4 * r.sphereCount;
      case "cylinders":
        return 6 * r.cylinderCount;
      case "text":
        return 4 * r.charCount;
      case "lines":
        return 4 * r.lineCount;
      case "direct-volume":
        var n = r.gridDimension.ref.value;
        return n[0] * n[1] * n[2];
      case "image":
        return 4;
    }
  }, e.getGroupCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "points":
      case "spheres":
      case "cylinders":
      case "text":
      case "lines":
        return t(r) === 0 ? 0 : j2(r.groupBuffer.ref.value) + 1;
      case "direct-volume":
        return 1;
      case "image":
        return j2(r.groupTexture.ref.value.array) + 1;
      case "texture-mesh":
        return r.groupCount;
    }
  }, e.getUtils = function(r) {
    switch (r.kind) {
      case "mesh":
        return Xt.Utils;
      case "points":
        return im.Utils;
      case "spheres":
        return Nu.Utils;
      case "cylinders":
        return Wi.Utils;
      case "text":
        return vs.Utils;
      case "lines":
        return Ur.Utils;
      case "direct-volume":
        return ly.Utils;
      case "image":
        return dx.Utils;
      case "texture-mesh":
        return qd.Utils;
    }
  }, e.getGranularity = function(r, n) {
    return n === "instance" && r.nonInstanceable ? "group" : n;
  };
}(vi || (vi = {}));
var bne = Qe(13421772), dE = {};
function O8(e, t) {
  return { factory: O8, granularity: "groupInstance", color: function(r) {
    return mo.isLocation(r) ? r.shape.getColor(r.group, r.instance) : bne;
  }, props: t, description: "Assigns colors as defined by the shape object." };
}
var xne = { name: "shape-group", label: "Shape Group", category: "Miscellaneous", factory: O8, getParams: function(e) {
  return dE;
}, defaultValues: V.getDefaultValues(dE), isApplicable: function(e) {
  return !!e.shape;
} }, _ne = k(k({}, _l), { aPosition: rn("float32", 3, 0), elements: dm("uint32"), uBboxMin: ze("v3"), uBboxMax: ze("v3"), uBboxSize: ze("v3"), uMaxSteps: ze("i"), uStepScale: ze("f"), uJumpLength: ze("f"), uTransform: ze("m4"), uGridDim: ze("v3"), tTransferTex: Kt("image-uint8", "alpha", "ubyte", "linear"), uTransferScale: ze("f"), dGridTexType: Ht("string", ["2d", "3d"]), uGridTexDim: ze("v3"), tGridTex: Kt("texture", "rgba", "ubyte", "linear"), uGridStats: ze("v4"), uCellDim: ze("v3"), uCartnToUnit: ze("m4"), uUnitToCartn: ze("m4"), dPackedGroup: Ht("boolean"), dAxisOrder: Ht("string", ["012", "021", "102", "120", "201", "210"]), dIgnoreLight: Ht("boolean"), dXrayShaded: Ht("boolean") }), Sne = k(k({}, _l), { aGroup: rn("float32", 1, 0), aPosition: rn("float32", 3, 0), aNormal: rn("float32", 3, 0), elements: dm("uint32"), dFlatShaded: Ht("boolean"), uDoubleSided: ze("b"), dFlipSided: Ht("boolean"), dIgnoreLight: Ht("boolean"), dXrayShaded: Ht("boolean"), uBumpFrequency: ze("f"), uBumpAmplitude: ze("f"), meta: va("unknown") }), Ane = k(k(k({}, _l), zh), { aGroup: rn("float32", 1, 0), aPosition: rn("float32", 3, 0), dPointSizeAttenuation: Ht("boolean"), dPointStyle: Ht("string", ["square", "circle", "fuzzy"]) }), wne = k(k(k({}, _l), zh), { aGroup: rn("float32", 1, 0), aMapping: rn("float32", 2, 0), aStart: rn("float32", 3, 0), aEnd: rn("float32", 3, 0), elements: dm("uint32"), dLineSizeAttenuation: Ht("boolean"), uDoubleSided: ze("b"), dFlipSided: Ht("boolean") }), Cne = k(k(k({}, _l), zh), { aGroup: rn("float32", 1, 0), aPosition: rn("float32", 3, 0), aMapping: rn("float32", 2, 0), elements: dm("uint32"), padding: va("number"), uDoubleSided: ze("b"), dIgnoreLight: Ht("boolean"), dXrayShaded: Ht("boolean"), uBumpFrequency: ze("f"), uBumpAmplitude: ze("f") }), Ene = k(k(k({}, _l), zh), { aGroup: rn("float32", 1, 0), aPosition: rn("float32", 3, 0), aMapping: rn("float32", 2, 0), aDepth: rn("float32", 1, 0), elements: dm("uint32"), aTexCoord: rn("float32", 2, 0), tFont: Kt("image-uint8", "alpha", "ubyte", "linear"), padding: va("number"), uBorderWidth: ze("f"), uBorderColor: ze("v3"), uOffsetX: ze("f"), uOffsetY: ze("f"), uOffsetZ: ze("f"), uBackgroundColor: ze("v3"), uBackgroundOpacity: ze("f") }), Dne = k(k({}, _l), { uGeoTexDim: ze("v2", "buffered"), tPosition: Kt("texture", "rgb", "float", "nearest"), tGroup: Kt("texture", "alpha", "float", "nearest"), tNormal: Kt("texture", "rgb", "float", "nearest"), dFlatShaded: Ht("boolean"), uDoubleSided: ze("b"), dFlipSided: Ht("boolean"), dIgnoreLight: Ht("boolean"), dXrayShaded: Ht("boolean"), uBumpFrequency: ze("f"), uBumpAmplitude: ze("f"), meta: va("unknown") }), Mne = k(k({}, _l), { aGroup: rn("float32", 1, 0), aPosition: rn("float32", 3, 0), aUv: rn("float32", 2, 0), elements: dm("uint32"), uImageTexDim: ze("v2"), tImageTex: Kt("image-uint8", "rgba", "ubyte", "nearest"), tGroupTex: Kt("image-uint8", "rgba", "ubyte", "nearest"), dInterpolation: Ht("string", yne) }), Ine = k(k(k({}, _l), zh), { aGroup: rn("float32", 1, 0), aStart: rn("float32", 3, 0), aEnd: rn("float32", 3, 0), aMapping: rn("float32", 3, 0), aScale: rn("float32", 1, 0), aCap: rn("float32", 1, 0), elements: dm("uint32"), padding: va("number"), uDoubleSided: ze("b"), dIgnoreLight: Ht("boolean"), dXrayShaded: Ht("boolean"), uBumpFrequency: ze("f"), uBumpAmplitude: ze("f") }), or, mo, Tne = $i(0, 2147483647), Sl = $i(0, 2147483647);
function g1(e, t, r, n) {
  return { id: Tne(), type: e, values: t, state: r, materialId: n };
}
function Nne(e, t, r) {
  switch (t.type) {
    case "mesh":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Sne), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", r9, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "points":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Ane), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "points", L$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "spheres":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Cne), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", k$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "cylinders":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Ine), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", z$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "text":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Ene), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", U$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "lines":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), wne), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", G$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "direct-volume":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), _ne);
        n.isWebGL2 || (c.uMaxSteps = Ht("number"));
        var l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", V$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "image":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Mne), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", q$, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "texture-mesh":
      return function(n, a, i, o, s, u) {
        var c = k(k(k(k({}, Pc), Bc), Oc), Dne), l = { uObjectId: U.create(a) };
        return Rc(Fc(n, "triangles", r9, c, k(k({}, i), l), s, u), i, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
  }
  throw new Error("unsupported type");
}
(function(e) {
  function t(r) {
    var n = r.transforms.length, a = mo.Location(r);
    return ca(r.groupCount, n, 1, function(i, o) {
      return a.group = i, a.instance = o, a;
    });
  }
  e.create = function(r, n, a, i, o, s, u) {
    return { id: Fa.create22(), name: r, sourceData: n, geometry: a, transforms: u || [Ee.identity()], get groupCount() {
      return vi.getGroupCount(a);
    }, getColor: i, getSize: o, getLabel: s };
  }, e.getTheme = function(r) {
    return { color: O8(0, {}), size: F8({ shape: r }, {}) };
  }, e.groupIterator = t, e.createTransform = function(r, n) {
    for (var a = n && n.aTransform.ref.value.length >= 16 * r.length ? n.aTransform.ref.value : new Float32Array(16 * r.length), i = 0, o = r.length; i < o; ++i) Ee.toArray(r[i], a, 16 * i);
    return I8(a, r.length, n);
  }, e.createRenderObject = function(r, n) {
    var a = e.getTheme(r), i = vi.getUtils(r.geometry), o = Sl(), s = t(r), u = e.createTransform(r.transforms), c = i.createValues(r.geometry, u, s, a, n), l = i.createRenderableState(n);
    return g1(r.geometry.kind, c, l, o);
  }, e.Loci = function(r) {
    return { kind: "shape-loci", shape: r };
  }, e.isLoci = function(r) {
    return !!r && r.kind === "shape-loci";
  }, e.areLociEqual = function(r, n) {
    return r.shape === n.shape;
  }, e.isLociEmpty = function(r) {
    return r.shape.groupCount === 0;
  };
})(or || (or = {})), function(e) {
  function t(o) {
    for (var s = 0, u = 0, c = o.groups; u < c.length; u++) {
      var l = c[u];
      s += We.size(l.ids);
    }
    return s;
  }
  e.Location = function(o, s, u) {
    return s === void 0 && (s = 0), u === void 0 && (u = 0), { kind: "group-location", shape: o, group: s, instance: u };
  }, e.isLocation = function(o) {
    return !!o && o.kind === "group-location";
  }, e.Loci = function(o, s) {
    return { kind: "group-loci", shape: o, groups: s };
  }, e.isLoci = function(o) {
    return !!o && o.kind === "group-loci";
  }, e.areLociEqual = function(o, s) {
    if (o.shape !== s.shape || o.groups.length !== s.groups.length) return !1;
    for (var u = 0, c = o.groups.length; u < c; ++u) {
      var l = o.groups[u], d = l.ids, f = l.instance, m = s.groups[u], h = m.ids;
      if (f !== m.instance || !We.areEqual(d, h)) return !1;
    }
    return !0;
  }, e.isLociEmpty = function(o) {
    return t(o) === 0;
  }, e.size = t;
  var r = new Lp(), n = D.zero();
  function a(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, f = function(g, v) {
      We.forEach(g, function(y) {
        for (var _ = d[y], S = d[y + 1]; _ < S; ++_) D.fromArray(n, u, 3 * l[_]), D.transformMat4(n, n, c[v]), r.includeStep(n);
      });
    }, m = 0, h = o; m < h.length; m++) {
      var p = h[m];
      f(p.ids, p.instance);
    }
  }
  function i(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, f = function(g, v) {
      We.forEach(g, function(y) {
        for (var _ = d[y], S = d[y + 1]; _ < S; ++_) D.fromArray(n, u, 3 * l[_]), D.transformMat4(n, n, c[v]), r.radiusStep(n);
      });
    }, m = 0, h = o; m < h.length; m++) {
      var p = h[m];
      f(p.ids, p.instance);
    }
  }
  e.getBoundingSphere = function(o, s) {
    s || (s = Ve()), r.reset();
    var u = 0, c = o.shape, l = c.geometry, d = c.transforms;
    if (l.kind === "mesh" || l.kind === "points") {
      var f = l.kind === "mesh" ? l.vertexBuffer.ref.value : l.centerBuffer.ref.value;
      a(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), i(o.groups, l.groupMapping, f, d);
    } else if (l.kind === "lines") {
      var m = l.startBuffer.ref.value, h = l.endBuffer.ref.value;
      a(o.groups, l.groupMapping, m, d), a(o.groups, l.groupMapping, h, d), r.finishedIncludeStep(), i(o.groups, l.groupMapping, m, d), i(o.groups, l.groupMapping, h, d);
    } else {
      if (l.kind !== "spheres" && l.kind !== "text") return Ve.copy(s, l.boundingSphere);
      f = l.centerBuffer.ref.value, a(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), i(o.groups, l.groupMapping, f, d);
      for (var p = function(_, S) {
        We.forEach(_, function(b) {
          var x = o.shape.getSize(b, S);
          u < x && (u = x);
        });
      }, g = 0, v = o.groups; g < v.length; g++) {
        var y = v[g];
        p(y.ids, y.instance);
      }
    }
    return D.copy(s.center, r.center), s.radius = Math.sqrt(r.radiusSq), Ve.expand(s, s, u), s;
  };
}(mo || (mo = {}));
var Pne = 1, Bne = "Assigns sizes as defined by the shape object.", fE = {};
function F8(e, t) {
  return { factory: F8, granularity: "groupInstance", size: function(r) {
    return mo.isLocation(r) ? r.shape.getSize(r.group, r.instance) : Pne;
  }, props: t, description: Bne };
}
var One = { name: "shape-group", label: "Shape Group", category: "", factory: F8, getParams: function(e) {
  return fE;
}, defaultValues: V.getDefaultValues(fE), isApplicable: function(e) {
  return !!e.shape;
} }, mE = { bfactorFactor: V.Numeric(0.1, { min: 0, max: 1, step: 0.01 }), rmsfFactor: V.Numeric(0.05, { min: 0, max: 1, step: 0.01 }), baseSize: V.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) };
function pE(e, t, r) {
  return Ke.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) * r.bfactorFactor : Ke.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] * r.rmsfFactor : 0;
}
var Fne = { name: "uncertainty", label: "Uncertainty/Disorder", category: "", factory: function e(t, r) {
  return { factory: e, granularity: "group", size: function(n) {
    var a = r.baseSize;
    return lt.is(n) ? a += pE(n.unit, n.element, r) : Pt.isLocation(n) && (a += pE(n.aUnit, n.aUnit.elements[n.aIndex], r)), a;
  }, props: r, description: "Assigns a size reflecting the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique." };
}, getParams: function(e) {
  return mE;
}, defaultValues: V.getDefaultValues(mE), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, hE = { hydrogenSize: V.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), oxygenSize: V.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), baseSize: V.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) }, go, nu, Rne = { name: "aquasite", label: "Aquasite", category: "", factory: function e(t, r) {
  return { factory: e, granularity: "group", size: function(n) {
    var a = r.baseSize;
    return lt.is(n) && (a += function(i, o, s) {
      if (Ke.isAtomic(i)) {
        var u = i.model.atomicHierarchy.atoms.type_symbol.value(o).toUpperCase();
        return u === "H" ? s.hydrogenSize : u === "O" ? s.oxygenSize : 0;
      }
      return 0;
    }(n.unit, n.element, r)), a;
  }, props: r, description: "Aquasite" };
}, getParams: function(e) {
  return hE;
}, defaultValues: V.getDefaultValues(hE), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} };
function vE(e) {
  return e.map(function(t) {
    return [t.name, t.provider.label, t.provider.category];
  });
}
(function(e) {
  e.EmptyFactory = function() {
    return e.Empty;
  }, e.Empty = { factory: e.EmptyFactory, granularity: "uniform", size: function() {
    return 1;
  }, props: {} }, e.areEqual = function(t, r) {
    return t.factory === r.factory && Ud(t.props, r.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new FR(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { physical: Kre, "shape-group": One, uncertainty: Fne, uniform: Hre, aquasite: Rne };
})(go || (go = {})), function(e) {
  function t() {
    return { color: fl.Empty, size: go.Empty };
  }
  e.create = function(r, n, a, i) {
    i = i || t();
    var o = a.colorTheme, s = a.sizeTheme;
    return i.color = r.colorThemeRegistry.create(o.name, n, o.params), i.size = r.sizeThemeRegistry.create(s.name, n, s.params), i;
  }, e.createEmpty = t, e.ensureDependencies = function(r, n, a, i) {
    var o, s;
    return Be(this, 0, void 0, function() {
      return Te(this, function(u) {
        switch (u.label) {
          case 0:
            return [4, (o = n.colorThemeRegistry.get(i.colorTheme.name).ensureCustomProperties) === null || o === void 0 ? void 0 : o.attach(r, a)];
          case 1:
            return u.sent(), [4, (s = n.sizeThemeRegistry.get(i.sizeTheme.name).ensureCustomProperties) === null || s === void 0 ? void 0 : s.attach(r, a)];
          case 2:
            return u.sent(), [2];
        }
      });
    });
  }, e.releaseDependencies = function(r, n, a) {
    var i, o;
    (i = r.colorThemeRegistry.get(a.colorTheme.name).ensureCustomProperties) === null || i === void 0 || i.detach(n), (o = r.sizeThemeRegistry.get(a.sizeTheme.name).ensureCustomProperties) === null || o === void 0 || o.detach(n);
  };
}(nu || (nu = {}));
var FR = function() {
  function e(t, r) {
    var n = this;
    this.emptyProvider = r, this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map(), jO(t, function(a, i) {
      if (a.name !== i) throw new Error("Fix build in themes to have matching names. ".concat(a.name, " ").concat(i));
      n.add(a);
    });
  }
  return Object.defineProperty(e.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "types", { get: function() {
    return vE(this._list);
  }, enumerable: !1, configurable: !0 }), e.prototype.sort = function() {
    this._list.sort(function(t, r) {
      return t.provider.category === r.provider.category ? t.provider.label < r.provider.label ? -1 : t.provider.label > r.provider.label ? 1 : 0 : t.provider.category < r.provider.category ? -1 : 1;
    });
  }, e.prototype.add = function(t) {
    if (this._map.has(t.name)) throw new Error("".concat(t.name, " already registered."));
    var r = t.name;
    this._list.push({ name: r, provider: t }), this._map.set(r, t), this._name.set(t, r), this.sort();
  }, e.prototype.remove = function(t) {
    this._list.splice(this._list.findIndex(function(n) {
      return n.name === t.name;
    }), 1);
    var r = this._map.get(t.name);
    r && (this._map.delete(t.name), this._name.delete(r));
  }, e.prototype.has = function(t) {
    return this._map.has(t.name);
  }, e.prototype.get = function(t) {
    return this._map.get(t) || this.emptyProvider;
  }, e.prototype.getName = function(t) {
    if (!this._name.has(t)) throw new Error("'".concat(t.label, "' is not a registered theme provider."));
    return this._name.get(t);
  }, e.prototype.create = function(t, r, n) {
    n === void 0 && (n = {});
    var a = this.get(t);
    return a.factory(r, k(k({}, V.getDefaultValues(a.getParams(r))), n));
  }, e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return vE(this.getApplicableList(t));
  }, e;
}(), RR = { hue: V.Interval([1, 360], { min: 0, max: 360, step: 1 }), chroma: V.Interval([40, 70], { min: 0, max: 100, step: 1 }), luminance: V.Interval([15, 85], { min: 0, max: 100, step: 1 }), clusteringStepCount: V.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }), minSampleCount: V.Numeric(800, { min: 100, max: 5e3, step: 100 }, { isHidden: !0 }) };
function gE(e, t) {
  return Math.sqrt(Math.pow(Math.abs(e[0] - t[0]), 2) + Math.pow(Math.abs(e[1] - t[1]), 2) + Math.pow(Math.abs(e[2] - t[2]), 2));
}
var Ym = 2, gf = [0, 0, 0], yf = [0, 0, 0];
function Lne(e, t) {
  return ui.toHcl(gf, e), ui.fromColor(yf, ui.toColor(e)), gf[0] >= t.hue[0] && gf[0] <= t.hue[1] && gf[1] >= t.chroma[0] && gf[1] <= t.chroma[1] && gf[2] >= t.luminance[0] && gf[2] <= t.luminance[1] && yf[0] >= e[0] - Ym && yf[0] <= e[0] + Ym && yf[1] >= e[1] - Ym && yf[1] <= e[1] + Ym && yf[2] >= e[2] - Ym && yf[2] <= e[2] + Ym;
}
function kne(e, t) {
  t === void 0 && (t = {});
  var r = k(k({}, V.getDefaultValues(RR)), t);
  if (e <= 0) return [];
  var n = function(M, T) {
    for (var N = /* @__PURE__ */ new Map(), I = 1.001 * Math.cbrt(M), P = (T.hue[1] - T.hue[0]) / I, O = (T.chroma[1] - T.chroma[0]) / I, F = (T.luminance[1] - T.luminance[0]) / I, R = T.hue[0]; R <= T.hue[1]; R += P) for (var G = T.chroma[0]; G <= T.chroma[1]; G += O) for (var L = T.luminance[0]; L <= T.luminance[1]; L += F) {
      var q = ui.fromHcl(ui(), Qu.create(R, G, L));
      Lne(q, T) && N.set(q.toString(), q);
    }
    return Array.from(N.values());
  }(Math.max(r.minSampleCount, 5 * e), r);
  if (n.length < e) throw new Error("Not enough samples to generate distinct colors, increase sample count.");
  for (var a = [], i = [], o = Math.floor(n.length / e), s = 0; s < n.length && (a.push(n[s]), i.push([]), !(a.length >= e)); s += o) ;
  for (var u = 1; u <= r.clusteringStepCount; ++u) {
    var c = ll(i);
    for (s = 0; s < n.length; ++s) {
      for (var l = Number.MAX_SAFE_INTEGER, d = 0, f = 0; f < a.length; f++) {
        var m = gE(n[s], a[f]);
        m < l && (l = m, d = f);
      }
      c[d].push(n[s]);
    }
    var h = ll(a);
    for (s = 0; s < c.length; ++s) {
      for (var p = c[s], g = p.length, v = [], y = [], _ = [], S = 0, b = p; S < b.length; S++) {
        var x = b[S];
        v.push(x[0]), y.push(x[1]), _.push(x[2]);
      }
      var A = w2(v) / g, w = w2(y) / g, C = w2(_) / g;
      a[s] = [A, w, C];
    }
    if (Ud(h, a)) break;
  }
  return function(M) {
    for (var T = M.slice(0), N = [T.shift()]; T.length > 0; ) {
      for (var I = N[N.length - 1], P = 0, O = Number.MIN_SAFE_INTEGER, F = 0; F < T.length; ++F) {
        var R = gE(I, T[F]);
        R > O && (O = R, P = F);
      }
      N.push(T.splice(P, 1)[0]);
    }
    return N;
  }(a).map(function(M) {
    return ui.toColor(M);
  });
}
var LR = { type: "generate", colorList: "red-yellow-blue" };
function xs(e) {
  e === void 0 && (e = {});
  var t = k(k({}, LR), e);
  return { palette: V.MappedStatic(t.type, { colors: V.Group({ list: V.ColorList(t.colorList) }, { isFlat: !0 }), generate: V.Group(k(k({}, RR), { maxCount: V.Numeric(75, { min: 1, max: 250, step: 1 }) }), { isFlat: !0 }) }, { options: [["colors", "Color List"], ["generate", "Generate Distinct"]] }) };
}
V.getDefaultValues(xs());
var yE = { valueLabel: function(e) {
  return "".concat(e + 1);
}, minLabel: "Start", maxLabel: "End" };
function Bu(e, t, r) {
  var n, a, i;
  if (r === void 0 && (r = {}), t.palette.name === "colors" && t.palette.params.list.kind === "interpolate") {
    var o = t.palette.params.list, s = [0, e - 1], u = k(k({}, yE), r), c = u.minLabel, l = u.maxLabel, d = o.colors;
    d.length === 0 && (d = ul(LR.colorList).list);
    var f = cc.create({ listOrName: d, domain: s, minLabel: c, maxLabel: l });
    i = f.legend, a = f.color;
  } else {
    var m;
    t.palette.name === "colors" ? (m = t.palette.params.list.colors.map(function(_) {
      return Array.isArray(_) ? _[0] : _;
    }), m.length === 0 && (m = ul("dark-2").list.map(function(_) {
      return Array.isArray(_) ? _[0] : _;
    }))) : (e = Math.min(e, t.palette.params.maxCount), m = kne(e, t.palette.params));
    for (var h = (n = r.valueLabel) !== null && n !== void 0 ? n : yE.valueLabel, p = m.length, g = [], v = 0; v < e; ++v) {
      var y = v % p;
      g[y] === void 0 ? g[y] = [h(v), m[y]] : g[y][0] += ", ".concat(h(v));
    }
    i = Pu(g), a = function(_) {
      return m[_ % p];
    };
  }
  return { color: a, legend: i };
}
var bE = Qe(16448250), zne = "Gives every chain a color based on its `asym_id` value.", om = k({ asymId: V.Select("auth", V.arrayToOptions(["auth", "label"])) }, xs({ type: "colors", colorList: "many-distinct" }));
function xE(e, t) {
  var r = function(n, a) {
    switch (n.kind) {
      case 0:
        return a === "auth" ? at.chain.auth_asym_id : at.chain.label_asym_id;
      case 1:
      case 2:
        return at.coarse.asym_id;
    }
  }(e.unit, t)(e);
  return e.structure.root.models.length > 1 ? kR(e.unit.model, r) : r;
}
function kR(e, t) {
  return "".concat(t, "|").concat((yn.Index.get(e).value || 0) + 1);
}
function b3(e, t) {
  var r, n;
  if (e.structure) {
    var a = lt.create(e.structure.root), i = function(u, c) {
      for (var l = /* @__PURE__ */ new Map(), d = function(h) {
        var p = yn.AsymIdOffset.get(h).value, g = (c === "auth" ? p == null ? void 0 : p.auth : p == null ? void 0 : p.label) || 0, v = 0;
        h.properties.structAsymMap.forEach(function(y, _) {
          var S = y.auth_id, b = c === "auth" ? S : _, x = u.models.length > 1 ? kR(h, b) : b;
          l.has(x) || (l.set(x, v + g), ++v);
        });
      }, f = 0, m = u.models; f < m.length; f++) d(m[f]);
      return l;
    }(e.structure.root, t.asymId), o = Array.from(i.keys()), s = Bu(i.size, t, { valueLabel: function(u) {
      return o[u];
    } });
    n = s.legend, r = function(u) {
      var c = void 0;
      if (lt.is(u)) {
        var l = xE(u, t.asymId);
        c = i.get(l);
      } else Pt.isLocation(u) && (a.unit = u.aUnit, a.element = u.aUnit.elements[u.aIndex], l = xE(a, t.asymId), c = i.get(l));
      return c === void 0 ? bE : s.color(c);
    };
  } else r = function() {
    return bE;
  };
  return { factory: b3, granularity: "group", color: r, props: t, description: zne, legend: n };
}
var Une = { name: "chain-id", label: "Chain Id", category: "Chain Property", factory: b3, getParams: function(e) {
  var t, r = V.clone(om);
  return !((t = e.structure) === null || t === void 0) && t.models.some(function(n) {
    return n.coarseHierarchy.isDefined;
  }) && (r.asymId.defaultValue = "label"), r;
}, defaultValues: V.getDefaultValues(om), isApplicable: function(e) {
  return !!e.structure;
} }, _E = Qe(13421772), SE = k({}, xs({ type: "colors", colorList: "red-yellow-blue" })), Gne = { name: "element-index", label: "Element Index", category: "Atom Property", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    for (var i = t.structure.root.units, o = i.length, s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = 0, l = 0; l < o; ++l) s.set(l, c), c += i[l].elements.length, u.set(i[l].id, l);
    var d = Bu(c, r);
    a = d.legend, n = function(f) {
      if (lt.is(f)) {
        var m = u.get(f.unit.id), h = We.findPredecessorIndex(i[m].elements, f.element);
        return d.color(s.get(m) + h);
      }
      return Pt.isLocation(f) ? (m = u.get(f.aUnit.id), h = We.findPredecessorIndex(i[m].elements, f.aUnit.elements[f.aIndex]), d.color(s.get(m) + h)) : _E;
    };
  } else n = function() {
    return _E;
  };
  return { factory: e, granularity: "groupInstance", preferSmoothing: !0, color: n, props: r, description: "Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.", legend: a };
}, getParams: function(e) {
  return SE;
}, defaultValues: V.getDefaultValues(SE), isApplicable: function(e) {
  return !!e.structure;
} };
function y1(e) {
  var t = {};
  return jO(e, function(r, n) {
    t[n] = V.Color(e[n]);
  }), t;
}
var AE = Qe(13421772), Vne = "Assigns a color based on the operator name of a transformed chain.", Hp = k({}, xs({ type: "colors", colorList: "many-distinct" }));
function R8(e, t) {
  var r, n;
  if (e.structure) {
    var a = function(s) {
      for (var u = /* @__PURE__ */ new Map(), c = 0, l = s.units.length; c < l; ++c) {
        var d = s.units[c].conformation.operator.name;
        u.has(d) || u.set(d, u.size);
      }
      return u;
    }(e.structure.root), i = Array.from(a.keys()), o = Bu(a.size, t, { valueLabel: function(s) {
      return i[s];
    } });
    n = o.legend, r = function(s) {
      var u = void 0;
      if (lt.is(s)) {
        var c = s.unit.conformation.operator.name;
        u = a.get(c);
      } else if (Pt.isLocation(s)) {
        var l = s.aUnit.conformation.operator.name;
        u = a.get(l);
      }
      return u === void 0 ? AE : o.color(u);
    };
  } else r = function() {
    return AE;
  };
  return { factory: R8, granularity: "instance", color: r, props: t, description: Vne, legend: n };
}
var qne = { name: "operator-name", label: "Operator Name", category: "Symmetry", factory: R8, getParams: function(e) {
  return V.clone(Hp);
}, defaultValues: V.getDefaultValues(Hp), isApplicable: function(e) {
  return !!e.structure;
} }, wE = Qe(16448250), Hne = "Gives every chain a color based on its `label_entity_id` value.", Kp = k({}, xs({ type: "colors", colorList: "many-distinct" }));
function $1(e, t) {
  return "".concat(e, "|").concat(t);
}
function CE(e) {
  switch (e.unit.kind) {
    case 0:
      return at.chain.label_entity_id(e);
    case 1:
    case 2:
      return at.coarse.entity_id(e);
  }
}
function x3(e, t) {
  var r, n;
  if (e.structure) {
    var a = lt.create(e.structure.root), i = function(u) {
      for (var c = /* @__PURE__ */ new Map(), l = 0, d = u.models.length; l < d; ++l) {
        for (var f = u.models[l].atomicHierarchy.chains.label_entity_id, m = 0, h = f.rowCount; m < h; ++m) {
          var p = $1(f.value(m), l);
          c.has(p) || c.set(p, c.size);
        }
        var g = u.models[l].coarseHierarchy;
        if (g.isDefined) {
          var v = g.spheres.entity_id;
          for (m = 0, h = v.rowCount; m < h; ++m) p = $1(v.value(m), l), c.has(p) || c.set(p, c.size);
          var y = g.gaussians.entity_id;
          for (m = 0, h = y.rowCount; m < h; ++m) p = $1(y.value(m), l), c.has(p) || c.set(p, c.size);
        }
      }
      return c;
    }(e.structure.root), o = Array.from(i.keys()), s = Bu(i.size, t, { valueLabel: function(u) {
      return o[u];
    } });
    n = s.legend, r = function(u) {
      var c = void 0;
      if (lt.is(u)) {
        var l = $1(CE(u), u.structure.models.indexOf(u.unit.model));
        c = i.get(l);
      } else Pt.isLocation(u) && (a.unit = u.aUnit, a.element = u.aUnit.elements[u.aIndex], l = $1(CE(a), a.structure.models.indexOf(a.unit.model)), c = i.get(l));
      return c === void 0 ? wE : s.color(c);
    };
  } else r = function() {
    return wE;
  };
  return { factory: x3, granularity: "group", color: r, props: t, description: Hne, legend: n };
}
var Kne = { name: "entity-id", label: "Entity Id", category: "Chain Property", factory: x3, getParams: function(e) {
  return V.clone(Kp);
}, defaultValues: V.getDefaultValues(Kp), isApplicable: function(e) {
  return !!e.structure;
} }, I6 = "dark-2", hg = Qe(16448250), Xne = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).", Xp = k({}, xs({ type: "colors", colorList: I6 }));
function zR(e, t) {
  return "".concat(e, "|").concat(t);
}
function jne(e, t, r, n, a, i) {
  return "".concat(e, "|").concat(t, "|").concat(r, "|").concat(i || a || n);
}
function fx(e, t, r, n, a, i, o, s) {
  for (var u = a.entity_id, c = a.pdbx_src_id, l = a.pdbx_beg_seq_num, d = a.pdbx_end_seq_num, f = 0, m = a._rowCount; f < m; ++f) {
    var h = u.value(f), p = zR(r, h), g = void 0;
    if (e.has(p)) g = e.get(p);
    else {
      var v = n.entities.getEntityIndex(h), y = n.sequence.sequences[v].sequence;
      g = new Int16Array(y.length), e.set(p, g);
    }
    var _ = o ? o.value(f) : "", S = s ? s.value(f)[0] : "", b = jne(r, h, i.value(f), c.value(f), _, S), x = l.valueKind(f) === 0 ? l.value(f) : 1, A = d.valueKind(f) === 0 ? d.value(f) : g.length, w = void 0;
    t.has(b) ? w = t.get(b) : (w = t.size + 1, t.set(b, w));
    for (var C = x, M = A; C <= M; ++C) g[C - 1] = w;
  }
}
function UR(e) {
  for (var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = 0, a = e.length; n < a; ++n) {
    var i = e[n];
    if (Dn.is(i.sourceData)) {
      var o = i.sourceData.data.db, s = o.entity_src_gen, u = o.entity_src_nat, c = o.pdbx_entity_src_syn;
      fx(t, r, n, i, s, s.pdbx_gene_src_scientific_name, s.plasmid_name, s.pdbx_gene_src_gene), fx(t, r, n, i, u, u.pdbx_organism_scientific, u.pdbx_plasmid_name), fx(t, r, n, i, c, c.organism_scientific);
    }
  }
  return { seqToSrcByModelEntity: t, srcKeySerialMap: r };
}
function Yne(e) {
  var t = 0;
  return Array.from(e.keys()).map(function(r) {
    var n = r.split("|"), a = n[2], i = function(o) {
      o = o.trim();
      var s = parseInt(o, 10);
      return !isNaN(s) && s.toString() === o;
    }(n[3]) ? "Unnamed ".concat(++t) : n[3];
    return "".concat(i).concat(a ? " (".concat(a, ")") : "");
  });
}
function _3(e, t) {
  var r, n;
  if (e.structure) {
    var a = lt.create(e.structure), i = e.structure.root.models, o = UR(i), s = o.seqToSrcByModelEntity, u = o.srcKeySerialMap, c = Yne(u), l = Bu(u.size, t, { valueLabel: function(f) {
      return c[f];
    } });
    n = l.legend;
    var d = function(f) {
      var m = zR(i.indexOf(f.unit.model), at.entity.id(f)), h = s.get(m);
      if (h) {
        var p = h[at.residue.label_seq_id(f) - 1] - 1;
        return p === -1 ? hg : l.color(p);
      }
      return hg;
    };
    r = function(f) {
      return lt.is(f) ? d(f) : Pt.isLocation(f) ? (a.unit = f.aUnit, a.element = f.aUnit.elements[f.aIndex], d(a)) : hg;
    };
  } else r = function() {
    return hg;
  };
  return { factory: _3, granularity: "group", color: r, props: t, description: Xne, legend: n };
}
var Wne = { name: "entity-source", label: "Entity Source", category: "Chain Property", factory: _3, getParams: function(e) {
  var t = V.clone(Xp);
  return e.structure && UR(e.structure.root.models).srcKeySerialMap.size > Uo[I6].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = k(k({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: ul(I6).list } })), t;
}, defaultValues: V.getDefaultValues(Xp), isApplicable: function(e) {
  return !!e.structure;
} }, GR = { H: 13817304, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 7370475, O: 15425118, F: 2543814, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 15654476, S: 15771392, CL: 1286709, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 8860212, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, VR = Qe(16777215), qR = { carbonColor: V.MappedStatic("chain-id", { "chain-id": V.Group(om), "entity-id": V.Group(Kp), "entity-source": V.Group(Xp), "operator-name": V.Group(Hp), "element-symbol": V.EmptyGroup(), uniform: V.Group(cy) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(GR)) }) };
function Zne(e) {
  return qR;
}
function Qne(e, t) {
  var r = e[t];
  return r === void 0 ? VR : r;
}
function HR(e, t) {
  var r = cm(t.colors.name === "default" ? GR : t.colors.params, t.saturation, t.lightness), n = t.carbonColor, a = n.name === "chain-id" ? b3(e, n.params).color : n.name === "entity-id" ? x3(e, n.params).color : n.name === "entity-source" ? _3(e, n.params).color : n.name === "operator-name" ? R8(e, n.params).color : n.name === "element-symbol" ? void 0 : n.name === "uniform" ? Lh(0, n.params).color : Ja();
  function i(o, s) {
    return a && o === "C" ? a(s, !1) : Qne(r, o);
  }
  return { factory: HR, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(o) {
    if (lt.is(o)) {
      if (Ke.isAtomic(o.unit)) return i(o.unit.model.atomicHierarchy.atoms.type_symbol.value(o.element), o);
    } else if (Pt.isLocation(o) && Ke.isAtomic(o.aUnit))
      return i(o.aUnit.model.atomicHierarchy.atoms.type_symbol.value(o.aUnit.elements[o.aIndex]), o);
    return VR;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: Pu(Object.keys(r).map(function(o) {
    return [o, r[o]];
  })) };
}
var $ne = { name: "element-symbol", label: "Element Symbol", category: "Atom Property", factory: HR, getParams: Zne, defaultValues: V.getDefaultValues(qR), isApplicable: function(e) {
  return !!e.structure;
} }, KR = { water: 3697840, ion: 15729279, protein: 12496596, RNA: 16629894, DNA: 12540695, PNA: 4367514, saccharide: 8374655 }, T6 = Qe(16777113), Jne = "Assigns a color based on the molecule type of a residue.", N6 = { saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(KR)) }) };
function EE(e, t, r) {
  switch (XF(t, r)) {
    case 2:
      return e.water;
    case 3:
      return e.ion;
    case 5:
      return e.protein;
    case 6:
      return e.RNA;
    case 7:
      return e.DNA;
    case 8:
      return e.PNA;
    case 9:
      return e.saccharide;
  }
  return T6;
}
function L8(e, t) {
  var r = cm(t.colors.name === "default" ? KR : t.colors.params, t.saturation, t.lightness);
  return { factory: L8, granularity: "group", color: function(n) {
    return lt.is(n) ? EE(r, n.unit, n.element) : Pt.isLocation(n) ? EE(r, n.aUnit, n.aUnit.elements[n.aIndex]) : T6;
  }, props: t, description: Jne, legend: Pu(Object.keys(r).map(function(n) {
    return [n, r[n]];
  }).concat([["Other/unknown", T6]])) };
}
var eae = { name: "molecule-type", label: "Molecule Type", category: "Residue Property", factory: L8, getParams: function(e) {
  return N6;
}, defaultValues: V.getDefaultValues(N6), isApplicable: function(e) {
  return !!e.structure;
} }, P6 = "dark-2", DE = Qe(16448250), ME = k({}, xs({ type: "colors", colorList: P6 }));
function IE(e) {
  switch (e.kind) {
    case 0:
      return at.chain.label_asym_id;
    case 1:
    case 2:
      return at.coarse.asym_id;
  }
}
function TE(e) {
  for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.unitSymmetryGroups.length; r < n; ++r) {
    var a = e.unitSymmetryGroups[r].units[0], i = a.model;
    if (Ke.isAtomic(a)) for (var o = i.atomicHierarchy, s = o.chainAtomSegments, u = o.chains, c = nr.transientSegments(s, a.elements); c.hasNext; ) {
      var l = c.move().index, d = u.label_entity_id.value(l), f = i.entities.getEntityIndex(d);
      if (i.entities.data.type.value(f) === "polymer") {
        var m = u.label_asym_id.value(l);
        t.has(m) || t.set(m, t.size);
      }
    }
    else if (Ke.isCoarse(a)) {
      var h = Ke.isSpheres(a) ? i.coarseHierarchy.spheres : i.coarseHierarchy.gaussians, p = h.chainElementSegments, g = h.asym_id, v = h.entity_id;
      for (c = nr.transientSegments(p, a.elements); c.hasNext; ) {
        l = c.move().index;
        var y = p.offsets[l];
        d = v.value(y), f = i.entities.getEntityIndex(d), i.entities.data.type.value(f) === "polymer" && (m = g.value(y), t.has(m) || t.set(m, t.size));
      }
    }
  }
  return t;
}
var tae = { name: "polymer-id", label: "Polymer Chain Id", category: "Chain Property", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    var i = lt.create(t.structure), o = TE(t.structure.root), s = Array.from(o.keys()), u = Bu(o.size, r, { valueLabel: function(c) {
      return s[c];
    } });
    a = u.legend, n = function(c) {
      var l = void 0;
      if (lt.is(c)) {
        var d = IE(c.unit);
        l = o.get(d(c));
      } else Pt.isLocation(c) && (d = IE(c.aUnit), i.unit = c.aUnit, i.element = c.aUnit.elements[c.aIndex], l = o.get(d(i)));
      return l === void 0 ? DE : u.color(l);
    };
  } else n = function() {
    return DE;
  };
  return { factory: e, granularity: "group", color: n, props: r, description: "Gives every polymer chain a color based on its `asym_id` value.", legend: a };
}, getParams: function(e) {
  var t = V.clone(ME);
  return e.structure && TE(e.structure.root).size > Uo[P6].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = k(k({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: ul(P6).list } })), t;
}, defaultValues: V.getDefaultValues(ME), isApplicable: function(e) {
  return !!e.structure;
} }, B6 = "dark-2", NE = Qe(13421772), PE = k({}, xs({ type: "colors", colorList: B6 }));
function BE(e) {
  for (var t = 0, r = e.units, n = 0, a = r.length; n < a; ++n) r[n].polymerElements.length > 0 && ++t;
  return t;
}
var rae = { name: "polymer-index", label: "Polymer Chain Instance", category: "Chain Property", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    var i = Bu(BE(t.structure.root), r);
    a = i.legend;
    for (var o = t.structure.root.units, s = /* @__PURE__ */ new Map(), u = 0, c = 0, l = o.length; u < l; ++u) o[u].polymerElements.length > 0 && (s.set(o[u].id, i.color(c)), ++c);
    n = function(d) {
      var f;
      return lt.is(d) ? f = s.get(d.unit.id) : Pt.isLocation(d) && (f = s.get(d.aUnit.id)), f !== void 0 ? f : NE;
    };
  } else n = function() {
    return NE;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.", legend: a };
}, getParams: function(e) {
  var t = V.clone(PE);
  return e.structure && BE(e.structure.root) > Uo[B6].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = k(k({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: ul(B6).list } })), t;
}, defaultValues: V.getDefaultValues(PE), isApplicable: function(e) {
  return !!e.structure;
} }, XR = { ALA: 9240460, ARG: 124, ASN: 16743536, ASP: 10485826, CYS: 16777072, GLN: 16731212, GLU: 6684672, GLY: 15658734, HIS: 7368959, ILE: 19456, LEU: 4546117, LYS: 4671416, MET: 12099650, PHE: 5459026, PRO: 5395026, SER: 16740418, THR: 12078080, TRP: 5195264, TYR: 9203788, VAL: 16747775, A: 14423100, G: 3329330, I: 10145074, C: 16766720, T: 4286945, U: 4251856, DA: 14423100, DG: 3329330, DI: 10145074, DC: 16766720, DT: 4286945, DU: 4251856, APN: 14423100, GPN: 3329330, CPN: 16766720, TPN: 4286945, MOL: 0 }, O6 = Qe(16711935), OE = { saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(1, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(XR)) }) };
function FE(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function RE(e, t) {
  var r = e.coarseElements.seq_id_begin.value(t);
  if (r === e.coarseElements.seq_id_end.value(t)) {
    var n = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
function vg(e, t) {
  var r = e[t];
  return r === void 0 ? O6 : r;
}
var nae = { name: "residue-name", label: "Residue Name", category: "Residue Property", factory: function e(t, r) {
  var n = cm(r.colors.name === "default" ? XR : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(a) {
    if (lt.is(a)) {
      if (Ke.isAtomic(a.unit)) {
        var i = FE(a.unit, a.element);
        return vg(n, i);
      }
      if (i = RE(a.unit, a.element)) return vg(n, i);
    } else if (Pt.isLocation(a)) {
      if (Ke.isAtomic(a.aUnit))
        return i = FE(a.aUnit, a.aUnit.elements[a.aIndex]), vg(n, i);
      if (i = RE(a.aUnit, a.aUnit.elements[a.aIndex])) return vg(n, i);
    }
    return O6;
  }, props: r, description: "Assigns a color to every residue according to its name.", legend: Pu(Object.keys(n).map(function(a) {
    return [a, n[a]];
  }).concat([["Unknown", O6]])) };
}, getParams: function(e) {
  return OE;
}, defaultValues: V.getDefaultValues(OE), isApplicable: function(e) {
  return !!e.structure;
} }, jR = { alphaHelix: 16711808, threeTenHelix: 10485888, piHelix: 6291584, betaTurn: 6324479, betaStrand: 16762880, coil: 16777215, bend: 6740169, turn: 45670, dna: 11403518, rna: 16580962, carbohydrate: 10921722 }, F6 = Qe(8421504), LE = { saturation: V.Numeric(-1, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(jR)) }) };
function kE(e, t, r, n) {
  var a = Er.create(0);
  if (n && Ke.isAtomic(t)) {
    var i = n.get(t.invariantId);
    i && (a = i.type[i.getIndex(t.residueIndex[r])]);
  }
  if (Er.is(a, 2)) return Er.is(a, 2048) ? e.threeTenHelix : Er.is(a, 32768) ? e.piHelix : e.alphaHelix;
  if (Er.is(a, 4)) return e.betaStrand;
  if (Er.is(a, 8)) return e.bend;
  if (Er.is(a, 16)) return e.turn;
  var o = XF(t, r);
  return o === 7 ? e.dna : o === 6 ? e.rna : o === 9 ? e.carbohydrate : o === 5 ? e.coil : F6;
}
var aae = { name: "secondary-structure", label: "Secondary Structure", category: "Residue Property", factory: function e(t, r) {
  var n = t.structure && Oi.get(t.structure), a = n ? d1(n.id, n.version) : -1, i = cm(r.colors.name === "default" ? jR : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(o) {
    return lt.is(o) ? kE(i, o.unit, o.element, n == null ? void 0 : n.value) : Pt.isLocation(o) ? kE(i, o.aUnit, o.aUnit.elements[o.aIndex], n == null ? void 0 : n.value) : F6;
  }, props: r, contextHash: a, description: "Assigns a color based on the type of secondary structure and basic molecule type.", legend: Pu(Object.keys(i).map(function(o) {
    return [o, i[o]];
  }).concat([["Other", F6]])) };
}, getParams: function(e) {
  return LE;
}, defaultValues: V.getDefaultValues(LE), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? Oi.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && Oi.ref(e.structure, !1);
} } }, iae = Qe(13421772), zE = { list: V.ColorList("turbo", { presetKind: "scale" }) };
function UE(e, t) {
  var r = e.model;
  switch (e.kind) {
    case 0:
      var n = r.atomicHierarchy.residueAtomSegments.index[t];
      return r.atomicHierarchy.residues.label_seq_id.value(n);
    case 1:
      return Math.round((r.coarseHierarchy.spheres.seq_id_begin.value(t) + r.coarseHierarchy.spheres.seq_id_end.value(t)) / 2);
    case 2:
      return Math.round((r.coarseHierarchy.gaussians.seq_id_begin.value(t) + r.coarseHierarchy.gaussians.seq_id_end.value(t)) / 2);
  }
}
function GE(e, t) {
  var r = e.model, n = "";
  switch (e.kind) {
    case 0:
      var a = r.atomicHierarchy.chainAtomSegments.index[t];
      n = r.atomicHierarchy.chains.label_entity_id.value(a);
      break;
    case 1:
      n = r.coarseHierarchy.spheres.entity_id.value(t);
      break;
    case 2:
      n = r.coarseHierarchy.gaussians.entity_id.value(t);
  }
  if (n === "") return 0;
  var i = r.entities.getEntityIndex(n);
  if (i === -1) return 0;
  var o = r.sequence.byEntityKey[i];
  return o === void 0 ? 0 : o.sequence.length;
}
var oae = { name: "sequence-id", label: "Sequence Id", category: "Residue Property", factory: function e(t, r) {
  var n = cc.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(a) {
    if (lt.is(a)) {
      var i = a.unit, o = a.element;
      if ((s = UE(i, o)) > 0 && (u = GE(i, o))) return n.setDomain(0, u - 1), n.color(s);
    } else if (Pt.isLocation(a)) {
      var s, u, c = a.aUnit, l = a.aIndex;
      if ((s = UE(c, c.elements[l])) > 0 && (u = GE(c, c.elements[l]))) return n.setDomain(0, u - 1), n.color(s);
    }
    return iae;
  }, props: r, description: "Gives every polymer residue a color based on its `seq_id` value.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return zE;
}, defaultValues: V.getDefaultValues(zE), isApplicable: function(e) {
  return !!e.structure;
} }, R6 = "dark-2", VE = Qe(13421772), qE = k({}, xs({ type: "colors", colorList: R6 })), sae = { name: "unit-index", label: "Chain Instance", category: "Chain Property", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    var i = t.structure.root.units, o = Bu(i.length, r);
    a = o.legend;
    for (var s = /* @__PURE__ */ new Map(), u = 0, c = i.length; u < c; ++u) s.set(i[u].id, o.color(u));
    n = function(l) {
      return lt.is(l) ? s.get(l.unit.id) : Pt.isLocation(l) ? s.get(l.aUnit.id) : VE;
    };
  } else n = function() {
    return VE;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Gives every chain instance (single chain or collection of single elements) a unique color based on the position (index) of the chain in the list of chains in the structure.", legend: a };
}, getParams: function(e) {
  var t = V.clone(qE);
  return e.structure && e.structure.root.units.length > Uo[R6].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = k(k({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: ul(R6).list } })), t;
}, defaultValues: V.getDefaultValues(qE), isApplicable: function(e) {
  return !!e.structure;
} }, uae = Qe(16777113), HE = { domain: V.Interval([0, 100]), list: V.ColorList("red-white-blue", { presetKind: "scale" }) };
function KE(e, t) {
  return Ke.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) : Ke.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] : 0;
}
var cae = { name: "uncertainty", label: "Uncertainty/Disorder", category: "Atom Property", factory: function e(t, r) {
  var n = cc.create({ reverse: !0, domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(a) {
    return lt.is(a) ? n.color(KE(a.unit, a.element)) : Pt.isLocation(a) ? n.color(KE(a.aUnit, a.aUnit.elements[a.aIndex])) : uae;
  }, props: r, description: "Assigns a color based on the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return HE;
}, defaultValues: V.getDefaultValues(HE), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, lae = Qe(15658734), XE = { style: V.MappedStatic("entity-id", { uniform: V.Group(cy), "chain-id": V.Group(om), "entity-id": V.Group(Kp), "entity-source": V.Group(Xp), "molecule-type": V.Group(N6) }), carbonLightness: V.Numeric(0.8, { min: -6, max: 6, step: 0.1 }) }, dae = { name: "illustrative", label: "Illustrative", category: "Miscellaneous", factory: function e(t, r) {
  var n = r.style.name === "uniform" ? Lh(0, r.style.params) : r.style.name === "chain-id" ? b3(t, r.style.params) : r.style.name === "entity-id" ? x3(t, r.style.params) : r.style.name === "entity-source" ? _3(t, r.style.params) : r.style.name === "molecule-type" ? L8(0, r.style.params) : Ja(r.style), a = n.color, i = n.legend;
  function o(s, u) {
    var c = a(s, !1);
    return u === "C" ? Qe.lighten(c, r.carbonLightness) : c;
  }
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(s) {
    if (lt.is(s) && Ke.isAtomic(s.unit)) {
      var u = s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);
      return o(s, u);
    }
    if (Pt.isLocation(s) && Ke.isAtomic(s.aUnit)) {
      var c = s.aUnit.elements[s.aIndex];
      return u = s.aUnit.model.atomicHierarchy.atoms.type_symbol.value(c), o(s, u);
    }
    return lae;
  }, props: r, description: "Assigns an illustrative color that gives every chain a color based on the choosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).", legend: i };
}, getParams: function(e) {
  return V.clone(XE);
}, defaultValues: V.getDefaultValues(XE), isApplicable: function(e) {
  return !!e.structure;
} }, jE = { list: V.ColorList("red-yellow-green", { presetKind: "scale" }), scale: V.Select("DGwif", [["DGwif", "DG water-membrane"], ["DGwoct", "DG water-octanol"], ["Oct-IF", "DG difference"]]) }, fae = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
function YE(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function WE(e, t) {
  var r = e.coarseElements.seq_id_begin.value(t);
  if (r === e.coarseElements.seq_id_end.value(t)) {
    var n = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
var mae = { name: "hydrophobicity", label: "Hydrophobicity", category: "Residue Property", factory: function e(t, r) {
  var n = fae[r.scale], a = 1 / 0, i = -1 / 0;
  for (var o in N4) {
    var s = N4[o][n];
    a = Math.min(a, s), i = Math.max(i, s);
  }
  var u = cc.create({ listOrName: r.list.colors, domain: [i, a], minLabel: "Hydrophilic", maxLabel: "Hydrophobic" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(c) {
    var l;
    return lt.is(c) ? l = Ke.isAtomic(c.unit) ? YE(c.unit, c.element) : WE(c.unit, c.element) : Pt.isLocation(c) && (l = Ke.isAtomic(c.aUnit) ? YE(c.aUnit, c.aUnit.elements[c.aIndex]) : WE(c.aUnit, c.aUnit.elements[c.aIndex])), u.color(l ? function(d, f) {
      var m = N4[d];
      return m === void 0 ? 0 : m[f];
    }(l, n) : 0);
  }, props: r, description: 'Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).', legend: u ? u.legend : void 0 };
}, getParams: function(e) {
  return jE;
}, defaultValues: V.getDefaultValues(jE), isApplicable: function(e) {
  return !!e.structure;
} }, ZE = Qe(13421772), QE = k({}, xs({ type: "colors", colorList: "purples" })), pae = { name: "model-index", label: "Model Index", category: "Chain Property", factory: function e(t, r) {
  var n, a, i, o;
  if (t.structure) {
    for (var s = t.structure.root.models, u = 0, c = 0, l = s; c < l.length; c++) {
      var d = l[c];
      u = Math.max(u, ((n = yn.TrajectoryInfo.get(d)) === null || n === void 0 ? void 0 : n.size) || 0);
    }
    var f = Bu(u, r);
    o = f.legend;
    for (var m = /* @__PURE__ */ new Map(), h = 0, p = s.length; h < p; ++h) {
      var g = ((a = yn.TrajectoryInfo.get(s[h])) === null || a === void 0 ? void 0 : a.index) || 0;
      m.set(g, f.color(g));
    }
    i = function(v) {
      return lt.is(v) ? m.get(yn.TrajectoryInfo.get(v.unit.model).index) : Pt.isLocation(v) ? m.get(yn.TrajectoryInfo.get(v.aUnit.model).index) : ZE;
    };
  } else i = function() {
    return ZE;
  };
  return { factory: e, granularity: "instance", color: i, props: r, description: "Gives every model a unique color based on the position (index) of the model in the list of models in the structure.", legend: o };
}, getParams: function(e) {
  return QE;
}, defaultValues: V.getDefaultValues(QE), isApplicable: function(e) {
  return !!e.structure && e.structure.elementCount > 0 && yn.TrajectoryInfo.get(e.structure.models[0]).size > 1;
} }, hae = Qe(13421772), $E = { domain: V.Interval([0, 1]), list: V.ColorList("purples", { presetKind: "scale" }) };
function JE(e, t) {
  return Ke.isAtomic(e) ? e.model.atomicConformation.occupancy.value(t) : 0;
}
var vae = { name: "occupancy", label: "Occupancy", category: "Atom Property", factory: function e(t, r) {
  var n = cc.create({ reverse: !1, domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(a) {
    return lt.is(a) ? n.color(JE(a.unit, a.element)) : Pt.isLocation(a) ? n.color(JE(a.aUnit, a.aUnit.elements[a.aIndex])) : hae;
  }, props: r, description: "Assigns a color based on the occupancy of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return $E;
}, defaultValues: V.getDefaultValues($E), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.occupancy.isDefined;
  });
} }, L6 = "dark-2", eD = Qe(13421772), tD = k({}, xs({ type: "colors", colorList: L6 })), B0 = 1e4;
function k6(e) {
  return e.map(function(t) {
    return "".concat(t + B0).padStart(5, "0");
  }).join("");
}
function z6(e) {
  var t = function(i, o) {
    return Math.abs(i) < o ? 0 : Math.floor(Math.log10(Math.abs(i))) + 1;
  }(B0, 0), r = parseInt(e.substr(0, t)), n = parseInt(e.substr(t, t)), a = parseInt(e.substr(t + t, t));
  return [r - B0, n - B0, a - B0];
}
function mx(e) {
  return e.map(function(t) {
    return t + 5;
  }).join("");
}
function rD(e) {
  for (var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), n = 0, a = e.units.length; n < a; ++n) {
    var i = k6(e.units[n].conformation.operator.hkl);
    r.add(i);
  }
  var o = Array.from(r.values()).sort();
  return o.forEach(function(s) {
    return t.set(s, t.size);
  }), { min: z6(o[0]), max: z6(o[o.length - 1]), map: t };
}
var dl, gae = { name: "operator-hkl", label: "Operator HKL", category: "Symmetry", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    var i = rD(t.structure.root), o = i.min, s = i.max, u = i.map, c = [];
    u.forEach(function(f, m) {
      var h = f % u.size, p = mx(z6(m));
      c[h] === void 0 ? c[h] = p : c[h] += ", ".concat(p);
    });
    var l = { minLabel: mx(o), maxLabel: mx(s), valueLabel: function(f) {
      return c[f];
    } }, d = Bu(u.size, r, l);
    a = d.legend, n = function(f) {
      var m = void 0;
      if (lt.is(f)) {
        var h = k6(f.unit.conformation.operator.hkl);
        m = u.get(h);
      } else Pt.isLocation(f) && (h = k6(f.aUnit.conformation.operator.hkl), m = u.get(h));
      return m === void 0 ? eD : d.color(m);
    };
  } else n = function() {
    return eD;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Assigns a color based on the operator HKL value of a transformed chain.", legend: a };
}, getParams: function(e) {
  var t = V.clone(tD);
  return e.structure && rD(e.structure.root).map.size > Uo[L6].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = k(k({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: ul(L6).list } })), t;
}, defaultValues: V.getDefaultValues(tD), isApplicable: function(e) {
  return !!e.structure;
} };
(function(e) {
  e.Descriptor = { name: "atom_partial_charge" }, e.Provider = ic.create(e.Descriptor);
})(dl || (dl = {}));
var px = Qe(16777113), nD = { domain: V.Interval([-1, 1]), list: V.ColorList("red-white-blue", { presetKind: "scale" }) };
function aD(e, t) {
  var r;
  return (r = dl.Provider.get(e.model)) === null || r === void 0 ? void 0 : r.data.value(t);
}
var yae = { name: "partial-charge", label: "Partial Charge", category: "Atom Property", factory: function e(t, r) {
  var n = cc.create({ domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(a) {
    var i;
    return lt.is(a) ? (i = aD(a.unit, a.element)) === void 0 || Number.isNaN(i) ? px : n.color(i) : Pt.isLocation(a) ? (i = aD(a.aUnit, a.aUnit.elements[a.aIndex])) === void 0 || Number.isNaN(i) ? px : n.color(i) : px;
  }, props: r, description: "Assigns a color based on the partial charge of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return nD;
}, defaultValues: V.getDefaultValues(nD), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return dl.Provider.get(t) !== void 0;
  });
} }, iD = Qe(16448250), oD = k({}, xs({ type: "colors", colorList: "many-distinct" })), bae = { name: "atom-id", label: "Atom Id", category: "Atom Property", factory: function e(t, r) {
  var n, a;
  if (t.structure) {
    var i = lt.create(t.structure.root), o = function(c) {
      for (var l = /* @__PURE__ */ new Map(), d = 0, f = c.models; d < f.length; d++) for (var m = f[d].atomicHierarchy.atoms.label_atom_id, h = 0, p = m.rowCount; h < p; ++h) {
        var g = m.value(h);
        l.has(g) || l.set(g, l.size);
      }
      return l;
    }(t.structure.root), s = Array.from(o.keys()), u = Bu(o.size, r, { valueLabel: function(c) {
      return s[c];
    } });
    a = u.legend, n = function(c) {
      var l = void 0;
      if (lt.is(c)) {
        var d = at.atom.label_atom_id(c);
        l = o.get(d);
      } else Pt.isLocation(c) && (i.unit = c.aUnit, i.element = c.aUnit.elements[c.aIndex], d = at.atom.label_atom_id(i), l = o.get(d));
      return l === void 0 ? iD : u.color(l);
    };
  } else n = function() {
    return iD;
  };
  return { factory: e, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Gives every atom a color based on its `label_atom_id` value.", legend: a };
}, getParams: function(e) {
  return V.clone(oD);
}, defaultValues: V.getDefaultValues(oD), isApplicable: function(e) {
  return !!e.structure;
} }, xae = Qe(13421772), sD = { colorList: V.ColorList({ kind: "interpolate", colors: [[$t.white, 0], [$t.red, 0.25], [$t.white, 0.5], [$t.blue, 0.75], [$t.white, 1]] }, { offsets: !0, isEssential: !0 }) }, _ae = { name: "volume-value", label: "Volume Value", category: "Miscellaneous", factory: function e(t, r) {
  for (var n = cc.create({ domain: [0, 1], listOrName: r.colorList.colors }), a = [], i = 0; i < 256; ++i) a[i] = n.color(i / 255);
  var o = { colors: a, filter: "linear" };
  return { factory: e, granularity: "direct", color: function() {
    return xae;
  }, props: r, description: "Assign color based on the given value of a volume cell.", legend: n.legend, palette: o };
}, getParams: function(e) {
  return sD;
}, defaultValues: V.getDefaultValues(sD), isApplicable: function(e) {
  return !!e.volume;
} }, Sae = Qe(13421772), uD = { list: V.ColorList("turbo", { presetKind: "scale" }) }, Aae = { name: "uni-fold", label: "Uni-Fold", category: "Residue Property", factory: function e(t, r) {
  var n = cc.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", color: function(a) {
    if (lt.is(a)) {
      if (Ke.isAtomic(a.unit)) {
        if ((i = a.unit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(a.element)) >= 90) return Qe.fromRgb(148, 164, 239);
        if (i < 90 && i >= 70) return Qe.fromRgb(148, 225, 239);
        if (i < 70 && i >= 50) return Qe.fromRgb(240, 193, 145);
        if (i < 50) return Qe.fromRgb(239, 156, 156);
      }
    } else if (Pt.isLocation(a) && Ke.isAtomic(a.aUnit)) {
      var i;
      if ((i = a.aUnit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(a.aUnit.elements[a.aIndex])) >= 90) return Qe.fromRgb(148, 164, 239);
      if (i < 90 && i >= 70) return Qe.fromRgb(148, 225, 239);
      if (i < 70 && i >= 50) return Qe.fromRgb(240, 193, 145);
      if (i < 50) return Qe.fromRgb(239, 156, 156);
    }
    return Sae;
  }, props: r, description: "Fold", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return uD;
}, defaultValues: V.getDefaultValues(uD), isApplicable: function(e) {
  return !!e.structure;
} }, YR = { H: 16777215, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 3166456, O: 16715021, F: 9494608, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 16744448, S: 16777008, CL: 2093087, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 10889513, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, wae = Qe(16777215), cD = { carbonColor: V.MappedStatic("chain-id", { "chain-id": V.Group(om), "entity-id": V.Group(Kp), "entity-source": V.Group(Xp), "operator-name": V.Group(Hp), "element-symbol": V.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(YR)) }) }, Cae = { name: "cdr", label: "CDR", category: "Atom Property", factory: function e(t, r) {
  var n = cm(r.colors.name === "default" ? YR : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(a) {
    if (lt.is(a)) {
      if (Ke.isAtomic(a.unit)) {
        var i = a.unit.model.atomicHierarchy.atoms.cdr, o = a.unit.model.atomicHierarchy.chains.auth_asym_id, s = i.value(a.element), u = o.value(a.unit.chainIndex[a.element]);
        return s !== 0 ? s === 3 && u.toLocaleUpperCase() === "H" ? Qe.fromRgb(252, 180, 91) : Qe.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? Qe.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? Qe.fromRgb(148, 223, 247) : Qe(16777215);
      }
    } else if (Pt.isLocation(a) && Ke.isAtomic(a.aUnit))
      return i = a.aUnit.model.atomicHierarchy.atoms.cdr, o = a.aUnit.model.atomicHierarchy.chains.auth_asym_id, s = i.value(a.aUnit.elements[a.aIndex]), u = o.value(a.aUnit.chainIndex[a.aIndex]), s !== 0 ? s === 3 && u.toLocaleUpperCase() === "H" ? Qe.fromRgb(252, 180, 91) : Qe.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? Qe.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? Qe.fromRgb(148, 223, 247) : Qe(16777215);
    return wae;
  }, props: r, description: "CDR", legend: Pu(Object.keys(n).map(function(a) {
    return [a, n[a]];
  })) };
}, getParams: function(e) {
  return cD;
}, defaultValues: V.getDefaultValues(cD), isApplicable: function(e) {
  return !!e.structure;
} }, lD = Qe(16448250), dD = k({ themes: V.Value([]) }, xs({ type: "colors", colorList: "many-distinct" })), Eae = { name: "multi-theme", label: "Multi Theme", category: "Atom Property", factory: function e(t, r) {
  var n, a = r.themes;
  return n = t.structure ? function(i, o) {
    if (lt.is(i)) for (var s = 0; s < a.length; s++) {
      var u = a[s];
      if ((c = vo.toStructure(u.bundle, t.structure)).hasElement(i)) return u.colorTheme.color(i, o);
    }
    else if (Pt.isLocation(i) && Ke.isAtomic(i.aUnit)) for (s = 0; s < a.length; s++) {
      u = a[s];
      var c = vo.toStructure(u.bundle, t.structure), l = lt.create(i.aStructure, i.aUnit, i.aUnit.elements[i.aIndex]);
      if (c.hasElement(l)) return u.colorTheme.color(i, o);
    }
    return lD;
  } : function() {
    return lD;
  }, { factory: e, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Structure allows multi theme based on location" };
}, getParams: function(e) {
  return V.clone(dD);
}, defaultValues: V.getDefaultValues(dD), isApplicable: function(e) {
  return !!e.structure;
} }, WR = { H: 16777215, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 3166456, O: 16715021, F: 9494608, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 16744448, S: 16777008, CL: 2093087, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 10889513, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, Dae = Qe(16777215), fD = { carbonColor: V.MappedStatic("chain-id", { "chain-id": V.Group(om), "entity-id": V.Group(Kp), "entity-source": V.Group(Xp), "operator-name": V.Group(Hp), "element-symbol": V.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: V.MappedStatic("default", { default: V.EmptyGroup(), custom: V.Group(y1(WR)) }) }, Mae = { name: "em-confidence", label: "EM Confidence", category: "Residue Property", factory: function e(t, r) {
  var n = cm(r.colors.name === "default" ? WR : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(a) {
    if (lt.is(a)) {
      if (Ke.isAtomic(a.unit)) {
        var i = a.unit.model.atomicHierarchy.atoms.em_confidence;
        switch (!0) {
          case (o = parseFloat(i.value(a.element))) < -1:
            return Qe.fromRgb(239, 139, 139);
          case (o >= -1 && o < -0.8):
            return Qe.fromRgb(239, 151, 139);
          case (o >= -0.8 && o < -0.6):
            return Qe.fromRgb(239, 167, 138);
          case (o >= -0.6 && o < -0.4):
            return Qe.fromRgb(239, 190, 136);
          case (o >= -0.4 && o < -0.2):
            return Qe.fromRgb(239, 214, 136);
          case (o >= -0.2 && o < 0):
            return Qe.fromRgb(239, 236, 135);
          case (o >= 0 && o < 0.2):
            return Qe.fromRgb(134, 239, 134);
          case (o >= 0.2 && o < 0.4):
            return Qe.fromRgb(134, 239, 227);
          case (o >= 0.4 && o < 0.6):
            return Qe.fromRgb(134, 224, 239);
          case (o >= 0.6 && o < 0.8):
            return Qe.fromRgb(134, 200, 239);
          case (o >= 0.8 && o <= 1):
            return Qe.fromRgb(133, 175, 239);
          case o > 1:
            return Qe.fromRgb(134, 153, 239);
          default:
            return Qe(16777215);
        }
      }
    } else if (Pt.isLocation(a) && Ke.isAtomic(a.aUnit)) {
      var o;
      switch (i = a.aUnit.model.atomicHierarchy.atoms.em_confidence, !0) {
        case (o = parseFloat(i.value(a.aUnit.elements[a.aIndex]))) < -1:
          return Qe.fromRgb(239, 139, 139);
        case (o >= -1 && o < -0.8):
          return Qe.fromRgb(239, 151, 139);
        case (o >= -0.8 && o < -0.6):
          return Qe.fromRgb(239, 167, 138);
        case (o >= -0.6 && o < -0.4):
          return Qe.fromRgb(239, 190, 136);
        case (o >= -0.4 && o < -0.2):
          return Qe.fromRgb(239, 214, 136);
        case (o >= -0.2 && o < 0):
          return Qe.fromRgb(239, 236, 135);
        case (o >= 0 && o < 0.2):
          return Qe.fromRgb(134, 239, 134);
        case (o >= 0.2 && o < 0.4):
          return Qe.fromRgb(134, 239, 227);
        case (o >= 0.4 && o < 0.6):
          return Qe.fromRgb(134, 224, 239);
        case (o >= 0.6 && o < 0.8):
          return Qe.fromRgb(134, 200, 239);
        case (o >= 0.8 && o <= 1):
          return Qe.fromRgb(133, 175, 239);
        case o > 1:
          return Qe.fromRgb(134, 153, 239);
        default:
          return Qe(16777215);
      }
    }
    return Dae;
  }, props: r, description: "EM", legend: Pu(Object.keys(n).map(function(a) {
    return [a, n[a]];
  })) };
}, getParams: function(e) {
  return fD;
}, defaultValues: V.getDefaultValues(fD), isApplicable: function(e) {
  return !!e.structure;
} }, dy = { AC: 7384058, AG: 12632256, AL: 8499926, AM: 5528818, AR: 13631172, AS: 7655511, AT: 7688005, AU: 16765219, B: 2073103, BA: 51456, BE: 6215547, BH: 14680120, BI: 10375093, BK: 9064419, BR: 8270082, C: 5000268, CA: 5936829, CD: 16767375, CE: 16777159, CF: 10565332, CL: 3275778, CM: 7888099, CO: 175, CR: 158, CS: 5707663, CU: 2246620, DB: 13697103, DY: 2097095, ER: 58997, ES: 11739092, EU: 6422471, F: 11581926, FE: 11890944, FM: 11739066, FR: 4325478, GA: 10412915, GD: 4587463, GE: 8285862, H: 16764108, HE: 16574670, HF: 5096191, HG: 12105936, HO: 65436, HS: 15073326, I: 9699476, IN: 10909043, IR: 1528967, K: 10559990, KR: 16433651, LA: 5948489, LI: 8839027, LR: 13041766, LU: 43812, MD: 11734438, MG: 16481045, MN: 10946717, MO: 5551541, MT: 15400998, N: 11581926, NA: 16374844, NB: 7586505, ND: 13107143, NE: 16660405, NI: 12041149, NO: 12389767, NP: 33023, O: 16646912, OS: 2516630, P: 12623042, PA: 41471, PB: 5724513, PD: 27013, PM: 10747847, PO: 11230208, PR: 14286791, PT: 13684960, PU: 27647, RA: 32e3, RB: 7351984, RE: 2522539, RF: 13369433, RH: 687500, RN: 4358806, RU: 2396047, S: 16775680, SB: 10380213, SC: 11887531, SE: 10153743, SG: 14221381, SI: 1784826, SM: 9437127, SN: 10129081, SR: 65280, TA: 5089023, TB: 3211207, TC: 3907230, TE: 13924864, TH: 47871, TI: 7916287, TL: 10900557, TM: 54354, U: 36863, V: 15014144, W: 2200790, XE: 4366e3, Y: 9764863, YB: 48952, ZN: 9408385, ZR: 65280 }, fy = window.materialColors, mD = function() {
  Object.keys(fy.settings).forEach(function(e) {
    dy[e] = fy.getColorNumber(e);
  });
};
fy && (mD(), fy.setColorsSubject.subscribe(function() {
  mD();
}));
var hx = dy, pD = Qe(16777215), ZR = { carbonColor: V.MappedStatic("chain-id", { "chain-id": V.Group(k({}, om)), "operator-name": V.Group(k({}, Hp)), "element-symbol": V.Group({}) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: V.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: V.Numeric(0.2, { min: -6, max: 6, step: 0.1 }) };
function Iae(e) {
  return ZR;
}
function QR(e, t) {
  var r = cm(hx, t.saturation, t.lightness);
  function n(a, i) {
    return function(o, s) {
      var u = o[s];
      return u === void 0 ? pD : u;
    }(r, a);
  }
  return { factory: QR, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(a) {
    if (lt.is(a)) {
      if (Ke.isAtomic(a.unit)) return n(a.unit.model.atomicHierarchy.atoms.type_symbol.value(a.element));
    } else if (Pt.isLocation(a) && Ke.isAtomic(a.aUnit))
      return n(a.aUnit.model.atomicHierarchy.atoms.type_symbol.value(a.aUnit.elements[a.aIndex]));
    return pD;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: Pu(Object.keys(hx).map(function(a) {
    return [a, hx[a]];
  })) };
}
var fl, Et, qr, Tae = { name: "material-element-symbol", label: "Material Element Symbol", category: "Atom Property", factory: QR, getParams: Iae, defaultValues: V.getDefaultValues(ZR), isApplicable: function(e) {
  return !!e.structure;
} };
function vx(e, t, r) {
  switch (r) {
    case Et.Highlight:
      e[t] |= 1;
      break;
    case Et.RemoveHighlight:
      e[t] &= -2;
      break;
    case Et.Select:
      e[t] |= 2;
      break;
    case Et.Deselect:
      e[t] &= -3;
      break;
    case Et.Toggle:
      e[t] ^= 2;
      break;
    case Et.Clear:
      e[t] = 0;
  }
}
function U6(e, t, r) {
  if (r === Et.None) return !1;
  if (Fe.is(t)) {
    var n = Fe.start(t), a = Fe.end(t), i = n + 3 >> 2, o = i + (a - 4 * i >> 2);
    if (o <= i) {
      for (var s = n; s < a; ++s) vx(e, s, r);
      return !0;
    }
    var u = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), c = n, l = Math.min(4 * i, a), d = Math.max(n, 4 * o), f = a;
    switch (r) {
      case Et.Highlight:
        for (s = i; s < o; ++s) u[s] |= 16843009;
        break;
      case Et.RemoveHighlight:
        for (s = i; s < o; ++s) u[s] &= -16843010;
        break;
      case Et.Select:
        for (s = i; s < o; ++s) u[s] |= 33686018;
        break;
      case Et.Deselect:
        for (s = i; s < o; ++s) u[s] &= -33686019;
        break;
      case Et.Toggle:
        for (s = i; s < o; ++s) u[s] ^= 33686018;
        break;
      case Et.Clear:
        for (s = i; s < o; ++s) u[s] = 0;
        break;
      default:
        Ja();
    }
    for (s = c; s < l; ++s) vx(e, s, r);
    for (s = d; s < f; ++s) vx(e, s, r);
  } else switch (r) {
    case Et.Highlight:
      s = 0;
      for (var m = t.length; s < m; ++s) e[t[s]] |= 1;
      break;
    case Et.RemoveHighlight:
      for (s = 0, m = t.length; s < m; ++s) e[t[s]] &= -2;
      break;
    case Et.Select:
      for (s = 0, m = t.length; s < m; ++s) e[t[s]] |= 2;
      break;
    case Et.Deselect:
      for (s = 0, m = t.length; s < m; ++s) e[t[s]] &= -3;
      break;
    case Et.Toggle:
      for (s = 0, m = t.length; s < m; ++s) e[t[s]] ^= 2;
      break;
    case Et.Clear:
      for (s = 0, m = t.length; s < m; ++s) e[t[s]] = 0;
      break;
    default:
      Ja();
  }
  return !0;
}
(function(e) {
  e.PaletteScale = 16777215, e.EmptyFactory = function() {
    return e.Empty;
  };
  var t = Qe(13421772);
  e.Empty = { factory: e.EmptyFactory, granularity: "uniform", color: function() {
    return t;
  }, props: {} }, e.areEqual = function(r, n) {
    return r.contextHash === n.contextHash && r.factory === n.factory && Ud(r.props, n.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new FR(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { "atom-id": bae, "carbohydrate-symbol": Gre, "chain-id": Une, "element-index": Gne, "element-symbol": $ne, "material-element-symbol": Tae, "entity-id": Kne, "entity-source": Wne, hydrophobicity: mae, illustrative: dae, "model-index": pae, "molecule-type": eae, occupancy: vae, "operator-hkl": gae, "operator-name": qne, "partial-charge": yae, "polymer-id": tae, "polymer-index": rae, "residue-name": nae, "secondary-structure": aae, "sequence-id": oae, "shape-group": xne, uncertainty: cae, "unit-index": sae, uniform: qre, "volume-value": _ae, "uni-fold": Aae, cdr: Cae, "em-confidence": Mae, "multi-theme": Eae };
})(fl || (fl = {})), function(e) {
  e[e.None = 0] = "None", e[e.Highlight = 1] = "Highlight", e[e.RemoveHighlight = 2] = "RemoveHighlight", e[e.Select = 4] = "Select", e[e.Deselect = 8] = "Deselect", e[e.Toggle = 16] = "Toggle", e[e.Clear = 32] = "Clear";
}(Et || (Et = {})), function(e) {
  e.is = Ti.has, e.All = Et.Highlight | Et.RemoveHighlight | Et.Select | Et.Deselect | Et.Toggle | Et.Clear, e.Highlighting = Et.Highlight | Et.RemoveHighlight | Et.Clear, e.Selecting = Et.Select | Et.Deselect | Et.Toggle | Et.Clear, e.isReverse = function(t, r) {
    return t === Et.Highlight && r === Et.RemoveHighlight || t === Et.RemoveHighlight && r === Et.Highlight || t === Et.Select && r === Et.Deselect || t === Et.Deselect && r === Et.Select || t === Et.Toggle && r === Et.Toggle;
  };
}(qr || (qr = {}));
var k8 = { kind: "every-loci" };
function Vo(e) {
  return !!e && e.kind === "every-loci";
}
var an, Tn = { kind: "empty-loci" };
function Ld(e) {
  return !!e && e.kind === "empty-loci";
}
function Z0(e) {
  return !!e && e.kind === "data-loci";
}
function Nae(e, t) {
  if (!e6(e.data, t.data) || e.tag !== t.tag || e.elements.length !== t.elements.length) return !1;
  for (var r = 0, n = e.elements.length; r < n; ++r) if (!e6(e.elements[r], t.elements[r])) return !1;
  return !0;
}
function Pae(e) {
  return e.elements.length === 0;
}
function z8(e, t, r, n, a) {
  return { kind: "data-loci", tag: e, data: t, elements: r, getBoundingSphere: n, getLabel: a };
}
function Bae(e) {
  return Object.keys(e).filter(function(t) {
    return !isNaN(t);
  }).map(function(t) {
    return +t;
  }).sort(function(t, r) {
    return t - r;
  }).map(function(t) {
    return e[t];
  });
}
function gx(e, t, r) {
  return e && e[t] !== void 0 ? e[t] : r;
}
function rt(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  return { kind: "alias", aliases: t, symbol: e };
}
function gg(e, t) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  return e.info.namespace = "molscript-macro", e.id = "molscript-macro.".concat(e.info.name), { kind: "macro", symbol: e, translate: t, aliases: nt([e.info.name], r, !0) };
}
function Oae(e) {
  return e.kind === "alias" || e.kind === "macro";
}
(function(e) {
  var t = new iu("98");
  function r(o, s) {
    var u;
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return s || (s = Ve()), o.kind === "structure-loci" ? Ve.copy(s, o.structure.boundary.sphere) : o.kind === "element-loci" ? Ve.copy(s, et.getBoundary(o).sphere) : o.kind === "bond-loci" ? Pt.getBoundingSphere(o, s) : o.kind === "shape-loci" ? Ve.copy(s, o.shape.geometry.boundingSphere) : o.kind === "group-loci" ? mo.getBoundingSphere(o, s) : o.kind === "data-loci" ? (u = o.getBoundingSphere) === null || u === void 0 ? void 0 : u.call(o, s) : o.kind === "volume-loci" ? dr.getBoundingSphere(o.volume, s) : o.kind === "isosurface-loci" ? dr.Isosurface.getBoundingSphere(o.volume, o.isoValue, s) : o.kind === "cell-loci" ? dr.Cell.getBoundingSphere(o.volume, o.indices, s) : void 0;
  }
  e.getBundleBoundingSphere = function(o) {
    var s = o.loci.map(function(m) {
      return r(m);
    }).filter(function(m) {
      return !!m;
    });
    t.reset();
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      t.includePositionRadius(l.center, l.radius);
    }
    t.finishedIncludeStep();
    for (var d = 0, f = s; d < f.length; d++)
      l = f[d], t.radiusPositionRadius(l.center, l.radius);
    return t.getSphere();
  }, e.areEqual = function(o, s) {
    return !(!Vo(o) || !Vo(s)) || !(!Ld(o) || !Ld(s)) || (Z0(o) && Z0(s) ? Nae(o, s) : st.isLoci(o) && st.isLoci(s) ? st.areLociEqual(o, s) : et.is(o) && et.is(s) ? et.areEqual(o, s) : Pt.isLoci(o) && Pt.isLoci(s) ? Pt.areLociEqual(o, s) : or.isLoci(o) && or.isLoci(s) ? or.areLociEqual(o, s) : mo.isLoci(o) && mo.isLoci(s) ? mo.areLociEqual(o, s) : dr.isLoci(o) && dr.isLoci(s) ? dr.areLociEqual(o, s) : dr.Isosurface.isLoci(o) && dr.Isosurface.isLoci(s) ? dr.Isosurface.areLociEqual(o, s) : !(!dr.Cell.isLoci(o) || !dr.Cell.isLoci(s)) && dr.Cell.areLociEqual(o, s));
  }, e.isEvery = function(o) {
    return !!o && o.kind === "every-loci";
  }, e.isEmpty = function(o) {
    return !Vo(o) && (!!Ld(o) || (Z0(o) ? Pae(o) : st.isLoci(o) ? st.isLociEmpty(o) : et.is(o) ? et.isEmpty(o) : Pt.isLoci(o) ? Pt.isLociEmpty(o) : or.isLoci(o) ? or.isLociEmpty(o) : mo.isLoci(o) ? mo.isLociEmpty(o) : dr.isLoci(o) ? dr.isLociEmpty(o) : dr.Isosurface.isLoci(o) ? dr.Isosurface.isLociEmpty(o) : !!dr.Cell.isLoci(o) && dr.Cell.isLociEmpty(o)));
  }, e.remap = function(o, s) {
    return s instanceof st && (et.is(o) ? o = et.remap(o, s) : st.isLoci(o) ? o = st.remapLoci(o, s) : Pt.isLoci(o) && (o = Pt.remapLoci(o, s))), o;
  }, e.getBoundingSphere = r;
  var n = Ve.zero();
  e.getCenter = function(o, s) {
    var u = r(o, n);
    return u ? D.copy(s || D(), u.center) : void 0;
  }, e.getPrincipalAxes = function(o) {
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return o.kind === "structure-loci" ? et.getPrincipalAxes(st.toStructureElementLoci(o.structure)) : o.kind === "element-loci" ? et.getPrincipalAxes(o) : void (o.kind !== "bond-loci" && o.kind !== "shape-loci" && o.kind !== "group-loci" && o.kind !== "data-loci" && o.kind !== "volume-loci" && o.kind !== "isosurface-loci" && o.kind);
  };
  var a = { element: function(o) {
    return o;
  }, residue: function(o) {
    return et.is(o) ? et.extendToWholeResidues(o, !0) : o;
  }, chain: function(o) {
    return et.is(o) ? et.extendToWholeChains(o) : o;
  }, entity: function(o) {
    return et.is(o) ? et.extendToWholeEntities(o) : o;
  }, model: function(o) {
    return et.is(o) ? et.extendToWholeModels(o) : o;
  }, operator: function(o) {
    return et.is(o) ? et.extendToWholeOperators(o) : o;
  }, structure: function(o) {
    return et.is(o) ? st.toStructureElementLoci(o.structure) : mo.isLoci(o) ? or.Loci(o.shape) : o;
  }, elementInstances: function(o) {
    return et.is(o) ? et.extendToAllInstances(o) : o;
  }, residueInstances: function(o) {
    return et.is(o) ? et.extendToAllInstances(et.extendToWholeResidues(o, !0)) : o;
  }, chainInstances: function(o) {
    return et.is(o) ? et.extendToAllInstances(et.extendToWholeChains(o)) : o;
  } };
  function i(o, s) {
    return a[s](o);
  }
  e.GranularityOptions = V.objectToOptions(a, function(o) {
    switch (o) {
      case "element":
        return "Atom/Coarse Element";
      case "elementInstances":
        return ["Atom/Coarse Element Instances", "With Symmetry"];
      case "structure":
        return "Structure/Shape";
      default:
        return o.indexOf("Instances") ? [ac(o), "With Symmetry"] : ac(o);
    }
  }), e.simpleGranularity = function(o) {
    return o.replace("Instances", "");
  }, e.applyGranularity = i, e.normalize = function(o, s, u) {
    return u === void 0 && (u = !1), (s !== "element" || u) && Pt.isLoci(o) && (o = Pt.toStructureElementLoci(o)), st.isLoci(o) && (o = st.toStructureElementLoci(o.structure)), et.is(o) && (o = et.remap(o, o.structure.root)), s && (o = i(o, s)), o;
  };
})(an || (an = {}));
var Fae = [["Core symbols", rt(we.core.type.bool, "bool"), rt(we.core.type.num, "num"), rt(we.core.type.str, "str"), rt(we.core.type.regex, "regex"), rt(we.core.type.list, "list"), rt(we.core.type.set, "set"), rt(we.core.type.compositeKey, "composite-key"), rt(we.core.logic.not, "not"), rt(we.core.logic.and, "and"), rt(we.core.logic.or, "or"), rt(we.core.ctrl.if, "if"), rt(we.core.ctrl.fn, "fn"), rt(we.core.ctrl.eval, "eval"), rt(we.core.math.add, "add", "+"), rt(we.core.math.sub, "sub", "-"), rt(we.core.math.mult, "mult", "*"), rt(we.core.math.div, "div", "/"), rt(we.core.math.pow, "pow", "**"), rt(we.core.math.mod, "mod"), rt(we.core.math.min, "min"), rt(we.core.math.max, "max"), rt(we.core.math.floor, "floor"), rt(we.core.math.ceil, "ceil"), rt(we.core.math.roundInt, "round"), rt(we.core.math.abs, "abs"), rt(we.core.math.sqrt, "sqrt"), rt(we.core.math.cbrt, "cbrt"), rt(we.core.math.sin, "sin"), rt(we.core.math.cos, "cos"), rt(we.core.math.tan, "tan"), rt(we.core.math.asin, "asin"), rt(we.core.math.acos, "acos"), rt(we.core.math.atan, "atan"), rt(we.core.math.sinh, "sinh"), rt(we.core.math.cosh, "cosh"), rt(we.core.math.tanh, "tanh"), rt(we.core.math.exp, "exp"), rt(we.core.math.log, "log"), rt(we.core.math.log10, "log10"), rt(we.core.math.atan2, "atan2"), rt(we.core.rel.eq, "eq", "="), rt(we.core.rel.neq, "neq", "!="), rt(we.core.rel.lt, "lt", "<"), rt(we.core.rel.lte, "lte", "<="), rt(we.core.rel.gr, "gr", ">"), rt(we.core.rel.gre, "gre", ">="), rt(we.core.rel.inRange, "in-range"), rt(we.core.str.concat, "concat"), rt(we.core.str.match, "regex.match"), rt(we.core.list.getAt, "list.get"), rt(we.core.set.has, "set.has"), rt(we.core.set.isSubset, "set.subset")], ["Structure", ["Types", rt(we.structureQuery.type.entityType, "ent-type"), rt(we.structureQuery.type.authResidueId, "auth-resid"), rt(we.structureQuery.type.labelResidueId, "label-resid"), rt(we.structureQuery.type.ringFingerprint, "ringfp"), rt(we.structureQuery.type.bondFlags, "bond-flags")], ["Slots", rt(we.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")], ["Generators", rt(we.structureQuery.generator.atomGroups, "sel.atom.atom-groups"), rt(we.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"), rt(we.structureQuery.generator.rings, "sel.atom.rings"), rt(we.structureQuery.generator.empty, "sel.atom.empty"), rt(we.structureQuery.generator.all, "sel.atom.all"), rt(we.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"), gg(E0("sel.atom.atoms", Dt.Dictionary({ 0: ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." }) }), bt.ElementSelection, "A selection of singleton atom sets."), function(e) {
  return zt.struct.generator.atomGroups({ "atom-test": gx(e, 0, !0) });
}), gg(E0("sel.atom.res", Dt.Dictionary({ 0: ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." }) }), bt.ElementSelection, "A selection of atom sets grouped by residue."), function(e) {
  return zt.struct.generator.atomGroups({ "residue-test": gx(e, 0, !0), "group-by": zt.ammp("residueKey") });
}), gg(E0("sel.atom.chains", Dt.Dictionary({ 0: ot(Oe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." }) }), bt.ElementSelection, "A selection of atom sets grouped by chain."), function(e) {
  return zt.struct.generator.atomGroups({ "chain-test": gx(e, 0, !0), "group-by": zt.ammp("chainKey") });
})], ["Modifiers", rt(we.structureQuery.modifier.queryEach, "sel.atom.query-each"), rt(we.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"), rt(we.structureQuery.modifier.exceptBy, "sel.atom.except-by"), rt(we.structureQuery.modifier.unionBy, "sel.atom.union-by"), rt(we.structureQuery.modifier.union, "sel.atom.union"), rt(we.structureQuery.modifier.cluster, "sel.atom.cluster"), rt(we.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"), rt(we.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"), rt(we.structureQuery.modifier.includeConnected, "sel.atom.include-connected"), rt(we.structureQuery.modifier.expandProperty, "sel.atom.expand-property")], ["Filters", rt(we.structureQuery.filter.pick, "sel.atom.pick"), rt(we.structureQuery.filter.first, "sel.atom.first"), rt(we.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"), rt(we.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"), rt(we.structureQuery.filter.within, "sel.atom.within"), rt(we.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")], ["Combinators", rt(we.structureQuery.combinator.intersect, "sel.atom.intersect"), rt(we.structureQuery.combinator.merge, "sel.atom.merge"), rt(we.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")], ["Atom Set Properties", rt(we.structureQuery.atomSet.atomCount, "atom.set.atom-count"), rt(we.structureQuery.atomSet.countQuery, "atom.set.count-query"), rt(we.structureQuery.atomSet.reduce, "atom.set.reduce"), rt(we.structureQuery.atomSet.propertySet, "atom.set.property")], ["Atom Properties", rt(we.structureQuery.atomProperty.core.elementSymbol, "atom.el"), rt(we.structureQuery.atomProperty.core.vdw, "atom.vdw"), rt(we.structureQuery.atomProperty.core.mass, "atom.mass"), rt(we.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"), rt(we.structureQuery.atomProperty.core.x, "atom.x"), rt(we.structureQuery.atomProperty.core.y, "atom.y"), rt(we.structureQuery.atomProperty.core.z, "atom.z"), rt(we.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"), rt(we.structureQuery.atomProperty.core.operatorName, "atom.op-name"), rt(we.structureQuery.atomProperty.core.modelIndex, "atom.model-index"), rt(we.structureQuery.atomProperty.core.modelLabel, "atom.model-label"), rt(we.structureQuery.atomProperty.core.atomKey, "atom.key"), rt(we.structureQuery.atomProperty.core.bondCount, "atom.bond-count"), rt(we.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"), rt(we.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"), rt(we.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"), rt(we.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"), rt(we.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"), rt(we.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"), rt(we.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"), rt(we.structureQuery.atomProperty.macromolecular.id, "atom.id"), rt(we.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"), rt(we.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"), rt(we.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"), rt(we.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"), rt(we.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"), rt(we.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"), rt(we.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"), rt(we.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"), rt(we.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"), rt(we.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"), rt(we.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"), rt(we.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"), rt(we.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"), rt(we.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"), rt(we.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"), rt(we.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"), rt(we.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"), rt(we.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"), rt(we.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"), rt(we.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"), rt(we.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"), rt(we.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"), rt(we.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent")], ["Bond Properties", rt(we.structureQuery.bondProperty.order, "bond.order"), rt(we.structureQuery.bondProperty.length, "bond.length"), rt(we.structureQuery.bondProperty.atomA, "bond.atom-a"), rt(we.structureQuery.bondProperty.atomB, "bond.atom-b"), gg(E0("bond.is", Dt.List(bt.BondFlag), Oe.Bool, "Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(Oe.oneOfValues(bt.BondFlag).join(", "))), function(e) {
  return zt.core.flags.hasAny([zt.struct.bondProperty.flags(), zt.struct.type.bondFlags(Bae(e))]);
})]]], $R = [];
(function e(t) {
  for (var r = 0, n = t; r < n.length; r++) {
    var a = n[r];
    Oae(a) ? $R.push(a) : a instanceof Array && e(a);
  }
})(Fae);
var Rae = function() {
  for (var e = [], t = /* @__PURE__ */ Object.create(null), r = Sn.create(), n = Sn.create(), a = 0, i = $R; a < i.length; a++) {
    for (var o = i[a], s = 0, u = o.aliases; s < u.length; s++) {
      var c = u[s];
      if (e.push([c, o]), t[c]) throw new Error("Alias '".concat(c, "' already in use."));
      t[c] = o;
    }
    var l = o.symbol.args;
    if (l.kind === "dictionary") for (var d = 0, f = Object.keys(l.map); d < f.length; d++) {
      c = f[d], isNaN(c) && Sn.add(r, c, c);
      var m = l.map[c];
      m.type.kind === "oneof" && Oe.oneOfValues(m.type).forEach(function(h) {
        return Sn.add(n, h, h);
      });
    }
    else l.type.kind === "oneof" && Oe.oneOfValues(l.type).forEach(function(h) {
      return Sn.add(n, h, h);
    });
  }
  return { symbolList: e, symbolMap: t, namedArgs: r.array, constants: n.array };
}(), Wm = Rae.symbolMap;
function O0(e) {
  if (mi.isLiteral(e)) return e;
  if (mi.isSymbol(e)) {
    if (!Wm[e.name]) return e;
    var t = Wm[e.name];
    if (t.kind === "alias") return mi.Symbol(Wm[e.name].symbol.id);
    throw t.translate([]);
  }
  var r = mi.isSymbol(e.head) && !!Wm[e.head.name] && Wm[e.head.name].kind === "macro", n = r ? e.head : O0(e.head), a = n !== e.head;
  if (!e.args) return r ? O0(e.head) : a ? mi.Apply(n) : e;
  var i, o = !1;
  if (mi.isArgumentsArray(e.args)) {
    i = [];
    for (var s = 0, u = e.args.length; s < u; s++)
      (d = e.args[s]) !== (f = O0(d)) && (o = !0), i[i.length] = f;
    if (o || (i = e.args), !r && !a && !o) return e;
  } else {
    i = {};
    for (var c = 0, l = Object.keys(e.args); c < l.length; c++) {
      var d, f, m = l[c];
      (d = e.args[m]) !== (f = O0(d)) && (o = !0), i[m] = f;
    }
    if (!r && !a && !o) return e;
    o || (i = e.args);
  }
  if (r) {
    var h = Wm[e.head.name];
    return h.kind !== "macro" ? mi.Apply(n, i) : h.translate(i);
  }
  return mi.Apply(n, i);
}
function Lae(e) {
  return O0(e);
}
var G6, vu = function() {
  function e(t) {
    this._ = t;
  }
  return e.prototype.parse = function(t) {
    var r = this.skip(e.eof)._(t, 0);
    return r.status ? { success: !0, value: r.value } : { success: !1, index: JR(t, r.furthest), expected: r.expected };
  }, e.prototype.tryParse = function(t) {
    var r = this.parse(t);
    if (r.success) return r.value;
    var n = function(a, i) {
      return "expected ".concat(function(o) {
        return o.length === 1 ? o[0] : "one of " + o.join(", ");
      }(i.expected)).concat(function(o, s) {
        var u = s.index, c = u.offset;
        if (c === o.length) return ", got the end of the input";
        var l = c > 0 ? "'..." : "'", d = o.length - c > 12 ? "...'" : "'";
        return " at line ".concat(u.line, " column ").concat(u.column, ", got ").concat(l).concat(o.slice(c, c + 12)).concat(d);
      }(a, i));
    }(t, r);
    throw new Error(n);
  }, e.prototype.or = function(t) {
    return e.alt(this, t);
  }, e.prototype.trim = function(t) {
    return this.wrap(t, t);
  }, e.prototype.wrap = function(t, r) {
    return yx(1, typeof t == "string" ? e.string(t) : t, this, typeof r == "string" ? e.string(r) : r);
  }, e.prototype.thru = function(t) {
    return t(this);
  }, e.prototype.then = function(t) {
    return yx(1, this, t);
  }, e.prototype.many = function() {
    var t = this;
    return new e(function(r, n) {
      for (var a = [], i = void 0; ; ) {
        if (!(i = Ys(t._(r, n), i)).status) return Ys(Vi(n, a), i);
        if (n === i.index) throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
        n = i.index, a.push(i.value);
      }
    });
  }, e.prototype.times = function(t, r) {
    var n = this, a = r === void 0 ? t : r;
    return new e(function(i, o) {
      var s, u = [], c = void 0, l = void 0;
      for (s = 0; s < t; s++) {
        if (l = Ys(c = n._(i, o), l), !c.status) return l;
        o = c.index, u.push(c.value);
      }
      for (; s < a && (l = Ys(c = n._(i, o), l), c.status); s += 1) o = c.index, u.push(c.value);
      return Ys(Vi(o, u), l);
    });
  }, e.prototype.result = function(t) {
    return this.map(function() {
      return t;
    });
  }, e.prototype.atMost = function(t) {
    return this.times(0, t);
  }, e.prototype.atLeast = function(t) {
    return e.seq(this.times(t), this.many()).map(function(r) {
      return nt(nt([], r[0], !0), r[1], !0);
    });
  }, e.prototype.map = function(t) {
    var r = this;
    return new e(function(n, a) {
      var i = r._(n, a);
      return i.status ? Ys(Vi(i.index, t(i.value)), i) : i;
    });
  }, e.prototype.skip = function(t) {
    return yx(0, this, t);
  }, e.prototype.mark = function() {
    return e.seq(e.index, this, e.index).map(function(t) {
      return { start: t[0], value: t[1], end: t[2] };
    });
  }, e.prototype.node = function(t) {
    return e.seq(e.index, this, e.index).map(function(r) {
      return { name: t, start: r[0], value: r[1], end: r[2] };
    });
  }, e.prototype.sepBy = function(t) {
    return e.sepBy(this, t);
  }, e.prototype.sepBy1 = function(t) {
    return e.sepBy1(this, t);
  }, e.prototype.lookahead = function(t) {
    return this.skip(e.lookahead(t));
  }, e.prototype.notFollowedBy = function(t) {
    return this.skip(e.notFollowedBy(t));
  }, e.prototype.desc = function(t) {
    var r = this;
    return new e(function(n, a) {
      var i = r._(n, a);
      return i.status || (i.expected = [t]), i;
    });
  }, e.prototype.fallback = function(t) {
    return this.or(e.succeed(t));
  }, e.prototype.ap = function(t) {
    return e.seq(t, this).map(function(r) {
      return (0, r[0])(r[1]);
    });
  }, e.prototype.chain = function(t) {
    var r = this;
    return new e(function(n, a) {
      var i = r._(n, a);
      return i.status ? Ys(t(i.value)._(n, i.index), i) : i;
    });
  }, e;
}();
function yx(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  var n = t.length;
  return new vu(function(a, i) {
    for (var o, s, u = i, c = 0; c < n; c++) {
      if (!(o = Ys(t[c]._(a, u), o)).status) return o;
      e === c && (s = o.value), u = o.index;
    }
    return Ys(Vi(u, s), o);
  });
}
function Vi(e, t) {
  return { status: !0, index: e, value: t };
}
function Lc(e, t) {
  return { status: !1, furthest: e, expected: [t] };
}
function Ys(e, t) {
  if (!t || e.status || t.status || e.furthest > t.furthest) return e;
  var r = e.furthest === t.furthest ? function(n, a) {
    var i = n.length, o = a.length;
    if (i === 0) return a;
    if (o === 0) return n;
    for (var s = /* @__PURE__ */ new Set(), u = [], c = 0; c < i; c++) s.has(n[c]) || (u[u.length] = n[c], s.add(n[c]));
    for (c = 0; c < o; c++) s.has(a[c]) || (u[u.length] = a[c], s.add(a[c]));
    return u.sort(), u;
  }(e.expected, t.expected) : t.expected;
  return { status: e.status, furthest: t.furthest, expected: r };
}
function JR(e, t) {
  var r = e.slice(0, t).split(`
`);
  return { offset: t, line: r.length, column: r[r.length - 1].length + 1 };
}
function kae(e) {
  return e instanceof vu;
}
(function(e) {
  function t() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    var d = c.length;
    return new e(function(f, m) {
      for (var h, p = new Array(d), g = m, v = 0; v < d; v++) {
        if (!(h = Ys(c[v]._(f, g), h)).status) return h;
        p[v] = h.value, g = h.index;
      }
      return Ys(Vi(g, p), h);
    });
  }
  function r() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    return c.length === 0 ? s("zero alternates") : new e(function(d, f) {
      for (var m, h = 0; h < c.length; h++) if ((m = Ys(c[h]._(d, f), m)).status) return m;
      return m;
    });
  }
  function n(c, l) {
    return t(c, l.then(c).many()).map(function(d) {
      return nt([d[0]], d[1], !0);
    });
  }
  function a(c) {
    var l = "'".concat(c, "'");
    if (c.length === 1) {
      var d = c.charCodeAt(0);
      return new e(function(f, m) {
        return f.charCodeAt(m) === d ? Vi(m + 1, c) : Lc(m, l);
      });
    }
    return new e(function(f, m) {
      var h = m + c.length;
      return f.slice(m, h) === c ? Vi(h, c) : Lc(m, l);
    });
  }
  function i(c, l) {
    l === void 0 && (l = 0);
    var d = function(m) {
      return RegExp("^(?:" + m.source + ")", function(h) {
        var p = "" + h;
        return p.slice(p.lastIndexOf("/") + 1);
      }(m));
    }(c), f = "" + c;
    return new e(function(m, h) {
      var p = d.exec(m.slice(h));
      if (p) {
        if (0 <= l && l <= p.length) {
          var g = p[0], v = p[l];
          return Vi(h + g.length, v);
        }
        return Lc(h, "invalid match group (0 to ".concat(p.length, ") in ").concat(f));
      }
      return Lc(h, f);
    });
  }
  function o(c) {
    return new e(function(l, d) {
      return Vi(d, c);
    });
  }
  function s(c) {
    return new e(function(l, d) {
      return Lc(d, c);
    });
  }
  function u(c) {
    return new e(function(l, d) {
      var f = l.charAt(d);
      return d < l.length && c(f) ? Vi(d + 1, f) : Lc(d, "a character " + c);
    });
  }
  e.seq = t, e.alt = r, e.sepBy = function(c, l) {
    return n(c, l).or(o([]));
  }, e.sepBy1 = n, e.string = a, e.regexp = i, e.succeed = o, e.fail = s, e.lookahead = function c(l) {
    if (kae(l)) return new e(function(d, f) {
      var m = l._(d, f);
      return m.status && (m.index = f, m.value = null), m;
    });
    if (typeof l == "string") return c(a(l));
    if (l instanceof RegExp) return c(i(l));
    throw new Error("not a string, regexp, or parser: " + l);
  }, e.notFollowedBy = function(c) {
    return new e(function(l, d) {
      var f = c._(l, d);
      return f.status ? Lc(d, 'not "' + l.slice(d, f.index) + '"') : Vi(d, null);
    });
  }, e.test = u, e.oneOf = function(c) {
    return u(function(l) {
      return c.indexOf(l) >= 0;
    });
  }, e.noneOf = function(c) {
    return u(function(l) {
      return c.indexOf(l) < 0;
    });
  }, e.range = function(c, l) {
    return u(function(d) {
      return c <= d && d <= l;
    }).desc(c + "-" + l);
  }, e.takeWhile = function(c) {
    return new e(function(l, d) {
      for (var f = d; f < l.length && c(l.charAt(f)); ) f++;
      return Vi(f, l.slice(d, f));
    });
  }, e.lazy = function(c) {
    var l = new e(function(d, f) {
      var m = c()._;
      return l._ = m, m(d, f);
    });
    return l;
  }, e.empty = function() {
    return s("empty");
  }, e.index = new e(function(c, l) {
    return Vi(l, JR(c, l));
  }), e.anyChar = new e(function(c, l) {
    return l >= c.length ? Lc(l, "any character") : Vi(l + 1, c.charAt(l));
  }), e.all = new e(function(c, l) {
    return Vi(c.length, c.slice(l));
  }), e.eof = new e(function(c, l) {
    return l < c.length ? Lc(l, "EOF") : Vi(l, null);
  }), e.digit = i(/[0-9]/).desc("a digit"), e.digits = i(/[0-9]*/).desc("optional digits"), e.letter = i(/[a-z]/i).desc("a letter"), e.letters = i(/[a-z]*/i).desc("optional letters"), e.optWhitespace = i(/\s*/).desc("optional whitespace"), e.whitespace = i(/\s+/).desc("whitespace"), e.cr = a("\r"), e.lf = a(`
`), e.crlf = a(`\r
`), e.newline = r(e.crlf, e.lf, e.cr).desc("newline"), e.end = r(e.newline, e.eof);
})(vu || (vu = {})), function(e) {
  var t;
  (function(p) {
    p.str = function(g) {
      return { kind: "string", value: g };
    }, p.symb = function(g) {
      return { kind: "symbol", value: g };
    }, p.list = function(g, v) {
      return { kind: "list", bracket: g, nodes: v };
    }, p.comment = function(g) {
      return { kind: "comment", value: g };
    };
  })(t || (t = {}));
  var r = vu.regexp(/[\n\r\s]*/), n = vu.lazy(function() {
    return vu.alt(a, d, i, o).trim(r);
  }), a = vu.takeWhile(function(p) {
    return p !== "`";
  }).trim("`").map(t.str), i = vu.regexp(/[^()\[\]{};`,\n\r\s]+/).map(t.symb), o = vu.regexp(/\s*;+([^\n\r]*)\n/, 1).map(t.comment), s = n.many(), u = s.wrap("(", ")").map(function(p) {
    return t.list("(", p);
  }), c = s.wrap("[", "]").map(function(p) {
    return t.list("[", p);
  }), l = s.wrap("{", "}").map(function(p) {
    return t.list("{", p);
  }), d = vu.alt(u, c, l), f = n.many();
  function m(p) {
    switch (p.kind) {
      case "string":
        return p.value;
      case "symbol":
        var g = p.value;
        if (g.length > 1) switch (g.charAt(0)) {
          case ".":
            return zt.atomName(g.substr(1));
          case "_":
            return zt.struct.type.elementSymbol([g.substr(1)]);
        }
        return g === "true" || g !== "false" && (function(y) {
          return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(y) && !isNaN(+y);
        }(g) ? +g : mi.Symbol(g));
      case "list":
        switch (p.bracket) {
          case "[":
            return zt.core.type.list(h(p.nodes).map(m));
          case "{":
            return zt.core.type.set(h(p.nodes).map(m));
          case "(":
            if (p.nodes[0].kind === "comment") throw new Error("Invalid expression");
            var v = m(p.nodes[0]);
            return mi.Apply(v, function(y) {
              if (!(y.length <= 1)) {
                if (!function(P) {
                  for (var O = 1, F = P.length; O < F; O++) {
                    var R = P[O];
                    if (R.kind === "symbol" && R.value.length > 1 && R.value.charAt(0) === ":") return !0;
                  }
                  return !1;
                }(y)) {
                  for (var _ = [], S = 1, b = y.length; S < b; S++)
                    (C = y[S]).kind !== "comment" && (_[_.length] = m(C));
                  return _;
                }
                var x = {}, A = !0, w = 0;
                for (S = 1, b = y.length; S < b; S++) {
                  var C;
                  if ((C = y[S]).kind !== "comment") if (C.kind === "symbol" && C.value.length > 1 && C.value.charAt(0) === ":") {
                    var M = C.value.substr(1);
                    for (++S; S < b && y[S].kind === "comment"; ) S++;
                    if (S >= b) throw new Error("There must be a value foolowed a named arg ':".concat(M, "'."));
                    if (y[S].kind === "comment") throw new Error("Invalid expression");
                    x[M] = m(y[S]), isNaN(+M) && (A = !1);
                  } else x[w++] = m(C);
                }
                if (A) {
                  var T = Object.keys(x).map(function(P) {
                    return +P;
                  }).sort(function(P, O) {
                    return P - O;
                  }), N = !0;
                  for (S = 0, b = T.length; S < b; S++) if (T[S] !== S) {
                    N = !1;
                    break;
                  }
                  if (N) {
                    var I = [];
                    for (S = 0, b = T.length; S < b; S++) I[S] = x[S];
                    return I;
                  }
                }
                return x;
              }
            }(p.nodes));
          default:
            Ja(p.bracket);
        }
      default:
        Ja();
    }
  }
  function h(p) {
    for (var g = !1, v = 0, y = p.length; v < y; v++) if (p[v].kind === "comment") {
      g = !0;
      break;
    }
    return g ? p.filter(function(_) {
      return _.kind !== "comment";
    }) : p;
  }
  e.parse = function(p) {
    for (var g = function(b) {
      return f.tryParse(b);
    }(p), v = [], y = 0, _ = g; y < _.length; y++) {
      var S = _[y];
      S.kind !== "comment" && (v[v.length] = m(S));
    }
    return v;
  };
}(G6 || (G6 = {}));
var hD, jp, Q0, my, zae = function() {
  function e() {
    this.map = /* @__PURE__ */ new Map();
  }
  return e.prototype.removeSymbol = function(t) {
    this.map.delete(t.symbol.id);
  }, e.prototype.addSymbol = function(t) {
    this.map.has(t.symbol.id) && console.warn("Symbol '".concat(t.symbol.id, "' already added. Call removeSymbol/removeCustomProps re-adding the symbol.")), this.map.set(t.symbol.id, t);
  }, e.prototype.addCustomProp = function(t) {
    if (t.symbols) for (var r = 0, n = Object.keys(t.symbols); r < n.length; r++) {
      var a = n[r];
      this.addSymbol(t.symbols[a]);
    }
  }, e.prototype.removeCustomProp = function(t) {
    if (t.symbols) for (var r = 0, n = Object.keys(t.symbols); r < n.length; r++) {
      var a = n[r];
      this.removeSymbol(t.symbols[a]);
    }
  }, e.prototype.getRuntime = function(t) {
    return this.map.get(t);
  }, e;
}(), eL = new zae(), Uae = function(e) {
  this.table = e, this.constQueryContext = new tm(st.Empty);
};
(function(e) {
  e.Const = function(t) {
    return { kind: "const", value: t };
  }, e.Dynamic = function(t) {
    return { kind: "dynamic", runtime: t };
  };
})(hD || (hD = {})), function(e) {
  e.Const = function(t) {
    return { isConst: !0, fn: function(r) {
      return t;
    } };
  }, e.Dynamic = function(t) {
    return { isConst: !1, fn: t };
  };
}(jp || (jp = {})), function(e) {
  e.forEachEval = function(t, r, n, a) {
    if (typeof t.length == "number") for (var i = 0, o = t.length; i < o; i++) n(t[i](r), i, a);
    else {
      i = 0;
      for (var s = 0, u = Object.keys(t); s < u.length; s++)
        n(t[u[s]](r), i++, a);
    }
    return a;
  };
}(Q0 || (Q0 = {})), function(e) {
  e.Const = function(t, r) {
    return new vD(t, r, !0);
  }, e.Dynamic = function(t, r) {
    return new vD(t, r, !1);
  };
}(my || (my = {}));
var fc, vD = function() {
  function e(t, r, n) {
    this.symbol = t, this.fn = r, this.isConst = n;
  }
  return e.prototype.compile = function(t, r) {
    var n, a = !1;
    if (r) if (mi.isArgumentsArray(r)) {
      n = [], a = !0;
      for (var i = 0, o = r; i < o.length; i++) {
        var s = V6(t, o[i]);
        a = a && s.isConst, n.push(s.fn);
      }
    } else {
      n = /* @__PURE__ */ Object.create(null), a = !0;
      for (var u = 0, c = Object.keys(r); u < c.length; u++) {
        var l = c[u];
        s = V6(t, r[l]), a = a && s.isConst, n[l] = s.fn;
      }
    }
    else n = void 0, a = !0;
    return this.isConst && this.isConst && a ? jp.Const(this.fn(t.constQueryContext, n)) : jp.Dynamic(Gae(this.fn, n));
  }, e;
}();
function Gae(e, t) {
  return function(r) {
    return e(r, t);
  };
}
function V6(e, t) {
  if (mi.isLiteral(t)) return jp.Const(t);
  if (mi.isSymbol(t)) {
    var r = e.table.getRuntime(t.name);
    return r ? r.compile(e) : jp.Const(t.name);
  }
  if (!mi.isSymbol(t.head)) throw new Error("Can only apply symbols.");
  var n = e.table.getRuntime(t.head.name);
  if (!n) throw new Error("Symbol '".concat(t.head.name, "' is not implemented."));
  return n.compile(e, t.args);
}
function py(e) {
  return V6(new Uae(eL), e).fn;
}
function Dd(e, t) {
  return { expression: e, language: t };
}
function mh(e) {
  return { layers: e };
}
function ph(e, t) {
  return { kind: e, layers: t };
}
(function(e) {
  function t(n) {
    if (n.language === "mol-script") {
      var a = (i = n.expression, G6.parse(i));
      if (a.length === 0) throw new Error("No query");
      return Lae(a[0]);
    }
    var i;
    throw new Error("unsupported script language");
  }
  function r(n) {
    return py(t(n));
  }
  e.is = function(n) {
    return !!n && typeof n.expression == "string" && !!n.language;
  }, e.areEqual = function(n, a) {
    return n.language === a.language && n.expression === a.expression;
  }, e.toExpression = t, e.toQuery = r, e.toLoci = function(n, a) {
    var i = r(n)(new tm(a));
    return St.toLociWithSourceUnits(i);
  }, e.getStructureSelection = function(n, a, i) {
    return py(typeof n == "function" ? n(zt) : n)(new tm(a, i));
  };
})(Dd || (Dd = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var a = 0, i = r.layers.length; a < i; ++a)
      if (r.layers[a].clear !== n.layers[a].clear || r.layers[a].color !== n.layers[a].color || !an.areEqual(r.layers[a].loci, n.layers[a].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var a = [], i = 0, o = r.layers; i < o.length; i++) {
      var s = o[i], u = s.loci, c = s.color, l = s.clear;
      u = et.remap(u, n), et.isEmpty(u) || a.push({ loci: u, color: c, clear: l });
    }
    return { layers: a };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, a = /* @__PURE__ */ new Map(), i = et.none(n), o = 0, s = r.layers.length; o < s; ++o) {
      var u = r.layers[s - o - 1], c = u.loci, l = u.color, d = u.clear;
      if (c = et.subtract(c, i), i = et.union(c, i), !et.isEmpty(c)) {
        var f = d ? -1 : l;
        a.has(f) && (c = et.union(c, a.get(f))), a.set(f, c);
      }
    }
    var m = [];
    return a.forEach(function(h, p) {
      var g = p === -1, v = g ? Qe(0) : p;
      m.push({ loci: h, color: v, clear: g });
    }), { layers: m };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var a = r.layers[0].loci.structure, i = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.color, d = u.clear, f = et.remap(c, n);
      c = et.remap(f, a), et.isEmpty(c) || i.push({ loci: c, color: l, clear: d });
    }
    return { layers: i };
  }, e.ofScript = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.script, c = s.color, l = s.clear, d = Dd.toLoci(u, n);
      et.isEmpty(d) || a.push({ loci: d, color: c, clear: l });
    }
    return { layers: a };
  }, e.ofBundle = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.bundle, c = s.color, l = s.clear, d = vo.toLoci(u, n.root);
      a.push({ loci: d, color: c, clear: l });
    }
    return { layers: a };
  }, e.toBundle = function(r) {
    for (var n = [], a = 0, i = r.layers.length; a < i; ++a) {
      var o = r.layers[a], s = o.loci, u = o.color, c = o.clear, l = vo.fromLoci(s);
      n.push({ bundle: l, color: u, clear: c });
    }
    return { layers: n };
  };
}(mh || (mh = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { kind: "empty-loci", layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var a = 0, i = r.layers.length; a < i; ++a)
      if (r.layers[a].value !== n.layers[a].value || !an.areEqual(r.layers[a].loci, n.layers[a].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    if (r.kind === "element-loci") {
      for (var a = [], i = 0, o = r.layers; i < o.length; i++) {
        var s = o[i], u = et.remap(s.loci, n);
        et.isEmpty(u) || a.push({ loci: u, value: s.value });
      }
      return { kind: "element-loci", layers: a };
    }
    return r;
  }, e.merge = function(r) {
    if (t(r)) return r;
    if (r.kind === "element-loci") {
      for (var n = r.layers[0].loci.structure, a = /* @__PURE__ */ new Map(), i = et.none(n), o = 0, s = r.layers.length; o < s; ++o) {
        var u = r.layers[s - o - 1], c = u.loci, l = u.value;
        c = et.subtract(c, i), i = et.union(c, i), et.isEmpty(c) || (a.has(l) && (c = et.union(c, a.get(l))), a.set(l, c));
      }
      var d = [];
      return a.forEach(function(f, m) {
        d.push({ loci: f, value: m });
      }), { kind: "element-loci", layers: d };
    }
    return r;
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    if (r.kind === "element-loci") {
      for (var a = r.layers[0].loci.structure, i = [], o = 0, s = r.layers; o < s.length; o++) {
        var u = s[o], c = u.loci, l = u.value, d = et.remap(c, n);
        c = et.remap(d, a), et.isEmpty(c) || i.push({ loci: c, value: l });
      }
      return { kind: "element-loci", layers: i };
    }
    return r;
  }, e.ofScript = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.script, c = s.value, l = Dd.toLoci(u, n);
      et.isEmpty(l) || a.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: a };
  }, e.ofBundle = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.bundle, c = s.value, l = vo.toLoci(u, n.root);
      a.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: a };
  }, e.toBundle = function(r) {
    for (var n = [], a = 0, i = r.layers.length; a < i; ++a) {
      var o = r.layers[a], s = o.loci, u = o.value, c = vo.fromLoci(s);
      n.push({ bundle: c, value: u });
    }
    return { kind: "element-loci", layers: n };
  };
}(ph || (ph = {})), function(e) {
  e.create = function() {
    return { updateTransform: !1, updateMatrix: !1, updateColor: !1, updateSize: !1, createGeometry: !1, createNew: !1, info: {} };
  }, e.reset = function(t) {
    t.updateTransform = !1, t.updateMatrix = !1, t.updateColor = !1, t.updateSize = !1, t.createGeometry = !1, t.createNew = !1;
  };
}(fc || (fc = {}));
var Vae = { lowestElementCount: 1e6, lowerElementCount: 5e5, lowElementCount: 1e5, mediumElementCount: 2e4, highElementCount: 2e3, coarseGrainedFactor: 10, elementCountFactor: 1 };
function q6(e, t) {
  var r = Pa(e.quality, "auto"), n = Pa(e.detail, 1), a = Pa(e.radialSegments, 12), i = Pa(e.linearSegments, 8), o = Pa(e.resolution, 2), s = Pa(e.probePositions, 12), u = Pa(e.doubleSided, !0), c = 0;
  if (r === "auto") {
    if (t instanceof st) r = function(d, f) {
      f === void 0 && (f = {});
      var m = k(k({}, Vae), f), h = d.elementCount * m.elementCountFactor;
      return d.isCoarseGrained && (h *= m.coarseGrainedFactor), h > m.lowestElementCount ? "lowest" : h > m.lowerElementCount ? "lower" : h > m.lowElementCount ? "low" : h > m.mediumElementCount ? "medium" : h > m.highElementCount ? "high" : "higher";
    }(t.root), c = function(d) {
      if (d.root.models.length === 1) {
        var f = pi.Provider.get(d.root.model);
        if (f && f.spacegroup.name === "P 1" && !tu.isZero(f.spacegroup.cell)) return f.spacegroup.cell.volume;
      }
      return on.volume(d.root.boundary.box);
    }(t);
    else if (dr.is(t)) {
      var l = t.grid.cells.space.dimensions;
      r = (c = l[0] * l[1] * l[2]) < 1e7 ? "medium" : "low";
    }
  }
  switch (r) {
    case "highest":
      n = 3, a = 36, i = 18, o = 0.1, s = 72, u = !0;
      break;
    case "higher":
      n = 3, a = 28, i = 14, o = 0.3, s = 48, u = !0;
      break;
    case "high":
      n = 2, a = 20, i = 10, o = 0.5, s = 36, u = !0;
      break;
    case "medium":
      n = 1, a = 12, i = 8, o = 0.8, s = 24, u = !0;
      break;
    case "low":
      n = 0, a = 8, i = 3, o = 1.3, s = 24, u = !1;
      break;
    case "lower":
      n = 0, a = 4, i = 2, o = 3, s = 12, u = !1;
      break;
    case "lowest":
      n = 0, a = 2, i = 1, o = 8, s = 12, u = !1;
  }
  return o = Math.max(o, c / 5e8), o = Math.min(o, 20), (e.alpha !== void 0 && e.alpha < 1 || e.xrayShaded) && (u = !1), { detail: n, radialSegments: a, linearSegments: i, resolution: o, probePositions: s, doubleSided: u };
}
function hy(e, t) {
  t === void 0 && (t = 0);
  var r = e[0] * e[1] * e[2], n = Math.sqrt(r), a = Math.pow(2, Math.ceil(Math.log(n) / Math.log(2))), i = e[0] + t, o = e[1] + t, s = 1, u = i;
  return a < i * e[2] ? (i *= u = Math.floor(a / i), o *= s = Math.ceil(e[2] / u)) : i *= e[2], { width: i, height: o, columns: u, rows: s, powerOfTwoSize: o < a ? a : 2 * a };
}
function I2(e, t, r, n, a) {
  var i = e.colorType, o = e.vertexCount, s = e.groupCount, u = e.positionBuffer, c = e.transformBuffer, l = e.groupBuffer, d = e.itemSize, f = i.endsWith("Instance"), m = on.fromSphere3D(on(), f ? e.boundingSphere : e.invariantBoundingSphere), h = 1 + t, p = on.expand(on(), m, D.create(h, h, h)), g = 1 / t, v = on.scale(on(), p, g), y = on.size(D(), v);
  D.ceil(y, y), D.add(y, y, D.create(2, 2, 2));
  var _ = p.min, S = y[0], b = y[1], x = hy(y), A = x.width, w = x.height, C = new Float32Array(A * w * d), M = new Float32Array(A * w), T = new Uint8Array(A * w * d), N = { array: T, width: A, height: w, filter: "linear" }, I = f ? e.instanceCount : 1, P = e.colorData.array;
  function O(ht, xt, dt) {
    var Le = Math.floor(dt * S % A / S), j = Math.floor(dt * S / A);
    return d * (j * b * A + xt * A + (Le * S + ht));
  }
  for (var F = y[0], R = y[1], G = y[2], L = D(), q = 0; q < I; ++q) for (var K = 0; K < o; K += r) {
    D.fromArray(L, u, 3 * K), f && D.transformMat4Offset(L, L, c, 0, 0, 16 * q), D.sub(L, L, _), D.scale(L, L, g);
    for (var X = L[0], H = L[1], W = L[2], ee = Math.floor(X), $ = Math.floor(H), te = Math.floor(W), re = (q * s + l[K]) * d, ie = Math.max(0, ee - 2), oe = Math.max(0, $ - 2), se = Math.max(0, te - 2), he = Math.min(F, ee + 2 + 2), ge = Math.min(R, $ + 2 + 2), De = Math.min(G, te + 2 + 2), ae = ie; ae < he; ++ae) for (var ce = ae - X, _e = oe; _e < ge; ++_e) for (var le = _e - H, ue = se; ue < De; ++ue) {
      var be = ue - W, Se = Math.sqrt(ce * ce + le * le + be * be);
      if (!(Se > 2)) {
        for (var Ne = 2 - Se, J = O(ae, _e, ue), Z = 0; Z < d; ++Z) C[J + Z] += P[re + Z] * Ne;
        M[J / d] += Ne;
      }
    }
  }
  q = 0;
  for (var de = M.length; q < de; ++q) {
    var ye = q * d, Ae = M[q];
    for (Z = 0; Z < d; ++Z) T[ye + Z] = Math.round(C[ye + Z] / Ae);
  }
  var Ce = Ze.create(A, w), Ie = jt.create(_[0], _[1], _[2], g), Ue = f ? "volumeInstance" : "volume";
  if (n) {
    if (!a) {
      var Xe = d === 4 ? "rgba" : d === 3 ? "rgb" : "alpha";
      a = n.resources.texture("image-uint8", Xe, "ubyte", "linear");
    }
    return a.load(N), { kind: "volume", texture: a, gridTexDim: Ce, gridDim: y, gridTransform: Ie, type: Ue };
  }
  var je = function(ht) {
    var xt = ht.vertexCount, dt = ht.positionBuffer, Le = ht.transformBuffer, j = ht.grid, xe = ht.gridDim, ke = ht.gridTexDim, Je = ht.gridTransform, Ct = ht.vertexStride, At = ht.colorStride, Or = ht.itemOffset || 0, qn = ht.outputStride;
    if (qn + Or > At) throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
    var Xn = ht.colorType.endsWith("Instance"), kn = Xn ? ht.instanceCount : 1, fn = Oa(Math.max(1, kn * xt), qn, Uint8Array), la = fn.array, mn = xe[0], pn = xe[1], ba = ke[0], xa = D.fromArray(D(), Je, 0), to = Je[3];
    function zn(sb, ov, Cm) {
      var P1 = Math.floor(Cm * mn % ba / mn), Bl = Math.floor(Cm * mn / ba);
      return At * (Bl * pn * ba + ov * ba + (P1 * mn + sb));
    }
    for (var An = D(), jo = D(), Yo = D(), Co = D(), Lu = 0; Lu < kn; ++Lu) for (var ro = 0; ro < xt; ++ro) {
      D.fromArray(An, dt, ro * Ct), Xn && D.transformMat4Offset(An, An, Le, 0, 0, 16 * Lu), D.sub(An, An, xa), D.scale(An, An, to), D.floor(jo, An), D.ceil(Yo, An), D.sub(Co, An, jo), D.sub(An, Yo, jo), D.div(Co, Co, An);
      for (var _a = jo[0], yc = jo[1], El = jo[2], Dl = Yo[0], Ml = Yo[1], Il = Yo[2], Tl = Co[0], Sm = Co[1], Nl = Co[2], bc = zn(_a, yc, El) + Or, Kr = zn(Dl, yc, El) + Or, ri = zn(_a, yc, Il) + Or, I1 = zn(Dl, yc, Il) + Or, Pl = zn(_a, Ml, El) + Or, ku = zn(Dl, Ml, El) + Or, Am = zn(_a, Ml, Il) + Or, $h = zn(Dl, Ml, Il) + Or, rb = (Lu * xt + ro) * qn, Wo = 0; Wo < qn; ++Wo) {
        var nb = j[bc + Wo], ab = j[Kr + Wo], Jh = j[ri + Wo], ev = j[I1 + Wo], tv = j[Pl + Wo], T1 = j[ku + Wo], ib = j[Am + Wo], rv = j[$h + Wo], wm = Na(nb, ab, Tl), nv = Na(Jh, ev, Tl), ob = Na(tv, T1, Tl), av = Na(ib, rv, Tl), iv = Na(wm, ob, Sm), N1 = Na(nv, av, Sm);
        la[rb + Wo] = Na(iv, N1, Nl);
      }
    }
    return fn;
  }({ vertexCount: o, instanceCount: I, transformBuffer: c, positionBuffer: u, colorType: Ue, grid: T, gridDim: y, gridTexDim: Ce, gridTransform: Ie, vertexStride: 3, colorStride: d, outputStride: d });
  return { kind: "vertex", texture: je, texDim: Ze.create(je.width, je.height), type: f ? "vertexInstance" : "vertex" };
}
D.set, D.normalize, D.sub, D.addScalar, D.scale, D.toArray;
var qae = `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform sampler2D tCount;
uniform vec2 uTexSize;

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec4 color = texture2D(tColor, coords);
    float count = texture2D(tCount, coords).r;

    gl_FragColor = color / count;
}
`, Hae = `
precision highp float;

varying vec3 vPosition;
varying vec4 vColor;

uniform float uCurrentSlice;
uniform float uCurrentX;
uniform float uCurrentY;
uniform float uResolution;

const float p = 2.0;

void main() {
    vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;
    vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);
    float dist = distance(fragPos, vPosition);
    if (dist > p) discard;

    float f = p - dist;
    gl_FragColor = vColor * f;
    gl_FragData[1] = vec4(f);
}
`, Kae = `
precision highp float;

#include common
#include read_from_texture

uniform int uTotalCount;
uniform int uGroupCount;

attribute float aSample;
#define SampleID int(aSample)

attribute mat4 aTransform;
attribute float aInstance;

uniform vec2 uGeoTexDim;
uniform sampler2D tPosition;
uniform sampler2D tGroup;

uniform vec2 uColorTexDim;
uniform sampler2D tColor;

varying vec3 vPosition;
varying vec4 vColor;

uniform vec3 uBboxSize;
uniform vec3 uBboxMin;
uniform float uResolution;

void main() {
    vec3 position = readFromTexture(tPosition, SampleID, uGeoTexDim).xyz;
    float group = unpackRGBToInt(readFromTexture(tGroup, SampleID, uGeoTexDim).rgb);

    position = (aTransform * vec4(position, 1.0)).xyz;
    gl_PointSize = 7.0;
    vPosition = (position - uBboxMin) / uResolution;
    gl_Position = vec4(((position - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0);

    #if defined(dColorType_group)
        vColor = readFromTexture(tColor, group, uColorTexDim);
    #elif defined(dColorType_groupInstance)
        vColor = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim);
    #endif
}
`, Xae = { drawCount: va("number"), instanceCount: va("number"), stride: va("number"), uTotalCount: ze("i"), uInstanceCount: ze("i"), uGroupCount: ze("i"), aTransform: rn("float32", 16, 1), aInstance: rn("float32", 1, 1), aSample: rn("float32", 1, 0), uGeoTexDim: ze("v2", "buffered"), tPosition: Kt("texture", "rgba", "float", "nearest"), tGroup: Kt("texture", "rgba", "float", "nearest"), uColorTexDim: ze("v2"), tColor: Kt("texture", "rgba", "ubyte", "nearest"), dColorType: Ht("string", ["group", "groupInstance", "vertex", "vertexInstance"]), uCurrentSlice: ze("f"), uCurrentX: ze("f"), uCurrentY: ze("f"), uBboxMin: ze("v3", "material"), uBboxSize: ze("v3", "material"), uResolution: ze("f", "material") }, ss = "color-accumulate", J1 = "color-count";
function gD(e, t) {
  for (var r = new Float32Array(e), n = 0; n < e; ++n) r[n] = n * t;
  return r;
}
function jae(e, t, r, n, a) {
  if (e.namedComputeRenderables[ss]) {
    var i = D.sub(D(), r.max, r.min), o = e.namedComputeRenderables[ss].values, s = Math.round(t.vertexCount / a);
    (s > o.drawCount.ref.value || a !== o.stride.ref.value) && U.update(o.aSample, gD(s, a)), U.updateIfChanged(o.drawCount, s), U.updateIfChanged(o.instanceCount, t.instanceCount), U.updateIfChanged(o.stride, a), U.updateIfChanged(o.uTotalCount, t.vertexCount), U.updateIfChanged(o.uInstanceCount, t.instanceCount), U.updateIfChanged(o.uGroupCount, t.groupCount), U.update(o.aTransform, t.transformBuffer), U.update(o.aInstance, t.instanceBuffer), U.update(o.uGeoTexDim, Ze.set(o.uGeoTexDim.ref.value, t.positionTexture.getWidth(), t.positionTexture.getHeight())), U.update(o.tPosition, t.positionTexture), U.update(o.tGroup, t.groupTexture), U.update(o.uColorTexDim, Ze.set(o.uColorTexDim.ref.value, t.colorData.getWidth(), t.colorData.getHeight())), U.update(o.tColor, t.colorData), U.updateIfChanged(o.dColorType, t.colorType), U.updateIfChanged(o.uCurrentSlice, 0), U.updateIfChanged(o.uCurrentX, 0), U.updateIfChanged(o.uCurrentY, 0), U.update(o.uBboxMin, r.min), U.update(o.uBboxSize, i), U.updateIfChanged(o.uResolution, n), e.namedComputeRenderables[ss].update();
  } else e.namedComputeRenderables[ss] = function(u, c, l, d, f) {
    var m = D.sub(D(), l.max, l.min), h = Math.round(c.vertexCount / f), p = { drawCount: U.create(h), instanceCount: U.create(c.instanceCount), stride: U.create(f), uTotalCount: U.create(c.vertexCount), uInstanceCount: U.create(c.instanceCount), uGroupCount: U.create(c.groupCount), aTransform: U.create(c.transformBuffer), aInstance: U.create(c.instanceBuffer), aSample: U.create(gD(h, f)), uGeoTexDim: U.create(Ze.create(c.positionTexture.getWidth(), c.positionTexture.getHeight())), tPosition: U.create(c.positionTexture), tGroup: U.create(c.groupTexture), uColorTexDim: U.create(Ze.create(c.colorData.getWidth(), c.colorData.getHeight())), tColor: U.create(c.colorData), dColorType: U.create(c.colorType), uCurrentSlice: U.create(0), uCurrentX: U.create(0), uCurrentY: U.create(0), uBboxMin: U.create(l.min), uBboxSize: U.create(m), uResolution: U.create(d) }, g = k({}, Xae), v = Rn("accumulate", Kae, Hae, { drawBuffers: "required" }), y = Ua(u, "points", v, g, p);
    return Ga(y, p);
  }(e, t, r, n, a);
  return e.namedComputeRenderables[ss];
}
var Yae = k(k({}, ei), { tColor: Kt("texture", "rgba", "float", "nearest"), tCount: Kt("texture", "alpha", "float", "nearest"), uTexSize: ze("v2") }), e0 = "color-normalize";
function Wae(e, t, r) {
  if (e.namedComputeRenderables[e0]) {
    var n = e.namedComputeRenderables[e0].values;
    U.update(n.tColor, t), U.update(n.tCount, r), U.update(n.uTexSize, Ze.set(n.uTexSize.ref.value, t.getWidth(), t.getHeight())), e.namedComputeRenderables[e0].update();
  } else e.namedComputeRenderables[e0] = function(a, i, o) {
    var s = k(k({}, Qa), { tColor: U.create(i), tCount: U.create(o), uTexSize: U.create(Ze.create(i.getWidth(), i.getHeight())) }), u = k({}, Yae), c = Rn("normalize", Yi, qae), l = Ua(a, "triangles", c, u, s);
    return Ga(l, s);
  }(e, t, r);
  return e.namedComputeRenderables[e0];
}
function bx(e, t, r, n, a) {
  var i = n.extensions.drawBuffers;
  if (!i) throw new Error("need WebGL draw buffers");
  var o = n.gl, s = n.resources, u = n.state, c = n.extensions, l = c.colorBufferHalfFloat, d = c.textureHalfFloat, f = e.colorType.endsWith("Instance"), m = on.fromSphere3D(on(), f ? e.boundingSphere : e.invariantBoundingSphere), h = 1 + t, p = on.expand(on(), m, D.create(h, h, h)), g = 1 / t, v = on.scale(on(), p, g), y = on.size(D(), v);
  D.ceil(y, y), D.add(y, y, D.create(2, 2, 2));
  var _ = p.min, S = y[0], b = y[1], x = y[2], A = function($) {
    var te = $[0] * $[1] * $[2], re = Math.sqrt(te), ie = Math.pow(2, Math.ceil(Math.log(re) / Math.log(2))), oe = 0, se = $[1], he = 1, ge = $[2];
    return ie < $[0] * $[2] ? (ge = Math.floor(ie / $[0]), he = Math.ceil($[2] / ge), oe = ge * $[0], se *= he) : oe = $[0] * $[2], { texDimX: oe, texDimY: se, texRows: he, texCols: ge, powerOfTwoSize: se < ie ? ie : 2 * ie };
  }(y), w = A.texDimX, C = A.texDimY, M = A.texCols;
  n.namedFramebuffers[ss] || (n.namedFramebuffers[ss] = n.resources.framebuffer());
  var T = n.namedFramebuffers[ss];
  lr(o) ? (n.namedTextures[ss] || (n.namedTextures[ss] = l && d ? s.texture("image-float16", "rgba", "fp16", "nearest") : s.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[J1] || (n.namedTextures[J1] = s.texture("image-float32", "alpha", "float", "nearest"))) : (n.namedTextures[ss] || (n.namedTextures[ss] = s.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[J1] || (n.namedTextures[J1] = s.texture("image-float32", "rgba", "float", "nearest")));
  var N = n.namedTextures[ss], I = n.namedTextures[J1];
  N.define(w, C), I.define(w, C), N.attachFramebuffer(T, 0), I.attachFramebuffer(T, 1);
  var P = jae(n, e, p, t, r);
  u.currentRenderItemId = -1, T.bind(), i.drawBuffers([i.COLOR_ATTACHMENT0, i.COLOR_ATTACHMENT1]);
  var O = P.values, F = O.uCurrentSlice, R = O.uCurrentX, G = O.uCurrentY;
  (function($) {
    var te = $.gl, re = $.state;
    re.disable(te.CULL_FACE), re.enable(te.BLEND), re.disable(te.DEPTH_TEST), re.enable(te.SCISSOR_TEST), re.depthMask(!1), re.clearColor(0, 0, 0, 0), re.blendFunc(te.ONE, te.ONE), re.blendEquation(te.FUNC_ADD);
  })(n), o.viewport(0, 0, w, C), o.scissor(0, 0, w, C), o.clear(o.COLOR_BUFFER_BIT), U.update(G, 0);
  for (var L = 0, q = 0, K = 0, X = 0; X < x; ++X) L >= M && (L -= M, q += b, K = 0, U.update(G, q)), U.update(R, K), U.update(F, X), o.viewport(K, q, S, b), o.scissor(K, q, S, b), P.render(), ++L, K += S;
  N.detachFramebuffer(T, 0), I.detachFramebuffer(T, 1), i.drawBuffers([o.COLOR_ATTACHMENT0, o.NONE]), a || (a = s.texture("image-uint8", "rgba", "ubyte", "linear")), a.define(w, C);
  var H = Wae(n, N, I);
  u.currentRenderItemId = -1, function($) {
    var te = $.gl, re = $.state;
    re.disable(te.CULL_FACE), re.enable(te.BLEND), re.disable(te.DEPTH_TEST), re.enable(te.SCISSOR_TEST), re.depthMask(!1), re.clearColor(0, 0, 0, 0), re.blendFunc(te.ONE, te.ONE), re.blendEquation(te.FUNC_ADD);
  }(n), a.attachFramebuffer(T, 0), o.viewport(0, 0, w, C), o.scissor(0, 0, w, C), o.clear(o.COLOR_BUFFER_BIT), H.render();
  var W = jt.create(_[0], _[1], _[2], g), ee = f ? "volumeInstance" : "volume";
  return { texture: a, gridDim: y, gridTexDim: Ze.create(w, C), gridTransform: W, type: ee };
}
var cr, yD, Zm = "color-smoothing-rgba", xx = "color-smoothing-alpha";
function hh(e) {
  return { layers: e };
}
function vh(e) {
  return { layers: e };
}
(function(e) {
  e.setVisibility = function(t, r) {
    t && (t.state.visible = r);
  }, e.setAlphaFactor = function(t, r) {
    t && (t.state.alphaFactor = r);
  }, e.setPickable = function(t, r) {
    t && (t.state.pickable = r);
  }, e.setColorOnly = function(t, r) {
    t && (t.state.colorOnly = r);
  }, e.mark = function(t, r, n, a, i) {
    if (!t || Ld(r)) return !1;
    var o = t.values, s = o.tMarker, u = o.uMarker, c = o.markerAverage, l = o.markerStatus, d = o.uGroupCount, f = o.instanceCount, m = d.ref.value * f.ref.value, h = s.ref.value.array, p = l.ref.value;
    if (!Vo(r)) {
      var g = 0;
      if (a(r, function(b) {
        return g += Fe.size(b), !0;
      }, !0), g === 0) return !1;
      g === m && (r = k8);
    }
    var v = !1, y = -1, _ = -1;
    if (Vo(r)) {
      var S = function(b, x) {
        var A = -1, w = -1;
        switch (b) {
          case Et.Highlight:
            x === 0 || x === 1 ? (A = 1, w = 1) : x === 2 || x === 3 ? (A = 1, w = 3) : A = 1;
            break;
          case Et.RemoveHighlight:
            x === 0 || x === 1 ? (A = 0, w = 0) : x !== 2 && x !== 3 || (A = 1, w = 2);
            break;
          case Et.Select:
            x === 1 || x === 3 ? (A = 1, w = 3) : x === 0 || x === 2 ? (A = 1, w = 2) : A = 1;
            break;
          case Et.Deselect:
            x === 1 || x === 3 ? (A = 1, w = 1) : x !== 0 && x !== 2 || (A = 0, w = 0);
            break;
          case Et.Toggle:
            x === 1 ? (A = 1, w = 3) : x === 2 ? (A = 0, w = 0) : x === 3 ? (A = 1, w = 1) : x === 0 && (A = 1, w = 2);
            break;
          case Et.Clear:
            A = 0, w = 0;
        }
        return { average: A, status: w };
      }(n, p);
      S.status !== -1 ? (v = p !== S.status) && function(b, x, A) {
        b.fill(x, 0, A);
      }(h, S.status, m) : v = U6(h, Fe.ofLength(m), n), y = S.average, _ = S.status;
    } else (v = a(r, function(b) {
      return U6(h, b, n);
    }, !0)) && (y = function(b, x) {
      switch (b) {
        case Et.Highlight:
          return 0.5;
        case Et.RemoveHighlight:
          return x === 0 ? 0 : x === 2 || x === 3 ? 0.5 : -1;
        case Et.Select:
          return 0.5;
        case Et.Deselect:
          return x === 1 || x === 3 ? 0.5 : x === 0 ? 0 : -1;
        case Et.Toggle:
          return x === -1 ? -1 : 0.5;
        case Et.Clear:
          return x === -1 ? -1 : x === 0 ? 0 : 0.5;
        case Et.None:
          return -1;
        default:
          Ja();
      }
    }(n, p), i && i.status !== -1 && y === -1 && qr.isReverse(i.action, n) && an.areEqual(r, i.loci) && (y = (_ = i.status) === 0 ? 0 : 0.5));
    return v && (y === -1 && (y = CR(h, m)) === 0 && (_ = 0), i && (i.action = n, i.loci = r, i.status = p), U.updateIfChanged(u, _), _ === -1 && U.update(s, s.ref.value), U.updateIfChanged(c, y), U.updateIfChanged(l, _)), v;
  }, e.setOverpaint = function(t, r, n, a, i) {
    if (t) {
      var o = t.values, s = o.tOverpaint, u = o.dOverpaintType, c = o.dOverpaint, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(C, M) {
        var T = Oa(Math.max(1, C), 4, Uint8Array, M && M.tOverpaint.ref.value.array);
        M ? (U.update(M.tOverpaint, T), U.update(M.uOverpaintTexDim, Ze.create(T.width, T.height)), U.updateIfChanged(M.dOverpaint, C > 0)) : (U.create(T), U.create(Ze.create(T.width, T.height)), U.create(C > 0), U.create(ko()), U.create(D.create(1, 1, 1)), U.create(jt.create(0, 0, 0, 1)), U.create("groupInstance"));
      })(r.layers.length ? f : 0, t.values);
      var m = s.ref.value.array;
      a && WC(m, 0, f);
      for (var h = function(C, M) {
        var T = r.layers[C], N = T.loci, I = T.color, P = T.clear;
        n(N, function(O) {
          var F = Fe.start(O), R = Fe.end(O);
          return P ? WC(m, F, R) : function(G, L, q, K) {
            for (var X = L; X < q; ++X) Qe.toArray(K, G, 4 * X), G[4 * X + 3] = 255;
            return !0;
          }(m, F, R, I);
        }, !1);
      }, p = 0, g = r.layers.length; p < g; ++p) h(p);
      if (U.update(s, s.ref.value), U.updateIfChanged(u, "groupInstance"), U.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && i && J4(i.props)) {
        var v = i.geometry, y = i.props, _ = i.webgl;
        if (v.kind === "mesh") {
          var S = v.meta, b = S.resolution, x = S.overpaintTexture;
          (A = Of(y.smoothColors, !0, b)) && (function(C, M, T, N, I) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(C.dOverpaintType.ref.value)) {
              var P = I2({ vertexCount: C.uVertexCount.ref.value, instanceCount: C.uInstanceCount.ref.value, groupCount: C.uGroupCount.ref.value, transformBuffer: C.aTransform.ref.value, instanceBuffer: C.aInstance.ref.value, positionBuffer: C.aPosition.ref.value, groupBuffer: C.aGroup.ref.value, colorData: C.tOverpaint.ref.value, colorType: C.dOverpaintType.ref.value, boundingSphere: C.boundingSphere.ref.value, invariantBoundingSphere: C.invariantBoundingSphere.ref.value, itemSize: 4 }, M, T, N, I);
              P.kind === "volume" ? (U.updateIfChanged(C.dOverpaintType, P.type), U.update(C.tOverpaintGrid, P.texture), U.update(C.uOverpaintTexDim, P.gridTexDim), U.update(C.uOverpaintGridDim, P.gridDim), U.update(C.uOverpaintGridTransform, P.gridTransform)) : P.kind === "vertex" && (U.updateIfChanged(C.dOverpaintType, P.type), U.update(C.tOverpaint, P.texture), U.update(C.uOverpaintTexDim, P.texDim));
            }
          }(t.values, A.resolution, A.stride, _, x), v.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        } else if (_ && v.kind === "texture-mesh") {
          var A, w = v.meta;
          b = w.resolution, x = w.overpaintTexture, (A = Of(y.smoothColors, !0, b)) && (function(C, M, T, N, I) {
            if (/* @__PURE__ */ function(F) {
              return F === "groupInstance";
            }(C.dOverpaintType.ref.value)) {
              T *= 3, N.namedTextures[Zm] || (N.namedTextures[Zm] = N.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var P = N.namedTextures[Zm];
              P.load(C.tOverpaint.ref.value);
              var O = bx({ vertexCount: C.uVertexCount.ref.value, instanceCount: C.uInstanceCount.ref.value, groupCount: C.uGroupCount.ref.value, transformBuffer: C.aTransform.ref.value, instanceBuffer: C.aInstance.ref.value, positionTexture: C.tPosition.ref.value, groupTexture: C.tGroup.ref.value, colorData: P, colorType: C.dOverpaintType.ref.value, boundingSphere: C.boundingSphere.ref.value, invariantBoundingSphere: C.invariantBoundingSphere.ref.value }, M, T, N, I);
              U.updateIfChanged(C.dOverpaintType, O.type), U.update(C.tOverpaintGrid, O.texture), U.update(C.uOverpaintTexDim, O.gridTexDim), U.update(C.uOverpaintGridDim, O.gridDim), U.update(C.uOverpaintGridTransform, O.gridTransform);
            }
          }(t.values, A.resolution, A.stride, _, x), v.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        }
      }
    }
  }, e.setTransparency = function(t, r, n, a, i) {
    if (t) {
      var o = t.values, s = o.tTransparency, u = o.dTransparencyType, c = o.transparencyAverage, l = o.dTransparency, d = o.uGroupCount, f = o.instanceCount, m = d.ref.value * f.ref.value;
      (function(M, T) {
        var N = Oa(Math.max(1, M), 1, Uint8Array, T && T.tTransparency.ref.value.array);
        T ? (U.update(T.tTransparency, N), U.update(T.uTransparencyTexDim, Ze.create(N.width, N.height)), U.updateIfChanged(T.dTransparency, M > 0), U.updateIfChanged(T.transparencyAverage, ZC(N.array, M))) : (U.create(N), U.create(Ze.create(N.width, N.height)), U.create(M > 0), U.create(0), U.create(ko()), U.create(D.create(1, 1, 1)), U.create(jt.create(0, 0, 0, 1)), U.create("groupInstance"));
      })(r.layers.length ? m : 0, t.values);
      var h = s.ref.value.array;
      a && function(M, T, N) {
        M.fill(0, T, N);
      }(h, 0, m);
      for (var p = function(M, T) {
        var N = r.layers[M], I = N.loci, P = N.value;
        n(I, function(O) {
          var F = Fe.start(O), R = Fe.end(O);
          return function(G, L, q, K) {
            for (var X = L; X < q; ++X) G[X] = 255 * K;
            return !0;
          }(h, F, R, P);
        }, !1);
      }, g = 0, v = r.layers.length; g < v; ++g) p(g);
      if (U.update(s, s.ref.value), U.updateIfChanged(c, ZC(h, m)), U.updateIfChanged(u, "groupInstance"), U.updateIfChanged(l, r.layers.length > 0), r.layers.length !== 0 && i && J4(i.props)) {
        var y = i.geometry, _ = i.props, S = i.webgl;
        if (y.kind === "mesh") {
          var b = y.meta, x = b.resolution, A = b.transparencyTexture;
          (w = Of(_.smoothColors, !0, x)) && (function(M, T, N, I, P) {
            if (/* @__PURE__ */ function(F) {
              return F === "groupInstance";
            }(M.dTransparencyType.ref.value)) {
              var O = I2({ vertexCount: M.uVertexCount.ref.value, instanceCount: M.uInstanceCount.ref.value, groupCount: M.uGroupCount.ref.value, transformBuffer: M.aTransform.ref.value, instanceBuffer: M.aInstance.ref.value, positionBuffer: M.aPosition.ref.value, groupBuffer: M.aGroup.ref.value, colorData: M.tTransparency.ref.value, colorType: M.dTransparencyType.ref.value, boundingSphere: M.boundingSphere.ref.value, invariantBoundingSphere: M.invariantBoundingSphere.ref.value, itemSize: 1 }, T, N, I, P);
              O.kind === "volume" ? (U.updateIfChanged(M.dTransparencyType, O.type), U.update(M.tTransparencyGrid, O.texture), U.update(M.uTransparencyTexDim, O.gridTexDim), U.update(M.uTransparencyGridDim, O.gridDim), U.update(M.uTransparencyGridTransform, O.gridTransform)) : O.kind === "vertex" && (U.updateIfChanged(M.dTransparencyType, O.type), U.update(M.tTransparency, O.texture), U.update(M.uTransparencyTexDim, O.texDim));
            }
          }(t.values, w.resolution, w.stride, S, A), y.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        } else if (S && y.kind === "texture-mesh") {
          var w, C = y.meta;
          x = C.resolution, A = C.transparencyTexture, (w = Of(_.smoothColors, !0, x)) && (function(M, T, N, I, P) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(M.dTransparencyType.ref.value)) {
              N *= 3, I.namedTextures[xx] || (I.namedTextures[xx] = I.resources.texture("image-uint8", "alpha", "ubyte", "nearest"));
              var O = I.namedTextures[xx];
              O.load(M.tTransparency.ref.value);
              var F = bx({ vertexCount: M.uVertexCount.ref.value, instanceCount: M.uInstanceCount.ref.value, groupCount: M.uGroupCount.ref.value, transformBuffer: M.aTransform.ref.value, instanceBuffer: M.aInstance.ref.value, positionTexture: M.tPosition.ref.value, groupTexture: M.tGroup.ref.value, colorData: O, colorType: M.dTransparencyType.ref.value, boundingSphere: M.boundingSphere.ref.value, invariantBoundingSphere: M.invariantBoundingSphere.ref.value }, T, N, I, P);
              U.updateIfChanged(M.dTransparencyType, F.type), U.update(M.tTransparencyGrid, F.texture), U.update(M.uTransparencyTexDim, F.gridTexDim), U.update(M.uTransparencyGridDim, F.gridDim), U.update(M.uTransparencyGridTransform, F.gridTransform);
            }
          }(t.values, w.resolution, w.stride, S, A), y.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        }
      }
    }
  }, e.setSubstance = function(t, r, n, a, i) {
    if (t) {
      var o = t.values, s = o.tSubstance, u = o.dSubstanceType, c = o.dSubstance, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(C, M) {
        var T = Oa(Math.max(1, C), 4, Uint8Array, M && M.tSubstance.ref.value.array);
        M ? (U.update(M.tSubstance, T), U.update(M.uSubstanceTexDim, Ze.create(T.width, T.height)), U.updateIfChanged(M.dSubstance, C > 0)) : (U.create(T), U.create(Ze.create(T.width, T.height)), U.create(C > 0), U.create(ko()), U.create(D.create(1, 1, 1)), U.create(jt.create(0, 0, 0, 1)), U.create("groupInstance"));
      })(r.layers.length ? f : 0, t.values);
      var m = s.ref.value.array;
      a && QC(m, 0, f);
      for (var h = function(C, M) {
        var T = r.layers[C], N = T.loci, I = T.material, P = T.clear;
        n(N, function(O) {
          var F = Fe.start(O), R = Fe.end(O);
          return P ? QC(m, F, R) : function(G, L, q, K) {
            for (var X = L; X < q; ++X) qp.toArray(K, G, 4 * X), G[4 * X + 3] = 255;
            return !0;
          }(m, F, R, I);
        }, !1);
      }, p = 0, g = r.layers.length; p < g; ++p) h(p);
      if (U.update(s, s.ref.value), U.updateIfChanged(u, "groupInstance"), U.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && i && J4(i.props)) {
        var v = i.geometry, y = i.props, _ = i.webgl;
        if (v.kind === "mesh") {
          var S = v.meta, b = S.resolution, x = S.substanceTexture;
          (A = Of(y.smoothColors, !0, b)) && (function(C, M, T, N, I) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(C.dSubstanceType.ref.value)) {
              var P = I2({ vertexCount: C.uVertexCount.ref.value, instanceCount: C.uInstanceCount.ref.value, groupCount: C.uGroupCount.ref.value, transformBuffer: C.aTransform.ref.value, instanceBuffer: C.aInstance.ref.value, positionBuffer: C.aPosition.ref.value, groupBuffer: C.aGroup.ref.value, colorData: C.tSubstance.ref.value, colorType: C.dSubstanceType.ref.value, boundingSphere: C.boundingSphere.ref.value, invariantBoundingSphere: C.invariantBoundingSphere.ref.value, itemSize: 4 }, M, T, N, I);
              P.kind === "volume" ? (U.updateIfChanged(C.dSubstanceType, P.type), U.update(C.tSubstanceGrid, P.texture), U.update(C.uSubstanceTexDim, P.gridTexDim), U.update(C.uSubstanceGridDim, P.gridDim), U.update(C.uSubstanceGridTransform, P.gridTransform)) : P.kind === "vertex" && (U.updateIfChanged(C.dSubstanceType, P.type), U.update(C.tSubstance, P.texture), U.update(C.uSubstanceTexDim, P.texDim));
            }
          }(t.values, A.resolution, A.stride, _, x), v.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        } else if (_ && v.kind === "texture-mesh") {
          var A, w = v.meta;
          b = w.resolution, x = w.substanceTexture, (A = Of(y.smoothColors, !0, b)) && (function(C, M, T, N, I) {
            if (/* @__PURE__ */ function(F) {
              return F === "groupInstance";
            }(C.dSubstanceType.ref.value)) {
              T *= 3, N.namedTextures[Zm] || (N.namedTextures[Zm] = N.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var P = N.namedTextures[Zm];
              P.load(C.tSubstance.ref.value);
              var O = bx({ vertexCount: C.uVertexCount.ref.value, instanceCount: C.uInstanceCount.ref.value, groupCount: C.uGroupCount.ref.value, transformBuffer: C.aTransform.ref.value, instanceBuffer: C.aInstance.ref.value, positionTexture: C.tPosition.ref.value, groupTexture: C.tGroup.ref.value, colorData: P, colorType: C.dSubstanceType.ref.value, boundingSphere: C.boundingSphere.ref.value, invariantBoundingSphere: C.invariantBoundingSphere.ref.value }, M, T, N, I);
              U.updateIfChanged(C.dSubstanceType, O.type), U.update(C.tSubstanceGrid, O.texture), U.update(C.uSubstanceTexDim, O.gridTexDim), U.update(C.uSubstanceGridDim, O.gridDim), U.update(C.uSubstanceGridTransform, O.gridTransform);
            }
          }(t.values, A.resolution, A.stride, _, x), v.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        }
      }
    }
  }, e.setClipping = function(t, r, n, a) {
    if (t) {
      var i = t.values, o = i.tClipping, s = i.dClipping, u = i.uGroupCount, c = i.instanceCount, l = u.ref.value * c.ref.value;
      (function(p, g) {
        var v = Oa(Math.max(1, p), 1, Uint8Array, g && g.tClipping.ref.value.array);
        g ? (U.update(g.tClipping, v), U.update(g.uClippingTexDim, Ze.create(v.width, v.height)), U.updateIfChanged(g.dClipping, p > 0)) : (U.create(v), U.create(Ze.create(v.width, v.height)), U.create(p > 0));
      })(r.layers.length ? l : 0, t.values);
      var d = o.ref.value.array;
      a && function(p, g, v) {
        p.fill(0, g, v);
      }(d, 0, l);
      for (var f = function(p, g) {
        var v = r.layers[p], y = v.loci, _ = v.groups;
        n(y, function(S) {
          var b = Fe.start(S), x = Fe.end(S);
          return function(A, w, C, M) {
            return A.fill(M, w, C), !0;
          }(d, b, x, _);
        }, !1);
      }, m = 0, h = r.layers.length; m < h; ++m) f(m);
      U.update(o, o.ref.value), U.updateIfChanged(s, r.layers.length > 0);
    }
  }, e.setTransform = function(t, r, n) {
    if (t && (r || n)) {
      var a = t.values;
      r && (Ee.copy(a.matrix.ref.value, r), U.update(a.matrix, a.matrix.ref.value)), n ? (a.extraTransform.ref.value.set(n), U.update(a.extraTransform, a.extraTransform.ref.value)) : n === null && (D6(a.extraTransform.ref.value, a.instanceCount.ref.value), U.update(a.extraTransform, a.extraTransform.ref.value)), ER(a);
      var i = ja(a.invariantBoundingSphere.ref.value, a.aTransform.ref.value, a.instanceCount.ref.value);
      U.update(a.boundingSphere, i);
    }
  };
})(cr || (cr = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, function(r) {
    function n(a) {
      switch (a) {
        case "one":
          return 1;
        case "two":
          return 2;
        case "three":
          return 4;
        case "four":
          return 8;
        case "five":
          return 16;
        case "six":
          return 32;
      }
    }
    r.is = Ti.has, r.create = function(a) {
      return Ti.create(a);
    }, r.Names = { one: 1, two: 2, three: 4, four: 8, five: 16, six: 32 }, r.isName = function(a) {
      return a in r.Names;
    }, r.fromName = n, r.fromNames = function(a) {
      for (var i = 0, o = 0, s = a.length; o < s; ++o) i |= n(a[o]);
      return i;
    }, r.toNames = function(a) {
      var i = [];
      return r.is(a, 1) && i.push("one"), r.is(a, 2) && i.push("two"), r.is(a, 4) && i.push("three"), r.is(a, 8) && i.push("four"), r.is(a, 16) && i.push("five"), r.is(a, 32) && i.push("six"), i;
    };
  }(e.Groups || (e.Groups = {})), e.areEqual = function(r, n) {
    if (r.layers.length !== n.layers.length) return !1;
    for (var a = 0, i = r.layers.length; a < i; ++a)
      if (r.layers[a].groups !== n.layers[a].groups || !an.areEqual(r.layers[a].loci, n.layers[a].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var a = [], i = 0, o = r.layers; i < o.length; i++) {
      var s = o[i], u = s.loci, c = s.groups;
      u = et.remap(u, n), et.isEmpty(u) || a.push({ loci: u, groups: c });
    }
    return { layers: a };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, a = /* @__PURE__ */ new Map(), i = et.none(n), o = 0, s = r.layers.length; o < s; ++o) {
      var u = r.layers[s - o - 1], c = u.loci, l = u.groups;
      c = et.subtract(c, i), i = et.union(c, i), et.isEmpty(c) || (a.has(l) && (c = et.union(c, a.get(l))), a.set(l, c));
    }
    var d = [];
    return a.forEach(function(f, m) {
      d.push({ loci: f, groups: m });
    }), { layers: d };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var a = r.layers[0].loci.structure, i = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.groups, d = et.remap(c, n);
      c = et.remap(d, a), et.isEmpty(c) || i.push({ loci: c, groups: l });
    }
    return { layers: i };
  }, e.ofScript = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.script, c = s.groups, l = Dd.toLoci(u, n);
      et.isEmpty(l) || a.push({ loci: l, groups: c });
    }
    return { layers: a };
  }, e.ofBundle = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.bundle, c = s.groups, l = vo.toLoci(u, n.root);
      a.push({ loci: l, groups: c });
    }
    return { layers: a };
  }, e.toBundle = function(r) {
    for (var n = [], a = 0, i = r.layers.length; a < i; ++a) {
      var o = r.layers[a], s = o.loci, u = o.groups, c = vo.fromLoci(s);
      n.push({ bundle: c, groups: u });
    }
    return { layers: n };
  };
}(hh || (hh = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var a = 0, i = r.layers.length; a < i; ++a)
      if (r.layers[a].clear !== n.layers[a].clear || !s$(r.layers[a].material, n.layers[a].material) || !an.areEqual(r.layers[a].loci, n.layers[a].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var a = [], i = 0, o = r.layers; i < o.length; i++) {
      var s = o[i], u = s.loci, c = s.material, l = s.clear;
      u = et.remap(u, n), et.isEmpty(u) || a.push({ loci: u, material: c, clear: l });
    }
    return { layers: a };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, a = void 0, i = /* @__PURE__ */ new Map(), o = et.none(n), s = 0, u = r.layers.length; s < u; ++s) {
      var c = r.layers[u - s - 1], l = c.loci, d = c.material, f = c.clear;
      l = et.subtract(l, o), o = et.union(l, o), et.isEmpty(l) || (f ? a = a ? et.union(l, a) : l : (i.has(d) && (l = et.union(l, i.get(d))), i.set(d, l)));
    }
    var m = [];
    return a && m.push({ loci: a, material: qp(), clear: !0 }), i.forEach(function(h, p) {
      m.push({ loci: h, material: p, clear: !1 });
    }), { layers: m };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var a = r.layers[0].loci.structure, i = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.material, d = u.clear, f = et.remap(c, n);
      c = et.remap(f, a), et.isEmpty(c) || i.push({ loci: c, material: l, clear: d });
    }
    return { layers: i };
  }, e.ofScript = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.script, c = s.material, l = s.clear, d = Dd.toLoci(u, n);
      et.isEmpty(d) || a.push({ loci: d, material: c, clear: l });
    }
    return { layers: a };
  }, e.ofBundle = function(r, n) {
    for (var a = [], i = 0, o = r.length; i < o; ++i) {
      var s = r[i], u = s.bundle, c = s.material, l = s.clear, d = vo.toLoci(u, n.root);
      a.push({ loci: d, material: c, clear: l });
    }
    return { layers: a };
  }, e.toBundle = function(r) {
    for (var n = [], a = 0, i = r.layers.length; a < i; ++a) {
      var o = r.layers[a], s = o.loci, u = o.material, c = o.clear, l = vo.fromLoci(s);
      n.push({ bundle: l, material: u, clear: c });
    }
    return { layers: n };
  };
}(vh || (vh = {})), function(e) {
  e.getDetaultParams = function(t, r, n) {
    return V.getDefaultValues(t.getParams(r, n));
  };
}(yD || (yD = {}));
var fr, vy, Zae = { name: "", label: "", description: "", factory: function() {
  return fr.Empty;
}, getParams: function() {
  return {};
}, defaultValues: {}, defaultColorTheme: fl.EmptyProvider, defaultSizeTheme: go.EmptyProvider, isApplicable: function() {
  return !0;
} };
function bD(e) {
  return e.map(function(t) {
    return [t.name, t.provider.label];
  });
}
(function() {
  function e() {
    this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map();
  }
  Object.defineProperty(e.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "types", { get: function() {
    return bD(this._list);
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    if (this._map.has(t.name)) throw new Error("".concat(t.name, " already registered."));
    this._list.push({ name: t.name, provider: t }), this._map.set(t.name, t), this._name.set(t, t.name);
  }, e.prototype.getName = function(t) {
    if (!this._name.has(t)) throw new Error("'".concat(t.label, "' is not a registered represenatation provider."));
    return this._name.get(t);
  }, e.prototype.remove = function(t) {
    var r = t.name;
    this._list.splice(this._list.findIndex(function(a) {
      return a.name === r;
    }), 1);
    var n = this._map.get(r);
    n && (this._map.delete(r), this._name.delete(n));
  }, e.prototype.get = function(t) {
    return this._map.get(t) || Zae;
  }, Object.defineProperty(e.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return bD(this.getApplicableList(t));
  };
})(), function(e) {
  function t() {
    return { visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, syncManually: !1, transform: Ee.identity(), overpaint: mh.Empty, transparency: ph.Empty, substance: vh.Empty, clipping: hh.Empty, markerActions: qr.All };
  }
  function r(a, i) {
    i.visible !== void 0 && (a.visible = i.visible), i.alphaFactor !== void 0 && (a.alphaFactor = i.alphaFactor), i.pickable !== void 0 && (a.pickable = i.pickable), i.colorOnly !== void 0 && (a.colorOnly = i.colorOnly), i.overpaint !== void 0 && (a.overpaint = i.overpaint), i.transparency !== void 0 && (a.transparency = i.transparency), i.substance !== void 0 && (a.substance = i.substance), i.clipping !== void 0 && (a.clipping = i.clipping), i.syncManually !== void 0 && (a.syncManually = i.syncManually), i.transform !== void 0 && Ee.copy(a.transform, i.transform), i.markerActions !== void 0 && (a.markerActions = i.markerActions);
  }
  (function(a) {
    a.areEqual = function(i, o) {
      return i.repr === o.repr && an.areEqual(i.loci, o.loci);
    }, a.isEmpty = function(i) {
      return an.isEmpty(i.loci);
    }, a.Empty = { loci: Tn };
  })(e.Loci || (e.Loci = {})), e.createState = t, e.updateState = r, e.StateBuilder = { create: t, update: r }, e.Empty = { label: "", groupCount: 0, renderObjects: [], geometryVersion: -1, props: {}, params: {}, updated: new pa(), state: t(), theme: nu.createEmpty(), createOrUpdate: function() {
    return sr.constant("", void 0);
  }, setState: function() {
  }, setTheme: function() {
  }, getLoci: function() {
    return Tn;
  }, mark: function() {
    return !1;
  }, destroy: function() {
  } };
  var n = function() {
    function a() {
      this.curr = /* @__PURE__ */ new Set(), this.next = /* @__PURE__ */ new Set(), this._version = -1;
    }
    return Object.defineProperty(a.prototype, "version", { get: function() {
      return this._version;
    }, enumerable: !1, configurable: !0 }), a.prototype.add = function(i, o) {
      this.next.add(eu(i, o));
    }, a.prototype.snapshot = function() {
      var i;
      bo.areEqual(this.curr, this.next) || (this._version += 1), i = [this.next, this.curr], this.curr = i[0], this.next = i[1], this.next.clear();
    }, a;
  }();
  e.GeometryState = n, e.createMulti = function(a, i, o, s, u) {
    var c, l, d, f = this, m = 0, h = new pa(), p = new n(), g = s.create(), v = nu.createEmpty(), y = {}, _ = Object.keys(u).map(function(S, b) {
      y[b] = S;
      var x = u[S](i, o);
      return x.setState(g), x;
    });
    return { label: a, updated: h, get groupCount() {
      var S = 0;
      if (l) for (var b = l.visuals, x = 0, A = _.length; x < A; ++x) b && !b.includes(y[x]) || (S += _[x].groupCount);
      return S;
    }, get renderObjects() {
      var S = [];
      if (l) for (var b = l.visuals, x = 0, A = _.length; x < A; ++x) b && !b.includes(y[x]) || S.push.apply(S, _[x].renderObjects);
      return S;
    }, get geometryVersion() {
      return p.version;
    }, get props() {
      return l;
    }, get params() {
      return c;
    }, createOrUpdate: function(S, b) {
      S === void 0 && (S = {}), b && b !== d && (c = o(i, b), d = b, l || (l = V.getDefaultValues(c))), l || (l = {});
      var x = q6(Object.assign({}, l || {}, S || {}), d);
      Object.assign(l, S || {}, x || {});
      var A = l.visuals;
      return sr.create("Creating or updating '".concat(a, "' representation"), function(w) {
        return Be(f, 0, void 0, function() {
          var C, M;
          return Te(this, function(T) {
            switch (T.label) {
              case 0:
                C = 0, M = _.length, T.label = 1;
              case 1:
                return C < M ? A && !A.includes(y[C]) ? [3, 3] : [4, _[C].createOrUpdate(l, d).runInContext(w)] : [3, 5];
              case 2:
                T.sent(), T.label = 3;
              case 3:
                p.add(C, _[C].geometryVersion), T.label = 4;
              case 4:
                return ++C, [3, 1];
              case 5:
                return p.snapshot(), h.next(m++), [2];
            }
          });
        });
      });
    }, get state() {
      return g;
    }, get theme() {
      return v;
    }, getLoci: function(S) {
      for (var b = l.visuals, x = 0, A = _.length; x < A; ++x) if (!b || b.includes(y[x])) {
        var w = _[x].getLoci(S);
        if (!Ld(w)) return w;
      }
      return Tn;
    }, mark: function(S, b) {
      for (var x = !1, A = 0, w = _.length; A < w; ++A) x = _[A].mark(S, b) || x;
      return x;
    }, setState: function(S) {
      s.update(g, S);
      for (var b = 0, x = _.length; b < x; ++b) _[b].setState(S);
      h.next(m++);
    }, setTheme: function(S) {
      v = S;
      for (var b = 0, x = _.length; b < x; ++b) _[b].setTheme(S);
    }, destroy: function() {
      for (var S = 0, b = _.length; S < b; ++S) _[S].destroy();
    } };
  }, e.fromRenderObject = function(a, i) {
    var o = this, s = 0, u = new pa(), c = new n(), l = e.createState(), d = nu.createEmpty(), f = V.clone(yt.Params), m = V.getDefaultValues(yt.Params);
    return { label: a, updated: u, get groupCount() {
      return i.values.uGroupCount.ref.value;
    }, get renderObjects() {
      return [i];
    }, get geometryVersion() {
      return c.version;
    }, get props() {
      return m;
    }, get params() {
      return f;
    }, createOrUpdate: function(h) {
      h === void 0 && (h = {});
      var p = q6(Object.assign({}, m, h));
      return Object.assign(m, h, p), sr.create("Updating '".concat(a, "' representation"), function(g) {
        return Be(o, 0, void 0, function() {
          return Te(this, function(v) {
            return c.add(0, i.id), c.snapshot(), u.next(s++), [2];
          });
        });
      });
    }, get state() {
      return l;
    }, get theme() {
      return d;
    }, getLoci: function() {
      return Tn;
    }, mark: function(h, p) {
      return !1;
    }, setState: function(h) {
      h.visible !== void 0 && cr.setVisibility(i, h.visible), h.alphaFactor !== void 0 && cr.setAlphaFactor(i, h.alphaFactor), h.pickable !== void 0 && cr.setPickable(i, h.pickable), h.colorOnly !== void 0 && cr.setColorOnly(i, h.colorOnly), h.overpaint, h.transparency, h.substance, h.transform !== void 0 && cr.setTransform(i, h.transform), e.updateState(l, h);
    }, setTheme: function() {
    }, destroy: function() {
    } };
  };
}(fr || (fr = {})), function(e) {
  e.create = function() {
    return { view: Ee.identity(), position: D.create(0, 0, 0), direction: D.create(0, 0, -1), up: D.create(0, 1, 0) };
  };
  var t = D.zero();
  e.update = function(r) {
    D.add(t, r.position, r.direction), Ee.lookAt(r.view, r.position, t, r.up);
  };
}(vy || (vy = {}));
var Yp, Qae = function() {
  function e() {
    this.removeList = D9(), this.removeMap = /* @__PURE__ */ new Map(), this.addList = D9(), this.addMap = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.removeList.count === 0 && this.addList.count === 0;
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    if (this.removeMap.has(t)) {
      var r = this.removeMap.get(t);
      this.removeMap.delete(t), this.removeList.remove(r);
    }
    if (!this.addMap.has(t)) {
      var n = this.addList.addLast(t);
      this.addMap.set(t, n);
    }
  }, e.prototype.remove = function(t) {
    if (this.addMap.has(t)) {
      var r = this.addMap.get(t);
      this.addMap.delete(t), this.addList.remove(r);
    }
    if (!this.removeMap.has(t)) {
      var n = this.removeList.addLast(t);
      this.removeMap.set(t, n);
    }
  }, e.prototype.tryGetRemove = function() {
    var t = this.removeList.removeFirst();
    return t && this.removeMap.delete(t), t;
  }, e.prototype.tryGetAdd = function() {
    var t = this.addList.removeFirst();
    return t && this.addMap.delete(t), t;
  }, e;
}(), t0 = new iu("98");
function xD(e, t, r) {
  t0.reset();
  for (var n = 0, a = e.length; n < a; ++n) if (!r || e[n].state.visible) {
    var i = e[n].values.boundingSphere.ref.value;
    i.radius && t0.includeSphere(i);
  }
  for (t0.finishedIncludeStep(), n = 0, a = e.length; n < a; ++n) if (!r || e[n].state.visible) {
    var o = e[n].values.boundingSphere.ref.value;
    o.radius && t0.radiusSphere(o);
  }
  return t0.getSphere(t);
}
function $ae(e, t) {
  var r = (e.getProgram("colorBlended") || e.getProgram("colorWboit")).id, n = (t.getProgram("colorBlended") || e.getProgram("colorWboit")).id, a = e.materialId, i = t.materialId;
  return r !== n ? r - n : a !== i ? a - i : e.id - t.id;
}
(function(e) {
  e.create = function(t, r) {
    r === void 0 && (r = B8);
    var n = /* @__PURE__ */ new Map(), a = [], i = Ve(), o = Ve(), s = [], u = [], c = !0, l = !0, d = vy.create(), f = d.view, m = d.position, h = d.direction, p = d.up;
    function g(x) {
      if (n.has(x)) return console.warn("RenderObject with id '".concat(x.id, "' already present")), n.get(x);
      var A = Nne(t, x, r);
      return a.push(A), x.type === "direct-volume" ? u.push(A) : s.push(A), n.set(x, A), c = !0, l = !0, A;
    }
    function v(x) {
      var A = n.get(x);
      A && (A.dispose(), C2(a, A), C2(s, A), C2(u, A), n.delete(x), c = !0, l = !0);
    }
    var y = new Qae(), _ = -1;
    function S() {
      for (var x = 23, A = 0, w = a.length; A < w; ++A) a[A].state.visible && (x = 31 * x + a[A].id | 0);
      return (x = NO(x)) === -1 && (x = 0), x;
    }
    function b() {
      return S() !== _ && (l = !0, !0);
    }
    return { view: f, position: m, direction: h, up: p, renderables: a, primitives: { view: f, position: m, direction: h, up: p, renderables: s }, volumes: { view: f, position: m, direction: h, up: p, renderables: u }, syncVisibility: b, update: function(x, A) {
      var w;
      if (vy.update(d), x) for (var C = 0, M = x.length; C < M; ++C) (w = n.get(x[C])) === null || w === void 0 || w.update();
      else for (C = 0, M = a.length; C < M; ++C) a[C].update();
      A ? b() : (c = !0, l = !0);
    }, add: function(x) {
      return y.add(x);
    }, remove: function(x) {
      return y.remove(x);
    }, commit: function(x) {
      return x === void 0 && (x = Number.MAX_VALUE), function(A) {
        for (var w = ga(), C = 0; M = y.tryGetRemove(); ) if (v(M), ++C % 100 == 0 && ga() - w > A) return !1;
        for (; ; ) {
          var M;
          if (!(M = y.tryGetAdd())) break;
          if (g(M), ++C % 100 == 0 && ga() - w > A) return !1;
        }
        return a.sort($ae), !0;
      }(x);
    }, get needsCommit() {
      return !y.isEmpty;
    }, has: function(x) {
      return n.has(x);
    }, clear: function() {
      for (var x = 0, A = a.length; x < A; ++x) a[x].dispose();
      a.length = 0, n.clear(), c = !0, l = !0;
    }, forEach: function(x) {
      n.forEach(x);
    }, get count() {
      return a.length;
    }, get boundingSphere() {
      return c && (xD(a, i, !1), c = !1), i;
    }, get boundingSphereVisible() {
      return l && (xD(a, o, !0), l = !1, _ = S()), o;
    }, getMarkerAverage: function() {
      if (s.length === 0 && u.length === 0) return 0;
      for (var x = 0, A = 0, w = s.length; A < w; ++A) x += s[A].values.markerAverage.ref.value;
      for (A = 0, w = u.length; A < w; ++A) x += u[A].values.markerAverage.ref.value;
      return x / (s.length + u.length);
    } };
  };
})(Yp || (Yp = {}));
var H6 = function() {
  function e(t) {
    this.camera = t, this.t = 0, this.func = e.defaultTransition, this.start = 0, this.inTransition = !1, this.durationMs = 0, this._source = oa.createDefaultSnapshot(), this._target = oa.createDefaultSnapshot(), this._current = oa.createDefaultSnapshot();
  }
  return Object.defineProperty(e.prototype, "source", { get: function() {
    return this._source;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    return this._target;
  }, enumerable: !1, configurable: !0 }), e.prototype.apply = function(t, r, n) {
    r === void 0 && (r = 0), (!this.inTransition || r > 0) && oa.copySnapshot(this._source, this.camera.state), this.inTransition || oa.copySnapshot(this._target, this.camera.state), oa.copySnapshot(this._target, t), this._target.radius > this._target.radiusMax && (this._target.radius = this._target.radiusMax), this._target.radius < 0.01 && (this._target.radius = 0.01), this._target.radiusMax < 0.01 && (this._target.radiusMax = 0.01), !this.inTransition && r <= 0 || t.mode !== void 0 && t.mode !== this.camera.state.mode ? this.finish(this._target) : (this.inTransition = !0, this.func = n || e.defaultTransition, (!this.inTransition || r > 0) && (this.start = this.t, this.durationMs = r));
  }, e.prototype.tick = function(t) {
    this.t = t, this.update();
  }, e.prototype.finish = function(t) {
    oa.copySnapshot(this.camera.state, t), this.inTransition = !1;
  }, e.prototype.update = function() {
    if (this.inTransition) {
      var t = Math.min((this.t - this.start) / this.durationMs, 1);
      t !== 1 ? (this.func(this._current, t, this._source, this._target), oa.copySnapshot(this.camera.state, this._current)) : this.finish(this._target);
    }
  }, e;
}();
(function(e) {
  var t = Gn.identity();
  e.defaultTransition = function(r, n, a, i) {
    oa.copySnapshot(r, i), Gn.slerp(t, Gn.Identity, Gn.rotationTo(t, a.up, i.up), n), D.transformQuat(r.up, a.up, t), D.lerp(r.target, a.target, i.target, n), D.lerp(r.position, a.position, i.position, n), r.radius = Na(a.radius, i.radius, n), r.radiusMax = Na(a.radiusMax, i.radiusMax, n), r.fov = Na(a.fov, i.fov, n), r.fog = Na(a.fog, i.fog, n);
  };
})(H6 || (H6 = {}));
var _D = D(), SD = D(), yg = jt(), oa = function() {
  function e(t, r, n) {
    r === void 0 && (r = Za.create(0, 0, 128, 128)), n === void 0 && (n = {}), this.view = Ee.identity(), this.projection = Ee.identity(), this.projectionView = Ee.identity(), this.inverseProjectionView = Ee.identity(), this.state = e.createDefaultSnapshot(), this.viewOffset = e.ViewOffset(), this.near = 1, this.far = 1e4, this.fogNear = 5e3, this.fogFar = 1e4, this.zoom = 1, this.transition = new H6(this), this.stateChanged = new xd(this.state), this.prevProjection = Ee.identity(), this.prevView = Ee.identity(), this.deltaDirection = D(), this.newPosition = D(), this.viewport = r, this.pixelScale = n.pixelScale || 1, e.copySnapshot(this.state, t);
  }
  return Object.defineProperty(e.prototype, "pixelRatio", { get: function() {
    return (typeof window < "u" ? window.devicePixelRatio : 1) * this.pixelScale;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "position", { get: function() {
    return this.state.position;
  }, set: function(t) {
    D.copy(this.state.position, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "up", { get: function() {
    return this.state.up;
  }, set: function(t) {
    D.copy(this.state.up, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    return this.state.target;
  }, set: function(t) {
    D.copy(this.state.target, t);
  }, enumerable: !1, configurable: !0 }), e.prototype.update = function() {
    var t = this.state;
    if (t.radiusMax === 0) return !1;
    var r = 2 * Math.tan(t.fov / 2) * D.distance(t.position, t.target);
    switch (this.zoom = this.viewport.height / r, function(a) {
      var i = a.state, o = i.radius, s = i.radiusMax, u = (i.mode, i.fog), c = i.clipFar;
      o < 0.01 && (o = 0.01);
      var l = c ? o : s, d = D.distance(a.position, a.target), f = d - o, m = d + l, h = d - l * (-(50 - u) / 50), p = m;
      f = Math.max(Math.min(s, 5), f), m = Math.max(5, m), f === m && (m = f + 0.01), a.near = f, a.far = 2 * m, a.fogNear = h, a.fogFar = p;
    }(this), this.state.mode) {
      case "orthographic":
        (function(a) {
          var i = a.viewport, o = a.zoom, s = a.near, u = a.far, c = a.viewOffset, l = -i.width / 2, d = i.width / 2, f = i.height / 2, m = -i.height / 2, h = (d - l) / (2 * o), p = (f - m) / (2 * o), g = (d + l) / 2, v = (f + m) / 2, y = g - h, _ = g + h, S = v + p, b = v - p;
          if (c.enabled) {
            var x = o / (c.width / c.fullWidth), A = o / (c.height / c.fullHeight), w = (d - l) / c.width, C = (f - m) / c.height;
            _ = (y += w * (c.offsetX / x)) + w * (c.width / x), b = (S -= C * (c.offsetY / A)) - C * (c.height / A);
          }
          Ee.ortho(a.projection, y, _, S, b, s, u), Ee.lookAt(a.view, a.position, a.target, a.up);
        })(this);
        break;
      case "perspective":
        (function(a) {
          var i = a.viewport.width / a.viewport.height, o = a.near, s = a.far, u = a.viewOffset, c = o * Math.tan(0.5 * a.state.fov), l = 2 * c, d = i * l, f = -0.5 * d;
          u.enabled && (f += u.offsetX * d / u.fullWidth, c -= u.offsetY * l / u.fullHeight, d *= u.width / u.fullWidth, l *= u.height / u.fullHeight), Ee.perspective(a.projection, f, f + d, c, c - l, o, s), Ee.lookAt(a.view, a.position, a.target, a.up);
        })(this);
        break;
      default:
        Ja(this.state.mode);
    }
    var n = !Ee.areEqual(this.projection, this.prevProjection, Cn) || !Ee.areEqual(this.view, this.prevView, Cn);
    if (n) {
      if (Ee.mul(this.projectionView, this.projection, this.view), !Ee.tryInvert(this.inverseProjectionView, this.projectionView)) return Ee.copy(this.view, this.prevView), Ee.copy(this.projection, this.prevProjection), Ee.mul(this.projectionView, this.projection, this.view), !1;
      Ee.copy(this.prevView, this.view), Ee.copy(this.prevProjection, this.projection);
    }
    return n;
  }, e.prototype.setState = function(t, r) {
    !Number.isNaN(t.radius) && t.radius <= 0.01 || (this.transition.apply(t, r), this.stateChanged.next(t));
  }, e.prototype.getSnapshot = function() {
    return e.copySnapshot(e.createDefaultSnapshot(), this.state);
  }, e.prototype.getTargetDistance = function(t) {
    return e.targetDistance(t, this.state.fov, this.viewport.width, this.viewport.height);
  }, e.prototype.getFocus = function(t, r, n, a) {
    var i = Math.max(r, 0.01), o = this.getTargetDistance(i);
    D.sub(this.deltaDirection, this.target, this.position), a && D.matchDirection(this.deltaDirection, a, this.deltaDirection), D.setMagnitude(this.deltaDirection, this.deltaDirection, o), D.sub(this.newPosition, t, this.deltaDirection);
    var s = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return s.target = D.clone(t), s.radius = i, s.position = D.clone(this.newPosition), n && D.matchDirection(s.up, n, s.up), s;
  }, e.prototype.getInvariantFocus = function(t, r, n, a) {
    var i = Math.max(r, 0.01), o = this.getTargetDistance(i);
    D.copy(this.deltaDirection, a), D.setMagnitude(this.deltaDirection, this.deltaDirection, o), D.sub(this.newPosition, t, this.deltaDirection);
    var s = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return s.target = D.clone(t), s.radius = i, s.position = D.clone(this.newPosition), D.copy(s.up, n), s;
  }, e.prototype.focus = function(t, r, n, a, i) {
    r > 0 && this.setState(this.getFocus(t, r, a, i), n);
  }, e.prototype.project = function(t, r) {
    return function(n, a, i, o) {
      var s = i.x, u = i.y, c = i.width, l = i.height;
      jt.set(Vu, a[0], a[1], a[2], 1), jt.transformMat4(Vu, Vu, o);
      var d = Vu[3];
      return d !== 0 && (Vu[0] /= d, Vu[1] /= d, Vu[2] /= d), n[0] = (Vu[0] + 1) * c * 0.5 + s, n[1] = (1 - Vu[1]) * l * 0.5 + u, n[2] = 0.5 * (Vu[2] + 1), n[3] = d === 0 ? 0 : 1 / d, n;
    }(t, r, this.viewport, this.projectionView);
  }, e.prototype.unproject = function(t, r) {
    return C0(t, r, this.viewport, this.inverseProjectionView);
  }, e.prototype.getPixelSize = function(t) {
    return this.project(yg, t), this.unproject(_D, yg), yg[0] += 1, this.unproject(SD, yg), D.distance(_D, SD);
  }, e;
}();
(function(e) {
  e.ViewOffset = function() {
    return { enabled: !1, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 };
  }, e.setViewOffset = function(t, r, n, a, i, o, s) {
    t.fullWidth = r, t.fullHeight = n, t.offsetX = a, t.offsetY = i, t.width = o, t.height = s;
  }, e.copyViewOffset = function(t, r) {
    t.enabled = r.enabled, t.fullWidth = r.fullWidth, t.fullHeight = r.fullHeight, t.offsetX = r.offsetX, t.offsetY = r.offsetY, t.width = r.width, t.height = r.height;
  }, e.targetDistance = function(t, r, n, a) {
    var i = Math.max(t, 0.01), o = a < n ? 1 : n / a;
    return Math.abs(i / o / Math.sin(r / 2));
  }, e.createDefaultSnapshot = function() {
    return { mode: "orthographic", fov: Math.PI / 4, position: D.create(0, 0, 100), up: D.create(0, 1, 0), target: D.create(0, 0, 0), radius: 0, radiusMax: 10, fog: 50, clipFar: !0 };
  }, e.copySnapshot = function(t, r) {
    return r && (r.mode !== void 0 && (t.mode = r.mode), r.fov !== void 0 && (t.fov = r.fov), r.position !== void 0 && D.copy(t.position, r.position), r.up !== void 0 && D.copy(t.up, r.up), r.target !== void 0 && D.copy(t.target, r.target), r.radius !== void 0 && (t.radius = r.radius), r.radiusMax !== void 0 && (t.radiusMax = r.radiusMax), r.fog !== void 0 && (t.fog = r.fog), r.clipFar !== void 0 && (t.clipFar = r.clipFar)), t;
  }, e.areSnapshotsEqual = function(t, r) {
    return t.mode === r.mode && t.fov === r.fov && t.radius === r.radius && t.radiusMax === r.radiusMax && t.fog === r.fog && t.clipFar === r.clipFar && D.exactEquals(t.position, r.position) && D.exactEquals(t.up, r.up) && D.exactEquals(t.target, r.target);
  };
})(oa || (oa = {}));
var Jae = { radius: 1, detail: 0 };
function eie(e, t, r) {
  var n = k(k({}, Jae), r), a = n.radius, i = n.detail, o = /* @__PURE__ */ function() {
    var d = [], f = [], m = /* @__PURE__ */ new Map();
    function h(p) {
      var g = "".concat(p[0].toFixed(5), "|").concat(p[1].toFixed(5), "|").concat(p[2].toFixed(5)), v = m.get(g);
      return v === void 0 && (v = d.length / 3, m.set(g, v), d.push.apply(d, p)), v;
    }
    return { vertices: d, indices: f, add: function(p, g, v) {
      f.push(h(p), h(g), h(v));
    } };
  }(), s = o.vertices, u = o.indices;
  (function(d) {
    for (var f = D(), m = D(), h = D(), p = 0; p < t.length; p += 3) D.fromArray(f, e, 3 * t[p + 0]), D.fromArray(m, e, 3 * t[p + 1]), D.fromArray(h, e, 3 * t[p + 2]), l(f, m, h, d);
  })(i), function(d, f) {
    for (var m = 0, h = d.length; m < h; m += 3) D.fromArray(Ro, d, m), D.normalize(Ro, Ro), D.scale(Ro, Ro, f), D.toArray(Ro, d, m);
  }(s, a);
  var c = new Float32Array(s.length);
  return AR(s, u, c, s.length / 3, u.length / 3), { vertices: new Float32Array(s), normals: new Float32Array(c), indices: new Uint32Array(u) };
  function l(d, f, m, h) {
    for (var p = Math.pow(2, h), g = [], v = 0; v <= p; ++v) {
      g[v] = [];
      var y = D();
      D.lerp(y, d, m, v / p);
      var _ = D();
      D.lerp(_, f, m, v / p);
      for (var S = p - v, b = 0; b <= S; ++b) if (b === 0 && v === p) g[v][b] = y;
      else {
        var x = D();
        D.lerp(x, y, _, b / S), g[v][b] = x;
      }
    }
    for (v = 0; v < p; ++v) for (b = 0; b < 2 * (p - v) - 1; ++b) {
      var A = Math.floor(b / 2);
      b % 2 == 0 ? o.add(g[v][A + 1], g[v + 1][A], g[v][A]) : o.add(g[v][A + 1], g[v + 1][A + 1], g[v + 1][A]);
    }
  }
}
var _x, Fs = (1 + Math.sqrt(5)) / 2, tL = (_x || (_x = MR([-1, Fs, 0, 1, Fs, 0, -1, -Fs, 0, 1, -Fs, 0, 0, -1, Fs, 0, 1, Fs, 0, -1, -Fs, 0, 1, -Fs, Fs, 0, -1, Fs, 0, 1, -Fs, 0, -1, -Fs, 0, 1], [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1])), _x), tie = tL.vertices, rie = tL.indices;
function rL(e) {
  return 10 * Math.pow(Math.pow(2, e), 2) + 2;
}
var AD = /* @__PURE__ */ new Map(), nie = Ee.identity();
function aie(e) {
  var t = AD.get(e);
  return t === void 0 && (t = function(r) {
    return eie(tie, rie, { detail: r, radius: 1 });
  }(e), AD.set(e, t)), t;
}
function La(e, t, r, n) {
  Nt.addPrimitive(e, function(a, i, o) {
    return Ee.scaleUniformly(a, Ee.fromTranslation(a, i), o);
  }(nie, t, r), aie(n));
}
var Xu = { radiusTop: 1, radiusBottom: 1, height: 1, radialSegments: 8, heightSegments: 1, topCap: !1, bottomCap: !1, thetaStart: 0, thetaLength: 2 * Math.PI }, wD = D(), CD = D(), To = D(), No = D(), ju = D(), Qm = D(), iie = { height: 1, topCap: !0, bottomCap: !0 }, ED = /* @__PURE__ */ new Map(), DD = D.create(0, 1, 0), tc = D(), bg = D(), MD = D(), Md = Ee(), ID = Ee(), TD = D(), xp = D(), Sx = D();
function gy(e, t, r, n, a) {
  return D.setMagnitude(bg, r, n / 2), D.add(MD, t, bg), a ? D.matchDirection(Sx, DD, bg) : D.copy(Sx, DD), D.set(TD, 1, n, 1), D.makeRotation(ID, Sx, bg), Ee.scale(e, ID, TD), Ee.setTranslation(e, MD);
}
var Yu = new Int32Array(9);
function U8(e) {
  var t = function(a) {
    var i, o, s, u, c, l, d, f, m;
    return Yu[0] = Math.round(1e3 * ((i = a.radiusTop) !== null && i !== void 0 ? i : Xu.radiusTop)), Yu[1] = Math.round(1e3 * ((o = a.radiusBottom) !== null && o !== void 0 ? o : Xu.radiusBottom)), Yu[2] = Math.round(1e3 * ((s = a.height) !== null && s !== void 0 ? s : Xu.height)), Yu[3] = (u = a.radialSegments) !== null && u !== void 0 ? u : Xu.radialSegments, Yu[4] = (c = a.heightSegments) !== null && c !== void 0 ? c : Xu.heightSegments, Yu[5] = ((l = a.topCap) !== null && l !== void 0 ? l : Xu.topCap) ? 1 : 0, Yu[6] = ((d = a.bottomCap) !== null && d !== void 0 ? d : Xu.bottomCap) ? 1 : 0, Yu[7] = Math.round(1e3 * ((f = a.thetaStart) !== null && f !== void 0 ? f : Xu.thetaStart)), Yu[8] = Math.round(1e3 * ((m = a.thetaLength) !== null && m !== void 0 ? m : Xu.thetaLength)), Zi(Yu);
  }(e), r = ED.get(t);
  if (r === void 0) {
    if (e.radialSegments && e.radialSegments <= 4) {
      var n = function(a, i) {
        var o = a.length / 3;
        if (o < 3) throw new Error("need at least 3 points to build a prism");
        var s = k(k({}, iie), i), u = s.height, c = s.topCap, l = s.bottomCap, d = 2 * o, f = 4 * o, m = (c ? 1 : 0) + (l ? 1 : 0);
        o === 3 ? (d += m, f += 3 * m) : o === 4 ? (d += 2 * m, f += 4 * m) : (d += m * o, f += m * o * 3);
        var h = kh(d, f), p = 0.5 * u;
        D.set(wD, 0, 0, -p), D.set(CD, 0, 0, p);
        for (var g = 0; g < o; ++g) {
          var v = (g + 1) % o;
          D.set(To, a[3 * g], a[3 * g + 1], -p), D.set(No, a[3 * v], a[3 * v + 1], -p), D.set(ju, a[3 * v], a[3 * v + 1], p), D.set(Qm, a[3 * g], a[3 * g + 1], p), h.addQuad(To, No, ju, Qm);
        }
        if (o === 3) c && (D.set(To, a[0], a[1], -p), D.set(No, a[3], a[4], -p), D.set(ju, a[6], a[7], -p), h.add(ju, No, To)), l && (D.set(To, a[0], a[1], p), D.set(No, a[3], a[4], p), D.set(ju, a[6], a[7], p), h.add(To, No, ju));
        else if (o === 4) c && (D.set(To, a[0], a[1], -p), D.set(No, a[3], a[4], -p), D.set(ju, a[6], a[7], -p), D.set(Qm, a[9], a[10], -p), h.addQuad(Qm, ju, No, To)), l && (D.set(To, a[0], a[1], p), D.set(No, a[3], a[4], p), D.set(ju, a[6], a[7], p), D.set(Qm, a[9], a[10], p), h.addQuad(To, No, ju, Qm));
        else for (g = 0; g < o; ++g) v = (g + 1) % o, c && (D.set(To, a[3 * g], a[3 * g + 1], -p), D.set(No, a[3 * v], a[3 * v + 1], -p), h.add(wD, No, To)), l && (D.set(To, a[3 * g], a[3 * g + 1], p), D.set(No, a[3 * v], a[3 * v + 1], p), h.add(To, No, CD));
        return h.getPrimitive();
      }(h3(Math.max(3, e.radialSegments), !0, e.radiusTop), e);
      r = p3(n, Ee.rotX90);
    } else r = function(a) {
      var i = k(k({}, Xu), a), o = i.radiusTop, s = i.radiusBottom, u = i.height, c = i.radialSegments, l = i.heightSegments, d = i.topCap, f = i.bottomCap, m = i.thetaStart, h = i.thetaLength, p = [], g = [], v = [], y = 0, _ = [], S = u / 2;
      return function() {
        for (var x = D.zero(), A = (s - o) / u, w = 0; w <= l; ++w) {
          for (var C = [], M = w / l, T = M * (s - o) + o, N = 0; N <= c; ++N) {
            var I = N / c * h + m, P = Math.sin(I), O = Math.cos(I);
            g.push(T * P, -M * u + S, T * O), D.normalize(x, D.set(x, P, A, O)), v.push.apply(v, x), C.push(y++);
          }
          _.push(C);
        }
        for (N = 0; N < c; ++N) for (w = 0; w < l; ++w) {
          var F = _[w][N], R = _[w + 1][N], G = _[w + 1][N + 1], L = _[w][N + 1];
          p.push(F, R, L), p.push(R, G, L);
        }
      }(), d && o > 0 && b(!0), f && s > 0 && b(!1), { vertices: new Float32Array(g), normals: new Float32Array(v), indices: new Uint32Array(p) };
      function b(x) {
        for (var A = x === !0 ? o : s, w = x === !0 ? 1 : -1, C = y, M = 1; M <= c; ++M) g.push(0, S * w, 0), v.push(0, w, 0), ++y;
        var T = y;
        for (M = 0; M <= c; ++M) {
          var N = M / c * h + m, I = Math.cos(N), P = Math.sin(N);
          g.push(A * P, S * w, A * I), v.push(0, w, 0), ++y;
        }
        for (M = 0; M < c; ++M) {
          var O = C + M, F = T + M;
          x === !0 ? p.push(F, F + 1, O) : p.push(F + 1, F, O);
        }
      }
    }(e);
    ED.set(t, r);
  }
  return r;
}
function Ba(e, t, r, n, a) {
  var i = D.distance(t, r) * n;
  D.sub(tc, r, t), gy(Md, t, tc, i, !0), Nt.addPrimitive(e, Md, U8(a));
}
function oie(e, t, r, n, a, i) {
  var o = D.distance(t, r) * n, s = U8(i);
  D.sub(tc, r, t), D.add(xp, t, a), gy(Md, xp, tc, o, !0), Nt.addPrimitive(e, Md, s), D.sub(xp, t, a), gy(Md, xp, tc, o, !0), Nt.addPrimitive(e, Md, s);
}
function $0(e, t, r, n, a, i) {
  var o = Math.floor(a / 2), s = 1 / a;
  if (n < 1) {
    var u = n / 2 / a;
    n += a % 2 == 1 ? u : -u;
  }
  var c = D.distance(t, r) * n, l = U8(i);
  D.sub(tc, r, t);
  for (var d = 0; d < o; ++d) {
    var f = s * (2 * d + 1);
    D.setMagnitude(tc, tc, c * f), D.add(xp, t, tc), gy(Md, xp, tc, c * s, !1), Nt.addPrimitive(e, Md, l);
  }
}
var Nt, Jn = D(), ND = ka(), kc = D(), Wu = D(), bf = D(), xg = D(), ns = D.fromArray, sie = D.triangleNormal, PD = D.copy, _g = D.transformMat4, BD = D.transformMat3, OD = ka.directionTransform, fu = Ye.add3, Ax = Ye.add;
(function(e) {
  function t(n, a, i, o) {
    var s = n.vertices, u = n.normals, c = n.indices, l = n.groups, d = n.currentGroup, f = s.elementCount;
    fu(s, a[0], a[1], a[2]), fu(s, i[0], i[1], i[2]), fu(s, o[0], o[1], o[2]), sie(Jn, a, i, o);
    for (var m = 0; m < 3; ++m) fu(u, Jn[0], Jn[1], Jn[2]), Ax(l, d);
    fu(c, f, f + 1, f + 2);
  }
  function r(n, a, i) {
    for (var o = i.vertices, s = i.normals, u = i.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, m = n.currentGroup, h = c.elementCount, p = OD(ND, a), g = 0, v = o.length; g < v; g += 3) _g(Jn, ns(Jn, o, g), a), fu(c, Jn[0], Jn[1], Jn[2]), BD(Jn, ns(Jn, s, g), p), fu(l, Jn[0], Jn[1], Jn[2]), Ax(f, m);
    for (g = 0, v = u.length; g < v; g += 3) fu(d, u[g] + h, u[g + 1] + h, u[g + 2] + h);
  }
  e.createState = function(n, a, i) {
    return n === void 0 && (n = 2048), a === void 0 && (a = 1024), { currentGroup: -1, vertices: Ye.create(Float32Array, 3, a, i ? i.vertexBuffer.ref.value : n), normals: Ye.create(Float32Array, 3, a, i ? i.normalBuffer.ref.value : n), indices: Ye.create(Uint32Array, 3, 3 * a, i ? i.indexBuffer.ref.value : 3 * n), groups: Ye.create(Float32Array, 1, a, i ? i.groupBuffer.ref.value : n), mesh: i };
  }, e.addTriangle = t, e.addTriangleStrip = function(n, a, i) {
    ns(bf, a, 3 * i[0]), ns(xg, a, 3 * i[1]);
    for (var o = 2, s = i.length; o < s; o += 2) PD(kc, bf), PD(Wu, xg), ns(bf, a, 3 * i[o]), ns(xg, a, 3 * i[o + 1]), t(n, kc, Wu, bf), t(n, Wu, xg, bf);
  }, e.addTriangleFan = function(n, a, i) {
    ns(kc, a, 3 * i[0]);
    for (var o = 2, s = i.length; o < s; ++o) ns(Wu, a, 3 * i[o - 1]), ns(bf, a, 3 * i[o]), t(n, kc, bf, Wu);
  }, e.addPrimitive = r, e.addPrimitiveFlipped = function(n, a, i) {
    for (var o = i.vertices, s = i.normals, u = i.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, m = n.currentGroup, h = c.elementCount, p = OD(ND, a), g = 0, v = o.length; g < v; g += 3) _g(Jn, ns(Jn, o, g), a), fu(c, Jn[0], Jn[1], Jn[2]), BD(Jn, ns(Jn, s, g), p), fu(l, -Jn[0], -Jn[1], -Jn[2]), Ax(f, m);
    for (g = 0, v = u.length; g < v; g += 3) fu(d, u[g + 2] + h, u[g + 1] + h, u[g] + h);
  }, e.addCage = function(n, a, i, o, s, u) {
    for (var c = i.vertices, l = i.edges, d = { radiusTop: o, radiusBottom: o, radialSegments: u }, f = 0, m = l.length; f < m; f += 2) ns(kc, c, 3 * l[f]), ns(Wu, c, 3 * l[f + 1]), _g(kc, kc, a), _g(Wu, Wu, a), La(n, kc, o, s), La(n, Wu, o, s), Ba(n, kc, Wu, 1, d);
  }, e.addMesh = function(n, a, i) {
    r(n, a, { vertices: i.vertexBuffer.ref.value.subarray(0, 3 * i.vertexCount), normals: i.normalBuffer.ref.value.subarray(0, 3 * i.vertexCount), indices: i.indexBuffer.ref.value.subarray(0, 3 * i.triangleCount) });
  }, e.getMesh = function(n) {
    var a = n.vertices, i = n.normals, o = n.indices, s = n.groups, u = n.mesh, c = Ye.compact(a, !0), l = Ye.compact(o, !0), d = Ye.compact(i, !0), f = Ye.compact(s, !0);
    return Xt.create(c, l, d, f, n.vertices.elementCount, n.indices.elementCount, u);
  };
})(Nt || (Nt = {}));
var G8 = { sceneBoundingSpheres: V.Boolean(!1, { description: "Show full scene bounding spheres." }), visibleSceneBoundingSpheres: V.Boolean(!1, { description: "Show visible scene bounding spheres." }), objectBoundingSpheres: V.Boolean(!1, { description: "Show bounding spheres of visible render objects." }), instanceBoundingSpheres: V.Boolean(!1, { description: "Show bounding spheres of visible instances." }) }, uie = function() {
  function e(t, r, n) {
    this.objectsData = /* @__PURE__ */ new Map(), this.instancesData = /* @__PURE__ */ new Map(), this.scene = Yp.create(t, y3), this.parent = r, this._props = k(k({}, V.getDefaultValues(G8)), n);
  }
  return e.prototype.update = function() {
    var t = this, r = Sg(this.scene, this.parent.boundingSphere, this.sceneData, $t.lightgrey, cie);
    r && (this.sceneData = r);
    var n = Sg(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, $t.black, lie);
    n && (this.visibleSceneData = n), this.parent.forEach(function(a, i) {
      var o = t.objectsData.get(i), s = Sg(t.scene, a.values.boundingSphere.ref.value, o, $t.tomato, die);
      s && t.objectsData.set(i, s);
      var u = t.instancesData.get(i), c = Sg(t.scene, a.values.invariantBoundingSphere.ref.value, u, $t.skyblue, fie, { aTransform: i.values.aTransform, matrix: i.values.matrix, transform: i.values.transform, extraTransform: i.values.extraTransform, uInstanceCount: i.values.uInstanceCount, instanceCount: i.values.instanceCount, aInstance: i.values.aInstance, hasReflection: i.values.hasReflection });
      c && t.instancesData.set(i, c);
    }), this.objectsData.forEach(function(a, i) {
      t.parent.has(i) || (t.scene.remove(a.renderObject), t.objectsData.delete(i));
    }), this.instancesData.forEach(function(a, i) {
      t.parent.has(i) || (t.scene.remove(a.renderObject), t.instancesData.delete(i));
    }), this.scene.update(void 0, !1), this.scene.commit();
  }, e.prototype.syncVisibility = function() {
    var t = this;
    this.sceneData && (this.sceneData.renderObject.state.visible = this._props.sceneBoundingSpheres), this.visibleSceneData && (this.visibleSceneData.renderObject.state.visible = this._props.visibleSceneBoundingSpheres), this.parent.forEach(function(r, n) {
      var a = t.objectsData.get(n);
      a && (a.renderObject.state.visible = n.state.visible && t._props.objectBoundingSpheres);
      var i = t.instancesData.get(n);
      i && (i.renderObject.state.visible = n.state.visible && t._props.instanceBoundingSpheres);
    });
  }, e.prototype.clear = function() {
    this.sceneData = void 0, this.objectsData.clear(), this.scene.clear();
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this._props.sceneBoundingSpheres || this._props.visibleSceneBoundingSpheres || this._props.objectBoundingSpheres || this._props.instanceBoundingSpheres;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "props", { get: function() {
    return this._props;
  }, enumerable: !1, configurable: !0 }), e.prototype.setProps = function(t) {
    Object.assign(this._props, t), this.isEnabled && this.update();
  }, e;
}();
function Sg(e, t, r, n, a, i) {
  if (!r || !Ve.equals(r.boundingSphere, t)) {
    var o = function(u, c) {
      var l = 2, d = rL(l), f = Nt.createState(d, d / 2, c);
      if (u.radius && (La(f, u.center, u.radius, l), Ve.hasExtrema(u))) for (var m = 0, h = u.extrema; m < h.length; m++)
        La(f, h[m], 1, 0);
      return Nt.getMesh(f);
    }(t, r && r.mesh), s = r ? r.renderObject : function(u, c, l, d) {
      var f = Xt.Utils.createValuesSimple(u, { alpha: 0.1, doubleSided: !1 }, c, 1, d);
      return g1("mesh", f, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, l);
    }(o, n, a, i);
    return r ? U.updateIfChanged(s.values.drawCount, vi.getDrawCount(o)) : e.add(s), { boundingSphere: Ve.clone(t), renderObject: s, mesh: o };
  }
}
var cie = Sl(), lie = Sl(), die = Sl(), fie = Sl(), wx = D(), Cx = D(), FD = D(), nL = { maxFps: V.Numeric(30, { min: 10, max: 60, step: 10 }), preferAtomPixelPadding: V.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." }) }, mie = function() {
  function e(t, r, n, a, i) {
    var o = this;
    i === void 0 && (i = {}), this.canvasIdentify = t, this.lociGetter = r, this.input = n, this.camera = a, this.ev = xo.create(), this.events = { hover: this.ev(), drag: this.ev(), click: this.ev() }, this.startX = -1, this.startY = -1, this.endX = -1, this.endY = -1, this.id = void 0, this.position = void 0, this.currentIdentifyT = 0, this.isInteracting = !1, this.prevLoci = fr.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = $f.create(0), this.button = $f.create(0), this.modifiers = Fp.None, this.props = k(k({}, V.getDefaultValues(nL)), i), n.drag.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, f = s.modifiers;
      o.isInteracting = !0, o.drag(u, c, l, d, f);
    }), n.move.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.inside, d = s.buttons, f = s.button, m = s.modifiers;
      l && !o.isInteracting && o.move(u, c, d, f, m);
    }), n.leave.subscribe(function() {
      o.leave();
    }), n.click.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, f = s.modifiers;
      o.outsideViewport(u, c) || o.click(u, c, l, d, f);
    }), n.interactionEnd.subscribe(function() {
      o.isInteracting = !1;
    }), n.modifiers.subscribe(function(s) {
      o.modify(s);
    });
  }
  return e.prototype.setProps = function(t) {
    Object.assign(this.props, t);
  }, e.prototype.identify = function(t, r) {
    var n = this.startX !== this.endX || this.startY !== this.endY;
    if (t !== 2) {
      if (n) {
        var a = this.canvasIdentify(this.endX, this.endY);
        this.id = a == null ? void 0 : a.id, this.position = a == null ? void 0 : a.position, this.startX = this.endX, this.startY = this.endY;
      }
      if (t === 1) {
        var i = this.getLoci(this.id, this.position);
        return this.events.click.next({ current: i, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: Ze.create(this.endX, this.endY), position: this.position }), void (this.prevLoci = i);
      }
      if (this.inside && this.currentIdentifyT === r && n && !this.outsideViewport(this.endX, this.endY)) {
        var o = this.getLoci(this.id, this.position);
        this.events.hover.next({ current: o, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: Ze.create(this.endX, this.endY), position: this.position }), this.prevLoci = o;
      }
    } else n && !this.outsideViewport(this.startX, this.startY) && (this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: Ze.create(this.startX, this.startY), pageEnd: Ze.create(this.endX, this.endY) }), this.startX = this.endX, this.startY = this.endY);
  }, e.prototype.tick = function(t) {
    this.inside && t - this.prevT > 1e3 / this.props.maxFps && (this.prevT = t, this.currentIdentifyT = t, this.identify(this.isInteracting ? 2 : 0, t));
  }, e.prototype.leave = function() {
    this.inside = !1, fr.Loci.isEmpty(this.prevLoci) || (this.prevLoci = fr.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers }));
  }, e.prototype.move = function(t, r, n, a, i) {
    this.inside = !0, this.buttons = n, this.button = a, this.modifiers = i, this.endX = t, this.endY = r;
  }, e.prototype.click = function(t, r, n, a, i) {
    this.endX = t, this.endY = r, this.buttons = n, this.button = a, this.modifiers = i, this.identify(1, 0);
  }, e.prototype.drag = function(t, r, n, a, i) {
    this.endX = t, this.endY = r, this.buttons = n, this.button = a, this.modifiers = i, this.identify(2, 0);
  }, e.prototype.modify = function(t) {
    Fp.areEqual(t, this.modifiers) || (this.modifiers = t, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: Ze.create(this.endX, this.endY), position: this.position }));
  }, e.prototype.outsideViewport = function(t, r) {
    var n = this.input, a = this.camera.viewport;
    return t *= n.pixelRatio, r *= n.pixelRatio, t > a.x + a.width || n.height - r > a.y + a.height || t < a.x || n.height - r < a.y;
  }, e.prototype.getLoci = function(t, r) {
    var n, a = this.lociGetter(t), i = a.repr, o = a.loci;
    if (r && i && Pt.isLoci(o) && o.bonds.length === 2) {
      var s = o.bonds[0], u = s.aUnit, c = s.aIndex;
      u.conformation.position(u.elements[c], wx), D.sub(FD, this.camera.state.position, this.camera.state.target), D.projectPointOnPlane(Cx, r, FD, wx);
      var l = this.camera.getPixelSize(Cx), d = i.theme.size.size(o.bonds[0]) * ((n = i.props.sizeFactor) !== null && n !== void 0 ? n : 1);
      if (i.props.lineSizeAttenuation === !1 && (d *= l / 2), d += this.props.preferAtomPixelPadding * l, D.distance(Cx, wx) < d) return { repr: i, loci: Pt.toFirstStructureElementLoci(o) };
    }
    return { repr: i, loci: o };
  }, e.prototype.dispose = function() {
    this.ev.dispose();
  }, e;
}(), pie = { edgeThresholdMin: V.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 1e-4 }, { description: "Trims the algorithm from processing darks." }), edgeThresholdMax: V.Numeric(0.063, { min: 0.063, max: 0.333, step: 1e-3 }, { description: "The minimum amount of local contrast required to apply algorithm." }), iterations: V.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }), subpixelQuality: V.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." }) }, hie = function() {
  function e(t, r) {
    var n, a, i, o, s, u;
    this.webgl = t, this.renderable = (n = t, i = (a = r).getWidth(), o = a.getHeight(), s = k(k({}, Qa), { tColor: U.create(a), uTexSizeInv: U.create(Ze.create(1 / i, 1 / o)), dEdgeThresholdMin: U.create(0.0312), dEdgeThresholdMax: U.create(0.125), dIterations: U.create(12), dSubpixelQuality: U.create(0.3) }), u = k({}, vie), Ga(Ua(n, "triangles", gie, u, s), s));
  }
  return e.prototype.updateState = function(t) {
    var r = this.webgl, n = r.gl, a = r.state;
    a.enable(n.SCISSOR_TEST), a.disable(n.BLEND), a.disable(n.DEPTH_TEST), a.depthMask(!1);
    var i = t.x, o = t.y, s = t.width, u = t.height;
    n.viewport(i, o, s, u), n.scissor(i, o, s, u), a.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT);
  }, e.prototype.setSize = function(t, r) {
    U.update(this.renderable.values.uTexSizeInv, Ze.set(this.renderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r));
  }, e.prototype.update = function(t, r) {
    var n = this.renderable.values, a = r.edgeThresholdMin, i = r.edgeThresholdMax, o = r.iterations, s = r.subpixelQuality, u = !1;
    n.tColor.ref.value !== t && (U.update(this.renderable.values.tColor, t), u = !0), n.dEdgeThresholdMin.ref.value !== a && (u = !0), U.updateIfChanged(n.dEdgeThresholdMin, a), n.dEdgeThresholdMax.ref.value !== i && (u = !0), U.updateIfChanged(n.dEdgeThresholdMax, i), n.dIterations.ref.value !== o && (u = !0), U.updateIfChanged(n.dIterations, o), n.dSubpixelQuality.ref.value !== s && (u = !0), U.updateIfChanged(n.dSubpixelQuality, s), u && this.renderable.update();
  }, e.prototype.render = function(t, r) {
    r ? r.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.renderable.render();
  }, e;
}(), vie = k(k({}, ei), { tColor: Kt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ze("v2"), dEdgeThresholdMin: Ht("number"), dEdgeThresholdMax: Ht("number"), dIterations: Ht("number"), dSubpixelQuality: Ht("number") }), gie = Rn("fxaa", Yi, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

// adapted from https://github.com/kosua20/Rendu
// MIT License Copyright (c) 2017 Simon Rodriguez

#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))

float rgb2luma(vec3 rgb){
    return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114)));
}

float sampleLuma(vec2 uv) {
    return rgb2luma(texture2D(tColor, uv).rgb);
}

float sampleLuma(vec2 uv, float uOffset, float vOffset) {
    uv += uTexSizeInv * vec2(uOffset, vOffset);
    return sampleLuma(uv);
}

void main(void) {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec2 inverseScreenSize = uTexSizeInv;

    vec4 colorCenter = texture2D(tColor, coords);

    // Luma at the current fragment
    float lumaCenter = rgb2luma(colorCenter.rgb);

    // Luma at the four direct neighbours of the current fragment.
    float lumaDown = sampleLuma(coords, 0.0, -1.0);
    float lumaUp = sampleLuma(coords, 0.0, 1.0);
    float lumaLeft = sampleLuma(coords, -1.0, 0.0);
    float lumaRight = sampleLuma(coords, 1.0, 0.0);

    // Find the maximum and minimum luma around the current fragment.
    float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
    float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));

    // Compute the delta.
    float lumaRange = lumaMax - lumaMin;

    // If the luma variation is lower that a threshold (or if we are in a really dark area),
    // we are not on an edge, don't perform any AA.
    if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) {
        gl_FragColor = colorCenter;
        return;
    }

    // Query the 4 remaining corners lumas.
    float lumaDownLeft = sampleLuma(coords, -1.0, -1.0);
    float lumaUpRight = sampleLuma(coords, 1.0, 1.0);
    float lumaUpLeft = sampleLuma(coords, -1.0, 1.0);
    float lumaDownRight = sampleLuma(coords, 1.0, -1.0);

    // Combine the four edges lumas (using intermediary variables for future computations
    // with the same values).
    float lumaDownUp = lumaDown + lumaUp;
    float lumaLeftRight = lumaLeft + lumaRight;

    // Same for corners
    float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
    float lumaDownCorners = lumaDownLeft + lumaDownRight;
    float lumaRightCorners = lumaDownRight + lumaUpRight;
    float lumaUpCorners = lumaUpRight + lumaUpLeft;

    // Compute an estimation of the gradient along the horizontal and vertical axis.
    float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);
    float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);

    // Is the local edge horizontal or vertical ?
    bool isHorizontal = (edgeHorizontal >= edgeVertical);

    // Choose the step size (one pixel) accordingly.
    float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;

    // Select the two neighboring texels lumas in the opposite direction to the local edge.
    float luma1 = isHorizontal ? lumaDown : lumaLeft;
    float luma2 = isHorizontal ? lumaUp : lumaRight;
    // Compute gradients in this direction.
    float gradient1 = luma1 - lumaCenter;
    float gradient2 = luma2 - lumaCenter;

    // Which direction is the steepest ?
    bool is1Steepest = abs(gradient1) >= abs(gradient2);

    // Gradient in the corresponding direction, normalized.
    float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));

    // Average luma in the correct direction.
    float lumaLocalAverage = 0.0;
    if(is1Steepest){
        // Switch the direction
        stepLength = -stepLength;
        lumaLocalAverage = 0.5 * (luma1 + lumaCenter);
    } else {
        lumaLocalAverage = 0.5 * (luma2 + lumaCenter);
    }

    // Shift UV in the correct direction by half a pixel.
    vec2 currentUv = coords;
    if(isHorizontal){
        currentUv.y += stepLength * 0.5;
    } else {
        currentUv.x += stepLength * 0.5;
    }

    // Compute offset (for each iteration step) in the right direction.
    vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);
    // Compute UVs to explore on each side of the edge, orthogonally.
    // The QUALITY allows us to step faster.
    vec2 uv1 = currentUv - offset * QUALITY(0);
    vec2 uv2 = currentUv + offset * QUALITY(0);

    // Read the lumas at both current extremities of the exploration segment,
    // and compute the delta wrt to the local average luma.
    float lumaEnd1 = sampleLuma(uv1);
    float lumaEnd2 = sampleLuma(uv2);
    lumaEnd1 -= lumaLocalAverage;
    lumaEnd2 -= lumaLocalAverage;

    // If the luma deltas at the current extremities is larger than the local gradient,
    // we have reached the side of the edge.
    bool reached1 = abs(lumaEnd1) >= gradientScaled;
    bool reached2 = abs(lumaEnd2) >= gradientScaled;
    bool reachedBoth = reached1 && reached2;

    // If the side is not reached, we continue to explore in this direction.
    if(!reached1){
        uv1 -= offset * QUALITY(1);
    }
    if(!reached2){
        uv2 += offset * QUALITY(1);
    }

    // If both sides have not been reached, continue to explore.
    if(!reachedBoth){
        for(int i = 2; i < dIterations; i++){
            // If needed, read luma in 1st direction, compute delta.
            if(!reached1){
                lumaEnd1 = sampleLuma(uv1);
                lumaEnd1 = lumaEnd1 - lumaLocalAverage;
            }
            // If needed, read luma in opposite direction, compute delta.
            if(!reached2){
                lumaEnd2 = sampleLuma(uv2);
                lumaEnd2 = lumaEnd2 - lumaLocalAverage;
            }
            // If the luma deltas at the current extremities is larger than the local gradient,
            // we have reached the side of the edge.
            reached1 = abs(lumaEnd1) >= gradientScaled;
            reached2 = abs(lumaEnd2) >= gradientScaled;
            reachedBoth = reached1 && reached2;

            // If the side is not reached, we continue to explore in this direction,
            // with a variable quality.
            if(!reached1){
                uv1 -= offset * QUALITY(i);
            }
            if(!reached2){
                uv2 += offset * QUALITY(i);
            }

            // If both sides have been reached, stop the exploration.
            if(reachedBoth){
                break;
            }
        }
    }

    // Compute the distances to each side edge of the edge (!).
    float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y);
    float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y);

    // In which direction is the side of the edge closer ?
    bool isDirection1 = distance1 < distance2;
    float distanceFinal = min(distance1, distance2);

    // Thickness of the edge.
    float edgeThickness = (distance1 + distance2);

    // Is the luma at center smaller than the local average ?
    bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;

    // If the luma at center is smaller than at its neighbour,
    // the delta luma at each end should be positive (same variation).
    bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller;
    bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller;

    // Only keep the result in the direction of the closer side of the edge.
    bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;

    // UV offset: read in the direction of the closest side of the edge.
    float pixelOffset = - distanceFinal / edgeThickness + 0.5;

    // If the luma variation is incorrect, do not offset.
    float finalOffset = correctVariation ? pixelOffset : 0.0;

    // Sub-pixel shifting
    // Full weighted average of the luma over the 3x3 neighborhood.
    float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);
    // Ratio of the delta between the global average and the center luma,
    // over the luma range in the 3x3 neighborhood.
    float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);
    float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
    // Compute a sub-pixel offset based on this delta.
    float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality);

    // Pick the biggest of the two offsets.
    finalOffset = max(finalOffset, subPixelOffsetFinal);

    // Compute the final UV coordinates.
    vec2 finalUv = coords;
    if(isHorizontal){
        finalUv.y += finalOffset * stepLength;
    } else {
        finalUv.x += finalOffset * stepLength;
    }

    // Read the color at the new UV coordinates, and use it.
    gl_FragColor = texture2D(tColor, finalUv);
}
`), yie = { edgeThreshold: V.Numeric(0.1, { min: 0.05, max: 0.15, step: 0.01 }), maxSearchSteps: V.Numeric(16, { min: 0, max: 32, step: 1 }) }, bie = function() {
  function e(t, r) {
    if (this.webgl = t, this._supported = !1, typeof HTMLImageElement < "u") {
      var n = r.getWidth(), a = r.getHeight();
      this.edgesTarget = t.createRenderTarget(n, a, !1, "uint8", "linear"), this.weightsTarget = t.createRenderTarget(n, a, !1, "uint8", "linear"), this.edgesRenderable = function(i, o) {
        var s = o.getWidth(), u = o.getHeight(), c = k(k({}, Qa), { tColor: U.create(o), uTexSizeInv: U.create(Ze.create(1 / s, 1 / u)), uViewport: U.create(jt()), dEdgeThreshold: U.create(0.1) }), l = k({}, xie);
        return Ga(Ua(i, "triangles", _ie, l, c), c);
      }(t, r), this.weightsRenderable = function(i, o) {
        var s = o.getWidth(), u = o.getHeight(), c = u6(i.gl, i.extensions, "image-uint8", "rgb", "ubyte", "linear"), l = u6(i.gl, i.extensions, "image-uint8", "rgba", "ubyte", "nearest"), d = k(k({}, Qa), { tEdges: U.create(o), tArea: U.create(c), tSearch: U.create(l), uTexSizeInv: U.create(Ze.create(1 / s, 1 / u)), uViewport: U.create(jt()), dMaxSearchSteps: U.create(16) });
        g9("data:image/png;base64, ", d.tArea, c), g9("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=", d.tSearch, l);
        var f = k({}, Sie);
        return Ga(Ua(i, "triangles", Aie, f, d), d);
      }(t, this.edgesTarget.texture), this.blendRenderable = function(i, o, s) {
        var u = o.getWidth(), c = o.getHeight(), l = k(k({}, Qa), { tColor: U.create(o), tWeights: U.create(s), uTexSizeInv: U.create(Ze.create(1 / u, 1 / c)), uViewport: U.create(jt()) }), d = k({}, wie);
        return Ga(Ua(i, "triangles", Cie, d, l), l);
      }(t, r, this.weightsTarget.texture), this._supported = !0;
    } else zr && console.log('Missing "HTMLImageElement" required for "SMAA"');
  }
  return Object.defineProperty(e.prototype, "supported", { get: function() {
    return this._supported;
  }, enumerable: !1, configurable: !0 }), e.prototype.updateState = function(t) {
    var r = this.webgl, n = r.gl, a = r.state;
    a.enable(n.SCISSOR_TEST), a.disable(n.BLEND), a.disable(n.DEPTH_TEST), a.depthMask(!1);
    var i = t.x, o = t.y, s = t.width, u = t.height;
    n.viewport(i, o, s, u), n.scissor(i, o, s, u), a.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), U.update(this.edgesRenderable.values.uViewport, Za.toVec4(this.edgesRenderable.values.uViewport.ref.value, t)), U.update(this.weightsRenderable.values.uViewport, Za.toVec4(this.weightsRenderable.values.uViewport.ref.value, t)), U.update(this.blendRenderable.values.uViewport, Za.toVec4(this.blendRenderable.values.uViewport.ref.value, t));
  }, e.prototype.setSize = function(t, r) {
    var n = this.edgesTarget.getWidth(), a = this.edgesTarget.getHeight();
    t === n && r === a || (this.edgesTarget.setSize(t, r), this.weightsTarget.setSize(t, r), U.update(this.edgesRenderable.values.uTexSizeInv, Ze.set(this.edgesRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), U.update(this.weightsRenderable.values.uTexSizeInv, Ze.set(this.weightsRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), U.update(this.blendRenderable.values.uTexSizeInv, Ze.set(this.blendRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)));
  }, e.prototype.update = function(t, r) {
    var n = !1;
    this.edgesRenderable.values.tColor.ref.value !== t && (U.update(this.edgesRenderable.values.tColor, t), n = !0), this.edgesRenderable.values.dEdgeThreshold.ref.value !== r.edgeThreshold && (U.update(this.edgesRenderable.values.dEdgeThreshold, r.edgeThreshold), n = !0), n && this.edgesRenderable.update(), this.weightsRenderable.values.dMaxSearchSteps.ref.value !== r.maxSearchSteps && (U.update(this.weightsRenderable.values.dMaxSearchSteps, r.maxSearchSteps), this.weightsRenderable.update()), this.blendRenderable.values.tColor.ref.value !== t && (U.update(this.blendRenderable.values.tColor, t), this.blendRenderable.update());
  }, e.prototype.render = function(t, r) {
    this.edgesTarget.bind(), this.updateState(t), this.edgesRenderable.render(), this.weightsTarget.bind(), this.updateState(t), this.weightsRenderable.render(), r ? r.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.blendRenderable.render();
  }, e;
}(), xie = k(k({}, ei), { tColor: Kt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ze("v2"), uViewport: ze("v4"), dEdgeThreshold: Ht("number") }), _ie = Rn("smaa-edges", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[3];

void SMAAEdgeDetectionVS(vec2 texCoord) {
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component
    vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAAEdgeDetectionVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[3];

vec4 SMAAColorEdgeDetectionPS(vec2 texcoord, vec4 offset[3], sampler2D colorTex) {
    vec2 threshold = vec2(dEdgeThreshold, dEdgeThreshold);

    // Calculate color deltas:
    vec4 delta;
    vec3 C = texture2D(colorTex, texcoord).rgb;

    vec3 Cleft = texture2D(colorTex, offset[0].xy).rgb;
    vec3 t = abs(C - Cleft);
    delta.x = max(max(t.r, t.g), t.b);

    vec3 Ctop = texture2D(colorTex, offset[0].zw).rgb;
    t = abs(C - Ctop);
    delta.y = max(max(t.r, t.g), t.b);

    // We do the usual threshold:
    vec2 edges = step(threshold, delta.xy);

    // Then discard if there is no edge:
    if (dot(edges, vec2(1.0, 1.0 )) == 0.0)
        discard;

    // Calculate right and bottom deltas:
    vec3 Cright = texture2D(colorTex, offset[1].xy).rgb;
    t = abs( C - Cright );
    delta.z = max(max(t.r, t.g), t.b);

    vec3 Cbottom  = texture2D(colorTex, offset[1].zw).rgb;
    t = abs(C - Cbottom);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the maximum delta in the direct neighborhood:
    float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w );

    // Calculate left-left and top-top deltas:
    vec3 Cleftleft  = texture2D(colorTex, offset[2].xy).rgb;
    t = abs( C - Cleftleft );
    delta.z = max(max(t.r, t.g), t.b);

    vec3 Ctoptop = texture2D(colorTex, offset[2].zw).rgb;
    t = abs(C - Ctoptop);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the final maximum delta:
    maxDelta = max(max(maxDelta, delta.z), delta.w);

    // Local contrast adaptation in action:
    edges.xy *= step(0.5 * maxDelta, delta.xy);

    return vec4(edges, 0.0, 0.0);
}

void main() {
    gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor);
}
`), Sie = k(k({}, ei), { tEdges: Kt("texture", "rgba", "ubyte", "linear"), tArea: Kt("texture", "rgb", "ubyte", "linear"), tSearch: Kt("texture", "rgba", "ubyte", "nearest"), uTexSizeInv: ze("v2"), uViewport: ze("v4"), dMaxSearchSteps: Ht("number") }), Aie = Rn("smaa-weights", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[3];
varying vec2 vPixCoord;

void SMAABlendingWeightCalculationVS(vec2 texCoord) {
    vPixCoord = texCoord / uTexSizeInv;

    // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.25, 0.125, 1.25, 0.125); // WebGL port note: Changed sign in Y and W components
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.125, 0.25, -0.125, -1.25); // WebGL port note: Changed sign in Y and W components

    // And these for the searches, they indicate the ends of the loops:
    vOffset[2] = vec4(vOffset[0].xz, vOffset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * uTexSizeInv.xxyy * float(dMaxSearchSteps);
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAABlendingWeightCalculationVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + float(offset) * uTexSizeInv, 0.0)

#define SMAA_AREATEX_MAX_DISTANCE 16
#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0))
#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)

uniform sampler2D tEdges;
uniform sampler2D tArea;
uniform sampler2D tSearch;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[3];
varying vec2 vPixCoord;

#if __VERSION__ == 100
    vec2 round(vec2 x) {
        return sign(x) * floor(abs(x) + 0.5);
    }
#endif

float SMAASearchLength(sampler2D searchTex, vec2 e, float bias, float scale) {
    // Not required if searchTex accesses are set to point:
    // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
    // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
    //     e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
    e.r = bias + e.r * scale;
    return 255.0 * texture2D(searchTex, e, 0.0).r;
}

float SMAASearchXLeft(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    /**
     * @PSEUDO_GATHER4
     * This texCoord has been offset by (-0.25, -0.125) in the vertex shader to
     * sample between edge, thus fetching four edges in a row.
     * Sampling with different offsets in each direction allows to disambiguate
     * which edges are active from the four fetched ones.
     */
    vec2 e = vec2(0.0, 1.0);

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D( edgesTex, texCoord, 0.0).rg;
        texCoord -= vec2(2.0, 0.0) * uTexSizeInv;
        if (!(texCoord.x > end && e.g > 0.8281 && e.r == 0.0)) break;
    }

    // We correct the previous (-0.25, -0.125) offset we applied:
    texCoord.x += 0.25 * uTexSizeInv.x;

    // The searches are bias by 1, so adjust the coords accordingly:
    texCoord.x += uTexSizeInv.x;

    // Disambiguate the length added by the last step:
    texCoord.x += 2.0 * uTexSizeInv.x; // Undo last step
    texCoord.x -= uTexSizeInv.x * SMAASearchLength(searchTex, e, 0.0, 0.5);

    return texCoord.x;
}

float SMAASearchXRight(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 0.0, 1.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord += vec2(2.0, 0.0) * uTexSizeInv;
        if (!(texCoord.x < end && e.g > 0.8281 && e.r == 0.0)) break;
    }

    texCoord.x -= 0.25 * uTexSizeInv.x;
    texCoord.x -= uTexSizeInv.x;
    texCoord.x -= 2.0 * uTexSizeInv.x;
    texCoord.x += uTexSizeInv.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );

    return texCoord.x;
}

float SMAASearchYUp(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 1.0, 0.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord += vec2(0.0, 2.0) * uTexSizeInv; // WebGL port note: Changed sign
        if (!(texCoord.y > end && e.r > 0.8281 && e.g == 0.0)) break;
    }

    texCoord.y -= 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.0, 0.5); // WebGL port note: Changed sign

    return texCoord.y;
}

float SMAASearchYDown(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 1.0, 0.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord -= vec2( 0.0, 2.0 ) * uTexSizeInv; // WebGL port note: Changed sign
        if (!(texCoord.y < end && e.r > 0.8281 && e.g == 0.0)) break;
    }

    texCoord.y += 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.5, 0.5); // WebGL port note: Changed sign

    return texCoord.y;
}

vec2 SMAAArea(sampler2D areaTex, vec2 dist, float e1, float e2, float offset) {
    // Rounding prevents precision errors of bilinear filtering:
    vec2 texCoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * vec2(e1, e2)) + dist;

    // We do a scale and bias for mapping to texel space:
    texCoord = SMAA_AREATEX_PIXEL_SIZE * texCoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE);

    // Move to proper place, according to the subpixel offset:
    texCoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;

    return texture2D(areaTex, texCoord, 0.0).rg;
}

vec4 SMAABlendingWeightCalculationPS(vec2 texCoord, vec2 pixCoord, vec4 offset[3], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices) {
    vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);

    vec2 e = texture2D(edgesTex, texCoord).rg;

    if (e.g > 0.0) { // Edge at north
        vec2 d;

        // Find the distance to the left:
        vec2 coords;
        coords.x = SMAASearchXLeft(edgesTex, searchTex, offset[0].xy, offset[2].x );
        coords.y = offset[1].y; // offset[1].y = texCoord.y - 0.25 * uTexSizeInv.y (@CROSSING_OFFSET)
        d.x = coords.x;

        // Now fetch the left crossing edges, two at a time using bilinear
        // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
        // discern what value each edge has:
        float e1 = texture2D(edgesTex, coords, 0.0).r;

        // Find the distance to the right:
        coords.x = SMAASearchXRight(edgesTex, searchTex, offset[0].zw, offset[2].y);
        d.y = coords.x;

        // We want the distances to be in pixel units (doing this here allow to
        // better interleave arithmetic and memory accesses):
        d = d / uTexSizeInv.x - pixCoord.x;

        // SMAAArea below needs a sqrt, as the areas texture is compressed
        // quadratically:
        vec2 sqrt_d = sqrt(abs(d));

        // Fetch the right crossing edges:
        coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(1, 0)).r;

        // Ok, we know how this pattern looks like, now it is time for getting
        // the actual area:
        weights.rg = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.y));
    }

    if (e.r > 0.0) { // Edge at west
        vec2 d;

        // Find the distance to the top:
        vec2 coords;

        coords.y = SMAASearchYUp(edgesTex, searchTex, offset[1].xy, offset[2].z );
        coords.x = offset[0].x; // offset[1].x = texCoord.x - 0.25 * uTexSizeInv.x;
        d.x = coords.y;

        // Fetch the top crossing edges:
        float e1 = texture2D(edgesTex, coords, 0.0).g;

        // Find the distance to the bottom:
        coords.y = SMAASearchYDown(edgesTex, searchTex, offset[1].zw, offset[2].w);
        d.y = coords.y;

        // We want the distances to be in pixel units:
        d = d / uTexSizeInv.y - pixCoord.y;

        // SMAAArea below needs a sqrt, as the areas texture is compressed
        // quadratically:
        vec2 sqrt_d = sqrt(abs(d));

        // Fetch the bottom crossing edges:
        coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(0, 1)).g;

        // Get the area for this direction:
        weights.ba = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.x));
    }

    return weights;
}

void main() {
    gl_FragColor = SMAABlendingWeightCalculationPS(vUv, vPixCoord, vOffset, tEdges, tArea, tSearch, ivec4(0.0));
}
`), wie = k(k({}, ei), { tColor: Kt("texture", "rgba", "ubyte", "linear"), tWeights: Kt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ze("v2"), uViewport: ze("v4") }), Cie = Rn("smaa-blend", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[2];

void SMAANeighborhoodBlendingVS(vec2 texCoord) {
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAANeighborhoodBlendingVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tWeights;
uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[2];

vec4 SMAANeighborhoodBlendingPS(vec2 texCoord, vec4 offset[2], sampler2D colorTex, sampler2D blendTex) {
    // Fetch the blending weights for current pixel:
    vec4 a;
    a.xz = texture2D(blendTex, texCoord).xz;
    a.y = texture2D(blendTex, offset[1].zw).g;
    a.w = texture2D(blendTex, offset[1].xy).a;

    // Is there any blending weight with a value greater than 0.0?
    if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
        return texture2D(colorTex, texCoord, 0.0);
    } else {
        // Up to 4 lines can be crossing a pixel (one through each edge). We
        // favor blending by choosing the line with the maximum weight for each
        // direction:
        vec2 offset;
        offset.x = a.a > a.b ? a.a : -a.b; // left vs. right
        offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs

        // Then we go in the direction that has the maximum weight:
        if (abs(offset.x) > abs(offset.y)) { // horizontal vs. vertical
            offset.y = 0.0;
        } else {
            offset.x = 0.0;
        }

        // Fetch the opposite color and lerp by hand:
        vec4 C = texture2D(colorTex, texCoord, 0.0);
        texCoord += sign(offset) * uTexSizeInv;
        vec4 Cop = texture2D(colorTex, texCoord, 0.0);
        float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);

        // WebGL port note: Added gamma correction
        C.xyz = pow(C.xyz, vec3(2.2));
        Cop.xyz = pow(Cop.xyz, vec3(2.2));
        vec4 mixed = mix(C, Cop, s);
        mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));

        return mixed;
    }
}

void main() {
    gl_FragColor = SMAANeighborhoodBlendingPS(vUv, vOffset, tColor, tWeights);
}
`), Eie = k(k({}, ei), { tDepth: Kt("texture", "rgba", "ubyte", "nearest"), uTexSize: ze("v2"), dOrthographic: Ht("number"), uNear: ze("f"), uFar: ze("f"), uMaxPossibleViewZDiff: ze("f") }), Die = k(k({}, ei), { tDepth: Kt("texture", "rgba", "ubyte", "nearest"), uSamples: ze("v3[]"), dNSamples: Ht("number"), uProjection: ze("m4"), uInvProjection: ze("m4"), uBounds: ze("v4"), uTexSize: ze("v2"), uRadius: ze("f"), uBias: ze("f") }), Mie = k(k({}, ei), { tSsaoDepth: Kt("texture", "rgba", "ubyte", "nearest"), uTexSize: ze("v2"), uKernel: ze("f[]"), dOcclusionKernelSize: Ht("number"), uBlurDirectionX: ze("f"), uBlurDirectionY: ze("f"), uMaxPossibleViewZDiff: ze("f"), uNear: ze("f"), uFar: ze("f"), uBounds: ze("v4"), dOrthographic: Ht("number") });
function RD(e, t, r) {
  var n = k(k({}, Qa), { tSsaoDepth: U.create(t), uTexSize: U.create(Ze.create(t.getWidth(), t.getHeight())), uKernel: U.create([0]), dOcclusionKernelSize: U.create(15), uBlurDirectionX: U.create(r === "horizontal" ? 1 : 0), uBlurDirectionY: U.create(r === "vertical" ? 1 : 0), uMaxPossibleViewZDiff: U.create(0.5), uNear: U.create(0), uFar: U.create(1e4), uBounds: U.create(jt()), dOrthographic: U.create(0) }), a = k({}, Mie);
  return Ga(Ua(e, "triangles", Rn("ssao_blur", Yi, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tSsaoDepth;
uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform float uKernel[dOcclusionKernelSize];

uniform float uBlurDirectionX;
uniform float uBlurDirectionY;

uniform float uMaxPossibleViewZDiff;

uniform float uNear;
uniform float uFar;

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

bool outsideBounds(const in vec2 p) {
    return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;
}

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;

    vec2 packedDepth = texture2D(tSsaoDepth, coords).zw;

    if (outsideBounds(coords)) {
        gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);
        return;
    }

    float selfDepth = unpackRGToUnitInterval(packedDepth);
    // if background and if second pass
    if (isBackground(selfDepth) && uBlurDirectionY != 0.0) {
        gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);
        return;
    }

    float selfViewZ = getViewZ(selfDepth);

    vec2 offset = vec2(uBlurDirectionX, uBlurDirectionY) / uTexSize;

    float sum = 0.0;
    float kernelSum = 0.0;
    // only if kernelSize is odd
    for (int i = -dOcclusionKernelSize / 2; i <= dOcclusionKernelSize / 2; i++) {
        vec2 sampleCoords = coords + float(i) * offset;
        if (outsideBounds(sampleCoords)) {
            continue;
        }

        vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords);

        float sampleDepth = unpackRGToUnitInterval(sampleSsaoDepth.zw);
        if (isBackground(sampleDepth)) {
            continue;
        }

        if (abs(float(i)) > 1.0) { // abs is not defined for int in webgl1
            float sampleViewZ = getViewZ(sampleDepth);
            if (abs(selfViewZ - sampleViewZ) > uMaxPossibleViewZDiff) {
                continue;
            }
        }

        float kernel = uKernel[int(abs(float(i)))]; // abs is not defined for int in webgl1
        float sampleValue = unpackRGToUnitInterval(sampleSsaoDepth.xy);

        sum += kernel * sampleValue;
        kernelSum += kernel;
    }

    gl_FragColor = vec4(packUnitIntervalToRG(sum / kernelSum), packedDepth);
}
`), a, n), n);
}
var Iie = k(k({}, ei), { tSsaoDepth: Kt("texture", "rgba", "ubyte", "nearest"), tColor: Kt("texture", "rgba", "ubyte", "nearest"), tDepth: Kt("texture", "rgba", "ubyte", "nearest"), tOutlines: Kt("texture", "rgba", "ubyte", "nearest"), uTexSize: ze("v2"), dOrthographic: Ht("number"), uNear: ze("f"), uFar: ze("f"), uFogNear: ze("f"), uFogFar: ze("f"), uFogColor: ze("v3"), uOutlineColor: ze("v3"), uTransparentBackground: ze("b"), uMaxPossibleViewZDiff: ze("f"), dOcclusionEnable: Ht("boolean"), uOcclusionOffset: ze("v2"), dOutlineEnable: Ht("boolean"), dOutlineScale: Ht("number"), uOutlineThreshold: ze("f") }), aL = { occlusion: V.MappedStatic("on", { on: V.Group({ samples: V.Numeric(32, { min: 1, max: 256, step: 1 }), radius: V.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: "Final occlusion radius is 2^x" }), bias: V.Numeric(0.8, { min: 0, max: 3, step: 0.1 }), blurKernelSize: V.Numeric(15, { min: 1, max: 25, step: 2 }), resolutionScale: V.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" }) }), off: V.Group({}) }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect" }), outline: V.MappedStatic("off", { on: V.Group({ scale: V.Numeric(1, { min: 1, max: 5, step: 1 }), threshold: V.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }), color: V.Color(Qe(0)) }), off: V.Group({}) }, { cycle: !0, description: "Draw outline around 3D objects" }), antialiasing: V.MappedStatic("smaa", { fxaa: V.Group(pie), smaa: V.Group(yie), off: V.Group({}) }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges" }) }, jc = function() {
  function e(t, r) {
    this.webgl = t, this.drawPass = r, this.occlusionOffset = [0, 0];
    var n = r.colorTarget, a = r.depthTexture, i = n.getWidth(), o = n.getHeight();
    this.nSamples = 1, this.blurKernelSize = 1, this.downsampleFactor = 1, this.ssaoScale = this.calcSsaoScale(), this.target = t.createRenderTarget(i, o, !1, "uint8", "linear"), this.outlinesTarget = t.createRenderTarget(i, o, !1), this.outlinesRenderable = function(d, f) {
      var m = k(k({}, Qa), { tDepth: U.create(f), uTexSize: U.create(Ze.create(f.getWidth(), f.getHeight())), dOrthographic: U.create(0), uNear: U.create(1), uFar: U.create(1e4), uMaxPossibleViewZDiff: U.create(0.5) }), h = k({}, Eie);
      return Ga(Ua(d, "triangles", Rn("outlines", Yi, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tDepth;
uniform vec2 uTexSize;

uniform float uNear;
uniform float uFar;

uniform float uMaxPossibleViewZDiff;

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

float getDepth(const in vec2 coords) {
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

void main(void) {
    float backgroundViewZ = uFar + 3.0 * uMaxPossibleViewZDiff;

    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec2 invTexSize = 1.0 / uTexSize;

    float selfDepth = getDepth(coords);
    float selfViewZ = isBackground(selfDepth) ? backgroundViewZ : getViewZ(getDepth(coords));

    float outline = 1.0;
    float bestDepth = 1.0;

    for (int y = -1; y <= 1; y++) {
        for (int x = -1; x <= 1; x++) {
            vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;
            float sampleDepth = getDepth(sampleCoords);
            float sampleViewZ = isBackground(sampleDepth) ? backgroundViewZ : getViewZ(sampleDepth);

            if (abs(selfViewZ - sampleViewZ) > uMaxPossibleViewZDiff && selfDepth > sampleDepth && sampleDepth <= bestDepth) {
                outline = 0.0;
                bestDepth = sampleDepth;
            }
        }
    }

    gl_FragColor = vec4(outline, packUnitIntervalToRG(bestDepth), 0.0);
}
`), h, m), m);
    }(t, a), this.randomHemisphereVector = [];
    for (var s = 0; s < 256; s++) {
      var u = D();
      u[0] = 2 * Math.random() - 1, u[1] = 2 * Math.random() - 1, u[2] = Math.random(), D.normalize(u, u), D.scale(u, u, Math.random()), this.randomHemisphereVector.push(u);
    }
    this.ssaoFramebuffer = t.resources.framebuffer(), this.ssaoBlurFirstPassFramebuffer = t.resources.framebuffer(), this.ssaoBlurSecondPassFramebuffer = t.resources.framebuffer();
    var c = Math.floor(i * this.ssaoScale), l = Math.floor(o * this.ssaoScale);
    this.downsampledDepthTarget = t.createRenderTarget(c, l, !1, "uint8", "linear"), this.downsampleDepthRenderable = M6(t, a), this.ssaoDepthTexture = t.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTexture.define(c, l), this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer, "color0"), this.ssaoDepthBlurProxyTexture = t.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthBlurProxyTexture.define(c, l), this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer, "color0"), this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer, "color0"), this.ssaoRenderable = function(d, f) {
      var m = k(k({}, Qa), { tDepth: U.create(f), uSamples: U.create([0, 0, 1]), dNSamples: U.create(32), uProjection: U.create(Ee.identity()), uInvProjection: U.create(Ee.identity()), uBounds: U.create(jt()), uTexSize: U.create(Ze.create(d.gl.drawingBufferWidth, d.gl.drawingBufferHeight)), uRadius: U.create(8), uBias: U.create(0.025) }), h = k({}, Die);
      return Ga(Ua(d, "triangles", Rn("ssao", Yi, `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common

uniform sampler2D tDepth;
uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform vec3 uSamples[dNSamples];

uniform mat4 uProjection;
uniform mat4 uInvProjection;

uniform float uRadius;
uniform float uBias;

float smootherstep(float edge0, float edge1, float x) {
    x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
    return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);
}

float noise(const in vec2 coords) {
    float a = 12.9898;
    float b = 78.233;
    float c = 43758.5453;
    float dt = dot(coords, vec2(a,b));
    float sn = mod(dt, PI);
    return abs(fract(sin(sn) * c)); // is abs necessary?
}

vec2 getNoiseVec2(const in vec2 coords) {
    return vec2(noise(coords), noise(coords + vec2(PI, 2.71828)));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

bool outsideBounds(const in vec2 p) {
    return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;
}

float getDepth(const in vec2 coords) {
    return outsideBounds(coords) ? 1.0 : unpackRGBAToDepth(texture2D(tDepth, coords));
}

vec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {
    vec3 p1 = vec3(offset1, depth1 - depth);
    vec3 p2 = vec3(offset2, depth2 - depth);

    vec3 normal = cross(p1, p2);
    normal.z = -normal.z;

    return normalize(normal);
}

// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008]
void main(void) {
    vec2 invTexSize = 1.0 / uTexSize;
    vec2 selfCoords = gl_FragCoord.xy * invTexSize;

    float selfDepth = getDepth(selfCoords);
    vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);

    if (isBackground(selfDepth)) {
        gl_FragColor = vec4(packUnitIntervalToRG(0.0), selfPackedDepth);
        return;
    }

    vec2 offset1 = vec2(0.0, invTexSize.y);
    vec2 offset2 = vec2(invTexSize.x, 0.0);

    float selfDepth1 = getDepth(selfCoords + offset1);
    float selfDepth2 = getDepth(selfCoords + offset2);

    vec3 selfViewNormal = normalFromDepth(selfDepth, selfDepth1, selfDepth2, offset1, offset2);
    vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);

    vec3 randomVec = normalize(vec3(getNoiseVec2(selfCoords) * 2.0 - 1.0, 0.0));

    vec3 tangent = normalize(randomVec - selfViewNormal * dot(randomVec, selfViewNormal));
    vec3 bitangent = cross(selfViewNormal, tangent);
    mat3 TBN = mat3(tangent, bitangent, selfViewNormal);

    float occlusion = 0.0;
    for(int i = 0; i < dNSamples; i++){
        vec3 sampleViewPos = TBN * uSamples[i];
        sampleViewPos = selfViewPos + sampleViewPos * uRadius;

        vec4 offset = vec4(sampleViewPos, 1.0);
        offset = uProjection * offset;
        offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;

        float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, getDepth(offset.xy)), uInvProjection).z;

        occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
    }
    occlusion = 1.0 - (uBias * occlusion / float(dNSamples));

    vec2 packedOcclusion = packUnitIntervalToRG(occlusion);

    gl_FragColor = vec4(packedOcclusion, selfPackedDepth);
}
`), h, m), m);
    }(t, this.downsampleFactor === 1 ? a : this.downsampledDepthTarget.texture), this.ssaoBlurFirstPassRenderable = RD(t, this.ssaoDepthTexture, "horizontal"), this.ssaoBlurSecondPassRenderable = RD(t, this.ssaoDepthBlurProxyTexture, "vertical"), this.renderable = function(d, f, m, h, p) {
      var g = k(k({}, Qa), { tSsaoDepth: U.create(p), tColor: U.create(f), tDepth: U.create(m), tOutlines: U.create(h), uTexSize: U.create(Ze.create(f.getWidth(), f.getHeight())), dOrthographic: U.create(0), uNear: U.create(1), uFar: U.create(1e4), uFogNear: U.create(1e4), uFogFar: U.create(1e4), uFogColor: U.create(D.create(1, 1, 1)), uOutlineColor: U.create(D.create(0, 0, 0)), uTransparentBackground: U.create(!1), uMaxPossibleViewZDiff: U.create(0.5), dOcclusionEnable: U.create(!0), uOcclusionOffset: U.create(Ze.create(0, 0)), dOutlineEnable: U.create(!1), dOutlineScale: U.create(1), uOutlineThreshold: U.create(0.33) }), v = k({}, Iie);
      return Ga(Ua(d, "triangles", Rn("postprocessing", Yi, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tSsaoDepth;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform sampler2D tOutlines;
uniform vec2 uTexSize;

uniform float uNear;
uniform float uFar;
uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;
uniform vec3 uOutlineColor;
uniform bool uTransparentBackground;

uniform vec2 uOcclusionOffset;

uniform float uMaxPossibleViewZDiff;

const vec3 occlusionColor = vec3(0.0);

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

float getDepth(const in vec2 coords) {
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

float getOutline(const in vec2 coords, out float closestTexel) {
    float backgroundViewZ = uFar + 3.0 * uMaxPossibleViewZDiff;
    vec2 invTexSize = 1.0 / uTexSize;

    float selfDepth = getDepth(coords);
    float selfViewZ = isBackground(selfDepth) ? backgroundViewZ : getViewZ(selfDepth);

    float outline = 1.0;
    closestTexel = 1.0;
    for (int y = -dOutlineScale; y <= dOutlineScale; y++) {
        for (int x = -dOutlineScale; x <= dOutlineScale; x++) {
            if (x * x + y * y > dOutlineScale * dOutlineScale) {
                continue;
            }

            vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;

            vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);
            float sampleOutline = sampleOutlineCombined.r;
            float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);

            if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel && abs(selfViewZ - sampleOutlineDepth) > uMaxPossibleViewZDiff) {
                outline = 0.0;
                closestTexel = sampleOutlineDepth;
            }
        }
    }
    return outline;
}

float getSsao(vec2 coords) {
    float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepth, coords).xy);
    if (rawSsao > 0.999) {
        return 1.0;
    } else if (rawSsao > 0.001) {
        return rawSsao;
    }
    // treat values close to 0.0 as errors and return no occlusion
    return 1.0;
}

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec4 color = texture2D(tColor, coords);

    float viewDist;
    float fogFactor;

    #ifdef dOcclusionEnable
        float depth = getDepth(coords);
        if (!isBackground(depth)) {
            viewDist = abs(getViewZ(depth));
            fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            float occlusionFactor = getSsao(coords + uOcclusionOffset);
            if (!uTransparentBackground) {
                color.rgb = mix(mix(occlusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
            } else {
                color.rgb = mix(occlusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);
            }
        }
    #endif

    // outline needs to be handled after occlusion to keep them clean
    #ifdef dOutlineEnable
        float closestTexel;
        float outline = getOutline(coords, closestTexel);

        if (outline == 0.0) {
            color.rgb = mix(uOutlineColor, color.rgb, outline);
            viewDist = abs(getViewZ(closestTexel));
            fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            if (!uTransparentBackground) {
                color.rgb = mix(color.rgb, uFogColor, fogFactor);
            } else {
                color.a = 1.0 - fogFactor;
            }
        }
    #endif

    gl_FragColor = color;
}
`), v, g), g);
    }(t, n.texture, a, this.outlinesTarget.texture, this.ssaoDepthTexture);
  }
  return e.isEnabled = function(t) {
    return t.occlusion.name === "on" || t.outline.name === "on";
  }, e.prototype.calcSsaoScale = function() {
    return Math.min(1, 1 / this.webgl.pixelRatio) * this.downsampleFactor;
  }, e.prototype.setSize = function(t, r) {
    var n = this.renderable.values.uTexSize.ref.value, a = n[0], i = n[1], o = this.calcSsaoScale();
    if (t !== a || r !== i || this.ssaoScale !== o) {
      this.ssaoScale = o;
      var s = Math.floor(t * this.ssaoScale), u = Math.floor(r * this.ssaoScale);
      this.target.setSize(t, r), this.outlinesTarget.setSize(t, r), this.downsampledDepthTarget.setSize(s, u), this.ssaoDepthTexture.define(s, u), this.ssaoDepthBlurProxyTexture.define(s, u), U.update(this.renderable.values.uTexSize, Ze.set(this.renderable.values.uTexSize.ref.value, t, r)), U.update(this.outlinesRenderable.values.uTexSize, Ze.set(this.outlinesRenderable.values.uTexSize.ref.value, t, r)), U.update(this.downsampleDepthRenderable.values.uTexSize, Ze.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, s, u)), U.update(this.ssaoRenderable.values.uTexSize, Ze.set(this.ssaoRenderable.values.uTexSize.ref.value, s, u)), U.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Ze.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, s, u)), U.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Ze.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, s, u));
    }
  }, e.prototype.updateState = function(t, r, n, a) {
    var i = !1, o = !1, s = !1, u = t.state.mode === "orthographic" ? 1 : 0, c = a.outline.name === "on", l = a.occlusion.name === "on", d = Ee.identity();
    if (Ee.invert(d, t.projection), a.occlusion.name === "on") {
      U.update(this.ssaoRenderable.values.uProjection, t.projection), U.update(this.ssaoRenderable.values.uInvProjection, d);
      var f = this.renderable.values.uTexSize.ref.value, m = f[0], h = f[1], p = this.ssaoRenderable.values.uBounds, g = t.viewport, v = this.ssaoScale;
      if (jt.set(p.ref.value, Math.floor(g.x * v) / (m * v), Math.floor(g.y * v) / (h * v), Math.ceil((g.x + g.width) * v) / (m * v), Math.ceil((g.y + g.height) * v) / (h * v)), U.update(p, p.ref.value), U.update(this.ssaoBlurFirstPassRenderable.values.uBounds, p.ref.value), U.update(this.ssaoBlurSecondPassRenderable.values.uBounds, p.ref.value), U.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear, t.near), U.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear, t.near), U.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar, t.far), U.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar, t.far), this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value !== u && (s = !0), U.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOrthographic, u), U.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOrthographic, u), this.nSamples !== a.occlusion.params.samples && (o = !0, this.nSamples = a.occlusion.params.samples, U.update(this.ssaoRenderable.values.uSamples, function(F, R) {
        for (var G = [], L = 0; L < R; L++) {
          var q = (L * L + 2 * L + 1) / (R * R);
          q = 0.1 + 0.9 * q, G.push(F[L][0] * q), G.push(F[L][1] * q), G.push(F[L][2] * q);
        }
        return G;
      }(this.randomHemisphereVector, this.nSamples)), U.updateIfChanged(this.ssaoRenderable.values.dNSamples, this.nSamples)), U.updateIfChanged(this.ssaoRenderable.values.uRadius, Math.pow(2, a.occlusion.params.radius)), U.updateIfChanged(this.ssaoRenderable.values.uBias, a.occlusion.params.bias), this.blurKernelSize !== a.occlusion.params.blurKernelSize) {
        s = !0, this.blurKernelSize = a.occlusion.params.blurKernelSize;
        var y = function(F) {
          for (var R = F / 3, G = Math.floor((F + 1) / 2), L = [], q = 0; q < G; q++) L.push(1 / (Math.sqrt(2 * Math.PI) * R) * Math.exp(-q * q / (2 * R * R)));
          return L;
        }(this.blurKernelSize);
        U.update(this.ssaoBlurFirstPassRenderable.values.uKernel, y), U.update(this.ssaoBlurSecondPassRenderable.values.uKernel, y), U.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), U.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
      }
      if (this.downsampleFactor !== a.occlusion.params.resolutionScale) {
        o = !0, this.downsampleFactor = a.occlusion.params.resolutionScale, this.ssaoScale = this.calcSsaoScale();
        var _ = Math.floor(m * this.ssaoScale), S = Math.floor(h * this.ssaoScale);
        this.downsampledDepthTarget.setSize(_, S), this.ssaoDepthTexture.define(_, S), this.ssaoDepthBlurProxyTexture.define(_, S), this.ssaoScale === 1 ? U.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture) : U.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture), U.update(this.downsampleDepthRenderable.values.uTexSize, Ze.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, _, S)), U.update(this.ssaoRenderable.values.uTexSize, Ze.set(this.ssaoRenderable.values.uTexSize.ref.value, _, S)), U.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Ze.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, _, S)), U.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Ze.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, _, S));
      }
    }
    if (a.outline.name === "on") {
      var b = a.outline.params.threshold;
      t.state.mode === "orthographic" && (b /= 5);
      var x = Math.pow(1e3, b) / 1e3 * t.state.radiusMax, A = a.outline.params.scale - 1;
      U.updateIfChanged(this.outlinesRenderable.values.uNear, t.near), U.updateIfChanged(this.outlinesRenderable.values.uFar, t.far), U.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, x), U.update(this.renderable.values.uOutlineColor, Qe.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, a.outline.params.color)), U.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, x), this.renderable.values.dOutlineScale.ref.value !== A && (i = !0), U.updateIfChanged(this.renderable.values.dOutlineScale, A);
    }
    U.updateIfChanged(this.renderable.values.uFar, t.far), U.updateIfChanged(this.renderable.values.uNear, t.near), U.updateIfChanged(this.renderable.values.uFogFar, t.fogFar), U.updateIfChanged(this.renderable.values.uFogNear, t.fogNear), U.update(this.renderable.values.uFogColor, Qe.toVec3Normalized(this.renderable.values.uFogColor.ref.value, n)), U.updateIfChanged(this.renderable.values.uTransparentBackground, r), this.renderable.values.dOrthographic.ref.value !== u && (i = !0), U.updateIfChanged(this.renderable.values.dOrthographic, u), this.renderable.values.dOutlineEnable.ref.value !== c && (i = !0), U.updateIfChanged(this.renderable.values.dOutlineEnable, c), this.renderable.values.dOcclusionEnable.ref.value !== l && (i = !0), U.updateIfChanged(this.renderable.values.dOcclusionEnable, l), o && this.ssaoRenderable.update(), s && (this.ssaoBlurFirstPassRenderable.update(), this.ssaoBlurSecondPassRenderable.update()), i && this.renderable.update();
    var w = this.webgl, C = w.gl, M = w.state;
    M.enable(C.SCISSOR_TEST), M.disable(C.BLEND), M.disable(C.DEPTH_TEST), M.depthMask(!1);
    var T = t.viewport, N = T.x, I = T.y, P = T.width, O = T.height;
    C.viewport(N, I, P, O), C.scissor(N, I, P, O);
  }, e.prototype.setOcclusionOffset = function(t, r) {
    this.occlusionOffset[0] = t, this.occlusionOffset[1] = r, U.update(this.renderable.values.uOcclusionOffset, Ze.set(this.renderable.values.uOcclusionOffset.ref.value, t, r));
  }, e.prototype.render = function(t, r, n, a, i) {
    this.updateState(t, n, a, i), i.outline.name === "on" && (this.outlinesTarget.bind(), this.outlinesRenderable.render()), i.occlusion.name === "on" && this.occlusionOffset[0] === 0 && this.occlusionOffset[1] === 0 && (this.ssaoScale < 1 && (this.downsampledDepthTarget.bind(), this.downsampleDepthRenderable.render()), this.ssaoFramebuffer.bind(), this.ssaoRenderable.render(), this.ssaoBlurFirstPassFramebuffer.bind(), this.ssaoBlurFirstPassRenderable.render(), this.ssaoBlurSecondPassFramebuffer.bind(), this.ssaoBlurSecondPassRenderable.render()), r ? this.webgl.unbindFramebuffer() : this.target.bind();
    var o = this.webgl, s = o.gl;
    o.state.clearColor(0, 0, 0, 1), s.clear(s.COLOR_BUFFER_BIT), this.renderable.render();
  }, e;
}(), Ex = function() {
  function e(t, r) {
    this.drawPass = r;
    var n = r.colorTarget, a = n.getWidth(), i = n.getHeight();
    this.target = t.createRenderTarget(a, i, !1), this.fxaa = new hie(t, this.target.texture), this.smaa = new bie(t, this.target.texture);
  }
  return e.isEnabled = function(t) {
    return t.antialiasing.name !== "off";
  }, e.prototype.setSize = function(t, r) {
    var n = this.target.texture.getWidth(), a = this.target.texture.getHeight();
    t === n && r === a || (this.target.setSize(t, r), this.fxaa.setSize(t, r), this.smaa.supported && this.smaa.setSize(t, r));
  }, e.prototype._renderFxaa = function(t, r, n) {
    if (n.antialiasing.name === "fxaa") {
      var a = jc.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.fxaa.update(a, n.antialiasing.params), this.fxaa.render(t.viewport, r ? void 0 : this.target);
    }
  }, e.prototype._renderSmaa = function(t, r, n) {
    if (n.antialiasing.name === "smaa") {
      var a = jc.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.smaa.update(a, n.antialiasing.params), this.smaa.render(t.viewport, r ? void 0 : this.target);
    }
  }, e.prototype.render = function(t, r, n) {
    if (n.antialiasing.name !== "off") {
      if (n.antialiasing.name === "fxaa") this._renderFxaa(t, r, n);
      else if (n.antialiasing.name === "smaa") {
        if (!this.smaa.supported) throw new Error('SMAA not supported, missing "HTMLImageElement"');
        this._renderSmaa(t, r, n);
      }
    }
  }, e;
}(), Tie = k(k({}, ei), { tColor: Kt("texture", "rgba", "ubyte", "nearest"), uTexSize: ze("v2"), uWeight: ze("f") }), Nie = Rn("compose", Yi, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSize;
uniform float uWeight;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    gl_FragColor = texture2D(tColor, coords) * uWeight;
}
`), iL = { mode: V.Select("temporal", [["off", "Off"], ["on", "On"], ["temporal", "Temporal"]]), sampleLevel: V.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." }) }, yy = function() {
  function e(t, r) {
    this.webgl = t, this.drawPass = r;
    var n = t.extensions, a = n.colorBufferFloat, i = n.textureFloat, o = n.colorBufferHalfFloat, s = n.textureHalfFloat, u = r.colorTarget.getWidth(), c = r.colorTarget.getHeight();
    this.colorTarget = t.createRenderTarget(u, c, !1);
    var l, d, f, m, h = o && s ? "fp16" : a && i ? "float32" : "uint8";
    this.composeTarget = t.createRenderTarget(u, c, !1, h), this.holdTarget = t.createRenderTarget(u, c, !1), this.compose = (l = t, d = r.colorTarget.texture, f = k(k({}, Qa), { tColor: U.create(d), uTexSize: U.create(Ze.create(d.getWidth(), d.getHeight())), uWeight: U.create(1) }), m = k({}, Tie), Ga(Ua(l, "triangles", Nie, m, f), f));
  }
  return e.isEnabled = function(t) {
    return t.mode !== "off";
  }, e.prototype.syncSize = function() {
    var t = this.drawPass.colorTarget.getWidth(), r = this.drawPass.colorTarget.getHeight(), n = this.compose.values.uTexSize.ref.value, a = n[0], i = n[1];
    t === a && r === i || (this.colorTarget.setSize(t, r), this.composeTarget.setSize(t, r), this.holdTarget.setSize(t, r), U.update(this.compose.values.uTexSize, Ze.set(this.compose.values.uTexSize.ref.value, t, r)));
  }, e.prototype.render = function(t, r, n, a, i) {
    return n.multiSample.mode !== "temporal" || i ? (this.renderMultiSample(r, a, n), -2) : this.renderTemporalMultiSample(t, r, n, a);
  }, e.prototype.bindOutputTarget = function(t) {
    t ? this.webgl.unbindFramebuffer() : this.colorTarget.bind();
  }, e.prototype.renderMultiSample = function(t, r, n) {
    var a = t.camera, i = this, o = i.compose, s = i.composeTarget, u = i.drawPass, c = i.webgl, l = c.gl, d = c.state, f = K6[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))], m = a.viewport, h = m.x, p = m.y, g = m.width, v = m.height, y = 1 / f.length;
    a.viewOffset.enabled = !0, U.update(o.values.tColor, u.getColorTarget(n.postprocessing).texture), o.update();
    for (var _ = 0; _ < f.length; ++_) {
      var S = f[_];
      oa.setViewOffset(a.viewOffset, g, v, S[0], S[1], g, v), a.update();
      var b = y + 0.03125 * ((_ + 0.5) / f.length - 0.5);
      U.update(o.values.uWeight, b), _ === 0 ? u.postprocessing.setOcclusionOffset(0, 0) : u.postprocessing.setOcclusionOffset(S[0] / g, S[1] / v), u.render(t, n, !1), s.bind(), d.enable(l.BLEND), d.blendEquationSeparate(l.FUNC_ADD, l.FUNC_ADD), d.blendFuncSeparate(l.ONE, l.ONE, l.ONE, l.ONE), d.disable(l.DEPTH_TEST), d.depthMask(!1), l.viewport(h, p, g, v), l.scissor(h, p, g, v), _ === 0 && (d.clearColor(0, 0, 0, 0), l.clear(l.COLOR_BUFFER_BIT)), o.render();
    }
    u.postprocessing.setOcclusionOffset(0, 0), U.update(o.values.uWeight, 1), U.update(o.values.tColor, s.texture), o.update(), this.bindOutputTarget(r), l.viewport(h, p, g, v), l.scissor(h, p, g, v), d.disable(l.BLEND), o.render(), a.viewOffset.enabled = !1, a.update();
  }, e.prototype.renderTemporalMultiSample = function(t, r, n, a) {
    var i = r.camera, o = this, s = o.compose, u = o.composeTarget, c = o.holdTarget, l = o.drawPass, d = o.webgl, f = d.gl, m = d.state, h = K6[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))];
    if (t === -2 || t >= h.length) return -2;
    var p = i.viewport, g = p.x, v = p.y, y = p.width, _ = p.height, S = 1 / h.length;
    if (t === -1) l.render(r, n, !1), U.update(s.values.uWeight, 1), U.update(s.values.tColor, l.getColorTarget(n.postprocessing).texture), s.update(), c.bind(), m.disable(f.BLEND), m.disable(f.DEPTH_TEST), m.depthMask(!1), f.viewport(g, v, y, _), f.scissor(g, v, y, _), s.render(), t += 1;
    else {
      i.viewOffset.enabled = !0, U.update(s.values.tColor, l.getColorTarget(n.postprocessing).texture), U.update(s.values.uWeight, S), s.update();
      for (var b = Math.pow(2, Math.max(0, n.multiSample.sampleLevel - 2)), x = 0; x < b; ++x) {
        var A = h[t];
        if (oa.setViewOffset(i.viewOffset, y, _, A[0], A[1], y, _), i.update(), t === 0 ? l.postprocessing.setOcclusionOffset(0, 0) : l.postprocessing.setOcclusionOffset(A[0] / y, A[1] / _), l.render(r, n, !1), u.bind(), m.enable(f.BLEND), m.blendEquationSeparate(f.FUNC_ADD, f.FUNC_ADD), m.blendFuncSeparate(f.ONE, f.ONE, f.ONE, f.ONE), m.disable(f.DEPTH_TEST), m.depthMask(!1), f.viewport(g, v, y, _), f.scissor(g, v, y, _), t === 0 && (m.clearColor(0, 0, 0, 0), f.clear(f.COLOR_BUFFER_BIT)), s.render(), (t += 1) >= h.length) break;
      }
    }
    l.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(a), f.viewport(g, v, y, _), f.scissor(g, v, y, _);
    var w = t * S;
    return w > 0 && (U.update(s.values.uWeight, 1), U.update(s.values.tColor, u.texture), s.update(), m.disable(f.BLEND), s.render()), w < 1 && (U.update(s.values.uWeight, 1 - w), U.update(s.values.tColor, c.texture), s.update(), w === 0 ? m.disable(f.BLEND) : m.enable(f.BLEND), s.render()), i.viewOffset.enabled = !1, i.update(), t >= h.length ? -2 : t;
  }, e;
}(), K6 = [[[0, 0]], [[0, 0], [-4, -4]], [[0, 0], [6, -2], [-6, 2], [2, 6]], [[0, 0], [-1, 3], [5, 1], [-3, -5], [-5, 5], [-7, -1], [3, 7], [7, -7]], [[0, 0], [-1, -3], [-3, 2], [4, -1], [-5, -2], [2, 5], [5, 3], [3, -5], [-2, 6], [0, -7], [-4, -6], [-6, 4], [-8, 0], [7, -4], [6, 7], [-7, -8]], [[0, 0], [-7, -5], [-3, -5], [-5, -4], [-1, -4], [-2, -2], [-6, -1], [-4, 0], [-7, 1], [-1, 2], [-6, 3], [-3, 3], [-7, 6], [-3, 6], [-5, 7], [-1, 7], [5, -7], [1, -6], [6, -5], [4, -4], [2, -3], [7, -2], [1, -1], [4, -1], [2, 1], [6, 2], [0, 4], [4, 4], [2, 5], [7, 5], [5, 6], [3, 7]]];
K6.forEach(function(e) {
  e.forEach(function(t) {
    t[0] *= 0.0625, t[1] *= 0.0625;
  });
});
var oL = function() {
  function e(t) {
    this.multiSamplePass = t, this.sampleIndex = -2;
  }
  return e.prototype.update = function(t, r) {
    return t && (this.sampleIndex = -1), r.mode === "temporal" && this.sampleIndex !== -2;
  }, e.prototype.render = function(t, r, n, a) {
    return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, t, r, n, !!a), this.sampleIndex < 0;
  }, e;
}(), sL = { eyeSeparation: V.Numeric(0.064, { min: 0.01, max: 0.5, step: 1e-3 }), focus: V.Numeric(10, { min: 1, max: 100, step: 0.01 }) }, Pie = V.getDefaultValues(sL), Wp = function() {
  function e(t, r) {
    r === void 0 && (r = {}), this.parent = t, this.left = new LD(), this.right = new LD(), this.props = k(k({}, Pie), r);
  }
  return Object.defineProperty(e.prototype, "viewport", { get: function() {
    return this.parent.viewport;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "viewOffset", { get: function() {
    return this.parent.viewOffset;
  }, enumerable: !1, configurable: !0 }), e.prototype.setProps = function(t) {
    Object.assign(this.props, t);
  }, e.prototype.update = function() {
    this.parent.update(), function(t, r, n, a) {
      Za.copy(n.viewport, t.viewport), Ee.copy(n.view, t.view), Ee.copy(n.projection, t.projection), oa.copySnapshot(n.state, t.state), oa.copyViewOffset(n.viewOffset, t.viewOffset), n.far = t.far, n.near = t.near, n.fogFar = t.fogFar, n.fogNear = t.fogNear, Za.copy(a.viewport, t.viewport), Ee.copy(a.view, t.view), Ee.copy(a.projection, t.projection), oa.copySnapshot(a.state, t.state), oa.copyViewOffset(a.viewOffset, t.viewOffset), a.far = t.far, a.near = t.near, a.fogFar = t.fogFar, a.fogNear = t.fogNear;
      var i = Math.floor(t.viewport.width / 2), o = i / t.viewport.height;
      n.viewport.width = i, a.viewport.x += i, a.viewport.width -= i;
      var s, u, c = r.eyeSeparation / 2, l = c * t.near / r.focus, d = t.near * Math.tan(0.5 * t.state.fov);
      kD[12] = -c, zD[12] = c, s = -d * o + l, u = d * o + l, n.projection[0] = 2 * t.near / (u - s), n.projection[8] = (u + s) / (u - s), Ee.mul(n.view, n.view, kD), Ee.mul(n.projectionView, n.projection, n.view), Ee.invert(n.inverseProjectionView, n.projectionView), s = -d * o - l, u = d * o - l, a.projection[0] = 2 * t.near / (u - s), a.projection[8] = (u + s) / (u - s), Ee.mul(a.view, a.view, zD), Ee.mul(a.projectionView, a.projection, a.view), Ee.invert(a.inverseProjectionView, a.projectionView);
    }(this.parent, this.props, this.left, this.right);
  }, e;
}();
(function(e) {
  e.is = function(t) {
    return "left" in t && "right" in t;
  };
})(Wp || (Wp = {}));
var LD = function() {
  this.viewport = Za.create(0, 0, 0, 0), this.view = Ee(), this.projection = Ee(), this.projectionView = Ee(), this.inverseProjectionView = Ee(), this.state = oa.createDefaultSnapshot(), this.viewOffset = oa.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0;
}, kD = Ee.identity(), zD = Ee.identity(), Dx = Math.pow(2, 24) - 2, Bie = function() {
  function e(t, r, n) {
    this.webgl = t, this.drawPass = r, this.pickBaseScale = n;
    var a = n / t.pixelRatio;
    this.pickWidth = Math.ceil(r.colorTarget.getWidth() * a), this.pickHeight = Math.ceil(r.colorTarget.getHeight() * a), this.objectPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.instancePickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.groupPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.depthPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight);
  }
  return Object.defineProperty(e.prototype, "drawingBufferHeight", { get: function() {
    return this.drawPass.colorTarget.getHeight();
  }, enumerable: !1, configurable: !0 }), e.prototype.syncSize = function() {
    var t = this.pickBaseScale / this.webgl.pixelRatio, r = Math.ceil(this.drawPass.colorTarget.getWidth() * t), n = Math.ceil(this.drawPass.colorTarget.getHeight() * t);
    r === this.pickWidth && n === this.pickHeight || (this.pickWidth = r, this.pickHeight = n, this.objectPickTarget.setSize(this.pickWidth, this.pickHeight), this.instancePickTarget.setSize(this.pickWidth, this.pickHeight), this.groupPickTarget.setSize(this.pickWidth, this.pickHeight), this.depthPickTarget.setSize(this.pickWidth, this.pickHeight));
  }, e.prototype.renderVariant = function(t, r, n, a, i, o) {
    var s = this.drawPass.depthTexturePrimitives;
    t.clear(!1), t.update(r), t.renderPick(n.primitives, r, i, null, o), t.renderPick(n.volumes, r, i, s, o), t.renderPick(a.handle.scene, r, i, null, o), a.camera.isEnabled && (a.camera.update(r), t.update(a.camera.camera), t.renderPick(a.camera.scene, a.camera.camera, i, null, o));
  }, e.prototype.render = function(t, r, n, a) {
    this.objectPickTarget.bind(), this.renderVariant(t, r, n, a, "pick", 1), this.instancePickTarget.bind(), this.renderVariant(t, r, n, a, "pick", 2), this.groupPickTarget.bind(), this.renderVariant(t, r, n, a, "pick", 3), this.depthPickTarget.bind(), this.renderVariant(t, r, n, a, "depth", 0);
  }, e;
}(), Oie = function() {
  function e(t, r, n, a, i, o, s) {
    s === void 0 && (s = 1), this.webgl = t, this.renderer = r, this.scene = n, this.helper = a, this.pickPass = i, this.pickPadding = s, this.dirty = !0, this.viewport = Za(), this.setViewport(o.x, o.y, o.width, o.height);
  }
  return e.prototype.setupBuffers = function() {
    var t = this.pickWidth * this.pickHeight * 4;
    this.objectBuffer && this.objectBuffer.length === t || (this.objectBuffer = new Uint8Array(t), this.instanceBuffer = new Uint8Array(t), this.groupBuffer = new Uint8Array(t), this.depthBuffer = new Uint8Array(t));
  }, e.prototype.setViewport = function(t, r, n, a) {
    Za.set(this.viewport, t, r, n, a), this.pickScale = this.pickPass.pickBaseScale / this.webgl.pixelRatio, this.pickX = Math.ceil(t * this.pickScale), this.pickY = Math.ceil(r * this.pickScale);
    var i = Math.floor(n * this.pickScale), o = Math.floor(a * this.pickScale);
    i === this.pickWidth && o === this.pickHeight || (this.pickWidth = i, this.pickHeight = o, this.halfPickWidth = Math.floor(this.pickWidth / 2), this.setupBuffers()), this.spiral = function(s) {
      for (var u, c = 0, l = 0, d = [0, -1], f = 2 * s + 1, m = f / 2, h = [], p = Math.pow(f, 2); p > 0; --p) -m < c && c <= m && -m < l && l <= m && h.push([c, l]), (c === l || c < 0 && c === -l || c > 0 && c === 1 - l) && (u = [-d[1], d[0]], d[0] = u[0], d[1] = u[1]), c += d[0], l += d[1];
      return h;
    }(Math.round(this.pickScale * this.pickPadding));
  }, e.prototype.syncBuffers = function() {
    var t = this, r = t.pickX, n = t.pickY, a = t.pickWidth, i = t.pickHeight;
    this.pickPass.objectPickTarget.bind(), this.webgl.readPixels(r, n, a, i, this.objectBuffer), this.pickPass.instancePickTarget.bind(), this.webgl.readPixels(r, n, a, i, this.instanceBuffer), this.pickPass.groupPickTarget.bind(), this.webgl.readPixels(r, n, a, i, this.groupBuffer), this.pickPass.depthPickTarget.bind(), this.webgl.readPixels(r, n, a, i, this.depthBuffer);
  }, e.prototype.getBufferIdx = function(t, r) {
    return 4 * (r * this.pickWidth + t);
  }, e.prototype.getDepth = function(t, r) {
    var n = this.getBufferIdx(t, r), a = this.depthBuffer;
    return function(i, o, s, u) {
      return jt.set($C, i / 255, o / 255, s / 255, u / 255), jt.dot($C, rne);
    }(a[n], a[n + 1], a[n + 2], a[n + 3]);
  }, e.prototype.getId = function(t, r, n) {
    var a = this.getBufferIdx(t, r);
    return P8(n[a], n[a + 1], n[a + 2]);
  }, e.prototype.render = function(t) {
    var r = this, n = r.pickX, a = r.pickY, i = r.pickWidth, o = r.pickHeight, s = r.halfPickWidth, u = this, c = u.renderer, l = u.scene, d = u.helper;
    c.setTransparentBackground(!1), c.setDrawingBufferSize(this.pickPass.objectPickTarget.getWidth(), this.pickPass.objectPickTarget.getHeight()), c.setPixelRatio(this.pickScale), Wp.is(t) ? (c.setViewport(n, a, s, o), this.pickPass.render(c, t.left, l, d), c.setViewport(n + s, a, i - s, o), this.pickPass.render(c, t.right, l, d)) : (c.setViewport(n, a, i, o), this.pickPass.render(c, t, l, d)), this.dirty = !1;
  }, e.prototype.identifyInternal = function(t, r, n) {
    var a = this.webgl, i = this.pickScale;
    if (!a.isContextLost) {
      t *= a.pixelRatio, r *= a.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var o = this.viewport;
      if (!(t < o.x || r < o.y || t > o.x + o.width || r > o.y + o.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var s = t - o.x, u = r - o.y, c = Math.floor(s * i), l = Math.floor(u * i), d = this.getId(c, l, this.objectBuffer);
        if (d !== -1 && d !== Dx) {
          var f = this.getId(c, l, this.instanceBuffer);
          if (f !== -1 && f !== Dx) {
            var m = this.getId(c, l, this.groupBuffer);
            if (m !== -1 && m !== Dx) {
              var h = this.getDepth(c, l), p = D.create(t, o.height - r, h);
              if (Wp.is(n)) {
                var g = Math.floor(o.width / 2);
                t > o.x + g ? (p[0] = o.x + 2 * (s - g), C0(p, p, o, n.right.inverseProjectionView)) : (p[0] = o.x + 2 * s, C0(p, p, o, n.left.inverseProjectionView));
              } else C0(p, p, o, n.inverseProjectionView);
              return { id: { objectId: d, instanceId: f, groupId: m }, position: p };
            }
          }
        }
      }
    }
  }, e.prototype.identify = function(t, r, n) {
    for (var a = 0, i = this.spiral; a < i.length; a++) {
      var o = i[a], s = this.identifyInternal(t + o[0], r + o[1], n);
      if (s) return s;
    }
  }, e.prototype.getPosition = function(t, r, n) {
    var a = this.webgl;
    if (!a.isContextLost) {
      t *= a.pixelRatio, r *= a.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var i = this.viewport;
      if (!(t < i.x || r < i.y || t > i.x + i.width || r > i.y + i.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var o = 255 / 256, s = D.create(16777216, 65536, 256), u = jt.create(o / s[0], o / s[1], o / s[2], 0.99609375), c = jt();
        jt.set(c, 128 / 255, 128 / 255, 30 / 255, 60 / 255);
        var l = jt.dot(c, u) / (n.zoom / 40);
        l > 0.2 && (l = 0.1);
        var d = D.create(t, i.height - r, l);
        return C0(d, d, i, n.inverseProjectionView), { position: d };
      }
    }
  }, e;
}(), Fie = k(k({}, ei), { tWboitA: Kt("texture", "rgba", "float", "nearest"), tWboitB: Kt("texture", "rgba", "float", "nearest"), uTexSize: ze("v2") }), Rie = Rn("evaluate-wboit", Yi, `
precision highp float;

uniform sampler2D tWboitA;
uniform sampler2D tWboitB;
uniform vec2 uTexSize;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;

    vec4 accum = texture2D(tWboitA, coords);
    float r = 1.0 - accum.a;

    accum.a = texture2D(tWboitB, coords).r;
    // divisor needs to allow very small values for nice fading
    gl_FragColor = vec4(accum.rgb / clamp(accum.a, 0.00000001, 50000.0), r);
}
`), Lie = function() {
  function e(t, r, n) {
    if (this.webgl = t, this._supported = !1, e.isSupported(t)) {
      var a, i, o, s, u, c = t.resources;
      this.textureA = c.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(r, n), this.textureB = c.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(r, n), this.renderable = (a = t, i = this.textureA, o = this.textureB, s = k(k({}, Qa), { tWboitA: U.create(i), tWboitB: U.create(o), uTexSize: U.create(Ze.create(i.getWidth(), i.getHeight())) }), u = k({}, Fie), Ga(Ua(a, "triangles", Rie, u, s), s)), this.framebuffer = c.framebuffer(), this._supported = !0, this._init();
    }
  }
  return Object.defineProperty(e.prototype, "supported", { get: function() {
    return this._supported;
  }, enumerable: !1, configurable: !0 }), e.prototype.bind = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    this.framebuffer.bind(), r.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), r.disable(n.DEPTH_TEST), r.blendFuncSeparate(n.ONE, n.ONE, n.ZERO, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND);
  }, e.prototype.render = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    r.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND), this.renderable.update(), this.renderable.render();
  }, e.prototype.setSize = function(t, r) {
    var n = this.renderable.values.uTexSize.ref.value, a = n[0], i = n[1];
    t === a && r === i || (this.textureA.define(t, r), this.textureB.define(t, r), U.update(this.renderable.values.uTexSize, Ze.set(this.renderable.values.uTexSize.ref.value, t, r)));
  }, e.prototype.reset = function() {
    this._supported && this._init();
  }, e.prototype._init = function() {
    var t = this.webgl.extensions.drawBuffers;
    this.framebuffer.bind(), t.drawBuffers([t.COLOR_ATTACHMENT0, t.COLOR_ATTACHMENT1]), this.textureA.attachFramebuffer(this.framebuffer, "color0"), this.textureB.attachFramebuffer(this.framebuffer, "color1");
  }, e.isSupported = function(t) {
    var r = t.extensions, n = r.drawBuffers, a = r.textureFloat, i = r.colorBufferFloat, o = r.depthTexture;
    if (a && i && o && n) return !0;
    if (zr) {
      var s = [];
      a || s.push("textureFloat"), i || s.push("colorBufferFloat"), o || s.push("depthTexture"), n || s.push("drawBuffers"), console.log('Missing "'.concat(s.join('", "'), '" extensions required for "wboit"'));
    }
    return !1;
  }, e;
}(), uL = { enabled: V.Boolean(!0), highlightEdgeColor: V.Color(Qe.darken(Qe.fromNormalizedRgb(1, 0.4, 0.6), 1)), selectEdgeColor: V.Color(Qe.darken(Qe.fromNormalizedRgb(0.2, 1, 0.1), 1)), edgeScale: V.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }), ghostEdgeStrength: V.Numeric(1, { min: 0, max: 1, step: 0.1 }, { description: "Opacity of the hidden edges that are covered by other geometry. When set to 1, one less geometry render pass is done." }), innerEdgeFactor: V.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." }) }, UD = function() {
  function e(t, r, n) {
    this.webgl = t, this.depthTarget = t.createRenderTarget(r, n), this.maskTarget = t.createRenderTarget(r, n), this.edgesTarget = t.createRenderTarget(r, n), this.edge = function(a, i) {
      var o = i.getWidth(), s = i.getHeight(), u = k(k({}, Qa), { tMaskTexture: U.create(i), uTexSizeInv: U.create(Ze.create(1 / o, 1 / s)), dEdgeScale: U.create(1) }), c = k({}, kie);
      return Ga(Ua(a, "triangles", zie, c, u), u);
    }(t, this.maskTarget.texture), this.overlay = function(a, i) {
      var o = i.getWidth(), s = i.getHeight(), u = k(k({}, Qa), { tEdgeTexture: U.create(i), uTexSizeInv: U.create(Ze.create(1 / o, 1 / s)), uHighlightEdgeColor: U.create(D()), uSelectEdgeColor: U.create(D()), uGhostEdgeStrength: U.create(0), uInnerEdgeFactor: U.create(0) }), c = k({}, Uie);
      return Ga(Ua(a, "triangles", Gie, c, u), u);
    }(t, this.edgesTarget.texture);
  }
  return e.isEnabled = function(t) {
    return t.enabled;
  }, e.prototype.setEdgeState = function(t) {
    var r = this.webgl, n = r.gl, a = r.state;
    a.enable(n.SCISSOR_TEST), a.enable(n.BLEND), a.blendFunc(n.ONE, n.ONE), a.blendEquation(n.FUNC_ADD), a.disable(n.DEPTH_TEST), a.depthMask(!1);
    var i = t.x, o = t.y, s = t.width, u = t.height;
    n.viewport(i, o, s, u), n.scissor(i, o, s, u), a.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT);
  }, e.prototype.setOverlayState = function(t) {
    var r = this.webgl, n = r.gl, a = r.state;
    a.enable(n.SCISSOR_TEST), a.enable(n.BLEND), a.blendFunc(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA), a.blendEquation(n.FUNC_ADD), a.disable(n.DEPTH_TEST), a.depthMask(!1);
    var i = t.x, o = t.y, s = t.width, u = t.height;
    n.viewport(i, o, s, u), n.scissor(i, o, s, u);
  }, e.prototype.setSize = function(t, r) {
    var n = this.depthTarget.getWidth(), a = this.depthTarget.getHeight();
    t === n && r === a || (this.depthTarget.setSize(t, r), this.maskTarget.setSize(t, r), this.edgesTarget.setSize(t, r), U.update(this.edge.values.uTexSizeInv, Ze.set(this.edge.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), U.update(this.overlay.values.uTexSizeInv, Ze.set(this.overlay.values.uTexSizeInv.ref.value, 1 / t, 1 / r)));
  }, e.prototype.update = function(t) {
    var r = t.highlightEdgeColor, n = t.selectEdgeColor, a = t.edgeScale, i = t.innerEdgeFactor, o = t.ghostEdgeStrength, s = this.edge.values, u = Math.round(a * this.webgl.pixelRatio);
    s.dEdgeScale.ref.value !== u && (U.update(s.dEdgeScale, u), this.edge.update());
    var c = this.overlay.values;
    U.update(c.uHighlightEdgeColor, Qe.toVec3Normalized(c.uHighlightEdgeColor.ref.value, r)), U.update(c.uSelectEdgeColor, Qe.toVec3Normalized(c.uSelectEdgeColor.ref.value, n)), U.update(c.uInnerEdgeFactor, i), U.update(c.uGhostEdgeStrength, o);
  }, e.prototype.render = function(t, r) {
    this.edgesTarget.bind(), this.setEdgeState(t), this.edge.render(), r ? r.bind() : this.webgl.unbindFramebuffer(), this.setOverlayState(t), this.overlay.render();
  }, e;
}(), kie = k(k({}, ei), { tMaskTexture: Kt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ze("v2"), dEdgeScale: Ht("number") }), zie = Rn("edge", Yi, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tMaskTexture;
uniform vec2 uTexSizeInv;

void main() {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec4 offset = vec4(float(dEdgeScale), 0.0, 0.0, float(dEdgeScale)) * vec4(uTexSizeInv, uTexSizeInv);
    vec4 c0 = texture2D(tMaskTexture, coords);
    vec4 c1 = texture2D(tMaskTexture, coords + offset.xy);
    vec4 c2 = texture2D(tMaskTexture, coords - offset.xy);
    vec4 c3 = texture2D(tMaskTexture, coords + offset.yw);
    vec4 c4 = texture2D(tMaskTexture, coords - offset.yw);
    float diff1 = (c1.r - c2.r) * 0.5;
    float diff2 = (c3.r - c4.r) * 0.5;
    float d = length(vec2(diff1, diff2));
    if (d <= 0.0)
        discard;
    float a1 = min(c1.g, c2.g);
    float a2 = min(c3.g, c4.g);
    float visibility = min(a1, a2) > 0.001 ? 1.0 : 0.0;
    float mask = c0.r;
    float marker = min(c1.b, min(c2.b, min(c3.b, c4.b)));
    float fogAlpha = min(c1.a, min(c2.a, min(c3.a, c4.a)));
    gl_FragColor = vec4(visibility, mask, marker, fogAlpha);
}
`), Uie = k(k({}, ei), { tEdgeTexture: Kt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ze("v2"), uHighlightEdgeColor: ze("v3"), uSelectEdgeColor: ze("v3"), uGhostEdgeStrength: ze("f"), uInnerEdgeFactor: ze("f") }), Gie = Rn("overlay", Yi, `
precision highp float;
precision highp sampler2D;

uniform vec2 uTexSizeInv;
uniform sampler2D tEdgeTexture;
uniform vec3 uHighlightEdgeColor;
uniform vec3 uSelectEdgeColor;
uniform float uGhostEdgeStrength;
uniform float uInnerEdgeFactor;

void main() {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec4 edgeValue = texture2D(tEdgeTexture, coords);
    if (edgeValue.a > 0.0) {
        vec3 edgeColor = edgeValue.b == 1.0 ? uHighlightEdgeColor : uSelectEdgeColor;
        gl_FragColor.rgb = edgeValue.g > 0.0 ? edgeColor : edgeColor * uInnerEdgeFactor;
        gl_FragColor.a = (edgeValue.r == 1.0 ? uGhostEdgeStrength : 1.0) * edgeValue.a;
    } else {
        gl_FragColor = vec4(0.0);
    }
}
`), Vie = k(k({}, ei), { tDepthPrimitives: Kt("texture", "depth", "ushort", "nearest"), tDepthVolumes: Kt("texture", "depth", "ushort", "nearest"), uTexSize: ze("v2"), dPackedDepth: Ht("boolean") }), qie = Rn("depth-merge", Yi, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tDepthPrimitives;
uniform sampler2D tDepthVolumes;
uniform vec2 uTexSize;

#include common

float getDepth(const in vec2 coords, sampler2D tDepth) {
    #ifdef dPackedDepth
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #else
        return texture2D(tDepth, coords).r;
    #endif
}

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    float depth = min(getDepth(coords, tDepthPrimitives), getDepth(coords, tDepthVolumes));
    gl_FragColor = packDepthToRGBA(depth);
}
`), cL = function() {
  function e(t, r, n, a) {
    this.webgl = t;
    var i, o, s, u, c, l, d, f = t.extensions, m = t.resources, h = t.isWebGL2;
    this.drawTarget = (i = t.gl, { id: dF(), texture: ko(i), framebuffer: { id: cF(), bind: function() {
    }, reset: function() {
    }, destroy: function() {
    } }, getWidth: function() {
      return 0;
    }, getHeight: function() {
      return 0;
    }, bind: function() {
      i.bindFramebuffer(i.FRAMEBUFFER, null);
    }, setSize: function() {
    }, reset: function() {
    }, destroy: function() {
    } }), this.colorTarget = t.createRenderTarget(r, n, !0, "uint8", "linear"), this.packedDepth = !f.depthTexture, this.depthTarget = t.createRenderTarget(r, n), this.depthTexture = this.depthTarget.texture, this.depthTargetPrimitives = this.packedDepth ? t.createRenderTarget(r, n) : null, this.depthTargetVolumes = this.packedDepth ? t.createRenderTarget(r, n) : null, this.depthTexturePrimitives = this.depthTargetPrimitives ? this.depthTargetPrimitives.texture : m.texture("image-depth", "depth", h ? "float" : "ushort", "nearest"), this.depthTextureVolumes = this.depthTargetVolumes ? this.depthTargetVolumes.texture : m.texture("image-depth", "depth", h ? "float" : "ushort", "nearest"), this.packedDepth || (this.depthTexturePrimitives.define(r, n), this.depthTextureVolumes.define(r, n)), this.depthMerge = (o = t, s = this.depthTexturePrimitives, u = this.depthTextureVolumes, c = this.packedDepth, l = k(k({}, Qa), { tDepthPrimitives: U.create(s), tDepthVolumes: U.create(u), uTexSize: U.create(Ze.create(s.getWidth(), s.getHeight())), dPackedDepth: U.create(c) }), d = k({}, Vie), Ga(Ua(o, "triangles", qie, d, l), l)), this.wboit = a ? new Lie(t, r, n) : void 0, this.marking = new UD(t, r, n), this.postprocessing = new jc(t, this), this.antialiasing = new Ex(t, this), this.copyFboTarget = M6(t, this.colorTarget.texture), this.copyFboPostprocessing = M6(t, this.postprocessing.target.texture);
  }
  return Object.defineProperty(e.prototype, "wboitEnabled", { get: function() {
    var t;
    return !!(!((t = this.wboit) === null || t === void 0) && t.supported);
  }, enumerable: !1, configurable: !0 }), e.prototype.reset = function() {
    var t;
    (t = this.wboit) === null || t === void 0 || t.reset();
  }, e.prototype.setSize = function(t, r) {
    var n, a = this.colorTarget.getWidth(), i = this.colorTarget.getHeight();
    t === a && r === i || (this.colorTarget.setSize(t, r), this.depthTarget.setSize(t, r), this.depthTargetPrimitives ? this.depthTargetPrimitives.setSize(t, r) : this.depthTexturePrimitives.define(t, r), this.depthTargetVolumes ? this.depthTargetVolumes.setSize(t, r) : this.depthTextureVolumes.define(t, r), U.update(this.depthMerge.values.uTexSize, Ze.set(this.depthMerge.values.uTexSize.ref.value, t, r)), U.update(this.copyFboTarget.values.uTexSize, Ze.set(this.copyFboTarget.values.uTexSize.ref.value, t, r)), U.update(this.copyFboPostprocessing.values.uTexSize, Ze.set(this.copyFboPostprocessing.values.uTexSize.ref.value, t, r)), !((n = this.wboit) === null || n === void 0) && n.supported && this.wboit.setSize(t, r), this.marking.setSize(t, r), this.postprocessing.setSize(t, r), this.antialiasing.setSize(t, r));
  }, e.prototype._depthMerge = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    this.depthMerge.update(), this.depthTarget.bind(), r.disable(n.BLEND), r.disable(n.DEPTH_TEST), r.disable(n.CULL_FACE), r.depthMask(!1), r.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT), this.depthMerge.render();
  }, e.prototype._renderWboit = function(t, r, n, a, i) {
    var o;
    if (!(!((o = this.wboit) === null || o === void 0) && o.supported)) throw new Error("expected wboit to be supported");
    this.colorTarget.bind(), t.clear(!0), this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), t.clearDepth(), t.renderWboitOpaque(n.primitives, r, null), this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), t.clearDepth(), t.renderWboitOpaque(n.volumes, r, this.depthTexturePrimitives), this._depthMerge(), jc.isEnabled(i) && this.postprocessing.render(r, !1, a, t.props.backgroundColor, i), this.wboit.bind(), t.renderWboitTransparent(n.primitives, r, this.depthTexture), t.renderWboitTransparent(n.volumes, r, this.depthTexture), jc.isEnabled(i) ? (this.depthTexturePrimitives.attachFramebuffer(this.postprocessing.target.framebuffer, "depth"), this.postprocessing.target.bind()) : (this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind()), this.wboit.render();
  }, e.prototype._renderBlended = function(t, r, n, a, i, o) {
    if (a ? this.drawTarget.bind() : (this.colorTarget.bind(), this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth")), t.clear(!0), t.renderBlendedOpaque(n.primitives, r, null), !a) {
      this.depthTargetPrimitives && (this.depthTargetPrimitives.bind(), t.clear(!1), t.renderDepth(n.primitives, r, null), this.colorTarget.bind()), this.packedDepth || (this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), t.clearDepth()), t.renderBlendedVolumeOpaque(n.volumes, r, this.depthTexturePrimitives), this.depthTargetVolumes && (this.depthTargetVolumes.bind(), t.clear(!1), t.renderDepth(n.volumes, r, this.depthTexturePrimitives), this.colorTarget.bind()), this._depthMerge(), this.colorTarget.bind(), jc.isEnabled(o) && this.postprocessing.render(r, !1, i, t.props.backgroundColor, o), t.renderBlendedVolumeTransparent(n.volumes, r, this.depthTexturePrimitives);
      var s = jc.isEnabled(o) ? this.postprocessing.target : this.colorTarget;
      this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(s.framebuffer, "depth"), s.bind();
    }
    t.renderBlendedTransparent(n.primitives, r, null);
  }, e.prototype._render = function(t, r, n, a, i, o) {
    var s = n.volumes.renderables.length > 0, u = jc.isEnabled(o.postprocessing), c = Ex.isEnabled(o.postprocessing), l = UD.isEnabled(o.marking), d = r.viewport, f = d.x, m = d.y, h = d.width, p = d.height;
    if (t.setViewport(f, m, h, p), t.update(r), o.transparentBackground && !c && i && (this.drawTarget.bind(), t.clear(!1)), this.wboitEnabled ? this._renderWboit(t, r, n, o.transparentBackground, o.postprocessing) : this._renderBlended(t, r, n, !s && !u && !c && i, o.transparentBackground, o.postprocessing), u ? this.postprocessing.target.bind() : !i || s || this.wboitEnabled ? this.colorTarget.bind() : this.drawTarget.bind(), l) {
      var g = n.getMarkerAverage();
      if (g > 0) {
        var v = o.marking.ghostEdgeStrength < 1;
        v && g !== 1 && (this.marking.depthTarget.bind(), t.clear(!1, !0), t.renderMarkingDepth(n.primitives, r, null)), this.marking.maskTarget.bind(), t.clear(!1, !0), t.renderMarkingMask(n.primitives, r, v ? this.marking.depthTarget.texture : null), this.marking.update(o.marking), this.marking.render(r.viewport, u ? this.postprocessing.target : this.colorTarget);
      }
    }
    a.debug.isEnabled && (a.debug.syncVisibility(), t.renderBlended(a.debug.scene, r, null)), a.handle.isEnabled && t.renderBlended(a.handle.scene, r, null), a.camera.isEnabled && (a.camera.update(r), t.update(a.camera.camera), t.renderBlended(a.camera.scene, a.camera.camera, null)), c ? this.antialiasing.render(r, i, o.postprocessing) : i && (this.drawTarget.bind(), this.webgl.state.disable(this.webgl.gl.DEPTH_TEST), u ? this.copyFboPostprocessing.render() : (s || this.wboitEnabled) && this.copyFboTarget.render()), this.webgl.gl.flush();
  }, e.prototype.render = function(t, r, n) {
    var a = t.renderer, i = t.camera, o = t.scene, s = t.helper;
    a.setTransparentBackground(r.transparentBackground), a.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), a.setPixelRatio(this.webgl.pixelRatio), Wp.is(i) ? (this._render(a, i.left, o, s, n, r), this._render(a, i.right, o, s, n, r)) : this._render(a, i, o, s, n, r);
  }, e.prototype.getColorTarget = function(t) {
    return Ex.isEnabled(t) ? this.antialiasing.target : jc.isEnabled(t) ? this.postprocessing.target : this.colorTarget;
  }, e;
}();
function Au(e) {
  for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++) r[n - 1] = arguments[n];
  throw Error("[Immer] minified error nr: " + e + (r.length ? " " + r.map(function(a) {
    return "'" + a + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function Zp(e) {
  return !!e && !!e[gs];
}
function sm(e) {
  return !!e && (function(t) {
    if (!t || typeof t != "object") return !1;
    var r = Object.getPrototypeOf(t);
    if (r === null) return !0;
    var n = Object.hasOwnProperty.call(r, "constructor") && r.constructor;
    return n === Object || typeof n == "function" && Function.toString.call(n) === Wie;
  }(e) || Array.isArray(e) || !!e[YD] || !!e.constructor[YD] || V8(e) || q8(e));
}
function gh(e, t, r) {
  r === void 0 && (r = !1), Qp(e) === 0 ? (r ? Object.keys : Y8)(e).forEach(function(n) {
    r && typeof n == "symbol" || t(n, e[n], e);
  }) : e.forEach(function(n, a) {
    return t(a, n, e);
  });
}
function Qp(e) {
  var t = e[gs];
  return t ? t.i > 3 ? t.i - 4 : t.i : Array.isArray(e) ? 1 : V8(e) ? 2 : q8(e) ? 3 : 0;
}
function X6(e, t) {
  return Qp(e) === 2 ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
}
function lL(e, t, r) {
  var n = Qp(e);
  n === 2 ? e.set(t, r) : n === 3 ? (e.delete(t), e.add(r)) : e[t] = r;
}
function V8(e) {
  return jie && e instanceof Map;
}
function q8(e) {
  return Yie && e instanceof Set;
}
function Ff(e) {
  return e.o || e.t;
}
function H8(e) {
  if (Array.isArray(e)) return Array.prototype.slice.call(e);
  var t = Zie(e);
  delete t[gs];
  for (var r = Y8(t), n = 0; n < r.length; n++) {
    var a = r[n], i = t[a];
    i.writable === !1 && (i.writable = !0, i.configurable = !0), (i.get || i.set) && (t[a] = { configurable: !0, writable: !0, enumerable: i.enumerable, value: e[a] });
  }
  return Object.create(Object.getPrototypeOf(e), t);
}
function K8(e, t) {
  return t === void 0 && (t = !1), X8(e) || Zp(e) || !sm(e) || (Qp(e) > 1 && (e.set = e.add = e.clear = e.delete = Hie), Object.freeze(e), t && gh(e, function(r, n) {
    return K8(n, !0);
  }, !0)), e;
}
function Hie() {
  Au(2);
}
function X8(e) {
  return e == null || typeof e != "object" || Object.isFrozen(e);
}
function sc(e) {
  var t = Qie[e];
  return t || Au(18, e), t;
}
function GD() {
  return yh;
}
function Mx(e, t) {
  t && (sc("Patches"), e.u = [], e.s = [], e.v = t);
}
function by(e) {
  j6(e), e.p.forEach(Kie), e.p = null;
}
function j6(e) {
  e === yh && (yh = e.l);
}
function VD(e) {
  return yh = { p: [], l: yh, h: e, m: !0, _: 0 };
}
function Kie(e) {
  var t = e[gs];
  t.i === 0 || t.i === 1 ? t.j() : t.O = !0;
}
function Ix(e, t) {
  t._ = t.p.length;
  var r = t.p[0], n = e !== void 0 && e !== r;
  return t.h.g || sc("ES5").S(t, e, n), n ? (r[gs].P && (by(t), Au(4)), sm(e) && (e = xy(t, e), t.l || _y(t, e)), t.u && sc("Patches").M(r[gs].t, e, t.u, t.s)) : e = xy(t, r, []), by(t), t.u && t.v(t.u, t.s), e !== dL ? e : void 0;
}
function xy(e, t, r) {
  if (X8(t)) return t;
  var n = t[gs];
  if (!n) return gh(t, function(i, o) {
    return qD(e, n, t, i, o, r);
  }, !0), t;
  if (n.A !== e) return t;
  if (!n.P) return _y(e, n.t, !0), n.t;
  if (!n.I) {
    n.I = !0, n.A._--;
    var a = n.i === 4 || n.i === 5 ? n.o = H8(n.k) : n.o;
    gh(n.i === 3 ? new Set(a) : a, function(i, o) {
      return qD(e, n, a, i, o, r);
    }), _y(e, a, !1), r && e.u && sc("Patches").R(n, r, e.u, e.s);
  }
  return n.o;
}
function qD(e, t, r, n, a, i) {
  if (Zp(a)) {
    var o = xy(e, a, i && t && t.i !== 3 && !X6(t.D, n) ? i.concat(n) : void 0);
    if (lL(r, n, o), !Zp(o)) return;
    e.m = !1;
  }
  if (sm(a) && !X8(a)) {
    if (!e.h.F && e._ < 1) return;
    xy(e, a), t && t.A.l || _y(e, a);
  }
}
function _y(e, t, r) {
  r === void 0 && (r = !1), e.h.F && e.m && K8(t, r);
}
function Tx(e, t) {
  var r = e[gs];
  return (r ? Ff(r) : e)[t];
}
function HD(e, t) {
  if (t in e) for (var r = Object.getPrototypeOf(e); r; ) {
    var n = Object.getOwnPropertyDescriptor(r, t);
    if (n) return n;
    r = Object.getPrototypeOf(r);
  }
}
function Y6(e) {
  e.P || (e.P = !0, e.l && Y6(e.l));
}
function Nx(e) {
  e.o || (e.o = H8(e.t));
}
function W6(e, t, r) {
  var n = V8(t) ? sc("MapSet").N(t, r) : q8(t) ? sc("MapSet").T(t, r) : e.g ? function(a, i) {
    var o = Array.isArray(a), s = { i: o ? 1 : 0, A: i ? i.A : GD(), P: !1, I: !1, D: {}, l: i, t: a, k: null, o: null, j: null, C: !1 }, u = s, c = Z6;
    o && (u = [s], c = F0);
    var l = Proxy.revocable(u, c), d = l.revoke, f = l.proxy;
    return s.k = f, s.j = d, f;
  }(t, r) : sc("ES5").J(t, r);
  return (r ? r.A : GD()).p.push(n), n;
}
function Xie(e) {
  return Zp(e) || Au(22, e), function t(r) {
    if (!sm(r)) return r;
    var n, a = r[gs], i = Qp(r);
    if (a) {
      if (!a.P && (a.i < 4 || !sc("ES5").K(a))) return a.t;
      a.I = !0, n = KD(r, i), a.I = !1;
    } else n = KD(r, i);
    return gh(n, function(o, s) {
      a && function(u, c) {
        return Qp(u) === 2 ? u.get(c) : u[c];
      }(a.t, o) === s || lL(n, o, t(s));
    }), i === 3 ? new Set(n) : n;
  }(e);
}
function KD(e, t) {
  switch (t) {
    case 2:
      return new Map(e);
    case 3:
      return Array.from(e);
  }
  return H8(e);
}
var XD, yh, j8 = typeof Symbol < "u" && typeof Symbol("x") == "symbol", jie = typeof Map < "u", Yie = typeof Set < "u", jD = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", dL = j8 ? Symbol.for("immer-nothing") : ((XD = {})["immer-nothing"] = !0, XD), YD = j8 ? Symbol.for("immer-draftable") : "__$immer_draftable", gs = j8 ? Symbol.for("immer-state") : "__$immer_state", Wie = "" + Object.prototype.constructor, Y8 = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(e) {
  return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : Object.getOwnPropertyNames, Zie = Object.getOwnPropertyDescriptors || function(e) {
  var t = {};
  return Y8(e).forEach(function(r) {
    t[r] = Object.getOwnPropertyDescriptor(e, r);
  }), t;
}, Qie = {}, Z6 = { get: function(e, t) {
  if (t === gs) return e;
  var r = Ff(e);
  if (!X6(r, t)) return function(a, i, o) {
    var s, u = HD(i, o);
    return u ? "value" in u ? u.value : (s = u.get) === null || s === void 0 ? void 0 : s.call(a.k) : void 0;
  }(e, r, t);
  var n = r[t];
  return e.I || !sm(n) ? n : n === Tx(e.t, t) ? (Nx(e), e.o[t] = W6(e.A.h, n, e)) : n;
}, has: function(e, t) {
  return t in Ff(e);
}, ownKeys: function(e) {
  return Reflect.ownKeys(Ff(e));
}, set: function(e, t, r) {
  var n = HD(Ff(e), t);
  if (n != null && n.set) return n.set.call(e.k, r), !0;
  if (!e.P) {
    var a = Tx(Ff(e), t), i = a == null ? void 0 : a[gs];
    if (i && i.t === r) return e.o[t] = r, e.D[t] = !1, !0;
    if (function(o, s) {
      return o === s ? o !== 0 || 1 / o == 1 / s : o != o && s != s;
    }(r, a) && (r !== void 0 || X6(e.t, t))) return !0;
    Nx(e), Y6(e);
  }
  return e.o[t] === r && typeof r != "number" && (r !== void 0 || t in e.o) || (e.o[t] = r, e.D[t] = !0, !0);
}, deleteProperty: function(e, t) {
  return Tx(e.t, t) !== void 0 || t in e.t ? (e.D[t] = !1, Nx(e), Y6(e)) : delete e.D[t], e.o && delete e.o[t], !0;
}, getOwnPropertyDescriptor: function(e, t) {
  var r = Ff(e), n = Reflect.getOwnPropertyDescriptor(r, t);
  return n && { writable: !0, configurable: e.i !== 1 || t !== "length", enumerable: n.enumerable, value: r[t] };
}, defineProperty: function() {
  Au(11);
}, getPrototypeOf: function(e) {
  return Object.getPrototypeOf(e.t);
}, setPrototypeOf: function() {
  Au(12);
} }, F0 = {};
gh(Z6, function(e, t) {
  F0[e] = function() {
    return arguments[0] = arguments[0][0], t.apply(this, arguments);
  };
}), F0.deleteProperty = function(e, t) {
  return F0.set.call(this, e, t, void 0);
}, F0.set = function(e, t, r) {
  return Z6.set.call(this, e[0], t, r, e[0]);
};
var $ie = function() {
  function e(r) {
    var n = this;
    this.g = jD, this.F = !0, this.produce = function(a, i, o) {
      if (typeof a == "function" && typeof i != "function") {
        var s = i;
        i = a;
        var u = n;
        return function(p) {
          var g = this;
          p === void 0 && (p = s);
          for (var v = arguments.length, y = Array(v > 1 ? v - 1 : 0), _ = 1; _ < v; _++) y[_ - 1] = arguments[_];
          return u.produce(p, function(S) {
            var b;
            return (b = i).call.apply(b, [g, S].concat(y));
          });
        };
      }
      var c;
      if (typeof i != "function" && Au(6), o !== void 0 && typeof o != "function" && Au(7), sm(a)) {
        var l = VD(n), d = W6(n, a, void 0), f = !0;
        try {
          c = i(d), f = !1;
        } finally {
          f ? by(l) : j6(l);
        }
        return typeof Promise < "u" && c instanceof Promise ? c.then(function(p) {
          return Mx(l, o), Ix(p, l);
        }, function(p) {
          throw by(l), p;
        }) : (Mx(l, o), Ix(c, l));
      }
      if (!a || typeof a != "object") {
        if ((c = i(a)) === void 0 && (c = a), c === dL && (c = void 0), n.F && K8(c, !0), o) {
          var m = [], h = [];
          sc("Patches").M(a, c, m, h), o(m, h);
        }
        return c;
      }
      Au(21, a);
    }, this.produceWithPatches = function(a, i) {
      if (typeof a == "function") return function(c) {
        for (var l = arguments.length, d = Array(l > 1 ? l - 1 : 0), f = 1; f < l; f++) d[f - 1] = arguments[f];
        return n.produceWithPatches(c, function(m) {
          return a.apply(void 0, [m].concat(d));
        });
      };
      var o, s, u = n.produce(a, i, function(c, l) {
        o = c, s = l;
      });
      return typeof Promise < "u" && u instanceof Promise ? u.then(function(c) {
        return [c, o, s];
      }) : [u, o, s];
    }, typeof (r == null ? void 0 : r.useProxies) == "boolean" && this.setUseProxies(r.useProxies), typeof (r == null ? void 0 : r.autoFreeze) == "boolean" && this.setAutoFreeze(r.autoFreeze);
  }
  var t = e.prototype;
  return t.createDraft = function(r) {
    sm(r) || Au(8), Zp(r) && (r = Xie(r));
    var n = VD(this), a = W6(this, r, void 0);
    return a[gs].C = !0, j6(n), a;
  }, t.finishDraft = function(r, n) {
    var a = (r && r[gs]).A;
    return Mx(a, n), Ix(void 0, a);
  }, t.setAutoFreeze = function(r) {
    this.F = r;
  }, t.setUseProxies = function(r) {
    r && !jD && Au(20), this.g = r;
  }, t.applyPatches = function(r, n) {
    var a;
    for (a = n.length - 1; a >= 0; a--) {
      var i = n[a];
      if (i.path.length === 0 && i.op === "replace") {
        r = i.value;
        break;
      }
    }
    a > -1 && (n = n.slice(a + 1));
    var o = sc("Patches").$;
    return Zp(r) ? o(r, n) : this.produce(r, function(s) {
      return o(s, n);
    });
  }, e;
}(), is = new $ie(), W8 = is.produce;
is.produceWithPatches.bind(is), is.setAutoFreeze.bind(is), is.setUseProxies.bind(is), is.applyPatches.bind(is), is.createDraft.bind(is), is.finishDraft.bind(is);
var Hd, Rs = new Uint16Array([0, 1, 2, 1, 3, 2]), xf = Ye.add3, ai = Ye.add2, WD = Ye.add;
(function(e) {
  e.create = function(t, r, n, a) {
    t === void 0 && (t = {}), r === void 0 && (r = 2048), n === void 0 && (n = 1024), r *= 2, n *= 2;
    var i = Ye.create(Float32Array, 3, n, a ? a.centerBuffer.ref.value : r), o = Ye.create(Float32Array, 2, n, a ? a.mappingBuffer.ref.value : r), s = Ye.create(Float32Array, 1, n, a ? a.depthBuffer.ref.value : r), u = Ye.create(Uint32Array, 3, n, a ? a.indexBuffer.ref.value : r), c = Ye.create(Float32Array, 1, n, a ? a.groupBuffer.ref.value : r), l = Ye.create(Float32Array, 2, n, a ? a.tcoordBuffer.ref.value : r), d = k(k({}, V.getDefaultValues(vs.Params)), t), f = d.attachment, m = d.background, h = d.backgroundMargin, p = d.tether, g = d.tetherLength, v = d.tetherBaseWidth, y = function(x) {
      var A = JSON.stringify(x);
      return ax[A] === void 0 && (ax[A] = new ane(x)), ax[A];
    }(d), _ = 0.4 * h, S = y.buffer / y.lineHeight, b = function(x, A, w, C, M) {
      xf(i, x, A, w), WD(s, C), WD(c, M);
    };
    return { add: function(x, A, w, C, M, T, N) {
      for (var I = 0, P = x.length, O = 0; O < P; ++O)
        I += (ae = y.get(x[O])).nw - 2 * S;
      var F, R;
      if (F = f.startsWith("top") ? 0.8 : f.startsWith("middle") ? 0.4 : 0, R = f.endsWith("right") ? I : f.endsWith("center") ? I / 2 : 0, p) switch (f) {
        case "bottom-left":
          R -= g / 2 + _ + 0.1, F -= g / 2 + _;
          break;
        case "bottom-center":
          F -= g + _;
          break;
        case "bottom-right":
          R += g / 2 + _ + 0.1, F -= g / 2 + _;
          break;
        case "middle-left":
          R -= g + _ + 0.1;
          break;
        case "middle-center":
          break;
        case "middle-right":
          R += g + _ + 0.1;
          break;
        case "top-left":
          R -= g / 2 + _ + 0.1, F += g / 2 + _;
          break;
        case "top-center":
          F += g + _;
          break;
        case "top-right":
          R += g / 2 + _ + 0.1, F += g / 2 + _;
      }
      var G = (-R - _ - 0.1) * T, L = (I - R + _ + 0.1) * T, q = (0.8 - F + _) * T, K = (-F - _) * T;
      if (m) {
        ai(o, G, q), ai(o, G, K), ai(o, L, q), ai(o, L, K);
        for (var X = i.elementCount, H = 0; H < 4; ++H) ai(l, 10, 10), b(A, w, C, M, N);
        xf(u, X + Rs[0], X + Rs[1], X + Rs[2]), xf(u, X + Rs[3], X + Rs[4], X + Rs[5]);
      }
      if (p) {
        var W = void 0, ee = void 0, $ = void 0, te = void 0, re = void 0, ie = void 0, oe = void 0, se = void 0, he = g * T, ge = v * T;
        switch (f) {
          case "bottom-left":
            W = G - he / 2, $ = G + ge / 2, re = G, oe = G, ee = K - he / 2, te = K, ie = K + ge / 2, se = K;
            break;
          case "bottom-center":
            W = 0, $ = ge / 2, re = -ge / 2, oe = 0, ee = K - he, te = K, ie = K, se = K;
            break;
          case "bottom-right":
            W = L + he / 2, $ = L, re = L - ge / 2, oe = L, ee = K - he / 2, te = K + ge / 2, ie = K, se = K;
            break;
          case "middle-left":
            W = G - he, $ = G, re = G, oe = G, ee = 0, te = -ge / 2, ie = ge / 2, se = 0;
            break;
          case "middle-center":
            W = 0, $ = 0, re = 0, oe = 0, ee = 0, te = 0, ie = 0, se = 0;
            break;
          case "middle-right":
            W = L + he, $ = L, re = L, oe = L, ee = 0, te = ge / 2, ie = -ge / 2, se = 0;
            break;
          case "top-left":
            W = G - he / 2, $ = G + ge / 2, re = G, oe = G, ee = q + he / 2, te = q, ie = q - ge / 2, se = q;
            break;
          case "top-center":
            W = 0, $ = ge / 2, re = -ge / 2, oe = 0, ee = q + he, te = q, ie = q, se = q;
            break;
          case "top-right":
            W = L + he / 2, $ = L, re = L - ge / 2, oe = L, ee = q + he / 2, te = q - ge / 2, ie = q, se = q;
            break;
          default:
            Ja();
        }
        for (ai(o, W, ee), ai(o, $, te), ai(o, re, ie), ai(o, oe, se), X = i.elementCount, H = 0; H < 4; ++H) ai(l, 10, 10), b(A, w, C, M, N);
        xf(u, X, X + 1, X + 3), xf(u, X, X + 3, X + 2);
      }
      R += S, F += S;
      var De = 0;
      for (O = 0; O < P; ++O) {
        var ae, ce = (De - R) * T, _e = (De + (ae = y.get(x[O])).nw - R) * T, le = (ae.nh - F) * T, ue = -F * T;
        ai(o, ce, le), ai(o, ce, ue), ai(o, _e, le), ai(o, _e, ue);
        var be = y.texture.width, Se = y.texture.height;
        for (ai(l, ae.x / be, ae.y / Se), ai(l, ae.x / be, (ae.y + ae.h) / Se), ai(l, (ae.x + ae.w) / be, ae.y / Se), ai(l, (ae.x + ae.w) / be, (ae.y + ae.h) / Se), De += ae.nw - 2 * S, X = i.elementCount, H = 0; H < 4; ++H) b(A, w, C, M, N);
        xf(u, X + Rs[0], X + Rs[1], X + Rs[2]), xf(u, X + Rs[3], X + Rs[4], X + Rs[5]);
      }
    }, getText: function() {
      var x = y.texture, A = Ye.compact(i, !0), w = Ye.compact(o, !0), C = Ye.compact(s, !0), M = Ye.compact(u, !0), T = Ye.compact(c, !0), N = Ye.compact(l, !0);
      return vs.create(x, A, w, C, M, T, N, u.elementCount / 2, a);
    } };
  };
})(Hd || (Hd = {}));
var xn, fL = { alpha: V.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }), hideX: V.Boolean(!1), hideY: V.Boolean(!1), hideZ: V.Boolean(!1), colorX: V.Color($t.red, { isEssential: !0 }), colorY: V.Color($t.green, { isEssential: !0 }), colorZ: V.Color($t.blue, { isEssential: !0 }), scale: V.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }), vecA: V.Vec3(D.unitX), vecB: V.Vec3(D.unitY), vecC: V.Vec3(D.unitZ), location: V.Select("bottom-left", V.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])), locationOffsetX: V.Numeric(0), locationOffsetY: V.Numeric(0), originColor: V.Color($t.grey), radiusScale: V.Numeric(0.075, { min: 0.01, max: 0.3, step: 1e-3 }), showPlanes: V.Boolean(!1), planeColorXY: V.Color($t.grey, { label: "Plane Color XY" }), planeColorXZ: V.Color($t.grey, { label: "Plane Color XZ" }), planeColorYZ: V.Color($t.grey, { label: "Plane Color YZ" }), showLabels: V.Boolean(!0), labelX: V.Text("X"), labelY: V.Text("Y"), labelZ: V.Text("Z"), labelColorX: V.Color($t.grey), labelColorY: V.Color($t.grey), labelColorZ: V.Color($t.grey), labelOpacity: V.Numeric(1, { min: 0, max: 1, step: 0.01 }), labelScale: V.Numeric(0.15, { min: 0.1, max: 1, step: 0.01 }) }, S3 = { axes: V.MappedStatic("on", { on: V.Group(fL), off: V.Group({}) }, { cycle: !0, description: "Show camera orientation axes" }) }, mL = function() {
  function e(t, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = t, this.props = { axes: { name: "off", params: {} } }, this.pixelRatio = 1, this.eachGroup = function(a, i) {
      if (!ZD(a)) return !1;
      var o = !1;
      if (n.meshRenderObject) for (var s = n.meshRenderObject.values.uGroupCount.ref.value, u = 0, c = a.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, f = l.instanceId * s + d;
        i(Fe.ofSingleton(f)) && (o = !0);
      }
      if (n.textRenderObject) {
        s = n.textRenderObject.values.uGroupCount.ref.value;
        for (var m = 0, h = a.elements; m < h.length; m++) {
          var p = h[m];
          d = p.groupId, f = p.instanceId * s + d, i(Fe.ofSingleton(f)) && (o = !0);
        }
      }
      return o;
    }, this.scene = Yp.create(t, y3), this.camera = new oa(), D.set(this.camera.up, 0, 1, 0), D.set(this.camera.target, 0, 0, 0), this.setProps(r);
  }
  return e.prototype.setProps = function(t) {
    var r = this;
    this.props = W8(this.props, function(n) {
      if (t.axes !== void 0 && (n.axes.name = t.axes.name, t.axes.name === "on")) {
        r.scene.clear();
        var a = k(k({}, V.getDefaultValues(fL)), t.axes.params);
        r.pixelRatio = r.webgl.pixelRatio;
        var i = k(k({}, a), { scale: a.scale * r.pixelRatio, labelScale: a.labelScale * r.pixelRatio });
        r.meshRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(m, h) {
              var p = m.vecA, g = m.vecB, v = m.vecC, y = Nt.createState(512, 256, h), _ = 100 * m.scale, S = m.radiusScale * _, b = m.showLabels ? 100 * m.labelScale / 3 : 0, x = D.sub(D(), D.scale(D(), p, _ - b), D.scale(D(), D.create(0, 0, 1), 0.5 * _)), A = D.sub(D(), D.scale(D(), g, _ - b), D.scale(D(), D.create(0, 0, 1), 0.5 * _)), w = D.sub(D(), D.scale(D(), v, _ - b), D.scale(D(), D.create(0, 0, 1), 0.5 * _)), C = D.sub(D(), D.origin, D.scale(D(), D.create(0, 0, 1), 0.5 * _)), M = { radiusTop: S, radiusBottom: S, radialSegments: 32 };
              if (y.currentGroup = xn.Origin, La(y, C, S, 2), m.hideX || (y.currentGroup = xn.X, La(y, x, S, 2), Ba(y, C, x, 1, M)), m.hideY || (y.currentGroup = xn.Y, La(y, A, S, 2), Ba(y, C, A, 1, M)), m.hideZ || (y.currentGroup = xn.Z, La(y, w, S, 2), Ba(y, C, w, 1, M)), m.showPlanes) {
                if (D.scale(x, x, 0.5), D.scale(A, A, 0.5), D.scale(w, w, 0.5), !m.hideX && !m.hideY) {
                  y.currentGroup = xn.XY, Nt.addTriangle(y, C, x, A), Nt.addTriangle(y, C, A, x);
                  var T = D.add(D(), x, A);
                  Nt.addTriangle(y, T, x, A), Nt.addTriangle(y, T, A, x);
                }
                if (!m.hideX && !m.hideZ) {
                  y.currentGroup = xn.XZ, Nt.addTriangle(y, C, x, w), Nt.addTriangle(y, C, w, x);
                  var N = D.add(D(), x, w);
                  Nt.addTriangle(y, N, x, w), Nt.addTriangle(y, N, w, x);
                }
                if (!m.hideY && !m.hideZ) {
                  y.currentGroup = xn.YZ, Nt.addTriangle(y, C, A, w), Nt.addTriangle(y, C, w, A);
                  var I = D.add(D(), A, w);
                  Nt.addTriangle(y, I, A, w), Nt.addTriangle(y, I, w, A);
                }
              }
              return Nt.getMesh(y);
            }(u, void 0);
            d.setBoundingSphere(Ve.create(D.create(l / 2, l / 2, l / 2), l + l / 4));
            var f = function(m) {
              switch (m) {
                case xn.X:
                  return u.colorX;
                case xn.Y:
                  return u.colorY;
                case xn.Z:
                  return u.colorZ;
                case xn.XY:
                  return u.planeColorXY;
                case xn.XZ:
                  return u.planeColorXZ;
                case xn.YZ:
                  return u.planeColorYZ;
                case xn.Origin:
                  return u.originColor;
                default:
                  return $t.grey;
              }
            };
            return or.create("axes-mesh", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return or.createRenderObject(s, k(k(k({}, V.getDefaultValues(Xt.Params)), o), { ignoreLight: !0 }));
        }(i), r.scene.add(r.meshRenderObject), i.showLabels ? (r.textRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(m, h) {
              var p = m.vecA, g = m.vecB, v = m.vecC, y = Hd.create(m, 8, 8, h), _ = 100 * m.scale, S = D.add(D(), D.scale(D(), p, _), D.scale(D(), D.create(0, 0, 1), 1.5 * _)), b = D.add(D(), D.scale(D(), g, _), D.scale(D(), D.create(0, 0, 1), 1.5 * _)), x = D.add(D(), D.scale(D(), v, _), D.scale(D(), D.create(0, 0, 1), 1.5 * _)), A = 100 * m.labelScale;
              return m.hideX || y.add(m.labelX, S[0], S[1], S[2], 0, A, xn.X), m.hideY || y.add(m.labelY, b[0], b[1], b[2], 0, A, xn.Y), m.hideZ || y.add(m.labelZ, x[0], x[1], x[2], 0, A, xn.Z), y.getText();
            }(u, void 0);
            d.setBoundingSphere(Ve.create(D.create(l / 2, l / 2, l / 2), l));
            var f = function(m) {
              switch (m) {
                case xn.X:
                  return u.labelColorX;
                case xn.Y:
                  return u.labelColorY;
                case xn.Z:
                  return u.labelColorZ;
                default:
                  return $t.grey;
              }
            };
            return or.create("axes-text", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return or.createRenderObject(s, k(k(k({}, V.getDefaultValues(vs.Params)), o), { alpha: o.labelOpacity }));
        }(i), r.scene.add(r.textRenderObject)) : r.textRenderObject = void 0, r.scene.commit(), D.set(r.camera.position, 0, 0, 200 * i.scale), Ee.lookAt(r.camera.view, r.camera.position, r.camera.target, r.camera.up), n.axes.params = k({}, a);
      }
    });
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this.props.axes.name === "on";
  }, enumerable: !1, configurable: !0 }), e.prototype.getLoci = function(t) {
    var r = t.objectId, n = t.groupId, a = t.instanceId;
    return (this.meshRenderObject && r === this.meshRenderObject.id || this.textRenderObject && r === this.textRenderObject.id) && n !== xn.None ? function(i, o, s) {
      return z8("camera-axes", i, [{ groupId: o, instanceId: s }], void 0, function() {
        return function(u, c) {
          var l = c.props.axes, d = l.name === "on" ? l.params.labelX : "X", f = l.name === "on" ? l.params.labelY : "Y", m = l.name === "on" ? l.params.labelZ : "Z";
          switch (u) {
            case xn.X:
              return "".concat(d, " Axis");
            case xn.Y:
              return "".concat(f, " Axis");
            case xn.Z:
              return "".concat(m, " Axis");
            case xn.XY:
              return "".concat(d).concat(f, " Plane");
            case xn.XZ:
              return "".concat(d).concat(m, " Plane");
            case xn.YZ:
              return "".concat(f).concat(m, " Plane");
            case xn.Origin:
              return "Origin";
            default:
              return "Axes";
          }
        }(o, i);
      });
    }(this, n, a) : Tn;
  }, e.prototype.mark = function(t, r) {
    return !qr.is(qr.Highlighting, r) || !Vo(t) && (!ZD(t) || t.data !== this) ? !1 : cr.mark(this.meshRenderObject, t, r, this.eachGroup) || cr.mark(this.textRenderObject, t, r, this.eachGroup);
  }, e.prototype.update = function(t) {
    if (this.meshRenderObject && this.props.axes.name !== "off") {
      this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), function(o, s, u) {
        var c = o.near, l = o.far, d = -s.width / 2, f = s.width / 2, m = s.height / 2, h = -s.height / 2, p = (f - d) / 2, g = (m - h) / 2, v = (f + d) / 2, y = (m + h) / 2, _ = v - p, S = v + p, b = y + g, x = y - g;
        if (u.enabled) {
          var A = (f - d) / u.width, w = (m - h) / u.height;
          S = (_ += A * u.offsetX) + A * u.width, x = (b -= w * u.offsetY) - w * u.height;
        }
        Ee.ortho(o.projection, _, S, b, x, c, l);
      }(this.camera, t.viewport, t.viewOffset), Ee.extractRotation(this.scene.view, t.view);
      var r = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, n = this.props.axes.params.location, a = this.props.axes.params.locationOffsetX * this.pixelRatio, i = this.props.axes.params.locationOffsetY * this.pixelRatio;
      n === "bottom-left" ? Ee.setTranslation(this.scene.view, D.create(-t.viewport.width / 2 + r + a, -t.viewport.height / 2 + r + i, 0)) : n === "bottom-right" ? Ee.setTranslation(this.scene.view, D.create(t.viewport.width / 2 - r - a, -t.viewport.height / 2 + r + i, 0)) : n === "top-left" ? Ee.setTranslation(this.scene.view, D.create(-t.viewport.width / 2 + r + a, t.viewport.height / 2 - r - i, 0)) : n === "top-right" ? Ee.setTranslation(this.scene.view, D.create(t.viewport.width / 2 - r - a, t.viewport.height / 2 - r - i, 0)) : Ja();
    }
  }, e;
}();
function ZD(e) {
  return e.kind === "data-loci" && e.tag === "camera-axes";
}
(function(e) {
  e[e.None = 0] = "None", e[e.X = 1] = "X", e[e.Y = 2] = "Y", e[e.Z = 3] = "Z", e[e.XY = 4] = "XY", e[e.XZ = 5] = "XZ", e[e.YZ = 6] = "YZ", e[e.Origin = 7] = "Origin";
})(xn || (xn = {}));
var Jie = { transparentBackground: V.Boolean(!1), multiSample: V.Group(iL), postprocessing: V.Group(aL), marking: V.Group(uL), cameraHelper: V.Group(S3) }, eoe = function() {
  function e(t, r, n, a, i, o, s) {
    this.webgl = t, this.renderer = r, this.scene = n, this.camera = a, this._width = 0, this._height = 0, this._camera = new oa(), this.props = k(k({}, V.getDefaultValues(Jie)), s), this.drawPass = new cL(t, 128, 128, o), this.multiSamplePass = new yy(t, this.drawPass), this.multiSampleHelper = new oL(this.multiSamplePass), this.helper = { camera: new mL(t, this.props.cameraHelper), debug: i.debug, handle: i.handle }, this.setSize(1024, 768);
  }
  return Object.defineProperty(e.prototype, "colorTarget", { get: function() {
    return this._colorTarget;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "width", { get: function() {
    return this._width;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "height", { get: function() {
    return this._height;
  }, enumerable: !1, configurable: !0 }), e.prototype.setSize = function(t, r) {
    t === this._width && r === this._height || (this._width = t, this._height = r, this.drawPass.setSize(t, r), this.multiSamplePass.syncSize());
  }, e.prototype.setProps = function(t) {
    t === void 0 && (t = {}), Object.assign(this.props, t), t.cameraHelper && this.helper.camera.setProps(t.cameraHelper);
  }, e.prototype.render = function() {
    oa.copySnapshot(this._camera.state, this.camera.state), Za.set(this._camera.viewport, 0, 0, this._width, this._height), this._camera.update();
    var t = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
    yy.isEnabled(this.props.multiSample) ? (this.multiSampleHelper.render(t, this.props, !1), this._colorTarget = this.multiSamplePass.colorTarget) : (this.drawPass.render(t, this.props, !1), this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing));
  }, e.prototype.getImageData = function(t, r, n) {
    var a, i;
    this.setSize(t, r), this.render(), this.colorTarget.bind();
    var o = (a = n == null ? void 0 : n.width) !== null && a !== void 0 ? a : t, s = (i = n == null ? void 0 : n.height) !== null && i !== void 0 ? i : r, u = new Uint8Array(o * s * 4);
    n ? this.webgl.readPixels(n.x, r - n.y - n.height, o, s, u) : this.webgl.readPixels(0, 0, o, s, u);
    var c = jf.create(u, o, s);
    return jf.flipY(c), jf.divideByAlpha(c), new ImageData(new Uint8ClampedArray(u), o, s);
  }, e;
}(), toe = k(k({}, Xt.Params), { alpha: k(k({}, Xt.Params.alpha), { defaultValue: 1 }), ignoreLight: k(k({}, Xt.Params.ignoreLight), { defaultValue: !0 }), colorX: V.Color($t.red, { isEssential: !0 }), colorY: V.Color($t.green, { isEssential: !0 }), colorZ: V.Color($t.blue, { isEssential: !0 }), scale: V.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }) }), pL = { handle: V.MappedStatic("off", { on: V.Group(toe), off: V.Group({}) }, { cycle: !0, description: "Show handle tool" }) }, roe = function() {
  function e(t, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = t, this.props = { handle: { name: "off", params: {} } }, this.pixelRatio = 1, this._transform = Ee(), this.eachGroup = function(a, i) {
      if (!n.renderObject || !QD(a)) return !1;
      for (var o = !1, s = n.renderObject.values.uGroupCount.ref.value, u = 0, c = a.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, f = l.instanceId * s + d;
        i(Fe.ofSingleton(f)) && (o = !0);
      }
      return o;
    }, this.scene = Yp.create(t, y3), this.setProps(r);
  }
  return e.prototype.getBoundingSphere = function(t, r) {
    return this.renderObject && (Ve.copy(t, this.renderObject.values.invariantBoundingSphere.ref.value), Ee.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, 16 * r), Ve.transform(t, t, this._transform)), t;
  }, e.prototype.setProps = function(t) {
    var r = this;
    this.props = W8(this.props, function(n) {
      if (t.handle !== void 0 && (n.handle.name = t.handle.name, t.handle.name === "on")) {
        r.scene.clear(), r.pixelRatio = r.webgl.pixelRatio;
        var a = k(k({}, t.handle.params), { scale: t.handle.params.scale * r.webgl.pixelRatio });
        r.renderObject = function(i) {
          var o = function(s, u) {
            var c = 10 * s.scale, l = function(f, m) {
              var h = Nt.createState(512, 256, m), p = 0.05 * f, g = D.scale(D(), D.unitX, f), v = D.scale(D(), D.unitY, f), y = D.scale(D(), D.unitZ, f), _ = { radiusTop: p, radiusBottom: p, radialSegments: 32 };
              return h.currentGroup = _f.TranslateScreenXY, La(h, D.origin, 3 * p, 2), h.currentGroup = _f.TranslateObjectX, La(h, g, p, 2), Ba(h, D.origin, g, 1, _), h.currentGroup = _f.TranslateObjectY, La(h, v, p, 2), Ba(h, D.origin, v, 1, _), h.currentGroup = _f.TranslateObjectZ, La(h, y, p, 2), Ba(h, D.origin, y, 1, _), Nt.getMesh(h);
            }(c, void 0);
            l.setBoundingSphere(Ve.create(D.create(c / 2, c / 2, c / 2), c + c / 4));
            var d = function(f) {
              switch (f) {
                case _f.TranslateObjectX:
                  return s.colorX;
                case _f.TranslateObjectY:
                  return s.colorY;
                case _f.TranslateObjectZ:
                  return s.colorZ;
                default:
                  return $t.grey;
              }
            };
            return or.create("handle", {}, l, d, function() {
              return 1;
            }, function() {
              return "";
            });
          }(i);
          return or.createRenderObject(o, i);
        }(a), r.scene.add(r.renderObject), r.scene.commit(), n.handle.params = k({}, t.handle.params);
      }
    });
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this.props.handle.name === "on";
  }, enumerable: !1, configurable: !0 }), e.prototype.update = function(t, r, n) {
    this.renderObject && (this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), Ee.setTranslation(this.renderObject.values.aTransform.ref.value, r), Ee.fromMat3(this.renderObject.values.aTransform.ref.value, n), U.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0));
  }, e.prototype.getLoci = function(t) {
    var r = t.objectId, n = t.groupId, a = t.instanceId;
    return this.renderObject && r === this.renderObject.id ? function(i, o, s) {
      return z8("handle", i, [{ groupId: o, instanceId: s }], function(u) {
        return i.getBoundingSphere(u, s);
      }, function() {
        return "Handle Helper | Group Id ".concat(o, " | Instance Id ").concat(s);
      });
    }(this, n, a) : Tn;
  }, e.prototype.mark = function(t, r) {
    return !qr.is(qr.Highlighting, r) || !Vo(t) && (!QD(t) || t.data !== this) ? !1 : cr.mark(this.renderObject, t, r, this.eachGroup);
  }, e;
}(), _f = { None: 0, TranslateScreenXY: 1, TranslateObjectX: 3, TranslateObjectY: 4, TranslateObjectZ: 5 };
function QD(e) {
  return e.kind === "data-loci" && e.tag === "handle";
}
var Q6, noe = { debug: V.Group(G8), camera: V.Group({ helper: V.Group(S3) }), handle: V.Group(pL) }, aoe = V.getDefaultValues(noe), ioe = function(e, t, r) {
  r === void 0 && (r = {});
  var n = k(k({}, aoe), r);
  this.debug = new uie(e, t, n.debug), this.camera = new mL(e, n.camera.helper), this.handle = new roe(e, n.handle);
}, ooe = function() {
  function e(t, r) {
    r === void 0 && (r = {}), this.webgl = t;
    var n = t.gl;
    this.draw = new cL(t, n.drawingBufferWidth, n.drawingBufferHeight, r.enableWboit || !1), this.pick = new Bie(t, this.draw, r.pickScale || 0.25), this.multiSample = new yy(t, this.draw);
  }
  return e.prototype.updateSize = function() {
    var t = this.webgl.gl;
    this.draw.setSize(t.drawingBufferWidth, t.drawingBufferHeight), this.pick.syncSize(), this.multiSample.syncSize();
  }, e;
}(), Sy = { camera: V.Group({ mode: V.Select("orthographic", V.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }), helper: V.Group(S3, { isFlat: !0 }), stereo: V.MappedStatic("off", { on: V.Group(sL), off: V.Group({}) }, { cycle: !0, hideIf: function(e) {
  return (e == null ? void 0 : e.mode) !== "perspective";
} }), manualReset: V.Boolean(!1, { isHidden: !0 }) }, { pivot: "mode" }), cameraFog: V.MappedStatic("on", { on: V.Group({ intensity: V.Numeric(50, { min: 1, max: 100, step: 1 }) }), off: V.Group({}) }, { cycle: !0, description: "Show fog in the distance" }), cameraClipping: V.Group({ radius: V.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }), far: V.Boolean(!0, { description: "Hide scene in the distance" }) }, { pivot: "radius" }), viewport: V.MappedStatic("canvas", { canvas: V.Group({}), "static-frame": V.Group({ x: V.Numeric(0), y: V.Numeric(0), width: V.Numeric(128), height: V.Numeric(128) }), "relative-frame": V.Group({ x: V.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), y: V.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), width: V.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }), height: V.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }) }) }), cameraResetDurationMs: V.Numeric(250, { min: 0, max: 1e3, step: 1 }, { description: "The time it takes to reset the camera." }), transparentBackground: V.Boolean(!1), multiSample: V.Group(iL), postprocessing: V.Group(aL), marking: V.Group(uL), renderer: V.Group(i6), trackball: V.Group(sF), interaction: V.Group(nL), debug: V.Group(G8), handle: V.Group(pL) }, soe = V.getDefaultValues(Sy);
(function(e) {
  e.DefaultAttribs = { antialias: !0, preserveDrawingBuffer: !0, pixelScale: 1, pickScale: 0.25, pickPadding: 1, enableWboit: !0, preferWebGl1: !1 }, e.fromCanvas = function(t, r) {
    r === void 0 && (r = {});
    var n = k(k({}, e.DefaultAttribs), r), a = n.antialias, i = n.preserveDrawingBuffer, o = n.pixelScale, s = n.preferWebGl1, u = function(g, v) {
      function y(S) {
        try {
          return g.getContext(S, v);
        } catch {
          return null;
        }
      }
      var _ = (v != null && v.preferWebGl1 ? null : y("webgl2")) || y("webgl") || y("experimental-webgl");
      return zr && console.log("isWebgl2: ".concat(lr(_))), _;
    }(t, { antialias: a, preserveDrawingBuffer: i, alpha: !0, depth: !0, premultipliedAlpha: !0, preferWebGl1: s });
    if (u === null) throw new Error("Could not create a WebGL rendering context");
    var c = t6.fromElement(t, { pixelScale: o, preventGestures: !0 }), l = vJ(u, { pixelScale: o }), d = new ooe(l, r);
    if (zr) {
      var f = u.getExtension("WEBGL_lose_context");
      f && t.addEventListener("mousedown", function(g) {
        l.isContextLost || g.shiftKey && g.ctrlKey && g.altKey && (zr && console.log("lose context"), f.loseContext(), setTimeout(function() {
          l.isContextLost && (zr && console.log("restore context"), f.restoreContext());
        }, 1e3));
      }, !1);
    }
    var m = new xd(0), h = function(g) {
      l.setContextLost(), g && g.preventDefault(), zr && console.log("context lost"), m.next(ga());
    }, p = function() {
      l.isContextLost && (l.handleContextRestored(function() {
        d.draw.reset();
      }), zr && console.log("context restored"));
    };
    return t.addEventListener("webglcontextlost", h, !1), t.addEventListener("webglcontextrestored", p, !1), { canvas: t, webgl: l, input: c, passes: d, attribs: n, contextLost: m, contextRestored: l.contextRestored, dispose: function(g) {
      c.dispose(), t.removeEventListener("webglcontextlost", h, !1), t.removeEventListener("webglcontextrestored", p, !1), l.destroy(g);
    }, handleWebglContextLost: h, handlewWebglContextRestored: p };
  };
})(Q6 || (Q6 = {}));
var $6, uoe = typeof window < "u" ? window.requestAnimationFrame : function(e) {
  return setImmediate(function() {
    return e(Date.now());
  });
}, coe = typeof window < "u" ? window.cancelAnimationFrame : function(e) {
  return clearImmediate(e);
};
function $D(e, t, r) {
  r === void 0 && (r = 1);
  var n = window.innerWidth, a = window.innerHeight;
  t !== document.body && (n = t.offsetWidth, a = t.offsetHeight), function(i, o, s, u) {
    u === void 0 && (u = 1), i.width = Math.round(window.devicePixelRatio * u * o), i.height = Math.round(window.devicePixelRatio * u * s), Object.assign(i.style, { width: "".concat(o, "px"), height: "".concat(s, "px") });
  }(e, n, a, r);
}
function JD(e, t, r) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(n) {
      return [2, new Promise(function(a, i) {
        var o = function(s) {
          s ? a(s) : i("no blob returned");
        };
        HTMLCanvasElement.prototype.toBlob ? e.toBlob(o, t, r) : function(s, u, c, l) {
          for (var d = atob(s.toDataURL(c, l).split(",")[1]), f = d.length, m = f >> 2, h = new Uint8Array(f), p = new Uint32Array(h.buffer, 0, m), g = 0, v = 0; v < m; ++v) p[v] = d.charCodeAt(g++) | d.charCodeAt(g++) << 8 | d.charCodeAt(g++) << 16 | d.charCodeAt(g++) << 24;
          for (var y = 3 & f; y--; ) h[g] = d.charCodeAt(g++);
          u(new Blob([h], { type: c }));
        }(e, o, t, r);
      })];
    });
  });
}
function Hr(e, t) {
  return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t]);
}
function Z8(e, t) {
  return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t]);
}
function hL(e, t) {
  return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t]);
}
function Ay(e, t) {
  return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t]);
}
function loe(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t]);
}
function bh(e, t, r) {
  return function(n, a, i) {
    for (var o = 0, s = n.interUnitBonds.getEdgeIndices(i, a.id), u = 0, c = s.length; u < c; ++u) {
      var l = n.interUnitBonds.edges[s[u]];
      pr.isCovalent(l.props.flag) && (o += 1);
    }
    return o;
  }(e, t, r) + function(n, a) {
    for (var i = 0, o = n.bonds, s = o.offset, u = o.edgeProps.flags, c = s[a], l = s[a + 1]; c < l; ++c) pr.isCovalent(u[c]) && (i += 1);
    return i;
  }(t, r);
}
function eM(e, t, r, n) {
  var a = 0;
  return kd(e, t, r, function(i, o) {
    Hr(i, o) === n && (a += 1);
  }), a;
}
function doe(e, t, r, n, a) {
  return t === n ? function(i, o, s) {
    var u = i.bonds, c = u.offset, l = u.b, d = u.edgeProps.flags;
    pr.is;
    for (var f = c[o], m = c[o + 1]; f < m; ++f) if (l[f] === s && pr.isCovalent(d[f])) return !0;
    return !1;
  }(t, r, a) : function(i, o, s, u, c) {
    var l = i.interUnitBonds.getEdge(s, o.id, c, u.id);
    return l && pr.isCovalent(l.props.flag);
  }(e, t, r, n, a);
}
function nc(e, t, r) {
  for (var n = e.bonds, a = n.offset, i = n.b, o = n.edgeProps.flags, s = a[t], u = a[t + 1]; s < u; ++s) pr.isCovalent(o[s]) && r(e, i[s]);
}
function kd(e, t, r, n) {
  (function(a, i, o, s) {
    for (var u = a.interUnitBonds.getEdgeIndices(o, i.id), c = 0, l = u.length; c < l; ++c) {
      var d = a.interUnitBonds.edges[u[c]], f = a.unitMap.get(d.unitB);
      pr.isCovalent(d.props.flag) && s(f, d.indexB);
    }
  })(e, t, r, n), nc(t, r, n);
}
function Ag(e) {
  switch (e) {
    case 0:
      return 0;
    case 1:
      return 1;
    case 2:
      return 2;
    case 3:
      return 3;
    case 4:
      return 4;
    default:
      return 8;
  }
}
(function(e) {
  e.create = function(t, r) {
    var n = t.webgl, a = t.input, i = t.passes, o = t.attribs;
    r === void 0 && (r = {});
    var s = k(k({}, soe), r), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = new xd(0), d = ga(), f = new xd(0), m = new xd(0), h = n.gl, p = n.contextRestored, g = 0, v = 0, y = 128, _ = 128;
    Ne();
    var S = Yp.create(n, i.draw.wboitEnabled ? mne : y3), b = new oa({ position: D.create(0, 0, 100), mode: s.camera.mode, fog: s.cameraFog.name === "on" ? s.cameraFog.params.intensity : 0, clipFar: s.cameraClipping.far }, { x: g, y: v, width: y, height: _ }, { pixelScale: o.pixelScale }), x = new Wp(b, s.camera.stereo.params), A = o6.create(a, b, s.trackball), w = a6.create(n, s.renderer), C = new ioe(n, S, s), M = new Oie(n, w, S, C, i.pick, { x: g, y: v, width: y, height: _ }, o.pickPadding), T = new mie(se, G, a, b, s.interaction), N = new oL(i.multiSample), I = !1, P = void 0, O = void 0, F = !1, R = !0;
    function G(Z) {
      var de = Tn, ye = fr.Empty;
      if (Z) {
        var Ae = C.camera.getLoci(Z);
        if (Ae !== Tn) return { loci: Ae, repr: ye };
        de = C.handle.getLoci(Z), u.forEach(function(Ce, Ie) {
          var Ue = Ie.getLoci(Z);
          Ld(Ue) || (Ld(de) || console.warn("found another loci, this should not happen"), de = Ue, ye = Ie);
        });
      }
      return { loci: de, repr: ye };
    }
    var L = [];
    function q(Z, de) {
      var ye = Z.repr, Ae = Z.loci, Ce = !1;
      return ye ? Ce = ye.mark(Ae, de) : (Ce = C.handle.mark(Ae, de), Ce = C.camera.mark(Ae, de) || Ce, u.forEach(function(Ie, Ue) {
        Ce = Ue.mark(Ae, de) || Ce;
      })), Ce;
    }
    function K(Z) {
      if (n.isContextLost) return !1;
      var de = !1;
      if (F && (Se(!1), F = !1, de = !0), g > h.drawingBufferWidth || g + y < 0 || v > h.drawingBufferHeight || v + _ < 0) return !1;
      var ye = function() {
        for (var xt = !1, dt = 0, Le = L; dt < Le.length; dt++) {
          var j = Le[dt];
          xt = q(j[0], j[1]) || xt;
        }
        return L = [], xt && (S.update(void 0, !0), C.handle.scene.update(void 0, !0), C.camera.scene.update(void 0, !0)), xt;
      }(), Ae = !1;
      A.update(W);
      var Ce = b.update(), Ie = Z || Ce || de || X;
      X = !1;
      var Ue = N.update(ye || Ie, s.multiSample);
      if (Ie || Ue || ye) {
        var Xe = b;
        s.camera.stereo.name === "on" && (x.update(), Xe = x);
        var je = { renderer: w, camera: Xe, scene: S, helper: C };
        if (yy.isEnabled(s.multiSample)) {
          var ht = !Ce && ye && !A.isAnimating;
          N.render(je, s, !0, ht);
        } else i.draw.render(je, s, !0);
        M.dirty = M.dirty || Ie, Ae = !0;
      }
      return Ae;
    }
    var X = !1, H = !1, W = 0, ee = !1;
    function $(Z) {
      ee || K(!!(Z != null && Z.force)) && R && f.next(ga() - d);
    }
    function te() {
      X = !0;
    }
    var re = 0;
    function ie(Z, de) {
      W = Z, he(de == null ? void 0 : de.isSynchronous), b.transition.tick(W), de != null && de.manualDraw || ($(), b.transition.inTransition || n.isContextLost || T.tick(W));
    }
    function oe() {
      ie(ga()), re = uoe(oe);
    }
    function se(Z, de) {
      var ye = s.camera.stereo.name === "on" ? x : b;
      return n.isContextLost ? void 0 : M.identify(Z, de, ye);
    }
    function he(Z) {
      Z === void 0 && (Z = !1);
      var de = function(ye) {
        return S.needsCommit ? (Ve.copy(ge, S.boundingSphereVisible), S.commit(ye ? void 0 : ae) ? (C.debug.isEnabled && C.debug.update(), s.camera.manualReset || l.value !== 0 && !function() {
          if (b.state.radiusMax === 0) return !0;
          if (b.transition.inTransition || O) return !1;
          var Ae = !0, Ce = !0;
          Ve.set(De, b.state.target, b.state.radius);
          for (var Ie = 0, Ue = S.renderables; Ie < Ue.length; Ie++) {
            var Xe = Ue[Ie];
            if (Xe.state.visible) {
              var je = Xe.values.boundingSphere.ref.value;
              if (je.radius) {
                Ce = !1;
                var ht = D.distance(De.center, je.center);
                if ((ht > De.radius || ht > je.radius || je.radius > b.state.radiusMax) && !Ve.includes(ge, je)) return !0;
                Ve.overlaps(De, je) && (Ae = !1);
              }
            }
          }
          return Ae || !Ce && De.radius <= 0.1;
        }() || (I = !0), ge.radius === 0 && (P = 0), b.setState({ radiusMax: S.boundingSphere.radius }, 0), l.next(u.size), zr && ce(), !0) : !1) : !0;
      }(Z);
      de && (A.isLockCamera ? (P = void 0, O = void 0, I = !1) : function() {
        if (!(!I || A.isLockCamera)) {
          var ye = S.boundingSphereVisible, Ae = ye.center, Ce = ye.radius, Ie = A.props.autoAdjustMinMaxDistance;
          if (Ie.name === "on") {
            var Ue = Ie.params.minDistanceFactor * Ce + Ie.params.minDistancePadding, Xe = Math.max(Ie.params.maxDistanceFactor * Ce, Ie.params.maxDistanceMin);
            A.setProps({ minDistance: Ue, maxDistance: Xe });
          }
          if (Ce > 0) {
            var je = P === void 0 ? s.cameraResetDurationMs : P, ht = b.getFocus(Ae, Ce), xt = typeof O == "function" ? O(S, b) : O, dt = xt ? k(k({}, ht), xt) : ht;
            b.setState(k(k({}, dt), { radiusMax: S.boundingSphere.radius }), je);
          }
          P = void 0, O = void 0, I = !1;
        }
      }(), H && (C.debug.isEnabled && C.debug.update(), $({ force: !0 }), H = !1), m.next(ga()));
    }
    var ge = Ve(), De = Ve(), ae = 250;
    function ce() {
      console.table(S.renderables.map(function(Ce) {
        return { drawCount: Ce.values.drawCount.ref.value, instanceCount: Ce.values.instanceCount.ref.value, materialId: Ce.materialId, renderItemId: Ce.id };
      })), console.log(n.stats);
      var Z = n.resources.getByteCounts(), de = Z.texture, ye = Z.attribute, Ae = Z.elements;
      console.log({ texture: "".concat((de / 1024 / 1024).toFixed(3), " MiB"), attribute: "".concat((ye / 1024 / 1024).toFixed(3), " MiB"), elements: "".concat((Ae / 1024 / 1024).toFixed(3), " MiB") });
    }
    function _e(Z) {
      (function(Ae) {
        c.has(Ae) || c.set(Ae, Ae.updated.subscribe(function(Ce) {
          Ae.state.syncManually || _e(Ae);
        }));
      })(Z);
      var de = u.get(Z), ye = /* @__PURE__ */ new Set();
      Z.renderObjects.forEach(function(Ae) {
        return ye.add(Ae);
      }), de ? bo.areEqual(ye, de) || (ye.forEach(function(Ae) {
        de.has(Ae) || S.add(Ae);
      }), de.forEach(function(Ae) {
        ye.has(Ae) || S.remove(Ae);
      })) : Z.renderObjects.forEach(function(Ae) {
        return S.add(Ae);
      }), u.set(Z, ye), S.update(Z.renderObjects, !1), H = !0, zr && ce();
    }
    function le() {
      var Z = S.boundingSphere.radius > 0 ? 100 - Math.round(b.transition.target.radius / S.boundingSphere.radius * 100) : 0;
      return { camera: { mode: b.state.mode, helper: k({}, C.camera.props), stereo: k({}, s.camera.stereo), manualReset: !!s.camera.manualReset }, cameraFog: b.state.fog > 0 ? { name: "on", params: { intensity: b.state.fog } } : { name: "off", params: {} }, cameraClipping: { far: b.state.clipFar, radius: Z }, cameraResetDurationMs: s.cameraResetDurationMs, transparentBackground: s.transparentBackground, viewport: s.viewport, postprocessing: k({}, s.postprocessing), marking: k({}, s.marking), multiSample: k({}, s.multiSample), renderer: k({}, w.props), trackball: k({}, A.props), interaction: k({}, T.props), debug: k({}, C.debug.props), handle: k({}, C.handle.props) };
    }
    var ue = p.subscribe(function() {
      M.dirty = !0, $({ force: !0 }), $({ force: !0 });
    }), be = new xd(0);
    function Se(Z) {
      Z === void 0 && (Z = !0), i.updateSize(), Ne(), J(), Z && te(), be.next(+/* @__PURE__ */ new Date());
    }
    return { webgl: n, scene: S, helper: C, add: _e, remove: function(Z) {
      (function(ye) {
        var Ae = c.get(ye);
        Ae && (Ae.unsubscribe(), c.delete(ye));
      })(Z);
      var de = u.get(Z);
      de && (de.forEach(function(ye) {
        return S.remove(ye);
      }), u.delete(Z), H = !0, zr && ce());
    }, commit: he, controls: A, update: function(Z, de) {
      if (Z) {
        if (!u.has(Z)) return;
        S.update(Z.renderObjects, !!de);
      } else S.update(void 0, !!de);
      H = !0;
    }, clear: function() {
      c.forEach(function(Z) {
        return Z.unsubscribe();
      }), c.clear(), u.clear(), S.clear(), C.debug.clear(), te(), l.next(u.size);
    }, syncVisibility: function() {
      b.state.radiusMax === 0 && (I = !0, P = 0), S.syncVisibility() && C.debug.isEnabled && C.debug.update(), te();
    }, requestDraw: te, tick: ie, animate: function() {
      ee = !1, A.start(ga()), re === 0 && oe();
    }, resetTime: function(Z) {
      d = Z, A.start(Z);
    }, pause: function(Z) {
      Z === void 0 && (Z = !1), ee = Z, coe(re), re = 0;
    }, resume: function() {
      ee = !1;
    }, identify: se, getPosition: function(Z, de) {
      var ye = b;
      return n.isContextLost ? void 0 : M.getPosition(Z, de, ye);
    }, mark: function(Z, de) {
      L.push([Z, de]);
    }, getLoci: G, handleResize: Se, requestResize: function() {
      F = !0;
    }, requestCameraReset: function(Z) {
      P = Z == null ? void 0 : Z.durationMs, O = Z == null ? void 0 : Z.snapshot, I = !0;
    }, camera: b, boundingSphere: S.boundingSphere, boundingSphereVisible: S.boundingSphereVisible, get notifyDidDraw() {
      return R;
    }, set notifyDidDraw(Z) {
      R = Z;
    }, didDraw: f, commited: m, reprCount: l, resized: be, setProps: function(Z, de) {
      var ye, Ae, Ce;
      de === void 0 && (de = !1);
      var Ie = typeof Z == "function" ? W8(le(), Z) : Z, Ue = /* @__PURE__ */ Object.create(null);
      if (Ie.camera && Ie.camera.mode !== void 0 && Ie.camera.mode !== b.state.mode && (Ue.mode = Ie.camera.mode), Ie.cameraFog !== void 0 && Ie.cameraFog.params) {
        var Xe = Ie.cameraFog.name === "on" ? Ie.cameraFog.params.intensity : 0;
        Xe !== b.state.fog && (Ue.fog = Xe);
      }
      if (Ie.cameraClipping !== void 0 && (Ie.cameraClipping.far !== void 0 && Ie.cameraClipping.far !== b.state.clipFar && (Ue.clipFar = Ie.cameraClipping.far), Ie.cameraClipping.radius !== void 0)) {
        var je = S.boundingSphere.radius / 100 * (100 - Ie.cameraClipping.radius);
        je > 0 && je !== Ue.radius && (Ue.radius = Math.max(je, 0.01));
      }
      Object.keys(Ue).length > 0 && b.setState(Ue), !((ye = Ie.camera) === null || ye === void 0) && ye.helper && C.camera.setProps(Ie.camera.helper), ((Ae = Ie.camera) === null || Ae === void 0 ? void 0 : Ae.manualReset) !== void 0 && (s.camera.manualReset = Ie.camera.manualReset), ((Ce = Ie.camera) === null || Ce === void 0 ? void 0 : Ce.stereo) !== void 0 && Object.assign(s.camera.stereo, Ie.camera.stereo), Ie.cameraResetDurationMs !== void 0 && (s.cameraResetDurationMs = Ie.cameraResetDurationMs), Ie.transparentBackground !== void 0 && (s.transparentBackground = Ie.transparentBackground), Ie.viewport !== void 0 && (s.viewport === Ie.viewport || s.viewport.name === Ie.viewport.name && e6(s.viewport.params, Ie.viewport.params) || (s.viewport = Ie.viewport, Ne(), J())), Ie.postprocessing && Object.assign(s.postprocessing, Ie.postprocessing), Ie.marking && Object.assign(s.marking, Ie.marking), Ie.multiSample && Object.assign(s.multiSample, Ie.multiSample), Ie.renderer && w.setProps(Ie.renderer), Ie.trackball && A.setProps(Ie.trackball), Ie.interaction && T.setProps(Ie.interaction), Ie.debug && C.debug.setProps(Ie.debug), Ie.handle && C.handle.setProps(Ie.handle), Ue.mode === "orthographic" && (s.camera.stereo.name = "off"), de || te();
    }, getImagePass: function(Z) {
      return Z === void 0 && (Z = {}), new eoe(n, w, S, b, C, i.draw.wboitEnabled, Z);
    }, getRenderObjects: function() {
      var Z = [];
      return S.forEach(function(de, ye) {
        return Z.push(ye);
      }), Z;
    }, get props() {
      return le();
    }, get input() {
      return a;
    }, get stats() {
      return w.stats;
    }, get interaction() {
      return T.events;
    }, dispose: function() {
      ue.unsubscribe(), L = [], S.clear(), C.debug.clear(), A.dispose(), w.dispose(), T.dispose();
    } };
    function Ne() {
      var Z = g, de = v, ye = y, Ae = _;
      s.viewport.name === "canvas" ? (g = 0, v = 0, y = h.drawingBufferWidth, _ = h.drawingBufferHeight) : s.viewport.name === "static-frame" ? (g = s.viewport.params.x * n.pixelRatio, _ = s.viewport.params.height * n.pixelRatio, v = h.drawingBufferHeight - _ - s.viewport.params.y * n.pixelRatio, y = s.viewport.params.width * n.pixelRatio) : s.viewport.name === "relative-frame" && (g = Math.round(s.viewport.params.x * h.drawingBufferWidth), _ = Math.round(s.viewport.params.height * h.drawingBufferHeight), v = Math.round(h.drawingBufferHeight - _ - s.viewport.params.y * h.drawingBufferHeight), y = Math.round(s.viewport.params.width * h.drawingBufferWidth)), Z === g && de === v && ye === y && Ae === _ || (X = !0);
    }
    function J() {
      M.setViewport(g, v, y, _), w.setViewport(g, v, y, _), Za.set(b.viewport, g, v, y, _), Za.set(A.viewport, g, v, y, _);
    }
  };
})($6 || ($6 = {}));
var tM = D(), rM = D(), Px = D(), nM = D(), aM = D();
function J6(e, t, r, n, a) {
  var i = [];
  return t.conformation.position(t.elements[r], Px), n.conformation.position(n.elements[a], nM), D.sub(tM, nM, Px), kd(e, t, r, function(o, s) {
    Hr(o, s) !== "H" && (o.conformation.position(o.elements[s], aM), D.sub(rM, aM, Px), i.push(D.angle(tM, rM)));
  }), i;
}
var foe = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR"]), moe = /* @__PURE__ */ new Set(["BE", "MG", "CA", "SR", "BA", "RA"]), poe = /* @__PURE__ */ new Set(["ZN", "GA", "CD", "IN", "SN", "HG", "TI", "PB", "BI", "PO", "CN"]), hoe = /* @__PURE__ */ new Set(["F", "CL", "BR", "I", "AT"]);
function voe(e) {
  return hoe.has(e);
}
function vL(e) {
  var t = lh(e);
  return t >= 21 && t <= 29 || t >= 39 && t <= 47 || t >= 72 && t <= 79 || t >= 104 && t <= 108;
}
function goe(e) {
  return function(t) {
    return foe.has(t);
  }(e) || function(t) {
    return moe.has(t);
  }(e) || function(t) {
    var r = lh(t);
    return r >= 57 && r <= 71;
  }(e) || function(t) {
    var r = lh(t);
    return r >= 89 && r <= 103;
  }(e) || vL(e) || function(t) {
    return poe.has(t);
  }(e);
}
var Bx = new Pt.ElementBondIterator(), Ox = new Pt.ElementBondIterator(), $m = new Pt.ElementBondIterator(), Fx = new Pt.ElementBondIterator();
function yoe(e, t, r, n) {
  var a = eM(e, t, r, "H"), i = Hr(t, r), o = Z8(t, r), s = n.assignCharge === "always" || n.assignCharge === "auto" && o === 0, u = !["sdf", "mol"].includes(t.model.sourceData.kind) && (n.assignH === "always" || n.assignH === "auto" && a === 0), c = bh(e, t, r), l = function(_, S, b) {
    for (var x = 0, A = S.bonds, w = A.offset, C = A.edgeProps, M = C.flags, T = C.order, N = w[b], I = w[b + 1]; N < I; ++N) pr.isCovalent(M[N]) && (x += T[N]);
    return _.interUnitBonds.getEdgeIndices(b, S.id).forEach(function(P) {
      var O = _.interUnitBonds.edges[P];
      pr.isCovalent(O.props.flag) && (x += O.props.order);
    }), x;
  }(e, t, r), d = function(_, S, b) {
    var x = Hr(S, b), A = x === "O" || x === "N";
    if (A && bh(_, S, b) === 4) return !1;
    for (Bx.setElement(_, S, b); Bx.hasNext; ) {
      var w = Bx.move();
      if (w.order > 1) return !0;
      if (A) {
        var C = Hr(w.otherUnit, w.otherIndex);
        for (Ox.setElement(_, w.otherUnit, w.otherIndex); Ox.hasNext; ) {
          var M = Ox.move();
          if (M.order > 1) {
            if ((C === "P" || C === "S") && Hr(M.otherUnit, M.otherIndex) === "O") continue;
            return !0;
          }
        }
      }
    }
    return !1;
  }(e, t, r), f = l - c > 0, m = 0, h = 8;
  switch (i) {
    case "H":
      s && (c === 0 ? (o = 1, h = 0) : c === 1 && (o = 0, h = 1));
      break;
    case "C":
      s && (o = 0), u && (m = Math.max(0, 4 - l - Math.abs(o))), h = Ag(c + m + Math.max(0, -o));
      break;
    case "N":
      if (s) if (u) if (d && l < 4) o = c - a == 1 && l - a == 2 ? 1 : 0;
      else for ($m.setElement(e, t, r); $m.hasNext; ) {
        var p = $m.move(), g = Hr(p.otherUnit, p.otherIndex);
        if (g === "S" || goe(g) || pr.is(p.type, 32)) {
          o = 0;
          break;
        }
        o = 1;
      }
      else o = l - 3;
      u && (m = Math.max(0, 3 - l + o)), h = Ag(d && !f ? c + m - o : c + m + 1 - o);
      break;
    case "O":
      if (s && (u || (o = l - 2), l === 1)) {
        $m.setElement(e, t, r);
        e: for (; $m.hasNext; ) {
          var v = $m.move();
          for (Fx.setElement(e, v.otherUnit, v.otherIndex); Fx.hasNext; ) {
            var y = Fx.move();
            if ((y.otherUnit !== t || y.otherIndex !== r) && Hr(y.otherUnit, y.otherIndex) === "O" && y.order === 2) {
              o = -1;
              break e;
            }
          }
        }
      }
      u && (m = Math.max(0, 2 - l + o)), h = Ag(d && !f ? c + m - o + 1 : c + m - o + 2);
      break;
    case "S":
      s && (u || (o = l <= 3 && eM(e, t, r, "O") === 0 ? l - 2 : 0)), u && l < 2 && (m = Math.max(0, 2 - l + o)), l <= 3 && (h = Ag(c + m - o + 2));
      break;
    case "F":
    case "CL":
    case "BR":
    case "I":
    case "AT":
      s && (o = l - 1);
      break;
    case "LI":
    case "NA":
    case "K":
    case "RB":
    case "CS":
    case "FR":
      s && (o = 1 - l);
      break;
    case "BE":
    case "MG":
    case "CA":
    case "SR":
    case "BA":
    case "RA":
      s && (o = 2 - l);
      break;
    default:
      zr && console.warn("Requested charge, protonation for an unhandled element", i);
  }
  return [o, m, m + a, h];
}
function boe(e, t, r) {
  for (var n = t.elements.length, a = new Int8Array(n), i = new Int8Array(n), o = new Int8Array(n), s = new Int8Array(n), u = 0; u < n; ++u) {
    var c = yoe(e, t, u, r), l = c[0], d = c[1], f = c[2], m = c[3];
    a[u] = l, i[u] = d, o[u] = f, s[u] = m;
  }
  return { charge: a, implicitH: i, totalH: o, idealGeometry: s };
}
var gL = { assignCharge: V.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]), assignH: V.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]) };
function xoe(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u;
    return Te(this, function(c) {
      for (n = k(k({}, V.getDefaultValues(gL)), r), a = /* @__PURE__ */ new Map(), i = 0, o = t.units.length; i < o; ++i) s = t.units[i], Ke.isAtomic(s) && (u = boe(t, s, n), a.set(s.id, u));
      return [2, a];
    });
  });
}
var nn, e_, t_, Rx = k({}, gL), Uh = Up.createProvider({ label: "Valence Model", descriptor: Tu({ name: "molstar_computed_valence_model" }), type: "local", defaultParams: Rx, getParams: function(e) {
  return Rx;
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, r) {
  return Be(void 0, 0, void 0, function() {
    var n, a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return n = k(k({}, V.getDefaultValues(Rx)), r), a = {}, [4, xoe(e.runtime, t, n)];
        case 1:
          return [2, (a.value = i.sent(), a)];
      }
    });
  });
} });
(function(e) {
  function t(i, o) {
    for (var s = new Int32Array(o + 1), u = new Int32Array(o), c = new Int32Array(o), l = i.members, d = i.count, f = i.offsets, m = 0, h = f[d]; m < h; ++m) ++c[l[m]];
    var p = 0;
    for (m = 0; m < o; m++) s[m] = p, p += c[m];
    s[o] = p;
    var g = new Int32Array(p);
    for (m = 0; m < d; ++m) for (var v = f[m], y = f[m + 1]; v < y; ++v) {
      var _ = l[v];
      g[s[_] + u[_]] = m, ++u[_];
    }
    return { indices: g, offsets: s };
  }
  function r(i, o) {
    for (var s, u = i.count, c = i.types, l = [], d = 0; d < u; ++d) o.has(c[d]) && l.push(d);
    var f = $e.ofSortedArray(l);
    return { indices: f, get lookup3d() {
      if (!s) {
        var m = { x: i.x, y: i.y, z: i.z, indices: f };
        s = Jf(m, kp(m));
      }
      return s;
    } };
  }
  e.setPosition = function(i, o, s, u) {
    return D.set(i, u.x[s], u.y[s], u.z[s]), D.transformMat4(i, i, o.conformation.operator.matrix), i;
  }, e.createElementsIndex = t, e.create = function(i, o) {
    var s, u;
    return k(k({}, o), { get lookup3d() {
      if (!s) {
        var c = { x: o.x, y: o.y, z: o.z, indices: We.ofBounds(0, o.count) };
        s = Jf(c, kp(c));
      }
      return s;
    }, get elementsIndex() {
      return u || (u = t(o, i));
    }, subset: function(c) {
      return r(o, c);
    } });
  }, e.createSubset = r, e.Info = function(i, o, s) {
    var u = Uh.get(i).value;
    if (!u || !u.has(o.id)) throw new Error("valence model required");
    return { unit: o, types: s.types, feature: -1, x: s.x, y: s.y, z: s.z, members: s.members, offsets: s.offsets, idealGeometry: u.get(o.id).idealGeometry };
  }, e.position = function(i, o) {
    return D.set(i, o.x[o.feature], o.y[o.feature], o.z[o.feature]), D.transformMat4(i, i, o.unit.conformation.operator.matrix), i;
  };
  var n = D(), a = D();
  e.distance = function(i, o) {
    var s = i.members[i.offsets[i.feature]], u = o.members[o.offsets[o.feature]];
    return i.unit.conformation.position(i.unit.elements[s], n), o.unit.conformation.position(o.unit.elements[u], a), D.distance(n, a);
  }, e.Provider = function(i, o) {
    return { types: new Set(i), add: o };
  };
})(nn || (nn = {})), function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var a = Ye.create(Float32Array, 1, r, n ? n.x : t), i = Ye.create(Float32Array, 1, r, n ? n.y : t), o = Ye.create(Float32Array, 1, r, n ? n.z : t), s = Ye.create(Uint8Array, 1, r, n ? n.types : t), u = Ye.create(Uint8Array, 1, r, n ? n.groups : t), c = Ye.create(Uint32Array, 1, r, n ? n.offsets : t), l = Ye.create(Uint32Array, 1, r, n ? n.members : t), d = { x: 0, y: 0, z: 0, offset: 0, count: 0 };
    return { startState: function() {
      d.x = 0, d.y = 0, d.z = 0, d.offset = l.elementCount, d.count = 0;
    }, pushMember: function(f, m, h, p) {
      Ye.add(l, p), d.x += f, d.y += m, d.z += h, d.count += 1;
    }, finishState: function(f, m) {
      var h = d.count;
      h !== 0 && (Ye.add(s, f), Ye.add(u, m), Ye.add(a, d.x / h), Ye.add(i, d.y / h), Ye.add(o, d.z / h), Ye.add(c, d.offset));
    }, add: function(f, m, h, p, g, v) {
      Ye.add(s, f), Ye.add(u, m), Ye.add(a, h), Ye.add(i, p), Ye.add(o, g), Ye.add(c, l.elementCount), Ye.add(l, v);
    }, getFeatures: function(f) {
      Ye.add(c, l.elementCount);
      var m = Ye.compact(a, !0), h = Ye.compact(i, !0), p = Ye.compact(o, !0), g = a.elementCount;
      return nn.create(f, { x: m, y: h, z: p, count: g, types: Ye.compact(s, !0), groups: Ye.compact(u, !0), offsets: Ye.compact(c, !0), members: Ye.compact(l, !0) });
    } };
  };
}(e_ || (e_ = {})), function(e) {
  e.createElementsIndex = function(t, r, n) {
    for (var a = new Int32Array(n + 1), i = new Int32Array(n), o = new Int32Array(n), s = r.members, u = r.offsets, c = 0, l = 2 * t.edgeCount; c < l; ++c)
      if (!((p = t.a[c]) > (g = t.b[c]))) {
        for (var d = u[p], f = u[p + 1]; d < f; ++d) ++o[s[d]];
        for (d = u[g], f = u[g + 1]; d < f; ++d) ++o[s[d]];
      }
    var m = 0;
    for (c = 0; c < n; c++) a[c] = m, m += o[c];
    a[n] = m;
    var h = new Int32Array(m);
    for (c = 0, l = 2 * t.edgeCount; c < l; ++c) {
      var p, g;
      if (!((p = t.a[c]) > (g = t.b[c]))) {
        for (d = u[p], f = u[p + 1]; d < f; ++d)
          h[a[v = s[d]] + i[v]] = c, ++i[v];
        for (d = u[g], f = u[g + 1]; d < f; ++d) {
          var v;
          h[a[v = s[d]] + i[v]] = c, ++i[v];
        }
      }
    }
    return { indices: h, offsets: a };
  };
}(t_ || (t_ = {}));
var _o, Cr, _oe = function(e) {
  function t(r, n) {
    var a = e.call(this, r) || this;
    a.elementKeyIndex = /* @__PURE__ */ new Map();
    for (var i = 0, o = a.edges.length; i < o; ++i) for (var s = a.edges[i], u = s.unitA, c = s.indexA, l = n.get(u), d = l.offsets, f = l.members, m = d[c], h = d[c + 1]; m < h; ++m) {
      var p = a.getElementKey(f[m], u), g = a.elementKeyIndex.get(p);
      g === void 0 ? a.elementKeyIndex.set(p, [i]) : g.push(i);
    }
    return a;
  }
  return Ii(t, e), t.prototype.getContactIndicesForElement = function(r, n) {
    return this.elementKeyIndex.get(this.getElementKey(r, n.id)) || [];
  }, t.prototype.getElementKey = function(r, n) {
    return "".concat(r, "|").concat(n);
  }, t;
}(em);
function r_(e) {
  switch (e) {
    case Cr.HydrogenBond:
      return "Hydrogen Bond";
    case Cr.Hydrophobic:
      return "Hydrophobic Contact";
    case Cr.HalogenBond:
      return "Halogen Bond";
    case Cr.Ionic:
      return "Salt Bridge";
    case Cr.MetalCoordination:
      return "Metal Bond";
    case Cr.CationPi:
      return "Cation-Pi Interaction";
    case Cr.PiStacking:
      return "Pi Stacking";
    case Cr.WeakHydrogenBond:
      return "Weak Hydrogen Bond";
    case Cr.Unknown:
      return "Unknown Interaction";
  }
}
(function(e) {
  e[e.None = 0] = "None", e[e.Filtered = 1] = "Filtered";
})(_o || (_o = {})), function(e) {
  e[e.Unknown = 0] = "Unknown", e[e.Ionic = 1] = "Ionic", e[e.CationPi = 2] = "CationPi", e[e.PiStacking = 3] = "PiStacking", e[e.HydrogenBond = 4] = "HydrogenBond", e[e.HalogenBond = 5] = "HalogenBond", e[e.Hydrophobic = 6] = "Hydrophobic", e[e.MetalCoordination = 7] = "MetalCoordination", e[e.WeakHydrogenBond = 8] = "WeakHydrogenBond";
}(Cr || (Cr = {}));
var yL = { distanceMax: V.Numeric(2.8, { min: 1, max: 5, step: 0.1 }), backbone: V.Boolean(!0, { description: "Include backbone-to-backbone hydrogen bonds" }), accAngleDevMax: V.Numeric(90, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }), donAngleDevMax: V.Numeric(120, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }), accOutOfPlaneAngleMax: V.Numeric(90, { min: 0, max: 180, step: 1 }), donOutOfPlaneAngleMax: V.Numeric(45, { min: 0, max: 180, step: 1 }) }, bL = k(k({}, yL), { water: V.Boolean(!1, { description: "Include water-to-water hydrogen bonds" }), sulfurDistanceMax: V.Numeric(3.4, { min: 1, max: 5, step: 0.1 }) }), Soe = V.getDefaultValues(bL), xL = k({}, yL), Aoe = V.getDefaultValues(xL);
function iM(e, t) {
  return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[t]]] === 2;
}
function oM(e, t) {
  return _8.has(hL(e, t));
}
function _L(e) {
  return { includeBackbone: e.backbone, maxAccAngleDev: Kn(e.accAngleDevMax), maxDonAngleDev: Kn(e.donAngleDevMax), maxAccOutOfPlaneAngle: Kn(e.accOutOfPlaneAngleMax), maxDonOutOfPlaneAngle: Kn(e.donOutOfPlaneAngleMax) };
}
function SL(e, t, r, n) {
  var a = t.members[t.offsets[t.feature]], i = r.members[r.offsets[r.feature]];
  if (n.includeBackbone || (o = t.unit, s = a, u = r.unit, c = i, !oM(o, s) || !oM(u, c))) {
    var o, s, u, c, l = J6(e, t.unit, a, r.unit, i);
    if (Bi(l[0]) >= 120 && Bi(l[0]) <= 180) return !0;
  }
}
function woe(e, t, r, n, a) {
  var i = t.types[t.feature], o = r.types[r.feature];
  if (u = o, (s = i) === 5 && u === 4 || s === 4 && u === 5) {
    var s, u, c, l, d, f, m = o === 5 ? [t, r] : [r, t], h = m[0], p = m[1], g = h.members[h.offsets[h.feature]], v = p.members[p.offsets[p.feature]];
    if (!(n > (Hr(h.unit, g) === "S" || Hr(p.unit, v) === "S" ? a.maxSulfurDistSq : a.maxDistSq)) && (a.includeWater || (c = h.unit, l = g, d = p.unit, f = v, !iM(c, l) || !iM(d, f))) && SL(e, h, p, a)) return Cr.HydrogenBond;
  }
}
var Coe = nn.Provider([4], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = function(d, f) {
    var m = Hr(t, d), h = !1;
    m === "H" && (nc(t, d, function(p, g) {
      var v = Hr(p, g);
      v !== "N" && v !== "O" && v !== "S" || (h = !0);
    }), h && r.add(4, 0, i[n[d]], o[n[d]], s[n[d]], d));
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), Eoe = nn.Provider([9], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = function(d, f) {
    var m = Hr(t, d), h = !1;
    if (m === "H") {
      var p = [];
      if (nc(t, d, function(v, y) {
        Hr(v, y) === "C" && (function(_, S) {
          var b = _.rings.elementAromaticRingIndices, x = b.get(S);
          return x !== void 0;
        }(v, y) ? h = !0 : p.push(y));
      }), !h && p.length === 1) {
        var g = 0;
        nc(t, p[0], function(v, y) {
          Hr(v, y) === "F" && g++;
        }), g === 2 && (h = !0);
      }
      h && r.add(9, 0, i[n[d]], o[n[d]], s[n[d]], d);
    }
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), Doe = nn.Provider([5], function(e, t, r) {
  for (var n = function(y, _) {
    var S = Uh.get(y).value;
    if (!S) throw Error("expected valence model to be available");
    var b = S.get(_.id);
    if (!b) throw Error("expected valence model for unit to be available");
    return b;
  }(e, t), a = n.charge, i = n.implicitH, o = n.idealGeometry, s = t.elements, u = t.model.atomicConformation, c = u.x, l = u.y, d = u.z, f = function(y) {
    r.add(5, 0, c[s[y]], l[s[y]], d[s[y]], y);
  }, m = 0, h = s.length; m < h; ++m) {
    var p = Hr(t, m);
    if (p === "O") f(m);
    else if (p === "N") {
      if (a[m] < 1) {
        var g = bh(e, t, m) + i[m], v = o[m];
        (v === 4 && g < 4 || v === 3 && g < 3 || v === 2 && g < 2) && f(m);
      }
    } else p === "S" ? Z8(t, m) === -1 && f(m) : p === "F" && f(m);
  }
}), Moe = { name: "hydrogen-bonds", params: bL, createTester: function(e) {
  var t = Math.max(e.distanceMax, e.sulfurDistanceMax), r = function(n) {
    return k(k({}, _L(n)), { includeWater: n.water, maxSulfurDistSq: n.sulfurDistanceMax * n.sulfurDistanceMax, maxDistSq: n.distanceMax * n.distanceMax });
  }(e);
  return { maxDistance: t, requiredFeatures: /* @__PURE__ */ new Set([4, 5]), getType: function(n, a, i, o) {
    return woe(n, a, i, o, r);
  } };
} }, Ioe = { name: "weak-hydrogen-bonds", params: xL, createTester: function(e) {
  var t = _L(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([9, 5]), getType: function(r, n, a, i) {
    return function(o, s, u, c, l) {
      var d = s.types[s.feature], f = u.types[u.feature];
      if (h = f, (m = d) === 9 && h === 5 || m === 5 && h === 9) {
        var m, h, p = f === 5 ? [s, u] : [u, s];
        if (SL(o, p[0], p[1], l)) return Cr.WeakHydrogenBond;
      }
    }(r, n, a, 0, t);
  } };
} }, AL = { distanceMax: V.Numeric(3.5, { min: 1, max: 5, step: 0.1 }), angleMax: V.Numeric(60, { min: 0, max: 60, step: 1 }) }, Toe = V.getDefaultValues(AL), Noe = ["CL", "BR", "I", "AT"], Poe = Kn(180), Boe = Kn(120), Ooe = nn.Provider([6], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = 0, c = n.length; u < c; ++u) {
    var l = Hr(t, u);
    Noe.includes(l) && r.add(6, 0, i[n[u]], o[n[u]], s[n[u]], u);
  }
}), Foe = nn.Provider([7], function(e, t, r) {
  for (var n = function(A, w) {
    var C = Uh.get(A).value;
    if (!C) throw Error("expected valence model to be available");
    var M = C.get(w.id);
    if (!M) throw Error("expected valence model for unit to be available");
    return M;
  }(e, t), a = n.charge, i = n.implicitH, o = n.idealGeometry, s = t.elements, u = t.model.atomicConformation, c = u.x, l = u.y, d = u.z, f = function(A) {
    r.add(7, 0, c[s[A]], l[s[A]], d[s[A]], A);
  }, m = 0, h = s.length; m < h; ++m) {
    var p = Hr(t, m);
    if (p === "O") f(m);
    else if (p === "N") {
      if (a[m] < 1) {
        var g = bh(e, t, m) + i[m], v = o[m];
        (v === 4 && g < 4 || v === 3 && g < 3 || v === 2 && g < 2) && f(m);
      }
    } else p === "S" ? Z8(t, m) === -1 && f(m) : p === "F" && f(m);
  }
  for (var y = 0, _ = t.rings.aromaticRings; y < _.length; y++) {
    var S = _[y], b = t.rings.all[S];
    for (r.startState(), m = 0, h = b.length; m < h; ++m) {
      var x = b[m];
      r.pushMember(c[s[x]], l[s[x]], d[s[x]], x);
    }
    r.finishState(7, 0);
  }
}), Roe = { name: "halogen-bonds", params: AL, createTester: function(e) {
  var t = function(r) {
    return { angleMax: Kn(r.angleMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([6, 7]), getType: function(r, n, a) {
    return function(i, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (f = l, (d = c) === 7 && f === 6 || d === 6 && f === 7) {
        var d, f, m = c === 6 ? [o, s] : [s, o], h = m[0], p = m[1], g = h.members[h.offsets[h.feature]], v = p.members[p.offsets[p.feature]], y = J6(i, h.unit, g, p.unit, v);
        if (y.length === 1 && !(Poe - y[0] > u.angleMax)) {
          var _ = J6(i, p.unit, v, h.unit, g);
          if (_.length !== 0 && !_.some(function(S) {
            return Boe - S > u.angleMax;
          })) return Cr.HalogenBond;
        }
      }
    }(r, n, a, t);
  } };
} }, wL = { distanceMax: V.Numeric(5, { min: 0, max: 8, step: 0.1 }) }, Loe = V.getDefaultValues(wL), CL = { distanceMax: V.Numeric(5.5, { min: 1, max: 8, step: 0.1 }), offsetMax: V.Numeric(2, { min: 0, max: 4, step: 0.1 }), angleDevMax: V.Numeric(30, { min: 0, max: 180, step: 1 }) }, koe = V.getDefaultValues(CL), EL = { distanceMax: V.Numeric(6.6, { min: 1, max: 8, step: 0.1 }), offsetMax: V.Numeric(2, { min: 0, max: 4, step: 0.1 }) }, zoe = V.getDefaultValues(EL);
function DL(e, t) {
  var r = Uh.get(e).value;
  if (!r) throw Error("expected valence model to be available");
  var n = r.get(t.id);
  if (!n) throw Error("expected valence model for unit to be available");
  return n;
}
var sM = D(), uM = D(), $p = D(), Id = D(), Yf = D(), wg = D();
function n_(e, t) {
  var r = t.unit, n = t.feature, a = t.offsets, i = t.members, o = r.elements, s = a[n];
  return t.unit.conformation.position(o[i[s]], $p), t.unit.conformation.position(o[i[s + 1]], Id), t.unit.conformation.position(o[i[s + 2]], Yf), D.triangleNormal(e, $p, Id, Yf);
}
var Lx = Kn(180), Cg = Kn(90), J0 = D(), kx = D();
function Uoe(e, t, r, n, a) {
  var i, o, s = t.types[t.feature], u = r.types[r.feature];
  if (o = u, ((i = s) === 2 && o === 1 || i === 1 && o === 2) && function(c, l, d) {
    for (var f = c.feature, m = c.offsets, h = c.members, p = l.feature, g = l.offsets, v = l.members, y = m[f], _ = m[f + 1]; y < _; ++y) {
      var S = h[y];
      c.unit.conformation.position(c.unit.elements[S], sM);
      for (var b = g[p], x = g[p + 1]; b < x; ++b) {
        var A = v[b];
        if (l.unit.conformation.position(l.unit.elements[A], uM), D.squaredDistance(sM, uM) < d) return !0;
      }
    }
    return !1;
  }(t, r, a.distanceMaxSq)) return Cr.Ionic;
}
function Goe(e, t, r, n, a) {
  var i, o, s = t.types[t.feature], u = r.types[r.feature];
  if (o = u, (i = s) === 3 && o === 1 || i === 1 && o === 3) {
    var c = s === 3 ? [t, r] : [r, t], l = c[0], d = c[1];
    n_(J0, l);
    var f = function(m, h, p) {
      return nn.position($p, m), nn.position(Id, h), D.sub(Yf, $p, Id), D.projectOnPlane(wg, Yf, p), D.add(wg, wg, Id), D.distance(wg, Id);
    }(d, l, J0);
    if (f <= a.offsetMax) return Cr.CationPi;
  }
}
var Voe = nn.Provider([2], function(e, t, r) {
  for (var n = DL(e, t).charge, a = t.elements, i = t.model.atomicConformation, o = i.x, s = i.y, u = i.z, c = nr.transientSegments(t.model.atomicHierarchy.residueAtomSegments, a); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, m = function(p) {
    if (n[p] < 0) r.add(2, 0, o[a[p]], s[a[p]], u[a[p]], p);
    else if (Hr(t, p) === "O") {
      var g = -1, v = 0;
      if (nc(t, p, function(M, T) {
        Hr(t, T) === "C" && (g = T, v++);
      }), v === 1 && g !== -1) {
        var y = /* @__PURE__ */ new Set(), _ = 0;
        if (nc(t, g, function(M, T) {
          Hr(t, T) === "O" && y.add(T);
        }), y.size === 2) {
          for (var S = t.bonds, b = !0, x = 0, A = S.a.length; x < A; x++) {
            var w = S.a[x], C = S.b[x];
            y.has(C) && w !== g && Hr(t, w) !== "H" && (_ = -100), S.edgeProps.order[x] === 2 && C === p && (b = !1), w === g && y.has(C) && S.edgeProps.order[x] === 2 && _++;
          }
          _ === 1 && b && r.add(2, 0, o[a[p]], s[a[p]], u[a[p]], p);
        }
      }
    }
  }, h = d; h < f; ++h) m(h);
}), qoe = nn.Provider([1], function(e, t, r) {
  for (var n = DL(e, t).charge, a = t.elements, i = t.model.atomicConformation, o = i.x, s = i.y, u = i.z, c = nr.transientSegments(t.model.atomicHierarchy.residueAtomSegments, a); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, m = function(p) {
    if (n[p] > 0) r.add(1, 0, o[a[p]], s[a[p]], u[a[p]], p);
    else if (Hr(t, p) === "N") {
      var g = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Map();
      if (nc(t, p, function(_, S) {
        Hr(t, S) === "C" && g.add(S);
      }), !g.size) return "continue";
      g.forEach(function(_) {
        var S = /* @__PURE__ */ new Set();
        nc(t, _, function(b, x) {
          Hr(t, x) === "N" ? S.add(x) : g.delete(_);
        }), S.size !== 3 ? g.delete(_) : v.set(_, S);
      });
      var y = !1;
      if (!g.size) return "continue";
      g.forEach(function(_) {
        var S = t.bonds, b = v.get(_), x = 0;
        if (b) {
          for (var A = function(M, T) {
            var N = S.a[M], I = S.b[M];
            if (N === _ && b.has(I) && S.edgeProps.order[M] === 2) {
              I === p && (y = !0);
              var P = !0;
              nc(t, I, function(O, F) {
                F !== _ && Hr(t, F) !== "H" && (P = !1);
              }), P && b.delete(I), x++;
            }
          }, w = 0, C = S.a.length; w < C; w++) A(w);
          x !== 1 ? g.delete(_) : b.forEach(function(M) {
            var T = !0;
            nc(t, M, function(N, I) {
              I !== _ && Hr(t, I) !== "H" && (T = !1);
            }), T && b.delete(M);
          }), b.size > 1 && g.delete(_);
        }
      }), g.size && y && r.add(1, 0, o[a[p]], s[a[p]], u[a[p]], p);
    }
  }, h = d; h < f; ++h) m(h);
}), Hoe = nn.Provider([3], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = 0, c = t.rings.aromaticRings; u < c.length; u++) {
    var l = c[u], d = t.rings.all[l];
    r.startState();
    for (var f = 0, m = d.length; f < m; ++f) {
      var h = d[f];
      r.pushMember(i[n[h]], o[n[h]], s[n[h]], h);
    }
    r.finishState(3, 0);
  }
}), Koe = { name: "ionic", params: wL, createTester: function(e) {
  var t = function(r) {
    return { distanceMaxSq: r.distanceMax * r.distanceMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([2, 1]), getType: function(r, n, a, i) {
    return Uoe(0, n, a, 0, t);
  } };
} }, Xoe = { name: "pi-stacking", params: CL, createTester: function(e) {
  var t = function(r) {
    return { offsetMax: r.offsetMax, angleDevMax: Kn(r.angleDevMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3]), getType: function(r, n, a, i) {
    return function(o, s, u, c, l) {
      var d, f = s.types[s.feature], m = u.types[u.feature];
      if (d = m, f === 3 && d === 3) {
        n_(J0, s), n_(kx, u);
        var h = D.angle(J0, kx);
        nn.position($p, s), nn.position(Id, u), D.sub(Yf, $p, Id);
        var p = D.angle(J0, Yf), g = D.angle(kx, Yf), v = Bi(p > Cg ? Lx - p : p), y = Bi(g > Cg ? Lx - g : g), _ = h <= l.angleDevMax || h >= Lx - l.angleDevMax ? "parallel" : h <= l.angleDevMax + Cg && h >= Cg - l.angleDevMax ? "t-shaped" : void 0, S = _ === "parallel" ? [0, 33] : [0, 30];
        if (_ && (v >= S[0] && v <= S[1] || y >= S[0] && y <= S[1])) return Cr.PiStacking;
      }
    }(0, n, a, 0, t);
  } };
} }, joe = { name: "cation-pi", params: EL, createTester: function(e) {
  var t = function(r) {
    return { offsetMax: r.offsetMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3, 1]), getType: function(r, n, a, i) {
    return Goe(0, n, a, 0, t);
  } };
} }, ML = { distanceMax: V.Numeric(3, { min: 1, max: 5, step: 0.1 }) }, Yoe = V.getDefaultValues(ML), Eg = { 7: 0.71, 8: 0.63, 16: 1.03, 17: 0.99, 35: 1.14, 53: 1.33, 12: 1.39, 23: 1.34, 24: 1.22, 25: 1.19, 26: 1.16, 27: 1.11, 28: 1.1, 29: 1.12, 30: 1.18, 44: 1.25, 45: 1.25, 75: 1.31, 76: 1.29, 78: 1.23, 79: 1.24 }, Woe = ["LI", "NA", "K", "RB", "CS", "MG", "CA", "SR", "BA", "AL", "GA", "IN", "TL", "SC", "SN", "PB", "BI", "SB", "HG"];
function cM(e) {
  return !_8.has(e);
}
function Zoe(e) {
  return _8.has(e);
}
function Qoe(e) {
  return jJ.has(e);
}
function lM(e, t) {
  return e === 12 ? t === 11 || t === 12 : e === 13 ? t === 10 : void 0;
}
var Dg, r0, Jm, xr, qi, qe, Mt, $oe = nn.Provider([13, 12], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = 0, c = n.length; u < c; ++u) {
    var l = Hr(t, u), d = 0;
    Woe.includes(l) ? d = 13 : (vL(l) || l === "ZN" || l === "CD") && (d = 12), d && r.add(d, 0, i[n[u]], o[n[u]], s[n[u]], u);
  }
}), Joe = nn.Provider([10, 11], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = 0, c = n.length; u < c; ++u) {
    var l = Hr(t, u), d = loe(t, u), f = hL(t, u), m = !1, h = !1, p = Oh.has(d), g = A8.has(d);
    p || g ? p ? l === "O" ? (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(d) && cM(f) || Zoe(f)) && (m = !0, h = !0) : l !== "S" || d !== "CYS" && d !== "MET" ? l === "N" && d === "HIS" && cM(f) && (m = !0) : (m = !0, h = !0) : g && (l === "O" && Qoe(f) ? (m = !0, h = !0) : ["N3", "N4", "N7"].includes(f) ? m = !0 : ["O2", "O4", "O6"].includes(f) && (m = !0, h = !0)) : voe(l) || l === "O" || l === "S" ? (m = !0, h = !0) : l === "N" && (m = !0), m && r.add(11, 0, i[n[u]], o[n[u]], s[n[u]], u), h && r.add(10, 0, i[n[u]], o[n[u]], s[n[u]], u);
  }
}), ese = { name: "metal-coordination", params: ML, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([13, 12, 10, 11]), getType: function(t, r, n, a) {
    return function(i, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (lM(c, l) || lM(l, c)) {
        var d = zp[Hr(o.unit, o.members[o.offsets[o.feature]])], f = zp[Hr(s.unit, s.members[s.offsets[s.feature]])];
        if (d && f && Eg[d] && Eg[f]) {
          var m = Eg[d] + Eg[f] + 0.5, h = D.create(0, 0, 0), p = D.create(0, 0, 0);
          if (nn.position(h, o), nn.position(p, s), D.distance(h, p) > m) return;
        }
        return Cr.MetalCoordination;
      }
    }(0, r, n);
  } };
} };
(function(e) {
  e.Pdb = "pdb", e.Sdf = "sdf", e.Mol = "mol", e.Mol2 = "mol2", e.MMCif = "mmcif", e.Gro = "gro", e.Xtc = "xtc", e.Dump = "dump", e.Xyz = "xyz", e.Cif = "cif", e.MCif = "mcif", e.POSCAR = "poscar", e.Material = "material", e.Pymatgen = "pymatgen";
})(xr || (xr = {})), function(e) {
  e.Molecular = "Molecular", e.Protein = "Protein", e.Chain = "Chain", e.Residue = "Residue", e.Ligand = "Ligand", e.Solvent = "Solvent", e.Water = "Water", e.Other = "Other", e.Metal = "Metal", e.Ions = "Ions", e.Atom = "Atom";
}(qi || (qi = {})), function(e) {
  e.Ribbon = "Ribbon", e.BallAndStick = "BallAndStick", e.Line = "Line", e.Stick = "Stick", e.CPK = "CPK", e.Label = "Label", e.Distance = "Distance", e.Angle = "Angle", e.Dihedral = "Dihedral", e.IntraInteractions = "IntraInteractions", e.BetweenInteractions = "BetweenInteractions", e.Pharmacophore = "Pharmacophore", e.Pocket = "Pocket", e.Surface = "Surface", e.IsoSurface = "IsoSurface", e.RotateArrow = "RotateArrow", e.MappingLine = "MappingLine", e.UnitCell = "UnitCell", e.CustomLines = "CustomLines", e.CustomPlanes = "CustomPlanes", e.Trajectory = "Trajectory";
}(qe || (qe = {})), function(e) {
  e.RIBBON = "Ribbon", e.ATOM = "Atom", e.SURFACE = "Surface";
}(Mt || (Mt = {}));
var vd, On = ((Dg = {})[Mt.RIBBON] = [qe.Ribbon], Dg[Mt.ATOM] = [qe.CPK, qe.Line, qe.Stick, qe.BallAndStick], Dg[Mt.SURFACE] = [qe.Surface], Dg);
(function(e) {
  e[e.Not = 0] = "Not", e[e.Include = 1] = "Include", e[e.BeIncluded = 2] = "BeIncluded", e[e.Cross = 3] = "Cross";
})(vd || (vd = {}));
var Qr;
qe.Ribbon, qe.CPK, qe.Line, qe.Stick, qe.BallAndStick, qe.Surface;
var n0 = /* @__PURE__ */ new Set([qe.BallAndStick, qe.Line, qe.Stick, qe.CPK]), tse = /* @__PURE__ */ new Set([qe.BallAndStick, qe.Line, qe.Stick]), Jp = /* @__PURE__ */ new Set([qe.Label, qe.Distance, qe.Angle, qe.Dihedral]), rse = /* @__PURE__ */ new Set([qe.Surface, qe.Pharmacophore, qe.Pocket]);
(function(e) {
  e.Atom = "Atom", e.Residue = "Residue", e.Chain = "Chain", e.Molecular = "Molecular";
})(Qr || (Qr = {}));
var $u, nse = ((r0 = {})[Qr.Atom] = "element", r0[Qr.Residue] = "residue", r0[Qr.Chain] = "chain", r0[Qr.Molecular] = "entity", r0), ase = { element: Qr.Atom, residue: Qr.Residue, chain: Qr.Chain, entity: Qr.Molecular };
(function(e) {
  e.HydrogenBonds = "hydrogen-bonds", e.WeakHydrogenBonds = "weak-hydrogen-bonds", e.HalogenBonds = "halogen-bonds", e.SaltBridge = "ionic", e.PiPiStacking = "pi-stacking", e.PiCations = "cation-pi", e.MetalBonds = "metal-coordination", e.Hydrophobic = "hydrophobic";
})($u || ($u = {}));
var Lf, a_ = function(e) {
  var t, r = ((t = {})[$u.HydrogenBonds] = { name: "on", params: Soe }, t[$u.WeakHydrogenBonds] = { name: "off", params: Aoe }, t[$u.HalogenBonds] = { name: "on", params: Toe }, t[$u.SaltBridge] = { name: "on", params: Loe }, t[$u.PiPiStacking] = { name: "on", params: koe }, t[$u.PiCations] = { name: "on", params: zoe }, t[$u.MetalBonds] = { name: "on", params: Yoe }, t[$u.Hydrophobic] = { name: "off", params: {} }, t);
  return e && Object.keys(r).forEach(function(n) {
    r[n].name = e.includes(n) ? "on" : "off";
  }), r;
};
(function(e) {
  e[e.All = 0] = "All", e[e.Residues = 1] = "Residues", e[e.Water = 2] = "Water", e[e.SolventWithoutWater = 3] = "SolventWithoutWater", e[e.Solvent = 4] = "Solvent";
})(Lf || (Lf = {}));
var eh, Ea, Gf, ise = ((Jm = {})[Lf.All] = [qi.Protein, qi.Water, qi.Ligand, qi.Solvent], Jm[Lf.Residues] = [qi.Protein], Jm[Lf.Water] = [qi.Water], Jm[Lf.SolventWithoutWater] = [qi.Solvent], Jm[Lf.Solvent] = [qi.Water, qi.Solvent], Jm);
(function(e) {
  e.Structure = "Structure", e.Measurement = "Measurement", e.Interaction = "Interaction", e.Bond = "Bond";
})(eh || (eh = {})), function(e) {
  e[e.NotHydrogen = -1] = "NotHydrogen", e[e.NonPolar = 0] = "NonPolar", e[e.Polar = 1] = "Polar", e[e.ConnectPolar = 2] = "ConnectPolar", e[e.ConnectNonPolar = 3] = "ConnectNonPolar";
}(Ea || (Ea = {})), function(e) {
  e.Drug = "drug", e.Material = "material";
}(Gf || (Gf = {}));
var Ci = function(e) {
  if (e.kind === "element-loci") return e;
  if (e.kind === "structure-loci") return st.toStructureElementLoci(e.structure);
  if (e.kind === "shape-loci") {
    var t, r = e.shape.sourceData, n = [];
    return r.infos ? n.push.apply(n, nt([], r.infos, !0).map(function(a) {
      return a.loci;
    })) : r.pairs ? n.push.apply(n, r.pairs[0].loci) : r.triples ? n.push.apply(n, r.triples[0].loci) : r.quads && n.push.apply(n, r.quads[0].loci), n.forEach(function(a) {
      t = t ? et.union(t, Ci(a)) : Ci(a);
    }), t;
  }
}, ua = function(e, t) {
  var r = [], n = new Set(t), a = /* @__PURE__ */ new Set();
  return e.units.forEach(function(i) {
    if (!a.has(i.invariantId)) {
      a.add(i.invariantId);
      var o = [];
      i.elements.forEach(function(s, u) {
        t && !n.has(s) || o.push(u);
      }), o.length > 0 && r.push({ unit: i, indices: o });
    }
  }), et(e, r);
}, Ya = function(e) {
  var t = [];
  return e.elements.forEach(function(r) {
    t.push.apply(t, We.toArray(r.indices).map(function(n) {
      return r.unit.elements[n];
    }).filter(function(n) {
      return n !== void 0;
    }));
  }), t;
}, ose = function(e, t) {
  var r, n = nm.ofLoci(e);
  r = n.elementCount > 0 ? n.firstElementLoc : n.residueCount > 0 ? n.firstResidueLoc : n.chainCount > 0 ? n.firstChainLoc : n.unitCount > 0 ? n.firstUnitLoc : n.conformationCount > 0 ? n.firstConformationLoc : n.firstStructureLoc;
  var a = at.atom.em_confidence(r), i = at.atom.B_iso_or_equiv(r);
  switch (t) {
    case Qr.Atom:
      return n.elementCount === 1 ? { x: at.atom.x(r), y: at.atom.y(r), z: at.atom.z(r), granularity: Qr.Atom, atomName: at.atom.label_atom_id(r), atomId: at.atom.id(r), altId: at.atom.label_alt_id(r), residueName: at.atom.label_comp_id(r), residueId: at.residue.auth_seq_id(r), insertCode: at.residue.pdbx_PDB_ins_code(r), chainId: at.chain.label_asym_id(r), emConfidence: a, bfactor: i } : { granularity: Qr.Residue, altId: at.atom.label_alt_id(r), residueName: at.atom.label_comp_id(r), residueId: at.residue.auth_seq_id(r), chainId: at.chain.label_asym_id(r), insertCode: at.residue.pdbx_PDB_ins_code(r), emConfidence: a, bfactor: i };
    case Qr.Residue:
      return { granularity: Qr.Residue, altId: at.atom.label_alt_id(r), residueName: at.atom.label_comp_id(r), residueId: at.residue.auth_seq_id(r), chainId: at.chain.label_asym_id(r), insertCode: at.residue.pdbx_PDB_ins_code(r), bfactor: i };
    case Qr.Chain:
      return { granularity: Qr.Chain, chainId: at.chain.label_asym_id(r) };
    case Qr.Molecular:
      return { granularity: Qr.Molecular };
    default:
      return {};
  }
}, sse = function(e) {
  var t = e.elements[0], r = t.unitA, n = t.indexA, a = t.unitB, i = t.indexB, o = e.data.interactions, s = o.contacts, u = o.unitsContacts, c = o.unitsFeatures, l = c.get(r.id), d = l.members, f = l.offsets, m = c.get(a.id), h = m.members, p = m.offsets, g = -1;
  if (r === a) {
    var v = u.get(r.id), y = v.getDirectedEdgeIndex(n, i);
    g = v.edgeProps.type[y];
  } else
    y = s.getEdgeIndex(n, r.id, i, a.id), g = s.edges[y].props.type;
  var _ = Pt.Location(e.data.structure, r, d[f[n]], e.data.structure, a, h[p[i]]), S = et(_.aStructure, [{ unit: _.aUnit, indices: We.ofSingleton(_.aIndex) }]), b = et(_.bStructure, [{ unit: _.bUnit, indices: We.ofSingleton(_.bIndex) }]), x = nm.ofLoci(S), A = nm.ofLoci(b), w = x.firstElementLoc, C = A.firstElementLoc;
  return { infoA: { chainId: at.chain.label_asym_id(w), residueName: at.atom.label_comp_id(w), residueId: at.residue.auth_seq_id(w), atomName: at.atom.label_atom_id(w) }, infoB: { chainId: at.chain.label_asym_id(C), residueName: at.atom.label_comp_id(C), residueId: at.residue.auth_seq_id(C), atomName: at.atom.label_atom_id(C) }, interactionType: r_(g) };
}, use = function(e) {
  return fetch(e).then(function(t) {
    return t.text();
  });
}, cse = function(e) {
  return fetch(e).then(function(t) {
    return t.blob();
  });
}, lse = function(e) {
  return new Promise(function(t) {
    var r = new FileReader();
    r.onload = function(n) {
      return Be(this, 0, void 0, function() {
        return Te(this, function(a) {
          return t(r.result), [2];
        });
      });
    }, r.readAsText(e);
  });
}, Wf = function(e) {
  return Be(void 0, 0, void 0, function() {
    var t, r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof e != "string" ? [3, 4] : e.startsWith("http") || e.startsWith("https") ? [4, use(e)] : [3, 2];
        case 1:
          return r = n.sent(), [3, 3];
        case 2:
          r = e, n.label = 3;
        case 3:
          return t = r, [3, 6];
        case 4:
          return [4, lse(e)];
        case 5:
          t = n.sent(), n.label = 6;
        case 6:
          return [2, t];
      }
    });
  });
}, dse = function(e) {
  return Be(void 0, 0, void 0, function() {
    var t, r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof e != "string" ? [3, 2] : [4, cse(e)];
        case 1:
          return t = n.sent(), [3, 4];
        case 2:
          return r = Blob.bind, [4, e.arrayBuffer()];
        case 3:
          t = new (r.apply(Blob, [void 0, [n.sent()]]))(), n.label = 4;
        case 4:
          return [2, t];
      }
    });
  });
};
function fse(e, t, r) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(n) {
      return [2, new Promise(function(a, i) {
        var o = function(p) {
          p ? a(p) : i("no blob returned");
        };
        if (HTMLCanvasElement.prototype.toBlob) e.toBlob(o, t, r);
        else {
          for (var s = atob(e.toDataURL(t, r).split(",")[1]), u = s.length, c = u >> 2, l = new Uint8Array(u), d = new Uint32Array(l.buffer, 0, c), f = 0, m = 0; m < c; ++m) d[m] = s.charCodeAt(f++) | s.charCodeAt(f++) << 8 | s.charCodeAt(f++) << 16 | s.charCodeAt(f++) << 24;
          for (var h = 3 & u; h--; ) l[f] = s.charCodeAt(f++);
          o(new Blob([l], { type: t }));
        }
      })];
    });
  });
}
var mse = 1 / 0;
function IL(e, t, r, n, a) {
  var i = -1, o = e.length;
  for (r || (r = Array.isArray), a || (a = []); ++i < o; ) {
    var s = e[i];
    r(s) ? IL(s, t - 1, r, n, a) : a[a.length] = s;
  }
  return a;
}
function TL(e) {
  return e != null && e.length ? IL(e, mse) : [];
}
var zx = function(e, t) {
  for (var r = [], n = 0, a = t.length; n < a; n++) {
    var i = t[n], o = i.start, s = i.end;
    i.regular.test(e.slice(o, s)) || r.push({ start: o, end: s });
  }
  return r;
}, xh = function(e) {
  return e.length > 2 || e.length === 0 ? e : "".concat(e[0].toLocaleUpperCase()).concat(e.length === 2 ? e[1].toLocaleLowerCase() : "");
}, Ux = { HSE: "SER", HSD: "HIS", HSP: "HIS", "2AS": "ASP", "3AH": "HIS", "5HP": "GLU", ACL: "ARG", AGM: "ARG", AIB: "ALA", ALM: "ALA", ALO: "THR", ALY: "LYS", ARM: "ARG", ASA: "ASP", ASB: "ASP", ASK: "ASP", ASL: "ASP", ASQ: "ASP", AYA: "ALA", BCS: "CYS", BHD: "ASP", BMT: "THR", BNN: "ALA", BUC: "CYS", BUG: "LEU", C5C: "CYS", C6C: "CYS", CAS: "CYS", CCS: "CYS", CEA: "CYS", CGU: "GLU", CHG: "GLY", CLE: "LEU", CME: "CYS", CSD: "CYS", CSO: "CYS", CSP: "CYS", CSS: "CYS", CSW: "CYS", CSX: "CYS", CXM: "MET", CY1: "CYS", CY3: "CYS", CYG: "CYS", CYM: "CYS", CYQ: "CYS", DAH: "PHE", DAL: "ALA", DAR: "ARG", DAS: "ASP", DCY: "CYS", DGL: "GLU", DGN: "GLN", DHA: "ALA", DHI: "HIS", DIL: "ILE", DIV: "VAL", DLE: "LEU", DLY: "LYS", DNP: "ALA", DPN: "PHE", DPR: "PRO", DSN: "SER", DSP: "ASP", DTH: "THR", DTR: "TRP", DTY: "TYR", DVA: "VAL", EFC: "CYS", FLA: "ALA", FME: "MET", GGL: "GLU", GL3: "GLY", GLZ: "GLY", GMA: "GLU", GSC: "GLY", HAC: "ALA", HAR: "ARG", HIC: "HIS", HIP: "HIS", HMR: "ARG", HPQ: "PHE", HTR: "TRP", HYP: "PRO", IAS: "ASP", IIL: "ILE", IYR: "TYR", KCX: "LYS", LLP: "LYS", LLY: "LYS", LTR: "TRP", LYM: "LYS", LYZ: "LYS", MAA: "ALA", MEN: "ASN", MHS: "HIS", MIS: "SER", MLE: "LEU", MPQ: "GLY", MSA: "GLY", MSE: "MET", MVA: "VAL", NEM: "HIS", NEP: "HIS", NLE: "LEU", NLN: "LEU", NLP: "LEU", NMC: "GLY", OAS: "SER", OCS: "CYS", OMT: "MET", PAQ: "TYR", PCA: "GLU", PEC: "CYS", PHI: "PHE", PHL: "PHE", PR3: "CYS", PRR: "ALA", PTR: "TYR", PYX: "CYS", SAC: "SER", SAR: "GLY", SCH: "CYS", SCS: "CYS", SCY: "CYS", SEL: "SER", SEP: "SER", SET: "SER", SHC: "CYS", SHR: "LYS", SMC: "CYS", SOC: "CYS", STY: "TYR", SVA: "SER", TIH: "ALA", TPL: "TRP", TPO: "THR", TPQ: "ALA", TRG: "LYS", TRO: "TRP", TYB: "TYR", TYI: "TYR", TYQ: "TYR", TYS: "TYR", TYY: "TYR", ALA: "ALA", ASN: "ASN", CYS: "CYS", GLU: "GLU", HIS: "HIS", LEU: "LEU", MET: "MET", PRO: "PRO", THR: "THR", TYR: "TYR", ARG: "ARG", ASP: "ASP", GLN: "GLN", GLY: "GLY", ILE: "ILE", LYS: "LYS", PHE: "PHE", SER: "SER", TRP: "TRP", VAL: "VAL", "0CS": "ALA", "1AB": "PRO", "1LU": "LEU", "1PA": "PHE", "1TQ": "TRP", "1TY": "TYR", "23F": "PHE", "23S": "TRP", "2BU": "ALA", "2ML": "LEU", "2MR": "ARG", "2MT": "PRO", "2OP": "ALA", "2TY": "TYR", "32S": "TRP", "32T": "TRP", "3MD": "ASP", "3TY": "TYR", "4DP": "TRP", "4F3": "ALA", "4FB": "PRO", "4FW": "TRP", "4HT": "TRP", "4IN": "TRP", "4PH": "PHE", "5CS": "CYS", "6CL": "LYS", "6CW": "TRP", A0A: "ASP", AA4: "ALA", AAR: "ARG", AB7: "GLU", ABA: "ALA", ACB: "ASP", ACY: "GLY", AEI: "THR", AFA: "ASN", AGT: "CYS", AHB: "ASN", AHO: "ALA", AHP: "ALA", AKL: "ASP", ALC: "ALA", ALG: "ARG", ALN: "ALA", ALS: "ALA", ALT: "ALA", AME: "MET", AP7: "ALA", APH: "ALA", API: "LYS", APK: "LYS", AR2: "ARG", AR4: "GLU", ARO: "ARG", ASI: "ASP", AYG: "ALA", AZK: "LYS", B2A: "ALA", B2F: "PHE", B2I: "ILE", B2V: "VAL", B3A: "ALA", B3D: "ASP", B3E: "GLU", B3K: "LYS", B3S: "SER", B3X: "ASN", B3Y: "TYR", BAL: "ALA", BBC: "CYS", BCX: "CYS", BFD: "ASP", BG1: "SER", BIF: "PHE", BLE: "LEU", BLY: "LYS", BOR: "ARG", BPE: "CYS", BTR: "TRP", C12: "ALA", C1X: "LYS", C3Y: "CYS", C99: "ALA", CAB: "ALA", CAF: "CYS", CH6: "ALA", CH7: "ALA", CHP: "GLY", CHS: "PHE", CIR: "ARG", CLB: "ALA", CLD: "ALA", CLG: "LYS", CLH: "LYS", CLV: "ALA", CML: "CYS", CMT: "CYS", CQR: "ALA", CR2: "ALA", CR5: "ALA", CR7: "ALA", CR8: "ALA", CRK: "ALA", CRO: "THR", CRQ: "TYR", CRW: "ALA", CRX: "ALA", CS1: "CYS", CS3: "CYS", CS4: "CYS", CSA: "CYS", CSB: "CYS", CSE: "CYS", CSI: "ALA", CSR: "CYS", CSU: "CYS", CSY: "ALA", CSZ: "CYS", CTH: "THR", CWR: "ALA", CY0: "CYS", CY4: "CYS", CY7: "CYS", CYD: "CYS", CYF: "CYS", CYJ: "LYS", CYR: "CYS", CYX: "CYS", CZ2: "CYS", CZZ: "CYS", DA2: "ARG", DAB: "ALA", DAM: "ALA", DBU: "ALA", DBY: "TYR", DBZ: "ALA", DCL: "LEU", DDE: "HIS", DHL: "SER", DLS: "LYS", DMH: "ASN", DMK: "ASP", DNE: "LEU", DNG: "LEU", DNL: "LYS", DNM: "LEU", DPH: "PHE", DPL: "PRO", DPP: "ALA", DPQ: "TYR", DSE: "SER", DSG: "ASN", DYG: "ALA", DYS: "CYS", ESB: "TYR", ESC: "MET", FCL: "PHE", FGL: "ALA", FGP: "SER", FHL: "LYS", FLE: "LEU", FLT: "TYR", FOE: "CYS", FOG: "PHE", FOR: "MET", FRF: "PHE", FTR: "TRP", FTY: "TYR", GHG: "GLN", GHP: "GLY", GLH: "GLN", GMU: "ALA", GPL: "LYS", GT9: "CYS", GVL: "SER", GYC: "CYS", GYS: "GLY", H5M: "PRO", HHK: "ALA", HIA: "HIS", HID: "HIS", HIE: "HIS", HIQ: "HIS", HLU: "LEU", HMF: "ALA", HPE: "PHE", HPH: "PHE", HRG: "ARG", HSL: "SER", HSO: "HIS", HTI: "CYS", HY3: "PRO", IAM: "ALA", IGL: "ALA", ILG: "GLU" }, pse = { ALA: "A", CYS: "C", ASP: "D", GLU: "E", PHE: "F", GLY: "G", HIS: "H", ILE: "I", LYS: "K", LEU: "L", MET: "M", ASN: "N", PRO: "P", GLN: "Q", ARG: "R", SER: "S", THR: "T", VAL: "V", TRP: "W", TYR: "Y", HID: "H", HIE: "H", HIP: "H", ASH: "B", GLH: "E", LYN: "K", CYM: "CM" }, hse = [{ start: 0, end: 10, regular: /\s*[\d.-]+/ }, { start: 10, end: 20, regular: /\s*[\d.-]+/ }, { start: 20, end: 30, regular: /\s*[\d.-]+/ }, { start: 31, end: 33, regular: /[\sA-Za-z]+/ }], vse = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }, { start: 6, end: 9, regular: /\s*[\d]+/ }], gse = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }], NL = { Dihedral: qe.Dihedral, Distance: qe.Distance, Angle: qe.Angle, Label: qe.Label, "Molecular Surface": qe.Surface, "Ball & Stick": qe.BallAndStick, Line: qe.Line, Stick: qe.Stick, Spacefill: qe.CPK, Cartoon: qe.Ribbon }, PL = function(e, t, r) {
  var n, a = t[0], i = a.residueName, o = a.residueId, s = a.isEutectic, u = t.map(function(m) {
    return m.elementId;
  }), c = ua(e, u), l = nm.ofLoci(c);
  n = l.elementCount > 0 ? l.firstElementLoc : l.residueCount > 0 ? l.firstResidueLoc : l.chainCount > 0 ? l.firstChainLoc : l.unitCount > 0 ? l.firstUnitLoc : l.conformationCount > 0 ? l.firstConformationLoc : l.firstStructureLoc;
  var d, f = (d = at.residue.secondary_structure_type(n), Er.is(d, 2) ? "helix" : Er.is(d, 4) ? "sheet" : Er.is(d, 16) ? "turn" : Er.is(d, 8) ? "bend" : "none");
  return { residueNum: o, residueName: i.toUpperCase(), standardResidueName: Ux[i.toUpperCase()], oneLetter: s ? "X" : pse[Ux[i.toUpperCase()]] || Ux[i.toUpperCase()] || "X", elementIds: t.map(function(m) {
    return m.elementId;
  }), secondaryStructureType: f, secondaryStructureTypeInfo: at.residue.secondary_structure_type(n), secondaryStructureTypeKey: at.residue.secondary_structure_key(n), insCode: at.residue.pdbx_PDB_ins_code(n), index: r };
}, Q8 = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR", "BE", "MG", "CA", "SR", "BA", "RA", "AL", "GA", "IN", "SN", "TL", "PB", "BI", "SC", "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "Y", "ZR", "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "LA", "HF", "TA", "W", "RE", "OS", "IR", "PT", "AU", "HG", "AC", "RF", "DB", "SG", "BH", "HS", "MT", "CE", "PR", "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK", "CF", "ES", "FM", "MD", "NO", "LR"]), $8 = /* @__PURE__ */ new Set(["EOH", "GOL", "DMS", "PEG", "POL", "IOH", "DIO", "ACN", "SBT", "1BO", "CCN", "DMS", "GBL", "P2K", "MPD", "PGQ", "SEO"]), fo = function(e, t, r) {
  r === void 0 && (r = !1);
  var n = r ? "".concat(t.residueId, "_").concat(t.insertCode) : t.residueId;
  e[t.chainId] ? e[t.chainId][n] = (e[t.chainId][n] ? e[t.chainId][n] : []).concat(t) : (e[t.chainId] = {}, e[t.chainId][n] = [t]);
}, BL = function(e) {
  var t = {}, r = {}, n = {}, a = {}, i = {}, o = {}, s = {}, u = {}, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
  e.units.forEach(function(g) {
    var v;
    g.elements.forEach(function(x) {
      var A = mc(g, x);
      if (m1.has(A.residueName.toUpperCase())) fo(r, A);
      else if (Q8.has(A.typeSymbol.toUpperCase())) fo(a, A);
      else if ($8.has(A.residueName.toUpperCase())) fo(n, A);
      else if (Bh.has(A.residueName.toUpperCase())) fo(i, A);
      else {
        if (A.groupPDB === "ATOM" && !["UNK", "MOL"].includes(A.residueName)) return fo(t, A, !0), void c.add(A.elementId);
        if (A.groupPDB === "HETATM" || ["UNK", "MOL"].includes(A.residueName)) {
          var w = "".concat(A.chainId, "_").concat(A.residueId);
          l.set(w, l.has(w) ? nt(nt([], l.get(w), !0), [A], !1) : [A]);
        } else fo(s, A);
      }
    });
    for (var y = 0, _ = g.bonds.a.length; y < _; y++) {
      var S = g.elements[g.bonds.a[y]], b = g.elements[g.bonds.b[y]];
      d.has(S) ? (v = d.get(S)) === null || v === void 0 || v.add(b) : d.set(S, /* @__PURE__ */ new Set([b]));
    }
  }), l.forEach(function(g) {
    var v = !1;
    new Set(g.map(function(y) {
      return y.elementId;
    })).forEach(function(y) {
      if (d.has(y)) {
        var _ = d.get(y);
        _ == null || _.forEach(function(S) {
          c.has(S) && (v = !0);
        });
      }
    }), g.forEach(function(y) {
      v ? (Object.assign(y, { isEutectic: !0 }), fo(o, y)) : fo(s, y);
    });
  });
  var f = {};
  Object.keys(s).forEach(function(g) {
    var v = s[g];
    Object.keys(v).forEach(function(y) {
      var _ = v[y], S = _.filter(function(b) {
        return b.typeSymbol !== "H";
      });
      S.length > 10 && S.length < 150 ? (u[g] || (u[g] = {}), u[g][y] = _) : (f[g] || (f[g] = {}), f[g][y] = _);
    });
  });
  var m = {};
  Object.keys(t).forEach(function(g) {
    var v;
    m[g] || (m[g] = []), (v = m[g]).push.apply(v, Object.values(t[g]));
  }), Object.keys(o).forEach(function(g) {
    var v = o[g];
    Object.keys(v).forEach(function(y) {
      var _ = v[y];
      f[g] || (f[g] = {}), m[g] || (m[g] = []), m[g].push(_), f[g][y] = _;
    });
  });
  var h = 0, p = {};
  return Object.keys(m).forEach(function(g) {
    p[g] = {}, m[g].sort(function(v, y) {
      return v[0].residueId !== y[0].residueId ? v[0].residueId - y[0].residueId : v[0].insertCode.localeCompare(y[0].insertCode);
    }).forEach(function(v) {
      p[v[0].chainId]["".concat(v[0].residueId, "_").concat(v[0].insertCode)] = PL(e, v, h++);
    });
  }), { data: { polymer: t, water: r, otherSolvent: n, metal: a, ion: i, ligand: u, other: f }, extraData: { sequenceData: p } };
}, yse = function(e) {
  var t = {}, r = {}, n = {}, a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(d) {
    var f;
    d.elements.forEach(function(v) {
      var y = mc(d, v);
      if (!(m1.has(y.residueName.toUpperCase()) || Q8.has(y.typeSymbol.toUpperCase()) || $8.has(y.residueName.toUpperCase()) || Bh.has(y.residueName.toUpperCase()))) {
        if (y.groupPDB === "ATOM" && !["UNK", "MOL"].includes(y.residueName)) return fo(t, y, !0), void a.add(y.elementId);
        if (y.groupPDB === "HETATM" || ["UNK", "MOL"].includes(y.residueName)) {
          var _ = "".concat(y.chainId, "_").concat(y.residueId);
          i.set(_, i.has(_) ? nt(nt([], i.get(_), !0), [y], !1) : [y]);
        } else fo(n, y);
      }
    });
    for (var m = 0, h = d.bonds.a.length; m < h; m++) {
      var p = d.elements[d.bonds.a[m]], g = d.elements[d.bonds.b[m]];
      o.has(p) ? (f = o.get(p)) === null || f === void 0 || f.add(g) : o.set(p, /* @__PURE__ */ new Set([g]));
    }
  }), i.forEach(function(d) {
    var f = !1;
    new Set(d.map(function(m) {
      return m.elementId;
    })).forEach(function(m) {
      if (o.has(m)) {
        var h = o.get(m);
        h == null || h.forEach(function(p) {
          a.has(p) && (f = !0);
        });
      }
    }), d.forEach(function(m) {
      f ? (Object.assign(m, { isEutectic: !0 }), fo(r, m)) : fo(n, m);
    });
  });
  var s = {};
  Object.keys(n).forEach(function(d) {
    var f = n[d];
    Object.keys(f).forEach(function(m) {
      var h = f[m], p = h.filter(function(g) {
        return g.typeSymbol !== "H";
      });
      p.length <= 10 && p.length < 150 && (s[d] || (s[d] = {}), s[d][m] = h);
    });
  });
  var u = {};
  Object.keys(t).forEach(function(d) {
    var f;
    u[d] || (u[d] = []), (f = u[d]).push.apply(f, Object.values(t[d]));
  }), Object.keys(r).forEach(function(d) {
    var f = r[d];
    Object.keys(f).forEach(function(m) {
      var h = f[m];
      s[d] || (s[d] = {}), u[d] || (u[d] = []), u[d].push(h), s[d][m] = h;
    });
  });
  var c = 0, l = {};
  return Object.keys(u).forEach(function(d) {
    l[d] = {}, u[d].sort(function(f, m) {
      return f[0].residueId !== m[0].residueId ? f[0].residueId - m[0].residueId : f[0].insertCode.localeCompare(m[0].insertCode);
    }).forEach(function(f) {
      l[f[0].chainId]["".concat(f[0].residueId, "_").concat(f[0].insertCode)] = PL(e, f, c++);
    });
  }), l;
}, wy = function(e, t) {
  switch (t) {
    case Qr.Atom:
      return "".concat(e.elementId);
    case Qr.Residue:
      return "".concat(e.chainId, "_").concat(e.residueName, "_").concat(e.residueId);
    case Qr.Chain:
      return "".concat(e.chainId);
    case Qr.Molecular:
      return "".concat(e.unitId);
  }
  return "";
}, bse = function(e, t) {
  switch (t) {
    case Qr.Atom:
      return e;
    case Qr.Residue:
      return { unitId: e.unitId, chainId: e.chainId, groupPDB: e.groupPDB, residueId: e.residueId, residueName: e.residueName };
    case Qr.Chain:
      return { unitId: e.unitId, chainId: e.chainId };
    case Qr.Molecular:
      return { unitId: e.unitId };
  }
  return {};
};
function OL(e, t, r) {
  var n = this;
  return r === void 0 && (r = !1), sr.create("Parse PDB", function(a) {
    return Be(n, 0, void 0, function() {
      var i, o, s;
      return Te(this, function(u) {
        switch (u.label) {
          case 0:
            return o = (i = za).success, s = {}, [4, ft.readAllLinesAsync(e, a)];
          case 1:
            return [2, o.apply(i, [(s.lines = u.sent(), s.id = t, s.isPdbqt = r, s)])];
        }
      });
    });
  });
}
function xse(e, t) {
  var r = function(i, o) {
    return (t.substr(i, o) || "").trim();
  }, n = { entry_id: mt.ofString(e), length_a: mt.ofString(r(6, 9)), length_b: mt.ofString(r(15, 9)), length_c: mt.ofString(r(24, 9)), angle_alpha: mt.ofString(r(33, 7)), angle_beta: mt.ofString(r(40, 7)), angle_gamma: mt.ofString(r(47, 7)), Z_PDB: mt.ofString(r(66, 4)), pdbx_unique_axis: mt.ofString("?") }, a = { entry_id: mt.ofString(e), "space_group_name_H-M": mt.ofString(r(55, 11)), Int_Tables_number: mt.ofString("?"), cell_setting: mt.ofString("?"), space_group_name_Hall: mt.ofString("?") };
  return [Mi.ofFields("cell", n), Mi.ofFields("symmetry", a)];
}
function dM(e, t) {
  return { id: e, details: t, groups: [] };
}
function _se(e, t, r) {
  for (var n, a, i, o = [], s = 1, u = 1, c = function(H) {
    return e.data.substring(e.indices[2 * H], e.indices[2 * H + 1]);
  }, l = t; l < r; l++) {
    var d = c(l);
    if (d.substr(11, 12) === "BIOMOLECULE:") {
      var f = d.substr(23).trim(), m = "Biomolecule ".concat(f);
      (d = c(l + 1)).substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:" && (l++, m = d.substr(11).trim()), n = dM(f, m), o.push(n);
    } else if (d.substr(13, 5) === "BIOMT") {
      var h = d.split(/\s+/);
      (q = parseInt(d[18]) - 1) === 0 && (i = Ee.identity(), a.operators.push({ id: s++, matrix: i })), Ee.setValue(i, q, 0, parseFloat(h[4])), Ee.setValue(i, q, 1, parseFloat(h[5])), Ee.setValue(i, q, 2, parseFloat(h[6])), Ee.setValue(i, q, 3, parseFloat(h[7]));
    } else if (d.substr(11, 30) === "APPLY THE FOLLOWING TO CHAINS:" || d.substr(11, 30) === "                   AND CHAINS:") {
      d.substr(11, 5) === "APPLY" && (a = { chains: [], operators: [] }, n.groups.push(a));
      for (var p = 0, g = (v = d.substr(41, 30).split(",")).length; p < g; ++p)
        (y = v[p].trim()) && a.chains.push(y);
    } else if (d.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      n = dM("".concat(u), "Biomolecule ".concat(u)), o.push(n), u += 1, a = { chains: [], operators: [] }, n.groups.push(a);
      var v;
      for (p = 0, g = (v = (d = c(++l)).substr(11, 69).split(",")).length; p < g; ++p) {
        var y;
        (y = v[p].trim()) && a.chains.push(y);
      }
    }
  }
  if (o.length === 0) return [];
  for (var _ = { id: mt.ofStrings(o.map(function(H) {
    return H.id;
  })), details: mt.ofStrings(o.map(function(H) {
    return H.details;
  })) }, S = [], b = 0, x = o; b < x.length; b++) for (var A = 0, w = (P = x[b]).groups; A < w.length; A++) {
    var C = w[A];
    S.push({ assembly_id: P.id, oper_expression: C.operators.map(function(H) {
      return H.id;
    }).join(","), asym_id_list: C.chains.join(",") });
  }
  for (var M = { assembly_id: mt.ofStrings(S.map(function(H) {
    return H.assembly_id;
  })), oper_expression: mt.ofStrings(S.map(function(H) {
    return H.oper_expression;
  })), asym_id_list: mt.ofStrings(S.map(function(H) {
    return H.asym_id_list;
  })) }, T = [], N = 0, I = o; N < I.length; N++) for (var P, O = 0, F = (P = I[N]).groups; O < F.length; O++) for (var R = 0, G = F[O].operators; R < G.length; R++) {
    var L = G[R], q = { id: "" + L.id, type: "?", name: "?", symmetry_operation: "?" };
    for (l = 0; l < 3; l++) {
      for (p = 0; p < 3; p++) q["matrix[".concat(l + 1, "][").concat(p + 1, "]")] = "" + Ee.getValue(L.matrix, l, p);
      q["vector[".concat(l + 1, "]")] = "" + Ee.getValue(L.matrix, l, 3);
    }
    T.push(q);
  }
  var K = { id: mt.ofStrings(T.map(function(H) {
    return H.id;
  })), type: mt.ofStrings(T.map(function(H) {
    return H.type;
  })), name: mt.ofStrings(T.map(function(H) {
    return H.name;
  })), symmetry_operation: mt.ofStrings(T.map(function(H) {
    return H.symmetry_operation;
  })) }, X = function(H) {
    for (var W = function(te) {
      var re = "matrix[".concat(H + 1, "][").concat(te + 1, "]");
      K[re] = mt.ofStrings(T.map(function(ie) {
        return ie[re];
      }));
    }, ee = 0; ee < 3; ee++) W(ee);
    var $ = "vector[".concat(H + 1, "]");
    K[$] = mt.ofStrings(T.map(function(te) {
      return te[$];
    }));
  };
  for (l = 0; l < 3; l++) X(l);
  return [Mi.ofFields("pdbx_struct_assembly", _), Mi.ofFields("pdbx_struct_assembly_gen", M), Mi.ofFields("pdbx_struct_oper_list", K)];
}
function Sse(e, t, r) {
  for (var n, a = [], i = function(y) {
    return e.data.substring(e.indices[2 * y], e.indices[2 * y + 1]);
  }, o = t; o < r; o++) {
    var s = i(o), u = s.split(/\s+/);
    (h = parseInt(s[5]) - 1) === 0 && (n = Ee.identity(), a.push(n)), Ee.setValue(n, h, 0, parseFloat(u[2])), Ee.setValue(n, h, 1, parseFloat(u[3])), Ee.setValue(n, h, 2, parseFloat(u[4])), Ee.setValue(n, h, 3, parseFloat(u[5]));
  }
  if (a.length === 0) return [];
  for (var c = [], l = 1, d = 0, f = a; d < f.length; d++) {
    var m = f[d], h = { id: "ncsop" + l++, code: ".", details: "." };
    for (o = 0; o < 3; o++) {
      for (var p = 0; p < 3; p++) h["matrix[".concat(o + 1, "][").concat(p + 1, "]")] = "" + Ee.getValue(m, o, p);
      h["vector[".concat(o + 1, "]")] = "" + Ee.getValue(m, o, 3);
    }
    c.push(h);
  }
  var g = { id: mt.ofStrings(c.map(function(y) {
    return y.id;
  })), code: mt.ofStrings(c.map(function(y) {
    return y.code;
  })), details: mt.ofStrings(c.map(function(y) {
    return y.details;
  })) }, v = function(y) {
    for (var _ = function(x) {
      var A = "matrix[".concat(y + 1, "][").concat(x + 1, "]");
      g[A] = mt.ofStrings(c.map(function(w) {
        return w[A];
      }));
    }, S = 0; S < 3; S++) _(S);
    var b = "vector[".concat(y + 1, "]");
    g[b] = mt.ofStrings(c.map(function(x) {
      return x[b];
    }));
  };
  for (o = 0; o < 3; o++) v(o);
  return [Mi.ofFields("struct_ncs_oper", g)];
}
var Ase = { 1: "HELX_RH_AL_P", 2: "HELX_RH_OM_P", 3: "HELX_RH_PI_P", 4: "HELX_RH_GA_P", 5: "HELX_RH_3T_P", 6: "HELX_LH_AL_P", 7: "HELX_LH_OM_P", 8: "HELX_LH_GA_P", 9: "HELX_RH_27_P", 10: "HELX_RH_PP_P" };
function wse(e, t, r) {
  for (var n = [], a = function(f) {
    return e.data.substring(e.indices[2 * f], e.indices[2 * f + 1]);
  }, i = t; i < r; i++) {
    var o = a(i);
    n.push({ serNum: o.substr(7, 3).trim(), helixID: o.substr(11, 3).trim(), initResName: o.substr(15, 3).trim(), initChainID: o.substr(19, 1).trim(), initSeqNum: o.substr(21, 4).trim(), initICode: o.substr(25, 1).trim(), endResName: o.substr(27, 3).trim(), endChainID: o.substr(31, 3).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), helixClass: o.substr(38, 2).trim(), comment: o.substr(40, 30).trim(), length: o.substr(71, 5).trim() });
  }
  var s = mt.ofStrings(n.map(function(f) {
    return f.initChainID;
  })), u = mt.ofStrings(n.map(function(f) {
    return f.initResName;
  })), c = mt.ofStrings(n.map(function(f) {
    return f.endChainID;
  })), l = mt.ofStrings(n.map(function(f) {
    return f.endResName;
  })), d = { beg_label_asym_id: s, beg_label_comp_id: u, beg_label_seq_id: mt.ofUndefined(n.length, pe.Schema.int), beg_auth_asym_id: s, beg_auth_comp_id: u, beg_auth_seq_id: mt.ofStrings(n.map(function(f) {
    return f.initSeqNum;
  })), conf_type_id: mt.ofStrings(n.map(function(f) {
    return function(m) {
      return Ase[m] || "HELX_P";
    }(f.helixClass);
  })), details: mt.ofStrings(n.map(function(f) {
    return f.comment;
  })), end_label_asym_id: c, end_label_comp_id: l, end_label_seq_id: mt.ofUndefined(n.length, pe.Schema.int), end_auth_asym_id: c, end_auth_comp_id: l, end_auth_seq_id: mt.ofStrings(n.map(function(f) {
    return f.endSeqNum;
  })), id: mt.ofStrings(n.map(function(f) {
    return f.serNum;
  })), pdbx_beg_PDB_ins_code: mt.ofStrings(n.map(function(f) {
    return f.initICode;
  })), pdbx_end_PDB_ins_code: mt.ofStrings(n.map(function(f) {
    return f.endICode;
  })), pdbx_PDB_helix_class: mt.ofStrings(n.map(function(f) {
    return f.helixClass;
  })), pdbx_PDB_helix_length: mt.ofStrings(n.map(function(f) {
    return f.length;
  })), pdbx_PDB_helix_id: mt.ofStrings(n.map(function(f) {
    return f.helixID;
  })) };
  return Mi.ofFields("struct_conf", d);
}
function Cse(e, t, r) {
  for (var n = [], a = function(h) {
    return e.data.substring(e.indices[2 * h], e.indices[2 * h + 1]);
  }, i = t; i < r; i++) {
    var o = a(i);
    n.push({ strand: o.substr(7, 3).trim(), sheetID: o.substr(11, 3).trim(), numStrands: o.substr(14, 2).trim(), initResName: o.substr(17, 3).trim(), initChainID: o.substr(21, 1).trim(), initSeqNum: o.substr(22, 4).trim(), initICode: o.substr(26, 1).trim(), endResName: o.substr(28, 3).trim(), endChainID: o.substr(32, 1).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), sense: o.substr(38, 2).trim(), curAtom: o.substr(41, 4).trim(), curResName: o.substr(45, 3).trim(), curChainId: o.substr(49, 1).trim(), curResSeq: o.substr(50, 4).trim(), curICode: o.substr(54, 1).trim(), prevAtom: o.substr(56, 4).trim(), prevResName: o.substr(60, 3).trim(), prevChainId: o.substr(64, 1).trim(), prevResSeq: o.substr(65, 4).trim(), prevICode: o.substr(69, 1).trim() });
  }
  var s = mt.ofStrings(n.map(function(h) {
    return h.initChainID;
  })), u = mt.ofStrings(n.map(function(h) {
    return h.initResName;
  })), c = mt.ofStrings(n.map(function(h) {
    return h.initSeqNum;
  })), l = mt.ofStrings(n.map(function(h) {
    return h.endChainID;
  })), d = mt.ofStrings(n.map(function(h) {
    return h.endResName;
  })), f = mt.ofStrings(n.map(function(h) {
    return h.endSeqNum;
  })), m = { beg_label_asym_id: s, beg_label_comp_id: u, beg_label_seq_id: c, beg_auth_asym_id: s, beg_auth_comp_id: u, beg_auth_seq_id: c, end_label_asym_id: l, end_label_comp_id: l, end_label_seq_id: f, end_auth_asym_id: l, end_auth_comp_id: d, end_auth_seq_id: f, id: mt.ofStrings(n.map(function(h) {
    return h.strand;
  })), sheet_id: mt.ofStrings(n.map(function(h) {
    return h.sheetID;
  })), pdbx_beg_PDB_ins_code: mt.ofStrings(n.map(function(h) {
    return h.initICode;
  })), pdbx_end_PDB_ins_code: mt.ofStrings(n.map(function(h) {
    return h.endICode;
  })) };
  return Mi.ofFields("struct_sheet_range", m);
}
var Ese = { MOL_ID: "", MOLECULE: "", CHAIN: "", FRAGMENT: "", SYNONYM: "", EC: "", ENGINEERED: "", MUTATION: "", OTHER_DETAILS: "" };
function Dse(e, t, r) {
  for (var n, a = function(_) {
    return e.data.substring(e.indices[2 * _], e.indices[2 * _ + 1]);
  }, i = { chains: [], description: "" }, o = [], s = t; s < r; s++) {
    var u = a(s).substr(10, 70).trim(), c = u.indexOf(":"), l = u.substring(0, c), d = void 0;
    l in Ese ? (n = l, d = u.substring(c + 2)) : d = u, d = d.replace(/;$/, ""), n === "MOL_ID" ? (i = { chains: [], description: "" }, o.push(i)) : n === "MOLECULE" ? (i.description && (i.description += " "), i.description += d) : n === "CHAIN" && Array.prototype.push.apply(i.chains, d.split(/\s*,\s*/));
  }
  for (var f = [], m = 0, h = o; m < h.length; m++) for (var p = h[m], g = 0, v = p.chains; g < v.length; g++) {
    var y = v[g];
    f.push({ description: p.description, chains: [y] });
  }
  return f;
}
function Mse(e, t, r) {
  for (var n = function(c) {
    return e.data.substring(e.indices[2 * c], e.indices[2 * c + 1]);
  }, a = /* @__PURE__ */ new Map(), i = t; i < r; i++) {
    var o = n(i), s = o.substr(11, 3).trim(), u = o.substr(15).trim();
    a.has(s) ? a.set(s, "".concat(a.get(s), " ").concat(u)) : a.set(s, u);
  }
  return a;
}
var Ise = [/* @__PURE__ */ new Set(["CA"]), /* @__PURE__ */ new Set(["C"]), /* @__PURE__ */ new Set(["N"])], Tse = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C4'", "C4*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], Nse = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C3'", "C3*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], Pse = /* @__PURE__ */ new Set(["FMN", "NCN", "FNS", "FMA", "ATP", "ADP", "AMP", "GTP", "GDP", "GMP"]), fM = function() {
  var e = /* @__PURE__ */ new Map();
  return [{ id: "HIS", name: "HISTIDINE", type: "L-peptide linking" }, { id: "ARG", name: "ARGININE", type: "L-peptide linking" }, { id: "LYS", name: "LYSINE", type: "L-peptide linking" }, { id: "ILE", name: "ISOLEUCINE", type: "L-peptide linking" }, { id: "PHE", name: "PHENYLALANINE", type: "L-peptide linking" }, { id: "LEU", name: "LEUCINE", type: "L-peptide linking" }, { id: "TRP", name: "TRYPTOPHAN", type: "L-peptide linking" }, { id: "ALA", name: "ALANINE", type: "L-peptide linking" }, { id: "MET", name: "METHIONINE", type: "L-peptide linking" }, { id: "CYS", name: "CYSTEINE", type: "L-peptide linking" }, { id: "ASN", name: "ASPARAGINE", type: "L-peptide linking" }, { id: "VAL", name: "VALINE", type: "L-peptide linking" }, { id: "GLY", name: "GLYCINE", type: "peptide linking" }, { id: "SER", name: "SERINE", type: "L-peptide linking" }, { id: "GLN", name: "GLUTAMINE", type: "L-peptide linking" }, { id: "TYR", name: "TYROSINE", type: "L-peptide linking" }, { id: "ASP", name: "ASPARTIC ACID", type: "L-peptide linking" }, { id: "GLU", name: "GLUTAMIC ACID", type: "L-peptide linking" }, { id: "THR", name: "THREONINE", type: "L-peptide linking" }, { id: "PRO", name: "PROLINE", type: "L-peptide linking" }, { id: "SEC", name: "SELENOCYSTEINE", type: "L-peptide linking" }, { id: "PYL", name: "PYRROLYSINE", type: "L-peptide linking" }, { id: "MSE", name: "SELENOMETHIONINE", type: "L-peptide linking" }, { id: "SEP", name: "PHOSPHOSERINE", type: "L-peptide linking" }, { id: "TPO", name: "PHOSPHOTHREONINE", type: "L-peptide linking" }, { id: "PTR", name: "O-PHOSPHOTYROSINE", type: "L-peptide linking" }, { id: "PCA", name: "PYROGLUTAMIC ACID", type: "L-peptide linking" }, { id: "A", name: "ADENOSINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "C", name: "CYTIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "T", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "G", name: "GUANOSINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "I", name: "INOSINIC ACID", type: "RNA linking" }, { id: "U", name: "URIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "DA", name: "2'-DEOXYADENOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DC", name: "2'-DEOXYCYTIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DT", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DG", name: "2'-DEOXYGUANOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DI", name: "2'-DEOXYINOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DU", name: "2'-DEOXYURIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "ACE", name: "Acetylgroup", type: "peptide linking" }, { id: "NME", name: "Methylamine", type: "peptide linking" }].forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), mM = function() {
  var e = /* @__PURE__ */ new Map();
  return [{ id: "ZN2", name: "ZINC ION", type: "Ion" }, { id: "SOD", name: "SODIUM ION", type: "Ion" }, { id: "CES", name: "CESIUM ION", type: "Ion" }, { id: "CLA", name: "CHLORIDE ION", type: "Ion" }, { id: "CAL", name: "CALCIUM ION", type: "Ion" }, { id: "POT", name: "POTASSIUM ION", type: "Ion" }].forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), fm = function() {
  function e(t, r) {
    this.seqId = t, this.atomId = r, this.namesMap = /* @__PURE__ */ new Map(), this.comps = /* @__PURE__ */ new Map(), this.ids = [], this.names = [], this.types = [], this.mon_nstd_flags = [];
  }
  return e.prototype.set = function(t) {
    this.comps.set(t.id, t), this.ids.push(t.id), this.names.push(t.name), this.types.push(t.type), this.mon_nstd_flags.push(w8.has(t.id) ? "y" : "n");
  }, e.prototype.getAtomIds = function(t) {
    for (var r = /* @__PURE__ */ new Set(), n = this.seqId.value(t); t < this.seqId.rowCount && this.seqId.value(t) === n; )
      r.add(this.atomId.value(t)), t += 1;
    return r;
  }, e.prototype.hasAtomIds = function(t, r) {
    for (var n = 0, a = r.length; n < a; ++n) if (!bo.areIntersecting(t, r[n])) return !1;
    return !0;
  }, e.prototype.getType = function(t) {
    return this.hasAtomIds(t, Ise) ? "peptide linking" : this.hasAtomIds(t, Tse) ? "RNA linking" : this.hasAtomIds(t, Nse) ? "DNA linking" : "other";
  }, e.prototype.has = function(t) {
    return this.comps.has(t);
  }, e.prototype.get = function(t) {
    return this.comps.get(t);
  }, e.prototype.add = function(t, r) {
    if (!this.has(t)) if (fM.has(t)) this.set(fM.get(t));
    else if (m1.has(t)) this.set({ id: t, name: "WATER", type: "non-polymer" });
    else if (Pse.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "non-polymer" });
    else if (Fd.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "saccharide" });
    else {
      var n = this.getAtomIds(r);
      if (n.size === 1 && mM.has(t)) this.set(mM.get(t));
      else {
        var a = this.getType(n);
        this.set({ id: t, name: this.namesMap.get(t) || t, type: a });
      }
    }
    return this.get(t);
  }, e.prototype.getChemCompTable = function() {
    return Yr.ofPartialColumns(Go.chem_comp, { id: pe.ofStringArray(this.ids), name: pe.ofStringArray(this.names), type: pe.ofStringAliasArray(this.types), mon_nstd_flag: pe.ofStringAliasArray(this.mon_nstd_flags) }, this.ids.length);
  }, e.prototype.setNames = function(t) {
    var r = this;
    t.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, e;
}(), mm = function() {
  function e() {
    this.count = 0, this.ids = [], this.types = [], this.descriptions = [], this.compoundsMap = /* @__PURE__ */ new Map(), this.namesMap = /* @__PURE__ */ new Map(), this.heteroMap = /* @__PURE__ */ new Map(), this.chainMap = /* @__PURE__ */ new Map();
  }
  return e.prototype.set = function(t, r) {
    this.count += 1, this.ids.push("".concat(this.count)), this.types.push(t), this.descriptions.push([r]);
  }, e.prototype.getEntityId = function(t, r, n, a) {
    return r === 2 ? (this.waterId === void 0 && (this.set("water", (a == null ? void 0 : a.customName) || "Water"), this.waterId = "".concat(this.count)), this.waterId) : C8(r) ? this.compoundsMap.has(n) ? this.compoundsMap.get(n) : (this.chainMap.has(n) || (this.set("polymer", (a == null ? void 0 : a.customName) || "Polymer ".concat(this.chainMap.size + 1)), this.chainMap.set(n, "".concat(this.count))), this.chainMap.get(n)) : (this.heteroMap.has(t) || (this.set("non-polymer", (a == null ? void 0 : a.customName) || this.namesMap.get(t) || t), this.heteroMap.set(t, "".concat(this.count))), this.heteroMap.get(t));
  }, e.prototype.getEntityTable = function() {
    return Yr.ofPartialColumns(Go.entity, { id: pe.ofStringArray(this.ids), type: pe.ofStringAliasArray(this.types), pdbx_description: pe.ofStringListArray(this.descriptions) }, this.count);
  }, e.prototype.setCompounds = function(t) {
    for (var r = 0, n = t.length; r < n; ++r) {
      var a = t[r], i = a.chains, o = a.description;
      this.set("polymer", o);
      for (var s = 0, u = i.length; s < u; ++s) this.compoundsMap.set(i[s], "".concat(this.count));
    }
  }, e.prototype.setNames = function(t) {
    var r = this;
    t.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, e;
}();
function Cy(e, t, r, n) {
  for (var a = r, i = n - 1, o = t.charCodeAt(a); (o === 32 || o >= 48 && o <= 57) && a <= i; ) o = t.charCodeAt(++a);
  for (o = t.charCodeAt(i); (o === 32 || o >= 48 && o <= 57) && i >= a; ) o = t.charCodeAt(--i);
  if (a === ++i || a + 1 === i) return pt.add(e, a, i);
  if (o = t.charCodeAt(a), a + 2 === i) {
    var s = t.charCodeAt(a + 1);
    if (!((o !== 78 && o !== 110 || s !== 65 && s !== 97) && (o !== 67 && o !== 99 || s !== 76 && s !== 108) && (o !== 70 && o !== 102 || s !== 69 && s !== 101) && (o !== 83 && o !== 115 || s !== 73 && s !== 105) && (o !== 66 && o !== 98 || s !== 82 && s !== 114) && (o !== 65 && o !== 97 || s !== 83 && s !== 115))) return pt.add(e, a, a + 2);
  }
  if (o === 67 || o === 99 || o === 72 || o === 104 || o === 78 || o === 110 || o === 79 || o === 111 || o === 80 || o === 112 || o === 83 || o === 115) return pt.add(e, a, a + 1);
  pt.add(e, a, a);
}
var i_, Bse = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), Ose = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), Fse = /^[\s\d]+|[\s\d]+$/g;
function J8(e, t) {
  var r = (e = e.replace(Fse, "").toUpperCase()).length;
  if (r === 0 || r === 1 || Bse.has(e)) return e;
  if (r === 3 && t === e) {
    if (e === "SOD") return "NA";
    if (e === "POT") return "K";
    if (e === "CES") return "CS";
    if (e === "CAL") return "CA";
    if (e === "CLA") return "CL";
  }
  return Ose.has(e[0]) ? e[0] : e;
}
function pM(e, t, r, n, a, i) {
  var o = r.data, s = a - n;
  pt.addToken(e.group_PDB, ft.trim(r, n, n + 6)), ft.trim(r, n + 6, n + 11), e.id[e.index] = r.data.substring(r.tokenStart, r.tokenEnd), pt.addToken(e.auth_atom_id, ft.trim(r, n + 12, n + 16)), o.charCodeAt(n + 16) === 32 ? pt.add(e.label_alt_id, 0, 0) : pt.add(e.label_alt_id, n + 16, n + 17), pt.addToken(e.auth_comp_id, ft.trim(r, n + 17, n + 20)), pt.add(e.auth_asym_id, n + 21, n + 22), pt.addToken(e.auth_seq_id, ft.trim(r, n + 22, n + 26)), o.charCodeAt(n + 26) === 32 ? pt.add(e.pdbx_PDB_ins_code, 0, 0) : pt.add(e.pdbx_PDB_ins_code, n + 26, n + 27), pt.addToken(e.Cartn_x, ft.trim(r, n + 30, n + 38)), pt.addToken(e.Cartn_y, ft.trim(r, n + 38, n + 46)), pt.addToken(e.Cartn_z, ft.trim(r, n + 46, n + 54)), pt.addToken(e.occupancy, ft.trim(r, n + 54, n + 60)), s >= 66 ? pt.addToken(e.B_iso_or_equiv, ft.trim(r, n + 60, n + 66)) : pt.add(e.B_iso_or_equiv, 0, 0), i && pt.addToken(e.partial_charge, ft.trim(r, n + 70, n + 76)), s >= 78 && !i ? (ft.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? pt.addToken(e.type_symbol, r) : Cy(e.type_symbol, o, n + 12, n + 16)) : Cy(e.type_symbol, o, n + 12, n + 16), s >= 82 && pt.addToken(e.pdbx_formal_charge, ft.trim(r, n + 78, n + 82)), s >= 84 && pt.addToken(e.cdr, ft.trim(r, n + 82, n + 84)), s >= 90 && pt.addToken(e.em_confidence, ft.trim(r, n + 84, n + 90)), e.pdbx_PDB_model_num[e.index] = t, e.index++;
}
function Rse(e) {
  var t = mt.ofTokens(e.pdbx_auth_seq_id), r = mt.ofTokens(e.pdbx_auth_comp_id), n = mt.ofTokens(e.pdbx_auth_asym_id), a = mt.ofTokens(e.pdbx_auth_atom_id), i = { id: mt.ofStrings(e.id), type_symbol: mt.ofTokens(e.type_symbol), pdbx_label_atom_id: a, pdbx_label_alt_id: mt.ofTokens(e.pdbx_label_alt_id), pdbx_label_comp_id: r, pdbx_label_asym_id: n, pdbx_label_seq_id: t, pdbx_PDB_ins_code: mt.ofTokens(e.pdbx_PDB_ins_code), pdbx_auth_seq_id: t, pdbx_auth_comp_id: r, pdbx_auth_asym_id: n, pdbx_auth_atom_id: a };
  return i["U[1][1]"] = mt.ofNumbers(e["U[1][1]"]), i["U[2][2]"] = mt.ofNumbers(e["U[2][2]"]), i["U[3][3]"] = mt.ofNumbers(e["U[3][3]"]), i["U[1][2]"] = mt.ofNumbers(e["U[1][2]"]), i["U[1][3]"] = mt.ofNumbers(e["U[1][3]"]), i["U[2][3]"] = mt.ofNumbers(e["U[2][3]"]), i;
}
function Lse(e, t, r, n, a) {
  var i = r.data, o = a - n;
  ft.trim(r, n + 6, n + 11), e.id[e.index] = i.substring(r.tokenStart, r.tokenEnd), pt.addToken(e.pdbx_auth_atom_id, ft.trim(r, n + 12, n + 16)), i.charCodeAt(n + 16) === 32 ? pt.add(e.pdbx_label_alt_id, 0, 0) : pt.add(e.pdbx_label_alt_id, n + 16, n + 17), pt.addToken(e.pdbx_auth_comp_id, ft.trim(r, n + 17, n + 20)), pt.add(e.pdbx_auth_asym_id, n + 21, n + 22), pt.addToken(e.pdbx_auth_seq_id, ft.trim(r, n + 22, n + 26)), i.charCodeAt(n + 26) === 32 ? pt.add(e.pdbx_PDB_ins_code, 0, 0) : pt.add(e.pdbx_PDB_ins_code, n + 26, n + 27), e["U[1][1]"][e.index] = Pf(i, n + 28, n + 35) / 1e4, e["U[2][2]"][e.index] = Pf(i, n + 35, n + 42) / 1e4, e["U[3][3]"][e.index] = Pf(i, n + 42, n + 49) / 1e4, e["U[1][2]"][e.index] = Pf(i, n + 49, n + 56) / 1e4, e["U[1][3]"][e.index] = Pf(i, n + 56, n + 63) / 1e4, e["U[2][3]"][e.index] = Pf(i, n + 63, n + 70) / 1e4, o >= 78 ? (ft.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? pt.addToken(e.type_symbol, r) : Cy(e.type_symbol, i, n + 12, n + 16)) : Cy(e.type_symbol, i, n + 12, n + 16), e.index++;
}
function kse(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R;
    return Te(this, function(G) {
      for (t = e.lines, r = t.data, n = t.indices, a = ft(r), i = !!e.isPdbqt, o = 0, s = 0, C = 0, g = t.count; C < g; C++) switch (v = n[2 * C], y = n[2 * C + 1], r[v]) {
        case "A":
          fa(r, v, y, "ATOM  ") ? o++ : fa(r, v, y, "ANISOU") && s++;
          break;
        case "H":
          fa(r, v, y, "HETATM") && o++;
      }
      for (u = function(H, W) {
        var ee = function() {
          return pt.create(H, 2 * W);
        };
        return { index: 0, group_PDB: ee(), id: [], auth_atom_id: ee(), label_alt_id: ee(), auth_comp_id: ee(), auth_asym_id: ee(), auth_seq_id: ee(), pdbx_PDB_ins_code: ee(), Cartn_x: ee(), Cartn_y: ee(), Cartn_z: ee(), occupancy: ee(), B_iso_or_equiv: ee(), type_symbol: ee(), pdbx_PDB_model_num: [], label_entity_id: [], partial_charge: ee(), pdbx_formal_charge: ee(), cdr: ee(), em_confidence: ee() };
      }(r, o), c = function(H, W) {
        var ee = function() {
          return new Float32Array(W);
        }, $ = function() {
          return pt.create(H, 2 * W);
        };
        return { index: 0, count: W, id: [], type_symbol: $(), pdbx_label_atom_id: $(), pdbx_label_alt_id: $(), pdbx_label_comp_id: $(), pdbx_label_asym_id: $(), pdbx_label_seq_id: $(), pdbx_PDB_ins_code: $(), "U[1][1]": ee(), "U[2][2]": ee(), "U[3][3]": ee(), "U[1][2]": ee(), "U[1][3]": ee(), "U[2][3]": ee(), pdbx_auth_seq_id: $(), pdbx_auth_comp_id: $(), pdbx_auth_asym_id: $(), pdbx_auth_atom_id: $() };
      }(r, s), l = new mm(), d = [], f = [], m = 0, h = "", p = void 0, C = 0, g = t.count; C < g; C++) switch (v = n[2 * C], y = n[2 * C + 1], r[v]) {
        case "A":
          fa(r, v, y, "ATOM  ") ? (m || (m++, h = "" + m), pM(u, h, a, v, y, i)) : fa(r, v, y, "ANISOU") && Lse(c, 0, a, v, y);
          break;
        case "C":
          if (fa(r, v, y, "CRYST1")) d.push.apply(d, xse(e.id || "?", r.substring(v, y)));
          else if (fa(r, v, y, "CONECT")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "CONECT"); ) _++;
            p ? zr && console.log("only single CONECT block allowed, ignoring others") : p = [C, _], C = _ - 1;
          } else if (fa(r, v, y, "COMPND")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "COMPND"); ) _++;
            l.setCompounds(Dse(t, C, _)), C = _ - 1;
          }
          break;
        case "H":
          if (fa(r, v, y, "HETATM")) m || (m++, h = "" + m), pM(u, h, a, v, y, i);
          else if (fa(r, v, y, "HELIX")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "HELIX"); ) _++;
            d.push(wse(t, C, _)), C = _ - 1;
          } else if (fa(r, v, y, "HETNAM")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "HETNAM"); ) _++;
            f.push.apply(f, Array.from(Mse(t, C, _).entries())), C = _ - 1;
          }
          break;
        case "M":
          if (fa(r, v, y, "MODEL ") && (m++, h = "" + m), fa(r, v, y, "MTRIX")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "MTRIX"); ) _++;
            d.push.apply(d, Sse(t, C, _)), C = _ - 1;
          }
          break;
        case "O":
          break;
        case "R":
          if (fa(r, v, y, "REMARK 350")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "REMARK 350"); ) _++;
            d.push.apply(d, _se(t, C, _)), C = _ - 1;
          }
          break;
        case "S":
          if (fa(r, v, y, "SHEET")) {
            for (_ = C + 1; v = n[2 * _], y = n[2 * _ + 1], fa(r, v, y, "SHEET"); ) _++;
            d.push(Cse(t, C, _)), C = _ - 1;
          }
      }
      for (S = pe.ofIntTokens(u.auth_seq_id), b = pe.ofStringTokens(u.auth_atom_id), x = pe.ofStringTokens(u.auth_comp_id), A = pe.ofStringTokens(u.auth_asym_id), (w = new fm(S, b)).setNames(f), l.setNames(f), C = 0, M = x.rowCount; C < M; ++C) T = x.value(C), N = Fh(w.add(T, C).type, T), u.label_entity_id[C] = l.getEntityId(T, N, A.value(C));
      var L, q, K, X;
      for (L = u, q = mt.ofTokens(L.auth_asym_id), K = mt.ofTokens(L.auth_atom_id), X = mt.ofTokens(L.auth_comp_id), I = { auth_asym_id: q, auth_atom_id: K, auth_comp_id: X, auth_seq_id: mt.ofTokens(L.auth_seq_id), B_iso_or_equiv: mt.ofTokens(L.B_iso_or_equiv), Cartn_x: mt.ofTokens(L.Cartn_x), Cartn_y: mt.ofTokens(L.Cartn_y), Cartn_z: mt.ofTokens(L.Cartn_z), group_PDB: mt.ofTokens(L.group_PDB), id: mt.ofStrings(L.id), label_alt_id: mt.ofTokens(L.label_alt_id), label_asym_id: q, label_atom_id: K, label_comp_id: X, label_seq_id: mt.ofUndefined(L.index, pe.Schema.int), label_entity_id: mt.ofStrings(L.label_entity_id), occupancy: bJ(L.occupancy) ? mt.ofUndefined(L.index, pe.Schema.float) : mt.ofTokens(L.occupancy), type_symbol: mt.ofTokens(L.type_symbol), pdbx_PDB_ins_code: mt.ofTokens(L.pdbx_PDB_ins_code), pdbx_PDB_model_num: mt.ofStrings(L.pdbx_PDB_model_num), partial_charge: mt.ofTokens(L.partial_charge), pdbx_formal_charge: mt.ofTokens(L.pdbx_formal_charge), cdr: mt.ofTokens(L.cdr), em_confidence: mt.ofTokens(L.em_confidence) }, p && d.push(function(H, W, ee, $) {
        for (var te = {}, re = 0, ie = $.id.rowCount; re < ie; ++re) te[$.id.str(re)] = re;
        var oe = function(Ue) {
          return H.data.substring(H.indices[2 * Ue], H.indices[2 * Ue + 1]);
        }, se = [], he = [], ge = [], De = [], ae = [], ce = [], _e = [], le = [], ue = [], be = [], Se = [11, 16, 21, 26], Ne = 1;
        for (re = W; re < ee; re++) {
          var J = oe(re), Z = te[parseInt(J.substr(6, 5))], de = {};
          if (Z !== void 0) for (var ye = 0; ye < 4; ++ye) {
            var Ae = parseInt(J.substr(Se[ye], 5));
            if (!Number.isNaN(Ae)) {
              var Ce = te[Ae];
              Ce !== void 0 && (Z > Ce || de[Ce] === void 0 && (se.push("covale".concat(Ne)), he.push("covale"), ge.push($.label_asym_id.str(Z)), ae.push($.auth_seq_id.int(Z)), De.push($.label_seq_id.int(Z)), ce.push($.label_atom_id.str(Z)), _e.push($.label_asym_id.str(Ce)), ue.push($.auth_seq_id.int(Ce)), le.push($.label_seq_id.int(Ce)), be.push($.label_atom_id.str(Ce)), Ne += 1));
            }
          }
        }
        var Ie = { id: mt.ofStrings(se), conn_type_id: mt.ofStrings(he), ptnr1_label_asym_id: mt.ofStrings(ge), ptnr1_auth_seq_id: mt.ofNumbers(ae), ptnr1_label_seq_id: mt.ofNumbers(De), ptnr1_label_atom_id: mt.ofStrings(ce), ptnr2_label_asym_id: mt.ofStrings(_e), ptnr2_label_seq_id: mt.ofNumbers(le), ptnr2_auth_seq_id: mt.ofNumbers(ue), ptnr2_label_atom_id: mt.ofStrings(be) };
        return Mi.ofFields("struct_conn", Ie);
      }(t, p[0], p[1], I)), P = { entity: Mi.ofTable("entity", l.getEntityTable()), chem_comp: Mi.ofTable("chem_comp", w.getChemCompTable()), atom_site: Mi.ofFields("atom_site", I), atom_site_anisotrop: Mi.ofFields("atom_site_anisotrop", Rse(c)) }, O = 0, F = d; O < F.length; O++) R = F[O], P[R.name] = R;
      return [2, { header: e.id || "PDB", categoryNames: Object.keys(P), categories: P }];
    });
  });
}
function FL(e) {
  var t = this;
  return sr.create("Parse PDB", function(r) {
    return Be(t, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f, m;
      return Te(this, function(h) {
        switch (h.label) {
          case 0:
            return [4, r.update("Converting to mmCIF")];
          case 1:
            return h.sent(), [4, kse(e)];
          case 2:
            return n = h.sent(), a = Dn.fromFrame(n, void 0, i_.create(e)), [4, bl(Zd(a.data.db, !0), a, r)];
          case 3:
            return i = h.sent(), (o = (m = n.categories.atom_site) === null || m === void 0 ? void 0 : m.getField("partial_charge")) && i.frameCount === 1 && (s = i.representative, u = s.atomicHierarchy.atomSourceIndex, c = pe.isIdentity(u), l = c ? void 0 : u.toArray({ array: Int32Array }), d = o.toFloatArray(), f = l ? pe.ofFloatArray(pe.mapToArray(u, function(p) {
              return d[p];
            }, Float32Array)) : pe.ofFloatArray(d), dl.Provider.set(s, { data: f, type: "GASTEIGER" })), [2, i];
        }
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "pdb";
  }, e.create = function(t) {
    return { kind: "pdb", name: t.id || "", data: t };
  };
})(i_ || (i_ = {}));
var o_, zse = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, OL(e).run()] : [2, [vc()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, FL(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return st.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function Use(e) {
  switch (e) {
    case 7:
      return -3;
    case 6:
      return -2;
    case 5:
      return -1;
    case 0:
    case 4:
      return 0;
    case 3:
      return 1;
    case 2:
      return 2;
    case 1:
      return 3;
    default:
      return console.error("Value ".concat(e, " is outside the 0-7 range, defaulting to 0.")), 0;
  }
}
function eS(e, t) {
  for (var r = pt.create(e.data, 2 * t), n = pt.create(e.data, 2 * t), a = pt.create(e.data, 2 * t), i = pt.create(e.data, 2 * t), o = pt.create(e.data, 2 * t), s = 0; s < t; ++s) {
    ft.markLine(e);
    var u = e.tokenStart, c = e.position;
    ft.trim(e, u, u + 10), pt.addUnchecked(r, e.tokenStart, e.tokenEnd), ft.trim(e, u + 10, u + 20), pt.addUnchecked(n, e.tokenStart, e.tokenEnd), ft.trim(e, u + 20, u + 30), pt.addUnchecked(a, e.tokenStart, e.tokenEnd), ft.trim(e, u + 31, u + 34), pt.addUnchecked(i, e.tokenStart, e.tokenEnd), ft.trim(e, u + 36, u + 39), pt.addUnchecked(o, e.tokenStart, e.tokenEnd), e.position = c;
  }
  return { count: t, x: tn(r)(pe.Schema.float), y: tn(n)(pe.Schema.float), z: tn(a)(pe.Schema.float), type_symbol: tn(i)(pe.Schema.str), formal_charge: tn(o)(pe.Schema.int) };
}
function tS(e, t) {
  for (var r = pt.create(e.data, 2 * t), n = pt.create(e.data, 2 * t), a = pt.create(e.data, 2 * t), i = 0; i < t; ++i) {
    ft.markLine(e);
    var o = e.tokenStart, s = e.position;
    ft.trim(e, o, o + 3), pt.addUnchecked(r, e.tokenStart, e.tokenEnd), ft.trim(e, o + 3, o + 6), pt.addUnchecked(n, e.tokenStart, e.tokenEnd), ft.trim(e, o + 6, o + 9), pt.addUnchecked(a, e.tokenStart, e.tokenEnd), e.position = s;
  }
  return { count: t, atomIdxA: tn(r)(pe.Schema.int), atomIdxB: tn(n)(pe.Schema.int), order: tn(a)(pe.Schema.int) };
}
function Gse(e, t, r) {
  ft.trim(e, t + 6, t + 9);
  for (var n = parseInt(ft.getTokenString(e)), a = 0; a < n; ++a) {
    var i = 9 + 8 * a;
    ft.trim(e, t + i, t + i + 4);
    var o = ft.getTokenString(e);
    r.atomIdx.push(+o), ft.trim(e, t + i + 4, t + i + 8);
    var s = ft.getTokenString(e);
    r.charge.push(+s);
  }
  ft.eatLine(e);
}
function rS(e) {
  for (var t = { atomIdx: [], charge: [] }; e.position < e.length; ) {
    var r = e.position;
    ft.trim(e, r + 3, r + 6);
    var n = ft.getTokenString(e);
    if (n === "END") break;
    ft.eatLine(e), n === "CHG" && Gse(e, r, t);
  }
  return { atomIdx: pe.ofIntArray(t.atomIdx), charge: pe.ofIntArray(t.charge) };
}
function Vse(e) {
  var t = ft(e), r = ft.readLine(t).trim(), n = ft.readLine(t).trim(), a = ft.readLine(t).trim(), i = ft.readLine(t), o = +i.substr(0, 3), s = +i.substr(3, 3), u = { title: r, program: n, comment: a, atoms: eS(t, o), bonds: tS(t, s), formalCharges: rS(t) };
  return za.success(u);
}
function qse(e) {
  var t = this;
  return sr.create("Parse Mol", function() {
    return Be(t, 0, void 0, function() {
      return Te(this, function(r) {
        return [2, Vse(e)];
      });
    });
  });
}
function RL(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _;
    return Te(this, function(S) {
      switch (S.label) {
        case 0:
          if (n = e.atoms, a = e.bonds, i = e.formalCharges, o = pe.ofConst("MOL", e.atoms.count, pe.Schema.str), s = pe.ofConst("A", e.atoms.count, pe.Schema.str), u = pe.asArrayColumn(n.type_symbol), c = pe.ofConst(1, n.count, pe.Schema.int), l = new Int32Array(e.atoms.count), i.atomIdx.rowCount > 0) for (d = 0; d < i.atomIdx.rowCount; d++) l[i.atomIdx.value(d) - 1] = i.charge.value(d);
          else for (d = 0; d < e.atoms.count; d++) l[d] = Use(n.formal_charge.value(d));
          return f = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: s, auth_atom_id: u, auth_comp_id: o, auth_seq_id: c, Cartn_x: pe.asArrayColumn(n.x, Float32Array), Cartn_y: pe.asArrayColumn(n.y, Float32Array), Cartn_z: pe.asArrayColumn(n.z, Float32Array), id: pe.range(0, n.count - 1), label_asym_id: s, label_atom_id: u, label_comp_id: o, label_seq_id: c, label_entity_id: pe.ofConst("1", n.count, pe.Schema.str), occupancy: pe.ofConst(1, n.count, pe.Schema.float), type_symbol: u, pdbx_PDB_model_num: pe.ofConst(1, n.count, pe.Schema.int), pdbx_formal_charge: pe.ofIntArray(l) }, n.count), (m = new mm()).setNames([["MOL", "Ligand"]]), m.getEntityId("MOL", 0, "A"), (h = new fm(c, u)).setNames([["MOL", "Unknown Molecule"]]), h.add("MOL", 0), [4, bl(Zd({ entity: m.getEntityTable(), chem_comp: h.getChemCompTable(), atom_site: f }), t ?? o_.create(e), r)];
        case 1:
          return (p = S.sent()).frameCount > 0 && (g = pe.ofIntArray(pe.mapToArray(a.atomIdxA, function(b) {
            return b - 1;
          }, Int32Array)), v = pe.ofIntArray(pe.mapToArray(a.atomIdxB, function(b) {
            return b - 1;
          }, Int32Array)), y = pe.asArrayColumn(a.order, Int32Array), _ = Ra.fromData({ pairs: { indexA: g, indexB: v, order: y }, count: n.count }), Ra.Provider.set(p.representative, _)), [2, p];
      }
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mol";
  }, e.create = function(t) {
    return { kind: "mol", name: t.title, data: t };
  };
})(o_ || (o_ = {}));
var Hse = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, qse(e).run()] : [2, [vc()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, (a = t.result, sr.create("Parse MOL", function(i) {
            return RL(a, void 0, i);
          })).run()];
        case 2:
          return r = n.sent(), [2, [st.ofModel(r.representative)]];
      }
      var a;
    });
  });
} };
function zc(e) {
  ft.skipWhitespace(e), ft.eatValue(e);
}
function Uc(e, t) {
  var r = e.position;
  ft.skipWhitespace(e), ft.eatValue(e), ft.trim(e, r, e.position), pt.addUnchecked(t, e.tokenStart, e.tokenEnd);
}
var s_, Gx = "$$$$";
function Kse(e) {
  var t = ft.readLine(e).trim(), r = ft.readLine(e).trim(), n = ft.readLine(e).trim(), a = ft.readLine(e), i = a.trim().endsWith("V3000"), o = i ? function(h) {
    var p = pt.create(h.data, 1), g = pt.create(h.data, 1);
    return ft.eatLine(h), zc(h), zc(h), zc(h), Uc(h, p), Uc(h, g), ft.eatLine(h), { atomCount: tn(p)(pe.Schema.int).value(0), bondCount: tn(g)(pe.Schema.int).value(0) };
  }(e) : function(h) {
    return { atomCount: +h.substr(0, 3), bondCount: +h.substr(3, 3) };
  }(a), s = o.atomCount, u = o.bondCount;
  if (!Number.isNaN(s) && !Number.isNaN(u)) {
    var c = { atomIdx: pe.ofConst(0, s, pe.Schema.int), charge: pe.ofConst(0, s, pe.Schema.int) }, l = i ? function(h, p) {
      for (var g = pt.create(h.data, 2 * p), v = pt.create(h.data, 2 * p), y = pt.create(h.data, 2 * p), _ = pt.create(h.data, 2 * p), S = 0; S < p; ++S) {
        ft.markLine(h), zc(h), zc(h), zc(h);
        var b = h.position;
        Uc(h, _), Uc(h, g), Uc(h, v), Uc(h, y), h.position = b;
      }
      return ft.eatLine(h), ft.eatLine(h), { count: p, x: tn(g)(pe.Schema.float), y: tn(v)(pe.Schema.float), z: tn(y)(pe.Schema.float), type_symbol: tn(_)(pe.Schema.str), formal_charge: pe.ofConst(0, p, pe.Schema.int) };
    }(e, s) : eS(e, s), d = i ? function(h, p) {
      for (var g = pt.create(h.data, 2 * p), v = pt.create(h.data, 2 * p), y = pt.create(h.data, 2 * p), _ = 0; _ < p; ++_) {
        ft.markLine(h), zc(h), zc(h), zc(h);
        var S = h.position;
        Uc(h, y), Uc(h, g), Uc(h, v), h.position = S;
      }
      return ft.eatLine(h), ft.eatLine(h), { count: p, atomIdxA: tn(g)(pe.Schema.float), atomIdxB: tn(v)(pe.Schema.float), order: tn(y)(pe.Schema.float) };
    }(e, u) : tS(e, u), f = i ? c : rS(e), m = function(h) {
      for (var p = pt.create(h.data, 32), g = pt.create(h.data, 32); h.position < h.length; ) {
        var v = ft.readLine(h);
        if (v.startsWith(Gx)) break;
        if (v && v.startsWith("> ")) {
          pt.add(p, h.tokenStart + 2, h.tokenEnd), ft.markLine(h);
          for (var y = h.tokenStart, _ = h.tokenEnd, S = !1; h.position < h.length; ) {
            var b = ft.readLine(h);
            if (!b || b.startsWith(Gx) || b.startsWith("> ")) {
              pt.add(g, y, _), S = !0;
              break;
            }
            _ = h.tokenEnd;
          }
          S || pt.add(g, y, _);
        }
      }
      return { dataHeader: tn(p)(pe.Schema.str), data: tn(g)(pe.Schema.str) };
    }(e);
    return { molFile: { title: t, program: r, comment: n, atoms: l, bonds: d, formalCharges: f }, dataItems: m };
  }
  for (; e.position < e.length && !ft.readLine(e).startsWith(Gx); )
    ;
}
function Xse(e) {
  for (var t = ft(e), r = []; t.position < t.length; ) {
    var n = Kse(t);
    n && r.push(n);
  }
  return za.success({ compounds: r });
}
function jse(e) {
  var t = this;
  return sr.create("Parse Sdf", function() {
    return Be(t, 0, void 0, function() {
      return Te(this, function(r) {
        return [2, Xse(e)];
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "sdf";
  }, e.create = function(t) {
    return { kind: "sdf", name: t.molFile.title, data: t };
  };
})(s_ || (s_ = {}));
var Vx, th, Zf = {};
Vx = Zf, function() {
  var e = { not_string: /[^s]/, not_bool: /[^t]/, not_type: /[^T]/, not_primitive: /[^v]/, number: /[diefg]/, numeric_arg: /[bcdiefguxX]/, json: /[j]/, not_json: /[^j]/, text: /^[^\x25]+/, modulo: /^\x25{2}/, placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, key: /^([a-z_][a-z_\d]*)/i, key_access: /^\.([a-z_][a-z_\d]*)/i, index_access: /^\[(\d+)\]/, sign: /^[+-]/ };
  function t(a) {
    return function(i, o) {
      var s, u, c, l, d, f, m, h, p, g = 1, v = i.length, y = "";
      for (u = 0; u < v; u++) if (typeof i[u] == "string") y += i[u];
      else if (typeof i[u] == "object") {
        if ((l = i[u]).keys) for (s = o[g], c = 0; c < l.keys.length; c++) {
          if (s == null) throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"', l.keys[c], l.keys[c - 1]));
          s = s[l.keys[c]];
        }
        else s = l.param_no ? o[l.param_no] : o[g++];
        if (e.not_type.test(l.type) && e.not_primitive.test(l.type) && s instanceof Function && (s = s()), e.numeric_arg.test(l.type) && typeof s != "number" && isNaN(s)) throw new TypeError(t("[sprintf] expecting number but found %T", s));
        switch (e.number.test(l.type) && (h = s >= 0), l.type) {
          case "b":
            s = parseInt(s, 10).toString(2);
            break;
          case "c":
            s = String.fromCharCode(parseInt(s, 10));
            break;
          case "d":
          case "i":
            s = parseInt(s, 10);
            break;
          case "j":
            s = JSON.stringify(s, null, l.width ? parseInt(l.width) : 0);
            break;
          case "e":
            s = l.precision ? parseFloat(s).toExponential(l.precision) : parseFloat(s).toExponential();
            break;
          case "f":
            s = l.precision ? parseFloat(s).toFixed(l.precision) : parseFloat(s);
            break;
          case "g":
            s = l.precision ? String(Number(s.toPrecision(l.precision))) : parseFloat(s);
            break;
          case "o":
            s = (parseInt(s, 10) >>> 0).toString(8);
            break;
          case "s":
            s = String(s), s = l.precision ? s.substring(0, l.precision) : s;
            break;
          case "t":
            s = String(!!s), s = l.precision ? s.substring(0, l.precision) : s;
            break;
          case "T":
            s = Object.prototype.toString.call(s).slice(8, -1).toLowerCase(), s = l.precision ? s.substring(0, l.precision) : s;
            break;
          case "u":
            s = parseInt(s, 10) >>> 0;
            break;
          case "v":
            s = s.valueOf(), s = l.precision ? s.substring(0, l.precision) : s;
            break;
          case "x":
            s = (parseInt(s, 10) >>> 0).toString(16);
            break;
          case "X":
            s = (parseInt(s, 10) >>> 0).toString(16).toUpperCase();
        }
        e.json.test(l.type) ? y += s : (!e.number.test(l.type) || h && !l.sign ? p = "" : (p = h ? "+" : "-", s = s.toString().replace(e.sign, "")), f = l.pad_char ? l.pad_char === "0" ? "0" : l.pad_char.charAt(1) : " ", m = l.width - (p + s).length, d = l.width && m > 0 ? f.repeat(m) : "", y += l.align ? p + s + d : f === "0" ? p + d + s : d + p + s);
      }
      return y;
    }(function(i) {
      if (n[i]) return n[i];
      for (var o, s = i, u = [], c = 0; s; ) {
        if ((o = e.text.exec(s)) !== null) u.push(o[0]);
        else if ((o = e.modulo.exec(s)) !== null) u.push("%");
        else {
          if ((o = e.placeholder.exec(s)) === null) throw new SyntaxError("[sprintf] unexpected placeholder");
          if (o[2]) {
            c |= 1;
            var l = [], d = o[2], f = [];
            if ((f = e.key.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
            for (l.push(f[1]); (d = d.substring(f[0].length)) !== ""; ) if ((f = e.key_access.exec(d)) !== null) l.push(f[1]);
            else {
              if ((f = e.index_access.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
              l.push(f[1]);
            }
            o[2] = l;
          } else c |= 2;
          if (c === 3) throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
          u.push({ placeholder: o[0], param_no: o[1], keys: o[2], sign: o[3], pad_char: o[4], align: o[5], width: o[6], precision: o[7], type: o[8] });
        }
        s = s.substring(o[0].length);
      }
      return n[i] = u;
    }(a), arguments);
  }
  function r(a, i) {
    return t.apply(null, [a].concat(i || []));
  }
  var n = /* @__PURE__ */ Object.create(null);
  Vx.sprintf = t, Vx.vsprintf = r, typeof window < "u" && (window.sprintf = t, window.vsprintf = r);
}(), function(e) {
  e.PDB = "chemical/pdb", e.SDF = "chemical/x-mdl-sdf", e.MOL = "chemical/x-mdl-molfile", e.MOL2 = "chemical/x-mol2";
}(th || (th = {}));
var Yse = ["HEADER", "SOURCE", "AUTHOR", "OBSLTE", "KEYWDS", "REVDAT", "TITLE", "EXPDTA", "SPRSDE", "SPLT", "NUMMDL", "JRNL", "CAVEAT", "MDLTYP", "REMARKS", "COMPND"], Wse = ["DBREF", "DBREF1", "DBREF2", "SEQADV", "SEQRES", "MODRES"], Zse = ["HET   ", "HETNAM", "HETSYN", "FORMUL"], nS = function(e, t) {
  var r = ps(e);
  return (r == null ? void 0 : r.sourceData.kind) === "mmCIF" ? r.sourceData.data.source.data.lines.data.split(`
`).filter(function(n) {
    for (var a = 0, i = t.length; a < i; a++) if (n.startsWith(t[a])) return !0;
    return !1;
  }) : [];
};
function aS(e, t, r, n) {
  var a, i = [];
  if (((a = e.models[0]) === null || a === void 0 ? void 0 : a.sourceData.kind) === "mmCIF") {
    var o = nt(nt(nt([], Yse, !0), Wse, !0), Zse, !0);
    i.push.apply(i, nS(e, o));
  }
  var s = [];
  t ? s.push.apply(s, nt([], t, !0).sort(function(p, g) {
    return p - g;
  })) : e.units.forEach(function(p) {
    return s.push.apply(s, nt([], p.elements, !0));
  });
  var u = e.units[0], c = [], l = !1, d = !1;
  if (s.forEach(function(p) {
    var g = { elementId: p, group_PDB: u.model.atomicHierarchy.residues.group_PDB.value(u.residueIndex[p]), atom_id: u.model.atomicConformation.atomId.value(p), auth_atom_id: u.model.atomicHierarchy.atoms.auth_atom_id.value(p), label_alt_id: u.model.atomicHierarchy.atoms.label_alt_id.value(p), auth_comp_id: u.model.atomicHierarchy.atoms.label_comp_id.value(p), auth_asym_id: u.model.atomicHierarchy.chains.auth_asym_id.value(u.chainIndex[p]), auth_seq_id: u.model.atomicHierarchy.residues.auth_seq_id.value(u.residueIndex[p]), pdbx_PDB_ins_code: u.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(u.residueIndex[p]), x: u.model.atomicConformation.x[p], y: u.model.atomicConformation.y[p], z: u.model.atomicConformation.z[p], occupancy: u.model.atomicConformation.occupancy.value(p), B_iso_or_equiv: u.model.atomicConformation.B_iso_or_equiv.value(p), type_symbol: xh(u.model.atomicHierarchy.atoms.type_symbol.value(p)), charge: u.model.atomicHierarchy.atoms.pdbx_formal_charge.value(p), em_confidence: u.model.atomicHierarchy.atoms.em_confidence.value(p) };
    c.push(g), g.em_confidence && (l = !0), g.charge && (d = !0);
  }), n) {
    var f = n(c, []), m = f.editedAtomList, h = f.editedBondList;
    return i.push(u_(m, h, r && d, r && l)), i.join(`
`);
  }
  return i.push(u_(c, [], r && d, r && l)), i.join(`
`);
}
function u_(e, t, r, n) {
  var a = "ATOM  %5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), i = "HETATM%5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), o = "CONECT%5s%5s%5s%5s%5s", s = [], u = [];
  return e.forEach(function(c) {
    var l = c.elementId, d = c.atom_id, f = c.auth_atom_id, m = c.label_alt_id, h = c.auth_comp_id, p = c.auth_asym_id, g = c.auth_seq_id, v = c.pdbx_PDB_ins_code, y = v === void 0 ? " " : v, _ = c.x, S = c.y, b = c.z, x = c.occupancy, A = c.B_iso_or_equiv, w = c.type_symbol, C = c.group_PDB, M = c.charge, T = c.em_confidence, N = C === "HETATM" ? i : a;
    s.push(Zf.sprintf(N, d, f, m, h, p, g, y, _, S, b, x, A, " ", w, r ? M : "  ", n ? T : ""));
    var I = [];
    if (t && (t.forEach(function(F) {
      if (F.a !== l || I.includes(F.atom_idB)) {
        if (F.b === l && !I.includes(F.atom_idA)) for (R = 0, G = F.order; R < G; R++) I.push(F.atom_idA);
      } else for (var R = 0, G = F.order; R < G; R++) I.push(F.atom_idB);
    }), I.length > 0)) {
      for (var P = []; I.length > 0; ) {
        var O = I.shift();
        O && P.push(O), P.length === 4 && (u.push(Zf.sprintf(o, d, P[0], P[1], P[2], P[3])), P = []);
      }
      P.length > 0 && (u.push(Zf.sprintf(o, d, P[0] || "", P[1] || "", P[2] || "", P[3] || "")), P = []);
    }
  }), nt(nt([], s, !0), u, !0).join(`
`);
}
function c_(e, t, r, n, a) {
  var i, o, s, u, c, l;
  a === void 0 && (a = !1);
  var d = [];
  if (e.units.forEach(function(F) {
    return d.push.apply(d, nt([], F.elements, !0));
  }), d.length > 999) return "";
  if (d.length <= 0) {
    if (n) {
      var f = n([], []), m = f.editedAtomList, h = f.editedBondList, p = (i = e == null ? void 0 : e.state.model) !== null && i !== void 0 ? i : e == null ? void 0 : e.state.models[0], g = (o = p == null ? void 0 : p.sourceData) === null || o === void 0 ? void 0 : o.kind, v = T2(m, h);
      return g === "sdf" || g === "mol" ? nt(nt([p.entryId], v.split(`
`).slice(1), !0), ["$$$$"], !1).join(`
`) : "".concat(v, `
$$$$`);
    }
    return "";
  }
  var y = e.units[0], _ = [], S = /* @__PURE__ */ new Map();
  d.forEach(function(F) {
    var R;
    _.push({ elementId: F, group_PDB: y.model.atomicHierarchy.residues.group_PDB.value(y.residueIndex[F]), atom_id: y.model.atomicConformation.atomId.value(F), auth_atom_id: y.model.atomicHierarchy.atoms.label_atom_id.value(F), label_alt_id: y.model.atomicHierarchy.atoms.label_alt_id.value(F), auth_comp_id: y.model.atomicHierarchy.atoms.label_comp_id.value(F), auth_asym_id: y.model.atomicHierarchy.chains.auth_asym_id.value(y.chainIndex[F]), auth_seq_id: y.model.atomicHierarchy.residues.auth_seq_id.value(y.residueIndex[F]), pdbx_PDB_ins_code: y.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(y.residueIndex[F]), x: y.model.atomicConformation.x[F], y: y.model.atomicConformation.y[F], z: y.model.atomicConformation.z[F], occupancy: y.model.atomicConformation.occupancy.value(F), B_iso_or_equiv: y.model.atomicConformation.B_iso_or_equiv.value(F), type_symbol: xh(y.model.atomicHierarchy.atoms.type_symbol.value(F)), charge: y.model.atomicHierarchy.atoms.pdbx_formal_charge.value(F) || ((R = dl.Provider.get(y.model)) === null || R === void 0 ? void 0 : R.data.value(F)) || 0 });
  });
  var b = new Set(t), x = /* @__PURE__ */ new Map();
  if (a && ((s = e.model) === null || s === void 0 ? void 0 : s.sourceData.kind) === "mmCIF") for (var A = function(F, R) {
    for (var G = e.units[F], L = function(X, H) {
      var W = G.rings.all[G.rings.aromaticRings[X]].map(function(ee) {
        return G.elements[ee];
      });
      W.forEach(function(ee, $) {
        b.has(ee) && x.set(ee, new Set(nt(nt([], W.slice(0, $), !0), W.slice($ + 1), !0)));
      });
    }, q = 0, K = G.rings.aromaticRings.length; q < K; q++) L(q);
  }, w = 0, C = e.units.length; w < C; w++) A(w);
  e.units.forEach(function(F) {
    for (var R, G = 0, L = F.bonds.a.length; G < L; G++) {
      var q = F.elements[F.bonds.a[G]], K = F.elements[F.bonds.b[G]];
      if (d.includes(q) && d.includes(K) && !S.has("".concat(q, "_").concat(K)) && !S.has("".concat(K, "_").concat(q))) {
        var X = a && x.has(q) && (!((R = x.get(q)) === null || R === void 0) && R.has(K)) ? 4 : F.bonds.edgeProps.order[G];
        S.set("".concat(q, "_").concat(K), { a: d.indexOf(q) + 1, b: d.indexOf(K) + 1, order: X });
      }
    }
  });
  var M = [];
  if (((u = e.model) === null || u === void 0 ? void 0 : u.sourceData.kind) === "sdf" && (!((c = e.state.models) === null || c === void 0) && c.length)) for (var T = (l = e.state.models[0]) === null || l === void 0 ? void 0 : l.sourceData.data.dataItems, N = (w = 0, T.data.rowCount); w < N; w++) M.push("> ".concat(T.dataHeader.value(w), `
`).concat(T.data.value(w)));
  if (n) {
    var I = n(_, Array.from(S).map(function(F) {
      return F[1];
    })), P = (m = I.editedAtomList, h = I.editedBondList, T2(m, h));
    return "".concat(P, `
`).concat(M.join(`

`)).concat(M.length ? `

` : "", "$$$$");
  }
  var O = T2(_, Array.from(S).map(function(F) {
    return F[1];
  }));
  return "".concat(O, `
`).concat(M.join(`

`)).concat(M.length ? `

` : "", "$$$$");
}
var T2 = function(e, t, r) {
  var n = [];
  return n.push("".concat("", `

`)), n.push(Zf.sprintf("%3d%3d  0  0  0  0  0  0  0  0999 V2000", e.length, t.length)), e.forEach(function(a) {
    var i = a.x, o = a.y, s = a.z, u = a.type_symbol, c = a.charge;
    n.push(Zf.sprintf("%10.4f%10.4f%10.4f %-2s  0%3d  0  0  0  0  0  0  0  0  0  0", i, o, s, u, function(l) {
      switch (l) {
        case 0:
          return 0;
        case 3:
          return 1;
        case 2:
          return 2;
        case 1:
          return 3;
        case -1:
          return 5;
        case -2:
          return 6;
        case -3:
          return 7;
        default:
          return 0;
      }
    }(c)));
  }), t.forEach(function(a) {
    var i = a.a, o = a.b, s = a.order;
    n.push(Zf.sprintf("%3s%3s%3s  0  0  0  0", i, o, s));
  }), n.push("M  END"), n.join(`
`);
}, a0 = function(e, t, r, n) {
  return { elementId: -1, group_PDB: "HETATM", atom_id: e, auth_atom_id: t, label_alt_id: "", auth_comp_id: "UNK", auth_asym_id: " ", auth_seq_id: "1", x: parseFloat(r[0].toFixed(3)), y: parseFloat(r[1].toFixed(3)), z: parseFloat(r[2].toFixed(3)), occupancy: "1", B_iso_or_equiv: "0.00", type_symbol: t, charge: n ?? 0 };
}, Qse = function(e, t) {
  var r = [], n = [], a = 1, i = "sdf", o = [], s = [], u = !1, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = e.sort(function(g) {
    var v;
    return ((v = ps(g)) === null || v === void 0 ? void 0 : v.sourceData.kind) === "mmCIF" ? -1 : 1;
  });
  d.forEach(function(g, v) {
    var y;
    g && ((y = ps(g)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF" && Array.from(ps(g).properties.structAsymMap.keys()).forEach(function(_) {
      l.set("".concat(v, `
`).concat(_), _), c.has(_) && (u = !0), c.add(_);
    });
  });
  var f = "", m = 1;
  if (l.size > 35) return { format: "pdb", type: th.PDB, content: "" };
  if (u) c.clear(), Array.from(l.keys()).forEach(function(g, v) {
    var y = 65 + v > 90 ? String.fromCharCode(65 + v) : "".concat(v);
    l.set(g, y), v === l.size - 1 && (f = 65 + v + 1 > 90 ? String.fromCharCode(65 + v + 1) : "".concat(v));
  });
  else {
    for (var h = 65; h < 91 && f === ""; h++) {
      var p = String.fromCharCode(h);
      c.has(p) || (f = p);
    }
    for (h = 48; h < 58 && f === ""; h++)
      p = String.fromCharCode(h), c.has(p) || (f = p);
  }
  return d.forEach(function(g, v) {
    var y;
    if (g) if (((y = ps(g)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF") {
      var _ = [], S = nS(g, ["HEADER"]);
      _.push.apply(_, S);
      var b = ms(g), x = g.units[0], A = [];
      b.forEach(function(I) {
        var P, O = x.model.atomicHierarchy.chains.auth_asym_id.value(x.chainIndex[I]), F = { elementId: a, atom_id: "".concat(a), group_PDB: x.model.atomicHierarchy.residues.group_PDB.value(x.residueIndex[I]), auth_atom_id: x.model.atomicHierarchy.atoms.auth_atom_id.value(I), label_alt_id: x.model.atomicHierarchy.atoms.label_alt_id.value(I), auth_comp_id: x.model.atomicHierarchy.atoms.label_comp_id.value(I), auth_asym_id: (P = l.get("".concat(v, `
`).concat(O))) !== null && P !== void 0 ? P : O, auth_seq_id: x.model.atomicHierarchy.residues.auth_seq_id.value(x.residueIndex[I]), pdbx_PDB_ins_code: x.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(x.residueIndex[I]), x: x.model.atomicConformation.x[I], y: x.model.atomicConformation.y[I], z: x.model.atomicConformation.z[I], occupancy: x.model.atomicConformation.occupancy.value(I), B_iso_or_equiv: x.model.atomicConformation.B_iso_or_equiv.value(I), type_symbol: xh(x.model.atomicHierarchy.atoms.type_symbol.value(I)), charge: x.model.atomicHierarchy.atoms.pdbx_formal_charge.value(I) };
        A.push(F), a++;
      });
      var w = /* @__PURE__ */ new Map();
      g.units.forEach(function(I) {
        for (var P = 0, O = I.bonds.a.length; P < O; P++) {
          var F = I.elements[I.bonds.a[P]], R = I.elements[I.bonds.b[P]];
          if (b.includes(F) && b.includes(R) && !w.has("".concat(F, "_").concat(R)) && !w.has("".concat(R, "_").concat(F))) {
            var G = I.bonds.edgeProps.order[P];
            w.set("".concat(F, "_").concat(R), { a: A[b.indexOf(F)].elementId, b: A[b.indexOf(R)].elementId, order: G, atom_idA: A[b.indexOf(F)].atom_id, atom_idB: A[b.indexOf(F)].atom_id });
          }
        }
      }), r.push.apply(r, A), n.push.apply(n, Array.from(w).map(function(I) {
        return I[1];
      })), i = "pdb";
    } else {
      var C = ms(g), M = g.units[0], T = [], N = /* @__PURE__ */ new Map();
      C.forEach(function(I) {
        var P;
        T.push({ elementId: a, group_PDB: "HETATM", atom_id: "".concat(a), auth_atom_id: M.model.atomicHierarchy.atoms.label_atom_id.value(I), label_alt_id: M.model.atomicHierarchy.atoms.label_alt_id.value(I), auth_comp_id: M.model.atomicHierarchy.atoms.label_comp_id.value(I), auth_asym_id: f, auth_seq_id: "".concat(m), pdbx_PDB_ins_code: M.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(M.residueIndex[I]), x: M.model.atomicConformation.x[I], y: M.model.atomicConformation.y[I], z: M.model.atomicConformation.z[I], occupancy: M.model.atomicConformation.occupancy.value(I), B_iso_or_equiv: M.model.atomicConformation.B_iso_or_equiv.value(I), type_symbol: xh(M.model.atomicHierarchy.atoms.type_symbol.value(I)), charge: M.model.atomicHierarchy.atoms.pdbx_formal_charge.value(I) || ((P = dl.Provider.get(M.model)) === null || P === void 0 ? void 0 : P.data.value(I)) || 0 }), a++;
      }), g.units.forEach(function(I) {
        for (var P = 0, O = I.bonds.a.length; P < O; P++) {
          var F = I.elements[I.bonds.a[P]], R = I.elements[I.bonds.b[P]];
          if (C.includes(F) && C.includes(R) && !N.has("".concat(F, "_").concat(R)) && !N.has("".concat(R, "_").concat(F))) {
            var G = I.bonds.edgeProps.order[P];
            N.set("".concat(F, "_").concat(R), { a: T[C.indexOf(F)].elementId, b: T[C.indexOf(R)].elementId, order: G, atom_idA: T[C.indexOf(F)].atom_id, atom_idB: T[C.indexOf(F)].atom_id });
          }
        }
      }), m++, s.push.apply(s, T), n.push.apply(n, Array.from(N).map(function(I) {
        return I[1];
      }));
    }
  }), o.length === 2 && n.push({ a: o[0], b: o[1], order: 1, atom_idA: "".concat(o[0]), atom_idB: "".concat(o[1]) }), r.push.apply(r, s), i === "pdb" ? { format: "pdb", type: th.PDB, content: r.length > 99999 ? "" : u_(r, n, !1, !1) } : { format: "sdf", type: th.SDF, content: r.length > 999 || n.length > 999 ? "" : "".concat(T2(r, n), `
$$$$`) };
}, $se = function(e, t) {
  switch (t) {
    case xr.Pdb:
      return Jse(e);
    case xr.Sdf:
    case xr.Mol:
      return LL(e);
    default:
      return [e];
  }
}, Jse = function(e) {
  var t = e.split(`
`), r = [], n = [[]], a = 0;
  t.forEach(function(s) {
    switch (s[0]) {
      case "A":
        if (s.startsWith("ATOM")) return void n[a].push(s);
        if (s.startsWith("AUTHER")) return;
        r.push(s);
        break;
      case "C":
        if (s.startsWith("CONECT")) return void n[a].push(s);
        r.push(s);
        break;
      case "E":
        if (s.startsWith("ENDMDL")) return void (n[a].length > 0 && (a++, n.push([])));
        if (s.startsWith("END")) return;
        r.push(s);
        break;
      case "H":
        if (s.startsWith("HETATM")) return void n[a].push(s);
        r.push(s);
        break;
      case "M":
        if (s.startsWith("MODEL")) return void (n[a].length > 0 && (a++, n.push([])));
        if (s.startsWith("MASTER")) return;
        r.push(s);
        break;
      case "R":
        if (s.startsWith("REVDAT")) return;
        r.push(s);
        break;
      case "S":
        if (s.startsWith("SOURCE")) return;
        r.push(s);
        break;
      case "T":
        if (s.startsWith("TER")) return void n[a].push(s);
        r.push(s);
        break;
      default:
        r.push(s);
    }
  });
  var i = r.join(`
`), o = [];
  return n.forEach(function(s) {
    s.length > 0 && o.push("".concat(i).concat(i ? `
` : "").concat(s.join(`
`)));
  }), o;
}, LL = function(e) {
  return e.split(/\$\$\$\$\r?\n?/).filter(function(t) {
    return t.trim() !== "";
  });
}, eue = function(e) {
  for (var t = e.split(`
`), r = !0, n = !1, a = [], i = [], o = 0, s = t.length; o < s; o++) {
    var u = t[o];
    if (r) {
      if (a.length < 4)
        a.push(u), a.length === 4 && (c = zx(u, gse)).length > 0 && i.push({ index: o, info: c });
      else if (u.startsWith("M  END")) n = !0, r = !1, a = [];
      else if (!u.startsWith("M") && !u.startsWith("V")) {
        if (u.startsWith("G") || u.startsWith("A")) o++;
        else if (u.slice(4, 5) !== "T" && u.slice(4, 5) !== "F") {
          var c;
          u.length < 34 ? (c = zx(u, vse)).length > 0 && i.push({ index: o, info: c }) : (c = zx(u, hse)).length > 0 && i.push({ index: o, info: c });
        }
      }
    } else u.startsWith("$$$$") && (r = !0, a = []);
  }
  return n || i.push({ index: 0, info: [{ start: 0, end: 0 }] }), i;
}, tue = function(e, t) {
  switch (t) {
    case xr.Sdf:
    case xr.Mol:
      return eue(e);
    default:
      return [];
  }
}, rue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s, u, c, l;
    return Te(this, function(d) {
      switch (d.label) {
        case 0:
          if (!e.trim()) return [2, [vc()]];
          t = [], r = LL(e), n = 0, a = r, d.label = 1;
        case 1:
          return n < a.length ? [4, jse(a[n]).run()] : [3, 7];
        case 2:
          if ((i = d.sent()).isError) throw i;
          o = 0, s = i.result.compounds, d.label = 3;
        case 3:
          return o < s.length ? (u = s[o], [4, (f = u, sr.create("Parse SDF", function(m) {
            return RL(f.molFile, s_.create(f), m);
          })).run()]) : [3, 6];
        case 4:
          c = d.sent(), l = st.ofModel(c.representative), t.push(l), d.label = 5;
        case 5:
          return o++, [3, 3];
        case 6:
          return n++, [3, 1];
        case 7:
          return [2, t];
      }
      var f;
    });
  });
} };
function nue(e) {
  return function(t, r, n) {
    return function(a, i, o, s) {
      var u = a.data, c = a.indices, l = a.count, d = s.valueType, f = d === "str" ? function(m) {
        var h = c[2 * m] + i, p = c[2 * m + 1];
        if (h >= p) return "";
        var g = h + o;
        return g > p && (g = p), function(v, y, _) {
          for (var S = y, b = _ - 1, x = v.charCodeAt(S); (x === 9 || x === 32) && S <= b; ) x = v.charCodeAt(++S);
          for (x = v.charCodeAt(b); (x === 9 || x === 32) && b >= S; ) x = v.charCodeAt(--b);
          return v.substring(S, b + 1);
        }(u, h, g);
      } : d === "int" ? function(m) {
        var h = c[2 * m] + i;
        return h > c[2 * m + 1] ? 0 : Pf(u, h, h + o);
      } : function(m) {
        var h = c[2 * m] + i;
        return h > c[2 * m + 1] ? 0 : function(p, g, v) {
          for (; g < v && p.charCodeAt(g) === 32; ) g++;
          return Hf(p, g, v);
        }(u, h, h + o);
      };
      return { schema: s, __array: void 0, isDefined: !0, rowCount: l, value: f, valueKind: function(m) {
        return 0;
      }, toArray: function(m) {
        return ci(l, f, m);
      }, areValuesEqual: function(m, h) {
        return f(m) === f(h);
      } };
    }(e, t, r, n);
  };
}
function aue(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s, u, c, l, d;
    return Te(this, function(f) {
      switch (f.label) {
        case 0:
          return t = e.tokenizer, r = e.numberOfAtoms, [4, ft.readLinesAsync(t, r, e.runtimeCtx, 1e5)];
        case 1:
          return n = f.sent(), a = t.data.substring(n.indices[0], n.indices[1]).substring(20), i = a.match(/\.\d+/g), o = i.length === 6, e.header.hasVelocities = o, e.header.precision.position = i[0].length - 1, e.header.precision.velocity = o ? i[3].length - 1 : 0, s = e.header.precision.position + 5, u = 20 + 3 * s, c = e.header.precision.velocity + 4, l = nue(n), d = pe.Undefined(e.numberOfAtoms, pe.Schema.float), [2, { count: e.numberOfAtoms, residueNumber: l(0, 5, pe.Schema.int), residueName: l(5, 5, pe.Schema.str), atomName: l(10, 5, pe.Schema.str), atomNumber: l(15, 5, pe.Schema.int), x: l(20, s, pe.Schema.float), y: l(20 + s, s, pe.Schema.float), z: l(20 + 2 * s, s, pe.Schema.float), vx: o ? l(u, c, pe.Schema.float) : d, vy: o ? l(u + c, c, pe.Schema.float) : d, vz: o ? l(u + 2 * c, c, pe.Schema.float) : d }];
      }
    });
  });
}
function iue(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          return r = ft(e), [4, t.update({ message: "Parsing...", current: 0, max: e.length })];
        case 1:
          s.sent(), n = [], s.label = 2;
        case 2:
          return r.position < e.length ? (a = /* @__PURE__ */ function(u, c) {
            return { tokenizer: u, header: { title: "", timeInPs: 0, hasVelocities: !1, precision: { position: 0, velocity: 0 }, box: [0, 0, 0] }, numberOfAtoms: 0, runtimeCtx: c };
          }(r, t), function(u) {
            var c = u.tokenizer, l = u.header, d = ft.readLine(c);
            d.trim().length === 0 && (d = ft.readLine(c));
            var f = d.lastIndexOf("t=");
            f >= 0 ? (l.timeInPs = parseFloat(d.substring(f + 2)), l.title = d.substring(0, f).trim(), l.title && l.title[l.title.length - 1] === "," && (l.title = l.title.substring(0, l.title.length - 1))) : l.title = d;
          }(a), function(u) {
            var c = u.tokenizer;
            ft.markLine(c);
            var l = ft.getTokenString(c);
            u.numberOfAtoms = parseInt(l);
          }(a), [4, aue(a)]) : [3, 4];
        case 3:
          return i = s.sent(), function(u) {
            var c = u.tokenizer, l = ft.readLine(c).trim().split(/\s+/g);
            u.header.box = [+l[0], +l[1], +l[2]];
          }(a), n.push({ header: a.header, atoms: i }), [3, 2];
        case 4:
          return o = { structures: n }, [2, za.success(o)];
      }
    });
  });
}
function kL(e) {
  var t = this;
  return sr.create("Parse GRO", function(r) {
    return Be(t, 0, void 0, function() {
      return Te(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, iue(e, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
var hM = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", l_, oue = vR(function(e) {
  for (var t = e, r = 0, n = hM[t % 26]; t >= 26; ) t = Math.floor(t / 26), n += hM[t % 26], r += 1;
  return r >= 5 && console.warn("getChainId overflow"), n;
});
function zL(e) {
  var t = this;
  return sr.create("Parse GRO", function(r) {
    return Be(t, 0, void 0, function() {
      var n, a, i, o, s, u;
      return Te(this, function(c) {
        switch (c.label) {
          case 0:
            n = l_.fromGro(e), a = [], i = 0, o = e.structures.length, c.label = 1;
          case 1:
            return i < o ? (s = function(l, d) {
              for (var f = l.atomName, m = l.residueName, h = new Array(l.count), p = new Array(l.count), g = new Uint32Array(l.count), v = new Uint32Array(l.count), y = new Array(l.count), _ = new mm(), S = new fm(l.residueNumber, l.atomName), b = "", x = 0, A = "", w = 0, C = 0, M = -1, T = 0, N = l.count; T < N; ++T) {
                var I = l.residueNumber.value(T);
                if (I !== M) {
                  var P = l.residueName.value(T), O = Fh(S.add(P, T).type, P);
                  O === C && (I === M + 1 || M === 99999 && I === 0) || (A = oue(x), x += 1, w = 0), b = _.getEntityId(P, O, A), w += 1, M = I, C = O;
                }
                h[T] = b, p[T] = A, g[T] = w, v[T] = T, y[T] = J8(l.atomName.value(T), l.residueName.value(T));
              }
              var F = pe.ofStringArray(p), R = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: F, auth_atom_id: f, auth_comp_id: m, auth_seq_id: l.residueNumber, Cartn_x: pe.ofFloatArray(pe.mapToArray(l.x, function(G) {
                return 10 * G;
              }, Float32Array)), Cartn_y: pe.ofFloatArray(pe.mapToArray(l.y, function(G) {
                return 10 * G;
              }, Float32Array)), Cartn_z: pe.ofFloatArray(pe.mapToArray(l.z, function(G) {
                return 10 * G;
              }, Float32Array)), id: pe.ofIntArray(v), label_asym_id: F, label_atom_id: f, label_comp_id: m, label_seq_id: pe.ofIntArray(g), label_entity_id: pe.ofStringArray(h), occupancy: pe.ofConst(1, l.count, pe.Schema.float), type_symbol: pe.ofStringArray(y), pdbx_PDB_model_num: pe.ofConst(d, l.count, pe.Schema.int) }, l.count);
              return Zd({ entity: _.getEntityTable(), chem_comp: S.getChemCompTable(), atom_site: R });
            }(e.structures[i].atoms, i + 1), [4, bl(s, n, r)]) : [3, 4];
          case 2:
            (u = c.sent()).frameCount === 1 && a.push(u.representative), c.label = 3;
          case 3:
            return ++i, [3, 1];
          case 4:
            return [2, new dh(a)];
        }
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "gro";
  }, e.fromGro = function(t) {
    return { kind: "gro", name: t.structures[0].header.title, data: t };
  };
})(l_ || (l_ = {}));
var Bo, sue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, kL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, zL(t.result).run()];
        case 2:
          return [2, r.sent().representative];
      }
    });
  });
} }, ep = new Uint32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003, 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031, 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216]), qx = 9;
function uue() {
  throw new Error("(xdrfile error) Undefined error.");
}
function cue(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R, G;
    return Te(this, function(L) {
      switch (L.label) {
        case 0:
          r = new DataView(t.buffer, t.byteOffset), a = (n = { frames: [], boxes: [], times: [], timeOffset: 0, deltaTime: 0 }).frames, i = n.boxes, o = n.times, s = [0, 0, 0, 0, 0, 0], u = [0, 0, 0], c = [0, 0, 0], l = [0, 0, 0], d = [0.1, 0.1, 0.1], f = [0.1, 0.1, 0.1], m = 0, h = Bo.buf, L.label = 1;
        case 1:
          for (p = void 0, g = r.getInt32(m + 4), m += 12, o.push(r.getFloat32(m)), m += 4, v = new Float32Array(9), I = 0; I < 9; ++I) v[I] = 10 * r.getFloat32(m), m += 4;
          if (i.push(v), g <= 9) for (p = { count: g / 3, x: new Float32Array(g / 3), y: new Float32Array(g / 3), z: new Float32Array(g / 3) }, I = 0; I < g / 3; ++I) p.x[I] = r.getFloat32(m), p.y[I] = r.getFloat32(m), p.z[I] = r.getFloat32(m), m += 4;
          else {
            for (h[0] = h[1] = h[2] = 0, u[0] = u[1] = u[2] = 0, l[0] = l[1] = l[2] = 0, c[0] = c[1] = c[2] = 0, d[0] = d[1] = d[2] = 0, f[0] = f[1] = f[2] = 0, p = { count: g, x: new Float32Array(g), y: new Float32Array(g), z: new Float32Array(g) }, y = 0, _ = r.getInt32(m), m += 4, S = r.getFloat32(m), m += 4, s[0] = r.getInt32(m), s[1] = r.getInt32(m + 4), s[2] = r.getInt32(m + 8), s[3] = r.getInt32(m + 12), s[4] = r.getInt32(m + 16), s[5] = r.getInt32(m + 20), u[0] = s[3] - s[0] + 1, u[1] = s[4] - s[1] + 1, u[2] = s[5] - s[2] + 1, m += 24, b = void 0, (u[0] | u[1] | u[2]) > 16777215 ? (c[0] = Bo.sizeOfInt(u[0]), c[1] = Bo.sizeOfInt(u[1]), c[2] = Bo.sizeOfInt(u[2]), b = 0) : b = Bo.sizeOfInts(3, u), x = r.getInt32(m), m += 4, w = ep[A = qx > (A = x - 1) ? qx : A] / 2 | 0, C = ep[x] / 2 | 0, l[0] = l[1] = l[2] = ep[x], M = 4 * Math.ceil(r.getInt32(m) / 4), m += 4, T = 1 / S, N = 0, I = 0, d[0] = d[1] = d[2] = 0; I < _; ) {
              if (b === 0 ? (d[0] = Bo.decodeBits(t, m, c[0]), d[1] = Bo.decodeBits(t, m, c[1]), d[2] = Bo.decodeBits(t, m, c[2])) : Bo.decodeInts(t, m, b, u, d), I++, d[0] += s[0], d[1] += s[1], d[2] += s[2], f[0] = d[0], f[1] = d[1], f[2] = d[2], P = Bo.decodeBits(t, m, 1), O = 0, P === 1 && (N = Bo.decodeBits(t, m, 5), N -= O = N % 3, O--), N > 0) for (d[0] = d[1] = d[2] = 0, F = 0; F < N; F += 3) Bo.decodeInts(t, m, x, l, d), I++, d[0] += f[0] - C, d[1] += f[1] - C, d[2] += f[2] - C, F === 0 ? (R = d[0], d[0] = f[0], f[0] = R, R = d[1], d[1] = f[1], f[1] = R, R = d[2], d[2] = f[2], f[2] = R, p.x[y] = f[0] * T, p.y[y] = f[1] * T, p.z[y] = f[2] * T, y++) : (f[0] = d[0], f[1] = d[1], f[2] = d[2]), p.x[y] = d[0] * T, p.y[y] = d[1] * T, p.z[y] = d[2] * T, y++;
              else p.x[y] = d[0] * T, p.y[y] = d[1] * T, p.z[y] = d[2] * T, y++;
              x += O, O < 0 ? (C = w, w = x > qx ? ep[x - 1] / 2 | 0 : 0) : O > 0 && (w = C, C = ep[x] / 2 | 0), l[0] = l[1] = l[2] = ep[x], l[0] !== 0 && l[1] !== 0 && l[2] !== 0 || uue();
            }
            m += M;
          }
          for (G = 0; G < g; G++) p.x[G] *= 10, p.y[G] *= 10, p.z[G] *= 10;
          return a.push(p), e.shouldUpdate ? [4, e.update({ current: m, max: t.length })] : [3, 3];
        case 2:
          L.sent(), L.label = 3;
        case 3:
          return m >= t.length ? [3, 4] : [3, 1];
        case 4:
          return o.length >= 1 && (n.timeOffset = o[0]), o.length >= 2 && (n.deltaTime = o[1] - o[0]), [2, n];
      }
    });
  });
}
function lue(e) {
  var t = this;
  return sr.create("Parse XTC", function(r) {
    return Be(t, 0, void 0, function() {
      var n, a;
      return Te(this, function(i) {
        switch (i.label) {
          case 0:
            return i.trys.push([0, 2, , 3]), r.update({ canAbort: !0, message: "Parsing trajectory..." }), [4, cue(r, e)];
          case 1:
            return n = i.sent(), [2, za.success(n)];
          case 2:
            return a = i.sent(), [2, za.error("" + a)];
          case 3:
            return [2];
        }
      });
    });
  });
}
function Ey() {
  return Ey.empty();
}
function due(e) {
  var t = this;
  return sr.create("Parse XTC", function(r) {
    return Be(t, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d;
      return Te(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, r.update("Converting to coordinates")];
          case 1:
            for (f.sent(), n = C4(e.deltaTime, "step"), a = C4(e.timeOffset, n.unit), i = [], o = 0, s = e.frames.length; o < s; ++o) u = e.boxes[o], c = D.fromArray(D(), u, 0), l = D.fromArray(D(), u, 3), d = D.fromArray(D(), u, 6), i.push({ elementCount: e.frames[o].count, cell: Ey.fromBasis(c, l, d), x: e.frames[o].x, y: e.frames[o].y, z: e.frames[o].z, xyzOrdering: { isIdentity: !0 }, time: C4(a.value + n.value * o, n.unit) });
            return [2, Z2.create(i, n, a)];
        }
      });
    });
  });
}
(function(e) {
  e.sizeOfInt = function(s) {
    for (var u = 1, c = 0; s >= u && c < 32; ) c++, u <<= 1;
    return c;
  };
  var t = new Uint8Array(32);
  e.sizeOfInts = function(s, u) {
    var c = 1, l = 0;
    t[0] = 1;
    for (var d = 0; d < s; d++) {
      var f = void 0, m = 0;
      for (f = 0; f < c; f++) m += t[f] * u[d], t[f] = 255 & m, m >>= 8;
      for (; m !== 0; ) t[f++] = 255 & m, m >>= 8;
      c = f;
    }
    var h = 1;
    for (c--; t[c] >= h; ) l++, h *= 2;
    return l + 8 * c;
  };
  var r = new ArrayBuffer(24);
  e.buf = new Int32Array(r);
  var n = new Uint32Array(r);
  function a(s, u, c) {
    for (var l = c, d = (1 << l) - 1, f = n[1], m = n[2], h = e.buf[0], p = 0; l >= 8; ) p |= (m = m << 8 | s[u + h++]) >> f << l - 8, l -= 8;
    return l > 0 && (f < l && (f += 8, m = m << 8 | s[u + h++]), p |= m >> (f -= l) & (1 << l) - 1), p &= d, e.buf[0] = h, e.buf[1] = f, e.buf[2] = m, p;
  }
  function i(s, u) {
    var c = n[2], l = e.buf[0];
    return c = c << 8 | s[u + l], e.buf[0] = l + 1, e.buf[2] = c, c >> n[1] & 255;
  }
  e.decodeBits = a;
  var o = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  e.decodeInts = function(s, u, c, l, d) {
    var f = c, m = 0;
    for (o[0] = 0, o[1] = 0, o[2] = 0, o[3] = 0; f > 8; ) o[m++] = i(s, u), f -= 8;
    f > 0 && (o[m++] = a(s, u, f));
    for (var h = 2; h > 0; h--) {
      for (var p = 0, g = l[h], v = m - 1; v >= 0; v--) {
        var y = (p = p << 8 | o[v]) / g | 0;
        o[v] = y, p -= y * g;
      }
      d[h] = p;
    }
    d[0] = o[0] | o[1] << 8 | o[2] << 16 | o[3] << 24;
  };
})(Bo || (Bo = {})), function(e) {
  function t(n, a) {
    return { size: n, anglesInRadians: a };
  }
  function r() {
    return t(D(), D());
  }
  e.create = t, e.empty = r, e.fromBasis = function(n, a, i) {
    var o = D.magnitude(n), s = D.magnitude(a), u = D.magnitude(i), c = Math.acos(D.dot(a, i) / (s * u)), l = Math.acos(D.dot(n, i) / (o * u)), d = Math.acos(D.dot(n, a) / (o * s));
    return o <= 0 || s <= 0 || u <= 0 || c >= Math.PI || l >= Math.PI || d >= Math.PI ? r() : t(D.create(o, s, u), D.create(c, l, d));
  };
}(Ey || (Ey = {}));
var fue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(t) {
      return [2, new Promise(function(r) {
        var n = new FileReader();
        n.onload = function(a) {
          return Be(this, 0, void 0, function() {
            var i, o;
            return Te(this, function(s) {
              switch (s.label) {
                case 0:
                  return [4, lue(new Uint8Array(n.result)).run()];
                case 1:
                  if ((i = s.sent()).isError) throw new Error(i.message);
                  return [4, due(i.result).run()];
                case 2:
                  return o = s.sent(), r(o), [2];
              }
            });
          });
        }, n.readAsArrayBuffer(e);
      })];
    });
  });
} };
function UL(e, t, r, n, a, i) {
  var o = e, s = t, u = r, c = Math.cos(n * Math.PI / 180), l = Math.cos(a * Math.PI / 180), d = Math.cos(i * Math.PI / 180), f = Math.sin(n * Math.PI / 180), m = Math.sin(a * Math.PI / 180), h = function() {
    var b = (c * l - d) / (f * m);
    return Math.max(Math.min(b, 1), -1);
  }(), p = Math.acos(h), g = Ee.ofRows([[o * m, -s * f * Math.cos(p), 0, 0], [0, s * f * Math.sin(p), 0, 0], [o * l, s * c, u, 0], [0, 0, 0, 1]]), v = Ee.invert(Ee.zero(), g), y = D.create(g[0], g[4], g[8]), _ = D.create(g[1], g[5], g[9]), S = D.create(g[2], g[6], g[10]);
  return { a: e, b: t, c: r, volume: Math.abs(D.dot(y, y)) * r, alpha: n, beta: a, gamma: i, vecA: y, vecB: _, vecC: S, matrix: g, invertMatrix: v };
}
function GL(e, t, r) {
  var n = D.create.apply(null, e), a = D.create.apply(null, t), i = D.create.apply(null, r), o = n[0], s = n[1], u = n[2], c = a[0], l = a[1], d = a[2], f = i[0], m = i[1], h = i[2], p = Ee.ofRows([[o, c, f, 0], [s, l, m, 0], [u, d, h, 0], [0, 0, 0, 1]]), g = Ee.invert(Ee.zero(), p), v = Math.sqrt(Math.abs(D.dot(n, n))), y = Math.sqrt(Math.abs(D.dot(a, a))), _ = Math.sqrt(Math.abs(D.dot(i, i))), S = D.angle(a, i) * (180 / Math.PI), b = D.angle(n, i) * (180 / Math.PI), x = D.angle(n, a) * (180 / Math.PI);
  return { a: v, b: y, c: _, volume: Math.abs(D.dot(n, n)) * _, alpha: S, beta: b, gamma: x, vecA: n, vecB: a, vecC: i, matrix: p, invertMatrix: g };
}
var Dy, VL = [];
function mue(e) {
  ft.readLine(e);
  var t = +ft.readLine(e);
  ft.readLine(e);
  var r = +ft.readLine(e);
  isNaN(r) && (r = 0);
  var n = ft.readLine(e), a = new Float64Array(3), i = new Float64Array(3), o = new Float64Array(3);
  n.includes("xy xz yz") && function(b, x) {
    var A = x[0], w = x[1], C = x[2], M = x.map(function() {
      return ft.readLine(b).trim().split(/\s+/g).map(function(oe) {
        return Number(oe);
      });
    }), T = M[0], N = T[0], I = T[1], P = T[2], O = M[1], F = O[0], R = O[1], G = O[2], L = M[2], q = L[0], K = L[1], X = L[2], H = [[N, I], [F, R], [q, K]], W = [P, G, X], ee = [0, W[0], W[1], W[0] + W[1]], $ = [0, W[2]], te = [[Math.min.apply(null, ee), Math.max.apply(null, ee)], [Math.min.apply(null, $), Math.max.apply(null, $)], [0, 0]];
    H.forEach(function(oe, se) {
      oe.forEach(function(he, ge) {
        H[se][ge] = he - te[se][ge];
      });
    });
    var re = H.map(function(oe) {
      return oe[1] - oe[0];
    }), ie = [[re[0], 0, 0], [W[0], re[1], 0], [W[1], W[2], re[2]]];
    A[0] = ie[0][0], A[1] = ie[0][1], A[2] = ie[0][2], w[0] = ie[1][0], w[1] = ie[1][1], w[2] = ie[1][2], C[0] = ie[2][0], C[1] = ie[2][1], C[2] = ie[2][2];
  }(e, [a, i, o]);
  var s = function(b, x, A) {
    var w = new Float64Array(x), C = new Float64Array(x), M = new Float64Array(x), T = new Float64Array(x), N = new Float64Array(x), I = [["id", w], ["type", C], ["x", M], ["y", T], ["z", N]];
    I.sort(function(R, G) {
      return A.indexOf(R[0]) - A.indexOf(G[0]);
    });
    for (var P = I.map(function(R) {
      return R[1];
    }), O = function(R) {
      ft.readLine(b).trim().split(/\s+/g).forEach(function(G, L) {
        P[L][R] = Number(G);
      });
    }, F = 0; F < x; F++) O(F);
    return [w, C, M, T, N];
  }(e, r, ft.readLine(e).replace("ITEM: ATOMS", "").split(/\s+/g)), u = s[0], c = s[1], l = s[2], d = s[3], f = s[4], m = [], h = [];
  c.forEach(function(b) {
    m[b] || (m[b] = VL[b].symbol), h.push(m[b]);
  });
  for (var p = GL(a, i, o), g = new Float64Array(r), v = new Float64Array(r), y = new Float64Array(r), _ = 0; _ < r; _++) {
    var S = D.create(l[_], d[_], f[_]);
    D.transformMat4(S, S, p.invertMatrix), g[_] = S[0], v[_] = S[1], y[_] = S[2];
  }
  return { count: r, comment: "", x: pe.ofFloatArray(l), y: pe.ofFloatArray(d), z: pe.ofFloatArray(f), type_symbol: pe.ofStringArray(h), cell: p, timestep: t, fractX: pe.ofFloatArray(g), fractY: pe.ofFloatArray(v), fractZ: pe.ofFloatArray(y), id: pe.ofFloatArray(u) };
}
function pue(e) {
  for (var t = ft(e), r = []; ; ) {
    var n = mue(t);
    if (n.count === 0) break;
    r.push(n);
  }
  var a = { molecules: r, isMaterial: !0 };
  return za.success(a);
}
function iS(e) {
  var t = this;
  return sr.create("Parse Mol", function() {
    return Be(t, 0, void 0, function() {
      var r;
      return Te(this, function(n) {
        return r = function(a) {
          var i = a.split(/\r?\n/).reduce(function(o, s) {
            return s.includes("ITEM: TIMESTEP") && o.push([]), o[o.length - 1].push(s), o;
          }, []).map(function(o) {
            var s = o.findIndex(function(R) {
              return R.includes("ITEM: BOX BOUNDS");
            });
            o.splice(s, 1, "ITEM: BOX BOUNDS xy xz yz pp pp pp");
            var u = o.findIndex(function(R) {
              return R.includes("ITEM: ATOMS");
            }), c = o[u].includes("xs") || o[u].includes("xsu"), l = o[s + 1], d = o[s + 2], f = o[s + 3], m = l.split(" ").map(function(R) {
              return +R;
            }), h = m[0], p = m[1], g = m[2], v = g === void 0 ? 0 : g, y = d.split(" ").map(function(R) {
              return +R;
            }), _ = y[0], S = y[1], b = y[2], x = b === void 0 ? 0 : b, A = f.split(" ").map(function(R) {
              return +R;
            }), w = A[0], C = A[1], M = A[2], T = M === void 0 ? 0 : M;
            if (c) {
              var N = [[p - h - Math.abs(v) - Math.abs(x), 0, 0], [v, S - _ - Math.abs(T), 0], [x, T, C - w]], I = o.slice(u + 1).map(function(R) {
                return R.split(" ");
              }).map(function(R) {
                var G = R[0], L = R[1], q = function(K, X) {
                  for (var H = [], W = 0; W < K.length; W++) {
                    H[W] = [];
                    for (var ee = 0; ee < X[0].length; ee++) {
                      for (var $ = 0, te = 0; te < K[0].length; te++) $ += +K[W][te] * +X[te][ee];
                      H[W][ee] = $;
                    }
                  }
                  return H;
                }([[R[2], R[3], R[4]]], N)[0];
                return [G, L, q[0], q[1], q[2]];
              }), P = I.map(function(R) {
                return R.join(" ");
              }).join(`
`);
              return [o.slice(0, s + 4).join(`
`), F = "ITEM: ATOMS id type x y z", P].join(`
`);
            }
            var O = [[h, p, v], [_, S, x], [w, C, T]].map(function(R) {
              return R.join(" ");
            });
            o.splice.apply(o, nt([s + 1, 3], O, !1)), P = (I = o.slice(u + 1).map(function(R) {
              return R.split(" ");
            }).map(function(R) {
              return [R[0], R[1], R[2], R[3], R[4]];
            })).map(function(R) {
              return R.join(" ");
            }).join(`
`);
            var F = "ITEM: ATOMS id type x y z";
            return [o.slice(0, s + 4).join(`
`), F, P].join(`
`);
          });
          return i.join(`
`);
        }(e), [2, pue(r)];
      });
    });
  });
}
function hue(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F;
    return Te(this, function(R) {
      switch (R.label) {
        case 0:
          for (r = Dy.formatMol(e), n = r.molecules, a = 0, i = 0, o = n; i < o.length; i++) p = o[i], a += p.count;
          for (s = new Array(a), u = new Int32Array(a), c = new Float32Array(a), l = new Float32Array(a), d = new Float32Array(a), f = new Int32Array(a), m = function(G) {
            if (G.length) {
              var L = G[0], q = L.cell, K = L.spaceGroup;
              if (q) {
                var X = q.a, H = q.b, W = q.c, ee = q.alpha, $ = q.beta, te = q.gamma, re = q.matrix, ie = q.invertMatrix, oe = function(he) {
                  if (!he) return "P 1";
                  var ge = he.it_number.value(0), De = he["name_h-m_full"].value(0).replace("-", " ");
                  return he.it_number.isDefined ? (he["name_h-m_full"].isDefined, ge) : De;
                }(K), se = tu.createMaterial(oe, D.create(X, H, W), D.scale(D(), D.create(ee, $, te), Math.PI / 180), X * H * W, ie, re);
                return { spacegroup: Fo.create(se), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
              }
            }
          }(n), h = 0, F = 0; F < n.length; F++) for (p = n[F], g = 0; g < p.count; g++) s[h] = p.type_symbol.value(g), c[h] = p.x.value(g), l[h] = p.y.value(g), d[h] = p.z.value(g), u[h] = g, f[h] = F, h++;
          return v = pe.ofConst("MOL", a, pe.Schema.str), y = pe.ofConst("A", a, pe.Schema.str), _ = pe.ofConst(1, a, pe.Schema.int), S = pe.ofStringArray(s), b = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: y, auth_atom_id: S, auth_comp_id: v, auth_seq_id: _, Cartn_x: pe.ofFloatArray(c), Cartn_y: pe.ofFloatArray(l), Cartn_z: pe.ofFloatArray(d), id: pe.ofIntArray(u), label_asym_id: y, label_atom_id: S, label_comp_id: v, label_seq_id: _, label_entity_id: pe.ofConst("1", a, pe.Schema.str), occupancy: pe.ofConst(1, a, pe.Schema.float), type_symbol: S, pdbx_PDB_model_num: pe.ofIntArray(f) }, a), (x = new mm()).setNames([["MOL", "Ligand"]]), x.getEntityId("MOL", 0, "A"), (A = new fm(_, S)).setNames([["MOL", "Unknown Molecule"]]), A.add("MOL", 0), [4, bl(Zd({ entity: x.getEntityTable(), chem_comp: A.getChemCompTable(), atom_site: b }), Dy.create(r), t)];
        case 1:
          if ((w = R.sent()).frameCount > 0 && (C = w.representative, pi.Provider.set(C, m)), M = n[0], T = M.bonds) for (N = pe.ofIntArray(T.atomA), I = pe.ofIntArray(T.atomB), P = pe.ofIntArray(new Array(T.count).fill(1)), O = Ra.fromData({ pairs: { indexA: N, indexB: I, order: P }, count: M.count }), F = 0; F < w.frameCount; F++) Ra.Provider.set(w.getFrameAtIndex(F), O);
          return [2, w];
      }
    });
  });
}
function Qd(e) {
  return sr.create("Parse Material", function(t) {
    return hue(e, t);
  });
}
Object.entries({ Ac: { "Atomic mass": 227, "Atomic no": 89, "Atomic orbitals": { "1s": -3443.110367, "2p": -572.7627, "2s": -592.622878, "3d": -119.541743, "3p": -137.654394, "3s": -147.320716, "4d": -23.57061, "4f": -12.278225, "4p": -31.761846, "4s": -36.15826, "5d": -3.222752, "5p": -6.06511, "5s": -7.713078, "6d": -0.137786, "6p": -0.744524, "6s": -1.19698, "7s": -0.126551 }, "Atomic radius": 1.95, "Atomic radius calculated": "no data", "Boiling point": "3573 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "10070 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.26 }, "Liquid range": "2250 K", "Melting point": "1323 K", "Mendeleev no": 48, "Mineral hardness": "no data", "Molar volume": "22.55 cm<sup>3</sup>", Name: "Actinium", "Oxidation states": [3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "12 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.47, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "no data GPa", "Metallic radius": 1.878, iupac_ordering: 32, "IUPAC ordering": 32, "Ground level": "2D3/2", "Ionization energies": [5.380226, 11.75, 17.431, 44.8, 55, 67, 79, 98.9, 113.9, 143.9, 161.1, 233, 255, 279, 305, 330, 355, 390, 416, 444, 470, 610, 640, 670, 710, 780, 820, 920, 950, 1030, 1100, 1170, 1240, 1310, 1380, 1460, 1530, 1610, 1680, 1750, 1820, 1900, 1970, 2298, 2362, 2430, 2503, 2572, 2639, 2762, 2833, 2908, 2980, 3264, 3334, 3409, 3479, 3811, 3893, 4093, 4175, 6767, 6923, 7088, 7265, 7430, 7600, 7950, 8120, 8310, 8480, 8970, 9120, 9290, 9440, 10480, 10660, 11030, 11200, 23480, 23890, 24340, 24760, 28610, 29160, 29850, 30293.1, 119938.6, 122062.9], "Electron affinity": 0.35 }, Ag: { "Atomic mass": 107.8682, "Atomic no": 47, "Atomic orbitals": { "1s": -900.324578, "2p": -120.913351, "2s": -129.859807, "3d": -13.367803, "3p": -20.06763, "3s": -23.678437, "4d": -0.298706, "4p": -2.086602, "4s": -3.22309, "5s": -0.157407 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.65, "Boiling point": "2435 K", "Brinell hardness": "24.5 MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "18.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "10490 kg m<sup>-3</sup>", "Electrical resistivity": "1.63 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 1: 1.29, 2: 1.08, 3: 0.89 }, "Liquid range": "1200.07 K", "Melting point": "1234.93 K", "Mendeleev no": 71, "Mineral hardness": "2.5", "Molar volume": "10.27 cm<sup>3</sup>", Name: "Silver", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.37", Reflectivity: "97 %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, IV: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, IVSQ: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, V: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } }, VI: { "": { crystal_radius: 1.29, ionic_radius: 1.15 } }, VII: { "": { crystal_radius: 1.36, ionic_radius: 1.22 } }, VIII: { "": { crystal_radius: 1.42, ionic_radius: 1.28 } } }, 2: { IVSQ: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } }, VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } } }, 3: { IVSQ: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, VI: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "430 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "2600 m s<sup>-1</sup>", "Vickers hardness": "251 MN m<sup>-2</sup>", X: 1.93, "Youngs modulus": "83 GPa", "Metallic radius": 1.445, iupac_ordering: 72, "IUPAC ordering": 72, "Ground level": "2S1/2", "Ionization energies": [7.576234, 21.4844, 34.8, 49, 65, 82, 106, 125, 145.1, 167, 188, 271.46, 294, 321, 347, 381, 408.43, 469, 500.87, 885, 946, 1013, 1082, 1149, 1231, 1308, 1382, 1460, 1535, 1747, 1810.5, 1888, 1979, 2077, 2131, 2302, 2371.99, 5558, 5753, 5966, 6170, 6551, 6785, 7082, 7271.298, 30097.318, 30965.698], "Electron affinity": 1.304473 }, Al: { "Atomic mass": 26.9815386, "Atomic no": 13, "Atomic orbitals": { "1s": -55.156044, "2p": -2.564018, "2s": -3.934827, "3p": -0.102545, "3s": -0.286883 }, "Atomic radius": 1.25, "Atomic radius calculated": 1.18, "Boiling point": "2792 K", "Brinell hardness": "245 MN m<sup>-2</sup>", "Bulk modulus": "76 GPa", "Coefficient of linear thermal expansion": "23.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2700 kg m<sup>-3</sup>", "Electrical resistivity": "2.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>1</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 0.675 }, "Liquid range": "1858.53 K", "Melting point": "933.47 K", "Mendeleev no": 80, "Mineral hardness": "2.75", "Molar volume": "10.00 cm<sup>3</sup>", Name: "Aluminum", "Oxidation states": [1, 3], "Poissons ratio": "0.35", Reflectivity: "71 %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, V: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } }, VI: { "": { crystal_radius: 0.675, ionic_radius: 0.535 } } } }, "Superconduction temperature": "1.175 K", "Thermal conductivity": "235 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.84, "Velocity of sound": "5100 m s<sup>-1</sup>", "Vickers hardness": "167 MN m<sup>-2</sup>", X: 1.61, "Youngs modulus": "70 GPa", "NMR Quadrupole Moment": { "Al-27": 146.6 }, "Metallic radius": 1.43, iupac_ordering: 80, "IUPAC ordering": 80, "Ground level": "2P°1/2", "Ionization energies": [5.985769, 18.82855, 28.447642, 119.9924, 153.8252, 190.49, 241.76, 284.64, 330.21, 398.65, 442.005, 2085.97702, 2304.14007], "Electron affinity": 0.432835 }, Am: { "Atomic mass": 243, "Atomic no": 95, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2880 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>7</sup>.7s<sup>2</sup>", "Ionic radii": { 2: 1.4, 3: 1.115, 4: 0.99 }, "Liquid range": "1431 K", "Melting point": "1449 K", "Mendeleev no": 42, "Mineral hardness": "no data", "Molar volume": "17.63 cm<sup>3</sup>", Name: "Americium", "Oxidation states": [2, 3, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } }, VIII: { "": { crystal_radius: 1.4, ionic_radius: 1.26 } }, IX: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } } }, 3: { VI: { "": { crystal_radius: 1.115, ionic_radius: 0.975 } }, VIII: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "0.6 K", "Thermal conductivity": "10 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.44, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.73, iupac_ordering: 26, "IUPAC ordering": 26, "Ground level": "8S°7/2", "Ionization energies": [5.97381, 11.7, 21.7, 36.8, 50, 67.9, 95, 110, 125, 141, 163, 184, 206, 225, 242, 284, 305, 424, 451, 481, 511, 541, 571, 616, 646, 680, 711, 870, 900, 940, 980, 1090, 1130, 1240, 1280, 1410, 1490, 1570, 1650, 1730, 1820, 1900, 1980, 2070, 2160, 2240, 2320, 2410, 2480, 2874, 2946, 3021, 3101, 3178, 3251, 3402, 3479, 3563, 3641, 3956, 4033, 4115, 4191, 4642, 4733, 4960, 5050, 8040, 8210, 8390, 8590, 8770, 8950, 9380, 9560, 9770, 9960, 10490, 10650, 10830, 11e3, 12400, 12600, 13e3, 13190, 27110, 27550, 28040, 28500, 33700, 34300, 35100, 35549.4, 139769.5, 142161], "Electron affinity": 0.1 }, Ar: { "Atomic mass": 39.948, "Atomic no": 18, "Atomic orbitals": { "1s": -113.800134, "2p": -8.443439, "2s": -10.794172, "3p": -0.38233, "3s": -0.883384 }, "Atomic radius": 0.71, "Atomic radius calculated": 0.71, "Boiling point": "87.3 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "150.8 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>6</sup>", "Liquid range": "3.5 K", "Max oxidation state": 0, "Melting point": "83.8 K", "Mendeleev no": 3, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "22.56 cm<sup>3</sup>", Name: "Argon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000281", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.01772 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.88, "Velocity of sound": "319 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 3, "IUPAC ordering": 3, "Ground level": "1S0", "Ionization energies": [15.7596119, 27.62967, 40.735, 59.58, 74.84, 91.29, 124.41, 143.4567, 422.6, 479.76, 540.4, 619, 685.5, 755.13, 855.5, 918.375, 4120.6657, 4426.2229], "Electron affinity": -1.02 }, As: { "Atomic mass": 74.9216, "Atomic no": 33, "Atomic orbitals": { "1s": -423.336658, "2p": -47.527869, "2s": -53.093086, "3d": -1.542767, "3p": -4.851725, "3s": -6.730755, "4p": -0.197497, "4s": -0.52367 }, "Atomic radius": 1.15, "Atomic radius calculated": 1.14, "Boiling point": "887 K", "Brinell hardness": "1440 MN m<sup>-2</sup>", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "1700 K", "Density of solid": "5727 kg m<sup>-3</sup>", "Electrical resistivity": "33 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>3</sup>", "ICSD oxidation states": [2, 3, 5, -2, -3, -1], "Ionic radii": { 3: 0.72, 5: 0.6 }, "Liquid range": "203 K", "Melting point": "1090 K", "Mendeleev no": 89, "Mineral hardness": "3.5", "Molar volume": "12.95 cm<sup>3</sup>", Name: "Arsenic", "Oxidation states": [-3, 2, 3, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001552", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } } }, 5: { IV: { "": { crystal_radius: 0.475, ionic_radius: 0.335 } }, VI: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "50 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.85, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.18, "Youngs modulus": "8 GPa", "Metallic radius": "no data", iupac_ordering: 89, "IUPAC ordering": 89, "Ground level": "4S°3/2", "Ionization energies": [9.78855, 18.5892, 28.349, 50.15, 62.77, 121.19, 147, 180, 213, 247, 296, 333, 375, 418, 460, 587.6, 628.8, 672.9, 728.9, 774, 814, 911.7, 956.79, 2356.9, 2486, 2626, 2766, 2938, 3088.1, 3287, 3411.643, 14447.678, 15028.907], "Electron affinity": 0.80482 }, At: { "Atomic mass": 210, "Atomic no": 85, "Atomic orbitals": { "1s": -3127.390276, "2p": -513.044243, "2s": -531.81835, "3d": -103.060375, "3p": -119.995013, "3s": -129.035542, "4d": -18.295162, "4f": -8.063483, "4p": -25.778264, "4s": -29.809515, "5d": -1.643758, "5p": -4.027061, "5s": -5.453383, "6p": -0.255453, "6s": -0.560189 }, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>5</sup>", "Ionic radii": { 7: 0.76 }, "Liquid range": "no data K", "Melting point": "575 K", "Mendeleev no": 96, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Astatine", "Oxidation states": [-1, 1, 3, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 7: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "2 (estimate)W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 98, "IUPAC ordering": 98, "Ground level": "2P°3/2", "Ionization energies": [9.31751, 17.88, 26.58, 39.65, 50.39, 72, 85.1, 130.1, 149, 169, 192.1, 212, 236, 263, 287, 311, 335, 452, 481, 510, 540, 600, 630, 720, 750, 790, 860, 920, 990, 1050, 1120, 1180, 1250, 1320, 1380, 1450, 1510, 1590, 1650, 1948, 2007, 2071, 2139, 2203, 2266, 2373, 2439, 2510, 2576, 2841, 2905, 2977, 3042, 3312, 3388, 3573, 3649, 5976, 6122, 6279, 6445, 6604, 6759, 7068, 7230, 7410, 7570, 8030, 8180, 8330, 8480, 9330, 9500, 9830, 9990, 21210, 21600, 22030, 22420, 25580, 26090, 26730, 27139, 107923.4, 109886], "Electron affinity": 2.415787 }, Au: { "Atomic mass": 196.966569, "Atomic no": 79, "Atomic orbitals": { "1s": -2683.508245, "2p": -430.725701, "2s": -447.888973, "3d": -81.511751, "3p": -96.707, "3s": -104.824516, "4d": -12.131815, "4f": -3.486824, "4p": -18.578652, "4s": -22.078357, "5d": -0.304738, "5p": -2.002495, "5s": -3.113936, "6s": -0.162334 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.74, "Boiling point": "3129 K", "Brinell hardness": "2450 MN m<sup>-2</sup>", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "14.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "19300 kg m<sup>-3</sup>", "Electrical resistivity": "2.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>1</sup>", "Ionic radii": { 1: 1.51, 3: 0.99, 5: 0.71 }, "Liquid range": "1791.67 K", "Melting point": "1337.33 K", "Mendeleev no": 70, "Mineral hardness": "2.5", "Molar volume": "10.21 cm<sup>3</sup>", Name: "Gold", "Oxidation states": [-1, 1, 2, 3, 5], "Poissons ratio": "0.44", Reflectivity: "95 %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.51, ionic_radius: 1.37 } } }, 3: { IVSQ: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "320 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.14, "Velocity of sound": "1740 m s<sup>-1</sup>", "Vickers hardness": "216 MN m<sup>-2</sup>", X: 2.54, "Youngs modulus": "78 GPa", "Metallic radius": 1.442, iupac_ordering: 71, "IUPAC ordering": 71, "Ground level": "2S1/2", "Ionization energies": [9.225554, 20.203, 30, 45, 60, 74, 94, 112, 130.1, 149, 168.2, 248, 275, 299, 324, 365, 392, 433, 487, 520, 550, 600, 650, 710, 760, 820, 870, 930, 990, 1040, 1100, 1150, 1210, 1475, 1527, 1584, 1644, 1702, 1758, 1845, 1904, 1967, 2026, 2261, 2320, 2383, 2443, 2640, 2708, 2870, 2941, 4888, 5013, 5156, 5307, 5452, 5594, 5846, 5994, 6156, 6305, 6724, 6854, 6997, 7130, 7760, 7910, 8210, 8360, 18040, 18400, 18790, 19150, 21470, 21920, 22500, 22868.1, 91515.82, 93254.3], "Electron affinity": 2.30861025 }, B: { "Atomic mass": 10.811, "Atomic no": 5, "Atomic orbitals": { "1s": -6.564347, "2p": -0.136603, "2s": -0.344701 }, "Atomic radius": 0.85, "Atomic radius calculated": 0.87, "Boiling point": "4200 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2460 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>12</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>1</sup>", "ICSD oxidation states": [3, -3], "Ionic radii": { 3: 0.41 }, "Liquid range": "1851 K", "Melting point": "2349 K", "Mendeleev no": 86, "Mineral hardness": "9.3", "Molar volume": "4.39 cm<sup>3</sup>", Name: "Boron", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { III: { "": { crystal_radius: 0.15, ionic_radius: 0.01 } }, IV: { "": { crystal_radius: 0.25, ionic_radius: 0.11 } }, VI: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "27 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.92, "Velocity of sound": "16200 m s<sup>-1</sup>", "Vickers hardness": "49000 MN m<sup>-2</sup>", X: 2.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "B-10": 84.59, "B-11": 40.59 }, "Metallic radius": "no data", iupac_ordering: 81, "IUPAC ordering": 81, "Ground level": "2P°1/2", "Ionization energies": [8.298019, 25.15483, 37.93059, 259.3715, 340.2260229], "Electron affinity": 0.27972325 }, Ba: { "Atomic mass": 137.327, "Atomic no": 56, "Atomic orbitals": { "1s": -1305.743258, "2p": -189.598483, "2s": -200.844444, "3d": -28.528933, "3p": -37.536931, "3s": -42.359434, "4d": -3.432441, "4p": -6.497622, "4s": -8.257061, "5p": -0.698605, "5s": -1.157159, "6s": -0.118967 }, "Atomic radius": 2.15, "Atomic radius calculated": 2.53, "Boiling point": "2143 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "9.6 GPa", "Coefficient of linear thermal expansion": "20.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "3510 kg m<sup>-3</sup>", "Electrical resistivity": "34 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].6s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.49 }, "Liquid range": "1143 K", "Melting point": "1000 K", "Mendeleev no": 14, "Mineral hardness": "1.25", "Molar volume": "38.16 cm<sup>3</sup>", Name: "Barium", "Oxidation states": [2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "4.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } }, VII: { "": { crystal_radius: 1.52, ionic_radius: 1.38 } }, VIII: { "": { crystal_radius: 1.56, ionic_radius: 1.42 } }, IX: { "": { crystal_radius: 1.61, ionic_radius: 1.47 } }, X: { "": { crystal_radius: 1.66, ionic_radius: 1.52 } }, XI: { "": { crystal_radius: 1.71, ionic_radius: 1.57 } }, XII: { "": { crystal_radius: 1.75, ionic_radius: 1.61 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "18 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.68, "Velocity of sound": "1620 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.89, "Youngs modulus": "13 GPa", "Metallic radius": 2.236, iupac_ordering: 13, "IUPAC ordering": 13, "Ground level": "1S0", "Ionization energies": [5.2116646, 10.003826, 35.8438, 47, 58, 71, 86, 101, 130.5, 146.52, 241, 267.1, 296, 325, 354, 390, 422, 455, 488, 520, 646, 679, 717, 752, 809, 846, 935, 976.62, 1695, 1776, 1864, 1958, 2047, 2142, 2256, 2349, 2452, 2547, 2814, 2901, 2994, 3081, 3266, 3363, 3546, 3640, 8326, 8565, 8831, 9077, 9739, 10023, 10376, 10616.42, 43485.366, 44561.47], "Electron affinity": 0.144626 }, Be: { "Atomic mass": 9.012182, "Atomic no": 4, "Atomic orbitals": { "1s": -3.856411, "2s": -0.205744 }, "Atomic radius": 1.05, "Atomic radius calculated": 1.12, "Boiling point": "2742 K", "Brinell hardness": "600 MN m<sup>-2</sup>", "Bulk modulus": "130 GPa", "Coefficient of linear thermal expansion": "11.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1848 kg m<sup>-3</sup>", "Electrical resistivity": "3.8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.59 }, "Liquid range": "1182 K", "Melting point": "1560 K", "Mendeleev no": 77, "Mineral hardness": "5.5", "Molar volume": "4.85 cm<sup>3</sup>", Name: "Beryllium", "Oxidation states": [2], "Poissons ratio": "0.032", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "132 GPa", "Shannon radii": { 2: { III: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } }, IV: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } }, VI: { "": { crystal_radius: 0.59, ionic_radius: 0.45 } } } }, "Superconduction temperature": "0.026 K", "Thermal conductivity": "190 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.53, "Velocity of sound": "13000 m s<sup>-1</sup>", "Vickers hardness": "1670 MN m<sup>-2</sup>", X: 1.57, "Youngs modulus": "287 GPa", "NMR Quadrupole Moment": { "Be-9": 52.88 }, "Metallic radius": 1.12, iupac_ordering: 17, "IUPAC ordering": 17, "Ground level": "1S0", "Ionization energies": [9.322699, 18.21115, 153.896205, 217.7185861], "Electron affinity": -0.52 }, Bi: { "Atomic mass": 208.9804, "Atomic no": 83, "Atomic orbitals": { "1s": -2975.550959, "2p": -484.716359, "2s": -502.950758, "3d": -95.532476, "3p": -111.883393, "3s": -120.613998, "4d": -16.084817, "4f": -6.382744, "4p": -23.218641, "4s": -27.07034, "5d": -1.139408, "5p": -3.293637, "5s": -4.611934, "6p": -0.180198, "6s": -0.426129 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.43, "Boiling point": "1837 K", "Brinell hardness": "94.2 MN m<sup>-2</sup>", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "13.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9780 kg m<sup>-3</sup>", "Electrical resistivity": "130 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>3</sup>", "ICSD oxidation states": [1, 2, 3, 5], "Ionic radii": { 3: 1.17, 5: 0.9 }, "Liquid range": "1292.6 K", "Melting point": "544.4 K", "Mendeleev no": 87, "Mineral hardness": "2.25", "Molar volume": "21.31 cm<sup>3</sup>", Name: "Bismuth", "Oxidation states": [-3, 3, 5], "Poissons ratio": "0.33", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "12 GPa", "Shannon radii": { 3: { V: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VI: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VIII: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } } }, 5: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.07, "Velocity of sound": "1790 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.02, "Youngs modulus": "32 GPa", "Metallic radius": 1.82, iupac_ordering: 87, "IUPAC ordering": 87, "Ground level": "4S°3/2", "Ionization energies": [7.285516, 16.703, 25.57075, 45.37, 54.856, 88.4, 103, 122, 143, 161.1, 183, 208, 229, 252, 272.6, 370.2, 409, 436, 464, 520, 550, 620, 660, 690, 750, 810, 870, 930, 990, 1060, 1120, 1180, 1250, 1310, 1380, 1440, 1500, 1784, 1840, 1902, 1967, 2029, 2090, 2190, 2253, 2321, 2385, 2641, 2703, 2771, 2835, 3078, 3151, 3329, 3401.8, 5599, 5740, 5892, 6054, 6208, 6358, 6648, 6804, 6977, 7137, 7580, 7720, 7870, 8010, 8780, 8950, 9270, 9430, 20130, 20500, 20920, 21300, 24150, 24640, 25260, 25656.9, 102251.76, 104132.8], "Electron affinity": 0.94236213 }, Bk: { "Atomic mass": 247, "Atomic no": 97, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "14780 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>9</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.1, 4: 0.97 }, "Liquid range": "no data K", "Melting point": "1259 K", "Mendeleev no": 40, "Mineral hardness": "no data", "Molar volume": "16.84 cm<sup>3</sup>", Name: "Berkelium", "Oxidation states": [3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 4: { VI: { "": { crystal_radius: 0.97, ionic_radius: 0.83 } }, VIII: { "": { crystal_radius: 1.07, ionic_radius: 0.93 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "10 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.44, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.703, iupac_ordering: 24, "IUPAC ordering": 24, "Ground level": "6H°15/2", "Ionization energies": [6.19785, 11.9, 21.6, 36, 56, 70.1, 90, 114, 130, 147, 171, 195, 218, 240, 259, 279, 303, 339, 361, 497, 526, 557, 590, 621, 652, 700, 733, 768, 800, 960, 1e3, 1040, 1080, 1200, 1240, 1360, 1410, 1550, 1630, 1720, 1800, 1890, 1970, 2050, 2140, 2240, 2320, 2410, 2490, 2580, 2670, 3080, 3154, 3232, 3315, 3393, 3469, 3630, 3709, 3797, 3877, 4202, 4281, 4365, 4445, 4940, 5040, 5270, 5360, 8500, 8670, 8850, 9050, 9240, 9420, 9880, 10070, 10280, 10480, 11020, 11190, 11380, 11550, 13090, 13300, 13720, 13910, 28380, 28800, 29300, 29800, 35500, 36200, 37e3, 37457.6, 146904.7, 149398], "Electron affinity": -1.72 }, Br: { "Atomic mass": 79.904, "Atomic no": 35, "Atomic orbitals": { "1s": -480.182643, "2p": -55.67796, "2s": -61.710022, "3d": -2.52211, "3p": -6.298805, "3s": -8.409057, "4p": -0.295334, "4s": -0.720066 }, "Atomic radius": 1.15, "Atomic radius calculated": 0.94, "Boiling point": "332 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "1.9 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "586 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>18</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>5</sup>", "ICSD oxidation states": [5, -1], "Ionic radii": { "-1": 1.82, 3: 0.73, 5: 0.45, 7: 0.53 }, "Liquid range": "66.2 K", "Melting point": "265.8 K", "Mendeleev no": 98, "Mineral hardness": "no data", "Molar volume": "19.78 cm<sup>3</sup>", Name: "Bromine", "Oxidation states": [-1, 1, 3, 4, 5, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001132", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 1.82, ionic_radius: 1.96 } } }, 3: { IVSQ: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } } }, 5: { IIIPY: { "": { crystal_radius: 0.45, ionic_radius: 0.31 } } }, 7: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } }, VI: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.12 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.85, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.96, "Youngs modulus": "no data GPa", "Metallic radius": 1.14, iupac_ordering: 100, "IUPAC ordering": 100, "Ground level": "2P°3/2", "Ionization energies": [11.81381, 21.591, 34.871, 47.782, 59.595, 87.39, 103.03, 192.61, 224, 261, 301, 338, 393, 436, 481, 530, 577, 716.3, 761, 809.8, 870, 920.8, 963, 1070.6, 1119.17, 2731.4, 2869, 3021, 3169, 3361, 3523.1, 3735, 3868.986, 16317.011, 16937.127], "Electron affinity": 3.3635883 }, C: { "Atomic mass": 12.0107, "Atomic no": 6, "Atomic orbitals": { "1s": -9.947718, "2p": -0.199186, "2s": -0.500866 }, "Atomic radius": 0.7, "Atomic radius calculated": 0.67, "Boiling point": "4300 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "7.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2267 kg m<sup>-3</sup>", "Electrical resistivity": "about 1000 - direction dependent10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, -4, -3, -2], "Ionic radii": { 4: 0.3 }, "Liquid range": "500 K", "Melting point": "3800 K", "Mendeleev no": 95, "Mineral hardness": "0.5 (graphite; diamond is 10.0)(no units)", "Molar volume": "5.29 cm<sup>3</sup>", Name: "Carbon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "27 %", "Refractive index": "2.417 (diamond)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { III: { "": { crystal_radius: 0.06, ionic_radius: -0.08 } }, IV: { "": { crystal_radius: 0.29, ionic_radius: 0.15 } }, VI: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.7, "Velocity of sound": "18350 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.55, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "C-11": 33.27 }, "Metallic radius": "no data", iupac_ordering: 86, "IUPAC ordering": 86, "Ground level": "3P0", "Ionization energies": [11.260288, 24.383154, 47.88778, 64.49352, 392.090518, 489.993198], "Electron affinity": 1.262113612 }, Ca: { "Atomic mass": 40.078, "Atomic no": 20, "Atomic orbitals": { "1s": -143.935181, "2p": -12.285376, "2s": -15.046905, "3p": -1.030572, "3s": -1.706331, "4s": -0.141411 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.94, "Boiling point": "1757 K", "Brinell hardness": "167 MN m<sup>-2</sup>", "Bulk modulus": "17 GPa", "Coefficient of linear thermal expansion": "22.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1550 kg m<sup>-3</sup>", "Electrical resistivity": "3.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].4s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.14 }, "Liquid range": "642 K", "Melting point": "1115 K", "Mendeleev no": 16, "Mineral hardness": "1.75", "Molar volume": "26.20 cm<sup>3</sup>", Name: "Calcium", "Oxidation states": [2], "Poissons ratio": "0.31", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "7.4 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VII: { "": { crystal_radius: 1.2, ionic_radius: 1.06 } }, VIII: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } }, IX: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, X: { "": { crystal_radius: 1.37, ionic_radius: 1.23 } }, XII: { "": { crystal_radius: 1.48, ionic_radius: 1.34 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "200 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.31, "Velocity of sound": "3810 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1, "Youngs modulus": "20 GPa", "NMR Quadrupole Moment": { "Ca-41": -66.5, "Ca-43": -40.8 }, "Metallic radius": 1.976, iupac_ordering: 15, "IUPAC ordering": 15, "Ground level": "1S0", "Ionization energies": [6.11315547, 11.871719, 50.91316, 67.2732, 84.34, 108.78, 127.21, 147.24, 188.54, 211.275, 591.6, 658.2, 728.6, 817.2, 894, 973.7, 1086.8, 1157.726, 5128.8578, 5469.8616], "Electron affinity": 0.024551 }, Cd: { "Atomic mass": 112.411, "Atomic no": 48, "Atomic orbitals": { "1s": -941.476646, "2p": -127.63512, "2s": -136.83249, "3d": -14.685252, "3p": -21.637522, "3s": -25.379908, "4d": -0.47053, "4p": -2.39526, "4s": -3.596069, "5s": -0.204228 }, "Atomic radius": 1.55, "Atomic radius calculated": 1.61, "Boiling point": "1040 K", "Brinell hardness": "203 MN m<sup>-2</sup>", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "30.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8650 kg m<sup>-3</sup>", "Electrical resistivity": "7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.09 }, "Liquid range": "445.78 K", "Melting point": "594.22 K", "Mendeleev no": 75, "Mineral hardness": "2.0", "Molar volume": "13.00 cm<sup>3</sup>", Name: "Cadmium", "Oxidation states": [1, 2], "Poissons ratio": "0.30", Reflectivity: "67 %", "Refractive index": "no data", "Rigidity modulus": "19 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, V: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } }, VII: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VIII: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } }, XII: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } } } }, "Superconduction temperature": "0.517 K", "Thermal conductivity": "97 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "2310 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.69, "Youngs modulus": "50 GPa", "Metallic radius": 1.51, iupac_ordering: 75, "IUPAC ordering": 75, "Ground level": "1S0", "Ionization energies": [8.99382, 16.908313, 37.468, 51, 67.9, 87, 105, 130.1, 150, 173, 195, 218, 305, 329, 358, 385, 421, 452.6, 513, 546.19, 963, 1026, 1095, 1167, 1237, 1320, 1401, 1477, 1558, 1635, 1852, 1917.9, 1998, 2091, 2195, 2250, 2427, 2498.62, 5839, 6039, 6257, 6460, 6869, 7109, 7414, 7607.95, 31451.062, 32341.49], "Electron affinity": -0.72 }, Ce: { "Atomic mass": 140.116, "Atomic no": 58, "Atomic orbitals": { "1s": -1406.148284, "2p": -206.925148, "2s": -218.684842, "3d": -32.412569, "3p": -41.938282, "3s": -47.035283, "4d": -4.192548, "4f": -0.337442, "4p": -7.532106, "4s": -9.432744, "5d": -0.14055, "5p": -0.85011, "5s": -1.369728, "6s": -0.133974 }, "Atomic radius": 1.85, "Atomic radius calculated": "no data", "Boiling point": "3633 K", "Brinell hardness": "412 MN m<sup>-2</sup>", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "6.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "6689 kg m<sup>-3</sup>", "Electrical resistivity": "74 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>1</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.15, 4: 1.01 }, "Liquid range": "2565 K", "Melting point": "1068 K", "Mendeleev no": 32, "Mineral hardness": "2.5", "Molar volume": "20.69 cm<sup>3</sup>", Name: "Cerium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } }, VII: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, VIII: { "": { crystal_radius: 1.283, ionic_radius: 1.143 } }, IX: { "": { crystal_radius: 1.336, ionic_radius: 1.196 } }, X: { "": { crystal_radius: 1.39, ionic_radius: 1.25 } }, XII: { "": { crystal_radius: 1.48, ionic_radius: 1.34 } } }, 4: { VI: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VIII: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, X: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, XII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } } }, "Superconduction temperature": "0.022  (under pressure)K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.42, "Velocity of sound": "2100 m s<sup>-1</sup>", "Vickers hardness": "270 MN m<sup>-2</sup>", X: 1.12, "Youngs modulus": "34 GPa", "Metallic radius": 1.707, iupac_ordering: 46, "IUPAC ordering": 46, "Ground level": "1G°4", "Ionization energies": [5.5386, 10.956, 20.1974, 36.906, 65.55, 77.6, 91, 106, 125, 140, 172, 192.24, 312, 340, 371, 403, 435, 472, 509, 543, 579, 613, 749, 785, 824, 862, 924, 965, 1060, 1103.5, 1908, 1994, 2087, 2185, 2280, 2378, 2500, 2600, 2706, 2806, 3087, 3176, 3274, 3366, 3570, 3672, 3865, 3963, 9020, 9269, 9545, 9803, 10542, 10840, 11210, 11459.85, 46840.306, 47965.72], "Electron affinity": 0.572 }, Cf: { "Atomic mass": 251, "Atomic no": 98, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "15100 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>10</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.09, 4: 0.961 }, "Liquid range": "no data K", "Melting point": "1173 K", "Mendeleev no": 39, "Mineral hardness": "no data", "Molar volume": "16.50 cm<sup>3</sup>", Name: "Californium", "Oxidation states": [2, 3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } }, 4: { VI: { "": { crystal_radius: 0.961, ionic_radius: 0.821 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, iupac_ordering: 23, "IUPAC ordering": 23, "Ground level": "5I8", "Ionization energies": [6.28166, 12, 22.4, 37.7, 51.9, 75, 91, 112.9, 133, 152, 178, 201, 225, 247, 265, 286, 310, 334, 368, 390, 536, 566, 597, 630, 662, 695, 744, 778, 814, 847, 1010, 1050, 1090, 1120, 1250, 1300, 1420, 1470, 1620, 1700, 1790, 1880, 1960, 2050, 2130, 2220, 2320, 2410, 2490, 2580, 2670, 2750, 3186, 3261, 3340, 3424, 3503, 3581, 3747, 3828, 3915, 3998, 4329, 4407, 4494, 4570, 5100, 5190, 5430, 5520, 8730, 8900, 9090, 9290, 9480, 9660, 10140, 10330, 10550, 10740, 11300, 11470, 11650, 11820, 13450, 13660, 14080, 14280, 29e3, 29500, 3e4, 30500, 36500, 37100, 37900, 38443.5, 150579.3, 153124], "Electron affinity": -1.01 }, Cl: { "Atomic mass": 35.453, "Atomic no": 17, "Atomic orbitals": { "1s": -100.369229, "2p": -7.039982, "2s": -9.187993, "3p": -0.32038, "3s": -0.754458 }, "Atomic radius": 1, "Atomic radius calculated": 0.79, "Boiling point": "239.11 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "1.1 (liquid)GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "417 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>10</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>5</sup>", "ICSD oxidation states": [-1], "Ionic radii": { "-1": 1.67, 5: 0.26, 7: 0.41 }, "Liquid range": "67.51 K", "Melting point": "171.6 K", "Mendeleev no": 99, "Mineral hardness": "no data", "Molar volume": "17.39 cm<sup>3</sup>", Name: "Chlorine", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000773", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 1.67, ionic_radius: 1.81 } } }, 5: { IIIPY: { "": { crystal_radius: 0.26, ionic_radius: 0.12 } } }, 7: { IV: { "": { crystal_radius: 0.22, ionic_radius: 0.08 } }, VI: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0089 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.75, "Velocity of sound": "206 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.16, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Cl-35": -81.65, "Cl-37": -64.35 }, "Metallic radius": "no data", iupac_ordering: 101, "IUPAC ordering": 101, "Ground level": "2P°3/2", "Ionization energies": [12.967633, 23.81364, 39.8, 53.24, 67.68, 96.94, 114.2013, 348.306, 400.851, 456.7, 530, 591.58, 656.3, 750.23, 809.198, 3658.3438, 3946.2909], "Electron affinity": 3.61272528 }, Cm: { "Atomic mass": 247, "Atomic no": 96, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "3383 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "13510 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>7</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.11, 4: 0.99 }, "Liquid range": "1770 K", "Melting point": "1613 K", "Mendeleev no": 41, "Mineral hardness": "no data", "Molar volume": "18.05 cm<sup>3</sup>", Name: "Curium", "Oxidation states": [3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "8.8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.743, iupac_ordering: 25, "IUPAC ordering": 25, "Ground level": "9D°2", "Ionization energies": [5.99141, 12.4, 20.1, 37.7, 51, 69.1, 97, 112, 128, 144, 167, 190, 213, 235, 253, 272, 311, 332, 460, 489, 518, 550, 580, 611, 657, 689, 723, 755, 910, 950, 990, 1030, 1140, 1180, 1300, 1340, 1480, 1560, 1650, 1730, 1810, 1890, 1980, 2060, 2160, 2240, 2320, 2410, 2490, 2580, 2976, 3050, 3125, 3207, 3284, 3360, 3515, 3593, 3679, 3758, 4078, 4156, 4239, 4317, 4791, 4880, 5110, 5200, 8270, 8440, 8620, 8820, 9e3, 9180, 9630, 9820, 10020, 10220, 10760, 10920, 11100, 11270, 12740, 12950, 13350, 13550, 27740, 28180, 28700, 29100, 34600, 35200, 36e3, 36493, 143299.6, 145743], "Electron affinity": 0.28 }, Co: { "Atomic mass": 58.933195, "Atomic no": 27, "Atomic orbitals": { "1s": -275.616639, "2p": -28.152095, "2s": -32.379758, "3d": -0.322368, "3p": -2.388285, "3s": -3.651812, "4s": -0.204497 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.52, "Boiling point": "3200 K", "Brinell hardness": "700 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.0 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "8900 kg m<sup>-3</sup>", "Electrical resistivity": "6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>7</sup>.4s<sup>2</sup>", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": { 2: 0.885, 3: 0.75, 4: 0.67 }, "Ionic radii hs": { 2: 0.885, 3: 0.75, 4: 0.67 }, "Ionic radii ls": { 2: 0.79, 3: 0.685 }, "Liquid range": "1432 K", "Melting point": "1768 K", "Mendeleev no": 64, "Mineral hardness": "5.0", "Molar volume": "6.67 cm<sup>3</sup>", Name: "Cobalt", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.31", Reflectivity: "67 %", "Refractive index": "no data", "Rigidity modulus": "75 GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.72, ionic_radius: 0.58 } }, V: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, VI: { "Low Spin": { crystal_radius: 0.79, ionic_radius: 0.65 }, "High Spin": { crystal_radius: 0.885, ionic_radius: 0.745 } }, VIII: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } } }, 3: { VI: { "High Spin": { crystal_radius: 0.75, ionic_radius: 0.61 }, "Low Spin": { crystal_radius: 0.685, ionic_radius: 0.545 } } }, 4: { IV: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } }, VI: { "High Spin": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2, "Velocity of sound": "4720 m s<sup>-1</sup>", "Vickers hardness": "1043 MN m<sup>-2</sup>", X: 1.88, "Youngs modulus": "209 GPa", "NMR Quadrupole Moment": { "Co-59": 420.3 }, "Metallic radius": 1.25, iupac_ordering: 67, "IUPAC ordering": 67, "Ground level": "4F9/2", "Ionization energies": [7.88101, 17.0844, 33.5, 51.27, 79.5, 102, 128.9, 157.8, 186.14, 275.4, 305.32, 336.1, 378.5, 410, 441.1, 511.96, 546.588, 1397.2, 1504.5, 1606, 1724, 1844, 1960.8, 2119.4, 2218.876, 9544.1833, 10012.122], "Electron affinity": 0.662265 }, Cr: { "Atomic mass": 51.9961, "Atomic no": 24, "Atomic orbitals": { "1s": -213.881191, "2p": -20.526273, "2s": -24.113457, "3d": -0.118123, "3p": -1.65423, "3s": -2.649085, "4s": -0.150445 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.66, "Boiling point": "2944 K", "Brinell hardness": "1120 MN m<sup>-2</sup>", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "4.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 6], "Critical temperature": "no data K", "Density of solid": "7140 kg m<sup>-3</sup>", "Electrical resistivity": "12.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>5</sup>.4s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 2: 0.94 }, "Ionic radii hs": { 2: 0.94 }, "Ionic radii ls": { 2: 0.87, 3: 0.755, 4: 0.69, 5: 0.63, 6: 0.58 }, "Liquid range": "764 K", "Melting point": "2180 K", "Mendeleev no": 57, "Mineral hardness": "8.5", "Molar volume": "7.23 cm<sup>3</sup>", Name: "Chromium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "115 GPa", "Shannon radii": { 2: { VI: { "Low Spin": { crystal_radius: 0.87, ionic_radius: 0.73 }, "High Spin": { crystal_radius: 0.94, ionic_radius: 0.8 } } }, 3: { VI: { "": { crystal_radius: 0.755, ionic_radius: 0.615 } } }, 4: { IV: { "": { crystal_radius: 0.55, ionic_radius: 0.41 } }, VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } }, 5: { IV: { "": { crystal_radius: 0.485, ionic_radius: 0.345 } }, VI: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, VIII: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } }, 6: { IV: { "": { crystal_radius: 0.4, ionic_radius: 0.26 } }, VI: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "94 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "5940 m s<sup>-1</sup>", "Vickers hardness": "1060 MN m<sup>-2</sup>", X: 1.66, "Youngs modulus": "279 GPa", "NMR Quadrupole Moment": { "Cr-53": -150.5 }, "Metallic radius": 1.285, iupac_ordering: 58, "IUPAC ordering": 58, "Ground level": "7S3", "Ionization energies": [6.76651, 16.486305, 30.959, 49.16, 69.46, 90.6349, 160.29, 184.76, 209.5, 244.5, 270.8, 296.7, 354.7, 384.163, 1011.6, 1097.2, 1188, 1294.8, 1394.5, 1495.1, 1634.1, 1721.183, 7481.8628, 7894.7992], "Electron affinity": 0.6758412 }, Cs: { "Atomic mass": 132.9054519, "Atomic no": 55, "Atomic orbitals": { "1s": -1256.738791, "2p": -180.995344, "2s": -191.981873, "3d": -26.418398, "3p": -35.166423, "3s": -39.851584, "4d": -2.848386, "4p": -5.769326, "4s": -7.455966, "5p": -0.504903, "5s": -0.915819, "6s": -0.078699 }, "Atomic radius": 2.6, "Atomic radius calculated": 2.98, "Boiling point": "944 K", "Brinell hardness": "0.14 MN m<sup>-2</sup>", "Bulk modulus": "1.6 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "1938 K", "Density of solid": "1879 kg m<sup>-3</sup>", "Electrical resistivity": "21 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].6s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.81 }, "Liquid range": "642.41 K", "Melting point": "301.59 K", "Mendeleev no": 8, "Mineral hardness": "0.2", "Molar volume": "70.94 cm<sup>3</sup>", Name: "Cesium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.81, ionic_radius: 1.67 } }, VIII: { "": { crystal_radius: 1.88, ionic_radius: 1.74 } }, IX: { "": { crystal_radius: 1.92, ionic_radius: 1.78 } }, X: { "": { crystal_radius: 1.95, ionic_radius: 1.81 } }, XI: { "": { crystal_radius: 1.99, ionic_radius: 1.85 } }, XII: { "": { crystal_radius: 2.02, ionic_radius: 1.88 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "36 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.43, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.79, "Youngs modulus": "1.7 GPa", "Metallic radius": 2.719, iupac_ordering: 7, "IUPAC ordering": 7, "Ground level": "2S1/2", "Ionization energies": [3.89390572743, 23.15745, 33.195, 43, 56, 69.1, 82.9, 110.1, 125.61, 213.3, 233, 261, 289, 316, 352, 382, 413, 445, 476, 597, 629, 666, 700, 753, 791, 875, 916.1, 1592, 1672, 1757, 1848, 1936, 2029, 2137, 2230, 2329, 2422, 2683, 2767, 2859, 2945, 3118, 3214, 3392, 3485, 7989, 8224, 8484, 8726, 9350, 9629, 9974, 10208.78, 41861.075, 42912.99], "Electron affinity": 0.47163025 }, Cu: { "Atomic mass": 63.546, "Atomic no": 29, "Atomic orbitals": { "1s": -320.78852, "2p": -33.481247, "2s": -38.14131, "3d": -0.202272, "3p": -2.609244, "3s": -4.057453, "4s": -0.172056 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.45, "Boiling point": "3200 K", "Brinell hardness": "874 MN m<sup>-2</sup>", "Bulk modulus": "140 GPa", "Coefficient of linear thermal expansion": "16.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8920 kg m<sup>-3</sup>", "Electrical resistivity": "1.72 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 1: 0.91, 2: 0.87, 3: 0.68 }, "Liquid range": "1842.23 K", "Melting point": "1357.77 K", "Mendeleev no": 72, "Mineral hardness": "3.0", "Molar volume": "7.11 cm<sup>3</sup>", Name: "Copper", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", Reflectivity: "90 %", "Refractive index": "no data", "Rigidity modulus": "48 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, IV: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, VI: { "": { crystal_radius: 0.91, ionic_radius: 0.77 } } }, 2: { IV: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, IVSQ: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, V: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } }, VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } }, 3: { VI: { "Low Spin": { crystal_radius: 0.68, ionic_radius: 0.54 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "400 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.96, "Velocity of sound": "3570 m s<sup>-1</sup>", "Vickers hardness": "369 MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "130 GPa", "NMR Quadrupole Moment": { "Cu-63": -220.15, "Cu-65": -204.14 }, "Metallic radius": 1.278, iupac_ordering: 73, "IUPAC ordering": 73, "Ground level": "2S1/2", "Ionization energies": [7.72638, 20.29239, 36.841, 57.38, 79.8, 103, 139, 166, 198, 232.2, 265.33, 367, 401, 436, 483.1, 518.7, 552.8, 632.5, 670.608, 1690.5, 1800, 1918, 2044, 2179.4, 2307.3, 2479.1, 2586.954, 11062.4313, 11567.613], "Electron affinity": 1.235784 }, Dy: { "Atomic mass": 162.5, "Atomic no": 66, "Atomic orbitals": { "1s": -1843.229585, "2p": -281.558531, "2s": -295.342856, "3d": -47.4867, "3p": -59.091931, "3s": -65.299442, "4d": -5.686352, "4f": -0.265302, "4p": -10.094091, "4s": -12.551251, "5p": -0.90349, "5s": -1.547977, "6s": -0.132769 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.28, "Boiling point": "2840 K", "Brinell hardness": "500 MN m<sup>-2</sup>", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "9.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8551 kg m<sup>-3</sup>", "Electrical resistivity": "92.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>10</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 2: 1.21, 3: 1.052 }, "Liquid range": "1160 K", "Melting point": "1680 K", "Mendeleev no": 24, "Mineral hardness": "no data", "Molar volume": "19.01 cm<sup>3</sup>", Name: "Dysprosium", "Oxidation states": [2, 3], "Poissons ratio": "0.25", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "25 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, VII: { "": { crystal_radius: 1.27, ionic_radius: 1.13 } }, VIII: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } } }, 3: { VI: { "": { crystal_radius: 1.052, ionic_radius: 0.912 } }, VII: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VIII: { "": { crystal_radius: 1.167, ionic_radius: 1.027 } }, IX: { "": { crystal_radius: 1.223, ionic_radius: 1.083 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.31, "Velocity of sound": "2710 m s<sup>-1</sup>", "Vickers hardness": "540 MN m<sup>-2</sup>", X: 1.22, "Youngs modulus": "61 GPa", "Metallic radius": 1.773, iupac_ordering: 38, "IUPAC ordering": 38, "Ground level": "5I8", "Ionization energies": [5.93905, 11.647, 22.89, 41.23, 62.1, 93, 110, 127, 152, 170, 192, 224, 259, 279, 300, 332, 366, 399, 431, 464.9, 664, 702, 743, 786, 827, 872, 924, 969, 1014, 1059, 1232, 1275, 1325, 1371, 1468, 1520, 1638, 1691.7, 2882, 2987, 3098, 3217, 3331, 3445, 3607, 3725, 3852, 3970, 4303, 4407, 4523, 4629, 4945, 5066, 5296, 5412, 12081, 12370, 12690, 12986, 14144, 14495, 14936, 15228.06, 61736.56, 63073.5], "Electron affinity": 0.352 }, Er: { "Atomic mass": 167.259, "Atomic no": 68, "Atomic orbitals": { "1s": -1961.799176, "2p": -302.01827, "2s": -316.310631, "3d": -51.682149, "3p": -63.818655, "3s": -70.310142, "4d": -6.127443, "4f": -0.278577, "4p": -10.819574, "4s": -13.423547, "5p": -0.935202, "5s": -1.616073, "6s": -0.134905 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.26, "Boiling point": "3141 K", "Brinell hardness": "814 MN m<sup>-2</sup>", "Bulk modulus": "44 GPa", "Coefficient of linear thermal expansion": "12.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9066 kg m<sup>-3</sup>", "Electrical resistivity": "86.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>12</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.03 }, "Liquid range": "1371 K", "Melting point": "1802 K", "Mendeleev no": 22, "Mineral hardness": "no data", "Molar volume": "18.46 cm<sup>3</sup>", Name: "Erbium", "Oxidation states": [3], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "28 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } }, VII: { "": { crystal_radius: 1.085, ionic_radius: 0.945 } }, VIII: { "": { crystal_radius: 1.144, ionic_radius: 1.004 } }, IX: { "": { crystal_radius: 1.202, ionic_radius: 1.062 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.29, "Velocity of sound": "2830 m s<sup>-1</sup>", "Vickers hardness": "589 MN m<sup>-2</sup>", X: 1.24, "Youngs modulus": "70 GPa", "Metallic radius": 1.756, iupac_ordering: 36, "IUPAC ordering": 36, "Ground level": "3H6", "Ionization energies": [6.1077, 11.916, 22.7, 42.42, 65.1, 96, 114, 131, 158, 177, 201, 235, 268, 290, 311, 345, 381, 415, 450, 486, 520, 555, 770, 810, 853, 899, 943, 989, 1046, 1092, 1142, 1188, 1370, 1416, 1468, 1516, 1625, 1678, 1803, 1858.5, 3157, 3265, 3381, 3505, 3624, 3742, 3916, 4038, 4170, 4294, 4639, 4748, 4866, 4978, 5329, 5455, 5695, 5815, 12918, 13217, 13548, 13855, 15146, 15511, 15971, 16274.56, 65848.24, 67241.9], "Electron affinity": 0.312 }, Es: { "Atomic mass": 252, "Atomic no": 99, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>11</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "1133 K", "Mendeleev no": 38, "Mineral hardness": "no data", "Molar volume": "28.52 cm<sup>3</sup>", Name: "Einsteinium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, iupac_ordering: 22, "IUPAC ordering": 22, "Ground level": "4I°15/2", "Ionization energies": [6.36758, 12.2, 22.7, 38.8, 54.1, 71, 97, 112.9, 137, 157, 180, 206, 231, 252, 270, 294, 317, 342, 367, 398, 421, 576, 606, 638, 672, 705, 738, 790, 824, 861, 895, 1060, 1100, 1140, 1180, 1310, 1360, 1480, 1530, 1690, 1780, 1870, 1950, 2040, 2130, 2220, 2300, 2410, 2490, 2580, 2680, 2760, 2850, 3294, 3370, 3449, 3535, 3616, 3694, 3866, 3947, 4038, 4120, 4456, 4537, 4620, 4700, 5260, 5350, 5600, 5690, 8960, 9140, 9330, 9530, 9720, 9910, 10400, 10590, 10810, 11010, 11570, 11740, 11930, 12110, 13810, 14030, 14460, 14700, 29700, 30100, 30700, 31100, 37400, 38100, 38900, 39451.4, 154328.1, 156926], "Electron affinity": -0.3 }, Eu: { "Atomic mass": 151.964, "Atomic no": 63, "Atomic orbitals": { "1s": -1672.309322, "2p": -252.176697, "2s": -265.199534, "3d": -41.465518, "3p": -52.281987, "3s": -58.068128, "4d": -5.03242, "4f": -0.232773, "4p": -9.025455, "4s": -11.267747, "5p": -0.853575, "5s": -1.444087, "6s": -0.129426 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.31, "Boiling point": "1800 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "35 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "5244 kg m<sup>-3</sup>", "Electrical resistivity": "90 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>7</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.31, 3: 1.087 }, "Liquid range": "701 K", "Melting point": "1099 K", "Mendeleev no": 18, "Mineral hardness": "no data", "Molar volume": "28.97 cm<sup>3</sup>", Name: "Europium", "Oxidation states": [2, 3], "Poissons ratio": "0.15", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "7.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } }, VII: { "": { crystal_radius: 1.34, ionic_radius: 1.2 } }, VIII: { "": { crystal_radius: 1.39, ionic_radius: 1.25 } }, IX: { "": { crystal_radius: 1.44, ionic_radius: 1.3 } }, X: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } } }, 3: { VI: { "": { crystal_radius: 1.087, ionic_radius: 0.947 } }, VII: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } }, VIII: { "": { crystal_radius: 1.206, ionic_radius: 1.066 } }, IX: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "14 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.35, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "167 MN m<sup>-2</sup>", X: 1.2, "Youngs modulus": "18 GPa", "Metallic radius": 2.041, iupac_ordering: 41, "IUPAC ordering": 41, "Ground level": "8S°7/2", "Ionization energies": [5.670385, 11.24, 24.84, 42.94, 63.2, 89, 105, 120, 144, 161, 183, 213, 243, 263, 281, 311, 344.4, 518, 553, 590, 630, 667, 709, 755, 795, 838, 879, 1037, 1078, 1124, 1167, 1249, 1296, 1406, 1456.06, 2495, 2591, 2697, 2807, 2914, 3022, 3168, 3279, 3398, 3510, 3823, 3921, 4031, 4131, 4400, 4513, 4729, 4838, 10880, 11153, 11457, 11739, 12718, 13050, 13462, 13738.58, 55865.92, 57120.64], "Electron affinity": 0.11613 }, F: { "Atomic mass": 18.9984032, "Atomic no": 9, "Atomic orbitals": { "1s": -24.189391, "2p": -0.415606, "2s": -1.086859 }, "Atomic radius": 0.5, "Atomic radius calculated": 0.42, "Boiling point": "85.03 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1], "Critical temperature": "144 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>5</sup>", "ICSD oxidation states": [-1], "Ionic radii": { "-1": 1.19, 7: 0.22 }, "Liquid range": "31.5 K", "Melting point": "53.53 K", "Mendeleev no": 102, "Mineral hardness": "no data", "Molar volume": "11.20 cm<sup>3</sup>", Name: "Fluorine", "Oxidation states": [-1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000195", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { II: { "": { crystal_radius: 1.145, ionic_radius: 1.285 } }, III: { "": { crystal_radius: 1.16, ionic_radius: 1.3 } }, IV: { "": { crystal_radius: 1.17, ionic_radius: 1.31 } }, VI: { "": { crystal_radius: 1.19, ionic_radius: 1.33 } } }, 7: { VI: { "": { crystal_radius: 0.22, ionic_radius: 0.08 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0277 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.47, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.98, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "F-19": -94.2 }, "Metallic radius": "no data", iupac_ordering: 102, "IUPAC ordering": 102, "Ground level": "2P°3/2", "Ionization energies": [17.42282, 34.97081, 62.70798, 87.175, 114.249, 157.16311, 185.1868, 953.89805, 1103.11748], "Electron affinity": 3.401189824 }, Fe: { "Atomic mass": 55.845, "Atomic no": 26, "Atomic orbitals": { "1s": -254.225505, "2p": -25.551766, "2s": -29.56486, "3d": -0.295049, "3p": -2.187523, "3s": -3.360621, "4s": -0.197978 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.56, "Boiling point": "3134 K", "Brinell hardness": "490 MN m<sup>-2</sup>", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "11.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "7874 kg m<sup>-3</sup>", "Electrical resistivity": "10 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>6</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 0.92, 3: 0.785 }, "Ionic radii hs": { 2: 0.92, 3: 0.785 }, "Ionic radii ls": { 2: 0.75, 3: 0.69, 4: 0.725, 6: 0.39 }, "Liquid range": "1323 K", "Melting point": "1811 K", "Mendeleev no": 61, "Mineral hardness": "4.0", "Molar volume": "7.09 cm<sup>3</sup>", Name: "Iron", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.29", Reflectivity: "65 %", "Refractive index": "no data", "Rigidity modulus": "82 GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.77, ionic_radius: 0.63 } }, IVSQ: { "High Spin": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VI: { "Low Spin": { crystal_radius: 0.75, ionic_radius: 0.61 }, "High Spin": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "High Spin": { crystal_radius: 1.06, ionic_radius: 0.92 } } }, 3: { IV: { "High Spin": { crystal_radius: 0.63, ionic_radius: 0.49 } }, V: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "Low Spin": { crystal_radius: 0.69, ionic_radius: 0.55 }, "High Spin": { crystal_radius: 0.785, ionic_radius: 0.645 } }, VIII: { "High Spin": { crystal_radius: 0.92, ionic_radius: 0.78 } } }, 4: { VI: { "": { crystal_radius: 0.725, ionic_radius: 0.585 } } }, 6: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "80 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.04, "Velocity of sound": "4910 m s<sup>-1</sup>", "Vickers hardness": "608 MN m<sup>-2</sup>", X: 1.83, "Youngs modulus": "211 GPa", "NMR Quadrupole Moment": { "Fe-57": 160 }, "Metallic radius": 1.277, iupac_ordering: 64, "IUPAC ordering": 64, "Ground level": "5D4", "Ionization energies": [7.9024681, 16.19921, 30.651, 54.91, 75, 98.985, 124.976, 151.06, 233.6, 262.1, 290.9, 330.8, 361, 392.2, 456.2, 489.312, 1262.7, 1357.8, 1460, 1575.6, 1687, 1798.4, 1950.4, 2045.759, 8828.1879, 9277.6818], "Electron affinity": 0.15323634 }, Fm: { "Atomic mass": 257, "Atomic no": 100, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>12</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1800 K", "Mendeleev no": 37, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Fermium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 21, "IUPAC ordering": 21, "Ground level": "3H6", "Ionization energies": [6.5, 12.4, 23.2, 39.3, 55, 74, 93, 120, 136, 162, 185, 209, 237, 257, 276, 300, 326, 351, 377, 402, 430, 453, 616, 647, 680, 716, 749, 782, 837, 871, 909, 944, 1110, 1150, 1190, 1230, 1370, 1420, 1550, 1600, 1770, 1850, 1940, 2030, 2120, 2210, 2300, 2390, 2490, 2590, 2680, 2760, 2850, 2950, 3403, 3480, 3561, 3647, 3730, 3810, 3986, 4070, 4160, 4245, 4586, 4670, 4760, 4840, 5420, 5510, 5760, 5860, 9200, 9370, 9570, 9770, 9970, 10160, 10660, 10860, 11080, 11280, 11850, 12020, 12220, 12390, 14180, 14400, 14800, 15e3, 30300, 30800, 31300, 31800, 38400, 39100, 4e4, 40482.2, 158152.5, 160804], "Electron affinity": 0.35 }, Fr: { "Atomic mass": 223, "Atomic no": 87, "Atomic orbitals": { "1s": -3283.263399, "2p": -542.41424, "2s": -561.73045, "3d": -111.085223, "3p": -128.607136, "3s": -137.959632, "4d": -20.812462, "4f": -10.050648, "4p": -28.648131, "4s": -32.861013, "5d": -2.360991, "5p": -4.97328, "5s": -6.509516, "6p": -0.466197, "6s": -0.841848, "7s": -0.076176 }, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].7s<sup>1</sup>", "Ionic radii": { 1: 1.94 }, "Liquid range": "no data K", "Melting point": "maybe about 300 K", "Mendeleev no": 7, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Francium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.94, ionic_radius: 1.8 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.48, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.7, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 6, "IUPAC ordering": 6, "Ground level": "2S1/2", "Ionization energies": [4.0727411, 22.4, 33.5, 39.1, 50, 67, 80, 106, 120, 179, 200, 222.1, 245, 269, 293, 324, 349, 375, 400, 530, 560, 590, 620, 690, 720, 810, 850, 910, 980, 1040, 1110, 1180, 1250, 1320, 1380, 1460, 1530, 1600, 1670, 1740, 1810, 2119, 2182, 2247, 2317, 2384, 2450, 2564, 2631, 2706, 2774, 3049, 3115, 3190, 3257, 3556, 3635, 3828, 3907, 6365, 6516, 6678, 6849, 7013, 7172, 7500, 7670, 7850, 8020, 8500, 8640, 8800, 8950, 9890, 10070, 10420, 10590, 22330, 22730, 23170, 23570, 27060, 27590, 28260, 28683.4, 113817.2, 115859], "Electron affinity": 0.486 }, Ga: { "Atomic mass": 69.723, "Atomic no": 31, "Atomic orbitals": { "1s": -370.170639, "2p": -40.093339, "2s": -45.200869, "3d": -0.736204, "3p": -3.584666, "3s": -5.241645, "4p": -0.101634, "4s": -0.328019 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.36, "Boiling point": "2477 K", "Brinell hardness": "60 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "120 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "5904 kg m<sup>-3</sup>", "Electrical resistivity": "about  14 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>1</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 0.76 }, "Liquid range": "2174.09 K", "Melting point": "302.91 K", "Mendeleev no": 81, "Mineral hardness": "1.5", "Molar volume": "11.80 cm<sup>3</sup>", Name: "Gallium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.61, ionic_radius: 0.47 } }, V: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } } }, "Superconduction temperature": "1.083 K", "Thermal conductivity": "29 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.87, "Velocity of sound": "2740 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.81, "Youngs modulus": "no data GPa", "Metallic radius": 1.35, iupac_ordering: 79, "IUPAC ordering": 79, "Ground level": "2P°1/2", "Ionization energies": [5.999302, 20.51514, 30.72576, 63.241, 86.01, 112.7, 140.8, 169.9, 211, 244, 280, 319, 356, 471.2, 508.8, 548.3, 599.8, 640, 677, 765.7, 807.308, 2010, 2129, 2258, 2391, 2543.9, 2683, 2868, 2984.426, 12696.5575, 13239.489], "Electron affinity": 0.3012011 }, Gd: { "Atomic mass": 157.25, "Atomic no": 64, "Atomic orbitals": { "1s": -1728.625195, "2p": -262.081616, "2s": -275.36313, "3d": -43.754556, "3p": -54.836922, "3s": -60.764408, "4d": -5.531835, "4f": -0.489012, "4p": -9.669866, "4s": -11.986486, "5d": -0.12722, "5p": -0.978749, "5s": -1.608477, "6s": -0.143627 }, "Atomic radius": 1.8, "Atomic radius calculated": 2.33, "Boiling point": "3523 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "9.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7901 kg m<sup>-3</sup>", "Electrical resistivity": "131 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>7</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.075 }, "Liquid range": "1938 K", "Melting point": "1585 K", "Mendeleev no": 27, "Mineral hardness": "no data", "Molar volume": "19.90 cm<sup>3</sup>", Name: "Gadolinium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.078, ionic_radius: 0.938 } }, VII: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VIII: { "": { crystal_radius: 1.193, ionic_radius: 1.053 } }, IX: { "": { crystal_radius: 1.247, ionic_radius: 1.107 } } } }, "Superconduction temperature": "1.083 K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.34, "Velocity of sound": "2680 m s<sup>-1</sup>", "Vickers hardness": "570 MN m<sup>-2</sup>", X: 1.2, "Youngs modulus": "55 GPa", "Metallic radius": 1.802, iupac_ordering: 40, "IUPAC ordering": 40, "Ground level": "9D°2", "Ionization energies": [6.1498, 12.076, 20.54, 44.44, 64.8, 89, 106, 123, 144, 165, 183, 213, 246, 268, 288, 319, 352, 384.4, 565, 601, 639, 680, 719, 761, 810, 851, 895, 937, 1100, 1142, 1189, 1233, 1321, 1368, 1481, 1532.3, 2621, 2720, 2827, 2941, 3050, 3160, 3312, 3424, 3546, 3660, 3980, 4080, 4191, 4294, 4578, 4693, 4914, 5025, 11273, 11552, 11861, 12147, 13183, 13521, 13943, 14224.57, 57783.9, 59065.53], "Electron affinity": 0.137 }, Ge: { "Atomic mass": 72.64, "Atomic no": 32, "Atomic orbitals": { "1s": -396.292991, "2p": -43.720129, "2s": -49.055282, "3d": -1.117316, "3p": -4.194822, "3s": -5.961472, "4p": -0.149882, "4s": -0.426523 }, "Atomic radius": 1.25, "Atomic radius calculated": 1.25, "Boiling point": "3093 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "5323 kg m<sup>-3</sup>", "Electrical resistivity": "about 50000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 2: 0.87, 4: 0.67 }, "Liquid range": "1881.6 K", "Melting point": "1211.4 K", "Mendeleev no": 84, "Mineral hardness": "6.0", "Molar volume": "13.63 cm<sup>3</sup>", Name: "Germanium", "Oxidation states": [-4, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } }, 4: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "60 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "5400 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.01, "Youngs modulus": "no data GPa", "Metallic radius": 1.39, iupac_ordering: 84, "IUPAC ordering": 84, "Ground level": "3P0", "Ionization energies": [7.899435, 15.93461, 34.0576, 45.7155, 90.5, 115.9, 144.9, 176.4, 212.5, 252.1, 286, 326, 367, 407, 527.9, 567.3, 609.1, 662.8, 706.7, 744, 837.1, 880.44, 2180.1, 2304, 2439, 2575, 2737.1, 2881.9, 3074, 3194.293, 13557.4208, 14119.43], "Electron affinity": 1.232676413 }, H: { "Atomic mass": 1.00794, "Atomic no": 1, "Atomic orbitals": { "1s": -0.233471 }, "Atomic radius": 0.25, "Atomic radius calculated": 0.53, "Boiling point": "20.28 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1], "Critical temperature": "33 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "1s<sup>1</sup>", "ICSD oxidation states": [1, -1], "Liquid range": "6.27 K", "Melting point": "14.01 K", "Mendeleev no": 103, "Mineral hardness": "no data", "Molar volume": "11.42 cm<sup>3</sup>", Name: "Hydrogen", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000132 (gas; liquid 1.12)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { I: { "": { crystal_radius: -0.24, ionic_radius: -0.38 } }, II: { "": { crystal_radius: -0.04, ionic_radius: -0.18 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.1805 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.1, "Velocity of sound": "1270 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "H-2": 2.86 }, "Metallic radius": "no data", iupac_ordering: 92, "IUPAC ordering": 92, "Ground level": "2S1/2", "Ionization energies": [13.598434599702], "Electron affinity": 0.754598 }, He: { "Atomic mass": 4.002602, "Atomic no": 2, "Atomic orbitals": { "1s": -0.570425 }, "Atomic radius": "no data", "Atomic radius calculated": 0.31, "Boiling point": "4.22 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "5.19 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "1s<sup>2</sup>", "Liquid range": "3.27 K", "Max oxidation state": 0, "Melting point": "0.95 K", "Mendeleev no": 1, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "21.0 cm<sup>3</sup>", Name: "Helium", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000035 (gas; liquid 1.028)(no units)", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.1513 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.4, "Velocity of sound": "970 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 5, "IUPAC ordering": 5, "Ground level": "1S0", "Ionization energies": [24.587389011, 54.417765486], "Electron affinity": -0.52 }, Hf: { "Atomic mass": 178.49, "Atomic no": 72, "Atomic orbitals": { "1s": -2210.65199, "2p": -345.687023, "2s": -361.006527, "3d": -61.231443, "3p": -74.452656, "3s": -81.522812, "4d": -7.676638, "4f": -0.871574, "4p": -12.971211, "4s": -15.883625, "5d": -0.143805, "5p": -1.246441, "5s": -2.049828, "6s": -0.166465 }, "Atomic radius": 1.55, "Atomic radius calculated": 2.08, "Boiling point": "4876 K", "Brinell hardness": "1700 MN m<sup>-2</sup>", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "5.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "13310 kg m<sup>-3</sup>", "Electrical resistivity": "34 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>2</sup>.6s<sup>2</sup>", "ICSD oxidation states": [4], "Ionic radii": { 4: 0.85 }, "Liquid range": "2370 K", "Melting point": "2506 K", "Mendeleev no": 50, "Mineral hardness": "5.5", "Molar volume": "13.44 cm<sup>3</sup>", Name: "Hafnium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.37", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } }, VII: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 0.97, ionic_radius: 0.83 } } } }, "Superconduction temperature": "0.128 K", "Thermal conductivity": "23 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "3010 m s<sup>-1</sup>", "Vickers hardness": "1760 MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "78 GPa", "Metallic radius": 1.58, iupac_ordering: 50, "IUPAC ordering": 50, "Ground level": "3F2", "Ionization energies": [6.82507, 14.61, 22.55, 33.37, 68.37, 98, 118, 137, 157, 187, 209, 230, 270, 310, 334, 359, 399, 440, 481, 520, 570, 610, 650, 690, 730, 772, 1002, 1047, 1094, 1146, 1195, 1245, 1311, 1362, 1417, 1467, 1669, 1719, 1776, 1827, 1963, 2022, 2159, 2218.9, 3741, 3858, 3984, 4118, 4246, 4372, 4573, 4703, 4846, 4980, 5350, 5468, 5595, 5713, 6149, 6284, 6545, 6674, 14678, 14999, 15351, 15680, 17280, 17680, 18180, 18502.32, 74565.93, 76077.8], "Electron affinity": 0.17807 }, Hg: { "Atomic mass": 200.59, "Atomic no": 80, "Atomic orbitals": { "1s": -2755.022637, "2p": -443.848676, "2s": -461.27864, "3d": -84.845492, "3p": -100.328031, "3s": -108.597921, "4d": -13.019221, "4f": -4.110291, "4p": -19.636187, "4s": -23.222921, "5d": -0.452552, "5p": -2.261975, "5s": -3.423486, "6s": -0.205137 }, "Atomic radius": 1.5, "Atomic radius calculated": 1.71, "Boiling point": "629.88 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "25 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1, 2], "Critical temperature": "1750 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "96 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>", "ICSD oxidation states": [1, 2], "Ionic radii": { 1: 1.33, 2: 1.16 }, "Liquid range": "395.56 K", "Melting point": "234.32 K", "Mendeleev no": 74, "Mineral hardness": "1.5", "Molar volume": "14.09 cm<sup>3</sup>", Name: "Mercury", "Oxidation states": [1, 2, 4], "Poissons ratio": "no data", Reflectivity: "73 %", "Refractive index": "1.000933", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { III: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VI: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } } }, 2: { II: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, IV: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } } }, "Superconduction temperature": "3.95 K", "Thermal conductivity": "8.3 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "1407 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Hg-201": 387.6 }, "Metallic radius": 1.51, iupac_ordering: 74, "IUPAC ordering": 74, "Ground level": "1S0", "Ionization energies": [10.437504, 18.75688, 34.49, 48.55, 61.2, 76.6, 93, 113.9, 134, 153, 173, 192.7, 276.9, 307, 332, 357, 402, 429, 477, 530, 560, 590, 650, 710, 760, 820, 880, 930, 990, 1050, 1110, 1160, 1220, 1280, 1549, 1603, 1661, 1723, 1780, 1839, 1928, 1989, 2052, 2113, 2354, 2412, 2478, 2539, 2745, 2815, 2981, 3049.9, 5055, 5191, 5335, 5490, 5636, 5780, 6041, 6192, 6356, 6508, 6933, 7066, 7211, 7350, 8010, 8160, 8470, 8620, 18550, 18910, 19310, 19680, 22120, 22580, 23170, 23544.1, 94124.7, 95897.7], "Electron affinity": -0.52 }, Ho: { "Atomic mass": 164.93032, "Atomic no": 67, "Atomic orbitals": { "1s": -1902.051908, "2p": -291.700994, "2s": -305.739294, "3d": -49.565996, "3p": -61.436304, "3s": -67.785492, "4d": -5.906195, "4f": -0.272677, "4p": -10.455303, "4s": -12.985498, "5p": -0.919463, "5s": -1.582088, "6s": -0.133845 }, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2993 K", "Brinell hardness": "746 MN m<sup>-2</sup>", "Bulk modulus": "40 GPa", "Coefficient of linear thermal expansion": "11.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8795 kg m<sup>-3</sup>", "Electrical resistivity": "81.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>11</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.041 }, "Liquid range": "1259 K", "Melting point": "1734 K", "Mendeleev no": 23, "Mineral hardness": "no data", "Molar volume": "18.74 cm<sup>3</sup>", Name: "Holmium", "Oxidation states": [3], "Poissons ratio": "0.23", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.041, ionic_radius: 0.901 } }, VIII: { "": { crystal_radius: 1.155, ionic_radius: 1.015 } }, IX: { "": { crystal_radius: 1.212, ionic_radius: 1.072 } }, X: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.3, "Velocity of sound": "2760 m s<sup>-1</sup>", "Vickers hardness": "481 MN m<sup>-2</sup>", X: 1.23, "Youngs modulus": "65 GPa", "Metallic radius": 1.765, iupac_ordering: 37, "IUPAC ordering": 37, "Ground level": "4I°15/2", "Ionization energies": [6.0215, 11.781, 22.79, 42.52, 63.9, 95, 112, 129, 155, 173, 197, 229, 263, 284, 305, 340, 373, 408, 441, 475, 510, 715, 755, 797, 842, 885, 929, 985, 1029, 1077, 1122, 1300, 1346, 1395, 1443, 1545, 1598, 1719, 1773.6, 3018, 3125, 3238, 3359, 3476, 3592, 3760, 3880, 4009, 4131, 4469, 4576, 4693, 4802, 5135, 5258, 5494, 5611, 12495, 12790, 13116, 13417, 14639, 14998, 15448, 15745.77, 63772.43, 65136.8], "Electron affinity": 0.338 }, I: { "Atomic mass": 126.90447, "Atomic no": 53, "Atomic orbitals": { "1s": -1161.787047, "2p": -164.603788, "2s": -175.073804, "3d": -22.600693, "3p": -30.831092, "3s": -35.243351, "4d": -1.938179, "4p": -4.572522, "4s": -6.115811, "5p": -0.267904, "5s": -0.596339 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.15, "Boiling point": "457.4 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "819 K", "Density of solid": "4940 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>15</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>5</sup>", "ICSD oxidation states": [5, -1], "Ionic radii": { "-1": 2.06, 5: 1.09, 7: 0.67 }, "Liquid range": "70.55 K", "Melting point": "386.85 K", "Mendeleev no": 97, "Mineral hardness": "no data", "Molar volume": "25.72 cm<sup>3</sup>", Name: "Iodine", "Oxidation states": [-1, 1, 3, 5, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 2.06, ionic_radius: 2.2 } } }, 5: { IIIPY: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } }, VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } }, 7: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.449 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.98, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.66, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "I-127": -696.12, "I-129": -604.1 }, "Metallic radius": "no data", iupac_ordering: 99, "IUPAC ordering": 99, "Ground level": "2P°3/2", "Ionization energies": [10.45126, 19.13126, 29.57, 40.357, 51.52, 74.4, 87.61, 150.81, 171, 197, 220.9, 247, 279, 307, 335, 365, 393, 505, 535, 569, 601, 649, 683, 762, 800.8, 1397, 1472, 1553, 1639, 1720, 1812, 1911, 1999, 2093, 2181, 2431, 2510, 2598, 2680, 2836, 2926, 3096, 3185.5, 7337, 7563, 7811, 8044, 8601, 8867, 9196, 9421.1, 38716.996, 39721.41], "Electron affinity": 3.05905238 }, In: { "Atomic mass": 114.818, "Atomic no": 49, "Atomic orbitals": { "1s": -983.647445, "2p": -134.628845, "2s": -144.078357, "3d": -16.139823, "3p": -23.345778, "3s": -27.2206, "4d": -0.730481, "4p": -2.795832, "4s": -4.062639, "5p": -0.101782, "5s": -0.290497 }, "Atomic radius": 1.55, "Atomic radius calculated": 1.56, "Boiling point": "2345 K", "Brinell hardness": "8.83 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "32.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7310 kg m<sup>-3</sup>", "Electrical resistivity": "8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 3: 0.94 }, "Liquid range": "1915.25 K", "Melting point": "429.75 K", "Mendeleev no": 79, "Mineral hardness": "1.2", "Molar volume": "15.76 cm<sup>3</sup>", Name: "Indium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } }, VI: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "3.41 K", "Thermal conductivity": "82 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.93, "Velocity of sound": "1215 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.78, "Youngs modulus": "11 GPa", "NMR Quadrupole Moment": { "In-113": 759.8, "In-115": 770.8 }, "Metallic radius": 1.67, iupac_ordering: 78, "IUPAC ordering": 78, "Ground level": "2P°1/2", "Ionization energies": [5.7863557, 18.87041, 28.04415, 55.45, 69.3, 90, 109, 130.1, 156, 178, 201, 226, 249, 341, 368, 396, 425, 462, 497.1, 560, 593.38, 1043, 1109, 1181, 1255, 1328, 1413, 1496, 1575, 1659, 1738, 1961, 2028.5, 2111, 2207, 2317, 2373, 2555, 2628.77, 6126, 6331, 6554, 6770, 7196, 7442, 7754, 7953.14, 32837.592, 33750.31], "Electron affinity": 0.383926 }, Ir: { "Atomic mass": 192.217, "Atomic no": 77, "Atomic orbitals": { "1s": -2543.761342, "2p": -405.526834, "2s": -422.159424, "3d": -75.485027, "3p": -90.108427, "3s": -97.923081, "4d": -10.856593, "4f": -2.738339, "4p": -16.966578, "4s": -20.29429, "5d": -0.335189, "5p": -1.883349, "5s": -2.909174, "6s": -0.195511 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.8, "Boiling point": "4701 K", "Brinell hardness": "1670 MN m<sup>-2</sup>", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "22650 kg m<sup>-3</sup>", "Electrical resistivity": "4.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>7</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5], "Ionic radii": { 3: 0.82, 4: 0.765, 5: 0.71 }, "Liquid range": "1962 K", "Melting point": "2739 K", "Mendeleev no": 66, "Mineral hardness": "6.5", "Molar volume": "8.52 cm<sup>3</sup>", Name: "Iridium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", Reflectivity: "78 %", "Refractive index": "no data", "Rigidity modulus": "210 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 4: { VI: { "": { crystal_radius: 0.765, ionic_radius: 0.625 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "0.11 K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "4825 m s<sup>-1</sup>", "Vickers hardness": "1760 MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "528 GPa", "Metallic radius": 1.357, iupac_ordering: 65, "IUPAC ordering": 65, "Ground level": "4F9/2", "Ionization energies": [8.96702, 17, 28, 40, 57, 72, 89, 105, 122.7, 194.8, 217, 240, 264, 303, 329, 356, 407, 445, 472, 510, 560, 610, 670, 720, 770, 820, 870, 920, 980, 1030, 1080, 1331, 1381, 1436, 1493, 1548, 1603, 1684, 1739, 1801, 1857, 2083, 2139, 2201, 2258, 2435, 2500, 2656, 2720.4, 4540, 4668, 4806, 4952, 5092, 5229, 5466, 5609, 5765, 5910, 6315, 6441, 6580, 6708, 7274, 7421, 7710, 7850, 17040, 17390, 17770, 18120, 20210, 20650, 21200, 21556.6, 86438.9, 88113.3], "Electron affinity": 1.5643615 }, K: { "Atomic mass": 39.0983, "Atomic no": 19, "Atomic orbitals": { "1s": -128.414957, "2p": -10.283851, "2s": -12.839001, "3p": -0.693776, "3s": -1.281897, "4s": -0.088815 }, "Atomic radius": 2.2, "Atomic radius calculated": 2.43, "Boiling point": "1032 K", "Brinell hardness": "0.363 MN m<sup>-2</sup>", "Bulk modulus": "3.1 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2223 K", "Density of solid": "856 kg m<sup>-3</sup>", "Electrical resistivity": "7.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].4s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.52 }, "Liquid range": "695.47 K", "Melting point": "336.53 K", "Mendeleev no": 10, "Mineral hardness": "0.4", "Molar volume": "45.94 cm<sup>3</sup>", Name: "Potassium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "1.3 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 1.51, ionic_radius: 1.37 } }, VI: { "": { crystal_radius: 1.52, ionic_radius: 1.38 } }, VII: { "": { crystal_radius: 1.6, ionic_radius: 1.46 } }, VIII: { "": { crystal_radius: 1.65, ionic_radius: 1.51 } }, IX: { "": { crystal_radius: 1.69, ionic_radius: 1.55 } }, X: { "": { crystal_radius: 1.73, ionic_radius: 1.59 } }, XII: { "": { crystal_radius: 1.78, ionic_radius: 1.64 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.75, "Velocity of sound": "2000 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.82, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "K-39": 58.5, "K-40": -73, "K-41": 71.1 }, "Metallic radius": 2.381, iupac_ordering: 9, "IUPAC ordering": 9, "Ground level": "2S1/2", "Ionization energies": [4.34066373, 31.625, 45.8031, 60.917, 82.66, 99.44, 117.56, 154.87, 175.8174, 503.67, 565.6, 631.1, 714.7, 786.3, 860.92, 967.7, 1034.542, 4610.87018, 4934.0484], "Electron affinity": 0.50145913 }, Kr: { "Atomic mass": 83.798, "Atomic no": 36, "Atomic orbitals": { "1s": -509.982989, "2p": -60.017328, "2s": -66.285953, "3d": -3.074109, "3p": -7.086634, "3s": -9.315192, "4p": -0.34634, "4s": -0.820574 }, "Atomic radius": "no data", "Atomic radius calculated": 0.88, "Boiling point": "119.93 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "209.4 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>6</sup>", "Liquid range": "4.14 K", "Max oxidation state": 0, "Melting point": "115.79 K", "Mendeleev no": 4, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "27.99 cm<sup>3</sup>", Name: "Krypton", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000427", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00943 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "1120 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 2, "IUPAC ordering": 2, "Ground level": "1S0", "Ionization energies": [13.9996055, 24.35984, 35.838, 50.85, 64.69, 78.49, 109.13, 125.802, 233, 268, 308, 350, 391, 446, 492, 540, 591, 640, 785, 831.6, 882.8, 945, 999, 1042, 1155, 1205.23, 2928.9, 3072, 3228, 3380, 3584, 3752, 3971, 4109.083, 17296.421, 17936.209], "Electron affinity": -1.02 }, La: { "Atomic mass": 138.90547, "Atomic no": 57, "Atomic orbitals": { "1s": -1355.622446, "2p": -198.325243, "2s": -209.831151, "3d": -30.626696, "3p": -39.895838, "3s": -44.856283, "4d": -3.95801, "4p": -7.167724, "4s": -9.000543, "5d": -0.141085, "5p": -0.824498, "5s": -1.324936, "6s": -0.132233 }, "Atomic radius": 1.95, "Atomic radius calculated": "no data", "Boiling point": "3743 K", "Brinell hardness": "363 MN m<sup>-2</sup>", "Bulk modulus": "28 GPa", "Coefficient of linear thermal expansion": "12.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6146 kg m<sup>-3</sup>", "Electrical resistivity": "61.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 1.172 }, "Liquid range": "2550 K", "Melting point": "1193 K", "Mendeleev no": 33, "Mineral hardness": "2.5", "Molar volume": "22.39 cm<sup>3</sup>", Name: "Lanthanum", "Oxidation states": [2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.172, ionic_radius: 1.032 } }, VII: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } }, VIII: { "": { crystal_radius: 1.3, ionic_radius: 1.16 } }, IX: { "": { crystal_radius: 1.356, ionic_radius: 1.216 } }, X: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } }, XII: { "": { crystal_radius: 1.5, ionic_radius: 1.36 } } } }, "Superconduction temperature": "6.00 K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.43, "Velocity of sound": "2475 m s<sup>-1</sup>", "Vickers hardness": "491 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "37 GPa", "NMR Quadrupole Moment": { "La-139": 200.6 }, "Metallic radius": 1.877, iupac_ordering: 47, "IUPAC ordering": 47, "Ground level": "2D3/2", "Ionization energies": [5.5769, 11.18496, 19.1773, 49.95, 61.6, 74, 88, 105, 119, 151.4, 168.77, 275, 303, 332, 364, 393, 431, 464, 498, 533, 566, 696, 731, 770, 806, 865, 906, 995, 1039.09, 1800, 1884, 1974, 2069, 2162, 2259, 2377, 2473, 2577, 2674, 2950, 3036, 3133, 3222, 3416, 3515, 3704, 3800, 8669, 8914, 9184, 9437, 10136, 10426, 10789, 11033.4, 45144.996, 46245.6], "Electron affinity": 0.5575462 }, Li: { "Atomic mass": 6.941, "Atomic no": 3, "Atomic orbitals": { "1s": -1.878564, "2s": -0.10554 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.67, "Boiling point": "1615 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "46 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "3223 K", "Density of solid": "535 kg m<sup>-3</sup>", "Electrical resistivity": "9.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 0.9 }, "Liquid range": "1161.31 K", "Melting point": "453.69 K", "Mendeleev no": 12, "Mineral hardness": "0.6", "Molar volume": "13.02 cm<sup>3</sup>", Name: "Lithium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "4.2 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "85 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.82, "Velocity of sound": "6000 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.98, "Youngs modulus": "4.9 GPa", "NMR Quadrupole Moment": { "Li-6": -0.808, "Li-7": -40.1 }, "Metallic radius": 1.52, iupac_ordering: 11, "IUPAC ordering": 11, "Ground level": "2S1/2", "Ionization energies": [5.391714996, 75.640097, 122.45435914], "Electron affinity": 0.61804922 }, Lr: { "Atomic mass": 262, "Atomic no": 103, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>14</sup>.7s<sup>2</sup>.7p<sup>1</sup> (tentative)", "Liquid range": "no data K", "Melting point": "about 1900 K", "Mendeleev no": 34, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Lawrencium", "Oxidation states": [3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": "no data", "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 18, "IUPAC ordering": 18, "Ground level": "2P°1/2", "Ionization energies": [4.96, 14.54, 21.8, 43.6, 56, 80, 96, 121, 143, 165, 197, 216, 244, 269, 290, 322, 344, 374, 403, 431, 459, 487, 510, 540, 560, 745, 779, 814, 852, 888, 922, 985, 1020, 1061, 1098, 1280, 1320, 1360, 1410, 1570, 1620, 1760, 1810, 2010, 2100, 2190, 2290, 2380, 2470, 2570, 2670, 2780, 2860, 2960, 3060, 3150, 3250, 3741, 3821, 3906, 3996, 4082, 4165, 4360, 4448, 4540, 4630, 4990, 5070, 5160, 5250, 5920, 6030, 6290, 6390, 9920, 10110, 10310, 10520, 10720, 10920, 11470, 11680, 11910, 12120, 12710, 12890, 13090, 13300, 15300, 15600, 16e3, 16200, 32400, 32900, 33400, 33900, 41600, 42300, 43200, 43759, null, 172930], "Electron affinity": -0.31 }, Lu: { "Atomic mass": 174.967, "Atomic no": 71, "Atomic orbitals": { "1s": -2146.885351, "2p": -334.330902, "2s": -349.390492, "3d": -58.592982, "3p": -71.538779, "3s": -78.462398, "4d": -7.113364, "4f": -0.568096, "4p": -12.250904, "4s": -15.08337, "5d": -0.103686, "5p": -1.111991, "5s": -1.872086, "6s": -0.155112 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.17, "Boiling point": "3675 K", "Brinell hardness": "893 MN m<sup>-2</sup>", "Bulk modulus": "48 GPa", "Coefficient of linear thermal expansion": "9.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9841 kg m<sup>-3</sup>", "Electrical resistivity": "58 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.001 }, "Liquid range": "1750 K", "Melting point": "1925 K", "Mendeleev no": 20, "Mineral hardness": "no data", "Molar volume": "17.78 cm<sup>3</sup>", Name: "Lutetium", "Oxidation states": [3], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.001, ionic_radius: 0.861 } }, VIII: { "": { crystal_radius: 1.117, ionic_radius: 0.977 } }, IX: { "": { crystal_radius: 1.172, ionic_radius: 1.032 } } } }, "Superconduction temperature": "0.022 K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.24, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "1160 MN m<sup>-2</sup>", X: 1.27, "Youngs modulus": "69 GPa", "Metallic radius": 1.735, iupac_ordering: 33, "IUPAC ordering": 33, "Ground level": "2D3/2", "Ionization energies": [5.425871, 14.13, 20.9594, 45.249, 66.8, 98, 117, 136, 159, 185, 205, 238, 276, 305, 328, 361, 399, 438, 476, 520, 560, 600, 630, 670, 713, 941, 985, 1032, 1081, 1130, 1178, 1242, 1292, 1345, 1395, 1591, 1641, 1696, 1747, 1875, 1933, 2067, 2125.5, 3590, 3706, 3828, 3960, 4086, 4211, 4403, 4532, 4673, 4803, 5168, 5282, 5408, 5525, 5937, 6070, 6326, 6452, 14228, 14542, 14890, 15211, 16730, 17120, 17610, 17928.05, 72322.91, 73804.8], "Electron affinity": 0.23887 }, Md: { "Atomic mass": 258, "Atomic no": 101, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>13</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 36, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Mendelevium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.46, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 20, "IUPAC ordering": 20, "Ground level": "2F°7/2", "Ionization energies": [6.58, 12.4, 24.3, 40, 54.1, 76, 96, 115.1, 143.9, 162, 187, 215, 240, 260, 282, 307, 334, 360, 386, 412, 438, 462, 486, 659, 690, 723, 760, 794, 828, 885, 920, 958, 994, 1160, 1210, 1250, 1290, 1430, 1480, 1620, 1660, 1840, 1930, 2020, 2110, 2200, 2290, 2390, 2480, 2580, 2680, 2760, 2860, 2950, 3050, 3513, 3592, 3675, 3762, 3845, 3926, 4109, 4194, 4286, 4371, 4720, 4800, 4890, 4970, 5580, 5680, 5930, 6030, 9430, 9620, 9810, 10020, 10220, 10410, 10930, 11130, 11350, 11560, 12130, 12310, 12500, 12680, 14560, 14800, 15200, 15400, 31e3, 31500, 32e3, 32500, 39500, 40100, 41e3, 41548, null, 164764], "Electron affinity": 0.98 }, Mg: { "Atomic mass": 24.305, "Atomic no": 12, "Atomic orbitals": { "1s": -45.973167, "2p": -1.71897, "2s": -2.903746, "3s": -0.175427 }, "Atomic radius": 1.5, "Atomic radius calculated": 1.45, "Boiling point": "1363 K", "Brinell hardness": "260 MN m<sup>-2</sup>", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "8.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1738 kg m<sup>-3</sup>", "Electrical resistivity": "4.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.86 }, "Liquid range": "440 K", "Melting point": "923 K", "Mendeleev no": 73, "Mineral hardness": "2.5", "Molar volume": "14.00 cm<sup>3</sup>", Name: "Magnesium", "Oxidation states": [1, 2], "Poissons ratio": "0.29", Reflectivity: "74 %", "Refractive index": "no data", "Rigidity modulus": "17 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, V: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } }, VIII: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "160 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.73, "Velocity of sound": "4602 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.31, "Youngs modulus": "45 GPa", "NMR Quadrupole Moment": { "Mg-25": 199.4 }, "Metallic radius": 1.6, iupac_ordering: 16, "IUPAC ordering": 16, "Ground level": "1S0", "Ionization energies": [7.646236, 15.035271, 80.1436, 109.2654, 141.33, 186.76, 225.02, 265.924, 327.99, 367.489, 1761.80488, 1962.66366], "Electron affinity": -0.42 }, Mn: { "Atomic mass": 54.938045, "Atomic no": 25, "Atomic orbitals": { "1s": -233.696912, "2p": -23.066297, "2s": -26.866646, "3d": -0.26654, "3p": -1.99145, "3s": -3.076637, "4s": -0.191136 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.61, "Boiling point": "2334 K", "Brinell hardness": "196 MN m<sup>-2</sup>", "Bulk modulus": "120 GPa", "Coefficient of linear thermal expansion": "21.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4, 7], "Critical temperature": "no data K", "Density of solid": "7470 kg m<sup>-3</sup>", "Electrical resistivity": "144 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>5</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 7], "Ionic radii": { 2: 0.97, 3: 0.785, 4: 0.67, 5: 0.47, 6: 0.395, 7: 0.6 }, "Ionic radii hs": { 2: 0.97, 3: 0.785 }, "Ionic radii ls": { 2: 0.81, 3: 0.72, 4: 0.67, 5: 0.47, 6: 0.395, 7: 0.6 }, "Liquid range": "815 K", "Melting point": "1519 K", "Mendeleev no": 60, "Mineral hardness": "6.0", "Molar volume": "7.35 cm<sup>3</sup>", Name: "Manganese", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.8, ionic_radius: 0.66 } }, V: { "High Spin": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VI: { "Low Spin": { crystal_radius: 0.81, ionic_radius: 0.67 }, "High Spin": { crystal_radius: 0.97, ionic_radius: 0.83 } }, VII: { "High Spin": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 3: { V: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "Low Spin": { crystal_radius: 0.72, ionic_radius: 0.58 }, "High Spin": { crystal_radius: 0.785, ionic_radius: 0.645 } } }, 4: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } }, 5: { IV: { "": { crystal_radius: 0.47, ionic_radius: 0.33 } } }, 6: { IV: { "": { crystal_radius: 0.395, ionic_radius: 0.255 } } }, 7: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } }, VI: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "7.8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.05, "Velocity of sound": "5150 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.55, "Youngs modulus": "198 GPa", "NMR Quadrupole Moment": { "Mn-55": 330.1 }, "Metallic radius": 1.292, iupac_ordering: 61, "IUPAC ordering": 61, "Ground level": "6S5/2", "Ionization energies": [7.434038, 15.63999, 33.668, 51.21, 72.41, 95.604, 119.203, 195.5, 221.89, 248.6, 286.1, 314.4, 343.6, 402.95, 435.172, 1133.7, 1224.1, 1320.3, 1430.9, 1537.2, 1643.2, 1788.7, 1879.873, 8140.7872, 8571.9488], "Electron affinity": -0.52 }, Mo: { "Atomic mass": 95.94, "Atomic no": 42, "Atomic orbitals": { "1s": -709.232119, "2p": -90.791541, "2s": -98.503638, "3d": -8.257721, "3p": -13.71481, "3s": -16.681545, "4d": -0.153347, "4p": -1.39005, "4s": -2.234824, "5s": -0.14788 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.9, "Boiling point": "4912 K", "Brinell hardness": "1500 MN m<sup>-2</sup>", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "4.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "10280 kg m<sup>-3</sup>", "Electrical resistivity": "5.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>5</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 3: 0.83, 4: 0.79, 5: 0.75, 6: 0.73 }, "Liquid range": "2016 K", "Melting point": "2896 K", "Mendeleev no": 56, "Mineral hardness": "5.5", "Molar volume": "9.38 cm<sup>3</sup>", Name: "Molybdenum", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.31", Reflectivity: "58 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } } }, 4: { VI: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } } }, 5: { IV: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, VI: { "": { crystal_radius: 0.75, ionic_radius: 0.61 } } }, 6: { IV: { "": { crystal_radius: 0.55, ionic_radius: 0.41 } }, V: { "": { crystal_radius: 0.64, ionic_radius: 0.5 } }, VI: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, VII: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } } }, "Superconduction temperature": "0.915 K", "Thermal conductivity": "139 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.17, "Velocity of sound": "6190 m s<sup>-1</sup>", "Vickers hardness": "1530 MN m<sup>-2</sup>", X: 2.16, "Youngs modulus": "329 GPa", "Metallic radius": 1.402, iupac_ordering: 57, "IUPAC ordering": 57, "Ground level": "7S3", "Ionization energies": [7.09243, 16.16, 27.13, 40.33, 54.417, 68.82704, 125.638, 143.6, 164.12, 186.3, 209.3, 230.28, 279.1, 302.6, 544, 591, 646, 702, 758, 829, 890, 953, 1019, 1082, 1263, 1319.6, 1385.1, 1462, 1537, 1587, 1730.1, 1790.93, 4259, 4430, 4618, 4800, 5084, 5287, 5548, 5713.194, 23810.654, 24572.156], "Electron affinity": 0.74733 }, N: { "Atomic mass": 14.0067, "Atomic no": 7, "Atomic orbitals": { "1s": -14.011501, "2p": -0.266297, "2s": -0.676151 }, "Atomic radius": 0.65, "Atomic radius calculated": 0.56, "Boiling point": "77.36 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "126.2 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>3</sup>", "ICSD oxidation states": [1, 3, 5, -1, -3, -2], "Ionic radii": { "-3": 1.32, 3: 0.3, 5: 0.27 }, "Liquid range": "14.31 K", "Melting point": "63.05 K", "Mendeleev no": 100, "Mineral hardness": "no data", "Molar volume": "13.54 cm<sup>3</sup>", Name: "Nitrogen", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000298 (gas; liquid 1.197)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { "-3": { IV: { "": { crystal_radius: 1.32, ionic_radius: 1.46 } } }, 3: { VI: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } } }, 5: { III: { "": { crystal_radius: 0.044, ionic_radius: -0.104 } }, VI: { "": { crystal_radius: 0.27, ionic_radius: 0.13 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02583 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.55, "Velocity of sound": "333.6 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "N-14": 20.44 }, "Metallic radius": "no data", iupac_ordering: 91, "IUPAC ordering": 91, "Ground level": "4S°3/2", "Ionization energies": [14.53413, 29.60125, 47.4453, 77.4735, 97.8901, 552.06733, 667.046121], "Electron affinity": -0.07 }, Na: { "Atomic mass": 22.98976928, "Atomic no": 11, "Atomic orbitals": { "1s": -37.719975, "2p": -1.060636, "2s": -2.063401, "3s": -0.103415 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.9, "Boiling point": "1156 K", "Brinell hardness": "0.69 MN m<sup>-2</sup>", "Bulk modulus": "6.3 GPa", "Coefficient of linear thermal expansion": "71 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2573 K", "Density of solid": "968 kg m<sup>-3</sup>", "Electrical resistivity": "4.9 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.16 }, "Liquid range": "785.13 K", "Melting point": "370.87 K", "Mendeleev no": 11, "Mineral hardness": "0.5", "Molar volume": "23.78 cm<sup>3</sup>", Name: "Sodium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "3.3 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 1.13, ionic_radius: 0.99 } }, V: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VII: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } }, VIII: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, IX: { "": { crystal_radius: 1.38, ionic_radius: 1.24 } }, XII: { "": { crystal_radius: 1.53, ionic_radius: 1.39 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.27, "Velocity of sound": "3200 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.93, "Youngs modulus": "10 GPa", "NMR Quadrupole Moment": { "Na-23": 104.1 }, "Metallic radius": 1.86, iupac_ordering: 10, "IUPAC ordering": 10, "Ground level": "2S1/2", "Ionization energies": [5.13907696, 47.28636, 71.62, 98.936, 138.404, 172.23, 208.504, 264.192, 299.856, 1465.134502, 1648.7022], "Electron affinity": 0.54792625 }, Nb: { "Atomic mass": 92.90638, "Atomic no": 41, "Atomic orbitals": { "1s": -673.76253, "2p": -85.272175, "2s": -92.74086, "3d": -7.339839, "3p": -12.552855, "3s": -15.393727, "4d": -0.125252, "4p": -1.250049, "4s": -2.036693, "5s": -0.144272 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.98, "Boiling point": "5017 K", "Brinell hardness": "736 MN m<sup>-2</sup>", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "7.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "8570 kg m<sup>-3</sup>", "Electrical resistivity": "15.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>4</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": { 3: 0.86, 4: 0.82, 5: 0.78 }, "Liquid range": "2267 K", "Melting point": "2750 K", "Mendeleev no": 53, "Mineral hardness": "6.0", "Molar volume": "10.83 cm<sup>3</sup>", Name: "Niobium", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.40", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "38 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 4: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VIII: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } } }, 5: { IV: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } }, VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VII: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "9.25 K", "Thermal conductivity": "54 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "3480 m s<sup>-1</sup>", "Vickers hardness": "1320 MN m<sup>-2</sup>", X: 1.6, "Youngs modulus": "105 GPa", "Metallic radius": 1.473, iupac_ordering: 54, "IUPAC ordering": 54, "Ground level": "6D1/2", "Ionization energies": [6.75885, 14.32, 25.04, 37.611, 50.5728, 102.069, 119.1, 136, 159.2, 180, 200.28, 246.1, 268.59, 482.5, 530, 581, 636, 688, 758, 816, 877, 940, 1e3, 1176, 1230.6, 1293.7, 1368, 1439, 1488, 1625.9, 1684.97, 4020.1, 4187, 4369, 4540, 4815, 5011, 5265, 5426.066, 22648.046, 23388.801], "Electron affinity": 0.917407 }, Nd: { "Atomic mass": 144.242, "Atomic no": 60, "Atomic orbitals": { "1s": -1509.698955, "2p": -224.351816, "2s": -236.613572, "3d": -35.754515, "3p": -45.791219, "3s": -51.161263, "4d": -4.377027, "4f": -0.179508, "4p": -7.96782, "4s": -10.000891, "5p": -0.798503, "5s": -1.334934, "6s": -0.125796 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.06, "Boiling point": "3373 K", "Brinell hardness": "265 MN m<sup>-2</sup>", "Bulk modulus": "32 GPa", "Coefficient of linear thermal expansion": "9.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6800 kg m<sup>-3</sup>", "Electrical resistivity": "64.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>4</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.43, 3: 1.123 }, "Liquid range": "2076 K", "Melting point": "1297 K", "Mendeleev no": 30, "Mineral hardness": "no data", "Molar volume": "20.59 cm<sup>3</sup>", Name: "Neodymium", "Oxidation states": [2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "16 GPa", "Shannon radii": { 2: { VIII: { "": { crystal_radius: 1.43, ionic_radius: 1.29 } }, IX: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } } }, 3: { VI: { "": { crystal_radius: 1.123, ionic_radius: 0.983 } }, VIII: { "": { crystal_radius: 1.249, ionic_radius: 1.109 } }, IX: { "": { crystal_radius: 1.303, ionic_radius: 1.163 } }, XII: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.39, "Velocity of sound": "2330 m s<sup>-1</sup>", "Vickers hardness": "343 MN m<sup>-2</sup>", X: 1.14, "Youngs modulus": "41 GPa", "Metallic radius": 1.821, iupac_ordering: 44, "IUPAC ordering": 44, "Ground level": "5I4", "Ionization energies": [5.525, 10.783, 22.09, 40.6, 60, 84, 99, 114, 136, 152, 168, 195, 221, 243, 389, 420, 453, 489, 522, 562, 602, 638, 678, 714, 859, 896, 939, 978, 1049, 1092, 1191, 1238.42, 2134, 2224, 2321, 2425, 2525, 2627, 2758, 2861, 2974, 3078, 3371, 3465, 3567, 3662, 3891, 3997, 4198, 4302, 9742, 10002, 10288, 10555, 11384, 11694, 12082, 12341.66, 50339.59, 51515.58], "Electron affinity": 0.0974933 }, Ne: { "Atomic mass": 20.1797, "Atomic no": 10, "Atomic orbitals": { "1s": -30.305855, "2p": -0.498034, "2s": -1.322809 }, "Atomic radius": "no data", "Atomic radius calculated": 0.38, "Boiling point": "27.07 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "44.4 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>6</sup>", "Liquid range": "2.51 K", "Max oxidation state": 0, "Melting point": "24.56 K", "Mendeleev no": 2, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "13.23 cm<sup>3</sup>", Name: "Neon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000067", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.0491 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.54, "Velocity of sound": "936 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Ne-21": 101.55 }, "Metallic radius": "no data", iupac_ordering: 4, "IUPAC ordering": 4, "Ground level": "1S0", "Ionization energies": [21.564541, 40.96297, 63.4233, 97.19, 126.247, 157.934, 207.271, 239.097, 1195.80784, 1362.19916], "Electron affinity": -1.22 }, Ni: { "Atomic mass": 58.6934, "Atomic no": 28, "Atomic orbitals": { "1s": -297.870824, "2p": -30.868027, "2s": -35.312112, "3d": -0.348699, "3p": -2.594158, "3s": -3.950717, "4s": -0.210764 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.49, "Boiling point": "3186 K", "Brinell hardness": "700 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8908 kg m<sup>-3</sup>", "Electrical resistivity": "7.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>8</sup>.4s<sup>2</sup>", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": { 3: 0.74 }, "Ionic radii hs": { 3: 0.74 }, "Ionic radii ls": { 2: 0.83, 3: 0.7, 4: 0.62 }, "Liquid range": "1458 K", "Melting point": "1728 K", "Mendeleev no": 67, "Mineral hardness": "4.0", "Molar volume": "6.59 cm<sup>3</sup>", Name: "Nickel", "Oxidation states": [-1, 1, 2, 3, 4], "Poissons ratio": "0.31", Reflectivity: "72 %", "Refractive index": "no data", "Rigidity modulus": "76 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, IVSQ: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, V: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } }, VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } } }, 3: { VI: { "Low Spin": { crystal_radius: 0.7, ionic_radius: 0.56 }, "High Spin": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 4: { VI: { "Low Spin": { crystal_radius: 0.62, ionic_radius: 0.48 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "91 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.97, "Velocity of sound": "4970 m s<sup>-1</sup>", "Vickers hardness": "638 MN m<sup>-2</sup>", X: 1.91, "Youngs modulus": "200 GPa", "NMR Quadrupole Moment": { "Ni-61": 162.15 }, "Metallic radius": 1.246, iupac_ordering: 70, "IUPAC ordering": 70, "Ground level": "3F4", "Ionization energies": [7.639878, 18.168838, 35.187, 54.92, 76.06, 108, 132, 162, 193.2, 224.7, 319.5, 351.6, 384.5, 429.3, 462.8, 495.4, 571.07, 607.02, 1541, 1646, 1758, 1880, 2008.1, 2130.5, 2295.6, 2399.259, 10288.8862, 10775.386], "Electron affinity": 1.1571612 }, No: { "Atomic mass": 259, "Atomic no": 102, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>14</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 35, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Nobelium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.46, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 19, "IUPAC ordering": 19, "Ground level": "1S0", "Ionization energies": [6.62621, 12.93, 25.8, 41.5, 60, 74, 97, 119, 140, 170, 187, 216, 246, 267, 285, 312, 341, 367, 394, 422, 448, 475, 496, 520, 701, 734, 768, 805, 840, 875, 934, 969, 1010, 1045, 1220, 1260, 1300, 1350, 1500, 1550, 1680, 1730, 1920, 2010, 2110, 2200, 2290, 2380, 2470, 2570, 2680, 2760, 2860, 2950, 3050, 3140, 3627, 3705, 3790, 3878, 3962, 4045, 4234, 4320, 4413, 4500, 4850, 4930, 5030, 5110, 5750, 5850, 6110, 6210, 9680, 9860, 10060, 10270, 10470, 10660, 11200, 11410, 11630, 11840, 12420, 12600, 12800, 12980, 15e3, 15200, 15600, 15800, 31700, 32200, 32700, 33200, 40500, 41200, 42100, 42632, null, 168806], "Electron affinity": -2.33 }, Np: { "Atomic mass": 237, "Atomic no": 93, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4273 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "20450 kg m<sup>-3</sup>", "Electrical resistivity": "120 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>4</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 2: 1.24, 3: 1.15, 4: 1.01, 5: 0.89, 6: 0.86, 7: 0.85 }, "Liquid range": "3363 K", "Melting point": "910 K", "Mendeleev no": 44, "Mineral hardness": "no data", "Molar volume": "11.59 cm<sup>3</sup>", Name: "Neptunium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } } }, 3: { VI: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } } }, 4: { VI: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VIII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } } }, 5: { VI: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } } }, 6: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 7: { VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.39, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.36, "Youngs modulus": "no data GPa", "Metallic radius": 1.503, iupac_ordering: 28, "IUPAC ordering": 28, "Ground level": "6L11/2", "Ionization energies": [6.26554, 11.5, 19.7, 33.8, 48, 65, 92, 107, 121, 136, 151, 179, 196, 233, 252, 355, 382, 408, 438, 466, 495, 535, 565, 596, 626, 770, 810, 850, 880, 980, 1020, 1130, 1170, 1280, 1360, 1430, 1510, 1590, 1670, 1740, 1820, 1910, 1990, 2070, 2140, 2230, 2310, 2675, 2745, 2817, 2894, 2969, 3041, 3181, 3255, 3338, 3413, 3718, 3792, 3872, 3947, 4353, 4441, 4658, 4744, 7610, 7770, 7950, 8130, 8310, 8480, 8890, 9070, 9270, 9450, 9970, 10130, 10300, 10470, 11730, 11930, 12320, 12500, 25870, 26300, 26770, 27210, 31910, 32500, 33300, 33722.2, 132901.8, 135202], "Electron affinity": 0.48 }, O: { "Atomic mass": 15.9994, "Atomic no": 8, "Atomic orbitals": { "1s": -18.758245, "2p": -0.338381, "2s": -0.871362 }, "Atomic radius": 0.6, "Atomic radius calculated": 0.48, "Boiling point": "90.2 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2], "Critical temperature": "154.6 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>4</sup>", "ICSD oxidation states": [-2], "Ionic radii": { "-2": 1.26 }, "Liquid range": "35.4 K", "Melting point": "54.8 K", "Mendeleev no": 101, "Mineral hardness": "no data", "Molar volume": "17.36 cm<sup>3</sup>", Name: "Oxygen", "Oxidation states": [-2, -1, 1, 2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000271 (gas; liquid 1.221)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { "-2": { II: { "": { crystal_radius: 1.21, ionic_radius: 1.35 } }, III: { "": { crystal_radius: 1.22, ionic_radius: 1.36 } }, IV: { "": { crystal_radius: 1.24, ionic_radius: 1.38 } }, VI: { "": { crystal_radius: 1.26, ionic_radius: 1.4 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.42 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02658 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.52, "Velocity of sound": "317.5 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.44, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "O-17": -25.58 }, "Metallic radius": "no data", iupac_ordering: 97, "IUPAC ordering": 97, "Ground level": "3P2", "Ionization energies": [13.618055, 35.12112, 54.93554, 77.4135, 113.899, 138.1189, 739.32683, 871.409883], "Electron affinity": 1.4611053 }, Os: { "Atomic mass": 190.23, "Atomic no": 76, "Atomic orbitals": { "1s": -2475.238617, "2p": -393.15408, "2s": -409.522396, "3d": -72.497183, "3p": -86.837047, "3s": -94.501324, "4d": -10.176082, "4f": -2.321175, "4p": -16.119671, "4s": -19.362527, "5d": -0.296791, "5p": -1.757404, "5s": -2.738293, "6s": -0.191489 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.85, "Boiling point": "5285 K", "Brinell hardness": "3920 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "22610 kg m<sup>-3</sup>", "Electrical resistivity": "8.1 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>6</sup>.6s<sup>2</sup>", "Ionic radii": { 4: 0.77, 5: 0.715, 6: 0.685, 7: 0.665, 8: 0.53 }, "Liquid range": "1979 K", "Melting point": "3306 K", "Mendeleev no": 63, "Mineral hardness": "7.0", "Molar volume": "8.42 cm<sup>3</sup>", Name: "Osmium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.25", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "222 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } } }, 5: { VI: { "": { crystal_radius: 0.715, ionic_radius: 0.575 } } }, 6: { V: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, VI: { "": { crystal_radius: 0.685, ionic_radius: 0.545 } } }, 7: { VI: { "": { crystal_radius: 0.665, ionic_radius: 0.525 } } }, 8: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } } } }, "Superconduction temperature": "0.66 K", "Thermal conductivity": "88 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "4940 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": 1.352, iupac_ordering: 62, "IUPAC ordering": 62, "Ground level": "5D4", "Ionization energies": [8.43823, 17, 25, 41, 55, 70.1, 85.1, 102.02, 168.7, 190, 213, 235, 269, 298, 322, 367, 410, 436, 470, 520, 570, 620, 670, 720, 770, 820, 870, 920, 970, 1015, 1262, 1311, 1364, 1420, 1474, 1528, 1606, 1660, 1720, 1776, 1996, 2052, 2112, 2168, 2336, 2400, 2552, 2615.5, 4374, 4501, 4635, 4779, 4917, 5052, 5280, 5421, 5575, 5717, 6115, 6240, 6376, 6503, 7039, 7185, 7468, 7610, 16560, 16900, 17270, 17620, 19600, 20030, 20570, 20920.6, 83976.21, 85614.4], "Electron affinity": 1.0778013 }, P: { "Atomic mass": 30.973762, "Atomic no": 15, "Atomic orbitals": { "1s": -76.061897, "2p": -4.576617, "2s": -6.329346, "3p": -0.20608, "3s": -0.512364 }, "Atomic radius": 1, "Atomic radius calculated": 0.98, "Boiling point": "550 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "994 K", "Density of solid": "1823 kg m<sup>-3</sup>", "Electrical resistivity": "about 10 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>3</sup>", "ICSD oxidation states": [3, 4, 5, -2, -3, -1], "Ionic radii": { 3: 0.58, 5: 0.52 }, "Liquid range": "232.7 K", "Melting point": "(white P) 317.3 K", "Mendeleev no": 90, "Mineral hardness": "no data", "Molar volume": "17.02 cm<sup>3</sup>", Name: "Phosphorus", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001212", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } } }, 5: { IV: { "": { crystal_radius: 0.31, ionic_radius: 0.17 } }, V: { "": { crystal_radius: 0.43, ionic_radius: 0.29 } }, VI: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.236 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.8, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.19, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 90, "IUPAC ordering": 90, "Ground level": "4S°3/2", "Ionization energies": [10.486686, 19.76949, 30.20264, 51.44387, 65.02511, 220.43, 263.57, 309.6, 372.31, 424.4, 479.44, 560.62, 611.741, 2816.90879, 3069.8416], "Electron affinity": 0.7466071 }, Pa: { "Atomic mass": 231.03588, "Atomic no": 91, "Atomic orbitals": { "1s": -3606.333629, "2p": -603.470278, "2s": -623.870431, "3d": -127.781168, "3p": -146.485678, "3s": -156.466742, "4d": -25.933121, "4f": -14.105747, "4p": -34.48293, "4s": -39.064507, "5d": -3.659928, "5f": -0.316813, "5p": -6.709821, "5s": -8.463463, "6d": -0.142481, "6p": -0.799756, "6s": -1.287232, "7s": -0.129653 }, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "15370 kg m<sup>-3</sup>", "Electrical resistivity": "18 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>2</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.16, 4: 1.04, 5: 0.92 }, "Liquid range": "no data K", "Melting point": "1841 K", "Mendeleev no": 46, "Mineral hardness": "no data", "Molar volume": "15.18 cm<sup>3</sup>", Name: "Protactinium", "Oxidation states": [3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.18, ionic_radius: 1.04 } } }, 4: { VI: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VIII: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } } }, 5: { VI: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "": { crystal_radius: 1.05, ionic_radius: 0.91 } }, IX: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "1.4 K", "Thermal conductivity": "47 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.5, "Youngs modulus": "no data GPa", "Metallic radius": 1.642, iupac_ordering: 30, "IUPAC ordering": 30, "Ground level": "4K11/2", "Ionization energies": [5.89, 11.9, 18.6, 30.9, 44.3, 72, 85.1, 98.9, 111, 137, 153, 187, 203, 292, 316, 342, 369, 395, 423, 460, 488, 518, 546, 690, 720, 760, 790, 880, 920, 1020, 1060, 1150, 1220, 1300, 1370, 1450, 1520, 1600, 1670, 1760, 1830, 1910, 1980, 2060, 2130, 2483, 2550, 2620, 2696, 2766, 2837, 2968, 3040, 3119, 3193, 3488, 3558, 3637, 3709, 4077, 4161, 4370, 4454, 7181, 7341, 7510, 7690, 7870, 8040, 8410, 8590, 8780, 8960, 9460, 9620, 9790, 9950, 11100, 11290, 11660, 11840, 24660, 25080, 25540, 25970, 30230, 30800, 31520, 31971.6, 126296.6, 128507.1], "Electron affinity": 0.55 }, Pb: { "Atomic mass": 207.2, "Atomic no": 82, "Atomic orbitals": { "1s": -2901.078061, "2p": -470.877785, "2s": -488.843335, "3d": -91.889924, "3p": -107.950391, "3s": -116.526852, "4d": -15.030026, "4f": -5.592532, "4p": -21.990564, "4s": -25.75333, "5d": -0.902393, "5p": -2.941657, "5s": -4.206797, "6p": -0.141831, "6s": -0.357187 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.54, "Boiling point": "2022 K", "Brinell hardness": "38.3 MN m<sup>-2</sup>", "Bulk modulus": "46 GPa", "Coefficient of linear thermal expansion": "28.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "11340 kg m<sup>-3</sup>", "Electrical resistivity": "21 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>2</sup>", "ICSD oxidation states": [2, 4], "Ionic radii": { 2: 1.33, 4: 0.915 }, "Liquid range": "1421.39 K", "Melting point": "600.61 K", "Mendeleev no": 82, "Mineral hardness": "1.5", "Molar volume": "18.26 cm<sup>3</sup>", Name: "Lead", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.44", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "5.6 GPa", "Shannon radii": { 2: { IVPY: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } }, VI: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } }, VII: { "": { crystal_radius: 1.37, ionic_radius: 1.23 } }, VIII: { "": { crystal_radius: 1.43, ionic_radius: 1.29 } }, IX: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } }, X: { "": { crystal_radius: 1.54, ionic_radius: 1.4 } }, XI: { "": { crystal_radius: 1.59, ionic_radius: 1.45 } }, XII: { "": { crystal_radius: 1.63, ionic_radius: 1.49 } } }, 4: { IV: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } }, V: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } }, VI: { "": { crystal_radius: 0.915, ionic_radius: 0.775 } }, VIII: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } } } }, "Superconduction temperature": "7.2 K", "Thermal conductivity": "35 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "1260 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.33, "Youngs modulus": "16 GPa", "Metallic radius": 1.75, iupac_ordering: 82, "IUPAC ordering": 82, "Ground level": "1/2,1/2)0", "Ionization energies": [7.4166799, 15.032499, 31.9373, 42.33256, 68.8, 82.9, 100.1, 120, 138, 158, 182, 203, 224, 245.1, 338.1, 374, 401, 427, 478, 507, 570, 610, 650, 690, 750, 810, 870, 930, 990, 1050, 1120, 1180, 1240, 1300, 1360, 1430, 1704, 1760, 1819, 1884, 1945, 2004, 2101, 2163, 2230, 2292, 2543, 2605, 2671, 2735, 2965, 3036, 3211, 3282.1, 5414, 5555, 5703, 5862, 6015, 6162, 6442, 6597, 6767, 6924, 7362, 7500, 7650, 7790, 8520, 8680, 9e3, 9150, 19590, 19970, 20380, 20750, 23460, 23940, 24550, 24938.2, 99491.85, 101336.4], "Electron affinity": 0.3567212 }, Pd: { "Atomic mass": 106.42, "Atomic no": 46, "Atomic orbitals": { "1s": -860.134909, "2p": -114.408286, "2s": -123.105078, "3d": -12.132197, "3p": -18.580798, "3s": -22.060898, "4d": -0.160771, "4p": -1.815215, "4s": -2.889173 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.69, "Boiling point": "3236 K", "Brinell hardness": "37.3 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "11.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "12023 kg m<sup>-3</sup>", "Electrical resistivity": "10.8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>", "ICSD oxidation states": [2, 4], "Ionic radii": { 1: 0.73, 2: 1, 3: 0.9, 4: 0.755 }, "Liquid range": "1407.95 K", "Melting point": "1828.05 K", "Mendeleev no": 69, "Mineral hardness": "4.75", "Molar volume": "8.56 cm<sup>3</sup>", Name: "Palladium", "Oxidation states": [2, 4], "Poissons ratio": "0.39", Reflectivity: "72 %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } } }, 2: { IVSQ: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } } }, 3: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } }, 4: { VI: { "": { crystal_radius: 0.755, ionic_radius: 0.615 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "3070 m s<sup>-1</sup>", "Vickers hardness": "461 MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "121 GPa", "Metallic radius": 1.376, iupac_ordering: 69, "IUPAC ordering": 69, "Ground level": "1S0", "Ionization energies": [8.336839, 19.43, 32.93, 46, 61, 84.1, 101, 120, 141, 159.9, 238.57, 260, 286, 311, 342, 369.1, 427, 457.5, 810, 869, 933, 1e3, 1065, 1145, 1218, 1290, 1366, 1438, 1644, 1706.2, 1781.3, 1869, 1962, 2016, 2181, 2248.87, 5284, 5475, 5683, 5880, 6242, 6469, 6759, 6943.097, 28776.034, 29622.6], "Electron affinity": 0.5621412 }, Pm: { "Atomic mass": 145, "Atomic no": 61, "Atomic orbitals": { "1s": -1562.980284, "2p": -233.455114, "2s": -245.970548, "3d": -37.625433, "3p": -47.921132, "3s": -53.429311, "4d": -4.596822, "4f": -0.200159, "4p": -8.320495, "4s": -10.422756, "5p": -0.817702, "5s": -1.372265, "6s": -0.127053 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.05, "Boiling point": "3273 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "11 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7264 kg m<sup>-3</sup>", "Electrical resistivity": "about 75 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>5</sup>.6s<sup>2</sup>", "Ionic radii": { 3: 1.11 }, "Liquid range": "1900 K", "Melting point": "1373 K", "Mendeleev no": 29, "Mineral hardness": "no data", "Molar volume": "20.23 cm<sup>3</sup>", Name: "Promethium", "Oxidation states": [3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VIII: { "": { crystal_radius: 1.233, ionic_radius: 1.093 } }, IX: { "": { crystal_radius: 1.284, ionic_radius: 1.144 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.38, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.13, "Youngs modulus": "46 GPa", "Metallic radius": 1.811, iupac_ordering: 43, "IUPAC ordering": 43, "Ground level": "6H°5/2", "Ionization energies": [5.58187, 10.938, 22.44, 41.17, 61.7, 85, 101, 116, 138, 155, 174, 202, 229, 248, 269, 430, 462, 497, 534, 569, 609, 651, 689, 730, 767, 916, 956, 998, 1040, 1113, 1158, 1261, 1308.7, 2251, 2344, 2443, 2549, 2652, 2755, 2892, 2997, 3112, 3219, 3519, 3613, 3718, 3816, 4056, 4166, 4371, 4476, 10115, 10378, 10671, 10942, 11819, 12136, 12532, 12797.26, 52144.29, 53346.1], "Electron affinity": 0.129 }, Po: { "Atomic mass": 210, "Atomic no": 84, "Atomic orbitals": { "1s": -3050.988417, "2p": -498.77192, "2s": -517.275843, "3d": -99.256068, "3p": -115.898384, "3s": -124.783683, "4d": -17.173307, "4f": -7.206499, "4p": -24.481337, "4s": -28.42254, "5d": -1.386458, "5p": -3.655382, "5s": -5.027447, "6p": -0.217889, "6s": -0.493528 }, "Atomic radius": 1.9, "Atomic radius calculated": 1.35, "Boiling point": "1235 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4], "Critical temperature": "no data K", "Density of solid": "9196 kg m<sup>-3</sup>", "Electrical resistivity": "40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>4</sup>", "Ionic radii": { 4: 1.08, 6: 0.81 }, "Liquid range": "708 K", "Melting point": "527 K", "Mendeleev no": 91, "Mineral hardness": "no data", "Molar volume": "22.97 cm<sup>3</sup>", Name: "Polonium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } }, VIII: { "": { crystal_radius: 1.22, ionic_radius: 1.08 } } }, 6: { VI: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "20 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.97, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2, "Youngs modulus": "no data GPa", "Metallic radius": 1.53, iupac_ordering: 93, "IUPAC ordering": 93, "Ground level": "3P2", "Ionization energies": [8.41807, 19.3, 27.3, 36, 57, 69.1, 108, 125, 146.1, 166, 186, 209, 235, 257, 281, 304, 416, 444, 473, 502, 560, 590, 670, 700, 740, 800, 870, 930, 990, 1060, 1120, 1180, 1250, 1320, 1380, 1440, 1510, 1570, 1865, 1923, 1986, 2052, 2115, 2177, 2281, 2345, 2414, 2480, 2740, 2803, 2873, 2938, 3194, 3268, 3450, 3524.2, 5785, 5930, 6084, 6248, 6405, 6557, 6856, 7015, 7191, 7350, 7810, 7950, 8100, 8240, 9050, 9220, 9550, 9710, 20670, 21050, 21470, 21860, 24860, 25360, 25990, 26390.4, 105064.3, 106982.7], "Electron affinity": 1.407 }, Pr: { "Atomic mass": 140.90765, "Atomic no": 59, "Atomic orbitals": { "1s": -1457.338067, "2p": -215.418313, "2s": -227.426363, "3d": -33.913996, "3p": -43.692548, "3s": -48.924994, "4d": -4.154228, "4f": -0.155138, "4p": -7.613108, "4s": -9.577447, "5p": -0.778046, "5s": -1.296106, "6s": -0.124465 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.47, "Boiling point": "3563 K", "Brinell hardness": "481 MN m<sup>-2</sup>", "Bulk modulus": "29 GPa", "Coefficient of linear thermal expansion": "6.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6640 kg m<sup>-3</sup>", "Electrical resistivity": "70 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>3</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.13, 4: 0.99 }, "Liquid range": "2355 K", "Melting point": "1208 K", "Mendeleev no": 31, "Mineral hardness": "no data", "Molar volume": "20.80 cm<sup>3</sup>", Name: "Praseodymium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "15 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.13, ionic_radius: 0.99 } }, VIII: { "": { crystal_radius: 1.266, ionic_radius: 1.126 } }, IX: { "": { crystal_radius: 1.319, ionic_radius: 1.179 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.4, "Velocity of sound": "2280 m s<sup>-1</sup>", "Vickers hardness": "400 MN m<sup>-2</sup>", X: 1.13, "Youngs modulus": "37 GPa", "Metallic radius": 1.828, iupac_ordering: 45, "IUPAC ordering": 45, "Ground level": "4I°9/2", "Ionization energies": [5.4702, 10.631, 21.6237, 38.981, 57.53, 82, 97, 112, 131, 148, 162, 196, 217.02, 350, 378, 412, 445, 478, 516, 554, 590, 627, 663, 803, 840, 880, 920, 985, 1028, 1124, 1169.9, 2019, 2108, 2202, 2304, 2400, 2501, 2628, 2729, 2838, 2941, 3227, 3319, 3419, 3512, 3729, 3832, 4030, 4130, 9378, 9632, 9913, 10175, 10959, 11262, 11641, 11895.89, 48571.71, 49722.25], "Electron affinity": 0.1092346 }, Pt: { "Atomic mass": 195.084, "Atomic no": 78, "Atomic orbitals": { "1s": -2613.096532, "2p": -417.96053, "2s": -434.858003, "3d": -78.400271, "3p": -93.309108, "3s": -101.274869, "4d": -11.419476, "4f": -3.038049, "4p": -17.697297, "4s": -21.110651, "5d": -0.273634, "5p": -1.884256, "5s": -2.950526, "6s": -0.161308 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.77, "Boiling point": "4098 K", "Brinell hardness": "392 MN m<sup>-2</sup>", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "8.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "21090 kg m<sup>-3</sup>", "Electrical resistivity": "10.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>9</sup>.6s<sup>1</sup>", "Ionic radii": { 2: 0.94, 4: 0.765, 5: 0.71 }, "Liquid range": "2056.6 K", "Melting point": "2041.4 K", "Mendeleev no": 68, "Mineral hardness": "3.5", "Molar volume": "9.09 cm<sup>3</sup>", Name: "Platinum", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "0.38", Reflectivity: "73 %", "Refractive index": "no data", "Rigidity modulus": "61 GPa", "Shannon radii": { 2: { IVSQ: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, VI: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } } }, 4: { VI: { "": { crystal_radius: 0.765, ionic_radius: 0.625 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "2680 m s<sup>-1</sup>", "Vickers hardness": "549 MN m<sup>-2</sup>", X: 2.28, "Youngs modulus": "168 GPa", "Metallic radius": 1.387, iupac_ordering: 68, "IUPAC ordering": 68, "Ground level": "3D3", "Ionization energies": [8.95883, 18.56, 29, 43, 56, 75, 91, 109, 126, 144.9, 220.4, 245, 269, 293, 332, 358, 392, 445, 479, 507, 550, 610, 660, 710, 760, 820, 870, 930, 980, 1040, 1090, 1140, 1402, 1454, 1509, 1567, 1624, 1680, 1763, 1821, 1883, 1941, 2171, 2228, 2291, 2350, 2536, 2603, 2762, 2827.8, 4715, 4839, 4980, 5128, 5270, 5410, 5654, 5800, 5959, 6106, 6517, 6646, 6787, 6918, 7512, 7660, 7960, 8100, 17540, 17890, 18280, 18630, 20840, 21280, 21840, 22205.7, 88955.18, 90659.7], "Electron affinity": 2.125105 }, Pu: { "Atomic mass": 244, "Atomic no": 94, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "3503 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "19816 kg m<sup>-3</sup>", "Electrical resistivity": "150 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>6</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.14, 4: 1, 5: 0.88, 6: 0.85 }, "Liquid range": "2590.5 K", "Melting point": "912.5 K", "Mendeleev no": 43, "Mineral hardness": "no data", "Molar volume": "12.29 cm<sup>3</sup>", Name: "Plutonium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "43 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.14, ionic_radius: 1 } } }, 4: { VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 5: { VI: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } }, 6: { VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.43, "Velocity of sound": "2260 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.28, "Youngs modulus": "96 GPa", "Metallic radius": 1.523, iupac_ordering: 27, "IUPAC ordering": 27, "Ground level": "7F0", "Ionization energies": [6.02576, 11.5, 21.1, 35, 49, 80, 95, 109, 124, 139, 159, 179, 200, 219, 258, 278, 389, 416, 444, 474, 503, 532, 575, 605, 637, 668, 820, 850, 890, 930, 1030, 1070, 1180, 1220, 1340, 1420, 1500, 1580, 1660, 1740, 1820, 1890, 1990, 2070, 2150, 2230, 2310, 2390, 2774, 2844, 2918, 2997, 3072, 3146, 3290, 3366, 3449, 3527, 3836, 3911, 3993, 4068, 4496, 4585, 4807, 4890, 7830, 7990, 8170, 8360, 8540, 8710, 9130, 9310, 9520, 9700, 10230, 10390, 10570, 10730, 12060, 12260, 12660, 12840, 26480, 26920, 27400, 27840, 32800, 33400, 34100, 34625.8, 136299.2, 138646], "Electron affinity": -0.5 }, Ra: { "Atomic mass": 226, "Atomic no": 88, "Atomic orbitals": { "1s": -3362.736563, "2p": -557.513214, "2s": -577.101208, "3d": -115.306476, "3p": -133.12325, "3s": -142.632426, "4d": -22.208125, "4f": -11.181066, "4p": -30.221208, "4s": -34.525628, "5d": -2.819853, "5p": -5.547203, "5s": -7.139137, "6p": -0.634674, "6s": -1.05135, "7s": -0.113732 }, "Atomic radius": 2.15, "Atomic radius calculated": "no data", "Boiling point": "2010 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "5000 kg m<sup>-3</sup>", "Electrical resistivity": "100 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].7s<sup>2</sup>", "Ionic radii": { 2: 1.62 }, "Liquid range": "1037 K", "Melting point": "973 K", "Mendeleev no": 13, "Mineral hardness": "no data", "Molar volume": "41.09 cm<sup>3</sup>", Name: "Radium", "Oxidation states": [2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VIII: { "": { crystal_radius: 1.62, ionic_radius: 1.48 } }, XII: { "": { crystal_radius: 1.84, ionic_radius: 1.7 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "19 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.83, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.9, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Ra-223": 1210.3 }, "Metallic radius": 2.293, iupac_ordering: 12, "IUPAC ordering": 12, "Ground level": "1S0", "Ionization energies": [5.2784239, 10.14718, 31, 41, 52.9, 64, 82, 97, 124, 140, 204.9, 227, 250, 274, 299, 324, 356, 382, 409, 435, 570, 600, 630, 660, 740, 770, 860, 900, 970, 1040, 1110, 1180, 1250, 1320, 1390, 1460, 1530, 1610, 1680, 1750, 1820, 1880, 2208, 2271, 2338, 2409, 2477, 2544, 2662, 2731, 2806, 2876, 3155, 3224, 3298, 3368, 3682, 3762, 3959, 4040, 6565, 6718, 6881, 7056, 7222, 7380, 7720, 7890, 8080, 8250, 8730, 8880, 9040, 9200, 10190, 10360, 10720, 10890, 22900, 23300, 23750, 24160, 27830, 28370, 29050, 29479.8, 116848.7, 118931.3], "Electron affinity": 0.1 }, Rb: { "Atomic mass": 85.4678, "Atomic no": 37, "Atomic orbitals": { "1s": -540.957115, "2p": -64.784678, "2s": -71.291202, "3d": -3.915508, "3p": -8.165416, "3s": -10.513861, "4p": -0.59217, "4s": -1.135051, "5s": -0.085375 }, "Atomic radius": 2.35, "Atomic radius calculated": 2.65, "Boiling point": "961 K", "Brinell hardness": "0.216 MN m<sup>-2</sup>", "Bulk modulus": "2.5 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2093 K", "Density of solid": "1532 kg m<sup>-3</sup>", "Electrical resistivity": "13.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].5s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.66 }, "Liquid range": "648.54 K", "Melting point": "312.46 K", "Mendeleev no": 9, "Mineral hardness": "0.3", "Molar volume": "55.76 cm<sup>3</sup>", Name: "Rubidium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.66, ionic_radius: 1.52 } }, VII: { "": { crystal_radius: 1.7, ionic_radius: 1.56 } }, VIII: { "": { crystal_radius: 1.75, ionic_radius: 1.61 } }, IX: { "": { crystal_radius: 1.77, ionic_radius: 1.63 } }, X: { "": { crystal_radius: 1.8, ionic_radius: 1.66 } }, XI: { "": { crystal_radius: 1.83, ionic_radius: 1.69 } }, XII: { "": { crystal_radius: 1.86, ionic_radius: 1.72 } }, XIV: { "": { crystal_radius: 1.97, ionic_radius: 1.83 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "58 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.03, "Velocity of sound": "1300 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.82, "Youngs modulus": "2.4 GPa", "Metallic radius": 2.537, iupac_ordering: 8, "IUPAC ordering": 8, "Ground level": "2S1/2", "Ionization energies": [4.1771281, 27.28954, 39.247, 52.2, 68.44, 82.9, 98.67, 132.79, 150.628, 277.12, 313.1, 356, 400, 443, 502, 550, 601, 654, 706, 857, 905.3, 958.9, 1024, 1080, 1125, 1242.5, 1294.57, 3133.3, 3281, 3443, 3600, 3815, 3988, 4214, 4356.865, 18305.884, 18965.516], "Electron affinity": 0.48591621 }, Re: { "Atomic mass": 186.207, "Atomic no": 75, "Atomic orbitals": { "1s": -2407.665572, "2p": -380.982869, "2s": -397.087707, "3d": -69.57676, "3p": -83.634578, "3s": -91.149193, "4d": -9.516816, "4f": -1.92508, "4p": -15.295495, "4s": -18.454325, "5d": -0.258639, "5p": -1.631227, "5s": -2.567348, "6s": -0.186859 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.88, "Boiling point": "5869 K", "Brinell hardness": "1320 MN m<sup>-2</sup>", "Bulk modulus": "370 GPa", "Coefficient of linear thermal expansion": "6.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "21020 kg m<sup>-3</sup>", "Electrical resistivity": "18 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>5</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5, 6, 7], "Ionic radii": { 4: 0.77, 5: 0.72, 6: 0.69, 7: 0.67 }, "Liquid range": "2410 K", "Melting point": "3459 K", "Mendeleev no": 58, "Mineral hardness": "7.0", "Molar volume": "8.86 cm<sup>3</sup>", Name: "Rhenium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "0.30", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "178 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } } }, 5: { VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } } }, 6: { VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } }, 7: { IV: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "1.70 K", "Thermal conductivity": "48 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "4700 m s<sup>-1</sup>", "Vickers hardness": "2450 MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "463 GPa", "Metallic radius": 1.375, iupac_ordering: 59, "IUPAC ordering": 59, "Ground level": "6S5/2", "Ionization energies": [7.83352, 16.6, 27, 39.1, 51.9, 67, 82.71, 144.4, 165, 187, 208, 236, 268, 291, 330, 377, 403, 429, 476, 520, 570, 620, 670, 720, 760, 810, 860, 910, 953, 1194, 1242, 1294, 1349, 1402, 1454, 1530, 1583, 1641, 1696, 1912, 1966, 2025, 2080, 2240, 2302, 2450, 2514.5, 4214, 4335, 4468, 4609, 4745, 4877, 5099, 5236, 5388, 5528, 5919, 6042, 6176, 6300, 6810, 6952, 7230, 7366, 16080, 16410, 16780, 17120, 19e3, 19420, 19950, 20297.4, 81556.9, 83162.3], "Electron affinity": 0.06039663 }, Rh: { "Atomic mass": 102.9055, "Atomic no": 45, "Atomic orbitals": { "1s": -821.136773, "2p": -108.357665, "2s": -116.80695, "3d": -11.21725, "3p": -17.415299, "3s": -20.765603, "4d": -0.239422, "4p": -1.806456, "4s": -2.825505, "5s": -0.154624 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.73, "Boiling point": "3968 K", "Brinell hardness": "1100 MN m<sup>-2</sup>", "Bulk modulus": "380 GPa", "Coefficient of linear thermal expansion": "8.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "12450 kg m<sup>-3</sup>", "Electrical resistivity": "4.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>8</sup>.5s<sup>1</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 0.805, 4: 0.74, 5: 0.69 }, "Liquid range": "1731 K", "Melting point": "2237 K", "Mendeleev no": 65, "Mineral hardness": "6.0", "Molar volume": "8.28 cm<sup>3</sup>", Name: "Rhodium", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", Reflectivity: "84 %", "Refractive index": "no data", "Rigidity modulus": "150 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.805, ionic_radius: 0.665 } } }, 4: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 5: { VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "4700 m s<sup>-1</sup>", "Vickers hardness": "1246 MN m<sup>-2</sup>", X: 2.28, "Youngs modulus": "275 GPa", "Metallic radius": 1.345, iupac_ordering: 66, "IUPAC ordering": 66, "Ground level": "4F9/2", "Ionization energies": [7.4589, 18.08, 31.06, 42, 63, 80, 97, 115.1, 135, 207.51, 228, 252.1, 277, 306, 331.58, 389.3, 415.97, 739, 794, 857, 921, 984, 1061, 1131, 1202, 1274, 1344, 1544, 1604.9, 1677.6, 1763, 1851, 1903, 2063, 2129.22, 5018, 5203, 5406, 5600, 5940, 6161, 6444, 6623.262, 27486.983, 28311.965], "Electron affinity": 1.142892 }, Rn: { "Atomic mass": 220, "Atomic no": 86, "Atomic orbitals": { "1s": -3204.756288, "2p": -527.533025, "2s": -546.57796, "3d": -106.945006, "3p": -124.172862, "3s": -133.369144, "4d": -19.449994, "4f": -8.953318, "4p": -27.108985, "4s": -31.230804, "5d": -1.911329, "5p": -4.408702, "5s": -5.889683, "6p": -0.29318, "6s": -0.62657 }, "Atomic radius": "no data", "Atomic radius calculated": 1.2, "Boiling point": "211.3 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "377 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>6</sup>", "Liquid range": "9.3 K", "Max oxidation state": 0, "Melting point": "202 K", "Mendeleev no": 6, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "50.50 cm<sup>3</sup>", Name: "Radon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00361 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.2, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 0, "IUPAC ordering": 0, "Ground level": "1S0", "Ionization energies": [10.7485, 21.4, 29.4, 36.9, 52.9, 64, 88, 102, 154, 173.9, 195, 218, 240, 264, 293, 317, 342, 367, 488, 520, 550, 580, 640, 680, 760, 800, 850, 920, 980, 1050, 1110, 1180, 1250, 1310, 1390, 1460, 1520, 1590, 1660, 1720, 2033, 2094, 2158, 2227, 2293, 2357, 2467, 2535, 2606, 2674, 2944, 3010, 3082, 3149, 3433, 3510, 3699, 3777, 6169, 6318, 6476, 6646, 6807, 6964, 7283, 7450, 7630, 7800, 8260, 8410, 8570, 8710, 9610, 9780, 10120, 10290, 21770, 22160, 22600, 22990, 26310, 26830, 27490, 27903.1, 110842, 112843.7], "Electron affinity": -0.72 }, Ru: { "Atomic mass": 101.07, "Atomic no": 44, "Atomic orbitals": { "1s": -782.918621, "2p": -102.333649, "2s": -110.536054, "3d": -10.195668, "3p": -16.145217, "3s": -19.366692, "4d": -0.210375, "4p": -1.667549, "4s": -2.628363, "5s": -0.152834 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.78, "Boiling point": "4423 K", "Brinell hardness": "2160 MN m<sup>-2</sup>", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "6.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "12370 kg m<sup>-3</sup>", "Electrical resistivity": "7.1 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>7</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 3: 0.82, 4: 0.76, 5: 0.705, 7: 0.52, 8: 0.5 }, "Liquid range": "1816 K", "Melting point": "2607 K", "Mendeleev no": 62, "Mineral hardness": "6.5", "Molar volume": "8.17 cm<sup>3</sup>", Name: "Ruthenium", "Oxidation states": [-2, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.30", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "173 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 4: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } }, 5: { VI: { "": { crystal_radius: 0.705, ionic_radius: 0.565 } } }, 7: { IV: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } } }, 8: { IV: { "": { crystal_radius: 0.5, ionic_radius: 0.36 } } } }, "Superconduction temperature": "0.49 K", "Thermal conductivity": "120 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "5970 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "447 GPa", "Metallic radius": 1.339, iupac_ordering: 63, "IUPAC ordering": 63, "Ground level": "5F5", "Ionization energies": [7.3605, 16.76, 28.47, 45, 59, 76, 93, 110, 178.41, 198, 219.9, 245, 271, 295.9, 348, 376.25, 670, 723, 784, 845, 905, 981, 1048, 1115, 1187, 1253, 1447, 1506.7, 1577, 1659, 1743, 1794, 1949, 2013.04, 4758, 4939, 5136, 5330, 5647, 5861, 6137, 6311.721, 26229.895, 27033.502], "Electron affinity": 1.0463825 }, S: { "Atomic mass": 32.065, "Atomic no": 16, "Atomic orbitals": { "1s": -87.789937, "2p": -5.751257, "2s": -7.69994, "3p": -0.261676, "3s": -0.630912 }, "Atomic radius": 1, "Atomic radius calculated": 0.88, "Boiling point": "717.87 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1314 K", "Density of solid": "1960 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>23</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>4</sup>", "ICSD oxidation states": [-1, 2, 4, -2, 6], "Ionic radii": { "-2": 1.7, 4: 0.51, 6: 0.43 }, "Liquid range": "329.51 K", "Melting point": "388.36 K", "Mendeleev no": 94, "Mineral hardness": "2.0", "Molar volume": "15.53 cm<sup>3</sup>", Name: "Sulfur", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001111", "Rigidity modulus": "no data GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 1.7, ionic_radius: 1.84 } } }, 4: { VI: { "": { crystal_radius: 0.51, ionic_radius: 0.37 } } }, 6: { IV: { "": { crystal_radius: 0.26, ionic_radius: 0.12 } }, VI: { "": { crystal_radius: 0.43, ionic_radius: 0.29 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.205 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.8, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.58, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "S-33": -67.8, "S-35": 47.1 }, "Metallic radius": "no data", iupac_ordering: 96, "IUPAC ordering": 96, "Ground level": "3P2", "Ionization energies": [10.36001, 23.33788, 34.86, 47.222, 72.5945, 88.0529, 280.954, 328.794, 379.84, 447.7, 504.55, 564.41, 651.96, 706.994, 3223.7807, 3494.1879], "Electron affinity": 2.077104512 }, Sb: { "Atomic mass": 121.76, "Atomic no": 51, "Atomic orbitals": { "1s": -1070.823495, "2p": -149.214271, "2s": -159.171745, "3d": -19.239895, "3p": -26.956184, "3s": -31.098242, "4d": -1.297338, "4p": -3.646579, "4s": -5.04964, "5p": -0.185623, "5s": -0.445605 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.33, "Boiling point": "1860 K", "Brinell hardness": "294 MN m<sup>-2</sup>", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "11 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "no data K", "Density of solid": "6697 kg m<sup>-3</sup>", "Electrical resistivity": "40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>3</sup>", "ICSD oxidation states": [-2, 3, 5, -1, -3], "Ionic radii": { 3: 0.9, 5: 0.76 }, "Liquid range": "956.22 K", "Melting point": "903.78 K", "Mendeleev no": 88, "Mineral hardness": "3.0", "Molar volume": "18.19 cm<sup>3</sup>", Name: "Antimony", "Oxidation states": [-3, 3, 5], "Poissons ratio": "no data", Reflectivity: "55 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 3: { IVPY: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, V: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } }, VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } }, 5: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "24 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "3420 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.05, "Youngs modulus": "55 GPa", "NMR Quadrupole Moment": { "Sb-121": -543.11, "Sb-123": -692.14 }, "Metallic radius": 1.61, iupac_ordering: 88, "IUPAC ordering": 88, "Ground level": "4S°3/2", "Ionization energies": [8.608389, 16.626, 25.3235, 43.804, 55, 99.51, 117, 139, 162, 185, 214, 238, 265, 292, 317, 420, 447, 479, 510, 552, 584, 657, 693.26, 1214, 1285, 1360, 1441, 1518, 1606, 1698, 1781, 1869, 1954, 2190, 2266, 2349, 2428, 2567, 2654, 2815, 2900, 6714, 6929, 7167, 7390, 7887, 8140, 8455, 8669.48, 35710.028, 36668.05], "Electron affinity": 1.04740119 }, Sc: { "Atomic mass": 44.955912, "Atomic no": 21, "Atomic orbitals": { "1s": -160.184109, "2p": -14.240006, "2s": -17.206464, "3d": -0.13108, "3p": -1.233165, "3s": -1.988378, "4s": -0.156478 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.84, "Boiling point": "3103 K", "Brinell hardness": "750 MN m<sup>-2</sup>", "Bulk modulus": "57 GPa", "Coefficient of linear thermal expansion": "10.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2985 kg m<sup>-3</sup>", "Electrical resistivity": "about 55 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>1</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 0.885 }, "Liquid range": "1289 K", "Melting point": "1814 K", "Mendeleev no": 19, "Mineral hardness": "no data", "Molar volume": "15.00 cm<sup>3</sup>", Name: "Scandium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "29 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.885, ionic_radius: 0.745 } }, VIII: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } } } }, "Superconduction temperature": "0.05  (under pressure)K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.15, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.36, "Youngs modulus": "74 GPa", "NMR Quadrupole Moment": { "Sc-45": -220.2 }, "Metallic radius": 1.641, iupac_ordering: 49, "IUPAC ordering": 49, "Ground level": "2D3/2", "Ionization energies": [6.56149, 12.79977, 24.756839, 73.4894, 91.95, 110.68, 137.99, 158.08, 180.03, 225.18, 249.798, 687.36, 757.7, 833.2, 926.5, 1008.6, 1093.5, 1213.1, 1287.957, 5674.9037, 6033.7542], "Electron affinity": 0.1882 }, Se: { "Atomic mass": 78.96, "Atomic no": 34, "Atomic orbitals": { "1s": -451.300258, "2p": -51.514388, "2s": -57.311948, "3d": -2.011392, "3p": -5.553517, "3s": -7.547186, "4p": -0.245806, "4s": -0.621248 }, "Atomic radius": 1.15, "Atomic radius calculated": 1.03, "Boiling point": "958 K", "Brinell hardness": "736 MN m<sup>-2</sup>", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1766 K", "Density of solid": "4819 kg m<sup>-3</sup>", "Electrical resistivity": "high 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>4</sup>", "ICSD oxidation states": [-1, 4, -2, 6], "Ionic radii": { "-2": 1.84, 4: 0.64, 6: 0.56 }, "Liquid range": "464 K", "Melting point": "494 K", "Mendeleev no": 93, "Mineral hardness": "2.0", "Molar volume": "16.42 cm<sup>3</sup>", Name: "Selenium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "0.33", Reflectivity: "no data %", "Refractive index": "1.000895", "Rigidity modulus": "3.7 GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 1.84, ionic_radius: 1.98 } } }, 4: { VI: { "": { crystal_radius: 0.64, ionic_radius: 0.5 } } }, 6: { IV: { "": { crystal_radius: 0.42, ionic_radius: 0.28 } }, VI: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.52 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.9, "Velocity of sound": "3350 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.55, "Youngs modulus": "10 GPa", "Metallic radius": "no data", iupac_ordering: 95, "IUPAC ordering": 95, "Ground level": "3P2", "Ionization energies": [9.752392, 21.196, 31.697, 42.947, 68.3, 81.83, 155.327, 184, 219, 255, 291, 342.9, 383, 426, 473, 517, 650.5, 693.4, 739.8, 798, 845.8, 887, 989.6, 1036.36, 2540.7, 2674, 2820, 2964, 3146, 3301.8, 3507, 3636.526, 15367.491, 15968.084], "Electron affinity": 2.020604712 }, Si: { "Atomic mass": 28.0855, "Atomic no": 14, "Atomic orbitals": { "1s": -65.184426, "2p": -3.514938, "2s": -5.075056, "3p": -0.153293, "3s": -0.398139 }, "Atomic radius": 1.1, "Atomic radius calculated": 1.11, "Boiling point": "3173 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "2.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2330 kg m<sup>-3</sup>", "Electrical resistivity": "about 100000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>2</sup>", "ICSD oxidation states": [-4, 4], "Ionic radii": { 4: 0.54 }, "Liquid range": "1486 K", "Melting point": "1687 K", "Mendeleev no": 85, "Mineral hardness": "6.5", "Molar volume": "12.06 cm<sup>3</sup>", Name: "Silicon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "28 %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.4, ionic_radius: 0.26 } }, VI: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "2200 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "47 GPa", "Metallic radius": "no data", iupac_ordering: 85, "IUPAC ordering": 85, "Ground level": "3P0", "Ionization energies": [8.15168, 16.34585, 33.493, 45.14179, 166.767, 205.279, 246.57, 303.59, 351.28, 401.38, 476.273, 523.415, 2437.65815, 2673.17755], "Electron affinity": 1.38952128 }, Sm: { "Atomic mass": 150.36, "Atomic no": 62, "Atomic orbitals": { "1s": -1617.183426, "2p": -242.729726, "2s": -255.498846, "3d": -39.528656, "3p": -50.08426, "3s": -55.731133, "4d": -4.814978, "4f": -0.21776, "4p": -8.672685, "4s": -10.844667, "5p": -0.835987, "5s": -1.408552, "6s": -0.128259 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.38, "Boiling point": "2076 K", "Brinell hardness": "441 MN m<sup>-2</sup>", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "12.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7353 kg m<sup>-3</sup>", "Electrical resistivity": "94 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>6</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.36, 3: 1.0979999999999999 }, "Liquid range": "731 K", "Melting point": "1345 K", "Mendeleev no": 28, "Mineral hardness": "no data", "Molar volume": "19.98 cm<sup>3</sup>", Name: "Samarium", "Oxidation states": [2, 3], "Poissons ratio": "0.27", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 2: { VII: { "": { crystal_radius: 1.36, ionic_radius: 1.22 } }, VIII: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } }, IX: { "": { crystal_radius: 1.46, ionic_radius: 1.32 } } }, 3: { VI: { "": { crystal_radius: 1.098, ionic_radius: 0.958 } }, VII: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VIII: { "": { crystal_radius: 1.219, ionic_radius: 1.079 } }, IX: { "": { crystal_radius: 1.272, ionic_radius: 1.132 } }, XII: { "": { crystal_radius: 1.38, ionic_radius: 1.24 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.36, "Velocity of sound": "2130 m s<sup>-1</sup>", "Vickers hardness": "412 MN m<sup>-2</sup>", X: 1.17, "Youngs modulus": "50 GPa", "Metallic radius": 1.804, iupac_ordering: 42, "IUPAC ordering": 42, "Ground level": "7F0", "Ionization energies": [5.64371, 11.078, 23.55, 41.64, 62.7, 87, 103, 118, 141, 158, 179, 208, 237, 257, 276, 306.5, 474, 506, 543, 581, 617, 658, 702, 742, 782, 822, 976, 1016, 1060, 1103, 1180, 1226, 1332, 1381.56, 2371, 2466, 2569, 2676, 2782, 2887, 3028, 3137, 3253, 3363, 3669, 3766, 3873, 3971, 4227, 4337, 4548, 4655, 10494, 10762, 11060, 11337, 12264, 12588, 12992, 13262.85, 53986.12, 55214.23], "Electron affinity": 0.162 }, Sn: { "Atomic mass": 118.71, "Atomic no": 50, "Atomic orbitals": { "1s": -1026.762169, "2p": -141.821093, "2s": -151.523991, "3d": -17.657276, "3p": -25.117913, "3s": -29.125969, "4d": -1.004952, "4p": -3.211998, "4s": -4.546335, "5p": -0.14445, "5s": -0.369349 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.45, "Boiling point": "2875 K", "Brinell hardness": "51 MN m<sup>-2</sup>", "Bulk modulus": "58 GPa", "Coefficient of linear thermal expansion": "22 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "7310 kg m<sup>-3</sup>", "Electrical resistivity": "11.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 4: 0.83 }, "Liquid range": "2369.92 K", "Melting point": "505.08 K", "Mendeleev no": 83, "Mineral hardness": "1.5", "Molar volume": "16.29 cm<sup>3</sup>", Name: "Tin", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.36", Reflectivity: "54 %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, V: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } }, VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VII: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VIII: { "": { crystal_radius: 0.95, ionic_radius: 0.81 } } } }, "Superconduction temperature": "3.72 K", "Thermal conductivity": "67 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.17, "Velocity of sound": "2500 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.96, "Youngs modulus": "50 GPa", "NMR Quadrupole Moment": { "Sn-119": -132.1 }, "Metallic radius": 1.58, iupac_ordering: 83, "IUPAC ordering": 83, "Ground level": "3P0", "Ionization energies": [7.343918, 14.63307, 30.506, 40.74, 77.03, 94, 112.9, 135, 156, 184, 208, 232, 258, 282, 379, 407, 437, 466, 506, 537, 608, 642.35, 1127, 1195, 1269, 1347, 1421, 1508, 1596, 1676, 1763, 1844, 2074, 2142.1, 2227, 2326, 2443, 2499, 2687, 2762.49, 6421, 6631, 6859, 7080, 7531, 7790, 8103, 8306.95, 34257.143, 35192.39], "Electron affinity": 1.1120702 }, Sr: { "Atomic mass": 87.62, "Atomic no": 38, "Atomic orbitals": { "1s": -572.870169, "2p": -69.745941, "2s": -76.491823, "3d": -4.813498, "3p": -9.301863, "3s": -11.771585, "4p": -0.844489, "4s": -1.455317, "5s": -0.131793 }, "Atomic radius": 2, "Atomic radius calculated": 2.19, "Boiling point": "1655 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "22.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "2630 kg m<sup>-3</sup>", "Electrical resistivity": "13.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].5s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.32 }, "Liquid range": "605 K", "Melting point": "1050 K", "Mendeleev no": 15, "Mineral hardness": "1.5", "Molar volume": "33.94 cm<sup>3</sup>", Name: "Strontium", "Oxidation states": [2], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "6.1 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, VII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } }, VIII: { "": { crystal_radius: 1.4, ionic_radius: 1.26 } }, IX: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } }, X: { "": { crystal_radius: 1.5, ionic_radius: 1.36 } }, XII: { "": { crystal_radius: 1.58, ionic_radius: 1.44 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "35 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.49, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.95, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Sr-87": 305.2 }, "Metallic radius": 2.151, iupac_ordering: 14, "IUPAC ordering": 14, "Ground level": "1S0", "Ionization energies": [5.69486745, 11.0302765, 42.88353, 56.28, 70.7, 88, 104, 121.21, 158.33, 177.3, 324.07, 362, 408, 454, 499, 562, 612, 665, 722, 774, 932, 982.1, 1038, 1105, 1165, 1211, 1333.4, 1387.19, 3344.7, 3497, 3664, 3830, 4053, 4232, 4465, 4612.397, 19345.588, 20025.233], "Electron affinity": 0.052066 }, Ta: { "Atomic mass": 180.94788, "Atomic no": 73, "Atomic orbitals": { "1s": -2275.371387, "2p": -357.248334, "2s": -372.828724, "3d": -63.942521, "3p": -77.440942, "3s": -84.658467, "4d": -8.265848, "4f": -1.199347, "4p": -13.71981, "4s": -16.713337, "5d": -0.182464, "5p": -1.37653, "5s": -2.223807, "6s": -0.174814 }, "Atomic radius": 1.45, "Atomic radius calculated": 2, "Boiling point": "5731 K", "Brinell hardness": "800 MN m<sup>-2</sup>", "Bulk modulus": "200 GPa", "Coefficient of linear thermal expansion": "6.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "16650 kg m<sup>-3</sup>", "Electrical resistivity": "13.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>3</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5], "Ionic radii": { 3: 0.86, 4: 0.82, 5: 0.78 }, "Liquid range": "2441 K", "Melting point": "3290 K", "Mendeleev no": 52, "Mineral hardness": "6.5", "Molar volume": "10.85 cm<sup>3</sup>", Name: "Tantalum", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.34", Reflectivity: "78 %", "Refractive index": "no data", "Rigidity modulus": "69 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 4: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 5: { VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VII: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "4.47 K", "Thermal conductivity": "57 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.22, "Velocity of sound": "3400 m s<sup>-1</sup>", "Vickers hardness": "873 MN m<sup>-2</sup>", X: 1.5, "Youngs modulus": "186 GPa", "Metallic radius": 1.47, iupac_ordering: 53, "IUPAC ordering": 53, "Ground level": "4F3/2", "Ionization energies": [7.549571, 16.2, 23.1, 35, 48.272, 94.01, 119, 139, 159, 180, 213, 235, 262, 304, 338, 363, 396, 439, 482, 530, 570, 610, 660, 700, 750, 790, 832, 1064, 1110, 1160, 1211, 1262, 1313, 1382, 1434, 1490, 1542, 1748, 1799, 1857, 1910, 2053, 2113, 2254, 2314.7, 3898.7, 4014, 4143, 4278, 4410, 4537, 4745, 4877, 5024, 5159, 5537, 5655, 5785, 5907, 6364, 6502, 6769, 6900, 15137, 15461, 15820, 16150, 17840, 18250, 18760, 19088.51, 76852.03, 78394.7], "Electron affinity": 0.32312 }, Tb: { "Atomic mass": 158.92535, "Atomic no": 65, "Atomic orbitals": { "1s": -1785.331942, "2p": -271.590585, "2s": -285.121013, "3d": -45.443863, "3p": -56.785113, "3s": -62.851563, "4d": -5.467662, "4f": -0.256311, "4p": -9.735637, "4s": -12.120486, "5p": -0.88723, "5s": -1.513669, "6s": -0.131677 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.25, "Boiling point": "3503 K", "Brinell hardness": "677 MN m<sup>-2</sup>", "Bulk modulus": "38.7 GPa", "Coefficient of linear thermal expansion": "10.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8219 kg m<sup>-3</sup>", "Electrical resistivity": "115 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>9</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.063, 4: 0.9 }, "Liquid range": "1874 K", "Melting point": "1629 K", "Mendeleev no": 26, "Mineral hardness": "no data", "Molar volume": "19.30 cm<sup>3</sup>", Name: "Terbium", "Oxidation states": [1, 3, 4], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.063, ionic_radius: 0.923 } }, VII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } }, VIII: { "": { crystal_radius: 1.18, ionic_radius: 1.04 } }, IX: { "": { crystal_radius: 1.235, ionic_radius: 1.095 } } }, 4: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 1.02, ionic_radius: 0.88 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.33, "Velocity of sound": "2620 m s<sup>-1</sup>", "Vickers hardness": "863 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "56 GPa", "Metallic radius": 1.781, iupac_ordering: 39, "IUPAC ordering": 39, "Ground level": "6H°15/2", "Ionization energies": [5.8638, 11.513, 21.82, 39.33, 66.5, 90, 108, 125, 143, 168, 186, 216, 250, 273, 294, 325, 358, 393, 426.6, 613, 651, 690, 732, 772, 816, 866, 909, 954, 997, 1165, 1208, 1256, 1301, 1393, 1443, 1559, 1610.4, 2750, 2852, 2961, 3078, 3189, 3300, 3458, 3573, 3698, 3814, 4139, 4242, 4355, 4460, 4760, 4877, 5103, 5217, 11673, 11957, 12272, 12563, 13658, 14003, 14434, 14721.02, 59739.3, 61049.65], "Electron affinity": 0.131318 }, Tc: { "Atomic mass": 98, "Atomic no": 43, "Atomic orbitals": { "1s": -745.742024, "2p": -96.61021, "2s": -104.567508, "3d": -9.33986, "3p": -15.041738, "3s": -18.135303, "4d": -0.270262, "4p": -1.64323, "4s": -2.550712, "5s": -0.183636 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.83, "Boiling point": "4538 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 7], "Critical temperature": "no data K", "Density of solid": "11500 kg m<sup>-3</sup>", "Electrical resistivity": "about 22 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>5</sup>.5s<sup>2</sup>", "Ionic radii": { 4: 0.785, 5: 0.74, 7: 0.7 }, "Liquid range": "2108 K", "Melting point": "2430 K", "Mendeleev no": 59, "Mineral hardness": "no data", "Molar volume": "8.63 cm<sup>3</sup>", Name: "Technetium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.785, ionic_radius: 0.645 } } }, 5: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 7: { IV: { "": { crystal_radius: 0.51, ionic_radius: 0.37 } }, VI: { "": { crystal_radius: 0.7, ionic_radius: 0.56 } } } }, "Superconduction temperature": "7.8 K", "Thermal conductivity": "51 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "no data GPa", "Metallic radius": 1.363, iupac_ordering: 60, "IUPAC ordering": 60, "Ground level": "6S5/2", "Ionization energies": [7.11938, 15.26, 29.55, 41, 57, 72, 88, 150, 169, 189.9, 214, 239, 262.08, 311, 338.55, 604, 655, 713, 773, 829, 904, 968, 1032, 1102, 1166, 1354, 1411.6, 1479.5, 1559, 1638, 1689, 1838, 1900.28, 4505, 4681, 4874, 5060, 5361, 5570, 5838, 6008.391, 25004.533, 25786.99], "Electron affinity": 0.552 }, Te: { "Atomic mass": 127.6, "Atomic no": 52, "Atomic orbitals": { "1s": -1115.831819, "2p": -156.808583, "2s": -167.021776, "3d": -20.887801, "3p": -28.860685, "3s": -33.137485, "4d": -1.608381, "4p": -4.100084, "4s": -5.572846, "5p": -0.226594, "5s": -0.520997 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.23, "Boiling point": "1261 K", "Brinell hardness": "180 MN m<sup>-2</sup>", "Bulk modulus": "65 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "no data K", "Density of solid": "6240 kg m<sup>-3</sup>", "Electrical resistivity": "about 10000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>4</sup>", "ICSD oxidation states": [-2, 4, -1, 6], "Ionic radii": { "-2": 2.07, 4: 1.11, 6: 0.7 }, "Liquid range": "538.34 K", "Melting point": "722.66 K", "Mendeleev no": 92, "Mineral hardness": "2.25", "Molar volume": "20.46 cm<sup>3</sup>", Name: "Tellurium", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "50 %", "Refractive index": "1.000991", "Rigidity modulus": "16 GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 2.07, ionic_radius: 2.21 } } }, 4: { III: { "": { crystal_radius: 0.66, ionic_radius: 0.52 } }, IV: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } } }, 6: { IV: { "": { crystal_radius: 0.57, ionic_radius: 0.43 } }, VI: { "": { crystal_radius: 0.7, ionic_radius: 0.56 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "3 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "2610 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.1, "Youngs modulus": "43 GPa", "Metallic radius": "no data", iupac_ordering: 94, "IUPAC ordering": 94, "Ground level": "3P2", "Ionization energies": [9.009808, 18.6, 27.84, 37.4155, 59.3, 69.1, 124.2, 143, 167, 191.1, 215, 245, 272, 299, 328, 354, 461, 491, 522, 555, 599, 633, 709, 746.12, 1304, 1377, 1455, 1538, 1618, 1707, 1803, 1889, 1979, 2066, 2309, 2386, 2472, 2552, 2700, 2788, 2954, 3041, 7022, 7243, 7485, 7714, 8240, 8499, 8821, 9040.83, 37196.522, 38177.56], "Electron affinity": 1.9708757 }, Th: { "Atomic mass": 232.03806, "Atomic no": 90, "Atomic orbitals": { "1s": -3524.439052, "2p": -588.218112, "2s": -608.350958, "3d": -123.846396, "3p": -142.25581, "3s": -152.079741, "4d": -24.955184, "4f": -13.397389, "4p": -33.325252, "4s": -37.814094, "5d": -3.625729, "5p": -6.58281, "5s": -8.287057, "6d": -0.172896, "6p": -0.846921, "6s": -1.333769, "7s": -0.135872 }, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "5093 K", "Brinell hardness": "400 MN m<sup>-2</sup>", "Bulk modulus": "54 GPa", "Coefficient of linear thermal expansion": "11.0 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "11724 kg m<sup>-3</sup>", "Electrical resistivity": "15 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].6d<sup>2</sup>.7s<sup>2</sup>", "ICSD oxidation states": [4], "Ionic radii": { 4: 1.08 }, "Liquid range": "2978 K", "Melting point": "2115 K", "Mendeleev no": 47, "Mineral hardness": "3.0", "Molar volume": "19.80 cm<sup>3</sup>", Name: "Thorium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.27", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } }, VIII: { "": { crystal_radius: 1.19, ionic_radius: 1.05 } }, IX: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } }, X: { "": { crystal_radius: 1.27, ionic_radius: 1.13 } }, XI: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, XII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } } } }, "Superconduction temperature": "1.38 K", "Thermal conductivity": "54 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "2490 m s<sup>-1</sup>", "Vickers hardness": "350 MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "79 GPa", "Metallic radius": 1.798, iupac_ordering: 31, "IUPAC ordering": 31, "Ground level": "3F2", "Ionization energies": [6.3067, 12.1, 18.32, 28.648, 58, 69.1, 82, 95, 118, 133, 165, 181, 262, 285, 310, 336, 362, 389, 424, 451, 480, 508, 650, 680, 720, 750, 830, 870, 970, 1010, 1090, 1160, 1240, 1310, 1380, 1460, 1530, 1600, 1680, 1760, 1830, 1910, 1980, 2060, 2390, 2455, 2524, 2598, 2669, 2737, 2864, 2935, 3013, 3086, 3375, 3445, 3522, 3593, 3943, 4025, 4230, 4313, 6972, 7130, 7299, 7480, 7650, 7810, 8180, 8350, 8550, 8720, 9220, 9370, 9540, 9690, 10790, 10970, 11340, 11510, 24060, 24480, 24940, 25360, 29410, 29970, 30680, 31122.8, 123086.4, 125253.4], "Electron affinity": 1.17 }, Ti: { "Atomic mass": 47.867, "Atomic no": 22, "Atomic orbitals": { "1s": -177.276643, "2p": -16.285339, "2s": -19.457901, "3d": -0.17001, "3p": -1.422947, "3s": -2.258007, "4s": -0.167106 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.76, "Boiling point": "3560 K", "Brinell hardness": "716 MN m<sup>-2</sup>", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "8.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "4507 kg m<sup>-3</sup>", "Electrical resistivity": "about 40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>2</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 2: 1, 3: 0.81, 4: 0.745 }, "Liquid range": "1619 K", "Melting point": "1941 K", "Mendeleev no": 51, "Mineral hardness": "6.0", "Molar volume": "10.64 cm<sup>3</sup>", Name: "Titanium", "Oxidation states": [-1, 2, 3, 4], "Poissons ratio": "0.32", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } } }, 3: { VI: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } } }, 4: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, V: { "": { crystal_radius: 0.65, ionic_radius: 0.51 } }, VI: { "": { crystal_radius: 0.745, ionic_radius: 0.605 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "0.40 K", "Thermal conductivity": "22 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "4140 m s<sup>-1</sup>", "Vickers hardness": "970 MN m<sup>-2</sup>", X: 1.54, "Youngs modulus": "116 GPa", "NMR Quadrupole Moment": { "Ti-47": 302.1, "Ti-49": 247.11 }, "Metallic radius": 1.462, iupac_ordering: 52, "IUPAC ordering": 52, "Ground level": "3F2", "Ionization energies": [6.82812, 13.5755, 27.49171, 43.26717, 99.299, 119.533, 140.68, 170.5, 192.1, 215.92, 265.07, 291.5, 787.67, 864, 944.5, 1042.5, 1130.2, 1220.3, 1346.3, 1425.257, 6249.0226, 6625.8073], "Electron affinity": 0.075545 }, Tl: { "Atomic mass": 204.3833, "Atomic no": 81, "Atomic orbitals": { "1s": -2827.569408, "2p": -457.255971, "2s": -474.953368, "3d": -88.328299, "3p": -104.099296, "3s": -112.52218, "4d": -14.008848, "4f": -4.835747, "4p": -20.797078, "4s": -24.471512, "5d": -0.674544, "5p": -2.59873, "5s": -3.811512, "6p": -0.101507, "6s": -0.28502 }, "Atomic radius": 1.9, "Atomic radius calculated": 1.56, "Boiling point": "1746 K", "Brinell hardness": "26.4 MN m<sup>-2</sup>", "Bulk modulus": "43 GPa", "Coefficient of linear thermal expansion": "29.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1, 3], "Critical temperature": "no data K", "Density of solid": "11850 kg m<sup>-3</sup>", "Electrical resistivity": "15 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>1</sup>", "ICSD oxidation states": [1, 3], "Ionic radii": { 1: 1.64, 3: 1.025 }, "Liquid range": "1169 K", "Melting point": "577 K", "Mendeleev no": 78, "Mineral hardness": "1.2", "Molar volume": "17.22 cm<sup>3</sup>", Name: "Thallium", "Oxidation states": [1, 3], "Poissons ratio": "0.45", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "2.8 GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.64, ionic_radius: 1.5 } }, VIII: { "": { crystal_radius: 1.73, ionic_radius: 1.59 } }, XII: { "": { crystal_radius: 1.84, ionic_radius: 1.7 } } }, 3: { IV: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VI: { "": { crystal_radius: 1.025, ionic_radius: 0.885 } }, VIII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } } } }, "Superconduction temperature": "2.38 K", "Thermal conductivity": "46 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.96, "Velocity of sound": "818 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.62, "Youngs modulus": "8 GPa", "Metallic radius": 1.7, iupac_ordering: 77, "IUPAC ordering": 77, "Ground level": "2P°1/2", "Ionization energies": [6.1082873, 20.4283, 29.852, 51.14, 62.6, 80, 97.9, 116, 135, 158, 177, 198, 218.3, 306.9, 340, 366, 392, 439, 467, 520, 570, 600, 640, 700, 760, 820, 880, 930, 990, 1060, 1110, 1170, 1230, 1290, 1350, 1625, 1681, 1740, 1802, 1862, 1920, 2014, 2075, 2140, 2202, 2447, 2508, 2574, 2635, 2854, 2925, 3094, 3164.7, 5234, 5371, 5518, 5674, 5824, 5969, 6241, 6392, 6560, 6714, 7146, 7281, 7430, 7570, 8260, 8420, 8730, 8880, 19070, 19440, 19840, 20210, 22780, 23250, 23850, 24234.1, 96783.21, 98591.6], "Electron affinity": 0.32005319 }, Tm: { "Atomic mass": 168.93421, "Atomic no": 69, "Atomic orbitals": { "1s": -2022.471608, "2p": -312.510608, "2s": -327.05712, "3d": -53.835494, "3p": -66.239338, "3s": -72.873753, "4d": -6.350307, "4f": -0.28312, "4p": -11.187151, "4s": -13.865665, "5p": -0.950748, "5s": -1.64999, "6s": -0.135953 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "2223 K", "Brinell hardness": "471 MN m<sup>-2</sup>", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "13.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9321 kg m<sup>-3</sup>", "Electrical resistivity": "67.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>13</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 2: 1.17, 3: 1.02 }, "Liquid range": "405 K", "Melting point": "1818 K", "Mendeleev no": 21, "Mineral hardness": "no data", "Molar volume": "19.1 cm<sup>3</sup>", Name: "Thulium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VII: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } } }, 3: { VI: { "": { crystal_radius: 1.02, ionic_radius: 0.88 } }, VIII: { "": { crystal_radius: 1.134, ionic_radius: 0.994 } }, IX: { "": { crystal_radius: 1.192, ionic_radius: 1.052 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.27, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "520 MN m<sup>-2</sup>", X: 1.25, "Youngs modulus": "74 GPa", "Metallic radius": 1.747, iupac_ordering: 35, "IUPAC ordering": 35, "Ground level": "2F°7/2", "Ionization energies": [6.18431, 12.065, 23.66, 42.41, 65.4, 98, 116, 133, 160, 180, 205, 239, 274, 295, 317, 352, 387, 424, 460, 496, 530, 570, 603, 825, 866, 911, 958, 1004, 1050, 1110, 1157, 1207, 1255, 1442, 1490, 1542, 1591, 1706, 1761, 1889, 1945.2, 3298, 3409, 3528, 3653, 3775, 3895, 4075, 4199, 4335, 4461, 4812, 4922, 5044, 5157, 5527, 5656, 5901, 6023, 13347, 13651, 13988, 14300, 15663, 16036, 16510, 16814.34, 67965.26, 69387.3], "Electron affinity": 1.02922 }, U: { "Atomic mass": 238.02891, "Atomic no": 92, "Atomic orbitals": { "1s": -3689.355141, "2p": -619.10855, "2s": -639.778728, "3d": -131.977358, "3p": -150.97898, "3s": -161.118073, "4d": -27.123212, "4f": -15.02746, "4p": -35.853321, "4s": -40.528084, "5d": -3.866175, "5f": -0.366543, "5p": -7.018092, "5s": -8.824089, "6d": -0.14319, "6p": -0.822538, "6s": -1.325976, "7s": -0.130948 }, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4200 K", "Brinell hardness": "2400 MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "13.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [6], "Critical temperature": "no data K", "Density of solid": "19050 kg m<sup>-3</sup>", "Electrical resistivity": "28 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>3</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5, 6], "Ionic radii": { 3: 1.165, 4: 1.03, 5: 0.9, 6: 0.87 }, "Liquid range": "2794.7 K", "Melting point": "1405.3 K", "Mendeleev no": 45, "Mineral hardness": "6.0", "Molar volume": "12.49 cm<sup>3</sup>", Name: "Uranium", "Oxidation states": [3, 4, 5, 6], "Poissons ratio": "0.23", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "111 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.165, ionic_radius: 1.025 } } }, 4: { VI: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } }, VII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } }, VIII: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, IX: { "": { crystal_radius: 1.19, ionic_radius: 1.05 } }, XII: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } } }, 5: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VII: { "": { crystal_radius: 0.98, ionic_radius: 0.84 } } }, 6: { II: { "": { crystal_radius: 0.59, ionic_radius: 0.45 } }, IV: { "": { crystal_radius: 0.66, ionic_radius: 0.52 } }, VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } }, VII: { "": { crystal_radius: 0.95, ionic_radius: 0.81 } }, VIII: { "": { crystal_radius: 1, ionic_radius: 0.86 } } } }, "Superconduction temperature": "0.2 K", "Thermal conductivity": "27 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.41, "Velocity of sound": "3155 m s<sup>-1</sup>", "Vickers hardness": "1960 MN m<sup>-2</sup>", X: 1.38, "Youngs modulus": "208 GPa", "Metallic radius": 1.542, iupac_ordering: 29, "IUPAC ordering": 29, "Ground level": "5L°6", "Ionization energies": [6.19405, 11.6, 19.8, 36.7, 46, 62, 89, 101, 116, 128.9, 158, 173, 210, 227, 323, 348, 375, 402, 431, 458, 497, 525, 557, 585, 730, 770, 800, 840, 930, 970, 1070, 1110, 1210, 1290, 1370, 1440, 1520, 1590, 1670, 1750, 1830, 1910, 1990, 2070, 2140, 2220, 2578, 2646, 2718, 2794, 2867, 2938, 3073, 3147, 3228, 3301, 3602, 3675, 3753, 3827, 4214, 4299, 4513, 4598, 7393, 7550, 7730, 7910, 8090, 8260, 8650, 8830, 9030, 9210, 9720, 9870, 10040, 10200, 11410, 11600, 11990, 12160, 25260, 25680, 26150, 26590, 31060, 31640, 32400, 32836.5, 129570.3, 131821], "Electron affinity": 0.53 }, V: { "Atomic mass": 50.9415, "Atomic no": 23, "Atomic orbitals": { "1s": -195.224014, "2p": -18.435189, "2s": -21.815346, "3d": -0.204634, "3p": -1.610516, "3s": -2.526904, "4s": -0.175968 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.71, "Boiling point": "3680 K", "Brinell hardness": "628 MN m<sup>-2</sup>", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "8.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "6110 kg m<sup>-3</sup>", "Electrical resistivity": "20 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>3</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": { 2: 0.93, 3: 0.78, 4: 0.72, 5: 0.68 }, "Liquid range": "1497 K", "Melting point": "2183 K", "Mendeleev no": 54, "Mineral hardness": "7.0", "Molar volume": "8.32 cm<sup>3</sup>", Name: "Vanadium", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.37", Reflectivity: "61 %", "Refractive index": "no data", "Rigidity modulus": "47 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } } }, 3: { VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } } }, 4: { V: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } }, VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VIII: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 5: { IV: { "": { crystal_radius: 0.495, ionic_radius: 0.355 } }, V: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, VI: { "": { crystal_radius: 0.68, ionic_radius: 0.54 } } } }, "Superconduction temperature": "5.40 K", "Thermal conductivity": "31 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.07, "Velocity of sound": "4560 m s<sup>-1</sup>", "Vickers hardness": "628 MN m<sup>-2</sup>", X: 1.63, "Youngs modulus": "128 GPa", "NMR Quadrupole Moment": { "V-50": 210.4, "V-51": -52.1 }, "Metallic radius": 1.347, iupac_ordering: 55, "IUPAC ordering": 55, "Ground level": "4F3/2", "Ionization energies": [6.746187, 14.634, 29.3111, 46.709, 65.28165, 128.125, 150.72, 173.55, 206, 230.5, 254.8, 308.5, 336.274, 896, 977.2, 1062.9, 1165.2, 1258.9, 1354.2, 1486.7, 1569.656, 6851.3109, 7246.1226], "Electron affinity": 0.527662 }, W: { "Atomic mass": 183.84, "Atomic no": 74, "Atomic orbitals": { "1s": -2341.042887, "2p": -369.013973, "2s": -384.856157, "3d": -66.724787, "3p": -80.502102, "3s": -87.867792, "4d": -8.879693, "4f": -1.550835, "4p": -14.495102, "4s": -17.570797, "5d": -0.220603, "5p": -1.504457, "5s": -2.396018, "6s": -0.181413 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.93, "Boiling point": "5828 K", "Brinell hardness": "2570 MN m<sup>-2</sup>", "Bulk modulus": "310 GPa", "Coefficient of linear thermal expansion": "4.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "19250 kg m<sup>-3</sup>", "Electrical resistivity": "5.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>4</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 4: 0.8, 5: 0.76, 6: 0.74 }, "Liquid range": "2133 K", "Melting point": "3695 K", "Mendeleev no": 55, "Mineral hardness": "7.5", "Molar volume": "9.47 cm<sup>3</sup>", Name: "Tungsten", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.28", Reflectivity: "62 %", "Refractive index": "no data", "Rigidity modulus": "161 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } } }, 5: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } }, 6: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, V: { "": { crystal_radius: 0.65, ionic_radius: 0.51 } }, VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } } }, "Superconduction temperature": "0.015 K", "Thermal conductivity": "170 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "5174 m s<sup>-1</sup>", "Vickers hardness": "3430 MN m<sup>-2</sup>", X: 2.36, "Youngs modulus": "411 GPa", "Metallic radius": 1.41, iupac_ordering: 56, "IUPAC ordering": 56, "Ground level": "5D0", "Ionization energies": [7.86403, 16.37, 26, 38.2, 51.6, 64.77, 122.01, 141.2, 160.2, 179, 208.9, 231.6, 258.3, 290.7, 325.3, 361.9, 387.9, 420.7, 462.1, 502.6, 543.4, 594.5, 640.6, 685.6, 734.1, 784.4, 833.4, 881.4, 1132.2, 1180, 1230.4, 1283.4, 1335.1, 1386.8, 1459.9, 1512.4, 1569.1, 1621.7, 1829.8, 1882.9, 1940.6, 1994.8, 2149.1, 2210, 2354.5, 2414.1, 4057, 4180, 4309, 4446, 4578, 4709, 4927, 5063, 5209, 5348, 5719, 5840, 5970, 6093, 6596, 6735, 7e3, 7130, 15566, 15896, 16252, 16588, 18476, 18872, 19362, 19686.74, 79181.94, 80755.6], "Electron affinity": 0.816268 }, Xe: { "Atomic mass": 131.293, "Atomic no": 54, "Atomic orbitals": { "1s": -1208.688993, "2p": -172.599583, "2s": -183.327495, "3d": -24.37823, "3p": -32.867042, "3s": -37.415454, "4d": -2.286666, "4p": -5.063802, "4s": -6.67834, "5p": -0.309835, "5s": -0.672086 }, "Atomic radius": "no data", "Atomic radius calculated": 1.08, "Boiling point": "165.1 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "289.7 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>6</sup>", "Ionic radii": { 8: 0.62 }, "Liquid range": "3.7 K", "Max oxidation state": 8, "Melting point": "161.4 K", "Mendeleev no": 5, "Min oxidation state": 2, "Mineral hardness": "no data", "Molar volume": "35.92 cm<sup>3</sup>", Name: "Xenon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000702", "Rigidity modulus": "no data GPa", "Shannon radii": { 8: { IV: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } }, VI: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.00565 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "1090 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.6, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 1, "IUPAC ordering": 1, "Ground level": "1S0", "Ionization energies": [12.1298437, 20.975, 31.05, 42.2, 54.1, 66.703, 91.6, 105.9778, 179.84, 202, 229.02, 255, 281, 314, 343, 374, 404, 434, 549, 582, 616, 650, 700, 736, 818, 857, 1493, 1571, 1653, 1742, 1826, 1919, 2023, 2113, 2209, 2300, 2556, 2637, 2726, 2811, 2975, 3068, 3243, 3333.8, 7660, 7889, 8144, 8382, 8971, 9243, 9581, 9810.37, 40271.724, 41299.71], "Electron affinity": -0.82 }, Y: { "Atomic mass": 88.90585, "Atomic no": 39, "Atomic orbitals": { "1s": -605.631981, "2p": -74.803201, "2s": -81.789102, "3d": -5.671499, "3p": -10.399926, "3s": -12.992217, "4d": -0.108691, "4p": -1.02449, "4s": -1.697124, "5s": -0.150727 }, "Atomic radius": 1.8, "Atomic radius calculated": 2.12, "Boiling point": "3609 K", "Brinell hardness": "589 MN m<sup>-2</sup>", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "10.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "4472 kg m<sup>-3</sup>", "Electrical resistivity": "about 60 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>1</sup>.5s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.04 }, "Liquid range": "1810 K", "Melting point": "1799 K", "Mendeleev no": 25, "Mineral hardness": "no data", "Molar volume": "19.88 cm<sup>3</sup>", Name: "Yttrium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VIII: { "": { crystal_radius: 1.159, ionic_radius: 1.019 } }, IX: { "": { crystal_radius: 1.215, ionic_radius: 1.075 } } } }, "Superconduction temperature": "1.3  (under pressure)K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.32, "Velocity of sound": "3300 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.22, "Youngs modulus": "64 GPa", "Metallic radius": 1.8, iupac_ordering: 48, "IUPAC ordering": 48, "Ground level": "2D3/2", "Ionization energies": [6.21726, 12.2236, 20.52441, 60.6072, 75.35, 91.39, 110.02, 128.12, 145.64, 185.7, 205.814, 374.04, 414, 463, 512, 559, 624, 677, 733, 790, 847, 1010, 1061.9, 1120.2, 1190, 1253, 1300, 1427.6, 1483.12, 3562.9, 3720, 3892, 4060, 4299, 4484, 4724, 4875.731, 20415.717, 21115.55], "Electron affinity": 0.30712 }, Yb: { "Atomic mass": 173.04, "Atomic no": 70, "Atomic orbitals": { "1s": -2084.069389, "2p": -323.178219, "2s": -337.978976, "3d": -56.026315, "3p": -68.698655, "3s": -75.47663, "4d": -6.574963, "4f": -0.286408, "4p": -11.558246, "4s": -14.312076, "5p": -0.966137, "5s": -1.683886, "6s": -0.136989 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "1469 K", "Brinell hardness": "343 MN m<sup>-2</sup>", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "26.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6570 kg m<sup>-3</sup>", "Electrical resistivity": "25.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.16, 3: 1.008 }, "Liquid range": "372 K", "Melting point": "1097 K", "Mendeleev no": 17, "Mineral hardness": "no data", "Molar volume": "24.84 cm<sup>3</sup>", Name: "Ytterbium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "9.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VII: { "": { crystal_radius: 1.22, ionic_radius: 1.08 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } }, 3: { VI: { "": { crystal_radius: 1.008, ionic_radius: 0.868 } }, VII: { "": { crystal_radius: 1.065, ionic_radius: 0.925 } }, VIII: { "": { crystal_radius: 1.125, ionic_radius: 0.985 } }, IX: { "": { crystal_radius: 1.182, ionic_radius: 1.042 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "39 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.26, "Velocity of sound": "1590 m s<sup>-1</sup>", "Vickers hardness": "206 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "24 GPa", "Metallic radius": 1.94, iupac_ordering: 34, "IUPAC ordering": 34, "Ground level": "1S0", "Ionization energies": [6.25416, 12.179185, 25.053, 43.61, 65.6, 99, 117, 135, 163, 182, 209, 244, 279, 301, 324, 360, 396, 431, 469, 505, 540, 580, 610, 651, 882, 924, 971, 1019, 1065, 1114, 1175, 1224, 1275, 1324, 1516, 1564, 1618, 1668, 1789, 1845, 1978, 2036.4, 3443, 3555, 3677, 3805, 3929, 4051, 4238, 4364, 4502, 4630, 4988, 5101, 5224, 5339, 5731, 5860, 6111, 6236, 13784, 14093, 14435, 14752, 16191, 16570, 17050, 17365.44, 70123.04, 71574.8], "Electron affinity": -0.02 }, Zn: { "Atomic mass": 65.409, "Atomic no": 30, "Atomic orbitals": { "1s": -344.969756, "2p": -36.648765, "2s": -41.531323, "3d": -0.398944, "3p": -3.022363, "3s": -4.573041, "4s": -0.222725 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.42, "Boiling point": "1180 K", "Brinell hardness": "412 MN m<sup>-2</sup>", "Bulk modulus": "70 GPa", "Coefficient of linear thermal expansion": "30.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "7140 kg m<sup>-3</sup>", "Electrical resistivity": "6.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.88 }, "Liquid range": "487.32 K", "Melting point": "692.68 K", "Mendeleev no": 76, "Mineral hardness": "2.5", "Molar volume": "9.16 cm<sup>3</sup>", Name: "Zinc", "Oxidation states": [1, 2], "Poissons ratio": "0.25", Reflectivity: "80 %", "Refractive index": "1.002050", "Rigidity modulus": "43 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, V: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VI: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } }, VIII: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } } } }, "Superconduction temperature": "0.85 K", "Thermal conductivity": "120 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.01, "Velocity of sound": "3700 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.65, "Youngs modulus": "108 GPa", "NMR Quadrupole Moment": { "Zn-67": 150.15 }, "Metallic radius": 1.34, iupac_ordering: 76, "IUPAC ordering": 76, "Ground level": "1S0", "Ionization energies": [9.394197, 17.96439, 39.7233, 59.573, 82.6, 108, 133.9, 173.9, 203, 238, 274.4, 310.8, 417.6, 453.4, 490.6, 540, 577.8, 613.3, 697.5, 737.366, 1846.8, 1961, 2085, 2214, 2358, 2491.5, 2669.9, 2781.996, 11864.9399, 12388.929], "Electron affinity": -0.62 }, Zr: { "Atomic mass": 91.224, "Atomic no": 40, "Atomic orbitals": { "1s": -639.292236, "2p": -80.010043, "2s": -87.237062, "3d": -6.544643, "3p": -11.514415, "3s": -14.230432, "4d": -0.150673, "4p": -1.186597, "4s": -1.918971, "5s": -0.162391 }, "Atomic radius": 1.55, "Atomic radius calculated": 2.06, "Boiling point": "4682 K", "Brinell hardness": "650 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "6511 kg m<sup>-3</sup>", "Electrical resistivity": "43.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>2</sup>.5s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 4: 0.86 }, "Liquid range": "2554 K", "Melting point": "2128 K", "Mendeleev no": 49, "Mineral hardness": "5.0", "Molar volume": "14.02 cm<sup>3</sup>", Name: "Zirconium", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "33 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, V: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } }, VII: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "": { crystal_radius: 0.98, ionic_radius: 0.84 } }, IX: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } } } }, "Superconduction temperature": "0.61 K", "Thermal conductivity": "23 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "3800 m s<sup>-1</sup>", "Vickers hardness": "903 MN m<sup>-2</sup>", X: 1.33, "Youngs modulus": "68 GPa", "Metallic radius": 1.602, iupac_ordering: 51, "IUPAC ordering": 51, "Ground level": "3F2", "Ionization energies": [6.634126, 13.13, 23.17, 34.41836, 80.348, 96.38, 112, 133.7, 153, 172.02, 214.9, 236.252, 426, 470, 520, 573, 622, 690, 745, 803, 863, 922, 1092, 1144.7, 1205.4, 1277, 1344, 1392, 1525.1, 1582.37, 3788, 3950, 4127, 4300, 4553, 4744, 4991, 5146.935, 21516.469, 22236.678], "Electron affinity": 0.433289 }, Rf: { "Atomic mass": 267, "Atomic no": 104, Name: "Rutherfordium", "Ground level": "3F2", "Ionization energies": [6.02, 14.35, 23.84, 31.87, 64, 77, 102, 119, 146.1, 169, 193, 225, 244, 275, null, 791, 825, 860, 899, 936, 972, 1036, 1073, 1114, 1151, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3857, 3938, 4025, 4116, 4203, 4287, 4489, 4580, 4670, 4760, 5130, 5210, 5300, 5390, 6100, 6200, 6470, 6570, 10170, 10360, 10560, 10780, 10980, 11180, 11750, 11960, 12200, 12410, 13010, 13190, 13400, 13600, 15800, 16e3, 16400, 16700, 33100, 33600, 34100, 34600, 42700, 43400, 44300, null, null, 177148], "Electron affinity": null, "Van der waals radius": "no data" }, Db: { "Atomic mass": 268, "Atomic no": 105, Name: "Dubnium", "Ground level": "4F3/2", "Ionization energies": [6.8, 14, 23.1, 33, 43, 86, 98.9, 126, 145.1, 172, 196, 220.9, 254, 274, 307, null, 838, 872, 908, 948, 985, 1022, 1089, 1126, 1168, 1207, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3975, 4057, 4145, 4237, 4326, 4411, 4620, 4710, 4810, 4900, 5260, 5350, 5450, 5530, 6280, 6380, 6650, 6760, 10420, 10610, 10820, 11040, 11240, 11440, 12040, 12250, 12480, 12700, 13300, 13500, 13700, 13900, 16200, 16400, 16900, 17100, 33800, 34300, 34800, 35300, 43800, 44500, 45400, null, null, 181444], "Electron affinity": null, "Van der waals radius": "no data" }, Sg: { "Atomic mass": 269, "Atomic no": 106, Name: "Seaborgium", "Ground level": "0", "Ionization energies": [7.8, 17.1, 25.8, 35.5, 47.2, 59.3, 109, 122, 152, 170, 200, 224, 251, 285, 306, 339, null, 885, 921, 958, 998, 1036, 1073, 1143, 1181, 1223, 1263, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4095, 4178, 4267, 4360, 4450, 4540, 4750, 4840, 4940, 5030, 5410, 5490, 5590, 5680, 6460, 6570, 6840, 6950, 10680, 10870, 11080, 11300, 11510, 11710, 12320, 12540, 12780, 12990, 13600, 13800, 14e3, 14200, 16600, 16800, 17300, 17500, 34500, 35e3, 35600, 36100, 44900, 45700, 46600, null, null, 185839], "Electron affinity": null, "Van der waals radius": "no data" }, Bh: { "Atomic mass": 270, "Atomic no": 107, Name: "Bohrium", "Ground level": "5/2", "Ionization energies": [7.7, 17.5, 26.7, 37.3, 49, 62.1, 74.9, 134, 148, 178, 198, 228, 255, 281, 318, 337, 374, null, 934, 969, 1008, 1049, 1088, 1126, 1197, 1237, 1280, 1320, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4216, 4301, 4390, 4486, 4580, 4660, 4890, 4980, 5080, 5170, 5550, 5640, 5740, 5830, 6650, 6760, 7040, 7140, 10930, 11130, 11340, 11560, 11780, 11980, 12610, 12830, 13070, 13300, 13900, 14100, 14300, 14500, 17e3, 17300, 17700, 18e3, 35200, 35700, 36300, 36800, 46100, 46900, 47800, null, null, 190331], "Electron affinity": null, "Van der waals radius": "no data" }, Hs: { "Atomic mass": 270, "Atomic no": 108, Name: "Hassium", "Ground level": "4", "Ionization energies": [7.6, 18.2, 29.3, 37.7, 51.2, 64, 78.1, 91.7, 159.9, 173.9, 206.1, 227, 258, 285, 314, 351, 371, 409, null, 984, 1020, 1060, 1101, 1140, 1180, 1253, 1294, 1338, 1379, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4339, 4425, 4516, 4610, 4700, 4790, 5020, 5110, 5220, 5310, 5700, 5780, 5880, 5980, 6840, 6950, 7230, 7340, 11200, 11390, 11610, 11830, 12040, 12250, 12910, 13130, 13400, 13600, 14200, 14400, 14600, 14800, 17500, 17700, 18200, 18400, 35900, 36400, 37e3, 37500, 47300, 48100, 49e3, null, null, 194917], "Electron affinity": null, "Van der waals radius": "no data" }, Mt: { "Atomic mass": 278, "Atomic no": 109, Name: "Meitnerium", "Ground level": null, "Ionization energies": [50, null, null, 94, 109, 187, 202, 235.9, 257, 289, 318, 346, 386, 406, 445, null, 1035, 1072, 1112, 1154, 1195, 1234, 1311, 1352, 1397, 1439, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4464, 4551, 4640, 4740, 4830, 4920, 5160, 5250, 5360, 5450, 5840, 5930, 6030, 6130, 7030, 7150, 7430, 7550, 11460, 11660, 11870, 12100, 12320, 12530, 13200, 13400, 13700, 13900, 14500, 14700, 14900, 15100, 17900, 18200, 18700, 18900, 36700, 37200, 37800, 38300, 48500, 49400, 50300, null, null, 199606], "Electron affinity": null, "Van der waals radius": "no data" }, Ds: { "Atomic mass": 281, "Atomic no": 110, Name: "Darmstadtium", "Ground level": null, "Ionization energies": [65, null, null, 112.9, 128, 216, 231, 266, 288, 322, 352, 380, 422, 442, 483, null, 1087, 1125, 1165, 1208, 1250, 1290, 1369, 1412, 1457, 1500, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4590, 4680, 4770, 4870, 4960, 5060, 5300, 5400, 5500, 5600, 5990, 6080, 6190, 6280, 7230, 7350, 7640, 7750, 11730, 11930, 12140, 12380, 12600, 12810, 13500, 13700, 14e3, 14200, 14800, 15e3, 15300, 15500, 18400, 18600, 19100, 19400, 37400, 37900, 38500, 39100, 49800, 50700, 51600, null, null, 204400], "Electron affinity": null, "Van der waals radius": "no data" }, Rg: { "Atomic mass": 282, "Atomic no": 111, Name: "Roentgenium", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.565, "Van der waals radius": "no data" }, Cn: { "Atomic mass": 285, "Atomic no": 112, Name: "Copernicium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data" }, Nh: { "Atomic mass": 286, "Atomic no": 113, Name: "Nihonium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.69, "Van der waals radius": "no data" }, Fl: { "Atomic mass": 289, "Atomic no": 114, Name: "Flerovium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data" }, Mc: { "Atomic mass": 290, "Atomic no": 115, Name: "Moscovium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.366, "Van der waals radius": "no data" }, Lv: { "Atomic mass": 293, "Atomic no": 116, Name: "Livermorium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.776, "Van der waals radius": "no data" }, Ts: { "Atomic mass": 294, "Atomic no": 117, Name: "Tennessine", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.719, "Van der waals radius": "no data" }, Og: { "Atomic mass": 2949, "Atomic no": 118, Name: "Oganesson", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.0561, "Van der waals radius": "no data" } }).forEach(function(e) {
  var t = e[0], r = e[1];
  VL[r["Atomic no"]] = k(k({}, r), { symbol: t });
}), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "material";
  }, e.create = function(t) {
    return { kind: "material", name: "material", data: t };
  }, e.formatMol = function(t) {
    var r = t.isMaterial, n = t.molecules;
    if (!r || n.length > 1 || !n[0].cell) return t;
    for (var a = n[0], i = a.cell, o = a.x, s = a.y, u = a.z, c = o.rowCount, l = new Float32Array(c), d = new Float32Array(c), f = new Float32Array(c), m = 0; m < c; m++) {
      var h = D.create(o.value(m), s.value(m), u.value(m)), p = D.transformMat4(D.zero(), h, i.invertMatrix);
      l[m] = p[0], d[m] = p[1], f[m] = p[2];
    }
    return { isMaterial: !0, molecules: [k(k({}, n[0]), { fractX: pe.ofFloatArray(l), fractY: pe.ofFloatArray(d), fractZ: pe.ofFloatArray(f) })] };
  };
}(Dy || (Dy = {}));
var d_, vue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, iS(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, Qd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return st.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function gue(e) {
  var t = e.position >= e.data.length - 1 ? 0 : +ft.readLine(e);
  isNaN(t) && (t = 0);
  for (var r = ft.readLine(e), n = new Float64Array(t), a = new Float64Array(t), i = new Float64Array(t), o = new Array(t), s = 0; s < t; ++s) {
    var u = ft.readLineTrim(e).split(/\s+/g);
    o[s] = u[0], n[s] = +u[1], a[s] = +u[2], i[s] = +u[3];
  }
  return { count: t, comment: r, x: pe.ofFloatArray(n), y: pe.ofFloatArray(a), z: pe.ofFloatArray(i), type_symbol: pe.ofStringArray(o) };
}
function yue(e) {
  for (var t = ft(e), r = []; ; ) {
    var n = gue(t);
    if (n.count === 0) break;
    r.push(n);
  }
  var a = { molecules: r, isMaterial: !1 };
  return za.success(a);
}
function qL(e) {
  var t = this;
  return sr.create("Parse Mol", function() {
    return Be(t, 0, void 0, function() {
      return Te(this, function(r) {
        return [2, yue(e)];
      });
    });
  });
}
function HL(e) {
  return sr.create("Parse XYZ", function(t) {
    return function(r, n) {
      for (var a = r.molecules, i = 0, o = 0, s = a; o < s.length; o++) i += (g = s[o]).count;
      for (var u = new Array(i), c = new Int32Array(i), l = new Float32Array(i), d = new Float32Array(i), f = new Float32Array(i), m = new Int32Array(i), h = 0, p = 0; p < a.length; p++) for (var g = a[p], v = 0; v < g.count; v++) u[h] = g.type_symbol.value(v), l[h] = g.x.value(v), d[h] = g.y.value(v), f[h] = g.z.value(v), c[h] = v, m[h] = p, h++;
      var y = pe.ofConst("MOL", i, pe.Schema.str), _ = pe.ofConst("A", i, pe.Schema.str), S = pe.ofConst(1, i, pe.Schema.int), b = pe.ofStringArray(u), x = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: _, auth_atom_id: b, auth_comp_id: y, auth_seq_id: S, Cartn_x: pe.ofFloatArray(l), Cartn_y: pe.ofFloatArray(d), Cartn_z: pe.ofFloatArray(f), id: pe.ofIntArray(c), label_asym_id: _, label_atom_id: b, label_comp_id: y, label_seq_id: S, label_entity_id: pe.ofConst("1", i, pe.Schema.str), occupancy: pe.ofConst(1, i, pe.Schema.float), type_symbol: b, pdbx_PDB_model_num: pe.ofIntArray(m) }, i), A = new mm();
      A.setNames([["MOL", "Unknown Entity"]]), A.getEntityId("MOL", 0, "A");
      var w = new fm(S, b);
      return w.setNames([["MOL", "Unknown Molecule"]]), w.add("MOL", 0), bl(Zd({ entity: A.getEntityTable(), chem_comp: w.getChemCompTable(), atom_site: x }), d_.create(r), n);
    }(e, t);
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "xyz";
  }, e.create = function(t) {
    return { kind: "xyz", name: "xyz", data: t };
  };
})(d_ || (d_ = {}));
var R0, bue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, qL(e).run()] : [2, [vc()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, HL(t.result).run()];
        case 2:
          return r = n.sent(), [2, [st.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
    });
  });
} };
function xue(e, t, r) {
  var n;
  return Be(this, 0, void 0, function() {
    var a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R, G, L, q, K, X, H, W, ee, $, te, re, ie, oe, se, he, ge, De, ae, ce, _e, le;
    return Te(this, function(ue) {
      switch (ue.label) {
        case 0:
          for (a = e.atom_site._rowCount, i = pe.ofConst("MOL", a, pe.Schema.str), o = pe.ofConst("A", a, pe.Schema.str), s = pe.ofConst(1, a, pe.Schema.int), u = function(be) {
            var Se = be.cell, Ne = (Z = be.space_group, de = Z.it_number.value(0), ye = Z["name_h-m_full"].value(0).replace("-", " "), Z.it_number.isDefined ? (Z["name_h-m_full"].isDefined, de) : ye), J = tu.create(Ne, D.create(Se.length_a.value(0), Se.length_b.value(0), Se.length_c.value(0)), D.scale(D(), D.create(Se.angle_alpha.value(0), Se.angle_beta.value(0), Se.angle_gamma.value(0)), Math.PI / 180)), Z, de, ye;
            return { spacegroup: Fo.create(J), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
          }(e), c = u.spacegroup.cell.fromFractional, l = e.atom_site, d = l.fract_x, f = l.fract_y, m = l.fract_z, h = new Float32Array(a), p = new Float32Array(a), g = new Float32Array(a), v = D(), De = 0; De < a; ++De) D.set(v, d.value(De), f.value(De), m.value(De)), D.transformMat4(v, v, c), h[De] = v[0], p[De] = v[1], g[De] = v[2];
          if (y = e.atom_site, _ = y.type_symbol, S = y.label, _.isDefined) {
            for (M = new Array(a), A = new Int8Array(a), De = 0; De < a; ++De) w = _.value(De), C = w.length, w[C - 1] === "+" ? A[De] = parseInt(w[C - 2]) : w[C - 2] === "+" ? A[De] = parseInt(w[C - 1]) : w[C - 1] === "-" ? A[De] = -parseInt(w[C - 2]) : w[C - 2] === "-" ? A[De] = -parseInt(w[C - 1]) : (M[De] = w, A[De] = 0), w = (w = (w = w.replace(/\-/g, "")).replace(/\+/g, "")).replace(/[0-9]/g, ""), M[De] = w;
            b = pe.ofStringArray(M), x = pe.ofIntArray(A);
          } else {
            for (M = new Array(a), De = 0; De < a; ++De) M[De] = J8(S.value(De), "");
            b = pe.ofStringArray(M), x = pe.Undefined(a, pe.Schema.int);
          }
          return T = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: o, auth_atom_id: S, auth_comp_id: i, auth_seq_id: s, Cartn_x: pe.ofFloatArray(h), Cartn_y: pe.ofFloatArray(p), Cartn_z: pe.ofFloatArray(g), id: pe.range(0, a - 1), label_asym_id: o, label_atom_id: S, label_comp_id: i, label_seq_id: s, label_entity_id: pe.ofConst("1", a, pe.Schema.str), occupancy: e.atom_site.occupancy.isDefined ? e.atom_site.occupancy : pe.ofConst(1, a, pe.Schema.float), type_symbol: b, pdbx_formal_charge: x, pdbx_PDB_model_num: pe.ofConst(1, a, pe.Schema.int), B_iso_or_equiv: e.atom_site.u_iso_or_equiv }, a), N = e.chemical.name_common.value(0) || e.chemical.name_systematic.value(0) || e.chemical_formula.sum.value(0), (I = new mm()).setNames([["MOL", N || "Ligand"]]), I.getEntityId("MOL", 0, "A"), (P = new fm(s, e.atom_site.type_symbol)).setNames([["MOL", N || "Unknown Molecule"]]), P.add("MOL", 0), [4, bl(Zd({ entity: I.getEntityTable(), chem_comp: P.getChemCompTable(), atom_site: T }), t, r)];
        case 1:
          if ((O = ue.sent()).frameCount > 0 && (F = O.representative, pi.Provider.set(F, u), (R = e.geom_bond._rowCount) > 0)) {
            for (G = {}, L = e.atom_site.label, De = 0, q = L.rowCount; De < q; ++De) G[L.value(De)] = De;
            for (K = (n = t.data.frame.categories.ccdc_geom_bond_type) === null || n === void 0 ? void 0 : n.getField(""), X = [], H = [], W = [], ee = [], $ = [], te = /* @__PURE__ */ new Set(), re = 0, ie = e.geom_bond, oe = ie.atom_site_label_1, se = ie.atom_site_label_2, he = ie.valence, ge = ie.distance, De = 0; De < R; ++De) ae = G[oe.value(De)], ce = G[se.value(De)], _e = ae < ce ? eu(ae, ce) : eu(ce, ae), te.has(_e) || (te.add(_e), X[re] = ae, H[re] = ce, ee[re] = ge.value(De) || -1, K ? (le = K.str(De)) === "D" ? (W[re] = 2, $[re] = 1) : le === "A" ? (W[re] = 1, $[re] = 17) : (W[re] = 1, $[re] = 1) : ($[re] = 1, W[re] = he.isDefined ? he.value(De) : 1), re += 1);
            Ra.Provider.set(F, Ra.fromData({ pairs: { indexA: pe.ofIntArray(X), indexB: pe.ofIntArray(H), order: pe.ofIntArray(W), distance: pe.ofFloatArray(ee), flag: pe.ofIntArray($) }, count: a }));
          }
          return [2, O];
      }
    });
  });
}
function _ue(e) {
  var t = R0.fromFrame(e);
  return sr.create("Parse CIF Core", function(r) {
    return xue(t.data.db, t, r);
  });
}
Rd.Provider.formatRegistry.add("cifCore", function(e) {
  if (R0.is(e.sourceData)) {
    var t = e.sourceData.data.db, r = t.atom_site, n = t.atom_site_aniso;
    return { data: Yr.ofPartialColumns(Rd.Schema, { U: n.u }, n._rowCount), elementToAnsiotrop: Rd.getElementToAnsiotropFromLabel(r.label, n.label) };
  }
}, function(e) {
  return !!R0.is(e.sourceData) && e.sourceData.data.db.atom_site_aniso.u.isDefined;
}), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "cifCore";
  }, e.fromFrame = function(t, r) {
    return r || (r = aR.cifCore(t)), { kind: "cifCore", name: r.database_code.depnum_ccdc_archive.value(0) || r.database_code.depnum_ccdc_fiz.value(0) || r.database_code.icsd.value(0) || r.database_code.mdf.value(0) || r.database_code.nbs.value(0) || r.database_code.csd.value(0) || r.database_code.cod.value(0) || r._name, data: { db: r, frame: t } };
  };
}(R0 || (R0 = {}));
var Sue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s;
    return Te(this, function(u) {
      switch (u.label) {
        case 0:
          return e.trim() ? [4, nR(e).run()] : [2, [vc()]];
        case 1:
          if ((t = u.sent()).isError) throw t;
          r = function(c) {
            return c.startsWith(`data_SERVER
#
_density_server_result`) ? "dscif" : c.startsWith(`data_SERVER
#
data_SEGMENTATION_DATA`) ? "segcif" : c.includes("atom_site_fract_x") || c.includes("atom_site.fract_x") ? "coreCif" : -1;
          }(e) === -1 ? oR : _ue, n = [], a = 0, i = t.result.blocks.length, u.label = 2;
        case 2:
          return a < i ? (o = t.result.blocks[a], [4, r(o).run()]) : [3, 5];
        case 3:
          s = u.sent(), n.push(st.ofModel(s.frames[0], { dynamicBonds: !0 })), u.label = 4;
        case 4:
          return a++, [3, 2];
        case 5:
          return [2, n];
      }
    });
  });
} }, vM = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i;
    return Te(this, function(o) {
      switch (o.label) {
        case 0:
          return e.trim() ? [4, nR(e).run()] : [2, [vc()]];
        case 1:
          if ((t = o.sent()).isError) throw t;
          r = [], n = 0, a = t.result.blocks.length, o.label = 2;
        case 2:
          return n < a ? [4, oR(t.result.blocks[n]).run()] : [3, 5];
        case 3:
          i = o.sent(), r.push(st.ofModel(i.frames[0], { dynamicBonds: !0 })), o.label = 4;
        case 4:
          return n++, [3, 2];
        case 5:
          return [2, r];
      }
    });
  });
} };
function Aue(e) {
  var t = [], r = function(a) {
    var i = ft.readLine(a), o = +ft.readLine(a), s = new Float64Array(3), u = new Float64Array(3), c = new Float64Array(3);
    [s, u, c].forEach(function(O) {
      var F = ft.readLineTrim(a).trim().split(/\s+/g);
      O[0] = +F[0], O[1] = +F[1], O[2] = +F[2];
    });
    for (var l = GL(s, u, c), d = ft.readLineTrim(a).trim().split(/\s+/g), f = ft.readLineTrim(a).trim().split(/\s+/g), m = ft.readLineTrim(a), h = ["cartesian", "direct"].includes(m.toLowerCase()) ? "cartesian" : m, p = f.reduce(function(O, F) {
      return +O + +F;
    }, 0), g = new Float64Array(p), v = new Float64Array(p), y = new Float64Array(p), _ = new Float64Array(p), S = new Float64Array(p), b = new Float64Array(p), x = new Float64Array(p), A = new Float64Array(p), w = new Float64Array(p), C = new Array(p), M = function(O) {
      for (var F = O === 0 ? 0 : f.slice(0, O).reduce(function(q, K) {
        return +q + +K;
      }, 0), R = 0; R < Number(f[O]); R++) {
        var G = F + R, L = ft.readLineTrim(a).trim().split(/\s+/g);
        C[G] = d[O], x[G] = +L[0], A[G] = +L[1], w[G] = +L[2];
      }
    }, T = 0; T < f.length; T++) M(T);
    if (h === "cartesian") for (T = 0; T < p; T++) {
      g[T] = x[T], v[T] = A[T], y[T] = w[T];
      var N = D.create(g[T], v[T], y[T]), I = D.transformMat4(D.zero(), N, l.invertMatrix);
      _[T] = I[0], S[T] = I[1], b[T] = I[2];
    }
    else for (T = 0; T < p; T++) {
      _[T] = x[T], S[T] = A[T], b[T] = w[T];
      var P = D.create(g[T], v[T], y[T]);
      I = D.transformMat4(D.zero(), P, l.matrix), g[T] = I[0], v[T] = I[1], y[T] = I[2];
    }
    return { count: p, comment: i, scalingFactor: o, dynamics: h, type_symbol: pe.ofStringArray(C), x: pe.ofFloatArray(g), y: pe.ofFloatArray(v), z: pe.ofFloatArray(y), fractX: pe.ofFloatArray(g), fractY: pe.ofFloatArray(v), fractZ: pe.ofFloatArray(y), cell: l };
  }(ft(e));
  t.push(r);
  var n = { isMaterial: !0, molecules: t };
  return za.success(n);
}
function wue(e) {
  var t = this;
  return sr.create("Parse Mol", function() {
    return Be(t, 0, void 0, function() {
      return Te(this, function(r) {
        return [2, Aue(e)];
      });
    });
  });
}
var Cue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, wue(e).run()] : [2, [vc()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, Qd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return st.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function Eue(e) {
  var t = [], r = function(n, a, i) {
    for (var o = function() {
      if (i) return UL(i.a, i.b, i.c, i.alpha, i.beta, i.gamma);
    }(), s = n.length, u = new Float64Array(s), c = new Float64Array(s), l = new Float64Array(s), d = new Array(s), f = 0; f < s; f++) d[f] = n[f], u[f] = a[f][0], c[f] = a[f][1], l[f] = a[f][2];
    return { count: s, comment: "", type_symbol: pe.ofStringArray(d), x: pe.ofFloatArray(u), y: pe.ofFloatArray(c), z: pe.ofFloatArray(l), cell: o };
  }(e.elements, e.xyzs, e.lattice);
  return t.push(r), { isMaterial: !0, molecules: t };
}
function KL(e) {
  return Eue(e);
}
var Due = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, Qd(KL(e)).run()];
        case 1:
          return [2, t.sent().frames.map(function(r) {
            return st.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, L0 = function(e, t, r, n) {
  this.name = e, this.visible = t, this.origin = r, this.contents = n;
};
(function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Ii(t, e);
})(L0), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Ii(t, e);
}(L0), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Ii(t, e);
}(L0), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Ii(t, e);
}(L0);
var Mue = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return Ii(t, e), t.create = function(r) {
    var n = r.name, a = r.visible, i = r.origin, o = r.contents, s = {};
    return o.forEach(function(u) {
      Reflect.defineProperty(s, u.name, { value: u });
    }), new t(n, a, i, s);
  }, t;
}(L0);
function Iue(e) {
  var t = e.scene, r = e.structure, n = Mue.create(t).contents, a = n.atoms, i = n.bonds, o = a.contents.length, s = new Float64Array(o), u = new Float64Array(o), c = new Float64Array(o), l = new Array(o), d = function() {
    if (r.lattice) {
      var v = r.lattice;
      return UL(v.a, v.b, v.c, v.alpha, v.beta, v.gamma);
    }
  }(), f = {};
  i.contents.forEach(function(v) {
    v.positionPairs.forEach(function(y) {
      var _ = y[1].join(",");
      f[_] = f[_] || [], f[_].push(y[0]);
    });
  });
  var m = {};
  a.contents.forEach(function(v, y) {
    var _, S = v.positions, b = v.tooltip, x = S[0];
    for (var A in s[y] = x[0], u[y] = x[1], c[y] = x[2], l[y] = ((_ = b.split(/\s/)[0].match(/[A-Za-z]/g)) === null || _ === void 0 ? void 0 : _.join("")) || "", f) {
      var w = f[A];
      m[A] = m[A] || [], w[0].every(function(C, M) {
        return C === x[M];
      }) && (m[A][0] = y), w[1].every(function(C, M) {
        return C === x[M];
      }) && (m[A][1] = y);
    }
  });
  var h = [], p = [];
  Object.values(m).forEach(function(v) {
    h.push(v[0]), p.push(v[1]);
  });
  var g = { count: 2 * h.length, atomA: nt(nt([], h, !0), p, !0), atomB: nt(nt([], p, !0), h, !0) };
  return { comment: "", count: o, x: pe.ofFloatArray(s), y: pe.ofFloatArray(u), z: pe.ofFloatArray(c), type_symbol: pe.ofStringArray(l), cell: d, bonds: g };
}
function Tue(e) {
  var t = { molecules: e.map(Iue), isMaterial: !0 };
  return za.success(t);
}
function XL(e) {
  var t = this;
  return sr.create("Parse Mol", function() {
    return Be(t, 0, void 0, function() {
      return Te(this, function(r) {
        return [2, Tue(e)];
      });
    });
  });
}
var Nue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, XL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw new Error(t.message);
          return [4, Qd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return st.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, oS = ft.skipWhitespace, jL = ft.eatValue, Gs = ft.markLine, Vs = ft.getTokenString, YL = ft.readLine, f_, gM = /\s+/g;
function Pue(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x;
    return Te(this, function(A) {
      switch (A.label) {
        case 0:
          for (t = e.tokenizer, r = e.molecule; Vs(t) !== "@<TRIPOS>ATOM" && t.position < t.data.length; ) Gs(t);
          return n = t.position, a = t.lineNumber, i = YL(t), o = i.trim().split(/\s+/g), s = o.length, u = pt.create(t.data, 2 * r.num_atoms), c = pt.create(t.data, 2 * r.num_atoms), l = pt.create(t.data, 2 * r.num_atoms), d = pt.create(t.data, 2 * r.num_atoms), f = pt.create(t.data, 2 * r.num_atoms), m = pt.create(t.data, 2 * r.num_atoms), h = pt.create(t.data, 2 * r.num_atoms), p = pt.create(t.data, 2 * r.num_atoms), g = pt.create(t.data, 2 * r.num_atoms), v = pt.create(t.data, 2 * r.num_atoms), y = pe.Undefined(r.num_atoms, pe.Schema.float), _ = pe.Undefined(r.num_atoms, pe.Schema.int), S = pe.Undefined(r.num_atoms, pe.Schema.str), t.position = n, t.lineNumber = a, b = t.length, x = 0, [4, ih(e.runtimeCtx, 1e5, void 0, function(w) {
            for (var C = Math.min(r.num_atoms - x, w), M = 0; M < C; M++) for (var T = 0; T < s; T++) switch (oS(t), t.tokenStart = t.position, jL(t), T) {
              case 0:
                pt.addUnchecked(u, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                pt.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                pt.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                pt.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              case 4:
                pt.addUnchecked(f, t.tokenStart, t.tokenEnd);
                break;
              case 5:
                pt.addUnchecked(m, t.tokenStart, t.tokenEnd);
                break;
              case 6:
                pt.addUnchecked(h, t.tokenStart, t.tokenEnd);
                break;
              case 7:
                pt.addUnchecked(p, t.tokenStart, t.tokenEnd);
                break;
              case 8:
                pt.addUnchecked(g, t.tokenStart, t.tokenEnd);
                break;
              case 9:
                pt.addUnchecked(v, t.tokenStart, t.tokenEnd);
            }
            return x += C, C;
          }, function(w) {
            return w.update({ message: "Parsing...", current: t.position, max: b });
          })];
        case 1:
          return A.sent(), [2, { count: r.num_atoms, atom_id: tn(u)(pe.Schema.int), atom_name: tn(c)(pe.Schema.str), x: tn(l)(pe.Schema.float), y: tn(d)(pe.Schema.float), z: tn(f)(pe.Schema.float), atom_type: s > 5 ? tn(m)(pe.Schema.str) : S, subst_id: s > 6 ? tn(h)(pe.Schema.int) : _, subst_name: s > 7 ? tn(p)(pe.Schema.str) : S, charge: s > 8 ? tn(g)(pe.Schema.float) : y, status_bit: s > 9 ? tn(v)(pe.Schema.str) : S }];
      }
    });
  });
}
function Bue(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o, s, u, c, l, d, f, m, h;
    return Te(this, function(p) {
      switch (p.label) {
        case 0:
          for (t = e.tokenizer, r = e.molecule; Vs(t) !== "@<TRIPOS>BOND" && t.position < t.data.length; ) Gs(t);
          return n = t.position, a = t.lineNumber, i = YL(t), o = i.trim().split(/\s+/g), s = o.length, u = pt.create(t.data, 2 * r.num_bonds), c = pt.create(t.data, 2 * r.num_bonds), l = pt.create(t.data, 2 * r.num_bonds), d = pt.create(t.data, 2 * r.num_bonds), f = pt.create(t.data, 2 * r.num_bonds), t.position = n, t.lineNumber = a, m = t.length, h = 0, [4, ih(e.runtimeCtx, 1e5, void 0, function(g) {
            for (var v = Math.min(r.num_bonds - h, g), y = 0; y < v; y++) for (var _ = 0; _ < s; _++) switch (oS(t), t.tokenStart = t.position, jL(t), _) {
              case 0:
                pt.addUnchecked(u, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                pt.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                pt.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                pt.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              default:
                pt.addUnchecked(f, t.tokenStart, t.tokenEnd);
            }
            return h += v, v;
          }, function(g) {
            return g.update({ message: "Parsing...", current: t.position, max: m });
          })];
        case 1:
          return p.sent(), [2, { count: r.num_bonds, bond_id: tn(u)(pe.Schema.int), origin_atom_id: tn(c)(pe.Schema.int), target_atom_id: tn(l)(pe.Schema.int), bond_type: tn(d)(pe.Schema.str), status_bits: s > 4 ? tn(f)(pe.Schema.str) : pe.Undefined(r.num_bonds, pe.Schema.str) }];
      }
    });
  });
}
function Oue(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c;
    return Te(this, function(l) {
      switch (l.label) {
        case 0:
          n = ft(t), e.update({ message: "Parsing...", current: 0, max: t.length }), a = [], l.label = 1;
        case 1:
          return n.position < t.length ? (i = /* @__PURE__ */ function(d, f) {
            return { tokenizer: d, molecule: { mol_name: "", num_atoms: 0, num_bonds: 0, num_subst: 0, num_feat: 0, num_sets: 0, mol_type: "", charge_type: "", status_bits: "", mol_comment: "" }, runtimeCtx: f };
          }(n, e), function(d) {
            for (var f = d.tokenizer, m = d.molecule; Vs(f) !== "@<TRIPOS>MOLECULE" && f.position < f.data.length; ) Gs(f);
            Gs(f), m.mol_name = Vs(f), Gs(f);
            var h = Vs(f).trim().split(gM);
            m.num_atoms = parseInt(h[0]), m.num_bonds = parseInt(h[1]), m.num_subst = parseInt(h[2]), m.num_feat = parseInt(h[3]), m.num_sets = parseInt(h[4]), Gs(f);
            var p = Vs(f);
            if (!p.startsWith("@<TRIPOS>")) {
              m.mol_type = p, Gs(f);
              var g = Vs(f);
              if (!g.startsWith("@<TRIPOS>")) {
                m.charge_type = g, Gs(f);
                var v = Vs(f);
                if (!v.startsWith("@<TRIPOS>")) {
                  m.status_bits = v, Gs(f);
                  var y = Vs(f);
                  y.startsWith("@<TRIPOS>") || (m.mol_comment = y);
                }
              }
            }
          }(i), [4, Pue(i)]) : [3, 4];
        case 2:
          return o = l.sent(), [4, Bue(i)];
        case 3:
          for (s = l.sent(), u = function(d) {
            for (var f = d.tokenizer; f.position < f.data.length; ) {
              var m = Vs(f);
              if (m === "@<TRIPOS>MOLECULE") return;
              if (m === "@<TRIPOS>CRYSIN") break;
              Gs(f);
            }
            if (!(f.position >= f.data.length)) {
              Gs(f);
              var h = Vs(f).trim().split(gM);
              return { a: parseFloat(h[0]), b: parseFloat(h[1]), c: parseFloat(h[2]), alpha: parseFloat(h[3]), beta: parseFloat(h[4]), gamma: parseFloat(h[5]), spaceGroup: parseInt(h[6], 10), setting: parseInt(h[7], 10) };
            }
          }(i), a.push({ molecule: i.molecule, atoms: o, bonds: s, crysin: u }), oS(n); Vs(n) !== "@<TRIPOS>MOLECULE" && n.position < n.data.length; ) Gs(n);
          return [3, 1];
        case 4:
          return c = { name: r, structures: a }, [2, za.success(c)];
      }
    });
  });
}
function Fue(e, t) {
  var r = this;
  return sr.create("Parse MOL2", function(n) {
    return Be(r, 0, void 0, function() {
      return Te(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, Oue(n, e, t)];
          case 1:
            return [2, a.sent()];
        }
      });
    });
  });
}
function Rue(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N;
    return Te(this, function(I) {
      switch (I.label) {
        case 0:
          r = [], n = 0, a = e.structures.length, I.label = 1;
        case 1:
          if (!(n < a)) return [3, 4];
          for (i = e.structures[n], o = i.molecule, s = i.atoms, u = i.bonds, c = i.crysin, l = pe.ofConst("A", s.count, pe.Schema.str), d = new Array(s.count), f = !1, m = 0; m < s.count; ++m) if (s.atom_type.value(m).includes(".")) {
            f = !0;
            break;
          }
          for (h = 0; h < s.count; ++h) d[h] = f ? s.atom_type.value(h).split(".")[0].toUpperCase() : J8(s.atom_name.value(h), s.subst_name.value(h));
          for (p = Yr.ofPartialColumns(Go.atom_site, { auth_asym_id: l, auth_atom_id: pe.asArrayColumn(s.atom_name), auth_comp_id: s.subst_name, auth_seq_id: s.subst_id, Cartn_x: pe.asArrayColumn(s.x, Float32Array), Cartn_y: pe.asArrayColumn(s.y, Float32Array), Cartn_z: pe.asArrayColumn(s.z, Float32Array), id: pe.asArrayColumn(s.atom_id), label_asym_id: l, label_atom_id: pe.asArrayColumn(s.atom_name), label_comp_id: s.subst_name, label_seq_id: s.subst_id, label_entity_id: pe.ofConst("1", s.count, pe.Schema.str), occupancy: pe.ofConst(1, s.count, pe.Schema.float), type_symbol: pe.ofStringArray(d), pdbx_PDB_model_num: pe.ofConst(n, s.count, pe.Schema.int) }, s.count), (g = new mm()).setNames([["MOL", o.mol_name || "Ligand"]]), g.getEntityId("MOL", 0, "A"), v = new fm(s.subst_id, s.atom_name), y = 0, _ = s.subst_name.rowCount; y < _; ++y) v.add(s.subst_name.value(y), y);
          return [4, bl(Zd({ entity: g.getEntityTable(), chem_comp: v.getChemCompTable(), atom_site: p }), f_.create(e), t)];
        case 2:
          (S = I.sent()).frameCount > 0 && (b = pe.ofIntArray(pe.mapToArray(u.origin_atom_id, function(P) {
            return P - 1;
          }, Int32Array)), x = pe.ofIntArray(pe.mapToArray(u.target_atom_id, function(P) {
            return P - 1;
          }, Int32Array)), A = u.bond_id, w = pe.ofIntArray(pe.mapToArray(u.bond_type, function(P) {
            switch (P) {
              case "ar":
              case "am":
              case "un":
                return 1;
              case "du":
              case "nc":
                return 0;
              default:
                return parseInt(P);
            }
          }, Int8Array)), C = pe.ofIntArray(pe.mapToArray(u.bond_type, function(P) {
            switch (P) {
              case "ar":
              case "am":
                return 17;
              case "du":
              case "nc":
                return 0;
              default:
                return 1;
            }
          }, Int8Array)), M = Ra.fromData({ pairs: { key: A, indexA: b, indexB: x, order: w, flag: C }, count: s.count }), T = S.representative, Ra.Provider.set(T, M), dl.Provider.set(T, { data: s.charge, type: o.charge_type }), c && (N = function(P) {
            if (P.setting === 1) {
              var O = tu.create(P.spaceGroup, D.create(P.a, P.b, P.c), D.scale(D(), D.create(P.alpha, P.beta, P.gamma), Math.PI / 180));
              return { spacegroup: Fo.create(O), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
            }
          }(c), N && pi.Provider.set(T, N)), r.push(T)), I.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, new dh(r)];
      }
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mol2";
  }, e.create = function(t) {
    return { kind: "mol2", name: t.name, data: t };
  };
})(f_ || (f_ = {}));
var so, Lue = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t, r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, Fue(e, "").run()] : [2, [vc()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, (a = t.result, sr.create("Parse MOL2", function(i) {
            return Rue(a, i);
          })).run()];
        case 2:
          return r = n.sent(), [2, [st.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
      var a;
    });
  });
} }, ml = ((so = {})[xr.Pdb] = zse, so[xr.Mol] = Hse, so[xr.Sdf] = rue, so[xr.Gro] = sue, so[xr.Xtc] = fue, so[xr.Dump] = vue, so[xr.Xyz] = bue, so[xr.Cif] = Sue, so[xr.MMCif] = vM, so[xr.MCif] = vM, so[xr.POSCAR] = Cue, so[xr.Material] = Due, so[xr.Pymatgen] = Nue, so[xr.Mol2] = Lue, so), Vt = my.Const, Ot = my.Dynamic, kue = [Vt(we.core.type.bool, function(e, t) {
  return !!t[0](e);
}), Vt(we.core.type.num, function(e, t) {
  return +t[0](e);
}), Vt(we.core.type.str, function(e, t) {
  return "" + t[0](e);
}), Vt(we.core.type.list, function(e, t) {
  return Q0.forEachEval(t, e, function(r, n, a) {
    return a[n] = r;
  }, []);
}), Vt(we.core.type.set, function(e, t) {
  return Q0.forEachEval(t, e, function(r, n, a) {
    return a.add(r);
  }, /* @__PURE__ */ new Set());
}), Vt(we.core.type.regex, function(e, t) {
  return new RegExp(t[0](e), t[1] && t[1](e) || "");
}), Vt(we.core.type.bitflags, function(e, t) {
  return +t[0](e);
}), Vt(we.core.type.compositeKey, function(e, t) {
  return Q0.forEachEval(t, e, function(r, n, a) {
    return a[n] = "" + r;
  }, []).join("-");
}), Vt(we.core.logic.not, function(e, t) {
  return !t[0](e);
}), Vt(we.core.logic.and, function(e, t) {
  if (typeof t.length == "number") {
    for (var r = 0, n = t.length; r < n; r++) if (!t[r](e)) return !1;
  } else for (var a = 0, i = Object.keys(t); a < i.length; a++)
    if (!t[i[a]](e)) return !1;
  return !0;
}), Vt(we.core.logic.or, function(e, t) {
  if (typeof t.length == "number") {
    for (var r = 0, n = t.length; r < n; r++) if (t[r](e)) return !0;
  } else for (var a = 0, i = Object.keys(t); a < i.length; a++)
    if (t[i[a]](e)) return !0;
  return !1;
}), Vt(we.core.rel.eq, function(e, t) {
  return t[0](e) === t[1](e);
}), Vt(we.core.rel.neq, function(e, t) {
  return t[0](e) !== t[1](e);
}), Vt(we.core.rel.lt, function(e, t) {
  return t[0](e) < t[1](e);
}), Vt(we.core.rel.lte, function(e, t) {
  return t[0](e) <= t[1](e);
}), Vt(we.core.rel.gr, function(e, t) {
  return t[0](e) > t[1](e);
}), Vt(we.core.rel.gre, function(e, t) {
  return t[0](e) >= t[1](e);
}), Vt(we.core.rel.inRange, function(e, t) {
  var r = t[0](e);
  return r >= t[1](e) && r <= t[2](e);
}), Vt(we.core.math.add, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r += t[n](e);
  else for (var i = 0, o = Object.keys(t); i < o.length; i++)
    r += t[o[i]](e);
  return r;
}), Vt(we.core.math.sub, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") {
    if (t.length === 1) return -t[0](e);
    r = t[0](e) || 0;
    for (var n = 1, a = t.length; n < a; n++) r -= t[n](e);
  } else {
    var i = Object.keys(t);
    if (i.length === 1) return -t[i[0]](e);
    for (r = t[i[0]](e) || 0, n = 1, a = i.length; n < a; n++) r -= t[i[n]](e);
  }
  return r;
}), Vt(we.core.math.mult, function(e, t) {
  var r = 1;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r *= t[n](e);
  else for (var i = 0, o = Object.keys(t); i < o.length; i++)
    r *= t[o[i]](e);
  return r;
}), Vt(we.core.math.div, function(e, t) {
  return t[0](e) / t[1](e);
}), Vt(we.core.math.pow, function(e, t) {
  return Math.pow(t[0](e), t[1](e));
}), Vt(we.core.math.mod, function(e, t) {
  return t[0](e) % t[1](e);
}), Vt(we.core.math.min, function(e, t) {
  var r = Number.POSITIVE_INFINITY;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r = Math.min(t[n](e), r);
  else for (var i = 0, o = Object.keys(t); i < o.length; i++) {
    var s = o[i];
    r = Math.min(t[s](e), r);
  }
  return r;
}), Vt(we.core.math.max, function(e, t) {
  var r = Number.NEGATIVE_INFINITY;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r = Math.max(t[n](e), r);
  else for (var i = 0, o = Object.keys(t); i < o.length; i++) {
    var s = o[i];
    r = Math.max(t[s](e), r);
  }
  return r;
}), Vt(we.core.math.floor, function(e, t) {
  return Math.floor(t[0](e));
}), Vt(we.core.math.ceil, function(e, t) {
  return Math.ceil(t[0](e));
}), Vt(we.core.math.roundInt, function(e, t) {
  return Math.round(t[0](e));
}), Vt(we.core.math.abs, function(e, t) {
  return Math.abs(t[0](e));
}), Vt(we.core.math.sqrt, function(e, t) {
  return Math.sqrt(t[0](e));
}), Vt(we.core.math.cbrt, function(e, t) {
  return Math.cbrt(t[0](e));
}), Vt(we.core.math.sin, function(e, t) {
  return Math.sin(t[0](e));
}), Vt(we.core.math.cos, function(e, t) {
  return Math.cos(t[0](e));
}), Vt(we.core.math.tan, function(e, t) {
  return Math.tan(t[0](e));
}), Vt(we.core.math.asin, function(e, t) {
  return Math.asin(t[0](e));
}), Vt(we.core.math.acos, function(e, t) {
  return Math.acos(t[0](e));
}), Vt(we.core.math.atan, function(e, t) {
  return Math.atan(t[0](e));
}), Vt(we.core.math.sinh, function(e, t) {
  return Math.sinh(t[0](e));
}), Vt(we.core.math.cosh, function(e, t) {
  return Math.cosh(t[0](e));
}), Vt(we.core.math.tanh, function(e, t) {
  return Math.tanh(t[0](e));
}), Vt(we.core.math.exp, function(e, t) {
  return Math.exp(t[0](e));
}), Vt(we.core.math.log, function(e, t) {
  return Math.log(t[0](e));
}), Vt(we.core.math.log10, function(e, t) {
  return Math.log10(t[0](e));
}), Vt(we.core.math.atan2, function(e, t) {
  return Math.atan2(t[0](e), t[1](e));
}), Vt(we.core.str.match, function(e, t) {
  return t[0](e).test(t[1](e));
}), Vt(we.core.str.concat, function(e, t) {
  var r = [];
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r.push(t[n](e).toString());
  else for (var i = 0, o = Object.keys(t); i < o.length; i++) {
    var s = o[i];
    r.push(t[s](e).toString());
  }
  return r.join("");
}), Vt(we.core.list.getAt, function(e, t) {
  return t[0](e)[t[1](e)];
}), Vt(we.core.list.equal, function(e, t) {
  return function(r, n) {
    if (!r || r.length === 0) return !n || n.length === 0;
    if (!n) return !1;
    var a = r.length;
    if (a !== n.length) return !1;
    for (var i = 0; i < a; i++) if (r[i] !== n[i]) return !1;
    return !0;
  }(t[0](e), t[1](e));
}), Vt(we.core.set.has, function(e, t) {
  return t[0](e).has(t[1](e));
}), Vt(we.core.set.isSubset, function(e, t) {
  return bo.isSuperset(t[1](e), t[0](e));
}), Vt(we.core.flags.hasAny, function(e, t) {
  var r = t[1](e), n = t[0](e);
  return r ? !!(n & r) : !!n;
}), Vt(we.core.flags.hasAll, function(e, t) {
  var r = t[1](e), n = t[0](e);
  return r ? (n & r) === r : !n;
}), Vt(we.structureQuery.type.elementSymbol, function(e, t) {
  return Rp(t[0](e));
}), Vt(we.structureQuery.type.atomName, function(e, t) {
  return (r = t[0](e)) ? typeof r == "string" ? r.toUpperCase() : "".concat(r).toUpperCase() : "";
  var r;
}), Vt(we.structureQuery.type.bondFlags, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r = yM(r, t[n](e));
  else for (var i = 0, o = Object.keys(t); i < o.length; i++)
    r = yM(r, t[o[i]](e));
  return r;
}), Vt(we.structureQuery.type.ringFingerprint, function(e, t) {
  return Js.elementFingerprint(function(r, n) {
    var a = [];
    if (!n) return a;
    if (typeof n.length == "number") for (var i = 0, o = n.length; i < o; i++) a.push(n[i](r));
    else {
      var s = Object.keys(n);
      for (i = 1, o = s.length; i < o; i++) a.push(n[s[i]](r));
    }
    return a;
  }(e, t));
}), Vt(we.structureQuery.type.secondaryStructureFlags, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, a = t.length; n < a; n++) r = bM(r, t[n](e));
  else for (var i = 0, o = Object.keys(t); i < o.length; i++)
    r = bM(r, t[o[i]](e));
  return r;
}), Ot(we.structureQuery.filter.pick, function(e, t) {
  return Pn.filters.pick(t[0], t.test)(e);
}), Ot(we.structureQuery.filter.first, function(e, t) {
  return Pn.filters.first(t[0])(e);
}), Ot(we.structureQuery.filter.withSameAtomProperties, function(e, t) {
  return Pn.filters.withSameAtomProperties(t[0], t.source, t.property)(e);
}), Ot(we.structureQuery.filter.intersectedBy, function(e, t) {
  return Pn.filters.areIntersectedBy(t[0], t.by)(e);
}), Ot(we.structureQuery.filter.within, function(e, t) {
  return Pn.filters.within({ query: t[0], target: t.target, minRadius: t["min-radius"], maxRadius: t["max-radius"], elementRadius: t["atom-radius"], invert: t.invert })(e);
}), Ot(we.structureQuery.filter.isConnectedTo, function(e, t) {
  return Pn.filters.isConnectedTo({ query: t[0], target: t.target, disjunct: t.disjunct, invert: t.invert, bondTest: t["bond-test"] })(e);
}), Ot(we.structureQuery.generator.atomGroups, function(e, t) {
  return Pn.generators.atoms({ entityTest: t["entity-test"], chainTest: t["chain-test"], residueTest: t["residue-test"], atomTest: t["atom-test"], groupBy: t["group-by"] })(e);
}), Ot(we.structureQuery.generator.all, function(e) {
  return Pn.generators.all(e);
}), Ot(we.structureQuery.generator.empty, function(e) {
  return Pn.generators.none(e);
}), Ot(we.structureQuery.generator.bondedAtomicPairs, function(e, t) {
  return Pn.generators.bondedAtomicPairs(t && t[0])(e);
}), Ot(we.structureQuery.generator.rings, function(e, t) {
  var r, n;
  return Pn.generators.rings((r = t == null ? void 0 : t.fingerprint) === null || r === void 0 ? void 0 : r.call(t, e), (n = t == null ? void 0 : t["only-aromatic"]) === null || n === void 0 ? void 0 : n.call(t, e))(e);
}), Ot(we.structureQuery.modifier.includeSurroundings, function(e, t) {
  return Pn.modifiers.includeSurroundings(t[0], { radius: t.radius(e), wholeResidues: !(!t["as-whole-residues"] || !t["as-whole-residues"](e)), elementRadius: t["atom-radius"] })(e);
}), Ot(we.structureQuery.modifier.surroundingLigands, function(e, t) {
  return Pn.modifiers.surroundingLigands({ query: t[0], radius: t.radius(e), includeWater: !(!t["include-water"] || !t["include-water"](e)) })(e);
}), Ot(we.structureQuery.modifier.wholeResidues, function(e, t) {
  return Pn.modifiers.wholeResidues(t[0])(e);
}), Ot(we.structureQuery.modifier.union, function(e, t) {
  return Pn.modifiers.union(t[0])(e);
}), Ot(we.structureQuery.modifier.expandProperty, function(e, t) {
  return Pn.modifiers.expandProperty(t[0], t.property)(e);
}), Ot(we.structureQuery.modifier.exceptBy, function(e, t) {
  return Pn.modifiers.exceptBy(t[0], t.by)(e);
}), Ot(we.structureQuery.modifier.intersectBy, function(e, t) {
  return Pn.modifiers.intersectBy(t[0], t.by)(e);
}), Ot(we.structureQuery.modifier.includeConnected, function(e, t) {
  var r, n;
  return Pn.modifiers.includeConnected({ query: t[0], bondTest: t["bond-test"], wholeResidues: !(!t["as-whole-residues"] || !t["as-whole-residues"](e)), layerCount: t["layer-count"] && t["layer-count"](e) || 1, fixedPoint: (n = (r = t["fixed-point"]) === null || r === void 0 ? void 0 : r.call(t, e)) !== null && n !== void 0 && n })(e);
}), Ot(we.structureQuery.combinator.merge, function(e, t) {
  return Pn.combinators.merge(t)(e);
}), Ot(we.structureQuery.atomProperty.core.elementSymbol, un(at.atom.type_symbol)), Ot(we.structureQuery.atomProperty.core.vdw, function(e, t) {
  return m3(at.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Ot(we.structureQuery.atomProperty.core.mass, function(e, t) {
  return function(r) {
    var n = zp[r];
    return n === void 0 ? 10.81 : Ste[n];
  }(at.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Ot(we.structureQuery.atomProperty.core.atomicNumber, function(e, t) {
  return lh(at.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Ot(we.structureQuery.atomProperty.core.x, un(at.atom.x)), Ot(we.structureQuery.atomProperty.core.y, un(at.atom.y)), Ot(we.structureQuery.atomProperty.core.z, un(at.atom.z)), Ot(we.structureQuery.atomProperty.core.sourceIndex, un(at.atom.sourceIndex)), Ot(we.structureQuery.atomProperty.core.operatorName, un(at.unit.operator_name)), Ot(we.structureQuery.atomProperty.core.modelIndex, un(at.unit.model_index)), Ot(we.structureQuery.atomProperty.core.modelLabel, un(at.unit.model_label)), Ot(we.structureQuery.atomProperty.core.atomKey, function(e, t) {
  var r = t && t[0] && t[0](e) || e.element;
  return eu(r.unit.id, r.element);
}), Ot(we.structureQuery.atomProperty.macromolecular.residueKey, function(e, t) {
  return yre(t && t[0] && t[0](e) || e.element);
}), Ot(we.structureQuery.atomProperty.macromolecular.chainKey, function(e, t) {
  return bre(t && t[0] && t[0](e) || e.element);
}), Ot(we.structureQuery.atomProperty.macromolecular.entityKey, function(e, t) {
  return xre(t && t[0] && t[0](e) || e.element);
}), Ot(we.structureQuery.atomProperty.macromolecular.id, un(at.atom.id)), Ot(we.structureQuery.atomProperty.macromolecular.isHet, function(e, t) {
  return at.residue.group_PDB(t && t[0] && t[0](e) || e.element) !== "ATOM";
}), Ot(we.structureQuery.atomProperty.macromolecular.label_atom_id, un(at.atom.label_atom_id)), Ot(we.structureQuery.atomProperty.macromolecular.label_alt_id, un(at.atom.label_alt_id)), Ot(we.structureQuery.atomProperty.macromolecular.label_comp_id, un(at.atom.label_comp_id)), Ot(we.structureQuery.atomProperty.macromolecular.label_seq_id, un(at.residue.label_seq_id)), Ot(we.structureQuery.atomProperty.macromolecular.label_asym_id, un(at.chain.label_asym_id)), Ot(we.structureQuery.atomProperty.macromolecular.label_entity_id, un(at.entity.id)), Ot(we.structureQuery.atomProperty.macromolecular.auth_atom_id, un(at.atom.auth_atom_id)), Ot(we.structureQuery.atomProperty.macromolecular.auth_comp_id, un(at.atom.auth_comp_id)), Ot(we.structureQuery.atomProperty.macromolecular.auth_seq_id, un(at.residue.auth_seq_id)), Ot(we.structureQuery.atomProperty.macromolecular.auth_asym_id, un(at.chain.auth_asym_id)), Ot(we.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, un(at.residue.pdbx_PDB_ins_code)), Ot(we.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, un(at.atom.pdbx_formal_charge)), Ot(we.structureQuery.atomProperty.macromolecular.occupancy, un(at.atom.occupancy)), Ot(we.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, un(at.atom.B_iso_or_equiv)), Ot(we.structureQuery.atomProperty.macromolecular.entityType, un(at.entity.type)), Ot(we.structureQuery.atomProperty.macromolecular.entitySubtype, un(at.entity.subtype)), Ot(we.structureQuery.atomProperty.macromolecular.entityPrdId, un(at.entity.prd_id)), Ot(we.structureQuery.atomProperty.macromolecular.entityDescription, un(at.entity.pdbx_description)), Ot(we.structureQuery.atomProperty.macromolecular.objectPrimitive, un(at.unit.object_primitive)), Ot(we.structureQuery.atomProperty.macromolecular.isNonStandard, un(at.residue.isNonStandard)), Ot(we.structureQuery.atomProperty.macromolecular.secondaryStructureKey, un(at.residue.secondary_structure_key)), Ot(we.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, un(at.residue.secondary_structure_type)), Ot(we.structureQuery.atomProperty.macromolecular.chemCompType, un(at.residue.chem_comp_type)), Ot(we.structureQuery.bondProperty.order, function(e, t) {
  return e.atomicBond.order;
}), Ot(we.structureQuery.bondProperty.flags, function(e, t) {
  return e.atomicBond.type;
}), Ot(we.structureQuery.bondProperty.atomA, function(e, t) {
  return e.atomicBond.a;
}), Ot(we.structureQuery.bondProperty.atomB, function(e, t) {
  return e.atomicBond.b;
}), Ot(we.structureQuery.bondProperty.length, function(e, t) {
  return e.atomicBond.length;
}), Ot(we.internal.generator.bundleElement, function(e, t) {
  return QF(t.groupedUnits(e), t.ranges(e), t.set(e));
}), Ot(we.internal.generator.bundle, function(e, t) {
  return $F(t.elements(e))(e);
}), Ot(we.internal.generator.current, function(e, t) {
  return e.tryGetCurrentSelection();
})];
function un(e) {
  return function(t, r) {
    return e(r && r[0] && r[0](t) || t.element);
  };
}
function yM(e, t) {
  return e | (pr.isName(t) ? pr.fromName(t) : 0);
}
function bM(e, t) {
  switch (t.toLowerCase()) {
    case "helix":
      return 2 | e;
    case "alpha":
      return 4098 | e;
    case "pi":
      return 32770 | e;
    case "310":
      return 2050 | e;
    case "beta":
      return 4 | e;
    case "strand":
      return 4194308 | e;
    case "sheet":
      return 8388612 | e;
    case "turn":
      return 16 | e;
    case "bend":
      return 8 | e;
    case "coil":
      return 536870912 | e;
    default:
      return e;
  }
}
(function() {
  for (var e = 0, t = kue; e < t.length; e++) {
    var r = t[e];
    eL.addSymbol(r);
  }
})();
var My, zue = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function Uue(e, t, r) {
  var n = !1;
  return kd(e, t, r, function(a, i) {
    (function(o) {
      return zue.has(o);
    })(Hr(a, i)) && (n = !0);
  }), n;
}
(function(e) {
  e.Type = "Type", e.Structure = "Structure Property", e.Atom = "Atom Property", e.Bond = "Bond Property", e.Residue = "Residue Property", e.AminoAcid = "Amino Acid", e.NucleicBase = "Nucleic Base", e.Manipulate = "Manipulate Selection", e.Validation = "Validation", e.Misc = "Miscellaneous", e.Internal = "Internal";
})(My || (My = {}));
var Gue = function(e, t, r) {
  var n, a;
  return r === void 0 && (r = {}), { label: e, expression: t, description: r.description || "", category: (n = r.category) !== null && n !== void 0 ? n : My.Misc, isHidden: !!r.isHidden, priority: r.priority || 0, referencesCurrent: !!r.referencesCurrent, get query() {
    return a || (a = py(t)), a;
  }, ensureCustomProperties: r.ensureCustomProperties };
}("Polymer", zt.struct.modifier.union([zt.struct.generator.atomGroups({ "entity-test": zt.core.logic.and([zt.core.rel.eq([zt.ammp("entityType"), "polymer"]), zt.core.str.match([zt.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"), zt.ammp("entitySubtype")])]) })]), { category: My.Type }), xM = { polymer: Gue }, vc = function() {
  return st.Builder().getStructure();
}, WL = function(e, t) {
  for (var r = st.Builder(), n = new Set(t), a = 0, i = e.units; a < i.length; a++) {
    var o = i[a], s = nt([], o.elements, !0).filter(function(u) {
      return !n.has(u);
    });
    s.length && r.addUnit(o.kind, o.model, o.conformation.operator, s, o.traits);
  }
  return r.getStructure();
}, zo = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? t.structure : t.kind === "element-loci" ? et.toStructure(t) : st.Empty;
}, A3 = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? Ya(st.toStructureElementLoci(t.structure)) : t.kind === "element-loci" ? Ya(t) : [];
}, sa = function(e, t, r, n) {
  if ((t == null ? void 0 : t.length) === 0 && !r) return st.Empty;
  for (var a = st.Builder(), i = new Set(t), o = typeof n == "string" ? n : Fa.create22(), s = 0, u = e.units; s < u.length; s++) {
    var c = u[s], l = t != null && t.length ? nt([], c.elements, !0).filter(function(d) {
      return i.has(d);
    }) : c.elements;
    l.length && a.addUnit(c.kind, n ? k(k({}, c.model), { id: o }) : c.model, c.conformation.operator, l, c.traits);
  }
  return a.getStructure();
}, N2 = function(e, t) {
  for (var r = st.Builder(), n = /* @__PURE__ */ new Map(), a = 0, i = function(u, c) {
    var l = e[u], d = l.ref, f = l.elementIds, m = dn(t.cells.get(d)), h = new Set(f);
    n.set(u, []);
    for (var p = 0, g = m.units; p < g.length; p++) {
      var v = g[p], y = f ? nt([], v.elements, !0).filter(function(_) {
        return h.has(_);
      }) : v.elements;
      y.length && (n.get(u).push(a), r.addUnit(v.kind, v.model, v.conformation.operator, y, v.traits, a), a++);
    }
  }, o = 0, s = e.length; o < s; o++) i(o);
  return { unitsMap: n, structure: r.getStructure() };
}, m_ = function(e) {
  if (e.model.sourceData.kind === "gro") return { polymer: ms(t1(e1(e, xM.polymer.expression))), other: ms(t1(e1(e, zt.struct.modifier.exceptBy({ 0: Dd.toExpression(Dd("(sel.atom.all)", "mol-script")), by: xM.polymer.expression })))) };
  var t = {}, r = {}, n = /* @__PURE__ */ new Set(), a = [], i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(u) {
    var c;
    u.elements.forEach(function(h) {
      var p = mc(u, h);
      if (p.groupPDB === "ATOM" && !["UNK", "MOL"].includes(p.residueName)) return fo(t, p), n.add(p.elementId), void a.push(p.elementId);
      if (p.groupPDB === "HETATM" || ["UNK", "MOL"].includes(p.residueName)) {
        var g = "".concat(p.chainId, "_").concat(p.residueId);
        i.set(g, i.has(g) ? nt(nt([], i.get(g), !0), [p], !1) : [p]);
      } else fo(r, p);
    });
    for (var l = 0, d = u.bonds.a.length; l < d; l++) {
      var f = u.elements[u.bonds.a[l]], m = u.elements[u.bonds.b[l]];
      o.has(f) ? (c = o.get(f)) === null || c === void 0 || c.add(m) : o.set(f, /* @__PURE__ */ new Set([m]));
    }
  }), i.forEach(function(u) {
    var c = !1;
    new Set(u.map(function(l) {
      return l.elementId;
    })).forEach(function(l) {
      if (o.has(l)) {
        var d = o.get(l);
        d == null || d.forEach(function(f) {
          n.has(f) && (c = !0);
        });
      }
    }), u.forEach(function(l) {
      c ? (Object.assign(l, { isEutectic: !0 }), a.push(l.elementId), n.add(l.elementId)) : fo(r, l);
    });
  });
  var s = [];
  return Object.keys(r).forEach(function(u) {
    Object.keys(r[u]).forEach(function(c) {
      s.push.apply(s, r[u][c].map(function(l) {
        return l.elementId;
      }));
    });
  }), { polymer: a, other: s };
}, w3 = function(e, t) {
  var r;
  if (!e.elementCount) return "";
  if (t === xr.Pdb) return aS(e, void 0, !0);
  var n = ps(e), a = (r = n == null ? void 0 : n.entryId) !== null && r !== void 0 ? r : "";
  return t === xr.Sdf || t === xr.Mol ? a ? nt([a], c_(e).split(`
`).slice(1), !0).join(`
`) : c_(e) : void 0;
}, Vue = function(e, t) {
  var r = ps(e);
  return t !== xr.Material ? r.sourceData.data : r.sourceData.data.molecules[0];
}, que = function(e, t, r, n) {
  return Be(void 0, 0, void 0, function() {
    var a, i, o, s, u, c, l;
    return Te(this, function(d) {
      switch (d.label) {
        case 0:
          return a = !((u = e == null ? void 0 : e.models) === null || u === void 0) && u.length ? e.models[0] : e == null ? void 0 : e.model, ((l = n ?? (a ? a.sourceData.kind : (c = e == null ? void 0 : e.parent) === null || c === void 0 ? void 0 : c.model.sourceData.kind)) !== null && l !== void 0 ? l : "sdf") !== "mmCIF" ? [3, 3] : (o = (i = ml[xr.Pdb]).parse, [4, aS(e, void 0, !0, r)]);
        case 1:
          return [4, o.apply(i, [d.sent()])];
        case 2:
        case 5:
          return [2, d.sent()];
        case 3:
          return [4, c_(e, void 0, 0, t)];
        case 4:
          return s = d.sent(), [4, ml[xr.Sdf].parse(s)];
      }
    });
  });
}, e1 = function(e, t) {
  return py(t)(new tm(e));
}, t1 = function(e) {
  var t;
  if (e.structure) t = e.structure;
  else if (e.structures) {
    var r = e.structures.map(function(i) {
      return (i == null ? void 0 : i.units.length) > 0 ? st.toStructureElementLoci(i) : void 0;
    }).filter(function(i) {
      return i;
    });
    if (r.length === 0) return vc();
    for (var n = r[0], a = 1; a < r.length; a++) n = et.union(n, r[a]);
    t = et.toStructure(n);
  }
  return t;
}, ms = function(e) {
  var t = [];
  return e.units.forEach(function(r) {
    t.push.apply(t, r.elements);
  }), t;
}, mc = function(e, t) {
  var r;
  return { unitId: e.invariantId, elementId: t, chainId: e.model.atomicHierarchy.chains.auth_asym_id.value(e.chainIndex[t]), groupPDB: e.model.atomicHierarchy.residues.group_PDB.value(e.residueIndex[t]), residueId: e.model.atomicHierarchy.residues.auth_seq_id.value(e.residueIndex[t]), insertCode: e.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.residueIndex[t]), residueName: e.model.atomicHierarchy.atoms.label_comp_id.value(t), atomId: e.model.atomicConformation.atomId.value(t), atomName: e.model.atomicHierarchy.atoms.label_atom_id.value(t), typeSymbol: xh(e.model.atomicHierarchy.atoms.type_symbol.value(t)), charge: ((r = dl.Provider.get(e.model)) === null || r === void 0 ? void 0 : r.data.value(t)) || 0, altId: e.model.atomicHierarchy.atoms.label_alt_id.value(t), cdr: e.model.atomicHierarchy.atoms.cdr.value(t) || 0, bfactor: e.model.atomicHierarchy.atoms.B_iso_or_equiv.value(t), em_confidence: e.model.atomicHierarchy.atoms.em_confidence.value(t), x: e.model.atomicConformation.x[t], y: e.model.atomicConformation.y[t], z: e.model.atomicConformation.z[t], residueIndex: e.residueIndex[t], occupancy: e.model.atomicConformation.occupancy.value(t) };
}, ZL = function(e, t, r) {
  var n = r;
  if (e.units.some(function(i) {
    return !!i.elements.includes(t) && (n = i.invariantId, !0);
  }), n === void 0 || !e.unitMap.has(n)) return {};
  var a = e.unitMap.get(n);
  return mc(a, t);
}, QL = function(e, t) {
  e.units.forEach(function(r) {
    r.elements.forEach(function(n) {
      var a = mc(r, n);
      t(a);
    });
  });
}, Hue = function(e, t, r) {
  var n = [];
  return t.forEach(function(a) {
    var i = e.managers.cell.get(a.ref), o = dn(i), s = /* @__PURE__ */ new Map(), u = new Set(a.elementIds);
    o && (o.units.forEach(function(c) {
      c.elements.forEach(function(l) {
        var d;
        if (!a.elementIds || u.has(l)) {
          var f = mc(c, l), m = wy(f, r);
          s.has(m) ? (d = s.get(m)) === null || d === void 0 || d.push(f) : s.set(m, [f]);
        }
      });
    }), s.forEach(function(c) {
      n.push({ ref: a.ref, elementIds: c.map(function(l) {
        return l.elementId;
      }), props: bse(c[0], r) });
    }));
  }), n;
}, $L = function(e, t) {
  var r = {}, n = /* @__PURE__ */ new Set(), a = t ?? [];
  return t || e.managers.cell.traverse(function(i, o) {
    dn(i) && !o.isHidden && n.add(i.ref);
  }), n.forEach(function(i) {
    a.push({ ref: i });
  }), a.forEach(function(i) {
    var o, s = i.ref, u = i.elementIds, c = new Set(u), l = e.cells.get(s);
    if (l) {
      var d = dn(l);
      if (d) {
        var f = [], m = [], h = [], p = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
        d.units.forEach(function(S) {
          var b;
          S.elements.forEach(function(M) {
            var T, N;
            if (!u || c.has(M)) {
              var I = mc(S, M), P = wy(I, Qr.Residue);
              $8.has(I.residueName.toUpperCase()) ? f.push(I.elementId) : m1.has(I.residueName.toUpperCase()) ? m.push(I.elementId) : Q8.has(I.typeSymbol.toUpperCase()) || Bh.has(I.residueName.toUpperCase()) ? h.push(I.elementId) : I.groupPDB !== "ATOM" || ["UNK", "MOL"].includes(I.residueName) ? I.groupPDB === "HETATM" || ["UNK", "MOL"].includes(I.residueName) ? y.has(P) ? (T = y.get(P)) === null || T === void 0 || T.push(I) : y.set(P, [I]) : v.has(P) ? (N = v.get(P)) === null || N === void 0 || N.push(I) : v.set(P, [I]) : p.add(I.elementId);
            }
          });
          for (var x = 0, A = S.bonds.a.length; x < A; x++) {
            var w = S.elements[S.bonds.a[x]], C = S.elements[S.bonds.b[x]];
            _.has(w) ? (b = _.get(w)) === null || b === void 0 || b.add(C) : _.set(w, /* @__PURE__ */ new Set([C]));
          }
        }), y.forEach(function(S, b) {
          var x = !1, A = new Set(S.map(function(w) {
            return w.elementId;
          }));
          A.forEach(function(w) {
            if (_.has(w)) {
              var C = _.get(w);
              C == null || C.forEach(function(M) {
                p.has(M) && (x = !0);
              });
            }
          }), S.forEach(function(w) {
            var C;
            x ? p.add(w.elementId) : v.has(b) ? (C = v.get(b)) === null || C === void 0 || C.push(w) : v.set(b, [w]);
          });
        }), v.forEach(function(S, b) {
          var x = S.filter(function(A) {
            return A.typeSymbol !== "H";
          });
          x.length > 10 && x.length < 150 ? g.set(b, S) : h.push.apply(h, S.map(function(A) {
            return A.elementId;
          }));
        }), r[s] = ((o = {})[qi.Protein] = p.size ? [{ ref: s, elementIds: Array.from(p.values()) }] : [], o[qi.Ligand] = Array.from(g.entries()).map(function(S) {
          var b = S[0], x = S[1];
          return { ref: s, elementIds: x.map(function(A) {
            return A.elementId;
          }), name: b };
        }), o[qi.Solvent] = f.length ? [{ ref: s, elementIds: f }] : [], o[qi.Water] = m.length ? [{ ref: s, elementIds: m }] : [], o[qi.Other] = h.length ? [{ ref: s, elementIds: h }] : [], o);
      }
    }
  }), r;
}, ps = function(e) {
  var t;
  return (t = e.model) !== null && t !== void 0 ? t : e.models[0];
}, wu = function(e) {
  var t, r;
  return (r = (t = e.model) !== null && t !== void 0 ? t : e.models[0]) === null || r === void 0 ? void 0 : r.id;
}, dn = function(e) {
  var t, r, n, a;
  return (t = e == null ? void 0 : e.model.structure) !== null && t !== void 0 ? t : !((r = e == null ? void 0 : e.model) === null || r === void 0) && r.trajectory ? st.ofModel((n = e == null ? void 0 : e.model.trajectory) === null || n === void 0 ? void 0 : n.state.getFrameAtIndex((a = e == null ? void 0 : e.model.trajectory) === null || a === void 0 ? void 0 : a.frameIndex)) : void 0;
}, C3 = function(e, t) {
  var r = e.units.filter(function(i) {
    return $e.has(i.elements, t);
  })[0];
  if (!r || Ke.isCoarse(r)) return Ea.NotHydrogen;
  if (r.model.atomicHierarchy.derived.atom.atomicNumber[t] !== 1) {
    var n = Ea.NotHydrogen;
    return kd(e, r, r.elements.indexOf(t), function(i, o) {
      if (i.model.atomicHierarchy.derived.atom.atomicNumber[i.elements[o]] === 1) switch (C3(e, i.elements[o])) {
        case Ea.Polar:
          n = Ea.ConnectPolar;
          break;
        case Ea.NonPolar:
          n = Ea.ConnectNonPolar;
      }
    }), n;
  }
  var a = Uue(e, r, $e.indexOf(r.elements, t));
  return a ? Ea.Polar : a ? Ea.NotHydrogen : Ea.NonPolar;
}, Kue = function(e, t) {
  return Be(void 0, 0, void 0, function() {
    var r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, Promise.all(t.filter(function(a) {
            return e.cells.has(a.ref);
          }).map(function(a) {
            return e.managers.cell.getStructure(a.ref);
          }))];
        case 1:
          return r = n.sent(), [2, Qse(r)];
      }
    });
  });
}, JL = function(e) {
  return Array.from(e.cells.entries()).map(function(t) {
    var r = t[0], n = t[1];
    return dn(n) ? n.representations.size === 0 || Array.from(n.representations.values()).filter(function(a) {
      return !a.isHidden;
    }).length === 0 ? { ref: "" } : { ref: r } : { ref: "" };
  }).filter(function(t) {
    return t.ref;
  });
}, i0 = function(e, t) {
  return ZL(e, t).typeSymbol === "H" && C3(e, t) === Ea.NonPolar;
}, Hx = function(e) {
  if (!e) return e;
  var t = [], r = e.sort(function(a, i) {
    return +a - +i;
  }), n = [];
  return r.forEach(function(a, i) {
    n.length !== 0 ? n.length !== 1 ? n.length === 2 && (n[1] === a - 1 ? n[1] = a : (t.push.apply(t, n), n = [a])) : n[0] === a - 1 ? n.push(a) : (t.push(n[0], n[0]), n = [a]) : n.push(a);
  }), n.length && t.push.apply(t, n.length === 2 ? n : [n[0], n[0]]), t;
}, Mg = function(e) {
  for (var t = [], r = 0, n = e.length; r < n; r += 2) for (var a = e[r]; a <= e[r + 1]; a++) t.push(a);
  return t;
};
function um(e, t, r, n) {
  var a, i, o, s, u = 0, c = t.webgl, l = new pa(), d = new fr.GeometryState(), f = Sl(), m = [], h = ys.create(), p = nu.createEmpty();
  function g(v) {
    if (ys.update(h, v), v.visible !== void 0 && a && a.setVisibility(v.visible && (h.unitTransforms === null || h.unitTransforms.isIdentity)), v.alphaFactor !== void 0 && a && a.setAlphaFactor(v.alphaFactor), v.pickable !== void 0 && a && a.setPickable(v.pickable), v.overpaint !== void 0 && a) {
      var y = mh.remap(v.overpaint, i);
      a.setOverpaint(y, c);
    }
    if (v.transparency !== void 0 && a) {
      var _ = ph.remap(v.transparency, i);
      a.setTransparency(_, c);
    }
    if (v.substance !== void 0 && a) {
      var S = vh.remap(v.substance, i);
      a.setSubstance(S, c);
    }
    if (v.clipping !== void 0 && a) {
      var b = hh.remap(v.clipping, i);
      a.setClipping(b);
    }
    v.transform !== void 0 && a && a.setTransform(v.transform), v.unitTransforms !== void 0 && a && a.setVisibility(h.visible && (v.unitTransforms === null || v.unitTransforms.isIdentity));
  }
  return { label: e, get groupCount() {
    return a ? a.groupCount : 0;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return h;
  }, get theme() {
    return p;
  }, get geometryVersion() {
    return d.version;
  }, renderObjects: m, updated: l, createOrUpdate: function(v, y) {
    var _ = this;
    return v === void 0 && (v = {}), y && y !== i && (o = r(t, y), i = y, s || (s = V.getDefaultValues(o))), s = Object.assign({}, s, v), sr.create("Creating or updating ComplexRepresentation", function(S) {
      return Be(_, 0, void 0, function() {
        var b, x, A;
        return Te(this, function(w) {
          switch (w.label) {
            case 0:
              return b = !1, a ? !((A = a.mustRecreate) === null || A === void 0) && A.call(a, i, s, c) && (a.destroy(), a = n(f, i, s, c), b = !0) : (a = n(f, i, s, c), b = !0), (x = a.createOrUpdate({ webgl: c, runtime: S }, p, s, y)) ? [4, x] : [3, 2];
            case 1:
              w.sent(), w.label = 2;
            case 2:
              return b && g(h), m.length = 0, a && a.renderObject && (m.push(a.renderObject), d.add(a.renderObject.id, a.geometryVersion)), d.snapshot(), u += 1, l.next(u), [2];
          }
        });
      });
    });
  }, setState: g, setTheme: function(v) {
    p = v;
  }, getLoci: function(v) {
    return v === void 0 ? st.Loci(i.target) : a ? a.getLoci(v) : Tn;
  }, mark: function(v, y) {
    if (!i || !qr.is(h.markerActions, y)) return !1;
    if (st.isLoci(v) || et.is(v) || Pt.isLoci(v)) {
      if (!st.areRootsEquivalent(v.structure, i)) return !1;
      v = an.remap(v, i), (st.isLoci(v) || et.is(v) && et.isWholeStructure(v)) && (v = k8);
    } else if (!Vo(v) && !Z0(v)) return !1;
    return !an.isEmpty(v) && !!a && a.mark(v, y);
  }, destroy: function() {
    a && a.destroy();
  } };
}
function ek(e, t, r) {
  var n = t.elements, a = t.model;
  if (We.indexOf(n, r) !== -1) {
    for (var i = a.atomicHierarchy.residueAtomSegments, o = i.index, s = i.offsets, u = o[r], c = [], l = s[u], d = s[u + 1]; l < d; ++l) {
      var f = We.indexOf(n, l);
      f !== -1 && c.push(f);
    }
    return et(e, [{ unit: t, indices: We.ofSortedArray($e.ofSortedArray(c)) }]);
  }
  return Tn;
}
function _M(e, t, r) {
  for (var n = e.structure.child, a = t && n ? e.group.units.filter(function(c) {
    return n.unitMap.has(c.id);
  }) : e.group.units, i = a.length, o = 16 * i, s = r && r.aTransform.ref.value.length >= o ? r.aTransform.ref.value : new Float32Array(o), u = 0; u < i; u++) Ee.toArray(a[u].conformation.operator.matrix, s, 16 * u);
  return I8(s, i, r);
}
var Xue = V.objectToOptions({ atomic: {}, spheres: {}, gaussians: {} }), SM = 5e8;
function jue(e, t, r) {
  r === void 0 && (r = SM);
  var n = function(u, c, l) {
    l === void 0 && (l = SM);
    var d = on.size(D(), u);
    D.ceil(d, d), d.sort(function(h, p) {
      return p - h;
    });
    var f = Math.floor(Math.cbrt(l) * Math.cbrt(l)), m = d[0] * d[1];
    return { area: m, areaCells: Math.ceil(m / (c * c)), maxAreaCells: f };
  }(e, t.resolution, r), a = n.area, i = n.areaCells, o = n.maxAreaCells, s = i > o ? Math.sqrt(a / o) : t.resolution;
  return k(k({}, t), { resolution: s });
}
var sS = { ignoreHydrogens: V.Boolean(!1, { description: "Whether or not to include hydrogen atoms in the surface calculation." }), traceOnly: V.Boolean(!1, { description: "Whether or not to only use trace atoms in the surface calculation." }), includeParent: V.Boolean(!1, { description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure." }) };
V.getDefaultValues(sS);
var Yue = D();
function Wue(e, t, r, n) {
  return D.squaredDistance(D.set(Yue, e, t, r), n);
}
function Zue(e, t, r, n) {
  var a, i, o = n.ignoreHydrogens, s = n.traceOnly, u = n.includeParent, c = u ? e.root.unitMap.get(t.id) : t, l = function(T) {
    switch (T.kind) {
      case 0:
        return T.model.atomicConformation;
      case 1:
        return T.model.coarseConformation.spheres;
      case 2:
        return T.model.coarseConformation.gaussians;
    }
  }(c), d = l.x, f = l.y, m = l.z, h = c.elements, p = t.boundary.sphere, g = p.center, v = p.radius, y = (v + 7) * (v + 7);
  if (o || s || u && c !== t) {
    for (var _ = [], S = [], b = 0, x = h.length; b < x; ++b) {
      var A = h[b];
      o && p_(c, A) || s && !rk(c, A) || u && Wue(d[A], f[A], m[A], g) > y || (_.push(A), S.push(b));
    }
    a = $e.ofSortedArray(_), i = S;
  } else a = h, i = lc(new Int32Array(a.length));
  u && c !== t && function(T, N, I) {
    for (var P = 0, O = N.length, F = 0, R = I.length; F < R; ++F) {
      var G = $e.indexOfInRange(N, I[F], P, O);
      G === -1 ? T[F] = -2 : (T[F] = G, P = G);
    }
  }(i, t.elements, a);
  var w = { indices: a, x: d, y: f, z: m, id: i }, C = t === c ? t.boundary : kp(w), M = lt.create(e, c);
  return { position: w, boundary: C, radius: function(T) {
    return M.element = T, r.size(M);
  } };
}
var tk = zp.H;
function p_(e, t) {
  return !Ke.isCoarse(e) && e.model.atomicHierarchy.derived.atom.atomicNumber[t] === tk;
}
function h_(e, t) {
  return e[t] === tk;
}
function rk(e, t) {
  if (Ke.isCoarse(e)) return !0;
  var r = e.model.atomicHierarchy.atoms.label_atom_id.value(t);
  return r === "CA" || r === "BB" || r === "P";
}
function Gh(e) {
  return V.MultiSelect(e, Xue, { description: "For which kinds of units/chains to show the representation visuals." });
}
var qo = { unitKinds: Gh(["atomic", "spheres"]), includeParent: V.Boolean(!1, { isHidden: !0 }) }, nk = k({}, Xt.Params), Que = k({}, Nu.Params), ak = k({}, Wi.Params), $ue = k({}, im.Params), ik = k({}, Ur.Params), ok = k({}, vs.Params), sk = k({}, ly.Params), uk = k({}, qd.Params);
function E3(e, t) {
  var r, n, a, i, o, s, u, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, h = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, v = e.processValues, y = e.dispose, _ = e.geometryUtils, S = _.updateValues, b = _.updateBoundingSphere, x = _.updateRenderableState, A = _.createPositionIterator, w = fc.create(), C = { loci: Tn, action: Et.None, status: -1 }, M = Object.assign({}, l), T = nu.createEmpty(), N = -1;
  function I(F) {
    if (w.createNew) {
      if (u = f(i), !F) throw new Error("expected geometry to be given");
      r = function(R, G, L, q, K, X) {
        var H = vi.getUtils(G), W = H.createValues, ee = H.createRenderableState, $ = W(G, N8(), L, q, K), te = ee(K);
        return g1(G.kind, $, te, X);
      }(0, F, u, a, n, t), c = A(F, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (w.updateTransform && ru((u = f(i)).instanceCount * u.groupCount, r.values), w.createGeometry) {
        if (!F) throw new Error("expected geometry to be given");
        U.updateIfChanged(r.values.drawCount, vi.getDrawCount(F)), U.updateIfChanged(r.values.uVertexCount, vi.getVertexCount(F));
      }
      (w.updateTransform || w.createGeometry) && (b(r.values, F || s), c = A(s, r.values)), w.updateSize && "uSize" in r.values && xl(u, a.size, r.values), w.updateColor && hs(u, c, a.color, r.values), S(r.values, n), x(r.state, n);
    }
    M = n, T = a, o = i, F && (s = F, N += 1);
  }
  function P(F, R, G) {
    return function(L) {
      return !!Vo(L) || !(!st.isLoci(L) || !st.areRootsEquivalent(L.structure, o)) || !!(et.is(L) && st.areRootsEquivalent(L.structure, o) && et.isWholeStructure(L));
    }(F) ? R(Fe.ofBounds(0, u.groupCount * u.instanceCount)) : h(F, o, R, G);
  }
  function O(F) {
    r && (v == null || v(r.values, s, M, T, F.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? r : void 0;
  }, get geometryVersion() {
    return N;
  }, createOrUpdate: function(F, R, G, L) {
    if (G === void 0 && (G = {}), function(K, X, H) {
      if (!H && !o) throw new Error("missing structure");
      if (n = Object.assign({}, M, X), a = K, i = H, fc.reset(w), !r || !o) return w.createNew = !0, void (w.createGeometry = !0);
      p(w, n, M, a, T, i, o), st.areEquivalent(i, o) || (w.createGeometry = !0), st.areHierarchiesEqual(i, o) || (w.updateTransform = !0, w.createGeometry = !0), fl.areEqual(K.color, T.color) || (w.updateColor = !0), Ud(n.unitKinds, M.unitKinds) || (w.createGeometry = !0), o.child !== i.child && (w.createGeometry = !0), w.updateSize && !("uSize" in r.values) && (w.createGeometry = !0), w.createGeometry && (w.updateColor = !0, w.updateSize = !0);
    }(R, G, L || o), w.createGeometry) {
      var q = d(F, i, a, n, s);
      if (m8(q)) return q.then(function(K) {
        I(K), O(F);
      });
      I(q);
    } else I();
    O(F);
  }, getLoci: function(F) {
    return r ? m(F, o, r.id) : Tn;
  }, mark: function(F, R) {
    return cr.mark(r, F, R, P, C);
  }, setVisibility: function(F) {
    cr.setVisibility(r, F);
  }, setAlphaFactor: function(F) {
    cr.setAlphaFactor(r, F);
  }, setPickable: function(F) {
    cr.setPickable(r, F);
  }, setColorOnly: function(F) {
    cr.setColorOnly(r, F);
  }, setTransform: function(F, R) {
    cr.setTransform(r, F, R);
  }, setOverpaint: function(F, R) {
    var G = { geometry: s, props: M, webgl: R };
    cr.setOverpaint(r, F, P, !0, G);
  }, setTransparency: function(F, R) {
    var G = { geometry: s, props: M, webgl: R };
    cr.setTransparency(r, F, P, !0, G);
  }, setSubstance: function(F, R) {
    var G = { geometry: s, props: M, webgl: R };
    cr.setSubstance(r, F, P, !0, G);
  }, setClipping: function(F) {
    cr.setClipping(r, F, P, !0);
  }, destroy: function() {
    y == null || y(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
var ck = k(k({}, nk), qo);
function lk(e, t) {
  return E3(k(k({}, e), { setUpdateState: function(r, n, a, i, o, s, u) {
    e.setUpdateState(r, n, a, i, o, s, u), go.areEqual(i.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Xt.Utils }), t);
}
var Jue = k(k({}, ak), qo), ece = k(k({}, ik), qo), tce = k(k({}, ok), qo);
function ji(e, t, r, n) {
  var a, i, o, s, u = 0, c = t.webgl, l = new pa(), d = Sl(), f = [], m = new fr.GeometryState(), h = ys.create(), p = /* @__PURE__ */ new Map(), g = nu.createEmpty();
  function v(y, _, S) {
    var b = S.visible, x = S.alphaFactor, A = S.pickable, w = S.overpaint, C = S.transparency, M = S.substance, T = S.clipping, N = S.transform, I = S.unitTransforms;
    b !== void 0 && y.setVisibility(b), x !== void 0 && y.setAlphaFactor(x), A !== void 0 && y.setPickable(A), w !== void 0 && y.setOverpaint(w, c), C !== void 0 && y.setTransparency(C, c), M !== void 0 && y.setSubstance(M, c), T !== void 0 && y.setClipping(T), N !== void 0 && y.setTransform(N), I !== void 0 && (I ? y.setTransform(void 0, I.getSymmetryGroupTransforms(_)) : y.setTransform(void 0, null));
  }
  return { label: e, get groupCount() {
    var y = 0;
    return p.forEach(function(_) {
      var S = _.visual;
      S.renderObject && (y += S.groupCount);
    }), y;
  }, get geometryVersion() {
    return m.version;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return h;
  }, get theme() {
    return g;
  }, renderObjects: f, updated: l, createOrUpdate: function(y, _) {
    var S = this;
    return y === void 0 && (y = {}), _ && _ !== a && (o = r(t, _), s || (s = V.getDefaultValues(o))), s = Object.assign({}, s, y), sr.create("Creating or updating UnitsRepresentation", function(b) {
      return Be(S, 0, void 0, function() {
        var x, A, w, C, M, T, N, I, P, O, F, R, G;
        return Te(this, function(L) {
          switch (L.label) {
            case 0:
              if (a || _) return [3, 1];
              throw new Error("missing structure");
            case 1:
              if (!_ || a) return [3, 8];
              i = _.unitSymmetryGroups, M = 0, L.label = 2;
            case 2:
              return M < i.length ? (P = i[M], I = n(d, _, s, c), (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 4]) : [3, 7];
            case 3:
              L.sent(), L.label = 4;
            case 4:
              return v(I, P, h), p.set(P.hashCode, { visual: I, group: P }), b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: i.length })] : [3, 6];
            case 5:
              L.sent(), L.label = 6;
            case 6:
              return M++, [3, 2];
            case 7:
              return [3, 43];
            case 8:
              if (!_ || st.areUnitIdsAndIndicesEqual(_, a) && _.child === a.child) return [3, 22];
              i = _.unitSymmetryGroups, x = p, p = /* @__PURE__ */ new Map(), M = 0, L.label = 9;
            case 9:
              return M < i.length ? (P = i[M], (w = x.get(P.hashCode)) ? (I = w.visual, !((F = I.mustRecreate) === null || F === void 0) && F.call(I, { group: P, structure: _ }, s, c) ? (I.destroy(), I = n(d, _, s, c), (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 11]) : [3, 12]) : [3, 15]) : [3, 21];
            case 10:
              L.sent(), L.label = 11;
            case 11:
              return v(I, P, h), [3, 14];
            case 12:
              return (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 14];
            case 13:
              L.sent(), L.label = 14;
            case 14:
              return p.set(P.hashCode, { visual: I, group: P }), x.delete(P.hashCode), I.renderObject && U6(A = I.renderObject.values.tMarker.ref.value.array, Fe.ofBounds(0, A.length), Et.RemoveHighlight), [3, 18];
            case 15:
              return I = n(d, _, s, c), (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 17];
            case 16:
              L.sent(), L.label = 17;
            case 17:
              v(I, P, h), p.set(P.hashCode, { visual: I, group: P }), L.label = 18;
            case 18:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: i.length })] : [3, 20];
            case 19:
              L.sent(), L.label = 20;
            case 20:
              return M++, [3, 9];
            case 21:
              return x.forEach(function(q) {
                q.visual.destroy();
              }), [3, 43];
            case 22:
              if (!_ || _ === a || !st.areUnitIdsAndIndicesEqual(_, a)) return [3, 34];
              i = _.unitSymmetryGroups, M = 0, L.label = 23;
            case 23:
              return M < i.length ? (P = i[M], (w = p.get(P.hashCode)) ? (I = w.visual, !((R = I.mustRecreate) === null || R === void 0) && R.call(I, { group: P, structure: _ }, s, t.webgl) ? (I.destroy(), I = n(d, _, s, t.webgl), w.visual = I, (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 25]) : [3, 26]) : [3, 29]) : [3, 33];
            case 24:
              L.sent(), L.label = 25;
            case 25:
              return v(I, P, h), [3, 28];
            case 26:
              return (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: _ })) ? [4, O] : [3, 28];
            case 27:
              L.sent(), L.label = 28;
            case 28:
              return w.group = P, [3, 30];
            case 29:
              throw new Error("expected to find visual for hashCode ".concat(P.hashCode));
            case 30:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: i.length })] : [3, 32];
            case 31:
              L.sent(), L.label = 32;
            case 32:
              return M++, [3, 23];
            case 33:
              return [3, 43];
            case 34:
              C = [], p.forEach(function(q) {
                return C.push(q);
              }), M = 0, T = C.length, L.label = 35;
            case 35:
              return M < T ? (N = C[M], I = N.visual, P = N.group, !((G = I.mustRecreate) === null || G === void 0) && G.call(I, { group: P, structure: a }, s, t.webgl) ? (I.destroy(), I = n(d, a, s, c), C[M].visual = I, (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s, { group: P, structure: a })) ? [4, O] : [3, 37]) : [3, 38]) : [3, 43];
            case 36:
              L.sent(), L.label = 37;
            case 37:
              return v(I, P, h), [3, 40];
            case 38:
              return (O = I.createOrUpdate({ webgl: c, runtime: b }, g, s)) ? [4, O] : [3, 40];
            case 39:
              L.sent(), L.label = 40;
            case 40:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: T })] : [3, 42];
            case 41:
              L.sent(), L.label = 42;
            case 42:
              return ++M, [3, 35];
            case 43:
              return f.length = 0, p.forEach(function(q) {
                var K = q.visual;
                K.renderObject && (f.push(K.renderObject), m.add(K.renderObject.id, K.geometryVersion));
              }), m.snapshot(), _ && (a = _), l.next(u++), [2];
          }
        });
      });
    });
  }, setState: function(y) {
    var _ = y.visible, S = y.alphaFactor, b = y.pickable, x = y.overpaint, A = y.transparency, w = y.substance, C = y.clipping, M = y.transform, T = y.unitTransforms, N = y.syncManually, I = y.markerActions, P = {};
    _ !== h.visible && (P.visible = _), S !== h.alphaFactor && (P.alphaFactor = S), b !== h.pickable && (P.pickable = b), x !== void 0 && a && (P.overpaint = mh.remap(x, a)), A !== void 0 && a && (P.transparency = ph.remap(A, a)), w !== void 0 && a && (P.substance = vh.remap(w, a)), C !== void 0 && a && (P.clipping = hh.remap(C, a)), M === void 0 || Ee.areEqual(M, h.transform, Cn) || (P.transform = M), T === h.unitTransforms && (T == null ? void 0 : T.version) === y.unitTransformsVersion || (P.unitTransforms = T, h.unitTransformsVersion = T ? T == null ? void 0 : T.version : -1), N !== h.syncManually && (P.syncManually = N), I !== h.markerActions && (P.markerActions = I), p.forEach(function(O) {
      return v(O.visual, O.group, P);
    }), ys.update(h, P);
  }, setTheme: function(y) {
    g = y;
  }, getLoci: function(y) {
    if (y === void 0) return st.Loci(a.target);
    var _ = Tn;
    return p.forEach(function(S) {
      var b = S.visual.getLoci(y);
      Ld(b) || (_ = b);
    }), _;
  }, mark: function(y, _) {
    if (!a || !qr.is(h.markerActions, _)) return !1;
    if (st.isLoci(y) || et.is(y) || Pt.isLoci(y)) {
      if (!st.areRootsEquivalent(y.structure, a)) return !1;
      y = an.remap(y, a), (st.isLoci(y) || et.is(y) && et.isWholeStructure(y)) && (y = k8);
    } else if (!Vo(y) && !Z0(y)) return !1;
    if (an.isEmpty(y)) return !1;
    var S = !1;
    return p.forEach(function(b) {
      var x = b.visual;
      S = x.mark(y, _) || S;
    }), S;
  }, destroy: function() {
    p.forEach(function(y) {
      return y.visual.destroy();
    }), p.clear();
  } };
}
function Vh(e, t) {
  var r, n, a, i, o, s, u, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, h = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, v = e.processValues, y = e.dispose, _ = e.geometryUtils, S = _.createEmpty, b = _.updateValues, x = _.updateBoundingSphere, A = _.updateRenderableState, w = _.createPositionIterator, C = fc.create(), M = { loci: Tn, action: Et.None, status: -1 }, T = Object.assign({}, l), N = nu.createEmpty(), I = -1;
  function P(G) {
    if (C.createNew) {
      if (u = f(n), !G) throw new Error("expected geometry to be given");
      r = function(L, q, K, X, H, W) {
        var ee = vi.getUtils(q), $ = ee.createValues, te = ee.createRenderableState, re = $(q, _M(L, H.includeParent), K, X, H), ie = te(H);
        return g1(q.kind, re, ie, W);
      }(n, G, u, N, T, t), c = w(G, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (C.updateTransform && ru((u = f(n)).instanceCount * u.groupCount, r.values), C.updateMatrix && _M(n, T.includeParent, r.values), C.createGeometry) {
        if (!G) throw new Error("expected geometry to be given");
        U.updateIfChanged(r.values.drawCount, vi.getDrawCount(G)), U.updateIfChanged(r.values.uVertexCount, vi.getVertexCount(G));
      }
      (C.updateTransform || C.createGeometry) && (x(r.values, G || s), c = w(G || s, r.values)), C.updateSize && "uSize" in r.values && xl(u, N.size, r.values), C.updateColor && hs(u, c, N.color, r.values), b(r.values, T), A(r.state, T);
    }
    a = T, i = N, o = n, G && (s = G, I += 1);
  }
  function O(G, L, q, K, X, H) {
    return function(W, ee) {
      for (var $ = 0, te = W.length; $ < te; ++$)
        if (Ke.isAtomic(ee) && W[$] === "atomic" || Ke.isSpheres(ee) && W[$] === "spheres" || Ke.isGaussians(ee) && W[$] === "gaussians") return !0;
      return !1;
    }(X.unitKinds, L) ? d(G, L, q, K, X, H) : S(H);
  }
  function F(G, L, q) {
    return function(K) {
      return !!Vo(K) || !(!st.isLoci(K) || !st.areRootsEquivalent(K.structure, o.structure)) || !!(et.is(K) && st.areRootsEquivalent(K.structure, o.structure) && et.isWholeStructure(K));
    }(G) ? L(Fe.ofBounds(0, u.groupCount * u.instanceCount)) : h(G, o, L, q);
  }
  function R(G) {
    r && (v == null || v(r.values, s, a, i, G.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? r : void 0;
  }, get geometryVersion() {
    return I;
  }, createOrUpdate: function(G, L, q, K) {
    if (function(H, W, ee) {
      if (!ee && !o) throw new Error("missing structureGroup");
      if (T = W, N = H, n = ee, fc.reset(C), !r || !o) return C.createNew = !0, void (C.createGeometry = !0);
      p(C, T, a, N, i, n, o), st.areHierarchiesEqual(o.structure, n.structure) || (C.updateTransform = !0, C.updateColor = !0, C.updateSize = !0), fl.areEqual(N.color, i.color) || (C.updateColor = !0), o.structure.child !== n.structure.child && (C.createGeometry = !0), Ud(T.unitKinds, a.unitKinds) || (C.createGeometry = !0), n.group.transformHash !== o.group.transformHash && (n.group.units.length !== o.group.units.length || C.updateColor ? C.updateTransform = !0 : C.updateMatrix = !0);
      var $ = n.group.units[0], te = o.group.units[0];
      Ke.areOperatorsEqual($, te) || (C.updateTransform = !0), Ke.areConformationsEqual($, te) || (C.createGeometry = !0), C.updateTransform && (C.updateMatrix = !0), C.updateSize && !("uSize" in r.values) && (C.createGeometry = !0), (C.createGeometry || C.updateTransform) && (o.structure.hashCode !== n.structure.hashCode && (C.updateColor = !0, C.updateSize = !0), (N.color.granularity.startsWith("vertex") || r.values.dColorType.ref.value.startsWith("vertex") || N.color.granularity.startsWith("volume") || r.values.dColorType.ref.value.startsWith("volume")) && (C.updateColor = !0));
    }(L, q, K || o), C.createGeometry) {
      var X = O(G, n.group.units[0], n.structure, N, T, s);
      if (m8(X)) return X.then(function(H) {
        P(H), R(G);
      });
      P(X);
    } else P();
    R(G);
  }, getLoci: function(G) {
    return r ? m(G, o, r.id) : Tn;
  }, mark: function(G, L) {
    var q = !0;
    if (et.is(G)) {
      q = !1;
      for (var K = o.group.units[0].invariantId, X = 0, H = G.elements; X < H.length; X++)
        if (H[X].unit.invariantId === K) {
          q = !0;
          break;
        }
    }
    return !!q && cr.mark(r, G, L, F, M);
  }, setVisibility: function(G) {
    cr.setVisibility(r, G);
  }, setAlphaFactor: function(G) {
    cr.setAlphaFactor(r, G);
  }, setPickable: function(G) {
    cr.setPickable(r, G);
  }, setColorOnly: function(G) {
    cr.setColorOnly(r, G);
  }, setTransform: function(G, L) {
    cr.setTransform(r, G, L);
  }, setOverpaint: function(G, L) {
    var q = { geometry: s, props: a, webgl: L };
    cr.setOverpaint(r, G, F, !0, q);
  }, setTransparency: function(G, L) {
    var q = { geometry: s, props: a, webgl: L };
    cr.setTransparency(r, G, F, !0, q);
  }, setSubstance: function(G, L) {
    var q = { geometry: s, props: a, webgl: L };
    cr.setSubstance(r, G, F, !0, q);
  }, setClipping: function(G) {
    cr.setClipping(r, G, F, !0);
  }, destroy: function() {
    y == null || y(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
k(k({}, sk), qo), k(k({}, uk), qo);
var Al = k(k({}, nk), qo);
function wl(e, t) {
  return Vh(k(k({}, e), { setUpdateState: function(r, n, a, i, o, s, u) {
    e.setUpdateState(r, n, a, i, o, s, u), go.areEqual(i.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Xt.Utils }), t);
}
var rce = k(k({}, Que), qo), nce = k(k({}, ak), qo), ace = k(k({}, $ue), qo), uS = k(k({}, ik), qo);
function cS(e, t) {
  return Vh(k(k({}, e), { setUpdateState: function(r, n, a, i, o, s, u) {
    e.setUpdateState(r, n, a, i, o, s, u), go.areEqual(i.size, o.size) || (r.updateSize = !0);
  }, geometryUtils: Ur.Utils }), t);
}
k(k({}, ok), qo), k(k({}, sk), qo), k(k({}, uk), qo);
var ys = { create: function() {
  return k(k({}, fr.createState()), { unitTransforms: null, unitTransformsVersion: -1 });
}, update: function(e, t) {
  fr.updateState(e, t), t.unitTransforms !== void 0 && (e.unitTransforms = t.unitTransforms);
} };
function dk(e, t) {
  return { centerA: lt.create(e, t), centerB: lt.create(e, t) };
}
var ice = function() {
  function e(t, r) {
    this.unit = r, this.hasNext = !1, this.traceElementIndex = r.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = cn.transientSegments(vk(r), r.elements), this.value = dk(t, r), this.hasNext = this.gapIt.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.unit, r = t.elements, n = t.residueIndex, a = this.gapIt.move();
    return this.value.centerA.element = this.traceElementIndex[n[r[a.start]]], this.value.centerB.element = this.traceElementIndex[n[r[a.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
  }, e;
}(), oce = function() {
  function e(t, r) {
    this.unit = r, this.hasNext = !1, this.gapIt = cn.transientSegments(vk(r), r.elements), this.value = dk(t, r), this.hasNext = this.gapIt.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.gapIt.move();
    return this.value.centerA.element = this.unit.elements[t.start], this.value.centerB.element = this.unit.elements[t.end - 1], this.hasNext = this.gapIt.hasNext, this.value;
  }, e;
}();
function sce(e) {
  for (var t = e.atomicConformation, r = t.x, n = t.y, a = t.z, i = e.atomicHierarchy.derived.residue, o = i.polymerType, s = i.traceElementIndex, u = o.length, c = We.ofBounds(0, e.atomicConformation.atomId.rowCount), l = cn.transientSegments(e.atomicRanges.polymerRanges, c), d = nr.transientSegments(e.atomicHierarchy.residueAtomSegments, c), f = new Float32Array(3 * u), m = new Float32Array(3 * u), h = 0, p = -1, g = -1, v = D(), y = D(), _ = D(), S = D(), b = D(), x = D(), A = D(), w = D(), C = D(), M = D(), T = D(), N = D(), I = D(), P = D(); l.hasNext; ) {
    var O = l.move();
    for (d.setSegment(O), h = -1, g = -1; d.hasNext; ) {
      h += 1;
      var F = d.move().index;
      h === 0 && (g = F);
      var R = 3 * (p = F - 2);
      D.copy(v, y), D.copy(y, _), D.copy(_, S);
      var G = s[F];
      if (D.set(S, r[G], n[G], a[G]), !(h < 3)) {
        D.sub(b, y, v), D.sub(x, _, y), D.sub(A, S, _), D.sub(T, b, x), D.sub(N, x, A), D.cross(I, T, N), D.normalize(I, I), D.toArray(I, m, R);
        var L = Math.cos(D.angle(T, N)), q = D.magnitude(T), K = D.magnitude(N), X = Math.sqrt(K * q) / Math.max(2, 2 * (1 - L));
        D.scale(w, T, X / q), D.sub(w, y, w), D.toArray(w, f, R), D.scale(C, N, X / K), D.sub(C, _, C), D.toArray(C, f, R + 3), D.copy(P, I);
      }
    }
    var H = 3 * g;
    D.fromArray(w, f, H + 3), D.fromArray(C, f, H + 6), D.normalize(I, D.sub(I, w, C));
    var W = s[g];
    D.set(v, r[W], n[W], a[W]), D.copy(M, v), D.projectPointOnVector(M, M, I, w), D.toArray(M, f, H);
    var ee = p + 2, $ = 3 * ee;
    D.fromArray(w, f, $ - 3), D.fromArray(C, f, $ - 6), D.normalize(I, D.sub(I, w, C));
    var te = s[ee];
    D.set(v, r[te], n[te], a[te]), D.copy(M, v), D.projectPointOnVector(M, M, I, w), D.toArray(M, f, $);
  }
  return { centers: f };
}
var v_ = Dp.createProvider({ label: "Helix Orientation", descriptor: Tu({ name: "molstar_helix_orientation" }), type: "dynamic", defaultParams: {}, getParams: function() {
  return {};
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t) {
  return Be(void 0, 0, void 0, function() {
    return Te(this, function(r) {
      return [2, { value: sce(t) }];
    });
  });
} });
function mu(e) {
  return Er.is(e, 2);
}
function fk(e, t, r) {
  switch (r === void 0 && (r = {}), e.kind) {
    case 0:
      return new uce(e, t, r);
    case 1:
    case 2:
      return new cce(e, t);
  }
}
var P2 = Er.create(536870912);
function mk(e, t) {
  return { center: lt.create(e, t), centerPrev: lt.create(e, t), centerNext: lt.create(e, t), first: !1, last: !1, initial: !1, final: !1, secStrucFirst: !1, secStrucLast: !1, secStrucType: P2, moleculeType: 0, coarseBackboneFirst: !1, coarseBackboneLast: !1, isCoarseBackbone: !1, p0: D(), p1: D(), p2: D(), p3: D(), p4: D(), d12: D(), d23: D() };
}
var kt = D(), Ig = D(), Tg = D(), uce = function() {
  function e(t, r, n) {
    var a;
    if (n === void 0 && (n = {}), this.unit = t, this.state = 0, this.p0 = D(), this.p1 = D(), this.p2 = D(), this.p3 = D(), this.p4 = D(), this.p5 = D(), this.p6 = D(), this.d01 = D(), this.d12 = D(), this.d23 = D(), this.d34 = D(), this.hasNext = !1, this.atomicConformation = t.model.atomicConformation, this.residueAtomSegments = t.model.atomicHierarchy.residueAtomSegments, this.polymerRanges = t.model.atomicRanges.polymerRanges, this.traceElementIndex = t.model.atomicHierarchy.derived.residue.traceElementIndex, this.directionFromElementIndex = t.model.atomicHierarchy.derived.residue.directionFromElementIndex, this.directionToElementIndex = t.model.atomicHierarchy.derived.residue.directionToElementIndex, this.moleculeType = t.model.atomicHierarchy.derived.residue.moleculeType, this.cyclicPolymerMap = t.model.atomicRanges.cyclicPolymerMap, this.polymerIt = cn.transientSegments(this.polymerRanges, t.elements), this.residueIt = nr.transientSegments(this.residueAtomSegments, t.elements), this.value = mk(r, t), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, n.ignoreSecondaryStructure || (this.secondaryStructure = (a = Oi.get(r).value) === null || a === void 0 ? void 0 : a.get(t.invariantId)), n.useHelixOrientation) {
      var i = v_.get(t.model).value;
      if (!i) throw new Error("missing helix-orientation");
      this.helixOrientationCenters = i.centers;
    }
  }
  return e.prototype.atomicPos = function(t, r) {
    r !== -1 && (t[0] = this.atomicConformation.x[r], t[1] = this.atomicConformation.y[r], t[2] = this.atomicConformation.z[r]);
  }, e.prototype.pos = function(t, r, n) {
    var a = this.traceElementIndex[r];
    this.helixOrientationCenters && mu(n) ? D.fromArray(t, this.helixOrientationCenters, 3 * r) : this.atomicPos(t, a);
  }, e.prototype.updateResidueSegmentRange = function(t) {
    var r = this.residueAtomSegments.index;
    this.residueSegmentMin = r[this.polymerRanges[2 * t.index]], this.residueSegmentMax = r[this.polymerRanges[2 * t.index + 1]];
  }, e.prototype.getResidueIndex = function(t) {
    if (t < this.residueSegmentMin) t = (r = this.cyclicPolymerMap.get(this.residueSegmentMin)) !== void 0 ? r - (this.residueSegmentMin - t - 1) : this.residueSegmentMin;
    else if (t > this.residueSegmentMax) {
      var r;
      t = (r = this.cyclicPolymerMap.get(this.residueSegmentMax)) !== void 0 ? r + (t - this.residueSegmentMax - 1) : this.residueSegmentMax;
    }
    return t;
  }, e.prototype.getSecStruc = function(t) {
    if (this.secondaryStructure) {
      var r = this.secondaryStructure, n = r.type[(0, r.getIndex)(t)];
      return mu(n) ? 2 : n;
    }
    return P2;
  }, e.prototype.setControlPoint = function(t, r, n, a, i) {
    (function(o) {
      return Er.is(o, 4);
    })(i) || this.helixOrientationCenters && mu(i) ? D.scale(t, D.add(t, r, D.add(t, a, D.add(t, n, n))), 1 / 4) : D.copy(t, n);
  }, e.prototype.setFromToVector = function(t, r, n) {
    this.value.isCoarseBackbone || this.helixOrientationCenters && mu(n) ? D.set(t, 1, 0, 0) : (this.atomicPos(Ig, this.directionFromElementIndex[r]), this.atomicPos(Tg, this.directionToElementIndex[r]), D.sub(t, Tg, Ig));
  }, e.prototype.setDirection = function(t, r, n, a) {
    D.matchDirection(Ig, r, n), D.matchDirection(Tg, a, n), D.scale(t, D.add(t, Ig, D.add(t, Tg, D.add(t, n, n))), 1 / 4);
  }, e.prototype.move = function() {
    var t = this, r = t.residueIt, n = t.polymerIt, a = t.value;
    if (this.state === 0) {
      for (; n.hasNext; ) if (this.polymerSegment = n.move(), r.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), r.hasNext) {
        this.state = 1;
        var i = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], o = this.getResidueIndex(i - 1);
        this.currSecStrucType = i === o ? P2 : this.getSecStruc(o), this.nextSecStrucType = this.getSecStruc(i), this.currCoarseBackbone = this.directionFromElementIndex[o] === -1 || this.directionToElementIndex[o] === -1, this.nextCoarseBackbone = this.directionFromElementIndex[i] === -1 || this.directionToElementIndex[i] === -1;
        break;
      }
    }
    if (this.state === 1) {
      var s = r.move().index, u = this.getResidueIndex(s - 3), c = this.getResidueIndex(s - 2), l = this.getResidueIndex(s - 1), d = this.getResidueIndex(s + 1), f = this.getResidueIndex(s + 2), m = this.getResidueIndex(s + 3);
      this.prevSecStrucType = this.currSecStrucType, this.currSecStrucType = this.nextSecStrucType, this.nextSecStrucType = s === d ? P2 : this.getSecStruc(d), this.prevCoarseBackbone = this.currCoarseBackbone, this.currCoarseBackbone = this.nextCoarseBackbone, this.nextCoarseBackbone = this.directionFromElementIndex[d] === -1 || this.directionToElementIndex[d] === -1, a.secStrucType = this.currSecStrucType, a.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType, a.secStrucLast = this.currSecStrucType !== this.nextSecStrucType, a.isCoarseBackbone = this.currCoarseBackbone, a.coarseBackboneFirst = this.prevCoarseBackbone !== this.currCoarseBackbone, a.coarseBackboneLast = this.currCoarseBackbone !== this.nextCoarseBackbone, a.first = s === this.residueSegmentMin, a.last = s === this.residueSegmentMax, a.moleculeType = this.moleculeType[s], a.initial = s === l, a.final = s === d, a.centerPrev.element = this.traceElementIndex[l], a.center.element = this.traceElementIndex[s], a.centerNext.element = this.traceElementIndex[d];
      var h = this.getSecStruc(u), p = this.getSecStruc(c), g = this.getSecStruc(l), v = this.getSecStruc(s), y = this.getSecStruc(d), _ = this.getSecStruc(f), S = this.getSecStruc(m);
      this.pos(this.p0, u, h), this.pos(this.p1, c, p), this.pos(this.p2, l, g), this.pos(this.p3, s, v), this.pos(this.p4, d, y), this.pos(this.p5, f, _), this.pos(this.p6, m, S);
      var b = mu(h), x = mu(p), A = mu(g), w = mu(v), C = mu(y), M = mu(_), T = mu(S);
      this.helixOrientationCenters && (w !== A ? w ? (D.copy(this.p0, this.p3), D.copy(this.p1, this.p3), D.copy(this.p2, this.p3)) : A && (D.scale(kt, D.sub(kt, this.p2, this.p3), 2), D.add(this.p2, this.p3, kt), D.add(this.p1, this.p2, kt), D.add(this.p0, this.p1, kt)) : w !== x ? w ? (D.copy(this.p0, this.p2), D.copy(this.p1, this.p2)) : x && (D.scale(kt, D.sub(kt, this.p1, this.p2), 2), D.add(this.p1, this.p2, kt), D.add(this.p0, this.p1, kt)) : w !== b && (w ? D.copy(this.p0, this.p1) : b && (D.scale(kt, D.sub(kt, this.p0, this.p1), 2), D.add(this.p0, this.p1, kt))), w !== C ? w ? (D.copy(this.p4, this.p3), D.copy(this.p5, this.p3), D.copy(this.p6, this.p3)) : C && (D.scale(kt, D.sub(kt, this.p4, this.p3), 2), D.add(this.p4, this.p3, kt), D.add(this.p5, this.p4, kt), D.add(this.p6, this.p5, kt)) : w !== M ? w ? (D.copy(this.p5, this.p4), D.copy(this.p6, this.p4)) : M && (D.scale(kt, D.sub(kt, this.p5, this.p4), 2), D.add(this.p5, this.p4, kt), D.add(this.p6, this.p5, kt)) : w !== T && (w ? D.copy(this.p6, this.p5) : T && (D.scale(kt, D.sub(kt, this.p6, this.p5), 2), D.add(this.p6, this.p5, kt)))), this.setFromToVector(this.d01, l, g), this.setFromToVector(this.d12, s, v), this.setFromToVector(this.d23, d, y), this.setFromToVector(this.d34, f, _);
      var N = w && this.helixOrientationCenters, I = 1.5;
      s === l || v !== g && N ? (D.setMagnitude(kt, D.sub(kt, this.p3, this.p4), I), D.add(this.p2, this.p3, kt), D.add(this.p1, this.p2, kt), D.add(this.p0, this.p1, kt)) : l === c || v !== p && N ? (D.setMagnitude(kt, D.sub(kt, this.p2, this.p3), I), D.add(this.p1, this.p2, kt), D.add(this.p0, this.p1, kt)) : (c === u || v !== h && N) && (D.setMagnitude(kt, D.sub(kt, this.p1, this.p2), I), D.add(this.p0, this.p1, kt)), s === d || v !== y && N ? (D.setMagnitude(kt, D.sub(kt, this.p3, this.p2), I), D.add(this.p4, this.p3, kt), D.add(this.p5, this.p4, kt), D.add(this.p6, this.p5, kt)) : d === f || v !== _ && N ? (D.setMagnitude(kt, D.sub(kt, this.p4, this.p3), I), D.add(this.p5, this.p4, kt), D.add(this.p6, this.p5, kt)) : (f === m || v !== S && N) && (D.setMagnitude(kt, D.sub(kt, this.p5, this.p4), I), D.add(this.p6, this.p5, kt)), this.setControlPoint(a.p0, this.p0, this.p1, this.p2, p), this.setControlPoint(a.p1, this.p1, this.p2, this.p3, g), this.setControlPoint(a.p2, this.p2, this.p3, this.p4, v), this.setControlPoint(a.p3, this.p3, this.p4, this.p5, y), this.setControlPoint(a.p4, this.p4, this.p5, this.p6, _), this.setDirection(a.d12, this.d01, this.d12, this.d23), this.setDirection(a.d23, this.d12, this.d23, this.d34), r.hasNext || (this.state = 0);
    }
    return this.hasNext = r.hasNext || n.hasNext, this.value;
  }, e;
}(), cce = function() {
  function e(t, r) {
    switch (this.unit = t, this.state = 0, this.hasNext = !1, this.polymerIt = cn.transientSegments(function(n) {
      switch (n.kind) {
        case 0:
          return n.model.atomicRanges.polymerRanges;
        case 1:
          return n.model.coarseHierarchy.spheres.polymerRanges;
        case 2:
          return n.model.coarseHierarchy.gaussians.polymerRanges;
      }
    }(t), t.elements), this.value = mk(r, t), D.set(this.value.d12, 1, 0, 0), D.set(this.value.d23, 1, 0, 0), t.kind) {
      case 1:
        this.conformation = t.model.coarseConformation.spheres;
        break;
      case 2:
        this.conformation = t.model.coarseConformation.gaussians;
    }
    this.hasNext = this.polymerIt.hasNext;
  }
  return e.prototype.getElementIndex = function(t) {
    return Math.min(Math.max(this.polymerSegment.start, t), this.polymerSegment.end - 1);
  }, e.prototype.pos = function(t, r) {
    var n = this.unit.elements[r];
    t[0] = this.conformation.x[n], t[1] = this.conformation.y[n], t[2] = this.conformation.z[n];
  }, e.prototype.move = function() {
    if (this.state === 0) {
      for (; this.polymerIt.hasNext; ) if (this.polymerSegment = this.polymerIt.move(), this.elementIndex = this.polymerSegment.start, this.elementIndex < this.polymerSegment.end) {
        this.state = 1;
        break;
      }
    }
    if (this.state === 1) {
      var t = this.getElementIndex(this.elementIndex - 2), r = this.getElementIndex(this.elementIndex - 1), n = this.getElementIndex(this.elementIndex + 1), a = this.getElementIndex(this.elementIndex + 2);
      this.value.centerPrev.element = this.value.center.unit.elements[r], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[n], this.pos(this.value.p0, t), this.pos(this.value.p1, r), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, n), this.pos(this.value.p4, a);
      var i = 0.5;
      this.elementIndex === r ? (D.scale(kt, D.sub(kt, this.value.p2, this.value.p3), i), D.add(this.value.p1, this.value.p2, kt), D.add(this.value.p0, this.value.p1, kt)) : r === t && (D.scale(kt, D.sub(kt, this.value.p1, this.value.p2), i), D.add(this.value.p0, this.value.p1, kt)), this.elementIndex === n ? (D.scale(kt, D.sub(kt, this.value.p2, this.value.p1), i), D.add(this.value.p3, this.value.p2, kt), D.add(this.value.p4, this.value.p3, kt)) : n === a && (D.scale(kt, D.sub(kt, this.value.p3, this.value.p2), i), D.add(this.value.p4, this.value.p3, kt)), this.value.first = this.elementIndex === this.polymerSegment.start, this.value.last = this.elementIndex === this.polymerSegment.end - 1, this.elementIndex + 1 >= this.polymerSegment.end && (this.state = 0);
    }
    return this.hasNext = this.elementIndex + 1 < this.polymerSegment.end || this.polymerIt.hasNext, this.elementIndex += 1, this.value;
  }, e;
}(), Sf = D.fromArray, tp = D.toArray, Kx = D.normalize, lce = D.sub, rp = D.spline, dce = D.slerp, AM = D.copy, wM = D.cross, Xx = D.orthogonalize, fce = D.matchDirection, mce = D.scale, CM = D.add;
function pk(e) {
  var t = e + 1, r = 3 * t;
  return { curvePoints: new Float32Array(r), tangentVectors: new Float32Array(r), normalVectors: new Float32Array(r), binormalVectors: new Float32Array(r), widthValues: new Float32Array(t), heightValues: new Float32Array(t), linearSegments: e };
}
function hk(e, t, r, n) {
  (function(a, i, o, s) {
    for (var u = a.curvePoints, c = a.tangentVectors, l = a.linearSegments, d = i.p0, f = i.p1, m = i.p2, h = i.p3, p = i.p4, g = i.secStrucFirst, v = i.secStrucLast, y = 1 - s, _ = g ? 0.5 : o, S = v ? 0.5 : o, b = 0; b <= l; ++b) {
      var x = 1 * b / l;
      if (x < y) {
        var A = Na(_, o, x);
        rp(Wx, d, f, m, h, x + s, A), rp(jx, d, f, m, h, x + s + 0.01, _), rp(Yx, d, f, m, h, x + s - 0.01, _);
      } else
        A = Na(o, S, x), rp(Wx, f, m, h, p, x - y, A), rp(jx, f, m, h, p, x - y + 0.01, A), rp(Yx, f, m, h, p, x - y - 0.01, A);
      tp(Wx, u, 3 * b), Kx(Wl, lce(Wl, jx, Yx)), tp(Wl, c, 3 * b);
    }
  })(e, t, r, n), function(a, i) {
    var o = a.curvePoints, s = a.tangentVectors, u = a.normalVectors, c = a.binormalVectors, l = i.d12, d = i.d23, f = o.length / 3;
    Sf(DM, s, 0), Sf(MM, s, 3 * (f - 1)), Xx(Zx, DM, l), Xx(Ng, MM, d), fce(Ng, Ng, Zx), AM(o0, Zx);
    for (var m = f - 1, h = 0; h < f; ++h) {
      var p = MO(0, m, h) * m, g = h === 0 ? 0 : 1 / (f - p);
      Sf(Wl, s, 3 * h), Xx(pu, Wl, dce(pce, o0, Ng, g)), tp(pu, u, 3 * h), AM(o0, pu), Kx(np, wM(np, Wl, pu)), tp(np, c, 3 * h);
    }
    for (h = 1; h < m; ++h) Sf(o0, u, 3 * (h - 1)), Sf(pu, u, 3 * h), Sf(EM, u, 3 * (h + 1)), mce(pu, CM(pu, o0, CM(pu, EM, pu)), 1 / 3), tp(pu, u, 3 * h), Sf(Wl, s, 3 * h), Kx(np, wM(np, Wl, pu)), tp(np, c, 3 * h);
  }(e, t);
}
var jx = D(), Yx = D(), Wx = D(), pce = D(), Wl = D(), pu = D(), np = D(), o0 = D(), EM = D(), DM = D(), MM = D(), Zx = D(), Ng = D();
function IM(e, t, r, n, a, i, o, s) {
  for (var u = e.widthValues, c = e.heightValues, l = e.linearSegments, d = 1 - s, f = 0; f <= l; ++f) {
    var m = 1 * f / l;
    m < d ? (u[f] = Na(t, r, m + s), c[f] = Na(a, i, m + s)) : (u[f] = Na(r, n, m - d), c[f] = Na(i, o, m - d));
  }
}
var Iy, g_, Ty, hce = 0.5, vce = 0.9, gce = 0.5, yce = 0.3, TM = 2;
function vk(e) {
  switch (e.kind) {
    case 0:
      return e.model.atomicRanges.gapRanges;
    case 1:
      return e.model.coarseHierarchy.spheres.gapRanges;
    case 2:
      return e.model.coarseHierarchy.gaussians.gapRanges;
  }
}
function gk(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group.units[a];
    if (Ke.isAtomic(s)) return ek(o, s, s.polymerElements[i]);
    var u = s.elements, c = s.polymerElements[i], l = We.indexOf(u, c);
    if (l !== -1) return et(o, [{ unit: s, indices: We.ofSingleton(l) }]);
  }
  return Tn;
}
function NM(e, t, r, n, a, i) {
  for (var o = -1, s = -1, u = a; u <= i; u++)
    if (!((l = r[u]) < 0) && (o = We.indexOf(t, l)) >= 0) {
      s = u;
      break;
    }
  if (o < 0) return !1;
  var c = o;
  for (u = i; u > s; u--) {
    var l;
    if (!((l = r[u]) < 0)) {
      var d = We.indexOf(t, l);
      if (d >= 0) {
        c = d;
        break;
      }
    }
  }
  return n(Fe.ofRange(e + o, e + c));
}
function yk(e, t, r, n, a) {
  var i = !1, o = a.unit.elements, s = a.unit.model.atomicHierarchy.derived.residue.traceElementIndex, u = a.unit.model.atomicHierarchy.residueAtomSegments.index, c = r(a.unit);
  if (Fe.is(a.indices)) i = Fe.start(a.indices) === 0 && Fe.end(a.indices) === a.unit.elements.length ? n(Fe.ofBounds(e, e + t)) || i : NM(e, c, s, n, m = u[o[Fe.min(a.indices)]], h = u[o[Fe.max(a.indices)]]) || i;
  else for (var l = a.indices, d = 0, f = l.length; d < f; d++) {
    for (var m, h = m = u[o[l[d]]], p = d + 1; p < f; ) {
      var g = u[o[l[p]]];
      if (g - h > 1) break;
      h = g, p++;
    }
    d = p - 1, i = NM(e, c, s, n, m, h) || i;
  }
  return i;
}
function bce(e) {
  return e.polymerElements;
}
function bk(e, t, r) {
  var n = !1;
  if (!et.is(e)) return !1;
  var a = t.structure, i = t.group;
  if (!st.areEquivalent(e.structure, a)) return !1;
  for (var o = i.units[0].polymerElements.length, s = 0, u = e.elements; s < u.length; s++) {
    var c = u[s];
    if (i.unitIndexMap.has(c.unit.id)) {
      var l = i.unitIndexMap.get(c.unit.id) * o;
      if (Ke.isAtomic(c.unit)) n = yk(l, o, bce, r, c) || n;
      else if (Fe.is(c.indices)) {
        var d = l + Fe.start(c.indices), f = l + Fe.end(c.indices);
        n = r(Fe.ofBounds(d, f)) || n;
      } else for (var m = 0, h = c.indices.length; m < h; m++) {
        d = c.indices[m];
        for (var p = m + 1; p < h && c.indices[p] === d; ) p++;
        m = p - 1, f = c.indices[m], n = r(Fe.ofRange(l + d, l + f)) || n;
      }
    }
  }
  return n;
}
function xce(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group.units[a], u = We.indexOf(s.elements, s.gapElements[i]), c = We.indexOf(s.elements, s.gapElements[i % 2 ? i - 1 : i + 1]);
    if (u !== -1 && c !== -1) return Pt.Loci(o, [Pt.Location(o, s, u, o, s, c), Pt.Location(o, s, c, o, s, u)]);
  }
  return Tn;
}
function _ce(e, t, r) {
  var n = !1;
  if (Pt.isLoci(e)) {
    var a = t.structure, i = t.group;
    if (!st.areRootsEquivalent(e.structure, a)) return !1;
    e = Pt.remapLoci(e, a);
    for (var o = i.units[0].gapElements.length, s = 0, u = e.bonds; s < u.length; s++) {
      var c = u[s], l = i.unitIndexMap.get(c.aUnit.id);
      if (l !== void 0) {
        var d = We.indexOf(c.aUnit.gapElements, c.aUnit.elements[c.aIndex]), f = We.indexOf(c.bUnit.gapElements, c.bUnit.elements[c.bIndex]);
        d !== -1 && f !== -1 && r(Fe.ofSingleton(l * o + d)) && (n = !0);
      }
    }
  } else if (et.is(e)) {
    if (a = t.structure, i = t.group, !st.areRootsEquivalent(e.structure, a)) return !1;
    e = et.remap(e, a);
    for (var m = i.units[0].gapElements.length, h = function(v) {
      var y = i.unitIndexMap.get(v.unit.id);
      y !== void 0 && We.forEach(v.indices, function(_) {
        var S = We.indexOf(v.unit.gapElements, v.unit.elements[_]);
        S !== -1 && r(Fe.ofSingleton(y * m + S)) && (n = !0);
      });
    }, p = 0, g = e.elements; p < g.length; p++)
      h(g[p]);
  }
  return n;
}
function xk(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group.units[a];
    if (Ke.isAtomic(s)) return ek(o, s, s.nucleotideElements[i]);
  }
  return Tn;
}
function Sce(e) {
  return e.nucleotideElements;
}
function _k(e, t, r) {
  var n = !1;
  if (!et.is(e)) return !1;
  var a = t.structure, i = t.group;
  if (!st.areEquivalent(e.structure, a)) return !1;
  var o = i.units[0];
  if (!Ke.isAtomic(o)) return !1;
  for (var s = o.nucleotideElements.length, u = 0, c = e.elements; u < c.length; u++) {
    var l = c[u];
    if (Ke.isAtomic(l.unit) && i.unitIndexMap.has(l.unit.id)) {
      var d = i.unitIndexMap.get(l.unit.id) * s;
      Ke.isAtomic(l.unit) && (n = yk(d, s, Sce, r, l) || n);
    }
  }
  return n;
}
(function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, a = r.units[0].polymerElements, i = a.length, o = r.units.length, s = lt.create(n);
    return ca(i, o, 1, function(u, c) {
      var l = r.units[c];
      return s.unit = l, s.element = a[u], s;
    });
  };
})(Iy || (Iy = {})), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, a = r.units[0].gapElements, i = a.length, o = r.units.length, s = lt.create(n);
    return ca(i, o, 1, function(u, c) {
      var l = r.units[c];
      return s.unit = l, s.element = a[u], s;
    });
  };
}(g_ || (g_ = {})), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, a = r.units[0], i = Ke.isAtomic(a) ? a.nucleotideElements : [], o = i.length, s = r.units.length, u = lt.create(n);
    return ca(o, s, 1, function(c, l) {
      var d = r.units[l];
      return u.unit = d, u.element = i[c], u;
    });
  };
}(Ty || (Ty = {}));
var s0 = D(), Pg = D(), PM = D(), BM = D(), OM = D(), FM = D(), Bg = D(), Qx = D(), $x = D(), RM = D(), u0 = Ee.identity(), Ace = D(), LM = IR(), Sk = { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: V.Numeric(16, { min: 2, max: 56, step: 2 }, yt.CustomQualityParamInfo) };
function wce(e, t, r, n, a, i) {
  if (!Ke.isAtomic(t)) return Xt.createEmpty(i);
  var o = t.nucleotideElements.length;
  if (!o) return Xt.createEmpty(i);
  for (var s = a.sizeFactor, u = a.radialSegments, c = o * (LM.vertices.length / 3 + 2 * u), l = Nt.createState(c, c / 4, i), d = t.elements, f = t.model, m = f.atomicHierarchy, h = m.chainAtomSegments, p = m.residueAtomSegments, g = m.atoms, v = m.index, y = f.atomicHierarchy.derived.residue, _ = y.moleculeType, S = y.traceElementIndex, b = g.label_comp_id, x = t.conformation.invariantPosition, A = nr.transientSegments(h, d), w = nr.transientSegments(p, d), C = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u, bottomCap: !0 }, M = 0; A.hasNext; ) for (w.setSegment(A.move()); w.hasNext; ) {
    var T = w.move().index;
    if (p1(_[T])) {
      var N = b.value(p.offsets[T]), I = -1, P = -1, O = -1, F = -1, R = -1, G = -1, L = 2.5 * s, q = 4.5, K = FF(N), X = RF(N);
      if (!K && !X) {
        var H = v.findAtomOnResidue(T, "C4"), W = v.findAtomOnResidue(T, "N9");
        H !== -1 && W !== -1 && D.distance(x(H, s0), x(W, Pg)) < 1.6 ? K = !0 : X = !0;
      }
      K ? (q = 4.5, I = v.findAtomOnResidue(T, "N1"), P = v.findAtomOnResidue(T, "C4"), O = v.findAtomOnResidue(T, "C6"), F = v.findAtomOnResidue(T, "C2"), R = v.findAtomOnResidue(T, "N9"), G = S[T]) : X && (q = 3, I = v.findAtomOnResidue(T, "N3"), P = v.findAtomOnResidue(T, "C6"), O = v.findAtomOnResidue(T, "C4"), F = v.findAtomOnResidue(T, "C2"), (R = v.findAtomOnResidue(T, "N1")) === -1 && (R = v.findAtomOnResidue(T, "C1")), G = S[T]), R !== -1 && G !== -1 && (x(R, OM), x(G, FM), l.currentGroup = M, Ba(l, OM, FM, 1, C), I !== -1 && P !== -1 && O !== -1 && F !== -1 && (x(I, s0), x(P, Pg), x(O, PM), x(F, BM), D.normalize(Bg, D.sub(Bg, Pg, s0)), D.normalize(Qx, D.sub(Qx, BM, PM)), D.normalize($x, D.cross($x, Bg, Qx)), Ee.targetTo(u0, s0, Pg, $x), D.scaleAndAdd(RM, s0, Bg, q / 2 - 0.2), Ee.scale(u0, u0, D.set(Ace, 4.5, L, q)), Ee.setTranslation(u0, RM), Nt.addPrimitive(l, u0, LM))), ++M;
    }
  }
  var ee = Nt.getMesh(l), $ = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return ee.setBoundingSphere($), ee;
}
V.getDefaultValues(Sk);
var Ak = k(k({}, Al), Sk);
function Cce(e) {
  return wl({ defaultProps: V.getDefaultValues(Ak), createGeometry: wce, createLocationIterator: Ty.fromGroup, getLoci: xk, eachLocation: _k, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var Og = D.zero(), Zl = D.zero(), Fg = D.zero(), Rg = D.zero(), Af = D.zero(), ap = D.zero(), Lg = D.zero(), kM = D.zero(), zM = D.zero(), c0 = D.zero(), Ql = D.zero(), wk = { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: V.Numeric(16, { min: 2, max: 56, step: 2 }, yt.CustomQualityParamInfo), detail: V.Numeric(0, { min: 0, max: 3, step: 1 }, yt.CustomQualityParamInfo) };
V.getDefaultValues(wk);
var kg = new Float32Array(54), Ece = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), Dce = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), Mce = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), zg = new Float32Array(36), Ice = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), Tce = new Uint32Array([0, 10, 8, 6, 4, 2]), Nce = new Uint32Array([1, 3, 5, 7, 9, 11]), UM = D.zero();
function GM(e, t) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  for (var a = 0, i = r.length; a < i; ++a) {
    var o = r[a];
    D.toArray(D.add(UM, o, t), e, 2 * a * 3), D.toArray(D.sub(UM, o, t), e, 3 * (2 * a + 1));
  }
}
function Pce(e, t, r, n, a, i) {
  if (!Ke.isAtomic(t)) return Xt.createEmpty(i);
  var o = t.nucleotideElements.length;
  if (!o) return Xt.createEmpty(i);
  for (var s = a.sizeFactor, u = a.radialSegments, c = a.detail, l = o * (26 + 2 * u), d = Nt.createState(l, l / 4, i), f = t.elements, m = t.model, h = m.atomicHierarchy, p = h.chainAtomSegments, g = h.residueAtomSegments, v = h.atoms, y = h.index, _ = m.atomicHierarchy.derived.residue, S = _.moleculeType, b = _.traceElementIndex, x = v.label_comp_id, A = t.conformation.invariantPosition, w = nr.transientSegments(p, f), C = nr.transientSegments(g, f), M = 1 * s, T = 1.25 * s, N = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u }, I = 0; w.hasNext; ) for (C.setSegment(w.move()); C.hasNext; ) {
    var P = C.move().index;
    if (p1(S[P])) {
      var O = x.value(g.offsets[P]), F = -1, R = -1, G = -1, L = -1, q = -1, K = -1, X = -1, H = -1, W = -1, ee = -1;
      d.currentGroup = I;
      var $ = FF(O), te = RF(O);
      if (!$ && !te) {
        var re = y.findAtomOnResidue(P, "C4"), ie = y.findAtomOnResidue(P, "N9");
        re !== -1 && ie !== -1 && D.distance(A(re, Af), A(ie, c0)) < 1.6 ? $ = !0 : te = !0;
      }
      $ ? (F = b[P], R = y.findAtomOnResidue(P, "N1"), G = y.findAtomOnResidue(P, "C2"), L = y.findAtomOnResidue(P, "N3"), q = y.findAtomOnResidue(P, "C4"), (K = y.findAtomOnResidue(P, "C5")) === -1 && (K = y.findAtomOnResidue(P, "N5")), X = y.findAtomOnResidue(P, "C6"), (H = y.findAtomOnResidue(P, "N7")) === -1 && (H = y.findAtomOnResidue(P, "C7")), W = y.findAtomOnResidue(P, "C8"), (ee = y.findAtomOnResidue(P, "N9")) !== -1 && F !== -1 && (A(ee, c0), A(F, Og), d.currentGroup = I, Ba(d, c0, Og, 1, N), La(d, c0, M, c)), R !== -1 && G !== -1 && L !== -1 && q !== -1 && K !== -1 && X !== -1 && H !== -1 && W !== -1 && ee !== -1 && (A(R, Zl), A(G, Fg), A(L, Rg), A(q, Af), A(K, ap), A(X, Lg), A(H, kM), A(W, zM), D.triangleNormal(Ql, Zl, Af, ap), D.scale(Ql, Ql, T), GM(kg, Ql, Zl, Fg, Rg, Af, ap, Lg, kM, zM, c0), Nt.addTriangleStrip(d, kg, Ece), Nt.addTriangleFan(d, kg, Dce), Nt.addTriangleFan(d, kg, Mce))) : te && (F = b[P], (R = y.findAtomOnResidue(P, "N1")) === -1 && (R = y.findAtomOnResidue(P, "C1")), G = y.findAtomOnResidue(P, "C2"), L = y.findAtomOnResidue(P, "N3"), q = y.findAtomOnResidue(P, "C4"), K = y.findAtomOnResidue(P, "C5"), X = y.findAtomOnResidue(P, "C6"), R !== -1 && F !== -1 && (A(R, Zl), A(F, Og), d.currentGroup = I, Ba(d, Zl, Og, 1, N), La(d, Zl, M, c)), R !== -1 && G !== -1 && L !== -1 && q !== -1 && K !== -1 && X !== -1 && (A(G, Fg), A(L, Rg), A(q, Af), A(K, ap), A(X, Lg), D.triangleNormal(Ql, Zl, Af, ap), D.scale(Ql, Ql, T), GM(zg, Ql, Zl, Fg, Rg, Af, ap, Lg), Nt.addTriangleStrip(d, zg, Ice), Nt.addTriangleFan(d, zg, Tce), Nt.addTriangleFan(d, zg, Nce))), ++I;
    }
  }
  var oe = Nt.getMesh(d), se = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return oe.setBoundingSphere(se), oe;
}
var Ck = k(k({}, Al), wk);
function Bce(e) {
  return wl({ defaultProps: V.getDefaultValues(Ck), createGeometry: Pce, createLocationIterator: Ty.fromGroup, getLoci: xk, eachLocation: _k, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var Jx, wf = D.zero(), ip = D.zero(), Cf = D.zero(), VM = D.zero(), Ma = h3(3, !1), Ef = Ee.identity(), Oce = D.zero(), qM = D.zero(), HM = D.zero(), e5 = D.zero(), Fce = 4, Rce = 4, Lce = 6, kce = (Jx || (Jx = function() {
  for (var e = kh(8), t = 0; t < 3; ++t) {
    var r = (t + 1) % 3;
    D.set(wf, Ma[3 * t], Ma[3 * t + 1], -0.5), D.set(ip, Ma[3 * r], Ma[3 * r + 1], -0.5), D.set(Cf, Ma[3 * r], Ma[3 * r + 1], 0.5), D.set(VM, Ma[3 * t], Ma[3 * t + 1], 0.5), e.add(wf, ip, Cf), e.add(Cf, VM, wf);
  }
  return D.set(wf, Ma[0], Ma[1], -0.5), D.set(ip, Ma[3], Ma[4], -0.5), D.set(Cf, Ma[6], Ma[7], -0.5), e.add(Cf, ip, wf), D.set(wf, Ma[0], Ma[1], 0.5), D.set(ip, Ma[3], Ma[4], 0.5), D.set(Cf, Ma[6], Ma[7], 0.5), e.add(wf, ip, Cf), e.getPrimitive();
}()), Jx), Ek = { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }) };
function zce(e, t, r, n, a, i) {
  var o = t.polymerElements.length;
  if (!o) return Xt.createEmpty(i);
  for (var s = a.sizeFactor, u = 24 * o, c = Nt.createState(u, u / 10, i), l = pk(1), d = l.normalVectors, f = l.binormalVectors, m = 0, h = fk(t, r); h.hasNext; ) {
    var p = h.move();
    c.currentGroup = m;
    var g = p1(p.moleculeType), v = Er.is(p.secStrucType, 4);
    if (hk(l, p, g || v ? 0.5 : 0.9, g ? 0.3 : 0.5), v && !p.secStrucLast || !v) {
      var y = n.size.size(p.center) * s, _ = Fce * y, S = Rce * y, b = Lce * y, x = g ? f : d;
      D.fromArray(qM, x, 0), D.fromArray(HM, x, 3), D.normalize(e5, D.add(e5, qM, HM)), Ee.targetTo(Ef, p.p3, p.p1, e5), Ee.mul(Ef, Ef, Ee.rotY90Z180), Ee.scale(Ef, Ef, D.set(Oce, b, S, _)), Ee.setTranslation(Ef, p.p2), Nt.addPrimitive(c, Ef, kce);
    }
    ++m;
  }
  var A = Nt.getMesh(c), w = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return A.setBoundingSphere(w), A;
}
V.getDefaultValues(Ek);
var Dk = k(k({}, Al), Ek);
function Uce(e) {
  return wl({ defaultProps: V.getDefaultValues(Dk), createGeometry: zce, createLocationIterator: Iy.fromGroup, getLoci: gk, eachLocation: bk, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor;
  } }, e);
}
var t5 = 10, Mk = { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: V.Numeric(16, { min: 2, max: 56, step: 2 }, yt.CustomQualityParamInfo) };
function Gce(e, t, r, n, a, i) {
  var o = t.gapElements.length;
  if (!o) return Xt.createEmpty(i);
  for (var s = a.sizeFactor, u = a.radialSegments, c = t5 * u * 2 * o * 2, l = Nt.createState(c, c / 10, i), d = t.conformation.invariantPosition, f = D.zero(), m = D.zero(), h = { radiusTop: 1, radiusBottom: 1, topCap: !0, bottomCap: !0, radialSegments: u }, p = 0, g = function(x, A) {
    switch (A.kind) {
      case 0:
        return new ice(x, A);
      case 1:
      case 2:
        return new oce(x, A);
    }
  }(r, t); g.hasNext; ) {
    var v = g.move(), y = v.centerA, _ = v.centerB;
    y.element === _.element || (d(y.element, f), d(_.element, m), h.radiusTop = h.radiusBottom = n.size.size(y) * s, l.currentGroup = p, $0(l, f, m, 0.5, t5, h), h.radiusTop = h.radiusBottom = n.size.size(_) * s, l.currentGroup = p + 1, $0(l, m, f, 0.5, t5, h)), p += 2;
  }
  var S = Nt.getMesh(l), b = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return S.setBoundingSphere(b), S;
}
V.getDefaultValues(Mk);
var Ik = k(k({}, Al), Mk);
function Vce(e) {
  return wl({ defaultProps: V.getDefaultValues(Ik), createGeometry: Gce, createLocationIterator: g_.fromGroup, getLoci: xce, eachLocation: _ce, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var Pr = D(), jr = D(), qce = D(), us = D(), Ju = D(), Ug = D(), Gg = D(), l0 = D(), bu = D(), ec = D(), r5 = D(), $l = D(), Jl = D(), ed = D(), td = D(), qs = D.fromArray, Mp = D.scale, Xs = D.add, Zc = D.sub, Hce = D.magnitude, KM = D.negate, y_ = D.copy, Tk = D.cross, Kce = D.set, Jr = Ye.add3, Xce = Ye.add;
function Vg(e, t, r, n, a, i, o, s, u) {
  var c = t.vertices, l = t.normals, d = t.indices, f = c.elementCount;
  if (qs(Pr, n, e), Mp(Gg, Pr, o), Mp(Ug, Pr, s), qs(jr, a, e), Mp(us, jr, i), Tk(ec, jr, Pr), qs(bu, r, e), Xs($l, Xs($l, bu, us), Ug), Zc(Jl, Xs(Jl, bu, us), Gg), Zc(ed, Zc(ed, bu, us), Gg), Xs(td, Zc(td, bu, us), Ug), o < s ? (Jr(c, td[0], td[1], td[2]), Jr(c, ed[0], ed[1], ed[2]), Jr(c, Jl[0], Jl[1], Jl[2]), Jr(c, $l[0], $l[1], $l[2]), y_(Ju, Ug)) : (Jr(c, $l[0], $l[1], $l[2]), Jr(c, Jl[0], Jl[1], Jl[2]), Jr(c, ed[0], ed[1], ed[2]), Jr(c, td[0], td[1], td[2]), y_(Ju, Gg)), u) {
    for (var m = 0; m < 4; ++m) Jr(l, -ec[0], -ec[1], -ec[2]);
    Jr(d, f, f + 1, f + 2), Jr(d, f + 2, f + 3, f);
  } else {
    for (m = 0; m < 4; ++m) Jr(l, ec[0], ec[1], ec[2]);
    Jr(d, f + 2, f + 1, f), Jr(d, f, f + 3, f + 2);
  }
}
function n5(e, t, r, n, a, i, o, s, u, c) {
  var l = e.currentGroup, d = e.vertices, f = e.normals, m = e.indices, h = e.groups, p = d.elementCount, g = 0;
  s > 0 ? (qs(Pr, t, 0), qs(jr, t, 3 * a), g = s / Hce(Zc(qce, jr, Pr))) : Kce(l0, 0, 0, 0);
  for (var v = 0; v <= a; ++v) {
    var y = i[v], _ = o[v], S = s === 0 ? _ : s * (1 - v / a), b = 3 * v;
    qs(Ju, r, b), Mp(Ju, Ju, S), qs(us, n, b), Mp(us, us, y), s > 0 && (qs(Pr, r, b), qs(jr, n, b), Mp(l0, Tk(l0, Pr, jr), g)), qs(bu, t, b), qs(ec, r, b), qs(r5, n, b), Xs(Pr, Xs(Pr, bu, us), Ju), Xs(jr, ec, l0), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), Xs(Pr, Zc(Pr, bu, us), Ju), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), KM(jr, r5), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), Zc(Pr, Zc(Pr, bu, us), Ju), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), Xs(jr, KM(jr, ec), l0), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), Zc(Pr, Xs(Pr, bu, us), Ju), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), y_(jr, r5), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]), Xs(Pr, Xs(Pr, bu, us), Ju), Jr(d, Pr[0], Pr[1], Pr[2]), Jr(f, jr[0], jr[1], jr[2]);
  }
  for (v = 0; v < a; ++v) {
    for (var x = 0; x < 2; x++) Jr(m, p + 8 * v + 2 * x, p + 8 * (v + 1) + 2 * x + 1, p + 8 * v + 2 * x + 1), Jr(m, p + 8 * v + 2 * x, p + 8 * (v + 1) + 2 * x, p + 8 * (v + 1) + 2 * x + 1);
    for (x = 2; x < 4; x++) Jr(m, p + 8 * v + 2 * x, p + 8 * (v + 1) + 2 * x, p + 8 * v + 2 * x + 1), Jr(m, p + 8 * (v + 1) + 2 * x, p + 8 * (v + 1) + 2 * x + 1, p + 8 * v + 2 * x + 1);
  }
  if (u) {
    var y = i[0], _ = o[0], A = s === 0 ? _ : s;
    Vg(0, e, t, r, n, y, A, A, !1);
  } else s > 0 && (Vg(0, e, t, r, n, y = i[0], s, -(_ = o[0]), !1), Vg(0, e, t, r, n, y, -s, _, !1));
  c && s === 0 && Vg(3 * a, e, t, r, n, y = i[a], _ = o[a], _, !0), v = 0;
  for (var w = 8 * (a + 1) + (u ? 4 : s > 0 ? 8 : 0) + (c && s === 0 ? 4 : 0); v < w; ++v) Xce(h, l);
}
var aa = D(), wa = D(), uo = D(), ii = D(), zi = D();
function qg(e, t, r, n, a) {
  e[0] = t[0] * n + r[0] * a, e[1] = t[1] * n + r[1] * a, e[2] = t[2] * n + r[2] * a;
}
function op(e, t, r, n, a, i) {
  e[0] = t[0] * a + r[0] * i + n[0], e[1] = t[1] * a + r[1] * i + n[1], e[2] = t[2] * a + r[2] * i + n[2];
}
var Gc = D.fromArray, jce = D.normalize, a5 = D.scaleAndAdd, XM = D.cross, Yce = D.dot, Wce = D.unitX, Ui = Ye.add3, i5 = /* @__PURE__ */ new Map();
function jM(e, t, r, n, a, i, o, s, u, c, l) {
  for (var d = e.currentGroup, f = e.vertices, m = e.normals, h = e.indices, p = e.groups, g = f.elementCount, v = function(R, G) {
    var L = G ? 1 : 0, q = eu(R, L);
    if (!i5.has(q)) {
      for (var K = [], X = [], H = 0; H < R; ++H) {
        var W = (2 * H + L) / R * Math.PI;
        K[H] = Math.cos(W), X[H] = Math.sin(W);
      }
      i5.set(q, { cos: K, sin: X });
    }
    return i5.get(q);
  }(i, l === "rounded"), y = v.cos, _ = v.sin, S = Math.round(i / 4), b = 3 * S, x = 0; x <= a; ++x) {
    var A = 3 * x;
    Gc(ii, r, A), Gc(zi, n, A), Gc(uo, t, A);
    for (var w = o[x], C = s[x], M = l === "rounded" && C > w, T = 0; T < i; ++T) {
      if (M) {
        op(wa, ii, zi, uo, w * y[T], w * _[T]);
        var N = Yce(zi, Wce) < 0 ? T < S || T >= b ? C - w : -C + w : T >= S && T < b ? -C + w : C - w;
        a5(wa, wa, ii, N), T === S || T === S - 1 ? qg(aa, ii, zi, 0, 1) : T === b || T === b - 1 ? qg(aa, ii, zi, 0, -1) : qg(aa, ii, zi, y[T], _[T]);
      } else op(wa, ii, zi, uo, C * y[T], w * _[T]), qg(aa, ii, zi, w * y[T], C * _[T]);
      jce(aa, aa), Ui(f, wa[0], wa[1], wa[2]), Ui(m, aa[0], aa[1], aa[2]);
    }
  }
  var I = Math.round(i / 2);
  for (x = 0; x < a; ++x) {
    for (T = 0; T < I; ++T) Ui(h, g + x * i + (T + 1) % i, g + (x + 1) * i + (T + 1) % i, g + x * i + T), Ui(h, g + (x + 1) * i + (T + 1) % i, g + (x + 1) * i + T, g + x * i + T);
    for (T = I; T < i; ++T) Ui(h, g + x * i + (T + 1) % i, g + (x + 1) * i + T, g + x * i + T), Ui(h, g + (x + 1) * i + (T + 1) % i, g + (x + 1) * i + T, g + x * i + (T + 1) % i);
  }
  if (u) {
    var P = 0, O = f.elementCount;
    for (Gc(ii, r, P), Gc(zi, n, P), Gc(uo, t, P), XM(aa, zi, ii), Ui(f, uo[0], uo[1], uo[2]), Ui(m, aa[0], aa[1], aa[2]), w = o[0], C = s[0], (M = l === "rounded" && C > w) && (C -= w), g = f.elementCount, x = 0; x < i; ++x) M ? (op(wa, ii, zi, uo, w * y[x], w * _[x]), a5(wa, wa, ii, x < S || x >= b ? C : -C)) : op(wa, ii, zi, uo, C * y[x], w * _[x]), Ui(f, wa[0], wa[1], wa[2]), Ui(m, aa[0], aa[1], aa[2]), Ui(h, g + (x + 1) % i, g + x, O);
  }
  if (c)
    for (P = 3 * a, O = f.elementCount, Gc(ii, r, P), Gc(zi, n, P), Gc(uo, t, P), XM(aa, ii, zi), Ui(f, uo[0], uo[1], uo[2]), Ui(m, aa[0], aa[1], aa[2]), w = o[a], C = s[a], (M = l === "rounded" && C > w) && (C -= w), g = f.elementCount, x = 0; x < i; ++x) M ? (op(wa, ii, zi, uo, w * y[x], w * _[x]), a5(wa, wa, ii, x < S || x >= b ? C : -C)) : op(wa, ii, zi, uo, C * y[x], w * _[x]), Ui(f, wa[0], wa[1], wa[2]), Ui(m, aa[0], aa[1], aa[2]), Ui(h, g + x, g + (x + 1) % i, O);
  var F = (a + 1) * i + (u ? i + 1 : 0) + (c ? i + 1 : 0);
  Ye.addRepeat(p, F, d);
}
var Vc = D.fromArray, Zce = D.magnitude, o5 = D.sub, YM = D.add, s5 = D.scale, Qce = D.negate, $ce = D.copy, Jce = D.cross, Ls = Ye.add3, ele = Ye.add, Ia = D(), oi = D(), tle = D(), u5 = D(), Df = D(), WM = D(), d0 = D(), rle = D(), c5 = D();
function l5(e, t, r, n, a, i, o, s) {
  var u = e.currentGroup, c = e.vertices, l = e.normals, d = e.indices, f = e.groups, m = c.elementCount, h = 0;
  s > 0 && (Vc(Ia, t, 0), Vc(oi, t, 3 * a), h = s / Zce(o5(tle, oi, Ia)));
  for (var p = 0; p <= a; ++p) {
    var g = i[p], v = o[p], y = s === 0 ? v : s * (1 - p / a), _ = 3 * p;
    Vc(Df, r, _), s5(Df, Df, y), Vc(u5, n, _), s5(u5, u5, g), s > 0 && (Vc(Ia, r, _), Vc(oi, n, _), s5(WM, Jce(WM, Ia, oi), h)), Vc(d0, t, _), Vc(rle, r, _), Vc(c5, n, _), YM(Ia, d0, Df), Qce(oi, c5), Ls(c, Ia[0], Ia[1], Ia[2]), Ls(l, oi[0], oi[1], oi[2]), o5(Ia, d0, Df), Ls(c, Ia[0], Ia[1], Ia[2]), Ls(l, oi[0], oi[1], oi[2]), YM(Ia, d0, Df), $ce(oi, c5), Ls(c, Ia[0], Ia[1], Ia[2]), Ls(l, oi[0], oi[1], oi[2]), o5(Ia, d0, Df), Ls(c, Ia[0], Ia[1], Ia[2]), Ls(l, oi[0], oi[1], oi[2]);
  }
  for (p = 0; p < a; ++p) Ls(d, m + 4 * p, m + 4 * (p + 1) + 1, m + 4 * p + 1), Ls(d, m + 4 * p, m + 4 * (p + 1), m + 4 * (p + 1) + 1), Ls(d, m + 4 * p + 2 + 1, m + 4 * (p + 1) + 2 + 1, m + 4 * p + 2), Ls(d, m + 4 * p + 2, m + 4 * (p + 1) + 2 + 1, m + 4 * (p + 1) + 2);
  p = 0;
  for (var S = 4 * (a + 1); p < S; ++p) ele(f, u);
}
var Nk = { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), aspectRatio: V.Numeric(5, { min: 0.1, max: 10, step: 0.1 }), arrowFactor: V.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }), tubularHelices: V.Boolean(!1, { description: "Draw alpha helices as tubes" }), helixProfile: V.Select("elliptical", V.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein and nucleic helix trace profile" }), detail: V.Numeric(0, { min: 0, max: 3, step: 1 }, yt.CustomQualityParamInfo), linearSegments: V.Numeric(8, { min: 1, max: 48, step: 1 }, yt.CustomQualityParamInfo), radialSegments: V.Numeric(16, { min: 2, max: 56, step: 2 }, yt.CustomQualityParamInfo) };
V.getDefaultValues(Nk);
var Po = D();
function nle(e, t, r, n, a, i) {
  var o = t.polymerElements.length;
  if (!o) return Xt.createEmpty(i);
  for (var s = a.sizeFactor, u = a.detail, c = a.linearSegments, l = a.radialSegments, d = a.aspectRatio, f = a.arrowFactor, m = a.tubularHelices, h = a.helixProfile, p = c * l * o + (l + 1) * o * 2, g = Nt.createState(p, p / 10, i), v = Ke.isCoarse(t), y = pk(c), _ = y.curvePoints, S = y.normalVectors, b = y.binormalVectors, x = y.widthValues, A = y.heightValues, w = 0, C = fk(t, r, { ignoreSecondaryStructure: !1, useHelixOrientation: m }); C.hasNext; ) {
    var M = C.move();
    g.currentGroup = w;
    var T = p1(M.moleculeType), N = Er.is(M.secStrucType, 4), I = Er.is(M.secStrucType, 2), P = T ? yce : gce;
    hk(y, M, I && !m ? vce : hce, P);
    var O = n.size.size(M.centerPrev) * s, F = n.size.size(M.center) * s, R = n.size.size(M.centerNext) * s;
    v && (O *= d / 2, F *= d / 2, R *= d / 2);
    var G = M.secStrucFirst || M.coarseBackboneFirst || M.first, L = M.secStrucLast || M.coarseBackboneLast || M.last, q = c;
    if (M.initial) {
      var K = c - (q = Math.max(Math.round(c * P), 1));
      _.copyWithin(0, 3 * K), b.copyWithin(0, 3 * K), S.copyWithin(0, 3 * K), D.fromArray(Po, _, 3), D.normalize(Po, D.sub(Po, M.p2, Po)), D.scaleAndAdd(Po, M.p2, Po, F * TM), D.toArray(Po, _, 0);
    } else M.final && (q = Math.max(Math.round(c * (1 - P)), 1), D.fromArray(Po, _, 3 * q - 3), D.normalize(Po, D.sub(Po, M.p2, Po)), D.scaleAndAdd(Po, M.p2, Po, F * TM), D.toArray(Po, _, 3 * q));
    if (M.initial === !0 && M.final === !0) La(g, M.p2, 2 * F, u);
    else if (N) {
      var X = O * d, H = F * d, W = R * d, ee = M.secStrucLast ? H * f : 0;
      IM(y, O, F, R, X, H, W, P), l === 2 ? l5(g, _, S, b, q, x, A, ee) : n5(g, _, S, b, q, x, A, ee, G, L);
    } else {
      X = void 0, H = void 0, W = void 0, I && !M.isCoarseBackbone ? m ? (X = O *= 1.5 * d, H = F *= 1.5 * d, W = R *= 1.5 * d) : (X = O * d, H = F * d, W = R * d) : T && !M.isCoarseBackbone ? (X = O * d, H = F * d, W = R * d) : (X = O, H = F, W = R), IM(y, O, F, R, X, H, W, P);
      var $ = T && !M.isCoarseBackbone ? [b, S] : [S, b], te = $[0], re = $[1];
      if (T && !M.isCoarseBackbone) for (var ie = 0, oe = te.length; ie < oe; ie++) te[ie] *= -1;
      l === 2 ? T && !M.isCoarseBackbone ? l5(g, _, te, re, q, A, x, 0) : l5(g, _, te, re, q, x, A, 0) : l === 4 ? n5(g, _, te, re, q, x, A, 0, G, L) : H === F ? jM(g, _, te, re, q, l, x, A, G, L, "elliptical") : h === "square" ? n5(g, _, te, re, q, x, A, 0, G, L) : jM(g, _, te, re, q, l, x, A, G, L, h);
    }
    ++w;
  }
  var se = Nt.getMesh(g), he = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return se.setBoundingSphere(he), se;
}
var Pk = k(k({}, Al), Nk);
function ale(e) {
  return wl({ defaultProps: V.getDefaultValues(Pk), createGeometry: nle, createLocationIterator: Iy.fromGroup, getLoci: gk, eachLocation: bk, setUpdateState: function(t, r, n, a, i, o, s) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.tubularHelices !== n.tubularHelices || r.detail !== n.detail || r.linearSegments !== n.linearSegments || r.radialSegments !== n.radialSegments || r.aspectRatio !== n.aspectRatio || r.arrowFactor !== n.arrowFactor || r.helixProfile !== n.helixProfile;
    var u = Oi.get(o.structure).version;
    t.info.secondaryStructureHash !== u && (t.createGeometry = t.info.secondaryStructureHash !== void 0, t.info.secondaryStructureHash = u);
  } }, e);
}
var Bk = { "polymer-trace": function(e, t) {
  return ji("Polymer trace mesh", e, t, ale);
}, "polymer-gap": function(e, t) {
  return ji("Polymer gap cylinder", e, t, Vce);
}, "nucleotide-block": function(e, t) {
  return ji("Nucleotide block mesh", e, t, Cce);
}, "nucleotide-ring": function(e, t) {
  return ji("Nucleotide ring mesh", e, t, Bce);
}, "direction-wedge": function(e, t) {
  return ji("Polymer direction wedge", e, t, Uce);
} }, ZM = k(k(k(k(k(k({}, Pk), Ik), Ak), Ck), Dk), { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: V.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring"], V.objectToOptions(Bk)), bumpFrequency: V.Numeric(2, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory) }), _h, Wc = { name: "cartoon", label: "Cartoon", description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.", factory: function(e, t) {
  return fr.createMulti("Cartoon", e, t, ys, Bk);
}, getParams: function(e, t) {
  var r = V.clone(ZM), n = !1, a = !1;
  return t.units.forEach(function(i) {
    !n && Ke.isAtomic(i) && i.nucleotideElements.length && (n = !0), !a && i.gapElements.length && (a = !0);
  }), r.visuals.defaultValue = ["polymer-trace"], n && r.visuals.defaultValue.push("nucleotide-ring"), a && r.visuals.defaultValue.push("polymer-gap"), r;
}, defaultValues: V.getDefaultValues(ZM), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.polymerResidueCount > 0;
}, ensureCustomProperties: { attach: function(e, t) {
  return Be(void 0, 0, void 0, function() {
    var r, n, a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, Oi.attach(e, t, void 0, !0)];
        case 1:
          i.sent(), r = 0, n = t.models, i.label = 2;
        case 2:
          return r < n.length ? (a = n[r], [4, v_.attach(e, a, void 0, !0)]) : [3, 5];
        case 3:
          i.sent(), i.label = 4;
        case 4:
          return r++, [3, 2];
        case 5:
          return [2];
      }
    });
  });
}, detach: function(e) {
  Oi.ref(e, !1);
  for (var t = 0, r = e.models; t < r.length; t++) {
    var n = r[t];
    v_.ref(n, !1);
  }
} } }, ile = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.elementCount ? [4, Oi.attach({ runtime: fs, assetManager: new $c() }, e)] : [3, 2];
        case 1:
          a.sent(), a.label = 2;
        case 2:
          return (n = Wc.factory(t, Wc.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, n.createOrUpdate(k(k({}, Wc.defaultValues), { quality: "auto" }), e).run()];
        case 3:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), t.elementCount ? [4, Oi.attach({ runtime: fs, assetManager: new $c() }, t)] : [3, 2];
        case 1:
          a.sent(), a.label = 2;
        case 2:
          return [4, e.createOrUpdate({}, t).run()];
        case 3:
          return a.sent(), [2];
      }
    });
  });
} }, Hg = D(), Kg = D(), Mf = D(), d5 = Ye.add, QM = Ye.add3;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var a = Ye.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t), i = Ye.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : t), o = Ye.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : t), s = Ye.create(Float32Array, 1, r, n ? n.scaleBuffer.ref.value : t), u = Ye.create(Float32Array, 1, r, n ? n.capBuffer.ref.value : t), c = function(d, f, m, h, p, g, v, y, _, S) {
      for (var b = 0; b < 6; ++b) QM(i, d, f, m), QM(o, h, p, g), d5(a, S), d5(s, v), d5(u, (y ? 1 : 0) + (_ ? 2 : 0));
    }, l = function(d, f, m, h, p, g, v) {
      var y = D.distance(d, f), _ = Math.floor(m / 2), S = 1 / m;
      D.sub(Mf, f, d);
      for (var b = 0; b < _; ++b) {
        var x = S * (2 * b + 1);
        D.setMagnitude(Mf, Mf, y * x), D.add(Hg, d, Mf), D.setMagnitude(Mf, Mf, y * S * (2 * (b + 1))), D.add(Kg, d, Mf), c(Hg[0], Hg[1], Hg[2], Kg[0], Kg[1], Kg[2], h, p, g, v);
      }
    };
    return { add: c, addFixedCountDashes: l, addFixedLengthDashes: function(d, f, m, h, p, g, v) {
      var y = D.distance(d, f);
      l(d, f, y / m, h, p, g, v);
    }, getCylinders: function() {
      var d = a.elementCount / 6, f = Ye.compact(a, !0), m = Ye.compact(i, !0), h = Ye.compact(o, !0), p = Ye.compact(s, !0), g = Ye.compact(u, !0), v = n && d <= n.cylinderCount ? n.mappingBuffer.ref.value : new Float32Array(18 * d), y = n && d <= n.cylinderCount ? n.indexBuffer.ref.value : new Uint32Array(12 * d);
      return (!n || d > n.cylinderCount) && function(_, S, b) {
        for (var x = 0; x < _; ++x) {
          var A = 18 * x;
          S[A] = -1, S[A + 1] = 1, S[A + 2] = -1, S[A + 3] = -1, S[A + 4] = -1, S[A + 5] = -1, S[A + 6] = 1, S[A + 7] = 1, S[A + 8] = -1, S[A + 9] = 1, S[A + 10] = 1, S[A + 11] = 1, S[A + 12] = 1, S[A + 13] = -1, S[A + 14] = -1, S[A + 15] = 1, S[A + 16] = -1, S[A + 17] = 1;
        }
        for (x = 0; x < _; ++x) {
          var w = 6 * x, C = 12 * x;
          b[C] = w, b[C + 1] = w + 1, b[C + 2] = w + 2, b[C + 3] = w + 1, b[C + 4] = w + 4, b[C + 5] = w + 2, b[C + 6] = w + 2, b[C + 7] = w + 4, b[C + 8] = w + 3, b[C + 9] = w + 4, b[C + 10] = w + 5, b[C + 11] = w + 3;
        }
      }(d, v, y), Wi.create(v, y, f, m, h, p, g, d, n);
    } };
  };
})(_h || (_h = {}));
var D3 = { linkScale: V.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), linkSpacing: V.Numeric(1, { min: 0, max: 2, step: 0.01 }), linkCap: V.Boolean(!1), aromaticScale: V.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), aromaticSpacing: V.Numeric(1.5, { min: 0, max: 3, step: 0.01 }), aromaticDashCount: V.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: V.Numeric(4, { min: 2, max: 10, step: 2 }), dashScale: V.Numeric(0.8, { min: 0, max: 2, step: 0.1 }), dashCap: V.Boolean(!0), stubCap: V.Boolean(!0), radialSegments: V.Numeric(16, { min: 2, max: 56, step: 2 }, yt.CustomQualityParamInfo) };
V.getDefaultValues(D3);
var Ok = { linkScale: V.Numeric(0.5, { min: 0, max: 1, step: 0.1 }), linkSpacing: V.Numeric(0.1, { min: 0, max: 2, step: 0.01 }), aromaticDashCount: V.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: V.Numeric(4, { min: 2, max: 10, step: 2 }) };
V.getDefaultValues(Ok);
var Mr = D(), rd = D(), ks = D(), ole = D.create(0, 1, 0);
function lS(e, t, r, n) {
  D.normalize(rd, D.sub(rd, t, r)), n !== null ? D.sub(ks, t, n) : D.copy(ks, t), D.normalize(ks, ks);
  var a = D.dot(rd, ks);
  return 1 - Math.abs(a) < 1e-5 && (D.set(ks, 1, 0, 0), a = D.dot(rd, ks), 1 - Math.abs(a) < 1e-5 && (D.set(ks, 0, 1, 0), a = D.dot(rd, ks))), D.setMagnitude(rd, rd, a), D.sub(ks, ks, rd), D.normalize(e, ks);
}
var ls = D.scale, ta = D.add, _n = D.sub, wi = D.setMagnitude, sle = D.dot;
function M3(e, t, r, n) {
  var a = t.linkCount, i = t.referencePosition, o = t.position, s = t.style, u = t.radius, c = t.ignore, l = t.stub;
  if (!a) return { mesh: Xt.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, m = r.radialSegments, h = r.linkCap, p = r.aromaticScale, g = r.aromaticSpacing, v = r.aromaticDashCount, y = r.dashCount, _ = r.dashScale, S = r.dashCap, b = r.stubCap, x = 2 * m * a * 2, A = Nt.createState(x, x / 4, n), w = D(), C = D(), M = D(), T = D(), N = 0, I = { radiusTop: 1, radiusBottom: 1, radialSegments: m, topCap: h, bottomCap: h }, P = y + 1, O = 0, F = a; O < F; ++O) if (!c || !c(O)) {
    o(w, C, O), ta(T, T, w), ta(T, T, C), N += 2, _n(Mr, C, w);
    var R = sle(Mr, ole) > 0, G = u(O), L = s ? s(O) : 0, q = b && !!l && l(O), K = R ? [q, h] : [h, q], X = K[0], H = K[1];
    A.currentGroup = O;
    var W = v + 1;
    if (L === 0) I.radiusTop = I.radiusBottom = G, I.topCap = X, I.bottomCap = H, Ba(A, w, C, 0.5, I);
    else if (L === 1) I.radiusTop = I.radiusBottom = G * _, I.topCap = I.bottomCap = S, $0(A, w, C, 0.5, P, I);
    else if (L === 2 || L === 3 || L === 4 || L === 5 || L === 7 || L === 8) {
      var ee = L === 2 || L === 3 ? 2 : L === 4 || L === 5 ? 3 : 1.5, $ = G * (d / (0.5 * ee)), te = (G - $) * f;
      if (lS(M, w, C, i ? i(O) : null), I.topCap = X, I.bottomCap = H, L === 7 || L === 8) {
        I.radiusTop = I.radiusBottom = G, Ba(A, w, C, 0.5, I);
        var re = G + p * G + p * G * g;
        wi(Mr, _n(Mr, C, w), 0.5 * G), ta(w, w, Mr), _n(C, C, Mr), I.radiusTop = I.radiusBottom = G * p, I.topCap = I.bottomCap = S, wi(M, M, re), _n(w, w, M), _n(C, C, M), $0(A, w, C, 0.5, W, I), L === 8 && (wi(M, M, 2 * re), ta(w, w, M), ta(C, C, M), $0(A, w, C, 0.5, W, I));
      } else if (L === 3 || L === 5) {
        var ie = G + $ + d * G * f;
        wi(M, M, ie), I.radiusTop = I.radiusBottom = G, Ba(A, w, C, 0.5, I), ls(Mr, Mr, f * d * 0.2), ta(w, w, Mr), _n(C, C, Mr), I.radiusTop = I.radiusBottom = $, I.topCap = R ? q : S, I.bottomCap = R ? S : q, wi(M, M, ie), _n(w, w, M), _n(C, C, M), Ba(A, w, C, 0.5, I), ee === 3 && (wi(M, M, 2 * ie), ta(w, w, M), ta(C, C, M), Ba(A, w, C, 0.5, I));
      } else wi(M, M, te), I.radiusTop = I.radiusBottom = $, ee === 3 && Ba(A, w, C, 0.5, I), oie(A, w, C, 0.5, M, I);
    } else L === 6 && (ls(Mr, Mr, 0.475), ta(w, w, Mr), _n(C, C, Mr), I.radiusTop = I.radiusBottom = G, I.topCap = X, I.bottomCap = H, Ba(A, w, C, 0.5, I));
  }
  var oe = n ? Ve.clone(n.boundingSphere) : void 0, se = Nt.getMesh(A);
  return N === 0 ? { mesh: se } : (D.scale(T, T, 1 / N), oe && D.distance(T, oe.center) / oe.radius < 1 ? { mesh: se, boundingSphere: oe } : { mesh: se });
}
function Fk(e, t, r, n) {
  var a = t.linkCount, i = t.referencePosition, o = t.position, s = t.style, u = t.radius, c = t.ignore, l = t.stub;
  if (!a) return { cylinders: Wi.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, m = r.linkCap, h = r.aromaticScale, p = r.aromaticSpacing, g = r.aromaticDashCount, v = r.dashCount, y = r.dashScale, _ = r.dashCap, S = r.stubCap, b = 2 * a, x = _h.create(b, b / 4, n), A = D(), w = D(), C = D(), M = D(), T = D(), N = 0, I = v % 2 == 1 ? v : v + 1, P = 0.5 - 0.25 / I, O = g + 1, F = 0.5 - 0.25 / O, R = 0, G = a; R < G; ++R) if (!c || !c(R)) {
    o(A, w, R), ta(T, T, A), ta(T, T, w), N += 2;
    var L = u(R), q = s ? s(R) : 0, K = S && !!l && l(R);
    if (q === 0) ls(C, ta(C, A, w), 0.5), x.add(A[0], A[1], A[2], C[0], C[1], C[2], 1, m, K, R);
    else if (q === 1) ls(Mr, _n(Mr, w, A), P), _n(w, w, Mr), x.addFixedCountDashes(A, w, I, y, _, _, R);
    else if (q === 2 || q === 3 || q === 4 || q === 5 || q === 7 || q === 8) {
      var X = q === 2 || q === 3 ? 2 : q === 4 || q === 5 ? 3 : 1.5, H = d / (0.5 * X), W = (L - H * L) * f;
      if (ls(C, ta(C, A, w), 0.5), lS(M, A, w, i ? i(R) : null), q === 7 || q === 8) {
        x.add(A[0], A[1], A[2], C[0], C[1], C[2], 1, m, K, R);
        var ee = L + h * L + h * L * p;
        ls(Mr, _n(Mr, w, A), F), _n(w, w, Mr), wi(Mr, _n(Mr, w, A), 0.5 * L), ta(A, A, Mr), wi(M, M, ee), _n(A, A, M), _n(w, w, M), x.addFixedCountDashes(A, w, O, h, _, _, R), q === 8 && (wi(M, M, 2 * ee), ta(A, A, M), ta(w, w, M), x.addFixedCountDashes(A, w, O, h, _, _, R));
      } else q === 3 || q === 5 ? (wi(M, M, L + H * L + d * L * f), x.add(A[0], A[1], A[2], C[0], C[1], C[2], 1, m, K, R), wi(Mr, _n(Mr, A, w), L / 1.5), _n(A, A, Mr), X === 3 && x.add(A[0] + M[0], A[1] + M[1], A[2] + M[2], C[0] + M[0], C[1] + M[1], C[2] + M[2], H, m, K, R), x.add(A[0] - M[0], A[1] - M[1], A[2] - M[2], C[0] - M[0], C[1] - M[1], C[2] - M[2], H, _, K, R)) : (wi(M, M, W), X === 3 && x.add(A[0], A[1], A[2], C[0], C[1], C[2], H, m, K, R), x.add(A[0] + M[0], A[1] + M[1], A[2] + M[2], C[0] + M[0], C[1] + M[1], C[2] + M[2], H, m, K, R), x.add(A[0] - M[0], A[1] - M[1], A[2] - M[2], C[0] - M[0], C[1] - M[1], C[2] - M[2], H, m, K, R));
    } else q === 6 && (ls(Mr, _n(Mr, w, A), 0.475), ta(A, A, Mr), _n(w, w, Mr), x.add(A[0], A[1], A[2], w[0], w[1], w[2], 1, m, K, R));
  }
  var $ = n ? Ve.clone(n.boundingSphere) : void 0, te = x.getCylinders();
  return N === 0 ? { cylinders: te } : (D.scale(T, T, 1 / N), $ && D.distance(T, $.center) / $.radius < 1 ? { cylinders: te, boundingSphere: $ } : { cylinders: te });
}
function Rk(e, t, r, n) {
  var a = t.linkCount, i = t.referencePosition, o = t.position, s = t.style, u = t.ignore;
  if (!a) return { lines: Ur.createEmpty(n) };
  for (var c = r.linkScale, l = r.linkSpacing, d = r.aromaticDashCount, f = r.dashCount, m = 2 * a, h = hi.create(m, m / 4, n), p = D(), g = D(), v = D(), y = D(), _ = D(), S = 0, b = f % 2 == 1 ? f : f + 1, x = 0.5 - 0.25 / b, A = d + 1, w = 0.5 - 0.25 / A, C = 0, M = a; C < M; ++C) if (!u || !u(C)) {
    o(p, g, C), ta(_, _, p), ta(_, _, g), S += 2;
    var T = s ? s(C) : 0;
    if (T === 0) ls(v, ta(v, p, g), 0.5), h.add(p[0], p[1], p[2], v[0], v[1], v[2], C);
    else if (T === 1) ls(Mr, _n(Mr, g, p), x), _n(g, g, Mr), h.addFixedCountDashes(p, g, b, C);
    else if (T === 2 || T === 3 || T === 4 || T === 5 || T === 7 || T === 8) {
      var N = T === 2 || T === 3 ? 2 : T === 4 || T === 5 ? 3 : 1.5, I = (1 - c / (0.5 * N) * 1) * l;
      ls(v, ta(v, p, g), 0.5), lS(y, p, g, i ? i(C) : null), T === 7 || T === 8 ? (h.add(p[0], p[1], p[2], v[0], v[1], v[2], C), ls(Mr, _n(Mr, g, p), w), _n(g, g, Mr), wi(y, y, 4.5 * I), _n(p, p, y), _n(g, g, y), h.addFixedCountDashes(p, g, A, C), T === 8 && (wi(y, y, 4.5 * I * 2), ta(p, p, y), ta(g, g, y), h.addFixedCountDashes(p, g, A, C))) : T === 3 || T === 5 ? (wi(y, y, 3 * I), h.add(p[0], p[1], p[2], v[0], v[1], v[2], C), ls(Mr, _n(Mr, p, g), l * c), _n(p, p, Mr), N === 3 && h.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], v[0] + y[0], v[1] + y[1], v[2] + y[2], C), h.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], v[0] - y[0], v[1] - y[1], v[2] - y[2], C)) : (wi(y, y, 1.5 * I), N === 3 && h.add(p[0], p[1], p[2], v[0], v[1], v[2], C), h.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], v[0] + y[0], v[1] + y[1], v[2] + y[2], C), h.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], v[0] - y[0], v[1] - y[1], v[2] - y[2], C));
    } else T === 6 && (ls(Mr, _n(Mr, g, p), 0.475), ta(p, p, Mr), _n(g, g, Mr), h.add(p[0], p[1], p[2], g[0], g[1], g[2], C));
  }
  var P = n ? Ve.clone(n.boundingSphere) : void 0, O = h.getLines();
  return S === 0 ? { lines: O } : (D.scale(_, _, 1 / S), P && D.distance(_, P.center) / P.radius < 1 ? { lines: O, boundingSphere: P } : { lines: O });
}
var dS = { includeTypes: V.MultiSelect(f8(pr.Names), V.objectToOptions(pr.Names)), excludeTypes: V.MultiSelect([], V.objectToOptions(pr.Names)), ignoreHydrogens: V.Boolean(!1), aromaticBonds: V.Boolean(!0, { description: "Display aromatic bonds with dashes" }), multipleBonds: V.Select("symmetric", V.arrayToOptions(["off", "symmetric", "offset"])) };
V.getDefaultValues(dS);
var fS = k(k(k({}, D3), dS), { adjustCylinderLength: V.Boolean(!1, { description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds." }) });
V.getDefaultValues(fS);
var Kd, mS = k(k({}, Ok), dS);
function I3(e, t, r) {
  return !pr.is(e, r) || pr.is(t, r);
}
function Lk(e, t, r) {
  var n = t.elements, a = t.model.atomicHierarchy.derived.atom.atomicNumber, i = t.bonds, o = i.a, s = i.b, u = i.edgeProps.flags, c = r.ignoreHydrogens, l = r.includeTypes, d = r.excludeTypes, f = pr.fromNames(l), m = pr.fromNames(d), h = pr.isAll(f) && m === 0, p = e.child, g = p == null ? void 0 : p.unitMap.get(t.id);
  if (p && !g) throw new Error("expected childUnit to exist if child exists");
  if (!h || c || p) return function(v) {
    return !!g && !$e.has(g.elements, n[o[v]]) || c && (h_(a, n[o[v]]) || h_(a, n[s[v]])) || !h && I3(f, m, u[v]);
  };
}
function kk(e, t) {
  var r = e.interUnitBonds.edges, n = t.ignoreHydrogens, a = t.includeTypes, i = t.excludeTypes, o = pr.fromNames(a), s = pr.fromNames(i), u = pr.isAll(o) && s === 0, c = e.child;
  if (!u || n || c) return function(l) {
    if (c) {
      var d = r[l], f = c.unitMap.get(d.unitA);
      if (!f) return !0;
      var m = e.unitMap.get(d.unitA).elements[d.indexA];
      if (!$e.has(f.elements, m)) return !0;
    }
    if (n) {
      d = r[l];
      var h = e.unitMap.get(d.unitA), p = e.unitMap.get(d.unitB);
      if (p_(h, h.elements[d.indexA]) || p_(p, p.elements[d.indexB])) return !0;
    }
    return !(u || !I3(o, s, r[l].props.flag));
  };
}
function b_(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group.units[a];
    if (Ke.isAtomic(s)) {
      var u = o.target, c = s.bonds.a[i], l = s.bonds.b[i];
      return Pt.Loci(u, [Pt.Location(u, s, c, u, s, l), Pt.Location(u, s, l, u, s, c)]);
    }
  }
  return Tn;
}
function x_(e, t, r, n) {
  var a = !1;
  if (Pt.isLoci(e)) {
    var i = t.structure, o = t.group;
    if (!st.areEquivalent(e.structure, i)) return !1;
    var s = o.units[0];
    if (!Ke.isAtomic(s)) return !1;
    for (var u = 2 * s.bonds.edgeCount, c = 0, l = e.bonds; c < l.length; c++) {
      var d = l[c];
      if (d.aUnit === d.bUnit) {
        var f = o.unitIndexMap.get(d.aUnit.id);
        if (f !== void 0) {
          var m = s.bonds.getDirectedEdgeIndex(d.aIndex, d.bIndex);
          m !== -1 && r(Fe.ofSingleton(f * u + m)) && (a = !0);
        }
      }
    }
  } else if (et.is(e)) {
    if (i = t.structure, o = t.group, !st.areEquivalent(e.structure, i) || (s = o.units[0], !Ke.isAtomic(s))) return !1;
    for (var h = 2 * s.bonds.edgeCount, p = function(y) {
      var _ = o.unitIndexMap.get(y.unit.id);
      if (_ !== void 0) {
        var S = s.bonds, b = S.offset, x = S.b;
        We.forEach(y.indices, function(A) {
          for (var w = b[A], C = b[A + 1]; w < C; w++) n && !We.has(y.indices, x[w]) || r(Fe.ofSingleton(_ * h + w)) && (a = !0);
        });
      }
    }, g = 0, v = e.elements; g < v.length; g++)
      p(v[g]);
  }
  return a;
}
function __(e, t, r) {
  var n = e.objectId, a = e.groupId;
  if (r === n) {
    var i = t.target, o = t.interUnitBonds.edges[a], s = t.unitMap.get(o.unitA), u = t.unitMap.get(o.unitB);
    return Pt.Loci(i, [Pt.Location(i, s, o.indexA, i, u, o.indexB), Pt.Location(i, u, o.indexB, i, s, o.indexA)]);
  }
  return Tn;
}
V.getDefaultValues(mS), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, a = r.units[0], i = Ke.isAtomic(a) ? 2 * a.bonds.edgeCount : 0, o = r.units.length, s = Pt.Location(n, void 0, void 0, n, void 0, void 0);
    return ca(i, o, 1, function(u, c) {
      var l = r.units[c];
      return s.aUnit = l, s.bUnit = l, s.aIndex = l.bonds.a[u], s.bIndex = l.bonds.b[u], s;
    });
  }, e.fromStructure = function(t) {
    var r = t.interUnitBonds.edgeCount, n = Pt.Location(t, void 0, void 0, t, void 0, void 0);
    return ca(r, 1, 1, function(a) {
      var i = t.interUnitBonds.edges[a];
      return n.aUnit = t.unitMap.get(i.unitA), n.aIndex = i.indexA, n.bUnit = t.unitMap.get(i.unitB), n.bIndex = i.indexB, n;
    }, !0);
  };
}(Kd || (Kd = {}));
var f5 = /* @__PURE__ */ new Map();
function S_(e, t, r, n) {
  var a = !1;
  if (Pt.isLoci(e)) {
    if (!st.areEquivalent(e.structure, t)) return !1;
    for (var i = 0, o = e.bonds; i < o.length; i++) {
      var s = o[i], u = t.interUnitBonds.getBondIndexFromLocation(s);
      u !== -1 && r(Fe.ofSingleton(u)) && (a = !0);
    }
  } else if (et.is(e)) {
    if (!st.areEquivalent(e.structure, t) || n && e.elements.length === 1) return !1;
    for (var c = 0, l = e.elements; c < l.length; c++) {
      var d = l[c];
      f5.set(d.unit.id, d.indices);
    }
    for (var f = function(p) {
      var g = p.unit;
      if (!Ke.isAtomic(g)) return "continue";
      t.interUnitBonds.getConnectedUnits(g.id).forEach(function(v) {
        var y = f5.get(v.unitB);
        n && !y || We.forEach(p.indices, function(_) {
          v.connectedIndices.includes(_) && v.getEdges(_).forEach(function(S) {
            if (!n || y && We.has(y, S.indexB)) {
              var b = t.interUnitBonds.getEdgeIndex(_, g.id, S.indexB, v.unitB);
              r(Fe.ofSingleton(b)) && (a = !0);
            }
          });
        });
      });
    }, m = 0, h = e.elements; m < h.length; m++)
      f(d = h[m]);
    f5.clear();
  }
  return a;
}
var m5 = pr.is;
function zk(e, t, r, n) {
  var a, i = e.elements, o = e.bonds, s = o.edgeCount, u = o.a, c = o.b, l = o.edgeProps, d = o.offset, f = l.order, m = l.flags, h = n.sizeFactor, p = n.sizeAspectRatio, g = n.adjustCylinderLength, v = n.aromaticBonds, y = n.includeTypes, _ = n.excludeTypes, S = n.multipleBonds, b = S === "off", x = S === "symmetric", A = I3(pr.fromNames(y), pr.fromNames(_), 32), w = D(), C = D(), M = e.conformation.invariantPosition, T = lt.create(t, e), N = Pt.Location(t, e, void 0, t, e, void 0), I = t.child;
  if (n.includeParent && I) {
    var P = I.unitMap.get(e.id);
    if (!P) throw new Error("expected childUnit to exist");
    a = function(L) {
      var q = i[u[L]], K = i[c[L]];
      return $e.has(P.elements, q) && !$e.has(P.elements, K);
    };
  }
  var O = e.rings, F = O.elementRingIndices, R = O.elementAromaticRingIndices, G = v ? e.resonance.delocalizedTriplets : void 0;
  return { linkCount: 2 * s, referencePosition: function(L) {
    var q, K, X = u[L], H = c[L], W = G == null ? void 0 : G.getThirdElement(X, H);
    if (W !== void 0) return M(i[W], w);
    X > H && (X = (q = [H, X])[0], H = q[1]), d[X + 1] - d[X] == 1 && (X = (K = [H, X])[0], H = K[1]);
    for (var ee = R.get(X) || F.get(X), $ = 0, te = d[X], re = d[X + 1]; te < re; ++te) {
      var ie = c[te];
      if (ie !== H && ie !== X) {
        if (!ee) return M(i[ie], w);
        var oe = R.get(ie) || F.get(ie);
        if (!oe) continue;
        var se = Y2(ee, oe);
        se > $ && ($ = se, M(i[ie], w));
      }
    }
    return $ > 0 ? w : null;
  }, position: function(L, q, K) {
    if (M(i[u[K]], L), M(i[c[K]], q), g) {
      var X = function(te) {
        return T.element = i[u[te]], r.size.size(T) * h;
      }(K), H = function(te) {
        return T.element = i[c[te]], r.size.size(T) * h;
      }(K), W = Math.min(X, H) * p, ee = Math.sqrt(Math.max(0, X * X - W * W)) - 0.05, $ = Math.sqrt(Math.max(0, H * H - W * W)) - 0.05;
      if (ee <= 0.01 && $ <= 0.01) return;
      D.normalize(C, D.sub(C, q, L)), D.scaleAndAdd(L, L, C, ee), D.scaleAndAdd(q, q, C, -$);
    }
  }, style: function(L) {
    var q = f[L], K = m[L];
    if (m5(K, 2) || m5(K, 4)) return 1;
    if (q === 3) return b ? 0 : x ? 4 : 5;
    if (v) {
      var X = u[L], H = c[L], W = R.get(X), ee = R.get(H), $ = W && ee ? Y2(W, ee) : 0;
      if (m5(K, 16) || $ && !A) {
        if ($ === 2) return 8;
        if ($ === 1 || G != null && G.getThirdElement(X, H)) return 7;
      }
    }
    return q !== 2 || b ? 0 : x ? 2 : 3;
  }, radius: function(L) {
    return function(q) {
      return N.aIndex = u[q], N.bIndex = c[q], r.size.size(N) * h;
    }(L) * p;
  }, ignore: Lk(t, e, n), stub: a };
}
function ule(e, t, r, n, a, i) {
  if (!Ke.isAtomic(t) || !t.bonds.edgeCount) return Wi.createEmpty(i);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Wi.createEmpty(i);
  var u = Fk(0, zk(t, r, n, a), a, i), c = u.cylinders, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.cylinderCount > 0) {
    var d = Ve.expand(Ve(), (s ?? t).boundary.sphere, 1 * a.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
function cle(e, t, r, n, a, i) {
  if (!Ke.isAtomic(t) || !t.bonds.edgeCount) return Xt.createEmpty(i);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Xt.createEmpty(i);
  var u = M3(0, zk(t, r, n, a), a, i), c = u.mesh, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.triangleCount > 0) {
    var d = Ve.expand(Ve(), (s ?? t).boundary.sphere, 1 * a.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
var Ny = k(k(k(k({}, Al), nce), fS), { sizeFactor: V.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: V.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: V.Boolean(!0), includeParent: V.Boolean(!1) });
function Uk(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(a) {
    return function(i, o) {
      return Vh(k(k({}, i), { setUpdateState: function(s, u, c, l, d, f, m) {
        i.setUpdateState(s, u, c, l, d, f, m), go.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: Wi.Utils }), o);
    }({ defaultProps: V.getDefaultValues(Ny), createGeometry: ule, createLocationIterator: Kd.fromGroup, getLoci: b_, eachLocation: x_, setUpdateState: function(i, o, s, u, c, l, d) {
      i.createGeometry = o.sizeAspectRatio !== s.sizeAspectRatio || o.linkScale !== s.linkScale || o.linkSpacing !== s.linkSpacing || o.ignoreHydrogens !== s.ignoreHydrogens || o.linkCap !== s.linkCap || o.aromaticScale !== s.aromaticScale || o.aromaticSpacing !== s.aromaticSpacing || o.aromaticDashCount !== s.aromaticDashCount || o.dashCount !== s.dashCount || o.dashScale !== s.dashScale || o.dashCap !== s.dashCap || o.stubCap !== s.stubCap || !ho(o.includeTypes, s.includeTypes) || !ho(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var f = l.group.units[0], m = d.group.units[0];
      Ke.isAtomic(f) && Ke.isAtomic(m) && (Ho.areEqual(f.bonds, m.bonds) || (i.createGeometry = !0, i.updateTransform = !0, i.updateColor = !0, i.updateSize = !0));
    }, mustRecreate: function(i, o, s) {
      return !o.tryUseImpostor || !s;
    } }, a);
  }(e) : function(a) {
    return wl({ defaultProps: V.getDefaultValues(Ny), createGeometry: cle, createLocationIterator: Kd.fromGroup, getLoci: b_, eachLocation: x_, setUpdateState: function(i, o, s, u, c, l, d) {
      i.createGeometry = o.sizeFactor !== s.sizeFactor || o.sizeAspectRatio !== s.sizeAspectRatio || o.radialSegments !== s.radialSegments || o.linkScale !== s.linkScale || o.linkSpacing !== s.linkSpacing || o.ignoreHydrogens !== s.ignoreHydrogens || o.linkCap !== s.linkCap || o.aromaticScale !== s.aromaticScale || o.aromaticSpacing !== s.aromaticSpacing || o.aromaticDashCount !== s.aromaticDashCount || o.dashCount !== s.dashCount || o.dashScale !== s.dashScale || o.dashCap !== s.dashCap || o.stubCap !== s.stubCap || !ho(o.includeTypes, s.includeTypes) || !ho(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var f = l.group.units[0], m = d.group.units[0];
      Ke.isAtomic(f) && Ke.isAtomic(m) && (Ho.areEqual(f.bonds, m.bonds) || (i.createGeometry = !0, i.updateTransform = !0, i.updateColor = !0, i.updateSize = !0));
    }, mustRecreate: function(i, o, s) {
      return o.tryUseImpostor && !!s;
    } }, a);
  }(e);
}
var p5 = new Pt.ElementBondIterator();
function $M(e, t, r, n) {
  for (p5.setElement(t, r, n); p5.hasNext; ) {
    var a = p5.move();
    return a.otherUnit.conformation.position(a.otherUnit.elements[a.otherIndex], e), e;
  }
  return null;
}
var JM = D();
function Gk(e, t, r) {
  var n, a = lt.create(e), i = Pt.Location(e, void 0, void 0, e, void 0, void 0), o = e.interUnitBonds, s = o.edgeCount, u = o.edges, c = r.sizeFactor, l = r.sizeAspectRatio, d = r.adjustCylinderLength, f = r.aromaticBonds, m = r.multipleBonds, h = m === "off", p = m === "symmetric", g = D(), v = e.child;
  return r.includeParent && v && (n = function(y) {
    var _ = u[y], S = v.unitMap.get(_.unitA), b = v.unitMap.get(_.unitB), x = e.unitMap.get(_.unitA).elements[_.indexA], A = e.unitMap.get(_.unitB).elements[_.indexB];
    return S && $e.has(S.elements, x) && (!b || !$e.has(b.elements, A));
  }), { linkCount: s, referencePosition: function(y) {
    var _, S, b, x, A = u[y];
    if (A.unitA < A.unitB) _ = e.unitMap.get(A.unitA), S = e.unitMap.get(A.unitB), b = A.indexA, x = A.indexB;
    else {
      if (!(A.unitA > A.unitB)) throw new Error("same units in createInterUnitBondCylinderMesh");
      _ = e.unitMap.get(A.unitB), S = e.unitMap.get(A.unitA), b = A.indexB, x = A.indexA;
    }
    return $M(JM, e, _, b) || $M(JM, e, S, x);
  }, position: function(y, _, S) {
    var b = u[S], x = e.unitMap.get(b.unitA), A = e.unitMap.get(b.unitB);
    if (x.conformation.position(x.elements[b.indexA], y), A.conformation.position(A.elements[b.indexB], _), d) {
      var w = function(I) {
        var P = u[I];
        return a.unit = e.unitMap.get(P.unitA), a.element = a.unit.elements[P.indexA], t.size.size(a) * c;
      }(S), C = function(I) {
        var P = u[I];
        return a.unit = e.unitMap.get(P.unitB), a.element = a.unit.elements[P.indexB], t.size.size(a) * c;
      }(S), M = Math.min(w, C) * l, T = Math.sqrt(Math.max(0, w * w - M * M)) - 0.05, N = Math.sqrt(Math.max(0, C * C - M * M)) - 0.05;
      if (T <= 0.01 && N <= 0.01) return;
      D.normalize(g, D.sub(g, _, y)), D.scaleAndAdd(y, y, g, T), D.scaleAndAdd(_, _, g, -N);
    }
  }, style: function(y) {
    var _ = u[y].props.order, S = Ti.create(u[y].props.flag);
    return pr.is(S, 2) || pr.is(S, 4) ? 1 : _ === 3 ? h ? 0 : p ? 4 : 5 : f && pr.is(S, 16) ? 7 : _ !== 2 || h ? 0 : p ? 2 : 3;
  }, radius: function(y) {
    return function(_) {
      var S = u[_];
      return i.aUnit = e.unitMap.get(S.unitA), i.aIndex = S.indexA, i.bUnit = e.unitMap.get(S.unitB), i.bIndex = S.indexB, t.size.size(i) * c;
    }(y) * l;
  }, ignore: kk(e, r), stub: n };
}
function lle(e, t, r, n, a) {
  if (!t.interUnitBonds.edgeCount) return Wi.createEmpty(a);
  var i = Fk(0, Gk(t, r, n), n, a), o = i.cylinders, s = i.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.cylinderCount > 0) {
    var u = t.child, c = Ve.expand(Ve(), (u ?? t).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
function dle(e, t, r, n, a) {
  if (!t.interUnitBonds.edgeCount) return Xt.createEmpty(a);
  var i = M3(0, Gk(t, r, n), n, a), o = i.mesh, s = i.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.triangleCount > 0) {
    var u = t.child, c = Ve.expand(Ve(), (u ?? t).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
var Py = k(k(k(k({}, ck), Jue), fS), { sizeFactor: V.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: V.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: V.Boolean(!0), includeParent: V.Boolean(!1) });
function Vk(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(a) {
    return function(i, o) {
      return E3(k(k({}, i), { setUpdateState: function(s, u, c, l, d, f, m) {
        i.setUpdateState(s, u, c, l, d, f, m), go.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: Wi.Utils }), o);
    }({ defaultProps: V.getDefaultValues(Py), createGeometry: lle, createLocationIterator: Kd.fromStructure, getLoci: __, eachLocation: S_, setUpdateState: function(i, o, s, u, c, l, d) {
      i.createGeometry = o.sizeAspectRatio !== s.sizeAspectRatio || o.linkScale !== s.linkScale || o.linkSpacing !== s.linkSpacing || o.ignoreHydrogens !== s.ignoreHydrogens || o.linkCap !== s.linkCap || o.aromaticScale !== s.aromaticScale || o.aromaticSpacing !== s.aromaticSpacing || o.aromaticDashCount !== s.aromaticDashCount || o.dashCount !== s.dashCount || o.dashScale !== s.dashScale || o.dashCap !== s.dashCap || o.stubCap !== s.stubCap || !ho(o.includeTypes, s.includeTypes) || !ho(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.multipleBonds !== s.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (i.createGeometry = !0, i.updateTransform = !0, i.updateColor = !0, i.updateSize = !0);
    }, mustRecreate: function(i, o, s) {
      return !o.tryUseImpostor || !s;
    } }, a);
  }(e) : function(a) {
    return lk({ defaultProps: V.getDefaultValues(Py), createGeometry: dle, createLocationIterator: Kd.fromStructure, getLoci: __, eachLocation: S_, setUpdateState: function(i, o, s, u, c, l, d) {
      i.createGeometry = o.sizeFactor !== s.sizeFactor || o.sizeAspectRatio !== s.sizeAspectRatio || o.radialSegments !== s.radialSegments || o.linkScale !== s.linkScale || o.linkSpacing !== s.linkSpacing || o.ignoreHydrogens !== s.ignoreHydrogens || o.linkCap !== s.linkCap || o.aromaticScale !== s.aromaticScale || o.aromaticSpacing !== s.aromaticSpacing || o.aromaticDashCount !== s.aromaticDashCount || o.dashCount !== s.dashCount || o.dashScale !== s.dashScale || o.dashCap !== s.dashCap || o.stubCap !== s.stubCap || !ho(o.includeTypes, s.includeTypes) || !ho(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.multipleBonds !== s.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (i.createGeometry = !0, i.updateTransform = !0, i.updateColor = !0, i.updateSize = !0);
    }, mustRecreate: function(i, o, s) {
      return o.tryUseImpostor && !!s;
    } }, a);
  }(e);
}
var Sh, eI = new Float32Array([-1, 1, -1, -1, 1, 1, 1, -1]), sp = new Uint16Array([0, 1, 2, 1, 3, 2]), h5 = Ye.add3, fle = Ye.add2, mle = Ye.add;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024), t *= 4, r *= 4;
    var a = Ye.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : t), i = Ye.create(Float32Array, 2, r, n ? n.mappingBuffer.ref.value : t), o = Ye.create(Uint32Array, 3, r / 2, n ? n.indexBuffer.ref.value : t / 2), s = Ye.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t);
    return { add: function(u, c, l, d) {
      for (var f = a.elementCount, m = 0; m < 4; ++m) h5(a, u, c, l), fle(i, eI[2 * m], eI[2 * m + 1]), mle(s, d);
      h5(o, f + sp[0], f + sp[1], f + sp[2]), h5(o, f + sp[3], f + sp[4], f + sp[5]);
    }, getSpheres: function() {
      var u = Ye.compact(a, !0), c = Ye.compact(i, !0), l = Ye.compact(o, !0), d = Ye.compact(s, !0);
      return Nu.create(u, c, l, d, a.elementCount / 4, n);
    } };
  };
})(Sh || (Sh = {}));
var pl, qk = D.add;
function T3(e, t, r) {
  var n = r.ignoreHydrogens, a = r.traceOnly, i = t.model.atomicHierarchy.derived.atom.atomicNumber, o = Ke.isCoarse(t), s = e.child, u = s == null ? void 0 : s.unitMap.get(t.id);
  if (s && !u) throw new Error("expected childUnit to exist if child exists");
  if (s || n || a) return function(c) {
    return !!u && !$e.has(u.elements, c) || !o && n && h_(i, c) || a && !rk(t, c);
  };
}
function ple(e, t, r, n, a, i) {
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Xt.createEmpty(i);
  for (var u = a.detail, c = a.sizeFactor, l = t.elements, d = l.length, f = d * rL(u), m = Nt.createState(f, f / 2, i), h = D(), p = t.conformation.invariantPosition, g = T3(r, t, a), v = lt.create(r, t), y = n.size.size, _ = D(), S = 0, b = 0, x = 0; x < d; x++) if (!g || !g(l[x])) {
    v.element = l[x], p(l[x], h), qk(_, _, h), b += 1, m.currentGroup = x;
    var A = y(v);
    A > S && (S = A), La(m, h, A * c, u);
  }
  var w, C = i ? Ve.clone(i.boundingSphere) : void 0, M = Nt.getMesh(m);
  return b === 0 || (D.scale(_, _, 1 / b), w = C && D.distance(_, C.center) / C.radius < 1 ? C : Ve.expand(Ve(), (s ?? t).boundary.sphere, S * c + 0.05), M.setBoundingSphere(w)), M;
}
function hle(e, t, r, n, a, i) {
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Nu.createEmpty(i);
  for (var u = t.elements, c = u.length, l = Sh.create(c, c / 2, i), d = D(), f = t.conformation.invariantPosition, m = T3(r, t, a), h = lt.create(r, t), p = n.size.size, g = D(), v = 0, y = 0, _ = 0; _ < c; _++) if (!(m != null && m(u[_]))) {
    f(u[_], d), l.add(d[0], d[1], d[2], _), qk(g, g, d), y += 1, h.element = u[_];
    var S = p(h);
    S > v && (v = S);
  }
  var b, x = i ? Ve.clone(i.boundingSphere) : void 0, A = l.getSpheres();
  return y === 0 || (D.scale(g, g, 1 / y), b = x && D.distance(g, x.center) / x.radius < 1 ? x : Ve.expand(Ve(), (s ?? t).boundary.sphere, v * a.sizeFactor + 0.05), A.setBoundingSphere(b)), A;
}
function r1(e, t, r) {
  var n = !1;
  if (!et.is(e)) return !1;
  var a = t.structure, i = t.group;
  if (!st.areEquivalent(e.structure, a)) return !1;
  for (var o = i.elements.length, s = i.unitIndexMap, u = 0, c = e.elements; u < c.length; u++) {
    var l = c[u], d = s.get(l.unit.id);
    if (d !== void 0) {
      var f = d * o;
      if (Fe.is(l.indices)) {
        var m = f + Fe.start(l.indices), h = f + Fe.end(l.indices);
        r(Fe.ofBounds(m, h)) && (n = !0);
      } else for (var p = 0, g = l.indices.length; p < g; p++) {
        m = l.indices[p];
        for (var v = p + 1; v < g && l.indices[v] === m; ) v++;
        p = v - 1, h = l.indices[p], n = r(Fe.ofRange(f + m, f + h)) || n;
      }
    }
  }
  return n;
}
function n1(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group.units[a], u = We.ofSingleton(i);
    return et(o.target, [{ unit: s, indices: u }]);
  }
  return Tn;
}
function vle(e, t, r) {
  var n = !1;
  if (!et.is(e) || !st.areEquivalent(e.structure, t)) return !1;
  for (var a = t.serialMapping.cumulativeUnitElementCount, i = 0, o = e.elements; i < o.length; i++) {
    var s = o[i], u = t.unitIndexMap.get(s.unit.id);
    if (u !== void 0) if (Fe.is(s.indices)) {
      var c = a[u] + Fe.start(s.indices), l = a[u] + Fe.end(s.indices);
      r(Fe.ofBounds(c, l)) && (n = !0);
    } else for (var d = 0, f = s.indices.length; d < f; d++) {
      var m = a[u] + s.indices[d];
      r(Fe.ofSingleton(m)) && (n = !0);
    }
  }
  return n;
}
function gle(e, t, r) {
  var n = e.objectId, a = e.groupId;
  if (r === n) {
    var i = t.serialMapping, o = i.unitIndices, s = i.cumulativeUnitElementCount, u = o[a], c = t.units[u], l = a - s[u];
    return et(t, [{ unit: c, indices: We.ofSingleton(l) }]);
  }
  return Tn;
}
(function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, a = r.elements.length, i = r.units.length, o = lt.create(n);
    return ca(a, i, 1, function(s, u) {
      var c = r.units[u];
      return o.unit = c, o.element = c.elements[s], o;
    });
  }, e.fromStructure = function(t) {
    var r = t.units, n = t.elementCount, a = t.serialMapping, i = a.unitIndices, o = a.elementIndices, s = lt.create(t);
    return ca(n, 1, 1, function(u) {
      return s.unit = r[i[u]], s.element = o[u], s;
    }, !0);
  };
})(pl || (pl = {}));
var Ah = k(k(k({}, Al), rce), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), detail: V.Numeric(0, { min: 0, max: 3, step: 1 }, yt.CustomQualityParamInfo), ignoreHydrogens: V.Boolean(!1), traceOnly: V.Boolean(!1), tryUseImpostor: V.Boolean(!0) });
function pS(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(a) {
    return function(i, o) {
      return Vh(k(k({}, i), { setUpdateState: function(s, u, c, l, d, f, m) {
        i.setUpdateState(s, u, c, l, d, f, m), go.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: Nu.Utils }), o);
    }({ defaultProps: V.getDefaultValues(Ah), createGeometry: hle, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(i, o, s) {
      i.createGeometry = o.ignoreHydrogens !== s.ignoreHydrogens || o.traceOnly !== s.traceOnly;
    }, mustRecreate: function(i, o, s) {
      return !o.tryUseImpostor || !s;
    } }, a);
  }(e) : function(a) {
    return wl({ defaultProps: V.getDefaultValues(Ah), createGeometry: ple, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(i, o, s) {
      i.createGeometry = o.sizeFactor !== s.sizeFactor || o.detail !== s.detail || o.ignoreHydrogens !== s.ignoreHydrogens || o.traceOnly !== s.traceOnly;
    }, mustRecreate: function(i, o, s) {
      return o.tryUseImpostor && !!s;
    } }, a);
  }(e);
}
var yle = k(k({}, tce), { sizeFactor: V.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), background: V.Boolean(!1), backgroundMargin: V.Numeric(0, { min: 0, max: 1, step: 0.01 }), backgroundColor: V.Color($t.black), backgroundOpacity: V.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), borderWidth: V.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }), level: V.Select("element", [["element", "Element"]], { isEssential: !0 }), chainScale: V.Numeric(10, { min: 0, max: 20, step: 0.1 }), residueScale: V.Numeric(1, { min: 0, max: 20, step: 0.1 }), elementScale: V.Numeric(2, { min: 0, max: 20, step: 0.1 }), attachment: V.Select("middle-left", [["bottom-left", "bottom-left"], ["bottom-center", "bottom-center"], ["bottom-right", "bottom-right"], ["middle-left", "middle-left"], ["middle-center", "middle-center"], ["middle-right", "middle-right"], ["top-left", "top-left"], ["top-center", "top-center"], ["top-right", "top-right"]]), tether: V.Boolean(!0), tetherLength: V.Numeric(0.2, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: V.Numeric(0, { min: 0, max: 1, step: 0.01 }) });
function hS(e) {
  return function(t, r) {
    return E3(k(k({}, t), { setUpdateState: function(n, a, i, o, s, u, c) {
      t.setUpdateState(n, a, i, o, s, u, c), go.areEqual(o.size, s.size) || (n.updateSize = !0), a.background !== i.background && (n.createGeometry = !0), a.backgroundMargin !== i.backgroundMargin && (n.createGeometry = !0), a.tether !== i.tether && (n.createGeometry = !0), a.tetherLength !== i.tetherLength && (n.createGeometry = !0), a.tetherBaseWidth !== i.tetherBaseWidth && (n.createGeometry = !0), a.attachment !== i.attachment && (n.createGeometry = !0), a.fontFamily !== i.fontFamily && (n.createGeometry = !0), a.fontQuality !== i.fontQuality && (n.createGeometry = !0), a.fontStyle !== i.fontStyle && (n.createGeometry = !0), a.fontVariant !== i.fontVariant && (n.createGeometry = !0), a.fontWeight !== i.fontWeight && (n.createGeometry = !0);
    }, geometryUtils: vs.Utils }), r);
  }({ defaultProps: V.getDefaultValues(yle), createGeometry: ble, createLocationIterator: pl.fromStructure, getLoci: gle, eachLocation: vle, setUpdateState: function(t, r, n) {
    t.createGeometry = r.level !== n.level || r.level === "element" && r.elementScale !== n.elementScale;
  } }, e);
}
function ble(e, t, r, n, a) {
  return r.size.size = function() {
    return 1;
  }, r.color.color = function(i) {
    if (lt.is(i) && Ke.isAtomic(i.unit)) {
      var o = (0, at.atom.pdbx_formal_charge)(i);
      if (o > 0) return $t.red;
      if (o < 0) return $t.blue;
    }
    return $t.white;
  }, n.sizeFactor = 0.2, function(i, o, s, u, c) {
    for (var l = lt.create(o), d = o.units, f = o.serialMapping, m = at.atom.pdbx_formal_charge, h = f.cumulativeUnitElementCount, p = o.elementCount, g = Hd.create(u, p, p / 2, c), v = !1, y = 0, _ = d.length; y < _; ++y) {
      var S = d[y], b = S.conformation.position, x = S.elements;
      l.unit = S;
      for (var A = h[y], w = 0, C = x.length; w < C; w++) {
        l.element = x[w];
        var M = m(l);
        if (M !== 0) {
          b(l.element, Xg);
          var T = "".concat(M > 0 ? "+" : "").concat(M);
          g.add(T, Xg[0], Xg[1], Xg[2], 0, 5, A + w), v = !0;
        }
      }
      if (!v) {
        var N = o.boundary.sphere.center;
        g.add("", N[0], N[1], N[2], 0, 0, A + 1);
      }
    }
    return g.getText();
  }(0, t, 0, n, a);
}
var Xg = D(), Hk = { "element-sphere": function(e, t) {
  return ji("Element sphere", e, t, pS);
}, "intra-bond": function(e, t) {
  return ji("Intra-unit bond cylinder", e, t, Uk);
}, "inter-bond": function(e, t) {
  return um("Inter-unit bond cylinder", e, t, Vk);
}, "charge-text": function(e, t) {
  return um("Charge Text", e, t, hS);
} }, tI = k(k(k(k(k({}, Ah), { traceOnly: V.Boolean(!1, { isHidden: !0 }) }), Ny), Py), { includeParent: V.Boolean(!1), unitKinds: Gh(["atomic"]), sizeFactor: V.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: V.Numeric(0.5, { min: 0.01, max: 3, step: 0.01 }), visuals: V.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], V.objectToOptions(Hk)), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory) }), lo = { name: "ball-and-stick", label: "Ball & Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return fr.createMulti("Ball & Stick", e, t, ys, Hk);
}, getParams: function(e, t) {
  return V.clone(tI);
}, defaultValues: V.getDefaultValues(tI), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, Kk = { create: function(e, t, r) {
  var n;
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return (a = lo.factory(t, lo.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, a.createOrUpdate(k(k({}, lo.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} };
function Fn(e, t, r) {
  r === void 0 && (r = {});
  var n, a, i, o, s = 0, u = new pa(), c = fr.createState(), l = Sl(), d = [], f = -1, m = nu.createEmpty(), h = V.getDefaultValues(t.Params);
  r.modifyState && fr.updateState(c, r.modifyState(c));
  var p = fc.create();
  function g(v, y) {
    return Vo(v) || or.isLoci(v) && v.shape === a ? y(Fe.ofBounds(0, a.groupCount * a.transforms.length)) : function(_, S, b) {
      if (!mo.isLoci(_) || _.shape !== S) return !1;
      for (var x = !1, A = S.groupCount, w = _.groups, C = 0, M = w; C < M.length; C++) {
        var T = M[C], N = T.ids, I = T.instance;
        if (Fe.is(N)) {
          var P = I * A + Fe.start(N), O = I * A + Fe.end(N);
          b(Fe.ofBounds(P, O)) && (x = !0);
        } else for (var F = 0, R = N.length; F < R; F++) {
          var G = I * A + N[F];
          b(Fe.ofSingleton(G)) && (x = !0);
        }
      }
      return x;
    }(v, a, y);
  }
  return { label: "Shape geometry", get groupCount() {
    return i ? i.count : 0;
  }, get props() {
    return h;
  }, get params() {
  }, get state() {
    return c;
  }, get theme() {
    return m;
  }, renderObjects: d, get geometryVersion() {
    return f;
  }, updated: u, createOrUpdate: function(v, y) {
    var _ = this;
    return v === void 0 && (v = {}), r.modifyProps && (v = r.modifyProps(v)), sr.create("ShapeRepresentation.create", function(S) {
      return Be(_, 0, void 0, function() {
        var b, x, A, w, C, M, T, N;
        return Te(this, function(I) {
          switch (I.label) {
            case 0:
              return b = Object.assign(h, v), y ? [4, e(S, y, b, a)] : [3, 2];
            case 1:
              return A = I.sent(), [3, 3];
            case 2:
              A = void 0, I.label = 3;
            case 3:
              if (function(P, O) {
                fc.reset(p), (O || a) && (O && !a ? p.createNew = !0 : O && a && O.id === a.id || (O && a && O.id !== a.id ? (p.updateTransform = !0, p.createGeometry = !0) : O && console.warn("unexpected state")), p.updateTransform && (p.updateColor = !0, p.updateSize = !0), p.createGeometry && (p.updateColor = !0, p.updateSize = !0));
              }(0, x = A), x && (a = x, Object.assign(m, or.getTheme(a))), p.createNew) d.length = 0, i = or.groupIterator(a), w = or.createTransform(a.transforms), C = t.createValues(a.geometry, w, i, m, b), M = t.createRenderableState(b), r.modifyState && Object.assign(M, r.modifyState(M)), fr.updateState(c, M), (n = g1(a.geometry.kind, C, M, l)) && d.push(n), o = t.createPositionIterator(a.geometry, n.values);
              else {
                if (!n) throw new Error("expected renderObject to be available");
                p.updateTransform && (or.createTransform(a.transforms, n.values), i = or.groupIterator(a), T = i.instanceCount, N = i.groupCount, ru(T * N, n.values)), p.createGeometry && (U.updateIfChanged(n.values.drawCount, vi.getDrawCount(a.geometry)), U.updateIfChanged(n.values.uVertexCount, vi.getVertexCount(a.geometry))), (p.updateTransform || p.createGeometry) && (t.updateBoundingSphere(n.values, a.geometry), o = t.createPositionIterator(a.geometry, n.values)), p.updateColor && hs(i, o, m.color, n.values), p.updateSize && "uSize" in n.values && xl(i, m.size, n.values), t.updateValues(n.values, b), t.updateRenderableState(n.state, b);
              }
              return h = b, (p.createGeometry || p.createNew) && (f += 1), u.next(s++), [2];
          }
        });
      });
    });
  }, getLoci: function(v) {
    if (v === void 0) return or.Loci(a);
    var y = v.objectId, _ = v.groupId, S = v.instanceId;
    return n && n.id === y ? mo.Loci(a, [{ ids: We.ofSingleton(_), instance: S }]) : Tn;
  }, mark: function(v, y) {
    if (!qr.is(c.markerActions, y)) return !1;
    if (mo.isLoci(v) || or.isLoci(v)) {
      if (v.shape !== a) return !1;
    } else if (!Vo(v)) return !1;
    return cr.mark(n, v, y, g);
  }, setState: function(v) {
    r.modifyState && (v = r.modifyState(v)), n && (v.visible !== void 0 && cr.setVisibility(n, v.visible), v.alphaFactor !== void 0 && cr.setAlphaFactor(n, v.alphaFactor), v.pickable !== void 0 && cr.setPickable(n, v.pickable), v.colorOnly !== void 0 && cr.setColorOnly(n, v.colorOnly), v.overpaint !== void 0 && cr.setOverpaint(n, v.overpaint, g, !0), v.transparency !== void 0 && cr.setTransparency(n, v.transparency, g, !0), v.substance !== void 0 && cr.setSubstance(n, v.substance, g, !0), v.transform !== void 0 && cr.setTransform(n, v.transform)), fr.updateState(c, v);
  }, setTheme: function(v) {
    zr && console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`");
  }, destroy: function() {
    d.length = 0, n && (n.state.disposed = !0, n = void 0);
  } };
}
var b1 = { granularity: "element", condensed: !1, reverse: !1, countsOnly: !1, hidePrefix: !1, htmlStyling: !0 };
function Xk(e, t) {
  switch (t === void 0 && (t = {}), e.kind) {
    case "structure-loci":
      return e.structure.models.map(function(c) {
        return c.entry;
      }).filter(function(c) {
        return !!c;
      }).join(", ");
    case "element-loci":
      return function(c, l) {
        l === void 0 && (l = {});
        var d = k(k({}, b1), l), f = function(m, h, p, g, v) {
          h === void 0 && (h = !1), p === void 0 && (p = !1), g === void 0 && (g = !1), v === void 0 && (v = !1);
          var y = m.structureCount, _ = m.chainCount, S = m.residueCount, b = m.conformationCount, x = m.elementCount;
          if (h || x !== 1 || S !== 0 || _ !== 0) {
            if (h || x !== 0 || S !== 1 || _ !== 0) {
              if (h || x !== 0 || S !== 0 || _ !== 1) {
                if (h)
                  return A = [], y > 0 && A.push(yp(y, "Structure")), _ > 0 && A.push(yp(_, "Chain")), S > 0 && A.push(yp(S, "Residue")), b > 0 && A.push(yp(b, "Conformation")), x > 0 && A.push(yp(x, "Element")), A.join("<small> + </small>");
                var A = [];
                return y > 0 && A.push(y === 1 ? Kc(m.firstStructureLoc, { hidePrefix: p, condensed: g, granularity: "structure", reverse: v }, !0) : f0(y, m.firstStructureLoc, "structure", p, v, g)), _ > 0 && (A.push(_ === 1 ? Kc(m.firstChainLoc, { condensed: g, granularity: "chain", hidePrefix: p, reverse: v }, !0) : f0(_, m.firstChainLoc, "chain", p, v, g)), p = !0), S > 0 && (A.push(S === 1 ? Kc(m.firstResidueLoc, { condensed: g, granularity: "residue", hidePrefix: p, reverse: v }, !0) : f0(S, m.firstResidueLoc, "residue", p, v, g)), p = !0), b > 0 && (A.push(b === 1 ? Kc(m.firstConformationLoc, { condensed: g, granularity: "conformation", hidePrefix: p, reverse: v }, !0) : f0(b, m.firstConformationLoc, "conformation", p, v, g)), p = !0), x > 0 && A.push(x === 1 ? Kc(m.firstElementLoc, { condensed: g, granularity: "element", hidePrefix: p, reverse: v }, !0) : f0(x, m.firstElementLoc, "element", p, v, g)), A.join("<small> + </small>");
              }
              var w = m.firstChainLoc.unit, C = Ke.isAtomic(w) && function(M) {
                var T = M.elements, N = M.model, I = N.atomicHierarchy, P = I.chainAtomSegments, O = I.residueAtomSegments, F = P.offsets[P.index[T[0]]], R = P.offsets[P.index[T[T.length - 1]] + 1] - 1;
                return O.index[R] - O.index[F] + 1;
              }(w) === 1 || Ke.Traits.is(w.traits, 1) ? "residue" : "chain";
              return Kc(m.firstChainLoc, { hidePrefix: p, condensed: g, granularity: C, reverse: v }, !0);
            }
            return Kc(m.firstResidueLoc, { hidePrefix: p, condensed: g, granularity: "residue", reverse: v }, !0);
          }
          return Kc(m.firstElementLoc, { hidePrefix: p, condensed: g, granularity: "element", reverse: v }, !0);
        }(c, d.countsOnly, d.hidePrefix, d.condensed, d.reverse);
        return d.htmlStyling ? f : s8(f);
      }(nm.ofLoci(e), t);
    case "bond-loci":
      var r = e.bonds[0];
      return r ? jk(r) : "";
    case "shape-loci":
      return e.shape.name;
    case "group-loci":
      var n = e.groups[0];
      return n ? e.shape.getLabel(We.start(n.ids), n.instance) : "";
    case "every-loci":
      return "Everything";
    case "empty-loci":
      return "Nothing";
    case "data-loci":
      return e.getLabel();
    case "volume-loci":
      return e.volume.label || "Volume";
    case "isosurface-loci":
      return ["".concat(e.volume.label || "Volume"), "Isosurface at ".concat(dr.IsoValue.toString(e.isoValue))].join(" | ");
    case "cell-loci":
      var a = We.size(e.indices), i = We.start(e.indices), o = dr.IsoValue.absolute(e.volume.grid.cells.data[i]), s = dr.IsoValue.toRelative(o, e.volume.grid.stats), u = ["".concat(e.volume.label || "Volume"), "".concat(a === 1 ? "Cell #".concat(i) : "".concat(a, " Cells"))];
      return a === 1 && u.push("".concat(dr.IsoValue.toString(o), " (").concat(dr.IsoValue.toString(s), ")")), u.join(" | ");
  }
}
function yp(e, t) {
  return e === 1 ? "1 ".concat(t) : "".concat(e, " ").concat(t, "s");
}
function f0(e, t, r, n, a, i) {
  return "".concat(Kc(t, { granularity: r, hidePrefix: n, reverse: a, condensed: i }), " <small>[+ ").concat(yp(e - 1, "other ".concat(o8(r))), "]</small>");
}
function jk(e, t) {
  return t === void 0 && (t = {}), N3({ loci: [et(e.aStructure, [{ unit: e.aUnit, indices: We.ofSingleton(e.aIndex) }]), et(e.bStructure, [{ unit: e.bUnit, indices: We.ofSingleton(e.bIndex) }])] }, t);
}
function N3(e, t) {
  t === void 0 && (t = {});
  var r = k(k({}, b1), t), n = function(a, i) {
    for (var o = i.granularity, s = i.hidePrefix, u = i.reverse, c = i.condensed, l = !0, d = 0, f = a.loci; d < f.length; d++) {
      var m = f[d];
      if (!et.is(m) || et.size(m) !== 1) {
        l = !1;
        break;
      }
    }
    if (l) {
      var h = a.loci.map(function(A) {
        var w = A.elements[0], C = w.unit, M = w.indices;
        return lt.create(A.structure, C, C.elements[We.start(M)]);
      }), p = h.map(function(A) {
        return Yk(A, o, s, u || c);
      });
      if (c) return p.map(function(A) {
        return A[0].replace(/\[.*\]/g, "").trim();
      }).filter(function(A) {
        return !!A;
      }).join(" — ");
      for (var g = 0, v = 0, y = Math.min.apply(Math, p.map(function(A) {
        return A.length;
      })) - 1; v < y; ++v) {
        for (var _ = !0, S = 1, b = p.length; S < b; ++S) if (p[0][v] !== p[S][v]) {
          _ = !1;
          break;
        }
        if (!_) break;
        g += 1;
      }
      if (g > 0) {
        var x = [p[0].join(" | ")];
        for (S = 1, b = p.length; S < b; ++S) x.push(p[S].slice(g).filter(function(A) {
          return !!A;
        }).join(" | "));
        return x.join(" — ");
      }
      return p.map(function(A) {
        return A.filter(function(w) {
          return !!w;
        }).join(" | ");
      }).filter(function(A) {
        return !!A;
      }).join("</br>");
    }
    return p = a.loci.map(function(A) {
      return Xk(A, i);
    }), p.filter(function(A) {
      return !!A;
    }).join(c ? " — " : "</br>");
  }(e, r);
  return r.htmlStyling ? n : s8(n);
}
function Kc(e, t, r) {
  var n, a;
  t === void 0 && (t = {});
  var i = k(k({}, b1), t), o = Yk(e, i.granularity, i.hidePrefix, i.reverse || i.condensed), s = (i.condensed ? (a = (n = o[0]) === null || n === void 0 ? void 0 : n.replace(/\[.*\]/g, "").trim()) !== null && a !== void 0 ? a : "" : o.filter(function(u) {
    return !!u;
  }).join(" | ")) + (r ? function(u) {
    if (u >= 90) return "<div><small>Plddt ".concat(u, " (Very high)</small></div>");
    if (u < 90 && u >= 70) return "<div><small>Plddt ".concat(u, " (Confident)</small></div>");
    if (u < 70 && u >= 50) return "<div><small>Plddt ".concat(u, " (Low)</small></div>");
    if (u < 50) return "<div><small>Plddt ".concat(u, " (Very low)</small></div>");
  }(at.atom.B_iso_or_equiv(e)) : "");
  return i.htmlStyling ? s : s8(s);
}
function Yk(e, t, r, n) {
  t === void 0 && (t = "element"), r === void 0 && (r = !1), n === void 0 && (n = !1);
  var a = [];
  if (!r) {
    var i = e.unit.model.entry;
    i.length > 30 && (i = i.substr(0, 27) + "…"), a.push("<small>".concat(i, "</small>")), t !== "structure" && (a.push("<small>Model ".concat(e.unit.model.modelNum, "</small>")), a.push("<small>Instance ".concat(e.unit.conformation.operator.name, "</small>")));
  }
  return Ke.isAtomic(e.unit) ? a.push.apply(a, function(o, s, u) {
    u === void 0 && (u = !1);
    var c = lt.residueIndex(o), l = at.chain.label_asym_id(o), d = at.chain.auth_asym_id(o), f = o.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(c) === 0, m = at.residue.label_seq_id(o), h = at.residue.auth_seq_id(o), p = at.residue.pdbx_PDB_ins_code(o), g = at.atom.label_comp_id(o), v = at.atom.label_atom_id(o), y = at.atom.label_alt_id(o), _ = at.atom.occupancy(o), S = at.atom.id(o), b = at.residue.microheterogeneityCompIds(o), x = s === "residue" && b.length > 1 ? "(".concat(b.join("|"), ")") : g, A = [];
    switch (s) {
      case "element":
        A.push("<b>".concat(v, " ").concat(S, "</b>").concat(y ? "%".concat(y) : ""));
      case "conformation":
        s === "conformation" && y && A.push("<small>Conformation</small> <b>".concat(y, "</b>"));
      case "residue":
        var w = m === h && f ? m : h;
        A.push("<b>".concat(x, " ").concat(w, "</b>").concat(w !== m ? " <small>[auth</small> <b>".concat(m, "</b><small>]</small>") : "", "<b>").concat(p || "", "</b>"));
      case "chain":
        l === d ? A.push("<b>".concat(l, "</b>")) : s === "chain" && Ke.Traits.is(o.unit.traits, 1) ? A.push("<small>[auth</small> <b>".concat(d, "</b><small>]</small>")) : A.push("<b>".concat(l, "</b> <small>[auth</small> <b>").concat(d, "</b><small>]</small>"));
    }
    return A.length > 0 && _ !== 1 && !u && (A[0] = "".concat(A[0], " <small>[occupancy</small> <b>").concat(Math.round(100 * _) / 100, "</b><small>]</small>")), A.reverse();
  }(e, t, n)) : Ke.isCoarse(e.unit) ? a.push.apply(a, function(o, s) {
    var u = at.coarse.asym_id(o), c = at.coarse.seq_id_begin(o), l = at.coarse.seq_id_end(o), d = [];
    switch (s) {
      case "element":
      case "conformation":
      case "residue":
        if (c === l) {
          var f = at.coarse.entityKey(o), m = o.unit.model.sequence.byEntityKey[f].sequence.compId.value(c - 1);
          d.push("<b>".concat(m, " ").concat(c, "</b>"));
        } else d.push("<b>".concat(c, "-").concat(l, "</b>"));
      case "chain":
        d.push("<b>".concat(u, "</b>"));
    }
    return d.reverse();
  }(e, t)) : a.push("Unknown"), n ? a.reverse() : a;
}
function wh(e, t) {
  t === void 0 && (t = {});
  var r = k(k(k({}, b1), { measureOnly: !1, unitLabel: "Å" }), t), n = e.loci.map(function(u) {
    return an.getCenter(u);
  }), a = n[0], i = n[1], o = "".concat(D.distance(a, i).toFixed(2), " ").concat(r.unitLabel);
  if (r.measureOnly) return o;
  var s = N3(e, r);
  return r.condensed ? "".concat(o, " | ").concat(s) : "Distance ".concat(o, "</br>").concat(s);
}
function vS(e, t) {
  t === void 0 && (t = {});
  var r = k(k(k({}, b1), { measureOnly: !1 }), t), n = e.loci.map(function(d) {
    return an.getCenter(d);
  }), a = n[0], i = n[1], o = n[2], s = D.sub(D(), a, i), u = D.sub(D(), o, i), c = "".concat(Bi(D.angle(s, u)).toFixed(2), "°");
  if (r.measureOnly) return c;
  var l = N3(e, r);
  return r.condensed ? "".concat(c, " | ").concat(l) : "Angle ".concat(c, "</br>").concat(l);
}
function gS(e, t) {
  t === void 0 && (t = {});
  var r = k(k(k({}, b1), { measureOnly: !1 }), t), n = e.loci.map(function(l) {
    return an.getCenter(l);
  }), a = n[0], i = n[1], o = n[2], s = n[3], u = "".concat(Bi(D.dihedralAngle(a, i, o, s)).toFixed(2), "°");
  if (r.measureOnly) return u;
  var c = N3(e, r);
  return r.condensed ? "".concat(u, " | ").concat(c) : "Dihedral ".concat(u, "</br>").concat(c);
}
var xle = { customText: V.Text("", { label: "Text", description: "Override the label with custom value.", isEssential: !0 }), textColor: V.Color($t.black, { isEssential: !0 }), textSize: V.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }, P3 = k(k(k({}, vs.Params), xle), { borderWidth: V.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 }) }), _le = k(k({}, P3), { offsetZ: V.Numeric(2, { min: 0, max: 10, step: 0.1 }), textSize: V.Numeric(0.7, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }), Wk = { text: function(e, t) {
  return Fn(wle, vs.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !0 });
  } });
} }, Sle = k(k({}, _le), { scaleByRadius: V.Boolean(!1), visuals: V.MultiSelect(["text"], V.objectToOptions(Wk)), textColor: V.Color(Qe.fromRgb(241, 160, 119), { isEssential: !0 }) }), Ale = Ve();
function v5(e, t) {
  return t === void 0 && (t = !1), e.label || Xk(e.loci, { hidePrefix: !0, htmlStyling: !1, condensed: t }).split("Plddt")[0];
}
function wle(e, t, r, n) {
  var a = function(u, c, l) {
    for (var d = Hd.create(c, 128, 64, l), f = c.customText.trim(), m = 0, h = u.infos.length; m < h; ++m) {
      var p = u.infos[m], g = an.getBoundingSphere(p.loci, Ale);
      if (g) {
        var v = g.center, y = g.radius, _ = f || v5(p, !0);
        d.add(_, v[0], v[1], v[2], c.scaleByRadius ? y / 0.9 : 0, c.scaleByRadius ? Math.max(1, y) : 1, m);
      }
    }
    return d.getText();
  }(t, r, n && n.geometry), i = function(u) {
    return u.infos.length === 1 ? v5(u.infos[0]) : "".concat(u.infos.length, " Labels");
  }(t), o = r.customText.trim(), s = o ? function(u) {
    return o;
  } : function(u) {
    return v5(t.infos[u]);
  };
  return or.create(i, t, a, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, s);
}
var Cle = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            var u = fr.createMulti("Label", o, s, fr.StateBuilder, Wk);
            return u.setState({ pickable: !0, markerActions: qr.All }), u;
          }(t, function() {
            return Sle;
          }), [4, a.createOrUpdate(r ?? {}, { infos: e[0].loci ? e : e.map(function(o) {
            return { loci: o };
          }) }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { infos: t.map(function(i) {
            return { loci: i };
          }) }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Zk = { unitLabel: V.Text("Å", { isEssential: !0 }) }, Ele = k(k(k({}, Ur.Params), Zk), { lineSizeAttenuation: V.Boolean(!0), linesColor: V.Color($t.lightgreen, { isEssential: !0 }), linesSize: V.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }), dashLength: V.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 }) }), Dle = k(k({}, P3), Zk), Qk = { lines: function(e, t) {
  return Fn(Ile, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !0, markerActions: qr.All });
  } });
}, text: function(e, t) {
  return Fn(Tle, vs.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
} }, Mle = k(k(k({}, Ele), Dle), { visuals: V.MultiSelect(["lines", "text"], V.objectToOptions(Qk)) });
function $k(e, t) {
  var r = t.sphereA, n = t.sphereB, a = t.center, i = e.loci, o = i[0], s = i[1];
  return an.getBoundingSphere(o, r), an.getBoundingSphere(s, n), D.add(a, r.center, n.center), D.scale(a, a, 0.5), t.distance = D.distance(r.center, n.center), t;
}
var gd = { sphereA: Ve(), sphereB: Ve(), center: D(), distance: 0 };
function Jk(e, t) {
  return e.pairs.length === 1 ? "Distance ".concat(wh(e.pairs[0], { unitLabel: t, measureOnly: !0 })) : "".concat(e.pairs.length, " Distances");
}
function Ile(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) $k(o.pairs[l], gd), c.addFixedLengthDashes(gd.sphereA.center, gd.sphereB.center, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = Jk(t, r.unitLabel);
  return or.create(i, t, a, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return wh(t.pairs[o], r);
  });
}
function Tle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = Hd.create(s, 128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) {
      $k(o.pairs[l], gd);
      var f = gd.center, m = gd.distance, h = gd.sphereA, p = gd.sphereB, g = s.customText || "".concat(m.toFixed(2), " ").concat(s.unitLabel), v = Math.max(2, h.radius, p.radius) / 2;
      c.add(g, f[0], f[1], f[2], 1, v, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), i = Jk(t, r.unitLabel);
  return or.create(i, t, a, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return wh(t.pairs[o], r);
  });
}
var Nle = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            var u = fr.createMulti("Distance", o, s, fr.StateBuilder, Qk);
            return u.setState({ pickable: !0, markerActions: qr.All }), u;
          }(t, function() {
            return Mle;
          }), [4, a.createOrUpdate(r ?? {}, { pairs: [{ loci: e.slice(-2) }] }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Ple = { radius: 1, segments: 36, thetaStart: 0, thetaLength: 2 * Math.PI };
function yS(e) {
  var t = k(k({}, Ple), e), r = t.radius, n = t.segments, a = t.thetaStart, i = t.thetaLength, o = i === 2 * Math.PI, s = o ? n + 1 : n + 2, u = new Float32Array(3 * s), c = new Float32Array(3 * s), l = new Uint32Array(3 * n);
  u[0] = 0, u[1] = 0, u[2] = 0, c[0] = 0, c[1] = 1, c[2] = 0;
  for (var d = 0, f = 3; d < n; ++d, f += 3) {
    var m = a + d / n * i;
    u[f] = r * Math.sin(m), u[f + 1] = 0, u[f + 2] = r * Math.cos(m), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0;
  }
  for (d = 1, f = 0; d < n; ++d, f += 3) l[f] = d, l[f + 1] = d + 1, l[f + 2] = 0;
  if (o)
    l[h = 3 * (n - 1)] = n, l[h + 1] = 1, l[h + 2] = 0;
  else {
    var h;
    m = a + i, u[f = 3 * (n + 1)] = r * Math.sin(m), u[f + 1] = 0, u[f + 2] = r * Math.cos(m), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0, l[h = 3 * (n - 1)] = n, l[h + 1] = n + 1, l[h + 2] = 0;
  }
  return { vertices: u, normals: c, indices: l };
}
var ez = { color: V.Color($t.lightgreen), arcScale: V.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, tz = k(k(k({}, Ur.Params), ez), { lineSizeAttenuation: V.Boolean(!0), linesSize: V.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: V.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), Ble = k({}, tz), Ole = k({}, tz), Fle = k(k(k({}, Xt.Params), ez), { ignoreLight: V.Boolean(!0), sectorOpacity: V.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), rz = { vectors: function(e, t) {
  return Fn(Lle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1 });
  } });
}, arc: function(e, t) {
  return Fn(kle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1 });
  } });
}, sector: function(e, t) {
  return Fn(zle, Xt.Utils, { modifyProps: function(r) {
    return k(k({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.Highlighting });
  } });
}, text: function(e, t) {
  return Fn(Ule, vs.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: Et.None });
  } });
} }, Rle = k(k(k(k(k({}, Ble), Ole), Fle), P3), { visuals: V.MultiSelect(["vectors", "sector", "text"], V.objectToOptions(rz)) }), nd = D(), m0 = Ee();
function B3(e, t, r) {
  var n = t.sphereA, a = t.sphereB, i = t.sphereC, o = t.arcDirA, s = t.arcDirC, u = t.arcNormal, c = e.loci, l = c[0], d = c[1], f = c[2];
  an.getBoundingSphere(l, n), an.getBoundingSphere(d, a), an.getBoundingSphere(f, i), D.sub(o, n.center, a.center), D.sub(s, i.center, a.center), D.cross(u, o, s);
  var m = Math.min(D.magnitude(o), D.magnitude(s)) * r;
  return t.radius = m, t.angle = D.angle(o, s), t;
}
function nz(e, t) {
  var r = e.radius, n = e.angle, a = t ? DO(n, r) / t : 32;
  return Ee.targetTo(m0, e.sphereB.center, e.sphereA.center, e.arcNormal), Ee.setTranslation(m0, e.sphereB.center), Ee.mul(m0, m0, Ee.rotY180), p3(yS({ radius: r, thetaLength: n, segments: a }), m0);
}
var di = { sphereA: Ve(), sphereB: Ve(), sphereC: Ve(), arcDirA: D(), arcDirC: D(), arcNormal: D(), radius: 0, angle: 0 };
function O3(e) {
  return e.triples.length === 1 ? "Angle ".concat(vS(e.triples[0], { measureOnly: !0 })) : "".concat(e.triples.length, " Angles");
}
function Lle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) B3(o.triples[l], di, s.arcScale), c.addFixedLengthDashes(di.sphereB.center, di.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(di.sphereB.center, di.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = O3(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function kle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      B3(o.triples[l], di, s.arcScale);
      for (var f = nz(di, s.dashLength), m = f.indices, h = f.vertices, p = 0, g = m.length; p < g; p += 3) if (p % 2 != 1) {
        var v = 3 * m[p], y = 3 * m[p + 1], _ = h[v], S = h[v + 1], b = h[v + 2], x = h[y], A = h[y + 1], w = h[y + 2];
        c.add(_, S, b, x, A, w, l);
      }
    }
    return c.getLines();
  }(t, r, n && n.geometry), i = O3(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function zle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = Nt.createState(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      B3(o.triples[l], di, s.arcScale);
      var f = nz(di);
      c.currentGroup = l, Nt.addPrimitive(c, Ee.id, f), Nt.addPrimitiveFlipped(c, Ee.id, f);
    }
    return Nt.getMesh(c);
  }(t, r, n && n.geometry), i = O3(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return vS(t.triples[o]);
  });
}
function Ule(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = Hd.create(s, 128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      B3(o.triples[l], di, s.arcScale), D.add(nd, di.arcDirA, di.arcDirC), D.setMagnitude(nd, nd, di.radius), D.add(nd, di.sphereB.center, nd);
      var f = Bi(di.angle).toFixed(2), m = s.customText || "".concat(f, "°"), h = Math.max(2, di.sphereA.radius, di.sphereB.radius, di.sphereC.radius) / 2;
      c.add(m, nd[0], nd[1], nd[2], 0.1, h, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), i = O3(t);
  return or.create(i, t, a, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return vS(t.triples[o]);
  });
}
var Gle = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            return fr.createMulti("Angle", o, s, fr.StateBuilder, rz);
          }(t, function() {
            return Rle;
          }), [4, a.createOrUpdate(r ?? {}, { triples: [{ loci: e.slice(-3) }] }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { triples: [{ loci: t.slice(-3) }] }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, az = { color: V.Color($t.lightgreen), arcScale: V.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, F3 = k(k(k({}, Ur.Params), az), { lineSizeAttenuation: V.Boolean(!0), linesSize: V.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: V.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), Vle = k({}, F3), qle = k({}, F3), Hle = k({}, F3), Kle = k({}, F3), Xle = k(k(k({}, Xt.Params), az), { ignoreLight: V.Boolean(!0), sectorOpacity: V.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), iz = { vectors: function(e, t) {
  return Fn(Yle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
}, extenders: function(e, t) {
  return Fn(Qle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
}, connector: function(e, t) {
  return Fn(Wle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
}, arms: function(e, t) {
  return Fn(Zle, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
}, arc: function(e, t) {
  return Fn($le, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { pickable: !1, markerActions: qr.All });
  } });
}, sector: function(e, t) {
  return Fn(Jle, Xt.Utils, { modifyProps: function(r) {
    return k(k({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, text: function(e, t) {
  return Fn(ede, vs.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
} }, jle = k(k(k(k(k(k(k({}, Vle), qle), Hle), Kle), Xle), P3), { visuals: V.MultiSelect(["extenders", "arms", "sector", "text"], V.objectToOptions(iz)) }), Ki = D(), p0 = Ee();
function pm(e, t, r) {
  var n = t.sphereA, a = t.sphereB, i = t.sphereC, o = t.sphereD, s = t.dirBA, u = t.dirCD, c = t.projA, l = t.projD, d = t.arcPointA, f = t.arcPointD, m = t.arcDirA, h = t.arcDirD, p = t.arcCenter, g = t.arcNormal, v = e.loci, y = v[0], _ = v[1], S = v[2], b = v[3];
  an.getBoundingSphere(y, n), an.getBoundingSphere(_, a), an.getBoundingSphere(S, i), an.getBoundingSphere(b, o), D.add(p, a.center, i.center), D.scale(p, p, 0.5), D.sub(s, n.center, a.center), D.sub(u, o.center, i.center), D.add(d, p, s), D.add(f, p, u), D.sub(g, i.center, a.center), D.orthogonalize(m, g, s), D.orthogonalize(h, g, u), D.projectPointOnVector(c, d, m, p), D.projectPointOnVector(l, f, h, p);
  var x = Math.min(D.distance(c, p), D.distance(l, p)) * r;
  D.setMagnitude(m, m, x), D.setMagnitude(h, h, x), D.add(d, p, m), D.add(f, p, h), t.radius = x, t.angle = D.dihedralAngle(n.center, a.center, i.center, o.center), D.matchDirection(Ki, g, D.sub(Ki, d, n.center));
  var A = D.angle(s, Ki), w = x / Math.cos(A - Iw);
  D.add(c, a.center, D.setMagnitude(Ki, s, w)), D.matchDirection(Ki, g, D.sub(Ki, f, o.center));
  var C = D.angle(u, Ki), M = x / Math.cos(C - Iw);
  return D.add(l, i.center, D.setMagnitude(Ki, u, M)), t;
}
function oz(e, t) {
  var r = e.radius, n = e.angle, a = t ? DO(n, r) / t : 32;
  return Ee.targetTo(p0, e.arcCenter, n < 0 ? e.arcPointD : e.arcPointA, e.arcNormal), Ee.setTranslation(p0, e.arcCenter), Ee.mul(p0, p0, Ee.rotY180), p3(yS({ radius: r, thetaLength: Math.abs(n), segments: a }), p0);
}
var ln = { sphereA: Ve(), sphereB: Ve(), sphereC: Ve(), sphereD: Ve(), dirBA: D(), dirCD: D(), projA: D(), projD: D(), arcPointA: D(), arcPointD: D(), arcDirA: D(), arcDirD: D(), arcCenter: D(), arcNormal: D(), radius: 0, angle: 0 };
function hm(e) {
  return e.quads.length === 1 ? "Dihedral ".concat(gS(e.quads[0], { measureOnly: !0 })) : "".concat(e.quads.length, " Dihedrals");
}
function Yle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) pm(o.quads[l], ln, s.arcScale), c.addFixedLengthDashes(ln.arcCenter, ln.arcPointA, s.dashLength, l), c.addFixedLengthDashes(ln.arcCenter, ln.arcPointD, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Wle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) pm(o.quads[l], ln, s.arcScale), c.addFixedLengthDashes(ln.sphereB.center, ln.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Zle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) pm(o.quads[l], ln, s.arcScale), c.addFixedLengthDashes(ln.sphereB.center, ln.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(ln.sphereC.center, ln.sphereD.center, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Qle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) pm(o.quads[l], ln, s.arcScale), c.addFixedLengthDashes(ln.arcPointA, ln.projA, s.dashLength, l), c.addFixedLengthDashes(ln.arcPointD, ln.projD, s.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function $le(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      pm(o.quads[l], ln, s.arcScale);
      for (var f = oz(ln, s.dashLength), m = f.indices, h = f.vertices, p = 0, g = m.length; p < g; p += 3) if (p % 2 != 1) {
        var v = 3 * m[p], y = 3 * m[p + 1], _ = h[v], S = h[v + 1], b = h[v + 2], x = h[y], A = h[y + 1], w = h[y + 2];
        c.add(_, S, b, x, A, w, l);
      }
    }
    return c.getLines();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Jle(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = Nt.createState(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      pm(o.quads[l], ln, s.arcScale);
      var f = oz(ln);
      c.currentGroup = l, Nt.addPrimitive(c, Ee.id, f), Nt.addPrimitiveFlipped(c, Ee.id, f);
    }
    return Nt.getMesh(c);
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return gS(t.quads[o]);
  });
}
function ede(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = Hd.create(s, 128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      pm(o.quads[l], ln, s.arcScale), D.add(Ki, ln.arcDirA, ln.arcDirD), D.setMagnitude(Ki, Ki, ln.radius), D.add(Ki, ln.arcCenter, Ki);
      var f = Bi(ln.angle).toFixed(2);
      f === "-0.00" && (f = "0.00");
      var m = s.customText || "".concat(f, "°"), h = Math.max(2, ln.sphereA.radius, ln.sphereB.radius, ln.sphereC.radius, ln.sphereD.radius) / 2;
      c.add(m, Ki[0], Ki[1], Ki[2], 0.1, h, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), i = hm(t);
  return or.create(i, t, a, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return gS(t.quads[o]);
  });
}
var tde = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            var u = fr.createMulti("Dihedral", o, s, fr.StateBuilder, iz);
            return u.setState({ pickable: !0, markerActions: qr.All }), u;
          }(t, function() {
            return jle;
          }), [4, a.createOrUpdate(r ?? {}, { quads: [{ loci: e.slice(-4) }] }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { quads: [{ loci: t.slice(-4) }] }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, g5 = pr.is;
function rde(e, t, r, n, a, i) {
  if (!Ke.isAtomic(t)) return Ur.createEmpty(i);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Ur.createEmpty(i);
  var u = lt.create(r, t), c = t.elements, l = t.bonds, d = l.edgeCount, f = l.a, m = l.b, h = l.edgeProps, p = l.offset;
  if (!d) return Ur.createEmpty(i);
  var g = h.order, v = h.flags, y = a.sizeFactor, _ = a.aromaticBonds, S = a.includeTypes, b = a.excludeTypes, x = a.multipleBonds, A = x === "off", w = x === "symmetric", C = I3(pr.fromNames(S), pr.fromNames(b), 32), M = D(), T = t.conformation.invariantPosition, N = t.rings, I = N.elementRingIndices, P = N.elementAromaticRingIndices, O = _ ? t.resonance.delocalizedTriplets : void 0, F = { linkCount: 2 * d, referencePosition: function(K) {
    var X, H, W = f[K], ee = m[K], $ = O == null ? void 0 : O.getThirdElement(W, ee);
    if ($ !== void 0) return T(c[$], M);
    W > ee && (W = (X = [ee, W])[0], ee = X[1]), p[W + 1] - p[W] == 1 && (W = (H = [ee, W])[0], ee = H[1]);
    for (var te = P.get(W) || I.get(W), re = 0, ie = p[W], oe = p[W + 1]; ie < oe; ++ie) {
      var se = m[ie];
      if (se !== ee && se !== W) {
        if (!te) return T(c[se], M);
        var he = P.get(se) || I.get(se);
        if (!he) continue;
        var ge = Y2(te, he);
        ge > re && (re = ge, T(c[se], M));
      }
    }
    return re > 0 ? M : null;
  }, position: function(K, X, H) {
    T(c[f[H]], K), T(c[m[H]], X);
  }, style: function(K) {
    var X = g[K], H = v[K];
    if (g5(H, 2) || g5(H, 4)) return 1;
    if (X === 3) return A ? 0 : w ? 4 : 5;
    if (_) {
      var W = f[K], ee = m[K], $ = P.get(W), te = P.get(ee), re = $ && te ? Y2($, te) : 0;
      if (g5(H, 16) || re && !C) {
        if (re === 2) return 8;
        if (re === 1 || O != null && O.getThirdElement(W, ee)) return 7;
      }
    }
    return X !== 2 || A ? 0 : w ? 2 : 3;
  }, radius: function(K) {
    u.element = c[f[K]];
    var X = n.size.size(u);
    u.element = c[m[K]];
    var H = n.size.size(u);
    return Math.min(X, H) * y;
  }, ignore: Lk(r, t, a) }, R = Rk(0, F, a, i), G = R.lines, L = R.boundingSphere;
  if (L) G.setBoundingSphere(L);
  else if (G.lineCount > 0) {
    var q = Ve.expand(Ve(), (s ?? t).boundary.sphere, 1 * y);
    G.setBoundingSphere(q);
  }
  return G;
}
var sz = k(k(k({}, uS), mS), { includeParent: V.Boolean(!1) });
function nde(e) {
  return cS({ defaultProps: V.getDefaultValues(sz), createGeometry: rde, createLocationIterator: Kd.fromGroup, getLoci: b_, eachLocation: x_, setUpdateState: function(t, r, n, a, i, o, s) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !ho(r.includeTypes, n.includeTypes) || !ho(r.excludeTypes, n.excludeTypes) || r.aromaticBonds !== n.aromaticBonds || r.multipleBonds !== n.multipleBonds;
    var u = o.group.units[0], c = s.group.units[0];
    Ke.isAtomic(u) && Ke.isAtomic(c) && (Ho.areEqual(u.bonds, c.bonds) || (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0));
  } }, e);
}
var y5 = new Pt.ElementBondIterator();
function rI(e, t, r, n) {
  for (y5.setElement(t, r, n); y5.hasNext; ) {
    var a = y5.move();
    return a.otherUnit.conformation.position(a.otherUnit.elements[a.otherIndex], e), e;
  }
  return null;
}
function ade(e, t, r, n, a) {
  var i = t.interUnitBonds, o = i.edgeCount, s = i.edges;
  if (!o) return Ur.createEmpty(a);
  var u = n.sizeFactor, c = n.aromaticBonds, l = n.multipleBonds, d = l === "off", f = l === "symmetric", m = D(), h = lt.create(), p = { linkCount: o, referencePosition: function(b) {
    var x, A, w, C, M = s[b];
    if (M.unitA < M.unitB) x = t.unitMap.get(M.unitA), A = t.unitMap.get(M.unitB), w = M.indexA, C = M.indexB;
    else {
      if (!(M.unitA > M.unitB)) throw new Error("same units in createInterUnitBondLines");
      x = t.unitMap.get(M.unitB), A = t.unitMap.get(M.unitA), w = M.indexB, C = M.indexA;
    }
    return rI(m, t, x, w) || rI(m, t, A, C);
  }, position: function(b, x, A) {
    var w = s[A], C = t.unitMap.get(w.unitA), M = t.unitMap.get(w.unitB);
    C.conformation.position(C.elements[w.indexA], b), M.conformation.position(M.elements[w.indexB], x);
  }, style: function(b) {
    var x = s[b].props.order, A = Ti.create(s[b].props.flag);
    return pr.is(A, 2) || pr.is(A, 4) ? 1 : x === 3 ? d ? 0 : f ? 4 : 5 : c && pr.is(A, 16) ? 7 : x !== 2 || d ? 0 : f ? 2 : 3;
  }, radius: function(b) {
    var x = s[b];
    h.structure = t, h.unit = t.unitMap.get(x.unitA), h.element = h.unit.elements[x.indexA];
    var A = r.size.size(h);
    h.unit = t.unitMap.get(x.unitB), h.element = h.unit.elements[x.indexB];
    var w = r.size.size(h);
    return Math.min(A, w) * u;
  }, ignore: kk(t, n) }, g = Rk(0, p, n, a), v = g.lines, y = g.boundingSphere;
  if (y) v.setBoundingSphere(y);
  else if (v.lineCount > 0) {
    var _ = t.child, S = Ve.expand(Ve(), (_ ?? t).boundary.sphere, 1 * u);
    v.setBoundingSphere(S);
  }
  return v;
}
var uz = k(k(k({}, ece), mS), { includeParent: V.Boolean(!1) });
function ide(e) {
  return function(t, r) {
    return E3(k(k({}, t), { setUpdateState: function(n, a, i, o, s, u, c) {
      t.setUpdateState(n, a, i, o, s, u, c), go.areEqual(o.size, s.size) || (n.updateSize = !0);
    }, geometryUtils: Ur.Utils }), r);
  }({ defaultProps: V.getDefaultValues(uz), createGeometry: ade, createLocationIterator: Kd.fromStructure, getLoci: __, eachLocation: S_, setUpdateState: function(t, r, n, a, i, o, s) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !ho(r.includeTypes, n.includeTypes) || !ho(r.excludeTypes, n.excludeTypes) || r.multipleBonds !== n.multipleBonds, o.interUnitBonds !== s.interUnitBonds && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0);
  } }, e);
}
var A_, ode = Ye.add3, sde = Ye.add;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var a = Ye.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : t), i = Ye.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t);
    return { add: function(o, s, u, c) {
      ode(a, o, s, u), sde(i, c);
    }, getPoints: function() {
      var o = Ye.compact(a, !0), s = Ye.compact(i, !0);
      return im.create(o, s, a.elementCount, n);
    } };
  };
})(A_ || (A_ = {}));
var nI = D.add, cz = k(k({}, ace), { pointSizeAttenuation: V.Boolean(!1), ignoreHydrogens: V.Boolean(!1), traceOnly: V.Boolean(!1) });
function ude(e, t, r, n, a, i) {
  var o = r.child;
  if (o && !o.unitMap.get(t.id)) return im.createEmpty(i);
  var s = t.elements, u = s.length, c = A_.create(u, u / 10, i), l = D(), d = t.conformation.invariantPosition, f = T3(r, t, a), m = D(), h = 0;
  if (f) for (var p = 0; p < u; ++p) f(s[p]) || (d(s[p], l), nI(m, m, l), h += 1, c.add(l[0], l[1], l[2], p));
  else for (p = 0; p < u; ++p) d(s[p], l), nI(m, m, l), h += 1, c.add(l[0], l[1], l[2], p);
  var g, v = i ? Ve.clone(i.boundingSphere) : void 0, y = c.getPoints();
  return h === 0 || (D.scale(m, m, 1 / h), g = v && D.distance(m, v.center) / v.radius < 1 ? v : Ve.expand(Ve(), t.boundary.sphere, 1), y.setBoundingSphere(g)), y;
}
function cde(e) {
  return function(t, r) {
    return Vh(k(k({}, t), { setUpdateState: function(n, a, i, o, s, u, c) {
      t.setUpdateState(n, a, i, o, s, u, c), go.areEqual(o.size, s.size) || (n.updateSize = !0);
    }, geometryUtils: im.Utils }), r);
  }({ defaultProps: V.getDefaultValues(cz), createGeometry: ude, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(t, r, n) {
    t.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly;
  } }, e);
}
var up = D.scaleAndAdd, aI = D.unitX, iI = D.unitY, oI = D.unitZ, lz = k(k({}, uS), { lineSizeAttenuation: V.Boolean(!1), ignoreHydrogens: V.Boolean(!1), traceOnly: V.Boolean(!1), crosses: V.Select("lone", V.arrayToOptions(["lone", "all"])), crossSize: V.Numeric(0.35, { min: 0, max: 2, step: 0.01 }) });
function lde(e, t, r, n, a, i) {
  var o = r.child;
  if (o && !o.unitMap.get(t.id)) return Ur.createEmpty(i);
  for (var s = t.elements, u = s.length, c = hi.create(u, u / 10, i), l = D(), d = D(), f = D(), m = t.conformation.invariantPosition, h = T3(r, t, a), p = a.crossSize / 2, g = a.crosses === "lone", v = 0; v < u; ++v) h && h(s[v]) || g && Ke.isAtomic(t) && bh(r, t, v) !== 0 || (m(s[v], l), up(d, l, aI, p), up(f, l, aI, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], v), up(d, l, iI, p), up(f, l, iI, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], v), up(d, l, oI, p), up(f, l, oI, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], v));
  var y = c.getLines(), _ = Ve.expand(Ve(), t.boundary.sphere, 1 * a.sizeFactor);
  return y.setBoundingSphere(_), y;
}
function dde(e) {
  return cS({ defaultProps: V.getDefaultValues(lz), createGeometry: lde, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(t, r, n) {
    t.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly || r.crosses !== n.crosses || r.crossSize !== n.crossSize;
  } }, e);
}
var dz = { "intra-bond": function(e, t) {
  return ji("Intra-unit bond line", e, t, nde);
}, "inter-bond": function(e, t) {
  return um("Inter-unit bond line", e, t, ide);
}, "element-point": function(e, t) {
  return ji("Points", e, t, cde);
}, "element-cross": function(e, t) {
  return ji("Crosses", e, t, dde);
}, "charge-text": function(e, t) {
  return um("Charge Text", e, t, hS);
} }, sI = k(k(k(k(k({}, sz), uz), cz), lz), { multipleBonds: V.Select("offset", V.arrayToOptions(["off", "symmetric", "offset"])), includeParent: V.Boolean(!1), sizeFactor: V.Numeric(0.01, { min: 0.01, max: 10, step: 0.01 }), unitKinds: Gh(["atomic"]), visuals: V.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross", "charge-text"], V.objectToOptions(dz)), lineSizeAttenuation: V.Boolean(!0), traceOnly: V.Boolean(!1, { isHidden: !0 }), pointSizeAttenuation: V.Boolean(!0), pointStyle: V.Select("circle", V.objectToOptions({ square: "Square", circle: "Circle", fuzzy: "Fuzzy" })) }), b5 = { name: "line", label: "Line", description: "Displays bonds as lines and atoms as points or croses.", factory: function(e, t) {
  return fr.createMulti("Line", e, t, ys, dz);
}, getParams: function(e, t) {
  var r = V.clone(sI);
  return r.pointStyle.defaultValue = "circle", r;
}, defaultValues: V.getDefaultValues(sI), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, fde = { create: function(e, t, r) {
  var n;
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return (a = b5.factory(t, b5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, a.createOrUpdate(k(k({}, b5.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }), e).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, fz = { "element-sphere": function(e, t) {
  return ji("Element sphere", e, t, pS);
}, "intra-bond": function(e, t) {
  return ji("Intra-unit bond cylinder", e, t, Uk);
}, "inter-bond": function(e, t) {
  return um("Inter-unit bond cylinder", e, t, Vk);
}, "charge-text": function(e, t) {
  return um("Charge Text", e, t, hS);
} }, uI = k(k(k(k(k({}, Ah), { traceOnly: V.Boolean(!1, { isHidden: !0 }) }), Ny), Py), { includeParent: V.Boolean(!1), unitKinds: Gh(["atomic"]), visuals: V.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], V.objectToOptions(fz)), bumpFrequency: V.Numeric(0, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), sizeFactor: V.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: V.Numeric(1, { min: 0.01, max: 3, step: 0.01 }), multipleBonds: V.Select("offset", V.arrayToOptions(["off", "symmetric", "offset"])), tryUseImpostor: V.Boolean(!0), linkScale: V.Numeric(0.55, { min: 0, max: 1, step: 0.01 }) }), x5 = { name: "stick", label: "Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return fr.createMulti("Ball & Stick", e, t, ys, fz);
}, getParams: function(e, t) {
  return V.clone(uI);
}, defaultValues: V.getDefaultValues(uI), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, mde = { create: function(e, t, r) {
  var n;
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return (a = x5.factory(t, x5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, a.createOrUpdate(k(k({}, x5.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, bS = { probeRadius: V.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }), resolution: V.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, k({ description: "Grid resolution/cell spacing." }, yt.CustomQualityParamInfo)), probePositions: V.Numeric(36, { min: 12, max: 90, step: 1 }, k({ description: "Number of positions tested for probe target intersection." }, yt.CustomQualityParamInfo)) };
function pde(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    function o(Se, Ne, J, Z, de) {
      if (d !== -1) {
        if ((Ce = d) !== Z && Ce !== de && s(Ce, Se, Ne, J)) return Ce;
        d = -1;
      }
      for (var ye = 0, Ae = A.count; ye < Ae; ++ye) {
        var Ce;
        if ((Ce = We.getAt(w, A.indices[ye])) !== Z && Ce !== de && s(Ce, Se, Ne, J)) return d = Ce, Ce;
      }
      return -1;
    }
    function s(Se, Ne, J, Z) {
      var de = I[Se], ye = C[Se] - Ne, Ae = M[Se] - J, Ce = T[Se] - Z;
      return ye * ye + Ae * Ae + Ce * Ce < de * de;
    }
    function u() {
      return Be(this, 0, void 0, function() {
        var Se;
        return Te(this, function(Ne) {
          switch (Ne.label) {
            case 0:
              Se = 0, Ne.label = 1;
            case 1:
              return Se < P ? (function(J, Z) {
                for (var de = J; de < Z; ++de) {
                  var ye = We.getAt(w, de), Ae = C[ye], Ce = M[ye], Ie = T[ye], Ue = I[ye], Xe = Ue * Ue;
                  x.find(Ae, Ce, Ie, Ue);
                  for (var je = Math.ceil(Ue * _), ht = Math.floor(_ * (Ae - G)), xt = Math.floor(_ * (Ce - L)), dt = Math.floor(_ * (Ie - q)), Le = Math.max(0, ht - je), j = Math.max(0, xt - je), xe = Math.max(0, dt - je), ke = Math.min(H, ht + je + 2), Je = Math.min(W, xt + je + 2), Ct = Math.min(ee, dt + je + 2), At = Le; At < ke; ++At) for (var Or = De[At] - Ae, qn = At * te, Xn = j; Xn < Je; ++Xn) for (var kn = ae[Xn] - Ce, fn = Or * Or + kn * kn, la = Xn * $ + qn, mn = xe; mn < Ct; ++mn) {
                    var pn = ce[mn] - Ie, ba = fn + pn * pn;
                    if (ba < Xe) {
                      var xa = mn + la;
                      he[xa] < 0 && (he[xa] *= -1);
                      var to = Math.sqrt(ba), zn = Ue / to;
                      if (o(Or * zn + Ae, kn * zn + Ce, pn * zn + Ie, ye, -1) === -1) {
                        var An = Ue - to;
                        An < he[xa] && (he[xa] = An, ge[xa] = N[de]);
                      }
                    }
                  }
                }
              }(Se, Math.min(Se + _e, P)), e.shouldUpdate ? [4, e.update({ message: "projecting points", current: Se, max: P })] : [3, 3]) : [3, 4];
            case 2:
              Ne.sent(), Ne.label = 3;
            case 3:
              return Se += _e, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    function c(Se, Ne) {
      var J = I[Se], Z = I[Ne], de = f[0] = C[Ne] - C[Se], ye = f[1] = M[Ne] - M[Se], Ae = f[2] = T[Ne] - T[Se], Ce = de * de + ye * ye + Ae * Ae, Ie = Math.sqrt(Ce), Ue = J * ((J * J + Ie * Ie - Z * Z) / (2 * J * Ie));
      D.normalize(f, f), function(ro, _a) {
        ro[0] = ro[1] = ro[2] = 1, _a[0] !== 0 ? ro[0] = (_a[1] + _a[2]) / -_a[0] : _a[1] !== 0 ? ro[1] = (_a[0] + _a[2]) / -_a[1] : _a[2] !== 0 && (ro[2] = (_a[0] + _a[1]) / -_a[2]);
      }(h, f), D.normalize(h, h), D.cross(p, f, h), D.normalize(p, p);
      var Xe = Math.sqrt(J * J - Ue * Ue);
      D.scale(h, h, Xe), D.scale(p, p, Xe), D.scale(f, f, Ue), m[0] = f[0] + C[Se], m[1] = f[1] + M[Se], m[2] = f[2] + T[Se], d = -1;
      for (var je = 0; je < y; ++je) {
        var ht = ie[je], xt = oe[je], dt = m[0] + ht * h[0] + xt * p[0], Le = m[1] + ht * h[1] + xt * p[1], j = m[2] + ht * h[2] + xt * p[2];
        if (o(dt, Le, j, Se, Ne) === -1) for (var xe = Math.floor(_ * (dt - G)), ke = Math.floor(_ * (Le - L)), Je = Math.floor(_ * (j - q)), Ct = Math.max(0, xe - S), At = Math.max(0, ke - S), Or = Math.max(0, Je - S), qn = Math.min(H, xe + S + 2), Xn = Math.min(W, ke + S + 2), kn = Math.min(ee, Je + S + 2), fn = Ct; fn < qn; ++fn) for (var la = dt - De[fn], mn = fn * te, pn = At; pn < Xn; ++pn) for (var ba = Le - ae[pn], xa = la * la + ba * ba, to = pn * $ + mn, zn = Or; zn < kn; ++zn) {
          var An = j - ce[zn], jo = xa + An * An, Yo = zn + to, Co = he[Yo];
          if (Co > 0 && jo < Co * Co) {
            he[Yo] = Math.sqrt(jo);
            var Lu = la * f[0] + ba * f[1] + An * f[2];
            ge[Yo] = N[We.indexOf(w, Lu < 0 ? Ne : Se)];
          }
        }
      }
    }
    function l() {
      return Be(this, 0, void 0, function() {
        var Se;
        return Te(this, function(Ne) {
          switch (Ne.label) {
            case 0:
              Se = 0, Ne.label = 1;
            case 1:
              return Se < P ? (function(J, Z) {
                for (var de = J; de < Z; ++de) {
                  var ye = We.getAt(w, de);
                  x.find(C[ye], M[ye], T[ye], I[ye]);
                  for (var Ae = 0, Ce = A.count; Ae < Ce; ++Ae) {
                    var Ie = We.getAt(w, A.indices[Ae]);
                    ye < Ie && c(ye, Ie);
                  }
                }
              }(Se, Math.min(Se + _e, P)), e.shouldUpdate ? [4, e.update({ message: "projecting torii", current: Se, max: P })] : [3, 3]) : [3, 4];
            case 2:
              Ne.sent(), Ne.label = 3;
            case 3:
              return Se += _e, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    var d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R, G, L, q, K, X, H, W, ee, $, te, re, ie, oe, se, he, ge, De, ae, ce, _e, le, ue, be;
    return Te(this, function(Se) {
      switch (Se.label) {
        case 0:
          return d = -1, f = D(), m = D(), h = D(), p = D(), g = i.resolution, v = i.probeRadius, y = i.probePositions, _ = 1 / g, S = Math.max(5, 2 + Math.floor(v * _)), b = D.create(n, n, n), D.scale(b, b, 2), x = Jf(t, r, b), A = x.result, a === null && (a = x.boundary.box), w = t.indices, C = t.x, M = t.y, T = t.z, N = t.id, I = t.radius, P = We.size(w), O = n + g, F = on.expand(on(), a, D.create(O, O, O)), R = F.min, G = R[0], L = R[1], q = R[2], K = on.scale(on(), F, _), X = on.size(D(), K), D.ceil(X, X), H = X[0], W = X[1], ee = X[2], te = ($ = ee) * W, re = function(Ne) {
            for (var J = 0, Z = 2 * Math.PI / Ne, de = new Float32Array(Ne), ye = new Float32Array(Ne), Ae = 0; Ae < Ne; Ae++) de[Ae] = Math.cos(J), ye[Ae] = Math.sin(J), J += Z;
            return { cosTable: de, sinTable: ye };
          }(y), ie = re.cosTable, oe = re.sinTable, se = Wn.Space(X, [0, 1, 2], Float32Array), he = se.create(), ge = se.create(), he.fill(-1001), ge.fill(-1), De = D4(H, G, g), ae = D4(W, L, g), ce = D4(ee, q, g), _e = Math.ceil(1e5 / (Math.pow(Math.pow(n, 3), 3) * _)), [4, u()];
        case 1:
          return Se.sent(), [4, l()];
        case 2:
          return Se.sent(), le = Wn.create(se, he), ue = Wn.create(se, ge), be = Ee.identity(), Ee.fromScaling(be, D.create(g, g, g)), Ee.setTranslation(be, F.min), [2, { field: le, idField: ue, transform: be, resolution: g, maxRadius: n }];
      }
    });
  });
}
function mz(e, t, r, n) {
  var a = this, i = t.lookup3d.boundary.box, o = jue(i, n), s = function(d, f, m, h) {
    for (var p = h.probeRadius, g = Zue(d, f, m, h), v = g.position, y = g.boundary, _ = g.radius, S = v.indices, b = We.size(S), x = new Float32Array(We.end(S)), A = 0, w = 0; w < b; ++w) {
      var C = We.getAt(S, w), M = _(C);
      A < M && (A = M), x[C] = M + p;
    }
    return { position: k(k({}, v), { radius: x }), boundary: y, maxRadius: A };
  }(e, t, r, o), u = s.position, c = s.boundary, l = s.maxRadius;
  return sr.create("Molecular Surface", function(d) {
    return Be(a, 0, void 0, function() {
      return Te(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, hde(d, u, c, l, i, o)];
          case 1:
            return [2, f.sent()];
        }
      });
    });
  });
}
function hde(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(o) {
      return [2, pde(e, t, r, n, a, i)];
    });
  });
}
function ad(e, t, r) {
  return { i: e, j: t, k: r };
}
function zs(e, t) {
  return { a: e, b: t };
}
V.getDefaultValues(bS);
var ea = [ad(0, 0, 0), ad(1, 0, 0), ad(1, 1, 0), ad(0, 1, 0), ad(0, 0, 1), ad(1, 0, 1), ad(1, 1, 1), ad(0, 1, 1)], vde = [zs(ea[0], ea[1]), zs(ea[1], ea[2]), zs(ea[2], ea[3]), zs(ea[3], ea[0]), zs(ea[4], ea[5]), zs(ea[5], ea[6]), zs(ea[6], ea[7]), zs(ea[7], ea[4]), zs(ea[0], ea[4]), zs(ea[1], ea[5]), zs(ea[2], ea[6]), zs(ea[3], ea[7])], gde = [{ i: 0, j: 0, k: 0, e: 0 }, { i: 1, j: 0, k: 0, e: 1 }, { i: 0, j: 1, k: 0, e: 0 }, { i: 0, j: 0, k: 0, e: 1 }, { i: 0, j: 0, k: 1, e: 0 }, { i: 1, j: 0, k: 1, e: 1 }, { i: 0, j: 1, k: 1, e: 0 }, { i: 0, j: 0, k: 1, e: 1 }, { i: 0, j: 0, k: 0, e: 2 }, { i: 1, j: 0, k: 0, e: 2 }, { i: 1, j: 1, k: 0, e: 2 }, { i: 0, j: 1, k: 0, e: 2 }], yde = [0, 265, 515, 778, 1030, 1295, 1541, 1804, 2060, 2309, 2575, 2822, 3082, 3331, 3593, 3840, 400, 153, 915, 666, 1430, 1183, 1941, 1692, 2460, 2197, 2975, 2710, 3482, 3219, 3993, 3728, 560, 825, 51, 314, 1590, 1855, 1077, 1340, 2620, 2869, 2111, 2358, 3642, 3891, 3129, 3376, 928, 681, 419, 170, 1958, 1711, 1445, 1196, 2988, 2725, 2479, 2214, 4010, 3747, 3497, 3232, 1120, 1385, 1635, 1898, 102, 367, 613, 876, 3180, 3429, 3695, 3942, 2154, 2403, 2665, 2912, 1520, 1273, 2035, 1786, 502, 255, 1013, 764, 3580, 3317, 4095, 3830, 2554, 2291, 3065, 2800, 1616, 1881, 1107, 1370, 598, 863, 85, 348, 3676, 3925, 3167, 3414, 2650, 2899, 2137, 2384, 1984, 1737, 1475, 1226, 966, 719, 453, 204, 4044, 3781, 3535, 3270, 3018, 2755, 2505, 2240, 2240, 2505, 2755, 3018, 3270, 3535, 3781, 4044, 204, 453, 719, 966, 1226, 1475, 1737, 1984, 2384, 2137, 2899, 2650, 3414, 3167, 3925, 3676, 348, 85, 863, 598, 1370, 1107, 1881, 1616, 2800, 3065, 2291, 2554, 3830, 4095, 3317, 3580, 764, 1013, 255, 502, 1786, 2035, 1273, 1520, 2912, 2665, 2403, 2154, 3942, 3695, 3429, 3180, 876, 613, 367, 102, 1898, 1635, 1385, 1120, 3232, 3497, 3747, 4010, 2214, 2479, 2725, 2988, 1196, 1445, 1711, 1958, 170, 419, 681, 928, 3376, 3129, 3891, 3642, 2358, 2111, 2869, 2620, 1340, 1077, 1855, 1590, 314, 51, 825, 560, 3728, 3993, 3219, 3482, 2710, 2975, 2197, 2460, 1692, 1941, 1183, 1430, 666, 915, 153, 400, 3840, 3593, 3331, 3082, 2822, 2575, 2309, 2060, 1804, 1541, 1295, 1030, 778, 515, 265, 0], Ip = [[], [0, 8, 3], [0, 1, 9], [1, 8, 3, 9, 8, 1], [1, 2, 10], [0, 8, 3, 1, 2, 10], [9, 2, 10, 0, 2, 9], [2, 8, 3, 2, 10, 8, 10, 9, 8], [3, 11, 2], [0, 11, 2, 8, 11, 0], [1, 9, 0, 2, 3, 11], [1, 11, 2, 1, 9, 11, 9, 8, 11], [3, 10, 1, 11, 10, 3], [0, 10, 1, 0, 8, 10, 8, 11, 10], [3, 9, 0, 3, 11, 9, 11, 10, 9], [9, 8, 10, 10, 8, 11], [4, 7, 8], [4, 3, 0, 7, 3, 4], [0, 1, 9, 8, 4, 7], [4, 1, 9, 4, 7, 1, 7, 3, 1], [1, 2, 10, 8, 4, 7], [3, 4, 7, 3, 0, 4, 1, 2, 10], [9, 2, 10, 9, 0, 2, 8, 4, 7], [2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4], [8, 4, 7, 3, 11, 2], [11, 4, 7, 11, 2, 4, 2, 0, 4], [9, 0, 1, 8, 4, 7, 2, 3, 11], [4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1], [3, 10, 1, 3, 11, 10, 7, 8, 4], [1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4], [4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3], [4, 7, 11, 4, 11, 9, 9, 11, 10], [9, 5, 4], [9, 5, 4, 0, 8, 3], [0, 5, 4, 1, 5, 0], [8, 5, 4, 8, 3, 5, 3, 1, 5], [1, 2, 10, 9, 5, 4], [3, 0, 8, 1, 2, 10, 4, 9, 5], [5, 2, 10, 5, 4, 2, 4, 0, 2], [2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8], [9, 5, 4, 2, 3, 11], [0, 11, 2, 0, 8, 11, 4, 9, 5], [0, 5, 4, 0, 1, 5, 2, 3, 11], [2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5], [10, 3, 11, 10, 1, 3, 9, 5, 4], [4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10], [5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3], [5, 4, 8, 5, 8, 10, 10, 8, 11], [9, 7, 8, 5, 7, 9], [9, 3, 0, 9, 5, 3, 5, 7, 3], [0, 7, 8, 0, 1, 7, 1, 5, 7], [1, 5, 3, 3, 5, 7], [9, 7, 8, 9, 5, 7, 10, 1, 2], [10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3], [8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2], [2, 10, 5, 2, 5, 3, 3, 5, 7], [7, 9, 5, 7, 8, 9, 3, 11, 2], [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11], [2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7], [11, 2, 1, 11, 1, 7, 7, 1, 5], [9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11], [5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0], [11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0], [11, 10, 5, 7, 11, 5], [10, 6, 5], [0, 8, 3, 5, 10, 6], [9, 0, 1, 5, 10, 6], [1, 8, 3, 1, 9, 8, 5, 10, 6], [1, 6, 5, 2, 6, 1], [1, 6, 5, 1, 2, 6, 3, 0, 8], [9, 6, 5, 9, 0, 6, 0, 2, 6], [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8], [2, 3, 11, 10, 6, 5], [11, 0, 8, 11, 2, 0, 10, 6, 5], [0, 1, 9, 2, 3, 11, 5, 10, 6], [5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11], [6, 3, 11, 6, 5, 3, 5, 1, 3], [0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6], [3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9], [6, 5, 9, 6, 9, 11, 11, 9, 8], [5, 10, 6, 4, 7, 8], [4, 3, 0, 4, 7, 3, 6, 5, 10], [1, 9, 0, 5, 10, 6, 8, 4, 7], [10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4], [6, 1, 2, 6, 5, 1, 4, 7, 8], [1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7], [8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6], [7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9], [3, 11, 2, 7, 8, 4, 10, 6, 5], [5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11], [0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6], [9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6], [8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6], [5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11], [0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7], [6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9], [10, 4, 9, 6, 4, 10], [4, 10, 6, 4, 9, 10, 0, 8, 3], [10, 0, 1, 10, 6, 0, 6, 4, 0], [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10], [1, 4, 9, 1, 2, 4, 2, 6, 4], [3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4], [0, 2, 4, 4, 2, 6], [8, 3, 2, 8, 2, 4, 4, 2, 6], [10, 4, 9, 10, 6, 4, 11, 2, 3], [0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6], [3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10], [6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1], [9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3], [8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1], [3, 11, 6, 3, 6, 0, 0, 6, 4], [6, 4, 8, 11, 6, 8], [7, 10, 6, 7, 8, 10, 8, 9, 10], [0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10], [10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0], [10, 6, 7, 10, 7, 1, 1, 7, 3], [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7], [2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9], [7, 8, 0, 7, 0, 6, 6, 0, 2], [7, 3, 2, 6, 7, 2], [2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7], [2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7], [1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11], [11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1], [8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6], [0, 9, 1, 11, 6, 7], [7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0], [7, 11, 6], [7, 6, 11], [3, 0, 8, 11, 7, 6], [0, 1, 9, 11, 7, 6], [8, 1, 9, 8, 3, 1, 11, 7, 6], [10, 1, 2, 6, 11, 7], [1, 2, 10, 3, 0, 8, 6, 11, 7], [2, 9, 0, 2, 10, 9, 6, 11, 7], [6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8], [7, 2, 3, 6, 2, 7], [7, 0, 8, 7, 6, 0, 6, 2, 0], [2, 7, 6, 2, 3, 7, 0, 1, 9], [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6], [10, 7, 6, 10, 1, 7, 1, 3, 7], [10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8], [0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7], [7, 6, 10, 7, 10, 8, 8, 10, 9], [6, 8, 4, 11, 8, 6], [3, 6, 11, 3, 0, 6, 0, 4, 6], [8, 6, 11, 8, 4, 6, 9, 0, 1], [9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6], [6, 8, 4, 6, 11, 8, 2, 10, 1], [1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6], [4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9], [10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3], [8, 2, 3, 8, 4, 2, 4, 6, 2], [0, 4, 2, 4, 6, 2], [1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8], [1, 9, 4, 1, 4, 2, 2, 4, 6], [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1], [10, 1, 0, 10, 0, 6, 6, 0, 4], [4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3], [10, 9, 4, 6, 10, 4], [4, 9, 5, 7, 6, 11], [0, 8, 3, 4, 9, 5, 11, 7, 6], [5, 0, 1, 5, 4, 0, 7, 6, 11], [11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5], [9, 5, 4, 10, 1, 2, 7, 6, 11], [6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5], [7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2], [3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6], [7, 2, 3, 7, 6, 2, 5, 4, 9], [9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7], [3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0], [6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8], [9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7], [1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4], [4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10], [7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10], [6, 9, 5, 6, 11, 9, 11, 8, 9], [3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5], [0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11], [6, 11, 3, 6, 3, 5, 5, 3, 1], [1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6], [0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10], [11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5], [6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3], [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2], [9, 5, 6, 9, 6, 0, 0, 6, 2], [1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8], [1, 5, 6, 2, 1, 6], [1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6], [10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0], [0, 3, 8, 5, 6, 10], [10, 5, 6], [11, 5, 10, 7, 5, 11], [11, 5, 10, 11, 7, 5, 8, 3, 0], [5, 11, 7, 5, 10, 11, 1, 9, 0], [10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1], [11, 1, 2, 11, 7, 1, 7, 5, 1], [0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11], [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7], [7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2], [2, 5, 10, 2, 3, 5, 3, 7, 5], [8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5], [9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2], [9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2], [1, 3, 5, 3, 7, 5], [0, 8, 7, 0, 7, 1, 1, 7, 5], [9, 0, 3, 9, 3, 5, 5, 3, 7], [9, 8, 7, 5, 9, 7], [5, 8, 4, 5, 10, 8, 10, 11, 8], [5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0], [0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5], [10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4], [2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8], [0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11], [0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5], [9, 4, 5, 2, 11, 3], [2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4], [5, 10, 2, 5, 2, 4, 4, 2, 0], [3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9], [5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2], [8, 4, 5, 8, 5, 3, 3, 5, 1], [0, 4, 5, 1, 0, 5], [8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5], [9, 4, 5], [4, 11, 7, 4, 9, 11, 9, 10, 11], [0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11], [1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11], [3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4], [4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2], [9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3], [11, 7, 4, 11, 4, 2, 2, 4, 0], [11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4], [2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9], [9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7], [3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10], [1, 10, 2, 8, 7, 4], [4, 9, 1, 4, 1, 7, 7, 1, 3], [4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1], [4, 0, 3, 7, 4, 3], [4, 8, 7], [9, 10, 8, 10, 11, 8], [3, 0, 9, 3, 9, 11, 11, 9, 10], [0, 1, 10, 0, 10, 8, 8, 10, 11], [3, 1, 10, 11, 3, 10], [1, 2, 11, 1, 11, 9, 9, 11, 8], [3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9], [0, 2, 11, 8, 0, 11], [3, 2, 11], [2, 3, 8, 2, 8, 10, 10, 8, 9], [9, 10, 2, 0, 9, 2], [2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8], [1, 10, 2], [1, 3, 8, 9, 1, 8], [0, 9, 1], [0, 3, 8], []], _5 = [[0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0], [4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0], [4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8], [4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1], [2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0], [0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0], [0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8], [0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1], [2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1], [2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0], [0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8], [0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0]];
function pz(e) {
  return k(k({}, e), { bottomLeft: Pa(e.bottomLeft, [0, 0, 0]), topRight: Pa(e.topRight, e.scalarField.space.dimensions) });
}
function hz(e) {
  return { dX: e.topRight[0] - e.bottomLeft[0], dY: e.topRight[1] - e.bottomLeft[1], dZ: e.topRight[2] - e.bottomLeft[2] };
}
function vz(e, t) {
  var r = this;
  return sr.create("Marching Cubes Mesh", function(n) {
    return Be(r, 0, void 0, function() {
      var a, i, o, s, u, c, l;
      return Te(this, function(d) {
        switch (d.label) {
          case 0:
            return a = pz(e), i = hz(a), o = i.dX, s = i.dY, u = i.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(f, m) {
              var h = Math.min(65536, 4 * f), p = Ye.create(Float32Array, 3, f, m && m.vertexBuffer.ref.value), g = Ye.create(Float32Array, 3, f, m && m.normalBuffer.ref.value), v = Ye.create(Float32Array, 1, f, m && m.groupBuffer.ref.value), y = Ye.create(Uint32Array, 3, h, m && m.indexBuffer.ref.value), _ = 0, S = 0;
              return { addVertex: function(b, x, A) {
                return ++_, Ye.add3(p, b, x, A);
              }, addNormal: function(b, x, A) {
                Ye.add3(g, b, x, A);
              }, addGroup: function(b) {
                Ye.add(v, b);
              }, addTriangle: function(b, x, A, w) {
                var C = b[x], M = b[A], T = b[w];
                C >= 0 && M >= 0 && T >= 0 && (++S, Ye.add3(y, C, M, T));
              }, get: function() {
                var b = Ye.compact(p, !0), x = Ye.compact(g, !0), A = Ye.compact(y, !0), w = Ye.compact(v, !0);
                return Xt.create(b, A, x, w, _, S, m);
              } };
            }(c, t), [4, new yz(n, l, a).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
function gz(e, t) {
  var r = this;
  return sr.create("Marching Cubes Lines", function(n) {
    return Be(r, 0, void 0, function() {
      var a, i, o, s, u, c, l;
      return Te(this, function(d) {
        switch (d.label) {
          case 0:
            return a = pz(e), i = hz(a), o = i.dX, s = i.dY, u = i.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(f, m) {
              var h = Ye.create(Float32Array, 3, f), p = Ye.create(Float32Array, 1, f), g = Ye.create(Float32Array, 2, f), v = 0;
              return { addVertex: function(y, _, S) {
                return Ye.add3(h, y, _, S);
              }, addNormal: function() {
                return p8;
              }, addGroup: function(y) {
                Ye.add(p, y);
              }, addTriangle: function(y, _, S, b, x) {
                var A = y[_], w = y[S], C = y[b];
                A >= 0 && w >= 0 && C >= 0 && (_5[_][S] & x && (++v, Ye.add2(g, y[_], y[S])), _5[S][b] & x && (++v, Ye.add2(g, y[S], y[b])), _5[_][b] & x && (++v, Ye.add2(g, y[_], y[b])));
              }, get: function() {
                for (var y = Ye.compact(h, !0), _ = Ye.compact(g, !0), S = Ye.compact(p, !0), b = hi.create(v, v / 10, m), x = 0; x < v; ++x) {
                  var A = _[2 * x], w = _[2 * x + 1];
                  b.add(y[3 * A], y[3 * A + 1], y[3 * A + 2], y[3 * w], y[3 * w + 1], y[3 * w + 2], S[A]);
                }
                return b.getLines();
              } };
            }(c, t), [4, new yz(n, l, a).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
var yz = function() {
  function e(t, r, n) {
    this.ctx = t, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new bde(r, n), this.minX = n.bottomLeft[0], this.minY = n.bottomLeft[1], this.minZ = n.bottomLeft[2], this.maxX = n.topRight[0] - 1, this.maxY = n.topRight[1] - 1, this.maxZ = n.topRight[2] - 1, this.size = (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ), this.sliceSize = (this.maxX - this.minX) * (this.maxY - this.minY);
  }
  return e.prototype.doSlices = function() {
    return Be(this, 0, void 0, function() {
      var t, r;
      return Te(this, function(n) {
        switch (n.label) {
          case 0:
            t = 0, this.edgeFilter = 15, r = this.minZ, n.label = 1;
          case 1:
            return r < this.maxZ ? (this.slice(r), t += this.sliceSize, this.ctx.shouldUpdate ? [4, this.ctx.update({ message: "Computing surface...", current: t, max: this.size })] : [3, 3]) : [3, 4];
          case 2:
            n.sent(), n.label = 3;
          case 3:
            return r++, this.edgeFilter &= -5, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.slice = function(t) {
    this.edgeFilter |= 2;
    for (var r = this.minY; r < this.maxY; r++, this.edgeFilter &= -3) {
      this.edgeFilter |= 1;
      for (var n = this.minX; n < this.maxX; n++, this.edgeFilter &= -2) this.state.processCell(n, r, t, this.edgeFilter);
    }
    this.state.clearEdgeVertexIndexSlice(t);
  }, e.prototype.run = function() {
    return Be(this, 0, void 0, function() {
      return Te(this, function(t) {
        switch (t.label) {
          case 0:
            return [4, this.doSlices()];
          case 1:
            return t.sent(), [2];
        }
      });
    });
  }, e;
}(), bde = function() {
  function e(t, r) {
    this.builder = t, this.vertList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this.i = 0, this.j = 0, this.k = 0;
    var n = r.scalarField.space.dimensions;
    this.nX = n[0], this.nY = n[1], this.nZ = n[2], this.isoLevel = r.isoLevel, this.scalarFieldGet = r.scalarField.space.get, this.scalarField = r.scalarField.data, r.idField && (this.idField = r.idField.data, this.idFieldGet = r.idField.space.get), this.verticesOnEdges = new Int32Array(3 * this.nX * this.nY * 2);
  }
  return e.prototype.get3dOffsetFromEdgeInfo = function(t) {
    return this.nX * ((this.k + t.k) % 2 * this.nY + this.j + t.j) + this.i + t.i;
  }, e.prototype.clearEdgeVertexIndexSlice = function(t) {
    var r = t % 2 == 0 ? 0 : 3 * this.nX * this.nY, n = t % 2 == 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
    this.verticesOnEdges.fill(0, r, n);
  }, e.prototype.interpolate = function(t) {
    var r = gde[t], n = 3 * this.get3dOffsetFromEdgeInfo(r) + r.e, a = this.verticesOnEdges[n];
    if (a > 0) return a - 1;
    var i = this.scalarField, o = this.scalarFieldGet, s = vde[t], u = s.a, c = s.b, l = u.i + this.i, d = u.j + this.j, f = u.k + this.k, m = c.i + this.i, h = c.j + this.j, p = c.k + this.k, g = o(i, l, d, f), v = o(i, m, h, p), y = (this.isoLevel - g) / (g - v);
    if (this.idField) {
      var _ = this.idFieldGet(this.idField, l, d, f), S = this.idFieldGet(this.idField, m, h, p), b = y < 0.5 ? _ : S;
      if (b === -1 && (b = y < 0.5 ? S : _), b === -2) return -1;
      this.builder.addGroup(b);
    } else this.builder.addGroup(0);
    var x = this.builder.addVertex(l + y * (l - m), d + y * (d - h), f + y * (f - p));
    this.verticesOnEdges[n] = x + 1;
    var A = o(i, Math.max(0, l - 1), d, f) - o(i, Math.min(this.nX - 1, l + 1), d, f), w = o(i, l, Math.max(0, d - 1), f) - o(i, l, Math.min(this.nY - 1, d + 1), f), C = o(i, l, d, Math.max(0, f - 1)) - o(i, l, d, Math.min(this.nZ, f + 1)), M = A + y * (A - (o(i, Math.max(0, m - 1), h, p) - o(i, Math.min(this.nX - 1, m + 1), h, p))), T = w + y * (w - (o(i, m, Math.max(0, h - 1), p) - o(i, m, Math.min(this.nY - 1, h + 1), p))), N = C + y * (C - (o(i, m, h, Math.max(0, p - 1)) - o(i, m, h, Math.min(this.nZ - 1, p + 1))));
    return this.isoLevel >= 0 ? this.builder.addNormal(M, T, N) : this.builder.addNormal(-M, -T, -N), x;
  }, e.prototype.get = function(t, r, n) {
    return this.scalarFieldGet(this.scalarField, t, r, n);
  }, e.prototype.processCell = function(t, r, n, a) {
    var i = 0;
    if (this.get(t, r, n) < this.isoLevel && (i |= 1), this.get(t + 1, r, n) < this.isoLevel && (i |= 2), this.get(t + 1, r + 1, n) < this.isoLevel && (i |= 4), this.get(t, r + 1, n) < this.isoLevel && (i |= 8), this.get(t, r, n + 1) < this.isoLevel && (i |= 16), this.get(t + 1, r, n + 1) < this.isoLevel && (i |= 32), this.get(t + 1, r + 1, n + 1) < this.isoLevel && (i |= 64), this.get(t, r + 1, n + 1) < this.isoLevel && (i |= 128), i !== 0 && i !== 255) {
      this.i = t, this.j = r, this.k = n;
      var o = yde[i];
      (1 & o) > 0 && (this.vertList[0] = this.interpolate(0)), (2 & o) > 0 && (this.vertList[1] = this.interpolate(1)), (4 & o) > 0 && (this.vertList[2] = this.interpolate(2)), (8 & o) > 0 && (this.vertList[3] = this.interpolate(3)), (16 & o) > 0 && (this.vertList[4] = this.interpolate(4)), (32 & o) > 0 && (this.vertList[5] = this.interpolate(5)), (64 & o) > 0 && (this.vertList[6] = this.interpolate(6)), (128 & o) > 0 && (this.vertList[7] = this.interpolate(7)), (256 & o) > 0 && (this.vertList[8] = this.interpolate(8)), (512 & o) > 0 && (this.vertList[9] = this.interpolate(9)), (1024 & o) > 0 && (this.vertList[10] = this.interpolate(10)), (2048 & o) > 0 && (this.vertList[11] = this.interpolate(11));
      for (var s = Ip[i], u = 0; u < s.length; u += 3) {
        var c = s[u], l = s[u + 1], d = s[u + 2];
        this.isoLevel >= 0 ? this.builder.addTriangle(this.vertList, c, l, d, a) : this.builder.addTriangle(this.vertList, d, l, c, a);
      }
    }
  }, e;
}(), bz = k(k(k(k({}, Al), bS), sS), Qre);
function xde(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, m, h;
    return Te(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, mz(r, t, n.size, a).runInContext(e.runtime)];
        case 1:
          return o = p.sent(), s = o.transform, u = o.field, c = o.idField, l = o.resolution, d = o.maxRadius, [4, vz({ isoLevel: a.probeRadius, scalarField: u, idField: c }, i).runAsChild(e.runtime)];
        case 2:
          return f = p.sent(), a.includeParent && (m = Math.ceil(2 / a.resolution), Xt.smoothEdges(f, { iterations: m, maxNewEdgeLength: Math.sqrt(2) })), Xt.transform(f, s), e.webgl && !e.webgl.isWebGL2 && Xt.uniformTriangleGroup(f), h = Ve.expand(Ve(), t.boundary.sphere, d), f.setBoundingSphere(h), f.meta.resolution = l, [2, f];
      }
    });
  });
}
function _de(e) {
  return wl({ defaultProps: V.getDefaultValues(bz), createGeometry: xde, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(t, r, n) {
    r.resolution !== n.resolution && (t.createGeometry = !0), r.probeRadius !== n.probeRadius && (t.createGeometry = !0), r.probePositions !== n.probePositions && (t.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (t.createGeometry = !0), r.traceOnly !== n.traceOnly && (t.createGeometry = !0), r.includeParent !== n.includeParent && (t.createGeometry = !0), r.smoothColors.name !== n.smoothColors.name ? t.updateColor = !0 : r.smoothColors.name === "on" && n.smoothColors.name === "on" && (r.smoothColors.params.resolutionFactor !== n.smoothColors.params.resolutionFactor && (t.updateColor = !0), r.smoothColors.params.sampleStride !== n.smoothColors.params.sampleStride && (t.updateColor = !0));
  }, processValues: function(t, r, n, a, i) {
    var o = r.meta, s = o.resolution, u = o.colorTexture, c = Of(n.smoothColors, a.color.preferSmoothing, s);
    c && (function(l, d, f, m, h) {
      if (/* @__PURE__ */ function(g) {
        return g === "group" || g === "groupInstance";
      }(l.dColorType.ref.value)) {
        var p = I2({ vertexCount: l.uVertexCount.ref.value, instanceCount: l.uInstanceCount.ref.value, groupCount: l.uGroupCount.ref.value, transformBuffer: l.aTransform.ref.value, instanceBuffer: l.aInstance.ref.value, positionBuffer: l.aPosition.ref.value, groupBuffer: l.aGroup.ref.value, colorData: l.tColor.ref.value, colorType: l.dColorType.ref.value, boundingSphere: l.boundingSphere.ref.value, invariantBoundingSphere: l.invariantBoundingSphere.ref.value, itemSize: 3 }, d, f, m, h);
        p.kind === "volume" ? (U.updateIfChanged(l.dColorType, p.type), U.update(l.tColorGrid, p.texture), U.update(l.uColorTexDim, p.gridTexDim), U.update(l.uColorGridDim, p.gridDim), U.update(l.uColorGridTransform, p.gridTransform)) : p.kind === "vertex" && (U.updateIfChanged(l.dColorType, p.type), U.update(l.tColor, p.texture), U.update(l.uColorTexDim, p.texDim));
      }
    }(t, c.resolution, c.stride, i, u), r.meta.colorTexture = t.tColorGrid.ref.value);
  }, dispose: function(t) {
    var r;
    (r = t.meta.colorTexture) === null || r === void 0 || r.destroy();
  } }, e);
}
var xz = k(k(k(k({}, uS), bS), sS), { sizeFactor: V.Numeric(1.5, { min: 0, max: 10, step: 0.1 }) });
function Sde(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    var o, s, u, c, l, d, f;
    return Te(this, function(m) {
      switch (m.label) {
        case 0:
          return [4, mz(r, t, n.size, a).runInContext(e.runtime)];
        case 1:
          return o = m.sent(), s = o.transform, u = o.field, c = o.idField, l = o.maxRadius, [4, gz({ isoLevel: a.probeRadius, scalarField: u, idField: c }, i).runAsChild(e.runtime)];
        case 2:
          return d = m.sent(), Ur.transform(d, s), f = Ve.expand(Ve(), t.boundary.sphere, l), d.setBoundingSphere(f), [2, d];
      }
    });
  });
}
function Ade(e) {
  return cS({ defaultProps: V.getDefaultValues(xz), createGeometry: Sde, createLocationIterator: pl.fromGroup, getLoci: n1, eachLocation: r1, setUpdateState: function(t, r, n) {
    r.resolution !== n.resolution && (t.createGeometry = !0), r.probeRadius !== n.probeRadius && (t.createGeometry = !0), r.probePositions !== n.probePositions && (t.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (t.createGeometry = !0), r.includeParent !== n.includeParent && (t.createGeometry = !0);
  } }, e);
}
var _z = { "molecular-surface-mesh": function(e, t) {
  return ji("Molecular surface mesh", e, t, _de);
}, "molecular-surface-wireframe": function(e, t) {
  return ji("Molecular surface wireframe", e, t, Ade);
} }, cI = k(k(k({}, bz), xz), { visuals: V.MultiSelect(["molecular-surface-mesh"], V.objectToOptions(_z)), bumpFrequency: V.Numeric(1, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory) }), S5, A5 = { name: "molecular-surface", label: "Molecular Surface", description: "Displays a molecular surface.", factory: function(e, t) {
  return fr.createMulti("Molecular Surface", e, t, ys, _z);
}, getParams: function(e, t) {
  return V.clone(cI);
}, defaultValues: V.getDefaultValues(cI), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, wde = { parse: function(e, t) {
  var r, n = t.managers.cell.get(e.ref), a = dn(n);
  return a ? sa(a, (r = e.elementIds) !== null && r !== void 0 ? r : [], !0) : st.Empty;
}, createTheme: function(e, t, r) {
  return t.managers.representation.createTheme(qe.Surface, this.parse(e, t), r);
}, create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return (n = A5.factory(t, A5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, n.createOrUpdate(k(k({}, A5.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Cde = D.create(0, 0, -0.5), Ede = D.create(0, 0, 0.5), id = D(), od = D(), jg = D(), lI = D();
function Dde() {
  return S5 || (S5 = function(e) {
    for (var t = e.length / 3, r = (t === 3 ? 1 : t === 4 ? 2 : t) + t, n = kh(r, t === 4 ? 3 * t + 4 : 3 * r), a = 0; a < t; ++a) {
      var i = (a + 1) % t;
      D.set(id, e[3 * a], e[3 * a + 1], -0.5), D.set(od, e[3 * i], e[3 * i + 1], -0.5), n.add(id, od, Ede);
    }
    if (t === 3) D.set(id, e[0], e[1], -0.5), D.set(od, e[3], e[4], -0.5), D.set(jg, e[6], e[7], -0.5), n.add(jg, od, id);
    else if (t === 4) D.set(id, e[0], e[1], -0.5), D.set(od, e[3], e[4], -0.5), D.set(jg, e[6], e[7], -0.5), D.set(lI, e[9], e[10], -0.5), n.addQuad(lI, jg, od, id);
    else for (a = 0; a < t; ++a) i = (a + 1) % t, D.set(id, e[3 * a], e[3 * a + 1], -0.5), D.set(od, e[3 * i], e[3 * i + 1], -0.5), n.add(Cde, od, id);
    return n.getPrimitive();
  }(h3(8, !0))), S5;
}
var w_ = { center: V.Vec3(D()), vec: V.Vec3(D()), color: V.Color(Qe.fromRgb(255, 196, 36)), alpha: V.Numeric(0.9, { min: 0, max: 1, step: 0.1 }) }, Sz = { "rotate-arrow-cylinder": function(e, t) {
  return Fn(Ide, Wi.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "rotate-arrow-arrowhead": function(e, t) {
  return Fn(Tde, Xt.Utils);
} }, Mde = k(k(k({}, Ur.Params), w_), { visuals: V.MultiSelect(["rotate-arrow-cylinder", "rotate-arrow-arrowhead"], V.objectToOptions(Sz)) });
function Ide(e, t, r, n) {
  var a = r.center, i = r.vec, o = D.create(0, 0, 0);
  D.normalize(o, i);
  var s = D.create(0, 0, 0);
  D.scale(s, o, 0.25);
  var u = D.create(0, 0, 0);
  D.sub(u, i, s);
  var c = D.create(0, 0, 0);
  D.add(c, a, u);
  var l = D.create(0, 0, 0);
  D.scale(l, o, 0.45), D.sub(c, c, l);
  var d = _h.create(128, 64);
  return d.add(a[0], a[1], a[2], c[0], c[1], c[2], 0.05, !0, !0, 2), or.create("RotateArrow-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "RotateArrow";
  });
}
function Tde(e, t, r, n) {
  var a = Nt.createState(256, 128), i = Dde(), o = r.center, s = r.vec, u = D.create(0, 0, 0);
  D.normalize(u, s);
  var c = D.create(0, 0, 0);
  D.scale(c, u, 0.1);
  var l = D.create(0, 0, 0);
  D.sub(l, s, c);
  var d = D.create(0, 0, 0);
  D.add(d, o, l);
  var f = D.create(0, 0, 0), m = D.create(0, 0, 0);
  D.scale(m, u, 0.35), D.sub(f, d, m);
  var h = Ee.identity(), p = D();
  return D.add(p, f, s), Ee.targetTo(h, p, f, D.create(1, 0, 0)), Ee.setTranslation(h, f), a.currentGroup = 0, Ee.scaleUniformly(h, h, 0.4 * 1.5), Nt.addPrimitive(a, h, i), or.create("axes", r, Nt.getMesh(a), function() {
    return r.color;
  }, function() {
    return 0.05;
  }, function() {
    return "";
  });
}
k(k(k({}, Wi.Params), w_), { color: V.Color(Qe.fromRgb(255, 196, 36)), sizeFactor: V.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), k(k(k({}, Xt.Params), w_), { color: V.Color($t.brown) });
var Nde = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n = function(i, o) {
            var s = fr.createMulti("RotateArrow", i, o, ys, Sz);
            return s.setState({ markerActions: qr.All }), s;
          }(t, function() {
            return Mde;
          }), [4, n.createOrUpdate(e, e).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Pde = { "element-sphere": function(e, t) {
  return ji("Sphere mesh", e, t, pS);
} }, dI = k(k({}, Ah), { bumpFrequency: V.Numeric(1, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory) }), w5 = { name: "spacefill", label: "Spacefill", description: "Displays atomic/coarse elements as spheres.", factory: function(e, t) {
  return fr.createMulti("Spacefill", e, t, ys, Pde);
}, getParams: function(e, t) {
  var r = V.clone(dI);
  return t.isCoarseGrained && (r.sizeFactor.defaultValue = 2), r;
}, defaultValues: V.getDefaultValues(dI), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, Bde = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return (n = w5.factory(t, w5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, n.createOrUpdate(k(k({}, w5.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Ode = Ee.fromTranslation(Ee(), D.create(0.5, 0.5, 0.5)), Fde = g3(v3(TR()), Ode), If = D(), fI = Ee(), Az = k(k({}, Xt.Params), { alpha: k(k({}, Xt.Params.alpha), { defaultValue: 0.51 }), ignoreLight: k(k({}, Xt.Params.ignoreLight), { defaultValue: !0 }), colorX: V.Color($t.red, { isEssential: !0 }), colorY: V.Color($t.green, { isEssential: !0 }), colorZ: V.Color($t.blue, { isEssential: !0 }), scale: V.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }), Rde = k(k(k({}, Xt.Params), Az), { pocketColor: V.Color($t.red), pocketScale: V.Numeric(4, { min: 0.1, max: 5, step: 0.1 }), x: V.Numeric(10), y: V.Numeric(10), z: V.Numeric(10), center: V.Vec3(D()) }), Lde = k(k({}, Rde), Az), kde = { axes: function(e, t) {
  return Fn(Ude, Xt.Utils);
}, mesh: function(e, t) {
  return Fn(zde, Xt.Utils);
} };
function zde(e, t, r, n) {
  var a = function(o, s, u) {
    var c = Nt.createState(256, 128, u), l = o.gridPocket.fromFractional;
    D.copy(If, o.ref), D.subScalar(If, If, 0.5), Ee.fromTranslation(fI, If);
    var d = g3(v3(Fde), fI), f = Math.cbrt(o.gridPocket.volume) / 300 * s.pocketScale;
    c.currentGroup = 1, Nt.addCage(c, l, d, f, 2, 20);
    var m = Ve.fromDimensionsAndTransform(Ve(), D.unit, l);
    D.transformMat4(If, If, l), Ve.translate(m, m, If), Ve.expand(m, m, f);
    var h = Nt.getMesh(c);
    return h.setBoundingSphere(m), h;
  }(t, r, n && n.geometry), i = "Grid Pocket Box";
  return or.create(i, t, a, function() {
    return r.pocketColor;
  }, function() {
    return 1;
  }, function() {
    return i;
  });
}
function mI(e, t, r, n) {
  var a = D(), i = Ee.ofRows([[e, 0, 0, 0], [0, t, 0, 0], [0, 0, r, 0], [0, 0, 0, 1]]), o = Ee.invert(Ee.zero(), i);
  return { ref: D.transformMat4(a, n, o), gridPocket: { fromFractional: i, toFractional: o, x: e, y: t, z: r, center: n, volume: e * t * r } };
}
function Ude(e, t, r, n) {
  var a = r.scale, i = function(o, s, u) {
    var c = s.gridPocket, l = c.x, d = c.y, f = c.z, m = c.center, h = c.volume, p = Nt.createState(512, 256, u), g = Math.cbrt(h) / 300 * o, v = m[0], y = m[1], _ = m[2], S = Math.min(l, d, f), b = D.create(v + S / 3, y, _), x = D.create(v, y + S / 3, _), A = D.create(v, y, _ + S / 3), w = { radiusTop: g, radiusBottom: g, radialSegments: 32 };
    return p.currentGroup = 0, La(p, m, g, 2), p.currentGroup = 1, La(p, b, g, 2), Ba(p, m, b, 1, w), p.currentGroup = 2, La(p, x, g, 2), Ba(p, m, x, 1, w), p.currentGroup = 3, La(p, A, g, 2), Ba(p, m, A, 1, w), D.scale(b, b, 0.5), D.scale(x, x, 0.5), D.scale(A, A, 0.5), Nt.getMesh(p);
  }(a, t, n == null ? void 0 : n.geometry);
  return i.setBoundingSphere(Ve.create(D.create(a / 2, a / 2, a / 2), a + a / 4)), or.create("axes", {}, i, function(o) {
    switch (o) {
      case 1:
        return r.colorX;
      case 2:
        return r.colorY;
      case 3:
        return r.colorZ;
      default:
        return $t.grey;
    }
  }, function() {
    return 1;
  }, function() {
    return "";
  });
}
var Gde = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s;
    return Te(this, function(u) {
      switch (u.label) {
        case 0:
          return n = function(c, l) {
            return fr.createMulti("Grid Pocket", c, l, fr.StateBuilder, kde);
          }(t, function() {
            return Lde;
          }), a = e.x, i = e.y, o = e.z, s = e.center, [4, n.createOrUpdate(e, mI(a, i, o, s)).run()];
        case 1:
          return u.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a, i, o, s;
    return Te(this, function(u) {
      switch (u.label) {
        case 0:
          return a = t.x, i = t.y, o = t.z, s = t.center, [4, e.createOrUpdate(t, mI(a, i, o, s)).run()];
        case 1:
          return u.sent(), [2];
      }
    });
  });
} }, Vde = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1], _p = { radiusFactor: V.Numeric(1, { min: 0.1, max: 3, step: 0.01 }, { description: "Scale the radius of the membrane layer" }), center: V.Vec3(D()), radius: V.Numeric(1), vec: V.Vec3(D()) }, wz = { "pharmacophore-ball-1": function(e, t) {
  return Fn(Xde, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "pharmacophore-ball-2": function(e, t) {
  return Fn(jde, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "pharmacophore-sphere-1": function(e, t) {
  return Fn(Wde, Nu.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "pharmacophore-sphere-2": function(e, t) {
  return Fn(Zde, Nu.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "pharmacophore-cylinder": function(e, t) {
  return Fn(Qde, Wi.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.All });
  } });
}, "pharmacophore-arrowhead": function(e, t) {
  return Fn($de, Xt.Utils);
} }, qde = k(k(k({}, Ur.Params), _p), { color: V.Color($t.blue), lineSizeAttenuation: V.Boolean(!1), linesSize: V.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: V.Boolean(!1), alpha: V.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), Hde = k(k(k({}, Ur.Params), _p), { color: V.Color($t.blue), lineSizeAttenuation: V.Boolean(!1), linesSize: V.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: V.Boolean(!1), alpha: V.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), Kde = k(k(k({}, qde), Hde), { visuals: V.MultiSelect(["pharmacophore-ball-1", "pharmacophore-ball-2", "pharmacophore-sphere-1", "pharmacophore-sphere-2", "pharmacophore-cylinder", "pharmacophore-arrowhead"], V.objectToOptions(wz)), alpha: V.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) });
function Xde(e, t, r, n) {
  var a = r.radiusFactor, i = r.center, o = a * r.radius, s = hi.create(128, 64, n == null ? void 0 : n.geometry), u = D.create(0, 0, 0);
  D.add(u, i, D.create(0, 1, 0));
  var c = D.create(0, 0, 0);
  D.add(c, i, D.create(0, 0, 1));
  var l = D.create(0, 0, 0);
  D.add(l, i, D.create(1, 0, 0)), fi(s, i, u, o, r), fi(s, i, c, o, r), fi(s, i, l, o, r);
  var d = D.create(0, 0, 0);
  D.add(d, i, D.create(0, 0.5 * o, 0));
  var f = D.create(0, 0, 0);
  D.add(f, d, D.create(0, Math.sqrt(0.75), 0)), fi(s, d, f, Math.sqrt(0.75) * o, r);
  var m = D.create(0, 0, 0);
  D.add(m, i, D.create(0, -0.5 * o, 0));
  var h = D.create(0, 0, 0);
  return D.add(h, m, D.create(0, -Math.sqrt(0.75), 0)), fi(s, m, h, Math.sqrt(0.75) * o, r), d = D.create(0, 0, 0), D.add(d, i, D.create(0.5 * o, 0, 0)), f = D.create(0, 0, 0), D.add(f, d, D.create(Math.sqrt(0.75), 0, 0)), fi(s, d, f, Math.sqrt(0.75) * o, r), m = D.create(0, 0, 0), D.add(m, i, D.create(-0.5 * o, 0, 0)), h = D.create(0, 0, 0), D.add(h, m, D.create(-Math.sqrt(0.75), 0, 0)), fi(s, m, h, Math.sqrt(0.75) * o, r), d = D.create(0, 0, 0), D.add(d, i, D.create(0, 0, 0.5 * o)), f = D.create(0, 0, 0), D.add(f, d, D.create(0, 0, Math.sqrt(0.75))), fi(s, d, f, Math.sqrt(0.75) * o, r), m = D.create(0, 0, 0), D.add(m, i, D.create(0, 0, -0.5 * o)), h = D.create(0, 0, 0), D.add(h, m, D.create(0, 0, -Math.sqrt(0.75))), fi(s, m, h, Math.sqrt(0.75) * o, r), or.create("pharmacophore-ball-1", r, s.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function jde(e, t, r, n) {
  var a = r.radiusFactor, i = r.center, o = r.radius, s = r.vec, u = a * o, c = D.create(0, 0, 0);
  D.add(c, i, s);
  var l = hi.create(128, 64, n == null ? void 0 : n.geometry), d = D.create(0, 0, 0);
  D.add(d, c, D.create(0, 1, 0));
  var f = D.create(0, 0, 0);
  D.add(f, c, D.create(0, 0, 1));
  var m = D.create(0, 0, 0);
  D.add(m, c, D.create(1, 0, 0)), fi(l, c, d, u, r), fi(l, c, f, u, r), fi(l, c, m, u, r);
  var h = D.create(0, 0, 0);
  D.add(h, c, D.create(0, 0.5 * u, 0));
  var p = D.create(0, 0, 0);
  D.add(p, h, D.create(0, Math.sqrt(0.75), 0)), fi(l, h, p, Math.sqrt(0.75) * u, r);
  var g = D.create(0, 0, 0);
  D.add(g, c, D.create(0, -0.5 * u, 0));
  var v = D.create(0, 0, 0);
  return D.add(v, g, D.create(0, -Math.sqrt(0.75), 0)), fi(l, g, v, Math.sqrt(0.75) * u, r), h = D.create(0, 0, 0), D.add(h, c, D.create(0.5 * u, 0, 0)), p = D.create(0, 0, 0), D.add(p, h, D.create(Math.sqrt(0.75), 0, 0)), fi(l, h, p, Math.sqrt(0.75) * u, r), g = D.create(0, 0, 0), D.add(g, c, D.create(-0.5 * u, 0, 0)), v = D.create(0, 0, 0), D.add(v, g, D.create(-Math.sqrt(0.75), 0, 0)), fi(l, g, v, Math.sqrt(0.75) * u, r), h = D.create(0, 0, 0), D.add(h, c, D.create(0, 0, 0.5 * u)), p = D.create(0, 0, 0), D.add(p, h, D.create(0, 0, Math.sqrt(0.75))), fi(l, h, p, Math.sqrt(0.75) * u, r), g = D.create(0, 0, 0), D.add(g, c, D.create(0, 0, -0.5 * u)), v = D.create(0, 0, 0), D.add(v, g, D.create(0, 0, -Math.sqrt(0.75))), fi(l, g, v, Math.sqrt(0.75) * u, r), or.create("pharmacophore-ball-2", r, l.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function fi(e, t, r, n, a, i) {
  for (var o = function(_, S, b) {
    D.dot(D.unitY, D.sub(Yde, _, S)) === 0 ? Ee.targetTo(cp, _, S, D.unitY) : Ee.targetTo(cp, _, S, D.unitX), Ee.setTranslation(cp, _), Ee.mul(cp, cp, Ee.rotX90);
    var x = yS({ radius: b, segments: 64 });
    return p3(x, cp);
  }(t, r, n), s = o.indices, u = o.vertices, c = 0, l = s.length; c < l; c += 3) if (!a.dashedLines || c % 2 != 1) {
    var d = 3 * s[c], f = 3 * s[c + 1], m = u[d], h = u[d + 1], p = u[d + 2], g = u[f], v = u[f + 1], y = u[f + 2];
    e.add(m, h, p, g, v, y, 0);
  }
}
k(k(k({}, Nu.Params), _p), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: V.Color($t.green), alpha: V.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), k(k(k({}, Nu.Params), _p), { sizeFactor: V.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: V.Color($t.brown), alpha: V.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), k(k(k({}, Wi.Params), _p), { color: V.Color($t.brown), sizeFactor: V.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), k(k(k({}, Xt.Params), _p), { color: V.Color($t.brown) });
var cp = Ee(), Yde = D();
function Cz(e, t, r, n) {
  e.add(t[0], t[1], t[2], n);
}
function Wde(e, t, r, n) {
  var a = r.center, i = r.radius, o = r.radiusFactor, s = Sh.create(128, 64);
  return Cz(s, a, 0, 0), or.create("pharmacophore-sphere-1", k(k({}, r), { sizeFactor: 0.1 * r.radius }), s.getSpheres(), function() {
    return r.color;
  }, function() {
    return i * o / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Zde(e, t, r, n) {
  var a = r.center, i = r.radius, o = r.vec, s = r.radiusFactor, u = D.create(0, 0, 0);
  D.add(u, a, o);
  var c = Sh.create(128, 64);
  return Cz(c, u, 0, 1), or.create("pharmacophore-sphere-2", k(k({}, r), { sizeFactor: 0.1 * r.radius }), c.getSpheres(), function() {
    return r.color;
  }, function() {
    return i * s / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Qde(e, t, r, n) {
  var a = r.center, i = r.vec, o = D.create(0, 0, 0);
  D.normalize(o, i);
  var s = D.create(0, 0, 0);
  D.scale(s, o, 0.25);
  var u = D.create(0, 0, 0);
  D.sub(u, i, s);
  var c = D.create(0, 0, 0);
  D.add(c, a, u);
  var l = D.create(0, 0, 0);
  D.scale(l, o, 0.3), D.sub(c, c, l);
  var d = _h.create(128, 64);
  return d.add(a[0], a[1], a[2], c[0], c[1], c[2], 0.025, !0, !0, 2), or.create("pharmacophore-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "pharmacophore";
  });
}
function $de(e, t, r, n) {
  var a = r.center, i = r.vec, o = D.create(0, 0, 0);
  D.normalize(o, i);
  var s = D.create(0, 0, 0);
  D.scale(s, o, 0.25);
  var u = D.create(0, 0, 0);
  D.sub(u, i, s);
  var c = D.create(0, 0, 0);
  D.add(c, a, u);
  var l = D.create(0, 0, 0), d = D.create(0, 0, 0);
  D.scale(d, o, 0.3), D.sub(l, c, d);
  var f = D.create(0, 0, 0), m = D.create(1, 2, l[2] - (o[0] * (1 - l[0]) + o[1] * (2 - l[1])) / o[2]);
  D.sub(f, m, l), D.normalize(f, f);
  var h = D.create(0, 0, 0);
  D.scale(h, f, 0.3);
  var p = D.create(0, 0, 0);
  D.add(p, l, h);
  var g = D.create(0, 0, 0);
  D.sub(g, p, l);
  var v = D.create(0, 0, 0), y = D.create(0, 0, 0);
  D.scale(y, g, Math.cos(120 * Math.PI / 180));
  var _ = D.create(0, 0, 0);
  D.cross(_, o, g), D.scale(_, _, Math.sin(120 * Math.PI / 180));
  var S = D.create(0, 0, 0);
  D.scale(S, o, D.dot(o, g) * (1 - Math.cos(120 * Math.PI / 180))), D.add(v, y, _), D.add(v, v, S), D.add(v, v, l);
  var b = D.create(0, 0, 0);
  y = D.create(0, 0, 0), D.scale(y, g, Math.cos(240 * Math.PI / 180)), _ = D.create(0, 0, 0), D.cross(_, o, g), D.scale(_, _, Math.sin(240 * Math.PI / 180)), S = D.create(0, 0, 0), D.scale(S, o, D.dot(o, g) * (1 - Math.cos(240 * Math.PI / 180))), D.add(b, y, _), D.add(b, b, S), D.add(b, b, l);
  var x = Nt.createState(128, 64), A = function(M) {
    return MR(M, Vde);
  }([c[0], c[1], c[2], p[0], p[1], p[2], v[0], v[1], v[2], b[0], b[1], b[2]]), w = Ee.ofRows([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), C = Ee.invert(Ee.zero(), w);
  return Nt.addPrimitive(x, C, A), or.create("axes", {}, Nt.getMesh(x), function() {
    return r.color;
  }, function() {
    return 0.15;
  }, function() {
    return "";
  });
}
var Jde = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n = function(i, o) {
            var s = fr.createMulti("Pharmacophore", i, o, ys, wz);
            return s.setState({ markerActions: qr.All }), s;
          }(t, function() {
            return Kde;
          }), [4, n.createOrUpdate(e, e).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} };
function C_(e, t) {
  var r, n, a, i, o, s, u, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, h = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, v = e.dispose, y = e.geometryUtils, _ = y.updateValues, S = y.updateBoundingSphere, b = y.updateRenderableState, x = y.createPositionIterator, A = fc.create(), w = Object.assign({}, l), C = nu.createEmpty(), M = -1;
  function T(I) {
    if (A.createNew) {
      if (u = f(i), !I) throw new Error("expected geometry to be given");
      r = function(P, O, F, R, G, L) {
        var q = vi.getUtils(O), K = q.createValues, X = q.createRenderableState, H = K(O, N8(), F, R, G), W = X(G);
        return g1(O.kind, H, W, L);
      }(0, I, u, a, n, t), c = x(I, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (u.reset(), A.createGeometry) {
        if (!I) throw new Error("expected geometry to be given");
        U.updateIfChanged(r.values.drawCount, vi.getDrawCount(I)), U.updateIfChanged(r.values.uVertexCount, vi.getVertexCount(I));
      }
      (A.updateTransform || A.createGeometry) && (S(r.values, I || s), c = x(I || s, r.values)), A.updateSize && "uSize" in r.values && xl(u, a.size, r.values), A.updateColor && hs(u, c, a.color, r.values), _(r.values, n), b(r.state, n);
    }
    w = n, C = a, o = i, I && (s = I, M += 1);
  }
  function N(I, P) {
    return Vo(I) ? P(Fe.ofBounds(0, u.groupCount * u.instanceCount)) : h(I, o, w, P);
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return r;
  }, get geometryVersion() {
    return M;
  }, createOrUpdate: function(I, P, O, F) {
    return O === void 0 && (O = {}), Be(this, 0, void 0, function() {
      var R;
      return Te(this, function(G) {
        return function(L, q, K) {
          if (!K && !o) throw new Error("missing volume");
          n = Object.assign({}, w, q), a = L, i = K, fc.reset(A), r && o && dr.areEquivalent(i, o) || (A.createNew = !0), A.createNew ? A.createGeometry = !0 : (p(A, K, n, w, a, C), fl.areEqual(L.color, C.color) || (A.updateColor = !0), A.createGeometry && (A.updateColor = !0));
        }(P, O, F || o), A.createGeometry ? [2, m8(R = d(I, i, a, n, s)) ? R.then(T) : T(R)] : (T(), [2]);
      });
    });
  }, getLoci: function(I) {
    return r ? m(I, o, w, r.id) : Tn;
  }, mark: function(I, P) {
    return cr.mark(r, I, P, N);
  }, setVisibility: function(I) {
    cr.setVisibility(r, I);
  }, setAlphaFactor: function(I) {
    cr.setAlphaFactor(r, I);
  }, setPickable: function(I) {
    cr.setPickable(r, I);
  }, setColorOnly: function(I) {
    cr.setColorOnly(r, I);
  }, setTransform: function(I, P) {
    cr.setTransform(r, I, P);
  }, setOverpaint: function(I) {
    return cr.setOverpaint(r, I, N, !0);
  }, setTransparency: function(I) {
    return cr.setTransparency(r, I, N, !0);
  }, setSubstance: function(I) {
    return cr.setSubstance(r, I, N, !0);
  }, setClipping: function(I) {
    return cr.setClipping(r, I, N, !0);
  }, destroy: function() {
    v == null || v(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
function pI(e, t, r, n, a) {
  var i, o, s, u, c = 0, l = t.webgl, d = new pa(), f = new fr.GeometryState(), m = Sl(), h = [], p = fr.createState(), g = nu.createEmpty();
  return { label: e, get groupCount() {
    return i ? i.groupCount : 0;
  }, get props() {
    return u;
  }, get params() {
    return s;
  }, get state() {
    return p;
  }, get theme() {
    return g;
  }, get geometryVersion() {
    return f.version;
  }, renderObjects: h, updated: d, createOrUpdate: function(v, y) {
    var _ = this;
    v === void 0 && (v = {}), y && y !== o && (s = r(t, y), o = y, u || (u = V.getDefaultValues(s)));
    var S = q6(Object.assign({}, u, v), o);
    return Object.assign(u, v, S), sr.create("Creating or updating VolumeRepresentation", function(b) {
      return Be(_, 0, void 0, function() {
        var x, A;
        return Te(this, function(w) {
          switch (w.label) {
            case 0:
              return i ? !((A = i.mustRecreate) === null || A === void 0) && A.call(i, o, u, l) && (i.destroy(), i = n(m, o, u, l)) : i = n(m, o, u, l), (x = i.createOrUpdate({ webgl: l, runtime: b }, g, u, y)) ? [4, x] : [3, 2];
            case 1:
              w.sent(), w.label = 2;
            case 2:
              return h.length = 0, i && i.renderObject && (h.push(i.renderObject), f.add(i.renderObject.id, i.geometryVersion)), f.snapshot(), d.next(c++), [2];
          }
        });
      });
    });
  }, setState: function(v) {
    v.visible !== void 0 && i && i.setVisibility(v.visible), v.alphaFactor !== void 0 && i && i.setAlphaFactor(v.alphaFactor), v.pickable !== void 0 && i && i.setPickable(v.pickable), v.overpaint !== void 0 && i && i.setOverpaint(v.overpaint), v.transparency !== void 0 && i && i.setTransparency(v.transparency), v.transform !== void 0 && i && i.setTransform(v.transform), fr.updateState(p, v);
  }, setTheme: function(v) {
    g = v;
  }, getLoci: function(v) {
    return v === void 0 ? a(o, u) : i ? i.getLoci(v) : Tn;
  }, mark: function(v, y) {
    return !!i && i.mark(v, y);
  }, destroy: function() {
    i && i.destroy();
  } };
}
k({}, yt.Params);
var efe = `
precision highp float;
precision highp int;

#if __VERSION__ == 100
    precision highp sampler2D;
    uniform sampler2D tTexture;
#else
    precision highp isampler2D;
    uniform isampler2D tTexture;
#endif

void main(void) {
    #if __VERSION__ == 100
        gl_FragColor = texture2D(tTexture, vec2(0.5));
    #else
        gl_FragColor = ivec4(texture2D(tTexture, vec2(0.5)).r);
    #endif
}
`, tfe = k(k({}, ei), { tTexture: Kt("texture", "rgba", "float", "nearest") }), Ws = "histopyramid-sum";
function rfe(e, t) {
  if (e.namedComputeRenderables[Ws]) {
    var r = e.namedComputeRenderables[Ws].values;
    U.update(r.tTexture, t), e.namedComputeRenderables[Ws].update();
  } else e.namedComputeRenderables[Ws] = function(n, a) {
    var i = k(k({}, Qa), { tTexture: U.create(a) }), o = k({}, tfe), s = Rn("sum", Yi, efe, {}, { 0: "ivec4" }), u = Ua(n, "triangles", s, o, i);
    return Ga(u, i);
  }(e, t);
  return e.namedComputeRenderables[Ws];
}
var Yg = new Uint8Array(4), hI = new Int32Array(4), Wg, Zg, nfe = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tInputLevel;

// previous level used to evaluate the new level
#if __VERSION__ == 100
    uniform sampler2D tPreviousLevel;
#else
    precision highp isampler2D;
    uniform isampler2D tPreviousLevel;
#endif

// inverted size of the previous level texture.
uniform float uSize;
uniform float uTexSize;
uniform bool uFirst;

#include common

void main(void) {
    float k = 0.5 * uSize;
    vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;

    #if __VERSION__ == 100
        float a, b, c, d;

        if (uFirst) {
            a = texture2D(tInputLevel, position).r * 255.0;
            b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;
            c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;
            d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;
        } else {
            a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);
            b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);
            c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);
            d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);
        }
        gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);
    #else
        int a, b, c, d;

        if (uFirst) {
            a = int(texture2D(tInputLevel, position).r * 255.0);
            b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);
            c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);
            d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);
        } else {
            a = texture2D(tPreviousLevel, position).r;
            b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;
            c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;
            d = texture2D(tPreviousLevel, position + vec2(k, k)).r;
        }
        gl_FragColor = ivec4(a + b + c + d);
    #endif
}
`, afe = k(k({}, ei), { tInputLevel: Kt("texture", "rgba", "float", "nearest"), tPreviousLevel: Kt("texture", "rgba", "float", "nearest"), uSize: ze("f"), uTexSize: ze("f"), uFirst: ze("b") }), yd = "histogram-pyramid";
function ife(e, t, r) {
  if (e.namedComputeRenderables[yd]) {
    var n = e.namedComputeRenderables[yd].values;
    U.update(n.tInputLevel, t), U.update(n.tPreviousLevel, r), e.namedComputeRenderables[yd].update();
  } else e.namedComputeRenderables[yd] = function(a, i, o) {
    var s = k(k({}, Qa), { tInputLevel: U.create(i), tPreviousLevel: U.create(o), uSize: U.create(0), uTexSize: U.create(0), uFirst: U.create(!0) }), u = k({}, afe), c = Rn("reduction", Yi, nfe, {}, { 0: "ivec4" }), l = Ua(a, "triangles", c, u, s);
    return Ga(l, s);
  }(e, t, r);
  return e.namedComputeRenderables[yd];
}
function ofe(e, t) {
  var r = Math.pow(2, t), n = "level".concat(t), a = e.isWebGL2 ? By(n, e, "image-int32", "alpha", "int", "nearest") : By(n, e, "image-uint8", "rgba", "ubyte", "nearest");
  a.define(r, r);
  var i = function(o, s) {
    var u = "".concat(yd, "-").concat(o);
    return s.namedFramebuffers[u];
  }(n, e);
  return i || (i = Ez(n, e), a.attachFramebuffer(i, 0)), { texture: a, framebuffer: i };
}
function Ez(e, t) {
  var r = "".concat(yd, "-").concat(e);
  return t.namedFramebuffers[r] || (t.namedFramebuffers[r] = t.resources.framebuffer()), t.namedFramebuffers[r];
}
function By(e, t, r, n, a, i) {
  var o = "".concat(yd, "-").concat(e);
  return t.namedTextures[o] || (t.namedTextures[o] = t.resources.texture(r, n, a, i)), t.namedTextures[o];
}
function sfe(e, t, r, n) {
  var a = e.gl, i = t.getWidth();
  if (i !== t.getHeight() || !function(_) {
    return _ !== 0 && !(_ & _ - 1);
  }(i)) throw new Error("inputTexture must be of square power-of-two size");
  var o = Math.ceil(Math.log(i) / Math.log(2)), s = Math.pow(2, o), u = Math.pow(2, o), c = Math.pow(2, o - 1), l = e.isWebGL2 ? By("pyramid", e, "image-int32", "alpha", "int", "nearest") : By("pyramid", e, "image-uint8", "rgba", "ubyte", "nearest");
  l.define(u, c);
  var d = Ez("pyramid", e);
  l.attachFramebuffer(d, 0), a.viewport(0, 0, u, c), lr(a) ? a.clearBufferiv(a.COLOR, 0, [0, 0, 0, 0]) : a.clear(a.COLOR_BUFFER_BIT);
  for (var f = [], m = 0; m < o; ++m) f.push(ofe(e, m));
  var h = ife(e, t, f[0].texture);
  e.state.currentRenderItemId = -1, function(_) {
    var S = _.gl, b = _.state;
    b.disable(S.CULL_FACE), b.disable(S.BLEND), b.disable(S.DEPTH_TEST), b.enable(S.SCISSOR_TEST), b.depthMask(!1), b.colorMask(!0, !0, !0, !0), b.clearColor(0, 0, 0, 0);
  }(e);
  var p = 0;
  for (m = 0; m < o; m++) {
    var g = o - 1 - m;
    f[g].framebuffer.bind();
    var v = Math.pow(2, g);
    U.update(h.values.uSize, Math.pow(2, m + 1) / s), U.update(h.values.uTexSize, v), U.updateIfChanged(h.values.uFirst, m === 0), m > 0 && (U.update(h.values.tPreviousLevel, f[o - m].texture), h.update()), e.state.currentRenderItemId = -1, a.viewport(0, 0, v, v), a.scissor(0, 0, v, v), lr(a) ? a.clearBufferiv(a.COLOR, 0, [0, 0, 0, 0]) : a.clear(a.COLOR_BUFFER_BIT), a.scissor(0, 0, n[0], n[1]), h.render(), l.bind(0), a.copyTexSubImage2D(a.TEXTURE_2D, 0, p, 0, 0, 0, v, v), l.unbind(0), p += v;
  }
  a.finish();
  var y = Math.max(1, function(_, S) {
    var b = _.gl, x = _.resources, A = rfe(_, S);
    _.state.currentRenderItemId = -1, _.namedFramebuffers[Ws] || (_.namedFramebuffers[Ws] = x.framebuffer());
    var w = _.namedFramebuffers[Ws];
    return _.namedTextures[Ws] || (_.namedTextures[Ws] = lr(b) ? x.texture("image-int32", "rgba", "int", "nearest") : x.texture("image-uint8", "rgba", "ubyte", "nearest"), _.namedTextures[Ws].define(1, 1)), _.namedTextures[Ws].attachFramebuffer(w, 0), function(C) {
      var M = C.gl, T = C.state;
      T.disable(M.CULL_FACE), T.disable(M.BLEND), T.disable(M.DEPTH_TEST), T.disable(M.SCISSOR_TEST), T.depthMask(!1), T.colorMask(!0, !0, !0, !0), T.clearColor(0, 0, 0, 0);
    }(_), b.viewport(0, 0, 1, 1), A.render(), b.finish(), _.readPixels(0, 0, 1, 1, lr(b) ? hI : Yg), _.unbindFramebuffer(), lr(b) ? hI[0] : P8(Yg[0], Yg[1], Yg[2]);
  }(e, f[0].texture));
  return { pyramidTex: l, count: y, height: Math.ceil(y / Math.pow(2, o)), levels: o, scale: r };
}
function ufe() {
  if (Wg !== void 0) return Wg;
  for (var e = (Wg = Oa(256, 1, Uint8Array)).array, t = 0, r = Ip.length; t < r; ++t) e[t] = Ip[t].length / 3;
  return Wg;
}
function cfe() {
  if (Zg !== void 0) return Zg;
  for (var e = (Zg = Oa(4096, 1, Uint8Array)).array, t = 0, r = Ip.length; t < r; ++t) for (var n = 0; n < 16; ++n) n < Ip[t].length ? e[16 * t + n] = Ip[t][n] : e[16 * t + n] = 255;
  return Zg;
}
var lfe = `
precision highp float;
precision highp int;
precision highp sampler2D;

#if __VERSION__ == 100
    uniform sampler2D tActiveVoxelsPyramid;
#else
    precision highp isampler2D;
    uniform isampler2D tActiveVoxelsPyramid;
#endif

uniform sampler2D tActiveVoxelsBase;
uniform sampler2D tVolumeData;
uniform sampler2D tTriIndices;

uniform float uIsoValue;
uniform float uLevels;
uniform float uSize;
uniform float uCount;
uniform bool uInvert;

uniform vec3 uGridDim;
uniform vec3 uGridTexDim;
uniform mat4 uGridTransform;

// scale to volume data coord
uniform vec2 uScale;

#include common

// cube corners (excluding origin)
const vec3 c1 = vec3(1., 0., 0.);
const vec3 c2 = vec3(1., 1., 0.);
const vec3 c3 = vec3(0., 1., 0.);
const vec3 c4 = vec3(0., 0., 1.);
const vec3 c5 = vec3(1., 0., 1.);
const vec3 c6 = vec3(1., 1., 1.);
const vec3 c7 = vec3(0., 1., 1.);

vec3 index3dFrom2d(vec2 coord) {
    vec2 gridTexPos = coord * uGridTexDim.xy;
    vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);
    vec2 posXY = gridTexPos - columnRow * uGridDim.xy;
    float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;
    return vec3(posXY, posZ);
}

vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);
    float row = intDiv(zSlice * gridDim.x, texDim.x);
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);
    return texture2D(tex, coord + 0.5 / (texDim / uScale));
}

vec4 voxel(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

vec4 voxelPadded(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

int idot2(const in ivec2 a, const in ivec2 b) {
    return a.x * b.x + a.y * b.y;
}

int idot4(const in ivec4 a, const in ivec4 b) {
    return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}

#if __VERSION__ == 100
    int pyramidVoxel(vec2 pos) {
        return int(unpackRGBToInt(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));
    }
#else
    int pyramidVoxel(vec2 pos) {
        return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;
    }
#endif

vec4 baseVoxel(vec2 pos) {
    return texture2D(tActiveVoxelsBase, pos / uSize);
}

vec4 getGroup(const in vec3 p) {
    vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding
    // note that we swap x and z because the texture is flipped around y
    #if defined(dAxisOrder_012)
        float group = p.z + p.y * gridDim.z + p.x * gridDim.z * gridDim.y; // 210
    #elif defined(dAxisOrder_021)
        float group = p.y + p.z * gridDim.y + p.x * gridDim.y * gridDim.z; // 120
    #elif defined(dAxisOrder_102)
        float group = p.z + p.x * gridDim.z + p.y * gridDim.z * gridDim.x; // 201
    #elif defined(dAxisOrder_120)
        float group = p.x + p.z * gridDim.x + p.y * gridDim.x * gridDim.z; // 021
    #elif defined(dAxisOrder_201)
        float group = p.y + p.x * gridDim.y + p.z * gridDim.y * gridDim.x; // 102
    #elif defined(dAxisOrder_210)
        float group = p.x + p.y * gridDim.x + p.z * gridDim.x * gridDim.y; // 012
    #endif
    return vec4(group > 16777215.5 ? vec3(1.0) : packIntToRGB(group), 1.0);
}

void main(void) {
    // get 1D index
    int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);

    // ignore 1D indices outside of the grid
    if(vI >= int(uCount)) discard;

    ivec2 offset = ivec2(int(uSize) - 2, 0);

    int start = 0;
    ivec4 starts = ivec4(0);
    ivec4 ends = ivec4(0);
    int diff = 2;
    ivec4 m = ivec4(0);
    ivec2 position = ivec2(0);
    ivec4 vI4 = ivec4(vI);

    ivec2 relativePosition = ivec2(0);
    int end = 0;
    ivec2 pos1 = ivec2(0);
    ivec2 pos2 = ivec2(0);
    ivec2 pos3 = ivec2(0);
    ivec2 pos4 = ivec2(0);
    ivec3 vI3 = ivec3(vI);
    ivec3 mask = ivec3(0);

    // traverse the different levels of the pyramid
    for(int i = 1; i < 14; i++) {
        if(float(i) >= uLevels) break;

        offset.x -= diff;
        diff *= 2;
        relativePosition = position + offset;

        end = start + pyramidVoxel(vec2(relativePosition));
        pos1 = ivec2(relativePosition);
        starts.x = start;
        ends.x = end;
        pos2 = ivec2(relativePosition + ivec2(1, 0));
        starts.y = ends.x;
        ends.y = ends.x + pyramidVoxel(vec2(pos2));
        pos3 = relativePosition + ivec2(0, 1);
        starts.z = ends.y;
        ends.z = ends.y + pyramidVoxel(vec2(pos3));
        pos4 = relativePosition + ivec2(1, 1);
        starts.w = ends.z;
        mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));
        m = ivec4(mask, 1 - int(any(bvec3(mask))));

        relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;
        start = idot4(m, starts);
        position = 2 * (relativePosition - offset);
    }

    end = start + int(baseVoxel(vec2(position)).r * 255.0);
    pos1 = position;
    starts.x = start;
    ends.x = end;
    pos2 = position + ivec2(1, 0);
    starts.y = ends.x;
    ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);
    pos3 = position + ivec2(0, 1);
    starts.z = ends.y;
    ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);
    pos4 = position + ivec2(1, 1);
    starts.w = ends.z;
    mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));
    m = ivec4(mask, 1 - int(any(bvec3(mask))));
    position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;

    vec2 coord2d = (vec2(position) / uSize) / uScale;
    vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);

    float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);

    // current vertex for the up to 15 MC cases
    int currentVertex = vI - idot4(m, starts);

    // ensure winding-order is the same for negative and positive iso-levels
    if (uInvert) {
        int v = imod(currentVertex + 1, 3);
        if (v == 1) currentVertex += 2;
        else if (v == 0) currentVertex -= 2;
    }

    // get index into triIndices table
    int mcIndex = 16 * int(edgeIndex) + currentVertex;
    vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);

    // bit mask to avoid conditionals (see comment below) for getting MC case corner
    vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));

    // get edge value masks
    vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));
    vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));
    vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));

    // apply bit masks
    vec3 b0 = coord3d +
                m1.y * c1 +
                m1.z * c2 +
                m1.w * c3 +
                m2.x * c4 +
                m2.y * c5 +
                m2.z * c6 +
                m2.w * c7 +
                m3.y * c1 +
                m3.z * c2 +
                m3.w * c3;
    vec3 b1 = coord3d +
                m1.x * c1 +
                m1.y * c2 +
                m1.z * c3 +
                m2.x * c5 +
                m2.y * c6 +
                m2.z * c7 +
                m2.w * c4 +
                m3.x * c4 +
                m3.y * c5 +
                m3.z * c6 +
                m3.w * c7;

    // the conditionals that are avoided by above bitmasks
    // vec3 b0 = coord3d;
    // vec3 b1 = coord3d;
    // if (mcIndex == 0.0) {
    //     b1 += c1;
    // } else if (mcIndex == 1.0) {
    //     b0 += c1; b1 += c2;
    // } else if (mcIndex == 2.0) {
    //     b0 += c2; b1 += c3;
    // } else if (mcIndex == 3.0) {
    //     b0 += c3;
    // } else if (mcIndex == 4.0) {
    //     b0 += c4; b1 += c5;
    // } else if (mcIndex == 5.0) {
    //     b0 += c5; b1 += c6;
    // } else if (mcIndex == 6.0) {
    //     b0 += c6; b1 += c7;
    // } else if (mcIndex == 7.0) {
    //     b0 += c7; b1 += c4;
    // } else if (mcIndex == 8.0) {
    //     b1 += c4;
    // } else if (mcIndex == 9.0) {
    //     b0 += c1; b1 += c5;
    // } else if (mcIndex == 10.0) {
    //     b0 += c2; b1 += c6;
    // } else if (mcIndex == 11.0) {
    //     b0 += c3; b1 += c7;
    // }
    // b0 = floor(b0 + 0.5);
    // b1 = floor(b1 + 0.5);

    vec4 d0 = voxel(b0);
    vec4 d1 = voxel(b1);

    float v0 = d0.a;
    float v1 = d1.a;

    float t = (uIsoValue - v0) / (v0 - v1);
    gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;

    // group id
    #if __VERSION__ == 100
        // webgl1 does not support 'flat' interpolation (i.e. no interpolation)
        // so we ensure a constant group id per triangle here
        #ifdef dPackedGroup
            gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);
        #else
            gl_FragData[1] = getGroup(coord3d);
        #endif
    #else
        #ifdef dPackedGroup
            gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);
        #else
            gl_FragData[1] = getGroup(t < 0.5 ? b0 : b1);
        #endif
    #endif

    // normals from gradients
    vec3 n0 = -normalize(vec3(
        voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,
        voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,
        voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a
    ));
    vec3 n1 = -normalize(vec3(
        voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,
        voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,
        voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a
    ));
    gl_FragData[2].xyz = -vec3(
        n0.x + t * (n0.x - n1.x),
        n0.y + t * (n0.y - n1.y),
        n0.z + t * (n0.z - n1.z)
    );

    // ensure normal-direction is the same for negative and positive iso-levels
    if (uInvert) {
        gl_FragData[2].xyz *= -1.0;
    }

    // apply normal matrix
    gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));
}
`, dfe = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tTriCount;
uniform sampler2D tVolumeData;

uniform float uIsoValue;
uniform vec3 uGridDim;
uniform vec3 uGridTexDim;
uniform vec2 uScale;

#include common

// cube corners (excluding origin)
const vec3 c1 = vec3(1., 0., 0.);
const vec3 c2 = vec3(1., 1., 0.);
const vec3 c3 = vec3(0., 1., 0.);
const vec3 c4 = vec3(0., 0., 1.);
const vec3 c5 = vec3(1., 0., 1.);
const vec3 c6 = vec3(1., 1., 1.);
const vec3 c7 = vec3(0., 1., 1.);

vec3 index3dFrom2d(vec2 coord) {
    vec2 gridTexPos = coord * uGridTexDim.xy;
    vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);
    vec2 posXY = gridTexPos - columnRow * uGridDim.xy;
    float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;
    return vec3(posXY, posZ);
}

vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);
    float row = intDiv(zSlice * gridDim.x, texDim.x);
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);
    return texture2D(tex, coord);
}

vec4 voxel(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

void main(void) {
    vec2 uv = gl_FragCoord.xy / uGridTexDim.xy;
    vec3 posXYZ = index3dFrom2d(uv);

    // get MC case as the sum of corners that are below the given iso level
    float c = step(voxel(posXYZ).a, uIsoValue)
        + 2. * step(voxel(posXYZ + c1).a, uIsoValue)
        + 4. * step(voxel(posXYZ + c2).a, uIsoValue)
        + 8. * step(voxel(posXYZ + c3).a, uIsoValue)
        + 16. * step(voxel(posXYZ + c4).a, uIsoValue)
        + 32. * step(voxel(posXYZ + c5).a, uIsoValue)
        + 64. * step(voxel(posXYZ + c6).a, uIsoValue)
        + 128. * step(voxel(posXYZ + c7).a, uIsoValue);
    c *= step(c, 254.);

    // handle out of bounds positions
    posXYZ += 1.0;
    posXYZ.xy += 1.0; // pixel padding (usually ok even if the texture has no padding)
    if (posXYZ.x >= uGridDim.x || posXYZ.y >= uGridDim.y || posXYZ.z >= uGridDim.z)
        c = 0.0;

    // get total triangles to generate for calculated MC case from triCount texture
    float totalTrianglesToGenerate = texture2D(tTriCount, vec2(intMod(c, 16.), floor(c / 16.)) / 16.).a;
    gl_FragColor = vec4(vec3(totalTrianglesToGenerate * 3.0), c / 255.0);
}
`, ffe = k(k({}, ei), { tTriCount: Kt("image-uint8", "alpha", "ubyte", "nearest"), tVolumeData: Kt("texture", "rgba", "ubyte", "nearest"), uIsoValue: ze("f"), uGridDim: ze("v3"), uGridTexDim: ze("v3"), uScale: ze("v2") }), xu = "active-voxels";
function mfe(e, t, r, n, a, i) {
  if (e.namedComputeRenderables[xu]) {
    var o = e.namedComputeRenderables[xu].values;
    U.update(o.uQuadScale, i), U.update(o.tVolumeData, t), U.updateIfChanged(o.uIsoValue, a), U.update(o.uGridDim, r), U.update(o.uGridTexDim, n), U.update(o.uScale, i), e.namedComputeRenderables[xu].update();
  } else e.namedComputeRenderables[xu] = function(s, u, c, l, d, f) {
    var m = k(k({}, Qa), { tTriCount: U.create(ufe()), uQuadScale: U.create(f), tVolumeData: U.create(u), uIsoValue: U.create(d), uGridDim: U.create(c), uGridTexDim: U.create(l), uScale: U.create(f) }), h = k({}, ffe), p = Rn("active-voxels", Yi, dfe), g = Ua(s, "triangles", p, h, m);
    return Ga(g, m);
  }(e, t, r, n, a, i);
  return e.namedComputeRenderables[xu];
}
var pfe = k(k({}, ei), { tTriIndices: Kt("image-uint8", "alpha", "ubyte", "nearest"), tActiveVoxelsPyramid: Kt("texture", "rgba", "float", "nearest"), tActiveVoxelsBase: Kt("texture", "rgba", "float", "nearest"), tVolumeData: Kt("texture", "rgba", "ubyte", "nearest"), uIsoValue: ze("f"), uSize: ze("f"), uLevels: ze("f"), uCount: ze("f"), uInvert: ze("b"), uGridDim: ze("v3"), uGridTexDim: ze("v3"), uGridTransform: ze("m4"), uScale: ze("v2"), dPackedGroup: Ht("boolean"), dAxisOrder: Ht("string", ["012", "021", "102", "120", "201", "210"]) }), bd = "isosurface";
function hfe(e, t, r, n, a, i, o, s, u, c, l, d, f, m) {
  if (e.namedComputeRenderables[bd]) {
    var h = e.namedComputeRenderables[bd].values;
    U.update(h.tActiveVoxelsPyramid, t), U.update(h.tActiveVoxelsBase, r), U.update(h.tVolumeData, n), U.updateIfChanged(h.uIsoValue, s), U.updateIfChanged(h.uSize, Math.pow(2, u)), U.updateIfChanged(h.uLevels, u), U.updateIfChanged(h.uCount, l), U.updateIfChanged(h.uInvert, d), U.update(h.uGridDim, a), U.update(h.uGridTexDim, i), U.update(h.uGridTransform, o), U.update(h.uScale, c), U.update(h.dPackedGroup, f), U.updateIfChanged(h.dAxisOrder, m.join("")), e.namedComputeRenderables[bd].update();
  } else e.namedComputeRenderables[bd] = function(p, g, v, y, _, S, b, x, A, w, C, M, T, N) {
    var I = k(k({}, Qa), { tTriIndices: U.create(cfe()), tActiveVoxelsPyramid: U.create(g), tActiveVoxelsBase: U.create(v), tVolumeData: U.create(y), uIsoValue: U.create(x), uSize: U.create(Math.pow(2, A)), uLevels: U.create(A), uCount: U.create(C), uInvert: U.create(M), uGridDim: U.create(_), uGridTexDim: U.create(S), uGridTransform: U.create(b), uScale: U.create(w), dPackedGroup: U.create(T), dAxisOrder: U.create(N.join("")) }), P = k({}, pfe), O = Rn("isosurface", Yi, lfe, { drawBuffers: "required" }), F = Ua(p, "triangles", O, P, I);
    return Ga(F, I);
  }(e, t, r, n, a, i, o, s, u, c, l, d, f, m);
  return e.namedComputeRenderables[bd];
}
function vfe(e, t, r, n, a, i, o, s, u, c, l, d, f) {
  var m = function(p, g, v, y, _, S) {
    var b = p.gl, x = p.resources, A = g.getWidth(), w = g.getHeight();
    p.namedFramebuffers[xu] || (p.namedFramebuffers[xu] = x.framebuffer());
    var C = p.namedFramebuffers[xu];
    C.bind(), p.namedTextures[xu] || (p.namedTextures[xu] = x.texture("image-uint8", "rgba", "ubyte", "nearest"));
    var M = p.namedTextures[xu];
    M.define(A, w);
    var T = mfe(p, g, v, y, _, S);
    return p.state.currentRenderItemId = -1, M.attachFramebuffer(C, 0), function(N) {
      var I = N.gl, P = N.state;
      P.disable(I.CULL_FACE), P.disable(I.BLEND), P.disable(I.DEPTH_TEST), P.enable(I.SCISSOR_TEST), P.depthMask(!1), P.colorMask(!0, !0, !0, !0), P.clearColor(0, 0, 0, 0);
    }(p), b.viewport(0, 0, A, w), b.scissor(0, 0, A, w), b.clear(b.COLOR_BUFFER_BIT), b.scissor(0, 0, y[0], y[1]), T.render(), b.finish(), M;
  }(e, t, r, n, o, a), h = function(p, g, v, y, _, S, b, x, A, w, C, M, T, N) {
    var I = p.extensions.drawBuffers;
    if (!I) throw new Error("need WebGL draw buffers");
    var P = p.gl, O = p.resources, F = p.extensions, R = y.pyramidTex, G = y.height, L = y.levels, q = y.scale, K = y.count, X = R.getWidth();
    p.namedFramebuffers[bd] || (p.namedFramebuffers[bd] = O.framebuffer());
    var H = p.namedFramebuffers[bd];
    lr(P) ? (M || (M = F.colorBufferHalfFloat && F.textureHalfFloat ? O.texture("image-float16", "rgba", "fp16", "nearest") : O.texture("image-float32", "rgba", "float", "nearest")), T || (T = O.texture("image-uint8", "rgba", "ubyte", "nearest")), N || (N = F.colorBufferHalfFloat && F.textureHalfFloat ? O.texture("image-float16", "rgba", "fp16", "nearest") : O.texture("image-float32", "rgba", "float", "nearest"))) : (M || (M = O.texture("image-float32", "rgba", "float", "nearest")), T || (T = O.texture("image-float32", "rgba", "float", "nearest")), N || (N = O.texture("image-float32", "rgba", "float", "nearest"))), M.define(X, G), T.define(X, G), N.define(X, G), M.attachFramebuffer(H, 0), T.attachFramebuffer(H, 1), N.attachFramebuffer(H, 2);
    var W = hfe(p, R, g, v, _, S, b, x, L, q, K, A, w, C);
    return p.state.currentRenderItemId = -1, H.bind(), I.drawBuffers([I.COLOR_ATTACHMENT0, I.COLOR_ATTACHMENT1, I.COLOR_ATTACHMENT2]), function(ee) {
      var $ = ee.gl, te = ee.state;
      te.disable($.CULL_FACE), te.disable($.BLEND), te.disable($.DEPTH_TEST), te.disable($.SCISSOR_TEST), te.depthMask(!1), te.colorMask(!0, !0, !0, !0), te.clearColor(0, 0, 0, 0);
    }(p), P.viewport(0, 0, X, G), P.clear(P.COLOR_BUFFER_BIT), W.render(), P.finish(), { vertexTexture: M, groupTexture: T, normalTexture: N, vertexCount: K };
  }(e, m, t, sfe(e, m, a, n), r, n, i, o, s, u, c, l, d, f);
  return h;
}
var Dz = { isoValue: dr.IsoValueParam }, k0 = 1;
function C5(e, t) {
  return !(e.grid.cells.data.length < Math.pow(10, 3)) && hy(e.grid.cells.space.dimensions, k0).powerOfTwoSize <= t.maxTextureSize / 2;
}
function gfe(e, t, r, n) {
  return r.tryUseGpu && n && function(a) {
    return a.extensions.colorBufferFloat && a.extensions.textureFloat && a.extensions.drawBuffers;
  }(n) && C5(t, n) ? function(a) {
    return C_({ defaultProps: V.getDefaultValues(I_), createGeometry: bfe, createLocationIterator: function(i) {
      return ca(i.grid.cells.data.length, 1, 1, function() {
        return dc;
      });
    }, getLoci: E_, eachLocation: D_, setUpdateState: function(i, o, s, u) {
      dr.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (i.createGeometry = !0);
    }, geometryUtils: qd.Utils, mustRecreate: function(i, o, s) {
      return !o.tryUseGpu || !s || !C5(i, s);
    }, dispose: function(i) {
      i.vertexTexture.ref.value.destroy(), i.groupTexture.ref.value.destroy(), i.normalTexture.ref.value.destroy(), i.doubleBuffer.destroy();
    } }, a);
  }(e) : function(a) {
    return C_({ defaultProps: V.getDefaultValues(I_), createGeometry: yfe, createLocationIterator: function(i) {
      return ca(i.grid.cells.data.length, 1, 1, function() {
        return dc;
      });
    }, getLoci: E_, eachLocation: D_, setUpdateState: function(i, o, s, u) {
      dr.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (i.createGeometry = !0);
    }, geometryUtils: Xt.Utils, mustRecreate: function(i, o, s) {
      return o.tryUseGpu && !!s && C5(i, s);
    } }, a);
  }(e);
}
function vI(e, t) {
  return dr.Isosurface.Loci(e, t.isoValue);
}
function E_(e, t, r, n) {
  var a = e.objectId, i = e.groupId;
  return n === a ? dr.Cell.Loci(t, Fe.ofSingleton(i)) : Tn;
}
function D_(e, t, r, n) {
  return function(a, i, o, s) {
    var u = !1;
    if (dr.isLoci(a)) {
      if (!dr.areEquivalent(a.volume, i)) return !1;
      s(Fe.ofLength(i.grid.cells.data.length)) && (u = !0);
    } else if (dr.Isosurface.isLoci(a)) {
      if (!dr.areEquivalent(a.volume, i)) return !1;
      if (o) {
        if (!dr.IsoValue.areSame(a.isoValue, o, i.grid.stats)) return !1;
        s(Fe.ofLength(i.grid.cells.data.length)) && (u = !0);
      } else for (var c = i.grid, l = c.stats, d = c.cells.data, f = l.sigma, m = dr.IsoValue.toAbsolute(a.isoValue, l).absoluteValue, h = 0, p = d.length; h < p; ++h) Yn(m, d[h], f) && s(Fe.ofSingleton(h)) && (u = !0);
    } else if (dr.Cell.isLoci(a)) {
      if (!dr.areEquivalent(a.volume, i)) return !1;
      Fe.is(a.indices) ? s(a.indices) && (u = !0) : We.forEach(a.indices, function(g) {
        s(Fe.ofSingleton(g)) && (u = !0);
      });
    }
    return u;
  }(e, t, r.isoValue, n);
}
function yfe(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s;
    return Te(this, function(u) {
      switch (u.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), i = lc(new Int32Array(t.grid.cells.data.length)), [4, vz({ isoLevel: dr.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: Wn.create(t.grid.cells.space, Wn.Data1(i)) }, a).runAsChild(e.runtime)];
        case 1:
          return o = u.sent(), s = Oo.getGridToCartesianTransform(t.grid), Xt.transform(o, s), e.webgl && !e.webgl.isWebGL2 && Xt.uniformTriangleGroup(o, !1), o.setBoundingSphere(dr.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
var M_, I_ = k(k(k(k({}, Xt.Params), qd.Params), Dz), { quality: k(k({}, Xt.Params.quality), { isEssential: !1 }), tryUseGpu: V.Boolean(!0) });
function bfe(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s, u, c, l, d, f, m, h, p, g, v, y, _;
    return Te(this, function(S) {
      if (!e.webgl) throw new Error("webgl context required to create volume isosurface texture-mesh");
      return t.grid.cells.data.length <= 1 ? [2, qd.createEmpty(a)] : (i = t.grid.stats, o = i.max, s = i.min, u = o - s, c = dr.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, l = (c - s) / u, d = M_.get(t, e.webgl), f = d.texture, m = d.gridDimension, h = d.gridTexDim, p = d.gridTexScale, g = d.transform, v = t.grid.cells.space.axisOrderSlowToFast, y = a == null ? void 0 : a.doubleBuffer.get(), _ = vfe(e.webgl, f, m, h, p, g, l, c < 0, !1, v, y == null ? void 0 : y.vertex, y == null ? void 0 : y.group, y == null ? void 0 : y.normal), [2, qd.create(_.vertexCount, 1, _.vertexTexture, _.groupTexture, _.normalTexture, dr.getBoundingSphere(t), a)]);
    });
  });
}
function xfe(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s;
    return Te(this, function(u) {
      switch (u.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), i = lc(new Int32Array(t.grid.cells.data.length)), [4, gz({ isoLevel: dr.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: Wn.create(t.grid.cells.space, Wn.Data1(i)) }, a).runAsChild(e.runtime)];
        case 1:
          return o = u.sent(), s = Oo.getGridToCartesianTransform(t.grid), Ur.transform(o, s), o.setBoundingSphere(dr.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
(function(e) {
  var t = "volume-isosurface-texture";
  e.descriptor = Tu({ name: t }), e.get = function(r, n) {
    var a = n.resources, i = Oo.getGridToCartesianTransform(r.grid), o = D.clone(r.grid.cells.space.dimensions), s = hy(o, k0), u = s.width, c = s.height, l = s.powerOfTwoSize, d = D.create(u, c, 0), f = Ze.create(u / l, c / l);
    if (l > n.maxTextureSize / 2) throw new Error("volume too large for gpu isosurface extraction");
    if (!r._propertyData[t]) {
      r._propertyData[t] = a.texture("image-uint8", "alpha", "ubyte", "linear");
      var m = r._propertyData[t];
      m.define(l, l), m.load(function(h, p, g) {
        var v = h.grid, y = v.cells, _ = y.space, S = y.data, b = v.stats, x = b.max, A = b.min, w = _.dimensions, C = _.dataOffset, M = hy(w, g), T = M.width, N = M.height, I = new Uint8Array(T * N * 1), P = { array: I, width: T, height: N }, O = x - A, F = w[0], R = w[1], G = w[2], L = F + g, q = R + g;
        D(), D();
        for (var K = 0; K < G; ++K) for (var X = 0; X < R; ++X) for (var H = 0; H < F; ++H) {
          var W = Math.floor(K * L % T / L), ee = 1 * (Math.floor(K * L / T) * q * T + X * T + (W * L + H)), $ = C(H, X, K);
          I[ee] = Math.round((S[$] - A) / O * 255);
        }
        return P;
      }(r, 0, k0), !0), r.customProperties.add(e.descriptor), r.customProperties.assets(e.descriptor, [{ dispose: function() {
        return m.destroy();
      } }]);
    }
    return o[0] += k0, o[1] += k0, { texture: r._propertyData[t], transform: i, gridDimension: o, gridTexDim: d, gridTexScale: f };
  };
})(M_ || (M_ = {}));
var Mz = k(k(k({}, Ur.Params), Dz), { quality: k(k({}, Ur.Params.quality), { isEssential: !1 }), sizeFactor: V.Numeric(3, { min: 0, max: 10, step: 0.1 }) });
function _fe(e) {
  return C_({ defaultProps: V.getDefaultValues(Mz), createGeometry: xfe, createLocationIterator: function(t) {
    return ca(t.grid.cells.data.length, 1, 1, function() {
      return dc;
    });
  }, getLoci: E_, eachLocation: D_, setUpdateState: function(t, r, n, a) {
    dr.IsoValue.areSame(n.isoValue, a.isoValue, r.grid.stats) || (t.createGeometry = !0);
  }, geometryUtils: Ur.Utils }, e);
}
var ol, T_, Ni, N_, Iz = { solid: function(e, t) {
  return pI("Isosurface mesh", e, t, gfe, vI);
}, wireframe: function(e, t) {
  return pI("Isosurface wireframe", e, t, _fe, vI);
} }, Tz = k(k(k({}, I_), Mz), { visuals: V.MultiSelect(["solid"], V.objectToOptions(Iz)), bumpFrequency: V.Numeric(1, { min: 0, max: 10, step: 0.1 }, yt.ShadingCategory), alpha: V.Numeric(0.12, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) });
function Sfe(e, t) {
  return fr.createMulti("Isosurface", e, t, fr.StateBuilder, Iz);
}
function gI(e) {
  return e === Ni.Float32 ? 4 : e === Ni.Int16 || e === Ni.Uint16 ? 2 : 1;
}
function Afe(e, t, r, n) {
  return r === void 0 && (r = 0), e === Ni.Float32 ? new Float32Array(t, r, n) : e === Ni.Int16 ? new Int16Array(t, r, n) : e === Ni.Uint16 ? new Uint16Array(t, r, n) : new Int8Array(t, r, n);
}
function wfe(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(o) {
      switch (o.label) {
        case 0:
          return [4, t.readBuffer(r, e.readBuffer, n, a)];
        case 1:
          return o.sent(), e.elementByteSize > 1 && (i !== void 0 && i !== ol.IsNativeEndianLittle || !ol.IsNativeEndianLittle) && ol.flipByteOrder(e.readBuffer, e.valuesBuffer, n, e.elementByteSize, a), [2, e.values];
      }
    });
  });
}
function Cfe(e) {
  return Be(this, 0, void 0, function() {
    var t, r, n, a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          return [4, e.readBuffer(0, 1024)];
        case 1:
          if (t = s.sent().buffer, (r = String.fromCharCode(t.readUInt8(208), t.readUInt8(209), t.readUInt8(210), t.readUInt8(211))) !== "MAP ") throw new Error('ccp4 format error, missing "MAP " string');
          return n = [t.readUInt8(212), t.readUInt8(213)], a = !1, n[0] === 68 && n[1] === 65 ? a = !0 : n[0] === 17 && n[1] === 17 ? a = !1 : t.readInt32LE(12) <= 16 && (a = !0), i = a ? function(u) {
            return t.readInt32LE(4 * u);
          } : function(u) {
            return t.readInt32BE(4 * u);
          }, o = a ? function(u) {
            return t.readFloatLE(4 * u);
          } : function(u) {
            return t.readFloatBE(4 * u);
          }, [2, { header: { NC: i(0), NR: i(1), NS: i(2), MODE: i(3), NCSTART: i(4), NRSTART: i(5), NSSTART: i(6), NX: i(7), NY: i(8), NZ: i(9), xLength: o(10), yLength: o(11), zLength: o(12), alpha: o(13), beta: o(14), gamma: o(15), MAPC: i(16), MAPR: i(17), MAPS: i(18), AMIN: o(19), AMAX: o(20), AMEAN: o(21), ISPG: i(22), NSYMBT: i(23), LSKFLG: i(24), SKWMAT: [], SKWTRN: [], userFlag1: i(39), userFlag2: i(40), originX: o(49), originY: o(50), originZ: o(51), MAP: r, MACHST: n, ARMS: o(54) }, littleEndian: a }];
      }
    });
  });
}
function Nz(e) {
  switch (e) {
    case 0:
      return Ni.Int8;
    case 1:
      return Ni.Int16;
    case 2:
      return Ni.Float32;
    case 3:
      throw new Error("mode 3 unsupported, complex 16-bit integers");
    case 4:
      throw new Error("mode 4 unsupported, complex 32-bit reals");
    case 6:
      Ni.Uint16;
    case 16:
      throw new Error("mode 16 unsupported, unsigned char * 3 (for rgb data, non-standard)");
  }
  throw new Error("unknown mode '".concat(e, "'"));
}
function Pz(e) {
  return e.userFlag1 === -128 && e.userFlag2 === 127;
}
function Bz(e) {
  return Pz(e) ? Ni.Float32 : Nz(e.MODE);
}
function Efe(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c, l, d, f;
    return Te(this, function(m) {
      switch (m.label) {
        case 0:
          return [4, r.update({ message: "Parsing CCP4/MRC/MAP file..." })];
        case 1:
          return m.sent(), [4, Cfe(e)];
        case 2:
          return n = m.sent(), a = n.header, i = n.littleEndian, o = function(h) {
            return 1024 + h.NSYMBT;
          }(a), s = Nz(a.MODE), u = Bz(a), c = a.NC * a.NR * a.NS, l = gI(s), d = c * l, f = function(h, p) {
            var g = gI(p), v = new ArrayBuffer(g * h), y = ol.fromArrayBuffer(v), _ = ol.IsNativeEndianLittle ? v : new ArrayBuffer(g * h);
            return { type: p, elementByteSize: g, readBuffer: y, valuesBuffer: new Uint8Array(_), values: Afe(p, _) };
          }(c, u), function(h, p, g, v, y, _) {
            Be(this, 0, void 0, function() {
              var S, b, x, A, w, C;
              return Te(this, function(M) {
                switch (M.label) {
                  case 0:
                    return Pz(h) ? (S = 3 * y, [4, g.readBuffer(v, p.readBuffer, y, S)]) : [3, 2];
                  case 1:
                    for (M.sent(), b = new Int8Array(p.valuesBuffer.buffer, S), x = (h.AMAX - h.AMIN) / 255, A = 0.5 * (h.AMIN + h.AMAX + x), w = 0, C = y; w < C; ++w) p.values[w] = x * b[w] + A;
                    return [3, 4];
                  case 2:
                    return [4, wfe(p, g, v, y, 0, _)];
                  case 3:
                    M.sent(), M.label = 4;
                  case 4:
                    return [2];
                }
              });
            });
          }(a, f, e, o, d, i), [2, { header: a, values: f.values, name: e.name }];
      }
    });
  });
}
function Dfe(e, t) {
  return function(r, n) {
    var a = this;
    return sr.create("Parse CCP4/MRC/MAP", function(i) {
      return Be(a, 0, void 0, function() {
        var o, s, u;
        return Te(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, 2, , 3]), s = (o = za).success, [4, Efe(r, 0, i)];
            case 1:
              return [2, s.apply(o, [c.sent()])];
            case 2:
              return u = c.sent(), [2, za.error(u)];
            case 3:
              return [2];
          }
        });
      });
    });
  }(T_.fromBuffer(ol.fromUint8Array(e), t), e.length);
}
function Mfe(e, t) {
  var r = this;
  return sr.create("Create Volume", function(n) {
    return Be(r, 0, void 0, function() {
      var a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S;
      return Te(this, function(b) {
        return a = e.header, i = e.values, o = D.create(a.xLength, a.yLength, a.zLength), s = D.create(Kn(a.alpha), Kn(a.beta), Kn(a.gamma)), u = a.ISPG > 65536 ? 0 : a.ISPG, c = tu.create(u || "P 1", o, s), l = D.create(a.MAPC - 1, a.MAPR - 1, a.MAPS - 1), d = Wn.convertToCanonicalAxisIndicesFastToSlow(l), f = [a.NX, a.NY, a.NZ], m = d([a.NC, a.NR, a.NS]), h = function(x) {
          return x.originX === 0 && x.originY === 0 && x.originZ === 0 ? D.create(x.NCSTART, x.NRSTART, x.NSSTART) : D.create(x.originX / (x.xLength / x.NX), x.originY / (x.yLength / x.NY), x.originZ / (x.zLength / x.NZ));
        }(a), p = d(h), g = D.create(p[0] / f[0], p[1] / f[1], p[2] / f[2]), v = D.create(m[0] / f[0], m[1] / f[1], m[2] / f[2]), y = Wn.Space(m, Wn.invertAxisOrder(l), function(x) {
          var A = Bz(x);
          switch (A) {
            case Ni.Float32:
              return Float32Array;
            case Ni.Int8:
              return Int8Array;
            case Ni.Int16:
              return Int16Array;
            case Ni.Uint16:
              return Uint16Array;
          }
          throw Error("".concat(A, " is not a supported value format."));
        }(a)), _ = Wn.create(y, Wn.Data1(i)), S = a.AMIN === 0 && a.AMAX === 0 && a.AMEAN === 0 && a.ARMS === 0, [2, { label: void 0, entryId: void 0, grid: { transform: { kind: "spacegroup", cell: c, fractionalBox: on.create(g, D.add(D.zero(), g, v)) }, cells: _, stats: { min: isNaN(a.AMIN) || S ? C$(i) : a.AMIN, max: isNaN(a.AMAX) || S ? j2(i) : a.AMAX, mean: isNaN(a.AMEAN) || S ? E$(i) : a.AMEAN, sigma: isNaN(a.ARMS) || a.ARMS === 0 ? D$(i) : a.ARMS } }, sourceData: N_.create(e), customProperties: new f1(), _propertyData: /* @__PURE__ */ Object.create(null) }];
      });
    });
  });
}
V.getDefaultValues(Tz), function(e) {
  function t(n) {
    var a = new DataView(n.buffer);
    return Object.assign(n.subarray(0), { readInt8: function(i) {
      return a.getInt8(i);
    }, readUInt8: function(i) {
      return a.getUint8(i);
    }, writeInt8: function(i, o) {
      return a.setInt8(o, i);
    }, writeUInt8: function(i, o) {
      return a.setUint8(o, i);
    }, readInt16LE: function(i) {
      return a.getInt16(i, !0);
    }, readInt32LE: function(i) {
      return a.getInt32(i, !0);
    }, readUInt16LE: function(i) {
      return a.getUint16(i, !0);
    }, readUInt32LE: function(i) {
      return a.getUint32(i, !0);
    }, readFloatLE: function(i) {
      return a.getFloat32(i, !0);
    }, readDoubleLE: function(i) {
      return a.getFloat64(i, !0);
    }, writeInt16LE: function(i, o) {
      return a.setInt16(o, i, !0);
    }, writeInt32LE: function(i, o) {
      return a.setInt32(o, i, !0);
    }, writeUInt16LE: function(i, o) {
      return a.setUint16(o, i, !0);
    }, writeUInt32LE: function(i, o) {
      return a.setUint32(o, i, !0);
    }, writeFloatLE: function(i, o) {
      return a.setFloat32(o, i, !0);
    }, writeDoubleLE: function(i, o) {
      return a.setFloat64(o, i, !0);
    }, readInt16BE: function(i) {
      return a.getInt16(i, !1);
    }, readInt32BE: function(i) {
      return a.getInt32(i, !1);
    }, readUInt16BE: function(i) {
      return a.getUint16(i, !1);
    }, readUInt32BE: function(i) {
      return a.getUint32(i, !1);
    }, readFloatBE: function(i) {
      return a.getFloat32(i, !1);
    }, readDoubleBE: function(i) {
      return a.getFloat64(i, !1);
    }, writeInt16BE: function(i, o) {
      return a.setInt16(o, i, !1);
    }, writeInt32BE: function(i, o) {
      return a.setInt32(o, i, !1);
    }, writeUInt16BE: function(i, o) {
      return a.setUint16(o, i, !1);
    }, writeUInt32BE: function(i, o) {
      return a.setUint32(o, i, !1);
    }, writeFloatBE: function(i, o) {
      return a.setFloat32(o, i, !1);
    }, writeDoubleBE: function(i, o) {
      return a.setFloat64(o, i, !1);
    }, copy: function(i, o, s, u) {
      return o = Pa(o, 0), s = Pa(s, 0), u = Pa(u, n.length), i.set(n.subarray(s, u), o), u - s;
    } });
  }
  function r(n, a, i, o, s) {
    for (var u = 0, c = i; u < c; u += o) for (var l = 0; l < o; l++) a[s + u + o - l - 1] = n[s + u + l];
  }
  e.fromUint8Array = t, e.fromArrayBuffer = function(n) {
    return t(new Uint8Array(n));
  }, e.fromBuffer = function(n) {
    return t(new Uint8Array(n));
  }, e.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330, e.flipByteOrder = r, e.flipByteOrderInPlace2 = function(n, a, i) {
    a === void 0 && (a = 0);
    for (var o = new Int16Array(n, a, i), s = 0, u = o.length; s < u; ++s) {
      var c = o[s];
      o[s] = (255 & c) << 8 | c >> 8 & 255;
    }
  }, e.ensureLittleEndian = function(n, a, i, o, s) {
    e.IsNativeEndianLittle || !i || o <= 1 || r(n, a, i, o, s);
  };
}(ol || (ol = {})), function(e) {
  e.fromBuffer = function(t, r) {
    return { name: r, readBuffer: function(n, a, i, o) {
      var s, u;
      if (typeof a == "number") {
        i = Pa(i, a);
        var c = n;
        s = (l = Math.min(t.length, c + i)) - c, u = ol.fromUint8Array(new Uint8Array(t.buffer, c, l - c));
      } else {
        i = Pa(i, a.length), c = n;
        var l = Math.min(t.length, c + i);
        a.set(t.subarray(c, l), o), s = l - c, u = a;
      }
      return i !== s && console.warn("byteCount ".concat(i, " and bytesRead ").concat(s, " differ")), Promise.resolve({ bytesRead: s, buffer: u });
    }, writeBuffer: function(n, a, i) {
      return i = Pa(i, a.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
    }, writeBufferSync: function(n, a, i) {
      return i = Pa(i, a.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
    }, close: p8 };
  };
}(T_ || (T_ = {})), function(e) {
  e.Float32 = "float32", e.Int8 = "int8", e.Int16 = "int16", e.Uint16 = "uint16";
}(Ni || (Ni = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "ccp4";
  }, e.create = function(t) {
    return { kind: "ccp4", name: t.name, data: t };
  };
}(N_ || (N_ = {}));
var Ife = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, Dfe(e, "Hermite").run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, Mfe(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Tfe = { createTheme: function(e, t, r) {
  var n, a;
  if (r != null && r.color) return { color: (n = t.managers.representation.ctx) === null || n === void 0 ? void 0 : n.colorThemeRegistry.create(r.color.name, { volume: e }, r.color.props), size: (a = t.managers.representation.ctx) === null || a === void 0 ? void 0 : a.colorThemeRegistry.create("uniform", {}, {}) };
}, parse: function(e, t) {
  return Be(this, 0, void 0, function() {
    var r;
    return Te(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, e.arrayBuffer()];
        case 1:
          return r = n.sent(), [4, Ife.parse(new Uint8Array(r))];
        case 2:
          return [2, n.sent()];
      }
    });
  });
}, create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = Sfe(t, function() {
            return Tz;
          }), r && a.setTheme(r), [4, a.createOrUpdate(n ?? {}, e).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(a ?? {}, t).run()];
        case 1:
          return i.sent(), n && e.setTheme(n), [2];
      }
    });
  });
} }, Nfe = { unitLabel: V.Text("Å", { isEssential: !0 }) }, Pfe = k(k(k({}, Ur.Params), Nfe), { lineSizeAttenuation: V.Boolean(!1), linesColor: V.Color(Qe(14080239), { isEssential: !0 }), linesSize: V.Numeric(0.8), alpha: V.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) }), Oz = { lines: function(e, t) {
  return Fn(Ffe, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.Highlighting });
  } });
} }, Bfe = k(k({}, Pfe), { visuals: V.MultiSelect(["lines"], V.objectToOptions(Oz)) });
function Ofe(e, t) {
  var r = t.sphereA, n = t.sphereB, a = t.center, i = e.loci, o = i[0], s = i[1];
  return an.getBoundingSphere(o, r), an.getBoundingSphere(s, n), D.add(a, r.center, n.center), D.scale(a, a, 0.5), t.distance = D.distance(r.center, n.center), t;
}
var Tf = { sphereA: Ve(), sphereB: Ve(), center: D(), distance: 0 };
function Ffe(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) Ofe(o.pairs[l], Tf), c.add(Tf.sphereA.center[0], Tf.sphereA.center[1], Tf.sphereA.center[2], Tf.sphereB.center[0], Tf.sphereB.center[1], Tf.sphereB.center[2], l);
    return c.getLines();
  }(t, 0, n && n.geometry), i = function(o, s) {
    return o.pairs.length === 1 ? "interactionLine ".concat(wh(o.pairs[0], { unitLabel: s, measureOnly: !0 })) : "".concat(o.pairs.length, " interactionLines");
  }(t, r.unitLabel);
  return or.create(i, t, a, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return wh(t.pairs[o], r);
  });
}
var Rfe = { parse: function(e, t) {
  return e.map(function(r) {
    var n = t.managers.cell.get(r.ref), a = dn(n);
    return ua(a, r.elementIds);
  });
}, create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n = function(i, o) {
            var s = fr.createMulti("interactionLine", i, o, fr.StateBuilder, Oz);
            return s.setState({ pickable: !0, markerActions: qr.All }), s;
          }(t, function() {
            return Bfe;
          }), [4, n.createOrUpdate({}, { pairs: [{ loci: e }] }).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate({}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Lfe = Ee.fromTranslation(Ee(), D.create(0.5, 0.5, 0.5)), kfe = g3(v3(TR()), Lfe), hu = D(), yI = Ee(), zfe = k(k({}, Xt.Params), { cellColor: V.Color($t.black), cellScale: V.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), ref: V.Select("model", V.objectToOptions({ origin: "Origin", model: "Model" }), { isEssential: !0 }), attachment: V.Select("corner", V.objectToOptions({ corner: "Corner", center: "Center" }), { isEssential: !0 }) }), Ufe = { mesh: function(e, t) {
  return Fn(Vfe, Xt.Utils);
} }, Gfe = k({}, zfe);
function Vfe(e, t, r, n) {
  var a = function(o, s, u) {
    var c = Nt.createState(256, 128, u), l = o.symmetry.spacegroup.cell.fromFractional;
    D.copy(hu, o.ref), s.attachment === "center" ? (D.trunc(hu, hu), D.subScalar(hu, hu, 0.5)) : D.floor(hu, hu), Ee.fromTranslation(yI, hu);
    var d = g3(v3(kfe), yI), f = Math.cbrt(o.symmetry.spacegroup.cell.volume) / 300 * s.cellScale;
    c.currentGroup = 1, Nt.addCage(c, l, d, f, 2, 20);
    var m = Ve.fromDimensionsAndTransform(Ve(), D.unit, l);
    D.transformMat4(hu, hu, l), Ve.translate(m, m, hu), Ve.expand(m, m, f);
    var h = Nt.getMesh(c);
    return h.setBoundingSphere(m), h;
  }(t, r, n && n.geometry), i = ny.getUnitcellLabel(t.symmetry);
  return or.create(i, t, a, function() {
    return r.cellColor;
  }, function() {
    return 1;
  }, function() {
    return i;
  });
}
var qfe = { create: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n;
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return n = function(i, o) {
            return fr.createMulti("Unit Cell", i, o, fr.StateBuilder, Ufe);
          }(t, function() {
            return Gfe;
          }), [4, n.createOrUpdate({}, e).run()];
        case 1:
          return a.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate({}, t).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Hfe = { unitLabel: V.Text("Å", { isEssential: !0 }) }, Kfe = k(k(k({}, Ur.Params), Hfe), { lineSizeAttenuation: V.Boolean(!1), linesColor: V.Color($t.black), linesSize: V.Numeric(2), alpha: V.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), isDash: V.Boolean(!1), dashLength: V.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), Fz = { lines: function(e, t) {
  return Fn(jfe, Ur.Utils, { modifyState: function(r) {
    return k(k({}, r), { markerActions: qr.Selecting });
  } });
} }, Xfe = k(k({}, Kfe), { visuals: V.MultiSelect(["lines"], V.objectToOptions(Fz)) });
function jfe(e, t, r, n) {
  var a = function(o, s, u) {
    for (var c = hi.create(128, 64, u), l = 0, d = o.lines.length; l < d; ++l) s.isDash ? c.addFixedLengthDashes(D.create(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2]), D.create(o.lines[l][1][0], o.lines[l][1][1], o.lines[l][1][2]), s.dashLength, l) : c.add(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2], o.lines[l][1][0], o.lines[l][1][1], o.lines[l][1][2], l);
    return c.getLines();
  }(t, r, n && n.geometry), i = function(o, s) {
    return "".concat(o.lines.length, " interactionLines");
  }(t, r.unitLabel);
  return or.create(i, t, a, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function() {
    return "CustomLines";
  });
}
var Yfe = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            var u = fr.createMulti("customLines", o, s, fr.StateBuilder, Fz);
            return u.setState({ pickable: !1, markerActions: qr.Selecting }), u;
          }(t, function() {
            return Xfe;
          }), [4, a.createOrUpdate(n ?? {}, { lines: e }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(a ?? {}, { lines: t }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Wfe = k(k({}, Xt.Params), { color: V.Color($t.orange), scaleFactor: V.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) }), Rz = { plane: function(e, t) {
  return Fn(Qfe, Xt.Utils);
} }, Zfe = k(k({}, Wfe), { visuals: V.MultiSelect(["plane"], V.objectToOptions(Rz)) });
function Qfe(e, t, r, n) {
  var a = function(i, o, s) {
    var u = Nt.createState(256, 128, s);
    return i.planes.forEach(function(c) {
      Nt.addTriangle(u, D.create.apply(D, c[0]), D.create.apply(D, c[1]), D.create.apply(D, c[2]));
    }), Nt.getMesh(u);
  }(t, 0, n && n.geometry);
  return or.create("CustomPlanes", t, a, function() {
    return r.color;
  }, function() {
    return 1;
  }, function() {
    return "CustomPlanes";
  });
}
var lp, h0, Zu, Ai, v0, $fe = { create: function(e, t, r, n) {
  return Be(this, 0, void 0, function() {
    var a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return a = function(o, s) {
            var u = fr.createMulti("CustomPlanes", o, s, fr.StateBuilder, Rz);
            return u.setState({ pickable: !1, markerActions: qr.Selecting }), u;
          }(t, function() {
            return Zfe;
          }), [4, a.createOrUpdate(n ?? {}, { planes: e }).run()];
        case 1:
          return i.sent(), [2, a];
      }
    });
  });
}, update: function(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(a ?? {}, { planes: t }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Zs = ((lp = {})[qe.Ribbon] = ile, lp[qe.BallAndStick] = Kk, lp[qe.Line] = fde, lp[qe.Stick] = mde, lp[qe.CPK] = Bde, lp), z0 = ((h0 = {})[qe.Label] = Cle, h0[qe.Distance] = Nle, h0[qe.Angle] = Gle, h0[qe.Dihedral] = tde, h0), B2 = ((Zu = {})[qe.Surface] = wde, Zu[qe.IsoSurface] = Tfe, Zu[qe.RotateArrow] = Nde, Zu[qe.Pocket] = Gde, Zu[qe.Pharmacophore] = Jde, Zu[qe.MappingLine] = Rfe, Zu[qe.UnitCell] = qfe, Zu[qe.CustomLines] = Yfe, Zu[qe.CustomPlanes] = $fe, Zu);
(function(e) {
  e.LigandReceptor = "ligand-receptor", e.IntraLigand = "intra-ligand", e.IntraReceptor = "intra-receptor", e.All = "all";
})(Ai || (Ai = {}));
var Jfe = function(e, t) {
  var r, n, a, i = Ci(e.getLoci());
  if (!i || !(!((a = (n = (r = i == null ? void 0 : i.elements) === null || r === void 0 ? void 0 : r[0]) === null || n === void 0 ? void 0 : n.unit) === null || a === void 0) && a.elements)) return vd.Not;
  var o = new Set(Ya(i)), s = 0;
  return t.forEach(function(u) {
    o.has(u) && s++;
  }), s ? s === t.length ? vd.Include : s === o.size ? vd.BeIncluded : vd.Cross : vd.Not;
}, eme = function(e, t) {
  var r, n;
  if (e.ref !== t.ref) return !1;
  if (!(!((r = e.elementIds) === null || r === void 0) && r.length) || !(!((n = t.elementIds) === null || n === void 0) && n.length)) return !0;
  var a = new Set(t.elementIds);
  return e.elementIds.some(function(i) {
    return a.has(i);
  });
}, Oy = function(e, t) {
  var r = Ci(e.getLoci());
  if (!r) return [];
  var n = ua(r == null ? void 0 : r.structure, t), a = et.intersect(r, n);
  return Ya(a);
}, P_ = function(e, t, r, n, a) {
  var i = zo(e);
  if (i) {
    var o = WL(i, t);
    return Zs[r].update(e, o, cd.managers.representation.ctx, n ? n(o) : e.theme), a && e.setState({ transparency: a(o) }), e;
  }
  console.warn("removeElementIdsInRepresentation");
}, tme = ((v0 = {})[qe.Label] = ["customText", "textColor", "textSize"], v0[qe.Distance] = ["linesColor", "textSize", "textColor"], v0[qe.Angle] = ["color", "textSize", "textColor"], v0[qe.Dihedral] = ["color", "textSize", "textColor"], v0), Lz = function(e, t) {
  if (Jp.has(e)) {
    var r = {};
    return tme[e].forEach(function(n) {
      r[n] = t.props[n];
    }), r;
  }
}, bI = function(e, t, r, n) {
  var a = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], i = e[0], o = e[1], s = e[2], u = function(I) {
    var P = D.create(I[0], I[1], I[2]);
    return D.normalize(P, P), [P[0], P[1], P[2]];
  }(function(I, P) {
    return [P[0] - I[0], P[1] - I[1], P[2] - I[2]];
  }(e, t)), c = u[0], l = u[1], d = u[2], f = c * c, m = c * l, h = c * d, p = l * l, g = l * d, v = d * d, y = i * c, _ = i * l, S = i * d, b = o * c, x = o * l, A = o * d, w = s * c, C = s * l, M = s * d, T = Math.cos(r * (Math.PI / 180)), N = Math.sin(r * (Math.PI / 180));
  return a[0][0] = f + (p + v) * T, a[0][1] = m * (1 - T) + d * N, a[0][2] = h * (1 - T) - l * N, a[0][3] = 0, a[1][0] = m * (1 - T) - d * N, a[1][1] = p + (f + v) * T, a[1][2] = g * (1 - T) + c * N, a[1][3] = 0, a[2][0] = h * (1 - T) + l * N, a[2][1] = g * (1 - T) - c * N, a[2][2] = v + (f + p) * T, a[2][3] = 0, a[3][0] = (i * (p + v) - c * (x + M)) * (1 - T) + (A - C) * N, a[3][1] = (o * (f + v) - l * (y + M)) * (1 - T) + (w - S) * N, a[3][2] = (s * (f + p) - d * (y + x)) * (1 - T) + (_ - b) * N, a[3][3] = 1, [n[0] * a[0][0] + n[1] * a[1][0] + n[2] * a[2][0] + a[3][0], n[0] * a[0][1] + n[1] * a[1][1] + n[2] * a[2][1] + a[3][1], n[0] * a[0][2] + n[1] * a[1][2] + n[2] * a[2][2] + a[3][2]];
}, kz = function(e, t, r) {
  var n, a, i, o, s, u;
  if (!e.canvas3d) return D.create(0, 0, 0);
  var c = Ze.create(0, 0), l = D.create(0, 0, 0), d = D.create(0, 0, 0);
  if (Ze.sub(c, Ze.copy(c, r), t), Ze.squaredMagnitude(c)) {
    var f = (a = (n = e.canvas3d) === null || n === void 0 ? void 0 : n.input.pixelRatio) !== null && a !== void 0 ? a : 1;
    return c[0] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.width * f, c[1] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.height * f * (((o = (i = e.layout) === null || i === void 0 ? void 0 : i.canvas.clientWidth) !== null && o !== void 0 ? o : 1) / ((u = (s = e.layout) === null || s === void 0 ? void 0 : s.canvas.clientHeight) !== null && u !== void 0 ? u : 1)), D.cross(l, D.sub(l, e.canvas3d.camera.position, e.canvas3d.camera.target), e.canvas3d.camera.up), D.setMagnitude(l, l, c[0]), D.setMagnitude(d, e.canvas3d.camera.up, c[1]), D.add(l, l, d), D.scale(l, l, 1 / 2100), l;
  }
  return D.create(0, 0, 0);
}, rme = function(e, t) {
  var r = et.getBoundary(ua(e, t));
  return { center: D.create((r.box.max[0] + r.box.min[0]) / 2, (r.box.max[1] + r.box.min[1]) / 2, (r.box.max[2] + r.box.min[2]) / 2), size: D.create(r.box.max[0] - r.box.min[0], r.box.max[1] - r.box.min[1], r.box.max[2] - r.box.min[2]) };
}, nme = function(e) {
  var t = ps(e);
  if (t) {
    var r = pi.Provider.get(t);
    if (r) {
      var n = function(a, i, o) {
        var s = D();
        return o.ref === "model" && D.transformMat4(s, yn.getCenter(a), i.spacegroup.cell.toFractional), { symmetry: i, ref: s };
      }(t, r, {});
      return n;
    }
  }
};
window.requestIdleCallback = window.requestIdleCallback || function(e) {
  var t = Date.now();
  return setTimeout(function() {
    e({ didTimeout: !1, timeRemaining: function() {
      return Math.max(0, 50 - (Date.now() - t));
    } });
  }, 1);
};
var B_, O_, g0 = new iu("98"), xI = function() {
  function e(t) {
    this.boundaryHelper = new iu("98"), this.plugin = t;
  }
  return e.prototype.focus = function(t) {
    var r;
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _ = this;
      return Te(this, function(S) {
        switch (S.label) {
          case 0:
            if (n = !1, a = [], i = [], t ? t.forEach(function(b) {
              var x = _.plugin.cells.get(b.ref);
              x && (Array.from(x.representations.keys()).some(function(A) {
                return Jp.has(A) || rse.has(A);
              }) ? i.push(b) : a.push(b));
            }) : (i.push.apply(i, Array.from(this.plugin.managers.selection.shape.selection.values()).map(function(b) {
              return { ref: b };
            })), a.push.apply(a, this.plugin.managers.selection.structure.getSelectionCellItems().length ? this.plugin.managers.selection.structure.getSelectionCellItems() : i.length ? [] : this.plugin.managers.cell.getAllDisplayedCellsRef().map(function(b) {
              return { ref: b };
            }))), !a.length && !i.length) return [2];
            o = D.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), s = D.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), g0.reset(), u = [], i.forEach(function(b) {
              var x = _.plugin.cells.get(b.ref);
              if (x) if (x.representations.has(qe.Surface)) a.push(x.model.other);
              else {
                if (x.representations.has(qe.Pharmacophore)) {
                  var A = x.model.other, w = A.center, C = A.normal, M = A.radius;
                  if (!C) return D.min(o, o, D.create(w[0] - M, w[1] - M, w[2] - M)), D.max(s, s, D.create(w[0] + M, w[1] + M, w[2] + M)), void (n = !0);
                  var T = D.create((w[0] + C[0]) / 2, (w[1] + C[1]) / 2, (w[2] + C[2]) / 2), N = (D.distance(C, w) + M) / 2;
                  return D.min(o, o, D.create(T[0] - N, T[1] - N, T[2] - N)), D.max(s, s, D.create(T[0] + N, T[1] + N, T[2] + N)), void (n = !0);
                }
                if (x.representations.has(qe.Pocket)) {
                  var I = x.model.other, P = (w = I.center, I.size), O = [(2 * w[0] + P[0]) / 2, (2 * w[1] + P[1]) / 2, (2 * w[2] + P[2]) / 2], F = [(2 * w[0] - P[0]) / 2, (2 * w[1] - P[1]) / 2, (2 * w[2] - P[2]) / 2], R = { min: D.fromArray(D.zero(), F, 0), max: D.fromArray(D.zero(), O, 0) };
                  return D.min(o, o, R.min), D.max(s, s, R.max), void (n = !0);
                }
                a.push.apply(a, x.dependency.on);
              }
            }), c = 0, l = a, S.label = 1;
          case 1:
            return c < l.length ? (d = l[c], this.plugin.cells.get(d.ref) ? [4, this.plugin.managers.cell.getStructure(d.ref)] : [2]) : [3, 4];
          case 2:
            if (!(f = S.sent())) return [2];
            m = ua(f, d.elementIds), (!et.isEmpty(m) || ((r = m == null ? void 0 : m.elements) === null || r === void 0 ? void 0 : r.length) > 0) && u.push(et.getBoundary(m)), S.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            if (!u.length) return n && this.focusSphere({ center: D.create((s[0] + o[0]) / 2, (s[1] + o[1]) / 2, (s[2] + o[2]) / 2), radius: D.distance(s, o) / 2 }), [2];
            for (g = 0, v = u.length; g < v; ++g) h = u[g], p = h.box, y = h.sphere, D.min(o, o, p.min), D.max(s, s, p.max), g0.includePositionRadius(y.center, y.radius);
            for (g0.finishedIncludeStep(), g = 0, v = u.length; g < v; ++g) y = u[g].sphere, g0.radiusPositionRadius(y.center, y.radius);
            return this.focusSphere(g0.getSphere()), [2];
        }
      });
    });
  }, e.prototype.focusSphere = function(t, r) {
    var n, a, i = k({ minRadius: 5, extraRadius: 4, durationMs: 250 }, r), o = i.extraRadius, s = i.minRadius, u = i.durationMs, c = Math.max(t.radius + o, s), l = (n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.camera.getFocus(t.center, c);
    (a = this.plugin.canvas3d) === null || a === void 0 || a.requestCameraReset({ durationMs: u, snapshot: l });
  }, e.prototype.reset = function() {
    var t;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.requestCameraReset({ durationMs: 200 });
  }, e.prototype.zoomIn = function() {
    var t, r, n = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (n) {
      var a = _I(n, 1);
      D.distance(n.target, a) < 10 || (n.position = a, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200));
    }
  }, e.prototype.zoomOut = function() {
    var t, r, n = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (n) {
      var a = _I(n, -1);
      n.position = a, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200);
    }
  }, e.prototype.updateAxes = function(t) {
    var r, n, a, i, o, s, u, c, l = { vecA: D.unitX, vecB: D.unitY, vecC: D.unitZ }, d = this.plugin.cells.get(t);
    if (d) {
      var f = dn(d);
      if (f && (!((i = (a = (n = (r = ps(f)) === null || r === void 0 ? void 0 : r.sourceData) === null || n === void 0 ? void 0 : n.data) === null || a === void 0 ? void 0 : a.molecules) === null || i === void 0) && i.length)) {
        var m = (u = (s = (o = ps(f)) === null || o === void 0 ? void 0 : o.sourceData) === null || s === void 0 ? void 0 : s.data) === null || u === void 0 ? void 0 : u.molecules[0].cell, h = m.vecA, p = m.vecB, g = m.vecC;
        l = { vecA: D.scale(D(), h, 1 / D.distance(D(), h)), vecB: D.scale(D(), p, 1 / D.distance(D(), p)), vecC: D.scale(D(), g, 1 / D.distance(D(), g)) };
      }
    }
    (c = this.plugin.canvas3d) === null || c === void 0 || c.setProps({ camera: { helper: { axes: { name: "on", params: l } } } });
  }, e;
}();
function _I(e, t) {
  var r = D();
  D.sub(r, e.target, e.position), D.normalize(r, r), D.scale(r, r, 5 * t);
  var n = e.position;
  return D.add(n, n, r), n;
}
(function(e) {
  e.create = function(t, r) {
    var n = [], a = [], i = [];
    return { add: function(o, s, u) {
      n[n.length] = o, a[a.length] = s, i[i.length] = u;
    }, getContacts: function() {
      for (var o = new Ho.EdgeBuilder(t.count, n, a), s = new Int8Array(o.slotCount), u = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(s, i[c]);
      var d, f = o.createGraph({ type: s, flag: u });
      return Object.defineProperty(f, "elementsIndex", { get: function() {
        return d || (d = t_.createElementsIndex(f, t, r));
      } });
    } };
  };
})(B_ || (B_ = {})), function(e) {
  e.create = function() {
    var t = new em.Builder();
    return { startUnitPair: function(r, n) {
      t.startUnitPair(r.id, n.id);
    }, finishUnitPair: function() {
      t.finishUnitPair();
    }, add: function(r, n, a) {
      t.add(r, n, { type: a, flag: _o.None });
    }, getContacts: function(r) {
      return new _oe(t.getMap(), r);
    } };
  };
}(O_ || (O_ = {}));
var ame = { lineOfSightDistFactor: V.Numeric(1, { min: 0, max: 3, step: 0.1 }) }, ime = 3;
function zz(e, t, r) {
  var n = t.members[t.offsets[t.feature]], a = r.members[r.offsets[r.feature]];
  if (n === a && t.unit === r.unit) return !1;
  var i = Ay(t.unit, n), o = Ay(r.unit, a);
  return (!i || !o || i === o) && (t.unit.residueIndex[t.unit.elements[n]] !== r.unit.residueIndex[r.unit.elements[a]] || t.unit !== r.unit) && !doe(e, t.unit, n, r.unit, a);
}
function SI(e, t, r, n) {
  var a = Ay(e, t), i = Ay(r, n);
  return a && i && a !== i;
}
function AI(e, t) {
  for (var r = t.feature, n = t.offsets, a = t.members, i = n[r], o = n[r + 1]; i < o; ++i) if (a[i] === e) return !0;
  return !1;
}
var sd = D(), E5 = D(), D5 = D(), ome = WF();
function sme(e, t, r, n) {
  var a = t.feature, i = r.feature, o = t.members[t.offsets[a]], s = r.members[r.offsets[i]];
  nn.position(E5, t), nn.position(D5, r), D.scale(sd, D.add(sd, E5, D5), 0.5);
  var u = n * ime, c = e.lookup3d.find(sd[0], sd[1], sd[2], u, ome), l = c.count, d = c.indices, f = c.units, m = c.squaredDistances;
  if (l === 0) return !0;
  for (var h = 0; h < l; ++h) {
    var p = d[h], g = f[h];
    if (Ke.isAtomic(g)) {
      var v = Hr(g, p);
      if (v !== "H") {
        var y = m3(v);
        if (!(y * y * n * n <= m[h] || SI(g, p, t.unit, o) || SI(g, p, r.unit, s) || t.unit === g && AI(p, t) || r.unit === g && AI(p, r) || (g.conformation.position(g.elements[p], sd), D.squaredDistance(sd, E5) < 1 || D.squaredDistance(sd, D5) < 1))) return !1;
      }
    }
  }
  return !0;
}
function ume(e, t, r, n, a, i, o) {
  for (var s = r.x, u = r.y, c = r.z, l = r.subset(a.requiredFeatures), d = l.lookup3d, f = l.indices, m = nn.Info(e, t, r), h = k({}, m), p = 0, g = We.size(f); p < g; ++p) {
    var v = We.getAt(f, p), y = d.find(s[v], u[v], c[v], a.maxDistance), _ = y.count, S = y.indices, b = y.squaredDistances;
    if (_ !== 0) {
      m.feature = v;
      for (var x = 0; x < _; ++x) {
        var A = We.getAt(f, S[x]);
        if (!(A <= v)) {
          h.feature = A;
          var w = m.unit.elements[m.members[m.offsets[m.feature]]], C = h.unit.elements[h.members[h.offsets[h.feature]]];
          if ((!o || o(m.unit, w, h.unit, C)) && zz(e, m, h)) {
            var M = a.getType(e, m, h, b[x]);
            M && n.add(v, A, M);
          }
        }
      }
    }
  }
}
var cme = Ee(), lme = { distanceMax: V.Numeric(4, { min: 1, max: 5, step: 0.1 }) }, dme = nn.Provider([8], function(e, t, r) {
  for (var n = t.elements, a = t.model.atomicConformation, i = a.x, o = a.y, s = a.z, u = function(d, f) {
    var m = Hr(t, d), h = !1;
    m === "C" ? (h = !0, kd(e, t, d, function(p, g) {
      var v = Hr(p, g);
      v !== "C" && v !== "H" && (h = !1);
    })) : m === "F" && (h = !0), h && r.add(8, 0, i[n[d]], o[n[d]], s[n[d]], d);
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), fme = { name: "hydrophobic", params: lme, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([8]), getType: function(t, r, n, a) {
    return function(i, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (d = l, c === 8 && d === 8) {
        var d, f = o.members[o.offsets[o.feature]], m = s.members[s.offsets[s.feature]];
        if (Hr(o.unit, f) !== "F" || Hr(s.unit, m) !== "F") return Cr.Hydrophobic;
      }
    }(0, r, n);
  } };
} };
function mme(e, t) {
  var r = t.contacts, n = function(c, l, d, f, m) {
    var h = f.get(d) || [1 / 0, -1], p = h[0], g = h[1];
    c < p ? (g !== -1 && m(g), f.set(d, [c, l])) : m(l);
  };
  function a(c, l, d, f, m) {
    var h = l.members[l.offsets[l.feature]], p = d.members[d.offsets[d.feature]], g = l.unit.getResidueIndex(h), v = d.unit.getResidueIndex(p), y = "".concat(h, "|").concat(l.unit.id, "|").concat(v, "|").concat(d.unit.id, "|A"), _ = "".concat(p, "|").concat(d.unit.id, "|").concat(g, "|").concat(l.unit.id, "|B"), S = nn.distance(l, d);
    n(S, c, y, f, m), n(S, c, _, f, m);
  }
  var i, o, s = /* @__PURE__ */ new Map(), u = function(c) {
    return r.edges[c].props.flag = _o.Filtered;
  };
  return { isApplicable: function(c) {
    return c === Cr.Hydrophobic;
  }, handleInterContact: function(c, l, d) {
    a(c, l, d, s, u);
  }, startUnit: function(c, l, d) {
    i = /* @__PURE__ */ new Map(), o = function(f) {
      return l.edgeProps.flag[f] = _o.Filtered;
    };
  }, handleIntraContact: function(c, l, d) {
    a(c, l, d, i, o);
  } };
}
function pme(e, t) {
  var r = t.contacts, n = function(a, i) {
    for (var o = a.types[a.feature] === 9 ? i : a, s = o.members[o.offsets[o.feature]], u = t.unitsContacts.get(o.unit.id), c = u.edgeProps.type, l = u.elementsIndex, d = l.offsets, f = l.indices, m = d[s], h = d[s + 1]; m < h; ++m) if (c[f[m]] === Cr.HydrogenBond) return !0;
    var p = r.getEdgeIndices(o.feature, o.unit.id);
    for (m = 0, h = p.length; m < h; ++m) if (r.edges[p[m]].props.type === Cr.HydrogenBond) return !0;
    return !1;
  };
  return { isApplicable: function(a) {
    return a === Cr.WeakHydrogenBond;
  }, handleInterContact: function(a, i, o) {
    n(i, o) && (r.edges[a].props.flag = _o.Filtered);
  }, startUnit: function() {
  }, handleIntraContact: function(a, i, o) {
    n(i, o) && (t.unitsContacts.get(i.unit.id).edgeProps.flag[a] = _o.Filtered);
  } };
}
function xS(e, t, r, n, a) {
  for (var i = r.offsets, o = r.feature, s = n.offsets, u = n.feature, c = i[o], l = i[o + 1]; c < l; ++c) for (var d = r.members[c], f = a.getContactIndicesForElement(d, r.unit), m = 0, h = f.length; m < h; ++m) {
    var p = f[m];
    if (e.includes(a.edges[p].props.type)) for (var g = s[u], v = s[u + 1]; g < v; ++g) {
      var y = n.members[g];
      if (a.getContactIndicesForElement(y, n.unit).includes(p)) return void (a.edges[t].props.flag = _o.Filtered);
    }
  }
}
function _S(e, t, r, n, a) {
  for (var i = a.edgeProps, o = i.type, s = i.flag, u = a.elementsIndex, c = u.offsets, l = u.indices, d = r.offsets, f = r.feature, m = n.offsets, h = n.feature, p = d[f], g = d[f + 1]; p < g; ++p) for (var v = r.members[p], y = c[v], _ = c[v + 1]; y < _; ++y) {
    var S = l[y];
    if (e.includes(o[S])) {
      for (var b = m[h], x = m[h + 1]; b < x; ++b) for (var A = n.members[b], w = c[A], C = c[A + 1]; w < C; ++w) if (S === l[w]) return void (s[t] = _o.Filtered);
    }
  }
}
function hme(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === Cr.Ionic;
  }, handleInterContact: function(n, a, i) {
    xS([Cr.HydrogenBond, Cr.WeakHydrogenBond], n, a, i, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, a, i) {
    _S([Cr.HydrogenBond, Cr.WeakHydrogenBond], n, a, i, t.unitsContacts.get(a.unit.id));
  } };
}
function vme(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === Cr.Hydrophobic || n === Cr.CationPi;
  }, handleInterContact: function(n, a, i) {
    xS([Cr.PiStacking], n, a, i, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, a, i) {
    _S([Cr.PiStacking], n, a, i, t.unitsContacts.get(a.unit.id));
  } };
}
function gme(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === Cr.Ionic;
  }, handleInterContact: function(n, a, i) {
    xS([Cr.MetalCoordination], n, a, i, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, a, i) {
    _S([Cr.MetalCoordination], n, a, i, t.unitsContacts.get(a.unit.id));
  } };
}
function yme(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M;
    return Te(this, function(T) {
      return Ke.isAtomic(t) ? (o = r.child, s = o == null ? void 0 : o.unitMap.get(t.id), o && !s ? [2, Xt.createEmpty(i)] : (u = lt.create(r, t), c = ra.get(r).value, l = c.unitsFeatures.get(t.id), d = c.unitsContacts.get(t.id), f = l.x, m = l.y, h = l.z, p = l.members, g = l.offsets, v = d.edgeCount, y = d.a, _ = d.b, S = d.edgeProps.flag, b = a.sizeFactor, v ? (x = { linkCount: 2 * v, position: function(N, I, P) {
        D.set(N, f[y[P]], m[y[P]], h[y[P]]), D.set(I, f[_[P]], m[_[P]], h[_[P]]);
      }, style: function(N) {
        return 1;
      }, radius: function(N) {
        u.element = t.elements[p[g[y[N]]]];
        var I = n.size.size(u);
        u.element = t.elements[p[g[_[N]]]];
        var P = n.size.size(u);
        return Math.min(I, P) * b;
      }, ignore: function(N) {
        if (S[N] === _o.Filtered) return !0;
        if (s) for (var I = y[N], P = g[I], O = g[I + 1]; P < O; ++P) {
          var F = t.elements[p[g[P]]];
          if (!$e.has(s.elements, F)) return !0;
        }
        return !1;
      } }, A = M3(0, x, a, i), w = A.mesh, (C = A.boundingSphere) ? w.setBoundingSphere(C) : w.triangleCount > 0 && (M = Ve.expand(Ve(), (s ?? t).boundary.sphere, 1 * b), w.setBoundingSphere(M)), [2, w]) : [2, Xt.createEmpty(i)])) : [2, Xt.createEmpty(i)];
    });
  });
}
var Uz = k(k(k({}, Al), D3), { sizeFactor: V.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: V.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: V.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: V.Boolean(!1) });
function bme(e) {
  return wl({ defaultProps: V.getDefaultValues(Uz), createGeometry: yme, createLocationIterator: Sme, getLoci: xme, eachLocation: _me, setUpdateState: function(t, r, n, a, i, o, s) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var u = ra.get(o.structure).version;
    t.info.interactionsHash !== u && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = u);
  } }, e);
}
function xme(e, t, r) {
  var n = e.objectId, a = e.instanceId, i = e.groupId;
  if (r === n) {
    var o = t.structure, s = t.group, u = o.unitMap.get(s.units[a].id), c = ra.get(o).value, l = c.unitsContacts.get(u.id), d = l.a, f = l.b;
    return hl.Loci(o, c, [{ unitA: u, indexA: d[i], unitB: u, indexB: f[i] }, { unitA: u, indexA: f[i], unitB: u, indexB: d[i] }]);
  }
  return Tn;
}
var M5 = /* @__PURE__ */ new Set();
function _me(e, t, r, n) {
  var a = !1;
  if (hl.isLoci(e)) {
    var i = t.structure, o = t.group;
    if (!st.areEquivalent(e.data.structure, i)) return !1;
    var s = ra.get(i).value;
    if (e.data.interactions !== s) return !1;
    for (var u = o.units[0], c = s.unitsContacts.get(u.id), l = 2 * c.edgeCount, d = 0, f = e.elements; d < f.length; d++)
      if ((T = f[d]).unitA === T.unitB) {
        var m = o.unitIndexMap.get(T.unitA.id);
        if (m !== void 0) {
          var h = c.getDirectedEdgeIndex(T.indexA, T.indexB);
          h !== -1 && r(Fe.ofSingleton(m * l + h)) && (a = !0);
        }
      }
  } else if (et.is(e)) {
    if (i = t.structure, o = t.group, !st.areEquivalent(e.structure, i) || !(s = ra.get(i).value)) return !1;
    u = o.units[0];
    for (var p = s.unitsContacts.get(u.id), g = s.unitsFeatures.get(u.id), v = 2 * p.edgeCount, y = p.offset, _ = g.elementsIndex, S = _.offsets, b = _.indices, x = g.members, A = g.offsets, w = function(N) {
      var I = o.unitIndexMap.get(N.unit.id);
      if (I === void 0) return "continue";
      We.forEach(N.indices, function(P) {
        for (var O = S[P], F = S[P + 1]; O < F; ++O) for (var R = b[O], G = y[R], L = y[R + 1]; G < L; ++G) M5.add(G);
      }), M5.forEach(function(P) {
        if (n) {
          for (var O = p.a[P], F = A[O], R = A[O + 1]; F < R; ++F) if (!We.has(N.indices, x[F])) return;
          var G = p.b[P];
          for (F = A[G], R = A[G + 1]; F < R; ++F) if (!We.has(N.indices, x[F])) return;
        }
        r(Fe.ofSingleton(I * v + P)) && (a = !0);
      }), M5.clear();
    }, C = 0, M = e.elements; C < M.length; C++) {
      var T;
      w(T = M[C]);
    }
  }
  return a;
}
function Sme(e) {
  var t = e.structure, r = e.group, n = r.units[0], a = ra.get(t).value, i = a.unitsContacts.get(n.id), o = 2 * i.edgeCount, s = r.units.length, u = hl.Location(a, t), c = u.element;
  return ca(o, s, 1, function(l, d) {
    var f = r.units[d];
    return c.unitA = f, c.indexA = i.a[l], c.unitB = f, c.indexB = i.b[l], u;
  });
}
function Ame(e, t, r, n, a) {
  if (!t.hasAtomic) return Xt.createEmpty(a);
  var i = lt.create(t), o = ra.get(t).value, s = o.contacts, u = o.unitsFeatures, c = s.edgeCount, l = s.edges, d = n.sizeFactor;
  if (!c) return Xt.createEmpty(a);
  var f = t.child, m = { linkCount: c, position: function(_, S, b) {
    var x = l[b], A = x.unitA, w = x.indexA, C = x.unitB, M = x.indexB, T = u.get(A), N = u.get(C), I = t.unitMap.get(A), P = t.unitMap.get(C);
    D.set(_, T.x[w], T.y[w], T.z[w]), D.transformMat4(_, _, I.conformation.operator.matrix), D.set(S, N.x[M], N.y[M], N.z[M]), D.transformMat4(S, S, P.conformation.operator.matrix);
  }, style: function(_) {
    return 1;
  }, radius: function(_) {
    var S = l[_], b = u.get(S.unitA);
    i.unit = t.unitMap.get(S.unitA), i.element = i.unit.elements[b.members[b.offsets[S.indexA]]];
    var x = r.size.size(i), A = u.get(S.unitB);
    i.unit = t.unitMap.get(S.unitB), i.element = i.unit.elements[A.members[A.offsets[S.indexB]]];
    var w = r.size.size(i);
    return Math.min(x, w) * d;
  }, ignore: function(_) {
    if (l[_].props.flag === _o.Filtered) return !0;
    if (f) {
      var S = l[_], b = f.unitMap.get(S.unitA);
      if (!b) return !0;
      for (var x = t.unitMap.get(S.unitA), A = u.get(S.unitA), w = A.offsets, C = A.members, M = w[S.indexA], T = w[S.indexA + 1]; M < T; ++M) {
        var N = x.elements[C[M]];
        if (!$e.has(b.elements, N)) return !0;
      }
    }
    return !1;
  } }, h = M3(0, m, n, a), p = h.mesh, g = h.boundingSphere;
  if (g) p.setBoundingSphere(g);
  else if (p.triangleCount > 0) {
    var v = t.child, y = Ve.expand(Ve(), (v ?? t).boundary.sphere, 1 * d);
    p.setBoundingSphere(y);
  }
  return p;
}
var Gz = k(k(k({}, ck), D3), { sizeFactor: V.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: V.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: V.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: V.Boolean(!1) });
function wme(e) {
  return lk({ defaultProps: V.getDefaultValues(Gz), createGeometry: Ame, createLocationIterator: Dme, getLoci: Cme, eachLocation: Eme, setUpdateState: function(t, r, n, a, i, o, s) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var u = ra.get(o).version;
    t.info.interactionsHash !== u && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = u);
  } }, e);
}
function Cme(e, t, r) {
  var n = e.objectId, a = e.groupId;
  if (r === n) {
    var i = ra.get(t).value, o = i.contacts.edges[a], s = t.unitMap.get(o.unitA), u = t.unitMap.get(o.unitB);
    return hl.Loci(t, i, [{ unitA: s, indexA: o.indexA, unitB: u, indexB: o.indexB }, { unitA: u, indexA: o.indexB, unitB: s, indexB: o.indexA }]);
  }
  return Tn;
}
var Qg = /* @__PURE__ */ new Map(), I5 = /* @__PURE__ */ new Set();
function Eme(e, t, r, n) {
  var a = !1;
  if (hl.isLoci(e)) {
    if (!st.areEquivalent(e.data.structure, t)) return !1;
    var i = ra.get(t).value;
    if (e.data.interactions !== i) return !1;
    for (var o = i.contacts, s = 0, u = e.elements; s < u.length; s++) {
      var c = u[s], l = o.getEdgeIndex(c.indexA, c.unitA.id, c.indexB, c.unitB.id);
      l !== -1 && r(Fe.ofSingleton(l)) && (a = !0);
    }
  } else if (et.is(e)) {
    if (!st.areEquivalent(e.structure, t) || n && e.elements.length === 1 || !(i = ra.get(t).value)) return !1;
    for (var d = i.contacts, f = i.unitsFeatures, m = 0, h = e.elements; m < h.length; m++) {
      var p = h[m];
      Qg.set(p.unit.id, p.indices);
    }
    for (var g = function(_) {
      var S = _.unit;
      if (!Ke.isAtomic(S)) return "continue";
      We.forEach(_.indices, function(b) {
        for (var x = 0, A = d.getContactIndicesForElement(b, S); x < A.length; x++) {
          var w = A[x];
          I5.add(w);
        }
      });
    }, v = 0, y = e.elements; v < y.length; v++)
      g(p = y[v]);
    I5.forEach(function(_) {
      if (n) {
        var S = d.edges[_], b = S.indexA, x = S.unitA, A = S.indexB, w = S.unitB, C = Qg.get(x), M = Qg.get(w);
        if (!C || !M) return;
        for (var T = f.get(x), N = T.offsets, I = T.members, P = N[b], O = N[b + 1]; P < O; ++P) if (!We.has(C, I[P])) return;
        var F = f.get(w), R = F.offsets, G = F.members;
        for (P = R[A], O = R[A + 1]; P < O; ++P) if (!We.has(M, G[P])) return;
      }
      r(Fe.ofSingleton(_)) && (a = !0);
    }), Qg.clear(), I5.clear();
  }
  return a;
}
function Dme(e) {
  var t = ra.get(e).value, r = t.contacts, n = r.edgeCount, a = hl.Location(t, e), i = a.element;
  return ca(n, 1, 1, function(o) {
    var s = r.edges[o];
    return i.unitA = e.unitMap.get(s.unitA), i.indexA = s.indexA, i.unitB = e.unitMap.get(s.unitB), i.indexB = s.indexB, a;
  }, !0);
}
var Vz = { "intra-unit": function(e, t) {
  return ji("Intra-unit interactions cylinder", e, t, bme);
}, "inter-unit": function(e, t) {
  return um("Inter-unit interactions cylinder", e, t, wme);
} }, wI = k(k(k({}, Uz), Gz), { unitKinds: Gh(["atomic"]), sizeFactor: V.Numeric(0.15, { min: 0.01, max: 1, step: 0.01 }), visuals: V.MultiSelect(["intra-unit", "inter-unit"], V.objectToOptions(Vz)) }), y0, hl, dp = { name: "interactions", label: "Non-covalent Interactions", description: "Displays non-covalent interactions as dashed cylinders.", factory: function(e, t) {
  return fr.createMulti("Interactions", e, t, ys, Vz);
}, getParams: function(e, t) {
  return V.clone(wI);
}, defaultValues: V.getDefaultValues(wI), defaultColorTheme: { name: "interaction-type" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0 && ra.isApplicable(e);
}, ensureCustomProperties: { attach: function(e, t) {
  return ra.attach(e, t, void 0, !0);
}, detach: function(e) {
  return ra.ref(e, !1);
} }, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, T5 = { createOrUpdateInCellItems: function(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s, u;
    return Te(this, function(c) {
      switch (c.label) {
        case 0:
          return i = N2(e, t).structure, o = k(k({}, ra.defaultParams), { type: r }), n && (o.providers.defaultValue = n), [4, ra.attach({ runtime: fs, assetManager: new $c() }, i, o)];
        case 1:
          return c.sent(), t.managers.cell.traverse(function(l, d) {
            var f;
            d.type === qe.IntraInteractions && (s = l.ref, d.state && ((f = t.canvas3d) === null || f === void 0 || f.remove(d.state), d.state.destroy())), d.type === qe.BetweenInteractions && t.managers.cell.remove([{ ref: l.ref }]);
          }), (u = dp.factory(t.managers.representation.ctx, dp.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: i }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: i }) }), [4, u.createOrUpdate({}, i).run()];
        case 2:
          return c.sent(), [2, { representation: u, structure: i, ref: s }];
      }
    });
  });
}, createOrUpdateBetweenCellItems: function(e, t, r, n, a) {
  return Be(this, 0, void 0, function() {
    var i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x;
    return Te(this, function(A) {
      switch (A.label) {
        case 0:
          for (i = N2(nt(nt([], e, !0), t, !0), r), o = i.unitsMap, s = i.structure, u = k({}, ra.defaultParams), n && (u.providers.defaultValue = n), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = 0, d = e.length; p < d; p++) o.get(p).forEach(function(w) {
            return c.add(w);
          });
          for (p = 0, d = t.length; p < d; p++) o.get(p + e.length).forEach(function(w) {
            return l.add(w);
          });
          return [4, ra.attach({ runtime: fs, assetManager: new $c() }, s, u)];
        case 1:
          if (A.sent(), !s.state.propertyData.molstar_computed_interactions) return [2, {}];
          for (f = s.state.propertyData.molstar_computed_interactions.data.value, m = f.contacts, h = f.unitsFeatures, p = 0, g = m.edgeCount; p < g; ++p) v = m.edges[p], y = s.unitMap.get(v.unitA), _ = s.unitMap.get(v.unitB), nn.Info(s, y, h.get(v.unitA)).feature = v.indexA, nn.Info(s, _, h.get(v.unitB)).feature = v.indexB, c.has(v.unitA) && l.has(v.unitB) || l.has(v.unitA) && c.has(v.unitB) || (m.edges[p].props.flag = _o.Filtered);
          return b = [], r.managers.cell.traverse(function(w, C) {
            var M;
            C.type === qe.BetweenInteractions && (S = w.ref, C.state && ((M = r.canvas3d) === null || M === void 0 || M.remove(C.state), C.state.destroy())), C.type === qe.IntraInteractions && b.push({ ref: w.ref });
          }), [4, r.managers.cell.remove(b)];
        case 2:
          return A.sent(), (x = dp.factory(r.managers.representation.ctx, dp.getParams)).setTheme({ color: r.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: s }), size: r.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: s }) }), [4, x.createOrUpdate({ visuals: ["inter-unit"] }, s).run()];
        case 3:
          return A.sent(), [2, { representation: x, structure: s, ref: S }];
      }
    });
  });
}, createOrUpdateGlobal: function(e, t, r, n, a, i) {
  return Be(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R, G;
    return Te(this, function(L) {
      switch (L.label) {
        case 0:
          o = /* @__PURE__ */ new Map(), s = [], u = 0, c = [], f8(a1).forEach(function(q) {
            var K = (n ?? N.providers.defaultValue)[q], X = K.name, H = K.params;
            X === "on" && c.push(a1[q].createTester(H));
          }), l = /* @__PURE__ */ new Set(), c.forEach(function(q) {
            return bo.add(l, q.requiredFeatures);
          }), d = qz.filter(function(q) {
            return bo.areIntersecting(l, q.types);
          }), C = 0, M = e.length, L.label = 1;
        case 1:
          return C < M ? (f = e[C], (m = t.cells.get(f.ref)) ? (h = f.elementIds ? sa(dn(m), f.elementIds) : dn(m), [4, Uh.attach({ runtime: fs, assetManager: new $c() }, h)]) : [3, 3]) : [3, 4];
        case 2:
          for (L.sent(), h.currentPropertyData.molstar_computed_valence_model.data.value.forEach(function(q) {
            o.set(u, q), u++;
          }), p = 0, g = h.units.length; p < g; p++) v = Kz(h, h.units[p], d), s.push(v);
          L.label = 3;
        case 3:
          return C++, [3, 1];
        case 4:
          for (y = N2(e, t), _ = y.unitsMap, S = y.structure, b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), w = function(q, K) {
            A.set(e[q].ref, /* @__PURE__ */ new Set());
            var X = _.get(q), H = t.cells.get(e[q].ref);
            if (H) {
              var W = dn(H).units;
              X.forEach(function(ee, $) {
                b.set(ee, e[q].ref), W && W[$] && x.set("".concat(e[q].ref, "_").concat(W[$].invariantId), ee);
              });
            }
          }, C = 0, M = e.length; C < M; C++) w(C);
          return Object.assign(S.currentPropertyData, { molstar_computed_valence_model: { props: { assignCharge: "auto", assignH: "auto" }, data: { id: 3224, version: 1, value: o } } }), T = /* @__PURE__ */ new Set(), i == null || i.map(function(q) {
            var K = q.ref, X = q.elementIds, H = t.cells.get(K);
            H && dn(H).units.forEach(function(W) {
              W.elements.filter(function(ee) {
                return X == null ? void 0 : X.includes(ee);
              }).forEach(function(ee) {
                return T.add("".concat(x.get("".concat(K, "_").concat(W.invariantId)), "_").concat(ee));
              });
            });
          }), N = k(k({}, ra.defaultParams), { type: r, featuresList: s, filterKeys: i ? Array.from(T.values()) : void 0 }), n && (N.providers.defaultValue = n), [4, ra.attach({ runtime: fs, assetManager: new $c() }, S, N)];
        case 5:
          return L.sent(), I = S.state.propertyData.molstar_computed_interactions.data.value, P = I.contacts, O = I.unitsContacts, F = I.unitsFeatures, P.edges.forEach(function(q) {
            var K = q.indexA, X = q.indexB, H = q.unitA, W = q.unitB, ee = q.props.flag, $ = F.get(H), te = $.members, re = $.offsets, ie = F.get(W), oe = ie.members, se = ie.offsets;
            if (ee !== _o.Filtered) {
              var he = S.unitMap.get(H).elements[te[re[K]]], ge = S.unitMap.get(W).elements[oe[se[X]]];
              A.get(b.get(H)).add(he), A.get(b.get(W)).add(ge);
            }
          }), Array.from(O.entries()).forEach(function(q) {
            for (var K = q[0], X = q[1], H = F.get(K), W = H.members, ee = H.offsets, $ = X.a, te = X.b, re = 0, ie = $.length; re < ie; re++) {
              var oe = S.unitMap.get(K).elements[W[ee[$[re]]]], se = S.unitMap.get(K).elements[W[ee[te[re]]]];
              A.get(b.get(K)).add(oe), A.get(b.get(K)).add(se);
            }
          }), t.managers.cell.traverse(function(q, K) {
            var X;
            K.type === qe.IntraInteractions && (R = q.ref, K.state && ((X = t.canvas3d) === null || X === void 0 || X.remove(K.state), K.state.destroy()));
          }), (G = dp.factory(t.managers.representation.ctx, dp.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: S }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: S }) }), [4, G.createOrUpdate({}, S).run()];
        case 6:
          return L.sent(), [2, { representation: G, structure: S, ref: R, interactionElementIds: Array.from(A.keys()).map(function(q) {
            return { ref: q, elementIds: Array.from(A.get(q).values()) };
          }).filter(function(q) {
            return q.elementIds.length;
          }) }];
      }
    });
  });
} };
(function(e) {
  function t(a, i) {
    var o = i.unitA, s = i.indexA, u = i.unitB, c = i.indexB, l = a.contacts, d = a.unitsContacts;
    if (o === u) {
      var f = d.get(o.id), m = f.getDirectedEdgeIndex(s, c);
      return r_(f.edgeProps.type[m]);
    }
    return m = l.getEdgeIndex(s, o.id, c, u.id), r_(l.edges[m].props.type);
  }
  function r(a, i, o) {
    var s = a.unitsFeatures;
    return Lp.fromPairProvider(i.length, function(u, c, l) {
      var d = i[u];
      nn.setPosition(c, d.unitA, d.indexA, s.get(d.unitA.id)), nn.setPosition(l, d.unitB, d.indexB, s.get(d.unitB.id));
    }, o);
  }
  function n(a, i, o) {
    var s = o[0];
    if (s === void 0) return "";
    var u = s.unitA, c = s.indexA, l = s.unitB, d = s.indexB, f = i.unitsFeatures, m = f.get(u.id), h = m.members, p = m.offsets, g = f.get(l.id), v = g.members, y = g.offsets, _ = { granularity: "element" };
    return (p[c + 1] - p[c] > 1 || y[d + 1] - y[d] > 1) && (_.granularity = "residue"), [t(i, s), jk(Pt.Location(a, u, h[p[c]], a, l, v[y[d]]), _)].join("</br>");
  }
  e.Location = function(a, i, o, s, u, c) {
    return /* @__PURE__ */ function(l, d, f) {
      return { kind: "data-location", tag: l, data: d, element: f };
    }("interactions", { structure: i, interactions: a }, { unitA: o, indexA: s, unitB: u, indexB: c });
  }, e.isLocation = function(a) {
    return !!a && a.kind === "data-location" && a.tag === "interactions";
  }, e.areLocationsEqual = function(a, i) {
    return a.data.structure === i.data.structure && a.data.interactions === i.data.interactions && a.element.indexA === i.element.indexA && a.element.indexB === i.element.indexB && a.element.unitA === i.element.unitA && a.element.unitB === i.element.unitB;
  }, e.locationLabel = function(a) {
    return t(a.data.interactions, a.element);
  }, e.Loci = function(a, i, o) {
    return z8("interactions", { structure: a, interactions: i }, o, function(s) {
      return r(i, o, s);
    }, function() {
      return n(a, i, o);
    });
  }, e.isLoci = function(a) {
    return !!a && a.kind === "data-loci" && a.tag === "interactions";
  }, e.getBoundingSphere = r, e.getLabel = n;
})(hl || (hl = {}));
var qz = [Coe, Eoe, Doe, Voe, qoe, Hoe, Ooe, Foe, dme, $oe, Joe], a1 = { ionic: Koe, "pi-stacking": Xoe, "cation-pi": joe, "halogen-bonds": Roe, "hydrogen-bonds": Moe, "weak-hydrogen-bonds": Ioe, hydrophobic: fme, "metal-coordination": ese }, Mme = function(e) {
  e === void 0 && (e = []);
  var t = /* @__PURE__ */ Object.create(null);
  return Object.keys(a1).forEach(function(r) {
    t[r] = V.MappedStatic(e.includes(r) ? "on" : "off", { on: V.Group(a1[r].params), off: V.Group({}) }, { cycle: !0 });
  }), t;
}(["ionic", "cation-pi", "pi-stacking", "hydrogen-bonds", "halogen-bonds", "metal-coordination", "weak-hydrogen-bonds"]), Ime = ((y0 = {})[Ai.LigandReceptor] = {}, y0[Ai.IntraLigand] = {}, y0[Ai.IntraReceptor] = {}, y0[Ai.All] = {}, y0), Tme = Object.keys(Ime), Nme = V.arrayToOptions(Tme), Hz = { providers: V.Group(Mme, { isFlat: !0 }), contacts: V.Group(ame, { label: "Advanced Options" }), type: V.Select(Ai.LigandReceptor, Nme, { isEssential: !0, description: "Visual/rendering quality of the representation." }), featuresList: V.Value([], { isHidden: !0 }), filterKeys: V.Value(void 0, { isHidden: !0 }) };
function Pme(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T;
    return Te(this, function(N) {
      switch (N.label) {
        case 0:
          n = k(k({}, V.getDefaultValues(Hz)), r), a = n.type, i = n.featuresList, o = n.filterKeys, s = new Set(o), u = BL(t).data, c = u.ligand, l = u.other, d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), Object.keys(c).forEach(function(I) {
            Object.keys(c[I]).forEach(function(P) {
              c[I][P].forEach(function(O) {
                d.add(O.unitId), f.add("".concat(O.unitId, "_").concat(O.elementId));
              });
            });
          }), Object.keys(l).forEach(function(I) {
            Object.keys(l[I]).forEach(function(P) {
              l[I][P].forEach(function(O) {
                d.add(O.unitId), f.add("".concat(O.unitId, "_").concat(O.elementId));
              });
            });
          }), m = [], f8(a1).forEach(function(I) {
            var P = n.providers[I], O = P.name, F = P.params;
            O === "on" && m.push(a1[I].createTester(a === Ai.All && ["hydrogen-bonds", "weak-hydrogen-bonds"].includes(I) ? k(k({}, F), { water: !0 }) : F));
          }), h = /* @__PURE__ */ new Set(), m.forEach(function(I) {
            return bo.add(h, I.requiredFeatures);
          }), p = qz.filter(function(I) {
            return bo.areIntersecting(h, I.types);
          }), g = uc.Mutable(), v = uc.Mutable(), y = 0, _ = t.unitSymmetryGroups.length, N.label = 1;
        case 1:
          return y < _ ? (S = t.unitSymmetryGroups[y], e.runtime.shouldUpdate ? [4, e.runtime.update({ message: "computing interactions", current: y, max: _ })] : [3, 3]) : [3, 5];
        case 2:
          N.sent(), N.label = 3;
        case 3:
          for (b = i && i[y] ? i[y] : Kz(t, S.units[0], p), x = function(I, P, O, F, R, G) {
            var L = B_.create(O, P.elements.length);
            return Ke.isAtomic(P) && function(q, K, X, H, W, ee, $) {
              for (var te = 0, re = W; te < re.length; te++) ume(q, K, X, H, re[te], 0, $);
            }(I, P, O, L, F, 0, G), L.getContacts();
          }(t, S.units[0], b, m, n.contacts, function(I, P, O, F) {
            return !!(!o || s.has("".concat(I.invariantId, "_").concat(P)) && s.has("".concat(O.invariantId, "_").concat(F))) && a !== Ai.IntraReceptor && (a === Ai.All || ["".concat(I.invariantId, "_").concat(P), "".concat(O.invariantId, "_").concat(F)].filter(function(R) {
              return f.has(R);
            }).length === (a === Ai.LigandReceptor ? 1 : 2));
          }), A = 0, w = S.units.length; A < w; ++A) C = S.units[A], g.set(C.id, b), v.set(C.id, x);
          N.label = 4;
        case 4:
          return ++y, [3, 1];
        case 5:
          return M = function(I, P, O, F, R) {
            var G = O_.create();
            return st.eachUnitPair(I, function(L, q) {
              var K = P.get(L.id), X = P.get(q.id);
              (function(H, W, ee, $, te, re, ie, oe, se) {
                var he = ee.count, ge = ee.x, De = ee.y, ae = ee.z, ce = te.lookup3d, _e = Ee.mul(cme, $.conformation.operator.inverse, W.conformation.operator.matrix), le = !Ee.isIdentity(_e), ue = D(), be = Math.max.apply(Math, ie.map(function(Je) {
                  return Je.maxDistance;
                })), Se = ce.boundary.sphere, Ne = Se.center, J = Se.radius, Z = (J + be) * (J + be), de = oe.lineOfSightDistFactor, ye = nn.Info(H, W, ee), Ae = nn.Info(H, $, te);
                re.startUnitPair(W, $);
                for (var Ce = 0; Ce < he; ++Ce) if (D.set(ue, ge[Ce], De[Ce], ae[Ce]), le && D.transformMat4(ue, ue, _e), !(D.squaredDistance(ue, Ne) > Z)) {
                  var Ie = ce.find(ue[0], ue[1], ue[2], be), Ue = Ie.indices, Xe = Ie.count, je = Ie.squaredDistances;
                  if (Xe !== 0) {
                    ye.feature = Ce;
                    for (var ht = 0; ht < Xe; ++ht) {
                      var xt = Ue[ht];
                      if (Ae.feature = xt, (!se || se(ye.unit, ye.unit.elements[ye.members[ye.offsets[Ce]]], Ae.unit, Ae.unit.elements[Ae.members[Ae.offsets[xt]]])) && zz(H, ye, Ae)) for (var dt = je[ht], Le = 0, j = ie; Le < j.length; Le++) {
                        var xe = j[Le];
                        if (dt < xe.maxDistance * xe.maxDistance) {
                          var ke = xe.getType(H, ye, Ae, dt);
                          if (ke && sme(H, ye, Ae, de)) {
                            re.add(Ce, xt, ke);
                            break;
                          }
                        }
                      }
                    }
                  }
                }
                re.finishUnitPair();
              })(I, L, K, q, X, G, O, F, R == null ? void 0 : R.elementIdFilter);
            }, { maxRadius: Math.max.apply(Math, O.map(function(L) {
              return L.maxDistance;
            })), validUnit: function(L) {
              return Ke.isAtomic(L);
            }, validUnitPair: function(L, q) {
              return st.validUnitPair(I, L, q) && (!(R != null && R.unitFilter) || R.unitFilter(L, q));
            } }), G.getContacts(P);
          }(t, g, m, n.contacts, { unitFilter: function(I, P) {
            return a === Ai.LigandReceptor ? [I.invariantId, P.invariantId].filter(function(O) {
              return d.has(O);
            }).length >= 1 : a !== Ai.IntraLigand || [I.invariantId, P.invariantId].filter(function(O) {
              return d.has(O);
            }).length === 2;
          }, elementIdFilter: function(I, P, O, F) {
            return !!(!o || s.has("".concat(I.invariantId, "_").concat(P)) && s.has("".concat(O.invariantId, "_").concat(F))) && (a === Ai.All || ["".concat(I.invariantId, "_").concat(P), "".concat(O.invariantId, "_").concat(F)].filter(function(R) {
              return f.has(R);
            }).length === (a === Ai.LigandReceptor ? 1 : a === Ai.IntraReceptor ? 0 : 2));
          } }), function(I, P) {
            for (var O = P.contacts, F = P.unitsContacts, R = P.unitsFeatures, G = [mme(0, P), pme(0, P), hme(0, P), vme(0, P), gme(0, P)], L = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), X = 0, H = O.edgeCount; X < H; ++X) {
              var W = O.edges[X], ee = I.unitMap.get(W.unitA), $ = I.unitMap.get(W.unitB);
              if ((ue = nn.Info(I, ee, R.get(W.unitA))).feature = W.indexA, (be = nn.Info(I, $, R.get(W.unitB))).feature = W.indexB, W.props.type === 5) {
                for (var te = [], re = (J = ue.types[ue.feature] === 5 ? ue : be).offsets[J.feature], ie = J.offsets[J.feature + 1]; re < ie; re++) te.push(J.members[re]);
                te.length > 1 && q.set(X, te), te.length === 1 && L.add(te[0]);
              }
              if (F.size) for (var oe = 0, se = G; oe < se.length; oe++) (ye = se[oe]).isApplicable(W.props.type) && ye.handleInterContact(X, ue, be);
            }
            for (var he = F.keys(); ; ) {
              var ge = he.next(), De = ge.done, ae = ge.value;
              if (De) break;
              var ce = F.get(ae), _e = R.get(ae), le = I.unitMap.get(ae);
              if (Ke.isAtomic(le)) {
                for (var ue = nn.Info(I, le, _e), be = nn.Info(I, le, _e), Se = 0, Ne = G; Se < Ne.length; Se++) (ye = Ne[Se]).startUnit(le, ce, _e);
                for (X = 0, H = 2 * ce.edgeCount; X < H; ++X) {
                  if (ue.feature = ce.a[X], be.feature = ce.b[X], ce.edgeProps.type[X] === 5) {
                    var J;
                    for (te = [], re = (J = ue.types[ue.feature] === 5 ? ue : be).offsets[J.feature], ie = J.offsets[J.feature + 1]; re < ie; re++) te.push(J.members[re]);
                    te.length > 1 && K.set(X, { elements: te, value: ae }), te.length === 1 && L.add(te[0]);
                  }
                  for (var Z = 0, de = G; Z < de.length; Z++) {
                    var ye;
                    (ye = de[Z]).isApplicable(ce.edgeProps.type[X]) && ye.handleIntraContact(X, ue, be);
                  }
                }
              }
            }
            q.forEach(function(Ae, Ce) {
              Ae.filter(function(Ie) {
                return L.has(Ie);
              }).length > 0 && (O.edges[Ce].props.flag = _o.Filtered);
            }), K.forEach(function(Ae, Ce) {
              var Ie = Ae.elements, Ue = Ae.value;
              Ie.filter(function(Xe) {
                return L.has(Xe);
              }).length > 0 && (F.get(Ue).edgeProps.flag[Ce] = _o.Filtered);
            });
          }(t, T = { unitsFeatures: g, unitsContacts: v, contacts: M }), [2, T];
      }
    });
  });
}
function Kz(e, t, r) {
  var n = t.elements.length, a = e_.create(n, n / 2);
  if (Ke.isAtomic(t)) for (var i = 0, o = r; i < o.length; i++)
    o[i].add(e, t, a);
  return a.getFeatures(n);
}
var N5 = k({}, Hz), ra = Up.createProvider({ label: "Interactions", descriptor: Tu({ name: "molstar_computed_interactions" }), type: "local", defaultParams: N5, getParams: function(e) {
  return N5;
}, isApplicable: function(e) {
  return !e.isCoarseGrained;
}, obtain: function(e, t, r) {
  return Be(void 0, 0, void 0, function() {
    var n, a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return n = k(k({}, V.getDefaultValues(N5)), r), a = {}, [4, Pme(e, t, n)];
        case 1:
          return [2, (a.value = i.sent(), a)];
      }
    });
  });
} }), F_ = Qe(13421772), Xi = { HydrogenBond: 16751667, Hydrophobic: 8421504, HalogenBond: 6154474, Ionic: 15820019, MetalCoordination: 11646163, CationPi: 3392621, PiStacking: 4436985, WeakHydrogenBond: 16771231 }, Bme = [["Hydrogen Bond", Xi.HydrogenBond], ["Hydrophobic", Xi.Hydrophobic], ["Halogen Bond", Xi.HalogenBond], ["Ionic", Xi.Ionic], ["Metal Coordination", Xi.MetalCoordination], ["Cation Pi", Xi.CationPi], ["Pi Stacking", Xi.PiStacking], ["Weak HydrogenBond", Xi.WeakHydrogenBond]];
function CI(e) {
  switch (e) {
    case Cr.HydrogenBond:
      return Xi.HydrogenBond;
    case Cr.Hydrophobic:
      return Xi.Hydrophobic;
    case Cr.HalogenBond:
      return Xi.HalogenBond;
    case Cr.Ionic:
      return Xi.Ionic;
    case Cr.MetalCoordination:
      return Xi.MetalCoordination;
    case Cr.CationPi:
      return Xi.CationPi;
    case Cr.PiStacking:
      return Xi.PiStacking;
    case Cr.WeakHydrogenBond:
      return Xi.WeakHydrogenBond;
    case Cr.Unknown:
      return F_;
  }
}
var EI = {}, b0, ud, x0, Nf, $g, Ome = { name: "interaction-type", label: "Interaction Type", category: "Miscellaneous", factory: function e(t, r) {
  var n, a = t.structure ? ra.get(t.structure) : void 0, i = a ? d1(a.id, a.version) : -1;
  return n = a && a.value ? function(o) {
    if (hl.isLocation(o)) {
      var s = o.data.interactions, u = s.unitsContacts, c = s.contacts, l = o.element, d = l.unitA, f = l.unitB, m = l.indexA, h = l.indexB;
      if (d === f) {
        var p = u.get(d.id), g = p.getDirectedEdgeIndex(m, h);
        return CI(p.edgeProps.type[g]);
      }
      return g = c.getEdgeIndex(m, d.id, h, f.id), CI(c.edges[g].props.type);
    }
    return F_;
  } : function() {
    return F_;
  }, { factory: e, granularity: "group", color: n, props: r, contextHash: i, description: "Assigns colors according the interaction type of a link.", legend: Pu(Bme) };
}, getParams: function(e) {
  return EI;
}, defaultValues: V.getDefaultValues(EI), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? ra.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && ra.ref(e.structure, !1);
} } }, R_ = { color: (b0 = {}, b0[Mt.ATOM] = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: Qe(14474728) } } } }, b0[Mt.RIBBON] = { name: "uniform", props: { value: Qe(14474728) } }, b0[Mt.SURFACE] = { name: "uniform" }, b0), size: (ud = {}, ud[qe.BallAndStick] = { name: "physical" }, ud[qe.Stick] = { name: "uniform" }, ud[qe.Line] = { name: "physical" }, ud[qe.CPK] = { name: "physical" }, ud[qe.Ribbon] = { name: "uniform" }, ud[qe.Surface] = { name: "physical" }, ud), transparency: (x0 = {}, x0[Mt.ATOM] = 0, x0[Mt.RIBBON] = 0, x0[Mt.SURFACE] = 0, x0) }, P5 = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: Qe(4777267) } } } }, Fme = function() {
  function e(t, r) {
    this.plugin = t, this.defaultTheme = k(k({}, R_), r);
  }
  return e.prototype.createColorTheme = function(t, r, n) {
    var a, i, o, s, u, c = this;
    return t.name === "multi-theme" ? (a = this.ctx) === null || a === void 0 ? void 0 : a.colorThemeRegistry.create("multi-theme", { structure: r }, { themes: (s = !((o = (i = t.props) === null || i === void 0 ? void 0 : i.themes) === null || o === void 0) && o.length ? t.props.themes : [this.defaultTheme.color[n]]) === null || s === void 0 ? void 0 : s.map(function(l) {
      return { colorTheme: c.createColorTheme(l, l.elementIds ? sa(r, l.elementIds) : r, n), bundle: vo.fromLoci(ua(r, l.elementIds)) };
    }) }) : (u = this.ctx) === null || u === void 0 ? void 0 : u.colorThemeRegistry.create(t.name, { structure: t.elementIds ? sa(r, t.elementIds) : r }, t.props);
  }, e.prototype.createTheme = function(t, r, n) {
    var a = Object.keys(On).find(function(s) {
      return On[s].includes(t);
    }), i = n != null && n.color ? n == null ? void 0 : n.color : this.defaultTheme.color[a], o = n != null && n.size ? n == null ? void 0 : n.size : this.defaultTheme.size[t];
    return { color: this.createColorTheme(i, r, a), size: this.ctx.sizeThemeRegistry.create(o.name, { structure: r }, o.props) };
  }, e.prototype.createTransparencyLayers = function(t, r) {
    if (!(r != null && r.length)) return { kind: "empty-loci", layers: [] };
    var n = r.map(function(a) {
      var i = a.elementIds, o = a.value;
      return { loci: ua(t, i), value: o !== void 0 ? 1 - o : 0 };
    });
    return { kind: "element-loci", layers: n };
  }, e.prototype.setColorTheme = function(t, r, n) {
    var a = this;
    t.forEach(function(i) {
      var o, s, u, c, l = i.ref, d = i.elementIds, f = a.plugin.cells.get(l);
      if (!(f != null && f.model.structure) && (f != null && f.representations.has(qe.Surface))) {
        if (n !== Mt.SURFACE) return;
        var m = et.toStructure(Ci(f.representations.get(qe.Surface).state.getLoci())), h = ms(m);
        return f.theme.color = ((o = { Atom: [], Ribbon: [] })[Mt.SURFACE] = [k({ elementIds: h }, r)], o), void B2[qe.Surface].update((u = f == null ? void 0 : f.representations.get(qe.Surface)) === null || u === void 0 ? void 0 : u.state, m, a.ctx, a.createTheme(qe.Surface, m, { color: r }));
      }
      var p = nt([], d ?? [], !0);
      d || p.push.apply(p, Ya(st.toStructureElementLoci(dn(f))));
      var g = new Set(p);
      f && (f.theme.color ? (!((c = f.theme.color[n]) === null || c === void 0) && c.length && (f.theme.color[n].forEach(function(v, y) {
        f.theme.color[n][y].elementIds = f.theme.color[n][y].elementIds.filter(function(_) {
          return !g.has(_);
        });
      }), f.theme.color[n] = f.theme.color[n].filter(function(v) {
        var y = v.elementIds;
        return y == null ? void 0 : y.length;
      })), f.theme.color[n].push(k({ elementIds: Array.from(g.values()) }, r))) : f.theme.color = ((s = { Atom: [], Ribbon: [], Surface: [] })[n] = [k({ elementIds: Array.from(g.values()) }, r)], s), On[n].forEach(function(v) {
        var y, _ = f.representations.get(v);
        if (_) {
          var S = zo(_.state);
          Zs[v].update(_.state, S, a.ctx, { color: a.ctx.colorThemeRegistry.create("multi-theme", { structure: S }, { themes: (y = f.theme.color[n]) === null || y === void 0 ? void 0 : y.map(function(b) {
            return { colorTheme: a.createColorTheme(b, S, n), bundle: vo.fromLoci(ua(S, b.elementIds)) };
          }) }), size: _.state.theme.size });
        }
      }));
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setTransparency = function(t, r, n) {
    var a = this, i = /* @__PURE__ */ new Set();
    t.forEach(function(s) {
      var u, c, l, d, f = s.ref, m = s.elementIds, h = a.plugin.cells.get(f);
      if (!(h != null && h.model.structure) && (h != null && h.representations.has(qe.Surface))) {
        if (n !== Mt.SURFACE) return;
        var p = et.toStructure(Ci(h.representations.get(qe.Surface).state.getLoci())), g = ms(p);
        return h.theme.transparency = ((u = {})[Mt.SURFACE] = [{ elementIds: g, value: r }], u), void ((l = h == null ? void 0 : h.representations.get(qe.Surface)) === null || l === void 0 || l.state.setState({ transparency: a.createTransparencyLayers(zo((d = h == null ? void 0 : h.representations.get(qe.Surface)) === null || d === void 0 ? void 0 : d.state), h == null ? void 0 : h.theme.transparency[n]) }));
      }
      var v = nt([], m ?? [], !0);
      !m && h && (p = dn(h)) && v.push.apply(v, Ya(st.toStructureElementLoci(p)));
      var y = new Set(v);
      if (h) if (i.add(f), h.theme.transparency) {
        var _ = h.theme.transparency[n];
        _.length && (_.forEach(function(S, b) {
          S.elementIds, _[b].elementIds = v.filter(function(x) {
            return !y.has(x);
          });
        }), h.theme.transparency[n] = _.filter(function(S) {
          return S.elementIds, v.length;
        })), h.theme.transparency[n].push({ elementIds: Array.from(y.values()), value: r });
      } else h.theme.transparency = ((c = {})[Mt.ATOM] = [], c[Mt.RIBBON] = [], c[Mt.SURFACE] = [], c[n] = { elementIds: Array.from(y.values()), value: r }, c);
    });
    var o = On[n];
    i.forEach(function(s) {
      var u = a.plugin.cells.get(s);
      o.forEach(function(c) {
        var l = u == null ? void 0 : u.representations.get(c);
        if (l) {
          var d = zo(l.state), f = a.createTransparencyLayers(d, u == null ? void 0 : u.theme.transparency[n]);
          l.state.setState({ transparency: f });
        }
      });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setDefaultTheme = function(t) {
    var r;
    this.defaultTheme = k(k(k({}, R_), (r = this.defaultTheme) !== null && r !== void 0 ? r : {}), t);
  }, e;
}(), _0 = [qe.BallAndStick, qe.Line, qe.Stick, qe.CPK], Rme = function(e) {
  function t(r, n, a) {
    var i = e.call(this, r, n) || this;
    return i.ev = xo.create(), i.event = { interactionParamsUpdated: i.ev(), interactionUpdated: i.ev() }, i.plugin = r, i.type = Ai.LigandReceptor, i.interactionParams = k(k({}, a), a_()), i;
  }
  return Ii(t, e), t.prototype.showInteractionInCellItems = function(r, n, a, i) {
    var o;
    return Be(this, 0, void 0, function() {
      var s, u, c, l, d, f, m = this;
      return Te(this, function(h) {
        switch (h.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), i && Array.from(r.map(function(p) {
              return p.ref;
            })).forEach(function(p) {
              var g = m.plugin.cells.get(p);
              if (g) {
                var v = [];
                On[Mt.ATOM].forEach(function(y) {
                  g.representations.has(y) && g.representations.get(y).state && v.push.apply(v, Ya(Ci(g.representations.get(y).state.getLoci())));
                }), s.set(p, new Set(v));
              }
            }), u = i ? r.map(function(p) {
              var g, v, y = p.ref, _ = p.elementIds, S = _ ? _.filter(function(b) {
                var x;
                return (x = s.get(y)) === null || x === void 0 ? void 0 : x.has(b);
              }) : Array.from((v = (g = s.get(y)) === null || g === void 0 ? void 0 : g.values()) !== null && v !== void 0 ? v : []);
              return { ref: y, elementIds: S };
            }).filter(function(p) {
              return p.elementIds.length;
            }) : r, [4, T5.createOrUpdateInCellItems(u, this.plugin, n, this.interactionParams, a)];
          case 1:
            return c = h.sent(), l = c.representation, d = c.ref, f = { representations: [{ state: l, isHidden: !1, type: qe.IntraInteractions }], model: { other: null }, dependency: { on: r } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(l), d ? (this.plugin.managers.cell.update(d, f), [2, d]) : [2, this.plugin.managers.cell.create(f)];
        }
      });
    });
  }, t.prototype.showInteractionBetweenCellItems = function(r, n, a, i) {
    var o;
    return i === void 0 && (i = !1), Be(this, 0, void 0, function() {
      var s, u, c, l, d, f, m, h = this;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), i && Array.from(nt(nt([], r, !0), n, !0).map(function(g) {
              return g.ref;
            })).forEach(function(g) {
              var v = h.plugin.cells.get(g);
              if (v) {
                var y = [];
                On[Mt.ATOM].forEach(function(_) {
                  v.representations.has(_) && v.representations.get(_).state && y.push.apply(y, Ya(Ci(v.representations.get(_).state.getLoci())));
                }), s.set(g, new Set(y));
              }
            }), u = i ? r.map(function(g) {
              var v, y, _ = g.ref, S = g.elementIds, b = S ? S.filter(function(x) {
                var A;
                return (A = s.get(_)) === null || A === void 0 ? void 0 : A.has(x);
              }) : Array.from((y = (v = s.get(_)) === null || v === void 0 ? void 0 : v.values()) !== null && y !== void 0 ? y : []);
              return { ref: _, elementIds: b };
            }).filter(function(g) {
              return g.elementIds.length;
            }) : r, c = i ? n.map(function(g) {
              var v, y, _ = g.ref, S = g.elementIds, b = S ? S.filter(function(x) {
                var A;
                return (A = s.get(_)) === null || A === void 0 ? void 0 : A.has(x);
              }) : Array.from((y = (v = s.get(_)) === null || v === void 0 ? void 0 : v.values()) !== null && y !== void 0 ? y : []);
              return { ref: _, elementIds: b };
            }).filter(function(g) {
              return g.elementIds.length;
            }) : n, [4, T5.createOrUpdateBetweenCellItems(u, c, this.plugin, this.interactionParams, a)];
          case 1:
            return l = p.sent(), d = l.representation, f = l.ref, d ? (m = { representations: [{ state: d, isHidden: !1, type: qe.BetweenInteractions }], model: { other: { itemsA: u, itemsB: c } }, dependency: { on: u.concat(c) } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(d), f ? (this.plugin.managers.cell.update(f, m), [2]) : [2, this.plugin.managers.cell.create(m)]) : [2];
        }
      });
    });
  }, t.prototype.setInteractionParams = function(r, n) {
    var a = this, i = new Set(Object.keys(this.interactionParams).filter(function(s) {
      var u;
      return ((u = a.interactionParams[s]) === null || u === void 0 ? void 0 : u.name) === "on";
    }));
    if (this.type === n && r.length === i.size && r.every(function(s) {
      return i.has(s);
    })) return !1;
    this.type = n, this.interactionParams = a_(r);
    var o = !1;
    return this.plugin.managers.cell.traverse(function(s, u) {
      u.type === qe.IntraInteractions && (o = !0, a.showGlobalInteraction(void 0, "lightPlugin.managers.representation.interactions.setInteractionParams"));
    }), this.event.interactionParamsUpdated.next({ params: this.interactionParams, type: n }), o;
  }, t.prototype.showGlobalInteraction = function(r, n) {
    var a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S = this;
      return Te(this, function(b) {
        switch (b.label) {
          case 0:
            return i = /* @__PURE__ */ new Map(), o = JL(this.plugin), r && Array.from(o.map(function(x) {
              return x.ref;
            })).forEach(function(x) {
              var A = S.plugin.cells.get(x);
              if (A) {
                var w = [];
                On[Mt.ATOM].forEach(function(C) {
                  A.representations.has(C) && A.representations.get(C).state && w.push.apply(w, Ya(Ci(A.representations.get(C).state.getLoci())));
                }), i.set(x, new Set(w));
              }
            }), s = r ? o.map(function(x) {
              var A, w, C = x.ref, M = x.elementIds, T = M ? M.filter(function(N) {
                var I;
                return (I = i.get(C)) === null || I === void 0 ? void 0 : I.has(N);
              }) : Array.from((w = (A = i.get(C)) === null || A === void 0 ? void 0 : A.values()) !== null && w !== void 0 ? w : []);
              return { ref: C, elementIds: T };
            }).filter(function(x) {
              return x.elementIds.length;
            }) : void 0, [4, T5.createOrUpdateGlobal(o, this.plugin, this.type, this.interactionParams, void 0, s)];
          case 1:
            if (u = b.sent(), c = u.representation, l = u.ref, d = u.interactionElementIds, f = { representations: [{ state: c, isHidden: !1, type: qe.IntraInteractions }], model: { other: { type: this.type } }, dependency: { on: o } }, (a = this.plugin.canvas3d) === null || a === void 0 || a.add(c), r) return [3, 5];
            m = [], h = {}, d.forEach(function(x) {
              var A, w = x.ref, C = x.elementIds, M = S.plugin.cells.get(w);
              if (M) {
                h[w] = ((A = {})[qe.BallAndStick] = /* @__PURE__ */ new Set(), A[qe.Line] = /* @__PURE__ */ new Set(), A[qe.Stick] = /* @__PURE__ */ new Set(), A[qe.CPK] = /* @__PURE__ */ new Set(), A);
                var T = new Set(C);
                _0.forEach(function(N) {
                  if (M.representations.has(N) && M.representations.get(N).state) {
                    var I = A3(M.representations.get(N).state);
                    h[w][N] = new Set(I), T.forEach(function(P) {
                      h[w][N].has(P) && T.delete(P);
                    });
                  }
                }), T.size && m.push({ ref: w, elementIds: Array.from(T.values()) });
              }
            }), (_ = {})[qe.BallAndStick] = [], _[qe.Line] = [], _[qe.Stick] = [], _[qe.CPK] = [], p = _, m.forEach(function(x) {
              var A, w = x.ref, C = x.elementIds, M = ((A = {})[qe.BallAndStick] = [], A[qe.Line] = [], A[qe.Stick] = [], A[qe.CPK] = [], A), T = /* @__PURE__ */ new Map();
              if (C != null && C.length) {
                var N = S.plugin.managers.cell.get(w), I = dn(N);
                if (I) {
                  var P = new Set(C), O = new Set(C.map(function(R) {
                    return wy(ZL(I, R), Qr.Residue);
                  })), F = /* @__PURE__ */ new Map();
                  I.units.forEach(function(R) {
                    R.elements.forEach(function(G) {
                      var L = mc(R, G), q = wy(L, Qr.Residue);
                      O.has(q) && (T.has(q) || T.set(q, /* @__PURE__ */ new Set()), (P.has(G) || L.typeSymbol !== "H" || C3(I, G) === Ea.Polar) && F.set(q, nt([G], F.has(q) ? F.get(q) : [], !0)), _0.some(function(K) {
                        var X, H;
                        !((X = h[w][K]) === null || X === void 0) && X.has(G) && ((H = T.get(q)) === null || H === void 0 || H.add(K));
                      }));
                    });
                  }), O.forEach(function(R) {
                    var G, L, q = T.get(R);
                    q && q.size !== 0 ? q.size > 0 && (L = M[Array.from(q.values())[0]]).push.apply(L, F.get(R)) : (G = M[qe.Stick]).push.apply(G, F.get(R));
                  }), _0.forEach(function(R) {
                    M[R].length && p[R].push({ ref: w, elementIds: M[R] });
                  });
                }
              }
            }), g = 0, v = _0.length, b.label = 2;
          case 2:
            return g < v ? (y = _0[g], p[y].length ? [4, this.plugin.managers.representation.setMolecularRepr(p[y], y, !0, !1)] : [3, 4]) : [3, 5];
          case 3:
            b.sent(), b.label = 4;
          case 4:
            return g++, [3, 2];
          case 5:
            return l ? (this.plugin.managers.cell.update(l, f), this.event.interactionUpdated.next({ from: n }), [2, d]) : (this.event.interactionUpdated.next({ from: n }), [4, this.plugin.managers.cell.create(f)]);
          case 6:
            return b.sent(), [2, d];
        }
      });
    });
  }, t;
}(Fme), Xz = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, kL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, zL(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Lme = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, iS(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, Qd(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, kme = function(e, t) {
  return Be(void 0, 0, void 0, function() {
    var r, n, a;
    return Te(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, iS(e).run()];
        case 1:
          if ((r = i.sent()).isError) throw r;
          return n = r.result, t && (o = t[0], n.molecules[0], s = o.graph.graphs, u = s.nodes, c = s.adjacency, l = [], d = [], u.forEach(function(f, m) {
            c[m].forEach(function(h) {
              h.to_jimage.some(function(p) {
                return p !== 0;
              }) || (l.push(f.id), d.push(h.id));
            });
          }), a = { count: l.length, atomA: l, atomB: d }, n.molecules[0] = k(k({}, n.molecules[0]), { bonds: a })), [4, Qd(n).run()];
        case 2:
          return [2, i.sent()];
      }
      var o, s, u, c, l, d;
    });
  });
}, zme = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, OL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, FL(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Ume = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, qL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, HL(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Gme = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    return Te(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, Qd(KL(e)).run()];
        case 1:
          return [2, t.sent()];
      }
    });
  });
} }, Vme = { parse: function(e) {
  return Be(this, 0, void 0, function() {
    var t;
    return Te(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, XL(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw new Error(t.message);
          return [4, Qd(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, L_ = ((Nf = {})[xr.Dump] = Lme, Nf[xr.Gro] = Xz, Nf[xr.Pdb] = zme, Nf[xr.Xyz] = Ume, Nf[xr.Material] = Gme, Nf[xr.Pymatgen] = Vme, Nf), DI = function(e) {
  function t(r, n, a) {
    var i = e.call(this, r, n) || this;
    return i.defaultTheme = k(k({}, R_), n), i.plugin = r, i.interactionParams = k(k({}, a), a_()), i.showPolarHydrogenOnly = !0, i.ctx = { webgl: void 0, colorThemeRegistry: fl.createRegistry(), sizeThemeRegistry: go.createRegistry(), props: { hideBond: !1 } }, i;
  }
  return Ii(t, e), Object.defineProperty(t.prototype, "hideBond", { get: function() {
    var r, n;
    return (n = (r = this.ctx) === null || r === void 0 ? void 0 : r.props.hideBond) !== null && n !== void 0 && n;
  }, set: function(r) {
    this.ctx.props.hideBond !== r && (this.ctx.props.hideBond = r, this.plugin.managers.cell.traverse(function(n, a) {
      var i, o, s, u, c;
      if (tse.has(a.type)) {
        var l = r ? (s = (o = (i = a.state) === null || i === void 0 ? void 0 : i.props) === null || o === void 0 ? void 0 : o.visuals) === null || s === void 0 ? void 0 : s.filter(function(d) {
          return d !== "intra-bond" && d !== "inter-bond";
        }) : Array.from(new Set(nt(nt([], (c = (u = a.state) === null || u === void 0 ? void 0 : u.props) === null || c === void 0 ? void 0 : c.visuals, !0), ["inter-bond", "intra-bond"], !1)));
        a.state.createOrUpdate({ visuals: l }, zo(a.state)).run();
      }
    }));
  }, enumerable: !1, configurable: !0 }), t.prototype.createContext = function() {
    this.ctx = { webgl: this.plugin.canvas3d.webgl, colorThemeRegistry: fl.createRegistry(), sizeThemeRegistry: go.createRegistry(), props: { hideBond: !1 } }, this.ctx.colorThemeRegistry.add(Ome);
  }, t.prototype.createMolecular = function(r) {
    var n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C;
    return Be(this, 0, void 0, function() {
      var M, T, N, I, P, O, F, R, G, L, q, K, X, H, W, ee, $, te, re, ie, oe, se, he, ge, De, ae, ce, _e = this;
      return Te(this, function(le) {
        switch (le.label) {
          case 0:
            M = r.format, T = r.reprType, N = r.theme, I = N === void 0 ? {} : N, P = r.elementIds, O = r.ref, F = r.defaultShown, R = r.updateInteraction, G = R === void 0 || R, L = r.autoConvertToTrajectory, q = L !== void 0 && L, le.label = 1;
          case 1:
            return le.trys.push([1, 12, , 13]), (K = typeof r.data == "string" || r.data instanceof File) ? [4, Wf(r.data)] : [3, 3];
          case 2:
            return H = le.sent(), [3, 4];
          case 3:
            H = r.data, le.label = 4;
          case 4:
            return X = H, [4, ml[M].parse(X)];
          case 5:
            return (W = le.sent()).length > 1 && q && L_[M] ? [4, this.plugin.managers.trajectory.importTrajectory({ data: X, format: M })] : [3, 7];
          case 6:
            return [2, (ee = le.sent()) ? [ee] : []];
          case 7:
            $ = r.data instanceof File ? r.data.name : "", te = F ?? W.length, re = Object.keys(On).find(function(ue) {
              return On[ue].includes(T);
            }), ie = [], oe = 0, se = function(ue) {
              var be, Se, Ne, J, Z, de, ye, Ae, Ce, Ie, Ue, Xe, je, ht, xt, dt, Le, j, xe, ke;
              return Te(this, function(Je) {
                switch (Je.label) {
                  case 0:
                    return be = nt([], P ?? [], !0), Se = ue, he.showPolarHydrogenOnly && n0.has(T) && (be = (P ?? ms(ue)).filter(function(Ct) {
                      return !i0(ue, Ct);
                    }), Se = sa(ue, be)), Ne = !te, J = M === xr.Material || ((n = w3(ue, M)) !== null && n !== void 0 ? n : K) ? X : Vue(ue, M), Z = { representations: [{ isHidden: Ne, type: T }], model: {}, assets: [{ format: M, data: ["sdf", "mol"].includes(M) && $ && !(J != null && J.split(`
`)[0].trim()) ? nt(["".concat($).concat(oe > 0 ? "_".concat(oe) : "")], J.split(`
`).slice(1), !0).join(`
`) : J }], theme: { color: (je = {}, je[re] = [k({ elementIds: P ?? Ya(st.toStructureElementLoci(ue)) }, (i = (a = I[re]) === null || a === void 0 ? void 0 : a.color) !== null && i !== void 0 ? i : re === Mt.ATOM ? P5 : he.defaultTheme.color[re])], je), transparency: (ht = {}, ht[Mt.ATOM] = [], ht[Mt.RIBBON] = [], ht[Mt.SURFACE] = [], ht[re] = !((o = I[re]) === null || o === void 0) && o.transparency ? [(s = I[re]) === null || s === void 0 ? void 0 : s.transparency] : [], ht), size: (xt = {}, xt[Mt.ATOM] = [], xt[Mt.RIBBON] = [], xt[Mt.SURFACE] = [], xt[re] = !((u = I[re]) === null || u === void 0) && u.size ? [(c = I[re]) === null || c === void 0 ? void 0 : c.size] : [], xt) }, ref: O }, oe++, Ne ? [3, 2] : [4, Zs[T].create(Se, he.ctx, he.createTheme(T, ue, k(k({}, I[re]), re !== Mt.ATOM || !((l = I[re]) === null || l === void 0) && l.color ? {} : { color: P5 })))];
                  case 1:
                    return de = Je.sent(), !((d = I[re]) === null || d === void 0) && d.transparency && de.setState({ transparency: he.createTransparencyLayers(ue, [(f = I[re]) === null || f === void 0 ? void 0 : f.transparency]) }), te--, (m = he.plugin.canvas3d) === null || m === void 0 || m.add(de), Object.assign(Z.representations[0], { state: de }), [3, 3];
                  case 2:
                    Object.assign(Z.representations[0], { cache: { isHidden: Ne, type: T, elementIds: be } }), Je.label = 3;
                  case 3:
                    return ye = he.plugin.managers.cell.create(Z), ie.push(ye), M !== xr.Pdb || P != null && P.length ? [3, 7] : (Ae = m_(ue), Ce = Ae.polymer, (Ie = Ae.other).length ? Ne ? [3, 6] : (Ue = sa(ue, Ce), [4, Zs[qe.Ribbon].update(Z.representations[0].state, sa(ue, Ce), he.ctx, he.createTheme(qe.Ribbon, Ue, I[Mt.RIBBON]))]) : [3, 7]);
                  case 4:
                    return Je.sent(), Xe = sa(ue, Ie), he.plugin.managers.cell.update(ye, { representations: [], model: { structure: ue }, theme: { color: (dt = {}, dt[Mt.ATOM] = [k({ elementIds: Ie ?? Ya(st.toStructureElementLoci(ue)) }, (p = (h = I[Mt.ATOM]) === null || h === void 0 ? void 0 : h.color) !== null && p !== void 0 ? p : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: Qe(4777267) } } } })], dt), transparency: (Le = {}, Le[Mt.ATOM] = !((g = I[Mt.ATOM]) === null || g === void 0) && g.transparency ? [(v = I[Mt.ATOM]) === null || v === void 0 ? void 0 : v.transparency] : [], Le), size: (j = {}, j[Mt.ATOM] = [], j[Mt.RIBBON] = [], j[Mt.SURFACE] = [], j[re] = !((y = I[Mt.ATOM]) === null || y === void 0) && y.size ? [(_ = I[Mt.ATOM]) === null || _ === void 0 ? void 0 : _.size] : [], j) } }), [4, he.addMolecularRepr(ye, { elementIds: Ie, reprType: qe.BallAndStick, isHidden: Ne, theme: he.createTheme(qe.BallAndStick, Xe, k({ color: k({ elementIds: Ie }, P5) }, I[Mt.ATOM])), transparency: !((S = I[Mt.ATOM]) === null || S === void 0) && S.transparency ? [(b = I[Mt.ATOM]) === null || b === void 0 ? void 0 : b.transparency] : void 0 })];
                  case 5:
                    return Je.sent(), [3, 7];
                  case 6:
                    he.plugin.managers.cell.update(ye, { representations: [k(k({}, Z.representations[0]), { cache: k(k({}, Z.representations[0].cache), { elementIds: Ce }) }), { isHidden: Ne, type: qe.BallAndStick, cache: { isHidden: Ne, type: qe.BallAndStick, elementIds: Ie } }], model: {}, theme: { color: (xe = {}, xe[Mt.ATOM] = [k({ elementIds: Ie ?? Ya(st.toStructureElementLoci(ue)) }, (A = (x = I[Mt.ATOM]) === null || x === void 0 ? void 0 : x.color) !== null && A !== void 0 ? A : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: Qe(4777267) } } } })], xe), transparency: (ke = {}, ke[Mt.ATOM] = !((w = I[Mt.ATOM]) === null || w === void 0) && w.transparency ? [(C = I[Mt.ATOM]) === null || C === void 0 ? void 0 : C.transparency] : [], ke) } }), Je.label = 7;
                  case 7:
                    return Ne || he.plugin.managers.cell.update(ye, { model: { structure: ue } }), G && he.plugin.managers.cell.traverse(function(Ct, At) {
                      At.type === qe.IntraInteractions && _e.plugin.managers.representation.showGlobalInteraction(void 0, "lightPlugin.managers.representation.createMolecular");
                    }), he.plugin.managers.snapshot.event.changed.next({ from: "repr: createMolecular" }), [2];
                }
              });
            }, he = this, ge = 0, De = W, le.label = 8;
          case 8:
            return ge < De.length ? (ae = De[ge], [5, se(ae)]) : [3, 11];
          case 9:
            le.sent(), le.label = 10;
          case 10:
            return ge++, [3, 8];
          case 11:
            return [2, ie];
          case 12:
            return ce = le.sent(), console.log(ce), [2, []];
          case 13:
            return [2];
        }
      });
    });
  }, t.prototype.updateMolecular = function(r) {
    var n;
    return Be(this, 0, void 0, function() {
      var a, i, o, s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M = this;
      return Te(this, function(T) {
        for (a = r.ref, i = r.structure, o = this.plugin.managers.cell.get(a), s = et.toExpression(st.toStructureElementLoci(o.model.structure)), u = et.toExpression(st.toStructureElementLoci(i)), c = zt.struct.modifier.exceptBy({ 0: u, by: s }), (l = ms(t1(e1(i, c)))).length && (((d = o.theme.color[Mt.ATOM]) == null ? void 0 : d.length) === 1 ? d[0].elementIds ? (w = d[0].elementIds).push.apply(w, l) : d[0].elementIds = nt([], l, !0) : d == null || d.push(k({ elementIds: l }, this.defaultTheme.color[Mt.ATOM])), this.plugin.managers.cell.update(a, { representations: [], model: {}, theme: { color: (C = {}, C[Mt.ATOM] = d, C) } })), (f = [qe.BallAndStick, qe.Stick, qe.Line, qe.CPK]).forEach(function(N) {
          !m && o.representations.has(N) && (m = N);
        }), h = function(N) {
          var I = N[0], P = N[1], O = Object.keys(On).find(function(q) {
            return On[q].includes(I);
          }), F = o.theme.color[O], R = P.state.getLoci(), G = et.toExpression(st.toStructureElementLoci(R.structure));
          f.includes(I) && I !== m || (G = zt.struct.modifier.union([zt.struct.combinator.merge([c, G])]));
          var L = t1(e1(i, G));
          Zs[I].update(P.state, L, p.ctx, p.createTheme(I, i, { color: { name: "multi-theme", props: { themes: F } }, size: o.theme.size && (!((n = o.theme.size[O]) === null || n === void 0) && n.length) ? o.theme.size[O][0] : p.defaultTheme.size[I] })), P.state.setState({ transparency: p.createTransparencyLayers(L, o == null ? void 0 : o.theme.transparency[O]) });
        }, p = this, g = 0, v = Array.from(o.representations); g < v.length; g++) y = v[g], h(y);
        for (_ = function(N) {
          var I = S.plugin.cells.get(N);
          I && I.representations.forEach(function(P, O) {
            O === qe.IntraInteractions && M.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.updateMolecular"), Object.keys(z0).includes(O) && M.plugin.managers.representation.updateMeasurement({ items: I.dependency.on, ref: N });
          });
        }, S = this, b = 0, x = o.dependency.by; b < x.length; b++) A = x[b], _(A);
        return this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateMolecular" }), [2, o];
      });
    });
  }, t.prototype.createMeasurement = function(r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f, m, h;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            if (n = r.type, a = r.theme, i = r.items, o = r.ref, s = r.isHidden, !Jp.has(n)) return console.warn("There is no ".concat(n, " type ")), [2, ""];
            u = [], c = 0, l = i, p.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [4, this.plugin.managers.cell.getStructure(d.ref)]) : [3, 4];
          case 2:
            if (!(f = p.sent())) return [2, ""];
            u.push(ua(f, d.elementIds)), p.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return [4, z0[n].create(u, this.ctx, r.props, a)];
          case 5:
            return m = p.sent(), h = this.plugin.managers.cell.create({ representations: [{ state: m, isHidden: s != null && s, type: n }], model: { loci: u }, dependency: { on: i }, ref: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, h];
        }
      });
    });
  }, t.prototype.updateMeasurement = function(r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f = this;
      return Te(this, function(m) {
        switch (m.label) {
          case 0:
            return n = r.items, a = r.ref, i = r.params, o = this.plugin.cells.get(a), s = n.filter(function(h) {
              return dn(f.plugin.cells.get(h.ref));
            }), u = s.map(function(h) {
              return ua(dn(f.plugin.cells.get(h.ref)), h.elementIds);
            }), o ? (c = Array.from(o.representations)[0], l = c[0], d = c[1], l && d ? d.state ? [4, z0[l].update(d.state, u, i)] : [3, 2] : (console.error("There is no ".concat(l)), [2, !1])) : (console.warn("There is no ".concat(a)), [2, !1]);
          case 1:
            m.sent(), m.label = 2;
          case 2:
            return this.plugin.managers.cell.update(a, { model: { loci: u } }), [2, !0];
        }
      });
    });
  }, t.prototype.createStaticLabel = function(r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f, m;
      return Te(this, function(h) {
        switch (h.label) {
          case 0:
            n = r.theme, a = r.items, i = r.ref, o = r.isHidden, s = [], u = 0, c = a, h.label = 1;
          case 1:
            return u < c.length ? (l = c[u], [4, this.plugin.managers.cell.getStructure(l.item.ref)]) : [3, 4];
          case 2:
            if (!(d = h.sent())) return [2, ""];
            s.push({ loci: ua(d, l.item.elementIds), label: l.label }), h.label = 3;
          case 3:
            return u++, [3, 1];
          case 4:
            return [4, z0[qe.Label].create(s, this.ctx, r.props, n)];
          case 5:
            return f = h.sent(), m = this.plugin.managers.cell.create({ representations: [{ state: f, isHidden: o != null && o, type: qe.Label }], model: { loci: s.map(function(p) {
              return p.loci;
            }) }, dependency: { on: a.map(function(p) {
              return p.item;
            }) }, ref: i }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, m];
        }
      });
    });
  }, t.prototype.createOther = function(r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l, d, f, m, h, p, g, v, y;
      return Te(this, function(_) {
        switch (_.label) {
          case 0:
            return n = r.type, a = r.theme, i = r.data, o = r.ref, s = r.isHidden, u = s !== void 0 && s, c = r.serverData, l = r.params, B2[n] ? (d = B2[n]).parse ? [4, d.parse(i, this.plugin)] : [3, 2] : (console.warn("There is no ".concat(n, " type ")), [2]);
          case 1:
            return m = _.sent(), [3, 3];
          case 2:
            m = i, _.label = 3;
          case 3:
            return f = m, [4, d.create(f, this.ctx, d.createTheme ? d.createTheme(n === qe.IsoSurface ? f : i, this.plugin, a) : void 0, l)];
          case 4:
            return h = _.sent(), n === qe.Surface && (a != null && a.transparency) && h.setState({ transparency: this.createTransparencyLayers(f, [a == null ? void 0 : a.transparency]) }), p = this.plugin.managers.cell.create({ representations: [{ state: h, isHidden: u, type: n }], model: { other: c ? { serverData: c, data: i } : i }, theme: n === qe.Surface ? { color: (g = {}, g[Mt.SURFACE] = a != null && a.color ? [a == null ? void 0 : a.color] : [], g), transparency: (v = {}, v[Mt.SURFACE] = a != null && a.transparency ? [a == null ? void 0 : a.transparency] : [], v), size: (y = {}, y[Mt.SURFACE] = a != null && a.size ? [a == null ? void 0 : a.size] : [], y) } : void 0, ref: o, dependency: n === qe.Surface ? { on: [i] } : n === qe.MappingLine ? { on: i } : void 0 }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createOther" }), [2, p];
        }
      });
    });
  }, t.prototype.updateOther = function(r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u;
      return Te(this, function(c) {
        switch (c.label) {
          case 0:
            return n = r.data, a = r.ref, (i = this.plugin.cells.get(a)) ? (o = Array.from(i.representations)[0], s = o[0], u = o[1], s && u ? [4, B2[s].update(u.state, n, this.ctx)] : (console.error("There is no ".concat(s)), [2, !1])) : (console.warn("There is no ".concat(a)), [2, !1]);
          case 1:
            return c.sent(), this.plugin.managers.cell.update(a, { model: { other: n } }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateOther" }), [2, !0];
        }
      });
    });
  }, t.prototype.addMolecularRepr = function(r, n) {
    var a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u, c, l, d, f, m, h;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            return i = n.elementIds, o = n.reprType, s = n.isHidden, u = n.theme, c = n.transparency, l = this.plugin.managers.cell.get(r), d = dn(l), l && d ? (f = nt([], i ?? [], !0), n0.has(o) && this.showPolarHydrogenOnly && (f = (i || ms(d)).filter(function(g) {
              return !i0(d, g);
            })), m = sa(d, f, !0), [4, Zs[o].create(m, this.ctx, u)]) : [2];
          case 1:
            return h = p.sent(), c && h.setState({ transparency: this.createTransparencyLayers(m, c) }), s || (a = this.plugin.canvas3d) === null || a === void 0 || a.add(h), l.representations.set(o, { state: h, isHidden: s, type: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: addMolecularRepr" }), [2];
        }
      });
    });
  }, t.prototype.checkStructuresDisplayed = function(r, n) {
    var a, i = this.plugin.managers.cell.get(r.ref), o = dn(i), s = new Set(n && !n0.has(n) || !this.showPolarHydrogenOnly ? r.elementIds : ((a = r.elementIds) !== null && a !== void 0 ? a : []).filter(function(u) {
      return !i0(o, u);
    }));
    return (n ? [i.representations.get(n)] : Array.from(i.representations.values())).filter(function(u) {
      return (u == null ? void 0 : u.isHidden) !== !0 && (u == null ? void 0 : u.state);
    }).forEach(function(u) {
      var c, l, d;
      if (s.size) {
        var f = Ci(u.state.getLoci());
        f && (!((d = (l = (c = f == null ? void 0 : f.elements) === null || c === void 0 ? void 0 : c[0]) === null || l === void 0 ? void 0 : l.unit) === null || d === void 0) && d.elements) && Ya(f).forEach(function(m) {
          return s.delete(m);
        });
      }
    }), s.size === 0;
  }, t.prototype.setMolecularRepr = function(r, n, a, i, o) {
    var s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A;
    return i === void 0 && (i = !0), o === void 0 && (o = !0), Be(this, 0, void 0, function() {
      var w, C, M, T, N, I, P, O, F, R, G, L, q, K, X, H, W, ee, $, te, re = this;
      return Te(this, function(ie) {
        switch (ie.label) {
          case 0:
            if (w = /* @__PURE__ */ new Map(), C = r.filter(function(oe) {
              return dn(re.plugin.managers.cell.get(oe.ref));
            }), M = !!i && C.every(function(oe) {
              return re.checkStructuresDisplayed(oe, n);
            }), T = Object.keys(On).find(function(oe) {
              return On[oe].includes(n);
            }), N = [], !M) return [3, 5];
            I = function(oe) {
              var se, he, ge;
              return Te(this, function(De) {
                switch (De.label) {
                  case 0:
                    return w.set(oe.ref, /* @__PURE__ */ new Set()), se = P.plugin.managers.cell.get(oe.ref), he = se.representations.get(n), ge = se.theme.color[T], [4, P_(he == null ? void 0 : he.state, (s = oe.elementIds) !== null && s !== void 0 ? s : [], n, function(ae) {
                      var ce;
                      return re.createTheme(n, ae, { color: { name: "multi-theme", props: { themes: ge } }, size: se.theme.size && (!((ce = se.theme.size[T]) === null || ce === void 0) && ce.length) ? se.theme.size[T][0] : re.defaultTheme.size[n] });
                    }, function(ae) {
                      return re.createTransparencyLayers(ae, se == null ? void 0 : se.theme.transparency[T]);
                    })];
                  case 1:
                    return De.sent(), (u = w.get(oe.ref)) === null || u === void 0 || u.add(n), se.dependency.by.length && N.push.apply(N, se.dependency.by), [2];
                }
              });
            }, P = this, O = 0, F = C, ie.label = 1;
          case 1:
            return O < F.length ? (K = F[O], [5, I(K)]) : [3, 4];
          case 2:
            ie.sent(), ie.label = 3;
          case 3:
            return O++, [3, 1];
          case 4:
            return [3, 9];
          case 5:
            R = function(oe) {
              var se, he, ge, De, ae, ce, _e, le, ue, be, Se, Ne, J, Z, de, ye, Ae, Ce, Ie;
              return Te(this, function(Ue) {
                switch (Ue.label) {
                  case 0:
                    if (w.set(oe.ref, /* @__PURE__ */ new Set()), se = G.plugin.managers.cell.get(oe.ref), he = se.representations.get(n), ge = dn(se), De = se.theme.color[T], ae = [], De == null || De.forEach(function(Xe) {
                      var je;
                      ae.push.apply(ae, (je = Xe.elementIds) !== null && je !== void 0 ? je : []);
                    }), ce = new Set(ae), (_e = ((c = oe.elementIds) !== null && c !== void 0 ? c : []).filter(function(Xe) {
                      return !ce.has(Xe);
                    })).length && (De == null || De.push(k({ elementIds: _e }, G.defaultTheme.color[T])), se.theme.color = k(k({}, se.theme.color), ((Ie = {})[T] = De, Ie))), le = [], !a) return [3, 4];
                    ue = function(Xe) {
                      var je;
                      return Te(this, function(ht) {
                        switch (ht.label) {
                          case 0:
                            return !i && Xe.type !== qe.Ribbon && n !== qe.Ribbon && (je = Oy(Xe.state, (l = oe.elementIds) !== null && l !== void 0 ? l : [])).length ? (oe.elementIds = (d = oe.elementIds) === null || d === void 0 ? void 0 : d.filter(function(xt) {
                              return !je.includes(xt);
                            }), [2, "continue"]) : Xe.type === n || Xe.type === qe.Ribbon || Xe.isHidden || Jfe(Xe.state, (f = oe.elementIds) !== null && f !== void 0 ? f : []) === vd.Not ? [2, "continue"] : (le.push.apply(le, Oy(Xe == null ? void 0 : Xe.state, (m = oe.elementIds) !== null && m !== void 0 ? m : [])), [4, P_(Xe == null ? void 0 : Xe.state, (h = oe.elementIds) !== null && h !== void 0 ? h : [], Xe == null ? void 0 : Xe.type, function(xt) {
                              var dt;
                              return re.createTheme(Xe == null ? void 0 : Xe.type, xt, { color: { name: "multi-theme", props: { themes: De } }, size: se.theme.size && (!((dt = se.theme.size[T]) === null || dt === void 0) && dt.length) ? se.theme.size[T][0] : re.defaultTheme.size[Xe == null ? void 0 : Xe.type] });
                            }, function(xt) {
                              return re.createTransparencyLayers(xt, se == null ? void 0 : se.theme.transparency[T]);
                            })]);
                          case 1:
                            return ht.sent(), (p = w.get(oe.ref)) === null || p === void 0 || p.add(Xe.type), [2];
                        }
                      });
                    }, be = 0, Se = Array.from(se.representations), Ue.label = 1;
                  case 1:
                    return be < Se.length ? (Ne = Se[be], J = Ne[1], [5, ue(J)]) : [3, 4];
                  case 2:
                    Ue.sent(), Ue.label = 3;
                  case 3:
                    return be++, [3, 1];
                  case 4:
                    return Z = new Set(le), he ? (de = (g = A3(he.state)) !== null && g !== void 0 ? g : [], ye = sa(ge, Array.from(new Set(de.concat(n0.has(n) && G.showPolarHydrogenOnly ? ((v = oe.elementIds) !== null && v !== void 0 ? v : []).filter(function(Xe) {
                      return Z.has(Xe) || !i0(ge, Xe);
                    }) : (y = oe.elementIds) !== null && y !== void 0 ? y : [])))), Ae = G.createTransparencyLayers(ye, se == null ? void 0 : se.theme.transparency[T]), [4, Zs[n].update(he == null ? void 0 : he.state, ye, G.ctx, G.createTheme(n, ye, { color: { name: "multi-theme", props: { themes: De } }, size: se.theme.size && (!((_ = se.theme.size[T]) === null || _ === void 0) && _.length) ? se.theme.size[T][0] : G.defaultTheme.size[n] }))]) : [3, 6];
                  case 5:
                    return Ue.sent(), (S = w.get(oe.ref)) === null || S === void 0 || S.add(n), he.state.setState({ transparency: Ae }), [3, 8];
                  case 6:
                    return ye = sa(ge, n0.has(n) && G.showPolarHydrogenOnly ? oe.elementIds.filter(function(Xe) {
                      return Z.has(Xe) || !i0(ge, Xe);
                    }) : oe.elementIds), Ae = G.createTransparencyLayers(se == null ? void 0 : se.model.structure, se == null ? void 0 : se.theme.transparency[T]), [4, Zs[n].create(ye, G.plugin.managers.representation.ctx, G.createTheme(n, ye, { color: { name: "multi-theme", props: { themes: De } }, size: se.theme.size && (!((b = se.theme.size[T]) === null || b === void 0) && b.length) ? se.theme.size[T][0] : G.defaultTheme.size[n] }))];
                  case 7:
                    Ce = Ue.sent(), (x = w.get(oe.ref)) === null || x === void 0 || x.add(n), (A = G.plugin.canvas3d) === null || A === void 0 || A.add(Ce), Ce.setState({ transparency: Ae }), se.representations.set(n, { state: Ce, isHidden: !1, type: n }), Ue.label = 8;
                  case 8:
                    return se.dependency.by.length && N.push.apply(N, se.dependency.by), [2];
                }
              });
            }, G = this, L = 0, q = C, ie.label = 6;
          case 6:
            return L < q.length ? (K = q[L], [5, R(K)]) : [3, 9];
          case 7:
            ie.sent(), ie.label = 8;
          case 8:
            return L++, [3, 6];
          case 9:
            for (X = this.plugin.managers.selection.structure.getSelection(), w.forEach(function(oe, se) {
              var he;
              if (oe.size) {
                var ge = re.plugin.cells.get(se), De = (he = X[se]) !== null && he !== void 0 ? he : [];
                oe.forEach(function(ae) {
                  var ce, _e = ge == null ? void 0 : ge.representations.get(ae);
                  if (_e) {
                    var le = ua(zo(_e.state), De);
                    (ce = re.plugin.canvas3d) === null || ce === void 0 || ce.mark({ loci: le, repr: _e.state }, Et.Select);
                  }
                });
              }
            }), H = Array.from(new Set(N).values()), W = 0, ee = H; W < ee.length; W++) $ = ee[W], (te = this.plugin.cells.get($)) && te.representations.forEach(function(oe, se) {
              se === qe.IntraInteractions && o && re.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.setMolecularRepr");
            });
            return this.plugin.managers.snapshot.event.changed.next({ from: "repr: setMolecularRepr" }), [2];
        }
      });
    });
  }, t.prototype.showOrHideHs = function(r, n, a) {
    var i = this, o = a ?? this.plugin.managers.selection.structure.getSelectionCellItems(), s = [];
    o.forEach(function(f) {
      var m = i.plugin.cells.get(f.ref);
      if (m) {
        var h = dn(m);
        if (h) {
          f.elementIds || Object.assign(f, { elementIds: ms(h) });
          var p = f.elementIds.map(function(S) {
            return C3(h, S);
          }), g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
          m.representations.forEach(function(S, b) {
            if ([qe.BallAndStick, qe.CPK, qe.Stick, qe.Line].includes(b)) {
              var x = Ci(S.state.getLoci());
              if (!x) return;
              var A = Ya(x);
              v.set(b, nt([], A, !0)), A.forEach(function(w) {
                g.set(w, b);
              });
            }
          });
          var y = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
          p.forEach(function(S, b) {
            var x;
            if (f.elementIds) {
              var A = f.elementIds[b], w = h.units.filter(function(C) {
                return $e.indexOf(C.elements, A) !== -1;
              })[0];
              (!n && S === Ea.NonPolar || !r && S === Ea.Polar) && g.has(A) ? y.has(g.get(A)) ? (x = y.get(g.get(A))) === null || x === void 0 || x.add(A) : y.set(g.get(A), /* @__PURE__ */ new Set([A])) : ((!n && S === Ea.ConnectNonPolar || !r && S === Ea.ConnectPolar) && kd(h, w, w.elements.indexOf(A), function(C, M) {
                var T;
                C.model.atomicHierarchy.derived.atom.atomicNumber[C.elements[M]] === 1 && g.has(C.elements[M]) && (y.has(g.get(A)) ? (T = y.get(g.get(A))) === null || T === void 0 || T.add(C.elements[M]) : y.set(g.get(A), /* @__PURE__ */ new Set([C.elements[M]])));
              }), !(n && S === Ea.NonPolar || r && S === Ea.Polar) || g.has(A) ? (n && S === Ea.ConnectNonPolar || r && S === Ea.ConnectPolar) && g.has(A) && kd(h, w, w.elements.indexOf(A), function(C, M) {
                var T;
                C.model.atomicHierarchy.derived.atom.atomicNumber[C.elements[M]] !== 1 || g.has(C.elements[M]) || (_.has(g.get(A)) ? (T = _.get(g.get(A))) === null || T === void 0 || T.add(C.elements[M]) : _.set(g.get(A), /* @__PURE__ */ new Set([C.elements[M]])));
              }) : kd(h, w, w.elements.indexOf(A), function(C, M) {
                var T;
                C.model.atomicHierarchy.derived.atom.atomicNumber[C.elements[M]] !== 1 && g.has(C.elements[M]) && (_.has(g.get(C.elements[M])) ? (T = _.get(g.get(C.elements[M]))) === null || T === void 0 || T.add(A) : _.set(g.get(C.elements[M]), /* @__PURE__ */ new Set([A])));
              }));
            }
          }), m.representations.forEach(function(S, b) {
            var x;
            if ([qe.BallAndStick, qe.CPK, qe.Stick, qe.Line].includes(b)) {
              var A = !1, w = v.get(b);
              if (y.has(b) && y.get(b).size > 0) {
                var C = y.get(b);
                w = w == null ? void 0 : w.filter(function(I) {
                  return !C.has(I);
                }), A = !0;
              }
              if (_.has(b) && _.get(b).size > 0) {
                var M = _.get(b);
                w = Array.from(new Set(nt(nt([], Array.from(M.values()), !0), w, !0))), A = !0;
              }
              if (A) {
                var T = sa(h, w), N = m.theme.color[Mt.ATOM];
                Zs[b].update(S.state, T, i.ctx, i.createTheme(b, T, { color: { name: "multi-theme", props: { themes: N } }, size: m.theme.size && (!((x = m.theme.size[Mt.ATOM]) === null || x === void 0) && x.length) ? m.theme.size[Mt.ATOM][0] : i.defaultTheme.size[b] }));
              }
            }
          }), m.dependency.by.length && s.push.apply(s, m.dependency.by);
        }
      }
    });
    for (var u = 0, c = Array.from(new Set(s).values()); u < c.length; u++) {
      var l = c[u], d = this.plugin.cells.get(l);
      d && d.representations.forEach(function(f, m) {
        m === qe.IntraInteractions && i.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.showOrHideHs");
      });
    }
  }, t.prototype.redraw = function() {
    var r = this;
    this.plugin.canvas3d && (this.plugin.canvas3d.clear(), Array.from(this.plugin.cells.values()).forEach(function(n) {
      n.representations.forEach(function(a) {
        var i;
        a.isHidden !== !0 && a.state && ((i = r.plugin.canvas3d) === null || i === void 0 || i.add(a.state));
      });
    }));
  }, t.prototype.updateBondThresholds = function(r) {
    var n = this, a = r.reduce(function(o, s) {
      var u;
      return k(k({}, o), ((u = {})[qF(sh[s.atomA], sh[s.atomB])] = s.distance, u));
    }, {});
    Object.assign(VF, a), Object.assign(GF, a);
    var i = /* @__PURE__ */ new Set();
    this.plugin.managers.cell.traverse(function(o, s) {
      return Be(n, 0, void 0, function() {
        var u, c, l, d;
        return Te(this, function(f) {
          switch (f.label) {
            case 0:
              return i.has(o.ref) || !o.model.structure ? [2] : (u = o.assets[0], c = u.format, l = u.data, [4, ml[c].parse(l)]);
            case 1:
              return d = f.sent(), this.plugin.managers.editor.coverStructure(o.ref, d[0], o.assets[0]), i.add(o.ref), [2];
          }
        });
      });
    });
  }, t;
}(Rme), B5 = (($g = {})[Mt.ATOM] = [], $g[Mt.RIBBON] = [], $g[Mt.SURFACE] = [], $g), MI = function() {
  function e(t) {
    var r, n = this;
    this.plugin = t, (r = this.plugin.canvas3d) === null || r === void 0 || r.reprCount.subscribe(function(a) {
      if (a > 100 && n.idleCellSet.size) {
        var i = Array.from(n.idleCellSet.values())[0];
        n.idleCellSet.delete(i), n.clearReprState(i);
      }
    }), this.idleCellSet = /* @__PURE__ */ new Set();
  }
  return e.prototype.get = function(t) {
    var r = this.plugin.cells.get(t);
    if (r) return r;
    console.error("no ".concat(t, " cell"));
  }, e.prototype.getHierarchy = function(t) {
    var r = this, n = this.get(t);
    if (!(n != null && n.model.structure)) return console.error("".concat(t, " cell does not have structure")), { data: { polymer: {}, water: {}, otherSolvent: {}, metal: {}, ion: {}, ligand: {}, other: {} }, extraData: { sequenceData: {} } };
    var a = [], i = [];
    n.dependency.by.forEach(function(s) {
      var u, c, l;
      if (r.plugin.cells.has(s)) {
        var d = r.get(s);
        d && (d.representations.has(qe.Label) && i.push({ ref: s, dependencies: nt([], d.dependency.on, !0), label: ((c = (u = d.representations.get(qe.Label)) === null || u === void 0 ? void 0 : u.state) !== null && c !== void 0 ? c : (l = d.representations.get(qe.Label)) === null || l === void 0 ? void 0 : l.cache).props.customText }), d.representations.has(qe.Surface) && a.push({ ref: s, dependencies: nt([], d.dependency.on, !0) }));
      }
    });
    var o = BL(n.model.structure);
    return k(k({}, o), { extraData: k(k({}, o.extraData), { label: i, surface: a }) });
  }, e.prototype.getSequence = function(t) {
    return Be(this, 0, void 0, function() {
      var r;
      return Te(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(t)];
          case 1:
            return (r = n.sent()) ? [2, yse(r)] : [2];
        }
      });
    });
  }, e.prototype.getStructure = function(t) {
    var r;
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u, c, l;
      return Te(this, function(d) {
        switch (d.label) {
          case 0:
            return (n = this.get(t)) ? (a = dn(n)) ? [2, a] : a || !(!((r = n.assets) === null || r === void 0) && r.length) ? [3, 5] : (i = n.assets[0], o = i.data, s = i.format, l = (c = ml[s]).parse, [4, Wf(o)]) : [2];
          case 1:
            return [4, l.apply(c, [d.sent()])];
          case 2:
            return u = d.sent()[0], s !== xr.Pdb || !u.elementCount || yn.hasSecondaryStructure(u == null ? void 0 : u.model) ? [3, 4] : [4, Oi.attach({}, u, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
          case 3:
            d.sent(), d.label = 4;
          case 4:
            return this.update(t, { model: { structure: u } }), [2, u];
          case 5:
            return [2];
        }
      });
    });
  }, e.prototype.getLoci = function(t) {
    return Be(this, 0, void 0, function() {
      var r;
      return Te(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (r = n.sent()) ? [2, ua(r, t.elementIds)] : [2, Tn];
        }
      });
    });
  }, e.prototype.getMolecularName = function(t) {
    var r, n, a, i, o, s, u = this.get(t);
    if (!u.model.structure) return !((r = u.assets) === null || r === void 0) && r.length && ["sdf", "mol"].includes(u.assets[0].format) ? "".concat(u.assets[0].data).split(`
`)[0] : "";
    var c = ((a = (n = u.model.structure) === null || n === void 0 ? void 0 : n.state.model) !== null && a !== void 0 ? a : !((i = u.model.structure) === null || i === void 0) && i.state.models) ? (o = u.model.structure) === null || o === void 0 ? void 0 : o.state.models[0] : void 0;
    if (!c) return "";
    var l = (s = c.sourceData) === null || s === void 0 ? void 0 : s.kind;
    return l === "sdf" || l === "mol" ? c.entryId : "";
  }, e.prototype.isFromPdb = function(t) {
    var r, n = this.plugin.cells.get(t);
    if (!n) return !1;
    var a = dn(n);
    return !!a && ((r = ps(a)) === null || r === void 0 ? void 0 : r.sourceData.kind) === "mmCIF";
  }, e.prototype.getCellPdbId = function(t) {
    if (!this.isFromPdb(t)) return "";
    var r = this.plugin.cells.get(t);
    if (!r) return "";
    var n = dn(r);
    if (!n) return "";
    var a = "";
    if (this.plugin.managers.cell.isFromPdb(t)) {
      for (var i = nS(n, ["HEADER"]), o = 0, s = i.length; o < s && !a; o++) if (i[o].startsWith("HEADER") && i[o].length >= 66) {
        var u = i[o].slice(62, 66).replace(" ", "");
        u.length === 4 && /^[A-Za-z0-9]*$/.test(u) && (a = u);
      }
    }
    return a;
  }, e.prototype.getMeasurementName = function(t, r) {
    var n, a, i = this.get(t);
    if (!i.representations.get(r)) return console.warn("There is no ".concat(r, " in ").concat(t, " cell"));
    var o = ((a = (n = i.model) === null || n === void 0 ? void 0 : n.loci) !== null && a !== void 0 ? a : []).map(function(s) {
      return an.getCenter(s);
    });
    return r === qe.Distance ? "".concat(D.distance(o[0], o[1]).toFixed(2), "Å") : r === qe.Angle ? "".concat(Bi(D.angle(D.sub(D(), o[0], o[1]), D.sub(D(), o[2], o[1]))).toFixed(2), "°") : r === qe.Dihedral ? "".concat(Bi(D.dihedralAngle(o[0], o[1], o[2], o[3])).toFixed(2), "°") : "";
  }, e.prototype.create = function(t) {
    var r, n, a = this, i = t.representations, o = t.model, s = t.assets, u = t.dependency, c = t.ref, l = t.theme, d = c ?? Fa.create22(), f = /* @__PURE__ */ new Map();
    return i.forEach(function(m) {
      var h;
      !m.isHidden && m.state && ((h = a.plugin.canvas3d) === null || h === void 0 || h.add(m.state)), f.set(m.type, m);
    }), this.plugin.cells.set(d, { ref: d, representations: f, dependency: k({ on: [], by: [] }, u), theme: { color: k(k({}, B5), l == null ? void 0 : l.color), size: k(k({}, B5), l == null ? void 0 : l.size), transparency: k(k({}, B5), l == null ? void 0 : l.transparency) }, assets: s, model: o }), !((r = u == null ? void 0 : u.on) === null || r === void 0) && r.length && Array.from(new Set(u == null ? void 0 : u.on)).forEach(function(m) {
      a.addDependency(m.ref, { by: [d] });
    }), !((n = u == null ? void 0 : u.by) === null || n === void 0) && n.length && Array.from(new Set(u == null ? void 0 : u.by)).forEach(function(m) {
      a.addDependency(m, { on: [{ ref: d }] });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "cell:create" }), d;
  }, e.prototype.createEmptyMolecularCell = function(t) {
    var r, n, a, i;
    return Be(this, 0, void 0, function() {
      var o, s, u, c;
      return Te(this, function(l) {
        switch (l.label) {
          case 0:
            return o = vc(), [4, Kk.create(o, this.plugin.managers.representation.ctx)];
          case 1:
            return s = l.sent(), [2, this.create({ representations: [{ state: s, isHidden: !1, type: qe.BallAndStick }], model: { structure: o }, assets: [{ format: xr.Sdf, data: "" }], theme: { transparency: (u = {}, u[Mt.ATOM] = t && (!((r = t[Mt.ATOM]) === null || r === void 0) && r.transparency) ? [(n = t[Mt.ATOM]) === null || n === void 0 ? void 0 : n.transparency] : [], u[Mt.RIBBON] = [], u[Mt.SURFACE] = [], u), size: (c = {}, c[Mt.ATOM] = t && (!((a = t[Mt.ATOM]) === null || a === void 0) && a.size) ? [(i = t[Mt.ATOM]) === null || i === void 0 ? void 0 : i.size] : [], c[Mt.RIBBON] = [], c[Mt.SURFACE] = [], c) } })];
        }
      });
    });
  }, e.prototype.copyMolecular = function(t, r) {
    var n, a, i, o, s, u;
    return Be(this, 0, void 0, function() {
      var c, l, d, f, m, h;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            c = [], l = function(g) {
              var v, y, _, S, b, x, A, w, C, M, T, N, I;
              return Te(this, function(P) {
                switch (P.label) {
                  case 0:
                    return v = d.get(g.ref), [4, d.getStructure(g.ref)];
                  case 1:
                    return y = P.sent(), _ = [], (S = sa(y, (n = g.elementIds) !== null && n !== void 0 ? n : [], !0, !0)).elementCount ? [4, Oi.attach({}, S, void 0, !0)] : [3, 3];
                  case 2:
                    P.sent(), P.label = 3;
                  case 3:
                    return b = wu(S), g.representationType ? (x = Object.keys(On).find(function(O) {
                      return On[O].includes(g.representationType);
                    }), [4, Zs[g.representationType].create(S, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(g.representationType, S, { color: { name: "multi-theme", props: { themes: v.theme.color[x] } }, size: v.theme.size && (!((a = v.theme.size[x]) === null || a === void 0) && a.length) ? v.theme.size[x][0] : d.plugin.managers.representation.defaultTheme.size[g.representationType] }))]) : [3, 5];
                  case 4:
                    return A = P.sent(), _.push({ state: A, isHidden: (i = r == null ? void 0 : r.isHidden) === null || i === void 0 || i, type: g.representationType }), [3, 9];
                  case 5:
                    w = function(O, F) {
                      var R, G, L;
                      return Te(this, function(q) {
                        switch (q.label) {
                          case 0:
                            return R = Object.keys(On).find(function(K) {
                              return On[K].includes(O);
                            }), !(!((o = g.elementIds) === null || o === void 0) && o.length) || Oy(F.state, g.elementIds).length ? (G = sa(F.state ? zo(F.state) : sa(S, F.cache.elementIds, !0), (s = g.elementIds) !== null && s !== void 0 ? s : [], !0, b), [4, Zs[O].create(G, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(O, G, { color: { name: "multi-theme", props: { themes: v.theme.color[R] } }, size: d.plugin.managers.representation.defaultTheme.size[O] }))]) : [3, 2];
                          case 1:
                            L = q.sent(), _.push({ state: L, isHidden: (u = r == null ? void 0 : r.isHidden) === null || u === void 0 || u, type: O }), q.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, C = 0, M = Array.from(v.representations), P.label = 6;
                  case 6:
                    return C < M.length ? (T = M[C], N = T[0], I = T[1], [5, w(N, I)]) : [3, 9];
                  case 7:
                    P.sent(), P.label = 8;
                  case 8:
                    return C++, [3, 6];
                  case 9:
                    return c.push(d.create({ representations: _, model: { structure: S }, assets: v.assets, theme: k({}, v.theme) })), [2];
                }
              });
            }, d = this, f = 0, m = t, p.label = 1;
          case 1:
            return f < m.length ? (h = m[f], [5, l(h)]) : [3, 4];
          case 2:
            p.sent(), p.label = 3;
          case 3:
            return f++, [3, 1];
          case 4:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:copyMolecular" }), [2, c];
        }
      });
    });
  }, e.prototype.update = function(t, r) {
    var n, a, i, o, s, u, c, l = this, d = this.plugin.managers.cell.get(t);
    d.model = Object.assign(d.model, r.model), r.theme && (d.theme = { color: k(k({}, d.theme.color), r.theme.color), size: k(k({}, d.theme.size), r.theme.size), transparency: k(k({}, d.theme.transparency), r.theme.transparency) }), !((n = r.representations) === null || n === void 0) && n.length && r.representations.forEach(function(f) {
      var m;
      d.representations.set(f.type, Object.assign((m = d.representations.get(f.type)) !== null && m !== void 0 ? m : {}, f));
    }), !((i = (a = r.dependency) === null || a === void 0 ? void 0 : a.on) === null || i === void 0) && i.length && (this.removeDependency(t, { on: d.dependency.on }), Array.from(new Set((o = r.dependency) === null || o === void 0 ? void 0 : o.on)).forEach(function(f) {
      l.addDependency(f.ref, { by: [t] });
    })), !((u = (s = r.dependency) === null || s === void 0 ? void 0 : s.by) === null || u === void 0) && u.length && (this.removeDependency(t, { by: d.dependency.by }), Array.from(new Set((c = r.dependency) === null || c === void 0 ? void 0 : c.by)).forEach(function(f) {
      l.addDependency(f, { on: [{ ref: t }] });
    })), d.dependency = k(k({}, d.dependency), r.dependency), r.assets && (d.assets = r.assets), this.plugin.managers.snapshot.event.changed.next({ from: "cell:update" });
  }, e.prototype.remove = function(t, r) {
    var n, a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u, c, l, d, f = this;
      return Te(this, function(m) {
        switch (m.label) {
          case 0:
            i = "", o = /* @__PURE__ */ new Map(), s = function(h) {
              var p, g, v, y, _, S, b, x, A, w, C, M;
              return Te(this, function(T) {
                switch (T.label) {
                  case 0:
                    return u.plugin.cells.has(h.ref) ? (p = u.get(h.ref), [4, u.getStructure(h.ref)]) : [2, "continue"];
                  case 1:
                    if (g = T.sent(), h.ref && g && u.plugin.managers.selection.structure.remove({ item: { ref: h.ref, elementIds: (n = h.elementIds) !== null && n !== void 0 ? n : ms(g) } }), o.has(h.ref) && o.get(h.ref) !== void 0 ? o.set(h.ref, h.elementIds === void 0 ? void 0 : nt(nt([], h.elementIds, !0), o.get(h.ref), !0)) : o.set(h.ref, h.elementIds), r) p.representations.forEach(function(N) {
                      var I, P;
                      if (Jp.has(N.type) && p.dependency.on.length) {
                        var O = p.dependency.on.some(function(F) {
                          return eme(F, r);
                        });
                        O && (!N.isHidden && N.state && ((I = f.plugin.canvas3d) === null || I === void 0 || I.remove(N.state)), p.representations.delete(N.type));
                      }
                      N.type === qe.Surface && (r.elementIds || (N.state && ((P = f.plugin.canvas3d) === null || P === void 0 || P.remove(N.state)), p.representations.delete(N.type)));
                    });
                    else if (!((a = h == null ? void 0 : h.elementIds) === null || a === void 0) && a.length) {
                      for (v = function(N, I) {
                        var P = Object.keys(On).find(function(O) {
                          return On[O].includes(N);
                        });
                        P_(I.state, h.elementIds, N, function(O) {
                          var F;
                          return f.plugin.managers.representation.createTheme(N, O, { color: { name: "multi-theme", props: { themes: p.theme.color[P] } }, size: p.theme.size && (!((F = p.theme.size[P]) === null || F === void 0) && F.length) ? p.theme.size[P][0] : f.plugin.managers.representation.defaultTheme.size[I.type] });
                        }, function(O) {
                          var F;
                          return f.plugin.managers.representation.createTransparencyLayers(O, nt([], (F = p == null ? void 0 : p.theme.transparency[P]) !== null && F !== void 0 ? F : [], !0));
                        });
                      }, y = 0, _ = Array.from(p.representations); y < _.length; y++) S = _[y], b = S[0], x = S[1], v(b, x);
                      g && (p.model.structure = WL(g, h.elementIds));
                    } else p.representations.forEach(function(N) {
                      var I;
                      !N.isHidden && N.state && ((I = f.plugin.canvas3d) === null || I === void 0 || I.remove(N.state)), p.representations.delete(N.type);
                    });
                    if (!p.dependency.by.length) return [3, 6];
                    A = 0, w = Array.from(new Set(p.dependency.by)), T.label = 2;
                  case 2:
                    return A < w.length ? (C = w[A], (M = u.plugin.cells.get(C)) != null && M.representations.has(qe.IntraInteractions) ? (i = C, [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return [4, u.remove([{ ref: C }], h)];
                  case 4:
                    T.sent(), T.label = 5;
                  case 5:
                    return A++, [3, 2];
                  case 6:
                    return p.representations.size || (p.dependency.on.length && Array.from(new Set(p.dependency.on)).forEach(function(N) {
                      var I = f.plugin.cells.get(N.ref);
                      if (I) {
                        var P = I.dependency.by.findIndex(function(O) {
                          return O === h.ref;
                        });
                        P !== -1 && I.dependency.by.splice(P, 1);
                      }
                    }), u.plugin.cells.delete(h.ref)), [2];
                }
              });
            }, u = this, c = 0, l = t, m.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [5, s(d)]) : [3, 4];
          case 2:
            m.sent(), m.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return i && this.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.cell.remove"), this.plugin.managers.snapshot.event.changed.next({ from: "cell:remove" }), [2];
        }
      });
    });
  }, e.prototype.extractMolecular = function(t, r) {
    var n, a, i, o, s;
    return Be(this, 0, void 0, function() {
      var u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A;
      return Te(this, function(w) {
        switch (w.label) {
          case 0:
            u = [], c = 0, l = t, w.label = 1;
          case 1:
            return c < l.length ? (d = l[c], f = this.get(d.ref), [4, this.getStructure(d.ref)]) : [3, 8];
          case 2:
            m = w.sent(), h = sa(m, (n = d.elementIds) !== null && n !== void 0 ? n : [], !0, !0), p = !((a = f.assets) === null || a === void 0) && a.length && (!((i = f.assets[0]) === null || i === void 0) && i.format) ? f.assets[0].format : xr.Pdb, g = [], v = function(C, M) {
              var T, N, I, P;
              return Te(this, function(O) {
                switch (O.label) {
                  case 0:
                    return T = Object.keys(On).find(function(F) {
                      return On[F].includes(C);
                    }), (N = Oy(M.state, d.elementIds)).length ? (I = sa(h, N), [4, Zs[C].create(I, y.plugin.managers.representation.ctx, y.plugin.managers.representation.createTheme(C, I, { color: { name: "multi-theme", props: { themes: f.theme.color[T] } }, size: f.theme.size && (!((o = f.theme.size[T]) === null || o === void 0) && o.length) ? f.theme.size[T][0] : y.plugin.managers.representation.defaultTheme.size[M.type] }))]) : [3, 2];
                  case 1:
                    P = O.sent(), g.push({ state: P, isHidden: (s = r == null ? void 0 : r.isHidden) === null || s === void 0 || s, type: C }), O.label = 2;
                  case 2:
                    return [2];
                }
              });
            }, y = this, _ = 0, S = Array.from(f.representations), w.label = 3;
          case 3:
            return _ < S.length ? (b = S[_], x = b[0], A = b[1], [5, v(x, A)]) : [3, 6];
          case 4:
            w.sent(), w.label = 5;
          case 5:
            return _++, [3, 3];
          case 6:
            u.push(this.create({ representations: g, model: { structure: h }, assets: [{ format: p, data: w3(h, p) }], theme: k({}, f.theme) })), this.remove([d]), w.label = 7;
          case 7:
            return c++, [3, 1];
          case 8:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:extractMolecular" }), [2, u];
        }
      });
    });
  }, e.prototype.addDependency = function(t, r) {
    var n, a, i = this.get(t);
    !((n = r.on) === null || n === void 0) && n.length && (i.dependency.on = i.dependency.on.concat(r.on)), !((a = r.by) === null || a === void 0) && a.length && (i.dependency.by = Array.from(new Set(i.dependency.by.concat(r.by))));
  }, e.prototype.removeDependency = function(t, r) {
    var n, a, i = this;
    !((n = r.on) === null || n === void 0) && n.length && r.on.forEach(function(o) {
      i.plugin.cells.has(o.ref) && (i.get(o.ref).dependency.by = i.get(o.ref).dependency.by.filter(function(s) {
        return s !== t;
      }));
    }), !((a = r.by) === null || a === void 0) && a.length && r.by.forEach(function(o) {
      i.plugin.cells.has(o) && (i.get(o).dependency.on = i.get(o).dependency.on.filter(function(s) {
        return s.ref !== t;
      }));
    });
  }, e.prototype.query = function(t) {
    var r = [];
    return this.plugin.cells.forEach(function(n) {
      n.representations.forEach(function(a) {
        t(n, a) && r.push(n);
      });
    }), r;
  }, e.prototype.traverse = function(t) {
    this.plugin.cells.forEach(function(r) {
      r.representations.forEach(function(n) {
        t(r, n);
      });
    });
  }, e.prototype.getAllDisplayedCellsRef = function() {
    var t = /* @__PURE__ */ new Set();
    return this.plugin.managers.cell.traverse(function(r, n) {
      [qe.Ribbon, qe.BallAndStick, qe.Line, qe.Stick, qe.CPK].includes(n.type) && !n.isHidden && dn(r) && t.add(r.ref);
    }), Array.from(t.values());
  }, e.prototype.clearReprState = function(t) {
    var r = this, n = this.get(t), a = /* @__PURE__ */ new Map(), i = n.model.structure;
    if (i) {
      if (i) {
        var o = 0;
        i.units.forEach(function(s) {
          s.elements.forEach(function(u) {
            a.set(u, o++);
          });
        });
      }
      Array.from(n.representations.entries()).forEach(function(s) {
        var u;
        s[0];
        var c = s[1];
        c.state && ((u = r.plugin.canvas3d) === null || u === void 0 || u.remove(c.state), n.representations.set(c.type, { isHidden: c.isHidden, type: c.type, cache: { type: c.type, elementIds: A3(c.state).map(function(l) {
          return a && (a != null && a.has(l)) ? a == null ? void 0 : a.get(l) : l;
        }), isHidden: c.isHidden, params: Jp.has(c.type) ? Lz(c.type, c.state) : void 0 } }));
      });
    }
  }, e.prototype.recoveryCache = function(t, r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s;
      return Te(this, function(u) {
        switch (u.label) {
          case 0:
            return n = this.get(t), a = Array.from(n.representations.values()), r ? [4, this.recoveryReprCache(n, r)] : [3, 2];
          case 1:
            u.sent(), u.label = 2;
          case 2:
            i = 0, o = a, u.label = 3;
          case 3:
            return i < o.length ? (s = o[i]).cache ? [4, this.recoveryReprCache(n, s.cache)] : [3, 5] : [3, 6];
          case 4:
            u.sent(), u.label = 5;
          case 5:
            return i++, [3, 3];
          case 6:
            return [2];
        }
      });
    });
  }, e.prototype.recoveryReprCache = function(t, r) {
    var n, a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u;
      return Te(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (i = c.sent()) ? (o = Object.keys(On).find(function(l) {
              return On[l].includes(r.type);
            }), s = t.theme.color[o], u = t.theme.transparency ? t.theme.transparency[o] : void 0, [4, this.plugin.managers.representation.addMolecularRepr(t.ref, { reprType: r.type, elementIds: r.elementIds, isHidden: r.isHidden, theme: this.plugin.managers.representation.createTheme(r.type, sa(i, (n = r.elementIds) !== null && n !== void 0 ? n : [], !0), { color: { name: "multi-theme", props: { themes: s } }, size: t.theme.size && (!((a = t.theme.size[o]) === null || a === void 0) && a.length) ? t.theme.size[o][0] : this.plugin.managers.representation.defaultTheme.size[r.type] }), transparency: u })]) : [2];
          case 2:
            return c.sent(), [2];
        }
      });
    });
  }, e.prototype.overlapLigands = function(t, r, n) {
    return Be(this, 0, void 0, function() {
      var a, i, o, s, u, c, l, d, f, m, h;
      return Te(this, function(p) {
        switch (p.label) {
          case 0:
            return a = function(g) {
              var v = ft(g), y = ft.readLine(v).trim(), _ = ft.readLine(v).trim(), S = ft.readLine(v).trim(), b = ft.readLine(v), x = +b.substr(0, 3), A = +b.substr(3, 3);
              return { title: y, program: _, comment: S, atoms: eS(v, x), bonds: tS(v, A), formalCharges: rS(v) };
            }(n), i = [Array.from(a.atoms.x.toArray()).reduce(function(g, v) {
              return g + v;
            }) / a.atoms.count, Array.from(a.atoms.y.toArray()).reduce(function(g, v) {
              return g + v;
            }) / a.atoms.count, Array.from(a.atoms.z.toArray()).reduce(function(g, v) {
              return g + v;
            }) / a.atoms.count], [4, this.getStructure(t)];
          case 1:
            for (o = p.sent(), s = ua(o, r), u = et.getBoundary(s).sphere.center, c = [u[0] - i[0], u[1] - i[1], u[2] - i[2]], l = [], d = /* @__PURE__ */ new Map(), m = 0, h = a.formalCharges.atomIdx.rowCount; m < h; m++) d.set(a.formalCharges.atomIdx.value(m) - 1, a.formalCharges.charge.value(m));
            for (m = 0, h = a.atoms.count; m < h; m++) l.push({ x: a.atoms.x.value(m) + c[0], y: a.atoms.y.value(m) + c[1], z: a.atoms.z.value(m) + c[2], type_symbol: a.atoms.type_symbol.value(m), charge: d.get(m) || 0 });
            for (f = [], m = 0, h = a.bonds.count; m < h; m++) f.push({ a: a.bonds.atomIdxA.value(m), b: a.bonds.atomIdxB.value(m), order: a.bonds.order.value(m) });
            return [2, { atoms: l, bonds: f }];
        }
      });
    });
  }, e.prototype.getUnitCellData = function(t) {
    var r = this.get(t);
    if (r) {
      var n = dn(r);
      return nme(n);
    }
  }, e;
}(), fp = { createByTrajectory: function(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p;
    return Te(this, function(g) {
      switch (g.label) {
        case 0:
          return r = e.trajectory, n = e.frameIndex, a = e.mode, i = r, o = st.ofModel(i.getFrameAtIndex(n)), s = [], a !== Gf.Drug ? [3, 7] : (u = m_(o), c = u.polymer, l = u.other, c.length ? (d = sa(o, c)).elementCount ? [4, Oi.attach({ runtime: fs, assetManager: new $c() }, d, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          g.sent(), g.label = 2;
        case 2:
          return (f = Wc.factory(t, Wc.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: d }, { value: Qe(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: d }) }), [4, f.createOrUpdate(k(k({}, Wc.defaultValues), { quality: "auto" }), d).run()];
        case 3:
          g.sent(), s.push({ state: f, type: qe.Ribbon }), g.label = 4;
        case 4:
          return l.length ? (m = sa(o, l), (h = lo.factory(t, lo.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: m }, { carbonColor: { name: "uniform", params: { value: Qe(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: m }) }), [4, h.createOrUpdate(k(k({}, lo.defaultValues), { quality: "auto" }), m).run()]) : [3, 6];
        case 5:
          g.sent(), s.push({ state: h, type: qe.BallAndStick }), g.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (p = lo.factory(t, lo.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: o }), size: t.sizeThemeRegistry.create("physical", { structure: o }) }), [4, p.createOrUpdate(k(k({}, lo.defaultValues), { quality: "auto" }), o).run()];
        case 8:
          g.sent(), s.push({ state: p, type: qe.BallAndStick }), g.label = 9;
        case 9:
          return [2, { model: i, reprs: s }];
      }
    });
  });
}, create: function(e, t) {
  return Be(this, 0, void 0, function() {
    var r, n, a, i, o, s, u, c, l, d, f, m, h, p, g;
    return Te(this, function(v) {
      switch (v.label) {
        case 0:
          return r = e.model, n = e.coordinates, a = e.frameIndex, i = e.mode, o = yn.trajectoryFromModelAndCoordinates(r, n), s = st.ofModel(o.getFrameAtIndex(a)), u = [], i !== Gf.Drug ? [3, 7] : (c = m_(s), l = c.polymer, d = c.other, l.length ? (f = sa(s, l)).elementCount ? [4, Oi.attach({ runtime: fs, assetManager: new $c() }, f, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          v.sent(), v.label = 2;
        case 2:
          return (m = Wc.factory(t, Wc.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: f }, { value: Qe(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: f }) }), [4, m.createOrUpdate(k(k({}, Wc.defaultValues), { quality: "auto" }), f).run()];
        case 3:
          v.sent(), u.push({ state: m, type: qe.Ribbon }), v.label = 4;
        case 4:
          return d.length ? (h = sa(s, d), (p = lo.factory(t, lo.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: h }, { carbonColor: { name: "uniform", params: { value: Qe(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: h }) }), [4, p.createOrUpdate(k(k({}, lo.defaultValues), { quality: "auto" }), h).run()]) : [3, 6];
        case 5:
          v.sent(), u.push({ state: p, type: qe.BallAndStick }), v.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (g = lo.factory(t, lo.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: s }), size: t.sizeThemeRegistry.create("physical", { structure: s }) }), [4, g.createOrUpdate(k(k({}, lo.defaultValues), { quality: "auto" }), s).run()];
        case 8:
          v.sent(), u.push({ state: g, type: qe.BallAndStick }), v.label = 9;
        case 9:
          return [2, { model: o, reprs: u }];
      }
    });
  });
}, update: function(e, t, r) {
  return Be(this, 0, void 0, function() {
    var n, a, i, o;
    return Te(this, function(s) {
      switch (s.label) {
        case 0:
          return n = t.trajectory, a = t.frameIndex, i = t.mode, (o = st.ofModel(n.getFrameAtIndex(a))).elementCount ? [4, Oi.attach({ runtime: fs, assetManager: new $c() }, o, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2];
        case 1:
          s.sent(), s.label = 2;
        case 2:
          return [4, Promise.all(e.map(function(u) {
            var c = Object.keys(On).find(function(f) {
              return On[f].includes(u.type);
            }), l = et.toExpression(st.toStructureElementLoci(u.getLoci().structure)), d = t1(e1(o, l));
            u.setTheme({ color: r.colorThemeRegistry.create(i === Gf.Drug ? c === Mt.RIBBON ? "uniform" : "element-symbol" : "material-element-symbol", { structure: d }, i === Gf.Drug ? c === Mt.RIBBON ? { value: Qe(14474728) } : { carbonColor: { name: "uniform", params: { value: Qe(14474728) } } } : {}), size: r.sizeThemeRegistry.create(c === Mt.RIBBON ? "uniform" : "physical", { structure: d }, u.theme.size.props) }), u.createOrUpdate({}, d).run();
          }))];
        case 3:
          return s.sent(), [2];
      }
    });
  });
} }, II = function() {
  function e(t) {
    this.ev = xo.create(), this.updated = this.ev(), this.plugin = t, this.paused = !1;
  }
  return e.prototype.import = function(t, r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o, s, u;
      return Te(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, Wf(t.data)];
          case 1:
            return n = c.sent(), [4, ml[t.format].parse(n)];
          case 2:
            return a = c.sent(), [4, dse(r.data)];
          case 3:
            return i = c.sent(), [4, ml[r.format].parse(i)];
          case 4:
            return o = c.sent(), [4, fp.create({ model: t.format === xr.Gro ? a : a[0].model, coordinates: o, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return s = c.sent(), u = Ya(st.toStructureElementLoci(t.format === xr.Gro ? st.ofModel(s.model.frames[0], { dynamicBonds: !0 }) : a[0])), [2, this.plugin.managers.cell.create({ representations: s.reprs.map(function(l) {
              return k({ isHidden: !1 }, l);
            }), model: { trajectory: { state: s.model, frameIndex: 0 } }, assets: [{ data: n, format: t.format }, { data: i, format: r.format }], theme: { color: { Atom: [k({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[Mt.ATOM])], Ribbon: [k({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[Mt.RIBBON])] } } })];
        }
      });
    });
  }, e.prototype.importWithGro = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a;
      return Te(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, Wf(t.data)];
          case 1:
            return r = i.sent(), [4, Xz.parse(r)];
          case 2:
            return n = i.sent(), [4, fp.createByTrajectory({ trajectory: n, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 3:
            return a = i.sent(), [2, this.plugin.managers.cell.create({ representations: a.reprs.map(function(o) {
              return k({ isHidden: !1 }, o);
            }), model: { trajectory: { state: a.model, frameIndex: 0 } }, assets: [{ data: r, format: t.format }] })];
        }
      });
    });
  }, e.prototype.importTrajectory = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a, i;
      return Te(this, function(o) {
        switch (o.label) {
          case 0:
            return L_[t.format] ? typeof t.data == "string" || t.data instanceof File ? [4, Wf(t.data)] : [3, 2] : [2];
          case 1:
            return n = o.sent(), [3, 3];
          case 2:
            n = t.data, o.label = 3;
          case 3:
            return r = n, [4, L_[t.format].parse(r)];
          case 4:
            return a = o.sent(), [4, fp.createByTrajectory({ trajectory: a, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return i = o.sent(), [2, this.plugin.managers.cell.create({ representations: i.reprs.map(function(s) {
              return k({ isHidden: !1 }, s);
            }), model: { trajectory: { state: i.model, frameIndex: 0 } }, assets: [{ data: r, format: t.format }] })];
        }
      });
    });
  }, e.prototype.getTrajectoryCell = function(t) {
    var r = [];
    if (t) {
      var n = this.plugin.cells.get(t);
      if (!(n != null && n.model.trajectory)) return [];
      r.push(n);
    } else this.plugin.cells.forEach(function(a) {
      a.model.trajectory && r.push(a);
    });
    return r;
  }, e.prototype.play = function(t) {
    var r = this;
    this.paused = !1;
    var n = function() {
      r.next(t), r.paused || window.requestAnimationFrame(n);
    };
    window.requestAnimationFrame(n);
  }, e.prototype.next = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a, i, o, s, u, c;
      return Te(this, function(l) {
        switch (l.label) {
          case 0:
            r = this.getTrajectoryCell(t), n = 0, a = r, l.label = 1;
          case 1:
            return n < a.length ? (i = a[n], o = i.model.trajectory, s = o.state, u = o.frameIndex, c = u >= s.frameCount - 1 ? 0 : u + 1, [4, fp.update(Array.from(i.representations).map(function(d) {
              return d[0], d[1].state;
            }), { trajectory: s, frameIndex: c, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)]) : [3, 4];
          case 2:
            l.sent(), i.model.trajectory.frameIndex = c, this.updateDependencyByCells(t), t && this.updated.next({ ref: t, frame: c }), l.label = 3;
          case 3:
            return n++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.setFrameIndex = function(t, r) {
    var n;
    return Be(this, 0, void 0, function() {
      var a, i, o, s;
      return Te(this, function(u) {
        switch (u.label) {
          case 0:
            a = this.getTrajectoryCell(r), i = 0, o = a, u.label = 1;
          case 1:
            return i < o.length ? (s = o[i], [4, fp.update(Array.from(s.representations).map(function(c) {
              return c[0], c[1].state;
            }), { trajectory: (n = s.model.trajectory) === null || n === void 0 ? void 0 : n.state, frameIndex: t, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)]) : [3, 4];
          case 2:
            u.sent(), s.model.trajectory.frameIndex = t, u.label = 3;
          case 3:
            return i++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.updateDependencyByCells = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a, i, o, s, u, c, l, d = this;
      return Te(this, function(f) {
        for (r = this.getTrajectoryCell(t), n = 0, a = r; n < a.length; n++) if ((i = a[n]).dependency.by.length) for (o = function(m) {
          var h = s.plugin.cells.get(m);
          h && h.representations.forEach(function(p, g) {
            g === qe.IntraInteractions && d.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.trajectory.updateDependencyByCells"), Object.keys(z0).includes(g) && d.plugin.managers.representation.updateMeasurement({ items: h.dependency.on, ref: m });
          });
        }, s = this, u = 0, c = i.dependency.by; u < c.length; u++) l = c[u], o(l);
        return [2];
      });
    });
  }, e.prototype.mergeDumpAndPymatgen = function(t, r) {
    return Be(this, 0, void 0, function() {
      var n, a, i;
      return Te(this, function(o) {
        switch (o.label) {
          case 0:
            return (n = this.getTrajectoryCell(r)).length && n[0].assets[0].format === xr.Dump ? (a = n[0], [4, kme(a.assets[0].data, t)]) : [2];
          case 1:
            return i = o.sent(), a.model.trajectory = { state: i, frameIndex: a.model.trajectory.frameIndex }, [4, fp.update(Array.from(a.representations).map(function(s) {
              return s[0], s[1].state;
            }), { trajectory: i, frameIndex: a.model.trajectory.frameIndex, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 2:
            return o.sent(), a.model.trajectory.frameIndex = a.model.trajectory.frameIndex, this.updateDependencyByCells(r), [2];
        }
      });
    });
  }, e.prototype.pause = function() {
    this.paused = !0;
  }, e;
}();
function TI(e) {
  try {
    e.dispatchEvent(new MouseEvent("click"));
  } catch {
    var t = document.createEvent("MouseEvents");
    t.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), e.dispatchEvent(t);
  }
}
function jz(e, t) {
  if (t === void 0 && (t = "download"), e) if ("download" in HTMLAnchorElement.prototype) {
    var r = document.createElement("a");
    r.download = t, r.rel = "noopener", typeof e == "string" ? (r.href = e, TI(r)) : (r.href = URL.createObjectURL(e), setTimeout(function() {
      return URL.revokeObjectURL(r.href);
    }, 4e4), setTimeout(function() {
      return TI(r);
    }));
  } else if (typeof navigator < "u" && navigator.msSaveOrOpenBlob) navigator.msSaveOrOpenBlob(e, t);
  else {
    var n = window.navigator.userAgent, a = /Safari/i.test(n), i = /CriOS\/[\d]+/.test(n), o = function(c) {
      var l;
      l = i ? c : c.replace(/^data:[^;]*;/, "data:attachment/file;"), window.open(l, "_blank") || (window.location.href = l);
    };
    if ((a || i) && FileReader) if (e instanceof Blob) {
      var s = new FileReader();
      s.onloadend = function() {
        return o(s.result);
      }, s.readAsDataURL(e);
    } else o(e);
    else {
      var u = URL.createObjectURL(typeof e == "string" ? new Blob([e]) : e);
      location.href = u, setTimeout(function() {
        return URL.revokeObjectURL(u);
      }, 4e4);
    }
  }
}
var Hs, rh, NI = function() {
  function e(t) {
    this.ev = xo.create(), this.event = { changed: this.ev() }, this.plugin = t;
  }
  return e.prototype.setSnapshot = function(t, r) {
    var n, a, i, o, s;
    return Be(this, 0, void 0, function() {
      var u, c, l, d, f, m, h, p;
      return Te(this, function(g) {
        switch (g.label) {
          case 0:
            for (u = /* @__PURE__ */ new Map(), ((n = t == null ? void 0 : t.params) === null || n === void 0 ? void 0 : n.showPolarHydrogenOnly) !== void 0 && (this.plugin.managers.representation.showPolarHydrogenOnly = t.params.showPolarHydrogenOnly), ((a = t == null ? void 0 : t.params) === null || a === void 0 ? void 0 : a.interactionParams) !== void 0 && (this.plugin.managers.representation.interactionParams = t.params.interactionParams), c = 0, l = t.cells; c < l.length; c++) p = l[c], u.set(p.ref, { ref: p.ref, assets: p.assets, dependency: p.dependency, model: {}, representations: /* @__PURE__ */ new Map(), theme: p.theme });
            this.plugin.cells = u, d = function(v) {
              var y, _, S, b, x, A, w, C, M, T, N, I, P, O, F, R, G, L, q, K, X;
              return Te(this, function(H) {
                switch (H.label) {
                  case 0:
                    return y = v.model, _ = y.structure, y.trajectory, S = y.other, b = v.representations, x = v.dependency, A = v.theme, w = void 0, _ ? b != null && b.some(function(W) {
                      return W.isHidden !== !0;
                    }) ? (C = typeof _.data == "string" || _.data instanceof File, N = (T = ml[_.format]).parse, C ? [4, Wf(_.data)] : [3, 2]) : [3, 7] : [3, 8];
                  case 1:
                    return I = H.sent(), [3, 3];
                  case 2:
                    I = _.data, H.label = 3;
                  case 3:
                    return [4, N.apply(T, [I])];
                  case 4:
                    return M = H.sent(), _.format !== xr.Pdb || !M[0].elementCount || yn.hasSecondaryStructure((i = M[0]) === null || i === void 0 ? void 0 : i.model) ? [3, 6] : [4, Oi.attach({}, M[0], { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
                  case 5:
                    H.sent(), H.label = 6;
                  case 6:
                    return w = M[0], f.plugin.managers.cell.update(v.ref, { representations: [], model: { structure: M[0] }, assets: [{ format: _.format, data: _.data }] }), [3, 8];
                  case 7:
                    f.plugin.managers.cell.update(v.ref, { representations: [], model: { structure: void 0 }, assets: [{ format: _.format, data: _.data }] }), H.label = 8;
                  case 8:
                    return P = v.theme, A && (O = {}, Object.keys(A).forEach(function(W) {
                      var ee = A[W];
                      if (ee) {
                        var $ = {};
                        Object.keys(ee).forEach(function(te) {
                          var re = ee[te], ie = [];
                          re != null && re.length && re.forEach(function(oe) {
                            ie.push(k(k({}, oe), { elementIds: oe.elementIds ? Mg(oe.elementIds) : oe.elementIds }));
                          }), $[te] = ie;
                        }), O[W] = $;
                      }
                    }), P = O, f.plugin.managers.cell.update(v.ref, { representations: [], model: {}, theme: O })), b != null && b.length ? w ? [3, 9] : (f.plugin.managers.cell.update(v.ref, { representations: b == null ? void 0 : b.map(function(W) {
                      var ee;
                      return W.cache ? W : k(k({}, W), { elementIds: [], cache: k(k({}, W), { elementIds: !((ee = W.elementIds) === null || ee === void 0) && ee.length ? Mg(W.elementIds) : W.elementIds }) });
                    }), model: {} }), [3, 13]) : [3, 13];
                  case 9:
                    F = function(W) {
                      var ee, $, te, re;
                      return Te(this, function(ie) {
                        switch (ie.label) {
                          case 0:
                            return !((o = W.elementIds) === null || o === void 0) && o.length ? (ee = Object.keys(On).find(function(oe) {
                              return On[oe].includes(W.type);
                            }), $ = P.color[ee], te = P.transparency ? P.transparency[ee] : void 0, re = W.elementIds ? Mg(W.elementIds) : [], [4, f.plugin.managers.representation.addMolecularRepr(v.ref, { reprType: W.type, elementIds: re, isHidden: W.isHidden, theme: f.plugin.managers.representation.createTheme(W.type, sa(w, re, !0), { color: { name: "multi-theme", props: { themes: $ } }, size: P.size && (!((s = P.size[ee]) === null || s === void 0) && s.length) ? P.size[ee][0] : f.plugin.managers.representation.defaultTheme.size[W.type] }), transparency: te })]) : [3, 2];
                          case 1:
                            ie.sent(), ie.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, R = 0, G = b, H.label = 10;
                  case 10:
                    return R < G.length ? (L = G[R], [5, F(L)]) : [3, 13];
                  case 11:
                    H.sent(), H.label = 12;
                  case 12:
                    return R++, [3, 10];
                  case 13:
                    return S ? (L = b[0], S.serverData && !S.data && r ? [4, r(S.serverData)] : [3, 15]) : [3, 18];
                  case 14:
                    return K = H.sent(), [3, 16];
                  case 15:
                    K = S, H.label = 16;
                  case 16:
                    return q = K, [4, f.plugin.managers.representation.createOther({ data: L.type === qe.IsoSurface ? new File([q.data], q.name) : q, serverData: S.serverData, type: L.type, ref: v.ref, isHidden: L.isHidden })];
                  case 17:
                    H.sent(), H.label = 18;
                  case 18:
                    return x.on.length ? (X = x.on.map(function(W) {
                      return k(k({}, W), { elementIds: W.elementIds ? Mg(W.elementIds) : W.elementIds });
                    }), [4, f.plugin.managers.representation.createMeasurement({ items: X, type: b[0].type, ref: v.ref, props: b[0].params, isHidden: b[0].isHidden })]) : [3, 20];
                  case 19:
                    H.sent(), f.plugin.managers.cell.update(v.ref, { representations: [], model: {}, dependency: k(k({}, v.dependency), { on: X }) }), H.label = 20;
                  case 20:
                    return [2];
                }
              });
            }, f = this, m = 0, h = t.cells, g.label = 1;
          case 1:
            return m < h.length ? (p = h[m], [5, d(p)]) : [3, 4];
          case 2:
            g.sent(), g.label = 3;
          case 3:
            return m++, [3, 1];
          case 4:
            return this.refresh(), [2];
        }
      });
    });
  }, e.prototype.getSnapshot = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a = this;
      return Te(this, function(i) {
        switch (i.label) {
          case 0:
            return this.timestamp = Date.now(), r = [], n = {}, Array.from(this.plugin.cells.values()).map(function(o) {
              var s = o.model.structure, u = o.ref;
              if (s) {
                var c = /* @__PURE__ */ new Map(), l = 0;
                s.units.forEach(function(d) {
                  d.elements.forEach(function(f) {
                    c.set(f, l++);
                  });
                }), n[u] = c;
              }
            }), [4, Promise.all(Array.from(this.plugin.cells.values()).map(function(o) {
              return Be(a, 0, void 0, function() {
                var s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T;
                return Te(this, function(N) {
                  switch (N.label) {
                    case 0:
                      return s = o.representations, u = o.assets, c = o.model, l = c.structure, d = c.trajectory, f = c.other, m = function(I, P) {
                        var O = {};
                        for (var F in I) Object.prototype.hasOwnProperty.call(I, F) && P.indexOf(F) < 0 && (O[F] = I[F]);
                        if (I != null && typeof Object.getOwnPropertySymbols == "function") {
                          var R = 0;
                          for (F = Object.getOwnPropertySymbols(I); R < F.length; R++) P.indexOf(F[R]) < 0 && Object.prototype.propertyIsEnumerable.call(I, F[R]) && (O[F[R]] = I[F[R]]);
                        }
                        return O;
                      }(o, ["representations", "assets", "model"]), (h = ll(m)).model = {}, s.get(qe.IntraInteractions) || s.get(qe.BetweenInteractions) ? [2] : (l ? h.model.structure = { data: (w = (A = w3(l, u == null ? void 0 : u[0].format)) !== null && A !== void 0 ? A : u == null ? void 0 : u[0].data) !== null && w !== void 0 ? w : ps(l).sourceData.data, format: u == null ? void 0 : u[0].format } : u && (h.assets = u), d && (h.model.trajectory = { data: "提取的结构信息", format: u == null ? void 0 : u[0].format }), f ? s.get(qe.IsoSurface) ? (p = !!o.model.other.serverData, g = p ? o.model.other.data : o.model.other, v = h.model, t ? (y = { serverData: p ? o.model.other.serverData : o.model.other }, [3, 3]) : [3, 1]) : [3, 4] : [3, 5]);
                    case 1:
                      return x = {}, _ = Uint8Array.bind, [4, g.arrayBuffer()];
                    case 2:
                      x.data = new (_.apply(Uint8Array, [void 0, N.sent()]))(), x.name = g.name, x.serverData = p ? o.model.other.serverData : o.model.other, y = x, N.label = 3;
                    case 3:
                      return v.other = y, [3, 5];
                    case 4:
                      h.model.other = o.model.other, N.label = 5;
                    case 5:
                      return s != null && s.size && (h.representations = [], S = n[m.ref], s.forEach(function(I) {
                        h.representations.push({ type: I.type, elementIds: I.state ? Hx(A3(I.state).map(function(P) {
                          return S && (S != null && S.has(P)) ? S == null ? void 0 : S.get(P) : P;
                        })) : [], isHidden: I.isHidden, params: Jp.has(I.type) && I.state ? Lz(I.type, I.state) : void 0, cache: I.cache });
                      }), m.theme && Object.keys(m.theme).forEach(function(I) {
                        var P = m.theme[I];
                        if (P) {
                          var O = {};
                          Object.keys(P).forEach(function(F) {
                            var R = P[F], G = [];
                            R != null && R.length && R.forEach(function(L) {
                              G.push(k(k({}, L), { elementIds: Hx(L.elementIds && S ? L.elementIds.map(function(q) {
                                var K;
                                return (K = S.get(q)) !== null && K !== void 0 ? K : q;
                              }) : L.elementIds) }));
                            }), O[F] = G;
                          }), h.theme[I] = O;
                        }
                      })), !((M = (C = m.dependency) === null || C === void 0 ? void 0 : C.on) === null || M === void 0) && M.length && (b = [], (T = m.dependency) === null || T === void 0 || T.on.forEach(function(I) {
                        var P = n[m.ref];
                        b.push(k(k({}, I), { elementIds: Hx(I.elementIds && P ? I.elementIds.map(function(O) {
                          var F;
                          return (F = P.get(O)) !== null && F !== void 0 ? F : O;
                        }) : I.elementIds) }));
                      }), h.dependency.on = b), r.push(h), [2];
                  }
                });
              });
            }))];
          case 1:
            return i.sent(), [2, { cells: r, timestamp: this.timestamp, params: { interactionParams: ll(this.plugin.managers.representation.interactionParams), showPolarHydrogenOnly: this.plugin.managers.representation.showPolarHydrogenOnly } }];
        }
      });
    });
  }, e.prototype.refresh = function() {
    var t, r, n, a = this.plugin;
    (t = a.canvas3d) === null || t === void 0 || t.pause(!0), (r = a.canvas3d) === null || r === void 0 || r.clear(), a.cells.forEach(function(i) {
      i.representations.forEach(function(o) {
        var s;
        !o.isHidden && o.state && ((s = a.canvas3d) === null || s === void 0 || s.add(o.state));
      });
    }), (n = a.canvas3d) === null || n === void 0 || n.animate();
  }, e.prototype.downloadAsImage = function(t, r) {
    var n, a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u, c, l, d, f, m, h, p, g, v, y;
      return Te(this, function(_) {
        switch (_.label) {
          case 0:
            if (i = r || { width: ((n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.webgl.gl.drawingBufferWidth) || 0, height: ((a = this.plugin.canvas3d) === null || a === void 0 ? void 0 : a.webgl.gl.drawingBufferHeight) || 0 }, o = i.width, s = i.height, u = { x: 0, y: 0, width: 1, height: 1 }, (c = { x: Math.floor(u.x * o), y: Math.floor(u.y * s), width: Math.ceil(u.width * o), height: Math.ceil(u.height * s) }).width + c.x > o && (c.width = o - c.x), c.height + c.y > s && (c.height = s - c.y), o <= 0 || s <= 0) return [2];
            if (l = this.plugin.canvas3d, d = l.webgl.extensions, f = d.colorBufferFloat, m = d.textureFloat, h = l.props.postprocessing.occlusion, p = l.getImagePass({ transparentBackground: !0, cameraHelper: { axes: { name: "off", params: {} } }, multiSample: k(k({}, l.props.multiSample), { mode: "on", sampleLevel: f && m ? 4 : 2 }), postprocessing: k(k({}, l.props.postprocessing), { occlusion: h.name === "on" ? { name: "on", params: k(k({}, h.params), { samples: 128, resolutionScale: l.webgl.pixelRatio }) } : h }), marking: k({}, l.props.marking) }), g = p.getImageData(o, s, c), (v = document.createElement("canvas")).width = g.width, v.height = g.height, !(y = v.getContext("2d"))) throw new Error("Could not create canvas 2d context");
            return y.putImageData(g, 0, 0), [4, fse(v, "png")];
          case 1:
            return jz(_.sent(), t), [2];
        }
      });
    });
  }, e;
}(), qme = { Dihedral: qe.Dihedral, Distance: qe.Distance, Angle: qe.Angle, Label: qe.Label, "Molecular Surface": qe.Surface }, Hme = function() {
  function e(t) {
    var r = this;
    this.ev = xo.create(), this.prev = /* @__PURE__ */ new Map(), this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = t, this.selection = /* @__PURE__ */ new Set(), this.event.change.subscribe(function(n) {
      var a = n.current, i = a.repr;
      if (a.loci.kind !== "empty-loci") {
        var o = qme[i.label];
        o === qe.Surface && (n.current.loci = n.current.repr.getLoci()), t.cells.forEach(function(s) {
          var u;
          s.representations.has(o) && ((u = s.representations.get(o)) === null || u === void 0 ? void 0 : u.state) === i && (r.selection.has(s.ref) ? n.button !== 2 && r.remove({ item: { ref: s.ref }, loci: n.current }) : r.add({ item: { ref: s.ref }, loci: n.current }));
        });
      } else r.clear();
    });
  }
  return e.prototype.add = function(t) {
    var r, n, a = t.item.ref;
    this.selection.add(a);
    var i = this.plugin.cells.get(a);
    if (i) {
      var o = Array.from(i.representations.values())[0];
      if (t != null && t.loci || o.state) {
        var s = (r = t.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(s, Et.Select), this.event.add.next({ ref: a, loci: s }), this.prev.set(a, s), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.remove = function(t) {
    var r, n, a = t.item.ref;
    this.selection.delete(a);
    var i = this.plugin.cells.get(a);
    if (i) {
      var o = Array.from(i.representations.values())[0];
      if (o.state) {
        var s = (r = t.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(s, Et.Deselect), this.event.remove.next({ ref: a, loci: s }), this.prev.delete(a), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.clear = function() {
    var t = this;
    this.selection.clear(), this.prev.forEach(function(r) {
      var n;
      (n = t.plugin.canvas3d) === null || n === void 0 || n.mark(r, Et.Deselect);
    }), this.prev.clear(), this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e;
}(), Kme = function() {
  function e(t) {
    var r = this;
    this.ev = xo.create(), this.lociGranularity = "residue", this.prev = [], this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = t, this.selection = /* @__PURE__ */ new Map(), this.event.change.subscribe(function(n) {
      if (n.current.loci.kind === "element-loci" && r.plugin.cells.forEach(function(s, u) {
        var c;
        if (s != null && s.model.structure && wu(s == null ? void 0 : s.model.structure) === wu(n.current.loci.structure) || s.model.trajectory && (s == null ? void 0 : s.model.trajectory.state.getFrameAtIndex(s.model.trajectory.frameIndex).id) === wu(n.current.loci.structure)) {
          var l = dn(s);
          n.current.loci = an.normalize(ua(l, Ya(n.current.loci)), r.lociGranularity, !0);
          var d = Ya(n.current.loci), f = new Set((c = r.selection.get(u)) !== null && c !== void 0 ? c : []), m = f.size ? d.filter(function(h) {
            return !f.has(h);
          }) : d;
          n.button !== 2 && m.length === 0 ? r.remove({ item: { ref: u, elementIds: d }, reprLoci: n.current }) : r.add({ item: { ref: u, elementIds: m }, reprLoci: n.current });
        }
      }), n.current.loci.kind === "bond-loci") {
        var a = n.current.loci;
        n.current.loci = an.normalize(n.current.loci, r.lociGranularity, !0);
        var i = /* @__PURE__ */ new Set();
        a.bonds.forEach(function(s) {
          i.add(s.aUnit.elements[s.aIndex]), i.add(s.bUnit.elements[s.bIndex]);
        });
        var o = Ya(n.current.loci);
        r.plugin.cells.forEach(function(s, u) {
          var c;
          if (s != null && s.model.structure && wu(s == null ? void 0 : s.model.structure) === wu(a.bonds[0].aStructure)) {
            var l = new Set((c = r.selection.get(u)) !== null && c !== void 0 ? c : []), d = l.size ? o.filter(function(f) {
              return !l.has(f);
            }) : o;
            n.button !== 2 && d.length === 0 ? r.remove({ item: { ref: u, elementIds: o }, reprLoci: n.current }) : r.add({ item: { ref: u, elementIds: d }, reprLoci: n.current });
          }
        });
      }
      n.current.loci.kind === "empty-loci" && r.clear();
    });
  }
  return Object.defineProperty(e.prototype, "granularity", { get: function() {
    return ase[this.lociGranularity];
  }, enumerable: !1, configurable: !0 }), e.prototype.getSelectionCellItems = function(t) {
    t === void 0 && (t = !1);
    var r = Array.from(this.selection).map(function(n) {
      return { ref: n[0], elementIds: n[1] };
    }).filter(function(n) {
      var a;
      return (a = n.elementIds) === null || a === void 0 ? void 0 : a.length;
    });
    return t && !r.length ? JL(this.plugin) : r;
  }, e.prototype.getSelection = function() {
    return Array.from(this.selection).reduce(function(t, r) {
      var n;
      return k(k({}, t), ((n = {})[r[0]] = r[1], n));
    }, {});
  }, e.prototype.add = function(t, r, n) {
    var a, i, o = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var s = t.item, u = s.ref, c = s.elementIds;
    if (!c || c.length) {
      this.selection.set(u, Array.from(new Set(nt(nt([], (a = this.selection.get(u)) !== null && a !== void 0 ? a : [], !0), c ?? [], !0))));
      var l = this.plugin.cells.get(u);
      if (l) {
        var d = dn(l);
        if (d) {
          var f, m = this.selection.get(u);
          l == null || l.representations.forEach(function(h) {
            var p;
            if (!h.isHidden && h.state) {
              var g = r ? an.normalize(et.intersect(ua(zo(h.state), m), Ci(h.state.getLoci())), o.lociGranularity, !0) : et.intersect(ua(zo(h.state), m), Ci(h.state.getLoci()));
              f = { loci: g, repr: h.state }, (p = o.plugin.canvas3d) === null || p === void 0 || p.mark(f, Et.Select);
            }
          }), this.prev.push({ ref: u, elementIds: c }), n || (this.event.add.next({ loci: (i = t.reprLoci) !== null && i !== void 0 ? i : { loci: ua(d, m) }, item: t.item }), this.plugin.managers.selection.event.changed.next({}));
        }
      }
    } else console.warn("add selection, elementIds is empty");
  }, e.prototype.remove = function(t, r, n) {
    var a, i = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var o = t.item, s = o.ref, u = o.elementIds;
    if (!u || u.length) {
      if (this.selection.has(s)) {
        var c = /* @__PURE__ */ new Set(), l = [], d = new Set(u);
        this.selection.get(s).forEach(function(g) {
          d.has(g) ? c.add(g) : l.push(g);
        }), l.length ? this.selection.set(s, l) : this.selection.delete(s);
        var f, m = this.plugin.cells.get(s), h = (a = this.selection.get(s)) !== null && a !== void 0 ? a : [];
        m == null || m.representations.forEach(function(g) {
          var v, y;
          if (!g.isHidden && g.state) {
            var _ = r ? an.normalize(et.intersect(ua(zo(g.state), h), Ci(g.state.getLoci())), i.lociGranularity, !0) : et.intersect(ua(zo(g.state), h), Ci(g.state.getLoci()));
            (v = i.plugin.canvas3d) === null || v === void 0 || v.mark({ loci: Ci(g.state.getLoci()), repr: g.state }, Et.Deselect), f = { loci: _, repr: g.state }, (y = i.plugin.canvas3d) === null || y === void 0 || y.mark(f, Et.Select);
          }
        });
        var p = [];
        this.prev.forEach(function(g) {
          var v = g.ref, y = g.elementIds;
          if (v === s) {
            var _ = [];
            y == null || y.forEach(function(S) {
              c.has(S) || _.push(S);
            }), _.length && p.push({ ref: v, elementIds: _ });
          }
        }), this.prev = p, n || (this.event.remove.next({ loci: f, item: t.item }), this.plugin.managers.selection.event.changed.next({}));
      }
    } else console.warn("remove selection, elementIds is empty");
  }, e.prototype.clear = function() {
    var t = this;
    Array.from(this.selection.keys()).forEach(function(r) {
      var n = t.plugin.cells.get(r);
      n && (n == null || n.representations.forEach(function(a) {
        var i;
        !a.isHidden && a.state && ((i = t.plugin.canvas3d) === null || i === void 0 || i.mark({ loci: Ci(a.state.getLoci()), repr: a.state }, Et.Deselect));
      }));
    }), this.selection.clear(), this.prev = [], this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e.prototype.setGranularity = function(t) {
    this.lociGranularity = nse[t];
  }, e.prototype.expand = function(t, r) {
    var n = this, a = r ?? this.getSelectionCellItems(), i = this.plugin.managers.cell.getAllDisplayedCellsRef(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), u = N2(i.map(function(S) {
      return { ref: S };
    }), this.plugin), c = u.unitsMap, l = u.structure;
    c.forEach(function(S, b) {
      o.set(i[b], S.map(function(x) {
        return l.unitMap.get(x);
      })), S.forEach(function(x) {
        return s.set(x, i[b]);
      });
    });
    var d = TL(a.map(function(S) {
      var b, x = o.get(S.ref), A = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
      x.forEach(function(M, T) {
        A.set(T, new Set(M.elements)), w.set(T, []);
      }), (b = S.elementIds) === null || b === void 0 || b.forEach(function(M) {
        A.forEach(function(T, N) {
          var I;
          T.has(M) && ((I = w.get(N)) === null || I === void 0 || I.push(x[N].elements.indexOf(M)));
        });
      });
      var C = Array.from(w.entries()).filter(function(M) {
        return M[0], M[1].length;
      }).map(function(M) {
        var T = M[0], N = M[1];
        return { unit: x[T], indices: N };
      });
      return C;
    })), f = et(l, d), m = et.toExpression(f), h = zt.struct.modifier.union([zt.struct.modifier.exceptBy({ 0: zt.struct.modifier.includeSurroundings({ 0: m, radius: t.radius, "as-whole-residues": t.asWholeResidue }), by: m })]), p = t1(e1(l, h)), g = /* @__PURE__ */ new Map();
    p.units.forEach(function(S) {
      var b, x = s.get(S.id);
      x && (g.has(x) ? (b = g.get(x)) === null || b === void 0 || b.push.apply(b, S.elements) : g.set(x, nt([], S.elements, !0)));
    });
    var v = Array.from(g.entries()).map(function(S) {
      return { ref: S[0], elementIds: S[1] };
    }), y = $L(this.plugin, v), _ = ise[t.filter];
    t.excludeSelectedAtoms && this.clear(), Object.keys(y).forEach(function(S) {
      var b = [];
      _.forEach(function(x) {
        y[S][x].forEach(function(A) {
          return b.push.apply(b, A.elementIds);
        });
      }), n.add({ item: { ref: S, elementIds: b } }, !1);
    });
  }, e;
}(), PI = function() {
  function e(t) {
    this.ev = xo.create(), this.event = { changed: this.ev() }, this.plugin = t, this.structure = new Kme(t), this.shape = new Hme(t);
  }
  return e.prototype.clear = function() {
    this.structure.clear(), this.shape.clear();
  }, e;
}(), BI = function() {
  function e(t) {
    this.ev = xo.create(), this.allowEmptyClick = !0, this.allowSelect = !0, this.rightClick = this.ev(), this.plugin = t, this.allowEmptyClick = !0, this.allowSelect = !0;
  }
  return e.prototype.subscribe = function() {
    var t, r, n = this;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.subscribe(function(a) {
      if (a.current.loci.kind === "empty-loci") {
        if (!n.allowEmptyClick || a.button === 2) return;
        n.plugin.managers.selection.shape.event.change.next(a), n.plugin.managers.selection.structure.event.change.next(a);
      } else if (n.allowSelect) a.current.repr.label === "Molecular Surface" || a.current.loci.kind === "group-loci" ? n.plugin.managers.selection.shape.event.change.next(a) : a.current.loci.kind !== "element-loci" && a.current.loci.kind !== "bond-loci" || n.plugin.managers.selection.structure.event.change.next(a);
      else if (a.button !== 2) return;
      a.button === 2 && n.rightClick.next({ loci: a.current, modifiers: a.modifiers, isEmpty: a.current.loci.kind === "empty-loci", isSelection: !1, reprType: NL[a.current.repr.label] });
    }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.hover.subscribe(function(a) {
      a.current.loci.kind !== "empty-loci" ? n.plugin.managers.highlight.setHoverSelection(a.current) : n.plugin.managers.highlight.setHoverSelection();
    });
  }, e.prototype.setAllowEmptyClick = function(t) {
    this.allowEmptyClick = t;
  }, e.prototype.setAllowSelect = function(t) {
    this.allowSelect = t;
  }, e;
}(), Xme = { interval: void 0, observers: void 0, cRef: "", elementId: -1, totalOffset: D.create(0, 0, 0) }, jme = function() {
  function e(t) {
    this.state = Xme, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click", "drag"], this.plugin.managers.selection.structure.setGranularity(Qr.Atom), this.state.observers = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.drag.observers.pop(), this.state.interval = setInterval(function() {
      if (n.state.totalOffset.filter(function(i) {
        return i !== 0;
      }).length !== 0 && n.state.elementId !== -1) {
        var a = nt([], n.state.totalOffset, !0);
        n.state.totalOffset = D.create(0, 0, 0), n.plugin.managers.editor.executeEdit(n.state.cRef, function(i, o) {
          var s = nt([], i, !0), u = nt([], o, !0);
          return s.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= a[0], c.y -= a[1], c.z -= a[2]);
          }), { editedAtomList: s, editedBondList: u };
        }, function(i, o) {
          var s = nt([], i, !0), u = nt([], o, !0);
          return s.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= a[0], c.y -= a[1], c.z -= a[2]);
          }), { editedAtomList: s, editedBondList: u };
        });
      }
    }, this.intervalTime), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(function(a) {
      var i = a.current.loci;
      if (i.kind === "element-loci") {
        var o = We.toArray(i.elements[0].indices);
        if (o.length === 1) {
          n.plugin.cells.forEach(function(u, c) {
            u.model.structure && et.isSubset(st.toStructureElementLoci(u.model.structure), i) && (n.state.cRef = c);
          });
          var s = kz(n.plugin, a.pageStart, a.pageEnd);
          D.add(n.state.totalOffset, n.state.totalOffset, s), n.state.elementId = i.elements[0].unit.elements[o[0]];
        }
      }
    });
  }, e.prototype.end = function() {
    var t, r;
    this.state.interval && clearInterval(this.state.interval), (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.drag.observers.pop(), this.state.observers && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.observers)), this.state.observers = void 0, this.state.cRef = "", this.state.elementId = -1, this.state.totalOffset = D.create(0, 0, 0);
  }, e;
}(), Yme = { elementType: "C", drawClickObserver: void 0, position: void 0, isDelete: !1 }, Wme = function() {
  function e(t) {
    this.ev = xo.create(), this.state = Yme, this.event = { update: this.ev() }, this.plugin = t;
  }
  return e.prototype.setElementType = function(t) {
    this.state.elementType = t;
  }, e.prototype.setPosition = function(t) {
    this.state.position = t;
  }, e.prototype.setIsDelete = function(t) {
    this.state.isDelete = t;
  }, e.prototype.start = function() {
    var t, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click"], this.plugin.managers.selection.structure.setGranularity(Qr.Atom), this.state.drawClickObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.click.observers.pop(), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(a) {
      return Be(n, 0, void 0, function() {
        var i, o, s, u, c, l, d, f, m, h, p, g, v, y = this;
        return Te(this, function(_) {
          switch (_.label) {
            case 0:
              return a.current.loci && a.current.loci.kind === "element-loci" ? (i = a.current.loci, (o = We.toArray(i.elements[0].indices)).length !== 1 ? [3, 5] : (this.plugin.cells.forEach(function(S, b) {
                S.model.structure && et.isSubset(st.toStructureElementLoci(S.model.structure), i) && (s = b);
              }), u = i.elements[0].unit.elements[o[0]], s ? this.state.isDelete ? [3, 2] : [4, this.plugin.managers.editor.editAtomType(this.state.elementType, [{ ref: s, elementIds: [u] }])] : [2])) : [3, 6];
            case 1:
              return _.sent(), [3, 4];
            case 2:
              return [4, this.plugin.managers.cell.remove([{ ref: s, elementIds: [u] }])];
            case 3:
              _.sent(), _.label = 4;
            case 4:
              this.event.update.next({ isUpdateHierarchy: !0, cRef: s }), _.label = 5;
            case 5:
              return [3, 9];
            case 6:
              return !a.current.loci || a.current.loci.kind !== "empty-loci" || this.state.isDelete ? [3, 9] : (c = Array.from(this.plugin.cells.entries()).filter(function(S) {
                S[0];
                var b = S[1];
                return b.model.structure && (Array.from(b.representations.values()).findIndex(function(x) {
                  return x.isHidden === !1;
                }) !== -1 || !b.representations.size);
              }), c.length ? (l = ((h = c[0][1].model.structure) === null || h === void 0 ? void 0 : h.units.length) === 0, (d = (((p = this.plugin.canvas3d) === null || p === void 0 ? void 0 : p.getPosition(a.page[0], a.page[1])) || { position: void 0 }).position) ? c.length !== 1 ? [3, 8] : (f = c[0][1].model.structure) ? (m = "".concat(Math.max.apply(Math, Array.from((v = (g = f.model) === null || g === void 0 ? void 0 : g.atomicConformation.atomId.toArray()) !== null && v !== void 0 ? v : [0])) + 1), [4, this.plugin.managers.editor.executeEdit(c[0][0], function(S, b) {
                return { editedAtomList: nt(nt([], S, !0), [a0(m, y.state.elementType, d)], !1), editedBondList: nt([], b, !0), affectedAtomIds: [+m] };
              }, function(S, b) {
                return { editedAtomList: nt(nt([], S, !0), [a0(m, y.state.elementType, d)], !1), editedBondList: nt([], b, !0) };
              })]) : [2] : [3, 9]) : (this.event.update.next({ hasMultiRef: !0 }), [2]));
            case 7:
              return _.sent(), this.event.update.next({ isUpdateHierarchy: !0, cRef: c[0][0], isEmpty: l }), [3, 9];
            case 8:
              this.setPosition(d), this.event.update.next({ hasMultiRef: !0, newAtom: a0("", this.state.elementType, d) }), _.label = 9;
            case 9:
              return [2];
          }
        });
      });
    });
  }, e.prototype.end = function() {
    var t, r;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.observers.pop(), this.state.drawClickObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(this.state.drawClickObserver)), this.state.drawClickObserver = void 0;
  }, e.prototype.addAtomByRef = function(t) {
    var r, n, a = this;
    if (this.state.position) {
      var i = this.plugin.cells.get(t);
      if (i) {
        var o = i.model.structure;
        if (o) {
          var s = "".concat(Math.max.apply(Math, Array.from((n = (r = o.model) === null || r === void 0 ? void 0 : r.atomicConformation.atomId.toArray()) !== null && n !== void 0 ? n : [0])) + 1);
          this.plugin.managers.editor.executeEdit(t, function(u, c) {
            return { editedAtomList: nt(nt([], u, !0), [a0(s, a.state.elementType, a.state.position)], !1), editedBondList: nt([], c, !0), affectedAtomIds: [+s] };
          }, function(u, c) {
            return { editedAtomList: nt(nt([], u, !0), [a0(s, a.state.elementType, a.state.position)], !1), editedBondList: nt([], c, !0) };
          }), this.setPosition();
        }
      }
    }
  }, e;
}(), Zme = { interval: void 0, dragObserver: void 0, cRef: "", elementIds: [], unit: void 0, rotateOffset: D.create(0, 0, 0), rotateAtoms: [], arrowCRef: void 0, invert: !1, pointA: D.create(0, 0, 0), pointB: D.create(0, 0, 0) }, Qme = function() {
  function e(t) {
    this.state = Zme, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, r, n;
    return Be(this, 0, void 0, function() {
      var a, i = this;
      return Te(this, function(o) {
        switch (o.label) {
          case 0:
            return this.plugin.managers.editor.disabledInteraction = ["drag"], this.plugin.managers.selection.structure.setGranularity(Qr.Atom), this.state.dragObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.drag.observers.pop(), a = function() {
              return Be(i, 0, void 0, function() {
                var s, u, c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I, P;
                return Te(this, function(O) {
                  switch (O.label) {
                    case 0:
                      if (this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), s = this.plugin.managers.selection.structure.selection, this.state.cRef = "", this.state.elementIds = [], this.state.unit = void 0, u = Array.from(s.entries()).filter(function(F) {
                        return F[0], F[1].length > 0;
                      }), u.length !== 1) return [3, 2];
                      if ((c = u[0][1]).length !== 2) return [3, 2];
                      if (this.state.cRef = u[0][0], this.state.elementIds = nt([], c, !0), !(l = (P = this.plugin.cells.get(u[0][0])) === null || P === void 0 ? void 0 : P.model.structure)) return [2];
                      for (d = l.units.find(function(F) {
                        return $e.has(F.elements, c[0]) && $e.has(F.elements, c[1]);
                      }), this.state.unit = d, m = (f = d).bonds, h = f.conformation, p = f.rings, g = f.elements, v = /* @__PURE__ */ new Map(), y = -1, _ = 0, S = m.a.length; _ < S; _++) {
                        if (y === -1 && (g[m.a[_]] === c[0] && g[m.b[_]] === c[1] && m.edgeProps.order[_] === 1 || g[m.a[_]] === c[1] && g[m.b[_]] === c[0] && m.edgeProps.order[_] === 1)) {
                          for (b = 0, x = p.all.length; b < x; b++) if (p.all[b].includes(c[0]) && p.all[b].includes(c[1])) return [2];
                          y = _;
                        }
                        v.has(g[m.a[_]]) ? v.set(g[m.a[_]], nt(nt([], v.get(g[m.a[_]]), !0), [g[m.b[_]]], !1)) : v.set(g[m.a[_]], [g[m.b[_]]]);
                      }
                      return y !== -1 && v.get(c[0]).length > 1 && v.get(c[1]).length > 1 ? (A = this.state.invert ? 1 : 0, w = this.state.invert ? 0 : 1, this.state.pointA = D.create(h.x(c[w]), h.y(c[w]), h.z(c[w])), this.state.pointB = D.create(h.x(c[A]), h.y(c[A]), h.z(c[A])), C = this.state, [4, this.plugin.managers.representation.createOther({ data: { center: this.state.pointA, vec: D.create(this.state.pointB[0] - this.state.pointA[0], this.state.pointB[1] - this.state.pointA[1], this.state.pointB[2] - this.state.pointA[2]), color: Qe.fromRgb(255, 196, 36), alpha: 0.9 }, type: qe.RotateArrow })]) : [3, 2];
                    case 1:
                      for (C.arrowCRef = O.sent(), M = nt([], v.get(c[A]).filter(function(F) {
                        return F !== c[w] && F !== c[A];
                      }), !0), T = [c[A]], this.state.rotateAtoms = nt([], M, !0); M.length; ) N = M.shift(), (I = this.state.rotateAtoms).push.apply(I, v.get(N)), T.push(N), M.push.apply(M, v.get(N).filter(function(F) {
                        return !T.includes(F);
                      }));
                      this.state.rotateAtoms = Array.from(new Set(this.state.rotateAtoms.filter(function(F) {
                        return F !== c[w] && F !== c[A];
                      }))), O.label = 2;
                    case 2:
                      return [2];
                  }
                });
              });
            }, [4, a()];
          case 1:
            return o.sent(), this.plugin.managers.selection.structure.event.add.subscribe(function() {
              i.state.invert = !1, i.state.rotateOffset = D.create(0, 0, 0), i.state.rotateAtoms = [], i.state.cRef = "", i.state.elementIds = [], i.state.unit = void 0, a();
            }), this.plugin.managers.selection.structure.event.remove.subscribe(function() {
              i.state.invert = !1, i.state.rotateOffset = D.create(0, 0, 0), i.state.rotateAtoms = [], i.state.cRef = "", i.state.elementIds = [], i.state.unit = void 0, a();
            }), this.plugin.managers.selection.structure.event.clear.subscribe(function() {
              i.state.invert = !1, i.state.rotateOffset = D.create(0, 0, 0), i.state.rotateAtoms = [], i.state.cRef = "", i.state.elementIds = [], i.state.unit = void 0, i.state.arrowCRef && i.plugin.managers.cell.remove([{ ref: i.state.arrowCRef }]);
            }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(s) {
              s.current.loci.kind === "group-loci" && (s.current.repr ? s.current.repr.label === "RotateArrow" : s.current.loci.shape.name.split("-").shift() === "RotateArrow") && (i.state.invert = !i.state.invert, a());
            }), this.state.interval = setInterval(function() {
              if (i.state.rotateOffset.filter(function(d) {
                return d !== 0;
              }).length !== 0 && i.state.cRef && i.state.elementIds.length === 2 && i.state.rotateAtoms.length !== 0) {
                var s = i.state.elementIds, u = i.state.unit.conformation, c = D.angle(D.sub(D.create(0, 0, 0), i.state.pointA, i.state.pointB), D.create(i.state.rotateOffset[0], i.state.rotateOffset[1], i.state.rotateOffset[2]));
                D.cross(D.create(0, 0, 0), D.sub(D.create(0, 0, 0), i.state.pointA, i.state.pointB), D.create(i.state.rotateOffset[0], i.state.rotateOffset[1], i.state.rotateOffset[2]))[2] < 0 && (c = 2 * Math.PI - c);
                var l = 5 * D.distance(D.create(0, 0, 0), D.create(i.state.rotateOffset[0], i.state.rotateOffset[1], i.state.rotateOffset[2])) * (c < Math.PI && c > 0 ? -1 : 1);
                i.state.rotateOffset = D.create(0, 0, 0), i.plugin.managers.editor.executeEdit(i.state.cRef, function(d, f) {
                  var m = nt([], d, !0), h = nt([], f, !0);
                  return m.forEach(function(p) {
                    if (i.state.rotateAtoms.includes(p.elementId)) {
                      var g = bI([u.x(s[1]), u.y(s[1]), u.z(s[1])], [u.x(s[0]), u.y(s[0]), u.z(s[0])], l, [p.x, p.y, p.z]);
                      p.x = g[0], p.y = g[1], p.z = g[2];
                    }
                  }), { editedAtomList: m, editedBondList: h };
                }, function(d, f) {
                  var m = nt([], d, !0), h = nt([], f, !0);
                  return m.forEach(function(p) {
                    if (i.state.rotateAtoms.includes(p.elementId)) {
                      var g = bI([u.x(s[1]), u.y(s[1]), u.z(s[1])], [u.x(s[0]), u.y(s[0]), u.z(s[0])], l, [p.x, p.y, p.z]);
                      p.x = g[0], p.y = g[1], p.z = g[2];
                    }
                  }), { editedAtomList: m, editedBondList: h };
                });
              }
            }, this.intervalTime), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(function(s) {
              if (i.state.rotateAtoms.length) {
                var u = kz(i.plugin, s.pageStart, s.pageEnd);
                i.state.rotateOffset[0] += u[0], i.state.rotateOffset[1] += u[1], i.state.rotateOffset[2] += u[2];
              }
            }), [2];
        }
      });
    });
  }, e.prototype.end = function() {
    var t, r, n;
    this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), this.state.interval && clearInterval(this.state.interval), (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.drag.observers.pop(), this.state.dragObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.dragObserver)), this.state.invert = !1, this.state.dragObserver = void 0, this.state.rotateOffset = D.create(0, 0, 0), this.state.rotateAtoms = [], this.state.elementIds = [], this.state.unit = void 0, this.plugin.managers.selection.structure.event.add.observers.pop(), this.plugin.managers.selection.structure.event.remove.observers.pop(), this.plugin.managers.selection.structure.event.clear.observers.pop(), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.click.observers.pop();
  }, e;
}();
(function(e) {
  e[e.None = 0] = "None", e[e.Drag = 1] = "Drag", e[e.Rotate = 2] = "Rotate", e[e.Draw = 3] = "Draw";
})(Hs || (Hs = {})), function(e) {
  e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE", e[e.TRIPLE = 3] = "TRIPLE", e[e.AROMATIC = 4] = "AROMATIC", e[e.SINGLE_OR_DOUBLE = 5] = "SINGLE_OR_DOUBLE", e[e.SINGLE_OR_AROMATIC = 6] = "SINGLE_OR_AROMATIC", e[e.DOUBLE_OR_AROMATIC = 7] = "DOUBLE_OR_AROMATIC", e[e.ANY = 8] = "ANY";
}(rh || (rh = {}));
var OI = [rh.SINGLE, rh.DOUBLE, rh.TRIPLE], FI = function() {
  function e(t) {
    var r;
    this.state = { mode: Hs.None, editAtomDisabled: !1, addBondDisabled: !1, editBondDisabled: !1, selectedPdb: !1, isMergeNeeded: !1 }, this.ev = xo.create(), this.editStateUpdated = this.ev(), this.editStructureUpdated = this.ev(), this.plugin = t, this.instance = ((r = {})[Hs.Drag] = new jme(t), r[Hs.Rotate] = new Qme(t), r[Hs.Draw] = new Wme(t), r[Hs.None] = void 0, r);
  }
  return Object.defineProperty(e.prototype, "isEditing", { get: function() {
    var t;
    return !!(!((t = this.plugin.canvas3d) === null || t === void 0) && t.controls.isEditing);
  }, set: function(t) {
    var r, n, a = ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.controls.isEditing) === !1 && t;
    if ((n = this.plugin.canvas3d) === null || n === void 0 || n.controls.setEditState(t), a && this.setState(this.getEditState()), !t) {
      var i = [];
      this.plugin.cells.forEach(function(o, s) {
        o.representations.has(qe.RotateArrow) && i.push({ ref: s });
      }), this.plugin.managers.cell.remove(i);
    }
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "disabledInteraction", { get: function() {
    var t;
    return ((t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.controls.disabledInteraction) || [];
  }, set: function(t) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setDisabledInteractionState(t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isLockCamera", { get: function() {
    var t;
    return !!(!((t = this.plugin.canvas3d) === null || t === void 0) && t.controls.isLockCamera);
  }, set: function(t) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setLockCameraState(t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "drawEditor", { get: function() {
    return this.instance[Hs.Draw];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rotateEditor", { get: function() {
    return this.instance[Hs.Rotate];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dragEditor", { get: function() {
    return this.instance[Hs.Drag];
  }, enumerable: !1, configurable: !0 }), e.prototype.setState = function(t) {
    Object.assign(this.state, t), this.editStateUpdated.next(this.state);
  }, e.prototype.setEditorMode = function(t, r, n) {
    r === void 0 && (r = !1), n === void 0 && (n = ["click", "drag"]), this.isEditing = t, this.isLockCamera = r, this.disabledInteraction = n;
  }, e.prototype.getEditState = function() {
    var t, r, n, a, i = this, o = !0, s = !0, u = !0, c = !1, l = !1;
    if (!this.isEditing) return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
    var d = this.plugin.managers.selection.structure.selection, f = [];
    if (d.forEach(function(y, _) {
      f.push(_), c = c || i.plugin.managers.cell.isFromPdb(_);
    }), f.length > 0) for (var m = 0, h = f.length; m < h; m++) {
      var p = f[m];
      d.has(p) && (o = !1);
    }
    if (f.length === 0 || f.length > 2) return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
    if (f.length === 2) (g = nt(nt([], (t = d.get(f[0])) !== null && t !== void 0 ? t : [], !0), (r = d.get(f[1])) !== null && r !== void 0 ? r : [], !0)).length === 2 && (s = !1, l = !0);
    else if (f.length === 1) {
      var g;
      if (((g = d.get(f[0])) == null ? void 0 : g.length) === 2) {
        s = !1;
        var v = this.plugin.cells.get(f[0]);
        !((n = v == null ? void 0 : v.model.structure) === null || n === void 0) && n.units.length && ((a = v == null ? void 0 : v.model.structure) === null || a === void 0 ? void 0 : a.units[0]).bonds.getEdgeIndex(g[0], g[1]) !== -1 && (u = !1);
      }
    }
    return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
  }, e.prototype.coverStructure = function(t, r, n) {
    return Be(this, 0, void 0, function() {
      var a, i, o, s = this;
      return Te(this, function(u) {
        switch (u.label) {
          case 0:
            return a = n.format, i = n.data, [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: r })];
          case 1:
            return (o = u.sent()).model.structure = r, this.plugin.managers.cell.update(t, { model: o.model, representations: Array.from(o.representations.values()), assets: [{ format: a, data: i }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(c, l) {
              l.type === qe.IntraInteractions && s.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.executeEdit = function(t, r, n, a) {
    var i, o, s;
    return Be(this, 0, void 0, function() {
      var u, c, l, d, f, m = this;
      return Te(this, function(h) {
        switch (h.label) {
          case 0:
            return u = this.plugin.cells.get(t), (c = (i = u == null ? void 0 : u.model) === null || i === void 0 ? void 0 : i.structure) ? [4, que(c, r, n, a)] : [2];
          case 1:
            return (l = h.sent()).length <= 0 ? [2] : [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: l[0] })];
          case 2:
            return (d = h.sent()).model.structure = l[0], f = ((s = (o = ps(l[0])) === null || o === void 0 ? void 0 : o.sourceData) === null || s === void 0 ? void 0 : s.kind) !== "mmCIF" ? xr.Sdf : xr.Pdb, this.plugin.managers.cell.update(t, { model: d.model, representations: Array.from(d.representations.values()), assets: [{ format: f, data: w3(l[0], f) }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(p, g) {
              g.type === qe.IntraInteractions && m.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.coverSourceData = function(t, r, n, a) {
    var i, o, s, u, c, l, d;
    return Be(this, 0, void 0, function() {
      var f, m, h, p, g, v, y, _, S, b, x, A = this;
      return Te(this, function(w) {
        switch (w.label) {
          case 0:
            return this.plugin.cells.has(t) ? (h = (m = ml[r]).parse, [4, Wf(n)]) : [2];
          case 1:
            return [4, h.apply(m, [w.sent()])];
          case 2:
            return f = w.sent(), a ? ((p = this.plugin.cells.get(t)) == null || p.representations.forEach(function(C) {
              var M;
              C.state && ((M = A.plugin.canvas3d) === null || M === void 0 || M.remove(C.state));
            }), this.plugin.managers.cell.update(t, { model: { structure: f[0] }, representations: [], assets: [{ format: r, data: n }] }), p.representations = /* @__PURE__ */ new Map(), [4, this.plugin.managers.representation.setMolecularRepr([{ ref: t, elementIds: ms(f[0]) }], a, !1)]) : [3, 4];
          case 3:
            return w.sent(), g = this.plugin.managers.selection.structure.getSelection(), v = (i = g[t]) !== null && i !== void 0 ? i : [], (y = (o = this.plugin.cells.get(t)) === null || o === void 0 ? void 0 : o.representations.get(a)) && (_ = ua(zo(y.state), v), (s = this.plugin.canvas3d) === null || s === void 0 || s.mark({ loci: _, repr: y.state }, Et.Select)), [2];
          case 4:
            return [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: f[0] })];
          case 5:
            return (S = w.sent()).model.structure = f[0], this.plugin.managers.cell.update(t, { model: S.model, representations: Array.from(S.representations.values()), assets: [{ format: r, data: n }] }), b = this.plugin.managers.selection.structure.getSelection(), x = (u = b[t]) !== null && u !== void 0 ? u : [], (c = this.plugin.cells.get(t)) === null || c === void 0 || c.representations.values(), Array.from((d = (l = this.plugin.cells.get(t)) === null || l === void 0 ? void 0 : l.representations.values()) !== null && d !== void 0 ? d : []).forEach(function(C) {
              var M, T = ua(zo(C.state), x);
              (M = A.plugin.canvas3d) === null || M === void 0 || M.mark({ loci: T, repr: C.state }, Et.Select);
            }), this.plugin.managers.cell.traverse(function(C, M) {
              M.type === qe.IntraInteractions && A.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.coverSourceData");
            }), [2];
        }
      });
    });
  }, e.prototype.edit = function(t, r) {
    return Be(this, 0, void 0, function() {
      var n, a, i, o = this;
      return Te(this, function(s) {
        switch (s.label) {
          case 0:
            return n = this.isLockCamera, this.isLockCamera = !0, a = r ?? this.plugin.managers.selection.structure.getSelectionCellItems(), [4, Promise.all(a.map(function(u) {
              var c = u.ref, l = u.elementIds;
              return t(c, l ?? []);
            }))];
          case 1:
            return s.sent(), i = this.plugin.managers.selection.structure.getSelection(), a.forEach(function(u) {
              var c, l, d = u.ref, f = o.plugin.cells.get(d), m = (c = i[d]) !== null && c !== void 0 ? c : [];
              Array.from((l = f == null ? void 0 : f.representations.values()) !== null && l !== void 0 ? l : []).forEach(function(h) {
                var p, g = ua(zo(h.state), m);
                (p = o.plugin.canvas3d) === null || p === void 0 || p.mark({ loci: g, repr: h.state }, Et.Select);
              });
            }), this.isLockCamera = n, [2];
        }
      });
    });
  }, e.prototype.deleteAtoms = function(t) {
    return Be(this, 0, void 0, function() {
      var r, n, a = this;
      return Te(this, function(i) {
        switch (i.label) {
          case 0:
            return r = {}, n = function(o, s) {
              return a.executeEdit(o, function(u, c) {
                var l = new Set(s), d = /* @__PURE__ */ new Map(), f = [];
                u.forEach(function(h) {
                  var p = l.has(h.elementId);
                  return p || (r[h.elementId] = f.length, f.push(k({}, h)), d.set(h.elementId + 1, f.length)), !p;
                });
                var m = c.filter(function(h) {
                  var p = l.has(h.a - 1) || l.has(h.b - 1);
                  return d.has(h.a) && (h.a = d.get(h.a)), d.has(h.b) && (h.b = d.get(h.b)), !p;
                });
                return { editedAtomList: f, editedBondList: m };
              }, function(u, c) {
                var l = new Set(s), d = [];
                u.forEach(function(m) {
                  l.has(m.elementId) || (r[m.elementId] = d.length, d.push(m));
                });
                var f = nt([], c, !0);
                return { editedAtomList: d, editedBondList: f, affectedAtomIds: [] };
              });
            }, [4, this.edit(n, t)];
          case 1:
            return i.sent(), [2, r];
        }
      });
    });
  }, e.prototype.editAtomCharge = function(t, r) {
    var n = this;
    return this.edit(function(a, i) {
      return n.executeEdit(a, function(o, s) {
        var u = new Set(i), c = nt([], o, !0), l = nt([], s, !0), d = [];
        return c.forEach(function(f) {
          if (u.has(f.elementId)) {
            var m = f.charge !== void 0 ? f.charge + t : t;
            m <= 3 && m >= -3 && (f.charge = m, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      }, function(o, s) {
        var u = new Set(i), c = nt([], o, !0), l = nt([], s, !0), d = [];
        return c.forEach(function(f) {
          if (u.has(f.elementId)) {
            var m = f.charge !== void 0 ? f.charge + t : t;
            m <= 3 && m >= -3 && (f.charge = m, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      });
    }, r);
  }, e.prototype.editAtomType = function(t, r) {
    var n = this, a = t ?? this.instance[Hs.Draw].state.elementType;
    return this.edit(function(i, o) {
      return n.executeEdit(i, function(s, u) {
        var c = new Set(o), l = nt([], s, !0), d = nt([], u, !0), f = [];
        return l.forEach(function(m) {
          c.has(m.elementId) && (m.auth_atom_id = a, m.type_symbol = a, f.push(parseInt(m.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      }, function(s, u) {
        var c = new Set(o), l = nt([], s, !0), d = nt([], u, !0), f = [];
        return l.forEach(function(m) {
          c.has(m.elementId) && (m.auth_atom_id = a, m.type_symbol = a, f.push(parseInt(m.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      });
    }, r);
  }, e.prototype.editBondOrder = function(t, r) {
    var n = this;
    return this.edit(function(a, i) {
      return n.executeEdit(a, function(o, s) {
        var u = nt([], o, !0), c = nt([], s, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a - 1 === i[0] && d.b - 1 === i[1] || d.a - 1 === i[1] && d.b - 1 === i[0]) {
            var f = d.order + t;
            OI.includes(f) && (d.order = f, l.add(d.a - 1), l.add(d.b - 1));
          }
        }), { editedAtomList: u, editedBondList: c, affectedAtomIds: Array.from(l) };
      }, function(o, s) {
        var u = nt([], o, !0), c = nt([], s, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a === i[0] && d.b === i[1] || d.a === i[1] && d.b === i[0]) {
            var f = d.order + t;
            OI.includes(f) && (d.order = f, l.add(d.atom_idA === void 0 ? d.a - 1 : parseInt(d.atom_idA, 10)), l.add(d.atom_idB === void 0 ? d.b - 1 : parseInt(d.atom_idB, 10)));
          }
        }), { editedAtomList: u, editedBondList: c, affectedAtomIds: Array.from(l) };
      });
    }, r);
  }, e.prototype.addOrDelBond = function(t, r) {
    var n, a = this;
    if (!r || r.length === 1 && ((n = r[0].elementIds) === null || n === void 0 ? void 0 : n.length) === 2) {
      if (!r) {
        var i = this.plugin.managers.selection.structure.selection;
        if (i.size !== 1 && Array.from(i.values())[0].length !== 2) return;
      }
      return this.edit(function(o, s) {
        return a.executeEdit(o, function(u, c) {
          var l = nt([], u, !0), d = nt([], c, !0), f = nt([], s, !0);
          return t ? d.filter(function(m) {
            return m.a - 1 === s[0] && m.b - 1 === s[1] || m.a - 1 === s[1] && m.b - 1 === s[0];
          }).length === 0 && d.push({ a: s[0] + 1, b: s[1] + 1, order: 1 }) : d = d.filter(function(m) {
            return !(m.a - 1 === s[0] && m.b - 1 === s[1] || m.a - 1 === s[1] && m.b - 1 === s[0]);
          }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
        }, function(u, c) {
          var l, d = nt([], u, !0), f = nt([], c, !0), m = [];
          if (t) {
            if (f.filter(function(y) {
              return y.a === s[0] && y.b === s[1] || y.a === s[1] && y.b === s[0];
            }).length === 0) {
              var h = (l = a.plugin.cells.get(o)) === null || l === void 0 ? void 0 : l.model.structure;
              if (h && h.units.length > 0) {
                var p = h.units[0], g = p.model.atomicConformation.atomId.value(s[0]), v = p.model.atomicConformation.atomId.value(s[1]);
                f.push({ a: s[0], b: s[1], order: 1, atom_idA: "".concat(g), atom_idB: "".concat(v) }), m.push(g, v);
              }
            }
          } else f = f.filter(function(y) {
            return !(y.a === s[0] && y.b === s[1] || y.a === s[1] && y.b === s[0]) || (m.push(y.atom_idA === void 0 ? y.a - 1 : parseInt(y.atom_idA, 10), y.atom_idB === void 0 ? y.b - 1 : parseInt(y.atom_idB, 10)), !1);
          });
          return { editedAtomList: d, editedBondList: f, affectedAtomIds: m };
        });
      }, r);
    }
  }, e.prototype.changeEditorMode = function(t) {
    var r = this.instance[this.state.mode];
    this.isLockCamera = !1, this.disabledInteraction = [], r && r.end();
    var n = this.instance[t];
    n && (this.isEditing = !0, this.isLockCamera = !0, n.start()), this.setState({ mode: t });
  }, e.prototype.start = function() {
    var t = this;
    this.plugin.managers.selection.event.changed.subscribe(function() {
      t.setState(t.getEditState());
    });
  }, e;
}(), RI = function() {
  function e(t) {
    this.ev = xo.create(), this.info = this.ev(), this.handleHighlightLocis = [], this.plugin = t;
  }
  return e.prototype.setHoverSelection = function(t, r) {
    var n, a, i, o = this;
    if (r === void 0 && (r = !0), this.hoverLoci && ((n = this.plugin.canvas3d) === null || n === void 0 || n.mark(this.hoverLoci, Et.RemoveHighlight)), !((a = this.handleHighlightLocis) === null || a === void 0) && a.length && this.handleHighlightLocis.forEach(function(u) {
      var c;
      (c = o.plugin.canvas3d) === null || c === void 0 || c.mark(u, Et.RemoveHighlight);
    }), t) {
      var s = { loci: an.normalize(t.loci, this.plugin.managers.selection.structure.lociGranularity), repr: t.repr };
      (i = this.plugin.canvas3d) === null || i === void 0 || i.mark(s, Et.Highlight), this.hoverLoci = s, r && this.info.next({ loci: s, info: this.createHighlightInfo(s) });
    } else this.info.next({});
  }, e.prototype.addHighlightLocis = function(t, r) {
    var n, a = this;
    r === void 0 && (r = !0), r && (this.handleHighlightLocis.forEach(function(i) {
      var o;
      (o = a.plugin.canvas3d) === null || o === void 0 || o.mark(i, Et.RemoveHighlight);
    }), this.handleHighlightLocis = []), t.forEach(function(i) {
      var o;
      (o = a.plugin.canvas3d) === null || o === void 0 || o.mark(i, Et.Highlight);
    }), (n = this.handleHighlightLocis).push.apply(n, t);
  }, e.prototype.createHighlightInfo = function(t) {
    if (t.loci.kind === "element-loci") {
      var r = "";
      if (Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], v = p[1];
        return !(r || !dn(v) || wu(dn(v)) !== wu(t.loci.structure)) && (r = g, !0);
      }), !r) return;
      var n, a = this.plugin.cells.get(r), i = "";
      if (Object.entries(On).forEach(function(p) {
        var g = p[0];
        p[1].includes(NL[t.repr.label]) && (n = g);
      }), n && a.theme.color && a.theme.color[n]) {
        var o = a.theme.color[n], s = Ya(t.loci);
        o.forEach(function(p) {
          var g = new Set(p.elementIds);
          s.filter(function(v) {
            return !g.has(v);
          }).length === 0 && (i = p.name);
        });
      }
      return m = k({ type: eh.Structure, ref: r, colorThemeName: i }, ose(t.loci, this.plugin.managers.selection.structure.granularity));
    }
    if (t.loci.kind === "data-loci" && t.loci.tag === "interactions") {
      var u = "", c = "", l = t.loci.elements[0], d = l.unitA, f = l.unitB;
      Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], v = p[1];
        if (u && c) return !0;
        if (v.model.structure) {
          var y = wu(v.model.structure);
          y === d.model.id && (u = g), y === f.model.id && (c = g);
        }
        return !1;
      });
      var m = k({ type: eh.Interaction }, sse(t.loci));
      return Object.assign(m.infoA, { ref: u }), Object.assign(m.infoB, { ref: c }), m;
    }
    if (t.loci.kind === "group-loci") return {};
    if (t.loci.kind === "bond-loci") {
      var h = "";
      return Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], v = p[1];
        return !(h || !v.model.structure || wu(v.model.structure) !== wu(t.loci.structure)) && (h = g, !0);
      }), m = { infoA: mc(t.loci.bonds[0].aUnit, t.loci.bonds[0].aUnit.elements[t.loci.bonds[0].aIndex]), infoB: mc(t.loci.bonds[0].bUnit, t.loci.bonds[0].bUnit.elements[t.loci.bonds[0].bIndex]), ref: h, type: eh.Bond };
    }
  }, e.prototype.clear = function() {
    this.hoverLoci = void 0;
  }, e;
}(), $me = [["viewport", "Viewport"], ["hd", "HD (1280 * 720 pixels)"], ["full-hd", "Full HD (1920 x 1080 pixels)"], ["ultra-hd", "Ultra HD (3840 x 2160 pixels)"], ["custom", "Custom"]], LI = function() {
  function e(t) {
    this.plugin = t, this.ev = xo.create(), this._params = void 0, this.behaviors = { values: this.ev.behavior({ transparent: this.params.transparent.defaultValue, axes: { name: "off", params: {} }, resolution: this.params.resolution.defaultValue }), cropParams: this.ev.behavior({ auto: !1, relativePadding: 0.1 }), relativeCrop: this.ev.behavior({ x: 0, y: 0, width: 1, height: 1 }) }, this.events = { previewed: this.ev() }, this._previewPass = void 0, this._imagePass = void 0, this.canvas = document.createElement("canvas"), this.previewCanvas = document.createElement("canvas"), this.previewData = { image: { data: new Uint8ClampedArray(1), width: 1, height: 0 }, background: Qe(0), transparent: !1 };
  }
  return e.prototype.createParams = function() {
    var t = Math.min(this.plugin.canvas3d ? this.plugin.canvas3d.webgl.maxRenderbufferSize : 4096, 4096);
    return { resolution: V.MappedStatic("ultra-hd", { viewport: V.Group({}), hd: V.Group({}), "full-hd": V.Group({}), "ultra-hd": V.Group({}), custom: V.Group({ width: V.Numeric(1920, { min: 128, max: t, step: 1 }), height: V.Numeric(1080, { min: 128, max: t, step: 1 }) }, { isFlat: !0 }) }, { options: $me }), transparent: V.Boolean(!1), axes: S3.axes };
  }, Object.defineProperty(e.prototype, "params", { get: function() {
    return this._params ? this._params : this._params = this.createParams();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "values", { get: function() {
    return this.behaviors.values.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cropParams", { get: function() {
    return this.behaviors.cropParams.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "relativeCrop", { get: function() {
    return this.behaviors.relativeCrop.value;
  }, enumerable: !1, configurable: !0 }), e.prototype.getCanvasSize = function() {
    var t, r;
    return { width: ((t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.webgl.gl.drawingBufferWidth) || 0, height: ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.webgl.gl.drawingBufferHeight) || 0 };
  }, e.prototype.getSize = function() {
    var t = this.values;
    switch (t.resolution.name) {
      case "viewport":
        return this.getCanvasSize();
      case "hd":
        return { width: 1280, height: 720 };
      case "full-hd":
        return { width: 1920, height: 1080 };
      case "ultra-hd":
        return { width: 3840, height: 2160 };
      default:
        return { width: t.resolution.params.width, height: t.resolution.params.height };
    }
  }, e.prototype.createPass = function(t) {
    var r = this.plugin.canvas3d, n = r.webgl.extensions, a = n.colorBufferFloat, i = n.textureFloat, o = r.props.postprocessing.occlusion;
    return r.getImagePass({ transparentBackground: this.values.transparent, cameraHelper: { axes: this.values.axes }, multiSample: { mode: t ? "on" : "off", sampleLevel: a && i ? 4 : 2 }, postprocessing: k(k({}, r.props.postprocessing), { occlusion: o.name === "on" ? { name: "on", params: k(k({}, o.params), { samples: 128, resolutionScale: 1 }) } : o }), marking: k({}, r.props.marking) });
  }, Object.defineProperty(e.prototype, "previewPass", { get: function() {
    return this._previewPass || (this._previewPass = this.createPass(!1));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "imagePass", { get: function() {
    if (this._imagePass) {
      var t = this.plugin.canvas3d, r = t.props.postprocessing.occlusion;
      return this._imagePass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: k(k({}, t.props.postprocessing), { occlusion: r.name === "on" ? { name: "on", params: k(k({}, r.params), { samples: 128, resolutionScale: 1 }) } : r }), marking: k({}, t.props.marking) }), this._imagePass;
    }
    return this._imagePass = this.createPass(!0);
  }, enumerable: !1, configurable: !0 }), e.prototype.resetCrop = function() {
    this.behaviors.relativeCrop.next({ x: 0, y: 0, width: 1, height: 1 });
  }, e.prototype.toggleAutocrop = function() {
    this.cropParams.auto ? (this.behaviors.cropParams.next(k(k({}, this.cropParams), { auto: !1 })), this.resetCrop()) : this.behaviors.cropParams.next(k(k({}, this.cropParams), { auto: !0 }));
  }, Object.defineProperty(e.prototype, "isFullFrame", { get: function() {
    var t = this.relativeCrop;
    return Yn(t.x, 0, 1e-5) && Yn(t.y, 0, 1e-5) && Yn(t.width, 1, 1e-5) && Yn(t.height, 1, 1e-5);
  }, enumerable: !1, configurable: !0 }), e.prototype.autocrop = function(t) {
    t === void 0 && (t = this.cropParams.relativePadding);
    for (var r = this.previewData.image, n = r.data, a = r.width, i = r.height, o = this.previewData.transparent, s = o ? this.previewData.background : 4278190080 | this.previewData.background, u = a, c = 0, l = i, d = 0, f = 0; f < i; f++) for (var m = f * a, h = 0; h < a; h++) {
      var p = 4 * (m + h);
      if (o) {
        if (n[p + 3] === 0) continue;
      } else if ((n[p] << 16 | n[p + 1] << 8 | n[p + 2] | n[p + 3] << 24) === s) continue;
      h < u && (u = h), h > c && (c = h), f < l && (l = f), f > d && (d = f);
    }
    if (u > c) {
      var g = u;
      u = c, c = g;
    }
    l > d && (g = l, l = d, d = g);
    var v = c - u + 1, y = d - l + 1;
    u -= t * v, c += t * v, l -= t * y, d += t * y;
    var _ = { x: Math.max(0, u / a), y: Math.max(0, l / i), width: Math.min(1, (c - u + 1) / a), height: Math.min(1, (d - l + 1) / i) };
    this.behaviors.relativeCrop.next(_);
  }, e.prototype.getPreview = function(t) {
    t === void 0 && (t = 320);
    var r = this.getSize(), n = r.width, a = r.height;
    if (!(n <= 0 || a <= 0)) {
      var i = n / a, o = 0, s = 0;
      i > 1 ? (o = t, s = Math.round(t / i)) : (s = t, o = Math.round(t * i));
      var u = this.plugin.canvas3d.props;
      this.previewPass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: u.postprocessing, marking: u.marking });
      var c = this.previewPass.getImageData(o, s), l = this.previewCanvas;
      l.width = c.width, l.height = c.height, this.previewData.image = c, this.previewData.background = u.renderer.backgroundColor, this.previewData.transparent = this.values.transparent;
      var d = l.getContext("2d");
      if (!d) throw new Error("Could not create canvas 2d context");
      return d.putImageData(c, 0, 0), this.cropParams.auto && this.autocrop(), this.events.previewed.next(void 0), { canvas: l, width: o, height: s };
    }
  }, e.prototype.getSizeAndViewport = function() {
    var t = this.getSize(), r = t.width, n = t.height, a = this.relativeCrop, i = { x: Math.floor(a.x * r), y: Math.floor(a.y * n), width: Math.ceil(a.width * r), height: Math.ceil(a.height * n) };
    return i.width + i.x > r && (i.width = r - i.x), i.height + i.y > n && (i.height = n - i.y), { width: r, height: n, viewport: i };
  }, e.prototype.draw = function() {
    return Be(this, 0, void 0, function() {
      var t, r, n, a, i, o, s;
      return Te(this, function(u) {
        if (t = this.getSizeAndViewport(), r = t.width, n = t.height, a = t.viewport, r <= 0 || n <= 0) return [2];
        if (i = this.imagePass.getImageData(r, n, a), (o = this.canvas).width = i.width, o.height = i.height, !(s = o.getContext("2d"))) throw new Error("Could not create canvas 2d context");
        return s.putImageData(i, 0, 0), [2];
      });
    });
  }, e.prototype.getImageDataUri = function() {
    return Be(this, 0, void 0, function() {
      return Te(this, function(t) {
        switch (t.label) {
          case 0:
            return [4, this.draw()];
          case 1:
            return t.sent(), [2, this.canvas.toDataURL("png")];
        }
      });
    });
  }, e.prototype.copyToClipboard = function() {
    return Be(this, 0, void 0, function() {
      var t, r, n;
      return Te(this, function(a) {
        switch (a.label) {
          case 0:
            return (t = navigator.clipboard) != null && t.write ? [4, this.draw()] : [2];
          case 1:
            return a.sent(), [4, JD(this.canvas, "png")];
          case 2:
            return r = a.sent(), n = new ClipboardItem({ "image/png": r }), [4, t.write([n])];
          case 3:
            return a.sent(), [2];
        }
      });
    });
  }, e.prototype.getAxesScale = function() {
    var t = this.getSize(), r = t.width * t.height;
    switch (!0) {
      case r <= 921600:
        return 0.22;
      case r <= 2073600:
        return 0.33;
      case r <= 8294400:
        return 0.5;
      default:
        return 0.65;
    }
  }, e.prototype.download = function(t) {
    return Be(this, 0, void 0, function() {
      return Te(this, function(r) {
        switch (r.label) {
          case 0:
            return this.behaviors.values.next({ transparent: this.values.transparent, axes: k(k({}, this.values.axes), { params: k(k(k({}, this.params.axes.defaultValue), this.values.axes.params), { scale: this.getAxesScale() }) }), resolution: this.values.resolution }), [4, this.draw()];
          case 1:
            return r.sent(), this.behaviors.cropParams.next(k(k({}, this.cropParams), { auto: !1 })), this.resetCrop(), [4, JD(this.canvas, "png")];
          case 2:
            return jz(r.sent(), t), this.behaviors.values.next({ transparent: this.values.transparent, axes: k(k({}, this.values.axes), { params: k(k(k({}, this.params.axes.defaultValue), this.values.axes.params), { scale: 0.11 }) }), resolution: this.values.resolution }), [2];
        }
      });
    });
  }, e;
}(), Jme = V.getDefaultValues(Sy), Yz = function() {
  function e() {
    this.mode = Gf.Drug, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new xI(this), representation: new DI(this), cell: new MI(this), trajectory: new II(this), snapshot: new NI(this), selection: new PI(this), events: new BI(this), highlight: new RI(this), editor: new FI(this), screenshot: new LI(this) };
  }
  var t;
  return e.prototype.createCanvas = function(r, n) {
    var a = document.createElement("canvas");
    r.appendChild(a), $D(a, r), this.layout = { root: r, canvas: a }, this.canvas3d = $6.create(Q6.fromCanvas(a), V.merge(Sy, V.getDefaultValues(Sy), k({ camera: { mode: "orthographic", helper: { axes: { name: "on", params: {} } }, stereo: { name: "off", params: {} }, fov: 90, manualReset: !1 }, cameraResetDurationMs: 0, cameraFog: { name: "on", params: { intensity: 50 } }, renderer: k(k({}, Jme.renderer), { backgroundColor: Qe(15922682) }), postprocessing: { occlusion: { name: "off", params: {} }, outline: { name: "off", params: {} }, antialiasing: { name: "fxaa", params: { edgeThresholdMin: 0.0312, edgeThresholdMax: 0.063, iterations: 12, subpixelQuality: 0.3 } }, background: { variant: { name: "off", params: {} } }, shadow: { name: "off", params: {} } }, helper: { handle: { handle: { name: "off" } } }, transparentBackground: !1 }, n))), this.canvas3d.animate(), this.managers.representation.createContext(), this.managers.events.subscribe(), this.managers.editor.start();
  }, e.prototype.focus = function(r, n) {
    return Be(this, 0, void 0, function() {
      var a, i, o, s, u = this;
      return Te(this, function(c) {
        switch (c.label) {
          case 0:
            return a = [], i = new Set(r.map(function(l) {
              var d, f, m;
              return a.push.apply(a, (m = (f = (d = u.cells.get(l.ref)) === null || d === void 0 ? void 0 : d.dependency) === null || f === void 0 ? void 0 : f.by) !== null && m !== void 0 ? m : []), l.ref;
            })), o = new Set(a), s = Array.from(this.cells).map(function(l) {
              return { ref: l[0] };
            }).filter(function(l) {
              return !i.has(l.ref) && !o.has(l.ref);
            }), this.hide(s, !0), [4, this.show(r, n)];
          case 1:
            return c.sent(), [2, s];
        }
      });
    });
  }, e.prototype.show = function(r, n) {
    var a;
    return Be(this, 0, void 0, function() {
      var i, o, s, u, c, l = this;
      return Te(this, function(d) {
        switch (d.label) {
          case 0:
            i = function(f) {
              var m, h, p, g, v, y, _, S;
              return Te(this, function(b) {
                switch (b.label) {
                  case 0:
                    return o.managers.cell.idleCellSet.delete(f.ref), m = o.managers.cell.get(f.ref), [4, o.managers.cell.getStructure(f.ref)];
                  case 1:
                    if (b.sent(), !m || !f.representationType && Array.from(m.representations.values()).some(function(x) {
                      return !x.isHidden;
                    })) return [2, "continue"];
                    h = 0, p = Array.from(m.representations), b.label = 2;
                  case 2:
                    return h < p.length ? (g = p[h], v = g[0], (y = g[1]).state ? (!y.isHidden || f.representationType && f.representationType !== v || ((a = o.canvas3d) === null || a === void 0 || a.add(y.state), m.representations.set(v, k(k({}, y), { isHidden: !1 }))), [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return y.cache ? [4, cd.managers.cell.recoveryReprCache(m, k(k({}, y.cache), { isHidden: !1 }))] : [3, 5];
                  case 4:
                    b.sent(), b.label = 5;
                  case 5:
                    return h++, [3, 2];
                  case 6:
                    return m.dependency.by.length && (_ = [], S = m.dependency.by.filter(function(x) {
                      var A = l.cells.has(x);
                      if (A) {
                        if (l.cells.get(x).dependency.on.some(function(w) {
                          var C, M;
                          return Array.from((M = (C = l.cells.get(w.ref)) === null || C === void 0 ? void 0 : C.representations.values()) !== null && M !== void 0 ? M : []).filter(function(T) {
                            return T.isHidden !== !0;
                          }).length === 0;
                        })) return !1;
                      } else _.push(x);
                      return A;
                    }), o.show(S.map(function(x) {
                      return { ref: x };
                    }), !0), _.length && o.managers.cell.update(f.ref, { model: {}, dependency: { by: S } })), [2];
                }
              });
            }, o = this, s = 0, u = r, d.label = 1;
          case 1:
            return s < u.length ? (c = u[s], [5, i(c)]) : [3, 4];
          case 2:
            d.sent(), d.label = 3;
          case 3:
            return s++, [3, 1];
          case 4:
            return n || this.managers.cell.traverse(function(f, m) {
              m.type === qe.IntraInteractions && l.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
            }), this.managers.snapshot.event.changed.next({ from: "show" }), [2];
        }
      });
    });
  }, e.prototype.hide = function(r, n) {
    var a = this;
    r.forEach(function(i) {
      a.managers.cell.idleCellSet.add(i.ref);
      var o = a.cells.get(i.ref);
      if (o && (a.managers.selection.shape.selection.has(i.ref) && a.managers.selection.shape.remove({ item: i }), a.managers.selection.structure.selection.has(i.ref) && a.managers.selection.structure.remove({ item: { ref: i.ref, elementIds: ms(dn(o)) } }), o.representations.forEach(function(c, l) {
        var d;
        c.isHidden || i.representationType && i.representationType !== l || (c.state && ((d = a.canvas3d) === null || d === void 0 || d.remove(c.state)), o.representations.set(l, k(k(k({}, c), { isHidden: !0 }), c.cache ? { cache: k(k({}, c.cache), { isHidden: !0 }) } : {})));
      }), o.dependency.by.length)) {
        var s = [], u = o.dependency.by.filter(function(c) {
          var l = a.cells.has(c);
          l || s.push(c);
          var d = a.cells.get(c);
          return !(d != null && d.representations.has(qe.IntraInteractions)) && l;
        });
        a.hide(u.map(function(c) {
          return { ref: c };
        }), !0), s.length && a.managers.cell.update(i.ref, { model: {}, dependency: { by: u } });
      }
    }), n || this.managers.cell.traverse(function(i, o) {
      o.type === qe.IntraInteractions && a.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
    }), this.managers.snapshot.event.changed.next({ from: "hide" });
  }, e.prototype.toggle = function(r) {
    var n = this, a = r.types, i = r.forceAction, o = r.refs, s = Array.from(this.cells).filter(function(l) {
      var d = l[0], f = l[1], m = (!o || o.includes(d)) && a.some(function(h) {
        return f.representations.get(h);
      });
      return !!m && !!f.dependency.on.every(function(h) {
        var p = n.cells.get(h.ref);
        return !!p && !Array.from(p.representations.values()).every(function(g) {
          return g.isHidden === !0;
        });
      });
    });
    if (s.length) {
      var u = i ?? s.some(function(l) {
        l[0];
        var d = l[1];
        return a.some(function(f) {
          var m;
          return (m = d.representations.get(f)) === null || m === void 0 ? void 0 : m.isHidden;
        });
      }) ? "show" : "hide", c = TL(s.map(function(l) {
        var d = l[0], f = l[1];
        return Array.from(f.representations).filter(function(m) {
          var h = m[0];
          return a.includes(h);
        }).map(function(m) {
          return { representationType: m[0], ref: d };
        });
      }));
      this[u](c);
    }
  }, e.prototype.refresh = function(r) {
    var n, a, i, o, s;
    this.canvas3d && (!((a = (n = this.layout) === null || n === void 0 ? void 0 : n.root.children[0]) === null || a === void 0) && a.clientWidth) && (r != null && r.fixCamera && (s = this.canvas3d.camera.getSnapshot()), $D(this.layout.canvas, this.layout.root), (i = this.canvas3d) === null || i === void 0 || i.handleResize(), r != null && r.fixCamera ? (o = this.canvas3d) === null || o === void 0 || o.camera.setState(s) : this.managers.camera.focus());
  }, e.prototype.clear = function() {
    var r;
    this.managers.selection.clear(), this.managers.highlight.clear(), this.managers.editor.changeEditorMode(Hs.None), this.cells = /* @__PURE__ */ new Map(), (r = this.canvas3d) === null || r === void 0 || r.clear();
  }, e.prototype.dispose = function() {
    var r;
    (r = this.canvas3d) === null || r === void 0 || r.dispose(), this.layout = void 0, this.canvas3d = void 0, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new xI(this), representation: new DI(this), cell: new MI(this), trajectory: new II(this), snapshot: new NI(this), selection: new PI(this), events: new BI(this), highlight: new RI(this), editor: new FI(this), screenshot: new LI(this) };
  }, t = e, e.Utils = { sliceCellItems: function(r, n) {
    return Hue(cd, r, n);
  }, queryCellItems: function(r) {
    return $L(cd, r);
  }, exportToPdb: function(r) {
    return Be(void 0, 0, void 0, function() {
      return Te(t, function(n) {
        switch (n.label) {
          case 0:
            return [4, cd.managers.cell.getStructure(r.ref)];
          case 1:
            return [2, aS(n.sent(), r.elementIds, !1)];
        }
      });
    });
  }, getBox: function(r) {
    return Be(void 0, 0, void 0, function() {
      var n, a;
      return Te(t, function(i) {
        switch (i.label) {
          case 0:
            return [4, cd.managers.cell.getStructure(r.ref)];
          case 1:
            return n = i.sent(), [2, rme(n, (a = r.elementIds) !== null && a !== void 0 ? a : [])];
        }
      });
    });
  }, splitMolecularContent: function(r, n) {
    return $se(r, n);
  }, checkMolecularContentVerify: function(r, n) {
    return tue(r, n);
  }, getMergedContent: function(r) {
    return Kue(cd, r);
  }, traverseAtoms: function(r, n) {
    return Be(void 0, 0, void 0, function() {
      var a;
      return Te(t, function(i) {
        switch (i.label) {
          case 0:
            return [4, cd.managers.cell.getStructure(r)];
          case 1:
            return (a = i.sent()) ? (QL(a, n), [2]) : [2];
        }
      });
    });
  } }, e;
}(), cd = new Yz();
function Ei() {
  return Ei = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var n in r) ({}).hasOwnProperty.call(r, n) && (e[n] = r[n]);
    }
    return e;
  }, Ei.apply(null, arguments);
}
var R3 = {
  // minimum relative difference between two compared values,
  // used by all comparison functions
  relTol: 1e-12,
  // minimum absolute difference between two compared values,
  // used by all comparison functions
  absTol: 1e-15,
  // type of default matrix output. Choose 'matrix' (default) or 'array'
  matrix: "Matrix",
  // type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'
  number: "number",
  // type of fallback used for config { number: 'bigint' } when a value cannot be represented
  // in the configured numeric type. Choose 'number' (default) or 'BigNumber'.
  numberFallback: "number",
  // number of significant digits in BigNumbers
  precision: 64,
  // predictable output type of functions. When true, output type depends only
  // on the input types. When false (default), output type can vary depending
  // on input values. For example `math.sqrt(-4)` returns `complex('2i')` when
  // predictable is false, and returns `NaN` when true.
  predictable: !1,
  // random seed for seeded pseudo random number generation
  // null = randomly seed
  randomSeed: null
};
function _r(e) {
  return typeof e == "number";
}
function hr(e) {
  return !e || typeof e != "object" || typeof e.constructor != "function" ? !1 : e.isBigNumber === !0 && typeof e.constructor.prototype == "object" && e.constructor.prototype.isBigNumber === !0 || typeof e.constructor.isDecimal == "function" && e.constructor.isDecimal(e) === !0;
}
function Wz(e) {
  return typeof e == "bigint";
}
function Mu(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isComplex === !0 || !1;
}
function vm(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isFraction === !0 || !1;
}
function Lo(e) {
  return e && e.constructor.prototype.isUnit === !0 || !1;
}
function Di(e) {
  return typeof e == "string";
}
var en = Array.isArray;
function Zt(e) {
  return e && e.constructor.prototype.isMatrix === !0 || !1;
}
function bs(e) {
  return Array.isArray(e) || Zt(e);
}
function Ch(e) {
  return e && e.isDenseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function Td(e) {
  return e && e.isSparseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function L3(e) {
  return e && e.constructor.prototype.isRange === !0 || !1;
}
function qh(e) {
  return e && e.constructor.prototype.isIndex === !0 || !1;
}
function Zz(e) {
  return typeof e == "boolean";
}
function Qz(e) {
  return e && e.constructor.prototype.isResultSet === !0 || !1;
}
function SS(e) {
  return e && e.constructor.prototype.isHelp === !0 || !1;
}
function $z(e) {
  return typeof e == "function";
}
function Jz(e) {
  return e instanceof Date;
}
function eU(e) {
  return e instanceof RegExp;
}
function Hh(e) {
  return !!(e && typeof e == "object" && e.constructor === Object && !Mu(e) && !vm(e));
}
function tU(e) {
  return e === null;
}
function rU(e) {
  return e === void 0;
}
function Xd(e) {
  return e && e.isAccessorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function cs(e) {
  return e && e.isArrayNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function nU(e) {
  return e && e.isAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function aU(e) {
  return e && e.isBlockNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function iU(e) {
  return e && e.isConditionalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Vr(e) {
  return e && e.isConstantNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function k_(e) {
  return Vr(e) || Da(e) && e.args.length === 1 && Vr(e.args[0]) && "-+~".includes(e.op);
}
function x1(e) {
  return e && e.isFunctionAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function vl(e) {
  return e && e.isFunctionNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function gm(e) {
  return e && e.isIndexNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function gn(e) {
  return e && e.isNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Kh(e) {
  return e && e.isObjectNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Da(e) {
  return e && e.isOperatorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function pc(e) {
  return e && e.isParenthesisNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function oU(e) {
  return e && e.isRangeNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function sU(e) {
  return e && e.isRelationalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Wa(e) {
  return e && e.isSymbolNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function AS(e) {
  return e && e.constructor.prototype.isChain === !0 || !1;
}
function Nn(e) {
  var t = typeof e;
  return t === "object" ? e === null ? "null" : hr(e) ? "BigNumber" : e.constructor && e.constructor.name ? e.constructor.name : "Object" : t;
}
function Jt(e) {
  var t = typeof e;
  if (t === "number" || t === "bigint" || t === "string" || t === "boolean" || e === null || e === void 0)
    return e;
  if (typeof e.clone == "function")
    return e.clone();
  if (Array.isArray(e))
    return e.map(function(r) {
      return Jt(r);
    });
  if (e instanceof Date) return new Date(e.valueOf());
  if (hr(e)) return e;
  if (Hh(e))
    return epe(e, Jt);
  throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e, ")"));
}
function epe(e, t) {
  var r = {};
  for (var n in e)
    Tt(e, n) && (r[n] = t(e[n]));
  return r;
}
function uU(e, t) {
  for (var r in t)
    Tt(t, r) && (e[r] = t[r]);
  return e;
}
function cU(e, t) {
  if (Array.isArray(t))
    throw new TypeError("Arrays are not supported by deepExtend");
  for (var r in t)
    if (Tt(t, r) && !(r in Object.prototype) && !(r in Function.prototype))
      if (t[r] && t[r].constructor === Object)
        e[r] === void 0 && (e[r] = {}), e[r] && e[r].constructor === Object ? cU(e[r], t[r]) : e[r] = t[r];
      else {
        if (Array.isArray(t[r]))
          throw new TypeError("Arrays are not supported by deepExtend");
        e[r] = t[r];
      }
  return e;
}
function gl(e, t) {
  var r, n, a;
  if (Array.isArray(e)) {
    if (!Array.isArray(t) || e.length !== t.length)
      return !1;
    for (n = 0, a = e.length; n < a; n++)
      if (!gl(e[n], t[n]))
        return !1;
    return !0;
  } else {
    if (typeof e == "function")
      return e === t;
    if (e instanceof Object) {
      if (Array.isArray(t) || !(t instanceof Object))
        return !1;
      for (r in e)
        if (!(r in t) || !gl(e[r], t[r]))
          return !1;
      for (r in t)
        if (!(r in e))
          return !1;
      return !0;
    } else
      return e === t;
  }
}
function tpe(e) {
  var t = {};
  return lU(e, t), t;
}
function lU(e, t) {
  for (var r in e)
    if (Tt(e, r)) {
      var n = e[r];
      typeof n == "object" && n !== null ? lU(n, t) : t[r] = n;
    }
}
function O2(e, t, r) {
  var n = !0, a;
  Object.defineProperty(e, t, {
    get: function() {
      return n && (a = r(), n = !1), a;
    },
    set: function(o) {
      a = o, n = !1;
    },
    configurable: !0,
    enumerable: !0
  });
}
function Tt(e, t) {
  return e && Object.hasOwnProperty.call(e, t);
}
function rpe(e) {
  return e && typeof e.factory == "function";
}
function npe(e, t) {
  for (var r = {}, n = 0; n < t.length; n++) {
    var a = t[n], i = e[a];
    i !== void 0 && (r[a] = i);
  }
  return r;
}
var z_ = ["Matrix", "Array"], U_ = ["number", "BigNumber", "Fraction"];
function ape(e, t) {
  function r(n) {
    if (n) {
      if (n.epsilon !== void 0) {
        console.warn('Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.');
        var a = Jt(n);
        return a.relTol = n.epsilon, a.absTol = n.epsilon * 1e-3, delete a.epsilon, r(a);
      }
      var i = Jt(e);
      kI(n, "matrix", z_), kI(n, "number", U_), cU(e, n);
      var o = Jt(e), s = Jt(n);
      return t("config", o, i, s), o;
    } else
      return Jt(e);
  }
  return r.MATRIX_OPTIONS = z_, r.NUMBER_OPTIONS = U_, Object.keys(R3).forEach((n) => {
    Object.defineProperty(r, n, {
      get: () => e[n],
      enumerable: !0,
      configurable: !0
    });
  }), r;
}
function kI(e, t, r) {
  e[t] !== void 0 && !r.includes(e[t]) && console.warn('Warning: Unknown value "' + e[t] + '" for configuration option "' + t + '". Available options: ' + r.map((n) => JSON.stringify(n)).join(", ") + ".");
}
var gi = function(t) {
  if (t)
    throw new Error(`The global config is readonly. 
Please create a mathjs instance if you want to change the default configuration. 
Example:

  import { create, all } from 'mathjs';
  const mathjs = create(all);
  mathjs.config({ number: 'BigNumber' });
`);
  return Object.freeze(R3);
};
Ei(gi, R3, {
  MATRIX_OPTIONS: z_,
  NUMBER_OPTIONS: U_
});
function zI() {
  return !0;
}
function Us() {
  return !1;
}
function mp() {
}
const UI = "Argument is not a typed-function.";
function dU() {
  function e(J) {
    return typeof J == "object" && J !== null && J.constructor === Object;
  }
  const t = [{
    name: "number",
    test: function(J) {
      return typeof J == "number";
    }
  }, {
    name: "string",
    test: function(J) {
      return typeof J == "string";
    }
  }, {
    name: "boolean",
    test: function(J) {
      return typeof J == "boolean";
    }
  }, {
    name: "Function",
    test: function(J) {
      return typeof J == "function";
    }
  }, {
    name: "Array",
    test: Array.isArray
  }, {
    name: "Date",
    test: function(J) {
      return J instanceof Date;
    }
  }, {
    name: "RegExp",
    test: function(J) {
      return J instanceof RegExp;
    }
  }, {
    name: "Object",
    test: e
  }, {
    name: "null",
    test: function(J) {
      return J === null;
    }
  }, {
    name: "undefined",
    test: function(J) {
      return J === void 0;
    }
  }], r = {
    name: "any",
    test: zI,
    isAny: !0
  };
  let n, a, i = 0, o = {
    createCount: 0
  };
  function s(J) {
    const Z = n.get(J);
    if (Z)
      return Z;
    let de = 'Unknown type "' + J + '"';
    const ye = J.toLowerCase();
    let Ae;
    for (Ae of a)
      if (Ae.toLowerCase() === ye) {
        de += '. Did you mean "' + Ae + '" ?';
        break;
      }
    throw new TypeError(de);
  }
  function u(J) {
    let Z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "any";
    const de = Z ? s(Z).index : a.length, ye = [];
    for (let Ce = 0; Ce < J.length; ++Ce) {
      if (!J[Ce] || typeof J[Ce].name != "string" || typeof J[Ce].test != "function")
        throw new TypeError("Object with properties {name: string, test: function} expected");
      const Ie = J[Ce].name;
      if (n.has(Ie))
        throw new TypeError('Duplicate type name "' + Ie + '"');
      ye.push(Ie), n.set(Ie, {
        name: Ie,
        test: J[Ce].test,
        isAny: J[Ce].isAny,
        index: de + Ce,
        conversionsTo: []
        // Newly added type can't have any conversions to it
      });
    }
    const Ae = a.slice(de);
    a = a.slice(0, de).concat(ye).concat(Ae);
    for (let Ce = de + ye.length; Ce < a.length; ++Ce)
      n.get(a[Ce]).index = Ce;
  }
  function c() {
    n = /* @__PURE__ */ new Map(), a = [], i = 0, u([r], !1);
  }
  c(), u(t);
  function l() {
    let J;
    for (J of a)
      n.get(J).conversionsTo = [];
    i = 0;
  }
  function d(J) {
    const Z = a.filter((de) => {
      const ye = n.get(de);
      return !ye.isAny && ye.test(J);
    });
    return Z.length ? Z : ["any"];
  }
  function f(J) {
    return J && typeof J == "function" && "_typedFunctionData" in J;
  }
  function m(J, Z, de) {
    if (!f(J))
      throw new TypeError(UI);
    const ye = de && de.exact, Ae = Array.isArray(Z) ? Z.join(",") : Z, Ce = S(Ae), Ie = g(Ce);
    if (!ye || Ie in J.signatures) {
      const ht = J._typedFunctionData.signatureMap.get(Ie);
      if (ht)
        return ht;
    }
    const Ue = Ce.length;
    let Xe;
    if (ye) {
      Xe = [];
      let ht;
      for (ht in J.signatures)
        Xe.push(J._typedFunctionData.signatureMap.get(ht));
    } else
      Xe = J._typedFunctionData.signatures;
    for (let ht = 0; ht < Ue; ++ht) {
      const xt = Ce[ht], dt = [];
      let Le;
      for (Le of Xe) {
        const j = w(Le.params, ht);
        if (!(!j || xt.restParam && !j.restParam)) {
          if (!j.hasAny) {
            const xe = _(j);
            if (xt.types.some((ke) => !xe.has(ke.name)))
              continue;
          }
          dt.push(Le);
        }
      }
      if (Xe = dt, Xe.length === 0) break;
    }
    let je;
    for (je of Xe)
      if (je.params.length <= Ue)
        return je;
    throw new TypeError("Signature not found (signature: " + (J.name || "unnamed") + "(" + g(Ce, ", ") + "))");
  }
  function h(J, Z, de) {
    return m(J, Z, de).implementation;
  }
  function p(J, Z) {
    const de = s(Z);
    if (de.test(J))
      return J;
    const ye = de.conversionsTo;
    if (ye.length === 0)
      throw new Error("There are no conversions to " + Z + " defined.");
    for (let Ae = 0; Ae < ye.length; Ae++)
      if (s(ye[Ae].from).test(J))
        return ye[Ae].convert(J);
    throw new Error("Cannot convert " + J + " to " + Z);
  }
  function g(J) {
    let Z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
    return J.map((de) => de.name).join(Z);
  }
  function v(J) {
    const Z = J.indexOf("...") === 0, ye = (Z ? J.length > 3 ? J.slice(3) : "any" : J).split("|").map((Ue) => s(Ue.trim()));
    let Ae = !1, Ce = Z ? "..." : "";
    return {
      types: ye.map(function(Ue) {
        return Ae = Ue.isAny || Ae, Ce += Ue.name + "|", {
          name: Ue.name,
          typeIndex: Ue.index,
          test: Ue.test,
          isAny: Ue.isAny,
          conversion: null,
          conversionIndex: -1
        };
      }),
      name: Ce.slice(0, -1),
      // remove trailing '|' from above
      hasAny: Ae,
      hasConversion: !1,
      restParam: Z
    };
  }
  function y(J) {
    const Z = J.types.map((Ie) => Ie.name), de = R(Z);
    let ye = J.hasAny, Ae = J.name;
    const Ce = de.map(function(Ie) {
      const Ue = s(Ie.from);
      return ye = Ue.isAny || ye, Ae += "|" + Ie.from, {
        name: Ie.from,
        typeIndex: Ue.index,
        test: Ue.test,
        isAny: Ue.isAny,
        conversion: Ie,
        conversionIndex: Ie.index
      };
    });
    return {
      types: J.types.concat(Ce),
      name: Ae,
      hasAny: ye,
      hasConversion: Ce.length > 0,
      restParam: J.restParam
    };
  }
  function _(J) {
    return J.typeSet || (J.typeSet = /* @__PURE__ */ new Set(), J.types.forEach((Z) => J.typeSet.add(Z.name))), J.typeSet;
  }
  function S(J) {
    const Z = [];
    if (typeof J != "string")
      throw new TypeError("Signatures must be strings");
    const de = J.trim();
    if (de === "")
      return Z;
    const ye = de.split(",");
    for (let Ae = 0; Ae < ye.length; ++Ae) {
      const Ce = v(ye[Ae].trim());
      if (Ce.restParam && Ae !== ye.length - 1)
        throw new SyntaxError('Unexpected rest parameter "' + ye[Ae] + '": only allowed for the last parameter');
      if (Ce.types.length === 0)
        return null;
      Z.push(Ce);
    }
    return Z;
  }
  function b(J) {
    const Z = ie(J);
    return Z ? Z.restParam : !1;
  }
  function x(J) {
    if (!J || J.types.length === 0)
      return zI;
    if (J.types.length === 1)
      return s(J.types[0].name).test;
    if (J.types.length === 2) {
      const Z = s(J.types[0].name).test, de = s(J.types[1].name).test;
      return function(Ae) {
        return Z(Ae) || de(Ae);
      };
    } else {
      const Z = J.types.map(function(de) {
        return s(de.name).test;
      });
      return function(ye) {
        for (let Ae = 0; Ae < Z.length; Ae++)
          if (Z[Ae](ye))
            return !0;
        return !1;
      };
    }
  }
  function A(J) {
    let Z, de, ye;
    if (b(J)) {
      Z = re(J).map(x);
      const Ae = Z.length, Ce = x(ie(J)), Ie = function(Ue) {
        for (let Xe = Ae; Xe < Ue.length; Xe++)
          if (!Ce(Ue[Xe]))
            return !1;
        return !0;
      };
      return function(Xe) {
        for (let je = 0; je < Z.length; je++)
          if (!Z[je](Xe[je]))
            return !1;
        return Ie(Xe) && Xe.length >= Ae + 1;
      };
    } else
      return J.length === 0 ? function(Ce) {
        return Ce.length === 0;
      } : J.length === 1 ? (de = x(J[0]), function(Ce) {
        return de(Ce[0]) && Ce.length === 1;
      }) : J.length === 2 ? (de = x(J[0]), ye = x(J[1]), function(Ce) {
        return de(Ce[0]) && ye(Ce[1]) && Ce.length === 2;
      }) : (Z = J.map(x), function(Ce) {
        for (let Ie = 0; Ie < Z.length; Ie++)
          if (!Z[Ie](Ce[Ie]))
            return !1;
        return Ce.length === Z.length;
      });
  }
  function w(J, Z) {
    return Z < J.length ? J[Z] : b(J) ? ie(J) : null;
  }
  function C(J, Z) {
    const de = w(J, Z);
    return de ? _(de) : /* @__PURE__ */ new Set();
  }
  function M(J) {
    return J.conversion === null || J.conversion === void 0;
  }
  function T(J, Z) {
    const de = /* @__PURE__ */ new Set();
    return J.forEach((ye) => {
      const Ae = C(ye.params, Z);
      let Ce;
      for (Ce of Ae)
        de.add(Ce);
    }), de.has("any") ? ["any"] : Array.from(de);
  }
  function N(J, Z, de) {
    let ye, Ae;
    const Ce = J || "unnamed";
    let Ie = de, Ue;
    for (Ue = 0; Ue < Z.length; Ue++) {
      const xt = [];
      if (Ie.forEach((dt) => {
        const Le = w(dt.params, Ue), j = x(Le);
        (Ue < dt.params.length || b(dt.params)) && j(Z[Ue]) && xt.push(dt);
      }), xt.length === 0) {
        if (Ae = T(Ie, Ue), Ae.length > 0) {
          const dt = d(Z[Ue]);
          return ye = new TypeError("Unexpected type of argument in function " + Ce + " (expected: " + Ae.join(" or ") + ", actual: " + dt.join(" | ") + ", index: " + Ue + ")"), ye.data = {
            category: "wrongType",
            fn: Ce,
            index: Ue,
            actual: dt,
            expected: Ae
          }, ye;
        }
      } else
        Ie = xt;
    }
    const Xe = Ie.map(function(xt) {
      return b(xt.params) ? 1 / 0 : xt.params.length;
    });
    if (Z.length < Math.min.apply(null, Xe))
      return Ae = T(Ie, Ue), ye = new TypeError("Too few arguments in function " + Ce + " (expected: " + Ae.join(" or ") + ", index: " + Z.length + ")"), ye.data = {
        category: "tooFewArgs",
        fn: Ce,
        index: Z.length,
        expected: Ae
      }, ye;
    const je = Math.max.apply(null, Xe);
    if (Z.length > je)
      return ye = new TypeError("Too many arguments in function " + Ce + " (expected: " + je + ", actual: " + Z.length + ")"), ye.data = {
        category: "tooManyArgs",
        fn: Ce,
        index: Z.length,
        expectedLength: je
      }, ye;
    const ht = [];
    for (let xt = 0; xt < Z.length; ++xt)
      ht.push(d(Z[xt]).join("|"));
    return ye = new TypeError('Arguments of type "' + ht.join(", ") + '" do not match any of the defined signatures of function ' + Ce + "."), ye.data = {
      category: "mismatch",
      actual: ht
    }, ye;
  }
  function I(J) {
    let Z = a.length + 1;
    for (let de = 0; de < J.types.length; de++)
      M(J.types[de]) && (Z = Math.min(Z, J.types[de].typeIndex));
    return Z;
  }
  function P(J) {
    let Z = i + 1;
    for (let de = 0; de < J.types.length; de++)
      M(J.types[de]) || (Z = Math.min(Z, J.types[de].conversionIndex));
    return Z;
  }
  function O(J, Z) {
    if (J.hasAny) {
      if (!Z.hasAny)
        return 1;
    } else if (Z.hasAny)
      return -1;
    if (J.restParam) {
      if (!Z.restParam)
        return 1;
    } else if (Z.restParam)
      return -1;
    if (J.hasConversion) {
      if (!Z.hasConversion)
        return 1;
    } else if (Z.hasConversion)
      return -1;
    const de = I(J) - I(Z);
    if (de < 0)
      return -1;
    if (de > 0)
      return 1;
    const ye = P(J) - P(Z);
    return ye < 0 ? -1 : ye > 0 ? 1 : 0;
  }
  function F(J, Z) {
    const de = J.params, ye = Z.params, Ae = ie(de), Ce = ie(ye), Ie = b(de), Ue = b(ye);
    if (Ie && Ae.hasAny) {
      if (!Ue || !Ce.hasAny)
        return 1;
    } else if (Ue && Ce.hasAny)
      return -1;
    let Xe = 0, je = 0, ht;
    for (ht of de)
      ht.hasAny && ++Xe, ht.hasConversion && ++je;
    let xt = 0, dt = 0;
    for (ht of ye)
      ht.hasAny && ++xt, ht.hasConversion && ++dt;
    if (Xe !== xt)
      return Xe - xt;
    if (Ie && Ae.hasConversion) {
      if (!Ue || !Ce.hasConversion)
        return 1;
    } else if (Ue && Ce.hasConversion)
      return -1;
    if (je !== dt)
      return je - dt;
    if (Ie) {
      if (!Ue)
        return 1;
    } else if (Ue)
      return -1;
    const Le = (de.length - ye.length) * (Ie ? -1 : 1);
    if (Le !== 0)
      return Le;
    const j = [];
    let xe = 0;
    for (let Je = 0; Je < de.length; ++Je) {
      const Ct = O(de[Je], ye[Je]);
      j.push(Ct), xe += Ct;
    }
    if (xe !== 0)
      return xe;
    let ke;
    for (ke of j)
      if (ke !== 0)
        return ke;
    return 0;
  }
  function R(J) {
    if (J.length === 0)
      return [];
    const Z = J.map(s);
    J.length > 1 && Z.sort((Ae, Ce) => Ae.index - Ce.index);
    let de = Z[0].conversionsTo;
    if (J.length === 1)
      return de;
    de = de.concat([]);
    const ye = new Set(J);
    for (let Ae = 1; Ae < Z.length; ++Ae) {
      let Ce;
      for (Ce of Z[Ae].conversionsTo)
        ye.has(Ce.from) || (de.push(Ce), ye.add(Ce.from));
    }
    return de;
  }
  function G(J, Z) {
    let de = Z;
    if (J.some((Ae) => Ae.hasConversion)) {
      const Ae = b(J), Ce = J.map(L);
      de = function() {
        const Ue = [], Xe = Ae ? arguments.length - 1 : arguments.length;
        for (let je = 0; je < Xe; je++)
          Ue[je] = Ce[je](arguments[je]);
        return Ae && (Ue[Xe] = arguments[Xe].map(Ce[Xe])), Z.apply(this, Ue);
      };
    }
    let ye = de;
    if (b(J)) {
      const Ae = J.length - 1;
      ye = function() {
        return de.apply(this, oe(arguments, 0, Ae).concat([oe(arguments, Ae)]));
      };
    }
    return ye;
  }
  function L(J) {
    let Z, de, ye, Ae;
    const Ce = [], Ie = [];
    switch (J.types.forEach(function(Ue) {
      Ue.conversion && (Ce.push(s(Ue.conversion.from).test), Ie.push(Ue.conversion.convert));
    }), Ie.length) {
      case 0:
        return function(Xe) {
          return Xe;
        };
      case 1:
        return Z = Ce[0], ye = Ie[0], function(Xe) {
          return Z(Xe) ? ye(Xe) : Xe;
        };
      case 2:
        return Z = Ce[0], de = Ce[1], ye = Ie[0], Ae = Ie[1], function(Xe) {
          return Z(Xe) ? ye(Xe) : de(Xe) ? Ae(Xe) : Xe;
        };
      default:
        return function(Xe) {
          for (let je = 0; je < Ie.length; je++)
            if (Ce[je](Xe))
              return Ie[je](Xe);
          return Xe;
        };
    }
  }
  function q(J) {
    function Z(de, ye, Ae) {
      if (ye < de.length) {
        const Ce = de[ye];
        let Ie = [];
        if (Ce.restParam) {
          const Ue = Ce.types.filter(M);
          Ue.length < Ce.types.length && Ie.push({
            types: Ue,
            name: "..." + Ue.map((Xe) => Xe.name).join("|"),
            hasAny: Ue.some((Xe) => Xe.isAny),
            hasConversion: !1,
            restParam: !0
          }), Ie.push(Ce);
        } else
          Ie = Ce.types.map(function(Ue) {
            return {
              types: [Ue],
              name: Ue.name,
              hasAny: Ue.isAny,
              hasConversion: Ue.conversion,
              restParam: !1
            };
          });
        return he(Ie, function(Ue) {
          return Z(de, ye + 1, Ae.concat([Ue]));
        });
      } else
        return [Ae];
    }
    return Z(J, 0, []);
  }
  function K(J, Z) {
    const de = Math.max(J.length, Z.length);
    for (let Ue = 0; Ue < de; Ue++) {
      const Xe = C(J, Ue), je = C(Z, Ue);
      let ht = !1, xt;
      for (xt of je)
        if (Xe.has(xt)) {
          ht = !0;
          break;
        }
      if (!ht)
        return !1;
    }
    const ye = J.length, Ae = Z.length, Ce = b(J), Ie = b(Z);
    return Ce ? Ie ? ye === Ae : Ae >= ye : Ie ? ye >= Ae : ye === Ae;
  }
  function X(J) {
    return J.map((Z) => _e(Z) ? ae(Z.referToSelf.callback) : ce(Z) ? De(Z.referTo.references, Z.referTo.callback) : Z);
  }
  function H(J, Z, de) {
    const ye = [];
    let Ae;
    for (Ae of J) {
      let Ce = de[Ae];
      if (typeof Ce != "number")
        throw new TypeError('No definition for referenced signature "' + Ae + '"');
      if (Ce = Z[Ce], typeof Ce != "function")
        return !1;
      ye.push(Ce);
    }
    return ye;
  }
  function W(J, Z, de) {
    const ye = X(J), Ae = new Array(ye.length).fill(!1);
    let Ce = !0;
    for (; Ce; ) {
      Ce = !1;
      let Ie = !0;
      for (let Ue = 0; Ue < ye.length; ++Ue) {
        if (Ae[Ue]) continue;
        const Xe = ye[Ue];
        if (_e(Xe))
          ye[Ue] = Xe.referToSelf.callback(de), ye[Ue].referToSelf = Xe.referToSelf, Ae[Ue] = !0, Ie = !1;
        else if (ce(Xe)) {
          const je = H(Xe.referTo.references, ye, Z);
          je ? (ye[Ue] = Xe.referTo.callback.apply(this, je), ye[Ue].referTo = Xe.referTo, Ae[Ue] = !0, Ie = !1) : Ce = !0;
        }
      }
      if (Ie && Ce)
        throw new SyntaxError("Circular reference detected in resolving typed.referTo");
    }
    return ye;
  }
  function ee(J) {
    const Z = /\bthis(\(|\.signatures\b)/;
    Object.keys(J).forEach((de) => {
      const ye = J[de];
      if (Z.test(ye.toString()))
        throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.");
    });
  }
  function $(J, Z) {
    if (o.createCount++, Object.keys(Z).length === 0)
      throw new SyntaxError("No signatures provided");
    o.warnAgainstDeprecatedThis && ee(Z);
    const de = [], ye = [], Ae = {}, Ce = [];
    let Ie;
    for (Ie in Z) {
      if (!Object.prototype.hasOwnProperty.call(Z, Ie))
        continue;
      const Kr = S(Ie);
      if (!Kr) continue;
      de.forEach(function(ku) {
        if (K(ku, Kr))
          throw new TypeError('Conflicting signatures "' + g(ku) + '" and "' + g(Kr) + '".');
      }), de.push(Kr);
      const ri = ye.length;
      ye.push(Z[Ie]);
      const I1 = Kr.map(y);
      let Pl;
      for (Pl of q(I1)) {
        const ku = g(Pl);
        Ce.push({
          params: Pl,
          name: ku,
          fn: ri
        }), Pl.every((Am) => !Am.hasConversion) && (Ae[ku] = ri);
      }
    }
    Ce.sort(F);
    const Ue = W(ye, Ae, bc);
    let Xe;
    for (Xe in Ae)
      Object.prototype.hasOwnProperty.call(Ae, Xe) && (Ae[Xe] = Ue[Ae[Xe]]);
    const je = [], ht = /* @__PURE__ */ new Map();
    for (Xe of Ce)
      ht.has(Xe.name) || (Xe.fn = Ue[Xe.fn], je.push(Xe), ht.set(Xe.name, Xe));
    const xt = je[0] && je[0].params.length <= 2 && !b(je[0].params), dt = je[1] && je[1].params.length <= 2 && !b(je[1].params), Le = je[2] && je[2].params.length <= 2 && !b(je[2].params), j = je[3] && je[3].params.length <= 2 && !b(je[3].params), xe = je[4] && je[4].params.length <= 2 && !b(je[4].params), ke = je[5] && je[5].params.length <= 2 && !b(je[5].params), Je = xt && dt && Le && j && xe && ke;
    for (let Kr = 0; Kr < je.length; ++Kr)
      je[Kr].test = A(je[Kr].params);
    const Ct = xt ? x(je[0].params[0]) : Us, At = dt ? x(je[1].params[0]) : Us, Or = Le ? x(je[2].params[0]) : Us, qn = j ? x(je[3].params[0]) : Us, Xn = xe ? x(je[4].params[0]) : Us, kn = ke ? x(je[5].params[0]) : Us, fn = xt ? x(je[0].params[1]) : Us, la = dt ? x(je[1].params[1]) : Us, mn = Le ? x(je[2].params[1]) : Us, pn = j ? x(je[3].params[1]) : Us, ba = xe ? x(je[4].params[1]) : Us, xa = ke ? x(je[5].params[1]) : Us;
    for (let Kr = 0; Kr < je.length; ++Kr)
      je[Kr].implementation = G(je[Kr].params, je[Kr].fn);
    const to = xt ? je[0].implementation : mp, zn = dt ? je[1].implementation : mp, An = Le ? je[2].implementation : mp, jo = j ? je[3].implementation : mp, Yo = xe ? je[4].implementation : mp, Co = ke ? je[5].implementation : mp, Lu = xt ? je[0].params.length : -1, ro = dt ? je[1].params.length : -1, _a = Le ? je[2].params.length : -1, yc = j ? je[3].params.length : -1, El = xe ? je[4].params.length : -1, Dl = ke ? je[5].params.length : -1, Ml = Je ? 6 : 0, Il = je.length, Tl = je.map((Kr) => Kr.test), Sm = je.map((Kr) => Kr.implementation), Nl = function() {
      for (let ri = Ml; ri < Il; ri++)
        if (Tl[ri](arguments))
          return Sm[ri].apply(this, arguments);
      return o.onMismatch(J, arguments, je);
    };
    function bc(Kr, ri) {
      return arguments.length === Lu && Ct(Kr) && fn(ri) ? to.apply(this, arguments) : arguments.length === ro && At(Kr) && la(ri) ? zn.apply(this, arguments) : arguments.length === _a && Or(Kr) && mn(ri) ? An.apply(this, arguments) : arguments.length === yc && qn(Kr) && pn(ri) ? jo.apply(this, arguments) : arguments.length === El && Xn(Kr) && ba(ri) ? Yo.apply(this, arguments) : arguments.length === Dl && kn(Kr) && xa(ri) ? Co.apply(this, arguments) : Nl.apply(this, arguments);
    }
    try {
      Object.defineProperty(bc, "name", {
        value: J
      });
    } catch {
    }
    return bc.signatures = Ae, bc._typedFunctionData = {
      signatures: je,
      signatureMap: ht
    }, bc;
  }
  function te(J, Z, de) {
    throw N(J, Z, de);
  }
  function re(J) {
    return oe(J, 0, J.length - 1);
  }
  function ie(J) {
    return J[J.length - 1];
  }
  function oe(J, Z, de) {
    return Array.prototype.slice.call(J, Z, de);
  }
  function se(J, Z) {
    for (let de = 0; de < J.length; de++)
      if (Z(J[de]))
        return J[de];
  }
  function he(J, Z) {
    return Array.prototype.concat.apply([], J.map(Z));
  }
  function ge() {
    const J = re(arguments).map((de) => g(S(de))), Z = ie(arguments);
    if (typeof Z != "function")
      throw new TypeError("Callback function expected as last argument");
    return De(J, Z);
  }
  function De(J, Z) {
    return {
      referTo: {
        references: J,
        callback: Z
      }
    };
  }
  function ae(J) {
    if (typeof J != "function")
      throw new TypeError("Callback function expected as first argument");
    return {
      referToSelf: {
        callback: J
      }
    };
  }
  function ce(J) {
    return J && typeof J.referTo == "object" && Array.isArray(J.referTo.references) && typeof J.referTo.callback == "function";
  }
  function _e(J) {
    return J && typeof J.referToSelf == "object" && typeof J.referToSelf.callback == "function";
  }
  function le(J, Z) {
    if (!J)
      return Z;
    if (Z && Z !== J) {
      const de = new Error("Function names do not match (expected: " + J + ", actual: " + Z + ")");
      throw de.data = {
        actual: Z,
        expected: J
      }, de;
    }
    return J;
  }
  function ue(J) {
    let Z;
    for (const de in J)
      Object.prototype.hasOwnProperty.call(J, de) && (f(J[de]) || typeof J[de].signature == "string") && (Z = le(Z, J[de].name));
    return Z;
  }
  function be(J, Z) {
    let de;
    for (de in Z)
      if (Object.prototype.hasOwnProperty.call(Z, de)) {
        if (de in J && Z[de] !== J[de]) {
          const ye = new Error('Signature "' + de + '" is defined twice');
          throw ye.data = {
            signature: de,
            sourceFunction: Z[de],
            destFunction: J[de]
          }, ye;
        }
        J[de] = Z[de];
      }
  }
  const Se = o;
  o = function(J) {
    const Z = typeof J == "string", de = Z ? 1 : 0;
    let ye = Z ? J : "";
    const Ae = {};
    for (let Ce = de; Ce < arguments.length; ++Ce) {
      const Ie = arguments[Ce];
      let Ue = {}, Xe;
      if (typeof Ie == "function" ? (Xe = Ie.name, typeof Ie.signature == "string" ? Ue[Ie.signature] = Ie : f(Ie) && (Ue = Ie.signatures)) : e(Ie) && (Ue = Ie, Z || (Xe = ue(Ie))), Object.keys(Ue).length === 0) {
        const je = new TypeError("Argument to 'typed' at index " + Ce + " is not a (typed) function, nor an object with signatures as keys and functions as values.");
        throw je.data = {
          index: Ce,
          argument: Ie
        }, je;
      }
      Z || (ye = le(ye, Xe)), be(Ae, Ue);
    }
    return $(ye || "", Ae);
  }, o.create = dU, o.createCount = Se.createCount, o.onMismatch = te, o.throwMismatchError = te, o.createError = N, o.clear = c, o.clearConversions = l, o.addTypes = u, o._findType = s, o.referTo = ge, o.referToSelf = ae, o.convert = p, o.findSignature = m, o.find = h, o.isTypedFunction = f, o.warnAgainstDeprecatedThis = !0, o.addType = function(J, Z) {
    let de = "any";
    Z !== !1 && n.has("Object") && (de = "Object"), o.addTypes([J], de);
  };
  function Ne(J) {
    if (!J || typeof J.from != "string" || typeof J.to != "string" || typeof J.convert != "function")
      throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");
    if (J.to === J.from)
      throw new SyntaxError('Illegal to define conversion from "' + J.from + '" to itself.');
  }
  return o.addConversion = function(J) {
    let Z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
      override: !1
    };
    Ne(J);
    const de = s(J.to), ye = de.conversionsTo.find((Ae) => Ae.from === J.from);
    if (ye)
      if (Z && Z.override)
        o.removeConversion({
          from: ye.from,
          to: J.to,
          convert: ye.convert
        });
      else
        throw new Error('There is already a conversion from "' + J.from + '" to "' + de.name + '"');
    de.conversionsTo.push({
      from: J.from,
      convert: J.convert,
      index: i++
    });
  }, o.addConversions = function(J, Z) {
    J.forEach((de) => o.addConversion(de, Z));
  }, o.removeConversion = function(J) {
    Ne(J);
    const Z = s(J.to), de = se(Z.conversionsTo, (Ae) => Ae.from === J.from);
    if (!de)
      throw new Error("Attempt to remove nonexistent conversion from " + J.from + " to " + J.to);
    if (de.convert !== J.convert)
      throw new Error("Conversion to remove does not match existing conversion");
    const ye = Z.conversionsTo.indexOf(de);
    Z.conversionsTo.splice(ye, 1);
  }, o.resolve = function(J, Z) {
    if (!f(J))
      throw new TypeError(UI);
    const de = J._typedFunctionData.signatures;
    for (let ye = 0; ye < de.length; ++ye)
      if (de[ye].test(Z))
        return de[ye];
    return null;
  }, o;
}
const Vf = dU();
function Ut(e) {
  return typeof e == "boolean" ? !0 : isFinite(e) ? e === Math.round(e) : !1;
}
function ipe(e) {
  return /^-?\d+$/.test(e);
}
function $d(e, t) {
  return t.number === "bigint" && !ipe(e) ? t.numberFallback : t.number;
}
var Nd = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, ope = Math.log2 || function(t) {
  return Math.log(t) / Math.LN2;
}, spe = Math.log10 || function(t) {
  return Math.log(t) / Math.LN10;
}, upe = Math.log1p || function(e) {
  return Math.log(e + 1);
}, cpe = Math.cbrt || function(t) {
  if (t === 0)
    return t;
  var r = t < 0, n;
  return r && (t = -t), isFinite(t) ? (n = Math.exp(Math.log(t) / 3), n = (t / (n * n) + 2 * n) / 3) : n = t, r ? -n : n;
}, lpe = Math.expm1 || function(t) {
  return t >= 2e-4 || t <= -2e-4 ? Math.exp(t) - 1 : t + t * t / 2 + t * t * t / 6;
};
function O5(e, t, r) {
  var n = {
    2: "0b",
    8: "0o",
    16: "0x"
  }, a = n[t], i = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!Ut(r))
      throw new Error("size must be an integer");
    if (e > 2 ** (r - 1) - 1 || e < -(2 ** (r - 1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!Ut(e))
      throw new Error("Value must be an integer");
    e < 0 && (e = e + 2 ** r), i = "i".concat(r);
  }
  var o = "";
  return e < 0 && (e = -e, o = "-"), "".concat(o).concat(a).concat(e.toString(t)).concat(i);
}
function Qf(e, t) {
  if (typeof t == "function")
    return t(e);
  if (e === 1 / 0)
    return "Infinity";
  if (e === -1 / 0)
    return "-Infinity";
  if (isNaN(e))
    return "NaN";
  var {
    notation: r,
    precision: n,
    wordSize: a
  } = fU(t);
  switch (r) {
    case "fixed":
      return mU(e, n);
    case "exponential":
      return pU(e, n);
    case "engineering":
      return dpe(e, n);
    case "bin":
      return O5(e, 2, a);
    case "oct":
      return O5(e, 8, a);
    case "hex":
      return O5(e, 16, a);
    case "auto":
      return fpe(e, n, t).replace(/((\.\d*?)(0+))($|e)/, function() {
        var i = arguments[2], o = arguments[4];
        return i !== "." ? i + o : o;
      });
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function fU(e) {
  var t = "auto", r, n;
  if (e !== void 0)
    if (_r(e))
      r = e;
    else if (hr(e))
      r = e.toNumber();
    else if (Hh(e))
      e.precision !== void 0 && (r = GI(e.precision, () => {
        throw new Error('Option "precision" must be a number or BigNumber');
      })), e.wordSize !== void 0 && (n = GI(e.wordSize, () => {
        throw new Error('Option "wordSize" must be a number or BigNumber');
      })), e.notation && (t = e.notation);
    else
      throw new Error("Unsupported type of options, number, BigNumber, or object expected");
  return {
    notation: t,
    precision: r,
    wordSize: n
  };
}
function Xh(e) {
  var t = String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
  if (!t)
    throw new SyntaxError("Invalid number " + e);
  var r = t[1], n = t[2], a = parseFloat(t[4] || "0"), i = n.indexOf(".");
  a += i !== -1 ? i - 1 : n.length - 1;
  var o = n.replace(".", "").replace(/^0*/, function(s) {
    return a -= s.length, "";
  }).replace(/0*$/, "").split("").map(function(s) {
    return parseInt(s);
  });
  return o.length === 0 && (o.push(0), a++), {
    sign: r,
    coefficients: o,
    exponent: a
  };
}
function dpe(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Xh(e), n = k3(r, t), a = n.exponent, i = n.coefficients, o = a % 3 === 0 ? a : a < 0 ? a - 3 - a % 3 : a - a % 3;
  if (_r(t))
    for (; t > i.length || a - o + 1 > i.length; )
      i.push(0);
  else
    for (var s = Math.abs(a - o) - (i.length - 1), u = 0; u < s; u++)
      i.push(0);
  for (var c = Math.abs(a - o), l = 1; c > 0; )
    l++, c--;
  var d = i.slice(l).join(""), f = _r(t) && d.length || d.match(/[1-9]/) ? "." + d : "", m = i.slice(0, l).join("") + f + "e" + (a >= 0 ? "+" : "") + o.toString();
  return n.sign + m;
}
function mU(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Xh(e), n = typeof t == "number" ? k3(r, r.exponent + 1 + t) : r, a = n.coefficients, i = n.exponent + 1, o = i + (t || 0);
  return a.length < o && (a = a.concat(Tp(o - a.length))), i < 0 && (a = Tp(-i + 1).concat(a), i = 1), i < a.length && a.splice(i, 0, i === 0 ? "0." : "."), n.sign + a.join("");
}
function pU(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Xh(e), n = t ? k3(r, t) : r, a = n.coefficients, i = n.exponent;
  a.length < t && (a = a.concat(Tp(t - a.length)));
  var o = a.shift();
  return n.sign + o + (a.length > 0 ? "." + a.join("") : "") + "e" + (i >= 0 ? "+" : "") + i;
}
function fpe(e, t, r) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var n = VI(r == null ? void 0 : r.lowerExp, -3), a = VI(r == null ? void 0 : r.upperExp, 5), i = Xh(e), o = t ? k3(i, t) : i;
  if (o.exponent < n || o.exponent >= a)
    return pU(e, t);
  var s = o.coefficients, u = o.exponent;
  s.length < t && (s = s.concat(Tp(t - s.length))), s = s.concat(Tp(u - s.length + 1 + (s.length < t ? t - s.length : 0))), s = Tp(-u).concat(s);
  var c = u > 0 ? u : 0;
  return c < s.length - 1 && s.splice(c + 1, 0, "."), o.sign + s.join("");
}
function k3(e, t) {
  for (var r = {
    sign: e.sign,
    coefficients: e.coefficients,
    exponent: e.exponent
  }, n = r.coefficients; t <= 0; )
    n.unshift(0), r.exponent++, t++;
  if (n.length > t) {
    var a = n.splice(t, n.length - t);
    if (a[0] >= 5) {
      var i = t - 1;
      for (n[i]++; n[i] === 10; )
        n.pop(), i === 0 && (n.unshift(0), r.exponent++, i++), i--, n[i]++;
    }
  }
  return r;
}
function Tp(e) {
  for (var t = [], r = 0; r < e; r++)
    t.push(0);
  return t;
}
function mpe(e) {
  return e.toExponential().replace(/e.*$/, "").replace(/^0\.?0*|\./, "").length;
}
function Fi(e, t) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-8, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return isNaN(e) || isNaN(t) ? !1 : !isFinite(e) || !isFinite(t) ? e === t : e === t ? !0 : Math.abs(e - t) <= Math.max(r * Math.max(Math.abs(e), Math.abs(t)), n);
}
var ppe = Math.acosh || function(e) {
  return Math.log(Math.sqrt(e * e - 1) + e);
}, hpe = Math.asinh || function(e) {
  return Math.log(Math.sqrt(e * e + 1) + e);
}, vpe = Math.atanh || function(e) {
  return Math.log((1 + e) / (1 - e)) / 2;
}, gpe = Math.cosh || function(e) {
  return (Math.exp(e) + Math.exp(-e)) / 2;
}, ype = Math.sinh || function(e) {
  return (Math.exp(e) - Math.exp(-e)) / 2;
}, bpe = Math.tanh || function(e) {
  var t = Math.exp(2 * e);
  return (t - 1) / (t + 1);
};
function xpe(e, t) {
  var r = !0, n = t > 0 ? !0 : t < 0 ? !1 : 1 / t === 1 / 0;
  return r ^ n ? -e : e;
}
function GI(e, t) {
  if (_r(e))
    return e;
  if (hr(e))
    return e.toNumber();
  t();
}
function VI(e, t) {
  return _r(e) ? e : hr(e) ? e.toNumber() : t;
}
function me(e, t, r, n) {
  function a(i) {
    var o = npe(i, t.map(hU));
    return _pe(e, t, i), r(o);
  }
  return a.isFactory = !0, a.fn = e, a.dependencies = t.slice().sort(), n && (a.meta = n), a;
}
function nh(e) {
  return typeof e == "function" && typeof e.fn == "string" && Array.isArray(e.dependencies);
}
function _pe(e, t, r) {
  var n = t.filter((i) => !Spe(i)).every((i) => r[i] !== void 0);
  if (!n) {
    var a = t.filter((i) => r[i] === void 0);
    throw new Error('Cannot create function "'.concat(e, '", ') + "some dependencies are missing: ".concat(a.map((i) => '"'.concat(i, '"')).join(", "), "."));
  }
}
function Spe(e) {
  return e && e[0] === "?";
}
function hU(e) {
  return e && e[0] === "?" ? e.slice(1) : e;
}
function yo(e, t) {
  if (gU(e) && vU(e, t))
    return e[t];
  throw typeof e[t] == "function" && wS(e, t) ? new Error('Cannot access method "' + t + '" as a property') : new Error('No access to property "' + t + '"');
}
function i1(e, t, r) {
  if (gU(e) && vU(e, t))
    return e[t] = r, r;
  throw new Error('No access to property "' + t + '"');
}
function Ape(e, t) {
  return t in e;
}
function vU(e, t) {
  return !e || typeof e != "object" ? !1 : Tt(Cpe, t) ? !0 : !(t in Object.prototype || t in Function.prototype);
}
function wpe(e, t) {
  if (!wS(e, t))
    throw new Error('No access to method "' + t + '"');
  return e[t];
}
function wS(e, t) {
  return e == null || typeof e[t] != "function" || Tt(e, t) && Object.getPrototypeOf && t in Object.getPrototypeOf(e) ? !1 : Tt(Epe, t) ? !0 : !(t in Object.prototype || t in Function.prototype);
}
function gU(e) {
  return typeof e == "object" && e && e.constructor === Object;
}
var Cpe = {
  length: !0,
  name: !0
}, Epe = {
  toString: !0,
  valueOf: !0,
  toLocaleString: !0
};
class z3 {
  constructor(t) {
    this.wrappedObject = t, this[Symbol.iterator] = this.entries;
  }
  keys() {
    return Object.keys(this.wrappedObject).values();
  }
  get(t) {
    return yo(this.wrappedObject, t);
  }
  set(t, r) {
    return i1(this.wrappedObject, t, r), this;
  }
  has(t) {
    return Ape(this.wrappedObject, t);
  }
  entries() {
    return bU(this.keys(), (t) => [t, this.get(t)]);
  }
  forEach(t) {
    for (var r of this.keys())
      t(this.get(r), r, this);
  }
  delete(t) {
    delete this.wrappedObject[t];
  }
  clear() {
    for (var t of this.keys())
      this.delete(t);
  }
  get size() {
    return Object.keys(this.wrappedObject).length;
  }
}
class yU {
  /**
   * @param {Map} a
   * @param {Map} b
   * @param {Set} bKeys
   */
  constructor(t, r, n) {
    this.a = t, this.b = r, this.bKeys = n, this[Symbol.iterator] = this.entries;
  }
  get(t) {
    return this.bKeys.has(t) ? this.b.get(t) : this.a.get(t);
  }
  set(t, r) {
    return this.bKeys.has(t) ? this.b.set(t, r) : this.a.set(t, r), this;
  }
  has(t) {
    return this.b.has(t) || this.a.has(t);
  }
  keys() {
    return (/* @__PURE__ */ new Set([...this.a.keys(), ...this.b.keys()]))[Symbol.iterator]();
  }
  entries() {
    return bU(this.keys(), (t) => [t, this.get(t)]);
  }
  forEach(t) {
    for (var r of this.keys())
      t(this.get(r), r, this);
  }
  delete(t) {
    return this.bKeys.has(t) ? this.b.delete(t) : this.a.delete(t);
  }
  clear() {
    this.a.clear(), this.b.clear();
  }
  get size() {
    return [...this.keys()].length;
  }
}
function bU(e, t) {
  return {
    next: () => {
      var r = e.next();
      return r.done ? r : {
        value: t(r.value),
        done: !1
      };
    }
  };
}
function Eh() {
  return /* @__PURE__ */ new Map();
}
function Np(e) {
  if (!e)
    return Eh();
  if (xU(e))
    return e;
  if (Hh(e))
    return new z3(e);
  throw new Error("createMap can create maps from objects or Maps");
}
function Dpe(e) {
  if (e instanceof z3)
    return e.wrappedObject;
  var t = {};
  for (var r of e.keys()) {
    var n = e.get(r);
    i1(t, r, n);
  }
  return t;
}
function xU(e) {
  return e ? e instanceof Map || e instanceof z3 || typeof e.set == "function" && typeof e.get == "function" && typeof e.keys == "function" && typeof e.has == "function" : !1;
}
var _U = function() {
  return _U = Vf.create, Vf;
}, Mpe = ["?BigNumber", "?Complex", "?DenseMatrix", "?Fraction"], SU = /* @__PURE__ */ me("typed", Mpe, function(t) {
  var {
    BigNumber: r,
    Complex: n,
    DenseMatrix: a,
    Fraction: i
  } = t, o = _U();
  return o.clear(), o.addTypes([
    {
      name: "number",
      test: _r
    },
    {
      name: "Complex",
      test: Mu
    },
    {
      name: "BigNumber",
      test: hr
    },
    {
      name: "bigint",
      test: Wz
    },
    {
      name: "Fraction",
      test: vm
    },
    {
      name: "Unit",
      test: Lo
    },
    // The following type matches a valid variable name, i.e., an alphanumeric
    // string starting with an alphabetic character. It is used (at least)
    // in the definition of the derivative() function, as the argument telling
    // what to differentiate over must (currently) be a variable.
    {
      name: "identifier",
      test: (s) => Di && /^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(s)
    },
    {
      name: "string",
      test: Di
    },
    {
      name: "Chain",
      test: AS
    },
    {
      name: "Array",
      test: en
    },
    {
      name: "Matrix",
      test: Zt
    },
    {
      name: "DenseMatrix",
      test: Ch
    },
    {
      name: "SparseMatrix",
      test: Td
    },
    {
      name: "Range",
      test: L3
    },
    {
      name: "Index",
      test: qh
    },
    {
      name: "boolean",
      test: Zz
    },
    {
      name: "ResultSet",
      test: Qz
    },
    {
      name: "Help",
      test: SS
    },
    {
      name: "function",
      test: $z
    },
    {
      name: "Date",
      test: Jz
    },
    {
      name: "RegExp",
      test: eU
    },
    {
      name: "null",
      test: tU
    },
    {
      name: "undefined",
      test: rU
    },
    {
      name: "AccessorNode",
      test: Xd
    },
    {
      name: "ArrayNode",
      test: cs
    },
    {
      name: "AssignmentNode",
      test: nU
    },
    {
      name: "BlockNode",
      test: aU
    },
    {
      name: "ConditionalNode",
      test: iU
    },
    {
      name: "ConstantNode",
      test: Vr
    },
    {
      name: "FunctionNode",
      test: vl
    },
    {
      name: "FunctionAssignmentNode",
      test: x1
    },
    {
      name: "IndexNode",
      test: gm
    },
    {
      name: "Node",
      test: gn
    },
    {
      name: "ObjectNode",
      test: Kh
    },
    {
      name: "OperatorNode",
      test: Da
    },
    {
      name: "ParenthesisNode",
      test: pc
    },
    {
      name: "RangeNode",
      test: oU
    },
    {
      name: "RelationalNode",
      test: sU
    },
    {
      name: "SymbolNode",
      test: Wa
    },
    {
      name: "Map",
      test: xU
    },
    {
      name: "Object",
      test: Hh
    }
    // order 'Object' last, it matches on other classes too
  ]), o.addConversions([{
    from: "number",
    to: "BigNumber",
    convert: function(u) {
      if (r || Jg(u), mpe(u) > 15)
        throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: " + u + "). Use function bignumber(x) to convert to BigNumber.");
      return new r(u);
    }
  }, {
    from: "number",
    to: "Complex",
    convert: function(u) {
      return n || e2(u), new n(u, 0);
    }
  }, {
    from: "BigNumber",
    to: "Complex",
    convert: function(u) {
      return n || e2(u), new n(u.toNumber(), 0);
    }
  }, {
    from: "bigint",
    to: "number",
    convert: function(u) {
      if (u > Number.MAX_SAFE_INTEGER)
        throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: " + u + ")");
      return Number(u);
    }
  }, {
    from: "bigint",
    to: "BigNumber",
    convert: function(u) {
      return r || Jg(u), new r(u.toString());
    }
  }, {
    from: "bigint",
    to: "Fraction",
    convert: function(u) {
      return i || t2(u), new i(u.toString());
    }
  }, {
    from: "Fraction",
    to: "BigNumber",
    convert: function(u) {
      throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.");
    }
  }, {
    from: "Fraction",
    to: "Complex",
    convert: function(u) {
      return n || e2(u), new n(u.valueOf(), 0);
    }
  }, {
    from: "number",
    to: "Fraction",
    convert: function(u) {
      i || t2(u);
      var c = new i(u);
      if (c.valueOf() !== u)
        throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: " + u + "). Use function fraction(x) to convert to Fraction.");
      return c;
    }
  }, {
    // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))`
    //  from: 'Fraction',
    //  to: 'number',
    //  convert: function (x) {
    //    return x.valueOf()
    //  }
    // }, {
    from: "string",
    to: "number",
    convert: function(u) {
      var c = Number(u);
      if (isNaN(c))
        throw new Error('Cannot convert "' + u + '" to a number');
      return c;
    }
  }, {
    from: "string",
    to: "BigNumber",
    convert: function(u) {
      r || Jg(u);
      try {
        return new r(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to BigNumber');
      }
    }
  }, {
    from: "string",
    to: "bigint",
    convert: function(u) {
      try {
        return BigInt(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to BigInt');
      }
    }
  }, {
    from: "string",
    to: "Fraction",
    convert: function(u) {
      i || t2(u);
      try {
        return new i(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to Fraction');
      }
    }
  }, {
    from: "string",
    to: "Complex",
    convert: function(u) {
      n || e2(u);
      try {
        return new n(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to Complex');
      }
    }
  }, {
    from: "boolean",
    to: "number",
    convert: function(u) {
      return +u;
    }
  }, {
    from: "boolean",
    to: "BigNumber",
    convert: function(u) {
      return r || Jg(u), new r(+u);
    }
  }, {
    from: "boolean",
    to: "bigint",
    convert: function(u) {
      return BigInt(+u);
    }
  }, {
    from: "boolean",
    to: "Fraction",
    convert: function(u) {
      return i || t2(u), new i(+u);
    }
  }, {
    from: "boolean",
    to: "string",
    convert: function(u) {
      return String(u);
    }
  }, {
    from: "Array",
    to: "Matrix",
    convert: function(u) {
      return a || Ipe(), new a(u);
    }
  }, {
    from: "Matrix",
    to: "Array",
    convert: function(u) {
      return u.valueOf();
    }
  }]), o.onMismatch = (s, u, c) => {
    var l = o.createError(s, u, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && u.length === 1 && bs(u[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(s, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(s, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o.onMismatch = (s, u, c) => {
    var l = o.createError(s, u, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && u.length === 1 && bs(u[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(s, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(s, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o;
});
function Jg(e) {
  throw new Error("Cannot convert value ".concat(e, " into a BigNumber: no class 'BigNumber' provided"));
}
function e2(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Complex number: no class 'Complex' provided"));
}
function Ipe() {
  throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");
}
function t2(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Fraction, no class 'Fraction' provided."));
}
var Tpe = "ResultSet", Npe = [], Ppe = /* @__PURE__ */ me(Tpe, Npe, () => {
  function e(t) {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
    this.entries = t || [];
  }
  return e.prototype.type = "ResultSet", e.prototype.isResultSet = !0, e.prototype.valueOf = function() {
    return this.entries;
  }, e.prototype.toString = function() {
    return "[" + this.entries.join(", ") + "]";
  }, e.prototype.toJSON = function() {
    return {
      mathjs: "ResultSet",
      entries: this.entries
    };
  }, e.fromJSON = function(t) {
    return new e(t.entries);
  }, e;
}, {
  isClass: !0
});
/*!
 *  decimal.js v10.4.3
 *  An arbitrary-precision Decimal type for JavaScript.
 *  https://github.com/MikeMcl/decimal.js
 *  Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
 *  MIT Licence
 */
var Sp = 9e15, Jd = 1e9, G_ = "0123456789abcdef", Fy = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", Ry = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", V_ = {
  // These values must be integers within the stated ranges (inclusive).
  // Most of these values can be changed at run-time using the `Decimal.config` method.
  // The maximum number of significant digits of the result of a calculation or base conversion.
  // E.g. `Decimal.config({ precision: 20 });`
  precision: 20,
  // 1 to MAX_DIGITS
  // The rounding mode used when rounding to `precision`.
  //
  // ROUND_UP         0 Away from zero.
  // ROUND_DOWN       1 Towards zero.
  // ROUND_CEIL       2 Towards +Infinity.
  // ROUND_FLOOR      3 Towards -Infinity.
  // ROUND_HALF_UP    4 Towards nearest neighbour. If equidistant, up.
  // ROUND_HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.
  // ROUND_HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.
  // ROUND_HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.
  // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  //
  // E.g.
  // `Decimal.rounding = 4;`
  // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  rounding: 4,
  // 0 to 8
  // The modulo mode used when calculating the modulus: a mod n.
  // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  // The remainder (r) is calculated as: r = a - n * q.
  //
  // UP         0 The remainder is positive if the dividend is negative, else is negative.
  // DOWN       1 The remainder has the same sign as the dividend (JavaScript %).
  // FLOOR      3 The remainder has the same sign as the divisor (Python %).
  // HALF_EVEN  6 The IEEE 754 remainder function.
  // EUCLID     9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  //
  // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  // division (9) are commonly used for the modulus operation. The other rounding modes can also
  // be used, but they may not give useful results.
  modulo: 1,
  // 0 to 9
  // The exponent value at and beneath which `toString` returns exponential notation.
  // JavaScript numbers: -7
  toExpNeg: -7,
  // 0 to -EXP_LIMIT
  // The exponent value at and above which `toString` returns exponential notation.
  // JavaScript numbers: 21
  toExpPos: 21,
  // 0 to EXP_LIMIT
  // The minimum exponent value, beneath which underflow to zero occurs.
  // JavaScript numbers: -324  (5e-324)
  minE: -Sp,
  // -1 to -EXP_LIMIT
  // The maximum exponent value, above which overflow to Infinity occurs.
  // JavaScript numbers: 308  (1.7976931348623157e+308)
  maxE: Sp,
  // 1 to EXP_LIMIT
  // Whether to use cryptographically-secure random number generation, if available.
  crypto: !1
  // true/false
}, AU, Jc, vr = !0, U3 = "[DecimalError] ", jd = U3 + "Invalid argument: ", wU = U3 + "Precision limit exceeded", CU = U3 + "crypto unavailable", EU = "[object Decimal]", Qi = Math.floor, Ka = Math.pow, Bpe = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Ope = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, Fpe = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, DU = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, Iu = 1e7, rr = 7, Rpe = 9007199254740991, Lpe = Fy.length - 1, q_ = Ry.length - 1, vt = { toStringTag: EU };
vt.absoluteValue = vt.abs = function() {
  var e = new this.constructor(this);
  return e.s < 0 && (e.s = 1), Yt(e);
};
vt.ceil = function() {
  return Yt(new this.constructor(this), this.e + 1, 2);
};
vt.clampedTo = vt.clamp = function(e, t) {
  var r, n = this, a = n.constructor;
  if (e = new a(e), t = new a(t), !e.s || !t.s) return new a(NaN);
  if (e.gt(t)) throw Error(jd + t);
  return r = n.cmp(e), r < 0 ? e : n.cmp(t) > 0 ? t : new a(n);
};
vt.comparedTo = vt.cmp = function(e) {
  var t, r, n, a, i = this, o = i.d, s = (e = new i.constructor(e)).d, u = i.s, c = e.s;
  if (!o || !s)
    return !u || !c ? NaN : u !== c ? u : o === s ? 0 : !o ^ u < 0 ? 1 : -1;
  if (!o[0] || !s[0]) return o[0] ? u : s[0] ? -c : 0;
  if (u !== c) return u;
  if (i.e !== e.e) return i.e > e.e ^ u < 0 ? 1 : -1;
  for (n = o.length, a = s.length, t = 0, r = n < a ? n : a; t < r; ++t)
    if (o[t] !== s[t]) return o[t] > s[t] ^ u < 0 ? 1 : -1;
  return n === a ? 0 : n > a ^ u < 0 ? 1 : -1;
};
vt.cosine = vt.cos = function() {
  var e, t, r = this, n = r.constructor;
  return r.d ? r.d[0] ? (e = n.precision, t = n.rounding, n.precision = e + Math.max(r.e, r.sd()) + rr, n.rounding = 1, r = kpe(n, PU(n, r)), n.precision = e, n.rounding = t, Yt(Jc == 2 || Jc == 3 ? r.neg() : r, e, t, !0)) : new n(1) : new n(NaN);
};
vt.cubeRoot = vt.cbrt = function() {
  var e, t, r, n, a, i, o, s, u, c, l = this, d = l.constructor;
  if (!l.isFinite() || l.isZero()) return new d(l);
  for (vr = !1, i = l.s * Ka(l.s * l, 1 / 3), !i || Math.abs(i) == 1 / 0 ? (r = Pi(l.d), e = l.e, (i = (e - r.length + 1) % 3) && (r += i == 1 || i == -2 ? "0" : "00"), i = Ka(r, 1 / 3), e = Qi((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), i == 1 / 0 ? r = "5e" + e : (r = i.toExponential(), r = r.slice(0, r.indexOf("e") + 1) + e), n = new d(r), n.s = l.s) : n = new d(i.toString()), o = (e = d.precision) + 3; ; )
    if (s = n, u = s.times(s).times(s), c = u.plus(l), n = Vn(c.plus(l).times(s), c.plus(u), o + 2, 1), Pi(s.d).slice(0, o) === (r = Pi(n.d)).slice(0, o))
      if (r = r.slice(o - 3, o + 1), r == "9999" || !a && r == "4999") {
        if (!a && (Yt(s, e + 1, 0), s.times(s).times(s).eq(l))) {
          n = s;
          break;
        }
        o += 4, a = 1;
      } else {
        (!+r || !+r.slice(1) && r.charAt(0) == "5") && (Yt(n, e + 1, 1), t = !n.times(n).times(n).eq(l));
        break;
      }
  return vr = !0, Yt(n, e, d.rounding, t);
};
vt.decimalPlaces = vt.dp = function() {
  var e, t = this.d, r = NaN;
  if (t) {
    if (e = t.length - 1, r = (e - Qi(this.e / rr)) * rr, e = t[e], e) for (; e % 10 == 0; e /= 10) r--;
    r < 0 && (r = 0);
  }
  return r;
};
vt.dividedBy = vt.div = function(e) {
  return Vn(this, new this.constructor(e));
};
vt.dividedToIntegerBy = vt.divToInt = function(e) {
  var t = this, r = t.constructor;
  return Yt(Vn(t, new r(e), 0, 1, 1), r.precision, r.rounding);
};
vt.equals = vt.eq = function(e) {
  return this.cmp(e) === 0;
};
vt.floor = function() {
  return Yt(new this.constructor(this), this.e + 1, 3);
};
vt.greaterThan = vt.gt = function(e) {
  return this.cmp(e) > 0;
};
vt.greaterThanOrEqualTo = vt.gte = function(e) {
  var t = this.cmp(e);
  return t == 1 || t === 0;
};
vt.hyperbolicCosine = vt.cosh = function() {
  var e, t, r, n, a, i = this, o = i.constructor, s = new o(1);
  if (!i.isFinite()) return new o(i.s ? 1 / 0 : NaN);
  if (i.isZero()) return s;
  r = o.precision, n = o.rounding, o.precision = r + Math.max(i.e, i.sd()) + 4, o.rounding = 1, a = i.d.length, a < 32 ? (e = Math.ceil(a / 3), t = (1 / V3(4, e)).toString()) : (e = 16, t = "2.3283064365386962890625e-10"), i = o1(o, 1, i.times(t), new o(1), !0);
  for (var u, c = e, l = new o(8); c--; )
    u = i.times(i), i = s.minus(u.times(l.minus(u.times(l))));
  return Yt(i, o.precision = r, o.rounding = n, !0);
};
vt.hyperbolicSine = vt.sinh = function() {
  var e, t, r, n, a = this, i = a.constructor;
  if (!a.isFinite() || a.isZero()) return new i(a);
  if (t = i.precision, r = i.rounding, i.precision = t + Math.max(a.e, a.sd()) + 4, i.rounding = 1, n = a.d.length, n < 3)
    a = o1(i, 2, a, a, !0);
  else {
    e = 1.4 * Math.sqrt(n), e = e > 16 ? 16 : e | 0, a = a.times(1 / V3(5, e)), a = o1(i, 2, a, a, !0);
    for (var o, s = new i(5), u = new i(16), c = new i(20); e--; )
      o = a.times(a), a = a.times(s.plus(o.times(u.times(o).plus(c))));
  }
  return i.precision = t, i.rounding = r, Yt(a, t, r, !0);
};
vt.hyperbolicTangent = vt.tanh = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 7, n.rounding = 1, Vn(r.sinh(), r.cosh(), n.precision = e, n.rounding = t)) : new n(r.s);
};
vt.inverseCosine = vt.acos = function() {
  var e, t = this, r = t.constructor, n = t.abs().cmp(1), a = r.precision, i = r.rounding;
  return n !== -1 ? n === 0 ? t.isNeg() ? Eu(r, a, i) : new r(0) : new r(NaN) : t.isZero() ? Eu(r, a + 4, i).times(0.5) : (r.precision = a + 6, r.rounding = 1, t = t.asin(), e = Eu(r, a + 4, i).times(0.5), r.precision = a, r.rounding = i, e.minus(t));
};
vt.inverseHyperbolicCosine = vt.acosh = function() {
  var e, t, r = this, n = r.constructor;
  return r.lte(1) ? new n(r.eq(1) ? 0 : NaN) : r.isFinite() ? (e = n.precision, t = n.rounding, n.precision = e + Math.max(Math.abs(r.e), r.sd()) + 4, n.rounding = 1, vr = !1, r = r.times(r).minus(1).sqrt().plus(r), vr = !0, n.precision = e, n.rounding = t, r.ln()) : new n(r);
};
vt.inverseHyperbolicSine = vt.asinh = function() {
  var e, t, r = this, n = r.constructor;
  return !r.isFinite() || r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 2 * Math.max(Math.abs(r.e), r.sd()) + 6, n.rounding = 1, vr = !1, r = r.times(r).plus(1).sqrt().plus(r), vr = !0, n.precision = e, n.rounding = t, r.ln());
};
vt.inverseHyperbolicTangent = vt.atanh = function() {
  var e, t, r, n, a = this, i = a.constructor;
  return a.isFinite() ? a.e >= 0 ? new i(a.abs().eq(1) ? a.s / 0 : a.isZero() ? a : NaN) : (e = i.precision, t = i.rounding, n = a.sd(), Math.max(n, e) < 2 * -a.e - 1 ? Yt(new i(a), e, t, !0) : (i.precision = r = n - a.e, a = Vn(a.plus(1), new i(1).minus(a), r + e, 1), i.precision = e + 4, i.rounding = 1, a = a.ln(), i.precision = e, i.rounding = t, a.times(0.5))) : new i(NaN);
};
vt.inverseSine = vt.asin = function() {
  var e, t, r, n, a = this, i = a.constructor;
  return a.isZero() ? new i(a) : (t = a.abs().cmp(1), r = i.precision, n = i.rounding, t !== -1 ? t === 0 ? (e = Eu(i, r + 4, n).times(0.5), e.s = a.s, e) : new i(NaN) : (i.precision = r + 6, i.rounding = 1, a = a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(), i.precision = r, i.rounding = n, a.times(2)));
};
vt.inverseTangent = vt.atan = function() {
  var e, t, r, n, a, i, o, s, u, c = this, l = c.constructor, d = l.precision, f = l.rounding;
  if (c.isFinite()) {
    if (c.isZero())
      return new l(c);
    if (c.abs().eq(1) && d + 4 <= q_)
      return o = Eu(l, d + 4, f).times(0.25), o.s = c.s, o;
  } else {
    if (!c.s) return new l(NaN);
    if (d + 4 <= q_)
      return o = Eu(l, d + 4, f).times(0.5), o.s = c.s, o;
  }
  for (l.precision = s = d + 10, l.rounding = 1, r = Math.min(28, s / rr + 2 | 0), e = r; e; --e) c = c.div(c.times(c).plus(1).sqrt().plus(1));
  for (vr = !1, t = Math.ceil(s / rr), n = 1, u = c.times(c), o = new l(c), a = c; e !== -1; )
    if (a = a.times(u), i = o.minus(a.div(n += 2)), a = a.times(u), o = i.plus(a.div(n += 2)), o.d[t] !== void 0) for (e = t; o.d[e] === i.d[e] && e--; ) ;
  return r && (o = o.times(2 << r - 1)), vr = !0, Yt(o, l.precision = d, l.rounding = f, !0);
};
vt.isFinite = function() {
  return !!this.d;
};
vt.isInteger = vt.isInt = function() {
  return !!this.d && Qi(this.e / rr) > this.d.length - 2;
};
vt.isNaN = function() {
  return !this.s;
};
vt.isNegative = vt.isNeg = function() {
  return this.s < 0;
};
vt.isPositive = vt.isPos = function() {
  return this.s > 0;
};
vt.isZero = function() {
  return !!this.d && this.d[0] === 0;
};
vt.lessThan = vt.lt = function(e) {
  return this.cmp(e) < 0;
};
vt.lessThanOrEqualTo = vt.lte = function(e) {
  return this.cmp(e) < 1;
};
vt.logarithm = vt.log = function(e) {
  var t, r, n, a, i, o, s, u, c = this, l = c.constructor, d = l.precision, f = l.rounding, m = 5;
  if (e == null)
    e = new l(10), t = !0;
  else {
    if (e = new l(e), r = e.d, e.s < 0 || !r || !r[0] || e.eq(1)) return new l(NaN);
    t = e.eq(10);
  }
  if (r = c.d, c.s < 0 || !r || !r[0] || c.eq(1))
    return new l(r && !r[0] ? -1 / 0 : c.s != 1 ? NaN : r ? 0 : 1 / 0);
  if (t)
    if (r.length > 1)
      i = !0;
    else {
      for (a = r[0]; a % 10 === 0; ) a /= 10;
      i = a !== 1;
    }
  if (vr = !1, s = d + m, o = Pd(c, s), n = t ? Ly(l, s + 10) : Pd(e, s), u = Vn(o, n, s, 1), Dh(u.d, a = d, f))
    do
      if (s += 10, o = Pd(c, s), n = t ? Ly(l, s + 10) : Pd(e, s), u = Vn(o, n, s, 1), !i) {
        +Pi(u.d).slice(a + 1, a + 15) + 1 == 1e14 && (u = Yt(u, d + 1, 0));
        break;
      }
    while (Dh(u.d, a += 10, f));
  return vr = !0, Yt(u, d, f);
};
vt.minus = vt.sub = function(e) {
  var t, r, n, a, i, o, s, u, c, l, d, f, m = this, h = m.constructor;
  if (e = new h(e), !m.d || !e.d)
    return !m.s || !e.s ? e = new h(NaN) : m.d ? e.s = -e.s : e = new h(e.d || m.s !== e.s ? m : NaN), e;
  if (m.s != e.s)
    return e.s = -e.s, m.plus(e);
  if (c = m.d, f = e.d, s = h.precision, u = h.rounding, !c[0] || !f[0]) {
    if (f[0]) e.s = -e.s;
    else if (c[0]) e = new h(m);
    else return new h(u === 3 ? -0 : 0);
    return vr ? Yt(e, s, u) : e;
  }
  if (r = Qi(e.e / rr), l = Qi(m.e / rr), c = c.slice(), i = l - r, i) {
    for (d = i < 0, d ? (t = c, i = -i, o = f.length) : (t = f, r = l, o = c.length), n = Math.max(Math.ceil(s / rr), o) + 2, i > n && (i = n, t.length = 1), t.reverse(), n = i; n--; ) t.push(0);
    t.reverse();
  } else {
    for (n = c.length, o = f.length, d = n < o, d && (o = n), n = 0; n < o; n++)
      if (c[n] != f[n]) {
        d = c[n] < f[n];
        break;
      }
    i = 0;
  }
  for (d && (t = c, c = f, f = t, e.s = -e.s), o = c.length, n = f.length - o; n > 0; --n) c[o++] = 0;
  for (n = f.length; n > i; ) {
    if (c[--n] < f[n]) {
      for (a = n; a && c[--a] === 0; ) c[a] = Iu - 1;
      --c[a], c[n] += Iu;
    }
    c[n] -= f[n];
  }
  for (; c[--o] === 0; ) c.pop();
  for (; c[0] === 0; c.shift()) --r;
  return c[0] ? (e.d = c, e.e = G3(c, r), vr ? Yt(e, s, u) : e) : new h(u === 3 ? -0 : 0);
};
vt.modulo = vt.mod = function(e) {
  var t, r = this, n = r.constructor;
  return e = new n(e), !r.d || !e.s || e.d && !e.d[0] ? new n(NaN) : !e.d || r.d && !r.d[0] ? Yt(new n(r), n.precision, n.rounding) : (vr = !1, n.modulo == 9 ? (t = Vn(r, e.abs(), 0, 3, 1), t.s *= e.s) : t = Vn(r, e, 0, n.modulo, 1), t = t.times(e), vr = !0, r.minus(t));
};
vt.naturalExponential = vt.exp = function() {
  return H_(this);
};
vt.naturalLogarithm = vt.ln = function() {
  return Pd(this);
};
vt.negated = vt.neg = function() {
  var e = new this.constructor(this);
  return e.s = -e.s, Yt(e);
};
vt.plus = vt.add = function(e) {
  var t, r, n, a, i, o, s, u, c, l, d = this, f = d.constructor;
  if (e = new f(e), !d.d || !e.d)
    return !d.s || !e.s ? e = new f(NaN) : d.d || (e = new f(e.d || d.s === e.s ? d : NaN)), e;
  if (d.s != e.s)
    return e.s = -e.s, d.minus(e);
  if (c = d.d, l = e.d, s = f.precision, u = f.rounding, !c[0] || !l[0])
    return l[0] || (e = new f(d)), vr ? Yt(e, s, u) : e;
  if (i = Qi(d.e / rr), n = Qi(e.e / rr), c = c.slice(), a = i - n, a) {
    for (a < 0 ? (r = c, a = -a, o = l.length) : (r = l, n = i, o = c.length), i = Math.ceil(s / rr), o = i > o ? i + 1 : o + 1, a > o && (a = o, r.length = 1), r.reverse(); a--; ) r.push(0);
    r.reverse();
  }
  for (o = c.length, a = l.length, o - a < 0 && (a = o, r = l, l = c, c = r), t = 0; a; )
    t = (c[--a] = c[a] + l[a] + t) / Iu | 0, c[a] %= Iu;
  for (t && (c.unshift(t), ++n), o = c.length; c[--o] == 0; ) c.pop();
  return e.d = c, e.e = G3(c, n), vr ? Yt(e, s, u) : e;
};
vt.precision = vt.sd = function(e) {
  var t, r = this;
  if (e !== void 0 && e !== !!e && e !== 1 && e !== 0) throw Error(jd + e);
  return r.d ? (t = MU(r.d), e && r.e + 1 > t && (t = r.e + 1)) : t = NaN, t;
};
vt.round = function() {
  var e = this, t = e.constructor;
  return Yt(new t(e), e.e + 1, t.rounding);
};
vt.sine = vt.sin = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + Math.max(r.e, r.sd()) + rr, n.rounding = 1, r = Upe(n, PU(n, r)), n.precision = e, n.rounding = t, Yt(Jc > 2 ? r.neg() : r, e, t, !0)) : new n(NaN);
};
vt.squareRoot = vt.sqrt = function() {
  var e, t, r, n, a, i, o = this, s = o.d, u = o.e, c = o.s, l = o.constructor;
  if (c !== 1 || !s || !s[0])
    return new l(!c || c < 0 && (!s || s[0]) ? NaN : s ? o : 1 / 0);
  for (vr = !1, c = Math.sqrt(+o), c == 0 || c == 1 / 0 ? (t = Pi(s), (t.length + u) % 2 == 0 && (t += "0"), c = Math.sqrt(t), u = Qi((u + 1) / 2) - (u < 0 || u % 2), c == 1 / 0 ? t = "5e" + u : (t = c.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + u), n = new l(t)) : n = new l(c.toString()), r = (u = l.precision) + 3; ; )
    if (i = n, n = i.plus(Vn(o, i, r + 2, 1)).times(0.5), Pi(i.d).slice(0, r) === (t = Pi(n.d)).slice(0, r))
      if (t = t.slice(r - 3, r + 1), t == "9999" || !a && t == "4999") {
        if (!a && (Yt(i, u + 1, 0), i.times(i).eq(o))) {
          n = i;
          break;
        }
        r += 4, a = 1;
      } else {
        (!+t || !+t.slice(1) && t.charAt(0) == "5") && (Yt(n, u + 1, 1), e = !n.times(n).eq(o));
        break;
      }
  return vr = !0, Yt(n, u, l.rounding, e);
};
vt.tangent = vt.tan = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 10, n.rounding = 1, r = r.sin(), r.s = 1, r = Vn(r, new n(1).minus(r.times(r)).sqrt(), e + 10, 0), n.precision = e, n.rounding = t, Yt(Jc == 2 || Jc == 4 ? r.neg() : r, e, t, !0)) : new n(NaN);
};
vt.times = vt.mul = function(e) {
  var t, r, n, a, i, o, s, u, c, l = this, d = l.constructor, f = l.d, m = (e = new d(e)).d;
  if (e.s *= l.s, !f || !f[0] || !m || !m[0])
    return new d(!e.s || f && !f[0] && !m || m && !m[0] && !f ? NaN : !f || !m ? e.s / 0 : e.s * 0);
  for (r = Qi(l.e / rr) + Qi(e.e / rr), u = f.length, c = m.length, u < c && (i = f, f = m, m = i, o = u, u = c, c = o), i = [], o = u + c, n = o; n--; ) i.push(0);
  for (n = c; --n >= 0; ) {
    for (t = 0, a = u + n; a > n; )
      s = i[a] + m[n] * f[a - n - 1] + t, i[a--] = s % Iu | 0, t = s / Iu | 0;
    i[a] = (i[a] + t) % Iu | 0;
  }
  for (; !i[--o]; ) i.pop();
  return t ? ++r : i.shift(), e.d = i, e.e = G3(i, r), vr ? Yt(e, d.precision, d.rounding) : e;
};
vt.toBinary = function(e, t) {
  return CS(this, 2, e, t);
};
vt.toDecimalPlaces = vt.toDP = function(e, t) {
  var r = this, n = r.constructor;
  return r = new n(r), e === void 0 ? r : (Ko(e, 0, Jd), t === void 0 ? t = n.rounding : Ko(t, 0, 8), Yt(r, e + r.e + 1, t));
};
vt.toExponential = function(e, t) {
  var r, n = this, a = n.constructor;
  return e === void 0 ? r = hc(n, !0) : (Ko(e, 0, Jd), t === void 0 ? t = a.rounding : Ko(t, 0, 8), n = Yt(new a(n), e + 1, t), r = hc(n, !0, e + 1)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
vt.toFixed = function(e, t) {
  var r, n, a = this, i = a.constructor;
  return e === void 0 ? r = hc(a) : (Ko(e, 0, Jd), t === void 0 ? t = i.rounding : Ko(t, 0, 8), n = Yt(new i(a), e + a.e + 1, t), r = hc(n, !1, e + n.e + 1)), a.isNeg() && !a.isZero() ? "-" + r : r;
};
vt.toFraction = function(e) {
  var t, r, n, a, i, o, s, u, c, l, d, f, m = this, h = m.d, p = m.constructor;
  if (!h) return new p(m);
  if (c = r = new p(1), n = u = new p(0), t = new p(n), i = t.e = MU(h) - m.e - 1, o = i % rr, t.d[0] = Ka(10, o < 0 ? rr + o : o), e == null)
    e = i > 0 ? t : c;
  else {
    if (s = new p(e), !s.isInt() || s.lt(c)) throw Error(jd + s);
    e = s.gt(t) ? i > 0 ? t : c : s;
  }
  for (vr = !1, s = new p(Pi(h)), l = p.precision, p.precision = i = h.length * rr * 2; d = Vn(s, t, 0, 1, 1), a = r.plus(d.times(n)), a.cmp(e) != 1; )
    r = n, n = a, a = c, c = u.plus(d.times(a)), u = a, a = t, t = s.minus(d.times(a)), s = a;
  return a = Vn(e.minus(r), n, 0, 1, 1), u = u.plus(a.times(c)), r = r.plus(a.times(n)), u.s = c.s = m.s, f = Vn(c, n, i, 1).minus(m).abs().cmp(Vn(u, r, i, 1).minus(m).abs()) < 1 ? [c, n] : [u, r], p.precision = l, vr = !0, f;
};
vt.toHexadecimal = vt.toHex = function(e, t) {
  return CS(this, 16, e, t);
};
vt.toNearest = function(e, t) {
  var r = this, n = r.constructor;
  if (r = new n(r), e == null) {
    if (!r.d) return r;
    e = new n(1), t = n.rounding;
  } else {
    if (e = new n(e), t === void 0 ? t = n.rounding : Ko(t, 0, 8), !r.d) return e.s ? r : e;
    if (!e.d)
      return e.s && (e.s = r.s), e;
  }
  return e.d[0] ? (vr = !1, r = Vn(r, e, 0, t, 1).times(e), vr = !0, Yt(r)) : (e.s = r.s, r = e), r;
};
vt.toNumber = function() {
  return +this;
};
vt.toOctal = function(e, t) {
  return CS(this, 8, e, t);
};
vt.toPower = vt.pow = function(e) {
  var t, r, n, a, i, o, s = this, u = s.constructor, c = +(e = new u(e));
  if (!s.d || !e.d || !s.d[0] || !e.d[0]) return new u(Ka(+s, c));
  if (s = new u(s), s.eq(1)) return s;
  if (n = u.precision, i = u.rounding, e.eq(1)) return Yt(s, n, i);
  if (t = Qi(e.e / rr), t >= e.d.length - 1 && (r = c < 0 ? -c : c) <= Rpe)
    return a = IU(u, s, r, n), e.s < 0 ? new u(1).div(a) : Yt(a, n, i);
  if (o = s.s, o < 0) {
    if (t < e.d.length - 1) return new u(NaN);
    if (e.d[t] & 1 || (o = 1), s.e == 0 && s.d[0] == 1 && s.d.length == 1)
      return s.s = o, s;
  }
  return r = Ka(+s, c), t = r == 0 || !isFinite(r) ? Qi(c * (Math.log("0." + Pi(s.d)) / Math.LN10 + s.e + 1)) : new u(r + "").e, t > u.maxE + 1 || t < u.minE - 1 ? new u(t > 0 ? o / 0 : 0) : (vr = !1, u.rounding = s.s = 1, r = Math.min(12, (t + "").length), a = H_(e.times(Pd(s, n + r)), n), a.d && (a = Yt(a, n + 5, 1), Dh(a.d, n, i) && (t = n + 10, a = Yt(H_(e.times(Pd(s, t + r)), t), t + 5, 1), +Pi(a.d).slice(n + 1, n + 15) + 1 == 1e14 && (a = Yt(a, n + 1, 0)))), a.s = o, vr = !0, u.rounding = i, Yt(a, n, i));
};
vt.toPrecision = function(e, t) {
  var r, n = this, a = n.constructor;
  return e === void 0 ? r = hc(n, n.e <= a.toExpNeg || n.e >= a.toExpPos) : (Ko(e, 1, Jd), t === void 0 ? t = a.rounding : Ko(t, 0, 8), n = Yt(new a(n), e, t), r = hc(n, e <= n.e || n.e <= a.toExpNeg, e)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
vt.toSignificantDigits = vt.toSD = function(e, t) {
  var r = this, n = r.constructor;
  return e === void 0 ? (e = n.precision, t = n.rounding) : (Ko(e, 1, Jd), t === void 0 ? t = n.rounding : Ko(t, 0, 8)), Yt(new n(r), e, t);
};
vt.toString = function() {
  var e = this, t = e.constructor, r = hc(e, e.e <= t.toExpNeg || e.e >= t.toExpPos);
  return e.isNeg() && !e.isZero() ? "-" + r : r;
};
vt.truncated = vt.trunc = function() {
  return Yt(new this.constructor(this), this.e + 1, 1);
};
vt.valueOf = vt.toJSON = function() {
  var e = this, t = e.constructor, r = hc(e, e.e <= t.toExpNeg || e.e >= t.toExpPos);
  return e.isNeg() ? "-" + r : r;
};
function Pi(e) {
  var t, r, n, a = e.length - 1, i = "", o = e[0];
  if (a > 0) {
    for (i += o, t = 1; t < a; t++)
      n = e[t] + "", r = rr - n.length, r && (i += fd(r)), i += n;
    o = e[t], n = o + "", r = rr - n.length, r && (i += fd(r));
  } else if (o === 0)
    return "0";
  for (; o % 10 === 0; ) o /= 10;
  return i + o;
}
function Ko(e, t, r) {
  if (e !== ~~e || e < t || e > r)
    throw Error(jd + e);
}
function Dh(e, t, r, n) {
  var a, i, o, s;
  for (i = e[0]; i >= 10; i /= 10) --t;
  return --t < 0 ? (t += rr, a = 0) : (a = Math.ceil((t + 1) / rr), t %= rr), i = Ka(10, rr - t), s = e[a] % i | 0, n == null ? t < 3 ? (t == 0 ? s = s / 100 | 0 : t == 1 && (s = s / 10 | 0), o = r < 4 && s == 99999 || r > 3 && s == 49999 || s == 5e4 || s == 0) : o = (r < 4 && s + 1 == i || r > 3 && s + 1 == i / 2) && (e[a + 1] / i / 100 | 0) == Ka(10, t - 2) - 1 || (s == i / 2 || s == 0) && (e[a + 1] / i / 100 | 0) == 0 : t < 4 ? (t == 0 ? s = s / 1e3 | 0 : t == 1 ? s = s / 100 | 0 : t == 2 && (s = s / 10 | 0), o = (n || r < 4) && s == 9999 || !n && r > 3 && s == 4999) : o = ((n || r < 4) && s + 1 == i || !n && r > 3 && s + 1 == i / 2) && (e[a + 1] / i / 1e3 | 0) == Ka(10, t - 3) - 1, o;
}
function F2(e, t, r) {
  for (var n, a = [0], i, o = 0, s = e.length; o < s; ) {
    for (i = a.length; i--; ) a[i] *= t;
    for (a[0] += G_.indexOf(e.charAt(o++)), n = 0; n < a.length; n++)
      a[n] > r - 1 && (a[n + 1] === void 0 && (a[n + 1] = 0), a[n + 1] += a[n] / r | 0, a[n] %= r);
  }
  return a.reverse();
}
function kpe(e, t) {
  var r, n, a;
  if (t.isZero()) return t;
  n = t.d.length, n < 32 ? (r = Math.ceil(n / 3), a = (1 / V3(4, r)).toString()) : (r = 16, a = "2.3283064365386962890625e-10"), e.precision += r, t = o1(e, 1, t.times(a), new e(1));
  for (var i = r; i--; ) {
    var o = t.times(t);
    t = o.times(o).minus(o).times(8).plus(1);
  }
  return e.precision -= r, t;
}
var Vn = /* @__PURE__ */ function() {
  function e(n, a, i) {
    var o, s = 0, u = n.length;
    for (n = n.slice(); u--; )
      o = n[u] * a + s, n[u] = o % i | 0, s = o / i | 0;
    return s && n.unshift(s), n;
  }
  function t(n, a, i, o) {
    var s, u;
    if (i != o)
      u = i > o ? 1 : -1;
    else
      for (s = u = 0; s < i; s++)
        if (n[s] != a[s]) {
          u = n[s] > a[s] ? 1 : -1;
          break;
        }
    return u;
  }
  function r(n, a, i, o) {
    for (var s = 0; i--; )
      n[i] -= s, s = n[i] < a[i] ? 1 : 0, n[i] = s * o + n[i] - a[i];
    for (; !n[0] && n.length > 1; ) n.shift();
  }
  return function(n, a, i, o, s, u) {
    var c, l, d, f, m, h, p, g, v, y, _, S, b, x, A, w, C, M, T, N, I = n.constructor, P = n.s == a.s ? 1 : -1, O = n.d, F = a.d;
    if (!O || !O[0] || !F || !F[0])
      return new I(
        // Return NaN if either NaN, or both Infinity or 0.
        !n.s || !a.s || (O ? F && O[0] == F[0] : !F) ? NaN : (
          // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
          O && O[0] == 0 || !F ? P * 0 : P / 0
        )
      );
    for (u ? (m = 1, l = n.e - a.e) : (u = Iu, m = rr, l = Qi(n.e / m) - Qi(a.e / m)), T = F.length, C = O.length, v = new I(P), y = v.d = [], d = 0; F[d] == (O[d] || 0); d++) ;
    if (F[d] > (O[d] || 0) && l--, i == null ? (x = i = I.precision, o = I.rounding) : s ? x = i + (n.e - a.e) + 1 : x = i, x < 0)
      y.push(1), h = !0;
    else {
      if (x = x / m + 2 | 0, d = 0, T == 1) {
        for (f = 0, F = F[0], x++; (d < C || f) && x--; d++)
          A = f * u + (O[d] || 0), y[d] = A / F | 0, f = A % F | 0;
        h = f || d < C;
      } else {
        for (f = u / (F[0] + 1) | 0, f > 1 && (F = e(F, f, u), O = e(O, f, u), T = F.length, C = O.length), w = T, _ = O.slice(0, T), S = _.length; S < T; ) _[S++] = 0;
        N = F.slice(), N.unshift(0), M = F[0], F[1] >= u / 2 && ++M;
        do
          f = 0, c = t(F, _, T, S), c < 0 ? (b = _[0], T != S && (b = b * u + (_[1] || 0)), f = b / M | 0, f > 1 ? (f >= u && (f = u - 1), p = e(F, f, u), g = p.length, S = _.length, c = t(p, _, g, S), c == 1 && (f--, r(p, T < g ? N : F, g, u))) : (f == 0 && (c = f = 1), p = F.slice()), g = p.length, g < S && p.unshift(0), r(_, p, S, u), c == -1 && (S = _.length, c = t(F, _, T, S), c < 1 && (f++, r(_, T < S ? N : F, S, u))), S = _.length) : c === 0 && (f++, _ = [0]), y[d++] = f, c && _[0] ? _[S++] = O[w] || 0 : (_ = [O[w]], S = 1);
        while ((w++ < C || _[0] !== void 0) && x--);
        h = _[0] !== void 0;
      }
      y[0] || y.shift();
    }
    if (m == 1)
      v.e = l, AU = h;
    else {
      for (d = 1, f = y[0]; f >= 10; f /= 10) d++;
      v.e = d + l * m - 1, Yt(v, s ? i + v.e + 1 : i, o, h);
    }
    return v;
  };
}();
function Yt(e, t, r, n) {
  var a, i, o, s, u, c, l, d, f, m = e.constructor;
  e: if (t != null) {
    if (d = e.d, !d) return e;
    for (a = 1, s = d[0]; s >= 10; s /= 10) a++;
    if (i = t - a, i < 0)
      i += rr, o = t, l = d[f = 0], u = l / Ka(10, a - o - 1) % 10 | 0;
    else if (f = Math.ceil((i + 1) / rr), s = d.length, f >= s)
      if (n) {
        for (; s++ <= f; ) d.push(0);
        l = u = 0, a = 1, i %= rr, o = i - rr + 1;
      } else
        break e;
    else {
      for (l = s = d[f], a = 1; s >= 10; s /= 10) a++;
      i %= rr, o = i - rr + a, u = o < 0 ? 0 : l / Ka(10, a - o - 1) % 10 | 0;
    }
    if (n = n || t < 0 || d[f + 1] !== void 0 || (o < 0 ? l : l % Ka(10, a - o - 1)), c = r < 4 ? (u || n) && (r == 0 || r == (e.s < 0 ? 3 : 2)) : u > 5 || u == 5 && (r == 4 || n || r == 6 && // Check whether the digit to the left of the rounding digit is odd.
    (i > 0 ? o > 0 ? l / Ka(10, a - o) : 0 : d[f - 1]) % 10 & 1 || r == (e.s < 0 ? 8 : 7)), t < 1 || !d[0])
      return d.length = 0, c ? (t -= e.e + 1, d[0] = Ka(10, (rr - t % rr) % rr), e.e = -t || 0) : d[0] = e.e = 0, e;
    if (i == 0 ? (d.length = f, s = 1, f--) : (d.length = f + 1, s = Ka(10, rr - i), d[f] = o > 0 ? (l / Ka(10, a - o) % Ka(10, o) | 0) * s : 0), c)
      for (; ; )
        if (f == 0) {
          for (i = 1, o = d[0]; o >= 10; o /= 10) i++;
          for (o = d[0] += s, s = 1; o >= 10; o /= 10) s++;
          i != s && (e.e++, d[0] == Iu && (d[0] = 1));
          break;
        } else {
          if (d[f] += s, d[f] != Iu) break;
          d[f--] = 0, s = 1;
        }
    for (i = d.length; d[--i] === 0; ) d.pop();
  }
  return vr && (e.e > m.maxE ? (e.d = null, e.e = NaN) : e.e < m.minE && (e.e = 0, e.d = [0])), e;
}
function hc(e, t, r) {
  if (!e.isFinite()) return NU(e);
  var n, a = e.e, i = Pi(e.d), o = i.length;
  return t ? (r && (n = r - o) > 0 ? i = i.charAt(0) + "." + i.slice(1) + fd(n) : o > 1 && (i = i.charAt(0) + "." + i.slice(1)), i = i + (e.e < 0 ? "e" : "e+") + e.e) : a < 0 ? (i = "0." + fd(-a - 1) + i, r && (n = r - o) > 0 && (i += fd(n))) : a >= o ? (i += fd(a + 1 - o), r && (n = r - a - 1) > 0 && (i = i + "." + fd(n))) : ((n = a + 1) < o && (i = i.slice(0, n) + "." + i.slice(n)), r && (n = r - o) > 0 && (a + 1 === o && (i += "."), i += fd(n))), i;
}
function G3(e, t) {
  var r = e[0];
  for (t *= rr; r >= 10; r /= 10) t++;
  return t;
}
function Ly(e, t, r) {
  if (t > Lpe)
    throw vr = !0, r && (e.precision = r), Error(wU);
  return Yt(new e(Fy), t, 1, !0);
}
function Eu(e, t, r) {
  if (t > q_) throw Error(wU);
  return Yt(new e(Ry), t, r, !0);
}
function MU(e) {
  var t = e.length - 1, r = t * rr + 1;
  if (t = e[t], t) {
    for (; t % 10 == 0; t /= 10) r--;
    for (t = e[0]; t >= 10; t /= 10) r++;
  }
  return r;
}
function fd(e) {
  for (var t = ""; e--; ) t += "0";
  return t;
}
function IU(e, t, r, n) {
  var a, i = new e(1), o = Math.ceil(n / rr + 4);
  for (vr = !1; ; ) {
    if (r % 2 && (i = i.times(t), HI(i.d, o) && (a = !0)), r = Qi(r / 2), r === 0) {
      r = i.d.length - 1, a && i.d[r] === 0 && ++i.d[r];
      break;
    }
    t = t.times(t), HI(t.d, o);
  }
  return vr = !0, i;
}
function qI(e) {
  return e.d[e.d.length - 1] & 1;
}
function TU(e, t, r) {
  for (var n, a = new e(t[0]), i = 0; ++i < t.length; )
    if (n = new e(t[i]), n.s)
      a[r](n) && (a = n);
    else {
      a = n;
      break;
    }
  return a;
}
function H_(e, t) {
  var r, n, a, i, o, s, u, c = 0, l = 0, d = 0, f = e.constructor, m = f.rounding, h = f.precision;
  if (!e.d || !e.d[0] || e.e > 17)
    return new f(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN);
  for (t == null ? (vr = !1, u = h) : u = t, s = new f(0.03125); e.e > -2; )
    e = e.times(s), d += 5;
  for (n = Math.log(Ka(2, d)) / Math.LN10 * 2 + 5 | 0, u += n, r = i = o = new f(1), f.precision = u; ; ) {
    if (i = Yt(i.times(e), u, 1), r = r.times(++l), s = o.plus(Vn(i, r, u, 1)), Pi(s.d).slice(0, u) === Pi(o.d).slice(0, u)) {
      for (a = d; a--; ) o = Yt(o.times(o), u, 1);
      if (t == null)
        if (c < 3 && Dh(o.d, u - n, m, c))
          f.precision = u += 10, r = i = s = new f(1), l = 0, c++;
        else
          return Yt(o, f.precision = h, m, vr = !0);
      else
        return f.precision = h, o;
    }
    o = s;
  }
}
function Pd(e, t) {
  var r, n, a, i, o, s, u, c, l, d, f, m = 1, h = 10, p = e, g = p.d, v = p.constructor, y = v.rounding, _ = v.precision;
  if (p.s < 0 || !g || !g[0] || !p.e && g[0] == 1 && g.length == 1)
    return new v(g && !g[0] ? -1 / 0 : p.s != 1 ? NaN : g ? 0 : p);
  if (t == null ? (vr = !1, l = _) : l = t, v.precision = l += h, r = Pi(g), n = r.charAt(0), Math.abs(i = p.e) < 15e14) {
    for (; n < 7 && n != 1 || n == 1 && r.charAt(1) > 3; )
      p = p.times(e), r = Pi(p.d), n = r.charAt(0), m++;
    i = p.e, n > 1 ? (p = new v("0." + r), i++) : p = new v(n + "." + r.slice(1));
  } else
    return c = Ly(v, l + 2, _).times(i + ""), p = Pd(new v(n + "." + r.slice(1)), l - h).plus(c), v.precision = _, t == null ? Yt(p, _, y, vr = !0) : p;
  for (d = p, u = o = p = Vn(p.minus(1), p.plus(1), l, 1), f = Yt(p.times(p), l, 1), a = 3; ; ) {
    if (o = Yt(o.times(f), l, 1), c = u.plus(Vn(o, new v(a), l, 1)), Pi(c.d).slice(0, l) === Pi(u.d).slice(0, l))
      if (u = u.times(2), i !== 0 && (u = u.plus(Ly(v, l + 2, _).times(i + ""))), u = Vn(u, new v(m), l, 1), t == null)
        if (Dh(u.d, l - h, y, s))
          v.precision = l += h, c = o = p = Vn(d.minus(1), d.plus(1), l, 1), f = Yt(p.times(p), l, 1), a = s = 1;
        else
          return Yt(u, v.precision = _, y, vr = !0);
      else
        return v.precision = _, u;
    u = c, a += 2;
  }
}
function NU(e) {
  return String(e.s * e.s / 0);
}
function K_(e, t) {
  var r, n, a;
  for ((r = t.indexOf(".")) > -1 && (t = t.replace(".", "")), (n = t.search(/e/i)) > 0 ? (r < 0 && (r = n), r += +t.slice(n + 1), t = t.substring(0, n)) : r < 0 && (r = t.length), n = 0; t.charCodeAt(n) === 48; n++) ;
  for (a = t.length; t.charCodeAt(a - 1) === 48; --a) ;
  if (t = t.slice(n, a), t) {
    if (a -= n, e.e = r = r - n - 1, e.d = [], n = (r + 1) % rr, r < 0 && (n += rr), n < a) {
      for (n && e.d.push(+t.slice(0, n)), a -= rr; n < a; ) e.d.push(+t.slice(n, n += rr));
      t = t.slice(n), n = rr - t.length;
    } else
      n -= a;
    for (; n--; ) t += "0";
    e.d.push(+t), vr && (e.e > e.constructor.maxE ? (e.d = null, e.e = NaN) : e.e < e.constructor.minE && (e.e = 0, e.d = [0]));
  } else
    e.e = 0, e.d = [0];
  return e;
}
function zpe(e, t) {
  var r, n, a, i, o, s, u, c, l;
  if (t.indexOf("_") > -1) {
    if (t = t.replace(/(\d)_(?=\d)/g, "$1"), DU.test(t)) return K_(e, t);
  } else if (t === "Infinity" || t === "NaN")
    return +t || (e.s = NaN), e.e = NaN, e.d = null, e;
  if (Ope.test(t))
    r = 16, t = t.toLowerCase();
  else if (Bpe.test(t))
    r = 2;
  else if (Fpe.test(t))
    r = 8;
  else
    throw Error(jd + t);
  for (i = t.search(/p/i), i > 0 ? (u = +t.slice(i + 1), t = t.substring(2, i)) : t = t.slice(2), i = t.indexOf("."), o = i >= 0, n = e.constructor, o && (t = t.replace(".", ""), s = t.length, i = s - i, a = IU(n, new n(r), i, i * 2)), c = F2(t, r, Iu), l = c.length - 1, i = l; c[i] === 0; --i) c.pop();
  return i < 0 ? new n(e.s * 0) : (e.e = G3(c, l), e.d = c, vr = !1, o && (e = Vn(e, a, s * 4)), u && (e = e.times(Math.abs(u) < 54 ? Ka(2, u) : Yd.pow(2, u))), vr = !0, e);
}
function Upe(e, t) {
  var r, n = t.d.length;
  if (n < 3)
    return t.isZero() ? t : o1(e, 2, t, t);
  r = 1.4 * Math.sqrt(n), r = r > 16 ? 16 : r | 0, t = t.times(1 / V3(5, r)), t = o1(e, 2, t, t);
  for (var a, i = new e(5), o = new e(16), s = new e(20); r--; )
    a = t.times(t), t = t.times(i.plus(a.times(o.times(a).minus(s))));
  return t;
}
function o1(e, t, r, n, a) {
  var i, o, s, u, c = e.precision, l = Math.ceil(c / rr);
  for (vr = !1, u = r.times(r), s = new e(n); ; ) {
    if (o = Vn(s.times(u), new e(t++ * t++), c, 1), s = a ? n.plus(o) : n.minus(o), n = Vn(o.times(u), new e(t++ * t++), c, 1), o = s.plus(n), o.d[l] !== void 0) {
      for (i = l; o.d[i] === s.d[i] && i--; ) ;
      if (i == -1) break;
    }
    i = s, s = n, n = o, o = i;
  }
  return vr = !0, o.d.length = l + 1, o;
}
function V3(e, t) {
  for (var r = e; --t; ) r *= e;
  return r;
}
function PU(e, t) {
  var r, n = t.s < 0, a = Eu(e, e.precision, 1), i = a.times(0.5);
  if (t = t.abs(), t.lte(i))
    return Jc = n ? 4 : 1, t;
  if (r = t.divToInt(a), r.isZero())
    Jc = n ? 3 : 2;
  else {
    if (t = t.minus(r.times(a)), t.lte(i))
      return Jc = qI(r) ? n ? 2 : 3 : n ? 4 : 1, t;
    Jc = qI(r) ? n ? 1 : 4 : n ? 3 : 2;
  }
  return t.minus(a).abs();
}
function CS(e, t, r, n) {
  var a, i, o, s, u, c, l, d, f, m = e.constructor, h = r !== void 0;
  if (h ? (Ko(r, 1, Jd), n === void 0 ? n = m.rounding : Ko(n, 0, 8)) : (r = m.precision, n = m.rounding), !e.isFinite())
    l = NU(e);
  else {
    for (l = hc(e), o = l.indexOf("."), h ? (a = 2, t == 16 ? r = r * 4 - 3 : t == 8 && (r = r * 3 - 2)) : a = t, o >= 0 && (l = l.replace(".", ""), f = new m(1), f.e = l.length - o, f.d = F2(hc(f), 10, a), f.e = f.d.length), d = F2(l, 10, a), i = u = d.length; d[--u] == 0; ) d.pop();
    if (!d[0])
      l = h ? "0p+0" : "0";
    else {
      if (o < 0 ? i-- : (e = new m(e), e.d = d, e.e = i, e = Vn(e, f, r, n, 0, a), d = e.d, i = e.e, c = AU), o = d[r], s = a / 2, c = c || d[r + 1] !== void 0, c = n < 4 ? (o !== void 0 || c) && (n === 0 || n === (e.s < 0 ? 3 : 2)) : o > s || o === s && (n === 4 || c || n === 6 && d[r - 1] & 1 || n === (e.s < 0 ? 8 : 7)), d.length = r, c)
        for (; ++d[--r] > a - 1; )
          d[r] = 0, r || (++i, d.unshift(1));
      for (u = d.length; !d[u - 1]; --u) ;
      for (o = 0, l = ""; o < u; o++) l += G_.charAt(d[o]);
      if (h) {
        if (u > 1)
          if (t == 16 || t == 8) {
            for (o = t == 16 ? 4 : 3, --u; u % o; u++) l += "0";
            for (d = F2(l, a, t), u = d.length; !d[u - 1]; --u) ;
            for (o = 1, l = "1."; o < u; o++) l += G_.charAt(d[o]);
          } else
            l = l.charAt(0) + "." + l.slice(1);
        l = l + (i < 0 ? "p" : "p+") + i;
      } else if (i < 0) {
        for (; ++i; ) l = "0" + l;
        l = "0." + l;
      } else if (++i > u) for (i -= u; i--; ) l += "0";
      else i < u && (l = l.slice(0, i) + "." + l.slice(i));
    }
    l = (t == 16 ? "0x" : t == 2 ? "0b" : t == 8 ? "0o" : "") + l;
  }
  return e.s < 0 ? "-" + l : l;
}
function HI(e, t) {
  if (e.length > t)
    return e.length = t, !0;
}
function Gpe(e) {
  return new this(e).abs();
}
function Vpe(e) {
  return new this(e).acos();
}
function qpe(e) {
  return new this(e).acosh();
}
function Hpe(e, t) {
  return new this(e).plus(t);
}
function Kpe(e) {
  return new this(e).asin();
}
function Xpe(e) {
  return new this(e).asinh();
}
function jpe(e) {
  return new this(e).atan();
}
function Ype(e) {
  return new this(e).atanh();
}
function Wpe(e, t) {
  e = new this(e), t = new this(t);
  var r, n = this.precision, a = this.rounding, i = n + 4;
  return !e.s || !t.s ? r = new this(NaN) : !e.d && !t.d ? (r = Eu(this, i, 1).times(t.s > 0 ? 0.25 : 0.75), r.s = e.s) : !t.d || e.isZero() ? (r = t.s < 0 ? Eu(this, n, a) : new this(0), r.s = e.s) : !e.d || t.isZero() ? (r = Eu(this, i, 1).times(0.5), r.s = e.s) : t.s < 0 ? (this.precision = i, this.rounding = 1, r = this.atan(Vn(e, t, i, 1)), t = Eu(this, i, 1), this.precision = n, this.rounding = a, r = e.s < 0 ? r.minus(t) : r.plus(t)) : r = this.atan(Vn(e, t, i, 1)), r;
}
function Zpe(e) {
  return new this(e).cbrt();
}
function Qpe(e) {
  return Yt(e = new this(e), e.e + 1, 2);
}
function $pe(e, t, r) {
  return new this(e).clamp(t, r);
}
function Jpe(e) {
  if (!e || typeof e != "object") throw Error(U3 + "Object expected");
  var t, r, n, a = e.defaults === !0, i = [
    "precision",
    1,
    Jd,
    "rounding",
    0,
    8,
    "toExpNeg",
    -Sp,
    0,
    "toExpPos",
    0,
    Sp,
    "maxE",
    0,
    Sp,
    "minE",
    -Sp,
    0,
    "modulo",
    0,
    9
  ];
  for (t = 0; t < i.length; t += 3)
    if (r = i[t], a && (this[r] = V_[r]), (n = e[r]) !== void 0)
      if (Qi(n) === n && n >= i[t + 1] && n <= i[t + 2]) this[r] = n;
      else throw Error(jd + r + ": " + n);
  if (r = "crypto", a && (this[r] = V_[r]), (n = e[r]) !== void 0)
    if (n === !0 || n === !1 || n === 0 || n === 1)
      if (n)
        if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
          this[r] = !0;
        else
          throw Error(CU);
      else
        this[r] = !1;
    else
      throw Error(jd + r + ": " + n);
  return this;
}
function e1e(e) {
  return new this(e).cos();
}
function t1e(e) {
  return new this(e).cosh();
}
function BU(e) {
  var t, r, n;
  function a(i) {
    var o, s, u, c = this;
    if (!(c instanceof a)) return new a(i);
    if (c.constructor = a, KI(i)) {
      c.s = i.s, vr ? !i.d || i.e > a.maxE ? (c.e = NaN, c.d = null) : i.e < a.minE ? (c.e = 0, c.d = [0]) : (c.e = i.e, c.d = i.d.slice()) : (c.e = i.e, c.d = i.d ? i.d.slice() : i.d);
      return;
    }
    if (u = typeof i, u === "number") {
      if (i === 0) {
        c.s = 1 / i < 0 ? -1 : 1, c.e = 0, c.d = [0];
        return;
      }
      if (i < 0 ? (i = -i, c.s = -1) : c.s = 1, i === ~~i && i < 1e7) {
        for (o = 0, s = i; s >= 10; s /= 10) o++;
        vr ? o > a.maxE ? (c.e = NaN, c.d = null) : o < a.minE ? (c.e = 0, c.d = [0]) : (c.e = o, c.d = [i]) : (c.e = o, c.d = [i]);
        return;
      } else if (i * 0 !== 0) {
        i || (c.s = NaN), c.e = NaN, c.d = null;
        return;
      }
      return K_(c, i.toString());
    } else if (u !== "string")
      throw Error(jd + i);
    return (s = i.charCodeAt(0)) === 45 ? (i = i.slice(1), c.s = -1) : (s === 43 && (i = i.slice(1)), c.s = 1), DU.test(i) ? K_(c, i) : zpe(c, i);
  }
  if (a.prototype = vt, a.ROUND_UP = 0, a.ROUND_DOWN = 1, a.ROUND_CEIL = 2, a.ROUND_FLOOR = 3, a.ROUND_HALF_UP = 4, a.ROUND_HALF_DOWN = 5, a.ROUND_HALF_EVEN = 6, a.ROUND_HALF_CEIL = 7, a.ROUND_HALF_FLOOR = 8, a.EUCLID = 9, a.config = a.set = Jpe, a.clone = BU, a.isDecimal = KI, a.abs = Gpe, a.acos = Vpe, a.acosh = qpe, a.add = Hpe, a.asin = Kpe, a.asinh = Xpe, a.atan = jpe, a.atanh = Ype, a.atan2 = Wpe, a.cbrt = Zpe, a.ceil = Qpe, a.clamp = $pe, a.cos = e1e, a.cosh = t1e, a.div = r1e, a.exp = n1e, a.floor = a1e, a.hypot = i1e, a.ln = o1e, a.log = s1e, a.log10 = c1e, a.log2 = u1e, a.max = l1e, a.min = d1e, a.mod = f1e, a.mul = m1e, a.pow = p1e, a.random = h1e, a.round = v1e, a.sign = g1e, a.sin = y1e, a.sinh = b1e, a.sqrt = x1e, a.sub = _1e, a.sum = S1e, a.tan = A1e, a.tanh = w1e, a.trunc = C1e, e === void 0 && (e = {}), e && e.defaults !== !0)
    for (n = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], t = 0; t < n.length; ) e.hasOwnProperty(r = n[t++]) || (e[r] = this[r]);
  return a.config(e), a;
}
function r1e(e, t) {
  return new this(e).div(t);
}
function n1e(e) {
  return new this(e).exp();
}
function a1e(e) {
  return Yt(e = new this(e), e.e + 1, 3);
}
function i1e() {
  var e, t, r = new this(0);
  for (vr = !1, e = 0; e < arguments.length; )
    if (t = new this(arguments[e++]), t.d)
      r.d && (r = r.plus(t.times(t)));
    else {
      if (t.s)
        return vr = !0, new this(1 / 0);
      r = t;
    }
  return vr = !0, r.sqrt();
}
function KI(e) {
  return e instanceof Yd || e && e.toStringTag === EU || !1;
}
function o1e(e) {
  return new this(e).ln();
}
function s1e(e, t) {
  return new this(e).log(t);
}
function u1e(e) {
  return new this(e).log(2);
}
function c1e(e) {
  return new this(e).log(10);
}
function l1e() {
  return TU(this, arguments, "lt");
}
function d1e() {
  return TU(this, arguments, "gt");
}
function f1e(e, t) {
  return new this(e).mod(t);
}
function m1e(e, t) {
  return new this(e).mul(t);
}
function p1e(e, t) {
  return new this(e).pow(t);
}
function h1e(e) {
  var t, r, n, a, i = 0, o = new this(1), s = [];
  if (e === void 0 ? e = this.precision : Ko(e, 1, Jd), n = Math.ceil(e / rr), this.crypto)
    if (crypto.getRandomValues)
      for (t = crypto.getRandomValues(new Uint32Array(n)); i < n; )
        a = t[i], a >= 429e7 ? t[i] = crypto.getRandomValues(new Uint32Array(1))[0] : s[i++] = a % 1e7;
    else if (crypto.randomBytes) {
      for (t = crypto.randomBytes(n *= 4); i < n; )
        a = t[i] + (t[i + 1] << 8) + (t[i + 2] << 16) + ((t[i + 3] & 127) << 24), a >= 214e7 ? crypto.randomBytes(4).copy(t, i) : (s.push(a % 1e7), i += 4);
      i = n / 4;
    } else
      throw Error(CU);
  else for (; i < n; ) s[i++] = Math.random() * 1e7 | 0;
  for (n = s[--i], e %= rr, n && e && (a = Ka(10, rr - e), s[i] = (n / a | 0) * a); s[i] === 0; i--) s.pop();
  if (i < 0)
    r = 0, s = [0];
  else {
    for (r = -1; s[0] === 0; r -= rr) s.shift();
    for (n = 1, a = s[0]; a >= 10; a /= 10) n++;
    n < rr && (r -= rr - n);
  }
  return o.e = r, o.d = s, o;
}
function v1e(e) {
  return Yt(e = new this(e), e.e + 1, this.rounding);
}
function g1e(e) {
  return e = new this(e), e.d ? e.d[0] ? e.s : 0 * e.s : e.s || NaN;
}
function y1e(e) {
  return new this(e).sin();
}
function b1e(e) {
  return new this(e).sinh();
}
function x1e(e) {
  return new this(e).sqrt();
}
function _1e(e, t) {
  return new this(e).sub(t);
}
function S1e() {
  var e = 0, t = arguments, r = new this(t[e]);
  for (vr = !1; r.s && ++e < t.length; ) r = r.plus(t[e]);
  return vr = !0, Yt(r, this.precision, this.rounding);
}
function A1e(e) {
  return new this(e).tan();
}
function w1e(e) {
  return new this(e).tanh();
}
function C1e(e) {
  return Yt(e = new this(e), e.e + 1, 1);
}
vt[Symbol.for("nodejs.util.inspect.custom")] = vt.toString;
vt[Symbol.toStringTag] = "Decimal";
var Yd = vt.constructor = BU(V_);
Fy = new Yd(Fy);
Ry = new Yd(Ry);
var E1e = "BigNumber", D1e = ["?on", "config"], OU = /* @__PURE__ */ me(E1e, D1e, (e) => {
  var {
    on: t,
    config: r
  } = e, n = Yd.clone({
    precision: r.precision,
    modulo: Yd.EUCLID
  });
  return n.prototype = Object.create(n.prototype), n.prototype.type = "BigNumber", n.prototype.isBigNumber = !0, n.prototype.toJSON = function() {
    return {
      mathjs: "BigNumber",
      value: this.toString()
    };
  }, n.fromJSON = function(a) {
    return new n(a.value);
  }, t && t("config", function(a, i) {
    a.precision !== i.precision && n.config({
      precision: a.precision
    });
  }), n;
}, {
  isClass: !0
}), Qs = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function jh(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function M1e(e) {
  if (e.__esModule) return e;
  var t = e.default;
  if (typeof t == "function") {
    var r = function n() {
      return this instanceof n ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
    };
    r.prototype = t.prototype;
  } else r = {};
  return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
    var a = Object.getOwnPropertyDescriptor(e, n);
    Object.defineProperty(r, n, a.get ? a : {
      enumerable: !0,
      get: function() {
        return e[n];
      }
    });
  }), r;
}
var FU = { exports: {} };
/**
 * @license Complex.js v2.1.1 12/05/2020
 *
 * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
(function(e, t) {
  (function(r) {
    var n = Math.cosh || function(d) {
      return Math.abs(d) < 1e-9 ? 1 - d : (Math.exp(d) + Math.exp(-d)) * 0.5;
    }, a = Math.sinh || function(d) {
      return Math.abs(d) < 1e-9 ? d : (Math.exp(d) - Math.exp(-d)) * 0.5;
    }, i = function(d) {
      var f = Math.PI / 4;
      if (-f > d || d > f)
        return Math.cos(d) - 1;
      var m = d * d;
      return m * (m * (m * (m * (m * (m * (m * (m / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
    }, o = function(d, f) {
      var m = Math.abs(d), h = Math.abs(f);
      return m < 3e3 && h < 3e3 ? Math.sqrt(m * m + h * h) : (m < h ? (m = h, h = d / f) : h = f / d, m * Math.sqrt(1 + h * h));
    }, s = function() {
      throw SyntaxError("Invalid Param");
    };
    function u(d, f) {
      var m = Math.abs(d), h = Math.abs(f);
      return d === 0 ? Math.log(h) : f === 0 ? Math.log(m) : m < 3e3 && h < 3e3 ? Math.log(d * d + f * f) * 0.5 : (d = d / 2, f = f / 2, 0.5 * Math.log(d * d + f * f) + Math.LN2);
    }
    var c = function(d, f) {
      var m = { re: 0, im: 0 };
      if (d == null)
        m.re = m.im = 0;
      else if (f !== void 0)
        m.re = d, m.im = f;
      else
        switch (typeof d) {
          case "object":
            if ("im" in d && "re" in d)
              m.re = d.re, m.im = d.im;
            else if ("abs" in d && "arg" in d) {
              if (!Number.isFinite(d.abs) && Number.isFinite(d.arg))
                return l.INFINITY;
              m.re = d.abs * Math.cos(d.arg), m.im = d.abs * Math.sin(d.arg);
            } else if ("r" in d && "phi" in d) {
              if (!Number.isFinite(d.r) && Number.isFinite(d.phi))
                return l.INFINITY;
              m.re = d.r * Math.cos(d.phi), m.im = d.r * Math.sin(d.phi);
            } else d.length === 2 ? (m.re = d[0], m.im = d[1]) : s();
            break;
          case "string":
            m.im = /* void */
            m.re = 0;
            var h = d.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), p = 1, g = 0;
            h === null && s();
            for (var v = 0; v < h.length; v++) {
              var y = h[v];
              y === " " || y === "	" || y === `
` || (y === "+" ? p++ : y === "-" ? g++ : y === "i" || y === "I" ? (p + g === 0 && s(), h[v + 1] !== " " && !isNaN(h[v + 1]) ? (m.im += parseFloat((g % 2 ? "-" : "") + h[v + 1]), v++) : m.im += parseFloat((g % 2 ? "-" : "") + "1"), p = g = 0) : ((p + g === 0 || isNaN(y)) && s(), h[v + 1] === "i" || h[v + 1] === "I" ? (m.im += parseFloat((g % 2 ? "-" : "") + y), v++) : m.re += parseFloat((g % 2 ? "-" : "") + y), p = g = 0));
            }
            p + g > 0 && s();
            break;
          case "number":
            m.im = 0, m.re = d;
            break;
          default:
            s();
        }
      return isNaN(m.re) || isNaN(m.im), m;
    };
    function l(d, f) {
      if (!(this instanceof l))
        return new l(d, f);
      var m = c(d, f);
      this.re = m.re, this.im = m.im;
    }
    l.prototype = {
      re: 0,
      im: 0,
      /**
       * Calculates the sign of a complex number, which is a normalized complex
       *
       * @returns {Complex}
       */
      sign: function() {
        var d = this.abs();
        return new l(
          this.re / d,
          this.im / d
        );
      },
      /**
       * Adds two complex numbers
       *
       * @returns {Complex}
       */
      add: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : new l(
          this.re + m.re,
          this.im + m.im
        );
      },
      /**
       * Subtracts two complex numbers
       *
       * @returns {Complex}
       */
      sub: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : new l(
          this.re - m.re,
          this.im - m.im
        );
      },
      /**
       * Multiplies two complex numbers
       *
       * @returns {Complex}
       */
      mul: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isZero() || this.isZero() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : m.im === 0 && this.im === 0 ? new l(this.re * m.re, 0) : new l(
          this.re * m.re - this.im * m.im,
          this.re * m.im + this.im * m.re
        );
      },
      /**
       * Divides two complex numbers
       *
       * @returns {Complex}
       */
      div: function(d, f) {
        var m = new l(d, f);
        if (this.isZero() && m.isZero() || this.isInfinite() && m.isInfinite())
          return l.NAN;
        if (this.isInfinite() || m.isZero())
          return l.INFINITY;
        if (this.isZero() || m.isInfinite())
          return l.ZERO;
        d = this.re, f = this.im;
        var h = m.re, p = m.im, g, v;
        return p === 0 ? new l(d / h, f / h) : Math.abs(h) < Math.abs(p) ? (v = h / p, g = h * v + p, new l(
          (d * v + f) / g,
          (f * v - d) / g
        )) : (v = p / h, g = p * v + h, new l(
          (d + f * v) / g,
          (f - d * v) / g
        ));
      },
      /**
       * Calculate the power of two complex numbers
       *
       * @returns {Complex}
       */
      pow: function(d, f) {
        var m = new l(d, f);
        if (d = this.re, f = this.im, m.isZero())
          return l.ONE;
        if (m.im === 0) {
          if (f === 0 && d > 0)
            return new l(Math.pow(d, m.re), 0);
          if (d === 0)
            switch ((m.re % 4 + 4) % 4) {
              case 0:
                return new l(Math.pow(f, m.re), 0);
              case 1:
                return new l(0, Math.pow(f, m.re));
              case 2:
                return new l(-Math.pow(f, m.re), 0);
              case 3:
                return new l(0, -Math.pow(f, m.re));
            }
        }
        if (d === 0 && f === 0 && m.re > 0 && m.im >= 0)
          return l.ZERO;
        var h = Math.atan2(f, d), p = u(d, f);
        return d = Math.exp(m.re * p - m.im * h), f = m.im * p + m.re * h, new l(
          d * Math.cos(f),
          d * Math.sin(f)
        );
      },
      /**
       * Calculate the complex square root
       *
       * @returns {Complex}
       */
      sqrt: function() {
        var d = this.re, f = this.im, m = this.abs(), h, p;
        if (d >= 0) {
          if (f === 0)
            return new l(Math.sqrt(d), 0);
          h = 0.5 * Math.sqrt(2 * (m + d));
        } else
          h = Math.abs(f) / Math.sqrt(2 * (m - d));
        return d <= 0 ? p = 0.5 * Math.sqrt(2 * (m - d)) : p = Math.abs(f) / Math.sqrt(2 * (m + d)), new l(h, f < 0 ? -p : p);
      },
      /**
       * Calculate the complex exponent
       *
       * @returns {Complex}
       */
      exp: function() {
        var d = Math.exp(this.re);
        return this.im, new l(
          d * Math.cos(this.im),
          d * Math.sin(this.im)
        );
      },
      /**
       * Calculate the complex exponent and subtracts one.
       *
       * This may be more accurate than `Complex(x).exp().sub(1)` if
       * `x` is small.
       *
       * @returns {Complex}
       */
      expm1: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.expm1(d) * Math.cos(f) + i(f),
          Math.exp(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the natural log
       *
       * @returns {Complex}
       */
      log: function() {
        var d = this.re, f = this.im;
        return new l(
          u(d, f),
          Math.atan2(f, d)
        );
      },
      /**
       * Calculate the magnitude of the complex number
       *
       * @returns {number}
       */
      abs: function() {
        return o(this.re, this.im);
      },
      /**
       * Calculate the angle of the complex number
       *
       * @returns {number}
       */
      arg: function() {
        return Math.atan2(this.im, this.re);
      },
      /**
       * Calculate the sine of the complex number
       *
       * @returns {Complex}
       */
      sin: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.sin(d) * n(f),
          Math.cos(d) * a(f)
        );
      },
      /**
       * Calculate the cosine
       *
       * @returns {Complex}
       */
      cos: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.cos(d) * n(f),
          -Math.sin(d) * a(f)
        );
      },
      /**
       * Calculate the tangent
       *
       * @returns {Complex}
       */
      tan: function() {
        var d = 2 * this.re, f = 2 * this.im, m = Math.cos(d) + n(f);
        return new l(
          Math.sin(d) / m,
          a(f) / m
        );
      },
      /**
       * Calculate the cotangent
       *
       * @returns {Complex}
       */
      cot: function() {
        var d = 2 * this.re, f = 2 * this.im, m = Math.cos(d) - n(f);
        return new l(
          -Math.sin(d) / m,
          a(f) / m
        );
      },
      /**
       * Calculate the secant
       *
       * @returns {Complex}
       */
      sec: function() {
        var d = this.re, f = this.im, m = 0.5 * n(2 * f) + 0.5 * Math.cos(2 * d);
        return new l(
          Math.cos(d) * n(f) / m,
          Math.sin(d) * a(f) / m
        );
      },
      /**
       * Calculate the cosecans
       *
       * @returns {Complex}
       */
      csc: function() {
        var d = this.re, f = this.im, m = 0.5 * n(2 * f) - 0.5 * Math.cos(2 * d);
        return new l(
          Math.sin(d) * n(f) / m,
          -Math.cos(d) * a(f) / m
        );
      },
      /**
       * Calculate the complex arcus sinus
       *
       * @returns {Complex}
       */
      asin: function() {
        var d = this.re, f = this.im, m = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), h = new l(
          m.re - f,
          m.im + d
        ).log();
        return new l(h.im, -h.re);
      },
      /**
       * Calculate the complex arcus cosinus
       *
       * @returns {Complex}
       */
      acos: function() {
        var d = this.re, f = this.im, m = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), h = new l(
          m.re - f,
          m.im + d
        ).log();
        return new l(Math.PI / 2 - h.im, h.re);
      },
      /**
       * Calculate the complex arcus tangent
       *
       * @returns {Complex}
       */
      atan: function() {
        var d = this.re, f = this.im;
        if (d === 0) {
          if (f === 1)
            return new l(0, 1 / 0);
          if (f === -1)
            return new l(0, -1 / 0);
        }
        var m = d * d + (1 - f) * (1 - f), h = new l(
          (1 - f * f - d * d) / m,
          -2 * d / m
        ).log();
        return new l(-0.5 * h.im, 0.5 * h.re);
      },
      /**
       * Calculate the complex arcus cotangent
       *
       * @returns {Complex}
       */
      acot: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(Math.atan2(1, d), 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).atan() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atan();
      },
      /**
       * Calculate the complex arcus secant
       *
       * @returns {Complex}
       */
      asec: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, 1 / 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).acos() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acos();
      },
      /**
       * Calculate the complex arcus cosecans
       *
       * @returns {Complex}
       */
      acsc: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(Math.PI / 2, 1 / 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).asin() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asin();
      },
      /**
       * Calculate the complex sinh
       *
       * @returns {Complex}
       */
      sinh: function() {
        var d = this.re, f = this.im;
        return new l(
          a(d) * Math.cos(f),
          n(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex cosh
       *
       * @returns {Complex}
       */
      cosh: function() {
        var d = this.re, f = this.im;
        return new l(
          n(d) * Math.cos(f),
          a(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex tanh
       *
       * @returns {Complex}
       */
      tanh: function() {
        var d = 2 * this.re, f = 2 * this.im, m = n(d) + Math.cos(f);
        return new l(
          a(d) / m,
          Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      coth: function() {
        var d = 2 * this.re, f = 2 * this.im, m = n(d) - Math.cos(f);
        return new l(
          a(d) / m,
          -Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      csch: function() {
        var d = this.re, f = this.im, m = Math.cos(2 * f) - n(2 * d);
        return new l(
          -2 * a(d) * Math.cos(f) / m,
          2 * n(d) * Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex sech
       *
       * @returns {Complex}
       */
      sech: function() {
        var d = this.re, f = this.im, m = Math.cos(2 * f) + n(2 * d);
        return new l(
          2 * n(d) * Math.cos(f) / m,
          -2 * a(d) * Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex asinh
       *
       * @returns {Complex}
       */
      asinh: function() {
        var d = this.im;
        this.im = -this.re, this.re = d;
        var f = this.asin();
        return this.re = -this.im, this.im = d, d = f.re, f.re = -f.im, f.im = d, f;
      },
      /**
       * Calculate the complex acosh
       *
       * @returns {Complex}
       */
      acosh: function() {
        var d = this.acos();
        if (d.im <= 0) {
          var f = d.re;
          d.re = -d.im, d.im = f;
        } else {
          var f = d.im;
          d.im = -d.re, d.re = f;
        }
        return d;
      },
      /**
       * Calculate the complex atanh
       *
       * @returns {Complex}
       */
      atanh: function() {
        var d = this.re, f = this.im, m = d > 1 && f === 0, h = 1 - d, p = 1 + d, g = h * h + f * f, v = g !== 0 ? new l(
          (p * h - f * f) / g,
          (f * h + p * f) / g
        ) : new l(
          d !== -1 ? d / 0 : 0,
          f !== 0 ? f / 0 : 0
        ), y = v.re;
        return v.re = u(v.re, v.im) / 2, v.im = Math.atan2(v.im, y) / 2, m && (v.im = -v.im), v;
      },
      /**
       * Calculate the complex acoth
       *
       * @returns {Complex}
       */
      acoth: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, Math.PI / 2);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).atanh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atanh();
      },
      /**
       * Calculate the complex acsch
       *
       * @returns {Complex}
       */
      acsch: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(
            d !== 0 ? Math.log(d + Math.sqrt(d * d + 1)) : 1 / 0,
            0
          );
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).asinh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asinh();
      },
      /**
       * Calculate the complex asech
       *
       * @returns {Complex}
       */
      asech: function() {
        var d = this.re, f = this.im;
        if (this.isZero())
          return l.INFINITY;
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).acosh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acosh();
      },
      /**
       * Calculate the complex inverse 1/z
       *
       * @returns {Complex}
       */
      inverse: function() {
        if (this.isZero())
          return l.INFINITY;
        if (this.isInfinite())
          return l.ZERO;
        var d = this.re, f = this.im, m = d * d + f * f;
        return new l(d / m, -f / m);
      },
      /**
       * Returns the complex conjugate
       *
       * @returns {Complex}
       */
      conjugate: function() {
        return new l(this.re, -this.im);
      },
      /**
       * Gets the negated complex number
       *
       * @returns {Complex}
       */
      neg: function() {
        return new l(-this.re, -this.im);
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      ceil: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.ceil(this.re * d) / d,
          Math.ceil(this.im * d) / d
        );
      },
      /**
       * Floors the actual complex number
       *
       * @returns {Complex}
       */
      floor: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.floor(this.re * d) / d,
          Math.floor(this.im * d) / d
        );
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      round: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.round(this.re * d) / d,
          Math.round(this.im * d) / d
        );
      },
      /**
       * Compares two complex numbers
       *
       * **Note:** new Complex(Infinity).equals(Infinity) === false
       *
       * @returns {boolean}
       */
      equals: function(d, f) {
        var m = new l(d, f);
        return Math.abs(m.re - this.re) <= l.EPSILON && Math.abs(m.im - this.im) <= l.EPSILON;
      },
      /**
       * Clones the actual object
       *
       * @returns {Complex}
       */
      clone: function() {
        return new l(this.re, this.im);
      },
      /**
       * Gets a string of the actual complex number
       *
       * @returns {string}
       */
      toString: function() {
        var d = this.re, f = this.im, m = "";
        return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(d) < l.EPSILON && (d = 0), Math.abs(f) < l.EPSILON && (f = 0), f === 0 ? m + d : (d !== 0 ? (m += d, m += " ", f < 0 ? (f = -f, m += "-") : m += "+", m += " ") : f < 0 && (f = -f, m += "-"), f !== 1 && (m += f), m + "i"));
      },
      /**
       * Returns the actual number as a vector
       *
       * @returns {Array}
       */
      toVector: function() {
        return [this.re, this.im];
      },
      /**
       * Returns the actual real value of the current object
       *
       * @returns {number|null}
       */
      valueOf: function() {
        return this.im === 0 ? this.re : null;
      },
      /**
       * Determines whether a complex number is not on the Riemann sphere.
       *
       * @returns {boolean}
       */
      isNaN: function() {
        return isNaN(this.re) || isNaN(this.im);
      },
      /**
       * Determines whether or not a complex number is at the zero pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isZero: function() {
        return this.im === 0 && this.re === 0;
      },
      /**
       * Determines whether a complex number is not at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isFinite: function() {
        return isFinite(this.re) && isFinite(this.im);
      },
      /**
       * Determines whether or not a complex number is at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isInfinite: function() {
        return !(this.isNaN() || this.isFinite());
      }
    }, l.ZERO = new l(0, 0), l.ONE = new l(1, 0), l.I = new l(0, 1), l.PI = new l(Math.PI, 0), l.E = new l(Math.E, 0), l.INFINITY = new l(1 / 0, 1 / 0), l.NAN = new l(NaN, NaN), l.EPSILON = 1e-15, Object.defineProperty(l, "__esModule", { value: !0 }), l.default = l, l.Complex = l, e.exports = l;
  })();
})(FU);
var I1e = FU.exports;
const xi = /* @__PURE__ */ jh(I1e);
var T1e = "Complex", N1e = [], RU = /* @__PURE__ */ me(T1e, N1e, () => (Object.defineProperty(xi, "name", {
  value: "Complex"
}), xi.prototype.constructor = xi, xi.prototype.type = "Complex", xi.prototype.isComplex = !0, xi.prototype.toJSON = function() {
  return {
    mathjs: "Complex",
    re: this.re,
    im: this.im
  };
}, xi.prototype.toPolar = function() {
  return {
    r: this.abs(),
    phi: this.arg()
  };
}, xi.prototype.format = function(e) {
  var t = "", r = this.im, n = this.re, a = Qf(this.re, e), i = Qf(this.im, e), o = _r(e) ? e : e ? e.precision : null;
  if (o !== null) {
    var s = Math.pow(10, -o);
    Math.abs(n / r) < s && (n = 0), Math.abs(r / n) < s && (r = 0);
  }
  return r === 0 ? t = a : n === 0 ? r === 1 ? t = "i" : r === -1 ? t = "-i" : t = i + "i" : r < 0 ? r === -1 ? t = a + " - i" : t = a + " - " + i.substring(1) + "i" : r === 1 ? t = a + " + i" : t = a + " + " + i + "i", t;
}, xi.fromPolar = function(e) {
  switch (arguments.length) {
    case 1: {
      var t = arguments[0];
      if (typeof t == "object")
        return xi(t);
      throw new TypeError("Input has to be an object with r and phi keys.");
    }
    case 2: {
      var r = arguments[0], n = arguments[1];
      if (_r(r)) {
        if (Lo(n) && n.hasBase("ANGLE") && (n = n.toNumber("rad")), _r(n))
          return new xi({
            r,
            phi: n
          });
        throw new TypeError("Phi is not a number nor an angle unit.");
      } else
        throw new TypeError("Radius r is not a number.");
    }
    default:
      throw new SyntaxError("Wrong number of arguments in function fromPolar");
  }
}, xi.prototype.valueOf = xi.prototype.toString, xi.fromJSON = function(e) {
  return new xi(e);
}, xi.compare = function(e, t) {
  return e.re > t.re ? 1 : e.re < t.re ? -1 : e.im > t.im ? 1 : e.im < t.im ? -1 : 0;
}, xi), {
  isClass: !0
});
/**
 * @license Fraction.js v4.3.7 31/08/2023
 * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
 *
 * Copyright (c) 2023, Robert Eisele (robert@raw.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
var P1e = 2e3, Lt = {
  s: 1,
  n: 0,
  d: 1
};
function qc(e, t) {
  if (isNaN(e = parseInt(e, 10)))
    throw R2();
  return e * t;
}
function ia(e, t) {
  if (t === 0)
    throw ES();
  var r = Object.create(Hi.prototype);
  r.s = e < 0 ? -1 : 1, e = e < 0 ? -e : e;
  var n = Ap(e, t);
  return r.n = e / n, r.d = t / n, r;
}
function XI(e) {
  for (var t = {}, r = e, n = 2, a = 4; a <= r; ) {
    for (; r % n === 0; )
      r /= n, t[n] = (t[n] || 0) + 1;
    a += 1 + 2 * n++;
  }
  return r !== e ? r > 1 && (t[r] = (t[r] || 0) + 1) : t[e] = (t[e] || 0) + 1, t;
}
var os = function(e, t) {
  var r = 0, n = 1, a = 1, i = 0, o = 0, s = 0, u = 1, c = 1, l = 0, d = 1, f = 1, m = 1, h = 1e7, p;
  if (e != null) if (t !== void 0) {
    if (r = e, n = t, a = r * n, r % 1 !== 0 || n % 1 !== 0)
      throw R1e();
  } else
    switch (typeof e) {
      case "object": {
        if ("d" in e && "n" in e)
          r = e.n, n = e.d, "s" in e && (r *= e.s);
        else if (0 in e)
          r = e[0], 1 in e && (n = e[1]);
        else
          throw R2();
        a = r * n;
        break;
      }
      case "number": {
        if (e < 0 && (a = e, e = -e), e % 1 === 0)
          r = e;
        else if (e > 0) {
          for (e >= 1 && (c = Math.pow(10, Math.floor(1 + Math.log(e) / Math.LN10)), e /= c); d <= h && m <= h; )
            if (p = (l + f) / (d + m), e === p) {
              d + m <= h ? (r = l + f, n = d + m) : m > d ? (r = f, n = m) : (r = l, n = d);
              break;
            } else
              e > p ? (l += f, d += m) : (f += l, m += d), d > h ? (r = f, n = m) : (r = l, n = d);
          r *= c;
        } else (isNaN(e) || isNaN(t)) && (n = r = NaN);
        break;
      }
      case "string": {
        if (d = e.match(/\d+|./g), d === null)
          throw R2();
        if (d[l] === "-" ? (a = -1, l++) : d[l] === "+" && l++, d.length === l + 1 ? o = qc(d[l++], a) : d[l + 1] === "." || d[l] === "." ? (d[l] !== "." && (i = qc(d[l++], a)), l++, (l + 1 === d.length || d[l + 1] === "(" && d[l + 3] === ")" || d[l + 1] === "'" && d[l + 3] === "'") && (o = qc(d[l], a), u = Math.pow(10, d[l].length), l++), (d[l] === "(" && d[l + 2] === ")" || d[l] === "'" && d[l + 2] === "'") && (s = qc(d[l + 1], a), c = Math.pow(10, d[l + 1].length) - 1, l += 3)) : d[l + 1] === "/" || d[l + 1] === ":" ? (o = qc(d[l], a), u = qc(d[l + 2], 1), l += 3) : d[l + 3] === "/" && d[l + 1] === " " && (i = qc(d[l], a), o = qc(d[l + 2], a), u = qc(d[l + 4], 1), l += 5), d.length <= l) {
          n = u * c, a = /* void */
          r = s + n * i + c * o;
          break;
        }
      }
      default:
        throw R2();
    }
  if (n === 0)
    throw ES();
  Lt.s = a < 0 ? -1 : 1, Lt.n = Math.abs(r), Lt.d = Math.abs(n);
};
function B1e(e, t, r) {
  for (var n = 1; t > 0; e = e * e % r, t >>= 1)
    t & 1 && (n = n * e % r);
  return n;
}
function O1e(e, t) {
  for (; t % 2 === 0; t /= 2)
    ;
  for (; t % 5 === 0; t /= 5)
    ;
  if (t === 1)
    return 0;
  for (var r = 10 % t, n = 1; r !== 1; n++)
    if (r = r * 10 % t, n > P1e)
      return 0;
  return n;
}
function F1e(e, t, r) {
  for (var n = 1, a = B1e(10, r, t), i = 0; i < 300; i++) {
    if (n === a)
      return i;
    n = n * 10 % t, a = a * 10 % t;
  }
  return 0;
}
function Ap(e, t) {
  if (!e)
    return t;
  if (!t)
    return e;
  for (; ; ) {
    if (e %= t, !e)
      return t;
    if (t %= e, !t)
      return e;
  }
}
function Hi(e, t) {
  if (os(e, t), this instanceof Hi)
    e = Ap(Lt.d, Lt.n), this.s = Lt.s, this.n = Lt.n / e, this.d = Lt.d / e;
  else
    return ia(Lt.s * Lt.n, Lt.d);
}
var ES = function() {
  return new Error("Division by Zero");
}, R2 = function() {
  return new Error("Invalid argument");
}, R1e = function() {
  return new Error("Parameters must be integer");
};
Hi.prototype = {
  s: 1,
  n: 0,
  d: 1,
  /**
   * Calculates the absolute value
   *
   * Ex: new Fraction(-4).abs() => 4
   **/
  abs: function() {
    return ia(this.n, this.d);
  },
  /**
   * Inverts the sign of the current fraction
   *
   * Ex: new Fraction(-4).neg() => 4
   **/
  neg: function() {
    return ia(-this.s * this.n, this.d);
  },
  /**
   * Adds two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
   **/
  add: function(e, t) {
    return os(e, t), ia(
      this.s * this.n * Lt.d + Lt.s * this.d * Lt.n,
      this.d * Lt.d
    );
  },
  /**
   * Subtracts two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
   **/
  sub: function(e, t) {
    return os(e, t), ia(
      this.s * this.n * Lt.d - Lt.s * this.d * Lt.n,
      this.d * Lt.d
    );
  },
  /**
   * Multiplies two rational numbers
   *
   * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
   **/
  mul: function(e, t) {
    return os(e, t), ia(
      this.s * Lt.s * this.n * Lt.n,
      this.d * Lt.d
    );
  },
  /**
   * Divides two rational numbers
   *
   * Ex: new Fraction("-17.(345)").inverse().div(3)
   **/
  div: function(e, t) {
    return os(e, t), ia(
      this.s * Lt.s * this.n * Lt.d,
      this.d * Lt.n
    );
  },
  /**
   * Clones the actual object
   *
   * Ex: new Fraction("-17.(345)").clone()
   **/
  clone: function() {
    return ia(this.s * this.n, this.d);
  },
  /**
   * Calculates the modulo of two rational numbers - a more precise fmod
   *
   * Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
   **/
  mod: function(e, t) {
    if (isNaN(this.n) || isNaN(this.d))
      return new Hi(NaN);
    if (e === void 0)
      return ia(this.s * this.n % this.d, 1);
    if (os(e, t), Lt.n === 0 && this.d === 0)
      throw ES();
    return ia(
      this.s * (Lt.d * this.n) % (Lt.n * this.d),
      Lt.d * this.d
    );
  },
  /**
   * Calculates the fractional gcd of two rational numbers
   *
   * Ex: new Fraction(5,8).gcd(3,7) => 1/56
   */
  gcd: function(e, t) {
    return os(e, t), ia(Ap(Lt.n, this.n) * Ap(Lt.d, this.d), Lt.d * this.d);
  },
  /**
   * Calculates the fractional lcm of two rational numbers
   *
   * Ex: new Fraction(5,8).lcm(3,7) => 15
   */
  lcm: function(e, t) {
    return os(e, t), Lt.n === 0 && this.n === 0 ? ia(0, 1) : ia(Lt.n * this.n, Ap(Lt.n, this.n) * Ap(Lt.d, this.d));
  },
  /**
   * Calculates the ceil of a rational number
   *
   * Ex: new Fraction('4.(3)').ceil() => (5 / 1)
   **/
  ceil: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Hi(NaN) : ia(Math.ceil(e * this.s * this.n / this.d), e);
  },
  /**
   * Calculates the floor of a rational number
   *
   * Ex: new Fraction('4.(3)').floor() => (4 / 1)
   **/
  floor: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Hi(NaN) : ia(Math.floor(e * this.s * this.n / this.d), e);
  },
  /**
   * Rounds a rational number
   *
   * Ex: new Fraction('4.(3)').round() => (4 / 1)
   **/
  round: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Hi(NaN) : ia(Math.round(e * this.s * this.n / this.d), e);
  },
  /**
   * Rounds a rational number to a multiple of another rational number
   *
   * Ex: new Fraction('0.9').roundTo("1/8") => 7 / 8
   **/
  roundTo: function(e, t) {
    return os(e, t), ia(this.s * Math.round(this.n * Lt.d / (this.d * Lt.n)) * Lt.n, Lt.d);
  },
  /**
   * Gets the inverse of the fraction, means numerator and denominator are exchanged
   *
   * Ex: new Fraction([-3, 4]).inverse() => -4 / 3
   **/
  inverse: function() {
    return ia(this.s * this.d, this.n);
  },
  /**
   * Calculates the fraction to some rational exponent, if possible
   *
   * Ex: new Fraction(-1,2).pow(-3) => -8
   */
  pow: function(e, t) {
    if (os(e, t), Lt.d === 1)
      return Lt.s < 0 ? ia(Math.pow(this.s * this.d, Lt.n), Math.pow(this.n, Lt.n)) : ia(Math.pow(this.s * this.n, Lt.n), Math.pow(this.d, Lt.n));
    if (this.s < 0) return null;
    var r = XI(this.n), n = XI(this.d), a = 1, i = 1;
    for (var o in r)
      if (o !== "1") {
        if (o === "0") {
          a = 0;
          break;
        }
        if (r[o] *= Lt.n, r[o] % Lt.d === 0)
          r[o] /= Lt.d;
        else return null;
        a *= Math.pow(o, r[o]);
      }
    for (var o in n)
      if (o !== "1") {
        if (n[o] *= Lt.n, n[o] % Lt.d === 0)
          n[o] /= Lt.d;
        else return null;
        i *= Math.pow(o, n[o]);
      }
    return Lt.s < 0 ? ia(i, a) : ia(a, i);
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  equals: function(e, t) {
    return os(e, t), this.s * this.n * Lt.d === Lt.s * Lt.n * this.d;
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  compare: function(e, t) {
    os(e, t);
    var r = this.s * this.n * Lt.d - Lt.s * Lt.n * this.d;
    return (0 < r) - (r < 0);
  },
  simplify: function(e) {
    if (isNaN(this.n) || isNaN(this.d))
      return this;
    e = e || 1e-3;
    for (var t = this.abs(), r = t.toContinued(), n = 1; n < r.length; n++) {
      for (var a = ia(r[n - 1], 1), i = n - 2; i >= 0; i--)
        a = a.inverse().add(r[i]);
      if (Math.abs(a.sub(t).valueOf()) < e)
        return a.mul(this.s);
    }
    return this;
  },
  /**
   * Check if two rational numbers are divisible
   *
   * Ex: new Fraction(19.6).divisible(1.5);
   */
  divisible: function(e, t) {
    return os(e, t), !(!(Lt.n * this.d) || this.n * Lt.d % (Lt.n * this.d));
  },
  /**
   * Returns a decimal representation of the fraction
   *
   * Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
   **/
  valueOf: function() {
    return this.s * this.n / this.d;
  },
  /**
   * Returns a string-fraction representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
   **/
  toFraction: function(e) {
    var t, r = "", n = this.n, a = this.d;
    return this.s < 0 && (r += "-"), a === 1 ? r += n : (e && (t = Math.floor(n / a)) > 0 && (r += t, r += " ", n %= a), r += n, r += "/", r += a), r;
  },
  /**
   * Returns a latex representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
   **/
  toLatex: function(e) {
    var t, r = "", n = this.n, a = this.d;
    return this.s < 0 && (r += "-"), a === 1 ? r += n : (e && (t = Math.floor(n / a)) > 0 && (r += t, n %= a), r += "\\frac{", r += n, r += "}{", r += a, r += "}"), r;
  },
  /**
   * Returns an array of continued fraction elements
   *
   * Ex: new Fraction("7/8").toContinued() => [0,1,7]
   */
  toContinued: function() {
    var e, t = this.n, r = this.d, n = [];
    if (isNaN(t) || isNaN(r))
      return n;
    do
      n.push(Math.floor(t / r)), e = t % r, t = r, r = e;
    while (t !== 1);
    return n;
  },
  /**
   * Creates a string representation of a fraction with all digits
   *
   * Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
   **/
  toString: function(e) {
    var t = this.n, r = this.d;
    if (isNaN(t) || isNaN(r))
      return "NaN";
    e = e || 15;
    var n = O1e(t, r), a = F1e(t, r, n), i = this.s < 0 ? "-" : "";
    if (i += t / r | 0, t %= r, t *= 10, t && (i += "."), n) {
      for (var o = a; o--; )
        i += t / r | 0, t %= r, t *= 10;
      i += "(";
      for (var o = n; o--; )
        i += t / r | 0, t %= r, t *= 10;
      i += ")";
    } else
      for (var o = e; t && o--; )
        i += t / r | 0, t %= r, t *= 10;
    return i;
  }
};
var L1e = "Fraction", k1e = [], LU = /* @__PURE__ */ me(L1e, k1e, () => (Object.defineProperty(Hi, "name", {
  value: "Fraction"
}), Hi.prototype.constructor = Hi, Hi.prototype.type = "Fraction", Hi.prototype.isFraction = !0, Hi.prototype.toJSON = function() {
  return {
    mathjs: "Fraction",
    n: this.s * this.n,
    d: this.d
  };
}, Hi.fromJSON = function(e) {
  return new Hi(e);
}, Hi), {
  isClass: !0
}), z1e = "Range", U1e = [], G1e = /* @__PURE__ */ me(z1e, U1e, () => {
  function e(t, r, n) {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
    var a = t != null, i = r != null, o = n != null;
    if (a) {
      if (hr(t))
        t = t.toNumber();
      else if (typeof t != "number")
        throw new TypeError("Parameter start must be a number");
    }
    if (i) {
      if (hr(r))
        r = r.toNumber();
      else if (typeof r != "number")
        throw new TypeError("Parameter end must be a number");
    }
    if (o) {
      if (hr(n))
        n = n.toNumber();
      else if (typeof n != "number")
        throw new TypeError("Parameter step must be a number");
    }
    this.start = a ? parseFloat(t) : 0, this.end = i ? parseFloat(r) : 0, this.step = o ? parseFloat(n) : 1;
  }
  return e.prototype.type = "Range", e.prototype.isRange = !0, e.parse = function(t) {
    if (typeof t != "string")
      return null;
    var r = t.split(":"), n = r.map(function(i) {
      return parseFloat(i);
    }), a = n.some(function(i) {
      return isNaN(i);
    });
    if (a)
      return null;
    switch (n.length) {
      case 2:
        return new e(n[0], n[1]);
      case 3:
        return new e(n[0], n[2], n[1]);
      default:
        return null;
    }
  }, e.prototype.clone = function() {
    return new e(this.start, this.end, this.step);
  }, e.prototype.size = function() {
    var t = 0, r = this.start, n = this.step, a = this.end, i = a - r;
    return Nd(n) === Nd(i) ? t = Math.ceil(i / n) : i === 0 && (t = 0), isNaN(t) && (t = 0), [t];
  }, e.prototype.min = function() {
    var t = this.size()[0];
    if (t > 0)
      return this.step > 0 ? this.start : this.start + (t - 1) * this.step;
  }, e.prototype.max = function() {
    var t = this.size()[0];
    if (t > 0)
      return this.step > 0 ? this.start + (t - 1) * this.step : this.start;
  }, e.prototype.forEach = function(t) {
    var r = this.start, n = this.step, a = this.end, i = 0;
    if (n > 0)
      for (; r < a; )
        t(r, [i], this), r += n, i++;
    else if (n < 0)
      for (; r > a; )
        t(r, [i], this), r += n, i++;
  }, e.prototype.map = function(t) {
    var r = [];
    return this.forEach(function(n, a, i) {
      r[a[0]] = t(n, a, i);
    }), r;
  }, e.prototype.toArray = function() {
    var t = [];
    return this.forEach(function(r, n) {
      t[n[0]] = r;
    }), t;
  }, e.prototype.valueOf = function() {
    return this.toArray();
  }, e.prototype.format = function(t) {
    var r = Qf(this.start, t);
    return this.step !== 1 && (r += ":" + Qf(this.step, t)), r += ":" + Qf(this.end, t), r;
  }, e.prototype.toString = function() {
    return this.format();
  }, e.prototype.toJSON = function() {
    return {
      mathjs: "Range",
      start: this.start,
      end: this.end,
      step: this.step
    };
  }, e.fromJSON = function(t) {
    return new e(t.start, t.end, t.step);
  }, e;
}, {
  isClass: !0
}), V1e = "Matrix", q1e = [], kU = /* @__PURE__ */ me(V1e, q1e, () => {
  function e() {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
  }
  return e.prototype.type = "Matrix", e.prototype.isMatrix = !0, e.prototype.storage = function() {
    throw new Error("Cannot invoke storage on a Matrix interface");
  }, e.prototype.datatype = function() {
    throw new Error("Cannot invoke datatype on a Matrix interface");
  }, e.prototype.create = function(t, r) {
    throw new Error("Cannot invoke create on a Matrix interface");
  }, e.prototype.subset = function(t, r, n) {
    throw new Error("Cannot invoke subset on a Matrix interface");
  }, e.prototype.get = function(t) {
    throw new Error("Cannot invoke get on a Matrix interface");
  }, e.prototype.set = function(t, r, n) {
    throw new Error("Cannot invoke set on a Matrix interface");
  }, e.prototype.resize = function(t, r) {
    throw new Error("Cannot invoke resize on a Matrix interface");
  }, e.prototype.reshape = function(t, r) {
    throw new Error("Cannot invoke reshape on a Matrix interface");
  }, e.prototype.clone = function() {
    throw new Error("Cannot invoke clone on a Matrix interface");
  }, e.prototype.size = function() {
    throw new Error("Cannot invoke size on a Matrix interface");
  }, e.prototype.map = function(t, r) {
    throw new Error("Cannot invoke map on a Matrix interface");
  }, e.prototype.forEach = function(t) {
    throw new Error("Cannot invoke forEach on a Matrix interface");
  }, e.prototype[Symbol.iterator] = function() {
    throw new Error("Cannot iterate a Matrix interface");
  }, e.prototype.toArray = function() {
    throw new Error("Cannot invoke toArray on a Matrix interface");
  }, e.prototype.valueOf = function() {
    throw new Error("Cannot invoke valueOf on a Matrix interface");
  }, e.prototype.format = function(t) {
    throw new Error("Cannot invoke format on a Matrix interface");
  }, e.prototype.toString = function() {
    throw new Error("Cannot invoke toString on a Matrix interface");
  }, e;
}, {
  isClass: !0
});
function F5(e, t, r) {
  var n = e.constructor, a = new n(2), i = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!Ut(r))
      throw new Error("size must be an integer");
    if (e.greaterThan(a.pow(r - 1).sub(1)) || e.lessThan(a.pow(r - 1).mul(-1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!e.isInteger())
      throw new Error("Value must be an integer");
    e.lessThan(0) && (e = e.add(a.pow(r))), i = "i".concat(r);
  }
  switch (t) {
    case 2:
      return "".concat(e.toBinary()).concat(i);
    case 8:
      return "".concat(e.toOctal()).concat(i);
    case 16:
      return "".concat(e.toHexadecimal()).concat(i);
    default:
      throw new Error("Base ".concat(t, " not supported "));
  }
}
function H1e(e, t) {
  if (typeof t == "function")
    return t(e);
  if (!e.isFinite())
    return e.isNaN() ? "NaN" : e.gt(0) ? "Infinity" : "-Infinity";
  var {
    notation: r,
    precision: n,
    wordSize: a
  } = fU(t);
  switch (r) {
    case "fixed":
      return X1e(e, n);
    case "exponential":
      return jI(e, n);
    case "engineering":
      return K1e(e, n);
    case "bin":
      return F5(e, 2, a);
    case "oct":
      return F5(e, 8, a);
    case "hex":
      return F5(e, 16, a);
    case "auto": {
      var i = YI(t == null ? void 0 : t.lowerExp, -3), o = YI(t == null ? void 0 : t.upperExp, 5);
      if (e.isZero()) return "0";
      var s, u = e.toSignificantDigits(n), c = u.e;
      return c >= i && c < o ? s = u.toFixed() : s = jI(e, n), s.replace(/((\.\d*?)(0+))($|e)/, function() {
        var l = arguments[2], d = arguments[4];
        return l !== "." ? l + d : d;
      });
    }
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function K1e(e, t) {
  var r = e.e, n = r % 3 === 0 ? r : r < 0 ? r - 3 - r % 3 : r - r % 3, a = e.mul(Math.pow(10, -n)), i = a.toPrecision(t);
  if (i.includes("e")) {
    var o = e.constructor;
    i = new o(i).toFixed();
  }
  return i + "e" + (r >= 0 ? "+" : "") + n.toString();
}
function jI(e, t) {
  return t !== void 0 ? e.toExponential(t - 1) : e.toExponential();
}
function X1e(e, t) {
  return e.toFixed(t);
}
function YI(e, t) {
  return _r(e) ? e : hr(e) ? e.toNumber() : t;
}
function j1e(e, t) {
  var r = e.length - t.length, n = e.length;
  return e.substring(r, n) === t;
}
function Br(e, t) {
  var r = Y1e(e, t);
  return t && typeof t == "object" && "truncate" in t && r.length > t.truncate ? r.substring(0, t.truncate - 3) + "..." : r;
}
function Y1e(e, t) {
  if (typeof e == "number")
    return Qf(e, t);
  if (hr(e))
    return H1e(e, t);
  if (W1e(e))
    return !t || t.fraction !== "decimal" ? e.s * e.n + "/" + e.d : e.toString();
  if (Array.isArray(e))
    return zU(e, t);
  if (Di(e))
    return wp(e);
  if (typeof e == "function")
    return e.syntax ? String(e.syntax) : "function";
  if (e && typeof e == "object") {
    if (typeof e.format == "function")
      return e.format(t);
    if (e && e.toString(t) !== {}.toString())
      return e.toString(t);
    var r = Object.keys(e).map((n) => wp(n) + ": " + Br(e[n], t));
    return "{" + r.join(", ") + "}";
  }
  return String(e);
}
function wp(e) {
  for (var t = String(e), r = "", n = 0; n < t.length; ) {
    var a = t.charAt(n);
    r += a in WI ? WI[a] : a, n++;
  }
  return '"' + r + '"';
}
var WI = {
  '"': '\\"',
  "\\": "\\\\",
  "\b": "\\b",
  "\f": "\\f",
  "\n": "\\n",
  "\r": "\\r",
  "	": "\\t"
};
function $s(e) {
  var t = String(e);
  return t = t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), t;
}
function zU(e, t) {
  if (Array.isArray(e)) {
    for (var r = "[", n = e.length, a = 0; a < n; a++)
      a !== 0 && (r += ", "), r += zU(e[a], t);
    return r += "]", r;
  } else
    return Br(e, t);
}
function W1e(e) {
  return e && typeof e == "object" && typeof e.s == "number" && typeof e.n == "number" && typeof e.d == "number" || !1;
}
function X_(e, t) {
  if (!Di(e))
    throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + Nn(e) + ", index: 0)");
  if (!Di(t))
    throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + Nn(t) + ", index: 1)");
  return e === t ? 0 : e > t ? 1 : -1;
}
function Ir(e, t, r) {
  if (!(this instanceof Ir))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.actual = e, this.expected = t, this.relation = r, this.message = "Dimension mismatch (" + (Array.isArray(e) ? "[" + e.join(", ") + "]" : e) + " " + (this.relation || "!=") + " " + (Array.isArray(t) ? "[" + t.join(", ") + "]" : t) + ")", this.stack = new Error().stack;
}
Ir.prototype = new RangeError();
Ir.prototype.constructor = RangeError;
Ir.prototype.name = "DimensionError";
Ir.prototype.isDimensionError = !0;
function ou(e, t, r) {
  if (!(this instanceof ou))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.index = e, arguments.length < 3 ? (this.min = 0, this.max = t) : (this.min = t, this.max = r), this.min !== void 0 && this.index < this.min ? this.message = "Index out of range (" + this.index + " < " + this.min + ")" : this.max !== void 0 && this.index >= this.max ? this.message = "Index out of range (" + this.index + " > " + (this.max - 1) + ")" : this.message = "Index out of range (" + this.index + ")", this.stack = new Error().stack;
}
ou.prototype = new RangeError();
ou.prototype.constructor = RangeError;
ou.prototype.name = "IndexError";
ou.prototype.isIndexError = !0;
function Sr(e) {
  for (var t = []; Array.isArray(e); )
    t.push(e.length), e = e[0];
  return t;
}
function UU(e, t, r) {
  var n, a = e.length;
  if (a !== t[r])
    throw new Ir(a, t[r]);
  if (r < t.length - 1) {
    var i = r + 1;
    for (n = 0; n < a; n++) {
      var o = e[n];
      if (!Array.isArray(o))
        throw new Ir(t.length - 1, t.length, "<");
      UU(e[n], t, i);
    }
  } else
    for (n = 0; n < a; n++)
      if (Array.isArray(e[n]))
        throw new Ir(t.length + 1, t.length, ">");
}
function ZI(e, t) {
  var r = t.length === 0;
  if (r) {
    if (Array.isArray(e))
      throw new Ir(e.length, 0);
  } else
    UU(e, t, 0);
}
function ky(e, t) {
  var r = e.isMatrix ? e._size : Sr(e), n = t._sourceSize;
  n.forEach((a, i) => {
    if (a !== null && a !== r[i])
      throw new Ir(a, r[i]);
  });
}
function En(e, t) {
  if (e !== void 0) {
    if (!_r(e) || !Ut(e))
      throw new TypeError("Index must be an integer (value: " + e + ")");
    if (e < 0 || typeof t == "number" && e >= t)
      throw new ou(e, t);
  }
}
function s1(e) {
  for (var t = 0; t < e._dimensions.length; ++t) {
    var r = e._dimensions[t];
    if (r._data && en(r._data)) {
      if (r._size[0] === 0)
        return !0;
    } else if (r.isRange) {
      if (r.start === r.end)
        return !0;
    } else if (Di(r) && r.length === 0)
      return !0;
  }
  return !1;
}
function u1(e, t, r) {
  if (!Array.isArray(t))
    throw new TypeError("Array expected");
  if (t.length === 0)
    throw new Error("Resizing to scalar is not supported");
  t.forEach(function(a) {
    if (!_r(a) || !Ut(a) || a < 0)
      throw new TypeError("Invalid size, must contain positive integers (size: " + Br(t) + ")");
  }), (_r(e) || hr(e)) && (e = [e]);
  var n = r !== void 0 ? r : 0;
  return j_(e, t, 0, n), e;
}
function j_(e, t, r, n) {
  var a, i, o = e.length, s = t[r], u = Math.min(o, s);
  if (e.length = s, r < t.length - 1) {
    var c = r + 1;
    for (a = 0; a < u; a++)
      i = e[a], Array.isArray(i) || (i = [i], e[a] = i), j_(i, t, c, n);
    for (a = u; a < s; a++)
      i = [], e[a] = i, j_(i, t, c, n);
  } else {
    for (a = 0; a < u; a++)
      for (; Array.isArray(e[a]); )
        e[a] = e[a][0];
    for (a = u; a < s; a++)
      e[a] = n;
  }
}
function DS(e, t) {
  var r = $r(e), n = r.length;
  if (!Array.isArray(e) || !Array.isArray(t))
    throw new TypeError("Array expected");
  if (t.length === 0)
    throw new Ir(0, n, "!=");
  t = MS(t, n);
  var a = GU(t);
  if (n !== a)
    throw new Ir(a, n, "!=");
  try {
    return Z1e(r, t);
  } catch (i) {
    throw i instanceof Ir ? new Ir(a, n, "!=") : i;
  }
}
function MS(e, t) {
  var r = GU(e), n = e.slice(), a = -1, i = e.indexOf(a), o = e.indexOf(a, i + 1) >= 0;
  if (o)
    throw new Error("More than one wildcard in sizes");
  var s = i >= 0, u = t % r === 0;
  if (s)
    if (u)
      n[i] = -t / r;
    else
      throw new Error("Could not replace wildcard, since " + t + " is no multiple of " + -r);
  return n;
}
function GU(e) {
  return e.reduce((t, r) => t * r, 1);
}
function Z1e(e, t) {
  for (var r = e, n, a = t.length - 1; a > 0; a--) {
    var i = t[a];
    n = [];
    for (var o = r.length / i, s = 0; s < o; s++)
      n.push(r.slice(s * i, (s + 1) * i));
    r = n;
  }
  return r;
}
function zy(e, t) {
  for (var r = Sr(e); Array.isArray(e) && e.length === 1; )
    e = e[0], r.shift();
  for (var n = r.length; r[n - 1] === 1; )
    n--;
  return n < r.length && (e = VU(e, n, 0), r.length = n), e;
}
function VU(e, t, r) {
  var n, a;
  if (r < t) {
    var i = r + 1;
    for (n = 0, a = e.length; n < a; n++)
      e[n] = VU(e[n], t, i);
  } else
    for (; Array.isArray(e); )
      e = e[0];
  return e;
}
function qU(e, t, r, n) {
  var a = n || Sr(e);
  if (r)
    for (var i = 0; i < r; i++)
      e = [e], a.unshift(1);
  for (e = HU(e, t, 0); a.length < t; )
    a.push(1);
  return e;
}
function HU(e, t, r) {
  var n, a;
  if (Array.isArray(e)) {
    var i = r + 1;
    for (n = 0, a = e.length; n < a; n++)
      e[n] = HU(e[n], t, i);
  } else
    for (var o = r; o < t; o++)
      e = [e];
  return e;
}
function $r(e) {
  if (!Array.isArray(e))
    return e;
  var t = [];
  return e.forEach(function r(n) {
    Array.isArray(n) ? n.forEach(r) : t.push(n);
  }), t;
}
function sl(e, t) {
  return Array.prototype.map.call(e, t);
}
function q3(e, t) {
  Array.prototype.forEach.call(e, t);
}
function KU(e, t) {
  if (Sr(e).length !== 1)
    throw new Error("Only one dimensional matrices supported");
  return Array.prototype.filter.call(e, t);
}
function Uy(e, t) {
  if (Sr(e).length !== 1)
    throw new Error("Only one dimensional matrices supported");
  return Array.prototype.filter.call(e, (r) => t.test(r));
}
function QI(e, t) {
  return Array.prototype.join.call(e, t);
}
function c1(e) {
  if (!Array.isArray(e))
    throw new TypeError("Array input expected");
  if (e.length === 0)
    return e;
  var t = [], r = 0;
  t[0] = {
    value: e[0],
    identifier: 0
  };
  for (var n = 1; n < e.length; n++)
    e[n] === e[n - 1] ? r++ : r = 0, t.push({
      value: e[n],
      identifier: r
    });
  return t;
}
function Gy(e) {
  if (!Array.isArray(e))
    throw new TypeError("Array input expected");
  if (e.length === 0)
    return e;
  for (var t = [], r = 0; r < e.length; r++)
    t.push(e[r].value);
  return t;
}
function Mh(e, t) {
  for (var r, n = 0, a = 0; a < e.length; a++) {
    var i = e[a], o = Array.isArray(i);
    if (a === 0 && o && (n = i.length), o && i.length !== n)
      return;
    var s = o ? Mh(i, t) : t(i);
    if (r === void 0)
      r = s;
    else if (r !== s)
      return "mixed";
  }
  return r;
}
function XU(e, t, r, n) {
  if (n < r) {
    if (e.length !== t.length)
      throw new Ir(e.length, t.length);
    for (var a = [], i = 0; i < e.length; i++)
      a[i] = XU(e[i], t[i], r, n + 1);
    return a;
  } else
    return e.concat(t);
}
function jU() {
  var e = Array.prototype.slice.call(arguments, 0, -1), t = Array.prototype.slice.call(arguments, -1);
  if (e.length === 1)
    return e[0];
  if (e.length > 1)
    return e.slice(1).reduce(function(r, n) {
      return XU(r, n, t, 0);
    }, e[0]);
  throw new Error("Wrong number of arguments in function concat");
}
function YU() {
  for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
    t[r] = arguments[r];
  for (var n = t.map((f) => f.length), a = Math.max(...n), i = new Array(a).fill(null), o = 0; o < t.length; o++)
    for (var s = t[o], u = n[o], c = 0; c < u; c++) {
      var l = a - u + c;
      s[c] > i[l] && (i[l] = s[c]);
    }
  for (var d = 0; d < t.length; d++)
    WU(t[d], i);
  return i;
}
function WU(e, t) {
  for (var r = t.length, n = e.length, a = 0; a < n; a++) {
    var i = r - n + a;
    if (e[a] < t[i] && e[a] > 1 || e[a] > t[i])
      throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(e, ") not possible to broadcast dimension ").concat(n, " with size ").concat(e[a], " to size ").concat(t[i]));
  }
}
function Y_(e, t) {
  var r = Sr(e);
  if (gl(r, t))
    return e;
  WU(r, t);
  var n = YU(r, t), a = n.length, i = [...Array(a - r.length).fill(1), ...r], o = $1e(e);
  r.length < a && (o = DS(o, i), r = Sr(o));
  for (var s = 0; s < a; s++)
    r[s] < n[s] && (o = Q1e(o, n[s], s), r = Sr(o));
  return o;
}
function Q1e(e, t, r) {
  return jU(...Array(t).fill(e), r);
}
function $1e(e) {
  return Ei([], e);
}
function J1e(e) {
  var t = 0, r = 1, n = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null), i = 0, o = function(u) {
    var c = a[u];
    if (c && (delete n[c], delete a[u], --t, r === c)) {
      if (!t) {
        i = 0, r = 1;
        return;
      }
      for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
        ;
    }
  };
  return e = Math.abs(e), {
    hit: function(u) {
      var c = a[u], l = ++i;
      if (n[l] = u, a[u] = l, !c)
        return ++t, t <= e ? void 0 : (u = n[r], o(u), u);
      if (delete n[c], r === c)
        for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
          ;
    },
    delete: o,
    clear: function() {
      t = i = 0, r = 1, n = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null);
    }
  };
}
function Yh(e) {
  var {
    hasher: t,
    limit: r
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return r = r ?? Number.POSITIVE_INFINITY, t = t ?? JSON.stringify, function n() {
    typeof n.cache != "object" && (n.cache = {
      values: /* @__PURE__ */ new Map(),
      lru: J1e(r || Number.POSITIVE_INFINITY)
    });
    for (var a = [], i = 0; i < arguments.length; i++)
      a[i] = arguments[i];
    var o = t(a);
    if (n.cache.values.has(o))
      return n.cache.lru.hit(o), n.cache.values.get(o);
    var s = e.apply(e, a);
    return n.cache.values.set(o, s), n.cache.values.delete(n.cache.lru.hit(o)), s;
  };
}
function ZU(e) {
  return Object.keys(e.signatures || {}).reduce(function(t, r) {
    var n = (r.match(/,/g) || []).length + 1;
    return Math.max(t, n);
  }, -1);
}
var e0e = "DenseMatrix", t0e = ["Matrix"], QU = /* @__PURE__ */ me(e0e, t0e, (e) => {
  var {
    Matrix: t
  } = e;
  function r(l, d) {
    if (!(this instanceof r))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (d && !Di(d))
      throw new Error("Invalid datatype: " + d);
    if (Zt(l))
      l.type === "DenseMatrix" ? (this._data = Jt(l._data), this._size = Jt(l._size), this._datatype = d || l._datatype) : (this._data = l.toArray(), this._size = l.size(), this._datatype = d || l._datatype);
    else if (l && en(l.data) && en(l.size))
      this._data = l.data, this._size = l.size, ZI(this._data, this._size), this._datatype = d || l.datatype;
    else if (en(l))
      this._data = c(l), this._size = Sr(this._data), ZI(this._data, this._size), this._datatype = d;
    else {
      if (l)
        throw new TypeError("Unsupported type of data (" + Nn(l) + ")");
      this._data = [], this._size = [0], this._datatype = d;
    }
  }
  r.prototype = new t(), r.prototype.createDenseMatrix = function(l, d) {
    return new r(l, d);
  }, Object.defineProperty(r, "name", {
    value: "DenseMatrix"
  }), r.prototype.constructor = r, r.prototype.type = "DenseMatrix", r.prototype.isDenseMatrix = !0, r.prototype.getDataType = function() {
    return Mh(this._data, Nn);
  }, r.prototype.storage = function() {
    return "dense";
  }, r.prototype.datatype = function() {
    return this._datatype;
  }, r.prototype.create = function(l, d) {
    return new r(l, d);
  }, r.prototype.subset = function(l, d, f) {
    switch (arguments.length) {
      case 1:
        return n(this, l);
      case 2:
      case 3:
        return i(this, l, d, f);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, r.prototype.get = function(l) {
    if (!en(l))
      throw new TypeError("Array expected");
    if (l.length !== this._size.length)
      throw new Ir(l.length, this._size.length);
    for (var d = 0; d < l.length; d++)
      En(l[d], this._size[d]);
    for (var f = this._data, m = 0, h = l.length; m < h; m++) {
      var p = l[m];
      En(p, f.length), f = f[p];
    }
    return f;
  }, r.prototype.set = function(l, d, f) {
    if (!en(l))
      throw new TypeError("Array expected");
    if (l.length < this._size.length)
      throw new Ir(l.length, this._size.length, "<");
    var m, h, p, g = l.map(function(y) {
      return y + 1;
    });
    u(this, g, f);
    var v = this._data;
    for (m = 0, h = l.length - 1; m < h; m++)
      p = l[m], En(p, v.length), v = v[p];
    return p = l[l.length - 1], En(p, v.length), v[p] = d, this;
  };
  function n(l, d) {
    if (!qh(d))
      throw new TypeError("Invalid index");
    var f = d.isScalar();
    if (f)
      return l.get(d.min());
    var m = d.size();
    if (m.length !== l._size.length)
      throw new Ir(m.length, l._size.length);
    for (var h = d.min(), p = d.max(), g = 0, v = l._size.length; g < v; g++)
      En(h[g], l._size[g]), En(p[g], l._size[g]);
    return new r(a(l._data, d, m.length, 0), l._datatype);
  }
  function a(l, d, f, m) {
    var h = m === f - 1, p = d.dimension(m);
    return h ? p.map(function(g) {
      return En(g, l.length), l[g];
    }).valueOf() : p.map(function(g) {
      En(g, l.length);
      var v = l[g];
      return a(v, d, f, m + 1);
    }).valueOf();
  }
  function i(l, d, f, m) {
    if (!d || d.isIndex !== !0)
      throw new TypeError("Invalid index");
    var h = d.size(), p = d.isScalar(), g;
    if (Zt(f) ? (g = f.size(), f = f.valueOf()) : g = Sr(f), p) {
      if (g.length !== 0)
        throw new TypeError("Scalar expected");
      l.set(d.min(), f, m);
    } else {
      if (!gl(g, h))
        try {
          g.length === 0 ? f = Y_([f], h) : f = Y_(f, h), g = Sr(f);
        } catch {
        }
      if (h.length < l._size.length)
        throw new Ir(h.length, l._size.length, "<");
      if (g.length < h.length) {
        for (var v = 0, y = 0; h[v] === 1 && g[v] === 1; )
          v++;
        for (; h[v] === 1; )
          y++, v++;
        f = qU(f, h.length, y, g);
      }
      if (!gl(h, g))
        throw new Ir(h, g, ">");
      var _ = d.max().map(function(x) {
        return x + 1;
      });
      u(l, _, m);
      var S = h.length, b = 0;
      o(l._data, d, f, S, b);
    }
    return l;
  }
  function o(l, d, f, m, h) {
    var p = h === m - 1, g = d.dimension(h);
    p ? g.forEach(function(v, y) {
      En(v), l[v] = f[y[0]];
    }) : g.forEach(function(v, y) {
      En(v), o(l[v], d, f[y[0]], m, h + 1);
    });
  }
  r.prototype.resize = function(l, d, f) {
    if (!bs(l))
      throw new TypeError("Array or Matrix expected");
    var m = l.valueOf().map((p) => Array.isArray(p) && p.length === 1 ? p[0] : p), h = f ? this.clone() : this;
    return s(h, m, d);
  };
  function s(l, d, f) {
    if (d.length === 0) {
      for (var m = l._data; en(m); )
        m = m[0];
      return m;
    }
    return l._size = d.slice(0), l._data = u1(l._data, l._size, f), l;
  }
  r.prototype.reshape = function(l, d) {
    var f = d ? this.clone() : this;
    f._data = DS(f._data, l);
    var m = f._size.reduce((h, p) => h * p);
    return f._size = MS(l, m), f;
  };
  function u(l, d, f) {
    for (var m = l._size.slice(0), h = !1; m.length < d.length; )
      m.push(0), h = !0;
    for (var p = 0, g = d.length; p < g; p++)
      d[p] > m[p] && (m[p] = d[p], h = !0);
    h && s(l, m, f);
  }
  r.prototype.clone = function() {
    var l = new r({
      data: Jt(this._data),
      size: Jt(this._size),
      datatype: this._datatype
    });
    return l;
  }, r.prototype.size = function() {
    return this._size.slice(0);
  }, r.prototype.map = function(l) {
    var d = this, f = ZU(l), m = function g(v, y) {
      return en(v) ? v.map(function(_, S) {
        return g(_, y.concat(S));
      }) : f === 1 ? l(v) : f === 2 ? l(v, y) : l(v, y, d);
    }, h = m(this._data, []), p = this._datatype !== void 0 ? Mh(h, Nn) : void 0;
    return new r(h, p);
  }, r.prototype.forEach = function(l) {
    var d = this, f = function m(h, p) {
      en(h) ? h.forEach(function(g, v) {
        m(g, p.concat(v));
      }) : l(h, p, d);
    };
    f(this._data, []);
  }, r.prototype[Symbol.iterator] = function* () {
    var l = function* d(f, m) {
      if (en(f))
        for (var h = 0; h < f.length; h++)
          yield* d(f[h], m.concat(h));
      else
        yield {
          value: f,
          index: m
        };
    };
    yield* l(this._data, []);
  }, r.prototype.rows = function() {
    var l = [], d = this.size();
    if (d.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    var f = this._data;
    for (var m of f)
      l.push(new r([m], this._datatype));
    return l;
  }, r.prototype.columns = function() {
    var l = this, d = [], f = this.size();
    if (f.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    for (var m = this._data, h = function(v) {
      var y = m.map((_) => [_[v]]);
      d.push(new r(y, l._datatype));
    }, p = 0; p < f[1]; p++)
      h(p);
    return d;
  }, r.prototype.toArray = function() {
    return Jt(this._data);
  }, r.prototype.valueOf = function() {
    return this._data;
  }, r.prototype.format = function(l) {
    return Br(this._data, l);
  }, r.prototype.toString = function() {
    return Br(this._data);
  }, r.prototype.toJSON = function() {
    return {
      mathjs: "DenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, r.prototype.diagonal = function(l) {
    if (l) {
      if (hr(l) && (l = l.toNumber()), !_r(l) || !Ut(l))
        throw new TypeError("The parameter k must be an integer number");
    } else
      l = 0;
    for (var d = l > 0 ? l : 0, f = l < 0 ? -l : 0, m = this._size[0], h = this._size[1], p = Math.min(m - f, h - d), g = [], v = 0; v < p; v++)
      g[v] = this._data[v + f][v + d];
    return new r({
      data: g,
      size: [p],
      datatype: this._datatype
    });
  }, r.diagonal = function(l, d, f, m) {
    if (!en(l))
      throw new TypeError("Array expected, size parameter");
    if (l.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (l = l.map(function(A) {
      if (hr(A) && (A = A.toNumber()), !_r(A) || !Ut(A) || A < 1)
        throw new Error("Size values must be positive integers");
      return A;
    }), f) {
      if (hr(f) && (f = f.toNumber()), !_r(f) || !Ut(f))
        throw new TypeError("The parameter k must be an integer number");
    } else
      f = 0;
    var h = f > 0 ? f : 0, p = f < 0 ? -f : 0, g = l[0], v = l[1], y = Math.min(g - p, v - h), _;
    if (en(d)) {
      if (d.length !== y)
        throw new Error("Invalid value array length");
      _ = function(w) {
        return d[w];
      };
    } else if (Zt(d)) {
      var S = d.size();
      if (S.length !== 1 || S[0] !== y)
        throw new Error("Invalid matrix length");
      _ = function(w) {
        return d.get([w]);
      };
    } else
      _ = function() {
        return d;
      };
    m || (m = hr(_(0)) ? _(0).mul(0) : 0);
    var b = [];
    if (l.length > 0) {
      b = u1(b, l, m);
      for (var x = 0; x < y; x++)
        b[x + p][x + h] = _(x);
    }
    return new r({
      data: b,
      size: [g, v]
    });
  }, r.fromJSON = function(l) {
    return new r(l);
  }, r.prototype.swapRows = function(l, d) {
    if (!_r(l) || !Ut(l) || !_r(d) || !Ut(d))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return En(l, this._size[0]), En(d, this._size[0]), r._swapRows(l, d, this._data), this;
  }, r._swapRows = function(l, d, f) {
    var m = f[l];
    f[l] = f[d], f[d] = m;
  };
  function c(l) {
    return Zt(l) ? c(l.valueOf()) : en(l) ? l.map(c) : l;
  }
  return r;
}, {
  isClass: !0
}), $I = "clone", r0e = ["typed"], n0e = /* @__PURE__ */ me($I, r0e, (e) => {
  var {
    typed: t
  } = e;
  return t($I, {
    any: Jt
  });
});
function $U(e) {
  var t = e.length, r = e[0].length, n, a, i = [];
  for (a = 0; a < r; a++) {
    var o = [];
    for (n = 0; n < t; n++)
      o.push(e[n][a]);
    i.push(o);
  }
  return i;
}
function _1(e) {
  for (var t = 0; t < e.length; t++)
    if (bs(e[t]))
      return !0;
  return !1;
}
function yl(e, t) {
  Zt(e) && (e = e.valueOf());
  for (var r = 0, n = e.length; r < n; r++) {
    var a = e[r];
    Array.isArray(a) ? yl(a, t) : t(a);
  }
}
function Tr(e, t, r) {
  return e && typeof e.map == "function" ? e.map(function(n) {
    return Tr(n, t);
  }) : t(e);
}
function H3(e, t, r) {
  var n = Array.isArray(e) ? Sr(e) : e.size();
  if (t < 0 || t >= n.length)
    throw new ou(t, n.length);
  return Zt(e) ? e.create(Vy(e.valueOf(), t, r)) : Vy(e, t, r);
}
function Vy(e, t, r) {
  var n, a, i, o;
  if (t <= 0)
    if (Array.isArray(e[0])) {
      for (o = $U(e), a = [], n = 0; n < o.length; n++)
        a[n] = Vy(o[n], t - 1, r);
      return a;
    } else {
      for (i = e[0], n = 1; n < e.length; n++)
        i = r(i, e[n]);
      return i;
    }
  else {
    for (a = [], n = 0; n < e.length; n++)
      a[n] = Vy(e[n], t - 1, r);
    return a;
  }
}
function JI(e, t, r, n, a, i, o, s, u, c, l) {
  var d = e._values, f = e._index, m = e._ptr, h, p, g, v;
  if (n)
    for (p = m[t], g = m[t + 1], h = p; h < g; h++)
      v = f[h], r[v] !== i ? (r[v] = i, o.push(v), n[v] = d[h]) : (n[v] = s(n[v], d[h]), a[v] = i);
  else
    for (p = m[t], g = m[t + 1], h = p; h < g; h++)
      v = f[h], r[v] !== i ? (r[v] = i, o.push(v)) : a[v] = i;
}
var eT = "isInteger", a0e = ["typed"], JU = /* @__PURE__ */ me(eT, a0e, (e) => {
  var {
    typed: t
  } = e;
  return t(eT, {
    number: Ut,
    // TODO: what to do with isInteger(add(0.1, 0.2))  ?
    BigNumber: function(n) {
      return n.isInt();
    },
    bigint: function(n) {
      return !0;
    },
    Fraction: function(n) {
      return n.d === 1 && isFinite(n.n);
    },
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), Ou = "number", S1 = "number, number";
function eG(e) {
  return Math.abs(e);
}
eG.signature = Ou;
function tG(e, t) {
  return e + t;
}
tG.signature = S1;
function rG(e, t) {
  return e - t;
}
rG.signature = S1;
function nG(e, t) {
  return e * t;
}
nG.signature = S1;
function aG(e) {
  return -e;
}
aG.signature = Ou;
function iG(e) {
  return e;
}
iG.signature = Ou;
function U0(e) {
  return cpe(e);
}
U0.signature = Ou;
function oG(e) {
  return e * e * e;
}
oG.signature = Ou;
function sG(e) {
  return Math.exp(e);
}
sG.signature = Ou;
function uG(e) {
  return lpe(e);
}
uG.signature = Ou;
function cG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Parameters in function lcm must be integer numbers");
  if (e === 0 || t === 0)
    return 0;
  for (var r, n = e * t; t !== 0; )
    r = t, t = e % r, e = r;
  return Math.abs(n / e);
}
cG.signature = S1;
function i0e(e, t) {
  return Math.log(e);
}
function lG(e) {
  return spe(e);
}
lG.signature = Ou;
function dG(e) {
  return ope(e);
}
dG.signature = Ou;
function tT(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2, r = t < 0;
  if (r && (t = -t), t === 0)
    throw new Error("Root must be non-zero");
  if (e < 0 && Math.abs(t) % 2 !== 1)
    throw new Error("Root must be odd when a is negative.");
  if (e === 0)
    return r ? 1 / 0 : 0;
  if (!isFinite(e))
    return r ? 0 : e;
  var n = Math.pow(Math.abs(e), 1 / t);
  return n = e < 0 ? -n : n, r ? 1 / n : n;
}
function W_(e) {
  return Nd(e);
}
W_.signature = Ou;
function fG(e) {
  return e * e;
}
fG.signature = Ou;
function mG(e, t) {
  var r, n, a, i = 0, o = 1, s = 1, u = 0;
  if (!Ut(e) || !Ut(t))
    throw new Error("Parameters in function xgcd must be integer numbers");
  for (; t; )
    n = Math.floor(e / t), a = e - n * t, r = i, i = o - n * i, o = r, r = s, s = u - n * s, u = r, e = t, t = a;
  var c;
  return e < 0 ? c = [-e, -o, -u] : c = [e, e ? o : 0, u], c;
}
mG.signature = S1;
function pG(e, t) {
  return e * e < 1 && t === 1 / 0 || e * e > 1 && t === -1 / 0 ? 0 : Math.pow(e, t);
}
pG.signature = S1;
function S0(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  if (!Ut(t) || t < 0 || t > 15)
    throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");
  return parseFloat(mU(e, t));
}
var o0e = "number", A1 = "number, number";
function hG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function bitAnd");
  return e & t;
}
hG.signature = A1;
function vG(e) {
  if (!Ut(e))
    throw new Error("Integer expected in function bitNot");
  return ~e;
}
vG.signature = o0e;
function gG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function bitOr");
  return e | t;
}
gG.signature = A1;
function yG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function bitXor");
  return e ^ t;
}
yG.signature = A1;
function bG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function leftShift");
  return e << t;
}
bG.signature = A1;
function xG(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function rightArithShift");
  return e >> t;
}
xG.signature = A1;
function _G(e, t) {
  if (!Ut(e) || !Ut(t))
    throw new Error("Integers expected in function rightLogShift");
  return e >>> t;
}
_G.signature = A1;
function el(e, t) {
  if (t < e)
    return 1;
  if (t === e)
    return t;
  var r = t + e >> 1;
  return el(e, r) * el(r + 1, t);
}
function SG(e, t) {
  if (!Ut(e) || e < 0)
    throw new TypeError("Positive integer value expected in function combinations");
  if (!Ut(t) || t < 0)
    throw new TypeError("Positive integer value expected in function combinations");
  if (t > e)
    throw new TypeError("k must be less than or equal to n");
  for (var r = e - t, n = 1, a = t < r ? r + 1 : t + 1, i = 2, o = t < r ? t : r, s = a; s <= e; ++s)
    for (n *= s; i <= o && n % i === 0; )
      n /= i, ++i;
  return i <= o && (n /= el(i, o)), n;
}
SG.signature = "number, number";
var s0e = Math.PI, u0e = 2 * Math.PI, c0e = Math.E, l0e = 1.618033988749895, d0e = "number", IS = "number, number";
function AG(e) {
  return !e;
}
AG.signature = d0e;
function Z_(e, t) {
  return !!(e || t);
}
Z_.signature = IS;
function Q_(e, t) {
  return !!e != !!t;
}
Q_.signature = IS;
function $_(e, t) {
  return !!(e && t);
}
$_.signature = IS;
function qy(e) {
  var t;
  if (Ut(e))
    return e <= 0 ? isFinite(e) ? 1 / 0 : NaN : e > 171 ? 1 / 0 : el(1, e - 1);
  if (e < 0.5)
    return Math.PI / (Math.sin(Math.PI * e) * qy(1 - e));
  if (e >= 171.35)
    return 1 / 0;
  if (e > 85) {
    var r = e * e, n = r * e, a = n * e, i = a * e;
    return Math.sqrt(2 * Math.PI / e) * Math.pow(e / Math.E, e) * (1 + 1 / (12 * e) + 1 / (288 * r) - 139 / (51840 * n) - 571 / (2488320 * a) + 163879 / (209018880 * i) + 5246819 / (75246796800 * i * e));
  }
  --e, t = Pp[0];
  for (var o = 1; o < Pp.length; ++o)
    t += Pp[o] / (e + o);
  var s = e + wG + 0.5;
  return Math.sqrt(2 * Math.PI) * Math.pow(s, e + 0.5) * Math.exp(-s) * t;
}
qy.signature = "number";
var wG = 4.7421875, Pp = [0.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -0.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, 1580887032249125e-19, -21026444172410488e-20, 21743961811521265e-20, -1643181065367639e-19, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22], CG = 0.9189385332046728, f0e = 5, m0e = 7, rT = [1.000000000190015, 76.18009172947146, -86.50532032941678, 24.01409824083091, -1.231739572450155, 0.001208650973866179, -5395239384953e-18];
function Hy(e) {
  if (e < 0) return NaN;
  if (e === 0) return 1 / 0;
  if (!isFinite(e)) return e;
  if (e < 0.5)
    return Math.log(Math.PI / Math.sin(Math.PI * e)) - Hy(1 - e);
  e = e - 1;
  for (var t = e + f0e + 0.5, r = rT[0], n = m0e - 1; n >= 1; n--)
    r += rT[n] / (e + n);
  return CG + (e + 0.5) * Math.log(t) - t + Math.log(r);
}
Hy.signature = "number";
var Ji = "number";
function EG(e) {
  return ppe(e);
}
EG.signature = Ji;
function DG(e) {
  return Math.atan(1 / e);
}
DG.signature = Ji;
function MG(e) {
  return isFinite(e) ? (Math.log((e + 1) / e) + Math.log(e / (e - 1))) / 2 : 0;
}
MG.signature = Ji;
function IG(e) {
  return Math.asin(1 / e);
}
IG.signature = Ji;
function TG(e) {
  var t = 1 / e;
  return Math.log(t + Math.sqrt(t * t + 1));
}
TG.signature = Ji;
function NG(e) {
  return Math.acos(1 / e);
}
NG.signature = Ji;
function PG(e) {
  var t = 1 / e, r = Math.sqrt(t * t - 1);
  return Math.log(r + t);
}
PG.signature = Ji;
function BG(e) {
  return hpe(e);
}
BG.signature = Ji;
function OG(e) {
  return vpe(e);
}
OG.signature = Ji;
function FG(e) {
  return 1 / Math.tan(e);
}
FG.signature = Ji;
function RG(e) {
  var t = Math.exp(2 * e);
  return (t + 1) / (t - 1);
}
RG.signature = Ji;
function LG(e) {
  return 1 / Math.sin(e);
}
LG.signature = Ji;
function kG(e) {
  return e === 0 ? Number.POSITIVE_INFINITY : Math.abs(2 / (Math.exp(e) - Math.exp(-e))) * Nd(e);
}
kG.signature = Ji;
function zG(e) {
  return 1 / Math.cos(e);
}
zG.signature = Ji;
function UG(e) {
  return 2 / (Math.exp(e) + Math.exp(-e));
}
UG.signature = Ji;
function GG(e) {
  return ype(e);
}
GG.signature = Ji;
var TS = "number";
function VG(e) {
  return e < 0;
}
VG.signature = TS;
function qG(e) {
  return e > 0;
}
qG.signature = TS;
function HG(e) {
  return Number.isNaN(e);
}
HG.signature = TS;
function Xo(e, t) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-9, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return e.isNaN() || t.isNaN() ? !1 : !e.isFinite() || !t.isFinite() ? e.eq(t) : e.eq(t) ? !0 : e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(), t.abs()).mul(r), n));
}
var nT = "isNegative", p0e = ["typed", "config"], h0e = /* @__PURE__ */ me(nT, p0e, (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(nT, {
    number: (n) => Fi(n, 0, r.relTol, r.absTol) ? !1 : VG(n),
    BigNumber: (n) => Xo(n, new n.constructor(0), r.relTol, r.absTol) ? !1 : n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n < 0n,
    Fraction: (n) => n.s < 0,
    // It's enough to decide on the sign
    Unit: t.referToSelf((n) => (a) => t.find(n, a.valueType())(a.value)),
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), aT = "isNumeric", v0e = ["typed"], g0e = /* @__PURE__ */ me(aT, v0e, (e) => {
  var {
    typed: t
  } = e;
  return t(aT, {
    "number | BigNumber | bigint | Fraction | boolean": () => !0,
    "Complex | Unit | string | null | undefined | Node": () => !1,
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), iT = "hasNumericValue", y0e = ["typed", "isNumeric"], b0e = /* @__PURE__ */ me(iT, y0e, (e) => {
  var {
    typed: t,
    isNumeric: r
  } = e;
  return t(iT, {
    boolean: () => !0,
    string: function(a) {
      return a.trim().length > 0 && !isNaN(Number(a));
    },
    any: function(a) {
      return r(a);
    }
  });
}), oT = "isPositive", x0e = ["typed", "config"], KG = /* @__PURE__ */ me(oT, x0e, (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(oT, {
    number: (n) => Fi(n, 0, r.relTol, r.absTol) ? !1 : qG(n),
    BigNumber: (n) => Xo(n, new n.constructor(0), r.relTol, r.absTol) ? !1 : !n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n > 0n,
    Fraction: (n) => n.s > 0 && n.n > 0,
    Unit: t.referToSelf((n) => (a) => t.find(n, a.valueType())(a.value)),
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), sT = "isZero", _0e = ["typed", "equalScalar"], XG = /* @__PURE__ */ me(sT, _0e, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return t(sT, {
    "number | BigNumber | Complex | Fraction": (n) => r(n, 0),
    bigint: (n) => n === 0n,
    Unit: t.referToSelf((n) => (a) => t.find(n, a.valueType())(a.value)),
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), uT = "isNaN", S0e = ["typed"], A0e = /* @__PURE__ */ me(uT, S0e, (e) => {
  var {
    typed: t
  } = e;
  return t(uT, {
    number: HG,
    BigNumber: function(n) {
      return n.isNaN();
    },
    bigint: function(n) {
      return !1;
    },
    Fraction: function(n) {
      return !1;
    },
    Complex: function(n) {
      return n.isNaN();
    },
    Unit: function(n) {
      return Number.isNaN(n.value);
    },
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), cT = "typeOf", w0e = ["typed"], C0e = /* @__PURE__ */ me(cT, w0e, (e) => {
  var {
    typed: t
  } = e;
  return t(cT, {
    any: Nn
  });
});
function E0e(e, t, r, n) {
  return Fi(e.re, t.re, r, n) && Fi(e.im, t.im, r, n);
}
var w1 = /* @__PURE__ */ me("compareUnits", ["typed"], (e) => {
  var {
    typed: t
  } = e;
  return {
    "Unit, Unit": t.referToSelf((r) => (n, a) => {
      if (!n.equalBase(a))
        throw new Error("Cannot compare units with different base");
      return t.find(r, [n.valueType(), a.valueType()])(n.value, a.value);
    })
  };
}), Ky = "equalScalar", D0e = ["typed", "config"], jG = /* @__PURE__ */ me(Ky, D0e, (e) => {
  var {
    typed: t,
    config: r
  } = e, n = w1({
    typed: t
  });
  return t(Ky, {
    "boolean, boolean": function(i, o) {
      return i === o;
    },
    "number, number": function(i, o) {
      return Fi(i, o, r.relTol, r.absTol);
    },
    "BigNumber, BigNumber": function(i, o) {
      return i.eq(o) || Xo(i, o, r.relTol, r.absTol);
    },
    "bigint, bigint": function(i, o) {
      return i === o;
    },
    "Fraction, Fraction": function(i, o) {
      return i.equals(o);
    },
    "Complex, Complex": function(i, o) {
      return E0e(i, o, r.relTol, r.absTol);
    }
  }, n);
});
me(Ky, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(Ky, {
    "number, number": function(a, i) {
      return Fi(a, i, r.relTol, r.absTol);
    }
  });
});
var M0e = "SparseMatrix", I0e = ["typed", "equalScalar", "Matrix"], YG = /* @__PURE__ */ me(M0e, I0e, (e) => {
  var {
    typed: t,
    equalScalar: r,
    Matrix: n
  } = e;
  function a(p, g) {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (g && !Di(g))
      throw new Error("Invalid datatype: " + g);
    if (Zt(p))
      i(this, p, g);
    else if (p && en(p.index) && en(p.ptr) && en(p.size))
      this._values = p.values, this._index = p.index, this._ptr = p.ptr, this._size = p.size, this._datatype = g || p.datatype;
    else if (en(p))
      o(this, p, g);
    else {
      if (p)
        throw new TypeError("Unsupported type of data (" + Nn(p) + ")");
      this._values = [], this._index = [], this._ptr = [0], this._size = [0, 0], this._datatype = g;
    }
  }
  function i(p, g, v) {
    g.type === "SparseMatrix" ? (p._values = g._values ? Jt(g._values) : void 0, p._index = Jt(g._index), p._ptr = Jt(g._ptr), p._size = Jt(g._size), p._datatype = v || g._datatype) : o(p, g.valueOf(), v || g._datatype);
  }
  function o(p, g, v) {
    p._values = [], p._index = [], p._ptr = [], p._datatype = v;
    var y = g.length, _ = 0, S = r, b = 0;
    if (Di(v) && (S = t.find(r, [v, v]) || r, b = t.convert(0, v)), y > 0) {
      var x = 0;
      do {
        p._ptr.push(p._index.length);
        for (var A = 0; A < y; A++) {
          var w = g[A];
          if (en(w)) {
            if (x === 0 && _ < w.length && (_ = w.length), x < w.length) {
              var C = w[x];
              S(C, b) || (p._values.push(C), p._index.push(A));
            }
          } else
            x === 0 && _ < 1 && (_ = 1), S(w, b) || (p._values.push(w), p._index.push(A));
        }
        x++;
      } while (x < _);
    }
    p._ptr.push(p._index.length), p._size = [y, _];
  }
  a.prototype = new n(), a.prototype.createSparseMatrix = function(p, g) {
    return new a(p, g);
  }, Object.defineProperty(a, "name", {
    value: "SparseMatrix"
  }), a.prototype.constructor = a, a.prototype.type = "SparseMatrix", a.prototype.isSparseMatrix = !0, a.prototype.getDataType = function() {
    return Mh(this._values, Nn);
  }, a.prototype.storage = function() {
    return "sparse";
  }, a.prototype.datatype = function() {
    return this._datatype;
  }, a.prototype.create = function(p, g) {
    return new a(p, g);
  }, a.prototype.density = function() {
    var p = this._size[0], g = this._size[1];
    return p !== 0 && g !== 0 ? this._index.length / (p * g) : 0;
  }, a.prototype.subset = function(p, g, v) {
    if (!this._values)
      throw new Error("Cannot invoke subset on a Pattern only matrix");
    switch (arguments.length) {
      case 1:
        return s(this, p);
      case 2:
      case 3:
        return u(this, p, g, v);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  };
  function s(p, g) {
    if (!qh(g))
      throw new TypeError("Invalid index");
    var v = g.isScalar();
    if (v)
      return p.get(g.min());
    var y = g.size();
    if (y.length !== p._size.length)
      throw new Ir(y.length, p._size.length);
    var _, S, b, x, A = g.min(), w = g.max();
    for (_ = 0, S = p._size.length; _ < S; _++)
      En(A[_], p._size[_]), En(w[_], p._size[_]);
    var C = p._values, M = p._index, T = p._ptr, N = g.dimension(0), I = g.dimension(1), P = [], O = [];
    N.forEach(function(L, q) {
      O[L] = q[0], P[L] = !0;
    });
    var F = C ? [] : void 0, R = [], G = [];
    return I.forEach(function(L) {
      for (G.push(R.length), b = T[L], x = T[L + 1]; b < x; b++)
        _ = M[b], P[_] === !0 && (R.push(O[_]), F && F.push(C[b]));
    }), G.push(R.length), new a({
      values: F,
      index: R,
      ptr: G,
      size: y,
      datatype: p._datatype
    });
  }
  function u(p, g, v, y) {
    if (!g || g.isIndex !== !0)
      throw new TypeError("Invalid index");
    var _ = g.size(), S = g.isScalar(), b;
    if (Zt(v) ? (b = v.size(), v = v.toArray()) : b = Sr(v), S) {
      if (b.length !== 0)
        throw new TypeError("Scalar expected");
      p.set(g.min(), v, y);
    } else {
      if (_.length !== 1 && _.length !== 2)
        throw new Ir(_.length, p._size.length, "<");
      if (b.length < _.length) {
        for (var x = 0, A = 0; _[x] === 1 && b[x] === 1; )
          x++;
        for (; _[x] === 1; )
          A++, x++;
        v = qU(v, _.length, A, b);
      }
      if (!gl(_, b))
        throw new Ir(_, b, ">");
      if (_.length === 1) {
        var w = g.dimension(0);
        w.forEach(function(T, N) {
          En(T), p.set([T, 0], v[N[0]], y);
        });
      } else {
        var C = g.dimension(0), M = g.dimension(1);
        C.forEach(function(T, N) {
          En(T), M.forEach(function(I, P) {
            En(I), p.set([T, I], v[N[0]][P[0]], y);
          });
        });
      }
    }
    return p;
  }
  a.prototype.get = function(p) {
    if (!en(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new Ir(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke get on a Pattern only matrix");
    var g = p[0], v = p[1];
    En(g, this._size[0]), En(v, this._size[1]);
    var y = c(g, this._ptr[v], this._ptr[v + 1], this._index);
    return y < this._ptr[v + 1] && this._index[y] === g ? this._values[y] : 0;
  }, a.prototype.set = function(p, g, v) {
    if (!en(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new Ir(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke set on a Pattern only matrix");
    var y = p[0], _ = p[1], S = this._size[0], b = this._size[1], x = r, A = 0;
    Di(this._datatype) && (x = t.find(r, [this._datatype, this._datatype]) || r, A = t.convert(0, this._datatype)), (y > S - 1 || _ > b - 1) && (f(this, Math.max(y + 1, S), Math.max(_ + 1, b), v), S = this._size[0], b = this._size[1]), En(y, S), En(_, b);
    var w = c(y, this._ptr[_], this._ptr[_ + 1], this._index);
    return w < this._ptr[_ + 1] && this._index[w] === y ? x(g, A) ? l(w, _, this._values, this._index, this._ptr) : this._values[w] = g : x(g, A) || d(w, y, _, g, this._values, this._index, this._ptr), this;
  };
  function c(p, g, v, y) {
    if (v - g === 0)
      return v;
    for (var _ = g; _ < v; _++)
      if (y[_] === p)
        return _;
    return g;
  }
  function l(p, g, v, y, _) {
    v.splice(p, 1), y.splice(p, 1);
    for (var S = g + 1; S < _.length; S++)
      _[S]--;
  }
  function d(p, g, v, y, _, S, b) {
    _.splice(p, 0, y), S.splice(p, 0, g);
    for (var x = v + 1; x < b.length; x++)
      b[x]++;
  }
  a.prototype.resize = function(p, g, v) {
    if (!bs(p))
      throw new TypeError("Array or Matrix expected");
    var y = p.valueOf().map((S) => Array.isArray(S) && S.length === 1 ? S[0] : S);
    if (y.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    y.forEach(function(S) {
      if (!_r(S) || !Ut(S) || S < 0)
        throw new TypeError("Invalid size, must contain positive integers (size: " + Br(y) + ")");
    });
    var _ = v ? this.clone() : this;
    return f(_, y[0], y[1], g);
  };
  function f(p, g, v, y) {
    var _ = y || 0, S = r, b = 0;
    Di(p._datatype) && (S = t.find(r, [p._datatype, p._datatype]) || r, b = t.convert(0, p._datatype), _ = t.convert(_, p._datatype));
    var x = !S(_, b), A = p._size[0], w = p._size[1], C, M, T;
    if (v > w) {
      for (M = w; M < v; M++)
        if (p._ptr[M] = p._values.length, x)
          for (C = 0; C < A; C++)
            p._values.push(_), p._index.push(C);
      p._ptr[v] = p._values.length;
    } else v < w && (p._ptr.splice(v + 1, w - v), p._values.splice(p._ptr[v], p._values.length), p._index.splice(p._ptr[v], p._index.length));
    if (w = v, g > A) {
      if (x) {
        var N = 0;
        for (M = 0; M < w; M++) {
          p._ptr[M] = p._ptr[M] + N, T = p._ptr[M + 1] + N;
          var I = 0;
          for (C = A; C < g; C++, I++)
            p._values.splice(T + I, 0, _), p._index.splice(T + I, 0, C), N++;
        }
        p._ptr[w] = p._values.length;
      }
    } else if (g < A) {
      var P = 0;
      for (M = 0; M < w; M++) {
        p._ptr[M] = p._ptr[M] - P;
        var O = p._ptr[M], F = p._ptr[M + 1] - P;
        for (T = O; T < F; T++)
          C = p._index[T], C > g - 1 && (p._values.splice(T, 1), p._index.splice(T, 1), P++);
      }
      p._ptr[M] = p._values.length;
    }
    return p._size[0] = g, p._size[1] = v, p;
  }
  a.prototype.reshape = function(p, g) {
    if (!en(p))
      throw new TypeError("Array expected");
    if (p.length !== 2)
      throw new Error("Sparse matrices can only be reshaped in two dimensions");
    p.forEach(function(L) {
      if (!_r(L) || !Ut(L) || L <= -2 || L === 0)
        throw new TypeError("Invalid size, must contain positive integers or -1 (size: " + Br(p) + ")");
    });
    var v = this._size[0] * this._size[1];
    p = MS(p, v);
    var y = p[0] * p[1];
    if (v !== y)
      throw new Error("Reshaping sparse matrix will result in the wrong number of elements");
    var _ = g ? this.clone() : this;
    if (this._size[0] === p[0] && this._size[1] === p[1])
      return _;
    for (var S = [], b = 0; b < _._ptr.length; b++)
      for (var x = 0; x < _._ptr[b + 1] - _._ptr[b]; x++)
        S.push(b);
    for (var A = _._values.slice(), w = _._index.slice(), C = 0; C < _._index.length; C++) {
      var M = w[C], T = S[C], N = M * _._size[1] + T;
      S[C] = N % p[1], w[C] = Math.floor(N / p[1]);
    }
    _._values.length = 0, _._index.length = 0, _._ptr.length = p[1] + 1, _._size = p.slice();
    for (var I = 0; I < _._ptr.length; I++)
      _._ptr[I] = 0;
    for (var P = 0; P < A.length; P++) {
      var O = w[P], F = S[P], R = A[P], G = c(O, _._ptr[F], _._ptr[F + 1], _._index);
      d(G, O, F, R, _._values, _._index, _._ptr);
    }
    return _;
  }, a.prototype.clone = function() {
    var p = new a({
      values: this._values ? Jt(this._values) : void 0,
      index: Jt(this._index),
      ptr: Jt(this._ptr),
      size: Jt(this._size),
      datatype: this._datatype
    });
    return p;
  }, a.prototype.size = function() {
    return this._size.slice(0);
  }, a.prototype.map = function(p, g) {
    if (!this._values)
      throw new Error("Cannot invoke map on a Pattern only matrix");
    var v = this, y = this._size[0], _ = this._size[1], S = ZU(p), b = function(A, w, C) {
      return S === 1 ? p(A) : S === 2 ? p(A, [w, C]) : p(A, [w, C], v);
    };
    return m(this, 0, y - 1, 0, _ - 1, b, g);
  };
  function m(p, g, v, y, _, S, b) {
    var x = [], A = [], w = [], C = r, M = 0;
    Di(p._datatype) && (C = t.find(r, [p._datatype, p._datatype]) || r, M = t.convert(0, p._datatype));
    for (var T = function(H, W, ee) {
      H = S(H, W, ee), C(H, M) || (x.push(H), A.push(W));
    }, N = y; N <= _; N++) {
      w.push(x.length);
      var I = p._ptr[N], P = p._ptr[N + 1];
      if (b)
        for (var O = I; O < P; O++) {
          var F = p._index[O];
          F >= g && F <= v && T(p._values[O], F - g, N - y);
        }
      else {
        for (var R = {}, G = I; G < P; G++) {
          var L = p._index[G];
          R[L] = p._values[G];
        }
        for (var q = g; q <= v; q++) {
          var K = q in R ? R[q] : 0;
          T(K, q - g, N - y);
        }
      }
    }
    return w.push(x.length), new a({
      values: x,
      index: A,
      ptr: w,
      size: [v - g + 1, _ - y + 1]
    });
  }
  a.prototype.forEach = function(p, g) {
    if (!this._values)
      throw new Error("Cannot invoke forEach on a Pattern only matrix");
    for (var v = this, y = this._size[0], _ = this._size[1], S = 0; S < _; S++) {
      var b = this._ptr[S], x = this._ptr[S + 1];
      if (g)
        for (var A = b; A < x; A++) {
          var w = this._index[A];
          p(this._values[A], [w, S], v);
        }
      else {
        for (var C = {}, M = b; M < x; M++) {
          var T = this._index[M];
          C[T] = this._values[M];
        }
        for (var N = 0; N < y; N++) {
          var I = N in C ? C[N] : 0;
          p(I, [N, S], v);
        }
      }
    }
  }, a.prototype[Symbol.iterator] = function* () {
    if (!this._values)
      throw new Error("Cannot iterate a Pattern only matrix");
    for (var p = this._size[1], g = 0; g < p; g++)
      for (var v = this._ptr[g], y = this._ptr[g + 1], _ = v; _ < y; _++) {
        var S = this._index[_];
        yield {
          value: this._values[_],
          index: [S, g]
        };
      }
  }, a.prototype.toArray = function() {
    return h(this._values, this._index, this._ptr, this._size, !0);
  }, a.prototype.valueOf = function() {
    return h(this._values, this._index, this._ptr, this._size, !1);
  };
  function h(p, g, v, y, _) {
    var S = y[0], b = y[1], x = [], A, w;
    for (A = 0; A < S; A++)
      for (x[A] = [], w = 0; w < b; w++)
        x[A][w] = 0;
    for (w = 0; w < b; w++)
      for (var C = v[w], M = v[w + 1], T = C; T < M; T++)
        A = g[T], x[A][w] = p ? _ ? Jt(p[T]) : p[T] : 1;
    return x;
  }
  return a.prototype.format = function(p) {
    for (var g = this._size[0], v = this._size[1], y = this.density(), _ = "Sparse Matrix [" + Br(g, p) + " x " + Br(v, p) + "] density: " + Br(y, p) + `
`, S = 0; S < v; S++)
      for (var b = this._ptr[S], x = this._ptr[S + 1], A = b; A < x; A++) {
        var w = this._index[A];
        _ += `
    (` + Br(w, p) + ", " + Br(S, p) + ") ==> " + (this._values ? Br(this._values[A], p) : "X");
      }
    return _;
  }, a.prototype.toString = function() {
    return Br(this.toArray());
  }, a.prototype.toJSON = function() {
    return {
      mathjs: "SparseMatrix",
      values: this._values,
      index: this._index,
      ptr: this._ptr,
      size: this._size,
      datatype: this._datatype
    };
  }, a.prototype.diagonal = function(p) {
    if (p) {
      if (hr(p) && (p = p.toNumber()), !_r(p) || !Ut(p))
        throw new TypeError("The parameter k must be an integer number");
    } else
      p = 0;
    var g = p > 0 ? p : 0, v = p < 0 ? -p : 0, y = this._size[0], _ = this._size[1], S = Math.min(y - v, _ - g), b = [], x = [], A = [];
    A[0] = 0;
    for (var w = g; w < _ && b.length < S; w++)
      for (var C = this._ptr[w], M = this._ptr[w + 1], T = C; T < M; T++) {
        var N = this._index[T];
        if (N === w - g + v) {
          b.push(this._values[T]), x[b.length - 1] = N - v;
          break;
        }
      }
    return A.push(b.length), new a({
      values: b,
      index: x,
      ptr: A,
      size: [S, 1]
    });
  }, a.fromJSON = function(p) {
    return new a(p);
  }, a.diagonal = function(p, g, v, y, _) {
    if (!en(p))
      throw new TypeError("Array expected, size parameter");
    if (p.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (p = p.map(function(L) {
      if (hr(L) && (L = L.toNumber()), !_r(L) || !Ut(L) || L < 1)
        throw new Error("Size values must be positive integers");
      return L;
    }), v) {
      if (hr(v) && (v = v.toNumber()), !_r(v) || !Ut(v))
        throw new TypeError("The parameter k must be an integer number");
    } else
      v = 0;
    var S = r, b = 0;
    Di(_) && (S = t.find(r, [_, _]) || r, b = t.convert(0, _));
    var x = v > 0 ? v : 0, A = v < 0 ? -v : 0, w = p[0], C = p[1], M = Math.min(w - A, C - x), T;
    if (en(g)) {
      if (g.length !== M)
        throw new Error("Invalid value array length");
      T = function(q) {
        return g[q];
      };
    } else if (Zt(g)) {
      var N = g.size();
      if (N.length !== 1 || N[0] !== M)
        throw new Error("Invalid matrix length");
      T = function(q) {
        return g.get([q]);
      };
    } else
      T = function() {
        return g;
      };
    for (var I = [], P = [], O = [], F = 0; F < C; F++) {
      O.push(I.length);
      var R = F - x;
      if (R >= 0 && R < M) {
        var G = T(R);
        S(G, b) || (P.push(R + A), I.push(G));
      }
    }
    return O.push(I.length), new a({
      values: I,
      index: P,
      ptr: O,
      size: [w, C]
    });
  }, a.prototype.swapRows = function(p, g) {
    if (!_r(p) || !Ut(p) || !_r(g) || !Ut(g))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return En(p, this._size[0]), En(g, this._size[0]), a._swapRows(p, g, this._size[1], this._values, this._index, this._ptr), this;
  }, a._forEachRow = function(p, g, v, y, _) {
    for (var S = y[p], b = y[p + 1], x = S; x < b; x++)
      _(v[x], g[x]);
  }, a._swapRows = function(p, g, v, y, _, S) {
    for (var b = 0; b < v; b++) {
      var x = S[b], A = S[b + 1], w = c(p, x, A, _), C = c(g, x, A, _);
      if (w < A && C < A && _[w] === p && _[C] === g) {
        if (y) {
          var M = y[w];
          y[w] = y[C], y[C] = M;
        }
        continue;
      }
      if (w < A && _[w] === p && (C >= A || _[C] !== g)) {
        var T = y ? y[w] : void 0;
        _.splice(C, 0, g), y && y.splice(C, 0, T), _.splice(C <= w ? w + 1 : w, 1), y && y.splice(C <= w ? w + 1 : w, 1);
        continue;
      }
      if (C < A && _[C] === g && (w >= A || _[w] !== p)) {
        var N = y ? y[C] : void 0;
        _.splice(w, 0, p), y && y.splice(w, 0, N), _.splice(w <= C ? C + 1 : C, 1), y && y.splice(w <= C ? C + 1 : C, 1);
      }
    }
  }, a;
}, {
  isClass: !0
}), T0e = "number", N0e = ["typed"];
function P0e(e) {
  var t = e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);
  if (t) {
    var r = {
      "0b": 2,
      "0o": 8,
      "0x": 16
    }[t[1]], n = t[2], a = t[3];
    return {
      input: e,
      radix: r,
      integerPart: n,
      fractionalPart: a
    };
  } else
    return null;
}
function B0e(e) {
  for (var t = parseInt(e.integerPart, e.radix), r = 0, n = 0; n < e.fractionalPart.length; n++) {
    var a = parseInt(e.fractionalPart[n], e.radix);
    r += a / Math.pow(e.radix, n + 1);
  }
  var i = t + r;
  if (isNaN(i))
    throw new SyntaxError('String "' + e.input + '" is not a valid number');
  return i;
}
var WG = /* @__PURE__ */ me(T0e, N0e, (e) => {
  var {
    typed: t
  } = e, r = t("number", {
    "": function() {
      return 0;
    },
    number: function(a) {
      return a;
    },
    string: function(a) {
      if (a === "NaN") return NaN;
      var i = P0e(a);
      if (i)
        return B0e(i);
      var o = 0, s = a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      s && (o = Number(s[2]), a = s[1]);
      var u = Number(a);
      if (isNaN(u))
        throw new SyntaxError('String "' + a + '" is not a valid number');
      if (s) {
        if (u > 2 ** o - 1)
          throw new SyntaxError('String "'.concat(a, '" is out of range'));
        u >= 2 ** (o - 1) && (u = u - 2 ** o);
      }
      return u;
    },
    BigNumber: function(a) {
      return a.toNumber();
    },
    bigint: function(a) {
      return Number(a);
    },
    Fraction: function(a) {
      return a.valueOf();
    },
    Unit: t.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    null: function(a) {
      return 0;
    },
    "Unit, string | Unit": function(a, i) {
      return a.toNumber(i);
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
  return r.fromJSON = function(n) {
    return parseFloat(n.value);
  }, r;
}), O0e = "bigint", F0e = ["typed"], R0e = /* @__PURE__ */ me(O0e, F0e, (e) => {
  var {
    typed: t
  } = e, r = t("bigint", {
    "": function() {
      return 0n;
    },
    bigint: function(a) {
      return a;
    },
    number: function(a) {
      return BigInt(a.toFixed());
    },
    BigNumber: function(a) {
      return BigInt(a.round().toString());
    },
    Fraction: function(a) {
      return BigInt(a.valueOf().toFixed());
    },
    "string | boolean": function(a) {
      return BigInt(a);
    },
    null: function(a) {
      return 0n;
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
  return r.fromJSON = function(n) {
    return BigInt(n.value);
  }, r;
}), lT = "string", L0e = ["typed"], k0e = /* @__PURE__ */ me(lT, L0e, (e) => {
  var {
    typed: t
  } = e;
  return t(lT, {
    "": function() {
      return "";
    },
    number: Qf,
    null: function(n) {
      return "null";
    },
    boolean: function(n) {
      return n + "";
    },
    string: function(n) {
      return n;
    },
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r)),
    any: function(n) {
      return String(n);
    }
  });
}), dT = "boolean", z0e = ["typed"], U0e = /* @__PURE__ */ me(dT, z0e, (e) => {
  var {
    typed: t
  } = e;
  return t(dT, {
    "": function() {
      return !1;
    },
    boolean: function(n) {
      return n;
    },
    number: function(n) {
      return !!n;
    },
    null: function(n) {
      return !1;
    },
    BigNumber: function(n) {
      return !n.isZero();
    },
    string: function(n) {
      var a = n.toLowerCase();
      if (a === "true")
        return !0;
      if (a === "false")
        return !1;
      var i = Number(n);
      if (n !== "" && !isNaN(i))
        return !!i;
      throw new Error('Cannot convert "' + n + '" to a boolean');
    },
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), G0e = "bignumber", V0e = ["typed", "BigNumber"], ZG = /* @__PURE__ */ me(G0e, V0e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t("bignumber", {
    "": function() {
      return new r(0);
    },
    number: function(a) {
      return new r(a + "");
    },
    string: function(a) {
      var i = a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      if (i) {
        var o = i[2], s = r(i[1]), u = new r(2).pow(Number(o));
        if (s.gt(u.sub(1)))
          throw new SyntaxError('String "'.concat(a, '" is out of range'));
        var c = new r(2).pow(Number(o) - 1);
        return s.gte(c) ? s.sub(u) : s;
      }
      return new r(a);
    },
    BigNumber: function(a) {
      return a;
    },
    bigint: function(a) {
      return new r(a.toString());
    },
    Unit: t.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    Fraction: function(a) {
      return new r(a.n).div(a.d).times(a.s);
    },
    null: function(a) {
      return new r(0);
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), q0e = "complex", H0e = ["typed", "Complex"], QG = /* @__PURE__ */ me(q0e, H0e, (e) => {
  var {
    typed: t,
    Complex: r
  } = e;
  return t("complex", {
    "": function() {
      return r.ZERO;
    },
    number: function(a) {
      return new r(a, 0);
    },
    "number, number": function(a, i) {
      return new r(a, i);
    },
    // TODO: this signature should be redundant
    "BigNumber, BigNumber": function(a, i) {
      return new r(a.toNumber(), i.toNumber());
    },
    Fraction: function(a) {
      return new r(a.valueOf(), 0);
    },
    Complex: function(a) {
      return a.clone();
    },
    string: function(a) {
      return r(a);
    },
    null: function(a) {
      return r(0);
    },
    Object: function(a) {
      if ("re" in a && "im" in a)
        return new r(a.re, a.im);
      if ("r" in a && "phi" in a || "abs" in a && "arg" in a)
        return new r(a);
      throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), K0e = "fraction", X0e = ["typed", "Fraction"], $G = /* @__PURE__ */ me(K0e, X0e, (e) => {
  var {
    typed: t,
    Fraction: r
  } = e;
  return t("fraction", {
    number: function(a) {
      if (!isFinite(a) || isNaN(a))
        throw new Error(a + " cannot be represented as a fraction");
      return new r(a);
    },
    string: function(a) {
      return new r(a);
    },
    "number, number": function(a, i) {
      return new r(a, i);
    },
    null: function(a) {
      return new r(0);
    },
    BigNumber: function(a) {
      return new r(a.toString());
    },
    bigint: function(a) {
      return new r(a.toString());
    },
    Fraction: function(a) {
      return a;
    },
    Unit: t.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    Object: function(a) {
      return new r(a);
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), fT = "matrix", j0e = ["typed", "Matrix", "DenseMatrix", "SparseMatrix"], JG = /* @__PURE__ */ me(fT, j0e, (e) => {
  var {
    typed: t,
    Matrix: r,
    DenseMatrix: n,
    SparseMatrix: a
  } = e;
  return t(fT, {
    "": function() {
      return i([]);
    },
    string: function(s) {
      return i([], s);
    },
    "string, string": function(s, u) {
      return i([], s, u);
    },
    Array: function(s) {
      return i(s);
    },
    Matrix: function(s) {
      return i(s, s.storage());
    },
    "Array | Matrix, string": i,
    "Array | Matrix, string, string": i
  });
  function i(o, s, u) {
    if (s === "dense" || s === "default" || s === void 0)
      return new n(o, u);
    if (s === "sparse")
      return new a(o, u);
    throw new TypeError("Unknown matrix type " + JSON.stringify(s) + ".");
  }
}), mT = "matrixFromFunction", Y0e = ["typed", "matrix", "isZero"], W0e = /* @__PURE__ */ me(mT, Y0e, (e) => {
  var {
    typed: t,
    matrix: r,
    isZero: n
  } = e;
  return t(mT, {
    "Array | Matrix, function, string, string": function(o, s, u, c) {
      return a(o, s, u, c);
    },
    "Array | Matrix, function, string": function(o, s, u) {
      return a(o, s, u);
    },
    "Matrix, function": function(o, s) {
      return a(o, s, "dense");
    },
    "Array, function": function(o, s) {
      return a(o, s, "dense").toArray();
    },
    "Array | Matrix, string, function": function(o, s, u) {
      return a(o, u, s);
    },
    "Array | Matrix, string, string, function": function(o, s, u, c) {
      return a(o, c, s, u);
    }
  });
  function a(i, o, s, u) {
    var c;
    return u !== void 0 ? c = r(s, u) : c = r(s), c.resize(i), c.forEach(function(l, d) {
      var f = o(d);
      n(f) || c.set(d, f);
    }), c;
  }
}), pT = "matrixFromRows", Z0e = ["typed", "matrix", "flatten", "size"], Q0e = /* @__PURE__ */ me(pT, Z0e, (e) => {
  var {
    typed: t,
    matrix: r,
    flatten: n,
    size: a
  } = e;
  return t(pT, {
    "...Array": function(u) {
      return i(u);
    },
    "...Matrix": function(u) {
      return r(i(u.map((c) => c.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function i(s) {
    if (s.length === 0) throw new TypeError("At least one row is needed to construct a matrix.");
    var u = o(s[0]), c = [];
    for (var l of s) {
      var d = o(l);
      if (d !== u)
        throw new TypeError("The vectors had different length: " + (u | 0) + " ≠ " + (d | 0));
      c.push(n(l));
    }
    return c;
  }
  function o(s) {
    var u = a(s);
    if (u.length === 1)
      return u[0];
    if (u.length === 2) {
      if (u[0] === 1)
        return u[1];
      if (u[1] === 1)
        return u[0];
      throw new TypeError("At least one of the arguments is not a vector.");
    } else
      throw new TypeError("Only one- or two-dimensional vectors are supported.");
  }
}), hT = "matrixFromColumns", $0e = ["typed", "matrix", "flatten", "size"], eV = /* @__PURE__ */ me(hT, $0e, (e) => {
  var {
    typed: t,
    matrix: r,
    flatten: n,
    size: a
  } = e;
  return t(hT, {
    "...Array": function(u) {
      return i(u);
    },
    "...Matrix": function(u) {
      return r(i(u.map((c) => c.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function i(s) {
    if (s.length === 0) throw new TypeError("At least one column is needed to construct a matrix.");
    for (var u = o(s[0]), c = [], l = 0; l < u; l++)
      c[l] = [];
    for (var d of s) {
      var f = o(d);
      if (f !== u)
        throw new TypeError("The vectors had different length: " + (u | 0) + " ≠ " + (f | 0));
      for (var m = n(d), h = 0; h < u; h++)
        c[h].push(m[h]);
    }
    return c;
  }
  function o(s) {
    var u = a(s);
    if (u.length === 1)
      return u[0];
    if (u.length === 2) {
      if (u[0] === 1)
        return u[1];
      if (u[1] === 1)
        return u[0];
      throw new TypeError("At least one of the arguments is not a vector.");
    } else
      throw new TypeError("Only one- or two-dimensional vectors are supported.");
  }
}), vT = "splitUnit", J0e = ["typed"], ehe = /* @__PURE__ */ me(vT, J0e, (e) => {
  var {
    typed: t
  } = e;
  return t(vT, {
    "Unit, Array": function(n, a) {
      return n.splitUnit(a);
    }
  });
}), gT = "unaryMinus", the = ["typed"], tV = /* @__PURE__ */ me(gT, the, (e) => {
  var {
    typed: t
  } = e;
  return t(gT, {
    number: aG,
    "Complex | BigNumber | Fraction": (r) => r.neg(),
    bigint: (r) => -r,
    Unit: t.referToSelf((r) => (n) => {
      var a = n.clone();
      return a.value = t.find(r, a.valueType())(n.value), a;
    }),
    // deep map collection, skip zeros since unaryMinus(0) = 0
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
    // TODO: add support for string
  });
}), yT = "unaryPlus", rhe = ["typed", "config", "numeric"], nhe = /* @__PURE__ */ me(yT, rhe, (e) => {
  var {
    typed: t,
    config: r,
    numeric: n
  } = e;
  return t(yT, {
    number: iG,
    Complex: function(i) {
      return i;
    },
    BigNumber: function(i) {
      return i;
    },
    bigint: function(i) {
      return i;
    },
    Fraction: function(i) {
      return i;
    },
    Unit: function(i) {
      return i.clone();
    },
    // deep map collection, skip zeros since unaryPlus(0) = 0
    "Array | Matrix": t.referToSelf((a) => (i) => Tr(i, a)),
    boolean: function(i) {
      return n(i ? 1 : 0, r.number);
    },
    string: function(i) {
      return n(i, $d(i, r));
    }
  });
}), bT = "abs", ahe = ["typed"], rV = /* @__PURE__ */ me(bT, ahe, (e) => {
  var {
    typed: t
  } = e;
  return t(bT, {
    number: eG,
    "Complex | BigNumber | Fraction | Unit": (r) => r.abs(),
    bigint: (r) => r < 0n ? -r : r,
    // deep map collection, skip zeros since abs(0) = 0
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), xT = "apply", ihe = ["typed", "isInteger"], NS = /* @__PURE__ */ me(xT, ihe, (e) => {
  var {
    typed: t,
    isInteger: r
  } = e;
  return t(xT, {
    "Array | Matrix, number | BigNumber, function": function(a, i, o) {
      if (!r(i))
        throw new TypeError("Integer number expected for dimension");
      var s = Array.isArray(a) ? Sr(a) : a.size();
      if (i < 0 || i >= s.length)
        throw new ou(i, s.length);
      return Zt(a) ? a.create(Xy(a.valueOf(), i, o)) : Xy(a, i, o);
    }
  });
});
function Xy(e, t, r) {
  var n, a, i;
  if (t <= 0)
    if (Array.isArray(e[0])) {
      for (i = ohe(e), a = [], n = 0; n < i.length; n++)
        a[n] = Xy(i[n], t - 1, r);
      return a;
    } else
      return r(e);
  else {
    for (a = [], n = 0; n < e.length; n++)
      a[n] = Xy(e[n], t - 1, r);
    return a;
  }
}
function ohe(e) {
  var t = e.length, r = e[0].length, n, a, i = [];
  for (a = 0; a < r; a++) {
    var o = [];
    for (n = 0; n < t; n++)
      o.push(e[n][a]);
    i.push(o);
  }
  return i;
}
var _T = "addScalar", she = ["typed"], nV = /* @__PURE__ */ me(_T, she, (e) => {
  var {
    typed: t
  } = e;
  return t(_T, {
    "number, number": tG,
    "Complex, Complex": function(n, a) {
      return n.add(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.plus(a);
    },
    "bigint, bigint": function(n, a) {
      return n + a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.add(a);
    },
    "Unit, Unit": t.referToSelf((r) => (n, a) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (a.value === null || a.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(a)) throw new Error("Units do not match");
      var i = n.clone();
      return i.value = t.find(r, [i.valueType(), a.valueType()])(i.value, a.value), i.fixPrefix = !1, i;
    })
  });
}), ST = "subtractScalar", uhe = ["typed"], aV = /* @__PURE__ */ me(ST, uhe, (e) => {
  var {
    typed: t
  } = e;
  return t(ST, {
    "number, number": rG,
    "Complex, Complex": function(n, a) {
      return n.sub(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.minus(a);
    },
    "bigint, bigint": function(n, a) {
      return n - a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.sub(a);
    },
    "Unit, Unit": t.referToSelf((r) => (n, a) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (a.value === null || a.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(a)) throw new Error("Units do not match");
      var i = n.clone();
      return i.value = t.find(r, [i.valueType(), a.valueType()])(i.value, a.value), i.fixPrefix = !1, i;
    })
  });
}), AT = "cbrt", che = ["config", "typed", "isNegative", "unaryMinus", "matrix", "Complex", "BigNumber", "Fraction"], lhe = /* @__PURE__ */ me(AT, che, (e) => {
  var {
    config: t,
    typed: r,
    isNegative: n,
    unaryMinus: a,
    matrix: i,
    Complex: o,
    BigNumber: s,
    Fraction: u
  } = e;
  return r(AT, {
    number: U0,
    // note: signature 'number, boolean' is also supported,
    //       created by typed as it knows how to convert number to Complex
    Complex: c,
    "Complex, boolean": c,
    BigNumber: function(f) {
      return f.cbrt();
    },
    Unit: l
  });
  function c(d, f) {
    var m = d.arg() / 3, h = d.abs(), p = new o(U0(h), 0).mul(new o(0, m).exp());
    if (f) {
      var g = [p, new o(U0(h), 0).mul(new o(0, m + Math.PI * 2 / 3).exp()), new o(U0(h), 0).mul(new o(0, m - Math.PI * 2 / 3).exp())];
      return t.matrix === "Array" ? g : i(g);
    } else
      return p;
  }
  function l(d) {
    if (d.value && Mu(d.value)) {
      var f = d.clone();
      return f.value = 1, f = f.pow(1 / 3), f.value = c(d.value), f;
    } else {
      var m = n(d.value);
      m && (d.value = a(d.value));
      var h;
      hr(d.value) ? h = new s(1).div(3) : vm(d.value) ? h = new u(1, 3) : h = 1 / 3;
      var p = d.pow(h);
      return m && (p.value = a(p.value)), p;
    }
  }
}), dhe = "matAlgo11xS0s", fhe = ["typed", "equalScalar"], Ri = /* @__PURE__ */ me(dhe, fhe, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o, s) {
    var u = a._values, c = a._index, l = a._ptr, d = a._size, f = a._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], h = d[1], p, g = r, v = 0, y = o;
    typeof f == "string" && (p = f, g = t.find(r, [p, p]), v = t.convert(0, p), i = t.convert(i, p), y = t.find(o, [p, p]));
    for (var _ = [], S = [], b = [], x = 0; x < h; x++) {
      b[x] = S.length;
      for (var A = l[x], w = l[x + 1], C = A; C < w; C++) {
        var M = c[C], T = s ? y(i, u[C]) : y(u[C], i);
        g(T, v) || (S.push(M), _.push(T));
      }
    }
    return b[h] = S.length, a.createSparseMatrix({
      values: _,
      index: S,
      ptr: b,
      size: [m, h],
      datatype: p
    });
  };
}), mhe = "matAlgo12xSfs", phe = ["typed", "DenseMatrix"], ti = /* @__PURE__ */ me(mhe, phe, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(a, i, o, s) {
    var u = a._values, c = a._index, l = a._ptr, d = a._size, f = a._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], h = d[1], p, g = o;
    typeof f == "string" && (p = f, i = t.convert(i, p), g = t.find(o, [p, p]));
    for (var v = [], y = [], _ = [], S = 0; S < h; S++) {
      for (var b = S + 1, x = l[S], A = l[S + 1], w = x; w < A; w++) {
        var C = c[w];
        y[C] = u[w], _[C] = b;
      }
      for (var M = 0; M < m; M++)
        S === 0 && (v[M] = []), _[M] === b ? v[M][S] = s ? g(i, y[M]) : g(y[M], i) : v[M][S] = s ? g(i, 0) : g(0, i);
    }
    return new r({
      data: v,
      size: [m, h],
      datatype: p
    });
  };
}), hhe = "matAlgo14xDs", vhe = ["typed"], Fu = /* @__PURE__ */ me(hhe, vhe, (e) => {
  var {
    typed: t
  } = e;
  return function(a, i, o, s) {
    var u = a._data, c = a._size, l = a._datatype, d, f = o;
    typeof l == "string" && (d = l, i = t.convert(i, d), f = t.find(o, [d, d]));
    var m = c.length > 0 ? r(f, 0, c, c[0], u, i, s) : [];
    return a.createDenseMatrix({
      data: m,
      size: Jt(c),
      datatype: d
    });
  };
  function r(n, a, i, o, s, u, c) {
    var l = [];
    if (a === i.length - 1)
      for (var d = 0; d < o; d++)
        l[d] = c ? n(u, s[d]) : n(s[d], u);
    else
      for (var f = 0; f < o; f++)
        l[f] = r(n, a + 1, i, i[a + 1], s[f], u, c);
    return l;
  }
}), J_ = "ceil", ghe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], yhe = /* @__PURE__ */ me(J_, ["typed", "config", "round"], (e) => {
  var {
    typed: t,
    config: r,
    round: n
  } = e;
  return t(J_, {
    number: function(i) {
      return Fi(i, n(i), r.relTol, r.absTol) ? n(i) : Math.ceil(i);
    },
    "number, number": function(i, o) {
      if (Fi(i, n(i, o), r.relTol, r.absTol))
        return n(i, o);
      var [s, u] = "".concat(i, "e").split("e"), c = Math.ceil(Number("".concat(s, "e").concat(Number(u) + o)));
      return [s, u] = "".concat(c, "e").split("e"), Number("".concat(s, "e").concat(Number(u) - o));
    }
  });
}), bhe = /* @__PURE__ */ me(J_, ghe, (e) => {
  var {
    typed: t,
    config: r,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: s
  } = e, u = Ri({
    typed: t,
    equalScalar: i
  }), c = ti({
    typed: t,
    DenseMatrix: s
  }), l = Fu({
    typed: t
  }), d = yhe({
    typed: t,
    config: r,
    round: n
  });
  return t("ceil", {
    number: d.signatures.number,
    "number,number": d.signatures["number,number"],
    Complex: function(m) {
      return m.ceil();
    },
    "Complex, number": function(m, h) {
      return m.ceil(h);
    },
    "Complex, BigNumber": function(m, h) {
      return m.ceil(h.toNumber());
    },
    BigNumber: function(m) {
      return Xo(m, n(m), r.relTol, r.absTol) ? n(m) : m.ceil();
    },
    "BigNumber, BigNumber": function(m, h) {
      return Xo(m, n(m, h), r.relTol, r.absTol) ? n(m, h) : m.toDecimalPlaces(h.toNumber(), Yd.ROUND_CEIL);
    },
    Fraction: function(m) {
      return m.ceil();
    },
    "Fraction, number": function(m, h) {
      return m.ceil(h);
    },
    "Fraction, BigNumber": function(m, h) {
      return m.ceil(h.toNumber());
    },
    "Array | Matrix": t.referToSelf((f) => (m) => Tr(m, f)),
    "Array, number | BigNumber": t.referToSelf((f) => (m, h) => Tr(m, (p) => f(p, h))),
    "SparseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => u(m, h, f, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => l(m, h, f, !1)),
    "number | Complex | Fraction | BigNumber, Array": t.referToSelf((f) => (m, h) => l(a(h), m, f, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": t.referToSelf((f) => (m, h) => i(m, 0) ? o(h.size(), h.storage()) : h.storage() === "dense" ? l(h, m, f, !0) : c(h, m, f, !0))
  });
}), wT = "cube", xhe = ["typed"], _he = /* @__PURE__ */ me(wT, xhe, (e) => {
  var {
    typed: t
  } = e;
  return t(wT, {
    number: oG,
    Complex: function(n) {
      return n.mul(n).mul(n);
    },
    BigNumber: function(n) {
      return n.times(n).times(n);
    },
    bigint: function(n) {
      return n * n * n;
    },
    Fraction: function(n) {
      return n.pow(3);
    },
    Unit: function(n) {
      return n.pow(3);
    }
  });
}), CT = "exp", She = ["typed"], Ahe = /* @__PURE__ */ me(CT, She, (e) => {
  var {
    typed: t
  } = e;
  return t(CT, {
    number: sG,
    Complex: function(n) {
      return n.exp();
    },
    BigNumber: function(n) {
      return n.exp();
    }
  });
}), ET = "expm1", whe = ["typed", "Complex"], Che = /* @__PURE__ */ me(ET, whe, (e) => {
  var {
    typed: t,
    Complex: r
  } = e;
  return t(ET, {
    number: uG,
    Complex: function(a) {
      var i = Math.exp(a.re);
      return new r(i * Math.cos(a.im) - 1, i * Math.sin(a.im));
    },
    BigNumber: function(a) {
      return a.exp().minus(1);
    }
  });
}), e8 = "fix", Ehe = ["typed", "Complex", "matrix", "ceil", "floor", "equalScalar", "zeros", "DenseMatrix"], Dhe = /* @__PURE__ */ me(e8, ["typed", "ceil", "floor"], (e) => {
  var {
    typed: t,
    ceil: r,
    floor: n
  } = e;
  return t(e8, {
    number: function(i) {
      return i > 0 ? n(i) : r(i);
    },
    "number, number": function(i, o) {
      return i > 0 ? n(i, o) : r(i, o);
    }
  });
}), Mhe = /* @__PURE__ */ me(e8, Ehe, (e) => {
  var {
    typed: t,
    Complex: r,
    matrix: n,
    ceil: a,
    floor: i,
    equalScalar: o,
    zeros: s,
    DenseMatrix: u
  } = e, c = ti({
    typed: t,
    DenseMatrix: u
  }), l = Fu({
    typed: t
  }), d = Dhe({
    typed: t,
    ceil: a,
    floor: i
  });
  return t("fix", {
    number: d.signatures.number,
    "number, number | BigNumber": d.signatures["number,number"],
    Complex: function(m) {
      return new r(m.re > 0 ? Math.floor(m.re) : Math.ceil(m.re), m.im > 0 ? Math.floor(m.im) : Math.ceil(m.im));
    },
    "Complex, number": function(m, h) {
      return new r(m.re > 0 ? i(m.re, h) : a(m.re, h), m.im > 0 ? i(m.im, h) : a(m.im, h));
    },
    "Complex, BigNumber": function(m, h) {
      var p = h.toNumber();
      return new r(m.re > 0 ? i(m.re, p) : a(m.re, p), m.im > 0 ? i(m.im, p) : a(m.im, p));
    },
    BigNumber: function(m) {
      return m.isNegative() ? a(m) : i(m);
    },
    "BigNumber, number | BigNumber": function(m, h) {
      return m.isNegative() ? a(m, h) : i(m, h);
    },
    Fraction: function(m) {
      return m.s < 0 ? m.ceil() : m.floor();
    },
    "Fraction, number | BigNumber": function(m, h) {
      return m.s < 0 ? a(m, h) : i(m, h);
    },
    "Array | Matrix": t.referToSelf((f) => (m) => Tr(m, f)),
    "Array | Matrix, number | BigNumber": t.referToSelf((f) => (m, h) => Tr(m, (p) => f(p, h))),
    "number | Complex | Fraction | BigNumber, Array": t.referToSelf((f) => (m, h) => l(n(h), m, f, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": t.referToSelf((f) => (m, h) => o(m, 0) ? s(h.size(), h.storage()) : h.storage() === "dense" ? l(h, m, f, !0) : c(h, m, f, !0))
  });
}), t8 = "floor", Ihe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], The = /* @__PURE__ */ me(t8, ["typed", "config", "round"], (e) => {
  var {
    typed: t,
    config: r,
    round: n
  } = e;
  return t(t8, {
    number: function(i) {
      return Fi(i, n(i), r.relTol, r.absTol) ? n(i) : Math.floor(i);
    },
    "number, number": function(i, o) {
      if (Fi(i, n(i, o), r.relTol, r.absTol))
        return n(i, o);
      var [s, u] = "".concat(i, "e").split("e"), c = Math.floor(Number("".concat(s, "e").concat(Number(u) + o)));
      return [s, u] = "".concat(c, "e").split("e"), Number("".concat(s, "e").concat(Number(u) - o));
    }
  });
}), iV = /* @__PURE__ */ me(t8, Ihe, (e) => {
  var {
    typed: t,
    config: r,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: s
  } = e, u = Ri({
    typed: t,
    equalScalar: i
  }), c = ti({
    typed: t,
    DenseMatrix: s
  }), l = Fu({
    typed: t
  }), d = The({
    typed: t,
    config: r,
    round: n
  });
  return t("floor", {
    number: d.signatures.number,
    "number,number": d.signatures["number,number"],
    Complex: function(m) {
      return m.floor();
    },
    "Complex, number": function(m, h) {
      return m.floor(h);
    },
    "Complex, BigNumber": function(m, h) {
      return m.floor(h.toNumber());
    },
    BigNumber: function(m) {
      return Xo(m, n(m), r.relTol, r.absTol) ? n(m) : m.floor();
    },
    "BigNumber, BigNumber": function(m, h) {
      return Xo(m, n(m, h), r.relTol, r.absTol) ? n(m, h) : m.toDecimalPlaces(h.toNumber(), Yd.ROUND_FLOOR);
    },
    Fraction: function(m) {
      return m.floor();
    },
    "Fraction, number": function(m, h) {
      return m.floor(h);
    },
    "Fraction, BigNumber": function(m, h) {
      return m.floor(h.toNumber());
    },
    "Array | Matrix": t.referToSelf((f) => (m) => Tr(m, f)),
    "Array, number | BigNumber": t.referToSelf((f) => (m, h) => Tr(m, (p) => f(p, h))),
    "SparseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => u(m, h, f, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => l(m, h, f, !1)),
    "number | Complex | Fraction | BigNumber, Array": t.referToSelf((f) => (m, h) => l(a(h), m, f, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": t.referToSelf((f) => (m, h) => i(m, 0) ? o(h.size(), h.storage()) : h.storage() === "dense" ? l(h, m, f, !0) : c(h, m, f, !0))
  });
}), Nhe = "matAlgo02xDS0", Phe = ["typed", "equalScalar"], Ru = /* @__PURE__ */ me(Nhe, Phe, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o, s) {
    var u = a._data, c = a._size, l = a._datatype || a.getDataType(), d = i._values, f = i._index, m = i._ptr, h = i._size, p = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (c.length !== h.length)
      throw new Ir(c.length, h.length);
    if (c[0] !== h[0] || c[1] !== h[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + c + ") must match Matrix B (" + h + ")");
    if (!d)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var g = c[0], v = c[1], y, _ = r, S = 0, b = o;
    typeof l == "string" && l === p && l !== "mixed" && (y = l, _ = t.find(r, [y, y]), S = t.convert(0, y), b = t.find(o, [y, y]));
    for (var x = [], A = [], w = [], C = 0; C < v; C++) {
      w[C] = A.length;
      for (var M = m[C], T = m[C + 1], N = M; N < T; N++) {
        var I = f[N], P = s ? b(d[N], u[I][C]) : b(u[I][C], d[N]);
        _(P, S) || (A.push(I), x.push(P));
      }
    }
    return w[v] = A.length, i.createSparseMatrix({
      values: x,
      index: A,
      ptr: w,
      size: [g, v],
      datatype: l === a._datatype && p === i._datatype ? y : void 0
    });
  };
}), Bhe = "matAlgo03xDSf", Ohe = ["typed"], Ao = /* @__PURE__ */ me(Bhe, Ohe, (e) => {
  var {
    typed: t
  } = e;
  return function(n, a, i, o) {
    var s = n._data, u = n._size, c = n._datatype || n.getDataType(), l = a._values, d = a._index, f = a._ptr, m = a._size, h = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (u.length !== m.length)
      throw new Ir(u.length, m.length);
    if (u[0] !== m[0] || u[1] !== m[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + m + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = u[0], g = u[1], v, y = 0, _ = i;
    typeof c == "string" && c === h && c !== "mixed" && (v = c, y = t.convert(0, v), _ = t.find(i, [v, v]));
    for (var S = [], b = 0; b < p; b++)
      S[b] = [];
    for (var x = [], A = [], w = 0; w < g; w++) {
      for (var C = w + 1, M = f[w], T = f[w + 1], N = M; N < T; N++) {
        var I = d[N];
        x[I] = o ? _(l[N], s[I][w]) : _(s[I][w], l[N]), A[I] = C;
      }
      for (var P = 0; P < p; P++)
        A[P] === C ? S[P][w] = x[P] : S[P][w] = o ? _(y, s[P][w]) : _(s[P][w], y);
    }
    return n.createDenseMatrix({
      data: S,
      size: [p, g],
      datatype: c === n._datatype && h === a._datatype ? v : void 0
    });
  };
}), Fhe = "matAlgo05xSfSf", Rhe = ["typed", "equalScalar"], K3 = /* @__PURE__ */ me(Fhe, Rhe, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o) {
    var s = a._values, u = a._index, c = a._ptr, l = a._size, d = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), f = i._values, m = i._index, h = i._ptr, p = i._size, g = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== p.length)
      throw new Ir(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var v = l[0], y = l[1], _, S = r, b = 0, x = o;
    typeof d == "string" && d === g && d !== "mixed" && (_ = d, S = t.find(r, [_, _]), b = t.convert(0, _), x = t.find(o, [_, _]));
    var A = s && f ? [] : void 0, w = [], C = [], M = A ? [] : void 0, T = A ? [] : void 0, N = [], I = [], P, O, F, R;
    for (O = 0; O < y; O++) {
      C[O] = w.length;
      var G = O + 1;
      for (F = c[O], R = c[O + 1]; F < R; F++)
        P = u[F], w.push(P), N[P] = G, M && (M[P] = s[F]);
      for (F = h[O], R = h[O + 1]; F < R; F++)
        P = m[F], N[P] !== G && w.push(P), I[P] = G, T && (T[P] = f[F]);
      if (A)
        for (F = C[O]; F < w.length; ) {
          P = w[F];
          var L = N[P], q = I[P];
          if (L === G || q === G) {
            var K = L === G ? M[P] : b, X = q === G ? T[P] : b, H = x(K, X);
            S(H, b) ? w.splice(F, 1) : (A.push(H), F++);
          }
        }
    }
    return C[y] = w.length, a.createSparseMatrix({
      values: A,
      index: w,
      ptr: C,
      size: [v, y],
      datatype: d === a._datatype && g === i._datatype ? _ : void 0
    });
  };
}), Lhe = "matAlgo13xDD", khe = ["typed"], zhe = /* @__PURE__ */ me(Lhe, khe, (e) => {
  var {
    typed: t
  } = e;
  return function(a, i, o) {
    var s = a._data, u = a._size, c = a._datatype, l = i._data, d = i._size, f = i._datatype, m = [];
    if (u.length !== d.length)
      throw new Ir(u.length, d.length);
    for (var h = 0; h < u.length; h++) {
      if (u[h] !== d[h])
        throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + d + ")");
      m[h] = u[h];
    }
    var p, g = o;
    typeof c == "string" && c === f && (p = c, g = t.find(o, [p, p]));
    var v = m.length > 0 ? r(g, 0, m, m[0], s, l) : [];
    return a.createDenseMatrix({
      data: v,
      size: m,
      datatype: p
    });
  };
  function r(n, a, i, o, s, u) {
    var c = [];
    if (a === i.length - 1)
      for (var l = 0; l < o; l++)
        c[l] = n(s[l], u[l]);
    else
      for (var d = 0; d < o; d++)
        c[d] = r(n, a + 1, i, i[a + 1], s[d], u[d]);
    return c;
  }
});
function si(e, t) {
  if (gl(e.size(), t.size()))
    return [e, t];
  var r = YU(e.size(), t.size());
  return [e, t].map((n) => Uhe(n, r));
}
function Uhe(e, t) {
  return gl(e.size(), t) ? e : e.create(Y_(e.valueOf(), t), e.datatype());
}
var Ghe = "matrixAlgorithmSuite", Vhe = ["typed", "matrix"], Ln = /* @__PURE__ */ me(Ghe, Vhe, (e) => {
  var {
    typed: t,
    matrix: r
  } = e, n = zhe({
    typed: t
  }), a = Fu({
    typed: t
  });
  return function(o) {
    var s = o.elop, u = o.SD || o.DS, c;
    s ? (c = {
      "DenseMatrix, DenseMatrix": (m, h) => n(...si(m, h), s),
      "Array, Array": (m, h) => n(...si(r(m), r(h)), s).valueOf(),
      "Array, DenseMatrix": (m, h) => n(...si(r(m), h), s),
      "DenseMatrix, Array": (m, h) => n(...si(m, r(h)), s)
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = (m, h) => o.SS(...si(m, h), s, !1)), o.DS && (c["DenseMatrix, SparseMatrix"] = (m, h) => o.DS(...si(m, h), s, !1), c["Array, SparseMatrix"] = (m, h) => o.DS(...si(r(m), h), s, !1)), u && (c["SparseMatrix, DenseMatrix"] = (m, h) => u(...si(h, m), s, !0), c["SparseMatrix, Array"] = (m, h) => u(...si(r(h), m), s, !0))) : (c = {
      "DenseMatrix, DenseMatrix": t.referToSelf((m) => (h, p) => n(...si(h, p), m)),
      "Array, Array": t.referToSelf((m) => (h, p) => n(...si(r(h), r(p)), m).valueOf()),
      "Array, DenseMatrix": t.referToSelf((m) => (h, p) => n(...si(r(h), p), m)),
      "DenseMatrix, Array": t.referToSelf((m) => (h, p) => n(...si(h, r(p)), m))
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = t.referToSelf((m) => (h, p) => o.SS(...si(h, p), m, !1))), o.DS && (c["DenseMatrix, SparseMatrix"] = t.referToSelf((m) => (h, p) => o.DS(...si(h, p), m, !1)), c["Array, SparseMatrix"] = t.referToSelf((m) => (h, p) => o.DS(...si(r(h), p), m, !1))), u && (c["SparseMatrix, DenseMatrix"] = t.referToSelf((m) => (h, p) => u(...si(p, h), m, !0)), c["SparseMatrix, Array"] = t.referToSelf((m) => (h, p) => u(...si(r(p), h), m, !0))));
    var l = o.scalar || "any", d = o.Ds || o.Ss;
    d && (s ? (c["DenseMatrix," + l] = (m, h) => a(m, h, s, !1), c[l + ", DenseMatrix"] = (m, h) => a(h, m, s, !0), c["Array," + l] = (m, h) => a(r(m), h, s, !1).valueOf(), c[l + ", Array"] = (m, h) => a(r(h), m, s, !0).valueOf()) : (c["DenseMatrix," + l] = t.referToSelf((m) => (h, p) => a(h, p, m, !1)), c[l + ", DenseMatrix"] = t.referToSelf((m) => (h, p) => a(p, h, m, !0)), c["Array," + l] = t.referToSelf((m) => (h, p) => a(r(h), p, m, !1).valueOf()), c[l + ", Array"] = t.referToSelf((m) => (h, p) => a(r(p), h, m, !0).valueOf())));
    var f = o.sS !== void 0 ? o.sS : o.Ss;
    return s ? (o.Ss && (c["SparseMatrix," + l] = (m, h) => o.Ss(m, h, s, !1)), f && (c[l + ", SparseMatrix"] = (m, h) => f(h, m, s, !0))) : (o.Ss && (c["SparseMatrix," + l] = t.referToSelf((m) => (h, p) => o.Ss(h, p, m, !1))), f && (c[l + ", SparseMatrix"] = t.referToSelf((m) => (h, p) => f(p, h, m, !0)))), s && s.signatures && uU(c, s.signatures), c;
  };
}), DT = "mod", qhe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], PS = /* @__PURE__ */ me(DT, qhe, (e) => {
  var {
    typed: t,
    config: r,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: s,
    concat: u
  } = e, c = iV({
    typed: t,
    config: r,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: s
  }), l = Ru({
    typed: t,
    equalScalar: i
  }), d = Ao({
    typed: t
  }), f = K3({
    typed: t,
    equalScalar: i
  }), m = Ri({
    typed: t,
    equalScalar: i
  }), h = ti({
    typed: t,
    DenseMatrix: s
  }), p = Ln({
    typed: t,
    matrix: a,
    concat: u
  });
  return t(DT, {
    "number, number": g,
    "BigNumber, BigNumber": function(y, _) {
      return _.isZero() ? y : y.sub(_.mul(c(y.div(_))));
    },
    "bigint, bigint": function(y, _) {
      if (_ === 0n)
        return y;
      if (y < 0) {
        var S = y % _;
        return S === 0n ? S : S + _;
      }
      return y % _;
    },
    "Fraction, Fraction": function(y, _) {
      return _.equals(0) ? y : y.sub(_.mul(c(y.div(_))));
    }
  }, p({
    SS: f,
    DS: d,
    SD: l,
    Ss: m,
    sS: h
  }));
  function g(v, y) {
    return y === 0 ? v : v - y * c(v / y);
  }
}), Hhe = "matAlgo01xDSid", Khe = ["typed"], ef = /* @__PURE__ */ me(Hhe, Khe, (e) => {
  var {
    typed: t
  } = e;
  return function(n, a, i, o) {
    var s = n._data, u = n._size, c = n._datatype || n.getDataType(), l = a._values, d = a._index, f = a._ptr, m = a._size, h = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (u.length !== m.length)
      throw new Ir(u.length, m.length);
    if (u[0] !== m[0] || u[1] !== m[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + m + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = u[0], g = u[1], v = typeof c == "string" && c !== "mixed" && c === h ? c : void 0, y = v ? t.find(i, [v, v]) : i, _, S, b = [];
    for (_ = 0; _ < p; _++)
      b[_] = [];
    var x = [], A = [];
    for (S = 0; S < g; S++) {
      for (var w = S + 1, C = f[S], M = f[S + 1], T = C; T < M; T++)
        _ = d[T], x[_] = o ? y(l[T], s[_][S]) : y(s[_][S], l[T]), A[_] = w;
      for (_ = 0; _ < p; _++)
        A[_] === w ? b[_][S] = x[_] : b[_][S] = s[_][S];
    }
    return n.createDenseMatrix({
      data: b,
      size: [p, g],
      datatype: c === n._datatype && h === a._datatype ? v : void 0
    });
  };
}), Xhe = "matAlgo04xSidSid", jhe = ["typed", "equalScalar"], BS = /* @__PURE__ */ me(Xhe, jhe, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o) {
    var s = a._values, u = a._index, c = a._ptr, l = a._size, d = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), f = i._values, m = i._index, h = i._ptr, p = i._size, g = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== p.length)
      throw new Ir(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var v = l[0], y = l[1], _, S = r, b = 0, x = o;
    typeof d == "string" && d === g && d !== "mixed" && (_ = d, S = t.find(r, [_, _]), b = t.convert(0, _), x = t.find(o, [_, _]));
    var A = s && f ? [] : void 0, w = [], C = [], M = s && f ? [] : void 0, T = s && f ? [] : void 0, N = [], I = [], P, O, F, R, G;
    for (O = 0; O < y; O++) {
      C[O] = w.length;
      var L = O + 1;
      for (R = c[O], G = c[O + 1], F = R; F < G; F++)
        P = u[F], w.push(P), N[P] = L, M && (M[P] = s[F]);
      for (R = h[O], G = h[O + 1], F = R; F < G; F++)
        if (P = m[F], N[P] === L) {
          if (M) {
            var q = x(M[P], f[F]);
            S(q, b) ? N[P] = null : M[P] = q;
          }
        } else
          w.push(P), I[P] = L, T && (T[P] = f[F]);
      if (M && T)
        for (F = C[O]; F < w.length; )
          P = w[F], N[P] === L ? (A[F] = M[P], F++) : I[P] === L ? (A[F] = T[P], F++) : w.splice(F, 1);
    }
    return C[y] = w.length, a.createSparseMatrix({
      values: A,
      index: w,
      ptr: C,
      size: [v, y],
      datatype: d === a._datatype && g === i._datatype ? _ : void 0
    });
  };
}), Yhe = "matAlgo10xSids", Whe = ["typed", "DenseMatrix"], ym = /* @__PURE__ */ me(Yhe, Whe, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(a, i, o, s) {
    var u = a._values, c = a._index, l = a._ptr, d = a._size, f = a._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], h = d[1], p, g = o;
    typeof f == "string" && (p = f, i = t.convert(i, p), g = t.find(o, [p, p]));
    for (var v = [], y = [], _ = [], S = 0; S < h; S++) {
      for (var b = S + 1, x = l[S], A = l[S + 1], w = x; w < A; w++) {
        var C = c[w];
        y[C] = u[w], _[C] = b;
      }
      for (var M = 0; M < m; M++)
        S === 0 && (v[M] = []), _[M] === b ? v[M][S] = s ? g(i, y[M]) : g(y[M], i) : v[M][S] = i;
    }
    return new r({
      data: v,
      size: [m, h],
      datatype: p
    });
  };
});
function Cl(e, t, r, n) {
  if (!(this instanceof Cl))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.fn = e, this.count = t, this.min = r, this.max = n, this.message = "Wrong number of arguments in function " + e + " (" + t + " provided, " + r + (n != null ? "-" + n : "") + " expected)", this.stack = new Error().stack;
}
Cl.prototype = new Error();
Cl.prototype.constructor = Error;
Cl.prototype.name = "ArgumentsError";
Cl.prototype.isArgumentsError = !0;
var MT = "gcd", Zhe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix", "concat"], R5 = "number | BigNumber | Fraction | Matrix | Array", Qhe = "".concat(R5, ", ").concat(R5, ", ...").concat(R5);
function IT(e) {
  return !e.some((t) => Array.isArray(t));
}
var $he = /* @__PURE__ */ me(MT, Zhe, (e) => {
  var {
    typed: t,
    matrix: r,
    config: n,
    round: a,
    equalScalar: i,
    zeros: o,
    BigNumber: s,
    DenseMatrix: u,
    concat: c
  } = e, l = PS({
    typed: t,
    config: n,
    round: a,
    matrix: r,
    equalScalar: i,
    zeros: o,
    DenseMatrix: u,
    concat: c
  }), d = ef({
    typed: t
  }), f = BS({
    typed: t,
    equalScalar: i
  }), m = ym({
    typed: t,
    DenseMatrix: u
  }), h = Ln({
    typed: t,
    matrix: r,
    concat: c
  });
  return t(MT, {
    "number, number": p,
    "BigNumber, BigNumber": g,
    "Fraction, Fraction": (v, y) => v.gcd(y)
  }, h({
    SS: f,
    DS: d,
    Ss: m
  }), {
    [Qhe]: t.referToSelf((v) => (y, _, S) => {
      for (var b = v(y, _), x = 0; x < S.length; x++)
        b = v(b, S[x]);
      return b;
    }),
    Array: t.referToSelf((v) => (y) => {
      if (y.length === 1 && Array.isArray(y[0]) && IT(y[0]))
        return v(...y[0]);
      if (IT(y))
        return v(...y);
      throw new Cl("gcd() supports only 1d matrices!");
    }),
    Matrix: t.referToSelf((v) => (y) => v(y.toArray()))
  });
  function p(v, y) {
    if (!Ut(v) || !Ut(y))
      throw new Error("Parameters in function gcd must be integer numbers");
    for (var _; y !== 0; )
      _ = l(v, y), v = y, y = _;
    return v < 0 ? -v : v;
  }
  function g(v, y) {
    if (!v.isInt() || !y.isInt())
      throw new Error("Parameters in function gcd must be integer numbers");
    for (var _ = new s(0); !y.isZero(); ) {
      var S = l(v, y);
      v = y, y = S;
    }
    return v.lt(_) ? v.neg() : v;
  }
}), Jhe = "matAlgo06xS0S0", eve = ["typed", "equalScalar"], X3 = /* @__PURE__ */ me(Jhe, eve, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o) {
    var s = a._values, u = a._size, c = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), l = i._values, d = i._size, f = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (u.length !== d.length)
      throw new Ir(u.length, d.length);
    if (u[0] !== d[0] || u[1] !== d[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + d + ")");
    var m = u[0], h = u[1], p, g = r, v = 0, y = o;
    typeof c == "string" && c === f && c !== "mixed" && (p = c, g = t.find(r, [p, p]), v = t.convert(0, p), y = t.find(o, [p, p]));
    for (var _ = s && l ? [] : void 0, S = [], b = [], x = _ ? [] : void 0, A = [], w = [], C = 0; C < h; C++) {
      b[C] = S.length;
      var M = C + 1;
      if (JI(a, C, A, x, w, M, S, y), JI(i, C, A, x, w, M, S, y), x)
        for (var T = b[C]; T < S.length; ) {
          var N = S[T];
          if (w[N] === M) {
            var I = x[N];
            g(I, v) ? S.splice(T, 1) : (_.push(I), T++);
          } else
            S.splice(T, 1);
        }
      else
        for (var P = b[C]; P < S.length; ) {
          var O = S[P];
          w[O] !== M ? S.splice(P, 1) : P++;
        }
    }
    return b[h] = S.length, a.createSparseMatrix({
      values: _,
      index: S,
      ptr: b,
      size: [m, h],
      datatype: c === a._datatype && f === i._datatype ? p : void 0
    });
  };
}), TT = "lcm", tve = ["typed", "matrix", "equalScalar", "concat"], rve = /* @__PURE__ */ me(TT, tve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    concat: a
  } = e, i = Ru({
    typed: t,
    equalScalar: n
  }), o = X3({
    typed: t,
    equalScalar: n
  }), s = Ri({
    typed: t,
    equalScalar: n
  }), u = Ln({
    typed: t,
    matrix: r,
    concat: a
  }), c = "number | BigNumber | Fraction | Matrix | Array", l = {};
  return l["".concat(c, ", ").concat(c, ", ...").concat(c)] = t.referToSelf((f) => (m, h, p) => {
    for (var g = f(m, h), v = 0; v < p.length; v++)
      g = f(g, p[v]);
    return g;
  }), t(TT, {
    "number, number": cG,
    "BigNumber, BigNumber": d,
    "Fraction, Fraction": (f, m) => f.lcm(m)
  }, u({
    SS: o,
    DS: i,
    Ss: s
  }), l);
  function d(f, m) {
    if (!f.isInt() || !m.isInt())
      throw new Error("Parameters in function lcm must be integer numbers");
    if (f.isZero())
      return f;
    if (m.isZero())
      return m;
    for (var h = f.times(m); !m.isZero(); ) {
      var p = m;
      m = f.mod(p), f = p;
    }
    return h.div(f).abs();
  }
}), NT = "log10", nve = ["typed", "config", "Complex"], ave = /* @__PURE__ */ me(NT, nve, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(NT, {
    number: function(i) {
      return i >= 0 || r.predictable ? lG(i) : new n(i, 0).log().div(Math.LN10);
    },
    Complex: function(i) {
      return new n(i).log().div(Math.LN10);
    },
    BigNumber: function(i) {
      return !i.isNegative() || r.predictable ? i.log() : new n(i.toNumber(), 0).log().div(Math.LN10);
    },
    "Array | Matrix": t.referToSelf((a) => (i) => Tr(i, a))
  });
}), PT = "log2", ive = ["typed", "config", "Complex"], ove = /* @__PURE__ */ me(PT, ive, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(PT, {
    number: function(o) {
      return o >= 0 || r.predictable ? dG(o) : a(new n(o, 0));
    },
    Complex: a,
    BigNumber: function(o) {
      return !o.isNegative() || r.predictable ? o.log(2) : a(new n(o.toNumber(), 0));
    },
    "Array | Matrix": t.referToSelf((i) => (o) => Tr(o, i))
  });
  function a(i) {
    var o = Math.sqrt(i.re * i.re + i.im * i.im);
    return new n(Math.log2 ? Math.log2(o) : Math.log(o) / Math.LN2, Math.atan2(i.im, i.re) / Math.LN2);
  }
}), sve = "multiplyScalar", uve = ["typed"], oV = /* @__PURE__ */ me(sve, uve, (e) => {
  var {
    typed: t
  } = e;
  return t("multiplyScalar", {
    "number, number": nG,
    "Complex, Complex": function(n, a) {
      return n.mul(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.times(a);
    },
    "bigint, bigint": function(n, a) {
      return n * a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.mul(a);
    },
    "number | Fraction | BigNumber | Complex, Unit": (r, n) => n.multiply(r),
    "Unit, number | Fraction | BigNumber | Complex | Unit": (r, n) => r.multiply(n)
  });
}), BT = "multiply", cve = ["typed", "matrix", "addScalar", "multiplyScalar", "equalScalar", "dot"], sV = /* @__PURE__ */ me(BT, cve, (e) => {
  var {
    typed: t,
    matrix: r,
    addScalar: n,
    multiplyScalar: a,
    equalScalar: i,
    dot: o
  } = e, s = Ri({
    typed: t,
    equalScalar: i
  }), u = Fu({
    typed: t
  });
  function c(b, x) {
    switch (b.length) {
      case 1:
        switch (x.length) {
          case 1:
            if (b[0] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");
            break;
          case 2:
            if (b[0] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Vector length (" + b[0] + ") must match Matrix rows (" + x[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + x.length + " dimensions)");
        }
        break;
      case 2:
        switch (x.length) {
          case 1:
            if (b[1] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix columns (" + b[1] + ") must match Vector length (" + x[0] + ")");
            break;
          case 2:
            if (b[1] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix A columns (" + b[1] + ") must match Matrix B rows (" + x[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + x.length + " dimensions)");
        }
        break;
      default:
        throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has " + b.length + " dimensions)");
    }
  }
  function l(b, x, A) {
    if (A === 0)
      throw new Error("Cannot multiply two empty vectors");
    return o(b, x);
  }
  function d(b, x) {
    if (x.storage() !== "dense")
      throw new Error("Support for SparseMatrix not implemented");
    return f(b, x);
  }
  function f(b, x) {
    var A = b._data, w = b._size, C = b._datatype || b.getDataType(), M = x._data, T = x._size, N = x._datatype || x.getDataType(), I = w[0], P = T[1], O, F = n, R = a;
    C && N && C === N && typeof C == "string" && C !== "mixed" && (O = C, F = t.find(n, [O, O]), R = t.find(a, [O, O]));
    for (var G = [], L = 0; L < P; L++) {
      for (var q = R(A[0], M[0][L]), K = 1; K < I; K++)
        q = F(q, R(A[K], M[K][L]));
      G[L] = q;
    }
    return b.createDenseMatrix({
      data: G,
      size: [P],
      datatype: C === b._datatype && N === x._datatype ? O : void 0
    });
  }
  var m = t("_multiplyMatrixVector", {
    "DenseMatrix, any": p,
    "SparseMatrix, any": y
  }), h = t("_multiplyMatrixMatrix", {
    "DenseMatrix, DenseMatrix": g,
    "DenseMatrix, SparseMatrix": v,
    "SparseMatrix, DenseMatrix": _,
    "SparseMatrix, SparseMatrix": S
  });
  function p(b, x) {
    var A = b._data, w = b._size, C = b._datatype || b.getDataType(), M = x._data, T = x._datatype || x.getDataType(), N = w[0], I = w[1], P, O = n, F = a;
    C && T && C === T && typeof C == "string" && C !== "mixed" && (P = C, O = t.find(n, [P, P]), F = t.find(a, [P, P]));
    for (var R = [], G = 0; G < N; G++) {
      for (var L = A[G], q = F(L[0], M[0]), K = 1; K < I; K++)
        q = O(q, F(L[K], M[K]));
      R[G] = q;
    }
    return b.createDenseMatrix({
      data: R,
      size: [N],
      datatype: C === b._datatype && T === x._datatype ? P : void 0
    });
  }
  function g(b, x) {
    var A = b._data, w = b._size, C = b._datatype || b.getDataType(), M = x._data, T = x._size, N = x._datatype || x.getDataType(), I = w[0], P = w[1], O = T[1], F, R = n, G = a;
    C && N && C === N && typeof C == "string" && C !== "mixed" && C !== "mixed" && (F = C, R = t.find(n, [F, F]), G = t.find(a, [F, F]));
    for (var L = [], q = 0; q < I; q++) {
      var K = A[q];
      L[q] = [];
      for (var X = 0; X < O; X++) {
        for (var H = G(K[0], M[0][X]), W = 1; W < P; W++)
          H = R(H, G(K[W], M[W][X]));
        L[q][X] = H;
      }
    }
    return b.createDenseMatrix({
      data: L,
      size: [I, O],
      datatype: C === b._datatype && N === x._datatype ? F : void 0
    });
  }
  function v(b, x) {
    var A = b._data, w = b._size, C = b._datatype || b.getDataType(), M = x._values, T = x._index, N = x._ptr, I = x._size, P = x._datatype || x._data === void 0 ? x._datatype : x.getDataType();
    if (!M)
      throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");
    var O = w[0], F = I[1], R, G = n, L = a, q = i, K = 0;
    C && P && C === P && typeof C == "string" && C !== "mixed" && (R = C, G = t.find(n, [R, R]), L = t.find(a, [R, R]), q = t.find(i, [R, R]), K = t.convert(0, R));
    for (var X = [], H = [], W = [], ee = x.createSparseMatrix({
      values: X,
      index: H,
      ptr: W,
      size: [O, F],
      datatype: C === b._datatype && P === x._datatype ? R : void 0
    }), $ = 0; $ < F; $++) {
      W[$] = H.length;
      var te = N[$], re = N[$ + 1];
      if (re > te)
        for (var ie = 0, oe = 0; oe < O; oe++) {
          for (var se = oe + 1, he = void 0, ge = te; ge < re; ge++) {
            var De = T[ge];
            ie !== se ? (he = L(A[oe][De], M[ge]), ie = se) : he = G(he, L(A[oe][De], M[ge]));
          }
          ie === se && !q(he, K) && (H.push(oe), X.push(he));
        }
    }
    return W[F] = H.length, ee;
  }
  function y(b, x) {
    var A = b._values, w = b._index, C = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType();
    if (!A)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var T = x._data, N = x._datatype || x.getDataType(), I = b._size[0], P = x._size[0], O = [], F = [], R = [], G, L = n, q = a, K = i, X = 0;
    M && N && M === N && typeof M == "string" && M !== "mixed" && (G = M, L = t.find(n, [G, G]), q = t.find(a, [G, G]), K = t.find(i, [G, G]), X = t.convert(0, G));
    var H = [], W = [];
    R[0] = 0;
    for (var ee = 0; ee < P; ee++) {
      var $ = T[ee];
      if (!K($, X))
        for (var te = C[ee], re = C[ee + 1], ie = te; ie < re; ie++) {
          var oe = w[ie];
          W[oe] ? H[oe] = L(H[oe], q($, A[ie])) : (W[oe] = !0, F.push(oe), H[oe] = q($, A[ie]));
        }
    }
    for (var se = F.length, he = 0; he < se; he++) {
      var ge = F[he];
      O[he] = H[ge];
    }
    return R[1] = F.length, b.createSparseMatrix({
      values: O,
      index: F,
      ptr: R,
      size: [I, 1],
      datatype: M === b._datatype && N === x._datatype ? G : void 0
    });
  }
  function _(b, x) {
    var A = b._values, w = b._index, C = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType();
    if (!A)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var T = x._data, N = x._datatype || x.getDataType(), I = b._size[0], P = x._size[0], O = x._size[1], F, R = n, G = a, L = i, q = 0;
    M && N && M === N && typeof M == "string" && M !== "mixed" && (F = M, R = t.find(n, [F, F]), G = t.find(a, [F, F]), L = t.find(i, [F, F]), q = t.convert(0, F));
    for (var K = [], X = [], H = [], W = b.createSparseMatrix({
      values: K,
      index: X,
      ptr: H,
      size: [I, O],
      datatype: M === b._datatype && N === x._datatype ? F : void 0
    }), ee = [], $ = [], te = 0; te < O; te++) {
      H[te] = X.length;
      for (var re = te + 1, ie = 0; ie < P; ie++) {
        var oe = T[ie][te];
        if (!L(oe, q))
          for (var se = C[ie], he = C[ie + 1], ge = se; ge < he; ge++) {
            var De = w[ge];
            $[De] !== re ? ($[De] = re, X.push(De), ee[De] = G(oe, A[ge])) : ee[De] = R(ee[De], G(oe, A[ge]));
          }
      }
      for (var ae = H[te], ce = X.length, _e = ae; _e < ce; _e++) {
        var le = X[_e];
        K[_e] = ee[le];
      }
    }
    return H[O] = X.length, W;
  }
  function S(b, x) {
    var A = b._values, w = b._index, C = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType(), T = x._values, N = x._index, I = x._ptr, P = x._datatype || x._data === void 0 ? x._datatype : x.getDataType(), O = b._size[0], F = x._size[1], R = A && T, G, L = n, q = a;
    M && P && M === P && typeof M == "string" && M !== "mixed" && (G = M, L = t.find(n, [G, G]), q = t.find(a, [G, G]));
    for (var K = R ? [] : void 0, X = [], H = [], W = b.createSparseMatrix({
      values: K,
      index: X,
      ptr: H,
      size: [O, F],
      datatype: M === b._datatype && P === x._datatype ? G : void 0
    }), ee = R ? [] : void 0, $ = [], te, re, ie, oe, se, he, ge, De, ae = 0; ae < F; ae++) {
      H[ae] = X.length;
      var ce = ae + 1;
      for (se = I[ae], he = I[ae + 1], oe = se; oe < he; oe++)
        if (De = N[oe], R)
          for (re = C[De], ie = C[De + 1], te = re; te < ie; te++)
            ge = w[te], $[ge] !== ce ? ($[ge] = ce, X.push(ge), ee[ge] = q(T[oe], A[te])) : ee[ge] = L(ee[ge], q(T[oe], A[te]));
        else
          for (re = C[De], ie = C[De + 1], te = re; te < ie; te++)
            ge = w[te], $[ge] !== ce && ($[ge] = ce, X.push(ge));
      if (R)
        for (var _e = H[ae], le = X.length, ue = _e; ue < le; ue++) {
          var be = X[ue];
          K[ue] = ee[be];
        }
    }
    return H[F] = X.length, W;
  }
  return t(BT, a, {
    // we extend the signatures of multiplyScalar with signatures dealing with matrices
    "Array, Array": t.referTo("Matrix, Matrix", (b) => (x, A) => {
      c(Sr(x), Sr(A));
      var w = b(r(x), r(A));
      return Zt(w) ? w.valueOf() : w;
    }),
    "Matrix, Matrix": function(x, A) {
      var w = x.size(), C = A.size();
      return c(w, C), w.length === 1 ? C.length === 1 ? l(x, A, w[0]) : d(x, A) : C.length === 1 ? m(x, A) : h(x, A);
    },
    "Matrix, Array": t.referTo("Matrix,Matrix", (b) => (x, A) => b(x, r(A))),
    "Array, Matrix": t.referToSelf((b) => (x, A) => b(r(x, A.storage()), A)),
    "SparseMatrix, any": function(x, A) {
      return s(x, A, a, !1);
    },
    "DenseMatrix, any": function(x, A) {
      return u(x, A, a, !1);
    },
    "any, SparseMatrix": function(x, A) {
      return s(A, x, a, !0);
    },
    "any, DenseMatrix": function(x, A) {
      return u(A, x, a, !0);
    },
    "Array, any": function(x, A) {
      return u(r(x), A, a, !1).valueOf();
    },
    "any, Array": function(x, A) {
      return u(r(A), x, a, !0).valueOf();
    },
    "any, any": a,
    "any, any, ...any": t.referToSelf((b) => (x, A, w) => {
      for (var C = b(x, A), M = 0; M < w.length; M++)
        C = b(C, w[M]);
      return C;
    })
  });
}), OT = "nthRoot", lve = ["typed", "matrix", "equalScalar", "BigNumber", "concat"], dve = /* @__PURE__ */ me(OT, lve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    BigNumber: a,
    concat: i
  } = e, o = ef({
    typed: t
  }), s = Ru({
    typed: t,
    equalScalar: n
  }), u = X3({
    typed: t,
    equalScalar: n
  }), c = Ri({
    typed: t,
    equalScalar: n
  }), l = Ln({
    typed: t,
    matrix: r,
    concat: i
  });
  function d() {
    throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.");
  }
  return t(OT, {
    number: tT,
    "number, number": tT,
    BigNumber: (m) => f(m, new a(2)),
    "BigNumber, BigNumber": f,
    Complex: d,
    "Complex, number": d,
    Array: t.referTo("DenseMatrix,number", (m) => (h) => m(r(h), 2).valueOf()),
    DenseMatrix: t.referTo("DenseMatrix,number", (m) => (h) => m(h, 2)),
    SparseMatrix: t.referTo("SparseMatrix,number", (m) => (h) => m(h, 2)),
    "SparseMatrix, SparseMatrix": t.referToSelf((m) => (h, p) => {
      if (p.density() === 1)
        return u(h, p, m);
      throw new Error("Root must be non-zero");
    }),
    "DenseMatrix, SparseMatrix": t.referToSelf((m) => (h, p) => {
      if (p.density() === 1)
        return o(h, p, m, !1);
      throw new Error("Root must be non-zero");
    }),
    "Array, SparseMatrix": t.referTo("DenseMatrix,SparseMatrix", (m) => (h, p) => m(r(h), p)),
    "number | BigNumber, SparseMatrix": t.referToSelf((m) => (h, p) => {
      if (p.density() === 1)
        return c(p, h, m, !0);
      throw new Error("Root must be non-zero");
    })
  }, l({
    scalar: "number | BigNumber",
    SD: s,
    Ss: c,
    sS: !1
  }));
  function f(m, h) {
    var p = a.precision, g = a.clone({
      precision: p + 2
    }), v = new a(0), y = new g(1), _ = h.isNegative();
    if (_ && (h = h.neg()), h.isZero())
      throw new Error("Root must be non-zero");
    if (m.isNegative() && !h.abs().mod(2).equals(1))
      throw new Error("Root must be odd when a is negative.");
    if (m.isZero())
      return _ ? new g(1 / 0) : 0;
    if (!m.isFinite())
      return _ ? v : m;
    var S = m.abs().pow(y.div(h));
    return S = m.isNeg() ? S.neg() : S, new a((_ ? y.div(S) : S).toPrecision(p));
  }
}), FT = "sign", fve = ["typed", "BigNumber", "Fraction", "complex"], uV = /* @__PURE__ */ me(FT, fve, (e) => {
  var {
    typed: t,
    BigNumber: r,
    complex: n,
    Fraction: a
  } = e;
  return t(FT, {
    number: W_,
    Complex: function(o) {
      return o.im === 0 ? n(W_(o.re)) : o.sign();
    },
    BigNumber: function(o) {
      return new r(o.cmp(0));
    },
    bigint: function(o) {
      return o > 0n ? 1n : o < 0n ? -1n : 0n;
    },
    Fraction: function(o) {
      return new a(o.s, 1);
    },
    // deep map collection, skip zeros since sign(0) = 0
    "Array | Matrix": t.referToSelf((i) => (o) => Tr(o, i)),
    Unit: t.referToSelf((i) => (o) => {
      if (!o._isDerived() && o.units[0].unit.offset !== 0)
        throw new TypeError("sign is ambiguous for units with offset");
      return t.find(i, o.valueType())(o.value);
    })
  });
}), mve = "sqrt", pve = ["config", "typed", "Complex"], cV = /* @__PURE__ */ me(mve, pve, (e) => {
  var {
    config: t,
    typed: r,
    Complex: n
  } = e;
  return r("sqrt", {
    number: a,
    Complex: function(o) {
      return o.sqrt();
    },
    BigNumber: function(o) {
      return !o.isNegative() || t.predictable ? o.sqrt() : a(o.toNumber());
    },
    Unit: function(o) {
      return o.pow(0.5);
    }
  });
  function a(i) {
    return isNaN(i) ? NaN : i >= 0 || t.predictable ? Math.sqrt(i) : new n(i, 0).sqrt();
  }
}), RT = "square", hve = ["typed"], vve = /* @__PURE__ */ me(RT, hve, (e) => {
  var {
    typed: t
  } = e;
  return t(RT, {
    number: fG,
    Complex: function(n) {
      return n.mul(n);
    },
    BigNumber: function(n) {
      return n.times(n);
    },
    bigint: function(n) {
      return n * n;
    },
    Fraction: function(n) {
      return n.mul(n);
    },
    Unit: function(n) {
      return n.pow(2);
    }
  });
}), LT = "subtract", gve = ["typed", "matrix", "equalScalar", "subtractScalar", "unaryMinus", "DenseMatrix", "concat"], lV = /* @__PURE__ */ me(LT, gve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    subtractScalar: a,
    unaryMinus: i,
    DenseMatrix: o,
    concat: s
  } = e, u = ef({
    typed: t
  }), c = Ao({
    typed: t
  }), l = K3({
    typed: t,
    equalScalar: n
  }), d = ym({
    typed: t,
    DenseMatrix: o
  }), f = ti({
    typed: t,
    DenseMatrix: o
  }), m = Ln({
    typed: t,
    matrix: r,
    concat: s
  });
  return t(LT, {
    "any, any": a
  }, m({
    elop: a,
    SS: l,
    DS: u,
    SD: c,
    Ss: f,
    sS: d
  }));
}), kT = "xgcd", yve = ["typed", "config", "matrix", "BigNumber"], bve = /* @__PURE__ */ me(kT, yve, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: a
  } = e;
  return t(kT, {
    "number, number": function(s, u) {
      var c = mG(s, u);
      return r.matrix === "Array" ? c : n(c);
    },
    "BigNumber, BigNumber": i
    // TODO: implement support for Fraction
  });
  function i(o, s) {
    var u, c, l, d = new a(0), f = new a(1), m = d, h = f, p = f, g = d;
    if (!o.isInt() || !s.isInt())
      throw new Error("Parameters in function xgcd must be integer numbers");
    for (; !s.isZero(); )
      c = o.div(s).floor(), l = o.mod(s), u = m, m = h.minus(c.times(m)), h = u, u = p, p = g.minus(c.times(p)), g = u, o = s, s = l;
    var v;
    return o.lt(d) ? v = [o.neg(), h.neg(), g.neg()] : v = [o, o.isZero() ? 0 : h, g], r.matrix === "Array" ? v : n(v);
  }
}), zT = "invmod", xve = ["typed", "config", "BigNumber", "xgcd", "equal", "smaller", "mod", "add", "isInteger"], _ve = /* @__PURE__ */ me(zT, xve, (e) => {
  var {
    typed: t,
    config: r,
    BigNumber: n,
    xgcd: a,
    equal: i,
    smaller: o,
    mod: s,
    add: u,
    isInteger: c
  } = e;
  return t(zT, {
    "number, number": l,
    "BigNumber, BigNumber": l
  });
  function l(d, f) {
    if (!c(d) || !c(f)) throw new Error("Parameters in function invmod must be integer numbers");
    if (d = s(d, f), i(f, 0)) throw new Error("Divisor must be non zero");
    var m = a(d, f);
    m = m.valueOf();
    var [h, p] = m;
    return i(h, n(1)) ? (p = s(p, f), o(p, n(0)) && (p = u(p, f)), p) : NaN;
  }
}), Sve = "matAlgo09xS0Sf", Ave = ["typed", "equalScalar"], dV = /* @__PURE__ */ me(Sve, Ave, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o) {
    var s = a._values, u = a._index, c = a._ptr, l = a._size, d = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), f = i._values, m = i._index, h = i._ptr, p = i._size, g = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== p.length)
      throw new Ir(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var v = l[0], y = l[1], _, S = r, b = 0, x = o;
    typeof d == "string" && d === g && d !== "mixed" && (_ = d, S = t.find(r, [_, _]), b = t.convert(0, _), x = t.find(o, [_, _]));
    var A = s && f ? [] : void 0, w = [], C = [], M = A ? [] : void 0, T = [], N, I, P, O, F;
    for (I = 0; I < y; I++) {
      C[I] = w.length;
      var R = I + 1;
      if (M)
        for (O = h[I], F = h[I + 1], P = O; P < F; P++)
          N = m[P], T[N] = R, M[N] = f[P];
      for (O = c[I], F = c[I + 1], P = O; P < F; P++)
        if (N = u[P], M) {
          var G = T[N] === R ? M[N] : b, L = x(s[P], G);
          S(L, b) || (w.push(N), A.push(L));
        } else
          w.push(N);
    }
    return C[y] = w.length, a.createSparseMatrix({
      values: A,
      index: w,
      ptr: C,
      size: [v, y],
      datatype: d === a._datatype && g === i._datatype ? _ : void 0
    });
  };
}), UT = "dotMultiply", wve = ["typed", "matrix", "equalScalar", "multiplyScalar", "concat"], Cve = /* @__PURE__ */ me(UT, wve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    multiplyScalar: a,
    concat: i
  } = e, o = Ru({
    typed: t,
    equalScalar: n
  }), s = dV({
    typed: t,
    equalScalar: n
  }), u = Ri({
    typed: t,
    equalScalar: n
  }), c = Ln({
    typed: t,
    matrix: r,
    concat: i
  });
  return t(UT, c({
    elop: a,
    SS: s,
    DS: o,
    Ss: u
  }));
});
function Eve(e, t) {
  if (e.isFinite() && !e.isInteger() || t.isFinite() && !t.isInteger())
    throw new Error("Integers expected in function bitAnd");
  var r = e.constructor;
  if (e.isNaN() || t.isNaN())
    return new r(NaN);
  if (e.isZero() || t.eq(-1) || e.eq(t))
    return e;
  if (t.isZero() || e.eq(-1))
    return t;
  if (!e.isFinite() || !t.isFinite()) {
    if (!e.isFinite() && !t.isFinite())
      return e.isNegative() === t.isNegative() ? e : new r(0);
    if (!e.isFinite())
      return t.isNegative() ? e : e.isNegative() ? new r(0) : t;
    if (!t.isFinite())
      return e.isNegative() ? t : t.isNegative() ? new r(0) : e;
  }
  return OS(e, t, function(n, a) {
    return n & a;
  });
}
function Ih(e) {
  if (e.isFinite() && !e.isInteger())
    throw new Error("Integer expected in function bitNot");
  var t = e.constructor, r = t.precision;
  t.config({
    precision: 1e9
  });
  var n = e.plus(new t(1));
  return n.s = -n.s || null, t.config({
    precision: r
  }), n;
}
function Dve(e, t) {
  if (e.isFinite() && !e.isInteger() || t.isFinite() && !t.isInteger())
    throw new Error("Integers expected in function bitOr");
  var r = e.constructor;
  if (e.isNaN() || t.isNaN())
    return new r(NaN);
  var n = new r(-1);
  return e.isZero() || t.eq(n) || e.eq(t) ? t : t.isZero() || e.eq(n) ? e : !e.isFinite() || !t.isFinite() ? !e.isFinite() && !e.isNegative() && t.isNegative() || e.isNegative() && !t.isNegative() && !t.isFinite() ? n : e.isNegative() && t.isNegative() ? e.isFinite() ? e : t : e.isFinite() ? t : e : OS(e, t, function(a, i) {
    return a | i;
  });
}
function OS(e, t, r) {
  var n = e.constructor, a, i, o = +(e.s < 0), s = +(t.s < 0);
  if (o) {
    a = r2(Ih(e));
    for (var u = 0; u < a.length; ++u)
      a[u] ^= 1;
  } else
    a = r2(e);
  if (s) {
    i = r2(Ih(t));
    for (var c = 0; c < i.length; ++c)
      i[c] ^= 1;
  } else
    i = r2(t);
  var l, d, f;
  a.length <= i.length ? (l = a, d = i, f = o) : (l = i, d = a, f = s);
  var m = l.length, h = d.length, p = r(o, s) ^ 1, g = new n(p ^ 1), v = new n(1), y = new n(2), _ = n.precision;
  for (n.config({
    precision: 1e9
  }); m > 0; )
    r(l[--m], d[--h]) === p && (g = g.plus(v)), v = v.times(y);
  for (; h > 0; )
    r(f, d[--h]) === p && (g = g.plus(v)), v = v.times(y);
  return n.config({
    precision: _
  }), p === 0 && (g.s = -g.s), g;
}
function r2(e) {
  for (var t = e.d, r = t[0] + "", n = 1; n < t.length; ++n) {
    for (var a = t[n] + "", i = 7 - a.length; i--; )
      a = "0" + a;
    r += a;
  }
  for (var o = r.length; r.charAt(o) === "0"; )
    o--;
  var s = e.e, u = r.slice(0, o + 1 || 1), c = u.length;
  if (s > 0)
    if (++s > c)
      for (s -= c; s--; )
        u += "0";
    else s < c && (u = u.slice(0, s) + "." + u.slice(s));
  for (var l = [0], d = 0; d < u.length; ) {
    for (var f = l.length; f--; )
      l[f] *= 10;
    l[0] += parseInt(u.charAt(d++));
    for (var m = 0; m < l.length; ++m)
      l[m] > 1 && ((l[m + 1] === null || l[m + 1] === void 0) && (l[m + 1] = 0), l[m + 1] += l[m] >> 1, l[m] &= 1);
  }
  return l.reverse();
}
function Mve(e, t) {
  if (e.isFinite() && !e.isInteger() || t.isFinite() && !t.isInteger())
    throw new Error("Integers expected in function bitXor");
  var r = e.constructor;
  if (e.isNaN() || t.isNaN())
    return new r(NaN);
  if (e.isZero())
    return t;
  if (t.isZero())
    return e;
  if (e.eq(t))
    return new r(0);
  var n = new r(-1);
  return e.eq(n) ? Ih(t) : t.eq(n) ? Ih(e) : !e.isFinite() || !t.isFinite() ? !e.isFinite() && !t.isFinite() ? n : new r(e.isNegative() === t.isNegative() ? 1 / 0 : -1 / 0) : OS(e, t, function(a, i) {
    return a ^ i;
  });
}
function Ive(e, t) {
  if (e.isFinite() && !e.isInteger() || t.isFinite() && !t.isInteger())
    throw new Error("Integers expected in function leftShift");
  var r = e.constructor;
  return e.isNaN() || t.isNaN() || t.isNegative() && !t.isZero() ? new r(NaN) : e.isZero() || t.isZero() ? e : !e.isFinite() && !t.isFinite() ? new r(NaN) : t.lt(55) ? e.times(Math.pow(2, t.toNumber()) + "") : e.times(new r(2).pow(t));
}
function Tve(e, t) {
  if (e.isFinite() && !e.isInteger() || t.isFinite() && !t.isInteger())
    throw new Error("Integers expected in function rightArithShift");
  var r = e.constructor;
  return e.isNaN() || t.isNaN() || t.isNegative() && !t.isZero() ? new r(NaN) : e.isZero() || t.isZero() ? e : t.isFinite() ? t.lt(55) ? e.div(Math.pow(2, t.toNumber()) + "").floor() : e.div(new r(2).pow(t)).floor() : e.isNegative() ? new r(-1) : e.isFinite() ? new r(0) : new r(NaN);
}
var GT = "bitAnd", Nve = ["typed", "matrix", "equalScalar", "concat"], fV = /* @__PURE__ */ me(GT, Nve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    concat: a
  } = e, i = Ru({
    typed: t,
    equalScalar: n
  }), o = X3({
    typed: t,
    equalScalar: n
  }), s = Ri({
    typed: t,
    equalScalar: n
  }), u = Ln({
    typed: t,
    matrix: r,
    concat: a
  });
  return t(GT, {
    "number, number": hG,
    "BigNumber, BigNumber": Eve,
    "bigint, bigint": (c, l) => c & l
  }, u({
    SS: o,
    DS: i,
    Ss: s
  }));
}), VT = "bitNot", Pve = ["typed"], Bve = /* @__PURE__ */ me(VT, Pve, (e) => {
  var {
    typed: t
  } = e;
  return t(VT, {
    number: vG,
    BigNumber: Ih,
    bigint: (r) => ~r,
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), qT = "bitOr", Ove = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], mV = /* @__PURE__ */ me(qT, Ove, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = ef({
    typed: t
  }), s = BS({
    typed: t,
    equalScalar: n
  }), u = ym({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: r,
    concat: i
  });
  return t(qT, {
    "number, number": gG,
    "BigNumber, BigNumber": Dve,
    "bigint, bigint": (l, d) => l | d
  }, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), Fve = "matAlgo07xSSf", Rve = ["typed", "DenseMatrix"], gc = /* @__PURE__ */ me(Fve, Rve, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(i, o, s) {
    var u = i._size, c = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), l = o._size, d = o._datatype || o._data === void 0 ? o._datatype : o.getDataType();
    if (u.length !== l.length)
      throw new Ir(u.length, l.length);
    if (u[0] !== l[0] || u[1] !== l[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + l + ")");
    var f = u[0], m = u[1], h, p = 0, g = s;
    typeof c == "string" && c === d && c !== "mixed" && (h = c, p = t.convert(0, h), g = t.find(s, [h, h]));
    var v, y, _ = [];
    for (v = 0; v < f; v++)
      _[v] = [];
    var S = [], b = [], x = [], A = [];
    for (y = 0; y < m; y++) {
      var w = y + 1;
      for (n(i, y, x, S, w), n(o, y, A, b, w), v = 0; v < f; v++) {
        var C = x[v] === w ? S[v] : p, M = A[v] === w ? b[v] : p;
        _[v][y] = g(C, M);
      }
    }
    return new r({
      data: _,
      size: [f, m],
      datatype: c === i._datatype && d === o._datatype ? h : void 0
    });
  };
  function n(a, i, o, s, u) {
    for (var c = a._values, l = a._index, d = a._ptr, f = d[i], m = d[i + 1]; f < m; f++) {
      var h = l[f];
      o[h] = u, s[h] = c[f];
    }
  }
}), HT = "bitXor", Lve = ["typed", "matrix", "DenseMatrix", "concat"], kve = /* @__PURE__ */ me(HT, Lve, (e) => {
  var {
    typed: t,
    matrix: r,
    DenseMatrix: n,
    concat: a
  } = e, i = Ao({
    typed: t
  }), o = gc({
    typed: t,
    DenseMatrix: n
  }), s = ti({
    typed: t,
    DenseMatrix: n
  }), u = Ln({
    typed: t,
    matrix: r,
    concat: a
  });
  return t(HT, {
    "number, number": yG,
    "BigNumber, BigNumber": Mve,
    "bigint, bigint": (c, l) => c ^ l
  }, u({
    SS: o,
    DS: i,
    Ss: s
  }));
}), KT = "arg", zve = ["typed"], Uve = /* @__PURE__ */ me(KT, zve, (e) => {
  var {
    typed: t
  } = e;
  return t(KT, {
    number: function(n) {
      return Math.atan2(0, n);
    },
    BigNumber: function(n) {
      return n.constructor.atan2(0, n);
    },
    Complex: function(n) {
      return n.arg();
    },
    // TODO: implement BigNumber support for function arg
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), XT = "conj", Gve = ["typed"], pV = /* @__PURE__ */ me(XT, Gve, (e) => {
  var {
    typed: t
  } = e;
  return t(XT, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.conjugate(),
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), jT = "im", Vve = ["typed"], hV = /* @__PURE__ */ me(jT, Vve, (e) => {
  var {
    typed: t
  } = e;
  return t(jT, {
    number: () => 0,
    "BigNumber | Fraction": (r) => r.mul(0),
    Complex: (r) => r.im,
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), YT = "re", qve = ["typed"], vV = /* @__PURE__ */ me(YT, qve, (e) => {
  var {
    typed: t
  } = e;
  return t(YT, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.re,
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), WT = "not", Hve = ["typed"], Kve = /* @__PURE__ */ me(WT, Hve, (e) => {
  var {
    typed: t
  } = e;
  return t(WT, {
    "null | undefined": () => !0,
    number: AG,
    Complex: function(n) {
      return n.re === 0 && n.im === 0;
    },
    BigNumber: function(n) {
      return n.isZero() || n.isNaN();
    },
    bigint: (r) => !r,
    Unit: t.referToSelf((r) => (n) => t.find(r, n.valueType())(n.value)),
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), ZT = "or", Xve = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], gV = /* @__PURE__ */ me(ZT, Xve, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = K3({
    typed: t,
    equalScalar: n
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: r,
    concat: i
  });
  return t(ZT, {
    "number, number": Z_,
    "Complex, Complex": function(d, f) {
      return d.re !== 0 || d.im !== 0 || f.re !== 0 || f.im !== 0;
    },
    "BigNumber, BigNumber": function(d, f) {
      return !d.isZero() && !d.isNaN() || !f.isZero() && !f.isNaN();
    },
    "bigint, bigint": Z_,
    "Unit, Unit": t.referToSelf((l) => (d, f) => l(d.value || 0, f.value || 0))
  }, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), QT = "xor", jve = ["typed", "matrix", "DenseMatrix", "concat"], Yve = /* @__PURE__ */ me(QT, jve, (e) => {
  var {
    typed: t,
    matrix: r,
    DenseMatrix: n,
    concat: a
  } = e, i = Ao({
    typed: t
  }), o = gc({
    typed: t,
    DenseMatrix: n
  }), s = ti({
    typed: t,
    DenseMatrix: n
  }), u = Ln({
    typed: t,
    matrix: r,
    concat: a
  });
  return t(QT, {
    "number, number": Q_,
    "Complex, Complex": function(l, d) {
      return (l.re !== 0 || l.im !== 0) != (d.re !== 0 || d.im !== 0);
    },
    "bigint, bigint": Q_,
    "BigNumber, BigNumber": function(l, d) {
      return (!l.isZero() && !l.isNaN()) != (!d.isZero() && !d.isNaN());
    },
    "Unit, Unit": t.referToSelf((c) => (l, d) => c(l.value || 0, d.value || 0))
  }, u({
    SS: o,
    DS: i,
    Ss: s
  }));
}), $T = "concat", Wve = ["typed", "matrix", "isInteger"], FS = /* @__PURE__ */ me($T, Wve, (e) => {
  var {
    typed: t,
    matrix: r,
    isInteger: n
  } = e;
  return t($T, {
    // TODO: change signature to '...Array | Matrix, dim?' when supported
    "...Array | Matrix | number | BigNumber": function(i) {
      var o, s = i.length, u = -1, c, l = !1, d = [];
      for (o = 0; o < s; o++) {
        var f = i[o];
        if (Zt(f) && (l = !0), _r(f) || hr(f)) {
          if (o !== s - 1)
            throw new Error("Dimension must be specified as last argument");
          if (c = u, u = f.valueOf(), !n(u))
            throw new TypeError("Integer number expected for dimension");
          if (u < 0 || o > 0 && u > c)
            throw new ou(u, c + 1);
        } else {
          var m = Jt(f).valueOf(), h = Sr(m);
          if (d[o] = m, c = u, u = h.length - 1, o > 0 && u !== c)
            throw new Ir(c + 1, u + 1);
        }
      }
      if (d.length === 0)
        throw new SyntaxError("At least one matrix expected");
      for (var p = d.shift(); d.length; )
        p = jU(p, d.shift(), u);
      return l ? r(p) : p;
    },
    "...string": function(i) {
      return i.join("");
    }
  });
}), JT = "column", Zve = ["typed", "Index", "matrix", "range"], RS = /* @__PURE__ */ me(JT, Zve, (e) => {
  var {
    typed: t,
    Index: r,
    matrix: n,
    range: a
  } = e;
  return t(JT, {
    "Matrix, number": i,
    "Array, number": function(s, u) {
      return i(n(Jt(s)), u).valueOf();
    }
  });
  function i(o, s) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    En(s, o.size()[1]);
    var u = a(0, o.size()[0]), c = new r(u, s), l = o.subset(c);
    return Zt(l) ? l : n([[l]]);
  }
}), eN = "count", Qve = ["typed", "size", "prod"], $ve = /* @__PURE__ */ me(eN, Qve, (e) => {
  var {
    typed: t,
    size: r,
    prod: n
  } = e;
  return t(eN, {
    string: function(i) {
      return i.length;
    },
    "Matrix | Array": function(i) {
      return n(r(i));
    }
  });
}), tN = "cross", Jve = ["typed", "matrix", "subtract", "multiply"], yV = /* @__PURE__ */ me(tN, Jve, (e) => {
  var {
    typed: t,
    matrix: r,
    subtract: n,
    multiply: a
  } = e;
  return t(tN, {
    "Matrix, Matrix": function(s, u) {
      return r(i(s.toArray(), u.toArray()));
    },
    "Matrix, Array": function(s, u) {
      return r(i(s.toArray(), u));
    },
    "Array, Matrix": function(s, u) {
      return r(i(s, u.toArray()));
    },
    "Array, Array": i
  });
  function i(o, s) {
    var u = Math.max(Sr(o).length, Sr(s).length);
    o = zy(o), s = zy(s);
    var c = Sr(o), l = Sr(s);
    if (c.length !== 1 || l.length !== 1 || c[0] !== 3 || l[0] !== 3)
      throw new RangeError("Vectors with length 3 expected (Size A = [" + c.join(", ") + "], B = [" + l.join(", ") + "])");
    var d = [n(a(o[1], s[2]), a(o[2], s[1])), n(a(o[2], s[0]), a(o[0], s[2])), n(a(o[0], s[1]), a(o[1], s[0]))];
    return u > 1 ? [d] : d;
  }
}), rN = "diag", ege = ["typed", "matrix", "DenseMatrix", "SparseMatrix"], bV = /* @__PURE__ */ me(rN, ege, (e) => {
  var {
    typed: t,
    matrix: r,
    DenseMatrix: n,
    SparseMatrix: a
  } = e;
  return t(rN, {
    // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments
    Array: function(c) {
      return i(c, 0, Sr(c), null);
    },
    "Array, number": function(c, l) {
      return i(c, l, Sr(c), null);
    },
    "Array, BigNumber": function(c, l) {
      return i(c, l.toNumber(), Sr(c), null);
    },
    "Array, string": function(c, l) {
      return i(c, 0, Sr(c), l);
    },
    "Array, number, string": function(c, l, d) {
      return i(c, l, Sr(c), d);
    },
    "Array, BigNumber, string": function(c, l, d) {
      return i(c, l.toNumber(), Sr(c), d);
    },
    Matrix: function(c) {
      return i(c, 0, c.size(), c.storage());
    },
    "Matrix, number": function(c, l) {
      return i(c, l, c.size(), c.storage());
    },
    "Matrix, BigNumber": function(c, l) {
      return i(c, l.toNumber(), c.size(), c.storage());
    },
    "Matrix, string": function(c, l) {
      return i(c, 0, c.size(), l);
    },
    "Matrix, number, string": function(c, l, d) {
      return i(c, l, c.size(), d);
    },
    "Matrix, BigNumber, string": function(c, l, d) {
      return i(c, l.toNumber(), c.size(), d);
    }
  });
  function i(u, c, l, d) {
    if (!Ut(c))
      throw new TypeError("Second parameter in function diag must be an integer");
    var f = c > 0 ? c : 0, m = c < 0 ? -c : 0;
    switch (l.length) {
      case 1:
        return o(u, c, d, l[0], m, f);
      case 2:
        return s(u, c, d, l, m, f);
    }
    throw new RangeError("Matrix for function diag must be 2 dimensional");
  }
  function o(u, c, l, d, f, m) {
    var h = [d + f, d + m];
    if (l && l !== "sparse" && l !== "dense")
      throw new TypeError("Unknown matrix type ".concat(l, '"'));
    var p = l === "sparse" ? a.diagonal(h, u, c) : n.diagonal(h, u, c);
    return l !== null ? p : p.valueOf();
  }
  function s(u, c, l, d, f, m) {
    if (Zt(u)) {
      var h = u.diagonal(c);
      return l !== null ? l !== h.storage() ? r(h, l) : h : h.valueOf();
    }
    for (var p = Math.min(d[0] - f, d[1] - m), g = [], v = 0; v < p; v++)
      g[v] = u[v + f][v + m];
    return l !== null ? r(g) : g;
  }
});
function C1(e, t, r, n, a) {
  if (Vf.isTypedFunction(e)) {
    var i = [t, r, n], o = Vf.resolve(e, i);
    if (o)
      return d(o.implementation, i);
    var s = [t, r], u = Vf.resolve(e, s);
    if (u)
      return d(u.implementation, s);
    var c = [t], l = Vf.resolve(e, c);
    return l ? d(l.implementation, c) : d(e, i);
  } else
    return e(t, r, n);
  function d(f, m) {
    try {
      return f.apply(f, m);
    } catch (g) {
      var h;
      if (g instanceof TypeError && ((h = g.data) === null || h === void 0 ? void 0 : h.category) === "wrongType") {
        var p = [];
        throw p.push("value: ".concat(Nn(t))), m.length >= 2 && p.push("index: ".concat(Nn(r))), m.length >= 3 && p.push("array: ".concat(Nn(n))), new TypeError("Function ".concat(a, " cannot apply callback arguments ") + "".concat(e.name, "(").concat(p.join(", "), ") at index ").concat(JSON.stringify(r)));
      } else
        throw new TypeError("Function ".concat(a, " cannot apply callback arguments ") + "to function ".concat(e.name, ": ").concat(g.message));
    }
  }
}
var tge = "filter", rge = ["typed"], nge = /* @__PURE__ */ me(tge, rge, (e) => {
  var {
    typed: t
  } = e;
  return t("filter", {
    "Array, function": nN,
    "Matrix, function": function(n, a) {
      return n.create(nN(n.toArray(), a));
    },
    "Array, RegExp": Uy,
    "Matrix, RegExp": function(n, a) {
      return n.create(Uy(n.toArray(), a));
    }
  });
});
function nN(e, t) {
  return KU(e, function(r, n, a) {
    return C1(t, r, [n], a, "filter");
  });
}
var aN = "flatten", age = ["typed", "matrix"], xV = /* @__PURE__ */ me(aN, age, (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return t(aN, {
    Array: function(a) {
      return $r(a);
    },
    Matrix: function(a) {
      var i = $r(a.toArray());
      return r(i);
    }
  });
}), iN = "forEach", ige = ["typed"], oge = /* @__PURE__ */ me(iN, ige, (e) => {
  var {
    typed: t
  } = e;
  return t(iN, {
    "Array, function": sge,
    "Matrix, function": function(n, a) {
      n.forEach(a);
    }
  });
});
function sge(e, t) {
  var r = function n(a, i) {
    if (Array.isArray(a))
      q3(a, function(o, s) {
        n(o, i.concat(s));
      });
    else
      return C1(t, a, i, e, "forEach");
  };
  r(e, []);
}
var oN = "getMatrixDataType", uge = ["typed"], _V = /* @__PURE__ */ me(oN, uge, (e) => {
  var {
    typed: t
  } = e;
  return t(oN, {
    Array: function(n) {
      return Mh(n, Nn);
    },
    Matrix: function(n) {
      return n.getDataType();
    }
  });
}), sN = "identity", cge = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix"], SV = /* @__PURE__ */ me(sN, cge, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: a,
    DenseMatrix: i,
    SparseMatrix: o
  } = e;
  return t(sN, {
    "": function() {
      return r.matrix === "Matrix" ? n([]) : [];
    },
    string: function(l) {
      return n(l);
    },
    "number | BigNumber": function(l) {
      return u(l, l, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, string": function(l, d) {
      return u(l, l, d);
    },
    "number | BigNumber, number | BigNumber": function(l, d) {
      return u(l, d, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, number | BigNumber, string": function(l, d, f) {
      return u(l, d, f);
    },
    Array: function(l) {
      return s(l);
    },
    "Array, string": function(l, d) {
      return s(l, d);
    },
    Matrix: function(l) {
      return s(l.valueOf(), l.storage());
    },
    "Matrix, string": function(l, d) {
      return s(l.valueOf(), d);
    }
  });
  function s(c, l) {
    switch (c.length) {
      case 0:
        return l ? n(l) : [];
      case 1:
        return u(c[0], c[0], l);
      case 2:
        return u(c[0], c[1], l);
      default:
        throw new Error("Vector containing two values expected");
    }
  }
  function u(c, l, d) {
    var f = hr(c) || hr(l) ? a : null;
    if (hr(c) && (c = c.toNumber()), hr(l) && (l = l.toNumber()), !Ut(c) || c < 1)
      throw new Error("Parameters in function identity must be positive integers");
    if (!Ut(l) || l < 1)
      throw new Error("Parameters in function identity must be positive integers");
    var m = f ? new a(1) : 1, h = f ? new f(0) : 0, p = [c, l];
    if (d) {
      if (d === "sparse")
        return o.diagonal(p, m, 0, h);
      if (d === "dense")
        return i.diagonal(p, m, 0, h);
      throw new TypeError('Unknown matrix type "'.concat(d, '"'));
    }
    for (var g = u1([], p, h), v = c < l ? c : l, y = 0; y < v; y++)
      g[y][y] = m;
    return g;
  }
}), uN = "kron", lge = ["typed", "matrix", "multiplyScalar"], dge = /* @__PURE__ */ me(uN, lge, (e) => {
  var {
    typed: t,
    matrix: r,
    multiplyScalar: n
  } = e;
  return t(uN, {
    "Matrix, Matrix": function(o, s) {
      return r(a(o.toArray(), s.toArray()));
    },
    "Matrix, Array": function(o, s) {
      return r(a(o.toArray(), s));
    },
    "Array, Matrix": function(o, s) {
      return r(a(o, s.toArray()));
    },
    "Array, Array": a
  });
  function a(i, o) {
    if (Sr(i).length === 1 && (i = [i]), Sr(o).length === 1 && (o = [o]), Sr(i).length > 2 || Sr(o).length > 2)
      throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = " + JSON.stringify(i.length) + ", y = " + JSON.stringify(o.length) + ")");
    var s = [], u = [];
    return i.map(function(c) {
      return o.map(function(l) {
        return u = [], s.push(u), c.map(function(d) {
          return l.map(function(f) {
            return u.push(n(d, f));
          });
        });
      });
    }) && s;
  }
}), cN = "map", fge = ["typed"], mge = /* @__PURE__ */ me(cN, fge, (e) => {
  var {
    typed: t
  } = e;
  return t(cN, {
    "Array, function": pge,
    "Matrix, function": function(n, a) {
      return n.map(a);
    }
  });
});
function pge(e, t) {
  var r = function n(a, i) {
    return Array.isArray(a) ? a.map(function(o, s) {
      return n(o, i.concat(s));
    }) : C1(t, a, i, e, "map");
  };
  return r(e, []);
}
var lN = "diff", hge = ["typed", "matrix", "subtract", "number"], AV = /* @__PURE__ */ me(lN, hge, (e) => {
  var {
    typed: t,
    matrix: r,
    subtract: n,
    number: a
  } = e;
  return t(lN, {
    "Array | Matrix": function(l) {
      return Zt(l) ? r(o(l.toArray())) : o(l);
    },
    "Array | Matrix, number": function(l, d) {
      if (!Ut(d)) throw new RangeError("Dimension must be a whole number");
      return Zt(l) ? r(i(l.toArray(), d)) : i(l, d);
    },
    "Array, BigNumber": t.referTo("Array,number", (c) => (l, d) => c(l, a(d))),
    "Matrix, BigNumber": t.referTo("Matrix,number", (c) => (l, d) => c(l, a(d)))
  });
  function i(c, l) {
    if (Zt(c) && (c = c.toArray()), !Array.isArray(c))
      throw RangeError("Array/Matrix does not have that many dimensions");
    if (l > 0) {
      var d = [];
      return c.forEach((f) => {
        d.push(i(f, l - 1));
      }), d;
    } else {
      if (l === 0)
        return o(c);
      throw RangeError("Cannot have negative dimension");
    }
  }
  function o(c) {
    for (var l = [], d = c.length, f = 1; f < d; f++)
      l.push(s(c[f - 1], c[f]));
    return l;
  }
  function s(c, l) {
    Zt(c) && (c = c.toArray()), Zt(l) && (l = l.toArray());
    var d = Array.isArray(c), f = Array.isArray(l);
    if (d && f)
      return u(c, l);
    if (!d && !f)
      return n(l, c);
    throw TypeError("Cannot calculate difference between 1 array and 1 non-array");
  }
  function u(c, l) {
    if (c.length !== l.length)
      throw RangeError("Not all sub-arrays have the same length");
    for (var d = [], f = c.length, m = 0; m < f; m++)
      d.push(s(c[m], l[m]));
    return d;
  }
}), vge = "ones", gge = ["typed", "config", "matrix", "BigNumber"], yge = /* @__PURE__ */ me(vge, gge, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: a
  } = e;
  return t("ones", {
    "": function() {
      return r.matrix === "Array" ? i([]) : i([], "default");
    },
    // math.ones(m, n, p, ..., format)
    // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
    "...number | BigNumber | string": function(c) {
      var l = c[c.length - 1];
      if (typeof l == "string") {
        var d = c.pop();
        return i(c, d);
      } else return r.matrix === "Array" ? i(c) : i(c, "default");
    },
    Array: i,
    Matrix: function(c) {
      var l = c.storage();
      return i(c.valueOf(), l);
    },
    "Array | Matrix, string": function(c, l) {
      return i(c.valueOf(), l);
    }
  });
  function i(u, c) {
    var l = o(u), d = l ? new a(1) : 1;
    if (s(u), c) {
      var f = n(c);
      return u.length > 0 ? f.resize(u, d) : f;
    } else {
      var m = [];
      return u.length > 0 ? u1(m, u, d) : m;
    }
  }
  function o(u) {
    var c = !1;
    return u.forEach(function(l, d, f) {
      hr(l) && (c = !0, f[d] = l.toNumber());
    }), c;
  }
  function s(u) {
    u.forEach(function(c) {
      if (typeof c != "number" || !Ut(c) || c < 0)
        throw new Error("Parameters in function ones must be positive integers");
    });
  }
});
function LS() {
  throw new Error('No "bignumber" implementation available');
}
function wV() {
  throw new Error('No "fraction" implementation available');
}
function CV() {
  throw new Error('No "matrix" implementation available');
}
var dN = "range", bge = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], kS = /* @__PURE__ */ me(dN, bge, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: s,
    largerEq: u,
    add: c,
    isPositive: l
  } = e;
  return t(dN, {
    // TODO: simplify signatures when typed-function supports default values and optional arguments
    // TODO: a number or boolean should not be converted to string here
    string: f,
    "string, boolean": f,
    "number, number": function(g, v) {
      return d(m(g, v, 1, !1));
    },
    "number, number, number": function(g, v, y) {
      return d(m(g, v, y, !1));
    },
    "number, number, boolean": function(g, v, y) {
      return d(m(g, v, 1, y));
    },
    "number, number, number, boolean": function(g, v, y, _) {
      return d(m(g, v, y, _));
    },
    "BigNumber, BigNumber": function(g, v) {
      var y = g.constructor;
      return d(m(g, v, new y(1), !1));
    },
    "BigNumber, BigNumber, BigNumber": function(g, v, y) {
      return d(m(g, v, y, !1));
    },
    "BigNumber, BigNumber, boolean": function(g, v, y) {
      var _ = g.constructor;
      return d(m(g, v, new _(1), y));
    },
    "BigNumber, BigNumber, BigNumber, boolean": function(g, v, y, _) {
      return d(m(g, v, y, _));
    },
    "Unit, Unit, Unit": function(g, v, y) {
      return d(m(g, v, y, !1));
    },
    "Unit, Unit, Unit, boolean": function(g, v, y, _) {
      return d(m(g, v, y, _));
    }
  });
  function d(p) {
    return r.matrix === "Matrix" ? n ? n(p) : CV() : p;
  }
  function f(p, g) {
    var v = h(p);
    if (!v)
      throw new SyntaxError('String "' + p + '" is no valid range');
    return r.number === "BigNumber" ? (a === void 0 && LS(), d(m(a(v.start), a(v.end), a(v.step)))) : d(m(v.start, v.end, v.step, g));
  }
  function m(p, g, v, y) {
    for (var _ = [], S = l(v) ? y ? o : i : y ? u : s, b = p; S(b, g); )
      _.push(b), b = c(b, v);
    return _;
  }
  function h(p) {
    var g = p.split(":"), v = g.map(function(_) {
      return Number(_);
    }), y = v.some(function(_) {
      return isNaN(_);
    });
    if (y)
      return null;
    switch (v.length) {
      case 2:
        return {
          start: v[0],
          end: v[1],
          step: 1
        };
      case 3:
        return {
          start: v[0],
          end: v[2],
          step: v[1]
        };
      default:
        return null;
    }
  }
}), fN = "reshape", xge = ["typed", "isInteger", "matrix"], EV = /* @__PURE__ */ me(fN, xge, (e) => {
  var {
    typed: t,
    isInteger: r
  } = e;
  return t(fN, {
    "Matrix, Array": function(a, i) {
      return a.reshape(i, !0);
    },
    "Array, Array": function(a, i) {
      return i.forEach(function(o) {
        if (!r(o))
          throw new TypeError("Invalid size for dimension: " + o);
      }), DS(a, i);
    }
  });
}), _ge = "resize", Sge = ["config", "matrix"], Age = /* @__PURE__ */ me(_ge, Sge, (e) => {
  var {
    config: t,
    matrix: r
  } = e;
  return function(i, o, s) {
    if (arguments.length !== 2 && arguments.length !== 3)
      throw new Cl("resize", arguments.length, 2, 3);
    if (Zt(o) && (o = o.valueOf()), hr(o[0]) && (o = o.map(function(l) {
      return hr(l) ? l.toNumber() : l;
    })), Zt(i))
      return i.resize(o, s, !0);
    if (typeof i == "string")
      return n(i, o, s);
    var u = Array.isArray(i) ? !1 : t.matrix !== "Array";
    if (o.length === 0) {
      for (; Array.isArray(i); )
        i = i[0];
      return Jt(i);
    } else {
      Array.isArray(i) || (i = [i]), i = Jt(i);
      var c = u1(i, o, s);
      return u ? r(c) : c;
    }
  };
  function n(a, i, o) {
    if (o !== void 0) {
      if (typeof o != "string" || o.length !== 1)
        throw new TypeError("Single character expected as defaultValue");
    } else
      o = " ";
    if (i.length !== 1)
      throw new Ir(i.length, 1);
    var s = i[0];
    if (typeof s != "number" || !Ut(s))
      throw new TypeError("Invalid size, must contain positive integers (size: " + Br(i) + ")");
    if (a.length > s)
      return a.substring(0, s);
    if (a.length < s) {
      for (var u = a, c = 0, l = s - a.length; c < l; c++)
        u += o;
      return u;
    } else
      return a;
  }
}), mN = "rotate", wge = ["typed", "multiply", "rotationMatrix"], Cge = /* @__PURE__ */ me(mN, wge, (e) => {
  var {
    typed: t,
    multiply: r,
    rotationMatrix: n
  } = e;
  return t(mN, {
    "Array , number | BigNumber | Complex | Unit": function(o, s) {
      a(o, 2);
      var u = r(n(s), o);
      return u.toArray();
    },
    "Matrix , number | BigNumber | Complex | Unit": function(o, s) {
      return a(o, 2), r(n(s), o);
    },
    "Array, number | BigNumber | Complex | Unit, Array | Matrix": function(o, s, u) {
      a(o, 3);
      var c = r(n(s, u), o);
      return c;
    },
    "Matrix, number | BigNumber | Complex | Unit, Array | Matrix": function(o, s, u) {
      return a(o, 3), r(n(s, u), o);
    }
  });
  function a(i, o) {
    var s = Array.isArray(i) ? Sr(i) : i.size();
    if (s.length > 2)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
    if (s.length === 2 && s[1] !== 1)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
    if (s[0] !== o)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
  }
}), pN = "rotationMatrix", Ege = ["typed", "config", "multiplyScalar", "addScalar", "unaryMinus", "norm", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix", "cos", "sin"], Dge = /* @__PURE__ */ me(pN, Ege, (e) => {
  var {
    typed: t,
    config: r,
    multiplyScalar: n,
    addScalar: a,
    unaryMinus: i,
    norm: o,
    BigNumber: s,
    matrix: u,
    DenseMatrix: c,
    SparseMatrix: l,
    cos: d,
    sin: f
  } = e;
  return t(pN, {
    "": function() {
      return r.matrix === "Matrix" ? u([]) : [];
    },
    string: function(_) {
      return u(_);
    },
    "number | BigNumber | Complex | Unit": function(_) {
      return m(_, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber | Complex | Unit, string": function(_, S) {
      return m(_, S);
    },
    "number | BigNumber | Complex | Unit, Array": function(_, S) {
      var b = u(S);
      return h(b), v(_, b, void 0);
    },
    "number | BigNumber | Complex | Unit, Matrix": function(_, S) {
      h(S);
      var b = S.storage() || (r.matrix === "Matrix" ? "dense" : void 0);
      return v(_, S, b);
    },
    "number | BigNumber | Complex | Unit, Array, string": function(_, S, b) {
      var x = u(S);
      return h(x), v(_, x, b);
    },
    "number | BigNumber | Complex | Unit, Matrix, string": function(_, S, b) {
      return h(S), v(_, S, b);
    }
  });
  function m(y, _) {
    var S = hr(y), b = S ? new s(-1) : -1, x = d(y), A = f(y), w = [[x, n(b, A)], [A, x]];
    return g(w, _);
  }
  function h(y) {
    var _ = y.size();
    if (_.length < 1 || _[0] !== 3)
      throw new RangeError("Vector must be of dimensions 1x3");
  }
  function p(y) {
    return y.reduce((_, S) => n(_, S));
  }
  function g(y, _) {
    if (_) {
      if (_ === "sparse")
        return new l(y);
      if (_ === "dense")
        return new c(y);
      throw new TypeError('Unknown matrix type "'.concat(_, '"'));
    }
    return y;
  }
  function v(y, _, S) {
    var b = o(_);
    if (b === 0)
      throw new RangeError("Rotation around zero vector");
    var x = hr(y) ? s : null, A = x ? new x(1) : 1, w = x ? new x(-1) : -1, C = x ? new x(_.get([0]) / b) : _.get([0]) / b, M = x ? new x(_.get([1]) / b) : _.get([1]) / b, T = x ? new x(_.get([2]) / b) : _.get([2]) / b, N = d(y), I = a(A, i(N)), P = f(y), O = a(N, p([C, C, I])), F = a(p([C, M, I]), p([w, T, P])), R = a(p([C, T, I]), p([M, P])), G = a(p([C, M, I]), p([T, P])), L = a(N, p([M, M, I])), q = a(p([M, T, I]), p([w, C, P])), K = a(p([C, T, I]), p([w, M, P])), X = a(p([M, T, I]), p([C, P])), H = a(N, p([T, T, I])), W = [[O, F, R], [G, L, q], [K, X, H]];
    return g(W, S);
  }
}), hN = "row", Mge = ["typed", "Index", "matrix", "range"], DV = /* @__PURE__ */ me(hN, Mge, (e) => {
  var {
    typed: t,
    Index: r,
    matrix: n,
    range: a
  } = e;
  return t(hN, {
    "Matrix, number": i,
    "Array, number": function(s, u) {
      return i(n(Jt(s)), u).valueOf();
    }
  });
  function i(o, s) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    En(s, o.size()[0]);
    var u = a(0, o.size()[1]), c = new r(s, u), l = o.subset(c);
    return Zt(l) ? l : n([[l]]);
  }
}), vN = "size", Ige = ["typed", "config", "?matrix"], MV = /* @__PURE__ */ me(vN, Ige, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n
  } = e;
  return t(vN, {
    Matrix: function(i) {
      return i.create(i.size());
    },
    Array: Sr,
    string: function(i) {
      return r.matrix === "Array" ? [i.length] : n([i.length]);
    },
    "number | Complex | BigNumber | Unit | boolean | null": function(i) {
      return r.matrix === "Array" ? [] : n ? n([]) : CV();
    }
  });
}), gN = "squeeze", Tge = ["typed", "matrix"], Nge = /* @__PURE__ */ me(gN, Tge, (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return t(gN, {
    Array: function(a) {
      return zy(Jt(a));
    },
    Matrix: function(a) {
      var i = zy(a.toArray());
      return Array.isArray(i) ? r(i) : i;
    },
    any: function(a) {
      return Jt(a);
    }
  });
}), yN = "subset", Pge = ["typed", "matrix", "zeros", "add"], IV = /* @__PURE__ */ me(yN, Pge, (e) => {
  var {
    typed: t,
    matrix: r,
    zeros: n,
    add: a
  } = e;
  return t(yN, {
    // get subset
    "Matrix, Index": function(s, u) {
      return s1(u) ? r() : (ky(s, u), s.subset(u));
    },
    "Array, Index": t.referTo("Matrix, Index", function(o) {
      return function(s, u) {
        var c = o(r(s), u);
        return u.isScalar() ? c : c.valueOf();
      };
    }),
    "Object, Index": Oge,
    "string, Index": Bge,
    // set subset
    "Matrix, Index, any, any": function(s, u, c, l) {
      return s1(u) ? s : (ky(s, u), s.clone().subset(u, i(c, u), l));
    },
    "Array, Index, any, any": t.referTo("Matrix, Index, any, any", function(o) {
      return function(s, u, c, l) {
        var d = o(r(s), u, c, l);
        return d.isMatrix ? d.valueOf() : d;
      };
    }),
    "Array, Index, any": t.referTo("Matrix, Index, any, any", function(o) {
      return function(s, u, c) {
        return o(r(s), u, c, void 0).valueOf();
      };
    }),
    "Matrix, Index, any": t.referTo("Matrix, Index, any, any", function(o) {
      return function(s, u, c) {
        return o(s, u, c, void 0);
      };
    }),
    "string, Index, string": bN,
    "string, Index, string, string": bN,
    "Object, Index, any": Fge
  });
  function i(o, s) {
    if (typeof o == "string")
      throw new Error("can't boradcast a string");
    if (s._isScalar)
      return o;
    var u = s.size();
    if (u.every((c) => c > 0))
      try {
        return a(o, n(u));
      } catch {
        return o;
      }
    else
      return o;
  }
});
function Bge(e, t) {
  if (!qh(t))
    throw new TypeError("Index expected");
  if (s1(t))
    return "";
  if (ky(Array.from(e), t), t.size().length !== 1)
    throw new Ir(t.size().length, 1);
  var r = e.length;
  En(t.min()[0], r), En(t.max()[0], r);
  var n = t.dimension(0), a = "";
  return n.forEach(function(i) {
    a += e.charAt(i);
  }), a;
}
function bN(e, t, r, n) {
  if (!t || t.isIndex !== !0)
    throw new TypeError("Index expected");
  if (s1(t))
    return e;
  if (ky(Array.from(e), t), t.size().length !== 1)
    throw new Ir(t.size().length, 1);
  if (n !== void 0) {
    if (typeof n != "string" || n.length !== 1)
      throw new TypeError("Single character expected as defaultValue");
  } else
    n = " ";
  var a = t.dimension(0), i = a.size()[0];
  if (i !== r.length)
    throw new Ir(a.size()[0], r.length);
  var o = e.length;
  En(t.min()[0]), En(t.max()[0]);
  for (var s = [], u = 0; u < o; u++)
    s[u] = e.charAt(u);
  if (a.forEach(function(d, f) {
    s[d] = r.charAt(f[0]);
  }), s.length > o)
    for (var c = o - 1, l = s.length; c < l; c++)
      s[c] || (s[c] = n);
  return s.join("");
}
function Oge(e, t) {
  if (!s1(t)) {
    if (t.size().length !== 1)
      throw new Ir(t.size(), 1);
    var r = t.dimension(0);
    if (typeof r != "string")
      throw new TypeError("String expected as index to retrieve an object property");
    return yo(e, r);
  }
}
function Fge(e, t, r) {
  if (s1(t))
    return e;
  if (t.size().length !== 1)
    throw new Ir(t.size(), 1);
  var n = t.dimension(0);
  if (typeof n != "string")
    throw new TypeError("String expected as index to retrieve an object property");
  var a = Jt(e);
  return i1(a, n, r), a;
}
var xN = "transpose", Rge = ["typed", "matrix"], TV = /* @__PURE__ */ me(xN, Rge, (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return t(xN, {
    Array: (o) => n(r(o)).valueOf(),
    Matrix: n,
    any: Jt
    // scalars
  });
  function n(o) {
    var s = o.size(), u;
    switch (s.length) {
      case 1:
        u = o.clone();
        break;
      case 2:
        {
          var c = s[0], l = s[1];
          if (l === 0)
            throw new RangeError("Cannot transpose a 2D matrix with no columns (size: " + Br(s) + ")");
          switch (o.storage()) {
            case "dense":
              u = a(o, c, l);
              break;
            case "sparse":
              u = i(o, c, l);
              break;
          }
        }
        break;
      default:
        throw new RangeError("Matrix must be a vector or two dimensional (size: " + Br(s) + ")");
    }
    return u;
  }
  function a(o, s, u) {
    for (var c = o._data, l = [], d, f = 0; f < u; f++) {
      d = l[f] = [];
      for (var m = 0; m < s; m++)
        d[m] = Jt(c[m][f]);
    }
    return o.createDenseMatrix({
      data: l,
      size: [u, s],
      datatype: o._datatype
    });
  }
  function i(o, s, u) {
    for (var c = o._values, l = o._index, d = o._ptr, f = c ? [] : void 0, m = [], h = [], p = [], g = 0; g < s; g++)
      p[g] = 0;
    var v, y, _;
    for (v = 0, y = l.length; v < y; v++)
      p[l[v]]++;
    for (var S = 0, b = 0; b < s; b++)
      h.push(S), S += p[b], p[b] = h[b];
    for (h.push(S), _ = 0; _ < u; _++)
      for (var x = d[_], A = d[_ + 1], w = x; w < A; w++) {
        var C = p[l[w]]++;
        m[C] = _, c && (f[C] = Jt(c[w]));
      }
    return o.createSparseMatrix({
      values: f,
      index: m,
      ptr: h,
      size: [u, s],
      datatype: o._datatype
    });
  }
}), _N = "ctranspose", Lge = ["typed", "transpose", "conj"], NV = /* @__PURE__ */ me(_N, Lge, (e) => {
  var {
    typed: t,
    transpose: r,
    conj: n
  } = e;
  return t(_N, {
    any: function(i) {
      return n(r(i));
    }
  });
}), SN = "zeros", kge = ["typed", "config", "matrix", "BigNumber"], PV = /* @__PURE__ */ me(SN, kge, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: a
  } = e;
  return t(SN, {
    "": function() {
      return r.matrix === "Array" ? i([]) : i([], "default");
    },
    // math.zeros(m, n, p, ..., format)
    // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
    "...number | BigNumber | string": function(c) {
      var l = c[c.length - 1];
      if (typeof l == "string") {
        var d = c.pop();
        return i(c, d);
      } else return r.matrix === "Array" ? i(c) : i(c, "default");
    },
    Array: i,
    Matrix: function(c) {
      var l = c.storage();
      return i(c.valueOf(), l);
    },
    "Array | Matrix, string": function(c, l) {
      return i(c.valueOf(), l);
    }
  });
  function i(u, c) {
    var l = o(u), d = l ? new a(0) : 0;
    if (s(u), c) {
      var f = n(c);
      return u.length > 0 ? f.resize(u, d) : f;
    } else {
      var m = [];
      return u.length > 0 ? u1(m, u, d) : m;
    }
  }
  function o(u) {
    var c = !1;
    return u.forEach(function(l, d, f) {
      hr(l) && (c = !0, f[d] = l.toNumber());
    }), c;
  }
  function s(u) {
    u.forEach(function(c) {
      if (typeof c != "number" || !Ut(c) || c < 0)
        throw new Error("Parameters in function zeros must be positive integers");
    });
  }
}), AN = "fft", zge = ["typed", "matrix", "addScalar", "multiplyScalar", "divideScalar", "exp", "tau", "i", "dotDivide", "conj", "pow", "ceil", "log2"], Uge = /* @__PURE__ */ me(AN, zge, (e) => {
  var {
    typed: t,
    matrix: r,
    addScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    exp: o,
    tau: s,
    i: u,
    dotDivide: c,
    conj: l,
    pow: d,
    ceil: f,
    log2: m
  } = e;
  return t(AN, {
    Array: h,
    Matrix: function(_) {
      return _.create(h(_.toArray()));
    }
  });
  function h(y) {
    var _ = Sr(y);
    return _.length === 1 ? v(y, _[0]) : p(y.map((S) => h(S, _.slice(1))), 0);
  }
  function p(y, _) {
    var S = Sr(y);
    if (_ !== 0) return new Array(S[0]).fill(0).map((x, A) => p(y[A], _ - 1));
    if (S.length === 1) return v(y);
    function b(x) {
      var A = Sr(x);
      return new Array(A[1]).fill(0).map((w, C) => new Array(A[0]).fill(0).map((M, T) => x[T][C]));
    }
    return b(p(b(y), 1));
  }
  function g(y) {
    for (var _ = y.length, S = o(i(a(-1, a(u, s)), _)), b = [], x = 1 - _; x < _; x++)
      b.push(d(S, i(d(x, 2), 2)));
    for (var A = d(2, f(m(_ + _ - 1))), w = [...new Array(_).fill(0).map((F, R) => a(y[R], b[_ - 1 + R])), ...new Array(A - _).fill(0)], C = [...new Array(_ + _ - 1).fill(0).map((F, R) => i(1, b[R])), ...new Array(A - (_ + _ - 1)).fill(0)], M = v(w), T = v(C), N = new Array(A).fill(0).map((F, R) => a(M[R], T[R])), I = c(l(h(l(N))), A), P = [], O = _ - 1; O < _ + _ - 1; O++)
      P.push(a(I[O], b[O]));
    return P;
  }
  function v(y) {
    var _ = y.length;
    if (_ === 1) return [y[0]];
    if (_ % 2 === 0) {
      for (var S = [...v(y.filter((w, C) => C % 2 === 0)), ...v(y.filter((w, C) => C % 2 === 1))], b = 0; b < _ / 2; b++) {
        var x = S[b], A = a(S[b + _ / 2], o(a(a(s, u), i(-b, _))));
        S[b] = n(x, A), S[b + _ / 2] = n(x, a(-1, A));
      }
      return S;
    } else
      return g(y);
  }
}), wN = "ifft", Gge = ["typed", "fft", "dotDivide", "conj"], Vge = /* @__PURE__ */ me(wN, Gge, (e) => {
  var {
    typed: t,
    fft: r,
    dotDivide: n,
    conj: a
  } = e;
  return t(wN, {
    "Array | Matrix": function(o) {
      var s = Zt(o) ? o.size() : Sr(o);
      return n(a(r(a(o))), s.reduce((u, c) => u * c, 1));
    }
  });
});
function Th(e) {
  "@babel/helpers - typeof";
  return Th = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
    return typeof t;
  } : function(t) {
    return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
  }, Th(e);
}
function qge(e, t) {
  if (Th(e) != "object" || !e) return e;
  var r = e[Symbol.toPrimitive];
  if (r !== void 0) {
    var n = r.call(e, t || "default");
    if (Th(n) != "object") return n;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (t === "string" ? String : Number)(e);
}
function Hge(e) {
  var t = qge(e, "string");
  return Th(t) == "symbol" ? t : t + "";
}
function $a(e, t, r) {
  return (t = Hge(t)) in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e;
}
function CN(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function Kge(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? CN(Object(r), !0).forEach(function(n) {
      $a(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : CN(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
var Xge = "solveODE", jge = ["typed", "add", "subtract", "multiply", "divide", "max", "map", "abs", "isPositive", "isNegative", "larger", "smaller", "matrix", "bignumber", "unaryMinus"], Yge = /* @__PURE__ */ me(Xge, jge, (e) => {
  var {
    typed: t,
    add: r,
    subtract: n,
    multiply: a,
    divide: i,
    max: o,
    map: s,
    abs: u,
    isPositive: c,
    isNegative: l,
    larger: d,
    smaller: f,
    matrix: m,
    bignumber: h,
    unaryMinus: p
  } = e;
  function g(w) {
    return function(C, M, T, N) {
      var I = !(M.length === 2 && (M.every(x) || M.every(Lo)));
      if (I)
        throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');
      var P = M[0], O = M[1], F = d(O, P), R = N.firstStep;
      if (R !== void 0 && !c(R))
        throw new Error('"firstStep" must be positive');
      var G = N.maxStep;
      if (G !== void 0 && !c(G))
        throw new Error('"maxStep" must be positive');
      var L = N.minStep;
      if (L && l(L))
        throw new Error('"minStep" must be positive or zero');
      var q = [P, O, R, L, G].filter((J) => J !== void 0);
      if (!(q.every(x) || q.every(Lo)))
        throw new Error('Inconsistent type of "t" dependant variables');
      for (var K = 1, X = N.tol ? N.tol : 1e-4, H = N.minDelta ? N.minDelta : 0.2, W = N.maxDelta ? N.maxDelta : 5, ee = N.maxIter ? N.maxIter : 1e4, $ = [P, O, ...T, G, L].some(hr), [te, re, ie, oe] = $ ? [h(w.a), h(w.c), h(w.b), h(w.bp)] : [w.a, w.c, w.b, w.bp], se = R ? F ? R : p(R) : i(n(O, P), K), he = [P], ge = [T], De = n(ie, oe), ae = 0, ce = 0, _e = S(F), le = b(F); _e(he[ae], O); ) {
        var ue = [];
        se = le(he[ae], O, se), ue.push(C(he[ae], ge[ae]));
        for (var be = 1; be < re.length; ++be)
          ue.push(C(r(he[ae], a(re[be], se)), r(ge[ae], a(se, te[be], ue))));
        var Se = o(u(s(a(De, ue), (J) => Lo(J) ? J.value : J)));
        Se < X && X / Se > 1 / 4 && (he.push(r(he[ae], se)), ge.push(r(ge[ae], a(se, ie, ue))), ae++);
        var Ne = 0.84 * (X / Se) ** (1 / 5);
        if (f(Ne, H) ? Ne = H : d(Ne, W) && (Ne = W), Ne = $ ? h(Ne) : Ne, se = a(se, Ne), G && d(u(se), G) ? se = F ? G : p(G) : L && f(u(se), L) && (se = F ? L : p(L)), ce++, ce > ee)
          throw new Error("Maximum number of iterations reached, try changing options");
      }
      return {
        t: he,
        y: ge
      };
    };
  }
  function v(w, C, M, T) {
    var N = [[], [0.5], [0, 0.75], [0.2222222222222222, 0.3333333333333333, 0.4444444444444444]], I = [null, 1 / 2, 3 / 4, 1], P = [2 / 9, 1 / 3, 4 / 9, 0], O = [7 / 24, 1 / 4, 1 / 3, 1 / 8], F = {
      a: N,
      c: I,
      b: P,
      bp: O
    };
    return g(F)(w, C, M, T);
  }
  function y(w, C, M, T) {
    var N = [[], [0.2], [0.075, 0.225], [0.9777777777777777, -3.7333333333333334, 3.5555555555555554], [2.9525986892242035, -11.595793324188385, 9.822892851699436, -0.2908093278463649], [2.8462752525252526, -10.757575757575758, 8.906422717743473, 0.2784090909090909, -0.2735313036020583], [0.09114583333333333, 0, 0.44923629829290207, 0.6510416666666666, -0.322376179245283, 0.13095238095238096]], I = [null, 1 / 5, 3 / 10, 4 / 5, 8 / 9, 1, 1], P = [35 / 384, 0, 500 / 1113, 125 / 192, -2187 / 6784, 11 / 84, 0], O = [5179 / 57600, 0, 7571 / 16695, 393 / 640, -92097 / 339200, 187 / 2100, 1 / 40], F = {
      a: N,
      c: I,
      b: P,
      bp: O
    };
    return g(F)(w, C, M, T);
  }
  function _(w, C, M, T) {
    var N = T.method ? T.method : "RK45", I = {
      RK23: v,
      RK45: y
    };
    if (N.toUpperCase() in I) {
      var P = Kge({}, T);
      return delete P.method, I[N.toUpperCase()](w, C, M, P);
    } else {
      var O = Object.keys(I).map((R) => '"'.concat(R, '"')), F = "".concat(O.slice(0, -1).join(", "), " and ").concat(O.slice(-1));
      throw new Error('Unavailable method "'.concat(N, '". Available methods are ').concat(F));
    }
  }
  function S(w) {
    return w ? f : d;
  }
  function b(w) {
    var C = w ? d : f;
    return function(M, T, N) {
      var I = r(M, N);
      return C(I, T) ? n(T, M) : N;
    };
  }
  function x(w) {
    return hr(w) || _r(w);
  }
  function A(w, C, M, T) {
    var N = _(w, C.toArray(), M.toArray(), T);
    return {
      t: m(N.t),
      y: m(N.y)
    };
  }
  return t("solveODE", {
    "function, Array, Array, Object": _,
    "function, Matrix, Matrix, Object": A,
    "function, Array, Array": (w, C, M) => _(w, C, M, {}),
    "function, Matrix, Matrix": (w, C, M) => A(w, C, M, {}),
    "function, Array, number | BigNumber | Unit": (w, C, M) => {
      var T = _(w, C, [M], {});
      return {
        t: T.t,
        y: T.y.map((N) => N[0])
      };
    },
    "function, Matrix, number | BigNumber | Unit": (w, C, M) => {
      var T = _(w, C.toArray(), [M], {});
      return {
        t: m(T.t),
        y: m(T.y.map((N) => N[0]))
      };
    },
    "function, Array, number | BigNumber | Unit, Object": (w, C, M, T) => {
      var N = _(w, C, [M], T);
      return {
        t: N.t,
        y: N.y.map((I) => I[0])
      };
    },
    "function, Matrix, number | BigNumber | Unit, Object": (w, C, M, T) => {
      var N = _(w, C.toArray(), [M], T);
      return {
        t: m(N.t),
        y: m(N.y.map((I) => I[0]))
      };
    }
  });
}), Wge = "erf", Zge = ["typed"], Qge = /* @__PURE__ */ me(Wge, Zge, (e) => {
  var {
    typed: t
  } = e;
  return t("name", {
    number: function(o) {
      var s = Math.abs(o);
      return s >= e2e ? Nd(o) : s <= $ge ? Nd(o) * r(s) : s <= 4 ? Nd(o) * (1 - n(s)) : Nd(o) * (1 - a(s));
    },
    "Array | Matrix": t.referToSelf((i) => (o) => Tr(o, i))
    // TODO: For complex numbers, use the approximation for the Faddeeva function
    //  from "More Efficient Computation of the Complex Error Function" (AMS)
  });
  function r(i) {
    var o = i * i, s = Hc[0][4] * o, u = o, c;
    for (c = 0; c < 3; c += 1)
      s = (s + Hc[0][c]) * o, u = (u + pp[0][c]) * o;
    return i * (s + Hc[0][3]) / (u + pp[0][3]);
  }
  function n(i) {
    var o = Hc[1][8] * i, s = i, u;
    for (u = 0; u < 7; u += 1)
      o = (o + Hc[1][u]) * i, s = (s + pp[1][u]) * i;
    var c = (o + Hc[1][7]) / (s + pp[1][7]), l = parseInt(i * 16) / 16, d = (i - l) * (i + l);
    return Math.exp(-l * l) * Math.exp(-d) * c;
  }
  function a(i) {
    var o = 1 / (i * i), s = Hc[2][5] * o, u = o, c;
    for (c = 0; c < 4; c += 1)
      s = (s + Hc[2][c]) * o, u = (u + pp[2][c]) * o;
    var l = o * (s + Hc[2][4]) / (u + pp[2][4]);
    l = (Jge - l) / i, o = parseInt(i * 16) / 16;
    var d = (i - o) * (i + o);
    return Math.exp(-o * o) * Math.exp(-d) * l;
  }
}), $ge = 0.46875, Jge = 0.5641895835477563, Hc = [[3.1611237438705655, 113.86415415105016, 377.485237685302, 3209.3775891384694, 0.18577770618460315], [0.5641884969886701, 8.883149794388377, 66.11919063714163, 298.6351381974001, 881.952221241769, 1712.0476126340707, 2051.0783778260716, 1230.3393547979972, 21531153547440383e-24], [0.30532663496123236, 0.36034489994980445, 0.12578172611122926, 0.016083785148742275, 6587491615298378e-19, 0.016315387137302097]], pp = [[23.601290952344122, 244.02463793444417, 1282.6165260773723, 2844.236833439171], [15.744926110709835, 117.6939508913125, 537.1811018620099, 1621.3895745666903, 3290.7992357334597, 4362.619090143247, 3439.3676741437216, 1230.3393548037495], [2.568520192289822, 1.8729528499234604, 0.5279051029514285, 0.06051834131244132, 0.0023352049762686918]], e2e = Math.pow(2, 53), EN = "zeta", t2e = ["typed", "config", "multiply", "pow", "divide", "factorial", "equal", "smallerEq", "isNegative", "gamma", "sin", "subtract", "add", "?Complex", "?BigNumber", "pi"], r2e = /* @__PURE__ */ me(EN, t2e, (e) => {
  var {
    typed: t,
    config: r,
    multiply: n,
    pow: a,
    divide: i,
    factorial: o,
    equal: s,
    smallerEq: u,
    isNegative: c,
    gamma: l,
    sin: d,
    subtract: f,
    add: m,
    Complex: h,
    BigNumber: p,
    pi: g
  } = e;
  return t(EN, {
    number: (x) => v(x, (A) => A, () => 20),
    BigNumber: (x) => v(x, (A) => new p(A), () => Math.abs(Math.log10(r.relTol))),
    Complex: y
  });
  function v(x, A, w) {
    return s(x, 0) ? A(-0.5) : s(x, 1) ? A(NaN) : isFinite(x) ? _(x, A, w, (C) => C) : c(x) ? A(NaN) : A(1);
  }
  function y(x) {
    return x.re === 0 && x.im === 0 ? new h(-0.5) : x.re === 1 ? new h(NaN, NaN) : x.re === 1 / 0 && x.im === 0 ? new h(1) : x.im === 1 / 0 || x.re === -1 / 0 ? new h(NaN, NaN) : _(x, (A) => A, (A) => Math.round(1.3 * 15 + 0.9 * Math.abs(A.im)), (A) => A.re);
  }
  function _(x, A, w, C) {
    var M = w(x);
    if (C(x) > -(M - 1) / 2)
      return b(x, A(M), A);
    var T = n(a(2, x), a(A(g), f(x, 1)));
    return T = n(T, d(n(i(A(g), 2), x))), T = n(T, l(f(1, x))), n(T, _(f(1, x), A, w, C));
  }
  function S(x, A) {
    for (var w = x, C = x; u(C, A); C = m(C, 1)) {
      var M = i(n(o(m(A, f(C, 1))), a(4, C)), n(o(f(A, C)), o(n(2, C))));
      w = m(w, M);
    }
    return n(A, w);
  }
  function b(x, A, w) {
    for (var C = i(1, n(S(w(0), A), f(1, a(2, f(1, x))))), M = w(0), T = w(1); u(T, A); T = m(T, 1))
      M = m(M, i(n((-1) ** (T - 1), S(T, A)), a(T, x)));
    return n(C, M);
  }
}), DN = "mode", n2e = ["typed", "isNaN", "isNumeric"], a2e = /* @__PURE__ */ me(DN, n2e, (e) => {
  var {
    typed: t,
    isNaN: r,
    isNumeric: n
  } = e;
  return t(DN, {
    "Array | Matrix": a,
    "...": function(o) {
      return a(o);
    }
  });
  function a(i) {
    i = $r(i.valueOf());
    var o = i.length;
    if (o === 0)
      throw new Error("Cannot calculate mode of an empty array");
    for (var s = {}, u = [], c = 0, l = 0; l < i.length; l++) {
      var d = i[l];
      if (n(d) && r(d))
        throw new Error("Cannot calculate mode of an array containing NaN values");
      d in s || (s[d] = 0), s[d]++, s[d] === c ? u.push(d) : s[d] > c && (c = s[d], u = [d]);
    }
    return u;
  }
});
function So(e, t, r) {
  var n;
  return String(e).includes("Unexpected type") ? (n = arguments.length > 2 ? " (type: " + Nn(r) + ", value: " + JSON.stringify(r) + ")" : " (type: " + e.data.actual + ")", new TypeError("Cannot calculate " + t + ", unexpected type of argument" + n)) : String(e).includes("complex numbers") ? (n = arguments.length > 2 ? " (type: " + Nn(r) + ", value: " + JSON.stringify(r) + ")" : "", new TypeError("Cannot calculate " + t + ", no ordering relation is defined for complex numbers" + n)) : e;
}
var MN = "prod", i2e = ["typed", "config", "multiplyScalar", "numeric"], o2e = /* @__PURE__ */ me(MN, i2e, (e) => {
  var {
    typed: t,
    config: r,
    multiplyScalar: n,
    numeric: a
  } = e;
  return t(MN, {
    // prod([a, b, c, d, ...])
    "Array | Matrix": i,
    // prod([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(s, u) {
      throw new Error("prod(A, dim) is not yet supported");
    },
    // prod(a, b, c, d, ...)
    "...": function(s) {
      return i(s);
    }
  });
  function i(o) {
    var s;
    if (yl(o, function(u) {
      try {
        s = s === void 0 ? u : n(s, u);
      } catch (c) {
        throw So(c, "prod", u);
      }
    }), typeof s == "string" && (s = a(s, $d(s, r))), s === void 0)
      throw new Error("Cannot calculate prod of an empty array");
    return s;
  }
}), IN = "format", s2e = ["typed"], u2e = /* @__PURE__ */ me(IN, s2e, (e) => {
  var {
    typed: t
  } = e;
  return t(IN, {
    any: Br,
    "any, Object | function | number | BigNumber": Br
  });
}), TN = "bin", c2e = ["typed", "format"], l2e = me(TN, c2e, (e) => {
  var {
    typed: t,
    format: r
  } = e;
  return t(TN, {
    "number | BigNumber": function(a) {
      return r(a, {
        notation: "bin"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return r(a, {
        notation: "bin",
        wordSize: i
      });
    }
  });
}), NN = "oct", d2e = ["typed", "format"], f2e = me(NN, d2e, (e) => {
  var {
    typed: t,
    format: r
  } = e;
  return t(NN, {
    "number | BigNumber": function(a) {
      return r(a, {
        notation: "oct"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return r(a, {
        notation: "oct",
        wordSize: i
      });
    }
  });
}), PN = "hex", m2e = ["typed", "format"], p2e = me(PN, m2e, (e) => {
  var {
    typed: t,
    format: r
  } = e;
  return t(PN, {
    "number | BigNumber": function(a) {
      return r(a, {
        notation: "hex"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return r(a, {
        notation: "hex",
        wordSize: i
      });
    }
  });
}), BV = /\$([\w.]+)/g, BN = "print", h2e = ["typed"], OV = /* @__PURE__ */ me(BN, h2e, (e) => {
  var {
    typed: t
  } = e;
  return t(BN, {
    // note: Matrix will be converted automatically to an Array
    "string, Object | Array": ON,
    "string, Object | Array, number | Object": ON
  });
});
function ON(e, t, r) {
  return e.replace(BV, function(n, a) {
    var i = a.split("."), o = t[i.shift()];
    for (o !== void 0 && o.isMatrix && (o = o.toArray()); i.length && o !== void 0; ) {
      var s = i.shift();
      o = s ? o[s] : o + ".";
    }
    return o !== void 0 ? Di(o) ? o : Br(o, r) : n;
  });
}
var FN = "to", v2e = ["typed", "matrix", "concat"], g2e = /* @__PURE__ */ me(FN, v2e, (e) => {
  var {
    typed: t,
    matrix: r,
    concat: n
  } = e, a = Ln({
    typed: t,
    matrix: r,
    concat: n
  });
  return t(FN, {
    "Unit, Unit | string": (i, o) => i.to(o)
  }, a({
    Ds: !0
  }));
}), RN = "isPrime", y2e = ["typed"], b2e = /* @__PURE__ */ me(RN, y2e, (e) => {
  var {
    typed: t
  } = e;
  return t(RN, {
    number: function(n) {
      if (n <= 3)
        return n > 1;
      if (n % 2 === 0 || n % 3 === 0)
        return !1;
      for (var a = 5; a * a <= n; a += 6)
        if (n % a === 0 || n % (a + 2) === 0)
          return !1;
      return !0;
    },
    bigint: function(n) {
      if (n <= 3n)
        return n > 1n;
      if (n % 2n === 0n || n % 3n === 0n)
        return !1;
      for (var a = 5n; a * a <= n; a += 6n)
        if (n % a === 0n || n % (a + 2n) === 0n)
          return !1;
      return !0;
    },
    BigNumber: function(n) {
      if (n.lte(3)) return n.gt(1);
      if (n.mod(2).eq(0) || n.mod(3).eq(0)) return !1;
      if (n.lt(Math.pow(2, 32))) {
        for (var a = n.toNumber(), i = 5; i * i <= a; i += 6)
          if (a % i === 0 || a % (i + 2) === 0)
            return !1;
        return !0;
      }
      function o(y, _, S) {
        for (var b = 1; !_.eq(0); )
          _.mod(2).eq(0) ? (_ = _.div(2), y = y.mul(y).mod(S)) : (_ = _.sub(1), b = y.mul(b).mod(S));
        return b;
      }
      var s = n.constructor.clone({
        precision: n.toFixed(0).length * 2
      });
      n = new s(n);
      for (var u = 0, c = n.sub(1); c.mod(2).eq(0); )
        c = c.div(2), u += 1;
      var l = null;
      if (n.lt("3317044064679887385961981"))
        l = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41].filter((y) => y < n);
      else {
        var d = Math.min(n.toNumber() - 2, Math.floor(2 * Math.pow(n.toFixed(0).length * Math.log(10), 2)));
        l = [];
        for (var f = 2; f <= d; f += 1)
          l.push(d);
      }
      for (var m = 0; m < l.length; m += 1) {
        var h = l[m], p = o(n.sub(n).add(h), c, n);
        if (!p.eq(1)) {
          for (var g = 0, v = p; !v.eq(n.sub(1)); g += 1, v = v.mul(v).mod(n))
            if (g === u - 1)
              return !1;
        }
      }
      return !0;
    },
    "Array | Matrix": t.referToSelf((r) => (n) => Tr(n, r))
  });
}), x2e = "numeric", _2e = ["number", "?bignumber", "?fraction"], FV = /* @__PURE__ */ me(x2e, _2e, (e) => {
  var {
    number: t,
    bignumber: r,
    fraction: n
  } = e, a = {
    string: !0,
    number: !0,
    BigNumber: !0,
    Fraction: !0
  }, i = {
    number: (o) => t(o),
    BigNumber: r ? (o) => r(o) : LS,
    bigint: (o) => BigInt(o),
    Fraction: n ? (o) => n(o) : wV
  };
  return function(s) {
    var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "number", c = arguments.length > 2 ? arguments[2] : void 0;
    if (c !== void 0)
      throw new SyntaxError("numeric() takes one or two arguments");
    var l = Nn(s);
    if (!(l in a))
      throw new TypeError("Cannot convert " + s + ' of type "' + l + '"; valid input types are ' + Object.keys(a).join(", "));
    if (!(u in i))
      throw new TypeError("Cannot convert " + s + ' to type "' + u + '"; valid output types are ' + Object.keys(i).join(", "));
    return u === l ? s : i[u](s);
  };
}), LN = "divideScalar", S2e = ["typed", "numeric"], RV = /* @__PURE__ */ me(LN, S2e, (e) => {
  var {
    typed: t,
    numeric: r
  } = e;
  return t(LN, {
    "number, number": function(a, i) {
      return a / i;
    },
    "Complex, Complex": function(a, i) {
      return a.div(i);
    },
    "BigNumber, BigNumber": function(a, i) {
      return a.div(i);
    },
    "bigint, bigint": function(a, i) {
      return a / i;
    },
    "Fraction, Fraction": function(a, i) {
      return a.div(i);
    },
    "Unit, number | Complex | Fraction | BigNumber | Unit": (n, a) => n.divide(a),
    "number | Fraction | Complex | BigNumber, Unit": (n, a) => a.divideInto(n)
  });
}), kN = "pow", A2e = ["typed", "config", "identity", "multiply", "matrix", "inv", "fraction", "number", "Complex"], LV = /* @__PURE__ */ me(kN, A2e, (e) => {
  var {
    typed: t,
    config: r,
    identity: n,
    multiply: a,
    matrix: i,
    inv: o,
    number: s,
    fraction: u,
    Complex: c
  } = e;
  return t(kN, {
    "number, number": l,
    "Complex, Complex": function(h, p) {
      return h.pow(p);
    },
    "BigNumber, BigNumber": function(h, p) {
      return p.isInteger() || h >= 0 || r.predictable ? h.pow(p) : new c(h.toNumber(), 0).pow(p.toNumber(), 0);
    },
    "bigint, bigint": (m, h) => m ** h,
    "Fraction, Fraction": function(h, p) {
      var g = h.pow(p);
      if (g != null)
        return g;
      if (r.predictable)
        throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");
      return l(h.valueOf(), p.valueOf());
    },
    "Array, number": d,
    "Array, BigNumber": function(h, p) {
      return d(h, p.toNumber());
    },
    "Matrix, number": f,
    "Matrix, BigNumber": function(h, p) {
      return f(h, p.toNumber());
    },
    "Unit, number | BigNumber": function(h, p) {
      return h.pow(p);
    }
  });
  function l(m, h) {
    if (r.predictable && !Ut(h) && m < 0)
      try {
        var p = u(h), g = s(p);
        if ((h === g || Math.abs((h - g) / h) < 1e-14) && p.d % 2 === 1)
          return (p.n % 2 === 0 ? 1 : -1) * Math.pow(-m, h);
      } catch {
      }
    return r.predictable && (m < -1 && h === 1 / 0 || m > -1 && m < 0 && h === -1 / 0) ? NaN : Ut(h) || m >= 0 || r.predictable ? pG(m, h) : m * m < 1 && h === 1 / 0 || m * m > 1 && h === -1 / 0 ? 0 : new c(m, 0).pow(h, 0);
  }
  function d(m, h) {
    if (!Ut(h))
      throw new TypeError("For A^b, b must be an integer (value is " + h + ")");
    var p = Sr(m);
    if (p.length !== 2)
      throw new Error("For A^b, A must be 2 dimensional (A has " + p.length + " dimensions)");
    if (p[0] !== p[1])
      throw new Error("For A^b, A must be square (size is " + p[0] + "x" + p[1] + ")");
    if (h < 0)
      try {
        return d(o(m), -h);
      } catch (y) {
        throw y.message === "Cannot calculate inverse, determinant is zero" ? new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is " + h + ")") : y;
      }
    for (var g = n(p[0]).valueOf(), v = m; h >= 1; )
      (h & 1) === 1 && (g = a(v, g)), h >>= 1, v = a(v, v);
    return g;
  }
  function f(m, h) {
    return i(d(m.valueOf(), h));
  }
}), hp = "Number of decimals in function round must be an integer", zN = "round", w2e = ["typed", "config", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix"], kV = /* @__PURE__ */ me(zN, w2e, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    equalScalar: a,
    zeros: i,
    BigNumber: o,
    DenseMatrix: s
  } = e, u = Ri({
    typed: t,
    equalScalar: a
  }), c = ti({
    typed: t,
    DenseMatrix: s
  }), l = Fu({
    typed: t
  });
  function d(f) {
    return Math.abs(Xh(f).exponent);
  }
  return t(zN, {
    number: function(m) {
      var h = S0(m, d(r.relTol)), p = Fi(m, h, r.relTol, r.absTol) ? h : m;
      return S0(p);
    },
    "number, number": function(m, h) {
      var p = d(r.relTol);
      if (h >= p)
        return S0(m, h);
      var g = S0(m, p), v = Fi(m, g, r.relTol, r.absTol) ? g : m;
      return S0(v, h);
    },
    "number, BigNumber": function(m, h) {
      if (!h.isInteger())
        throw new TypeError(hp);
      return new o(m).toDecimalPlaces(h.toNumber());
    },
    Complex: function(m) {
      return m.round();
    },
    "Complex, number": function(m, h) {
      if (h % 1)
        throw new TypeError(hp);
      return m.round(h);
    },
    "Complex, BigNumber": function(m, h) {
      if (!h.isInteger())
        throw new TypeError(hp);
      var p = h.toNumber();
      return m.round(p);
    },
    BigNumber: function(m) {
      var h = new o(m).toDecimalPlaces(d(r.relTol)), p = Xo(m, h, r.relTol, r.absTol) ? h : m;
      return p.toDecimalPlaces(0);
    },
    "BigNumber, BigNumber": function(m, h) {
      if (!h.isInteger())
        throw new TypeError(hp);
      var p = d(r.relTol);
      if (h >= p)
        return m.toDecimalPlaces(h.toNumber());
      var g = m.toDecimalPlaces(p), v = Xo(m, g, r.relTol, r.absTol) ? g : m;
      return v.toDecimalPlaces(h.toNumber());
    },
    Fraction: function(m) {
      return m.round();
    },
    "Fraction, number": function(m, h) {
      if (h % 1)
        throw new TypeError(hp);
      return m.round(h);
    },
    "Fraction, BigNumber": function(m, h) {
      if (!h.isInteger())
        throw new TypeError(hp);
      return m.round(h.toNumber());
    },
    "Unit, number, Unit": t.referToSelf((f) => function(m, h, p) {
      var g = m.toNumeric(p);
      return p.multiply(f(g, h));
    }),
    "Unit, BigNumber, Unit": t.referToSelf((f) => (m, h, p) => f(m, h.toNumber(), p)),
    "Unit, Unit": t.referToSelf((f) => (m, h) => f(m, 0, h)),
    "Array | Matrix, number, Unit": t.referToSelf((f) => (m, h, p) => Tr(m, (g) => f(g, h, p))),
    "Array | Matrix, BigNumber, Unit": t.referToSelf((f) => (m, h, p) => f(m, h.toNumber(), p)),
    "Array | Matrix, Unit": t.referToSelf((f) => (m, h) => f(m, 0, h)),
    "Array | Matrix": t.referToSelf((f) => (m) => Tr(m, f)),
    "SparseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => u(m, h, f, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((f) => (m, h) => l(m, h, f, !1)),
    "Array, number | BigNumber": t.referToSelf((f) => (m, h) => l(n(m), h, f, !1).valueOf()),
    "number | Complex | BigNumber | Fraction, SparseMatrix": t.referToSelf((f) => (m, h) => a(m, 0) ? i(h.size(), h.storage()) : c(h, m, f, !0)),
    "number | Complex | BigNumber | Fraction, DenseMatrix": t.referToSelf((f) => (m, h) => a(m, 0) ? i(h.size(), h.storage()) : l(h, m, f, !0)),
    "number | Complex | BigNumber | Fraction, Array": t.referToSelf((f) => (m, h) => l(n(h), m, f, !0).valueOf())
  });
}), UN = "log", C2e = ["config", "typed", "divideScalar", "Complex"], E2e = /* @__PURE__ */ me(UN, C2e, (e) => {
  var {
    typed: t,
    config: r,
    divideScalar: n,
    Complex: a
  } = e;
  return t(UN, {
    number: function(o) {
      return o >= 0 || r.predictable ? i0e(o) : new a(o, 0).log();
    },
    Complex: function(o) {
      return o.log();
    },
    BigNumber: function(o) {
      return !o.isNegative() || r.predictable ? o.ln() : new a(o.toNumber(), 0).log();
    },
    "any, any": t.referToSelf((i) => (o, s) => n(i(o), i(s)))
  });
}), GN = "log1p", D2e = ["typed", "config", "divideScalar", "log", "Complex"], M2e = /* @__PURE__ */ me(GN, D2e, (e) => {
  var {
    typed: t,
    config: r,
    divideScalar: n,
    log: a,
    Complex: i
  } = e;
  return t(GN, {
    number: function(u) {
      return u >= -1 || r.predictable ? upe(u) : o(new i(u, 0));
    },
    Complex: o,
    BigNumber: function(u) {
      var c = u.plus(1);
      return !c.isNegative() || r.predictable ? c.ln() : o(new i(u.toNumber(), 0));
    },
    "Array | Matrix": t.referToSelf((s) => (u) => Tr(u, s)),
    "any, any": t.referToSelf((s) => (u, c) => n(s(u), a(c)))
  });
  function o(s) {
    var u = s.re + 1;
    return new i(Math.log(Math.sqrt(u * u + s.im * s.im)), Math.atan2(s.im, u));
  }
}), VN = "nthRoots", I2e = ["config", "typed", "divideScalar", "Complex"], T2e = /* @__PURE__ */ me(VN, I2e, (e) => {
  var {
    typed: t,
    config: r,
    divideScalar: n,
    Complex: a
  } = e, i = [function(u) {
    return new a(u, 0);
  }, function(u) {
    return new a(0, u);
  }, function(u) {
    return new a(-u, 0);
  }, function(u) {
    return new a(0, -u);
  }];
  function o(s, u) {
    if (u < 0) throw new Error("Root must be greater than zero");
    if (u === 0) throw new Error("Root must be non-zero");
    if (u % 1 !== 0) throw new Error("Root must be an integer");
    if (s === 0 || s.abs() === 0) return [new a(0, 0)];
    var c = typeof s == "number", l;
    (c || s.re === 0 || s.im === 0) && (c ? l = 2 * +(s < 0) : s.im === 0 ? l = 2 * +(s.re < 0) : l = 2 * +(s.im < 0) + 1);
    for (var d = s.arg(), f = s.abs(), m = [], h = Math.pow(f, 1 / u), p = 0; p < u; p++) {
      var g = (l + 4 * p) / u;
      if (g === Math.round(g)) {
        m.push(i[g % 4](h));
        continue;
      }
      m.push(new a({
        r: h,
        phi: (d + 2 * Math.PI * p) / u
      }));
    }
    return m;
  }
  return t(VN, {
    Complex: function(u) {
      return o(u, 2);
    },
    "Complex, number": o
  });
}), qN = "dotPow", N2e = ["typed", "equalScalar", "matrix", "pow", "DenseMatrix", "concat"], P2e = /* @__PURE__ */ me(qN, N2e, (e) => {
  var {
    typed: t,
    equalScalar: r,
    matrix: n,
    pow: a,
    DenseMatrix: i,
    concat: o
  } = e, s = Ao({
    typed: t
  }), u = gc({
    typed: t,
    DenseMatrix: i
  }), c = Ri({
    typed: t,
    equalScalar: r
  }), l = ti({
    typed: t,
    DenseMatrix: i
  }), d = Ln({
    typed: t,
    matrix: n,
    concat: o
  }), f = {};
  for (var m in a.signatures)
    Object.prototype.hasOwnProperty.call(a.signatures, m) && !m.includes("Matrix") && !m.includes("Array") && (f[m] = a.signatures[m]);
  var h = t(f);
  return t(qN, d({
    elop: h,
    SS: u,
    DS: s,
    Ss: c,
    sS: l
  }));
}), HN = "dotDivide", B2e = ["typed", "matrix", "equalScalar", "divideScalar", "DenseMatrix", "concat"], O2e = /* @__PURE__ */ me(HN, B2e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    divideScalar: a,
    DenseMatrix: i,
    concat: o
  } = e, s = Ru({
    typed: t,
    equalScalar: n
  }), u = Ao({
    typed: t
  }), c = gc({
    typed: t,
    DenseMatrix: i
  }), l = Ri({
    typed: t,
    equalScalar: n
  }), d = ti({
    typed: t,
    DenseMatrix: i
  }), f = Ln({
    typed: t,
    matrix: r,
    concat: o
  });
  return t(HN, f({
    elop: a,
    SS: c,
    DS: u,
    SD: s,
    Ss: l,
    sS: d
  }));
});
function Wh(e) {
  var {
    DenseMatrix: t
  } = e;
  return function(n, a, i) {
    var o = n.size();
    if (o.length !== 2)
      throw new RangeError("Matrix must be two dimensional (size: " + Br(o) + ")");
    var s = o[0], u = o[1];
    if (s !== u)
      throw new RangeError("Matrix must be square (size: " + Br(o) + ")");
    var c = [];
    if (Zt(a)) {
      var l = a.size(), d = a._data;
      if (l.length === 1) {
        if (l[0] !== s)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var f = 0; f < s; f++)
          c[f] = [d[f]];
        return new t({
          data: c,
          size: [s, 1],
          datatype: a._datatype
        });
      }
      if (l.length === 2) {
        if (l[0] !== s || l[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        if (Ch(a)) {
          if (i) {
            c = [];
            for (var m = 0; m < s; m++)
              c[m] = [d[m][0]];
            return new t({
              data: c,
              size: [s, 1],
              datatype: a._datatype
            });
          }
          return a;
        }
        if (Td(a)) {
          for (var h = 0; h < s; h++)
            c[h] = [0];
          for (var p = a._values, g = a._index, v = a._ptr, y = v[1], _ = v[0]; _ < y; _++) {
            var S = g[_];
            c[S][0] = p[_];
          }
          return new t({
            data: c,
            size: [s, 1],
            datatype: a._datatype
          });
        }
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
    if (en(a)) {
      var b = Sr(a);
      if (b.length === 1) {
        if (b[0] !== s)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var x = 0; x < s; x++)
          c[x] = [a[x]];
        return new t({
          data: c,
          size: [s, 1]
        });
      }
      if (b.length === 2) {
        if (b[0] !== s || b[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var A = 0; A < s; A++)
          c[A] = [a[A][0]];
        return new t({
          data: c,
          size: [s, 1]
        });
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
  };
}
var KN = "lsolve", F2e = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], R2e = /* @__PURE__ */ me(KN, F2e, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: s
  } = e, u = Wh({
    DenseMatrix: s
  });
  return t(KN, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var h = r(f), p = c(h, m);
      return p.valueOf();
    }
  });
  function c(d, f) {
    f = u(d, f, !0);
    for (var m = f._data, h = d._size[0], p = d._size[1], g = [], v = d._data, y = 0; y < p; y++) {
      var _ = m[y][0] || 0, S = void 0;
      if (o(_, 0))
        S = 0;
      else {
        var b = v[y][y];
        if (o(b, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        S = n(_, b);
        for (var x = y + 1; x < h; x++)
          m[x] = [i(m[x][0] || 0, a(S, v[x][y]))];
      }
      g[y] = [S];
    }
    return new s({
      data: g,
      size: [h, 1]
    });
  }
  function l(d, f) {
    f = u(d, f, !0);
    for (var m = f._data, h = d._size[0], p = d._size[1], g = d._values, v = d._index, y = d._ptr, _ = [], S = 0; S < p; S++) {
      var b = m[S][0] || 0;
      if (o(b, 0))
        _[S] = [0];
      else {
        for (var x = 0, A = [], w = [], C = y[S], M = y[S + 1], T = C; T < M; T++) {
          var N = v[T];
          N === S ? x = g[T] : N > S && (A.push(g[T]), w.push(N));
        }
        if (o(x, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var I = n(b, x), P = 0, O = w.length; P < O; P++) {
          var F = w[P];
          m[F] = [i(m[F][0] || 0, a(I, A[P]))];
        }
        _[S] = [I];
      }
    }
    return new s({
      data: _,
      size: [h, 1]
    });
  }
}), XN = "usolve", L2e = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], zV = /* @__PURE__ */ me(XN, L2e, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: s
  } = e, u = Wh({
    DenseMatrix: s
  });
  return t(XN, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var h = r(f), p = c(h, m);
      return p.valueOf();
    }
  });
  function c(d, f) {
    f = u(d, f, !0);
    for (var m = f._data, h = d._size[0], p = d._size[1], g = [], v = d._data, y = p - 1; y >= 0; y--) {
      var _ = m[y][0] || 0, S = void 0;
      if (o(_, 0))
        S = 0;
      else {
        var b = v[y][y];
        if (o(b, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        S = n(_, b);
        for (var x = y - 1; x >= 0; x--)
          m[x] = [i(m[x][0] || 0, a(S, v[x][y]))];
      }
      g[y] = [S];
    }
    return new s({
      data: g,
      size: [h, 1]
    });
  }
  function l(d, f) {
    f = u(d, f, !0);
    for (var m = f._data, h = d._size[0], p = d._size[1], g = d._values, v = d._index, y = d._ptr, _ = [], S = p - 1; S >= 0; S--) {
      var b = m[S][0] || 0;
      if (o(b, 0))
        _[S] = [0];
      else {
        for (var x = 0, A = [], w = [], C = y[S], M = y[S + 1], T = M - 1; T >= C; T--) {
          var N = v[T];
          N === S ? x = g[T] : N < S && (A.push(g[T]), w.push(N));
        }
        if (o(x, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var I = n(b, x), P = 0, O = w.length; P < O; P++) {
          var F = w[P];
          m[F] = [i(m[F][0], a(I, A[P]))];
        }
        _[S] = [I];
      }
    }
    return new s({
      data: _,
      size: [h, 1]
    });
  }
}), jN = "lsolveAll", k2e = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], z2e = /* @__PURE__ */ me(jN, k2e, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: s
  } = e, u = Wh({
    DenseMatrix: s
  });
  return t(jN, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var h = r(f), p = c(h, m);
      return p.map((g) => g.valueOf());
    }
  });
  function c(d, f) {
    for (var m = [u(d, f, !0)._data.map((w) => w[0])], h = d._data, p = d._size[0], g = d._size[1], v = 0; v < g; v++)
      for (var y = m.length, _ = 0; _ < y; _++) {
        var S = m[_];
        if (o(h[v][v], 0))
          if (o(S[v], 0)) {
            if (_ === 0) {
              var x = [...S];
              x[v] = 1;
              for (var A = v + 1; A < g; A++)
                x[A] = i(x[A], h[A][v]);
              m.push(x);
            }
          } else {
            if (_ === 0)
              return [];
            m.splice(_, 1), _ -= 1, y -= 1;
          }
        else {
          S[v] = n(S[v], h[v][v]);
          for (var b = v + 1; b < g; b++)
            S[b] = i(S[b], a(S[v], h[b][v]));
        }
      }
    return m.map((w) => new s({
      data: w.map((C) => [C]),
      size: [p, 1]
    }));
  }
  function l(d, f) {
    for (var m = [u(d, f, !0)._data.map((K) => K[0])], h = d._size[0], p = d._size[1], g = d._values, v = d._index, y = d._ptr, _ = 0; _ < p; _++)
      for (var S = m.length, b = 0; b < S; b++) {
        for (var x = m[b], A = [], w = [], C = y[_], M = y[_ + 1], T = 0, N = C; N < M; N++) {
          var I = v[N];
          I === _ ? T = g[N] : I > _ && (A.push(g[N]), w.push(I));
        }
        if (o(T, 0))
          if (o(x[_], 0)) {
            if (b === 0) {
              var R = [...x];
              R[_] = 1;
              for (var G = 0, L = w.length; G < L; G++) {
                var q = w[G];
                R[q] = i(R[q], A[G]);
              }
              m.push(R);
            }
          } else {
            if (b === 0)
              return [];
            m.splice(b, 1), b -= 1, S -= 1;
          }
        else {
          x[_] = n(x[_], T);
          for (var P = 0, O = w.length; P < O; P++) {
            var F = w[P];
            x[F] = i(x[F], a(x[_], A[P]));
          }
        }
      }
    return m.map((K) => new s({
      data: K.map((X) => [X]),
      size: [h, 1]
    }));
  }
}), YN = "usolveAll", U2e = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], UV = /* @__PURE__ */ me(YN, U2e, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: s
  } = e, u = Wh({
    DenseMatrix: s
  });
  return t(YN, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var h = r(f), p = c(h, m);
      return p.map((g) => g.valueOf());
    }
  });
  function c(d, f) {
    for (var m = [u(d, f, !0)._data.map((w) => w[0])], h = d._data, p = d._size[0], g = d._size[1], v = g - 1; v >= 0; v--)
      for (var y = m.length, _ = 0; _ < y; _++) {
        var S = m[_];
        if (o(h[v][v], 0))
          if (o(S[v], 0)) {
            if (_ === 0) {
              var x = [...S];
              x[v] = 1;
              for (var A = v - 1; A >= 0; A--)
                x[A] = i(x[A], h[A][v]);
              m.push(x);
            }
          } else {
            if (_ === 0)
              return [];
            m.splice(_, 1), _ -= 1, y -= 1;
          }
        else {
          S[v] = n(S[v], h[v][v]);
          for (var b = v - 1; b >= 0; b--)
            S[b] = i(S[b], a(S[v], h[b][v]));
        }
      }
    return m.map((w) => new s({
      data: w.map((C) => [C]),
      size: [p, 1]
    }));
  }
  function l(d, f) {
    for (var m = [u(d, f, !0)._data.map((K) => K[0])], h = d._size[0], p = d._size[1], g = d._values, v = d._index, y = d._ptr, _ = p - 1; _ >= 0; _--)
      for (var S = m.length, b = 0; b < S; b++) {
        for (var x = m[b], A = [], w = [], C = y[_], M = y[_ + 1], T = 0, N = M - 1; N >= C; N--) {
          var I = v[N];
          I === _ ? T = g[N] : I < _ && (A.push(g[N]), w.push(I));
        }
        if (o(T, 0))
          if (o(x[_], 0)) {
            if (b === 0) {
              var R = [...x];
              R[_] = 1;
              for (var G = 0, L = w.length; G < L; G++) {
                var q = w[G];
                R[q] = i(R[q], A[G]);
              }
              m.push(R);
            }
          } else {
            if (b === 0)
              return [];
            m.splice(b, 1), b -= 1, S -= 1;
          }
        else {
          x[_] = n(x[_], T);
          for (var P = 0, O = w.length; P < O; P++) {
            var F = w[P];
            x[F] = i(x[F], a(x[_], A[P]));
          }
        }
      }
    return m.map((K) => new s({
      data: K.map((X) => [X]),
      size: [h, 1]
    }));
  }
}), G2e = "matAlgo08xS0Sid", V2e = ["typed", "equalScalar"], zS = /* @__PURE__ */ me(G2e, V2e, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(a, i, o) {
    var s = a._values, u = a._index, c = a._ptr, l = a._size, d = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), f = i._values, m = i._index, h = i._ptr, p = i._size, g = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== p.length)
      throw new Ir(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    if (!s || !f)
      throw new Error("Cannot perform operation on Pattern Sparse Matrices");
    var v = l[0], y = l[1], _, S = r, b = 0, x = o;
    typeof d == "string" && d === g && d !== "mixed" && (_ = d, S = t.find(r, [_, _]), b = t.convert(0, _), x = t.find(o, [_, _]));
    for (var A = [], w = [], C = [], M = [], T = [], N, I, P, O, F = 0; F < y; F++) {
      C[F] = w.length;
      var R = F + 1;
      for (I = c[F], P = c[F + 1], N = I; N < P; N++)
        O = u[N], T[O] = R, M[O] = s[N], w.push(O);
      for (I = h[F], P = h[F + 1], N = I; N < P; N++)
        O = m[N], T[O] === R && (M[O] = x(M[O], f[N]));
      for (N = C[F]; N < w.length; ) {
        O = w[N];
        var G = M[O];
        S(G, b) ? w.splice(N, 1) : (A.push(G), N++);
      }
    }
    return C[y] = w.length, a.createSparseMatrix({
      values: A,
      index: w,
      ptr: C,
      size: [v, y],
      datatype: d === a._datatype && g === i._datatype ? _ : void 0
    });
  };
}), US = /* @__PURE__ */ me("useMatrixForArrayScalar", ["typed", "matrix"], (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return {
    "Array, number": t.referTo("DenseMatrix, number", (n) => (a, i) => n(r(a), i).valueOf()),
    "Array, BigNumber": t.referTo("DenseMatrix, BigNumber", (n) => (a, i) => n(r(a), i).valueOf()),
    "number, Array": t.referTo("number, DenseMatrix", (n) => (a, i) => n(a, r(i)).valueOf()),
    "BigNumber, Array": t.referTo("BigNumber, DenseMatrix", (n) => (a, i) => n(a, r(i)).valueOf())
  };
}), WN = "leftShift", q2e = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], H2e = /* @__PURE__ */ me(WN, q2e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, s = ef({
    typed: t
  }), u = Ru({
    typed: t,
    equalScalar: n
  }), c = zS({
    typed: t,
    equalScalar: n
  }), l = ym({
    typed: t,
    DenseMatrix: i
  }), d = Ri({
    typed: t,
    equalScalar: n
  }), f = Fu({
    typed: t
  }), m = Ln({
    typed: t,
    matrix: r,
    concat: o
  }), h = US({
    typed: t,
    matrix: r
  });
  return t(WN, {
    "number, number": bG,
    "BigNumber, BigNumber": Ive,
    "bigint, bigint": (p, g) => p << g,
    "SparseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : d(g, v, p, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : f(g, v, p, !1)),
    "number | BigNumber, SparseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : l(v, g, p, !0)),
    "number | BigNumber, DenseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : f(v, g, p, !0))
  }, h, m({
    SS: c,
    DS: s,
    SD: u
  }));
}), ZN = "rightArithShift", K2e = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], X2e = /* @__PURE__ */ me(ZN, K2e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, s = ef({
    typed: t
  }), u = Ru({
    typed: t,
    equalScalar: n
  }), c = zS({
    typed: t,
    equalScalar: n
  }), l = ym({
    typed: t,
    DenseMatrix: i
  }), d = Ri({
    typed: t,
    equalScalar: n
  }), f = Fu({
    typed: t
  }), m = Ln({
    typed: t,
    matrix: r,
    concat: o
  }), h = US({
    typed: t,
    matrix: r
  });
  return t(ZN, {
    "number, number": xG,
    "BigNumber, BigNumber": Tve,
    "bigint, bigint": (p, g) => p >> g,
    "SparseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : d(g, v, p, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : f(g, v, p, !1)),
    "number | BigNumber, SparseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : l(v, g, p, !0)),
    "number | BigNumber, DenseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : f(v, g, p, !0))
  }, h, m({
    SS: c,
    DS: s,
    SD: u
  }));
}), QN = "rightLogShift", j2e = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], Y2e = /* @__PURE__ */ me(QN, j2e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, s = ef({
    typed: t
  }), u = Ru({
    typed: t,
    equalScalar: n
  }), c = zS({
    typed: t,
    equalScalar: n
  }), l = ym({
    typed: t,
    DenseMatrix: i
  }), d = Ri({
    typed: t,
    equalScalar: n
  }), f = Fu({
    typed: t
  }), m = Ln({
    typed: t,
    matrix: r,
    concat: o
  }), h = US({
    typed: t,
    matrix: r
  });
  return t(QN, {
    "number, number": _G,
    // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift
    "SparseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : d(g, v, p, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((p) => (g, v) => n(v, 0) ? g.clone() : f(g, v, p, !1)),
    "number | BigNumber, SparseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : l(v, g, p, !0)),
    "number | BigNumber, DenseMatrix": t.referToSelf((p) => (g, v) => n(g, 0) ? a(v.size(), v.storage()) : f(v, g, p, !0))
  }, h, m({
    SS: c,
    DS: s,
    SD: u
  }));
}), $N = "and", W2e = ["typed", "matrix", "equalScalar", "zeros", "not", "concat"], GV = /* @__PURE__ */ me($N, W2e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, s = Ru({
    typed: t,
    equalScalar: n
  }), u = X3({
    typed: t,
    equalScalar: n
  }), c = Ri({
    typed: t,
    equalScalar: n
  }), l = Fu({
    typed: t
  }), d = Ln({
    typed: t,
    matrix: r,
    concat: o
  });
  return t($N, {
    "number, number": $_,
    "Complex, Complex": function(m, h) {
      return (m.re !== 0 || m.im !== 0) && (h.re !== 0 || h.im !== 0);
    },
    "BigNumber, BigNumber": function(m, h) {
      return !m.isZero() && !h.isZero() && !m.isNaN() && !h.isNaN();
    },
    "bigint, bigint": $_,
    "Unit, Unit": t.referToSelf((f) => (m, h) => f(m.value || 0, h.value || 0)),
    "SparseMatrix, any": t.referToSelf((f) => (m, h) => i(h) ? a(m.size(), m.storage()) : c(m, h, f, !1)),
    "DenseMatrix, any": t.referToSelf((f) => (m, h) => i(h) ? a(m.size(), m.storage()) : l(m, h, f, !1)),
    "any, SparseMatrix": t.referToSelf((f) => (m, h) => i(m) ? a(m.size(), m.storage()) : c(h, m, f, !0)),
    "any, DenseMatrix": t.referToSelf((f) => (m, h) => i(m) ? a(m.size(), m.storage()) : l(h, m, f, !0)),
    "Array, any": t.referToSelf((f) => (m, h) => f(r(m), h).valueOf()),
    "any, Array": t.referToSelf((f) => (m, h) => f(m, r(h)).valueOf())
  }, d({
    SS: u,
    DS: s
  }));
}), jy = "compare", Z2e = ["typed", "config", "matrix", "equalScalar", "BigNumber", "Fraction", "DenseMatrix", "concat"], Q2e = /* @__PURE__ */ me(jy, Z2e, (e) => {
  var {
    typed: t,
    config: r,
    equalScalar: n,
    matrix: a,
    BigNumber: i,
    Fraction: o,
    DenseMatrix: s,
    concat: u
  } = e, c = Ao({
    typed: t
  }), l = K3({
    typed: t,
    equalScalar: n
  }), d = ti({
    typed: t,
    DenseMatrix: s
  }), f = Ln({
    typed: t,
    matrix: a,
    concat: u
  }), m = w1({
    typed: t
  });
  return t(jy, $2e({
    typed: t,
    config: r
  }), {
    "boolean, boolean": function(p, g) {
      return p === g ? 0 : p > g ? 1 : -1;
    },
    "BigNumber, BigNumber": function(p, g) {
      return Xo(p, g, r.relTol, r.absTol) ? new i(0) : new i(p.cmp(g));
    },
    "bigint, bigint": function(p, g) {
      return p === g ? 0n : p > g ? 1n : -1n;
    },
    "Fraction, Fraction": function(p, g) {
      return new o(p.compare(g));
    },
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, m, f({
    SS: l,
    DS: c,
    Ss: d
  }));
}), $2e = /* @__PURE__ */ me(jy, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(jy, {
    "number, number": function(a, i) {
      return Fi(a, i, r.relTol, r.absTol) ? 0 : a > i ? 1 : -1;
    }
  });
}), J2e = function e(t, r) {
  var n = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, a = /(^[ ]*|[ ]*$)/g, i = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, o = /^0x[0-9a-f]+$/i, s = /^0/, u = function(_) {
    return e.insensitive && ("" + _).toLowerCase() || "" + _;
  }, c = u(t).replace(a, "") || "", l = u(r).replace(a, "") || "", d = c.replace(n, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), f = l.replace(n, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), m = parseInt(c.match(o), 16) || d.length !== 1 && c.match(i) && Date.parse(c), h = parseInt(l.match(o), 16) || m && l.match(i) && Date.parse(l) || null, p, g;
  if (h) {
    if (m < h)
      return -1;
    if (m > h)
      return 1;
  }
  for (var v = 0, y = Math.max(d.length, f.length); v < y; v++) {
    if (p = !(d[v] || "").match(s) && parseFloat(d[v]) || d[v] || 0, g = !(f[v] || "").match(s) && parseFloat(f[v]) || f[v] || 0, isNaN(p) !== isNaN(g))
      return isNaN(p) ? 1 : -1;
    if (typeof p != typeof g && (p += "", g += ""), p < g)
      return -1;
    if (p > g)
      return 1;
  }
  return 0;
};
const vp = /* @__PURE__ */ jh(J2e);
var JN = "compareNatural", eye = ["typed", "compare"], tye = /* @__PURE__ */ me(JN, eye, (e) => {
  var {
    typed: t,
    compare: r
  } = e, n = r.signatures["boolean,boolean"];
  return t(JN, {
    "any, any": a
  });
  function a(u, c) {
    var l = Nn(u), d = Nn(c), f;
    if ((l === "number" || l === "BigNumber" || l === "Fraction") && (d === "number" || d === "BigNumber" || d === "Fraction"))
      return f = r(u, c), f.toString() !== "0" ? f > 0 ? 1 : -1 : vp(l, d);
    var m = ["Array", "DenseMatrix", "SparseMatrix"];
    if (m.includes(l) || m.includes(d))
      return f = i(a, u, c), f !== 0 ? f : vp(l, d);
    if (l !== d)
      return vp(l, d);
    if (l === "Complex")
      return rye(u, c);
    if (l === "Unit")
      return u.equalBase(c) ? a(u.value, c.value) : o(a, u.formatUnits(), c.formatUnits());
    if (l === "boolean")
      return n(u, c);
    if (l === "string")
      return vp(u, c);
    if (l === "Object")
      return s(a, u, c);
    if (l === "null" || l === "undefined")
      return 0;
    throw new TypeError('Unsupported type of value "' + l + '"');
  }
  function i(u, c, l) {
    return Td(c) && Td(l) ? o(u, c.toJSON().values, l.toJSON().values) : Td(c) ? i(u, c.toArray(), l) : Td(l) ? i(u, c, l.toArray()) : Ch(c) ? i(u, c.toJSON().data, l) : Ch(l) ? i(u, c, l.toJSON().data) : Array.isArray(c) ? Array.isArray(l) ? o(u, c, l) : i(u, c, [l]) : i(u, [c], l);
  }
  function o(u, c, l) {
    for (var d = 0, f = Math.min(c.length, l.length); d < f; d++) {
      var m = u(c[d], l[d]);
      if (m !== 0)
        return m;
    }
    return c.length > l.length ? 1 : c.length < l.length ? -1 : 0;
  }
  function s(u, c, l) {
    var d = Object.keys(c), f = Object.keys(l);
    d.sort(vp), f.sort(vp);
    var m = o(u, d, f);
    if (m !== 0)
      return m;
    for (var h = 0; h < d.length; h++) {
      var p = u(c[d[h]], l[f[h]]);
      if (p !== 0)
        return p;
    }
    return 0;
  }
});
function rye(e, t) {
  return e.re > t.re ? 1 : e.re < t.re ? -1 : e.im > t.im ? 1 : e.im < t.im ? -1 : 0;
}
var eP = "compareText", nye = ["typed", "matrix", "concat"];
X_.signature = "any, any";
var aye = /* @__PURE__ */ me(eP, nye, (e) => {
  var {
    typed: t,
    matrix: r,
    concat: n
  } = e, a = Ln({
    typed: t,
    matrix: r,
    concat: n
  });
  return t(eP, X_, a({
    elop: X_,
    Ds: !0
  }));
}), Yy = "equal", iye = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], VV = /* @__PURE__ */ me(Yy, iye, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = gc({
    typed: t,
    DenseMatrix: a
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: r,
    concat: i
  });
  return t(Yy, oye({
    typed: t,
    equalScalar: n
  }), c({
    elop: n,
    SS: s,
    DS: o,
    Ss: u
  }));
}), oye = me(Yy, ["typed", "equalScalar"], (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return t(Yy, {
    "any, any": function(a, i) {
      return a === null ? i === null : i === null ? a === null : a === void 0 ? i === void 0 : i === void 0 ? a === void 0 : r(a, i);
    }
  });
}), tP = "equalText", sye = ["typed", "compareText", "isZero"], uye = /* @__PURE__ */ me(tP, sye, (e) => {
  var {
    typed: t,
    compareText: r,
    isZero: n
  } = e;
  return t(tP, {
    "any, any": function(i, o) {
      return n(r(i, o));
    }
  });
}), Wy = "smaller", cye = ["typed", "config", "matrix", "DenseMatrix", "concat"], qV = /* @__PURE__ */ me(Wy, cye, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = gc({
    typed: t,
    DenseMatrix: a
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: n,
    concat: i
  }), l = w1({
    typed: t
  });
  return t(Wy, lye({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d < f,
    "BigNumber, BigNumber": function(f, m) {
      return f.lt(m) && !Xo(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d < f,
    "Fraction, Fraction": (d, f) => d.compare(f) === -1,
    "Complex, Complex": function(f, m) {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), lye = /* @__PURE__ */ me(Wy, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(Wy, {
    "number, number": function(a, i) {
      return a < i && !Fi(a, i, r.relTol, r.absTol);
    }
  });
}), Zy = "smallerEq", dye = ["typed", "config", "matrix", "DenseMatrix", "concat"], HV = /* @__PURE__ */ me(Zy, dye, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = gc({
    typed: t,
    DenseMatrix: a
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: n,
    concat: i
  }), l = w1({
    typed: t
  });
  return t(Zy, fye({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d <= f,
    "BigNumber, BigNumber": function(f, m) {
      return f.lte(m) || Xo(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d <= f,
    "Fraction, Fraction": (d, f) => d.compare(f) !== 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), fye = /* @__PURE__ */ me(Zy, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(Zy, {
    "number, number": function(a, i) {
      return a <= i || Fi(a, i, r.relTol, r.absTol);
    }
  });
}), Qy = "larger", mye = ["typed", "config", "matrix", "DenseMatrix", "concat"], KV = /* @__PURE__ */ me(Qy, mye, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = gc({
    typed: t,
    DenseMatrix: a
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: n,
    concat: i
  }), l = w1({
    typed: t
  });
  return t(Qy, pye({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d > f,
    "BigNumber, BigNumber": function(f, m) {
      return f.gt(m) && !Xo(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d > f,
    "Fraction, Fraction": (d, f) => d.compare(f) === 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), pye = /* @__PURE__ */ me(Qy, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(Qy, {
    "number, number": function(a, i) {
      return a > i && !Fi(a, i, r.relTol, r.absTol);
    }
  });
}), $y = "largerEq", hye = ["typed", "config", "matrix", "DenseMatrix", "concat"], XV = /* @__PURE__ */ me($y, hye, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Ao({
    typed: t
  }), s = gc({
    typed: t,
    DenseMatrix: a
  }), u = ti({
    typed: t,
    DenseMatrix: a
  }), c = Ln({
    typed: t,
    matrix: n,
    concat: i
  }), l = w1({
    typed: t
  });
  return t($y, vye({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d >= f,
    "BigNumber, BigNumber": function(f, m) {
      return f.gte(m) || Xo(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": function(f, m) {
      return f >= m;
    },
    "Fraction, Fraction": (d, f) => d.compare(f) !== -1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), vye = /* @__PURE__ */ me($y, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t($y, {
    "number, number": function(a, i) {
      return a >= i || Fi(a, i, r.relTol, r.absTol);
    }
  });
}), rP = "deepEqual", gye = ["typed", "equal"], yye = /* @__PURE__ */ me(rP, gye, (e) => {
  var {
    typed: t,
    equal: r
  } = e;
  return t(rP, {
    "any, any": function(i, o) {
      return n(i.valueOf(), o.valueOf());
    }
  });
  function n(a, i) {
    if (Array.isArray(a))
      if (Array.isArray(i)) {
        var o = a.length;
        if (o !== i.length)
          return !1;
        for (var s = 0; s < o; s++)
          if (!n(a[s], i[s]))
            return !1;
        return !0;
      } else
        return !1;
    else
      return Array.isArray(i) ? !1 : r(a, i);
  }
}), Jy = "unequal", bye = ["typed", "config", "equalScalar", "matrix", "DenseMatrix", "concat"], xye = /* @__PURE__ */ me(Jy, bye, (e) => {
  var {
    typed: t,
    config: r,
    equalScalar: n,
    matrix: a,
    DenseMatrix: i,
    concat: o
  } = e, s = Ao({
    typed: t
  }), u = gc({
    typed: t,
    DenseMatrix: i
  }), c = ti({
    typed: t,
    DenseMatrix: i
  }), l = Ln({
    typed: t,
    matrix: a,
    concat: o
  });
  return t(Jy, _ye({
    typed: t,
    equalScalar: n
  }), l({
    elop: d,
    SS: u,
    DS: s,
    Ss: c
  }));
  function d(f, m) {
    return !n(f, m);
  }
}), _ye = me(Jy, ["typed", "equalScalar"], (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return t(Jy, {
    "any, any": function(a, i) {
      return a === null ? i !== null : i === null ? a !== null : a === void 0 ? i !== void 0 : i === void 0 ? a !== void 0 : !r(a, i);
    }
  });
}), nP = "partitionSelect", Sye = ["typed", "isNumeric", "isNaN", "compare"], Aye = /* @__PURE__ */ me(nP, Sye, (e) => {
  var {
    typed: t,
    isNumeric: r,
    isNaN: n,
    compare: a
  } = e, i = a, o = (c, l) => -a(c, l);
  return t(nP, {
    "Array | Matrix, number": function(l, d) {
      return s(l, d, i);
    },
    "Array | Matrix, number, string": function(l, d, f) {
      if (f === "asc")
        return s(l, d, i);
      if (f === "desc")
        return s(l, d, o);
      throw new Error('Compare string must be "asc" or "desc"');
    },
    "Array | Matrix, number, function": s
  });
  function s(c, l, d) {
    if (!Ut(l) || l < 0)
      throw new Error("k must be a non-negative integer");
    if (Zt(c)) {
      var f = c.size();
      if (f.length > 1)
        throw new Error("Only one dimensional matrices supported");
      return u(c.valueOf(), l, d);
    }
    if (Array.isArray(c))
      return u(c, l, d);
  }
  function u(c, l, d) {
    if (l >= c.length)
      throw new Error("k out of bounds");
    for (var f = 0; f < c.length; f++)
      if (r(c[f]) && n(c[f]))
        return c[f];
    for (var m = 0, h = c.length - 1; m < h; ) {
      for (var p = m, g = h, v = c[Math.floor(Math.random() * (h - m + 1)) + m]; p < g; )
        if (d(c[p], v) >= 0) {
          var y = c[g];
          c[g] = c[p], c[p] = y, --g;
        } else
          ++p;
      d(c[p], v) > 0 && --p, l <= p ? h = p : m = p + 1;
    }
    return c[l];
  }
}), aP = "sort", wye = ["typed", "matrix", "compare", "compareNatural"], Cye = /* @__PURE__ */ me(aP, wye, (e) => {
  var {
    typed: t,
    matrix: r,
    compare: n,
    compareNatural: a
  } = e, i = n, o = (l, d) => -n(l, d);
  return t(aP, {
    Array: function(d) {
      return u(d), d.sort(i);
    },
    Matrix: function(d) {
      return c(d), r(d.toArray().sort(i), d.storage());
    },
    "Array, function": function(d, f) {
      return u(d), d.sort(f);
    },
    "Matrix, function": function(d, f) {
      return c(d), r(d.toArray().sort(f), d.storage());
    },
    "Array, string": function(d, f) {
      return u(d), d.sort(s(f));
    },
    "Matrix, string": function(d, f) {
      return c(d), r(d.toArray().sort(s(f)), d.storage());
    }
  });
  function s(l) {
    if (l === "asc")
      return i;
    if (l === "desc")
      return o;
    if (l === "natural")
      return a;
    throw new Error('String "asc", "desc", or "natural" expected');
  }
  function u(l) {
    if (Sr(l).length !== 1)
      throw new Error("One dimensional array expected");
  }
  function c(l) {
    if (l.size().length !== 1)
      throw new Error("One dimensional matrix expected");
  }
}), iP = "max", Eye = ["typed", "config", "numeric", "larger"], jV = /* @__PURE__ */ me(iP, Eye, (e) => {
  var {
    typed: t,
    config: r,
    numeric: n,
    larger: a
  } = e;
  return t(iP, {
    // max([a, b, c, d, ...])
    "Array | Matrix": o,
    // max([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(u, c) {
      return H3(u, c.valueOf(), i);
    },
    // max(a, b, c, d, ...)
    "...": function(u) {
      if (_1(u))
        throw new TypeError("Scalar values expected in function max");
      return o(u);
    }
  });
  function i(s, u) {
    try {
      return a(s, u) ? s : u;
    } catch (c) {
      throw So(c, "max", u);
    }
  }
  function o(s) {
    var u;
    if (yl(s, function(c) {
      try {
        isNaN(c) && typeof c == "number" ? u = NaN : (u === void 0 || a(c, u)) && (u = c);
      } catch (l) {
        throw So(l, "max", c);
      }
    }), u === void 0)
      throw new Error("Cannot calculate max of an empty array");
    return typeof u == "string" && (u = n(u, $d(u, r))), u;
  }
}), oP = "min", Dye = ["typed", "config", "numeric", "smaller"], YV = /* @__PURE__ */ me(oP, Dye, (e) => {
  var {
    typed: t,
    config: r,
    numeric: n,
    smaller: a
  } = e;
  return t(oP, {
    // min([a, b, c, d, ...])
    "Array | Matrix": o,
    // min([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(u, c) {
      return H3(u, c.valueOf(), i);
    },
    // min(a, b, c, d, ...)
    "...": function(u) {
      if (_1(u))
        throw new TypeError("Scalar values expected in function min");
      return o(u);
    }
  });
  function i(s, u) {
    try {
      return a(s, u) ? s : u;
    } catch (c) {
      throw So(c, "min", u);
    }
  }
  function o(s) {
    var u;
    if (yl(s, function(c) {
      try {
        isNaN(c) && typeof c == "number" ? u = NaN : (u === void 0 || a(c, u)) && (u = c);
      } catch (l) {
        throw So(l, "min", c);
      }
    }), u === void 0)
      throw new Error("Cannot calculate min of an empty array");
    return typeof u == "string" && (u = n(u, $d(u, r))), u;
  }
}), Mye = "ImmutableDenseMatrix", Iye = ["smaller", "DenseMatrix"], WV = /* @__PURE__ */ me(Mye, Iye, (e) => {
  var {
    smaller: t,
    DenseMatrix: r
  } = e;
  function n(a, i) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (i && !Di(i))
      throw new Error("Invalid datatype: " + i);
    if (Zt(a) || en(a)) {
      var o = new r(a, i);
      this._data = o._data, this._size = o._size, this._datatype = o._datatype, this._min = null, this._max = null;
    } else if (a && en(a.data) && en(a.size))
      this._data = a.data, this._size = a.size, this._datatype = a.datatype, this._min = typeof a.min < "u" ? a.min : null, this._max = typeof a.max < "u" ? a.max : null;
    else {
      if (a)
        throw new TypeError("Unsupported type of data (" + Nn(a) + ")");
      this._data = [], this._size = [0], this._datatype = i, this._min = null, this._max = null;
    }
  }
  return n.prototype = new r(), n.prototype.type = "ImmutableDenseMatrix", n.prototype.isImmutableDenseMatrix = !0, n.prototype.subset = function(a) {
    switch (arguments.length) {
      case 1: {
        var i = r.prototype.subset.call(this, a);
        return Zt(i) ? new n({
          data: i._data,
          size: i._size,
          datatype: i._datatype
        }) : i;
      }
      case 2:
      case 3:
        throw new Error("Cannot invoke set subset on an Immutable Matrix instance");
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, n.prototype.set = function() {
    throw new Error("Cannot invoke set on an Immutable Matrix instance");
  }, n.prototype.resize = function() {
    throw new Error("Cannot invoke resize on an Immutable Matrix instance");
  }, n.prototype.reshape = function() {
    throw new Error("Cannot invoke reshape on an Immutable Matrix instance");
  }, n.prototype.clone = function() {
    return new n({
      data: Jt(this._data),
      size: Jt(this._size),
      datatype: this._datatype
    });
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "ImmutableDenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, n.fromJSON = function(a) {
    return new n(a);
  }, n.prototype.swapRows = function() {
    throw new Error("Cannot invoke swapRows on an Immutable Matrix instance");
  }, n.prototype.min = function() {
    if (this._min === null) {
      var a = null;
      this.forEach(function(i) {
        (a === null || t(i, a)) && (a = i);
      }), this._min = a !== null ? a : void 0;
    }
    return this._min;
  }, n.prototype.max = function() {
    if (this._max === null) {
      var a = null;
      this.forEach(function(i) {
        (a === null || t(a, i)) && (a = i);
      }), this._max = a !== null ? a : void 0;
    }
    return this._max;
  }, n;
}, {
  isClass: !0
}), Tye = "Index", Nye = ["ImmutableDenseMatrix", "getMatrixDataType"], ZV = /* @__PURE__ */ me(Tye, Nye, (e) => {
  var {
    ImmutableDenseMatrix: t,
    getMatrixDataType: r
  } = e;
  function n(i) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._dimensions = [], this._sourceSize = [], this._isScalar = !0;
    for (var o = 0, s = arguments.length; o < s; o++) {
      var u = arguments[o], c = en(u), l = Zt(u), d = null;
      if (L3(u))
        this._dimensions.push(u), this._isScalar = !1;
      else if (c || l) {
        var f = void 0;
        r(u) === "boolean" ? (c && (f = a(sP(u).valueOf())), l && (f = a(sP(u._data).valueOf())), d = u.valueOf().length) : f = a(u.valueOf()), this._dimensions.push(f);
        var m = f.size();
        (m.length !== 1 || m[0] !== 1 || d !== null) && (this._isScalar = !1);
      } else if (typeof u == "number")
        this._dimensions.push(a([u]));
      else if (typeof u == "string")
        this._dimensions.push(u);
      else
        throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
      this._sourceSize.push(d);
    }
  }
  n.prototype.type = "Index", n.prototype.isIndex = !0;
  function a(i) {
    for (var o = 0, s = i.length; o < s; o++)
      if (typeof i[o] != "number" || !Ut(i[o]))
        throw new TypeError("Index parameters must be positive integer numbers");
    return new t(i);
  }
  return n.prototype.clone = function() {
    var i = new n();
    return i._dimensions = Jt(this._dimensions), i._isScalar = this._isScalar, i._sourceSize = this._sourceSize, i;
  }, n.create = function(i) {
    var o = new n();
    return n.apply(o, i), o;
  }, n.prototype.size = function() {
    for (var i = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      i[o] = typeof u == "string" ? 1 : u.size()[0];
    }
    return i;
  }, n.prototype.max = function() {
    for (var i = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      i[o] = typeof u == "string" ? u : u.max();
    }
    return i;
  }, n.prototype.min = function() {
    for (var i = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      i[o] = typeof u == "string" ? u : u.min();
    }
    return i;
  }, n.prototype.forEach = function(i) {
    for (var o = 0, s = this._dimensions.length; o < s; o++)
      i(this._dimensions[o], o, this);
  }, n.prototype.dimension = function(i) {
    return this._dimensions[i] || null;
  }, n.prototype.isObjectProperty = function() {
    return this._dimensions.length === 1 && typeof this._dimensions[0] == "string";
  }, n.prototype.getObjectProperty = function() {
    return this.isObjectProperty() ? this._dimensions[0] : null;
  }, n.prototype.isScalar = function() {
    return this._isScalar;
  }, n.prototype.toArray = function() {
    for (var i = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      i.push(typeof u == "string" ? u : u.toArray());
    }
    return i;
  }, n.prototype.valueOf = n.prototype.toArray, n.prototype.toString = function() {
    for (var i = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      typeof u == "string" ? i.push(JSON.stringify(u)) : i.push(u.toString());
    }
    return "[" + i.join(", ") + "]";
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "Index",
      dimensions: this._dimensions
    };
  }, n.fromJSON = function(i) {
    return n.create(i.dimensions);
  }, n;
}, {
  isClass: !0
});
function sP(e) {
  var t = [];
  return e.forEach((r, n) => {
    r && t.push(n);
  }), t;
}
var Pye = "FibonacciHeap", Bye = ["smaller", "larger"], Oye = /* @__PURE__ */ me(Pye, Bye, (e) => {
  var {
    smaller: t,
    larger: r
  } = e, n = 1 / Math.log((1 + Math.sqrt(5)) / 2);
  function a() {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._minimum = null, this._size = 0;
  }
  a.prototype.type = "FibonacciHeap", a.prototype.isFibonacciHeap = !0, a.prototype.insert = function(l, d) {
    var f = {
      key: l,
      value: d,
      degree: 0
    };
    if (this._minimum) {
      var m = this._minimum;
      f.left = m, f.right = m.right, m.right = f, f.right.left = f, t(l, m.key) && (this._minimum = f);
    } else
      f.left = f, f.right = f, this._minimum = f;
    return this._size++, f;
  }, a.prototype.size = function() {
    return this._size;
  }, a.prototype.clear = function() {
    this._minimum = null, this._size = 0;
  }, a.prototype.isEmpty = function() {
    return this._size === 0;
  }, a.prototype.extractMinimum = function() {
    var l = this._minimum;
    if (l === null)
      return l;
    for (var d = this._minimum, f = l.degree, m = l.child; f > 0; ) {
      var h = m.right;
      m.left.right = m.right, m.right.left = m.left, m.left = d, m.right = d.right, d.right = m, m.right.left = m, m.parent = null, m = h, f--;
    }
    return l.left.right = l.right, l.right.left = l.left, l === l.right ? d = null : (d = l.right, d = c(d, this._size)), this._size--, this._minimum = d, l;
  }, a.prototype.remove = function(l) {
    this._minimum = i(this._minimum, l, -1), this.extractMinimum();
  };
  function i(l, d, f) {
    d.key = f;
    var m = d.parent;
    return m && t(d.key, m.key) && (o(l, d, m), s(l, m)), t(d.key, l.key) && (l = d), l;
  }
  function o(l, d, f) {
    d.left.right = d.right, d.right.left = d.left, f.degree--, f.child === d && (f.child = d.right), f.degree === 0 && (f.child = null), d.left = l, d.right = l.right, l.right = d, d.right.left = d, d.parent = null, d.mark = !1;
  }
  function s(l, d) {
    var f = d.parent;
    f && (d.mark ? (o(l, d, f), s(f)) : d.mark = !0);
  }
  var u = function(d, f) {
    d.left.right = d.right, d.right.left = d.left, d.parent = f, f.child ? (d.left = f.child, d.right = f.child.right, f.child.right = d, d.right.left = d) : (f.child = d, d.right = d, d.left = d), f.degree++, d.mark = !1;
  };
  function c(l, d) {
    var f = Math.floor(Math.log(d) * n) + 1, m = new Array(f), h = 0, p = l;
    if (p)
      for (h++, p = p.right; p !== l; )
        h++, p = p.right;
    for (var g; h > 0; ) {
      for (var v = p.degree, y = p.right; g = m[v], !!g; ) {
        if (r(p.key, g.key)) {
          var _ = g;
          g = p, p = _;
        }
        u(g, p), m[v] = null, v++;
      }
      m[v] = p, p = y, h--;
    }
    l = null;
    for (var S = 0; S < f; S++)
      g = m[S], g && (l ? (g.left.right = g.right, g.right.left = g.left, g.left = l, g.right = l.right, l.right = g, g.right.left = g, t(g.key, l.key) && (l = g)) : l = g);
    return l;
  }
  return a;
}, {
  isClass: !0
}), Fye = "Spa", Rye = ["addScalar", "equalScalar", "FibonacciHeap"], Lye = /* @__PURE__ */ me(Fye, Rye, (e) => {
  var {
    addScalar: t,
    equalScalar: r,
    FibonacciHeap: n
  } = e;
  function a() {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._values = [], this._heap = new n();
  }
  return a.prototype.type = "Spa", a.prototype.isSpa = !0, a.prototype.set = function(i, o) {
    if (this._values[i])
      this._values[i].value = o;
    else {
      var s = this._heap.insert(i, o);
      this._values[i] = s;
    }
  }, a.prototype.get = function(i) {
    var o = this._values[i];
    return o ? o.value : 0;
  }, a.prototype.accumulate = function(i, o) {
    var s = this._values[i];
    s ? s.value = t(s.value, o) : (s = this._heap.insert(i, o), this._values[i] = s);
  }, a.prototype.forEach = function(i, o, s) {
    var u = this._heap, c = this._values, l = [], d = u.extractMinimum();
    for (d && l.push(d); d && d.key <= o; )
      d.key >= i && (r(d.value, 0) || s(d.key, d.value, this)), d = u.extractMinimum(), d && l.push(d);
    for (var f = 0; f < l.length; f++) {
      var m = l[f];
      d = u.insert(m.key, m.value), c[d.key] = d;
    }
  }, a.prototype.swap = function(i, o) {
    var s = this._values[i], u = this._values[o];
    if (!s && u)
      s = this._heap.insert(i, u.value), this._heap.remove(u), this._values[i] = s, this._values[o] = void 0;
    else if (s && !u)
      u = this._heap.insert(o, s.value), this._heap.remove(s), this._values[o] = u, this._values[i] = void 0;
    else if (s && u) {
      var c = s.value;
      s.value = u.value, u.value = c;
    }
  }, a;
}, {
  isClass: !0
}), kye = Yh(function(e) {
  return new e(1).exp();
}, {
  hasher: j3
}), zye = Yh(function(e) {
  return new e(1).plus(new e(5).sqrt()).div(2);
}, {
  hasher: j3
}), GS = Yh(function(e) {
  return e.acos(-1);
}, {
  hasher: j3
}), Uye = Yh(function(e) {
  return GS(e).times(2);
}, {
  hasher: j3
});
function j3(e) {
  return e[0].precision;
}
function uP(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function L5(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? uP(Object(r), !0).forEach(function(n) {
      $a(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : uP(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
var Gye = "Unit", Vye = ["?on", "config", "addScalar", "subtractScalar", "multiplyScalar", "divideScalar", "pow", "abs", "fix", "round", "equal", "isNumeric", "format", "number", "Complex", "BigNumber", "Fraction"], qye = /* @__PURE__ */ me(Gye, Vye, (e) => {
  var {
    on: t,
    config: r,
    addScalar: n,
    subtractScalar: a,
    multiplyScalar: i,
    divideScalar: o,
    pow: s,
    abs: u,
    fix: c,
    round: l,
    equal: d,
    isNumeric: f,
    format: m,
    number: h,
    Complex: p,
    BigNumber: g,
    Fraction: v
  } = e, y = h;
  function _(ae, ce) {
    if (!(this instanceof _))
      throw new Error("Constructor must be called with the new operator");
    if (!(ae == null || f(ae) || Mu(ae)))
      throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");
    if (this.fixPrefix = !1, this.skipAutomaticSimplification = !0, ce === void 0)
      this.units = [], this.dimensions = G.map((le) => 0);
    else if (typeof ce == "string") {
      var _e = _.parse(ce);
      this.units = _e.units, this.dimensions = _e.dimensions;
    } else if (Lo(ce) && ce.value === null)
      this.fixPrefix = ce.fixPrefix, this.skipAutomaticSimplification = ce.skipAutomaticSimplification, this.dimensions = ce.dimensions.slice(0), this.units = ce.units.map((le) => Ei({}, le));
    else
      throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");
    this.value = this._normalize(ae);
  }
  Object.defineProperty(_, "name", {
    value: "Unit"
  }), _.prototype.constructor = _, _.prototype.type = "Unit", _.prototype.isUnit = !0;
  var S, b, x;
  function A() {
    for (; x === " " || x === "	"; )
      M();
  }
  function w(ae) {
    return ae >= "0" && ae <= "9" || ae === ".";
  }
  function C(ae) {
    return ae >= "0" && ae <= "9";
  }
  function M() {
    b++, x = S.charAt(b);
  }
  function T(ae) {
    b = ae, x = S.charAt(b);
  }
  function N() {
    var ae = "", ce = b;
    if (x === "+" ? M() : x === "-" && (ae += x, M()), !w(x))
      return T(ce), null;
    if (x === ".") {
      if (ae += x, M(), !C(x))
        return T(ce), null;
    } else {
      for (; C(x); )
        ae += x, M();
      x === "." && (ae += x, M());
    }
    for (; C(x); )
      ae += x, M();
    if (x === "E" || x === "e") {
      var _e = "", le = b;
      if (_e += x, M(), (x === "+" || x === "-") && (_e += x, M()), !C(x))
        return T(le), ae;
      for (ae = ae + _e; C(x); )
        ae += x, M();
    }
    return ae;
  }
  function I() {
    for (var ae = ""; C(x) || _.isValidAlpha(x); )
      ae += x, M();
    var ce = ae.charAt(0);
    return _.isValidAlpha(ce) ? ae : null;
  }
  function P(ae) {
    return x === ae ? (M(), ae) : null;
  }
  _.parse = function(ae, ce) {
    if (ce = ce || {}, S = ae, b = -1, x = "", typeof S != "string")
      throw new TypeError("Invalid argument in Unit.parse, string expected");
    var _e = new _();
    _e.units = [];
    var le = 1, ue = !1;
    M(), A();
    var be = N(), Se = null;
    if (be) {
      if (r.number === "BigNumber")
        Se = new g(be);
      else if (r.number === "Fraction")
        try {
          Se = new v(be);
        } catch {
          Se = parseFloat(be);
        }
      else
        Se = parseFloat(be);
      A(), P("*") ? (le = 1, ue = !0) : P("/") && (le = -1, ue = !0);
    }
    for (var Ne = [], J = 1; ; ) {
      for (A(); x === "("; )
        Ne.push(le), J *= le, le = 1, M(), A();
      var Z = void 0;
      if (x) {
        var de = x;
        if (Z = I(), Z === null)
          throw new SyntaxError('Unexpected "' + de + '" in "' + S + '" at index ' + b.toString());
      } else
        break;
      var ye = O(Z);
      if (ye === null)
        throw new SyntaxError('Unit "' + Z + '" not found.');
      var Ae = le * J;
      if (A(), P("^")) {
        A();
        var Ce = N();
        if (Ce === null)
          throw new SyntaxError('In "' + ae + '", "^" must be followed by a floating-point number');
        Ae *= Ce;
      }
      _e.units.push({
        unit: ye.unit,
        prefix: ye.prefix,
        power: Ae
      });
      for (var Ie = 0; Ie < G.length; Ie++)
        _e.dimensions[Ie] += (ye.unit.dimensions[Ie] || 0) * Ae;
      for (A(); x === ")"; ) {
        if (Ne.length === 0)
          throw new SyntaxError('Unmatched ")" in "' + S + '" at index ' + b.toString());
        J /= Ne.pop(), M(), A();
      }
      if (ue = !1, P("*") ? (le = 1, ue = !0) : P("/") ? (le = -1, ue = !0) : le = 1, ye.unit.base) {
        var Ue = ye.unit.base.key;
        $.auto[Ue] = {
          unit: ye.unit,
          prefix: ye.prefix
        };
      }
    }
    if (A(), x)
      throw new SyntaxError('Could not parse: "' + ae + '"');
    if (ue)
      throw new SyntaxError('Trailing characters: "' + ae + '"');
    if (Ne.length !== 0)
      throw new SyntaxError('Unmatched "(" in "' + S + '"');
    if (_e.units.length === 0 && !ce.allowNoUnits)
      throw new SyntaxError('"' + ae + '" contains no units');
    return _e.value = Se !== void 0 ? _e._normalize(Se) : null, _e;
  }, _.prototype.clone = function() {
    var ae = new _();
    ae.fixPrefix = this.fixPrefix, ae.skipAutomaticSimplification = this.skipAutomaticSimplification, ae.value = Jt(this.value), ae.dimensions = this.dimensions.slice(0), ae.units = [];
    for (var ce = 0; ce < this.units.length; ce++) {
      ae.units[ce] = {};
      for (var _e in this.units[ce])
        Tt(this.units[ce], _e) && (ae.units[ce][_e] = this.units[ce][_e]);
    }
    return ae;
  }, _.prototype.valueType = function() {
    return Nn(this.value);
  }, _.prototype._isDerived = function() {
    return this.units.length === 0 ? !1 : this.units.length > 1 || Math.abs(this.units[0].power - 1) > 1e-15;
  }, _.prototype._normalize = function(ae) {
    if (ae == null || this.units.length === 0)
      return ae;
    for (var ce = ae, _e = _._getNumberConverter(Nn(ae)), le = 0; le < this.units.length; le++) {
      var ue = _e(this.units[le].unit.value), be = _e(this.units[le].prefix.value), Se = _e(this.units[le].power);
      ce = i(ce, s(i(ue, be), Se));
    }
    return ce;
  }, _.prototype._denormalize = function(ae, ce) {
    if (ae == null || this.units.length === 0)
      return ae;
    for (var _e = ae, le = _._getNumberConverter(Nn(ae)), ue = 0; ue < this.units.length; ue++) {
      var be = le(this.units[ue].unit.value), Se = le(this.units[ue].prefix.value), Ne = le(this.units[ue].power);
      _e = o(_e, s(i(be, Se), Ne));
    }
    return _e;
  };
  var O = Yh((ae) => {
    if (Tt(H, ae)) {
      var ce = H[ae], _e = ce.prefixes[""];
      return {
        unit: ce,
        prefix: _e
      };
    }
    for (var le in H)
      if (Tt(H, le) && j1e(ae, le)) {
        var ue = H[le], be = ae.length - le.length, Se = ae.substring(0, be), Ne = Tt(ue.prefixes, Se) ? ue.prefixes[Se] : void 0;
        if (Ne !== void 0)
          return {
            unit: ue,
            prefix: Ne
          };
      }
    return null;
  }, {
    hasher: (ae) => ae[0],
    limit: 100
  });
  _.isValuelessUnit = function(ae) {
    return O(ae) !== null;
  }, _.prototype.hasBase = function(ae) {
    if (typeof ae == "string" && (ae = L[ae]), !ae)
      return !1;
    for (var ce = 0; ce < G.length; ce++)
      if (Math.abs((this.dimensions[ce] || 0) - (ae.dimensions[ce] || 0)) > 1e-12)
        return !1;
    return !0;
  }, _.prototype.equalBase = function(ae) {
    for (var ce = 0; ce < G.length; ce++)
      if (Math.abs((this.dimensions[ce] || 0) - (ae.dimensions[ce] || 0)) > 1e-12)
        return !1;
    return !0;
  }, _.prototype.equals = function(ae) {
    return this.equalBase(ae) && d(this.value, ae.value);
  }, _.prototype.multiply = function(ae) {
    for (var ce = this.clone(), _e = Lo(ae) ? ae : new _(ae), le = 0; le < G.length; le++)
      ce.dimensions[le] = (this.dimensions[le] || 0) + (_e.dimensions[le] || 0);
    for (var ue = 0; ue < _e.units.length; ue++) {
      var be = L5({}, _e.units[ue]);
      ce.units.push(be);
    }
    if (this.value !== null || _e.value !== null) {
      var Se = this.value === null ? this._normalize(1) : this.value, Ne = _e.value === null ? _e._normalize(1) : _e.value;
      ce.value = i(Se, Ne);
    } else
      ce.value = null;
    return Lo(ae) && (ce.skipAutomaticSimplification = !1), F(ce);
  }, _.prototype.divideInto = function(ae) {
    return new _(ae).divide(this);
  }, _.prototype.divide = function(ae) {
    for (var ce = this.clone(), _e = Lo(ae) ? ae : new _(ae), le = 0; le < G.length; le++)
      ce.dimensions[le] = (this.dimensions[le] || 0) - (_e.dimensions[le] || 0);
    for (var ue = 0; ue < _e.units.length; ue++) {
      var be = L5(L5({}, _e.units[ue]), {}, {
        power: -_e.units[ue].power
      });
      ce.units.push(be);
    }
    if (this.value !== null || _e.value !== null) {
      var Se = this.value === null ? this._normalize(1) : this.value, Ne = _e.value === null ? _e._normalize(1) : _e.value;
      ce.value = o(Se, Ne);
    } else
      ce.value = null;
    return Lo(ae) && (ce.skipAutomaticSimplification = !1), F(ce);
  }, _.prototype.pow = function(ae) {
    for (var ce = this.clone(), _e = 0; _e < G.length; _e++)
      ce.dimensions[_e] = (this.dimensions[_e] || 0) * ae;
    for (var le = 0; le < ce.units.length; le++)
      ce.units[le].power *= ae;
    return ce.value !== null ? ce.value = s(ce.value, ae) : ce.value = null, ce.skipAutomaticSimplification = !1, F(ce);
  };
  function F(ae) {
    return ae.equalBase(L.NONE) && ae.value !== null && !r.predictable ? ae.value : ae;
  }
  _.prototype.abs = function() {
    var ae = this.clone();
    if (ae.value !== null)
      if (ae._isDerived() || ae.units.length === 0 || ae.units[0].unit.offset === 0)
        ae.value = u(ae.value);
      else {
        var ce = ae._numberConverter(), _e = ce(ae.units[0].unit.value), le = ce(ae.units[0].unit.offset), ue = i(_e, le);
        ae.value = a(u(n(ae.value, ue)), ue);
      }
    for (var be in ae.units)
      (ae.units[be].unit.name === "VA" || ae.units[be].unit.name === "VAR") && (ae.units[be].unit = H.W);
    return ae;
  }, _.prototype.to = function(ae) {
    var ce = this.value === null ? this._normalize(1) : this.value, _e;
    if (typeof ae == "string")
      _e = _.parse(ae);
    else if (Lo(ae))
      _e = ae.clone();
    else
      throw new Error("String or Unit expected as parameter");
    if (!this.equalBase(_e))
      throw new Error("Units do not match ('".concat(_e.toString(), "' != '").concat(this.toString(), "')"));
    if (_e.value !== null)
      throw new Error("Cannot convert to a unit with a value");
    if (this.value === null || this._isDerived() || this.units.length === 0 || _e.units.length === 0 || this.units[0].unit.offset === _e.units[0].unit.offset)
      _e.value = Jt(ce);
    else {
      var le = _._getNumberConverter(Nn(ce)), ue = this.units[0].unit.value, be = this.units[0].unit.offset, Se = i(ue, be), Ne = _e.units[0].unit.value, J = _e.units[0].unit.offset, Z = i(Ne, J);
      _e.value = n(ce, le(a(Se, Z)));
    }
    return _e.fixPrefix = !0, _e.skipAutomaticSimplification = !0, _e;
  }, _.prototype.toNumber = function(ae) {
    return y(this.toNumeric(ae));
  }, _.prototype.toNumeric = function(ae) {
    var ce;
    return ae ? ce = this.to(ae) : ce = this.clone(), ce._isDerived() || ce.units.length === 0 ? ce._denormalize(ce.value) : ce._denormalize(ce.value, ce.units[0].prefix.value);
  }, _.prototype.toString = function() {
    return this.format();
  }, _.prototype.toJSON = function() {
    return {
      mathjs: "Unit",
      value: this._denormalize(this.value),
      unit: this.units.length > 0 ? this.formatUnits() : null,
      fixPrefix: this.fixPrefix
    };
  }, _.fromJSON = function(ae) {
    var ce, _e = new _(ae.value, (ce = ae.unit) !== null && ce !== void 0 ? ce : void 0);
    return _e.fixPrefix = ae.fixPrefix || !1, _e;
  }, _.prototype.valueOf = _.prototype.toString, _.prototype.simplify = function() {
    var ae = this.clone(), ce = [], _e;
    for (var le in te)
      if (Tt(te, le) && ae.hasBase(L[le])) {
        _e = le;
        break;
      }
    if (_e === "NONE")
      ae.units = [];
    else {
      var ue;
      if (_e && Tt(te, _e) && (ue = te[_e]), ue)
        ae.units = [{
          unit: ue.unit,
          prefix: ue.prefix,
          power: 1
        }];
      else {
        for (var be = !1, Se = 0; Se < G.length; Se++) {
          var Ne = G[Se];
          Math.abs(ae.dimensions[Se] || 0) > 1e-12 && (Tt(te, Ne) ? ce.push({
            unit: te[Ne].unit,
            prefix: te[Ne].prefix,
            power: ae.dimensions[Se] || 0
          }) : be = !0);
        }
        ce.length < ae.units.length && !be && (ae.units = ce);
      }
    }
    return ae;
  }, _.prototype.toSI = function() {
    for (var ae = this.clone(), ce = [], _e = 0; _e < G.length; _e++) {
      var le = G[_e];
      if (Math.abs(ae.dimensions[_e] || 0) > 1e-12)
        if (Tt($.si, le))
          ce.push({
            unit: $.si[le].unit,
            prefix: $.si[le].prefix,
            power: ae.dimensions[_e] || 0
          });
        else
          throw new Error("Cannot express custom unit " + le + " in SI units");
    }
    return ae.units = ce, ae.fixPrefix = !0, ae.skipAutomaticSimplification = !0, this.value !== null ? (ae.value = null, this.to(ae)) : ae;
  }, _.prototype.formatUnits = function() {
    for (var ae = "", ce = "", _e = 0, le = 0, ue = 0; ue < this.units.length; ue++)
      this.units[ue].power > 0 ? (_e++, ae += " " + this.units[ue].prefix.name + this.units[ue].unit.name, Math.abs(this.units[ue].power - 1) > 1e-15 && (ae += "^" + this.units[ue].power)) : this.units[ue].power < 0 && le++;
    if (le > 0)
      for (var be = 0; be < this.units.length; be++)
        this.units[be].power < 0 && (_e > 0 ? (ce += " " + this.units[be].prefix.name + this.units[be].unit.name, Math.abs(this.units[be].power + 1) > 1e-15 && (ce += "^" + -this.units[be].power)) : (ce += " " + this.units[be].prefix.name + this.units[be].unit.name, ce += "^" + this.units[be].power));
    ae = ae.substr(1), ce = ce.substr(1), _e > 1 && le > 0 && (ae = "(" + ae + ")"), le > 1 && _e > 0 && (ce = "(" + ce + ")");
    var Se = ae;
    return _e > 0 && le > 0 && (Se += " / "), Se += ce, Se;
  }, _.prototype.format = function(ae) {
    var ce = this.skipAutomaticSimplification || this.value === null ? this.clone() : this.simplify(), _e = !1;
    typeof ce.value < "u" && ce.value !== null && Mu(ce.value) && (_e = Math.abs(ce.value.re) < 1e-14);
    for (var le in ce.units)
      Tt(ce.units, le) && ce.units[le].unit && (ce.units[le].unit.name === "VA" && _e ? ce.units[le].unit = H.VAR : ce.units[le].unit.name === "VAR" && !_e && (ce.units[le].unit = H.VA));
    ce.units.length === 1 && !ce.fixPrefix && Math.abs(ce.units[0].power - Math.round(ce.units[0].power)) < 1e-14 && (ce.units[0].prefix = ce._bestPrefix());
    var ue = ce._denormalize(ce.value), be = ce.value !== null ? m(ue, ae || {}) : "", Se = ce.formatUnits();
    return ce.value && Mu(ce.value) && (be = "(" + be + ")"), Se.length > 0 && be.length > 0 && (be += " "), be += Se, be;
  }, _.prototype._bestPrefix = function() {
    if (this.units.length !== 1)
      throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
    if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) >= 1e-14)
      throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
    var ae = this.value !== null ? u(this.value) : 0, ce = u(this.units[0].unit.value), _e = this.units[0].prefix;
    if (ae === 0)
      return _e;
    var le = this.units[0].power, ue = Math.log(ae / Math.pow(_e.value * ce, le)) / Math.LN10 - 1.2;
    if (ue > -2.200001 && ue < 1.800001) return _e;
    ue = Math.abs(ue);
    var be = this.units[0].unit.prefixes;
    for (var Se in be)
      if (Tt(be, Se)) {
        var Ne = be[Se];
        if (Ne.scientific) {
          var J = Math.abs(Math.log(ae / Math.pow(Ne.value * ce, le)) / Math.LN10 - 1.2);
          (J < ue || J === ue && Ne.name.length < _e.name.length) && (_e = Ne, ue = J);
        }
      }
    return _e;
  }, _.prototype.splitUnit = function(ae) {
    for (var ce = this.clone(), _e = [], le = 0; le < ae.length && (ce = ce.to(ae[le]), le !== ae.length - 1); le++) {
      var ue = ce.toNumeric(), be = l(ue), Se = void 0, Ne = d(be, ue);
      Ne ? Se = be : Se = c(ce.toNumeric());
      var J = new _(Se, ae[le].toString());
      _e.push(J), ce = a(ce, J);
    }
    for (var Z = 0, de = 0; de < _e.length; de++)
      Z = n(Z, _e[de].value);
    return d(Z, this.value) && (ce.value = 0), _e.push(ce), _e;
  };
  var R = {
    NONE: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      }
    },
    SHORT: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 10,
        scientific: !1
      },
      h: {
        name: "h",
        value: 100,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e3,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e6,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e9,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e12,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e15,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e18,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e21,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e24,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e27,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e30,
        scientific: !0
      },
      d: {
        name: "d",
        value: 0.1,
        scientific: !1
      },
      c: {
        name: "c",
        value: 0.01,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-3,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-6,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-9,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-12,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-15,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-18,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-21,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-24,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-27,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-30,
        scientific: !0
      }
    },
    LONG: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      deca: {
        name: "deca",
        value: 10,
        scientific: !1
      },
      hecto: {
        name: "hecto",
        value: 100,
        scientific: !1
      },
      kilo: {
        name: "kilo",
        value: 1e3,
        scientific: !0
      },
      mega: {
        name: "mega",
        value: 1e6,
        scientific: !0
      },
      giga: {
        name: "giga",
        value: 1e9,
        scientific: !0
      },
      tera: {
        name: "tera",
        value: 1e12,
        scientific: !0
      },
      peta: {
        name: "peta",
        value: 1e15,
        scientific: !0
      },
      exa: {
        name: "exa",
        value: 1e18,
        scientific: !0
      },
      zetta: {
        name: "zetta",
        value: 1e21,
        scientific: !0
      },
      yotta: {
        name: "yotta",
        value: 1e24,
        scientific: !0
      },
      ronna: {
        name: "ronna",
        value: 1e27,
        scientific: !0
      },
      quetta: {
        name: "quetta",
        value: 1e30,
        scientific: !0
      },
      deci: {
        name: "deci",
        value: 0.1,
        scientific: !1
      },
      centi: {
        name: "centi",
        value: 0.01,
        scientific: !1
      },
      milli: {
        name: "milli",
        value: 1e-3,
        scientific: !0
      },
      micro: {
        name: "micro",
        value: 1e-6,
        scientific: !0
      },
      nano: {
        name: "nano",
        value: 1e-9,
        scientific: !0
      },
      pico: {
        name: "pico",
        value: 1e-12,
        scientific: !0
      },
      femto: {
        name: "femto",
        value: 1e-15,
        scientific: !0
      },
      atto: {
        name: "atto",
        value: 1e-18,
        scientific: !0
      },
      zepto: {
        name: "zepto",
        value: 1e-21,
        scientific: !0
      },
      yocto: {
        name: "yocto",
        value: 1e-24,
        scientific: !0
      },
      ronto: {
        name: "ronto",
        value: 1e-27,
        scientific: !0
      },
      quecto: {
        name: "quecto",
        value: 1e-30,
        scientific: !0
      }
    },
    SQUARED: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 100,
        scientific: !1
      },
      h: {
        name: "h",
        value: 1e4,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e6,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e12,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e18,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e24,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e30,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e36,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e42,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e48,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e54,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e60,
        scientific: !0
      },
      d: {
        name: "d",
        value: 0.01,
        scientific: !1
      },
      c: {
        name: "c",
        value: 1e-4,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-6,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-12,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-18,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-24,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-30,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-36,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-42,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-48,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-54,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-60,
        scientific: !0
      }
    },
    CUBIC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 1e3,
        scientific: !1
      },
      h: {
        name: "h",
        value: 1e6,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e9,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e18,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e27,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e36,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e45,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e54,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e63,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e72,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e81,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e90,
        scientific: !0
      },
      d: {
        name: "d",
        value: 1e-3,
        scientific: !1
      },
      c: {
        name: "c",
        value: 1e-6,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-9,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-18,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-27,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-36,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-45,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-54,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-63,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-72,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-81,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-90,
        scientific: !0
      }
    },
    BINARY_SHORT_SI: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      k: {
        name: "k",
        value: 1e3,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e6,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e9,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e12,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e15,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e18,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e21,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e24,
        scientific: !0
      }
    },
    BINARY_SHORT_IEC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      Ki: {
        name: "Ki",
        value: 1024,
        scientific: !0
      },
      Mi: {
        name: "Mi",
        value: Math.pow(1024, 2),
        scientific: !0
      },
      Gi: {
        name: "Gi",
        value: Math.pow(1024, 3),
        scientific: !0
      },
      Ti: {
        name: "Ti",
        value: Math.pow(1024, 4),
        scientific: !0
      },
      Pi: {
        name: "Pi",
        value: Math.pow(1024, 5),
        scientific: !0
      },
      Ei: {
        name: "Ei",
        value: Math.pow(1024, 6),
        scientific: !0
      },
      Zi: {
        name: "Zi",
        value: Math.pow(1024, 7),
        scientific: !0
      },
      Yi: {
        name: "Yi",
        value: Math.pow(1024, 8),
        scientific: !0
      }
    },
    BINARY_LONG_SI: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      kilo: {
        name: "kilo",
        value: 1e3,
        scientific: !0
      },
      mega: {
        name: "mega",
        value: 1e6,
        scientific: !0
      },
      giga: {
        name: "giga",
        value: 1e9,
        scientific: !0
      },
      tera: {
        name: "tera",
        value: 1e12,
        scientific: !0
      },
      peta: {
        name: "peta",
        value: 1e15,
        scientific: !0
      },
      exa: {
        name: "exa",
        value: 1e18,
        scientific: !0
      },
      zetta: {
        name: "zetta",
        value: 1e21,
        scientific: !0
      },
      yotta: {
        name: "yotta",
        value: 1e24,
        scientific: !0
      }
    },
    BINARY_LONG_IEC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      kibi: {
        name: "kibi",
        value: 1024,
        scientific: !0
      },
      mebi: {
        name: "mebi",
        value: Math.pow(1024, 2),
        scientific: !0
      },
      gibi: {
        name: "gibi",
        value: Math.pow(1024, 3),
        scientific: !0
      },
      tebi: {
        name: "tebi",
        value: Math.pow(1024, 4),
        scientific: !0
      },
      pebi: {
        name: "pebi",
        value: Math.pow(1024, 5),
        scientific: !0
      },
      exi: {
        name: "exi",
        value: Math.pow(1024, 6),
        scientific: !0
      },
      zebi: {
        name: "zebi",
        value: Math.pow(1024, 7),
        scientific: !0
      },
      yobi: {
        name: "yobi",
        value: Math.pow(1024, 8),
        scientific: !0
      }
    },
    BTU: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      MM: {
        name: "MM",
        value: 1e6,
        scientific: !0
      }
    }
  };
  R.SHORTLONG = Ei({}, R.SHORT, R.LONG), R.BINARY_SHORT = Ei({}, R.BINARY_SHORT_SI, R.BINARY_SHORT_IEC), R.BINARY_LONG = Ei({}, R.BINARY_LONG_SI, R.BINARY_LONG_IEC);
  var G = ["MASS", "LENGTH", "TIME", "CURRENT", "TEMPERATURE", "LUMINOUS_INTENSITY", "AMOUNT_OF_SUBSTANCE", "ANGLE", "BIT"], L = {
    NONE: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    MASS: {
      dimensions: [1, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    LENGTH: {
      dimensions: [0, 1, 0, 0, 0, 0, 0, 0, 0]
    },
    TIME: {
      dimensions: [0, 0, 1, 0, 0, 0, 0, 0, 0]
    },
    CURRENT: {
      dimensions: [0, 0, 0, 1, 0, 0, 0, 0, 0]
    },
    TEMPERATURE: {
      dimensions: [0, 0, 0, 0, 1, 0, 0, 0, 0]
    },
    LUMINOUS_INTENSITY: {
      dimensions: [0, 0, 0, 0, 0, 1, 0, 0, 0]
    },
    AMOUNT_OF_SUBSTANCE: {
      dimensions: [0, 0, 0, 0, 0, 0, 1, 0, 0]
    },
    FORCE: {
      dimensions: [1, 1, -2, 0, 0, 0, 0, 0, 0]
    },
    SURFACE: {
      dimensions: [0, 2, 0, 0, 0, 0, 0, 0, 0]
    },
    VOLUME: {
      dimensions: [0, 3, 0, 0, 0, 0, 0, 0, 0]
    },
    ENERGY: {
      dimensions: [1, 2, -2, 0, 0, 0, 0, 0, 0]
    },
    POWER: {
      dimensions: [1, 2, -3, 0, 0, 0, 0, 0, 0]
    },
    PRESSURE: {
      dimensions: [1, -1, -2, 0, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CHARGE: {
      dimensions: [0, 0, 1, 1, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CAPACITANCE: {
      dimensions: [-1, -2, 4, 2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_POTENTIAL: {
      dimensions: [1, 2, -3, -1, 0, 0, 0, 0, 0]
    },
    ELECTRIC_RESISTANCE: {
      dimensions: [1, 2, -3, -2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_INDUCTANCE: {
      dimensions: [1, 2, -2, -2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CONDUCTANCE: {
      dimensions: [-1, -2, 3, 2, 0, 0, 0, 0, 0]
    },
    MAGNETIC_FLUX: {
      dimensions: [1, 2, -2, -1, 0, 0, 0, 0, 0]
    },
    MAGNETIC_FLUX_DENSITY: {
      dimensions: [1, 0, -2, -1, 0, 0, 0, 0, 0]
    },
    FREQUENCY: {
      dimensions: [0, 0, -1, 0, 0, 0, 0, 0, 0]
    },
    ANGLE: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 1, 0]
    },
    BIT: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 1]
    }
  };
  for (var q in L)
    Tt(L, q) && (L[q].key = q);
  var K = {}, X = {
    name: "",
    base: K,
    value: 1,
    offset: 0,
    dimensions: G.map((ae) => 0)
  }, H = {
    // length
    meter: {
      name: "meter",
      base: L.LENGTH,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    inch: {
      name: "inch",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.0254,
      offset: 0
    },
    foot: {
      name: "foot",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.3048,
      offset: 0
    },
    yard: {
      name: "yard",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.9144,
      offset: 0
    },
    mile: {
      name: "mile",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 1609.344,
      offset: 0
    },
    link: {
      name: "link",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.201168,
      offset: 0
    },
    rod: {
      name: "rod",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 5.0292,
      offset: 0
    },
    chain: {
      name: "chain",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 20.1168,
      offset: 0
    },
    angstrom: {
      name: "angstrom",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 1e-10,
      offset: 0
    },
    m: {
      name: "m",
      base: L.LENGTH,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    in: {
      name: "in",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.0254,
      offset: 0
    },
    ft: {
      name: "ft",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.3048,
      offset: 0
    },
    yd: {
      name: "yd",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.9144,
      offset: 0
    },
    mi: {
      name: "mi",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 1609.344,
      offset: 0
    },
    li: {
      name: "li",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 0.201168,
      offset: 0
    },
    rd: {
      name: "rd",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 5.02921,
      offset: 0
    },
    ch: {
      name: "ch",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 20.1168,
      offset: 0
    },
    mil: {
      name: "mil",
      base: L.LENGTH,
      prefixes: R.NONE,
      value: 254e-7,
      offset: 0
    },
    // 1/1000 inch
    // Surface
    m2: {
      name: "m2",
      base: L.SURFACE,
      prefixes: R.SQUARED,
      value: 1,
      offset: 0
    },
    sqin: {
      name: "sqin",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 64516e-8,
      offset: 0
    },
    // 645.16 mm2
    sqft: {
      name: "sqft",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 0.09290304,
      offset: 0
    },
    // 0.09290304 m2
    sqyd: {
      name: "sqyd",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 0.83612736,
      offset: 0
    },
    // 0.83612736 m2
    sqmi: {
      name: "sqmi",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 2589988110336e-6,
      offset: 0
    },
    // 2.589988110336 km2
    sqrd: {
      name: "sqrd",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 25.29295,
      offset: 0
    },
    // 25.29295 m2
    sqch: {
      name: "sqch",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 404.6873,
      offset: 0
    },
    // 404.6873 m2
    sqmil: {
      name: "sqmil",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 64516e-14,
      offset: 0
    },
    // 6.4516 * 10^-10 m2
    acre: {
      name: "acre",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 4046.86,
      offset: 0
    },
    // 4046.86 m2
    hectare: {
      name: "hectare",
      base: L.SURFACE,
      prefixes: R.NONE,
      value: 1e4,
      offset: 0
    },
    // 10000 m2
    // Volume
    m3: {
      name: "m3",
      base: L.VOLUME,
      prefixes: R.CUBIC,
      value: 1,
      offset: 0
    },
    L: {
      name: "L",
      base: L.VOLUME,
      prefixes: R.SHORT,
      value: 1e-3,
      offset: 0
    },
    // litre
    l: {
      name: "l",
      base: L.VOLUME,
      prefixes: R.SHORT,
      value: 1e-3,
      offset: 0
    },
    // litre
    litre: {
      name: "litre",
      base: L.VOLUME,
      prefixes: R.LONG,
      value: 1e-3,
      offset: 0
    },
    cuin: {
      name: "cuin",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 16387064e-12,
      offset: 0
    },
    // 1.6387064e-5 m3
    cuft: {
      name: "cuft",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.028316846592,
      offset: 0
    },
    // 28.316 846 592 L
    cuyd: {
      name: "cuyd",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.764554857984,
      offset: 0
    },
    // 764.554 857 984 L
    teaspoon: {
      name: "teaspoon",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 5e-6,
      offset: 0
    },
    // 5 mL
    tablespoon: {
      name: "tablespoon",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 15e-6,
      offset: 0
    },
    // 15 mL
    // {name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL  // not possible, we have already another cup
    drop: {
      name: "drop",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 5e-8,
      offset: 0
    },
    // 0.05 mL = 5e-8 m3
    gtt: {
      name: "gtt",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 5e-8,
      offset: 0
    },
    // 0.05 mL = 5e-8 m3
    // Liquid volume
    minim: {
      name: "minim",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 6161152e-14,
      offset: 0
    },
    // 0.06161152 mL
    fluiddram: {
      name: "fluiddram",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 36966911e-13,
      offset: 0
    },
    // 3.696691 mL
    fluidounce: {
      name: "fluidounce",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 2957353e-11,
      offset: 0
    },
    // 29.57353 mL
    gill: {
      name: "gill",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 1182941e-10,
      offset: 0
    },
    // 118.2941 mL
    cc: {
      name: "cc",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 1e-6,
      offset: 0
    },
    // 1e-6 L
    cup: {
      name: "cup",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 2365882e-10,
      offset: 0
    },
    // 236.5882 mL
    pint: {
      name: "pint",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 4731765e-10,
      offset: 0
    },
    // 473.1765 mL
    quart: {
      name: "quart",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 9463529e-10,
      offset: 0
    },
    // 946.3529 mL
    gallon: {
      name: "gallon",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 3785412e-9,
      offset: 0
    },
    // 3.785412 L
    beerbarrel: {
      name: "beerbarrel",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.1173478,
      offset: 0
    },
    // 117.3478 L
    oilbarrel: {
      name: "oilbarrel",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.1589873,
      offset: 0
    },
    // 158.9873 L
    hogshead: {
      name: "hogshead",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.238481,
      offset: 0
    },
    // 238.4810 L
    // {name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute
    fldr: {
      name: "fldr",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 36966911e-13,
      offset: 0
    },
    // 3.696691 mL
    floz: {
      name: "floz",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 2957353e-11,
      offset: 0
    },
    // 29.57353 mL
    gi: {
      name: "gi",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 1182941e-10,
      offset: 0
    },
    // 118.2941 mL
    cp: {
      name: "cp",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 2365882e-10,
      offset: 0
    },
    // 236.5882 mL
    pt: {
      name: "pt",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 4731765e-10,
      offset: 0
    },
    // 473.1765 mL
    qt: {
      name: "qt",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 9463529e-10,
      offset: 0
    },
    // 946.3529 mL
    gal: {
      name: "gal",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 3785412e-9,
      offset: 0
    },
    // 3.785412 L
    bbl: {
      name: "bbl",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.1173478,
      offset: 0
    },
    // 117.3478 L
    obl: {
      name: "obl",
      base: L.VOLUME,
      prefixes: R.NONE,
      value: 0.1589873,
      offset: 0
    },
    // 158.9873 L
    // {name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh?
    // Mass
    g: {
      name: "g",
      base: L.MASS,
      prefixes: R.SHORT,
      value: 1e-3,
      offset: 0
    },
    gram: {
      name: "gram",
      base: L.MASS,
      prefixes: R.LONG,
      value: 1e-3,
      offset: 0
    },
    ton: {
      name: "ton",
      base: L.MASS,
      prefixes: R.SHORT,
      value: 907.18474,
      offset: 0
    },
    t: {
      name: "t",
      base: L.MASS,
      prefixes: R.SHORT,
      value: 1e3,
      offset: 0
    },
    tonne: {
      name: "tonne",
      base: L.MASS,
      prefixes: R.LONG,
      value: 1e3,
      offset: 0
    },
    grain: {
      name: "grain",
      base: L.MASS,
      prefixes: R.NONE,
      value: 6479891e-11,
      offset: 0
    },
    dram: {
      name: "dram",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.0017718451953125,
      offset: 0
    },
    ounce: {
      name: "ounce",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.028349523125,
      offset: 0
    },
    poundmass: {
      name: "poundmass",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.45359237,
      offset: 0
    },
    hundredweight: {
      name: "hundredweight",
      base: L.MASS,
      prefixes: R.NONE,
      value: 45.359237,
      offset: 0
    },
    stick: {
      name: "stick",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.115,
      offset: 0
    },
    stone: {
      name: "stone",
      base: L.MASS,
      prefixes: R.NONE,
      value: 6.35029318,
      offset: 0
    },
    gr: {
      name: "gr",
      base: L.MASS,
      prefixes: R.NONE,
      value: 6479891e-11,
      offset: 0
    },
    dr: {
      name: "dr",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.0017718451953125,
      offset: 0
    },
    oz: {
      name: "oz",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.028349523125,
      offset: 0
    },
    lbm: {
      name: "lbm",
      base: L.MASS,
      prefixes: R.NONE,
      value: 0.45359237,
      offset: 0
    },
    cwt: {
      name: "cwt",
      base: L.MASS,
      prefixes: R.NONE,
      value: 45.359237,
      offset: 0
    },
    // Time
    s: {
      name: "s",
      base: L.TIME,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    min: {
      name: "min",
      base: L.TIME,
      prefixes: R.NONE,
      value: 60,
      offset: 0
    },
    h: {
      name: "h",
      base: L.TIME,
      prefixes: R.NONE,
      value: 3600,
      offset: 0
    },
    second: {
      name: "second",
      base: L.TIME,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    sec: {
      name: "sec",
      base: L.TIME,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    minute: {
      name: "minute",
      base: L.TIME,
      prefixes: R.NONE,
      value: 60,
      offset: 0
    },
    hour: {
      name: "hour",
      base: L.TIME,
      prefixes: R.NONE,
      value: 3600,
      offset: 0
    },
    day: {
      name: "day",
      base: L.TIME,
      prefixes: R.NONE,
      value: 86400,
      offset: 0
    },
    week: {
      name: "week",
      base: L.TIME,
      prefixes: R.NONE,
      value: 7 * 86400,
      offset: 0
    },
    month: {
      name: "month",
      base: L.TIME,
      prefixes: R.NONE,
      value: 2629800,
      // 1/12th of Julian year
      offset: 0
    },
    year: {
      name: "year",
      base: L.TIME,
      prefixes: R.NONE,
      value: 31557600,
      // Julian year
      offset: 0
    },
    decade: {
      name: "decade",
      base: L.TIME,
      prefixes: R.NONE,
      value: 315576e3,
      // Julian decade
      offset: 0
    },
    century: {
      name: "century",
      base: L.TIME,
      prefixes: R.NONE,
      value: 315576e4,
      // Julian century
      offset: 0
    },
    millennium: {
      name: "millennium",
      base: L.TIME,
      prefixes: R.NONE,
      value: 315576e5,
      // Julian millennium
      offset: 0
    },
    // Frequency
    hertz: {
      name: "Hertz",
      base: L.FREQUENCY,
      prefixes: R.LONG,
      value: 1,
      offset: 0,
      reciprocal: !0
    },
    Hz: {
      name: "Hz",
      base: L.FREQUENCY,
      prefixes: R.SHORT,
      value: 1,
      offset: 0,
      reciprocal: !0
    },
    // Angle
    rad: {
      name: "rad",
      base: L.ANGLE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    radian: {
      name: "radian",
      base: L.ANGLE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888
    deg: {
      name: "deg",
      base: L.ANGLE,
      prefixes: R.SHORT,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    degree: {
      name: "degree",
      base: L.ANGLE,
      prefixes: R.LONG,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // grad = rad / (2*pi) * 400  = rad / 0.015707963267948966192313216916399
    grad: {
      name: "grad",
      base: L.ANGLE,
      prefixes: R.SHORT,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    gradian: {
      name: "gradian",
      base: L.ANGLE,
      prefixes: R.LONG,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793
    cycle: {
      name: "cycle",
      base: L.ANGLE,
      prefixes: R.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // arcsec = rad / (3600 * (360 / 2 * pi)) = rad / 0.0000048481368110953599358991410235795
    arcsec: {
      name: "arcsec",
      base: L.ANGLE,
      prefixes: R.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // arcmin = rad / (60 * (360 / 2 * pi)) = rad / 0.00029088820866572159615394846141477
    arcmin: {
      name: "arcmin",
      base: L.ANGLE,
      prefixes: R.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // Electric current
    A: {
      name: "A",
      base: L.CURRENT,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    ampere: {
      name: "ampere",
      base: L.CURRENT,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    // Temperature
    // K(C) = °C + 273.15
    // K(F) = (°F + 459.67) * (5 / 9)
    // K(R) = °R * (5 / 9)
    K: {
      name: "K",
      base: L.TEMPERATURE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    degC: {
      name: "degC",
      base: L.TEMPERATURE,
      prefixes: R.SHORT,
      value: 1,
      offset: 273.15
    },
    degF: {
      name: "degF",
      base: L.TEMPERATURE,
      prefixes: R.SHORT,
      value: new v(5, 9),
      offset: 459.67
    },
    degR: {
      name: "degR",
      base: L.TEMPERATURE,
      prefixes: R.SHORT,
      value: new v(5, 9),
      offset: 0
    },
    kelvin: {
      name: "kelvin",
      base: L.TEMPERATURE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    celsius: {
      name: "celsius",
      base: L.TEMPERATURE,
      prefixes: R.LONG,
      value: 1,
      offset: 273.15
    },
    fahrenheit: {
      name: "fahrenheit",
      base: L.TEMPERATURE,
      prefixes: R.LONG,
      value: new v(5, 9),
      offset: 459.67
    },
    rankine: {
      name: "rankine",
      base: L.TEMPERATURE,
      prefixes: R.LONG,
      value: new v(5, 9),
      offset: 0
    },
    // amount of substance
    mol: {
      name: "mol",
      base: L.AMOUNT_OF_SUBSTANCE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    mole: {
      name: "mole",
      base: L.AMOUNT_OF_SUBSTANCE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    // luminous intensity
    cd: {
      name: "cd",
      base: L.LUMINOUS_INTENSITY,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    candela: {
      name: "candela",
      base: L.LUMINOUS_INTENSITY,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    // TODO: units STERADIAN
    // {name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0},
    // {name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0},
    // Force
    N: {
      name: "N",
      base: L.FORCE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    newton: {
      name: "newton",
      base: L.FORCE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    dyn: {
      name: "dyn",
      base: L.FORCE,
      prefixes: R.SHORT,
      value: 1e-5,
      offset: 0
    },
    dyne: {
      name: "dyne",
      base: L.FORCE,
      prefixes: R.LONG,
      value: 1e-5,
      offset: 0
    },
    lbf: {
      name: "lbf",
      base: L.FORCE,
      prefixes: R.NONE,
      value: 4.4482216152605,
      offset: 0
    },
    poundforce: {
      name: "poundforce",
      base: L.FORCE,
      prefixes: R.NONE,
      value: 4.4482216152605,
      offset: 0
    },
    kip: {
      name: "kip",
      base: L.FORCE,
      prefixes: R.LONG,
      value: 4448.2216,
      offset: 0
    },
    kilogramforce: {
      name: "kilogramforce",
      base: L.FORCE,
      prefixes: R.NONE,
      value: 9.80665,
      offset: 0
    },
    // Energy
    J: {
      name: "J",
      base: L.ENERGY,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    joule: {
      name: "joule",
      base: L.ENERGY,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    erg: {
      name: "erg",
      base: L.ENERGY,
      prefixes: R.SHORTLONG,
      // Both kiloerg and kerg are acceptable
      value: 1e-7,
      offset: 0
    },
    Wh: {
      name: "Wh",
      base: L.ENERGY,
      prefixes: R.SHORT,
      value: 3600,
      offset: 0
    },
    BTU: {
      name: "BTU",
      base: L.ENERGY,
      prefixes: R.BTU,
      value: 1055.05585262,
      offset: 0
    },
    eV: {
      name: "eV",
      base: L.ENERGY,
      prefixes: R.SHORT,
      value: 1602176565e-28,
      offset: 0
    },
    electronvolt: {
      name: "electronvolt",
      base: L.ENERGY,
      prefixes: R.LONG,
      value: 1602176565e-28,
      offset: 0
    },
    // Power
    W: {
      name: "W",
      base: L.POWER,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    watt: {
      name: "watt",
      base: L.POWER,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    hp: {
      name: "hp",
      base: L.POWER,
      prefixes: R.NONE,
      value: 745.6998715386,
      offset: 0
    },
    // Electrical power units
    VAR: {
      name: "VAR",
      base: L.POWER,
      prefixes: R.SHORT,
      value: p.I,
      offset: 0
    },
    VA: {
      name: "VA",
      base: L.POWER,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Pressure
    Pa: {
      name: "Pa",
      base: L.PRESSURE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    psi: {
      name: "psi",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 6894.75729276459,
      offset: 0
    },
    atm: {
      name: "atm",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 101325,
      offset: 0
    },
    bar: {
      name: "bar",
      base: L.PRESSURE,
      prefixes: R.SHORTLONG,
      value: 1e5,
      offset: 0
    },
    torr: {
      name: "torr",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 133.322,
      offset: 0
    },
    mmHg: {
      name: "mmHg",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 133.322,
      offset: 0
    },
    mmH2O: {
      name: "mmH2O",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 9.80665,
      offset: 0
    },
    cmH2O: {
      name: "cmH2O",
      base: L.PRESSURE,
      prefixes: R.NONE,
      value: 98.0665,
      offset: 0
    },
    // Electric charge
    coulomb: {
      name: "coulomb",
      base: L.ELECTRIC_CHARGE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    C: {
      name: "C",
      base: L.ELECTRIC_CHARGE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Electric capacitance
    farad: {
      name: "farad",
      base: L.ELECTRIC_CAPACITANCE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    F: {
      name: "F",
      base: L.ELECTRIC_CAPACITANCE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Electric potential
    volt: {
      name: "volt",
      base: L.ELECTRIC_POTENTIAL,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    V: {
      name: "V",
      base: L.ELECTRIC_POTENTIAL,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Electric resistance
    ohm: {
      name: "ohm",
      base: L.ELECTRIC_RESISTANCE,
      prefixes: R.SHORTLONG,
      // Both Mohm and megaohm are acceptable
      value: 1,
      offset: 0
    },
    /*
     * Unicode breaks in browsers if charset is not specified
    Ω: {
      name: 'Ω',
      base: BASE_UNITS.ELECTRIC_RESISTANCE,
      prefixes: PREFIXES.SHORT,
      value: 1,
      offset: 0
    },
    */
    // Electric inductance
    henry: {
      name: "henry",
      base: L.ELECTRIC_INDUCTANCE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    H: {
      name: "H",
      base: L.ELECTRIC_INDUCTANCE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Electric conductance
    siemens: {
      name: "siemens",
      base: L.ELECTRIC_CONDUCTANCE,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    S: {
      name: "S",
      base: L.ELECTRIC_CONDUCTANCE,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Magnetic flux
    weber: {
      name: "weber",
      base: L.MAGNETIC_FLUX,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    Wb: {
      name: "Wb",
      base: L.MAGNETIC_FLUX,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Magnetic flux density
    tesla: {
      name: "tesla",
      base: L.MAGNETIC_FLUX_DENSITY,
      prefixes: R.LONG,
      value: 1,
      offset: 0
    },
    T: {
      name: "T",
      base: L.MAGNETIC_FLUX_DENSITY,
      prefixes: R.SHORT,
      value: 1,
      offset: 0
    },
    // Binary
    b: {
      name: "b",
      base: L.BIT,
      prefixes: R.BINARY_SHORT,
      value: 1,
      offset: 0
    },
    bits: {
      name: "bits",
      base: L.BIT,
      prefixes: R.BINARY_LONG,
      value: 1,
      offset: 0
    },
    B: {
      name: "B",
      base: L.BIT,
      prefixes: R.BINARY_SHORT,
      value: 8,
      offset: 0
    },
    bytes: {
      name: "bytes",
      base: L.BIT,
      prefixes: R.BINARY_LONG,
      value: 8,
      offset: 0
    }
  }, W = {
    meters: "meter",
    inches: "inch",
    feet: "foot",
    yards: "yard",
    miles: "mile",
    links: "link",
    rods: "rod",
    chains: "chain",
    angstroms: "angstrom",
    lt: "l",
    litres: "litre",
    liter: "litre",
    liters: "litre",
    teaspoons: "teaspoon",
    tablespoons: "tablespoon",
    minims: "minim",
    fluiddrams: "fluiddram",
    fluidounces: "fluidounce",
    gills: "gill",
    cups: "cup",
    pints: "pint",
    quarts: "quart",
    gallons: "gallon",
    beerbarrels: "beerbarrel",
    oilbarrels: "oilbarrel",
    hogsheads: "hogshead",
    gtts: "gtt",
    grams: "gram",
    tons: "ton",
    tonnes: "tonne",
    grains: "grain",
    drams: "dram",
    ounces: "ounce",
    poundmasses: "poundmass",
    hundredweights: "hundredweight",
    sticks: "stick",
    lb: "lbm",
    lbs: "lbm",
    kips: "kip",
    kgf: "kilogramforce",
    acres: "acre",
    hectares: "hectare",
    sqfeet: "sqft",
    sqyard: "sqyd",
    sqmile: "sqmi",
    sqmiles: "sqmi",
    mmhg: "mmHg",
    mmh2o: "mmH2O",
    cmh2o: "cmH2O",
    seconds: "second",
    secs: "second",
    minutes: "minute",
    mins: "minute",
    hours: "hour",
    hr: "hour",
    hrs: "hour",
    days: "day",
    weeks: "week",
    months: "month",
    years: "year",
    decades: "decade",
    centuries: "century",
    millennia: "millennium",
    hertz: "hertz",
    radians: "radian",
    degrees: "degree",
    gradians: "gradian",
    cycles: "cycle",
    arcsecond: "arcsec",
    arcseconds: "arcsec",
    arcminute: "arcmin",
    arcminutes: "arcmin",
    BTUs: "BTU",
    watts: "watt",
    joules: "joule",
    amperes: "ampere",
    amps: "ampere",
    amp: "ampere",
    coulombs: "coulomb",
    volts: "volt",
    ohms: "ohm",
    farads: "farad",
    webers: "weber",
    teslas: "tesla",
    electronvolts: "electronvolt",
    moles: "mole",
    bit: "bits",
    byte: "bytes"
  };
  function ee(ae) {
    if (ae.number === "BigNumber") {
      var ce = GS(g);
      H.rad.value = new g(1), H.deg.value = ce.div(180), H.grad.value = ce.div(200), H.cycle.value = ce.times(2), H.arcsec.value = ce.div(648e3), H.arcmin.value = ce.div(10800);
    } else
      H.rad.value = 1, H.deg.value = Math.PI / 180, H.grad.value = Math.PI / 200, H.cycle.value = Math.PI * 2, H.arcsec.value = Math.PI / 648e3, H.arcmin.value = Math.PI / 10800;
    H.radian.value = H.rad.value, H.degree.value = H.deg.value, H.gradian.value = H.grad.value;
  }
  ee(r), t && t("config", function(ae, ce) {
    ae.number !== ce.number && ee(ae);
  });
  var $ = {
    si: {
      // Base units
      NONE: {
        unit: X,
        prefix: R.NONE[""]
      },
      LENGTH: {
        unit: H.m,
        prefix: R.SHORT[""]
      },
      MASS: {
        unit: H.g,
        prefix: R.SHORT.k
      },
      TIME: {
        unit: H.s,
        prefix: R.SHORT[""]
      },
      CURRENT: {
        unit: H.A,
        prefix: R.SHORT[""]
      },
      TEMPERATURE: {
        unit: H.K,
        prefix: R.SHORT[""]
      },
      LUMINOUS_INTENSITY: {
        unit: H.cd,
        prefix: R.SHORT[""]
      },
      AMOUNT_OF_SUBSTANCE: {
        unit: H.mol,
        prefix: R.SHORT[""]
      },
      ANGLE: {
        unit: H.rad,
        prefix: R.SHORT[""]
      },
      BIT: {
        unit: H.bits,
        prefix: R.SHORT[""]
      },
      // Derived units
      FORCE: {
        unit: H.N,
        prefix: R.SHORT[""]
      },
      ENERGY: {
        unit: H.J,
        prefix: R.SHORT[""]
      },
      POWER: {
        unit: H.W,
        prefix: R.SHORT[""]
      },
      PRESSURE: {
        unit: H.Pa,
        prefix: R.SHORT[""]
      },
      ELECTRIC_CHARGE: {
        unit: H.C,
        prefix: R.SHORT[""]
      },
      ELECTRIC_CAPACITANCE: {
        unit: H.F,
        prefix: R.SHORT[""]
      },
      ELECTRIC_POTENTIAL: {
        unit: H.V,
        prefix: R.SHORT[""]
      },
      ELECTRIC_RESISTANCE: {
        unit: H.ohm,
        prefix: R.SHORT[""]
      },
      ELECTRIC_INDUCTANCE: {
        unit: H.H,
        prefix: R.SHORT[""]
      },
      ELECTRIC_CONDUCTANCE: {
        unit: H.S,
        prefix: R.SHORT[""]
      },
      MAGNETIC_FLUX: {
        unit: H.Wb,
        prefix: R.SHORT[""]
      },
      MAGNETIC_FLUX_DENSITY: {
        unit: H.T,
        prefix: R.SHORT[""]
      },
      FREQUENCY: {
        unit: H.Hz,
        prefix: R.SHORT[""]
      }
    }
  };
  $.cgs = JSON.parse(JSON.stringify($.si)), $.cgs.LENGTH = {
    unit: H.m,
    prefix: R.SHORT.c
  }, $.cgs.MASS = {
    unit: H.g,
    prefix: R.SHORT[""]
  }, $.cgs.FORCE = {
    unit: H.dyn,
    prefix: R.SHORT[""]
  }, $.cgs.ENERGY = {
    unit: H.erg,
    prefix: R.NONE[""]
  }, $.us = JSON.parse(JSON.stringify($.si)), $.us.LENGTH = {
    unit: H.ft,
    prefix: R.NONE[""]
  }, $.us.MASS = {
    unit: H.lbm,
    prefix: R.NONE[""]
  }, $.us.TEMPERATURE = {
    unit: H.degF,
    prefix: R.NONE[""]
  }, $.us.FORCE = {
    unit: H.lbf,
    prefix: R.NONE[""]
  }, $.us.ENERGY = {
    unit: H.BTU,
    prefix: R.BTU[""]
  }, $.us.POWER = {
    unit: H.hp,
    prefix: R.NONE[""]
  }, $.us.PRESSURE = {
    unit: H.psi,
    prefix: R.NONE[""]
  }, $.auto = JSON.parse(JSON.stringify($.si));
  var te = $.auto;
  _.setUnitSystem = function(ae) {
    if (Tt($, ae))
      te = $[ae];
    else
      throw new Error("Unit system " + ae + " does not exist. Choices are: " + Object.keys($).join(", "));
  }, _.getUnitSystem = function() {
    for (var ae in $)
      if (Tt($, ae) && $[ae] === te)
        return ae;
  }, _.typeConverters = {
    BigNumber: function(ce) {
      return ce != null && ce.isFraction ? new g(ce.n).div(ce.d).times(ce.s) : new g(ce + "");
    },
    Fraction: function(ce) {
      return new v(ce);
    },
    Complex: function(ce) {
      return ce;
    },
    number: function(ce) {
      return ce != null && ce.isFraction ? h(ce) : ce;
    }
  }, _.prototype._numberConverter = function() {
    var ae = _.typeConverters[this.valueType()];
    if (ae)
      return ae;
    throw new TypeError('Unsupported Unit value type "' + this.valueType() + '"');
  }, _._getNumberConverter = function(ae) {
    if (!_.typeConverters[ae])
      throw new TypeError('Unsupported type "' + ae + '"');
    return _.typeConverters[ae];
  };
  for (var re in H)
    if (Tt(H, re)) {
      var ie = H[re];
      ie.dimensions = ie.base.dimensions;
    }
  for (var oe in W)
    if (Tt(W, oe)) {
      var se = H[W[oe]], he = {};
      for (var ge in se)
        Tt(se, ge) && (he[ge] = se[ge]);
      he.name = oe, H[oe] = he;
    }
  _.isValidAlpha = function(ce) {
    return /^[a-zA-Z]$/.test(ce);
  };
  function De(ae) {
    for (var ce = 0; ce < ae.length; ce++) {
      if (x = ae.charAt(ce), ce === 0 && !_.isValidAlpha(x))
        throw new Error('Invalid unit name (must begin with alpha character): "' + ae + '"');
      if (ce > 0 && !(_.isValidAlpha(x) || C(x)))
        throw new Error('Invalid unit name (only alphanumeric characters are allowed): "' + ae + '"');
    }
  }
  return _.createUnit = function(ae, ce) {
    if (typeof ae != "object")
      throw new TypeError("createUnit expects first parameter to be of type 'Object'");
    if (ce && ce.override) {
      for (var _e in ae)
        if (Tt(ae, _e) && _.deleteUnit(_e), ae[_e].aliases)
          for (var le = 0; le < ae[_e].aliases.length; le++)
            _.deleteUnit(ae[_e].aliases[le]);
    }
    var ue;
    for (var be in ae)
      Tt(ae, be) && (ue = _.createUnitSingle(be, ae[be]));
    return ue;
  }, _.createUnitSingle = function(ae, ce) {
    if ((typeof ce > "u" || ce === null) && (ce = {}), typeof ae != "string")
      throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");
    if (Tt(H, ae))
      throw new Error('Cannot create unit "' + ae + '": a unit with that name already exists');
    De(ae);
    var _e = null, le = [], ue = 0, be, Se, Ne;
    if (ce && ce.type === "Unit")
      _e = ce.clone();
    else if (typeof ce == "string")
      ce !== "" && (be = ce);
    else if (typeof ce == "object")
      be = ce.definition, Se = ce.prefixes, ue = ce.offset, Ne = ce.baseName, ce.aliases && (le = ce.aliases.valueOf());
    else
      throw new TypeError('Cannot create unit "' + ae + '" from "' + ce.toString() + '": expecting "string" or "Unit" or "Object"');
    if (le) {
      for (var J = 0; J < le.length; J++)
        if (Tt(H, le[J]))
          throw new Error('Cannot create alias "' + le[J] + '": a unit with that name already exists');
    }
    if (be && typeof be == "string" && !_e)
      try {
        _e = _.parse(be, {
          allowNoUnits: !0
        });
      } catch (j) {
        throw j.message = 'Could not create unit "' + ae + '" from "' + be + '": ' + j.message, j;
      }
    else be && be.type === "Unit" && (_e = be.clone());
    le = le || [], ue = ue || 0, Se && Se.toUpperCase ? Se = R[Se.toUpperCase()] || R.NONE : Se = R.NONE;
    var Z = {};
    if (_e) {
      Z = {
        name: ae,
        value: _e.value,
        dimensions: _e.dimensions.slice(0),
        prefixes: Se,
        offset: ue
      };
      var Ce = !1;
      for (var Ie in L)
        if (Tt(L, Ie)) {
          for (var Ue = !0, Xe = 0; Xe < G.length; Xe++)
            if (Math.abs((Z.dimensions[Xe] || 0) - (L[Ie].dimensions[Xe] || 0)) > 1e-12) {
              Ue = !1;
              break;
            }
          if (Ue) {
            Ce = !0, Z.base = L[Ie];
            break;
          }
        }
      if (!Ce) {
        Ne = Ne || ae + "_STUFF";
        var je = {
          dimensions: _e.dimensions.slice(0)
        };
        je.key = Ne, L[Ne] = je, te[Ne] = {
          unit: Z,
          prefix: R.NONE[""]
        }, Z.base = L[Ne];
      }
    } else {
      if (Ne = Ne || ae + "_STUFF", G.indexOf(Ne) >= 0)
        throw new Error('Cannot create new base unit "' + ae + '": a base unit with that name already exists (and cannot be overridden)');
      G.push(Ne);
      for (var de in L)
        Tt(L, de) && (L[de].dimensions[G.length - 1] = 0);
      for (var ye = {
        dimensions: []
      }, Ae = 0; Ae < G.length; Ae++)
        ye.dimensions[Ae] = 0;
      ye.dimensions[G.length - 1] = 1, ye.key = Ne, L[Ne] = ye, Z = {
        name: ae,
        value: 1,
        dimensions: L[Ne].dimensions.slice(0),
        prefixes: Se,
        offset: ue,
        base: L[Ne]
      }, te[Ne] = {
        unit: Z,
        prefix: R.NONE[""]
      };
    }
    _.UNITS[ae] = Z;
    for (var ht = 0; ht < le.length; ht++) {
      var xt = le[ht], dt = {};
      for (var Le in Z)
        Tt(Z, Le) && (dt[Le] = Z[Le]);
      dt.name = xt, _.UNITS[xt] = dt;
    }
    return delete O.cache, new _(null, ae);
  }, _.deleteUnit = function(ae) {
    delete _.UNITS[ae], delete O.cache;
  }, _.PREFIXES = R, _.BASE_DIMENSIONS = G, _.BASE_UNITS = L, _.UNIT_SYSTEMS = $, _.UNITS = H, _;
}, {
  isClass: !0
}), cP = "unit", Hye = ["typed", "Unit"], Kye = /* @__PURE__ */ me(cP, Hye, (e) => {
  var {
    typed: t,
    Unit: r
  } = e;
  return t(cP, {
    Unit: function(a) {
      return a.clone();
    },
    string: function(a) {
      return r.isValuelessUnit(a) ? new r(null, a) : r.parse(a, {
        allowNoUnits: !0
      });
    },
    "number | BigNumber | Fraction | Complex, string | Unit": function(a, i) {
      return new r(a, i);
    },
    "number | BigNumber | Fraction": function(a) {
      return new r(a);
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), lP = "sparse", Xye = ["typed", "SparseMatrix"], jye = /* @__PURE__ */ me(lP, Xye, (e) => {
  var {
    typed: t,
    SparseMatrix: r
  } = e;
  return t(lP, {
    "": function() {
      return new r([]);
    },
    string: function(a) {
      return new r([], a);
    },
    "Array | Matrix": function(a) {
      return new r(a);
    },
    "Array | Matrix, string": function(a, i) {
      return new r(a, i);
    }
  });
}), dP = "createUnit", Yye = ["typed", "Unit"], Wye = /* @__PURE__ */ me(dP, Yye, (e) => {
  var {
    typed: t,
    Unit: r
  } = e;
  return t(dP, {
    // General function signature. First parameter is an object where each property is the definition of a new unit. The object keys are the unit names and the values are the definitions. The values can be objects, strings, or Units. If a property is an empty object or an empty string, a new base unit is created. The second parameter is the options.
    "Object, Object": function(a, i) {
      return r.createUnit(a, i);
    },
    // Same as above but without the options.
    Object: function(a) {
      return r.createUnit(a, {});
    },
    // Shortcut method for creating one unit.
    "string, Unit | string | Object, Object": function(a, i, o) {
      var s = {};
      return s[a] = i, r.createUnit(s, o);
    },
    // Same as above but without the options.
    "string, Unit | string | Object": function(a, i) {
      var o = {};
      return o[a] = i, r.createUnit(o, {});
    },
    // Without a definition, creates a base unit.
    string: function(a) {
      var i = {};
      return i[a] = {}, r.createUnit(i, {});
    }
  });
}), fP = "acos", Zye = ["typed", "config", "Complex"], Qye = /* @__PURE__ */ me(fP, Zye, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(fP, {
    number: function(i) {
      return i >= -1 && i <= 1 || r.predictable ? Math.acos(i) : new n(i, 0).acos();
    },
    Complex: function(i) {
      return i.acos();
    },
    BigNumber: function(i) {
      return i.acos();
    }
  });
}), mP = "acosh", $ye = ["typed", "config", "Complex"], Jye = /* @__PURE__ */ me(mP, $ye, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(mP, {
    number: function(i) {
      return i >= 1 || r.predictable ? EG(i) : i <= -1 ? new n(Math.log(Math.sqrt(i * i - 1) - i), Math.PI) : new n(i, 0).acosh();
    },
    Complex: function(i) {
      return i.acosh();
    },
    BigNumber: function(i) {
      return i.acosh();
    }
  });
}), pP = "acot", e3e = ["typed", "BigNumber"], t3e = /* @__PURE__ */ me(pP, e3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t(pP, {
    number: DG,
    Complex: function(a) {
      return a.acot();
    },
    BigNumber: function(a) {
      return new r(1).div(a).atan();
    }
  });
}), hP = "acoth", r3e = ["typed", "config", "Complex", "BigNumber"], n3e = /* @__PURE__ */ me(hP, r3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n,
    BigNumber: a
  } = e;
  return t(hP, {
    number: function(o) {
      return o >= 1 || o <= -1 || r.predictable ? MG(o) : new n(o, 0).acoth();
    },
    Complex: function(o) {
      return o.acoth();
    },
    BigNumber: function(o) {
      return new a(1).div(o).atanh();
    }
  });
}), vP = "acsc", a3e = ["typed", "config", "Complex", "BigNumber"], i3e = /* @__PURE__ */ me(vP, a3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n,
    BigNumber: a
  } = e;
  return t(vP, {
    number: function(o) {
      return o <= -1 || o >= 1 || r.predictable ? IG(o) : new n(o, 0).acsc();
    },
    Complex: function(o) {
      return o.acsc();
    },
    BigNumber: function(o) {
      return new a(1).div(o).asin();
    }
  });
}), gP = "acsch", o3e = ["typed", "BigNumber"], s3e = /* @__PURE__ */ me(gP, o3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t(gP, {
    number: TG,
    Complex: function(a) {
      return a.acsch();
    },
    BigNumber: function(a) {
      return new r(1).div(a).asinh();
    }
  });
}), yP = "asec", u3e = ["typed", "config", "Complex", "BigNumber"], c3e = /* @__PURE__ */ me(yP, u3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n,
    BigNumber: a
  } = e;
  return t(yP, {
    number: function(o) {
      return o <= -1 || o >= 1 || r.predictable ? NG(o) : new n(o, 0).asec();
    },
    Complex: function(o) {
      return o.asec();
    },
    BigNumber: function(o) {
      return new a(1).div(o).acos();
    }
  });
}), bP = "asech", l3e = ["typed", "config", "Complex", "BigNumber"], d3e = /* @__PURE__ */ me(bP, l3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n,
    BigNumber: a
  } = e;
  return t(bP, {
    number: function(o) {
      if (o <= 1 && o >= -1 || r.predictable) {
        var s = 1 / o;
        if (s > 0 || r.predictable)
          return PG(o);
        var u = Math.sqrt(s * s - 1);
        return new n(Math.log(u - s), Math.PI);
      }
      return new n(o, 0).asech();
    },
    Complex: function(o) {
      return o.asech();
    },
    BigNumber: function(o) {
      return new a(1).div(o).acosh();
    }
  });
}), xP = "asin", f3e = ["typed", "config", "Complex"], m3e = /* @__PURE__ */ me(xP, f3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(xP, {
    number: function(i) {
      return i >= -1 && i <= 1 || r.predictable ? Math.asin(i) : new n(i, 0).asin();
    },
    Complex: function(i) {
      return i.asin();
    },
    BigNumber: function(i) {
      return i.asin();
    }
  });
}), p3e = "asinh", h3e = ["typed"], v3e = /* @__PURE__ */ me(p3e, h3e, (e) => {
  var {
    typed: t
  } = e;
  return t("asinh", {
    number: BG,
    Complex: function(n) {
      return n.asinh();
    },
    BigNumber: function(n) {
      return n.asinh();
    }
  });
}), g3e = "atan", y3e = ["typed"], QV = /* @__PURE__ */ me(g3e, y3e, (e) => {
  var {
    typed: t
  } = e;
  return t("atan", {
    number: function(n) {
      return Math.atan(n);
    },
    Complex: function(n) {
      return n.atan();
    },
    BigNumber: function(n) {
      return n.atan();
    }
  });
}), _P = "atan2", b3e = ["typed", "matrix", "equalScalar", "BigNumber", "DenseMatrix", "concat"], x3e = /* @__PURE__ */ me(_P, b3e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    BigNumber: a,
    DenseMatrix: i,
    concat: o
  } = e, s = Ru({
    typed: t,
    equalScalar: n
  }), u = Ao({
    typed: t
  }), c = dV({
    typed: t,
    equalScalar: n
  }), l = Ri({
    typed: t,
    equalScalar: n
  }), d = ti({
    typed: t,
    DenseMatrix: i
  }), f = Ln({
    typed: t,
    matrix: r,
    concat: o
  });
  return t(_P, {
    "number, number": Math.atan2,
    // Complex numbers doesn't seem to have a reasonable implementation of
    // atan2(). Even Matlab removed the support, after they only calculated
    // the atan only on base of the real part of the numbers and ignored
    // the imaginary.
    "BigNumber, BigNumber": (m, h) => a.atan2(m, h)
  }, f({
    scalar: "number | BigNumber",
    SS: c,
    DS: u,
    SD: s,
    Ss: l,
    sS: d
  }));
}), SP = "atanh", _3e = ["typed", "config", "Complex"], S3e = /* @__PURE__ */ me(SP, _3e, (e) => {
  var {
    typed: t,
    config: r,
    Complex: n
  } = e;
  return t(SP, {
    number: function(i) {
      return i <= 1 && i >= -1 || r.predictable ? OG(i) : new n(i, 0).atanh();
    },
    Complex: function(i) {
      return i.atanh();
    },
    BigNumber: function(i) {
      return i.atanh();
    }
  });
}), E1 = /* @__PURE__ */ me("trigUnit", ["typed"], (e) => {
  var {
    typed: t
  } = e;
  return {
    Unit: t.referToSelf((r) => (n) => {
      if (!n.hasBase(n.constructor.BASE_UNITS.ANGLE))
        throw new TypeError("Unit in function cot is no angle");
      return t.find(r, n.valueType())(n.value);
    })
  };
}), AP = "cos", A3e = ["typed"], $V = /* @__PURE__ */ me(AP, A3e, (e) => {
  var {
    typed: t
  } = e, r = E1({
    typed: t
  });
  return t(AP, {
    number: Math.cos,
    "Complex | BigNumber": (n) => n.cos()
  }, r);
}), wP = "cosh", w3e = ["typed"], C3e = /* @__PURE__ */ me(wP, w3e, (e) => {
  var {
    typed: t
  } = e;
  return t(wP, {
    number: gpe,
    "Complex | BigNumber": (r) => r.cosh()
  });
}), CP = "cot", E3e = ["typed", "BigNumber"], D3e = /* @__PURE__ */ me(CP, E3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e, n = E1({
    typed: t
  });
  return t(CP, {
    number: FG,
    Complex: (a) => a.cot(),
    BigNumber: (a) => new r(1).div(a.tan())
  }, n);
}), EP = "coth", M3e = ["typed", "BigNumber"], I3e = /* @__PURE__ */ me(EP, M3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t(EP, {
    number: RG,
    Complex: (n) => n.coth(),
    BigNumber: (n) => new r(1).div(n.tanh())
  });
}), DP = "csc", T3e = ["typed", "BigNumber"], N3e = /* @__PURE__ */ me(DP, T3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e, n = E1({
    typed: t
  });
  return t(DP, {
    number: LG,
    Complex: (a) => a.csc(),
    BigNumber: (a) => new r(1).div(a.sin())
  }, n);
}), MP = "csch", P3e = ["typed", "BigNumber"], B3e = /* @__PURE__ */ me(MP, P3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t(MP, {
    number: kG,
    Complex: (n) => n.csch(),
    BigNumber: (n) => new r(1).div(n.sinh())
  });
}), IP = "sec", O3e = ["typed", "BigNumber"], F3e = /* @__PURE__ */ me(IP, O3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e, n = E1({
    typed: t
  });
  return t(IP, {
    number: zG,
    Complex: (a) => a.sec(),
    BigNumber: (a) => new r(1).div(a.cos())
  }, n);
}), TP = "sech", R3e = ["typed", "BigNumber"], L3e = /* @__PURE__ */ me(TP, R3e, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t(TP, {
    number: UG,
    Complex: (n) => n.sech(),
    BigNumber: (n) => new r(1).div(n.cosh())
  });
}), NP = "sin", k3e = ["typed"], JV = /* @__PURE__ */ me(NP, k3e, (e) => {
  var {
    typed: t
  } = e, r = E1({
    typed: t
  });
  return t(NP, {
    number: Math.sin,
    "Complex | BigNumber": (n) => n.sin()
  }, r);
}), PP = "sinh", z3e = ["typed"], U3e = /* @__PURE__ */ me(PP, z3e, (e) => {
  var {
    typed: t
  } = e;
  return t(PP, {
    number: GG,
    "Complex | BigNumber": (r) => r.sinh()
  });
}), BP = "tan", G3e = ["typed"], V3e = /* @__PURE__ */ me(BP, G3e, (e) => {
  var {
    typed: t
  } = e, r = E1({
    typed: t
  });
  return t(BP, {
    number: Math.tan,
    "Complex | BigNumber": (n) => n.tan()
  }, r);
}), q3e = "tanh", H3e = ["typed"], K3e = /* @__PURE__ */ me(q3e, H3e, (e) => {
  var {
    typed: t
  } = e;
  return t("tanh", {
    number: bpe,
    "Complex | BigNumber": (r) => r.tanh()
  });
}), OP = "setCartesian", X3e = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], j3e = /* @__PURE__ */ me(OP, X3e, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return t(OP, {
    "Array | Matrix, Array | Matrix": function(u, c) {
      var l = [];
      if (n(r(u), new i(0)) !== 0 && n(r(c), new i(0)) !== 0) {
        var d = $r(Array.isArray(u) ? u : u.toArray()).sort(a), f = $r(Array.isArray(c) ? c : c.toArray()).sort(a);
        l = [];
        for (var m = 0; m < d.length; m++)
          for (var h = 0; h < f.length; h++)
            l.push([d[m], f[h]]);
      }
      return Array.isArray(u) && Array.isArray(c) ? l : new o(l);
    }
  });
}), FP = "setDifference", Y3e = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], W3e = /* @__PURE__ */ me(FP, Y3e, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return t(FP, {
    "Array | Matrix, Array | Matrix": function(u, c) {
      var l;
      if (n(r(u), new i(0)) === 0)
        l = [];
      else {
        if (n(r(c), new i(0)) === 0)
          return $r(u.toArray());
        var d = c1($r(Array.isArray(u) ? u : u.toArray()).sort(a)), f = c1($r(Array.isArray(c) ? c : c.toArray()).sort(a));
        l = [];
        for (var m, h = 0; h < d.length; h++) {
          m = !1;
          for (var p = 0; p < f.length; p++)
            if (a(d[h].value, f[p].value) === 0 && d[h].identifier === f[p].identifier) {
              m = !0;
              break;
            }
          m || l.push(d[h]);
        }
      }
      return Array.isArray(u) && Array.isArray(c) ? Gy(l) : new o(Gy(l));
    }
  });
}), RP = "setDistinct", Z3e = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], Q3e = /* @__PURE__ */ me(RP, Z3e, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return t(RP, {
    "Array | Matrix": function(u) {
      var c;
      if (n(r(u), new i(0)) === 0)
        c = [];
      else {
        var l = $r(Array.isArray(u) ? u : u.toArray()).sort(a);
        c = [], c.push(l[0]);
        for (var d = 1; d < l.length; d++)
          a(l[d], l[d - 1]) !== 0 && c.push(l[d]);
      }
      return Array.isArray(u) ? c : new o(c);
    }
  });
}), LP = "setIntersect", $3e = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], J3e = /* @__PURE__ */ me(LP, $3e, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return t(LP, {
    "Array | Matrix, Array | Matrix": function(u, c) {
      var l;
      if (n(r(u), new i(0)) === 0 || n(r(c), new i(0)) === 0)
        l = [];
      else {
        var d = c1($r(Array.isArray(u) ? u : u.toArray()).sort(a)), f = c1($r(Array.isArray(c) ? c : c.toArray()).sort(a));
        l = [];
        for (var m = 0; m < d.length; m++)
          for (var h = 0; h < f.length; h++)
            if (a(d[m].value, f[h].value) === 0 && d[m].identifier === f[h].identifier) {
              l.push(d[m]);
              break;
            }
      }
      return Array.isArray(u) && Array.isArray(c) ? Gy(l) : new o(Gy(l));
    }
  });
}), kP = "setIsSubset", ebe = ["typed", "size", "subset", "compareNatural", "Index"], tbe = /* @__PURE__ */ me(kP, ebe, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return t(kP, {
    "Array | Matrix, Array | Matrix": function(s, u) {
      if (n(r(s), new i(0)) === 0)
        return !0;
      if (n(r(u), new i(0)) === 0)
        return !1;
      for (var c = c1($r(Array.isArray(s) ? s : s.toArray()).sort(a)), l = c1($r(Array.isArray(u) ? u : u.toArray()).sort(a)), d, f = 0; f < c.length; f++) {
        d = !1;
        for (var m = 0; m < l.length; m++)
          if (a(c[f].value, l[m].value) === 0 && c[f].identifier === l[m].identifier) {
            d = !0;
            break;
          }
        if (d === !1)
          return !1;
      }
      return !0;
    }
  });
}), zP = "setMultiplicity", rbe = ["typed", "size", "subset", "compareNatural", "Index"], nbe = /* @__PURE__ */ me(zP, rbe, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return t(zP, {
    "number | BigNumber | Fraction | Complex, Array | Matrix": function(s, u) {
      if (n(r(u), new i(0)) === 0)
        return 0;
      for (var c = $r(Array.isArray(u) ? u : u.toArray()), l = 0, d = 0; d < c.length; d++)
        a(c[d], s) === 0 && l++;
      return l;
    }
  });
}), UP = "setPowerset", abe = ["typed", "size", "subset", "compareNatural", "Index"], ibe = /* @__PURE__ */ me(UP, abe, (e) => {
  var {
    typed: t,
    size: r,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return t(UP, {
    "Array | Matrix": function(c) {
      if (n(r(c), new i(0)) === 0)
        return [];
      for (var l = $r(Array.isArray(c) ? c : c.toArray()).sort(a), d = [], f = 0; f.toString(2).length <= l.length; )
        d.push(o(l, f.toString(2).split("").reverse())), f++;
      return s(d);
    }
  });
  function o(u, c) {
    for (var l = [], d = 0; d < c.length; d++)
      c[d] === "1" && l.push(u[d]);
    return l;
  }
  function s(u) {
    for (var c = [], l = u.length - 1; l > 0; l--)
      for (var d = 0; d < l; d++)
        u[d].length > u[d + 1].length && (c = u[d], u[d] = u[d + 1], u[d + 1] = c);
    return u;
  }
}), GP = "setSize", obe = ["typed", "compareNatural"], sbe = /* @__PURE__ */ me(GP, obe, (e) => {
  var {
    typed: t,
    compareNatural: r
  } = e;
  return t(GP, {
    "Array | Matrix": function(a) {
      return Array.isArray(a) ? $r(a).length : $r(a.toArray()).length;
    },
    "Array | Matrix, boolean": function(a, i) {
      if (i === !1 || a.length === 0)
        return Array.isArray(a) ? $r(a).length : $r(a.toArray()).length;
      for (var o = $r(Array.isArray(a) ? a : a.toArray()).sort(r), s = 1, u = 1; u < o.length; u++)
        r(o[u], o[u - 1]) !== 0 && s++;
      return s;
    }
  });
}), VP = "setSymDifference", ube = ["typed", "size", "concat", "subset", "setDifference", "Index"], cbe = /* @__PURE__ */ me(VP, ube, (e) => {
  var {
    typed: t,
    size: r,
    concat: n,
    subset: a,
    setDifference: i,
    Index: o
  } = e;
  return t(VP, {
    "Array | Matrix, Array | Matrix": function(u, c) {
      if (a(r(u), new o(0)) === 0)
        return $r(c);
      if (a(r(c), new o(0)) === 0)
        return $r(u);
      var l = $r(u), d = $r(c);
      return n(i(l, d), i(d, l));
    }
  });
}), qP = "setUnion", lbe = ["typed", "size", "concat", "subset", "setIntersect", "setSymDifference", "Index"], dbe = /* @__PURE__ */ me(qP, lbe, (e) => {
  var {
    typed: t,
    size: r,
    concat: n,
    subset: a,
    setIntersect: i,
    setSymDifference: o,
    Index: s
  } = e;
  return t(qP, {
    "Array | Matrix, Array | Matrix": function(c, l) {
      if (a(r(c), new s(0)) === 0)
        return $r(l);
      if (a(r(l), new s(0)) === 0)
        return $r(c);
      var d = $r(c), f = $r(l);
      return n(o(d, f), i(d, f));
    }
  });
}), HP = "add", fbe = ["typed", "matrix", "addScalar", "equalScalar", "DenseMatrix", "SparseMatrix", "concat"], eq = /* @__PURE__ */ me(HP, fbe, (e) => {
  var {
    typed: t,
    matrix: r,
    addScalar: n,
    equalScalar: a,
    DenseMatrix: i,
    SparseMatrix: o,
    concat: s
  } = e, u = ef({
    typed: t
  }), c = BS({
    typed: t,
    equalScalar: a
  }), l = ym({
    typed: t,
    DenseMatrix: i
  }), d = Ln({
    typed: t,
    matrix: r,
    concat: s
  });
  return t(HP, {
    "any, any": n,
    "any, any, ...any": t.referToSelf((f) => (m, h, p) => {
      for (var g = f(m, h), v = 0; v < p.length; v++)
        g = f(g, p[v]);
      return g;
    })
  }, d({
    elop: n,
    DS: u,
    SS: c,
    Ss: l
  }));
}), KP = "hypot", mbe = ["typed", "abs", "addScalar", "divideScalar", "multiplyScalar", "sqrt", "smaller", "isPositive"], pbe = /* @__PURE__ */ me(KP, mbe, (e) => {
  var {
    typed: t,
    abs: r,
    addScalar: n,
    divideScalar: a,
    multiplyScalar: i,
    sqrt: o,
    smaller: s,
    isPositive: u
  } = e;
  return t(KP, {
    "... number | BigNumber": c,
    Array: c,
    Matrix: (l) => c($r(l.toArray()))
  });
  function c(l) {
    for (var d = 0, f = 0, m = 0; m < l.length; m++) {
      if (Mu(l[m]))
        throw new TypeError("Unexpected type of argument to hypot");
      var h = r(l[m]);
      s(f, h) ? (d = i(d, i(a(f, h), a(f, h))), d = n(d, 1), f = h) : d = n(d, u(h) ? i(a(h, f), a(h, f)) : h);
    }
    return i(f, o(d));
  }
}), XP = "norm", hbe = ["typed", "abs", "add", "pow", "conj", "sqrt", "multiply", "equalScalar", "larger", "smaller", "matrix", "ctranspose", "eigs"], tq = /* @__PURE__ */ me(XP, hbe, (e) => {
  var {
    typed: t,
    abs: r,
    add: n,
    pow: a,
    conj: i,
    sqrt: o,
    multiply: s,
    equalScalar: u,
    larger: c,
    smaller: l,
    matrix: d,
    ctranspose: f,
    eigs: m
  } = e;
  return t(XP, {
    number: Math.abs,
    Complex: function(w) {
      return w.abs();
    },
    BigNumber: function(w) {
      return w.abs();
    },
    boolean: function(w) {
      return Math.abs(w);
    },
    Array: function(w) {
      return x(d(w), 2);
    },
    Matrix: function(w) {
      return x(w, 2);
    },
    "Array, number | BigNumber | string": function(w, C) {
      return x(d(w), C);
    },
    "Matrix, number | BigNumber | string": function(w, C) {
      return x(w, C);
    }
  });
  function h(A) {
    var w = 0;
    return A.forEach(function(C) {
      var M = r(C);
      c(M, w) && (w = M);
    }, !0), w;
  }
  function p(A) {
    var w;
    return A.forEach(function(C) {
      var M = r(C);
      (!w || l(M, w)) && (w = M);
    }, !0), w || 0;
  }
  function g(A, w) {
    if (w === Number.POSITIVE_INFINITY || w === "inf")
      return h(A);
    if (w === Number.NEGATIVE_INFINITY || w === "-inf")
      return p(A);
    if (w === "fro")
      return x(A, 2);
    if (typeof w == "number" && !isNaN(w)) {
      if (!u(w, 0)) {
        var C = 0;
        return A.forEach(function(M) {
          C = n(a(r(M), w), C);
        }, !0), a(C, 1 / w);
      }
      return Number.POSITIVE_INFINITY;
    }
    throw new Error("Unsupported parameter value");
  }
  function v(A) {
    var w = 0;
    return A.forEach(function(C, M) {
      w = n(w, s(C, i(C)));
    }), r(o(w));
  }
  function y(A) {
    var w = [], C = 0;
    return A.forEach(function(M, T) {
      var N = T[1], I = n(w[N] || 0, r(M));
      c(I, C) && (C = I), w[N] = I;
    }, !0), C;
  }
  function _(A) {
    var w = A.size();
    if (w[0] !== w[1])
      throw new RangeError("Invalid matrix dimensions");
    var C = f(A), M = s(C, A), T = m(M).values.toArray(), N = T[T.length - 1];
    return r(o(N));
  }
  function S(A) {
    var w = [], C = 0;
    return A.forEach(function(M, T) {
      var N = T[0], I = n(w[N] || 0, r(M));
      c(I, C) && (C = I), w[N] = I;
    }, !0), C;
  }
  function b(A, w) {
    if (w === 1)
      return y(A);
    if (w === Number.POSITIVE_INFINITY || w === "inf")
      return S(A);
    if (w === "fro")
      return v(A);
    if (w === 2)
      return _(A);
    throw new Error("Unsupported parameter value " + w);
  }
  function x(A, w) {
    var C = A.size();
    if (C.length === 1)
      return g(A, w);
    if (C.length === 2) {
      if (C[0] && C[1])
        return b(A, w);
      throw new RangeError("Invalid matrix dimensions");
    }
  }
}), jP = "dot", vbe = ["typed", "addScalar", "multiplyScalar", "conj", "size"], rq = /* @__PURE__ */ me(jP, vbe, (e) => {
  var {
    typed: t,
    addScalar: r,
    multiplyScalar: n,
    conj: a,
    size: i
  } = e;
  return t(jP, {
    "Array | DenseMatrix, Array | DenseMatrix": s,
    "SparseMatrix, SparseMatrix": u
  });
  function o(l, d) {
    var f = c(l), m = c(d), h, p;
    if (f.length === 1)
      h = f[0];
    else if (f.length === 2 && f[1] === 1)
      h = f[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + f.join(", ") + ")");
    if (m.length === 1)
      p = m[0];
    else if (m.length === 2 && m[1] === 1)
      p = m[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + m.join(", ") + ")");
    if (h !== p) throw new RangeError("Vectors must have equal length (" + h + " != " + p + ")");
    if (h === 0) throw new RangeError("Cannot calculate the dot product of empty vectors");
    return h;
  }
  function s(l, d) {
    var f = o(l, d), m = Zt(l) ? l._data : l, h = Zt(l) ? l._datatype || l.getDataType() : void 0, p = Zt(d) ? d._data : d, g = Zt(d) ? d._datatype || d.getDataType() : void 0, v = c(l).length === 2, y = c(d).length === 2, _ = r, S = n;
    if (h && g && h === g && typeof h == "string" && h !== "mixed") {
      var b = h;
      _ = t.find(r, [b, b]), S = t.find(n, [b, b]);
    }
    if (!v && !y) {
      for (var x = S(a(m[0]), p[0]), A = 1; A < f; A++)
        x = _(x, S(a(m[A]), p[A]));
      return x;
    }
    if (!v && y) {
      for (var w = S(a(m[0]), p[0][0]), C = 1; C < f; C++)
        w = _(w, S(a(m[C]), p[C][0]));
      return w;
    }
    if (v && !y) {
      for (var M = S(a(m[0][0]), p[0]), T = 1; T < f; T++)
        M = _(M, S(a(m[T][0]), p[T]));
      return M;
    }
    if (v && y) {
      for (var N = S(a(m[0][0]), p[0][0]), I = 1; I < f; I++)
        N = _(N, S(a(m[I][0]), p[I][0]));
      return N;
    }
  }
  function u(l, d) {
    o(l, d);
    for (var f = l._index, m = l._values, h = d._index, p = d._values, g = 0, v = r, y = n, _ = 0, S = 0; _ < f.length && S < h.length; ) {
      var b = f[_], x = h[S];
      if (b < x) {
        _++;
        continue;
      }
      if (b > x) {
        S++;
        continue;
      }
      b === x && (g = v(g, y(m[_], p[S])), _++, S++);
    }
    return g;
  }
  function c(l) {
    return Zt(l) ? l.size() : i(l);
  }
}), gbe = "trace", ybe = ["typed", "matrix", "add"], bbe = /* @__PURE__ */ me(gbe, ybe, (e) => {
  var {
    typed: t,
    matrix: r,
    add: n
  } = e;
  return t("trace", {
    Array: function(s) {
      return a(r(s));
    },
    SparseMatrix: i,
    DenseMatrix: a,
    any: Jt
  });
  function a(o) {
    var s = o._size, u = o._data;
    switch (s.length) {
      case 1:
        if (s[0] === 1)
          return Jt(u[0]);
        throw new RangeError("Matrix must be square (size: " + Br(s) + ")");
      case 2: {
        var c = s[0], l = s[1];
        if (c === l) {
          for (var d = 0, f = 0; f < c; f++)
            d = n(d, u[f][f]);
          return d;
        } else
          throw new RangeError("Matrix must be square (size: " + Br(s) + ")");
      }
      default:
        throw new RangeError("Matrix must be two dimensional (size: " + Br(s) + ")");
    }
  }
  function i(o) {
    var s = o._values, u = o._index, c = o._ptr, l = o._size, d = l[0], f = l[1];
    if (d === f) {
      var m = 0;
      if (s.length > 0)
        for (var h = 0; h < f; h++)
          for (var p = c[h], g = c[h + 1], v = p; v < g; v++) {
            var y = u[v];
            if (y === h) {
              m = n(m, s[v]);
              break;
            }
            if (y > h)
              break;
          }
      return m;
    }
    throw new RangeError("Matrix must be square (size: " + Br(l) + ")");
  }
}), YP = "index", xbe = ["typed", "Index"], _be = /* @__PURE__ */ me(YP, xbe, (e) => {
  var {
    typed: t,
    Index: r
  } = e;
  return t(YP, {
    "...number | string | BigNumber | Range | Array | Matrix": function(a) {
      var i = a.map(function(s) {
        return hr(s) ? s.toNumber() : en(s) || Zt(s) ? s.map(function(u) {
          return hr(u) ? u.toNumber() : u;
        }) : s;
      }), o = new r();
      return r.apply(o, i), o;
    }
  });
}), nq = /* @__PURE__ */ new Set(["end"]), Sbe = "Node", Abe = ["mathWithTransform"], wbe = /* @__PURE__ */ me(Sbe, Abe, (e) => {
  var {
    mathWithTransform: t
  } = e;
  function r(a) {
    for (var i of [...nq])
      if (a.has(i))
        throw new Error('Scope contains an illegal symbol, "' + i + '" is a reserved keyword');
  }
  class n {
    get type() {
      return "Node";
    }
    get isNode() {
      return !0;
    }
    /**
     * Evaluate the node
     * @param {Object} [scope]  Scope to read/write variables
     * @return {*}              Returns the result
     */
    evaluate(i) {
      return this.compile().evaluate(i);
    }
    /**
     * Compile the node into an optimized, evauatable JavaScript function
     * @return {{evaluate: function([Object])}} object
     *                Returns an object with a function 'evaluate',
     *                which can be invoked as expr.evaluate([scope: Object]),
     *                where scope is an optional object with
     *                variables.
     */
    compile() {
      var i = this._compile(t, {}), o = {}, s = null;
      function u(c) {
        var l = Np(c);
        return r(l), i(l, o, s);
      }
      return {
        evaluate: u
      };
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      throw new Error("Method _compile must be implemented by type " + this.type);
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      throw new Error("Cannot run forEach on a Node interface");
    }
    /**
     * Create a new Node whose children are the results of calling the
     * provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {OperatorNode} Returns a transformed copy of the node
     */
    map(i) {
      throw new Error("Cannot run map on a Node interface");
    }
    /**
     * Validate whether an object is a Node, for use with map
     * @param {Node} node
     * @returns {Node} Returns the input if it's a node, else throws an Error
     * @protected
     */
    _ifNode(i) {
      if (!gn(i))
        throw new TypeError("Callback function must return a Node");
      return i;
    }
    /**
     * Recursively traverse all nodes in a node tree. Executes given callback for
     * this node and each of its child nodes.
     * @param {function(node: Node, path: string, parent: Node)} callback
     *          A callback called for every node in the node tree.
     */
    traverse(i) {
      i(this, null, null);
      function o(s, u) {
        s.forEach(function(c, l, d) {
          u(c, l, d), o(c, u);
        });
      }
      o(this, i);
    }
    /**
     * Recursively transform a node tree via a transform function.
     *
     * For example, to replace all nodes of type SymbolNode having name 'x' with
     * a ConstantNode with value 2:
     *
     *     const res = Node.transform(function (node, path, parent) {
     *       if (node && node.isSymbolNode) && (node.name === 'x')) {
     *         return new ConstantNode(2)
     *       }
     *       else {
     *         return node
     *       }
     *     })
     *
     * @param {function(node: Node, path: string, parent: Node) : Node} callback
     *          A mapping function accepting a node, and returning
     *          a replacement for the node or the original node. The "signature"
     *          of the callback must be:
     *          callback(node: Node, index: string, parent: Node) : Node
     * @return {Node} Returns the original node or its replacement
     */
    transform(i) {
      function o(s, u, c) {
        var l = i(s, u, c);
        return l !== s ? l : s.map(o);
      }
      return o(this, null, null);
    }
    /**
     * Find any node in the node tree matching given filter function. For
     * example, to find all nodes of type SymbolNode having name 'x':
     *
     *     const results = Node.filter(function (node) {
     *       return (node && node.isSymbolNode) && (node.name === 'x')
     *     })
     *
     * @param {function(node: Node, path: string, parent: Node) : Node} callback
     *            A test function returning true when a node matches, and false
     *            otherwise. Function signature:
     *            callback(node: Node, index: string, parent: Node) : boolean
     * @return {Node[]} nodes
     *            An array with nodes matching given filter criteria
     */
    filter(i) {
      var o = [];
      return this.traverse(function(s, u, c) {
        i(s, u, c) && o.push(s);
      }), o;
    }
    /**
     * Create a shallow clone of this node
     * @return {Node}
     */
    clone() {
      throw new Error("Cannot clone a Node interface");
    }
    /**
     * Create a deep clone of this node
     * @return {Node}
     */
    cloneDeep() {
      return this.map(function(i) {
        return i.cloneDeep();
      });
    }
    /**
     * Deep compare this node with another node.
     * @param {Node} other
     * @return {boolean} Returns true when both nodes are of the same type and
     *                   contain the same values (as do their childs)
     */
    equals(i) {
      return i ? this.type === i.type && gl(this, i) : !1;
    }
    /**
     * Get string representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)"or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toString(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toString(i);
    }
    /**
     * Internal function to generate the string output.
     * This has to be implemented by every Node
     *
     * @throws {Error}
     */
    _toString() {
      throw new Error("_toString not implemented for " + this.type);
    }
    /**
     * Get a JSON representation of the node
     * Both .toJSON() and the static .fromJSON(json) should be implemented by all
     * implementations of Node
     * @returns {Object}
     */
    toJSON() {
      throw new Error("Cannot serialize object: toJSON not implemented by " + this.type);
    }
    /**
     * Get HTML representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)" or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toHTML(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toHTML(i);
    }
    /**
     * Internal function to generate the HTML output.
     * This has to be implemented by every Node
     *
     * @throws {Error}
     */
    _toHTML() {
      throw new Error("_toHTML not implemented for " + this.type);
    }
    /**
     * Get LaTeX representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)"or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toTex(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toTex(i);
    }
    /**
     * Internal function to generate the LaTeX output.
     * This has to be implemented by every Node
     *
     * @param {Object} [options]
     * @throws {Error}
     */
    _toTex(i) {
      throw new Error("_toTex not implemented for " + this.type);
    }
    /**
     * Helper used by `to...` functions.
     */
    _getCustomString(i) {
      if (i && typeof i == "object")
        switch (typeof i.handler) {
          case "object":
          case "undefined":
            return;
          case "function":
            return i.handler(this, i);
          default:
            throw new TypeError("Object or function expected as callback");
        }
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type;
    }
    /**
     * Get the content of the current Node.
     * @return {Node} node
     **/
    getContent() {
      return this;
    }
  }
  return n;
}, {
  isClass: !0,
  isNode: !0
});
function wo(e) {
  return e && e.isIndexError ? new ou(e.index + 1, e.min + 1, e.max !== void 0 ? e.max + 1 : void 0) : e;
}
function aq(e) {
  var {
    subset: t
  } = e;
  return function(n, a) {
    try {
      if (Array.isArray(n))
        return t(n, a);
      if (n && typeof n.subset == "function")
        return n.subset(a);
      if (typeof n == "string")
        return t(n, a);
      if (typeof n == "object") {
        if (!a.isObjectProperty())
          throw new TypeError("Cannot apply a numeric index as object property");
        return yo(n, a.getObjectProperty());
      } else
        throw new TypeError("Cannot apply index: unsupported type of object");
    } catch (i) {
      throw wo(i);
    }
  };
}
var n2 = "AccessorNode", Cbe = ["subset", "Node"], Ebe = /* @__PURE__ */ me(n2, Cbe, (e) => {
  var {
    subset: t,
    Node: r
  } = e, n = aq({
    subset: t
  });
  function a(o) {
    return !(Xd(o) || cs(o) || Vr(o) || vl(o) || Kh(o) || pc(o) || Wa(o));
  }
  class i extends r {
    /**
     * @constructor AccessorNode
     * @extends {Node}
     * Access an object property or get a matrix subset
     *
     * @param {Node} object                 The object from which to retrieve
     *                                      a property or subset.
     * @param {IndexNode} index             IndexNode containing ranges
     */
    constructor(s, u) {
      if (super(), !gn(s))
        throw new TypeError('Node expected for parameter "object"');
      if (!gm(u))
        throw new TypeError('IndexNode expected for parameter "index"');
      this.object = s, this.index = u;
    }
    // readonly property name
    get name() {
      return this.index ? this.index.isObjectProperty() ? this.index.getObjectProperty() : "" : this.object.name || "";
    }
    get type() {
      return n2;
    }
    get isAccessorNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(s, u) {
      var c = this.object._compile(s, u), l = this.index._compile(s, u);
      if (this.index.isObjectProperty()) {
        var d = this.index.getObjectProperty();
        return function(m, h, p) {
          return yo(c(m, h, p), d);
        };
      } else
        return function(m, h, p) {
          var g = c(m, h, p), v = l(m, h, g);
          return n(g, v);
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(s) {
      s(this.object, "object", this), s(this.index, "index", this);
    }
    /**
     * Create a new AccessorNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {AccessorNode} Returns a transformed copy of the node
     */
    map(s) {
      return new i(this._ifNode(s(this.object, "object", this)), this._ifNode(s(this.index, "index", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {AccessorNode}
     */
    clone() {
      return new i(this.object, this.index);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string}
     */
    _toString(s) {
      var u = this.object.toString(s);
      return a(this.object) && (u = "(" + u + ")"), u + this.index.toString(s);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string}
     */
    _toHTML(s) {
      var u = this.object.toHTML(s);
      return a(this.object) && (u = '<span class="math-parenthesis math-round-parenthesis">(</span>' + u + '<span class="math-parenthesis math-round-parenthesis">)</span>'), u + this.index.toHTML(s);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string}
     */
    _toTex(s) {
      var u = this.object.toTex(s);
      return a(this.object) && (u = "\\left(' + object + '\\right)"), u + this.index.toTex(s);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: n2,
        object: this.object,
        index: this.index
      };
    }
    /**
     * Instantiate an AccessorNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "AccessorNode", object: ..., index: ...}`,
     *     where mathjs is optional
     * @returns {AccessorNode}
     */
    static fromJSON(s) {
      return new i(s.object, s.index);
    }
  }
  return $a(i, "name", n2), i;
}, {
  isClass: !0,
  isNode: !0
}), a2 = "ArrayNode", Dbe = ["Node"], Mbe = /* @__PURE__ */ me(a2, Dbe, (e) => {
  var {
    Node: t
  } = e;
  class r extends t {
    /**
     * @constructor ArrayNode
     * @extends {Node}
     * Holds an 1-dimensional array with items
     * @param {Node[]} [items]   1 dimensional array with items
     */
    constructor(a) {
      if (super(), this.items = a || [], !Array.isArray(this.items) || !this.items.every(gn))
        throw new TypeError("Array containing Nodes expected");
    }
    get type() {
      return a2;
    }
    get isArrayNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = sl(this.items, function(c) {
        return c._compile(a, i);
      }), s = a.config.matrix !== "Array";
      if (s) {
        var u = a.matrix;
        return function(l, d, f) {
          return u(sl(o, function(m) {
            return m(l, d, f);
          }));
        };
      } else
        return function(l, d, f) {
          return sl(o, function(m) {
            return m(l, d, f);
          });
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      for (var i = 0; i < this.items.length; i++) {
        var o = this.items[i];
        a(o, "items[" + i + "]", this);
      }
    }
    /**
     * Create a new ArrayNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ArrayNode} Returns a transformed copy of the node
     */
    map(a) {
      for (var i = [], o = 0; o < this.items.length; o++)
        i[o] = this._ifNode(a(this.items[o], "items[" + o + "]", this));
      return new r(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ArrayNode}
     */
    clone() {
      return new r(this.items.slice(0));
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      var i = this.items.map(function(o) {
        return o.toString(a);
      });
      return "[" + i.join(", ") + "]";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: a2,
        items: this.items
      };
    }
    /**
     * Instantiate an ArrayNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ArrayNode", items: [...]}`,
     *                       where mathjs is optional
     * @returns {ArrayNode}
     */
    static fromJSON(a) {
      return new r(a.items);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      var i = this.items.map(function(o) {
        return o.toHTML(a);
      });
      return '<span class="math-parenthesis math-square-parenthesis">[</span>' + i.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      function i(o, s) {
        var u = o.some(cs) && !o.every(cs), c = s || u, l = c ? "&" : "\\\\", d = o.map(function(f) {
          return f.items ? i(f.items, !s) : f.toTex(a);
        }).join(l);
        return u || !c || c && !s ? "\\begin{bmatrix}" + d + "\\end{bmatrix}" : d;
      }
      return i(this.items, !1);
    }
  }
  return $a(r, "name", a2), r;
}, {
  isClass: !0,
  isNode: !0
});
function Ibe(e) {
  var {
    subset: t,
    matrix: r
  } = e;
  return function(a, i, o) {
    try {
      if (Array.isArray(a)) {
        var s = r(a).subset(i, o).valueOf();
        return s.forEach((u, c) => {
          a[c] = u;
        }), a;
      } else {
        if (a && typeof a.subset == "function")
          return a.subset(i, o);
        if (typeof a == "string")
          return t(a, i, o);
        if (typeof a == "object") {
          if (!i.isObjectProperty())
            throw TypeError("Cannot apply a numeric index as object property");
          return i1(a, i.getObjectProperty(), o), a;
        } else
          throw new TypeError("Cannot apply index: unsupported type of object");
      }
    } catch (u) {
      throw wo(u);
    }
  };
}
var _u = [{
  // assignment
  AssignmentNode: {},
  FunctionAssignmentNode: {}
}, {
  // conditional expression
  ConditionalNode: {
    latexLeftParens: !1,
    latexRightParens: !1,
    latexParens: !1
    // conditionals don't need parentheses in LaTeX because
    // they are 2 dimensional
  }
}, {
  // logical or
  "OperatorNode:or": {
    op: "or",
    associativity: "left",
    associativeWith: []
  }
}, {
  // logical xor
  "OperatorNode:xor": {
    op: "xor",
    associativity: "left",
    associativeWith: []
  }
}, {
  // logical and
  "OperatorNode:and": {
    op: "and",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise or
  "OperatorNode:bitOr": {
    op: "|",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise xor
  "OperatorNode:bitXor": {
    op: "^|",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise and
  "OperatorNode:bitAnd": {
    op: "&",
    associativity: "left",
    associativeWith: []
  }
}, {
  // relational operators
  "OperatorNode:equal": {
    op: "==",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:unequal": {
    op: "!=",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:smaller": {
    op: "<",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:larger": {
    op: ">",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:smallerEq": {
    op: "<=",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:largerEq": {
    op: ">=",
    associativity: "left",
    associativeWith: []
  },
  RelationalNode: {
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitshift operators
  "OperatorNode:leftShift": {
    op: "<<",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:rightArithShift": {
    op: ">>",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:rightLogShift": {
    op: ">>>",
    associativity: "left",
    associativeWith: []
  }
}, {
  // unit conversion
  "OperatorNode:to": {
    op: "to",
    associativity: "left",
    associativeWith: []
  }
}, {
  // range
  RangeNode: {}
}, {
  // addition, subtraction
  "OperatorNode:add": {
    op: "+",
    associativity: "left",
    associativeWith: ["OperatorNode:add", "OperatorNode:subtract"]
  },
  "OperatorNode:subtract": {
    op: "-",
    associativity: "left",
    associativeWith: []
  }
}, {
  // multiply, divide, modulus
  "OperatorNode:multiply": {
    op: "*",
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
  },
  "OperatorNode:divide": {
    op: "/",
    associativity: "left",
    associativeWith: [],
    latexLeftParens: !1,
    latexRightParens: !1,
    latexParens: !1
    // fractions don't require parentheses because
    // they're 2 dimensional, so parens aren't needed
    // in LaTeX
  },
  "OperatorNode:dotMultiply": {
    op: ".*",
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "OperatorNode:dotMultiply", "OperatorNode:doDivide"]
  },
  "OperatorNode:dotDivide": {
    op: "./",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:mod": {
    op: "mod",
    associativity: "left",
    associativeWith: []
  }
}, {
  // Repeat multiplication for implicit multiplication
  "OperatorNode:multiply": {
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
  }
}, {
  // unary prefix operators
  "OperatorNode:unaryPlus": {
    op: "+",
    associativity: "right"
  },
  "OperatorNode:unaryMinus": {
    op: "-",
    associativity: "right"
  },
  "OperatorNode:bitNot": {
    op: "~",
    associativity: "right"
  },
  "OperatorNode:not": {
    op: "not",
    associativity: "right"
  }
}, {
  // exponentiation
  "OperatorNode:pow": {
    op: "^",
    associativity: "right",
    associativeWith: [],
    latexRightParens: !1
    // the exponent doesn't need parentheses in
    // LaTeX because it's 2 dimensional
    // (it's on top)
  },
  "OperatorNode:dotPow": {
    op: ".^",
    associativity: "right",
    associativeWith: []
  }
}, {
  // factorial
  "OperatorNode:factorial": {
    op: "!",
    associativity: "left"
  }
}, {
  // matrix transpose
  "OperatorNode:ctranspose": {
    op: "'",
    associativity: "left"
  }
}];
function i2(e, t) {
  if (!t || t !== "auto") return e;
  for (var r = e; pc(r); ) r = r.content;
  return r;
}
function In(e, t, r, n) {
  var a = e;
  t !== "keep" && (a = e.getContent());
  for (var i = a.getIdentifier(), o = null, s = 0; s < _u.length; s++)
    if (i in _u[s]) {
      o = s;
      break;
    }
  if (i === "OperatorNode:multiply" && a.implicit && r !== "show") {
    var u = i2(a.args[0], t);
    !(Vr(u) && n && n.getIdentifier() === "OperatorNode:divide" && k_(i2(n.args[0], t))) && !(u.getIdentifier() === "OperatorNode:divide" && k_(i2(u.args[0], t)) && Vr(i2(u.args[1]))) && (o += 1);
  }
  return o;
}
function A0(e, t) {
  var r = e;
  t !== "keep" && (r = e.getContent());
  var n = r.getIdentifier(), a = In(r, t);
  if (a === null)
    return null;
  var i = _u[a][n];
  if (Tt(i, "associativity")) {
    if (i.associativity === "left")
      return "left";
    if (i.associativity === "right")
      return "right";
    throw Error("'" + n + "' has the invalid associativity '" + i.associativity + "'.");
  }
  return null;
}
function k5(e, t, r) {
  var n = r !== "keep" ? e.getContent() : e, a = r !== "keep" ? e.getContent() : t, i = n.getIdentifier(), o = a.getIdentifier(), s = In(n, r);
  if (s === null)
    return null;
  var u = _u[s][i];
  if (Tt(u, "associativeWith") && u.associativeWith instanceof Array) {
    for (var c = 0; c < u.associativeWith.length; c++)
      if (u.associativeWith[c] === o)
        return !0;
    return !1;
  }
  return null;
}
function Tbe(e) {
  var t = "OperatorNode:" + e;
  for (var r of _u)
    if (t in r)
      return r[t].op;
  return null;
}
var o2 = "AssignmentNode", Nbe = [
  "subset",
  "?matrix",
  // FIXME: should not be needed at all, should be handled by subset
  "Node"
], Pbe = /* @__PURE__ */ me(o2, Nbe, (e) => {
  var {
    subset: t,
    matrix: r,
    Node: n
  } = e, a = aq({
    subset: t
  }), i = Ibe({
    subset: t,
    matrix: r
  });
  function o(u, c, l) {
    c || (c = "keep");
    var d = In(u, c, l), f = In(u.value, c, l);
    return c === "all" || f !== null && f <= d;
  }
  class s extends n {
    /**
     * @constructor AssignmentNode
     * @extends {Node}
     *
     * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or
     * replace a subset of a matrix like `A[2,2]=42`.
     *
     * Syntax:
     *
     *     new AssignmentNode(symbol, value)
     *     new AssignmentNode(object, index, value)
     *
     * Usage:
     *
     *    new AssignmentNode(new SymbolNode('a'), new ConstantNode(2))  // a=2
     *    new AssignmentNode(new SymbolNode('a'),
     *                       new IndexNode('b'),
     *                       new ConstantNode(2))   // a.b=2
     *    new AssignmentNode(new SymbolNode('a'),
     *                       new IndexNode(1, 2),
     *                       new ConstantNode(3))  // a[1,2]=3
     *
     * @param {SymbolNode | AccessorNode} object
     *     Object on which to assign a value
     * @param {IndexNode} [index=null]
     *     Index, property name or matrix index. Optional. If not provided
     *     and `object` is a SymbolNode, the property is assigned to the
     *     global scope.
     * @param {Node} value
     *     The value to be assigned
     */
    constructor(c, l, d) {
      if (super(), this.object = c, this.index = d ? l : null, this.value = d || l, !Wa(c) && !Xd(c))
        throw new TypeError('SymbolNode or AccessorNode expected as "object"');
      if (Wa(c) && c.name === "end")
        throw new Error('Cannot assign to symbol "end"');
      if (this.index && !gm(this.index))
        throw new TypeError('IndexNode expected as "index"');
      if (!gn(this.value))
        throw new TypeError('Node expected as "value"');
    }
    // class name for typing purposes:
    // readonly property name
    get name() {
      return this.index ? this.index.isObjectProperty() ? this.index.getObjectProperty() : "" : this.object.name || "";
    }
    get type() {
      return o2;
    }
    get isAssignmentNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(c, l) {
      var d = this.object._compile(c, l), f = this.index ? this.index._compile(c, l) : null, m = this.value._compile(c, l), h = this.object.name;
      if (this.index)
        if (this.index.isObjectProperty()) {
          var p = this.index.getObjectProperty();
          return function(S, b, x) {
            var A = d(S, b, x), w = m(S, b, x);
            return i1(A, p, w), w;
          };
        } else {
          if (Wa(this.object))
            return function(S, b, x) {
              var A = d(S, b, x), w = m(S, b, x), C = f(S, b, A);
              return S.set(h, i(A, C, w)), w;
            };
          var g = this.object.object._compile(c, l);
          if (this.object.index.isObjectProperty()) {
            var v = this.object.index.getObjectProperty();
            return function(S, b, x) {
              var A = g(S, b, x), w = yo(A, v), C = f(S, b, w), M = m(S, b, x);
              return i1(A, v, i(w, C, M)), M;
            };
          } else {
            var y = this.object.index._compile(c, l);
            return function(S, b, x) {
              var A = g(S, b, x), w = y(S, b, A), C = a(A, w), M = f(S, b, C), T = m(S, b, x);
              return i(A, w, i(C, M, T)), T;
            };
          }
        }
      else {
        if (!Wa(this.object))
          throw new TypeError("SymbolNode expected as object");
        return function(S, b, x) {
          var A = m(S, b, x);
          return S.set(h, A), A;
        };
      }
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(c) {
      c(this.object, "object", this), this.index && c(this.index, "index", this), c(this.value, "value", this);
    }
    /**
     * Create a new AssignmentNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {AssignmentNode} Returns a transformed copy of the node
     */
    map(c) {
      var l = this._ifNode(c(this.object, "object", this)), d = this.index ? this._ifNode(c(this.index, "index", this)) : null, f = this._ifNode(c(this.value, "value", this));
      return new s(l, d, f);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {AssignmentNode}
     */
    clone() {
      return new s(this.object, this.index, this.value);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string}
     */
    _toString(c) {
      var l = this.object.toString(c), d = this.index ? this.index.toString(c) : "", f = this.value.toString(c);
      return o(this, c && c.parenthesis, c && c.implicit) && (f = "(" + f + ")"), l + d + " = " + f;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: o2,
        object: this.object,
        index: this.index,
        value: this.value
      };
    }
    /**
     * Instantiate an AssignmentNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "AssignmentNode", object: ..., index: ..., value: ...}`,
     *     where mathjs is optional
     * @returns {AssignmentNode}
     */
    static fromJSON(c) {
      return new s(c.object, c.index, c.value);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string}
     */
    _toHTML(c) {
      var l = this.object.toHTML(c), d = this.index ? this.index.toHTML(c) : "", f = this.value.toHTML(c);
      return o(this, c && c.parenthesis, c && c.implicit) && (f = '<span class="math-paranthesis math-round-parenthesis">(</span>' + f + '<span class="math-paranthesis math-round-parenthesis">)</span>'), l + d + '<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + f;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string}
     */
    _toTex(c) {
      var l = this.object.toTex(c), d = this.index ? this.index.toTex(c) : "", f = this.value.toTex(c);
      return o(this, c && c.parenthesis, c && c.implicit) && (f = "\\left(".concat(f, "\\right)")), l + d + "=" + f;
    }
  }
  return $a(s, "name", o2), s;
}, {
  isClass: !0,
  isNode: !0
}), s2 = "BlockNode", Bbe = ["ResultSet", "Node"], Obe = /* @__PURE__ */ me(s2, Bbe, (e) => {
  var {
    ResultSet: t,
    Node: r
  } = e;
  class n extends r {
    /**
     * @constructor BlockNode
     * @extends {Node}
     * Holds a set with blocks
     * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks
     *            An array with blocks, where a block is constructed as an
     *            Object with properties block, which is a Node, and visible,
     *            which is a boolean. The property visible is optional and
     *            is true by default
     */
    constructor(i) {
      if (super(), !Array.isArray(i)) throw new Error("Array expected");
      this.blocks = i.map(function(o) {
        var s = o && o.node, u = o && o.visible !== void 0 ? o.visible : !0;
        if (!gn(s)) throw new TypeError('Property "node" must be a Node');
        if (typeof u != "boolean")
          throw new TypeError('Property "visible" must be a boolean');
        return {
          node: s,
          visible: u
        };
      });
    }
    get type() {
      return s2;
    }
    get isBlockNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var s = sl(this.blocks, function(u) {
        return {
          evaluate: u.node._compile(i, o),
          visible: u.visible
        };
      });
      return function(c, l, d) {
        var f = [];
        return q3(s, function(h) {
          var p = h.evaluate(c, l, d);
          h.visible && f.push(p);
        }), new t(f);
      };
    }
    /**
     * Execute a callback for each of the child blocks of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      for (var o = 0; o < this.blocks.length; o++)
        i(this.blocks[o].node, "blocks[" + o + "].node", this);
    }
    /**
     * Create a new BlockNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {BlockNode} Returns a transformed copy of the node
     */
    map(i) {
      for (var o = [], s = 0; s < this.blocks.length; s++) {
        var u = this.blocks[s], c = this._ifNode(i(u.node, "blocks[" + s + "].node", this));
        o[s] = {
          node: c,
          visible: u.visible
        };
      }
      return new n(o);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {BlockNode}
     */
    clone() {
      var i = this.blocks.map(function(o) {
        return {
          node: o.node,
          visible: o.visible
        };
      });
      return new n(i);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(i) {
      return this.blocks.map(function(o) {
        return o.node.toString(i) + (o.visible ? "" : ";");
      }).join(`
`);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: s2,
        blocks: this.blocks
      };
    }
    /**
     * Instantiate an BlockNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "BlockNode", blocks: [{node: ..., visible: false}, ...]}`,
     *     where mathjs is optional
     * @returns {BlockNode}
     */
    static fromJSON(i) {
      return new n(i.blocks);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(i) {
      return this.blocks.map(function(o) {
        return o.node.toHTML(i) + (o.visible ? "" : '<span class="math-separator">;</span>');
      }).join('<span class="math-separator"><br /></span>');
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      return this.blocks.map(function(o) {
        return o.node.toTex(i) + (o.visible ? "" : ";");
      }).join(`\\;\\;
`);
    }
  }
  return $a(n, "name", s2), n;
}, {
  isClass: !0,
  isNode: !0
}), u2 = "ConditionalNode", Fbe = ["Node"], Rbe = /* @__PURE__ */ me(u2, Fbe, (e) => {
  var {
    Node: t
  } = e;
  function r(a) {
    if (typeof a == "number" || typeof a == "boolean" || typeof a == "string")
      return !!a;
    if (a) {
      if (hr(a))
        return !a.isZero();
      if (Mu(a))
        return !!(a.re || a.im);
      if (Lo(a))
        return !!a.value;
    }
    if (a == null)
      return !1;
    throw new TypeError('Unsupported type of condition "' + Nn(a) + '"');
  }
  class n extends t {
    /**
     * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr'
     *
     * @param {Node} condition   Condition, must result in a boolean
     * @param {Node} trueExpr    Expression evaluated when condition is true
     * @param {Node} falseExpr   Expression evaluated when condition is true
     *
     * @constructor ConditionalNode
     * @extends {Node}
     */
    constructor(i, o, s) {
      if (super(), !gn(i))
        throw new TypeError("Parameter condition must be a Node");
      if (!gn(o))
        throw new TypeError("Parameter trueExpr must be a Node");
      if (!gn(s))
        throw new TypeError("Parameter falseExpr must be a Node");
      this.condition = i, this.trueExpr = o, this.falseExpr = s;
    }
    get type() {
      return u2;
    }
    get isConditionalNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var s = this.condition._compile(i, o), u = this.trueExpr._compile(i, o), c = this.falseExpr._compile(i, o);
      return function(d, f, m) {
        return r(s(d, f, m)) ? u(d, f, m) : c(d, f, m);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      i(this.condition, "condition", this), i(this.trueExpr, "trueExpr", this), i(this.falseExpr, "falseExpr", this);
    }
    /**
     * Create a new ConditionalNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ConditionalNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this._ifNode(i(this.condition, "condition", this)), this._ifNode(i(this.trueExpr, "trueExpr", this)), this._ifNode(i(this.falseExpr, "falseExpr", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ConditionalNode}
     */
    clone() {
      return new n(this.condition, this.trueExpr, this.falseExpr);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", s = In(this, o, i && i.implicit), u = this.condition.toString(i), c = In(this.condition, o, i && i.implicit);
      (o === "all" || this.condition.type === "OperatorNode" || c !== null && c <= s) && (u = "(" + u + ")");
      var l = this.trueExpr.toString(i), d = In(this.trueExpr, o, i && i.implicit);
      (o === "all" || this.trueExpr.type === "OperatorNode" || d !== null && d <= s) && (l = "(" + l + ")");
      var f = this.falseExpr.toString(i), m = In(this.falseExpr, o, i && i.implicit);
      return (o === "all" || this.falseExpr.type === "OperatorNode" || m !== null && m <= s) && (f = "(" + f + ")"), u + " ? " + l + " : " + f;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: u2,
        condition: this.condition,
        trueExpr: this.trueExpr,
        falseExpr: this.falseExpr
      };
    }
    /**
     * Instantiate an ConditionalNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "ConditionalNode",
     *      "condition": ...,
     *      "trueExpr": ...,
     *      "falseExpr": ...}
     *     ```
     *     where mathjs is optional
     * @returns {ConditionalNode}
     */
    static fromJSON(i) {
      return new n(i.condition, i.trueExpr, i.falseExpr);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", s = In(this, o, i && i.implicit), u = this.condition.toHTML(i), c = In(this.condition, o, i && i.implicit);
      (o === "all" || this.condition.type === "OperatorNode" || c !== null && c <= s) && (u = '<span class="math-parenthesis math-round-parenthesis">(</span>' + u + '<span class="math-parenthesis math-round-parenthesis">)</span>');
      var l = this.trueExpr.toHTML(i), d = In(this.trueExpr, o, i && i.implicit);
      (o === "all" || this.trueExpr.type === "OperatorNode" || d !== null && d <= s) && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>');
      var f = this.falseExpr.toHTML(i), m = In(this.falseExpr, o, i && i.implicit);
      return (o === "all" || this.falseExpr.type === "OperatorNode" || m !== null && m <= s) && (f = '<span class="math-parenthesis math-round-parenthesis">(</span>' + f + '<span class="math-parenthesis math-round-parenthesis">)</span>'), u + '<span class="math-operator math-conditional-operator">?</span>' + l + '<span class="math-operator math-conditional-operator">:</span>' + f;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      return "\\begin{cases} {" + this.trueExpr.toTex(i) + "}, &\\quad{\\text{if }\\;" + this.condition.toTex(i) + "}\\\\{" + this.falseExpr.toTex(i) + "}, &\\quad{\\text{otherwise}}\\end{cases}";
    }
  }
  return $a(n, "name", u2), n;
}, {
  isClass: !0,
  isNode: !0
}), r8 = Object.assign || function(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t];
    for (var n in r)
      Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
  }
  return e;
}, Lbe = {
  "{": "\\{",
  "}": "\\}",
  "\\": "\\textbackslash{}",
  "#": "\\#",
  $: "\\$",
  "%": "\\%",
  "&": "\\&",
  "^": "\\textasciicircum{}",
  _: "\\_",
  "~": "\\textasciitilde{}"
}, kbe = {
  "–": "\\--",
  "—": "\\---",
  " ": "~",
  "	": "\\qquad{}",
  "\r\n": "\\newline{}",
  "\n": "\\newline{}"
}, zbe = function(t, r) {
  return r8({}, t, r);
}, Ube = function(e) {
  for (var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = t.preserveFormatting, n = r === void 0 ? !1 : r, a = t.escapeMapFn, i = a === void 0 ? zbe : a, o = String(e), s = "", u = i(r8({}, Lbe), n ? r8({}, kbe) : {}), c = Object.keys(u), l = function() {
    var f = !1;
    c.forEach(function(m, h) {
      f || o.length >= m.length && o.slice(0, m.length) === m && (s += u[c[h]], o = o.slice(m.length, o.length), f = !0);
    }), f || (s += o.slice(0, 1), o = o.slice(1, o.length));
  }; o; )
    l();
  return s;
};
const Gbe = /* @__PURE__ */ jh(Ube);
var n8 = {
  // GREEK LETTERS
  Alpha: "A",
  alpha: "\\alpha",
  Beta: "B",
  beta: "\\beta",
  Gamma: "\\Gamma",
  gamma: "\\gamma",
  Delta: "\\Delta",
  delta: "\\delta",
  Epsilon: "E",
  epsilon: "\\epsilon",
  varepsilon: "\\varepsilon",
  Zeta: "Z",
  zeta: "\\zeta",
  Eta: "H",
  eta: "\\eta",
  Theta: "\\Theta",
  theta: "\\theta",
  vartheta: "\\vartheta",
  Iota: "I",
  iota: "\\iota",
  Kappa: "K",
  kappa: "\\kappa",
  varkappa: "\\varkappa",
  Lambda: "\\Lambda",
  lambda: "\\lambda",
  Mu: "M",
  mu: "\\mu",
  Nu: "N",
  nu: "\\nu",
  Xi: "\\Xi",
  xi: "\\xi",
  Omicron: "O",
  omicron: "o",
  Pi: "\\Pi",
  pi: "\\pi",
  varpi: "\\varpi",
  Rho: "P",
  rho: "\\rho",
  varrho: "\\varrho",
  Sigma: "\\Sigma",
  sigma: "\\sigma",
  varsigma: "\\varsigma",
  Tau: "T",
  tau: "\\tau",
  Upsilon: "\\Upsilon",
  upsilon: "\\upsilon",
  Phi: "\\Phi",
  phi: "\\phi",
  varphi: "\\varphi",
  Chi: "X",
  chi: "\\chi",
  Psi: "\\Psi",
  psi: "\\psi",
  Omega: "\\Omega",
  omega: "\\omega",
  // logic
  true: "\\mathrm{True}",
  false: "\\mathrm{False}",
  // other
  i: "i",
  // TODO use \i ??
  inf: "\\infty",
  Inf: "\\infty",
  infinity: "\\infty",
  Infinity: "\\infty",
  oo: "\\infty",
  lim: "\\lim",
  undefined: "\\mathbf{?}"
}, Zr = {
  transpose: "^\\top",
  ctranspose: "^H",
  factorial: "!",
  pow: "^",
  dotPow: ".^\\wedge",
  // TODO find ideal solution
  unaryPlus: "+",
  unaryMinus: "-",
  bitNot: "\\~",
  // TODO find ideal solution
  not: "\\neg",
  multiply: "\\cdot",
  divide: "\\frac",
  // TODO how to handle that properly?
  dotMultiply: ".\\cdot",
  // TODO find ideal solution
  dotDivide: ".:",
  // TODO find ideal solution
  mod: "\\mod",
  add: "+",
  subtract: "-",
  to: "\\rightarrow",
  leftShift: "<<",
  rightArithShift: ">>",
  rightLogShift: ">>>",
  equal: "=",
  unequal: "\\neq",
  smaller: "<",
  larger: ">",
  smallerEq: "\\leq",
  largerEq: "\\geq",
  bitAnd: "\\&",
  bitXor: "\\underline{|}",
  bitOr: "|",
  and: "\\wedge",
  xor: "\\veebar",
  or: "\\vee"
}, WP = {
  // arithmetic
  abs: {
    1: "\\left|${args[0]}\\right|"
  },
  add: {
    2: "\\left(${args[0]}".concat(Zr.add, "${args[1]}\\right)")
  },
  cbrt: {
    1: "\\sqrt[3]{${args[0]}}"
  },
  ceil: {
    1: "\\left\\lceil${args[0]}\\right\\rceil"
  },
  cube: {
    1: "\\left(${args[0]}\\right)^3"
  },
  divide: {
    2: "\\frac{${args[0]}}{${args[1]}}"
  },
  dotDivide: {
    2: "\\left(${args[0]}".concat(Zr.dotDivide, "${args[1]}\\right)")
  },
  dotMultiply: {
    2: "\\left(${args[0]}".concat(Zr.dotMultiply, "${args[1]}\\right)")
  },
  dotPow: {
    2: "\\left(${args[0]}".concat(Zr.dotPow, "${args[1]}\\right)")
  },
  exp: {
    1: "\\exp\\left(${args[0]}\\right)"
  },
  expm1: "\\left(e".concat(Zr.pow, "{${args[0]}}-1\\right)"),
  fix: {
    1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
  },
  floor: {
    1: "\\left\\lfloor${args[0]}\\right\\rfloor"
  },
  gcd: "\\gcd\\left(${args}\\right)",
  hypot: "\\hypot\\left(${args}\\right)",
  log: {
    1: "\\ln\\left(${args[0]}\\right)",
    2: "\\log_{${args[1]}}\\left(${args[0]}\\right)"
  },
  log10: {
    1: "\\log_{10}\\left(${args[0]}\\right)"
  },
  log1p: {
    1: "\\ln\\left(${args[0]}+1\\right)",
    2: "\\log_{${args[1]}}\\left(${args[0]}+1\\right)"
  },
  log2: "\\log_{2}\\left(${args[0]}\\right)",
  mod: {
    2: "\\left(${args[0]}".concat(Zr.mod, "${args[1]}\\right)")
  },
  multiply: {
    2: "\\left(${args[0]}".concat(Zr.multiply, "${args[1]}\\right)")
  },
  norm: {
    1: "\\left\\|${args[0]}\\right\\|",
    2: void 0
    // use default template
  },
  nthRoot: {
    2: "\\sqrt[${args[1]}]{${args[0]}}"
  },
  nthRoots: {
    2: "\\{y : $y^{args[1]} = {${args[0]}}\\}"
  },
  pow: {
    2: "\\left(${args[0]}\\right)".concat(Zr.pow, "{${args[1]}}")
  },
  round: {
    1: "\\left\\lfloor${args[0]}\\right\\rceil",
    2: void 0
    // use default template
  },
  sign: {
    1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
  },
  sqrt: {
    1: "\\sqrt{${args[0]}}"
  },
  square: {
    1: "\\left(${args[0]}\\right)^2"
  },
  subtract: {
    2: "\\left(${args[0]}".concat(Zr.subtract, "${args[1]}\\right)")
  },
  unaryMinus: {
    1: "".concat(Zr.unaryMinus, "\\left(${args[0]}\\right)")
  },
  unaryPlus: {
    1: "".concat(Zr.unaryPlus, "\\left(${args[0]}\\right)")
  },
  // bitwise
  bitAnd: {
    2: "\\left(${args[0]}".concat(Zr.bitAnd, "${args[1]}\\right)")
  },
  bitNot: {
    1: Zr.bitNot + "\\left(${args[0]}\\right)"
  },
  bitOr: {
    2: "\\left(${args[0]}".concat(Zr.bitOr, "${args[1]}\\right)")
  },
  bitXor: {
    2: "\\left(${args[0]}".concat(Zr.bitXor, "${args[1]}\\right)")
  },
  leftShift: {
    2: "\\left(${args[0]}".concat(Zr.leftShift, "${args[1]}\\right)")
  },
  rightArithShift: {
    2: "\\left(${args[0]}".concat(Zr.rightArithShift, "${args[1]}\\right)")
  },
  rightLogShift: {
    2: "\\left(${args[0]}".concat(Zr.rightLogShift, "${args[1]}\\right)")
  },
  // combinatorics
  bellNumbers: {
    1: "\\mathrm{B}_{${args[0]}}"
  },
  catalan: {
    1: "\\mathrm{C}_{${args[0]}}"
  },
  stirlingS2: {
    2: "\\mathrm{S}\\left(${args}\\right)"
  },
  // complex
  arg: {
    1: "\\arg\\left(${args[0]}\\right)"
  },
  conj: {
    1: "\\left(${args[0]}\\right)^*"
  },
  im: {
    1: "\\Im\\left\\lbrace${args[0]}\\right\\rbrace"
  },
  re: {
    1: "\\Re\\left\\lbrace${args[0]}\\right\\rbrace"
  },
  // logical
  and: {
    2: "\\left(${args[0]}".concat(Zr.and, "${args[1]}\\right)")
  },
  not: {
    1: Zr.not + "\\left(${args[0]}\\right)"
  },
  or: {
    2: "\\left(${args[0]}".concat(Zr.or, "${args[1]}\\right)")
  },
  xor: {
    2: "\\left(${args[0]}".concat(Zr.xor, "${args[1]}\\right)")
  },
  // matrix
  cross: {
    2: "\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"
  },
  ctranspose: {
    1: "\\left(${args[0]}\\right)".concat(Zr.ctranspose)
  },
  det: {
    1: "\\det\\left(${args[0]}\\right)"
  },
  dot: {
    2: "\\left(${args[0]}\\cdot${args[1]}\\right)"
  },
  expm: {
    1: "\\exp\\left(${args[0]}\\right)"
  },
  inv: {
    1: "\\left(${args[0]}\\right)^{-1}"
  },
  pinv: {
    1: "\\left(${args[0]}\\right)^{+}"
  },
  sqrtm: {
    1: "{${args[0]}}".concat(Zr.pow, "{\\frac{1}{2}}")
  },
  trace: {
    1: "\\mathrm{tr}\\left(${args[0]}\\right)"
  },
  transpose: {
    1: "\\left(${args[0]}\\right)".concat(Zr.transpose)
  },
  // probability
  combinations: {
    2: "\\binom{${args[0]}}{${args[1]}}"
  },
  combinationsWithRep: {
    2: "\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"
  },
  factorial: {
    1: "\\left(${args[0]}\\right)".concat(Zr.factorial)
  },
  gamma: {
    1: "\\Gamma\\left(${args[0]}\\right)"
  },
  lgamma: {
    1: "\\ln\\Gamma\\left(${args[0]}\\right)"
  },
  // relational
  equal: {
    2: "\\left(${args[0]}".concat(Zr.equal, "${args[1]}\\right)")
  },
  larger: {
    2: "\\left(${args[0]}".concat(Zr.larger, "${args[1]}\\right)")
  },
  largerEq: {
    2: "\\left(${args[0]}".concat(Zr.largerEq, "${args[1]}\\right)")
  },
  smaller: {
    2: "\\left(${args[0]}".concat(Zr.smaller, "${args[1]}\\right)")
  },
  smallerEq: {
    2: "\\left(${args[0]}".concat(Zr.smallerEq, "${args[1]}\\right)")
  },
  unequal: {
    2: "\\left(${args[0]}".concat(Zr.unequal, "${args[1]}\\right)")
  },
  // special
  erf: {
    1: "erf\\left(${args[0]}\\right)"
  },
  // statistics
  max: "\\max\\left(${args}\\right)",
  min: "\\min\\left(${args}\\right)",
  variance: "\\mathrm{Var}\\left(${args}\\right)",
  // trigonometry
  acos: {
    1: "\\cos^{-1}\\left(${args[0]}\\right)"
  },
  acosh: {
    1: "\\cosh^{-1}\\left(${args[0]}\\right)"
  },
  acot: {
    1: "\\cot^{-1}\\left(${args[0]}\\right)"
  },
  acoth: {
    1: "\\coth^{-1}\\left(${args[0]}\\right)"
  },
  acsc: {
    1: "\\csc^{-1}\\left(${args[0]}\\right)"
  },
  acsch: {
    1: "\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"
  },
  asec: {
    1: "\\sec^{-1}\\left(${args[0]}\\right)"
  },
  asech: {
    1: "\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"
  },
  asin: {
    1: "\\sin^{-1}\\left(${args[0]}\\right)"
  },
  asinh: {
    1: "\\sinh^{-1}\\left(${args[0]}\\right)"
  },
  atan: {
    1: "\\tan^{-1}\\left(${args[0]}\\right)"
  },
  atan2: {
    2: "\\mathrm{atan2}\\left(${args}\\right)"
  },
  atanh: {
    1: "\\tanh^{-1}\\left(${args[0]}\\right)"
  },
  cos: {
    1: "\\cos\\left(${args[0]}\\right)"
  },
  cosh: {
    1: "\\cosh\\left(${args[0]}\\right)"
  },
  cot: {
    1: "\\cot\\left(${args[0]}\\right)"
  },
  coth: {
    1: "\\coth\\left(${args[0]}\\right)"
  },
  csc: {
    1: "\\csc\\left(${args[0]}\\right)"
  },
  csch: {
    1: "\\mathrm{csch}\\left(${args[0]}\\right)"
  },
  sec: {
    1: "\\sec\\left(${args[0]}\\right)"
  },
  sech: {
    1: "\\mathrm{sech}\\left(${args[0]}\\right)"
  },
  sin: {
    1: "\\sin\\left(${args[0]}\\right)"
  },
  sinh: {
    1: "\\sinh\\left(${args[0]}\\right)"
  },
  tan: {
    1: "\\tan\\left(${args[0]}\\right)"
  },
  tanh: {
    1: "\\tanh\\left(${args[0]}\\right)"
  },
  // unit
  to: {
    2: "\\left(${args[0]}".concat(Zr.to, "${args[1]}\\right)")
  },
  // utils
  numeric: function(t, r) {
    return t.args[0].toTex();
  },
  // type
  number: {
    0: "0",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
  },
  string: {
    0: '\\mathtt{""}',
    1: "\\mathrm{string}\\left(${args[0]}\\right)"
  },
  bignumber: {
    0: "0",
    1: "\\left(${args[0]}\\right)"
  },
  bigint: {
    0: "0",
    1: "\\left(${args[0]}\\right)"
  },
  complex: {
    0: "0",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)+".concat(n8.i, "\\cdot\\left(${args[1]}\\right)\\right)")
  },
  matrix: {
    0: "\\begin{bmatrix}\\end{bmatrix}",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(${args[0]}\\right)"
  },
  sparse: {
    0: "\\begin{bsparse}\\end{bsparse}",
    1: "\\left(${args[0]}\\right)"
  },
  unit: {
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
  }
}, Vbe = "\\mathrm{${name}}\\left(${args}\\right)", ZP = {
  deg: "^\\circ"
};
function a8(e) {
  return Gbe(e, {
    preserveFormatting: !0
  });
}
function iq(e, t) {
  return t = typeof t > "u" ? !1 : t, t ? Tt(ZP, e) ? ZP[e] : "\\mathrm{" + a8(e) + "}" : Tt(n8, e) ? n8[e] : a8(e);
}
var c2 = "ConstantNode", qbe = ["Node"], Hbe = /* @__PURE__ */ me(c2, qbe, (e) => {
  var {
    Node: t
  } = e;
  class r extends t {
    /**
     * A ConstantNode holds a constant value like a number or string.
     *
     * Usage:
     *
     *     new ConstantNode(2.3)
     *     new ConstantNode('hello')
     *
     * @param {*} value    Value can be any type (number, BigNumber, bigint, string, ...)
     * @constructor ConstantNode
     * @extends {Node}
     */
    constructor(a) {
      super(), this.value = a;
    }
    get type() {
      return c2;
    }
    get isConstantNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = this.value;
      return function() {
        return o;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
    }
    /**
     * Create a new ConstantNode with children produced by the given callback.
     * Trivial because there are no children.
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {ConstantNode} Returns a clone of the node
     */
    map(a) {
      return this.clone();
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ConstantNode}
     */
    clone() {
      return new r(this.value);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(a) {
      return Br(this.value, a);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(a) {
      var i = this._toString(a);
      switch (Nn(this.value)) {
        case "number":
        case "bigint":
        case "BigNumber":
        case "Fraction":
          return '<span class="math-number">' + i + "</span>";
        case "string":
          return '<span class="math-string">' + i + "</span>";
        case "boolean":
          return '<span class="math-boolean">' + i + "</span>";
        case "null":
          return '<span class="math-null-symbol">' + i + "</span>";
        case "undefined":
          return '<span class="math-undefined">' + i + "</span>";
        default:
          return '<span class="math-symbol">' + i + "</span>";
      }
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: c2,
        value: this.value
      };
    }
    /**
     * Instantiate a ConstantNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "SymbolNode", value: 2.3}`,
     *                       where mathjs is optional
     * @returns {ConstantNode}
     */
    static fromJSON(a) {
      return new r(a.value);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      var i = this._toString(a), o = Nn(this.value);
      switch (o) {
        case "string":
          return "\\mathtt{" + a8(i) + "}";
        case "number":
        case "BigNumber": {
          var s = o === "BigNumber" ? this.value.isFinite() : isFinite(this.value);
          if (!s)
            return this.value.valueOf() < 0 ? "-\\infty" : "\\infty";
          var u = i.toLowerCase().indexOf("e");
          return u !== -1 ? i.substring(0, u) + "\\cdot10^{" + i.substring(u + 1) + "}" : i;
        }
        case "bigint":
          return i.toString();
        case "Fraction":
          return this.value.toLatex();
        default:
          return i;
      }
    }
  }
  return $a(r, "name", c2), r;
}, {
  isClass: !0,
  isNode: !0
}), l2 = "FunctionAssignmentNode", Kbe = ["typed", "Node"], Xbe = /* @__PURE__ */ me(l2, Kbe, (e) => {
  var {
    typed: t,
    Node: r
  } = e;
  function n(i, o, s) {
    var u = In(i, o, s), c = In(i.expr, o, s);
    return o === "all" || c !== null && c <= u;
  }
  class a extends r {
    /**
     * @constructor FunctionAssignmentNode
     * @extends {Node}
     * Function assignment
     *
     * @param {string} name           Function name
     * @param {string[] | Array.<{name: string, type: string}>} params
     *                                Array with function parameter names, or an
     *                                array with objects containing the name
     *                                and type of the parameter
     * @param {Node} expr             The function expression
     */
    constructor(o, s, u) {
      if (super(), typeof o != "string")
        throw new TypeError('String expected for parameter "name"');
      if (!Array.isArray(s))
        throw new TypeError('Array containing strings or objects expected for parameter "params"');
      if (!gn(u))
        throw new TypeError('Node expected for parameter "expr"');
      if (nq.has(o))
        throw new Error('Illegal function name, "' + o + '" is a reserved keyword');
      var c = /* @__PURE__ */ new Set();
      for (var l of s) {
        var d = typeof l == "string" ? l : l.name;
        if (c.has(d))
          throw new Error('Duplicate parameter name "'.concat(d, '"'));
        c.add(d);
      }
      this.name = o, this.params = s.map(function(f) {
        return f && f.name || f;
      }), this.types = s.map(function(f) {
        return f && f.type || "any";
      }), this.expr = u;
    }
    get type() {
      return l2;
    }
    get isFunctionAssignmentNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(o, s) {
      var u = Object.create(s);
      q3(this.params, function(h) {
        u[h] = !0;
      });
      var c = this.expr._compile(o, u), l = this.name, d = this.params, f = QI(this.types, ","), m = l + "(" + QI(this.params, ", ") + ")";
      return function(p, g, v) {
        var y = {};
        y[f] = function() {
          for (var S = Object.create(g), b = 0; b < d.length; b++)
            S[d[b]] = arguments[b];
          return c(p, S, v);
        };
        var _ = t(l, y);
        return _.syntax = m, p.set(l, _), _;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(o) {
      o(this.expr, "expr", this);
    }
    /**
     * Create a new FunctionAssignmentNode whose children are the results of
     * calling the provided callback function for each child of the original
     * node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {FunctionAssignmentNode} Returns a transformed copy of the node
     */
    map(o) {
      var s = this._ifNode(o(this.expr, "expr", this));
      return new a(this.name, this.params.slice(0), s);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {FunctionAssignmentNode}
     */
    clone() {
      return new a(this.name, this.params.slice(0), this.expr);
    }
    /**
     * get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(o) {
      var s = o && o.parenthesis ? o.parenthesis : "keep", u = this.expr.toString(o);
      return n(this, s, o && o.implicit) && (u = "(" + u + ")"), this.name + "(" + this.params.join(", ") + ") = " + u;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      var o = this.types;
      return {
        mathjs: l2,
        name: this.name,
        params: this.params.map(function(s, u) {
          return {
            name: s,
            type: o[u]
          };
        }),
        expr: this.expr
      };
    }
    /**
     * Instantiate an FunctionAssignmentNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "FunctionAssignmentNode",
     *      name: ..., params: ..., expr: ...}
     *     ```
     *     where mathjs is optional
     * @returns {FunctionAssignmentNode}
     */
    static fromJSON(o) {
      return new a(o.name, o.params, o.expr);
    }
    /**
     * get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(o) {
      for (var s = o && o.parenthesis ? o.parenthesis : "keep", u = [], c = 0; c < this.params.length; c++)
        u.push('<span class="math-symbol math-parameter">' + $s(this.params[c]) + "</span>");
      var l = this.expr.toHTML(o);
      return n(this, s, o && o.implicit) && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>'), '<span class="math-function">' + $s(this.name) + '</span><span class="math-parenthesis math-round-parenthesis">(</span>' + u.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + l;
    }
    /**
     * get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(o) {
      var s = o && o.parenthesis ? o.parenthesis : "keep", u = this.expr.toTex(o);
      return n(this, s, o && o.implicit) && (u = "\\left(".concat(u, "\\right)")), "\\mathrm{" + this.name + "}\\left(" + this.params.map(iq).join(",") + "\\right)=" + u;
    }
  }
  return $a(a, "name", l2), a;
}, {
  isClass: !0,
  isNode: !0
}), d2 = "IndexNode", jbe = ["Node", "size"], Ybe = /* @__PURE__ */ me(d2, jbe, (e) => {
  var {
    Node: t,
    size: r
  } = e;
  class n extends t {
    /**
     * @constructor IndexNode
     * @extends Node
     *
     * Describes a subset of a matrix or an object property.
     * Cannot be used on its own, needs to be used within an AccessorNode or
     * AssignmentNode.
     *
     * @param {Node[]} dimensions
     * @param {boolean} [dotNotation=false]
     *     Optional property describing whether this index was written using dot
     *     notation like `a.b`, or using bracket notation like `a["b"]`
     *     (which is the default). This property is used for string conversion.
     */
    constructor(i, o) {
      if (super(), this.dimensions = i, this.dotNotation = o || !1, !Array.isArray(i) || !i.every(gn))
        throw new TypeError('Array containing Nodes expected for parameter "dimensions"');
      if (this.dotNotation && !this.isObjectProperty())
        throw new Error("dotNotation only applicable for object properties");
    }
    get type() {
      return d2;
    }
    get isIndexNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var s = sl(this.dimensions, function(c, l) {
        var d = c.filter((h) => h.isSymbolNode && h.name === "end").length > 0;
        if (d) {
          var f = Object.create(o);
          f.end = !0;
          var m = c._compile(i, f);
          return function(p, g, v) {
            if (!Zt(v) && !en(v) && !Di(v))
              throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is ' + Nn(v));
            var y = r(v).valueOf(), _ = Object.create(g);
            return _.end = y[l], m(p, _, v);
          };
        } else
          return c._compile(i, o);
      }), u = yo(i, "index");
      return function(l, d, f) {
        var m = sl(s, function(h) {
          return h(l, d, f);
        });
        return u(...m);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      for (var o = 0; o < this.dimensions.length; o++)
        i(this.dimensions[o], "dimensions[" + o + "]", this);
    }
    /**
     * Create a new IndexNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {IndexNode} Returns a transformed copy of the node
     */
    map(i) {
      for (var o = [], s = 0; s < this.dimensions.length; s++)
        o[s] = this._ifNode(i(this.dimensions[s], "dimensions[" + s + "]", this));
      return new n(o, this.dotNotation);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {IndexNode}
     */
    clone() {
      return new n(this.dimensions.slice(0), this.dotNotation);
    }
    /**
     * Test whether this IndexNode contains a single property name
     * @return {boolean}
     */
    isObjectProperty() {
      return this.dimensions.length === 1 && Vr(this.dimensions[0]) && typeof this.dimensions[0].value == "string";
    }
    /**
     * Returns the property name if IndexNode contains a property.
     * If not, returns null.
     * @return {string | null}
     */
    getObjectProperty() {
      return this.isObjectProperty() ? this.dimensions[0].value : null;
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      return this.dotNotation ? "." + this.getObjectProperty() : "[" + this.dimensions.join(", ") + "]";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: d2,
        dimensions: this.dimensions,
        dotNotation: this.dotNotation
      };
    }
    /**
     * Instantiate an IndexNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "IndexNode", dimensions: [...], dotNotation: false}`,
     *     where mathjs is optional
     * @returns {IndexNode}
     */
    static fromJSON(i) {
      return new n(i.dimensions, i.dotNotation);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      for (var o = [], s = 0; s < this.dimensions.length; s++)
        o[s] = this.dimensions[s].toHTML();
      return this.dotNotation ? '<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">' + $s(this.getObjectProperty()) + "</span>" : '<span class="math-parenthesis math-square-parenthesis">[</span>' + o.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      var o = this.dimensions.map(function(s) {
        return s.toTex(i);
      });
      return this.dotNotation ? "." + this.getObjectProperty() : "_{" + o.join(",") + "}";
    }
  }
  return $a(n, "name", d2), n;
}, {
  isClass: !0,
  isNode: !0
}), f2 = "ObjectNode", Wbe = ["Node"], Zbe = /* @__PURE__ */ me(f2, Wbe, (e) => {
  var {
    Node: t
  } = e;
  class r extends t {
    /**
     * @constructor ObjectNode
     * @extends {Node}
     * Holds an object with keys/values
     * @param {Object.<string, Node>} [properties]   object with key/value pairs
     */
    constructor(a) {
      if (super(), this.properties = a || {}, a && (typeof a != "object" || !Object.keys(a).every(function(i) {
        return gn(a[i]);
      })))
        throw new TypeError("Object containing Nodes expected");
    }
    get type() {
      return f2;
    }
    get isObjectNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = {};
      for (var s in this.properties)
        if (Tt(this.properties, s)) {
          var u = wp(s), c = JSON.parse(u), l = yo(this.properties, s);
          o[c] = l._compile(a, i);
        }
      return function(f, m, h) {
        var p = {};
        for (var g in o)
          Tt(o, g) && (p[g] = o[g](f, m, h));
        return p;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      for (var i in this.properties)
        Tt(this.properties, i) && a(this.properties[i], "properties[" + wp(i) + "]", this);
    }
    /**
     * Create a new ObjectNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ObjectNode} Returns a transformed copy of the node
     */
    map(a) {
      var i = {};
      for (var o in this.properties)
        Tt(this.properties, o) && (i[o] = this._ifNode(a(this.properties[o], "properties[" + wp(o) + "]", this)));
      return new r(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ObjectNode}
     */
    clone() {
      var a = {};
      for (var i in this.properties)
        Tt(this.properties, i) && (a[i] = this.properties[i]);
      return new r(a);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      var i = [];
      for (var o in this.properties)
        Tt(this.properties, o) && i.push(wp(o) + ": " + this.properties[o].toString(a));
      return "{" + i.join(", ") + "}";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: f2,
        properties: this.properties
      };
    }
    /**
     * Instantiate an OperatorNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ObjectNode", "properties": {...}}`,
     *                       where mathjs is optional
     * @returns {ObjectNode}
     */
    static fromJSON(a) {
      return new r(a.properties);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      var i = [];
      for (var o in this.properties)
        Tt(this.properties, o) && i.push('<span class="math-symbol math-property">' + $s(o) + '</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>' + this.properties[o].toHTML(a));
      return '<span class="math-parenthesis math-curly-parenthesis">{</span>' + i.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-curly-parenthesis">}</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      var i = [];
      for (var o in this.properties)
        Tt(this.properties, o) && i.push("\\mathbf{" + o + ":} & " + this.properties[o].toTex(a) + "\\\\");
      var s = "\\left\\{\\begin{array}{ll}" + i.join(`
`) + "\\end{array}\\right\\}";
      return s;
    }
  }
  return $a(r, "name", f2), r;
}, {
  isClass: !0,
  isNode: !0
});
function G0(e, t) {
  return new yU(e, new z3(t), new Set(Object.keys(t)));
}
var m2 = "OperatorNode", Qbe = ["Node"], $be = /* @__PURE__ */ me(m2, Qbe, (e) => {
  var {
    Node: t
  } = e;
  function r(i, o) {
    var s = i;
    if (o === "auto")
      for (; pc(s); ) s = s.content;
    return Vr(s) ? !0 : Da(s) ? r(s.args[0], o) : !1;
  }
  function n(i, o, s, u, c) {
    var l = In(i, o, s), d = A0(i, o);
    if (o === "all" || u.length > 2 && i.getIdentifier() !== "OperatorNode:add" && i.getIdentifier() !== "OperatorNode:multiply")
      return u.map(function(M) {
        switch (M.getContent().type) {
          case "ArrayNode":
          case "ConstantNode":
          case "SymbolNode":
          case "ParenthesisNode":
            return !1;
          default:
            return !0;
        }
      });
    var f;
    switch (u.length) {
      case 0:
        f = [];
        break;
      case 1:
        {
          var m = In(u[0], o, s, i);
          if (c && m !== null) {
            var h, p;
            if (o === "keep" ? (h = u[0].getIdentifier(), p = i.getIdentifier()) : (h = u[0].getContent().getIdentifier(), p = i.getContent().getIdentifier()), _u[l][p].latexLeftParens === !1) {
              f = [!1];
              break;
            }
            if (_u[m][h].latexParens === !1) {
              f = [!1];
              break;
            }
          }
          if (m === null) {
            f = [!1];
            break;
          }
          if (m <= l) {
            f = [!0];
            break;
          }
          f = [!1];
        }
        break;
      case 2:
        {
          var g, v = In(u[0], o, s, i), y = k5(i, u[0], o);
          v === null ? g = !1 : v === l && d === "right" && !y || v < l ? g = !0 : g = !1;
          var _, S = In(u[1], o, s, i), b = k5(i, u[1], o);
          if (S === null ? _ = !1 : S === l && d === "left" && !b || S < l ? _ = !0 : _ = !1, c) {
            var x, A, w;
            o === "keep" ? (x = i.getIdentifier(), A = i.args[0].getIdentifier(), w = i.args[1].getIdentifier()) : (x = i.getContent().getIdentifier(), A = i.args[0].getContent().getIdentifier(), w = i.args[1].getContent().getIdentifier()), v !== null && (_u[l][x].latexLeftParens === !1 && (g = !1), _u[v][A].latexParens === !1 && (g = !1)), S !== null && (_u[l][x].latexRightParens === !1 && (_ = !1), _u[S][w].latexParens === !1 && (_ = !1));
          }
          f = [g, _];
        }
        break;
      default:
        (i.getIdentifier() === "OperatorNode:add" || i.getIdentifier() === "OperatorNode:multiply") && (f = u.map(function(M) {
          var T = In(M, o, s, i), N = k5(i, M, o), I = A0(M, o);
          return T === null ? !1 : l === T && d === I && !N ? !0 : T < l;
        }));
        break;
    }
    if (u.length >= 2 && i.getIdentifier() === "OperatorNode:multiply" && i.implicit && o !== "all" && s === "hide")
      for (var C = 1; C < f.length; ++C)
        r(u[C], o) && !f[C - 1] && (o !== "keep" || !pc(u[C - 1])) && (f[C] = !0);
    return f;
  }
  class a extends t {
    /**
     * @constructor OperatorNode
     * @extends {Node}
     * An operator with two arguments, like 2+3
     *
     * @param {string} op           Operator name, for example '+'
     * @param {string} fn           Function name, for example 'add'
     * @param {Node[]} args         Operator arguments
     * @param {boolean} [implicit]  Is this an implicit multiplication?
     * @param {boolean} [isPercentage] Is this an percentage Operation?
     */
    constructor(o, s, u, c, l) {
      if (super(), typeof o != "string")
        throw new TypeError('string expected for parameter "op"');
      if (typeof s != "string")
        throw new TypeError('string expected for parameter "fn"');
      if (!Array.isArray(u) || !u.every(gn))
        throw new TypeError('Array containing Nodes expected for parameter "args"');
      this.implicit = c === !0, this.isPercentage = l === !0, this.op = o, this.fn = s, this.args = u || [];
    }
    get type() {
      return m2;
    }
    get isOperatorNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(o, s) {
      if (typeof this.fn != "string" || !wS(o, this.fn))
        throw o[this.fn] ? new Error('No access to function "' + this.fn + '"') : new Error("Function " + this.fn + ' missing in provided namespace "math"');
      var u = yo(o, this.fn), c = sl(this.args, function(h) {
        return h._compile(o, s);
      });
      if (typeof u == "function" && u.rawArgs === !0) {
        var l = this.args;
        return function(p, g, v) {
          return u(l, o, G0(p, g));
        };
      } else if (c.length === 1) {
        var d = c[0];
        return function(p, g, v) {
          return u(d(p, g, v));
        };
      } else if (c.length === 2) {
        var f = c[0], m = c[1];
        return function(p, g, v) {
          return u(f(p, g, v), m(p, g, v));
        };
      } else
        return function(p, g, v) {
          return u.apply(null, sl(c, function(y) {
            return y(p, g, v);
          }));
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(o) {
      for (var s = 0; s < this.args.length; s++)
        o(this.args[s], "args[" + s + "]", this);
    }
    /**
     * Create a new OperatorNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {OperatorNode} Returns a transformed copy of the node
     */
    map(o) {
      for (var s = [], u = 0; u < this.args.length; u++)
        s[u] = this._ifNode(o(this.args[u], "args[" + u + "]", this));
      return new a(this.op, this.fn, s, this.implicit, this.isPercentage);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {OperatorNode}
     */
    clone() {
      return new a(this.op, this.fn, this.args.slice(0), this.implicit, this.isPercentage);
    }
    /**
     * Check whether this is an unary OperatorNode:
     * has exactly one argument, like `-a`.
     * @return {boolean}
     *     Returns true when an unary operator node, false otherwise.
     */
    isUnary() {
      return this.args.length === 1;
    }
    /**
     * Check whether this is a binary OperatorNode:
     * has exactly two arguments, like `a + b`.
     * @return {boolean}
     *     Returns true when a binary operator node, false otherwise.
     */
    isBinary() {
      return this.args.length === 2;
    }
    /**
     * Get string representation.
     * @param {Object} options
     * @return {string} str
     */
    _toString(o) {
      var s = o && o.parenthesis ? o.parenthesis : "keep", u = o && o.implicit ? o.implicit : "hide", c = this.args, l = n(this, s, u, c, !1);
      if (c.length === 1) {
        var d = A0(this, s), f = c[0].toString(o);
        l[0] && (f = "(" + f + ")");
        var m = /[a-zA-Z]+/.test(this.op);
        return d === "right" ? this.op + (m ? " " : "") + f : d === "left" ? f + (m ? " " : "") + this.op : f + this.op;
      } else if (c.length === 2) {
        var h = c[0].toString(o), p = c[1].toString(o);
        return l[0] && (h = "(" + h + ")"), l[1] && (p = "(" + p + ")"), this.implicit && this.getIdentifier() === "OperatorNode:multiply" && u === "hide" ? h + " " + p : h + " " + this.op + " " + p;
      } else if (c.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
        var g = c.map(function(v, y) {
          return v = v.toString(o), l[y] && (v = "(" + v + ")"), v;
        });
        return this.implicit && this.getIdentifier() === "OperatorNode:multiply" && u === "hide" ? g.join(" ") : g.join(" " + this.op + " ");
      } else
        return this.fn + "(" + this.args.join(", ") + ")";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: m2,
        op: this.op,
        fn: this.fn,
        args: this.args,
        implicit: this.implicit,
        isPercentage: this.isPercentage
      };
    }
    /**
     * Instantiate an OperatorNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "OperatorNode",
     *      "op": "+", "fn": "add", "args": [...],
     *      "implicit": false,
     *      "isPercentage":false}
     *     ```
     *     where mathjs is optional
     * @returns {OperatorNode}
     */
    static fromJSON(o) {
      return new a(o.op, o.fn, o.args, o.implicit, o.isPercentage);
    }
    /**
     * Get HTML representation.
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(o) {
      var s = o && o.parenthesis ? o.parenthesis : "keep", u = o && o.implicit ? o.implicit : "hide", c = this.args, l = n(this, s, u, c, !1);
      if (c.length === 1) {
        var d = A0(this, s), f = c[0].toHTML(o);
        return l[0] && (f = '<span class="math-parenthesis math-round-parenthesis">(</span>' + f + '<span class="math-parenthesis math-round-parenthesis">)</span>'), d === "right" ? '<span class="math-operator math-unary-operator math-lefthand-unary-operator">' + $s(this.op) + "</span>" + f : f + '<span class="math-operator math-unary-operator math-righthand-unary-operator">' + $s(this.op) + "</span>";
      } else if (c.length === 2) {
        var m = c[0].toHTML(o), h = c[1].toHTML(o);
        return l[0] && (m = '<span class="math-parenthesis math-round-parenthesis">(</span>' + m + '<span class="math-parenthesis math-round-parenthesis">)</span>'), l[1] && (h = '<span class="math-parenthesis math-round-parenthesis">(</span>' + h + '<span class="math-parenthesis math-round-parenthesis">)</span>'), this.implicit && this.getIdentifier() === "OperatorNode:multiply" && u === "hide" ? m + '<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>' + h : m + '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + $s(this.op) + "</span>" + h;
      } else {
        var p = c.map(function(g, v) {
          return g = g.toHTML(o), l[v] && (g = '<span class="math-parenthesis math-round-parenthesis">(</span>' + g + '<span class="math-parenthesis math-round-parenthesis">)</span>'), g;
        });
        return c.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply") ? this.implicit && this.getIdentifier() === "OperatorNode:multiply" && u === "hide" ? p.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>') : p.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">' + $s(this.op) + "</span>") : '<span class="math-function">' + $s(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + p.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
      }
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(o) {
      var s = o && o.parenthesis ? o.parenthesis : "keep", u = o && o.implicit ? o.implicit : "hide", c = this.args, l = n(this, s, u, c, !0), d = Zr[this.fn];
      if (d = typeof d > "u" ? this.op : d, c.length === 1) {
        var f = A0(this, s), m = c[0].toTex(o);
        return l[0] && (m = "\\left(".concat(m, "\\right)")), f === "right" ? d + m : m + d;
      } else if (c.length === 2) {
        var h = c[0], p = h.toTex(o);
        l[0] && (p = "\\left(".concat(p, "\\right)"));
        var g = c[1], v = g.toTex(o);
        l[1] && (v = "\\left(".concat(v, "\\right)"));
        var y;
        switch (s === "keep" ? y = h.getIdentifier() : y = h.getContent().getIdentifier(), this.getIdentifier()) {
          case "OperatorNode:divide":
            return d + "{" + p + "}{" + v + "}";
          case "OperatorNode:pow":
            switch (p = "{" + p + "}", v = "{" + v + "}", y) {
              case "ConditionalNode":
              case "OperatorNode:divide":
                p = "\\left(".concat(p, "\\right)");
            }
            break;
          case "OperatorNode:multiply":
            if (this.implicit && u === "hide")
              return p + "~" + v;
        }
        return p + d + v;
      } else if (c.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
        var _ = c.map(function(S, b) {
          return S = S.toTex(o), l[b] && (S = "\\left(".concat(S, "\\right)")), S;
        });
        return this.getIdentifier() === "OperatorNode:multiply" && this.implicit && u === "hide" ? _.join("~") : _.join(d);
      } else
        return "\\mathrm{" + this.fn + "}\\left(" + c.map(function(S) {
          return S.toTex(o);
        }).join(",") + "\\right)";
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type + ":" + this.fn;
    }
  }
  return $a(a, "name", m2), a;
}, {
  isClass: !0,
  isNode: !0
}), p2 = "ParenthesisNode", Jbe = ["Node"], e4e = /* @__PURE__ */ me(p2, Jbe, (e) => {
  var {
    Node: t
  } = e;
  class r extends t {
    /**
     * @constructor ParenthesisNode
     * @extends {Node}
     * A parenthesis node describes manual parenthesis from the user input
     * @param {Node} content
     * @extends {Node}
     */
    constructor(a) {
      if (super(), !gn(a))
        throw new TypeError('Node expected for parameter "content"');
      this.content = a;
    }
    get type() {
      return p2;
    }
    get isParenthesisNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      return this.content._compile(a, i);
    }
    /**
     * Get the content of the current Node.
     * @return {Node} content
     * @override
     **/
    getContent() {
      return this.content.getContent();
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      a(this.content, "content", this);
    }
    /**
     * Create a new ParenthesisNode whose child is the result of calling
     * the provided callback function on the child of this node.
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {ParenthesisNode} Returns a clone of the node
     */
    map(a) {
      var i = a(this.content, "content", this);
      return new r(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ParenthesisNode}
     */
    clone() {
      return new r(this.content);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? "(" + this.content.toString(a) + ")" : this.content.toString(a);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: p2,
        content: this.content
      };
    }
    /**
     * Instantiate an ParenthesisNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ParenthesisNode", "content": ...}`,
     *                       where mathjs is optional
     * @returns {ParenthesisNode}
     */
    static fromJSON(a) {
      return new r(a.content);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? '<span class="math-parenthesis math-round-parenthesis">(</span>' + this.content.toHTML(a) + '<span class="math-parenthesis math-round-parenthesis">)</span>' : this.content.toHTML(a);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toTex(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? "\\left(".concat(this.content.toTex(a), "\\right)") : this.content.toTex(a);
    }
  }
  return $a(r, "name", p2), r;
}, {
  isClass: !0,
  isNode: !0
}), h2 = "RangeNode", t4e = ["Node"], r4e = /* @__PURE__ */ me(h2, t4e, (e) => {
  var {
    Node: t
  } = e;
  function r(a, i, o) {
    var s = In(a, i, o), u = {}, c = In(a.start, i, o);
    if (u.start = c !== null && c <= s || i === "all", a.step) {
      var l = In(a.step, i, o);
      u.step = l !== null && l <= s || i === "all";
    }
    var d = In(a.end, i, o);
    return u.end = d !== null && d <= s || i === "all", u;
  }
  class n extends t {
    /**
     * @constructor RangeNode
     * @extends {Node}
     * create a range
     * @param {Node} start  included lower-bound
     * @param {Node} end    included upper-bound
     * @param {Node} [step] optional step
     */
    constructor(i, o, s) {
      if (super(), !gn(i)) throw new TypeError("Node expected");
      if (!gn(o)) throw new TypeError("Node expected");
      if (s && !gn(s)) throw new TypeError("Node expected");
      if (arguments.length > 3) throw new Error("Too many arguments");
      this.start = i, this.end = o, this.step = s || null;
    }
    get type() {
      return h2;
    }
    get isRangeNode() {
      return !0;
    }
    /**
     * Check whether the RangeNode needs the `end` symbol to be defined.
     * This end is the size of the Matrix in current dimension.
     * @return {boolean}
     */
    needsEnd() {
      var i = this.filter(function(o) {
        return Wa(o) && o.name === "end";
      });
      return i.length > 0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var s = i.range, u = this.start._compile(i, o), c = this.end._compile(i, o);
      if (this.step) {
        var l = this.step._compile(i, o);
        return function(f, m, h) {
          return s(u(f, m, h), c(f, m, h), l(f, m, h));
        };
      } else
        return function(f, m, h) {
          return s(u(f, m, h), c(f, m, h));
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      i(this.start, "start", this), i(this.end, "end", this), this.step && i(this.step, "step", this);
    }
    /**
     * Create a new RangeNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {RangeNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this._ifNode(i(this.start, "start", this)), this._ifNode(i(this.end, "end", this)), this.step && this._ifNode(i(this.step, "step", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {RangeNode}
     */
    clone() {
      return new n(this.start, this.end, this.step && this.step);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", s = r(this, o, i && i.implicit), u, c = this.start.toString(i);
      if (s.start && (c = "(" + c + ")"), u = c, this.step) {
        var l = this.step.toString(i);
        s.step && (l = "(" + l + ")"), u += ":" + l;
      }
      var d = this.end.toString(i);
      return s.end && (d = "(" + d + ")"), u += ":" + d, u;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: h2,
        start: this.start,
        end: this.end,
        step: this.step
      };
    }
    /**
     * Instantiate an RangeNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "RangeNode", "start": ..., "end": ..., "step": ...}`,
     *     where mathjs is optional
     * @returns {RangeNode}
     */
    static fromJSON(i) {
      return new n(i.start, i.end, i.step);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", s = r(this, o, i && i.implicit), u, c = this.start.toHTML(i);
      if (s.start && (c = '<span class="math-parenthesis math-round-parenthesis">(</span>' + c + '<span class="math-parenthesis math-round-parenthesis">)</span>'), u = c, this.step) {
        var l = this.step.toHTML(i);
        s.step && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>'), u += '<span class="math-operator math-range-operator">:</span>' + l;
      }
      var d = this.end.toHTML(i);
      return s.end && (d = '<span class="math-parenthesis math-round-parenthesis">(</span>' + d + '<span class="math-parenthesis math-round-parenthesis">)</span>'), u += '<span class="math-operator math-range-operator">:</span>' + d, u;
    }
    /**
     * Get LaTeX representation
     * @params {Object} options
     * @return {string} str
     */
    _toTex(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", s = r(this, o, i && i.implicit), u = this.start.toTex(i);
      if (s.start && (u = "\\left(".concat(u, "\\right)")), this.step) {
        var c = this.step.toTex(i);
        s.step && (c = "\\left(".concat(c, "\\right)")), u += ":" + c;
      }
      var l = this.end.toTex(i);
      return s.end && (l = "\\left(".concat(l, "\\right)")), u += ":" + l, u;
    }
  }
  return $a(n, "name", h2), n;
}, {
  isClass: !0,
  isNode: !0
}), v2 = "RelationalNode", n4e = ["Node"], a4e = /* @__PURE__ */ me(v2, n4e, (e) => {
  var {
    Node: t
  } = e, r = {
    equal: "==",
    unequal: "!=",
    smaller: "<",
    larger: ">",
    smallerEq: "<=",
    largerEq: ">="
  };
  class n extends t {
    /**
     * A node representing a chained conditional expression, such as 'x > y > z'
     *
     * @param {String[]} conditionals
     *     An array of conditional operators used to compare the parameters
     * @param {Node[]} params
     *     The parameters that will be compared
     *
     * @constructor RelationalNode
     * @extends {Node}
     */
    constructor(i, o) {
      if (super(), !Array.isArray(i))
        throw new TypeError("Parameter conditionals must be an array");
      if (!Array.isArray(o))
        throw new TypeError("Parameter params must be an array");
      if (i.length !== o.length - 1)
        throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");
      this.conditionals = i, this.params = o;
    }
    get type() {
      return v2;
    }
    get isRelationalNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var s = this, u = this.params.map((c) => c._compile(i, o));
      return function(l, d, f) {
        for (var m, h = u[0](l, d, f), p = 0; p < s.conditionals.length; p++) {
          m = h, h = u[p + 1](l, d, f);
          var g = yo(i, s.conditionals[p]);
          if (!g(m, h))
            return !1;
        }
        return !0;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      this.params.forEach((o, s) => i(o, "params[" + s + "]", this), this);
    }
    /**
     * Create a new RelationalNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {RelationalNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this.conditionals.slice(), this.params.map((o, s) => this._ifNode(i(o, "params[" + s + "]", this)), this));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {RelationalNode}
     */
    clone() {
      return new n(this.conditionals, this.params);
    }
    /**
     * Get string representation.
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", s = In(this, o, i && i.implicit), u = this.params.map(function(d, f) {
        var m = In(d, o, i && i.implicit);
        return o === "all" || m !== null && m <= s ? "(" + d.toString(i) + ")" : d.toString(i);
      }), c = u[0], l = 0; l < this.conditionals.length; l++)
        c += " " + r[this.conditionals[l]], c += " " + u[l + 1];
      return c;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: v2,
        conditionals: this.conditionals,
        params: this.params
      };
    }
    /**
     * Instantiate a RelationalNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "RelationalNode", "conditionals": ..., "params": ...}`,
     *     where mathjs is optional
     * @returns {RelationalNode}
     */
    static fromJSON(i) {
      return new n(i.conditionals, i.params);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", s = In(this, o, i && i.implicit), u = this.params.map(function(d, f) {
        var m = In(d, o, i && i.implicit);
        return o === "all" || m !== null && m <= s ? '<span class="math-parenthesis math-round-parenthesis">(</span>' + d.toHTML(i) + '<span class="math-parenthesis math-round-parenthesis">)</span>' : d.toHTML(i);
      }), c = u[0], l = 0; l < this.conditionals.length; l++)
        c += '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + $s(r[this.conditionals[l]]) + "</span>" + u[l + 1];
      return c;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", s = In(this, o, i && i.implicit), u = this.params.map(function(d, f) {
        var m = In(d, o, i && i.implicit);
        return o === "all" || m !== null && m <= s ? "\\left(" + d.toTex(i) + "\right)" : d.toTex(i);
      }), c = u[0], l = 0; l < this.conditionals.length; l++)
        c += Zr[this.conditionals[l]] + u[l + 1];
      return c;
    }
  }
  return $a(n, "name", v2), n;
}, {
  isClass: !0,
  isNode: !0
}), i4e = "SymbolNode", o4e = ["math", "?Unit", "Node"], s4e = /* @__PURE__ */ me(i4e, o4e, (e) => {
  var {
    math: t,
    Unit: r,
    Node: n
  } = e;
  function a(o) {
    return r ? r.isValuelessUnit(o) : !1;
  }
  class i extends n {
    /**
     * @constructor SymbolNode
     * @extends {Node}
     * A symbol node can hold and resolve a symbol
     * @param {string} name
     * @extends {Node}
     */
    constructor(s) {
      if (super(), typeof s != "string")
        throw new TypeError('String expected for parameter "name"');
      this.name = s;
    }
    get type() {
      return "SymbolNode";
    }
    get isSymbolNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(s, u) {
      var c = this.name;
      if (u[c] === !0)
        return function(d, f, m) {
          return yo(f, c);
        };
      if (c in s)
        return function(d, f, m) {
          return d.has(c) ? d.get(c) : yo(s, c);
        };
      var l = a(c);
      return function(d, f, m) {
        return d.has(c) ? d.get(c) : l ? new r(null, c) : i.onUndefinedSymbol(c);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(s) {
    }
    /**
     * Create a new SymbolNode with children produced by the given callback.
     * Trivial since a SymbolNode has no children
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {SymbolNode} Returns a clone of the node
     */
    map(s) {
      return this.clone();
    }
    /**
     * Throws an error 'Undefined symbol {name}'
     * @param {string} name
     */
    static onUndefinedSymbol(s) {
      throw new Error("Undefined symbol " + s);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {SymbolNode}
     */
    clone() {
      return new i(this.name);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(s) {
      return this.name;
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(s) {
      var u = $s(this.name);
      return u === "true" || u === "false" ? '<span class="math-symbol math-boolean">' + u + "</span>" : u === "i" ? '<span class="math-symbol math-imaginary-symbol">' + u + "</span>" : u === "Infinity" ? '<span class="math-symbol math-infinity-symbol">' + u + "</span>" : u === "NaN" ? '<span class="math-symbol math-nan-symbol">' + u + "</span>" : u === "null" ? '<span class="math-symbol math-null-symbol">' + u + "</span>" : u === "undefined" ? '<span class="math-symbol math-undefined-symbol">' + u + "</span>" : '<span class="math-symbol">' + u + "</span>";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: "SymbolNode",
        name: this.name
      };
    }
    /**
     * Instantiate a SymbolNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "SymbolNode", name: "x"}`,
     *                       where mathjs is optional
     * @returns {SymbolNode}
     */
    static fromJSON(s) {
      return new i(s.name);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toTex(s) {
      var u = !1;
      typeof t[this.name] > "u" && a(this.name) && (u = !0);
      var c = iq(this.name, u);
      return c[0] === "\\" ? c : " " + c;
    }
  }
  return i;
}, {
  isClass: !0,
  isNode: !0
}), g2 = "FunctionNode", u4e = ["math", "Node", "SymbolNode"], c4e = /* @__PURE__ */ me(g2, u4e, (e) => {
  var t, {
    math: r,
    Node: n,
    SymbolNode: a
  } = e, i = (u) => Br(u, {
    truncate: 78
  });
  function o(u, c, l) {
    for (var d = "", f = /\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi, m = 0, h; (h = f.exec(u)) !== null; )
      if (d += u.substring(m, h.index), m = h.index, h[0] === "$$")
        d += "$", m++;
      else {
        m += h[0].length;
        var p = c[h[1]];
        if (!p)
          throw new ReferenceError("Template: Property " + h[1] + " does not exist.");
        if (h[2] === void 0)
          switch (typeof p) {
            case "string":
              d += p;
              break;
            case "object":
              if (gn(p))
                d += p.toTex(l);
              else if (Array.isArray(p))
                d += p.map(function(g, v) {
                  if (gn(g))
                    return g.toTex(l);
                  throw new TypeError("Template: " + h[1] + "[" + v + "] is not a Node.");
                }).join(",");
              else
                throw new TypeError("Template: " + h[1] + " has to be a Node, String or array of Nodes");
              break;
            default:
              throw new TypeError("Template: " + h[1] + " has to be a Node, String or array of Nodes");
          }
        else if (gn(p[h[2]] && p[h[2]]))
          d += p[h[2]].toTex(l);
        else
          throw new TypeError("Template: " + h[1] + "[" + h[2] + "] is not a Node.");
      }
    return d += u.slice(m), d;
  }
  class s extends n {
    /**
     * @constructor FunctionNode
     * @extends {./Node}
     * invoke a list with arguments on a node
     * @param {./Node | string} fn
     *     Item resolving to a function on which to invoke
     *     the arguments, typically a SymboNode or AccessorNode
     * @param {./Node[]} args
     */
    constructor(c, l) {
      if (super(), typeof c == "string" && (c = new a(c)), !gn(c)) throw new TypeError('Node expected as parameter "fn"');
      if (!Array.isArray(l) || !l.every(gn))
        throw new TypeError('Array containing Nodes expected for parameter "args"');
      this.fn = c, this.args = l || [];
    }
    // readonly property name
    get name() {
      return this.fn.name || "";
    }
    get type() {
      return g2;
    }
    get isFunctionNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(c, l) {
      var d = this.args.map((w) => w._compile(c, l));
      if (Wa(this.fn)) {
        var f = this.fn.name;
        if (l[f]) {
          var v = this.args;
          return function(C, M, T) {
            var N = yo(M, f);
            if (typeof N != "function")
              throw new TypeError("Argument '".concat(f, "' was not a function; received: ").concat(i(N)));
            if (N.rawArgs)
              return N(v, c, G0(C, M));
            var I = d.map((P) => P(C, M, T));
            return N.apply(N, I);
          };
        } else {
          var m = f in c ? yo(c, f) : void 0, h = typeof m == "function" && m.rawArgs === !0, p = (w) => {
            var C;
            if (w.has(f))
              C = w.get(f);
            else if (f in c)
              C = yo(c, f);
            else
              return s.onUndefinedFunction(f);
            if (typeof C == "function")
              return C;
            throw new TypeError("'".concat(f, `' is not a function; its value is:
  `).concat(i(C)));
          };
          if (h) {
            var g = this.args;
            return function(C, M, T) {
              var N = p(C);
              return N(g, c, G0(C, M));
            };
          } else
            switch (d.length) {
              case 0:
                return function(C, M, T) {
                  var N = p(C);
                  return N();
                };
              case 1:
                return function(C, M, T) {
                  var N = p(C), I = d[0];
                  return N(I(C, M, T));
                };
              case 2:
                return function(C, M, T) {
                  var N = p(C), I = d[0], P = d[1];
                  return N(I(C, M, T), P(C, M, T));
                };
              default:
                return function(C, M, T) {
                  var N = p(C), I = d.map((P) => P(C, M, T));
                  return N(...I);
                };
            }
        }
      } else if (Xd(this.fn) && gm(this.fn.index) && this.fn.index.isObjectProperty()) {
        var y = this.fn.object._compile(c, l), _ = this.fn.index.getObjectProperty(), S = this.args;
        return function(C, M, T) {
          var N = y(C, M, T), I = wpe(N, _);
          if (I != null && I.rawArgs)
            return I(S, c, G0(C, M));
          var P = d.map((O) => O(C, M, T));
          return I.apply(N, P);
        };
      } else {
        var b = this.fn.toString(), x = this.fn._compile(c, l), A = this.args;
        return function(C, M, T) {
          var N = x(C, M, T);
          if (typeof N != "function")
            throw new TypeError("Expression '".concat(b, "' did not evaluate to a function; value is:") + `
  `.concat(i(N)));
          if (N.rawArgs)
            return N(A, c, G0(C, M));
          var I = d.map((P) => P(C, M, T));
          return N.apply(N, I);
        };
      }
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(c) {
      c(this.fn, "fn", this);
      for (var l = 0; l < this.args.length; l++)
        c(this.args[l], "args[" + l + "]", this);
    }
    /**
     * Create a new FunctionNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {FunctionNode} Returns a transformed copy of the node
     */
    map(c) {
      for (var l = this._ifNode(c(this.fn, "fn", this)), d = [], f = 0; f < this.args.length; f++)
        d[f] = this._ifNode(c(this.args[f], "args[" + f + "]", this));
      return new s(l, d);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {FunctionNode}
     */
    clone() {
      return new s(this.fn, this.args.slice(0));
    }
    /**
     * Throws an error 'Undefined function {name}'
     * @param {string} name
     */
    /**
     * Get string representation. (wrapper function)
     * This overrides parts of Node's toString function.
     * If callback is an object containing callbacks, it
     * calls the correct callback for the current node,
     * otherwise it falls back to calling Node's toString
     * function.
     *
     * @param {Object} options
     * @return {string} str
     * @override
     */
    toString(c) {
      var l, d = this.fn.toString(c);
      return c && typeof c.handler == "object" && Tt(c.handler, d) && (l = c.handler[d](this, c)), typeof l < "u" ? l : super.toString(c);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(c) {
      var l = this.args.map(function(f) {
        return f.toString(c);
      }), d = x1(this.fn) ? "(" + this.fn.toString(c) + ")" : this.fn.toString(c);
      return d + "(" + l.join(", ") + ")";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: g2,
        fn: this.fn,
        args: this.args
      };
    }
    /**
     * Instantiate an AssignmentNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "FunctionNode", fn: ..., args: ...}`,
     *                       where mathjs is optional
     * @returns {FunctionNode}
     */
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(c) {
      var l = this.args.map(function(d) {
        return d.toHTML(c);
      });
      return '<span class="math-function">' + $s(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + l.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
    }
    /**
     * Get LaTeX representation. (wrapper function)
     * This overrides parts of Node's toTex function.
     * If callback is an object containing callbacks, it
     * calls the correct callback for the current node,
     * otherwise it falls back to calling Node's toTex
     * function.
     *
     * @param {Object} options
     * @return {string}
     */
    toTex(c) {
      var l;
      return c && typeof c.handler == "object" && Tt(c.handler, this.name) && (l = c.handler[this.name](this, c)), typeof l < "u" ? l : super.toTex(c);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(c) {
      var l = this.args.map(function(m) {
        return m.toTex(c);
      }), d;
      WP[this.name] && (d = WP[this.name]), r[this.name] && (typeof r[this.name].toTex == "function" || typeof r[this.name].toTex == "object" || typeof r[this.name].toTex == "string") && (d = r[this.name].toTex);
      var f;
      switch (typeof d) {
        case "function":
          f = d(this, c);
          break;
        case "string":
          f = o(d, this, c);
          break;
        case "object":
          switch (typeof d[l.length]) {
            case "function":
              f = d[l.length](this, c);
              break;
            case "string":
              f = o(d[l.length], this, c);
              break;
          }
      }
      return typeof f < "u" ? f : o(Vbe, this, c);
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type + ":" + this.name;
    }
  }
  return t = s, $a(s, "name", g2), $a(s, "onUndefinedFunction", function(u) {
    throw new Error("Undefined function " + u);
  }), $a(s, "fromJSON", function(u) {
    return new t(u.fn, u.args);
  }), s;
}, {
  isClass: !0,
  isNode: !0
}), QP = "parse", l4e = ["typed", "numeric", "config", "AccessorNode", "ArrayNode", "AssignmentNode", "BlockNode", "ConditionalNode", "ConstantNode", "FunctionAssignmentNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "RangeNode", "RelationalNode", "SymbolNode"], d4e = /* @__PURE__ */ me(QP, l4e, (e) => {
  var {
    typed: t,
    numeric: r,
    config: n,
    AccessorNode: a,
    ArrayNode: i,
    AssignmentNode: o,
    BlockNode: s,
    ConditionalNode: u,
    ConstantNode: c,
    FunctionAssignmentNode: l,
    FunctionNode: d,
    IndexNode: f,
    ObjectNode: m,
    OperatorNode: h,
    ParenthesisNode: p,
    RangeNode: g,
    RelationalNode: v,
    SymbolNode: y
  } = e, _ = t(QP, {
    string: function(xe) {
      return K(xe, {});
    },
    "Array | Matrix": function(xe) {
      return S(xe, {});
    },
    "string, Object": function(xe, ke) {
      var Je = ke.nodes !== void 0 ? ke.nodes : {};
      return K(xe, Je);
    },
    "Array | Matrix, Object": S
  });
  function S(j) {
    var xe = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, ke = xe.nodes !== void 0 ? xe.nodes : {};
    return Tr(j, function(Je) {
      if (typeof Je != "string") throw new TypeError("String expected");
      return K(Je, ke);
    });
  }
  var b = {
    NULL: 0,
    DELIMITER: 1,
    NUMBER: 2,
    SYMBOL: 3,
    UNKNOWN: 4
  }, x = {
    ",": !0,
    "(": !0,
    ")": !0,
    "[": !0,
    "]": !0,
    "{": !0,
    "}": !0,
    '"': !0,
    "'": !0,
    ";": !0,
    "+": !0,
    "-": !0,
    "*": !0,
    ".*": !0,
    "/": !0,
    "./": !0,
    "%": !0,
    "^": !0,
    ".^": !0,
    "~": !0,
    "!": !0,
    "&": !0,
    "|": !0,
    "^|": !0,
    "=": !0,
    ":": !0,
    "?": !0,
    "==": !0,
    "!=": !0,
    "<": !0,
    ">": !0,
    "<=": !0,
    ">=": !0,
    "<<": !0,
    ">>": !0,
    ">>>": !0
  }, A = {
    mod: !0,
    to: !0,
    in: !0,
    and: !0,
    xor: !0,
    or: !0,
    not: !0
  }, w = {
    true: !0,
    false: !1,
    null: null,
    undefined: void 0
  }, C = ["NaN", "Infinity"], M = {
    '"': '"',
    "'": "'",
    "\\": "\\",
    "/": "/",
    b: "\b",
    f: "\f",
    n: `
`,
    r: "\r",
    t: "	"
    // note that \u is handled separately in parseStringToken()
  };
  function T() {
    return {
      extraNodes: {},
      // current extra nodes, must be careful not to mutate
      expression: "",
      // current expression
      comment: "",
      // last parsed comment
      index: 0,
      // current index in expr
      token: "",
      // current token
      tokenType: b.NULL,
      // type of the token
      nestingLevel: 0,
      // level of nesting inside parameters, used to ignore newline characters
      conditionalLevel: null
      // when a conditional is being parsed, the level of the conditional is stored here
    };
  }
  function N(j, xe) {
    return j.expression.substr(j.index, xe);
  }
  function I(j) {
    return N(j, 1);
  }
  function P(j) {
    j.index++;
  }
  function O(j) {
    return j.expression.charAt(j.index - 1);
  }
  function F(j) {
    return j.expression.charAt(j.index + 1);
  }
  function R(j) {
    for (j.tokenType = b.NULL, j.token = "", j.comment = ""; ; ) {
      if (I(j) === "#")
        for (; I(j) !== `
` && I(j) !== ""; )
          j.comment += I(j), P(j);
      if (_.isWhitespace(I(j), j.nestingLevel))
        P(j);
      else
        break;
    }
    if (I(j) === "") {
      j.tokenType = b.DELIMITER;
      return;
    }
    if (I(j) === `
` && !j.nestingLevel) {
      j.tokenType = b.DELIMITER, j.token = I(j), P(j);
      return;
    }
    var xe = I(j), ke = N(j, 2), Je = N(j, 3);
    if (Je.length === 3 && x[Je]) {
      j.tokenType = b.DELIMITER, j.token = Je, P(j), P(j), P(j);
      return;
    }
    if (ke.length === 2 && x[ke]) {
      j.tokenType = b.DELIMITER, j.token = ke, P(j), P(j);
      return;
    }
    if (x[xe]) {
      j.tokenType = b.DELIMITER, j.token = xe, P(j);
      return;
    }
    if (_.isDigitDot(xe)) {
      j.tokenType = b.NUMBER;
      var Ct = N(j, 2);
      if (Ct === "0b" || Ct === "0o" || Ct === "0x") {
        for (j.token += I(j), P(j), j.token += I(j), P(j); _.isHexDigit(I(j)); )
          j.token += I(j), P(j);
        if (I(j) === ".")
          for (j.token += ".", P(j); _.isHexDigit(I(j)); )
            j.token += I(j), P(j);
        else if (I(j) === "i")
          for (j.token += "i", P(j); _.isDigit(I(j)); )
            j.token += I(j), P(j);
        return;
      }
      if (I(j) === ".") {
        if (j.token += I(j), P(j), !_.isDigit(I(j))) {
          j.tokenType = b.DELIMITER;
          return;
        }
      } else {
        for (; _.isDigit(I(j)); )
          j.token += I(j), P(j);
        _.isDecimalMark(I(j), F(j)) && (j.token += I(j), P(j));
      }
      for (; _.isDigit(I(j)); )
        j.token += I(j), P(j);
      if (I(j) === "E" || I(j) === "e") {
        if (_.isDigit(F(j)) || F(j) === "-" || F(j) === "+") {
          if (j.token += I(j), P(j), (I(j) === "+" || I(j) === "-") && (j.token += I(j), P(j)), !_.isDigit(I(j)))
            throw dt(j, 'Digit expected, got "' + I(j) + '"');
          for (; _.isDigit(I(j)); )
            j.token += I(j), P(j);
          if (_.isDecimalMark(I(j), F(j)))
            throw dt(j, 'Digit expected, got "' + I(j) + '"');
        } else if (F(j) === ".")
          throw P(j), dt(j, 'Digit expected, got "' + I(j) + '"');
      }
      return;
    }
    if (_.isAlpha(I(j), O(j), F(j))) {
      for (; _.isAlpha(I(j), O(j), F(j)) || _.isDigit(I(j)); )
        j.token += I(j), P(j);
      Tt(A, j.token) ? j.tokenType = b.DELIMITER : j.tokenType = b.SYMBOL;
      return;
    }
    for (j.tokenType = b.UNKNOWN; I(j) !== ""; )
      j.token += I(j), P(j);
    throw dt(j, 'Syntax error in part "' + j.token + '"');
  }
  function G(j) {
    do
      R(j);
    while (j.token === `
`);
  }
  function L(j) {
    j.nestingLevel++;
  }
  function q(j) {
    j.nestingLevel--;
  }
  _.isAlpha = function(xe, ke, Je) {
    return _.isValidLatinOrGreek(xe) || _.isValidMathSymbol(xe, Je) || _.isValidMathSymbol(ke, xe);
  }, _.isValidLatinOrGreek = function(xe) {
    return /^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(xe);
  }, _.isValidMathSymbol = function(xe, ke) {
    return /^[\uD835]$/.test(xe) && /^[\uDC00-\uDFFF]$/.test(ke) && /^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(ke);
  }, _.isWhitespace = function(xe, ke) {
    return xe === " " || xe === "	" || xe === `
` && ke > 0;
  }, _.isDecimalMark = function(xe, ke) {
    return xe === "." && ke !== "/" && ke !== "*" && ke !== "^";
  }, _.isDigitDot = function(xe) {
    return xe >= "0" && xe <= "9" || xe === ".";
  }, _.isDigit = function(xe) {
    return xe >= "0" && xe <= "9";
  }, _.isHexDigit = function(xe) {
    return xe >= "0" && xe <= "9" || xe >= "a" && xe <= "f" || xe >= "A" && xe <= "F";
  };
  function K(j, xe) {
    var ke = T();
    Ei(ke, {
      expression: j,
      extraNodes: xe
    }), R(ke);
    var Je = X(ke);
    if (ke.token !== "")
      throw ke.tokenType === b.DELIMITER ? Le(ke, "Unexpected operator " + ke.token) : dt(ke, 'Unexpected part "' + ke.token + '"');
    return Je;
  }
  function X(j) {
    var xe, ke = [], Je;
    for (j.token !== "" && j.token !== `
` && j.token !== ";" && (xe = H(j), j.comment && (xe.comment = j.comment)); j.token === `
` || j.token === ";"; )
      ke.length === 0 && xe && (Je = j.token !== ";", ke.push({
        node: xe,
        visible: Je
      })), R(j), j.token !== `
` && j.token !== ";" && j.token !== "" && (xe = H(j), j.comment && (xe.comment = j.comment), Je = j.token !== ";", ke.push({
        node: xe,
        visible: Je
      }));
    return ke.length > 0 ? new s(ke) : (xe || (xe = new c(void 0), j.comment && (xe.comment = j.comment)), xe);
  }
  function H(j) {
    var xe, ke, Je, Ct, At = W(j);
    if (j.token === "=") {
      if (Wa(At))
        return xe = At.name, G(j), Je = H(j), new o(new y(xe), Je);
      if (Xd(At))
        return G(j), Je = H(j), new o(At.object, At.index, Je);
      if (vl(At) && Wa(At.fn) && (Ct = !0, ke = [], xe = At.name, At.args.forEach(function(Or, qn) {
        Wa(Or) ? ke[qn] = Or.name : Ct = !1;
      }), Ct))
        return G(j), Je = H(j), new l(xe, ke, Je);
      throw dt(j, "Invalid left hand side of assignment operator =");
    }
    return At;
  }
  function W(j) {
    for (var xe = ee(j); j.token === "?"; ) {
      var ke = j.conditionalLevel;
      j.conditionalLevel = j.nestingLevel, G(j);
      var Je = xe, Ct = H(j);
      if (j.token !== ":") throw dt(j, "False part of conditional expression expected");
      j.conditionalLevel = null, G(j);
      var At = H(j);
      xe = new u(Je, Ct, At), j.conditionalLevel = ke;
    }
    return xe;
  }
  function ee(j) {
    for (var xe = $(j); j.token === "or"; )
      G(j), xe = new h("or", "or", [xe, $(j)]);
    return xe;
  }
  function $(j) {
    for (var xe = te(j); j.token === "xor"; )
      G(j), xe = new h("xor", "xor", [xe, te(j)]);
    return xe;
  }
  function te(j) {
    for (var xe = re(j); j.token === "and"; )
      G(j), xe = new h("and", "and", [xe, re(j)]);
    return xe;
  }
  function re(j) {
    for (var xe = ie(j); j.token === "|"; )
      G(j), xe = new h("|", "bitOr", [xe, ie(j)]);
    return xe;
  }
  function ie(j) {
    for (var xe = oe(j); j.token === "^|"; )
      G(j), xe = new h("^|", "bitXor", [xe, oe(j)]);
    return xe;
  }
  function oe(j) {
    for (var xe = se(j); j.token === "&"; )
      G(j), xe = new h("&", "bitAnd", [xe, se(j)]);
    return xe;
  }
  function se(j) {
    for (var xe = [he(j)], ke = [], Je = {
      "==": "equal",
      "!=": "unequal",
      "<": "smaller",
      ">": "larger",
      "<=": "smallerEq",
      ">=": "largerEq"
    }; Tt(Je, j.token); ) {
      var Ct = {
        name: j.token,
        fn: Je[j.token]
      };
      ke.push(Ct), G(j), xe.push(he(j));
    }
    return xe.length === 1 ? xe[0] : xe.length === 2 ? new h(ke[0].name, ke[0].fn, xe) : new v(ke.map((At) => At.fn), xe);
  }
  function he(j) {
    var xe, ke, Je, Ct;
    xe = ge(j);
    for (var At = {
      "<<": "leftShift",
      ">>": "rightArithShift",
      ">>>": "rightLogShift"
    }; Tt(At, j.token); )
      ke = j.token, Je = At[ke], G(j), Ct = [xe, ge(j)], xe = new h(ke, Je, Ct);
    return xe;
  }
  function ge(j) {
    var xe, ke, Je, Ct;
    xe = De(j);
    for (var At = {
      to: "to",
      in: "to"
      // alias of 'to'
    }; Tt(At, j.token); )
      ke = j.token, Je = At[ke], G(j), ke === "in" && j.token === "" ? xe = new h("*", "multiply", [xe, new y("in")], !0) : (Ct = [xe, De(j)], xe = new h(ke, Je, Ct));
    return xe;
  }
  function De(j) {
    var xe, ke = [];
    if (j.token === ":" ? xe = new c(1) : xe = ae(j), j.token === ":" && j.conditionalLevel !== j.nestingLevel) {
      for (ke.push(xe); j.token === ":" && ke.length < 3; )
        G(j), j.token === ")" || j.token === "]" || j.token === "," || j.token === "" ? ke.push(new y("end")) : ke.push(ae(j));
      ke.length === 3 ? xe = new g(ke[0], ke[2], ke[1]) : xe = new g(ke[0], ke[1]);
    }
    return xe;
  }
  function ae(j) {
    var xe, ke, Je, Ct;
    xe = ce(j);
    for (var At = {
      "+": "add",
      "-": "subtract"
    }; Tt(At, j.token); ) {
      ke = j.token, Je = At[ke], G(j);
      var Or = ce(j);
      Or.isPercentage ? Ct = [xe, new h("*", "multiply", [xe, Or])] : Ct = [xe, Or], xe = new h(ke, Je, Ct);
    }
    return xe;
  }
  function ce(j) {
    var xe, ke, Je, Ct;
    xe = _e(j), ke = xe;
    for (var At = {
      "*": "multiply",
      ".*": "dotMultiply",
      "/": "divide",
      "./": "dotDivide"
    }; Tt(At, j.token); )
      Je = j.token, Ct = At[Je], G(j), ke = _e(j), xe = new h(Je, Ct, [xe, ke]);
    return xe;
  }
  function _e(j) {
    var xe, ke;
    for (xe = le(j), ke = xe; j.tokenType === b.SYMBOL || j.token === "in" && Vr(xe) || j.tokenType === b.NUMBER && !Vr(ke) && (!Da(ke) || ke.op === "!") || j.token === "("; )
      ke = le(j), xe = new h(
        "*",
        "multiply",
        [xe, ke],
        !0
        /* implicit */
      );
    return xe;
  }
  function le(j) {
    for (var xe = ue(j), ke = xe, Je = []; j.token === "/" && k_(ke); )
      if (Je.push(Ei({}, j)), G(j), j.tokenType === b.NUMBER)
        if (Je.push(Ei({}, j)), G(j), j.tokenType === b.SYMBOL || j.token === "(")
          Ei(j, Je.pop()), Je.pop(), ke = ue(j), xe = new h("/", "divide", [xe, ke]);
        else {
          Je.pop(), Ei(j, Je.pop());
          break;
        }
      else {
        Ei(j, Je.pop());
        break;
      }
    return xe;
  }
  function ue(j) {
    var xe, ke, Je, Ct;
    xe = be(j);
    for (var At = {
      "%": "mod",
      mod: "mod"
    }; Tt(At, j.token); )
      ke = j.token, Je = At[ke], G(j), ke === "%" && j.tokenType === b.DELIMITER && j.token !== "(" ? xe = new h("/", "divide", [xe, new c(100)], !1, !0) : (Ct = [xe, be(j)], xe = new h(ke, Je, Ct));
    return xe;
  }
  function be(j) {
    var xe, ke, Je, Ct = {
      "-": "unaryMinus",
      "+": "unaryPlus",
      "~": "bitNot",
      not: "not"
    };
    return Tt(Ct, j.token) ? (Je = Ct[j.token], xe = j.token, G(j), ke = [be(j)], new h(xe, Je, ke)) : Se(j);
  }
  function Se(j) {
    var xe, ke, Je, Ct;
    return xe = Ne(j), (j.token === "^" || j.token === ".^") && (ke = j.token, Je = ke === "^" ? "pow" : "dotPow", G(j), Ct = [xe, be(j)], xe = new h(ke, Je, Ct)), xe;
  }
  function Ne(j) {
    var xe, ke, Je, Ct;
    xe = J(j);
    for (var At = {
      "!": "factorial",
      "'": "ctranspose"
    }; Tt(At, j.token); )
      ke = j.token, Je = At[ke], R(j), Ct = [xe], xe = new h(ke, Je, Ct), xe = de(j, xe);
    return xe;
  }
  function J(j) {
    var xe = [];
    if (j.tokenType === b.SYMBOL && Tt(j.extraNodes, j.token)) {
      var ke = j.extraNodes[j.token];
      if (R(j), j.token === "(") {
        if (xe = [], L(j), R(j), j.token !== ")")
          for (xe.push(H(j)); j.token === ","; )
            R(j), xe.push(H(j));
        if (j.token !== ")")
          throw dt(j, "Parenthesis ) expected");
        q(j), R(j);
      }
      return new ke(xe);
    }
    return Z(j);
  }
  function Z(j) {
    var xe, ke;
    return j.tokenType === b.SYMBOL || j.tokenType === b.DELIMITER && j.token in A ? (ke = j.token, R(j), Tt(w, ke) ? xe = new c(w[ke]) : C.includes(ke) ? xe = new c(r(ke, "number")) : xe = new y(ke), xe = de(j, xe), xe) : ye(j);
  }
  function de(j, xe, ke) {
    for (var Je; (j.token === "(" || j.token === "[" || j.token === ".") && !ke; )
      if (Je = [], j.token === "(")
        if (Wa(xe) || Xd(xe)) {
          if (L(j), R(j), j.token !== ")")
            for (Je.push(H(j)); j.token === ","; )
              R(j), Je.push(H(j));
          if (j.token !== ")")
            throw dt(j, "Parenthesis ) expected");
          q(j), R(j), xe = new d(xe, Je);
        } else
          return xe;
      else if (j.token === "[") {
        if (L(j), R(j), j.token !== "]")
          for (Je.push(H(j)); j.token === ","; )
            R(j), Je.push(H(j));
        if (j.token !== "]")
          throw dt(j, "Parenthesis ] expected");
        q(j), R(j), xe = new a(xe, new f(Je));
      } else {
        R(j);
        var Ct = j.tokenType === b.SYMBOL || j.tokenType === b.DELIMITER && j.token in A;
        if (!Ct)
          throw dt(j, "Property name expected after dot");
        Je.push(new c(j.token)), R(j);
        var At = !0;
        xe = new a(xe, new f(Je, At));
      }
    return xe;
  }
  function ye(j) {
    var xe, ke;
    return j.token === '"' || j.token === "'" ? (ke = Ae(j, j.token), xe = new c(ke), xe = de(j, xe), xe) : Ce(j);
  }
  function Ae(j, xe) {
    for (var ke = ""; I(j) !== "" && I(j) !== xe; )
      if (I(j) === "\\") {
        P(j);
        var Je = I(j), Ct = M[Je];
        if (Ct !== void 0)
          ke += Ct, j.index += 1;
        else if (Je === "u") {
          var At = j.expression.slice(j.index + 1, j.index + 5);
          if (/^[0-9A-Fa-f]{4}$/.test(At))
            ke += String.fromCharCode(parseInt(At, 16)), j.index += 5;
          else
            throw dt(j, "Invalid unicode character \\u".concat(At));
        } else
          throw dt(j, "Bad escape character \\".concat(Je));
      } else
        ke += I(j), P(j);
    if (R(j), j.token !== xe)
      throw dt(j, "End of string ".concat(xe, " expected"));
    return R(j), ke;
  }
  function Ce(j) {
    var xe, ke, Je, Ct;
    if (j.token === "[") {
      if (L(j), R(j), j.token !== "]") {
        var At = Ie(j);
        if (j.token === ";") {
          for (Je = 1, ke = [At]; j.token === ";"; )
            R(j), j.token !== "]" && (ke[Je] = Ie(j), Je++);
          if (j.token !== "]")
            throw dt(j, "End of matrix ] expected");
          q(j), R(j), Ct = ke[0].items.length;
          for (var Or = 1; Or < Je; Or++)
            if (ke[Or].items.length !== Ct)
              throw Le(j, "Column dimensions mismatch (" + ke[Or].items.length + " !== " + Ct + ")");
          xe = new i(ke);
        } else {
          if (j.token !== "]")
            throw dt(j, "End of matrix ] expected");
          q(j), R(j), xe = At;
        }
      } else
        q(j), R(j), xe = new i([]);
      return de(j, xe);
    }
    return Ue(j);
  }
  function Ie(j) {
    for (var xe = [H(j)], ke = 1; j.token === ","; )
      R(j), j.token !== "]" && j.token !== ";" && (xe[ke] = H(j), ke++);
    return new i(xe);
  }
  function Ue(j) {
    if (j.token === "{") {
      L(j);
      var xe, ke = {};
      do
        if (R(j), j.token !== "}") {
          if (j.token === '"' || j.token === "'")
            xe = Ae(j, j.token);
          else if (j.tokenType === b.SYMBOL || j.tokenType === b.DELIMITER && j.token in A)
            xe = j.token, R(j);
          else
            throw dt(j, "Symbol or string expected as object key");
          if (j.token !== ":")
            throw dt(j, "Colon : expected after object key");
          R(j), ke[xe] = H(j);
        }
      while (j.token === ",");
      if (j.token !== "}")
        throw dt(j, "Comma , or bracket } expected after object value");
      q(j), R(j);
      var Je = new m(ke);
      return Je = de(j, Je), Je;
    }
    return Xe(j);
  }
  function Xe(j) {
    var xe;
    if (j.tokenType === b.NUMBER) {
      xe = j.token, R(j);
      var ke = $d(xe, n), Je = r(xe, ke);
      return new c(Je);
    }
    return je(j);
  }
  function je(j) {
    var xe;
    if (j.token === "(") {
      if (L(j), R(j), xe = H(j), j.token !== ")")
        throw dt(j, "Parenthesis ) expected");
      return q(j), R(j), xe = new p(xe), xe = de(j, xe), xe;
    }
    return ht(j);
  }
  function ht(j) {
    throw j.token === "" ? dt(j, "Unexpected end of expression") : dt(j, "Value expected");
  }
  function xt(j) {
    return j.index - j.token.length + 1;
  }
  function dt(j, xe) {
    var ke = xt(j), Je = new SyntaxError(xe + " (char " + ke + ")");
    return Je.char = ke, Je;
  }
  function Le(j, xe) {
    var ke = xt(j), Je = new SyntaxError(xe + " (char " + ke + ")");
    return Je.char = ke, Je;
  }
  return t.addConversion({
    from: "string",
    to: "Node",
    convert: _
  }), _;
}), $P = "compile", f4e = ["typed", "parse"], m4e = /* @__PURE__ */ me($P, f4e, (e) => {
  var {
    typed: t,
    parse: r
  } = e;
  return t($P, {
    string: function(a) {
      return r(a).compile();
    },
    "Array | Matrix": function(a) {
      return Tr(a, function(i) {
        return r(i).compile();
      });
    }
  });
}), JP = "evaluate", p4e = ["typed", "parse"], h4e = /* @__PURE__ */ me(JP, p4e, (e) => {
  var {
    typed: t,
    parse: r
  } = e;
  return t(JP, {
    string: function(a) {
      var i = Eh();
      return r(a).compile().evaluate(i);
    },
    "string, Map | Object": function(a, i) {
      return r(a).compile().evaluate(i);
    },
    "Array | Matrix": function(a) {
      var i = Eh();
      return Tr(a, function(o) {
        return r(o).compile().evaluate(i);
      });
    },
    "Array | Matrix, Map | Object": function(a, i) {
      return Tr(a, function(o) {
        return r(o).compile().evaluate(i);
      });
    }
  });
}), v4e = "Parser", g4e = ["evaluate"], y4e = /* @__PURE__ */ me(v4e, g4e, (e) => {
  var {
    evaluate: t
  } = e;
  function r() {
    if (!(this instanceof r))
      throw new SyntaxError("Constructor must be called with the new operator");
    Object.defineProperty(this, "scope", {
      value: Eh(),
      writable: !1
    });
  }
  return r.prototype.type = "Parser", r.prototype.isParser = !0, r.prototype.evaluate = function(n) {
    return t(n, this.scope);
  }, r.prototype.get = function(n) {
    if (this.scope.has(n))
      return this.scope.get(n);
  }, r.prototype.getAll = function() {
    return Dpe(this.scope);
  }, r.prototype.getAllAsMap = function() {
    return this.scope;
  }, r.prototype.set = function(n, a) {
    return this.scope.set(n, a), a;
  }, r.prototype.remove = function(n) {
    this.scope.delete(n);
  }, r.prototype.clear = function() {
    this.scope.clear();
  }, r;
}, {
  isClass: !0
}), eB = "parser", b4e = ["typed", "Parser"], x4e = /* @__PURE__ */ me(eB, b4e, (e) => {
  var {
    typed: t,
    Parser: r
  } = e;
  return t(eB, {
    "": function() {
      return new r();
    }
  });
}), tB = "lup", _4e = ["typed", "matrix", "abs", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "larger", "equalScalar", "unaryMinus", "DenseMatrix", "SparseMatrix", "Spa"], S4e = /* @__PURE__ */ me(tB, _4e, (e) => {
  var {
    typed: t,
    matrix: r,
    abs: n,
    addScalar: a,
    divideScalar: i,
    multiplyScalar: o,
    subtractScalar: s,
    larger: u,
    equalScalar: c,
    unaryMinus: l,
    DenseMatrix: d,
    SparseMatrix: f,
    Spa: m
  } = e;
  return t(tB, {
    DenseMatrix: function(v) {
      return h(v);
    },
    SparseMatrix: function(v) {
      return p(v);
    },
    Array: function(v) {
      var y = r(v), _ = h(y);
      return {
        L: _.L.valueOf(),
        U: _.U.valueOf(),
        p: _.p
      };
    }
  });
  function h(g) {
    var v = g._size[0], y = g._size[1], _ = Math.min(v, y), S = Jt(g._data), b = [], x = [v, _], A = [], w = [_, y], C, M, T, N = [];
    for (C = 0; C < v; C++)
      N[C] = C;
    for (M = 0; M < y; M++) {
      if (M > 0)
        for (C = 0; C < v; C++) {
          var I = Math.min(C, M), P = 0;
          for (T = 0; T < I; T++)
            P = a(P, o(S[C][T], S[T][M]));
          S[C][M] = s(S[C][M], P);
        }
      var O = M, F = 0, R = 0;
      for (C = M; C < v; C++) {
        var G = S[C][M], L = n(G);
        u(L, F) && (O = C, F = L, R = G);
      }
      if (M !== O && (N[M] = [N[O], N[O] = N[M]][0], d._swapRows(M, O, S)), M < v)
        for (C = M + 1; C < v; C++) {
          var q = S[C][M];
          c(q, 0) || (S[C][M] = i(S[C][M], R));
        }
    }
    for (M = 0; M < y; M++)
      for (C = 0; C < v; C++) {
        if (M === 0 && (C < y && (A[C] = []), b[C] = []), C < M) {
          C < y && (A[C][M] = S[C][M]), M < v && (b[C][M] = 0);
          continue;
        }
        if (C === M) {
          C < y && (A[C][M] = S[C][M]), M < v && (b[C][M] = 1);
          continue;
        }
        C < y && (A[C][M] = 0), M < v && (b[C][M] = S[C][M]);
      }
    var K = new d({
      data: b,
      size: x
    }), X = new d({
      data: A,
      size: w
    }), H = [];
    for (C = 0, _ = N.length; C < _; C++)
      H[N[C]] = C;
    return {
      L: K,
      U: X,
      p: H,
      toString: function() {
        return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
P: ` + this.p;
      }
    };
  }
  function p(g) {
    var v = g._size[0], y = g._size[1], _ = Math.min(v, y), S = g._values, b = g._index, x = g._ptr, A = [], w = [], C = [], M = [v, _], T = [], N = [], I = [], P = [_, y], O, F, R, G = [], L = [];
    for (O = 0; O < v; O++)
      G[O] = O, L[O] = O;
    var q = function(H, W) {
      var ee = L[H], $ = L[W];
      G[ee] = W, G[$] = H, L[H] = $, L[W] = ee;
    }, K = function() {
      var H = new m();
      F < v && (C.push(A.length), A.push(1), w.push(F)), I.push(T.length);
      var W = x[F], ee = x[F + 1];
      for (R = W; R < ee; R++)
        O = b[R], H.set(G[O], S[R]);
      F > 0 && H.forEach(0, F - 1, function(ie, oe) {
        f._forEachRow(ie, A, w, C, function(se, he) {
          se > ie && H.accumulate(se, l(o(he, oe)));
        });
      });
      var $ = F, te = H.get(F), re = n(te);
      H.forEach(F + 1, v - 1, function(ie, oe) {
        var se = n(oe);
        u(se, re) && ($ = ie, re = se, te = oe);
      }), F !== $ && (f._swapRows(F, $, M[1], A, w, C), f._swapRows(F, $, P[1], T, N, I), H.swap(F, $), q(F, $)), H.forEach(0, v - 1, function(ie, oe) {
        ie <= F ? (T.push(oe), N.push(ie)) : (oe = i(oe, te), c(oe, 0) || (A.push(oe), w.push(ie)));
      });
    };
    for (F = 0; F < y; F++)
      K();
    return I.push(T.length), C.push(A.length), {
      L: new f({
        values: A,
        index: w,
        ptr: C,
        size: M
      }),
      U: new f({
        values: T,
        index: N,
        ptr: I,
        size: P
      }),
      p: G,
      toString: function() {
        return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
P: ` + this.p;
      }
    };
  }
}), rB = "qr", A4e = ["typed", "matrix", "zeros", "identity", "isZero", "equal", "sign", "sqrt", "conj", "unaryMinus", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "complex"], oq = /* @__PURE__ */ me(rB, A4e, (e) => {
  var {
    typed: t,
    matrix: r,
    zeros: n,
    identity: a,
    isZero: i,
    equal: o,
    sign: s,
    sqrt: u,
    conj: c,
    unaryMinus: l,
    addScalar: d,
    divideScalar: f,
    multiplyScalar: m,
    subtractScalar: h,
    complex: p
  } = e;
  return Ei(t(rB, {
    DenseMatrix: function(S) {
      return v(S);
    },
    SparseMatrix: function(S) {
      return y();
    },
    Array: function(S) {
      var b = r(S), x = v(b);
      return {
        Q: x.Q.valueOf(),
        R: x.R.valueOf()
      };
    }
  }), {
    _denseQRimpl: g
  });
  function g(_) {
    var S = _._size[0], b = _._size[1], x = a([S], "dense"), A = x._data, w = _.clone(), C = w._data, M, T, N, I = n([S], "");
    for (N = 0; N < Math.min(b, S); ++N) {
      var P = C[N][N], O = l(o(P, 0) ? 1 : s(P)), F = c(O), R = 0;
      for (M = N; M < S; M++)
        R = d(R, m(C[M][N], c(C[M][N])));
      var G = m(O, u(R));
      if (!i(G)) {
        var L = h(P, G);
        for (I[N] = 1, M = N + 1; M < S; M++)
          I[M] = f(C[M][N], L);
        var q = l(c(f(L, G))), K = void 0;
        for (T = N; T < b; T++) {
          for (K = 0, M = N; M < S; M++)
            K = d(K, m(c(I[M]), C[M][T]));
          for (K = m(K, q), M = N; M < S; M++)
            C[M][T] = m(h(C[M][T], m(I[M], K)), F);
        }
        for (M = 0; M < S; M++) {
          for (K = 0, T = N; T < S; T++)
            K = d(K, m(A[M][T], I[T]));
          for (K = m(K, q), T = N; T < S; ++T)
            A[M][T] = f(h(A[M][T], m(K, c(I[T]))), F);
        }
      }
    }
    return {
      Q: x,
      R: w,
      toString: function() {
        return "Q: " + this.Q.toString() + `
R: ` + this.R.toString();
      }
    };
  }
  function v(_) {
    var S = g(_), b = S.R._data;
    if (_._data.length > 0)
      for (var x = b[0][0].type === "Complex" ? p(0) : 0, A = 0; A < b.length; ++A)
        for (var w = 0; w < A && w < (b[0] || []).length; ++w)
          b[A][w] = x;
    return S;
  }
  function y(_) {
    throw new Error("qr not implemented for sparse matrices yet");
  }
});
function w4e(e, t, r, n) {
  e._values;
  for (var a = e._index, i = e._ptr, o = e._size, s = e._datatype, u = o[0], c = o[1], l = null, d = [], f = [], m = 0, h = 0; h < c; h++) {
    f[h] = m;
    for (var p = r ? r[h] : h, g = i[p], v = i[p + 1], y = g; y < v; y++) {
      var _ = a[y];
      d[m] = _, m++;
    }
  }
  return f[c] = m, e.createSparseMatrix({
    values: l,
    index: d,
    ptr: f,
    size: [u, c],
    datatype: s
  });
}
function sq(e, t, r, n, a, i, o) {
  var s = 0;
  for (r[o] = e; s >= 0; ) {
    var u = r[o + s], c = r[n + u];
    c === -1 ? (s--, i[t++] = u) : (r[n + u] = r[a + c], ++s, r[o + s] = c);
  }
  return t;
}
function C4e(e, t) {
  if (!e)
    return null;
  var r = 0, n, a = [], i = [], o = 0, s = t, u = 2 * t;
  for (n = 0; n < t; n++)
    i[o + n] = -1;
  for (n = t - 1; n >= 0; n--)
    e[n] !== -1 && (i[s + n] = i[o + e[n]], i[o + e[n]] = n);
  for (n = 0; n < t; n++)
    e[n] === -1 && (r = sq(n, r, i, o, s, a, u));
  return a;
}
function E4e(e, t) {
  if (!e)
    return null;
  var r = e._index, n = e._ptr, a = e._size, i = a[0], o = a[1], s = [], u = [], c = 0, l = o, d, f;
  for (d = 0; d < i; d++)
    u[l + d] = -1;
  for (var m = 0; m < o; m++) {
    s[m] = -1, u[c + m] = -1;
    for (var h = n[m], p = n[m + 1], g = h; g < p; g++) {
      var v = r[g];
      for (d = u[l + v]; d !== -1 && d < m; d = f)
        f = u[c + d], u[c + d] = m, f === -1 && (s[d] = m);
      u[l + v] = m;
    }
  }
  return s;
}
function D4e(e, t, r) {
  for (var n = e._values, a = e._index, i = e._ptr, o = e._size, s = o[1], u = 0, c = 0; c < s; c++) {
    var l = i[c];
    for (i[c] = u; l < i[c + 1]; l++)
      t(a[l], c, n ? n[l] : 1, r) && (a[u] = a[l], n && (n[u] = n[l]), u++);
  }
  return i[s] = u, a.splice(u, a.length - u), n && n.splice(u, n.length - u), u;
}
function md(e) {
  return -e - 2;
}
var M4e = "csAmd", I4e = ["add", "multiply", "transpose"], T4e = /* @__PURE__ */ me(M4e, I4e, (e) => {
  var {
    add: t,
    multiply: r,
    transpose: n
  } = e;
  return function(l, d) {
    if (!d || l <= 0 || l > 3)
      return null;
    var f = d._size, m = f[0], h = f[1], p = 0, g = Math.max(16, 10 * Math.sqrt(h));
    g = Math.min(h - 2, g);
    var v = a(l, d, m, h, g);
    D4e(v, u, null);
    for (var y = v._index, _ = v._ptr, S = _[h], b = [], x = [], A = 0, w = h + 1, C = 2 * (h + 1), M = 3 * (h + 1), T = 4 * (h + 1), N = 5 * (h + 1), I = 6 * (h + 1), P = 7 * (h + 1), O = b, F = i(h, _, x, A, M, O, C, P, w, I, T, N), R = o(h, _, x, N, T, I, g, w, M, O, C), G = 0, L, q, K, X, H, W, ee, $, te, re, ie, oe, se, he, ge, De; R < h; ) {
      for (K = -1; G < h && (K = x[M + G]) === -1; G++) ;
      x[C + K] !== -1 && (O[x[C + K]] = -1), x[M + G] = x[C + K];
      var ae = x[T + K], ce = x[w + K];
      R += ce;
      var _e = 0;
      x[w + K] = -ce;
      var le = _[K], ue = ae === 0 ? le : S, be = ue;
      for (X = 1; X <= ae + 1; X++) {
        for (X > ae ? (W = K, ee = le, $ = x[A + K] - ae) : (W = y[le++], ee = _[W], $ = x[A + W]), H = 1; H <= $; H++)
          L = y[ee++], !((te = x[w + L]) <= 0) && (_e += te, x[w + L] = -te, y[be++] = L, x[C + L] !== -1 && (O[x[C + L]] = O[L]), O[L] !== -1 ? x[C + O[L]] = x[C + L] : x[M + x[N + L]] = x[C + L]);
        W !== K && (_[W] = md(K), x[I + W] = 0);
      }
      for (ae !== 0 && (S = be), x[N + K] = _e, _[K] = ue, x[A + K] = be - ue, x[T + K] = -2, F = s(F, p, x, I, h), re = ue; re < be; re++)
        if (L = y[re], !((ie = x[T + L]) <= 0)) {
          te = -x[w + L];
          var Se = F - te;
          for (le = _[L], oe = _[L] + ie - 1; le <= oe; le++)
            W = y[le], x[I + W] >= F ? x[I + W] -= te : x[I + W] !== 0 && (x[I + W] = x[N + W] + Se);
        }
      for (re = ue; re < be; re++) {
        for (L = y[re], oe = _[L], se = oe + x[T + L] - 1, he = oe, ge = 0, De = 0, le = oe; le <= se; le++)
          if (W = y[le], x[I + W] !== 0) {
            var Ne = x[I + W] - F;
            Ne > 0 ? (De += Ne, y[he++] = W, ge += W) : (_[W] = md(K), x[I + W] = 0);
          }
        x[T + L] = he - oe + 1;
        var J = he, Z = oe + x[A + L];
        for (le = se + 1; le < Z; le++) {
          q = y[le];
          var de = x[w + q];
          de <= 0 || (De += de, y[he++] = q, ge += q);
        }
        De === 0 ? (_[L] = md(K), te = -x[w + L], _e -= te, ce += te, R += te, x[w + L] = 0, x[T + L] = -1) : (x[N + L] = Math.min(x[N + L], De), y[he] = y[J], y[J] = y[oe], y[oe] = K, x[A + L] = he - oe + 1, ge = (ge < 0 ? -ge : ge) % h, x[C + L] = x[P + ge], x[P + ge] = L, O[L] = ge);
      }
      for (x[N + K] = _e, p = Math.max(p, _e), F = s(F + p, p, x, I, h), re = ue; re < be; re++)
        if (L = y[re], !(x[w + L] >= 0))
          for (ge = O[L], L = x[P + ge], x[P + ge] = -1; L !== -1 && x[C + L] !== -1; L = x[C + L], F++) {
            for ($ = x[A + L], ie = x[T + L], le = _[L] + 1; le <= _[L] + $ - 1; le++)
              x[I + y[le]] = F;
            var ye = L;
            for (q = x[C + L]; q !== -1; ) {
              var Ae = x[A + q] === $ && x[T + q] === ie;
              for (le = _[q] + 1; Ae && le <= _[q] + $ - 1; le++)
                x[I + y[le]] !== F && (Ae = 0);
              Ae ? (_[q] = md(L), x[w + L] += x[w + q], x[w + q] = 0, x[T + q] = -1, q = x[C + q], x[C + ye] = q) : (ye = q, q = x[C + q]);
            }
          }
      for (le = ue, re = ue; re < be; re++)
        L = y[re], !((te = -x[w + L]) <= 0) && (x[w + L] = te, De = x[N + L] + _e - te, De = Math.min(De, h - R - te), x[M + De] !== -1 && (O[x[M + De]] = L), x[C + L] = x[M + De], O[L] = -1, x[M + De] = L, G = Math.min(G, De), x[N + L] = De, y[le++] = L);
      x[w + K] = ce, (x[A + K] = le - ue) === 0 && (_[K] = -1, x[I + K] = 0), ae !== 0 && (S = le);
    }
    for (L = 0; L < h; L++)
      _[L] = md(_[L]);
    for (q = 0; q <= h; q++)
      x[M + q] = -1;
    for (q = h; q >= 0; q--)
      x[w + q] > 0 || (x[C + q] = x[M + _[q]], x[M + _[q]] = q);
    for (W = h; W >= 0; W--)
      x[w + W] <= 0 || _[W] !== -1 && (x[C + W] = x[M + _[W]], x[M + _[W]] = W);
    for (K = 0, L = 0; L <= h; L++)
      _[L] === -1 && (K = sq(L, K, x, M, C, b, I));
    return b.splice(b.length - 1, 1), b;
  };
  function a(c, l, d, f, m) {
    var h = n(l);
    if (c === 1 && f === d)
      return t(l, h);
    if (c === 2) {
      for (var p = h._index, g = h._ptr, v = 0, y = 0; y < d; y++) {
        var _ = g[y];
        if (g[y] = v, !(g[y + 1] - _ > m))
          for (var S = g[y + 1]; _ < S; _++)
            p[v++] = p[_];
      }
      return g[d] = v, l = n(h), r(h, l);
    }
    return r(h, l);
  }
  function i(c, l, d, f, m, h, p, g, v, y, _, S) {
    for (var b = 0; b < c; b++)
      d[f + b] = l[b + 1] - l[b];
    d[f + c] = 0;
    for (var x = 0; x <= c; x++)
      d[m + x] = -1, h[x] = -1, d[p + x] = -1, d[g + x] = -1, d[v + x] = 1, d[y + x] = 1, d[_ + x] = 0, d[S + x] = d[f + x];
    var A = s(0, 0, d, y, c);
    return d[_ + c] = -2, l[c] = -1, d[y + c] = 0, A;
  }
  function o(c, l, d, f, m, h, p, g, v, y, _) {
    for (var S = 0, b = 0; b < c; b++) {
      var x = d[f + b];
      if (x === 0)
        d[m + b] = -2, S++, l[b] = -1, d[h + b] = 0;
      else if (x > p)
        d[g + b] = 0, d[m + b] = -1, S++, l[b] = md(c), d[g + c]++;
      else {
        var A = d[v + x];
        A !== -1 && (y[A] = b), d[_ + b] = d[v + x], d[v + x] = b;
      }
    }
    return S;
  }
  function s(c, l, d, f, m) {
    if (c < 2 || c + l < 0) {
      for (var h = 0; h < m; h++)
        d[f + h] !== 0 && (d[f + h] = 1);
      c = 2;
    }
    return c;
  }
  function u(c, l) {
    return c !== l;
  }
});
function N4e(e, t, r, n, a, i, o) {
  var s, u, c = 0, l;
  if (e <= t || r[n + t] <= r[a + e])
    return -1;
  r[a + e] = r[n + t];
  var d = r[i + e];
  if (r[i + e] = t, d === -1)
    c = 1, l = e;
  else {
    for (c = 2, l = d; l !== r[o + l]; l = r[o + l]) ;
    for (s = d; s !== l; s = u)
      u = r[o + s], r[o + s] = l;
  }
  return {
    jleaf: c,
    q: l
  };
}
var P4e = "csCounts", B4e = ["transpose"], O4e = /* @__PURE__ */ me(P4e, B4e, (e) => {
  var {
    transpose: t
  } = e;
  return function(r, n, a, i) {
    if (!r || !n || !a)
      return null;
    var o = r._size, s = o[0], u = o[1], c, l, d, f, m, h, p, g = 4 * u + (i ? u + s + 1 : 0), v = [], y = 0, _ = u, S = 2 * u, b = 3 * u, x = 4 * u, A = 5 * u + 1;
    for (d = 0; d < g; d++)
      v[d] = -1;
    var w = [], C = t(r), M = C._index, T = C._ptr;
    for (d = 0; d < u; d++)
      for (l = a[d], w[l] = v[b + l] === -1 ? 1 : 0; l !== -1 && v[b + l] === -1; l = n[l])
        v[b + l] = d;
    if (i) {
      for (d = 0; d < u; d++)
        v[a[d]] = d;
      for (c = 0; c < s; c++) {
        for (d = u, h = T[c], p = T[c + 1], m = h; m < p; m++)
          d = Math.min(d, v[M[m]]);
        v[A + c] = v[x + d], v[x + d] = c;
      }
    }
    for (c = 0; c < u; c++)
      v[y + c] = c;
    for (d = 0; d < u; d++) {
      for (l = a[d], n[l] !== -1 && w[n[l]]--, f = i ? v[x + d] : l; f !== -1; f = i ? v[A + f] : -1)
        for (m = T[f]; m < T[f + 1]; m++) {
          c = M[m];
          var N = N4e(c, l, v, b, _, S, y);
          N.jleaf >= 1 && w[l]++, N.jleaf === 2 && w[N.q]--;
        }
      n[l] !== -1 && (v[y + l] = n[l]);
    }
    for (l = 0; l < u; l++)
      n[l] !== -1 && (w[n[l]] += w[l]);
    return w;
  };
}), F4e = "csSqr", R4e = ["add", "multiply", "transpose"], L4e = /* @__PURE__ */ me(F4e, R4e, (e) => {
  var {
    add: t,
    multiply: r,
    transpose: n
  } = e, a = T4e({
    add: t,
    multiply: r,
    transpose: n
  }), i = O4e({
    transpose: n
  });
  return function(u, c, l) {
    var d = c._ptr, f = c._size, m = f[1], h, p = {};
    if (p.q = a(u, c), u && !p.q)
      return null;
    if (l) {
      var g = u ? w4e(c, null, p.q) : c;
      p.parent = E4e(g);
      var v = C4e(p.parent, m);
      if (p.cp = i(g, p.parent, v, 1), g && p.parent && p.cp && o(g, p))
        for (p.unz = 0, h = 0; h < m; h++)
          p.unz += p.cp[h];
    } else
      p.unz = 4 * d[m] + m, p.lnz = p.unz;
    return p;
  };
  function o(s, u) {
    var c = s._ptr, l = s._index, d = s._size, f = d[0], m = d[1];
    u.pinv = [], u.leftmost = [];
    var h = u.parent, p = u.pinv, g = u.leftmost, v = [], y = 0, _ = f, S = f + m, b = f + 2 * m, x, A, w, C, M;
    for (A = 0; A < m; A++)
      v[_ + A] = -1, v[S + A] = -1, v[b + A] = 0;
    for (x = 0; x < f; x++)
      g[x] = -1;
    for (A = m - 1; A >= 0; A--)
      for (C = c[A], M = c[A + 1], w = C; w < M; w++)
        g[l[w]] = A;
    for (x = f - 1; x >= 0; x--)
      p[x] = -1, A = g[x], A !== -1 && (v[b + A]++ === 0 && (v[S + A] = x), v[y + x] = v[_ + A], v[_ + A] = x);
    for (u.lnz = 0, u.m2 = f, A = 0; A < m; A++)
      if (x = v[_ + A], u.lnz++, x < 0 && (x = u.m2++), p[x] = A, !(--b[A] <= 0)) {
        u.lnz += v[b + A];
        var T = h[A];
        T !== -1 && (v[b + T] === 0 && (v[S + T] = v[S + A]), v[y + v[S + A]] = v[_ + T], v[_ + T] = v[y + x], v[b + T] += v[b + A]);
      }
    for (x = 0; x < f; x++)
      p[x] < 0 && (p[x] = A++);
    return !0;
  }
});
function i8(e, t) {
  return e[t] < 0;
}
function uq(e, t) {
  e[t] = md(e[t]);
}
function nB(e) {
  return e < 0 ? md(e) : e;
}
function k4e(e, t, r, n, a) {
  var i = t._index, o = t._ptr, s = t._size, u = s[1], c, l, d, f = 0;
  for (n[0] = e; f >= 0; ) {
    e = n[f];
    var m = a ? a[e] : e;
    i8(o, e) || (uq(o, e), n[u + f] = m < 0 ? 0 : nB(o[m]));
    var h = 1;
    for (l = n[u + f], d = m < 0 ? 0 : nB(o[m + 1]); l < d; l++)
      if (c = i[l], !i8(o, c)) {
        n[u + f] = l, n[++f] = c, h = 0;
        break;
      }
    h && (f--, n[--r] = e);
  }
  return r;
}
function z4e(e, t, r, n, a) {
  var i = e._ptr, o = e._size, s = t._index, u = t._ptr, c = o[1], l, d, f, m = c;
  for (d = u[r], f = u[r + 1], l = d; l < f; l++) {
    var h = s[l];
    i8(i, h) || (m = k4e(h, e, m, n, a));
  }
  for (l = m; l < c; l++)
    uq(i, n[l]);
  return m;
}
var U4e = "csSpsolve", G4e = ["divideScalar", "multiply", "subtract"], V4e = /* @__PURE__ */ me(U4e, G4e, (e) => {
  var {
    divideScalar: t,
    multiply: r,
    subtract: n
  } = e;
  return function(i, o, s, u, c, l, d) {
    var f = i._values, m = i._index, h = i._ptr, p = i._size, g = p[1], v = o._values, y = o._index, _ = o._ptr, S, b, x, A, w = z4e(i, o, s, u, l);
    for (S = w; S < g; S++)
      c[u[S]] = 0;
    for (b = _[s], x = _[s + 1], S = b; S < x; S++)
      c[y[S]] = v[S];
    for (var C = w; C < g; C++) {
      var M = u[C], T = l ? l[M] : M;
      if (!(T < 0))
        for (b = h[T], x = h[T + 1], c[M] = t(c[M], f[d ? b : x - 1]), S = d ? b + 1 : b, A = d ? x : x - 1; S < A; S++) {
          var N = m[S];
          c[N] = n(c[N], r(f[S], c[M]));
        }
    }
    return w;
  };
}), q4e = "csLu", H4e = ["abs", "divideScalar", "multiply", "subtract", "larger", "largerEq", "SparseMatrix"], K4e = /* @__PURE__ */ me(q4e, H4e, (e) => {
  var {
    abs: t,
    divideScalar: r,
    multiply: n,
    subtract: a,
    larger: i,
    largerEq: o,
    SparseMatrix: s
  } = e, u = V4e({
    divideScalar: r,
    multiply: n,
    subtract: a
  });
  return function(l, d, f) {
    if (!l)
      return null;
    var m = l._size, h = m[1], p, g = 100, v = 100;
    d && (p = d.q, g = d.lnz || g, v = d.unz || v);
    var y = [], _ = [], S = [], b = new s({
      values: y,
      index: _,
      ptr: S,
      size: [h, h]
    }), x = [], A = [], w = [], C = new s({
      values: x,
      index: A,
      ptr: w,
      size: [h, h]
    }), M = [], T, N, I = [], P = [];
    for (T = 0; T < h; T++)
      I[T] = 0, M[T] = -1, S[T + 1] = 0;
    g = 0, v = 0;
    for (var O = 0; O < h; O++) {
      S[O] = g, w[O] = v;
      var F = p ? p[O] : O, R = u(b, l, F, P, I, M, 1), G = -1, L = -1;
      for (N = R; N < h; N++)
        if (T = P[N], M[T] < 0) {
          var q = t(I[T]);
          i(q, L) && (L = q, G = T);
        } else
          A[v] = M[T], x[v++] = I[T];
      if (G === -1 || L <= 0)
        return null;
      M[F] < 0 && o(t(I[F]), n(L, f)) && (G = F);
      var K = I[G];
      for (A[v] = O, x[v++] = K, M[G] = O, _[g] = G, y[g++] = 1, N = R; N < h; N++)
        T = P[N], M[T] < 0 && (_[g] = T, y[g++] = r(I[T], K)), I[T] = 0;
    }
    for (S[h] = g, w[h] = v, N = 0; N < g; N++)
      _[N] = M[_[N]];
    return y.splice(g, y.length - g), _.splice(g, _.length - g), x.splice(v, x.length - v), A.splice(v, A.length - v), {
      L: b,
      U: C,
      pinv: M
    };
  };
}), aB = "slu", X4e = ["typed", "abs", "add", "multiply", "transpose", "divideScalar", "subtract", "larger", "largerEq", "SparseMatrix"], j4e = /* @__PURE__ */ me(aB, X4e, (e) => {
  var {
    typed: t,
    abs: r,
    add: n,
    multiply: a,
    transpose: i,
    divideScalar: o,
    subtract: s,
    larger: u,
    largerEq: c,
    SparseMatrix: l
  } = e, d = L4e({
    add: n,
    multiply: a,
    transpose: i
  }), f = K4e({
    abs: r,
    divideScalar: o,
    multiply: a,
    subtract: s,
    larger: u,
    largerEq: c,
    SparseMatrix: l
  });
  return t(aB, {
    "SparseMatrix, number, number": function(h, p, g) {
      if (!Ut(p) || p < 0 || p > 3)
        throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");
      if (g < 0 || g > 1)
        throw new Error("Partial pivoting threshold must be a number from 0 to 1");
      var v = d(p, h, !1), y = f(h, v, g);
      return {
        L: y.L,
        U: y.U,
        p: y.pinv,
        q: v.q,
        toString: function() {
          return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
p: ` + this.p.toString() + (this.q ? `
q: ` + this.q.toString() : "") + `
`;
        }
      };
    }
  });
});
function iB(e, t) {
  var r, n = t.length, a = [];
  if (e)
    for (r = 0; r < n; r++)
      a[e[r]] = t[r];
  else
    for (r = 0; r < n; r++)
      a[r] = t[r];
  return a;
}
var oB = "lusolve", Y4e = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "DenseMatrix"], W4e = /* @__PURE__ */ me(oB, Y4e, (e) => {
  var {
    typed: t,
    matrix: r,
    lup: n,
    slu: a,
    usolve: i,
    lsolve: o,
    DenseMatrix: s
  } = e, u = Wh({
    DenseMatrix: s
  });
  return t(oB, {
    "Array, Array | Matrix": function(f, m) {
      f = r(f);
      var h = n(f), p = l(h.L, h.U, h.p, null, m);
      return p.valueOf();
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      var h = n(f);
      return l(h.L, h.U, h.p, null, m);
    },
    "SparseMatrix, Array | Matrix": function(f, m) {
      var h = n(f);
      return l(h.L, h.U, h.p, null, m);
    },
    "SparseMatrix, Array | Matrix, number, number": function(f, m, h, p) {
      var g = a(f, h, p);
      return l(g.L, g.U, g.p, g.q, m);
    },
    "Object, Array | Matrix": function(f, m) {
      return l(f.L, f.U, f.p, f.q, m);
    }
  });
  function c(d) {
    if (Zt(d))
      return d;
    if (en(d))
      return r(d);
    throw new TypeError("Invalid Matrix LU decomposition");
  }
  function l(d, f, m, h, p) {
    d = c(d), f = c(f), m && (p = u(d, p, !0), p._data = iB(m, p._data));
    var g = o(d, p), v = i(f, g);
    return h && (v._data = iB(h, v._data)), v;
  }
}), sB = "polynomialRoot", Z4e = ["typed", "isZero", "equalScalar", "add", "subtract", "multiply", "divide", "sqrt", "unaryMinus", "cbrt", "typeOf", "im", "re"], Q4e = /* @__PURE__ */ me(sB, Z4e, (e) => {
  var {
    typed: t,
    isZero: r,
    equalScalar: n,
    add: a,
    subtract: i,
    multiply: o,
    divide: s,
    sqrt: u,
    unaryMinus: c,
    cbrt: l,
    typeOf: d,
    im: f,
    re: m
  } = e;
  return t(sB, {
    "number|Complex, ...number|Complex": (h, p) => {
      for (var g = [h, ...p]; g.length > 0 && r(g[g.length - 1]); )
        g.pop();
      if (g.length < 2)
        throw new RangeError("Polynomial [".concat(h, ", ").concat(p, "] must have a non-zero non-constant coefficient"));
      switch (g.length) {
        case 2:
          return [c(s(g[0], g[1]))];
        case 3: {
          var [v, y, _] = g, S = o(2, _), b = o(y, y), x = o(4, _, v);
          if (n(b, x)) return [s(c(y), S)];
          var A = u(i(b, x));
          return [s(i(A, y), S), s(i(c(A), y), S)];
        }
        case 4: {
          var [w, C, M, T] = g, N = c(o(3, T)), I = o(M, M), P = o(3, T, C), O = a(o(2, M, M, M), o(27, T, T, w)), F = o(9, T, M, C);
          if (n(I, P) && n(O, F))
            return [s(M, N)];
          var R = i(I, P), G = i(O, F), L = a(o(18, T, M, C, w), o(M, M, C, C)), q = a(o(4, M, M, M, w), o(4, T, C, C, C), o(27, T, T, w, w));
          if (n(L, q))
            return [
              s(i(o(4, T, M, C), a(o(9, T, T, w), o(M, M, M))), o(T, R)),
              // simple root
              s(i(o(9, T, w), o(M, C)), o(2, R))
              // double root
            ];
          var K;
          n(I, P) ? K = G : K = s(a(G, u(i(o(G, G), o(4, R, R, R)))), 2);
          var X = !0, H = l(K, X).toArray().map((W) => s(a(M, W, s(R, W)), N));
          return H.map((W) => d(W) === "Complex" && n(m(W), m(W) + f(W)) ? m(W) : W);
        }
        default:
          throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(g));
      }
    }
  });
}), $4e = "Help", J4e = ["evaluate"], exe = /* @__PURE__ */ me($4e, J4e, (e) => {
  var {
    evaluate: t
  } = e;
  function r(n) {
    if (!(this instanceof r))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (!n) throw new Error('Argument "doc" missing');
    this.doc = n;
  }
  return r.prototype.type = "Help", r.prototype.isHelp = !0, r.prototype.toString = function() {
    var n = this.doc || {}, a = `
`;
    if (n.name && (a += "Name: " + n.name + `

`), n.category && (a += "Category: " + n.category + `

`), n.description && (a += `Description:
    ` + n.description + `

`), n.syntax && (a += `Syntax:
    ` + n.syntax.join(`
    `) + `

`), n.examples) {
      a += `Examples:
`;
      for (var i = !1, o = t("config()"), s = {
        config: (d) => (i = !0, t("config(newConfig)", {
          newConfig: d
        }))
      }, u = 0; u < n.examples.length; u++) {
        var c = n.examples[u];
        a += "    " + c + `
`;
        var l = void 0;
        try {
          l = t(c, s);
        } catch (d) {
          l = d;
        }
        l !== void 0 && !SS(l) && (a += "        " + Br(l, {
          precision: 14
        }) + `
`);
      }
      a += `
`, i && t("config(originalConfig)", {
        originalConfig: o
      });
    }
    return n.mayThrow && n.mayThrow.length && (a += "Throws: " + n.mayThrow.join(", ") + `

`), n.seealso && n.seealso.length && (a += "See also: " + n.seealso.join(", ") + `
`), a;
  }, r.prototype.toJSON = function() {
    var n = Jt(this.doc);
    return n.mathjs = "Help", n;
  }, r.fromJSON = function(n) {
    var a = {};
    return Object.keys(n).filter((i) => i !== "mathjs").forEach((i) => {
      a[i] = n[i];
    }), new r(a);
  }, r.prototype.valueOf = r.prototype.toString, r;
}, {
  isClass: !0
}), txe = "Chain", rxe = ["?on", "math", "typed"], nxe = /* @__PURE__ */ me(txe, rxe, (e) => {
  var {
    on: t,
    math: r,
    typed: n
  } = e;
  function a(c) {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    AS(c) ? this.value = c.value : this.value = c;
  }
  a.prototype.type = "Chain", a.prototype.isChain = !0, a.prototype.done = function() {
    return this.value;
  }, a.prototype.valueOf = function() {
    return this.value;
  }, a.prototype.toString = function() {
    return Br(this.value);
  }, a.prototype.toJSON = function() {
    return {
      mathjs: "Chain",
      value: this.value
    };
  }, a.fromJSON = function(c) {
    return new a(c.value);
  };
  function i(c, l) {
    typeof l == "function" && (a.prototype[c] = s(l));
  }
  function o(c, l) {
    O2(a.prototype, c, function() {
      var f = l();
      if (typeof f == "function")
        return s(f);
    });
  }
  function s(c) {
    return function() {
      if (arguments.length === 0)
        return new a(c(this.value));
      for (var l = [this.value], d = 0; d < arguments.length; d++)
        l[d + 1] = arguments[d];
      if (n.isTypedFunction(c)) {
        var f = n.resolve(c, l);
        if (f.params.length === 1)
          throw new Error("chain function " + c.name + " cannot match rest parameter between chain value and additional arguments.");
        return new a(f.implementation.apply(c, l));
      }
      return new a(c.apply(c, l));
    };
  }
  a.createProxy = function(c, l) {
    if (typeof c == "string")
      i(c, l);
    else {
      var d = function(h) {
        Tt(c, h) && u[h] === void 0 && o(h, () => c[h]);
      };
      for (var f in c)
        d(f);
    }
  };
  var u = {
    expression: !0,
    docs: !0,
    type: !0,
    classes: !0,
    json: !0,
    error: !0,
    isChain: !0
    // conflicts with the property isChain of a Chain instance
  };
  return a.createProxy(r), t && t("import", function(c, l, d) {
    d || o(c, l);
  }), a;
}, {
  isClass: !0
}), uB = {
  name: "e",
  category: "Constants",
  syntax: ["e"],
  description: "Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",
  examples: ["e", "e ^ 2", "exp(2)", "log(e)"],
  seealso: ["exp"]
}, axe = {
  name: "false",
  category: "Constants",
  syntax: ["false"],
  description: "Boolean value false",
  examples: ["false"],
  seealso: ["true"]
}, ixe = {
  name: "i",
  category: "Constants",
  syntax: ["i"],
  description: "Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",
  examples: ["i", "i * i", "sqrt(-1)"],
  seealso: []
}, oxe = {
  name: "Infinity",
  category: "Constants",
  syntax: ["Infinity"],
  description: "Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",
  examples: ["Infinity", "1 / 0"],
  seealso: []
}, sxe = {
  name: "LN10",
  category: "Constants",
  syntax: ["LN10"],
  description: "Returns the natural logarithm of 10, approximately equal to 2.302",
  examples: ["LN10", "log(10)"],
  seealso: []
}, uxe = {
  name: "LN2",
  category: "Constants",
  syntax: ["LN2"],
  description: "Returns the natural logarithm of 2, approximately equal to 0.693",
  examples: ["LN2", "log(2)"],
  seealso: []
}, cxe = {
  name: "LOG10E",
  category: "Constants",
  syntax: ["LOG10E"],
  description: "Returns the base-10 logarithm of E, approximately equal to 0.434",
  examples: ["LOG10E", "log(e, 10)"],
  seealso: []
}, lxe = {
  name: "LOG2E",
  category: "Constants",
  syntax: ["LOG2E"],
  description: "Returns the base-2 logarithm of E, approximately equal to 1.442",
  examples: ["LOG2E", "log(e, 2)"],
  seealso: []
}, dxe = {
  name: "NaN",
  category: "Constants",
  syntax: ["NaN"],
  description: "Not a number",
  examples: ["NaN", "0 / 0"],
  seealso: []
}, fxe = {
  name: "null",
  category: "Constants",
  syntax: ["null"],
  description: "Value null",
  examples: ["null"],
  seealso: ["true", "false"]
}, mxe = {
  name: "phi",
  category: "Constants",
  syntax: ["phi"],
  description: "Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",
  examples: ["phi"],
  seealso: []
}, cB = {
  name: "pi",
  category: "Constants",
  syntax: ["pi"],
  description: "The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",
  examples: ["pi", "sin(pi/2)"],
  seealso: ["tau"]
}, pxe = {
  name: "SQRT1_2",
  category: "Constants",
  syntax: ["SQRT1_2"],
  description: "Returns the square root of 1/2, approximately equal to 0.707",
  examples: ["SQRT1_2", "sqrt(1/2)"],
  seealso: []
}, hxe = {
  name: "SQRT2",
  category: "Constants",
  syntax: ["SQRT2"],
  description: "Returns the square root of 2, approximately equal to 1.414",
  examples: ["SQRT2", "sqrt(2)"],
  seealso: []
}, vxe = {
  name: "tau",
  category: "Constants",
  syntax: ["tau"],
  description: "Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",
  examples: ["tau", "2 * pi"],
  seealso: ["pi"]
}, gxe = {
  name: "true",
  category: "Constants",
  syntax: ["true"],
  description: "Boolean value true",
  examples: ["true"],
  seealso: ["false"]
}, yxe = {
  name: "version",
  category: "Constants",
  syntax: ["version"],
  description: "A string with the version number of math.js",
  examples: ["version"],
  seealso: []
}, bxe = {
  name: "bignumber",
  category: "Construction",
  syntax: ["bignumber(x)"],
  description: "Create a big number from a number or string.",
  examples: ["0.1 + 0.2", "bignumber(0.1) + bignumber(0.2)", 'bignumber("7.2")', 'bignumber("7.2e500")', "bignumber([0.1, 0.2, 0.3])"],
  seealso: ["boolean", "bigint", "complex", "fraction", "index", "matrix", "string", "unit"]
}, xxe = {
  name: "bigint",
  category: "Construction",
  syntax: ["bigint(x)"],
  description: "Create a bigint, an integer with an arbitrary number of digits, from a number or string.",
  examples: ["123123123123123123 # a large number will lose digits", 'bigint("123123123123123123")', 'bignumber(["1", "3", "5"])'],
  seealso: ["boolean", "bignumber", "number", "complex", "fraction", "index", "matrix", "string", "unit"]
}, _xe = {
  name: "boolean",
  category: "Construction",
  syntax: ["x", "boolean(x)"],
  description: "Convert a string or number into a boolean.",
  examples: ["boolean(0)", "boolean(1)", "boolean(3)", 'boolean("true")', 'boolean("false")', "boolean([1, 0, 1, 1])"],
  seealso: ["bignumber", "complex", "index", "matrix", "number", "string", "unit"]
}, Sxe = {
  name: "complex",
  category: "Construction",
  syntax: ["complex()", "complex(re, im)", "complex(string)"],
  description: "Create a complex number.",
  examples: ["complex()", "complex(2, 3)", 'complex("7 - 2i")'],
  seealso: ["bignumber", "boolean", "index", "matrix", "number", "string", "unit"]
}, Axe = {
  name: "createUnit",
  category: "Construction",
  syntax: ["createUnit(definitions)", "createUnit(name, definition)"],
  description: "Create a user-defined unit and register it with the Unit type.",
  examples: ['createUnit("foo")', 'createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})', 'createUnit("mph", "1 mile/hour")'],
  seealso: ["unit", "splitUnit"]
}, wxe = {
  name: "fraction",
  category: "Construction",
  syntax: ["fraction(num)", "fraction(matrix)", "fraction(num,den)", "fraction({n: num, d: den})"],
  description: "Create a fraction from a number or from integer numerator and denominator.",
  examples: ["fraction(0.125)", "fraction(1, 3) + fraction(2, 5)", "fraction({n: 333, d: 53})", "fraction([sqrt(9), sqrt(10), sqrt(11)])"],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "string", "unit"]
}, Cxe = {
  name: "index",
  category: "Construction",
  syntax: ["[start]", "[start:end]", "[start:step:end]", "[start1, start 2, ...]", "[start1:end1, start2:end2, ...]", "[start1:step1:end1, start2:step2:end2, ...]"],
  description: "Create an index to get or replace a subset of a matrix",
  examples: ["A = [1, 2, 3; 4, 5, 6]", "A[1, :]", "A[1, 2] = 50", "A[1:2, 1:2] = 1", "B = [1, 2, 3]", "B[B>1 and B<3]"],
  seealso: ["bignumber", "boolean", "complex", "matrix,", "number", "range", "string", "unit"]
}, Exe = {
  name: "matrix",
  category: "Construction",
  syntax: ["[]", "[a1, b1, ...; a2, b2, ...]", "matrix()", 'matrix("dense")', "matrix([...])"],
  description: "Create a matrix.",
  examples: ["[]", "[1, 2, 3]", "[1, 2, 3; 4, 5, 6]", "matrix()", "matrix([3, 4])", 'matrix([3, 4; 5, 6], "sparse")', 'matrix([3, 4; 5, 6], "sparse", "number")'],
  seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "sparse"]
}, Dxe = {
  name: "number",
  category: "Construction",
  syntax: ["x", "number(x)", "number(unit, valuelessUnit)"],
  description: "Create a number or convert a string or boolean into a number.",
  examples: ["2", "2e3", "4.05", "number(2)", 'number("7.2")', "number(true)", "number([true, false, true, true])", 'number(unit("52cm"), "m")'],
  seealso: ["bignumber", "bigint", "boolean", "complex", "fraction", "index", "matrix", "string", "unit"]
}, Mxe = {
  name: "sparse",
  category: "Construction",
  syntax: ["sparse()", "sparse([a1, b1, ...; a1, b2, ...])", 'sparse([a1, b1, ...; a1, b2, ...], "number")'],
  description: "Create a sparse matrix.",
  examples: ["sparse()", "sparse([3, 4; 5, 6])", 'sparse([3, 0; 5, 0], "number")'],
  seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "matrix"]
}, Ixe = {
  name: "splitUnit",
  category: "Construction",
  syntax: ["splitUnit(unit: Unit, parts: Unit[])"],
  description: "Split a unit in an array of units whose sum is equal to the original unit.",
  examples: ['splitUnit(1 m, ["feet", "inch"])'],
  seealso: ["unit", "createUnit"]
}, Txe = {
  name: "string",
  category: "Construction",
  syntax: ['"text"', "string(x)"],
  description: "Create a string or convert a value to a string",
  examples: ['"Hello World!"', "string(4.2)", "string(3 + 2i)"],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "unit"]
}, Nxe = {
  name: "unit",
  category: "Construction",
  syntax: ["value unit", "unit(value, unit)", "unit(string)"],
  description: "Create a unit.",
  examples: ["5.5 mm", "3 inch", 'unit(7.1, "kilogram")', 'unit("23 deg")'],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "string"]
}, Pxe = {
  name: "config",
  category: "Core",
  syntax: ["config()", "config(options)"],
  description: "Get configuration or change configuration.",
  examples: ["config()", "1/3 + 1/4", 'config({number: "Fraction"})', "1/3 + 1/4"],
  seealso: []
}, Bxe = {
  name: "import",
  category: "Core",
  syntax: ["import(functions)", "import(functions, options)"],
  description: "Import functions or constants from an object.",
  examples: ["import({myFn: f(x)=x^2, myConstant: 32 })", "myFn(2)", "myConstant"],
  seealso: []
}, Oxe = {
  name: "typed",
  category: "Core",
  syntax: ["typed(signatures)", "typed(name, signatures)"],
  description: "Create a typed function.",
  examples: ['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })', "double(2)", 'double("hello")'],
  seealso: []
}, Fxe = {
  name: "derivative",
  category: "Algebra",
  syntax: ["derivative(expr, variable)", "derivative(expr, variable, {simplify: boolean})"],
  description: "Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",
  examples: ['derivative("2x^3", "x")', 'derivative("2x^3", "x", {simplify: false})', 'derivative("2x^2 + 3x + 4", "x")', 'derivative("sin(2x)", "x")', 'f = parse("x^2 + x")', 'x = parse("x")', "df = derivative(f, x)", "df.evaluate({x: 3})"],
  seealso: ["simplify", "parse", "evaluate"]
}, Rxe = {
  name: "leafCount",
  category: "Algebra",
  syntax: ["leafCount(expr)"],
  description: "Computes the number of leaves in the parse tree of the given expression",
  examples: ['leafCount("e^(i*pi)-1")', 'leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],
  seealso: ["simplify"]
}, Lxe = {
  name: "lsolve",
  category: "Algebra",
  syntax: ["x=lsolve(L, b)"],
  description: "Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
  seealso: ["lsolveAll", "lup", "lusolve", "usolve", "matrix", "sparse"]
}, kxe = {
  name: "lsolveAll",
  category: "Algebra",
  syntax: ["x=lsolveAll(L, b)"],
  description: "Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
  seealso: ["lsolve", "lup", "lusolve", "usolve", "matrix", "sparse"]
}, zxe = {
  name: "lup",
  category: "Algebra",
  syntax: ["lup(m)"],
  description: "Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",
  examples: ["lup([[2, 1], [1, 4]])", "lup(matrix([[2, 1], [1, 4]]))", "lup(sparse([[2, 1], [1, 4]]))"],
  seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "slu", "qr"]
}, Uxe = {
  name: "lusolve",
  category: "Algebra",
  syntax: ["x=lusolve(A, b)", "x=lusolve(lu, b)"],
  description: "Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lusolve(a, b)"],
  seealso: ["lup", "slu", "lsolve", "usolve", "matrix", "sparse"]
}, Gxe = {
  name: "polynomialRoot",
  category: "Algebra",
  syntax: ["x=polynomialRoot(-6, 3)", "x=polynomialRoot(4, -4, 1)", "x=polynomialRoot(-8, 12, -6, 1)"],
  description: "Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",
  examples: ["a = polynomialRoot(-6, 11, -6, 1)"],
  seealso: ["cbrt", "sqrt"]
}, Vxe = {
  name: "qr",
  category: "Algebra",
  syntax: ["qr(A)"],
  description: "Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",
  examples: ["qr([[1, -1,  4], [1,  4, -2], [1,  4,  2], [1,  -1, 0]])"],
  seealso: ["lup", "slu", "matrix"]
}, qxe = {
  name: "rationalize",
  category: "Algebra",
  syntax: ["rationalize(expr)", "rationalize(expr, scope)", "rationalize(expr, scope, detailed)"],
  description: "Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",
  examples: ['rationalize("2x/y - y/(x+1)")', 'rationalize("2x/y - y/(x+1)", true)'],
  seealso: ["simplify"]
}, Hxe = {
  name: "resolve",
  category: "Algebra",
  syntax: ["resolve(node, scope)"],
  description: "Recursively substitute variables in an expression tree.",
  examples: ['resolve(parse("1 + x"), { x: 7 })', 'resolve(parse("size(text)"), { text: "Hello World" })', 'resolve(parse("x + y"), { x: parse("3z") })', 'resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],
  seealso: ["simplify", "evaluate"],
  mayThrow: ["ReferenceError"]
}, Kxe = {
  name: "simplify",
  category: "Algebra",
  syntax: ["simplify(expr)", "simplify(expr, rules)"],
  description: "Simplify an expression tree.",
  examples: ['simplify("3 + 2 / 4")', 'simplify("2x + x")', 'f = parse("x * (x + 2 + x)")', "simplified = simplify(f)", "simplified.evaluate({x: 2})"],
  seealso: ["simplifyCore", "derivative", "evaluate", "parse", "rationalize", "resolve"]
}, Xxe = {
  name: "simplifyConstant",
  category: "Algebra",
  syntax: ["simplifyConstant(expr)", "simplifyConstant(expr, options)"],
  description: "Replace constant subexpressions of node with their values.",
  examples: ['simplifyConstant("(3-3)*x")', 'simplifyConstant(parse("z-cos(tau/8)"))'],
  seealso: ["simplify", "simplifyCore", "evaluate"]
}, jxe = {
  name: "simplifyCore",
  category: "Algebra",
  syntax: ["simplifyCore(node)"],
  description: "Perform simple one-pass simplifications on an expression tree.",
  examples: ['simplifyCore(parse("0*x"))', 'simplifyCore(parse("(x+0)*2"))'],
  seealso: ["simplify", "simplifyConstant", "evaluate"]
}, Yxe = {
  name: "slu",
  category: "Algebra",
  syntax: ["slu(A, order, threshold)"],
  description: "Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",
  examples: ["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],
  seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "lup", "qr"]
}, Wxe = {
  name: "symbolicEqual",
  category: "Algebra",
  syntax: ["symbolicEqual(expr1, expr2)", "symbolicEqual(expr1, expr2, options)"],
  description: "Returns true if the difference of the expressions simplifies to 0",
  examples: ['symbolicEqual("x*y","y*x")', 'symbolicEqual("abs(x^2)", "x^2")', 'symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],
  seealso: ["simplify", "evaluate"]
}, Zxe = {
  name: "usolve",
  category: "Algebra",
  syntax: ["x=usolve(U, b)"],
  description: "Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
  examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
  seealso: ["usolveAll", "lup", "lusolve", "lsolve", "matrix", "sparse"]
}, Qxe = {
  name: "usolveAll",
  category: "Algebra",
  syntax: ["x=usolve(U, b)"],
  description: "Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
  examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
  seealso: ["usolve", "lup", "lusolve", "lsolve", "matrix", "sparse"]
}, $xe = {
  name: "abs",
  category: "Arithmetic",
  syntax: ["abs(x)"],
  description: "Compute the absolute value.",
  examples: ["abs(3.5)", "abs(-4.2)"],
  seealso: ["sign"]
}, Jxe = {
  name: "add",
  category: "Operators",
  syntax: ["x + y", "add(x, y)"],
  description: "Add two values.",
  examples: ["a = 2.1 + 3.6", "a - 3.6", "3 + 2i", "3 cm + 2 inch", '"2.3" + "4"'],
  seealso: ["subtract"]
}, e5e = {
  name: "cbrt",
  category: "Arithmetic",
  syntax: ["cbrt(x)", "cbrt(x, allRoots)"],
  description: "Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",
  examples: ["cbrt(64)", "cube(4)", "cbrt(-8)", "cbrt(2 + 3i)", "cbrt(8i)", "cbrt(8i, true)", "cbrt(27 m^3)"],
  seealso: ["square", "sqrt", "cube", "multiply"]
}, t5e = {
  name: "ceil",
  category: "Arithmetic",
  syntax: ["ceil(x)"],
  description: "Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",
  examples: ["ceil(3.2)", "ceil(3.8)", "ceil(-4.2)"],
  seealso: ["floor", "fix", "round"]
}, r5e = {
  name: "cube",
  category: "Arithmetic",
  syntax: ["cube(x)"],
  description: "Compute the cube of a value. The cube of x is x * x * x.",
  examples: ["cube(2)", "2^3", "2 * 2 * 2"],
  seealso: ["multiply", "square", "pow"]
}, n5e = {
  name: "divide",
  category: "Operators",
  syntax: ["x / y", "divide(x, y)"],
  description: "Divide two values.",
  examples: ["a = 2 / 3", "a * 3", "4.5 / 2", "3 + 4 / 2", "(3 + 4) / 2", "18 km / 4.5"],
  seealso: ["multiply"]
}, a5e = {
  name: "dotDivide",
  category: "Operators",
  syntax: ["x ./ y", "dotDivide(x, y)"],
  description: "Divide two values element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a ./ b"],
  seealso: ["multiply", "dotMultiply", "divide"]
}, i5e = {
  name: "dotMultiply",
  category: "Operators",
  syntax: ["x .* y", "dotMultiply(x, y)"],
  description: "Multiply two values element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a .* b"],
  seealso: ["multiply", "divide", "dotDivide"]
}, o5e = {
  name: "dotPow",
  category: "Operators",
  syntax: ["x .^ y", "dotPow(x, y)"],
  description: "Calculates the power of x to y element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a .^ 2"],
  seealso: ["pow"]
}, s5e = {
  name: "exp",
  category: "Arithmetic",
  syntax: ["exp(x)"],
  description: "Calculate the exponent of a value.",
  examples: ["exp(1.3)", "e ^ 1.3", "log(exp(1.3))", "x = 2.4", "(exp(i*x) == cos(x) + i*sin(x))   # Euler's formula"],
  seealso: ["expm", "expm1", "pow", "log"]
}, u5e = {
  name: "expm",
  category: "Arithmetic",
  syntax: ["exp(x)"],
  description: "Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",
  examples: ["expm([[0,2],[0,0]])"],
  seealso: ["exp"]
}, c5e = {
  name: "expm1",
  category: "Arithmetic",
  syntax: ["expm1(x)"],
  description: "Calculate the value of subtracting 1 from the exponential value.",
  examples: ["expm1(2)", "pow(e, 2) - 1", "log(expm1(2) + 1)"],
  seealso: ["exp", "pow", "log"]
}, l5e = {
  name: "fix",
  category: "Arithmetic",
  syntax: ["fix(x)"],
  description: "Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",
  examples: ["fix(3.2)", "fix(3.8)", "fix(-4.2)", "fix(-4.8)"],
  seealso: ["ceil", "floor", "round"]
}, d5e = {
  name: "floor",
  category: "Arithmetic",
  syntax: ["floor(x)"],
  description: "Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",
  examples: ["floor(3.2)", "floor(3.8)", "floor(-4.2)"],
  seealso: ["ceil", "fix", "round"]
}, f5e = {
  name: "gcd",
  category: "Arithmetic",
  syntax: ["gcd(a, b)", "gcd(a, b, c, ...)"],
  description: "Compute the greatest common divisor.",
  examples: ["gcd(8, 12)", "gcd(-4, 6)", "gcd(25, 15, -10)"],
  seealso: ["lcm", "xgcd"]
}, m5e = {
  name: "hypot",
  category: "Arithmetic",
  syntax: ["hypot(a, b, c, ...)", "hypot([a, b, c, ...])"],
  description: "Calculate the hypotenusa of a list with values. ",
  examples: ["hypot(3, 4)", "sqrt(3^2 + 4^2)", "hypot(-2)", "hypot([3, 4, 5])"],
  seealso: ["abs", "norm"]
}, p5e = {
  name: "invmod",
  category: "Arithmetic",
  syntax: ["invmod(a, b)"],
  description: "Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",
  examples: ["invmod(8, 12)", "invmod(7, 13)", "invmod(15151, 15122)"],
  seealso: ["gcd", "xgcd"]
}, h5e = {
  name: "lcm",
  category: "Arithmetic",
  syntax: ["lcm(x, y)"],
  description: "Compute the least common multiple.",
  examples: ["lcm(4, 6)", "lcm(6, 21)", "lcm(6, 21, 5)"],
  seealso: ["gcd"]
}, v5e = {
  name: "log",
  category: "Arithmetic",
  syntax: ["log(x)", "log(x, base)"],
  description: "Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",
  examples: ["log(3.5)", "a = log(2.4)", "exp(a)", "10 ^ 4", "log(10000, 10)", "log(10000) / log(10)", "b = log(1024, 2)", "2 ^ b"],
  seealso: ["exp", "log1p", "log2", "log10"]
}, g5e = {
  name: "log10",
  category: "Arithmetic",
  syntax: ["log10(x)"],
  description: "Compute the 10-base logarithm of a value.",
  examples: ["log10(0.00001)", "log10(10000)", "10 ^ 4", "log(10000) / log(10)", "log(10000, 10)"],
  seealso: ["exp", "log"]
}, y5e = {
  name: "log1p",
  category: "Arithmetic",
  syntax: ["log1p(x)", "log1p(x, base)"],
  description: "Calculate the logarithm of a `value+1`",
  examples: ["log1p(2.5)", "exp(log1p(1.4))", "pow(10, 4)", "log1p(9999, 10)", "log1p(9999) / log(10)"],
  seealso: ["exp", "log", "log2", "log10"]
}, b5e = {
  name: "log2",
  category: "Arithmetic",
  syntax: ["log2(x)"],
  description: "Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",
  examples: ["log2(0.03125)", "log2(16)", "log2(16) / log2(2)", "pow(2, 4)"],
  seealso: ["exp", "log1p", "log", "log10"]
}, x5e = {
  name: "mod",
  category: "Operators",
  syntax: ["x % y", "x mod y", "mod(x, y)"],
  description: "Calculates the modulus, the remainder of an integer division.",
  examples: ["7 % 3", "11 % 2", "10 mod 4", "isOdd(x) = x % 2", "isOdd(2)", "isOdd(3)"],
  seealso: ["divide"]
}, _5e = {
  name: "multiply",
  category: "Operators",
  syntax: ["x * y", "multiply(x, y)"],
  description: "multiply two values.",
  examples: ["a = 2.1 * 3.4", "a / 3.4", "2 * 3 + 4", "2 * (3 + 4)", "3 * 2.1 km"],
  seealso: ["divide"]
}, S5e = {
  name: "norm",
  category: "Arithmetic",
  syntax: ["norm(x)", "norm(x, p)"],
  description: "Calculate the norm of a number, vector or matrix.",
  examples: ["abs(-3.5)", "norm(-3.5)", "norm(3 - 4i)", "norm([1, 2, -3], Infinity)", "norm([1, 2, -3], -Infinity)", "norm([3, 4], 2)", "norm([[1, 2], [3, 4]], 1)", 'norm([[1, 2], [3, 4]], "inf")', 'norm([[1, 2], [3, 4]], "fro")']
}, A5e = {
  name: "nthRoot",
  category: "Arithmetic",
  syntax: ["nthRoot(a)", "nthRoot(a, root)"],
  description: 'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',
  examples: ["4 ^ 3", "nthRoot(64, 3)", "nthRoot(9, 2)", "sqrt(9)"],
  seealso: ["nthRoots", "pow", "sqrt"]
}, w5e = {
  name: "nthRoots",
  category: "Arithmetic",
  syntax: ["nthRoots(A)", "nthRoots(A, root)"],
  description: 'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',
  examples: ["nthRoots(1)", "nthRoots(1, 3)"],
  seealso: ["sqrt", "pow", "nthRoot"]
}, C5e = {
  name: "pow",
  category: "Operators",
  syntax: ["x ^ y", "pow(x, y)"],
  description: "Calculates the power of x to y, x^y.",
  examples: ["2^3", "2*2*2", "1 + e ^ (pi * i)", "pow([[1, 2], [4, 3]], 2)", "pow([[1, 2], [4, 3]], -1)"],
  seealso: ["multiply", "nthRoot", "nthRoots", "sqrt"]
}, E5e = {
  name: "round",
  category: "Arithmetic",
  syntax: ["round(x)", "round(x, n)", "round(unit, valuelessUnit)", "round(unit, n, valuelessUnit)"],
  description: "round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",
  examples: ["round(3.2)", "round(3.8)", "round(-4.2)", "round(-4.8)", "round(pi, 3)", "round(123.45678, 2)", "round(3.241cm, 2, cm)", "round([3.2, 3.8, -4.7])"],
  seealso: ["ceil", "floor", "fix"]
}, D5e = {
  name: "sign",
  category: "Arithmetic",
  syntax: ["sign(x)"],
  description: "Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",
  examples: ["sign(3.5)", "sign(-4.2)", "sign(0)"],
  seealso: ["abs"]
}, M5e = {
  name: "sqrt",
  category: "Arithmetic",
  syntax: ["sqrt(x)"],
  description: "Compute the square root value. If x = y * y, then y is the square root of x.",
  examples: ["sqrt(25)", "5 * 5", "sqrt(-1)"],
  seealso: ["square", "sqrtm", "multiply", "nthRoot", "nthRoots", "pow"]
}, I5e = {
  name: "sqrtm",
  category: "Arithmetic",
  syntax: ["sqrtm(x)"],
  description: "Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",
  examples: ["sqrtm([[33, 24], [48, 57]])"],
  seealso: ["sqrt", "abs", "square", "multiply"]
}, T5e = {
  name: "sylvester",
  category: "Algebra",
  syntax: ["sylvester(A,B,C)"],
  description: "Solves the real-valued Sylvester equation AX+XB=C for X",
  examples: ["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])", "A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]", "sylvester(A, B, C)"],
  seealso: ["schur", "lyap"]
}, N5e = {
  name: "schur",
  category: "Algebra",
  syntax: ["schur(A)"],
  description: "Performs a real Schur decomposition of the real matrix A = UTU'",
  examples: ["schur([[1, 0], [-4, 3]])", "A = [[1, 0], [-4, 3]]", "schur(A)"],
  seealso: ["lyap", "sylvester"]
}, P5e = {
  name: "lyap",
  category: "Algebra",
  syntax: ["lyap(A,Q)"],
  description: "Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",
  examples: ["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])", "A = [[-2, 0], [1, -4]]", "Q = [[3, 1], [1, 3]]", "lyap(A,Q)"],
  seealso: ["schur", "sylvester"]
}, B5e = {
  name: "square",
  category: "Arithmetic",
  syntax: ["square(x)"],
  description: "Compute the square of a value. The square of x is x * x.",
  examples: ["square(3)", "sqrt(9)", "3^2", "3 * 3"],
  seealso: ["multiply", "pow", "sqrt", "cube"]
}, O5e = {
  name: "subtract",
  category: "Operators",
  syntax: ["x - y", "subtract(x, y)"],
  description: "subtract two values.",
  examples: ["a = 5.3 - 2", "a + 2", "2/3 - 1/6", "2 * 3 - 3", "2.1 km - 500m"],
  seealso: ["add"]
}, F5e = {
  name: "unaryMinus",
  category: "Operators",
  syntax: ["-x", "unaryMinus(x)"],
  description: "Inverse the sign of a value. Converts booleans and strings to numbers.",
  examples: ["-4.5", "-(-5.6)", '-"22"'],
  seealso: ["add", "subtract", "unaryPlus"]
}, R5e = {
  name: "unaryPlus",
  category: "Operators",
  syntax: ["+x", "unaryPlus(x)"],
  description: "Converts booleans and strings to numbers.",
  examples: ["+true", '+"2"'],
  seealso: ["add", "subtract", "unaryMinus"]
}, L5e = {
  name: "xgcd",
  category: "Arithmetic",
  syntax: ["xgcd(a, b)"],
  description: "Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",
  examples: ["xgcd(8, 12)", "gcd(8, 12)", "xgcd(36163, 21199)"],
  seealso: ["gcd", "lcm"]
}, k5e = {
  name: "bitAnd",
  category: "Bitwise",
  syntax: ["x & y", "bitAnd(x, y)"],
  description: "Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",
  examples: ["5 & 3", "bitAnd(53, 131)", "[1, 12, 31] & 42"],
  seealso: ["bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, z5e = {
  name: "bitNot",
  category: "Bitwise",
  syntax: ["~x", "bitNot(x)"],
  description: "Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",
  examples: ["~1", "~2", "bitNot([2, -3, 4])"],
  seealso: ["bitAnd", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, U5e = {
  name: "bitOr",
  category: "Bitwise",
  syntax: ["x | y", "bitOr(x, y)"],
  description: "Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",
  examples: ["5 | 3", "bitOr([1, 2, 3], 4)"],
  seealso: ["bitAnd", "bitNot", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, G5e = {
  name: "bitXor",
  category: "Bitwise",
  syntax: ["bitXor(x, y)"],
  description: "Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",
  examples: ["bitOr(1, 2)", "bitXor([2, 3, 4], 4)"],
  seealso: ["bitAnd", "bitNot", "bitOr", "leftShift", "rightArithShift", "rightLogShift"]
}, V5e = {
  name: "leftShift",
  category: "Bitwise",
  syntax: ["x << y", "leftShift(x, y)"],
  description: "Bitwise left logical shift of a value x by y number of bits.",
  examples: ["4 << 1", "8 >> 1"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "rightArithShift", "rightLogShift"]
}, q5e = {
  name: "rightArithShift",
  category: "Bitwise",
  syntax: ["x >> y", "rightArithShift(x, y)"],
  description: "Bitwise right arithmetic shift of a value x by y number of bits.",
  examples: ["8 >> 1", "4 << 1", "-12 >> 2"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightLogShift"]
}, H5e = {
  name: "rightLogShift",
  category: "Bitwise",
  syntax: ["x >>> y", "rightLogShift(x, y)"],
  description: "Bitwise right logical shift of a value x by y number of bits.",
  examples: ["8 >>> 1", "4 << 1", "-12 >>> 2"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift"]
}, K5e = {
  name: "bellNumbers",
  category: "Combinatorics",
  syntax: ["bellNumbers(n)"],
  description: "The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",
  examples: ["bellNumbers(3)", "bellNumbers(8)"],
  seealso: ["stirlingS2"]
}, X5e = {
  name: "catalan",
  category: "Combinatorics",
  syntax: ["catalan(n)"],
  description: "The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",
  examples: ["catalan(3)", "catalan(8)"],
  seealso: ["bellNumbers"]
}, j5e = {
  name: "composition",
  category: "Combinatorics",
  syntax: ["composition(n, k)"],
  description: "The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",
  examples: ["composition(5, 3)"],
  seealso: ["combinations"]
}, Y5e = {
  name: "stirlingS2",
  category: "Combinatorics",
  syntax: ["stirlingS2(n, k)"],
  description: "he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",
  examples: ["stirlingS2(5, 3)"],
  seealso: ["bellNumbers"]
}, W5e = {
  name: "arg",
  category: "Complex",
  syntax: ["arg(x)"],
  description: "Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",
  examples: ["arg(2 + 2i)", "atan2(3, 2)", "arg(2 + 3i)"],
  seealso: ["re", "im", "conj", "abs"]
}, Z5e = {
  name: "conj",
  category: "Complex",
  syntax: ["conj(x)"],
  description: "Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",
  examples: ["conj(2 + 3i)", "conj(2 - 3i)", "conj(-5.2i)"],
  seealso: ["re", "im", "abs", "arg"]
}, Q5e = {
  name: "im",
  category: "Complex",
  syntax: ["im(x)"],
  description: "Get the imaginary part of a complex number.",
  examples: ["im(2 + 3i)", "re(2 + 3i)", "im(-5.2i)", "im(2.4)"],
  seealso: ["re", "conj", "abs", "arg"]
}, $5e = {
  name: "re",
  category: "Complex",
  syntax: ["re(x)"],
  description: "Get the real part of a complex number.",
  examples: ["re(2 + 3i)", "im(2 + 3i)", "re(-5.2i)", "re(2.4)"],
  seealso: ["im", "conj", "abs", "arg"]
}, J5e = {
  name: "evaluate",
  category: "Expression",
  syntax: ["evaluate(expression)", "evaluate(expression, scope)", "evaluate([expr1, expr2, expr3, ...])", "evaluate([expr1, expr2, expr3, ...], scope)"],
  description: "Evaluate an expression or an array with expressions.",
  examples: ['evaluate("2 + 3")', 'evaluate("sqrt(16)")', 'evaluate("2 inch to cm")', 'evaluate("sin(x * pi)", { "x": 1/2 })', 'evaluate(["width=2", "height=4","width*height"])'],
  seealso: []
}, e6e = {
  name: "help",
  category: "Expression",
  syntax: ["help(object)", "help(string)"],
  description: "Display documentation on a function or data type.",
  examples: ["help(sqrt)", 'help("complex")'],
  seealso: []
}, t6e = {
  name: "distance",
  category: "Geometry",
  syntax: ["distance([x1, y1], [x2, y2])", "distance([[x1, y1], [x2, y2]])"],
  description: "Calculates the Euclidean distance between two points.",
  examples: ["distance([0,0], [4,4])", "distance([[0,0], [4,4]])"],
  seealso: []
}, r6e = {
  name: "intersect",
  category: "Geometry",
  syntax: ["intersect(expr1, expr2, expr3, expr4)", "intersect(expr1, expr2, expr3)"],
  description: "Computes the intersection point of lines and/or planes.",
  examples: ["intersect([0, 0], [10, 10], [10, 0], [0, 10])", "intersect([1, 0, 1],  [4, -2, 2], [1, 1, 1, 6])"],
  seealso: []
}, n6e = {
  name: "and",
  category: "Logical",
  syntax: ["x and y", "and(x, y)"],
  description: "Logical and. Test whether two values are both defined with a nonzero/nonempty value.",
  examples: ["true and false", "true and true", "2 and 4"],
  seealso: ["not", "or", "xor"]
}, a6e = {
  name: "not",
  category: "Logical",
  syntax: ["not x", "not(x)"],
  description: "Logical not. Flips the boolean value of given argument.",
  examples: ["not true", "not false", "not 2", "not 0"],
  seealso: ["and", "or", "xor"]
}, i6e = {
  name: "or",
  category: "Logical",
  syntax: ["x or y", "or(x, y)"],
  description: "Logical or. Test if at least one value is defined with a nonzero/nonempty value.",
  examples: ["true or false", "false or false", "0 or 4"],
  seealso: ["not", "and", "xor"]
}, o6e = {
  name: "xor",
  category: "Logical",
  syntax: ["x xor y", "xor(x, y)"],
  description: "Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",
  examples: ["true xor false", "false xor false", "true xor true", "0 xor 4"],
  seealso: ["not", "and", "or"]
}, s6e = {
  name: "column",
  category: "Matrix",
  syntax: ["column(x, index)"],
  description: "Return a column from a matrix or array.",
  examples: ["A = [[1, 2], [3, 4]]", "column(A, 1)", "column(A, 2)"],
  seealso: ["row", "matrixFromColumns"]
}, u6e = {
  name: "concat",
  category: "Matrix",
  syntax: ["concat(A, B, C, ...)", "concat(A, B, C, ..., dim)"],
  description: "Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",
  examples: ["A = [1, 2; 5, 6]", "B = [3, 4; 7, 8]", "concat(A, B)", "concat(A, B, 1)", "concat(A, B, 2)"],
  seealso: ["det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, c6e = {
  name: "count",
  category: "Matrix",
  syntax: ["count(x)"],
  description: "Count the number of elements of a matrix, array or string.",
  examples: ["a = [1, 2; 3, 4; 5, 6]", "count(a)", "size(a)", 'count("hello world")'],
  seealso: ["size"]
}, l6e = {
  name: "cross",
  category: "Matrix",
  syntax: ["cross(A, B)"],
  description: "Calculate the cross product for two vectors in three dimensional space.",
  examples: ["cross([1, 1, 0],  [0, 1, 1])", "cross([3, -3, 1], [4, 9, 2])", "cross([2, 3, 4],  [5, 6, 7])"],
  seealso: ["multiply", "dot"]
}, d6e = {
  name: "ctranspose",
  category: "Matrix",
  syntax: ["x'", "ctranspose(x)"],
  description: "Complex Conjugate and Transpose a matrix",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "ctranspose(a)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
}, f6e = {
  name: "det",
  category: "Matrix",
  syntax: ["det(x)"],
  description: "Calculate the determinant of a matrix",
  examples: ["det([1, 2; 3, 4])", "det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],
  seealso: ["concat", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, m6e = {
  name: "diag",
  category: "Matrix",
  syntax: ["diag(x)", "diag(x, k)"],
  description: "Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",
  examples: ["diag(1:3)", "diag(1:3, 1)", "a = [1, 2, 3; 4, 5, 6; 7, 8, 9]", "diag(a)"],
  seealso: ["concat", "det", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, p6e = {
  name: "diff",
  category: "Matrix",
  syntax: ["diff(arr)", "diff(arr, dim)"],
  description: ["Create a new matrix or array with the difference of the passed matrix or array.", "Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference", "If no dimension parameter is passed it is assumed as dimension 0", "Dimension is zero-based in javascript and one-based in the parser", "Arrays must be 'rectangular' meaning arrays like [1, 2]", "If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],
  examples: ["A = [1, 2, 4, 7, 0]", "diff(A)", "diff(A, 1)", "B = [[1, 2], [3, 4]]", "diff(B)", "diff(B, 1)", "diff(B, 2)", "diff(B, bignumber(2))", "diff([[1, 2], matrix([3, 4])], 2)"],
  seealso: ["subtract", "partitionSelect"]
}, h6e = {
  name: "dot",
  category: "Matrix",
  syntax: ["dot(A, B)", "A * B"],
  description: "Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",
  examples: ["dot([2, 4, 1], [2, 2, 3])", "[2, 4, 1] * [2, 2, 3]"],
  seealso: ["multiply", "cross"]
}, v6e = {
  name: "eigs",
  category: "Matrix",
  syntax: ["eigs(x)"],
  description: "Calculate the eigenvalues and optionally eigenvectors of a square matrix",
  examples: ["eigs([[5, 2.3], [2.3, 1]])", "eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],
  seealso: ["inv"]
}, g6e = {
  name: "filter",
  category: "Matrix",
  syntax: ["filter(x, test)"],
  description: "Filter items in a matrix.",
  examples: ["isPositive(x) = x > 0", "filter([6, -2, -1, 4, 3], isPositive)", "filter([6, -2, 0, 1, 0], x != 0)"],
  seealso: ["sort", "map", "forEach"]
}, y6e = {
  name: "flatten",
  category: "Matrix",
  syntax: ["flatten(x)"],
  description: "Flatten a multi dimensional matrix into a single dimensional matrix.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "size(a)", "b = flatten(a)", "size(b)"],
  seealso: ["concat", "resize", "size", "squeeze"]
}, b6e = {
  name: "forEach",
  category: "Matrix",
  syntax: ["forEach(x, callback)"],
  description: "Iterates over all elements of a matrix/array, and executes the given callback function.",
  examples: ["numberOfPets = {}", "addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;", 'forEach(["Dog","Cat","Cat"], addPet)', "numberOfPets"],
  seealso: ["map", "sort", "filter"]
}, x6e = {
  name: "getMatrixDataType",
  category: "Matrix",
  syntax: ["getMatrixDataType(x)"],
  description: 'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',
  examples: ["getMatrixDataType([1, 2, 3])", "getMatrixDataType([[5 cm], [2 inch]])", 'getMatrixDataType([1, "text"])', "getMatrixDataType([1, bignumber(4)])"],
  seealso: ["matrix", "sparse", "typeOf"]
}, _6e = {
  name: "identity",
  category: "Matrix",
  syntax: ["identity(n)", "identity(m, n)", "identity([m, n])"],
  description: "Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",
  examples: ["identity(3)", "identity(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "identity(size(a))"],
  seealso: ["concat", "det", "diag", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, S6e = {
  name: "inv",
  category: "Matrix",
  syntax: ["inv(x)"],
  description: "Calculate the inverse of a matrix",
  examples: ["inv([1, 2; 3, 4])", "inv(4)", "1 / 4"],
  seealso: ["concat", "det", "diag", "identity", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, A6e = {
  name: "pinv",
  category: "Matrix",
  syntax: ["pinv(x)"],
  description: "Calculate the Moore–Penrose inverse of a matrix",
  examples: ["pinv([1, 2; 3, 4])", "pinv([[1, 0], [0, 1], [0, 1]])", "pinv(4)"],
  seealso: ["inv"]
}, w6e = {
  name: "kron",
  category: "Matrix",
  syntax: ["kron(x, y)"],
  description: "Calculates the kronecker product of 2 matrices or vectors.",
  examples: ["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])", "kron([1,1], [2,3,4])"],
  seealso: ["multiply", "dot", "cross"]
}, C6e = {
  name: "map",
  category: "Matrix",
  syntax: ["map(x, callback)"],
  description: "Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",
  examples: ["map([1, 2, 3], square)"],
  seealso: ["filter", "forEach"]
}, E6e = {
  name: "matrixFromColumns",
  category: "Matrix",
  syntax: ["matrixFromColumns(...arr)", "matrixFromColumns(row1, row2)", "matrixFromColumns(row1, row2, row3)"],
  description: "Create a dense matrix from vectors as individual columns.",
  examples: ["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],
  seealso: ["matrix", "matrixFromRows", "matrixFromFunction", "zeros"]
}, D6e = {
  name: "matrixFromFunction",
  category: "Matrix",
  syntax: ["matrixFromFunction(size, fn)", "matrixFromFunction(size, fn, format)", "matrixFromFunction(size, fn, format, datatype)", "matrixFromFunction(size, format, fn)", "matrixFromFunction(size, format, datatype, fn)"],
  description: "Create a matrix by evaluating a generating function at each index.",
  examples: ["f(I) = I[1] - I[2]", "matrixFromFunction([3,3], f)", "g(I) = I[1] - I[2] == 1 ? 4 : 0", 'matrixFromFunction([100, 100], "sparse", g)', "matrixFromFunction([5], random)"],
  seealso: ["matrix", "matrixFromRows", "matrixFromColumns", "zeros"]
}, M6e = {
  name: "matrixFromRows",
  category: "Matrix",
  syntax: ["matrixFromRows(...arr)", "matrixFromRows(row1, row2)", "matrixFromRows(row1, row2, row3)"],
  description: "Create a dense matrix from vectors as individual rows.",
  examples: ["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],
  seealso: ["matrix", "matrixFromColumns", "matrixFromFunction", "zeros"]
}, I6e = {
  name: "ones",
  category: "Matrix",
  syntax: ["ones(m)", "ones(m, n)", "ones(m, n, p, ...)", "ones([m])", "ones([m, n])", "ones([m, n, p, ...])"],
  description: "Create a matrix containing ones.",
  examples: ["ones(3)", "ones(3, 5)", "ones([2,3]) * 4.5", "a = [1, 2, 3; 4, 5, 6]", "ones(size(a))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, T6e = {
  name: "partitionSelect",
  category: "Matrix",
  syntax: ["partitionSelect(x, k)", "partitionSelect(x, k, compare)"],
  description: "Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",
  examples: ["partitionSelect([5, 10, 1], 2)", 'partitionSelect(["C", "B", "A", "D"], 1, compareText)', "arr = [5, 2, 1]", "partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]", "arr", "partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]", "arr"],
  seealso: ["sort"]
}, N6e = {
  name: "range",
  category: "Type",
  syntax: ["start:end", "start:step:end", "range(start, end)", "range(start, end, step)", "range(string)"],
  description: "Create a range. Lower bound of the range is included, upper bound is excluded.",
  examples: ["1:5", "3:-1:-3", "range(3, 7)", "range(0, 12, 2)", 'range("4:10")', "range(1m, 1m, 3m)", "a = [1, 2, 3, 4; 5, 6, 7, 8]", "a[1:2, 1:2]"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, P6e = {
  name: "reshape",
  category: "Matrix",
  syntax: ["reshape(x, sizes)"],
  description: "Reshape a multi dimensional array to fit the specified dimensions.",
  examples: ["reshape([1, 2, 3, 4, 5, 6], [2, 3])", "reshape([[1, 2], [3, 4]], [1, 4])", "reshape([[1, 2], [3, 4]], [4])", "reshape([1, 2, 3, 4], [-1, 2])"],
  seealso: ["size", "squeeze", "resize"]
}, B6e = {
  name: "resize",
  category: "Matrix",
  syntax: ["resize(x, size)", "resize(x, size, defaultValue)"],
  description: "Resize a matrix.",
  examples: ["resize([1,2,3,4,5], [3])", "resize([1,2,3], [5])", "resize([1,2,3], [5], -1)", "resize(2, [2, 3])", 'resize("hello", [8], "!")'],
  seealso: ["size", "subset", "squeeze", "reshape"]
}, O6e = {
  name: "rotate",
  category: "Matrix",
  syntax: ["rotate(w, theta)", "rotate(w, theta, v)"],
  description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
  examples: ["rotate([1, 0], pi / 2)", 'rotate(matrix([1, 0]), unit("35deg"))', 'rotate([1, 0, 0], unit("90deg"), [0, 0, 1])', 'rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],
  seealso: ["matrix", "rotationMatrix"]
}, F6e = {
  name: "rotationMatrix",
  category: "Matrix",
  syntax: ["rotationMatrix(theta)", "rotationMatrix(theta, v)", "rotationMatrix(theta, v, format)"],
  description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
  examples: ["rotationMatrix(pi / 2)", 'rotationMatrix(unit("45deg"), [0, 0, 1])', 'rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],
  seealso: ["cos", "sin"]
}, R6e = {
  name: "row",
  category: "Matrix",
  syntax: ["row(x, index)"],
  description: "Return a row from a matrix or array.",
  examples: ["A = [[1, 2], [3, 4]]", "row(A, 1)", "row(A, 2)"],
  seealso: ["column", "matrixFromRows"]
}, L6e = {
  name: "size",
  category: "Matrix",
  syntax: ["size(x)"],
  description: "Calculate the size of a matrix.",
  examples: ["size(2.3)", 'size("hello world")', "a = [1, 2; 3, 4; 5, 6]", "size(a)", "size(1:6)"],
  seealso: ["concat", "count", "det", "diag", "identity", "inv", "ones", "range", "squeeze", "subset", "trace", "transpose", "zeros"]
}, k6e = {
  name: "sort",
  category: "Matrix",
  syntax: ["sort(x)", "sort(x, compare)"],
  description: 'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',
  examples: ["sort([5, 10, 1])", 'sort(["C", "B", "A", "D"], "natural")', "sortByLength(a, b) = size(a)[1] - size(b)[1]", 'sort(["Langdon", "Tom", "Sara"], sortByLength)', 'sort(["10", "1", "2"], "natural")'],
  seealso: ["map", "filter", "forEach"]
}, z6e = {
  name: "squeeze",
  category: "Matrix",
  syntax: ["squeeze(x)"],
  description: "Remove inner and outer singleton dimensions from a matrix.",
  examples: ["a = zeros(3,2,1)", "size(squeeze(a))", "b = zeros(1,1,3)", "size(squeeze(b))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "subset", "trace", "transpose", "zeros"]
}, U6e = {
  name: "subset",
  category: "Matrix",
  syntax: ["value(index)", "value(index) = replacement", "subset(value, [index])", "subset(value, [index], replacement)"],
  description: "Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",
  examples: ["d = [1, 2; 3, 4]", "e = []", "e[1, 1:2] = [5, 6]", "e[2, :] = [7, 8]", "f = d * e", "f[2, 1]", "f[:, 1]", "f[[1,2], [1,3]] = [9, 10; 11, 12]", "f"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "trace", "transpose", "zeros"]
}, G6e = {
  name: "trace",
  category: "Matrix",
  syntax: ["trace(A)"],
  description: "Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",
  examples: ["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]", "trace(A)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "transpose", "zeros"]
}, V6e = {
  name: "transpose",
  category: "Matrix",
  syntax: ["x'", "transpose(x)"],
  description: "Transpose a matrix",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "transpose(a)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
}, q6e = {
  name: "zeros",
  category: "Matrix",
  syntax: ["zeros(m)", "zeros(m, n)", "zeros(m, n, p, ...)", "zeros([m])", "zeros([m, n])", "zeros([m, n, p, ...])"],
  description: "Create a matrix containing zeros.",
  examples: ["zeros(3)", "zeros(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "zeros(size(a))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose"]
}, H6e = {
  name: "fft",
  category: "Matrix",
  syntax: ["fft(x)"],
  description: "Calculate N-dimensional fourier transform",
  examples: ["fft([[1, 0], [1, 0]])"],
  seealso: ["ifft"]
}, K6e = {
  name: "ifft",
  category: "Matrix",
  syntax: ["ifft(x)"],
  description: "Calculate N-dimensional inverse fourier transform",
  examples: ["ifft([[2, 2], [0, 0]])"],
  seealso: ["fft"]
}, X6e = {
  name: "combinations",
  category: "Probability",
  syntax: ["combinations(n, k)"],
  description: "Compute the number of combinations of n items taken k at a time",
  examples: ["combinations(7, 5)"],
  seealso: ["combinationsWithRep", "permutations", "factorial"]
}, j6e = {
  name: "combinationsWithRep",
  category: "Probability",
  syntax: ["combinationsWithRep(n, k)"],
  description: "Compute the number of combinations of n items taken k at a time with replacements.",
  examples: ["combinationsWithRep(7, 5)"],
  seealso: ["combinations", "permutations", "factorial"]
}, Y6e = {
  name: "factorial",
  category: "Probability",
  syntax: ["n!", "factorial(n)"],
  description: "Compute the factorial of a value",
  examples: ["5!", "5 * 4 * 3 * 2 * 1", "3!"],
  seealso: ["combinations", "combinationsWithRep", "permutations", "gamma"]
}, W6e = {
  name: "gamma",
  category: "Probability",
  syntax: ["gamma(n)"],
  description: "Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",
  examples: ["gamma(4)", "3!", "gamma(1/2)", "sqrt(pi)"],
  seealso: ["factorial"]
}, Z6e = {
  name: "lgamma",
  category: "Probability",
  syntax: ["lgamma(n)"],
  description: "Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",
  examples: ["lgamma(4)", "lgamma(1/2)", "lgamma(i)", "lgamma(complex(1.1, 2))"],
  seealso: ["gamma"]
}, Q6e = {
  name: "kldivergence",
  category: "Probability",
  syntax: ["kldivergence(x, y)"],
  description: "Calculate the Kullback-Leibler (KL) divergence  between two distributions.",
  examples: ["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],
  seealso: []
}, $6e = {
  name: "multinomial",
  category: "Probability",
  syntax: ["multinomial(A)"],
  description: "Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",
  examples: ["multinomial([1, 2, 1])"],
  seealso: ["combinations", "factorial"]
}, J6e = {
  name: "permutations",
  category: "Probability",
  syntax: ["permutations(n)", "permutations(n, k)"],
  description: "Compute the number of permutations of n items taken k at a time",
  examples: ["permutations(5)", "permutations(5, 3)"],
  seealso: ["combinations", "combinationsWithRep", "factorial"]
}, e_e = {
  name: "pickRandom",
  category: "Probability",
  syntax: ["pickRandom(array)", "pickRandom(array, number)", "pickRandom(array, weights)", "pickRandom(array, number, weights)", "pickRandom(array, weights, number)"],
  description: "Pick a random entry from a given array.",
  examples: ["pickRandom(0:10)", "pickRandom([1, 3, 1, 6])", "pickRandom([1, 3, 1, 6], 2)", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],
  seealso: ["random", "randomInt"]
}, t_e = {
  name: "random",
  category: "Probability",
  syntax: ["random()", "random(max)", "random(min, max)", "random(size)", "random(size, max)", "random(size, min, max)"],
  description: "Return a random number.",
  examples: ["random()", "random(10, 20)", "random([2, 3])"],
  seealso: ["pickRandom", "randomInt"]
}, r_e = {
  name: "randomInt",
  category: "Probability",
  syntax: ["randomInt(max)", "randomInt(min, max)", "randomInt(size)", "randomInt(size, max)", "randomInt(size, min, max)"],
  description: "Return a random integer number",
  examples: ["randomInt(10, 20)", "randomInt([2, 3], 10)"],
  seealso: ["pickRandom", "random"]
}, n_e = {
  name: "compare",
  category: "Relational",
  syntax: ["compare(x, y)"],
  description: "Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ["compare(2, 3)", "compare(3, 2)", "compare(2, 2)", "compare(5cm, 40mm)", "compare(2, [1, 2, 3])"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compareNatural", "compareText"]
}, a_e = {
  name: "compareNatural",
  category: "Relational",
  syntax: ["compareNatural(x, y)"],
  description: "Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ["compareNatural(2, 3)", "compareNatural(3, 2)", "compareNatural(2, 2)", "compareNatural(5cm, 40mm)", 'compareNatural("2", "10")', "compareNatural(2 + 3i, 2 + 4i)", "compareNatural([1, 2, 4], [1, 2, 3])", "compareNatural([1, 5], [1, 2, 3])", "compareNatural([1, 2], [1, 2])", "compareNatural({a: 2}, {a: 4})"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare", "compareText"]
}, i_e = {
  name: "compareText",
  category: "Relational",
  syntax: ["compareText(x, y)"],
  description: "Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ['compareText("B", "A")', 'compareText("A", "B")', 'compareText("A", "A")', 'compareText("2", "10")', 'compare("2", "10")', "compare(2, 10)", 'compareNatural("2", "10")', 'compareText("B", ["A", "B", "C"])'],
  seealso: ["compare", "compareNatural"]
}, o_e = {
  name: "deepEqual",
  category: "Relational",
  syntax: ["deepEqual(x, y)"],
  description: "Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",
  examples: ["deepEqual([1,3,4], [1,3,4])", "deepEqual([1,3,4], [1,3])"],
  seealso: ["equal", "unequal", "smaller", "larger", "smallerEq", "largerEq", "compare"]
}, s_e = {
  name: "equal",
  category: "Relational",
  syntax: ["x == y", "equal(x, y)"],
  description: "Check equality of two values. Returns true if the values are equal, and false if not.",
  examples: ["2+2 == 3", "2+2 == 4", "a = 3.2", "b = 6-2.8", "a == b", "50cm == 0.5m"],
  seealso: ["unequal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual", "equalText"]
}, u_e = {
  name: "equalText",
  category: "Relational",
  syntax: ["equalText(x, y)"],
  description: "Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",
  examples: ['equalText("Hello", "Hello")', 'equalText("a", "A")', 'equal("2e3", "2000")', 'equalText("2e3", "2000")', 'equalText("B", ["A", "B", "C"])'],
  seealso: ["compare", "compareNatural", "compareText", "equal"]
}, c_e = {
  name: "larger",
  category: "Relational",
  syntax: ["x > y", "larger(x, y)"],
  description: "Check if value x is larger than y. Returns true if x is larger than y, and false if not.",
  examples: ["2 > 3", "5 > 2*2", "a = 3.3", "b = 6-2.8", "(a > b)", "(b < a)", "5 cm > 2 inch"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare"]
}, l_e = {
  name: "largerEq",
  category: "Relational",
  syntax: ["x >= y", "largerEq(x, y)"],
  description: "Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",
  examples: ["2 >= 1+1", "2 > 1+1", "a = 3.2", "b = 6-2.8", "(a >= b)"],
  seealso: ["equal", "unequal", "smallerEq", "smaller", "compare"]
}, d_e = {
  name: "smaller",
  category: "Relational",
  syntax: ["x < y", "smaller(x, y)"],
  description: "Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",
  examples: ["2 < 3", "5 < 2*2", "a = 3.3", "b = 6-2.8", "(a < b)", "5 cm < 2 inch"],
  seealso: ["equal", "unequal", "larger", "smallerEq", "largerEq", "compare"]
}, f_e = {
  name: "smallerEq",
  category: "Relational",
  syntax: ["x <= y", "smallerEq(x, y)"],
  description: "Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",
  examples: ["2 <= 1+1", "2 < 1+1", "a = 3.2", "b = 6-2.8", "(a <= b)"],
  seealso: ["equal", "unequal", "larger", "smaller", "largerEq", "compare"]
}, m_e = {
  name: "unequal",
  category: "Relational",
  syntax: ["x != y", "unequal(x, y)"],
  description: "Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",
  examples: ["2+2 != 3", "2+2 != 4", "a = 3.2", "b = 6-2.8", "a != b", "50cm != 0.5m", "5 cm != 2 inch"],
  seealso: ["equal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual"]
}, p_e = {
  name: "setCartesian",
  category: "Set",
  syntax: ["setCartesian(set1, set2)"],
  description: "Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",
  examples: ["setCartesian([1, 2], [3, 4])"],
  seealso: ["setUnion", "setIntersect", "setDifference", "setPowerset"]
}, h_e = {
  name: "setDifference",
  category: "Set",
  syntax: ["setDifference(set1, set2)"],
  description: "Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setIntersect", "setSymDifference"]
}, v_e = {
  name: "setDistinct",
  category: "Set",
  syntax: ["setDistinct(set)"],
  description: "Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setDistinct([1, 1, 1, 2, 2, 3])"],
  seealso: ["setMultiplicity"]
}, g_e = {
  name: "setIntersect",
  category: "Set",
  syntax: ["setIntersect(set1, set2)"],
  description: "Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])", "setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setDifference"]
}, y_e = {
  name: "setIsSubset",
  category: "Set",
  syntax: ["setIsSubset(set1, set2)"],
  description: "Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setIsSubset([1, 2], [3, 4, 5, 6])", "setIsSubset([3, 4], [3, 4, 5, 6])"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, b_e = {
  name: "setMultiplicity",
  category: "Set",
  syntax: ["setMultiplicity(element, set)"],
  description: "Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setMultiplicity(1, [1, 2, 2, 4])", "setMultiplicity(2, [1, 2, 2, 4])"],
  seealso: ["setDistinct", "setSize"]
}, x_e = {
  name: "setPowerset",
  category: "Set",
  syntax: ["setPowerset(set)"],
  description: "Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setPowerset([1, 2, 3])"],
  seealso: ["setCartesian"]
}, __e = {
  name: "setSize",
  category: "Set",
  syntax: ["setSize(set)", "setSize(set, unique)"],
  description: 'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',
  examples: ["setSize([1, 2, 2, 4])", "setSize([1, 2, 2, 4], true)"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, S_e = {
  name: "setSymDifference",
  category: "Set",
  syntax: ["setSymDifference(set1, set2)"],
  description: "Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, A_e = {
  name: "setUnion",
  category: "Set",
  syntax: ["setUnion(set1, set2)"],
  description: "Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setUnion([1, 2, 3, 4], [3, 4, 5, 6])", "setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setIntersect", "setDifference"]
}, w_e = {
  name: "zpk2tf",
  category: "Signal",
  syntax: ["zpk2tf(z, p, k)"],
  description: "Compute the transfer function of a zero-pole-gain model.",
  examples: ["zpk2tf([1, 2], [-1, -2], 1)", "zpk2tf([1, 2], [-1, -2])", "zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],
  seealso: []
}, C_e = {
  name: "freqz",
  category: "Signal",
  syntax: ["freqz(b, a)", "freqz(b, a, w)"],
  description: "Calculates the frequency response of a filter given its numerator and denominator coefficients.",
  examples: ["freqz([1, 2], [1, 2, 3])", "freqz([1, 2], [1, 2, 3], [0, 1])", "freqz([1, 2], [1, 2, 3], 512)"],
  seealso: []
}, E_e = {
  name: "erf",
  category: "Special",
  syntax: ["erf(x)"],
  description: "Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",
  examples: ["erf(0.2)", "erf(-0.5)", "erf(4)"],
  seealso: []
}, D_e = {
  name: "zeta",
  category: "Special",
  syntax: ["zeta(s)"],
  description: "Compute the Riemann Zeta Function using an infinite series and Riemanns Functional Equation for the entire complex plane",
  examples: ["zeta(0.2)", "zeta(-0.5)", "zeta(4)"],
  seealso: []
}, M_e = {
  name: "mad",
  category: "Statistics",
  syntax: ["mad(a, b, c, ...)", "mad(A)"],
  description: "Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",
  examples: ["mad(10, 20, 30)", "mad([1, 2, 3])"],
  seealso: ["mean", "median", "std", "abs"]
}, I_e = {
  name: "max",
  category: "Statistics",
  syntax: ["max(a, b, c, ...)", "max(A)", "max(A, dimension)"],
  description: "Compute the maximum value of a list of values.",
  examples: ["max(2, 3, 4, 1)", "max([2, 3, 4, 1])", "max([2, 5; 4, 3])", "max([2, 5; 4, 3], 1)", "max([2, 5; 4, 3], 2)", "max(2.7, 7.1, -4.5, 2.0, 4.1)", "min(2.7, 7.1, -4.5, 2.0, 4.1)"],
  seealso: ["mean", "median", "min", "prod", "std", "sum", "variance"]
}, T_e = {
  name: "mean",
  category: "Statistics",
  syntax: ["mean(a, b, c, ...)", "mean(A)", "mean(A, dimension)"],
  description: "Compute the arithmetic mean of a list of values.",
  examples: ["mean(2, 3, 4, 1)", "mean([2, 3, 4, 1])", "mean([2, 5; 4, 3])", "mean([2, 5; 4, 3], 1)", "mean([2, 5; 4, 3], 2)", "mean([1.0, 2.7, 3.2, 4.0])"],
  seealso: ["max", "median", "min", "prod", "std", "sum", "variance"]
}, N_e = {
  name: "median",
  category: "Statistics",
  syntax: ["median(a, b, c, ...)", "median(A)"],
  description: "Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",
  examples: ["median(5, 2, 7)", "median([3, -1, 5, 7])"],
  seealso: ["max", "mean", "min", "prod", "std", "sum", "variance", "quantileSeq"]
}, P_e = {
  name: "min",
  category: "Statistics",
  syntax: ["min(a, b, c, ...)", "min(A)", "min(A, dimension)"],
  description: "Compute the minimum value of a list of values.",
  examples: ["min(2, 3, 4, 1)", "min([2, 3, 4, 1])", "min([2, 5; 4, 3])", "min([2, 5; 4, 3], 1)", "min([2, 5; 4, 3], 2)", "min(2.7, 7.1, -4.5, 2.0, 4.1)", "max(2.7, 7.1, -4.5, 2.0, 4.1)"],
  seealso: ["max", "mean", "median", "prod", "std", "sum", "variance"]
}, B_e = {
  name: "mode",
  category: "Statistics",
  syntax: ["mode(a, b, c, ...)", "mode(A)", "mode(A, a, b, B, c, ...)"],
  description: "Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",
  examples: ["mode(2, 1, 4, 3, 1)", "mode([1, 2.7, 3.2, 4, 2.7])", "mode(1, 4, 6, 1, 6)"],
  seealso: ["max", "mean", "min", "median", "prod", "std", "sum", "variance"]
}, O_e = {
  name: "prod",
  category: "Statistics",
  syntax: ["prod(a, b, c, ...)", "prod(A)"],
  description: "Compute the product of all values.",
  examples: ["prod(2, 3, 4)", "prod([2, 3, 4])", "prod([2, 5; 4, 3])"],
  seealso: ["max", "mean", "min", "median", "min", "std", "sum", "variance"]
}, F_e = {
  name: "quantileSeq",
  category: "Statistics",
  syntax: ["quantileSeq(A, prob[, sorted])", "quantileSeq(A, [prob1, prob2, ...][, sorted])", "quantileSeq(A, N[, sorted])"],
  description: `Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. 

In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,
  examples: ["quantileSeq([3, -1, 5, 7], 0.5)", "quantileSeq([3, -1, 5, 7], [1/3, 2/3])", "quantileSeq([3, -1, 5, 7], 2)", "quantileSeq([-1, 3, 5, 7], 0.5, true)"],
  seealso: ["mean", "median", "min", "max", "prod", "std", "sum", "variance"]
}, R_e = {
  name: "std",
  category: "Statistics",
  syntax: ["std(a, b, c, ...)", "std(A)", "std(A, dimension)", "std(A, normalization)", "std(A, dimension, normalization)"],
  description: 'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
  examples: ["std(2, 4, 6)", "std([2, 4, 6, 8])", 'std([2, 4, 6, 8], "uncorrected")', 'std([2, 4, 6, 8], "biased")', "std([1, 2, 3; 4, 5, 6])"],
  seealso: ["max", "mean", "min", "median", "prod", "sum", "variance"]
}, L_e = {
  name: "cumsum",
  category: "Statistics",
  syntax: ["cumsum(a, b, c, ...)", "cumsum(A)"],
  description: "Compute the cumulative sum of all values.",
  examples: ["cumsum(2, 3, 4, 1)", "cumsum([2, 3, 4, 1])", "cumsum([1, 2; 3, 4])", "cumsum([1, 2; 3, 4], 1)", "cumsum([1, 2; 3, 4], 2)"],
  seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
}, k_e = {
  name: "sum",
  category: "Statistics",
  syntax: ["sum(a, b, c, ...)", "sum(A)", "sum(A, dimension)"],
  description: "Compute the sum of all values.",
  examples: ["sum(2, 3, 4, 1)", "sum([2, 3, 4, 1])", "sum([2, 5; 4, 3])"],
  seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
}, z_e = {
  name: "variance",
  category: "Statistics",
  syntax: ["variance(a, b, c, ...)", "variance(A)", "variance(A, dimension)", "variance(A, normalization)", "variance(A, dimension, normalization)"],
  description: 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
  examples: ["variance(2, 4, 6)", "variance([2, 4, 6, 8])", 'variance([2, 4, 6, 8], "uncorrected")', 'variance([2, 4, 6, 8], "biased")', "variance([1, 2, 3; 4, 5, 6])"],
  seealso: ["max", "mean", "min", "median", "min", "prod", "std", "sum"]
}, U_e = {
  name: "corr",
  category: "Statistics",
  syntax: ["corr(A,B)"],
  description: "Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",
  examples: ["corr([2, 4, 6, 8],[1, 2, 3, 6])", "corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],
  seealso: ["max", "mean", "min", "median", "min", "prod", "std", "sum"]
}, G_e = {
  name: "acos",
  category: "Trigonometry",
  syntax: ["acos(x)"],
  description: "Compute the inverse cosine of a value in radians.",
  examples: ["acos(0.5)", "acos(cos(2.3))"],
  seealso: ["cos", "atan", "asin"]
}, V_e = {
  name: "acosh",
  category: "Trigonometry",
  syntax: ["acosh(x)"],
  description: "Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",
  examples: ["acosh(1.5)"],
  seealso: ["cosh", "asinh", "atanh"]
}, q_e = {
  name: "acot",
  category: "Trigonometry",
  syntax: ["acot(x)"],
  description: "Calculate the inverse cotangent of a value.",
  examples: ["acot(0.5)", "acot(cot(0.5))", "acot(2)"],
  seealso: ["cot", "atan"]
}, H_e = {
  name: "acoth",
  category: "Trigonometry",
  syntax: ["acoth(x)"],
  description: "Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",
  examples: ["acoth(2)", "acoth(0.5)"],
  seealso: ["acsch", "asech"]
}, K_e = {
  name: "acsc",
  category: "Trigonometry",
  syntax: ["acsc(x)"],
  description: "Calculate the inverse cotangent of a value.",
  examples: ["acsc(2)", "acsc(csc(0.5))", "acsc(0.5)"],
  seealso: ["csc", "asin", "asec"]
}, X_e = {
  name: "acsch",
  category: "Trigonometry",
  syntax: ["acsch(x)"],
  description: "Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",
  examples: ["acsch(0.5)"],
  seealso: ["asech", "acoth"]
}, j_e = {
  name: "asec",
  category: "Trigonometry",
  syntax: ["asec(x)"],
  description: "Calculate the inverse secant of a value.",
  examples: ["asec(0.5)", "asec(sec(0.5))", "asec(2)"],
  seealso: ["acos", "acot", "acsc"]
}, Y_e = {
  name: "asech",
  category: "Trigonometry",
  syntax: ["asech(x)"],
  description: "Calculate the inverse secant of a value.",
  examples: ["asech(0.5)"],
  seealso: ["acsch", "acoth"]
}, W_e = {
  name: "asin",
  category: "Trigonometry",
  syntax: ["asin(x)"],
  description: "Compute the inverse sine of a value in radians.",
  examples: ["asin(0.5)", "asin(sin(0.5))"],
  seealso: ["sin", "acos", "atan"]
}, Z_e = {
  name: "asinh",
  category: "Trigonometry",
  syntax: ["asinh(x)"],
  description: "Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",
  examples: ["asinh(0.5)"],
  seealso: ["acosh", "atanh"]
}, Q_e = {
  name: "atan",
  category: "Trigonometry",
  syntax: ["atan(x)"],
  description: "Compute the inverse tangent of a value in radians.",
  examples: ["atan(0.5)", "atan(tan(0.5))"],
  seealso: ["tan", "acos", "asin"]
}, $_e = {
  name: "atan2",
  category: "Trigonometry",
  syntax: ["atan2(y, x)"],
  description: "Computes the principal value of the arc tangent of y/x in radians.",
  examples: ["atan2(2, 2) / pi", "angle = 60 deg in rad", "x = cos(angle)", "y = sin(angle)", "atan2(y, x)"],
  seealso: ["sin", "cos", "tan"]
}, J_e = {
  name: "atanh",
  category: "Trigonometry",
  syntax: ["atanh(x)"],
  description: "Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",
  examples: ["atanh(0.5)"],
  seealso: ["acosh", "asinh"]
}, e8e = {
  name: "cos",
  category: "Trigonometry",
  syntax: ["cos(x)"],
  description: "Compute the cosine of x in radians.",
  examples: ["cos(2)", "cos(pi / 4) ^ 2", "cos(180 deg)", "cos(60 deg)", "sin(0.2)^2 + cos(0.2)^2"],
  seealso: ["acos", "sin", "tan"]
}, t8e = {
  name: "cosh",
  category: "Trigonometry",
  syntax: ["cosh(x)"],
  description: "Compute the hyperbolic cosine of x in radians.",
  examples: ["cosh(0.5)"],
  seealso: ["sinh", "tanh", "coth"]
}, r8e = {
  name: "cot",
  category: "Trigonometry",
  syntax: ["cot(x)"],
  description: "Compute the cotangent of x in radians. Defined as 1/tan(x)",
  examples: ["cot(2)", "1 / tan(2)"],
  seealso: ["sec", "csc", "tan"]
}, n8e = {
  name: "coth",
  category: "Trigonometry",
  syntax: ["coth(x)"],
  description: "Compute the hyperbolic cotangent of x in radians.",
  examples: ["coth(2)", "1 / tanh(2)"],
  seealso: ["sech", "csch", "tanh"]
}, a8e = {
  name: "csc",
  category: "Trigonometry",
  syntax: ["csc(x)"],
  description: "Compute the cosecant of x in radians. Defined as 1/sin(x)",
  examples: ["csc(2)", "1 / sin(2)"],
  seealso: ["sec", "cot", "sin"]
}, i8e = {
  name: "csch",
  category: "Trigonometry",
  syntax: ["csch(x)"],
  description: "Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",
  examples: ["csch(2)", "1 / sinh(2)"],
  seealso: ["sech", "coth", "sinh"]
}, o8e = {
  name: "sec",
  category: "Trigonometry",
  syntax: ["sec(x)"],
  description: "Compute the secant of x in radians. Defined as 1/cos(x)",
  examples: ["sec(2)", "1 / cos(2)"],
  seealso: ["cot", "csc", "cos"]
}, s8e = {
  name: "sech",
  category: "Trigonometry",
  syntax: ["sech(x)"],
  description: "Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",
  examples: ["sech(2)", "1 / cosh(2)"],
  seealso: ["coth", "csch", "cosh"]
}, u8e = {
  name: "sin",
  category: "Trigonometry",
  syntax: ["sin(x)"],
  description: "Compute the sine of x in radians.",
  examples: ["sin(2)", "sin(pi / 4) ^ 2", "sin(90 deg)", "sin(30 deg)", "sin(0.2)^2 + cos(0.2)^2"],
  seealso: ["asin", "cos", "tan"]
}, c8e = {
  name: "sinh",
  category: "Trigonometry",
  syntax: ["sinh(x)"],
  description: "Compute the hyperbolic sine of x in radians.",
  examples: ["sinh(0.5)"],
  seealso: ["cosh", "tanh"]
}, l8e = {
  name: "tan",
  category: "Trigonometry",
  syntax: ["tan(x)"],
  description: "Compute the tangent of x in radians.",
  examples: ["tan(0.5)", "sin(0.5) / cos(0.5)", "tan(pi / 4)", "tan(45 deg)"],
  seealso: ["atan", "sin", "cos"]
}, d8e = {
  name: "tanh",
  category: "Trigonometry",
  syntax: ["tanh(x)"],
  description: "Compute the hyperbolic tangent of x in radians.",
  examples: ["tanh(0.5)", "sinh(0.5) / cosh(0.5)"],
  seealso: ["sinh", "cosh"]
}, f8e = {
  name: "to",
  category: "Units",
  syntax: ["x to unit", "to(x, unit)"],
  description: "Change the unit of a value.",
  examples: ["5 inch to cm", "3.2kg to g", "16 bytes in bits"],
  seealso: []
}, m8e = {
  name: "bin",
  category: "Utils",
  syntax: ["bin(value)"],
  description: "Format a number as binary",
  examples: ["bin(2)"],
  seealso: ["oct", "hex"]
}, p8e = {
  name: "clone",
  category: "Utils",
  syntax: ["clone(x)"],
  description: "Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",
  examples: ["clone(3.5)", "clone(2 - 4i)", "clone(45 deg)", "clone([1, 2; 3, 4])", 'clone("hello world")'],
  seealso: []
}, h8e = {
  name: "format",
  category: "Utils",
  syntax: ["format(value)", "format(value, precision)"],
  description: "Format a value of any type as string.",
  examples: ["format(2.3)", "format(3 - 4i)", "format([])", "format(pi, 3)"],
  seealso: ["print"]
}, v8e = {
  name: "hasNumericValue",
  category: "Utils",
  syntax: ["hasNumericValue(x)"],
  description: "Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",
  examples: ["hasNumericValue(2)", 'hasNumericValue("2")', 'isNumeric("2")', "hasNumericValue(0)", "hasNumericValue(bignumber(500))", "hasNumericValue(fraction(0.125))", "hasNumericValue(2 + 3i)", 'hasNumericValue([2.3, "foo", false])'],
  seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "isNumeric"]
}, g8e = {
  name: "hex",
  category: "Utils",
  syntax: ["hex(value)"],
  description: "Format a number as hexadecimal",
  examples: ["hex(240)"],
  seealso: ["bin", "oct"]
}, y8e = {
  name: "isInteger",
  category: "Utils",
  syntax: ["isInteger(x)"],
  description: "Test whether a value is an integer number.",
  examples: ["isInteger(2)", "isInteger(3.5)", "isInteger([3, 0.5, -2])"],
  seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
}, b8e = {
  name: "isNaN",
  category: "Utils",
  syntax: ["isNaN(x)"],
  description: "Test whether a value is NaN (not a number)",
  examples: ["isNaN(2)", "isNaN(0 / 0)", "isNaN(NaN)", "isNaN(Infinity)"],
  seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
}, x8e = {
  name: "isNegative",
  category: "Utils",
  syntax: ["isNegative(x)"],
  description: "Test whether a value is negative: smaller than zero.",
  examples: ["isNegative(2)", "isNegative(0)", "isNegative(-4)", "isNegative([3, 0.5, -2])"],
  seealso: ["isInteger", "isNumeric", "isPositive", "isZero"]
}, _8e = {
  name: "isNumeric",
  category: "Utils",
  syntax: ["isNumeric(x)"],
  description: "Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",
  examples: ["isNumeric(2)", 'isNumeric("2")', 'hasNumericValue("2")', "isNumeric(0)", "isNumeric(bignumber(500))", "isNumeric(fraction(0.125))", "isNumeric(2 + 3i)", 'isNumeric([2.3, "foo", false])'],
  seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "hasNumericValue"]
}, S8e = {
  name: "isPositive",
  category: "Utils",
  syntax: ["isPositive(x)"],
  description: "Test whether a value is positive: larger than zero.",
  examples: ["isPositive(2)", "isPositive(0)", "isPositive(-4)", "isPositive([3, 0.5, -2])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
}, A8e = {
  name: "isPrime",
  category: "Utils",
  syntax: ["isPrime(x)"],
  description: "Test whether a value is prime: has no divisors other than itself and one.",
  examples: ["isPrime(3)", "isPrime(-2)", "isPrime([2, 17, 100])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
}, w8e = {
  name: "isZero",
  category: "Utils",
  syntax: ["isZero(x)"],
  description: "Test whether a value is zero.",
  examples: ["isZero(2)", "isZero(0)", "isZero(-4)", "isZero([3, 0, -2, 0])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isPositive"]
}, C8e = {
  name: "numeric",
  category: "Utils",
  syntax: ["numeric(x)"],
  description: "Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",
  examples: ['numeric("4")', 'numeric("4", "number")', 'numeric("4", "bigint")', 'numeric("4", "BigNumber")', 'numeric("4", "Fraction")', 'numeric(4, "Fraction")', 'numeric(fraction(2, 5), "number")'],
  seealso: ["number", "bigint", "fraction", "bignumber", "string", "format"]
}, E8e = {
  name: "oct",
  category: "Utils",
  syntax: ["oct(value)"],
  description: "Format a number as octal",
  examples: ["oct(56)"],
  seealso: ["bin", "hex"]
}, D8e = {
  name: "print",
  category: "Utils",
  syntax: ["print(template, values)", "print(template, values, precision)"],
  description: "Interpolate values into a string template.",
  examples: ['print("Lucy is $age years old", {age: 5})', 'print("The value of pi is $pi", {pi: pi}, 3)', 'print("Hello, $user.name!", {user: {name: "John"}})', 'print("Values: $1, $2, $3", [6, 9, 4])'],
  seealso: ["format"]
}, M8e = {
  name: "typeOf",
  category: "Utils",
  syntax: ["typeOf(x)"],
  description: "Get the type of a variable.",
  examples: ["typeOf(3.5)", "typeOf(2 - 4i)", "typeOf(45 deg)", 'typeOf("hello world")'],
  seealso: ["getMatrixDataType"]
}, I8e = {
  name: "solveODE",
  category: "Numeric",
  syntax: ["solveODE(func, tspan, y0)", "solveODE(func, tspan, y0, options)"],
  description: "Numerical Integration of Ordinary Differential Equations.",
  examples: ["f(t,y) = y", "tspan = [0, 4]", "solveODE(f, tspan, 1)", "solveODE(f, tspan, [1, 2])", 'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],
  seealso: ["derivative", "simplifyCore"]
}, T8e = {
  // construction functions
  bignumber: bxe,
  bigint: xxe,
  boolean: _xe,
  complex: Sxe,
  createUnit: Axe,
  fraction: wxe,
  index: Cxe,
  matrix: Exe,
  number: Dxe,
  sparse: Mxe,
  splitUnit: Ixe,
  string: Txe,
  unit: Nxe,
  // constants
  e: uB,
  E: uB,
  false: axe,
  i: ixe,
  Infinity: oxe,
  LN2: uxe,
  LN10: sxe,
  LOG2E: lxe,
  LOG10E: cxe,
  NaN: dxe,
  null: fxe,
  pi: cB,
  PI: cB,
  phi: mxe,
  SQRT1_2: pxe,
  SQRT2: hxe,
  tau: vxe,
  true: gxe,
  version: yxe,
  // physical constants
  // TODO: more detailed docs for physical constants
  speedOfLight: {
    description: "Speed of light in vacuum",
    examples: ["speedOfLight"]
  },
  gravitationConstant: {
    description: "Newtonian constant of gravitation",
    examples: ["gravitationConstant"]
  },
  planckConstant: {
    description: "Planck constant",
    examples: ["planckConstant"]
  },
  reducedPlanckConstant: {
    description: "Reduced Planck constant",
    examples: ["reducedPlanckConstant"]
  },
  magneticConstant: {
    description: "Magnetic constant (vacuum permeability)",
    examples: ["magneticConstant"]
  },
  electricConstant: {
    description: "Electric constant (vacuum permeability)",
    examples: ["electricConstant"]
  },
  vacuumImpedance: {
    description: "Characteristic impedance of vacuum",
    examples: ["vacuumImpedance"]
  },
  coulomb: {
    description: "Coulomb's constant",
    examples: ["coulomb"]
  },
  elementaryCharge: {
    description: "Elementary charge",
    examples: ["elementaryCharge"]
  },
  bohrMagneton: {
    description: "Borh magneton",
    examples: ["bohrMagneton"]
  },
  conductanceQuantum: {
    description: "Conductance quantum",
    examples: ["conductanceQuantum"]
  },
  inverseConductanceQuantum: {
    description: "Inverse conductance quantum",
    examples: ["inverseConductanceQuantum"]
  },
  // josephson: {description: 'Josephson constant', examples: ['josephson']},
  magneticFluxQuantum: {
    description: "Magnetic flux quantum",
    examples: ["magneticFluxQuantum"]
  },
  nuclearMagneton: {
    description: "Nuclear magneton",
    examples: ["nuclearMagneton"]
  },
  klitzing: {
    description: "Von Klitzing constant",
    examples: ["klitzing"]
  },
  bohrRadius: {
    description: "Borh radius",
    examples: ["bohrRadius"]
  },
  classicalElectronRadius: {
    description: "Classical electron radius",
    examples: ["classicalElectronRadius"]
  },
  electronMass: {
    description: "Electron mass",
    examples: ["electronMass"]
  },
  fermiCoupling: {
    description: "Fermi coupling constant",
    examples: ["fermiCoupling"]
  },
  fineStructure: {
    description: "Fine-structure constant",
    examples: ["fineStructure"]
  },
  hartreeEnergy: {
    description: "Hartree energy",
    examples: ["hartreeEnergy"]
  },
  protonMass: {
    description: "Proton mass",
    examples: ["protonMass"]
  },
  deuteronMass: {
    description: "Deuteron Mass",
    examples: ["deuteronMass"]
  },
  neutronMass: {
    description: "Neutron mass",
    examples: ["neutronMass"]
  },
  quantumOfCirculation: {
    description: "Quantum of circulation",
    examples: ["quantumOfCirculation"]
  },
  rydberg: {
    description: "Rydberg constant",
    examples: ["rydberg"]
  },
  thomsonCrossSection: {
    description: "Thomson cross section",
    examples: ["thomsonCrossSection"]
  },
  weakMixingAngle: {
    description: "Weak mixing angle",
    examples: ["weakMixingAngle"]
  },
  efimovFactor: {
    description: "Efimov factor",
    examples: ["efimovFactor"]
  },
  atomicMass: {
    description: "Atomic mass constant",
    examples: ["atomicMass"]
  },
  avogadro: {
    description: "Avogadro's number",
    examples: ["avogadro"]
  },
  boltzmann: {
    description: "Boltzmann constant",
    examples: ["boltzmann"]
  },
  faraday: {
    description: "Faraday constant",
    examples: ["faraday"]
  },
  firstRadiation: {
    description: "First radiation constant",
    examples: ["firstRadiation"]
  },
  loschmidt: {
    description: "Loschmidt constant at T=273.15 K and p=101.325 kPa",
    examples: ["loschmidt"]
  },
  gasConstant: {
    description: "Gas constant",
    examples: ["gasConstant"]
  },
  molarPlanckConstant: {
    description: "Molar Planck constant",
    examples: ["molarPlanckConstant"]
  },
  molarVolume: {
    description: "Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",
    examples: ["molarVolume"]
  },
  sackurTetrode: {
    description: "Sackur-Tetrode constant at T=1 K and p=101.325 kPa",
    examples: ["sackurTetrode"]
  },
  secondRadiation: {
    description: "Second radiation constant",
    examples: ["secondRadiation"]
  },
  stefanBoltzmann: {
    description: "Stefan-Boltzmann constant",
    examples: ["stefanBoltzmann"]
  },
  wienDisplacement: {
    description: "Wien displacement law constant",
    examples: ["wienDisplacement"]
  },
  // spectralRadiance: {description: 'First radiation constant for spectral radiance', examples: ['spectralRadiance']},
  molarMass: {
    description: "Molar mass constant",
    examples: ["molarMass"]
  },
  molarMassC12: {
    description: "Molar mass constant of carbon-12",
    examples: ["molarMassC12"]
  },
  gravity: {
    description: "Standard acceleration of gravity (standard acceleration of free-fall on Earth)",
    examples: ["gravity"]
  },
  planckLength: {
    description: "Planck length",
    examples: ["planckLength"]
  },
  planckMass: {
    description: "Planck mass",
    examples: ["planckMass"]
  },
  planckTime: {
    description: "Planck time",
    examples: ["planckTime"]
  },
  planckCharge: {
    description: "Planck charge",
    examples: ["planckCharge"]
  },
  planckTemperature: {
    description: "Planck temperature",
    examples: ["planckTemperature"]
  },
  // functions - algebra
  derivative: Fxe,
  lsolve: Lxe,
  lsolveAll: kxe,
  lup: zxe,
  lusolve: Uxe,
  leafCount: Rxe,
  polynomialRoot: Gxe,
  resolve: Hxe,
  simplify: Kxe,
  simplifyConstant: Xxe,
  simplifyCore: jxe,
  symbolicEqual: Wxe,
  rationalize: qxe,
  slu: Yxe,
  usolve: Zxe,
  usolveAll: Qxe,
  qr: Vxe,
  // functions - arithmetic
  abs: $xe,
  add: Jxe,
  cbrt: e5e,
  ceil: t5e,
  cube: r5e,
  divide: n5e,
  dotDivide: a5e,
  dotMultiply: i5e,
  dotPow: o5e,
  exp: s5e,
  expm: u5e,
  expm1: c5e,
  fix: l5e,
  floor: d5e,
  gcd: f5e,
  hypot: m5e,
  lcm: h5e,
  log: v5e,
  log2: b5e,
  log1p: y5e,
  log10: g5e,
  mod: x5e,
  multiply: _5e,
  norm: S5e,
  nthRoot: A5e,
  nthRoots: w5e,
  pow: C5e,
  round: E5e,
  sign: D5e,
  sqrt: M5e,
  sqrtm: I5e,
  square: B5e,
  subtract: O5e,
  unaryMinus: F5e,
  unaryPlus: R5e,
  xgcd: L5e,
  invmod: p5e,
  // functions - bitwise
  bitAnd: k5e,
  bitNot: z5e,
  bitOr: U5e,
  bitXor: G5e,
  leftShift: V5e,
  rightArithShift: q5e,
  rightLogShift: H5e,
  // functions - combinatorics
  bellNumbers: K5e,
  catalan: X5e,
  composition: j5e,
  stirlingS2: Y5e,
  // functions - core
  config: Pxe,
  import: Bxe,
  typed: Oxe,
  // functions - complex
  arg: W5e,
  conj: Z5e,
  re: $5e,
  im: Q5e,
  // functions - expression
  evaluate: J5e,
  help: e6e,
  // functions - geometry
  distance: t6e,
  intersect: r6e,
  // functions - logical
  and: n6e,
  not: a6e,
  or: i6e,
  xor: o6e,
  // functions - matrix
  concat: u6e,
  count: c6e,
  cross: l6e,
  column: s6e,
  ctranspose: d6e,
  det: f6e,
  diag: m6e,
  diff: p6e,
  dot: h6e,
  getMatrixDataType: x6e,
  identity: _6e,
  filter: g6e,
  flatten: y6e,
  forEach: b6e,
  inv: S6e,
  pinv: A6e,
  eigs: v6e,
  kron: w6e,
  matrixFromFunction: D6e,
  matrixFromRows: M6e,
  matrixFromColumns: E6e,
  map: C6e,
  ones: I6e,
  partitionSelect: T6e,
  range: N6e,
  resize: B6e,
  reshape: P6e,
  rotate: O6e,
  rotationMatrix: F6e,
  row: R6e,
  size: L6e,
  sort: k6e,
  squeeze: z6e,
  subset: U6e,
  trace: G6e,
  transpose: V6e,
  zeros: q6e,
  fft: H6e,
  ifft: K6e,
  sylvester: T5e,
  schur: N5e,
  lyap: P5e,
  // functions - numeric
  solveODE: I8e,
  // functions - probability
  combinations: X6e,
  combinationsWithRep: j6e,
  // distribution: distributionDocs,
  factorial: Y6e,
  gamma: W6e,
  kldivergence: Q6e,
  lgamma: Z6e,
  multinomial: $6e,
  permutations: J6e,
  pickRandom: e_e,
  random: t_e,
  randomInt: r_e,
  // functions - relational
  compare: n_e,
  compareNatural: a_e,
  compareText: i_e,
  deepEqual: o_e,
  equal: s_e,
  equalText: u_e,
  larger: c_e,
  largerEq: l_e,
  smaller: d_e,
  smallerEq: f_e,
  unequal: m_e,
  // functions - set
  setCartesian: p_e,
  setDifference: h_e,
  setDistinct: v_e,
  setIntersect: g_e,
  setIsSubset: y_e,
  setMultiplicity: b_e,
  setPowerset: x_e,
  setSize: __e,
  setSymDifference: S_e,
  setUnion: A_e,
  // functions - signal
  zpk2tf: w_e,
  freqz: C_e,
  // functions - special
  erf: E_e,
  zeta: D_e,
  // functions - statistics
  cumsum: L_e,
  mad: M_e,
  max: I_e,
  mean: T_e,
  median: N_e,
  min: P_e,
  mode: B_e,
  prod: O_e,
  quantileSeq: F_e,
  std: R_e,
  sum: k_e,
  variance: z_e,
  corr: U_e,
  // functions - trigonometry
  acos: G_e,
  acosh: V_e,
  acot: q_e,
  acoth: H_e,
  acsc: K_e,
  acsch: X_e,
  asec: j_e,
  asech: Y_e,
  asin: W_e,
  asinh: Z_e,
  atan: Q_e,
  atanh: J_e,
  atan2: $_e,
  cos: e8e,
  cosh: t8e,
  cot: r8e,
  coth: n8e,
  csc: a8e,
  csch: i8e,
  sec: o8e,
  sech: s8e,
  sin: u8e,
  sinh: c8e,
  tan: l8e,
  tanh: d8e,
  // functions - units
  to: f8e,
  // functions - utils
  clone: p8e,
  format: h8e,
  bin: m8e,
  oct: E8e,
  hex: g8e,
  isNaN: b8e,
  isInteger: y8e,
  isNegative: x8e,
  isNumeric: _8e,
  hasNumericValue: v8e,
  isPositive: S8e,
  isPrime: A8e,
  isZero: w8e,
  print: D8e,
  typeOf: M8e,
  numeric: C8e
}, lB = "help", N8e = ["typed", "mathWithTransform", "Help"], P8e = /* @__PURE__ */ me(lB, N8e, (e) => {
  var {
    typed: t,
    mathWithTransform: r,
    Help: n
  } = e;
  return t(lB, {
    any: function(i) {
      var o, s = i;
      if (typeof i != "string") {
        for (o in r)
          if (Tt(r, o) && i === r[o]) {
            s = o;
            break;
          }
      }
      var u = yo(T8e, s);
      if (!u) {
        var c = typeof s == "function" ? s.name : s;
        throw new Error('No documentation found on "' + c + '"');
      }
      return new n(u);
    }
  });
}), dB = "chain", B8e = ["typed", "Chain"], O8e = /* @__PURE__ */ me(dB, B8e, (e) => {
  var {
    typed: t,
    Chain: r
  } = e;
  return t(dB, {
    "": function() {
      return new r();
    },
    any: function(a) {
      return new r(a);
    }
  });
}), fB = "det", F8e = ["typed", "matrix", "subtractScalar", "multiply", "divideScalar", "isZero", "unaryMinus"], cq = /* @__PURE__ */ me(fB, F8e, (e) => {
  var {
    typed: t,
    matrix: r,
    subtractScalar: n,
    multiply: a,
    divideScalar: i,
    isZero: o,
    unaryMinus: s
  } = e;
  return t(fB, {
    any: function(l) {
      return Jt(l);
    },
    "Array | Matrix": function(l) {
      var d;
      switch (Zt(l) ? d = l.size() : Array.isArray(l) ? (l = r(l), d = l.size()) : d = [], d.length) {
        case 0:
          return Jt(l);
        case 1:
          if (d[0] === 1)
            return Jt(l.valueOf()[0]);
          if (d[0] === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + Br(d) + ")");
        case 2: {
          var f = d[0], m = d[1];
          if (f === m)
            return u(l.clone().valueOf(), f);
          if (m === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + Br(d) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + Br(d) + ")");
      }
    }
  });
  function u(c, l, d) {
    if (l === 1)
      return Jt(c[0][0]);
    if (l === 2)
      return n(a(c[0][0], c[1][1]), a(c[1][0], c[0][1]));
    for (var f = !1, m = new Array(l).fill(0).map((A, w) => w), h = 0; h < l; h++) {
      var p = m[h];
      if (o(c[p][h])) {
        var g = void 0;
        for (g = h + 1; g < l; g++)
          if (!o(c[m[g]][h])) {
            p = m[g], m[g] = m[h], m[h] = p, f = !f;
            break;
          }
        if (g === l) return c[p][h];
      }
      for (var v = c[p][h], y = h === 0 ? 1 : c[m[h - 1]][h - 1], _ = h + 1; _ < l; _++)
        for (var S = m[_], b = h + 1; b < l; b++)
          c[S][b] = i(n(a(c[S][b], v), a(c[S][h], c[p][b])), y);
    }
    var x = c[m[l - 1]][l - 1];
    return f ? s(x) : x;
  }
}), mB = "inv", R8e = ["typed", "matrix", "divideScalar", "addScalar", "multiply", "unaryMinus", "det", "identity", "abs"], lq = /* @__PURE__ */ me(mB, R8e, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    addScalar: a,
    multiply: i,
    unaryMinus: o,
    det: s,
    identity: u,
    abs: c
  } = e;
  return t(mB, {
    "Array | Matrix": function(f) {
      var m = Zt(f) ? f.size() : Sr(f);
      switch (m.length) {
        case 1:
          if (m[0] === 1)
            return Zt(f) ? r([n(1, f.valueOf()[0])]) : [n(1, f[0])];
          throw new RangeError("Matrix must be square (size: " + Br(m) + ")");
        case 2: {
          var h = m[0], p = m[1];
          if (h === p)
            return Zt(f) ? r(l(f.valueOf(), h, p), f.storage()) : l(f, h, p);
          throw new RangeError("Matrix must be square (size: " + Br(m) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + Br(m) + ")");
      }
    },
    any: function(f) {
      return n(1, f);
    }
  });
  function l(d, f, m) {
    var h, p, g, v, y;
    if (f === 1) {
      if (v = d[0][0], v === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(1, v)]];
    } else if (f === 2) {
      var _ = s(d);
      if (_ === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(d[1][1], _), n(o(d[0][1]), _)], [n(o(d[1][0]), _), n(d[0][0], _)]];
    } else {
      var S = d.concat();
      for (h = 0; h < f; h++)
        S[h] = S[h].concat();
      for (var b = u(f).valueOf(), x = 0; x < m; x++) {
        var A = c(S[x][x]), w = x;
        for (h = x + 1; h < f; )
          c(S[h][x]) > A && (A = c(S[h][x]), w = h), h++;
        if (A === 0)
          throw Error("Cannot calculate inverse, determinant is zero");
        h = w, h !== x && (y = S[x], S[x] = S[h], S[h] = y, y = b[x], b[x] = b[h], b[h] = y);
        var C = S[x], M = b[x];
        for (h = 0; h < f; h++) {
          var T = S[h], N = b[h];
          if (h !== x) {
            if (T[x] !== 0) {
              for (g = n(o(T[x]), C[x]), p = x; p < m; p++)
                T[p] = a(T[p], i(g, C[p]));
              for (p = 0; p < m; p++)
                N[p] = a(N[p], i(g, M[p]));
            }
          } else {
            for (g = C[x], p = x; p < m; p++)
              T[p] = n(T[p], g);
            for (p = 0; p < m; p++)
              N[p] = n(N[p], g);
          }
        }
      }
      return b;
    }
  }
}), pB = "pinv", L8e = ["typed", "matrix", "inv", "deepEqual", "equal", "dotDivide", "dot", "ctranspose", "divideScalar", "multiply", "add", "Complex"], k8e = /* @__PURE__ */ me(pB, L8e, (e) => {
  var {
    typed: t,
    matrix: r,
    inv: n,
    deepEqual: a,
    equal: i,
    dotDivide: o,
    dot: s,
    ctranspose: u,
    divideScalar: c,
    multiply: l,
    add: d,
    Complex: f
  } = e;
  return t(pB, {
    "Array | Matrix": function(_) {
      var S = Zt(_) ? _.size() : Sr(_);
      switch (S.length) {
        case 1:
          return v(_) ? u(_) : S[0] === 1 ? n(_) : o(u(_), s(_, _));
        case 2: {
          if (v(_)) return u(_);
          var b = S[0], x = S[1];
          if (b === x)
            try {
              return n(_);
            } catch (A) {
              if (!(A instanceof Error && A.message.match(/Cannot calculate inverse, determinant is zero/))) throw A;
            }
          return Zt(_) ? r(m(_.valueOf(), b, x), _.storage()) : m(_, b, x);
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + Br(S) + ")");
      }
    },
    any: function(_) {
      return i(_, 0) ? Jt(_) : c(1, _);
    }
  });
  function m(y, _, S) {
    var {
      C: b,
      F: x
    } = p(y, _, S), A = l(n(l(u(b), b)), u(b)), w = l(u(x), n(l(x, u(x))));
    return l(w, A);
  }
  function h(y, _, S) {
    for (var b = Jt(y), x = 0, A = 0; A < _; A++) {
      if (S <= x)
        return b;
      for (var w = A; g(b[w][x]); )
        if (w++, _ === w && (w = A, x++, S === x))
          return b;
      [b[w], b[A]] = [b[A], b[w]];
      for (var C = b[A][x], M = 0; M < S; M++)
        b[A][M] = o(b[A][M], C);
      for (var T = 0; T < _; T++)
        if (T !== A) {
          C = b[T][x];
          for (var N = 0; N < S; N++)
            b[T][N] = d(b[T][N], l(-1, l(C, b[A][N])));
        }
      x++;
    }
    return b;
  }
  function p(y, _, S) {
    var b = h(y, _, S), x = y.map((w, C) => w.filter((M, T) => T < _ && !g(s(b[T], b[T])))), A = b.filter((w, C) => !g(s(b[C], b[C])));
    return {
      C: x,
      F: A
    };
  }
  function g(y) {
    return i(d(y, f(1, 1)), d(0, f(1, 1)));
  }
  function v(y) {
    return a(d(y, f(1, 1)), d(l(y, 0), f(1, 1)));
  }
});
function z8e(e) {
  var {
    addScalar: t,
    subtract: r,
    flatten: n,
    multiply: a,
    multiplyScalar: i,
    divideScalar: o,
    sqrt: s,
    abs: u,
    bignumber: c,
    diag: l,
    size: d,
    reshape: f,
    inv: m,
    qr: h,
    usolve: p,
    usolveAll: g,
    equal: v,
    complex: y,
    larger: _,
    smaller: S,
    matrixFromColumns: b,
    dot: x
  } = e;
  function A(X, H, W, ee) {
    var $ = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, te = w(X, H, W, ee, $);
    C(X, H, W, ee, $, te);
    var {
      values: re,
      C: ie
    } = M(X, H, W, ee, $);
    if ($) {
      var oe = T(X, H, ie, te, re, W, ee);
      return {
        values: re,
        eigenvectors: oe
      };
    }
    return {
      values: re
    };
  }
  function w(X, H, W, ee, $) {
    var te = ee === "BigNumber", re = ee === "Complex", ie = te ? c(0) : 0, oe = te ? c(1) : re ? y(1) : 1, se = te ? c(1) : 1, he = te ? c(10) : 2, ge = i(he, he), De;
    $ && (De = Array(H).fill(oe));
    for (var ae = !1; !ae; ) {
      ae = !0;
      for (var ce = 0; ce < H; ce++) {
        for (var _e = ie, le = ie, ue = 0; ue < H; ue++)
          ce !== ue && (_e = t(_e, u(X[ue][ce])), le = t(le, u(X[ce][ue])));
        if (!v(_e, 0) && !v(le, 0)) {
          for (var be = se, Se = _e, Ne = o(le, he), J = i(le, he); S(Se, Ne); )
            Se = i(Se, ge), be = i(be, he);
          for (; _(Se, J); )
            Se = o(Se, ge), be = o(be, he);
          var Z = S(o(t(Se, le), be), i(t(_e, le), 0.95));
          if (Z) {
            ae = !1;
            for (var de = o(1, be), ye = 0; ye < H; ye++)
              ce !== ye && (X[ce][ye] = i(X[ce][ye], de), X[ye][ce] = i(X[ye][ce], be));
            $ && (De[ce] = i(De[ce], de));
          }
        }
      }
    }
    return $ ? l(De) : null;
  }
  function C(X, H, W, ee, $, te) {
    var re = ee === "BigNumber", ie = ee === "Complex", oe = re ? c(0) : ie ? y(0) : 0;
    re && (W = c(W));
    for (var se = 0; se < H - 2; se++) {
      for (var he = 0, ge = oe, De = se + 1; De < H; De++) {
        var ae = X[De][se];
        S(u(ge), u(ae)) && (ge = ae, he = De);
      }
      if (!S(u(ge), W)) {
        if (he !== se + 1) {
          var ce = X[he];
          X[he] = X[se + 1], X[se + 1] = ce;
          for (var _e = 0; _e < H; _e++) {
            var le = X[_e][he];
            X[_e][he] = X[_e][se + 1], X[_e][se + 1] = le;
          }
          if ($) {
            var ue = te[he];
            te[he] = te[se + 1], te[se + 1] = ue;
          }
        }
        for (var be = se + 2; be < H; be++) {
          var Se = o(X[be][se], ge);
          if (Se !== 0) {
            for (var Ne = 0; Ne < H; Ne++)
              X[be][Ne] = r(X[be][Ne], i(Se, X[se + 1][Ne]));
            for (var J = 0; J < H; J++)
              X[J][se + 1] = t(X[J][se + 1], i(Se, X[J][be]));
            if ($)
              for (var Z = 0; Z < H; Z++)
                te[be][Z] = r(te[be][Z], i(Se, te[se + 1][Z]));
          }
        }
      }
    }
    return te;
  }
  function M(X, H, W, ee, $) {
    var te = ee === "BigNumber", re = ee === "Complex", ie = te ? c(1) : re ? y(1) : 1;
    te && (W = c(W));
    for (var oe = Jt(X), se = [], he = H, ge = [], De = $ ? l(Array(H).fill(ie)) : void 0, ae = $ ? l(Array(he).fill(ie)) : void 0, ce = 0; ce <= 100; ) {
      ce += 1;
      for (var _e = oe[he - 1][he - 1], le = 0; le < he; le++)
        oe[le][le] = r(oe[le][le], _e);
      var {
        Q: ue,
        R: be
      } = h(oe);
      oe = a(be, ue);
      for (var Se = 0; Se < he; Se++)
        oe[Se][Se] = t(oe[Se][Se], _e);
      if ($ && (ae = a(ae, ue)), he === 1 || S(u(oe[he - 1][he - 2]), W)) {
        ce = 0, se.push(oe[he - 1][he - 1]), $ && (ge.unshift([[1]]), P(ae, H), De = a(De, ae), he > 1 && (ae = l(Array(he - 1).fill(ie)))), he -= 1, oe.pop();
        for (var Ne = 0; Ne < he; Ne++)
          oe[Ne].pop();
      } else if (he === 2 || S(u(oe[he - 2][he - 3]), W)) {
        ce = 0;
        var J = N(oe[he - 2][he - 2], oe[he - 2][he - 1], oe[he - 1][he - 2], oe[he - 1][he - 1]);
        se.push(...J), $ && (ge.unshift(I(oe[he - 2][he - 2], oe[he - 2][he - 1], oe[he - 1][he - 2], oe[he - 1][he - 1], J[0], J[1], W, ee)), P(ae, H), De = a(De, ae), he > 2 && (ae = l(Array(he - 2).fill(ie)))), he -= 2, oe.pop(), oe.pop();
        for (var Z = 0; Z < he; Z++)
          oe[Z].pop(), oe[Z].pop();
      }
      if (he === 0)
        break;
    }
    if (se.sort((Ae, Ce) => +r(u(Ae), u(Ce))), ce > 100) {
      var de = Error("The eigenvalues failed to converge. Only found these eigenvalues: " + se.join(", "));
      throw de.values = se, de.vectors = [], de;
    }
    var ye = $ ? a(De, O(ge, H)) : void 0;
    return {
      values: se,
      C: ye
    };
  }
  function T(X, H, W, ee, $, te, re) {
    var ie = m(W), oe = a(ie, X, W), se = re === "BigNumber", he = re === "Complex", ge = se ? c(0) : he ? y(0) : 0, De = se ? c(1) : he ? y(1) : 1, ae = [], ce = [];
    for (var _e of $) {
      var le = F(ae, _e, v);
      le === -1 ? (ae.push(_e), ce.push(1)) : ce[le] += 1;
    }
    for (var ue = [], be = ae.length, Se = Array(H).fill(ge), Ne = l(Array(H).fill(De)), J = function() {
      var ye = ae[Z], Ae = r(oe, a(ye, Ne)), Ce = g(Ae, Se);
      for (Ce.shift(); Ce.length < ce[Z]; ) {
        var Ie = R(Ae, H, Ce, te, re);
        if (Ie === null)
          break;
        Ce.push(Ie);
      }
      var Ue = a(m(ee), W);
      Ce = Ce.map((Xe) => a(Ue, Xe)), ue.push(...Ce.map((Xe) => ({
        value: ye,
        vector: n(Xe)
      })));
    }, Z = 0; Z < be; Z++)
      J();
    return ue;
  }
  function N(X, H, W, ee) {
    var $ = t(X, ee), te = r(i(X, ee), i(H, W)), re = i($, 0.5), ie = i(s(r(i($, $), i(4, te))), 0.5);
    return [t(re, ie), r(re, ie)];
  }
  function I(X, H, W, ee, $, te, re, ie) {
    var oe = ie === "BigNumber", se = ie === "Complex", he = oe ? c(0) : se ? y(0) : 0, ge = oe ? c(1) : se ? y(1) : 1;
    if (S(u(W), re))
      return [[ge, he], [he, ge]];
    if (_(u(r($, te)), re))
      return [[r($, ee), r(te, ee)], [W, W]];
    var De = r(X, $), ae = r(ee, $);
    return S(u(H), re) && S(u(ae), re) ? [[De, ge], [W, he]] : [[H, he], [ae, ge]];
  }
  function P(X, H) {
    for (var W = 0; W < X.length; W++)
      X[W].push(...Array(H - X[W].length).fill(0));
    for (var ee = X.length; ee < H; ee++)
      X.push(Array(H).fill(0)), X[ee][ee] = 1;
    return X;
  }
  function O(X, H) {
    for (var W = [], ee = 0; ee < H; ee++)
      W[ee] = Array(H).fill(0);
    var $ = 0;
    for (var te of X) {
      for (var re = te.length, ie = 0; ie < re; ie++)
        for (var oe = 0; oe < re; oe++)
          W[$ + ie][$ + oe] = te[ie][oe];
      $ += re;
    }
    return W;
  }
  function F(X, H, W) {
    for (var ee = 0; ee < X.length; ee++)
      if (W(X[ee], H))
        return ee;
    return -1;
  }
  function R(X, H, W, ee, $) {
    for (var te = $ === "BigNumber" ? c(1e3) : 1e3, re, ie = 0; ie < 5; ++ie) {
      re = G(H, W, $);
      try {
        re = p(X, re);
      } catch {
        continue;
      }
      if (_(q(re), te))
        break;
    }
    if (ie >= 5)
      return null;
    for (ie = 0; ; ) {
      var oe = p(X, re);
      if (S(q(L(re, [oe])), ee))
        break;
      if (++ie >= 10)
        return null;
      re = K(oe);
    }
    return re;
  }
  function G(X, H, W) {
    var ee = W === "BigNumber", $ = W === "Complex", te = Array(X).fill(0).map((re) => 2 * Math.random() - 1);
    return ee && (te = te.map((re) => c(re))), $ && (te = te.map((re) => y(re))), te = L(te, H), K(te, W);
  }
  function L(X, H) {
    var W = d(X);
    for (var ee of H)
      ee = f(ee, W), X = r(X, a(o(x(ee, X), x(ee, ee)), ee));
    return X;
  }
  function q(X) {
    return u(s(x(X, X)));
  }
  function K(X, H) {
    var W = H === "BigNumber", ee = H === "Complex", $ = W ? c(1) : ee ? y(1) : 1;
    return a(o($, q(X)), X);
  }
  return A;
}
function U8e(e) {
  var {
    config: t,
    addScalar: r,
    subtract: n,
    abs: a,
    atan: i,
    cos: o,
    sin: s,
    multiplyScalar: u,
    inv: c,
    bignumber: l,
    multiply: d,
    add: f
  } = e;
  function m(C, M) {
    var T = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : t.relTol, N = arguments.length > 3 ? arguments[3] : void 0, I = arguments.length > 4 ? arguments[4] : void 0;
    if (N === "number")
      return h(C, T, I);
    if (N === "BigNumber")
      return p(C, T, I);
    throw TypeError("Unsupported data type: " + N);
  }
  function h(C, M, T) {
    var N = C.length, I = Math.abs(M / N), P, O;
    if (T) {
      O = new Array(N);
      for (var F = 0; F < N; F++)
        O[F] = Array(N).fill(0), O[F][F] = 1;
    }
    for (var R = x(C); Math.abs(R[1]) >= Math.abs(I); ) {
      var G = R[0][0], L = R[0][1];
      P = g(C[G][G], C[L][L], C[G][L]), C = b(C, P, G, L), T && (O = y(O, P, G, L)), R = x(C);
    }
    for (var q = Array(N).fill(0), K = 0; K < N; K++)
      q[K] = C[K][K];
    return w(Jt(q), O, T);
  }
  function p(C, M, T) {
    var N = C.length, I = a(M / N), P, O;
    if (T) {
      O = new Array(N);
      for (var F = 0; F < N; F++)
        O[F] = Array(N).fill(0), O[F][F] = 1;
    }
    for (var R = A(C); a(R[1]) >= a(I); ) {
      var G = R[0][0], L = R[0][1];
      P = v(C[G][G], C[L][L], C[G][L]), C = S(C, P, G, L), T && (O = _(O, P, G, L)), R = A(C);
    }
    for (var q = Array(N).fill(0), K = 0; K < N; K++)
      q[K] = C[K][K];
    return w(Jt(q), O, T);
  }
  function g(C, M, T) {
    var N = M - C;
    return Math.abs(N) <= t.relTol ? Math.PI / 4 : 0.5 * Math.atan(2 * T / (M - C));
  }
  function v(C, M, T) {
    var N = n(M, C);
    return a(N) <= t.relTol ? l(-1).acos().div(4) : u(0.5, i(d(2, T, c(N))));
  }
  function y(C, M, T, N) {
    for (var I = C.length, P = Math.cos(M), O = Math.sin(M), F = Array(I).fill(0), R = Array(I).fill(0), G = 0; G < I; G++)
      F[G] = P * C[G][T] - O * C[G][N], R[G] = O * C[G][T] + P * C[G][N];
    for (var L = 0; L < I; L++)
      C[L][T] = F[L], C[L][N] = R[L];
    return C;
  }
  function _(C, M, T, N) {
    for (var I = C.length, P = o(M), O = s(M), F = Array(I).fill(l(0)), R = Array(I).fill(l(0)), G = 0; G < I; G++)
      F[G] = n(u(P, C[G][T]), u(O, C[G][N])), R[G] = r(u(O, C[G][T]), u(P, C[G][N]));
    for (var L = 0; L < I; L++)
      C[L][T] = F[L], C[L][N] = R[L];
    return C;
  }
  function S(C, M, T, N) {
    for (var I = C.length, P = l(o(M)), O = l(s(M)), F = u(P, P), R = u(O, O), G = Array(I).fill(l(0)), L = Array(I).fill(l(0)), q = d(l(2), P, O, C[T][N]), K = r(n(u(F, C[T][T]), q), u(R, C[N][N])), X = f(u(R, C[T][T]), q, u(F, C[N][N])), H = 0; H < I; H++)
      G[H] = n(u(P, C[T][H]), u(O, C[N][H])), L[H] = r(u(O, C[T][H]), u(P, C[N][H]));
    C[T][T] = K, C[N][N] = X, C[T][N] = l(0), C[N][T] = l(0);
    for (var W = 0; W < I; W++)
      W !== T && W !== N && (C[T][W] = G[W], C[W][T] = G[W], C[N][W] = L[W], C[W][N] = L[W]);
    return C;
  }
  function b(C, M, T, N) {
    for (var I = C.length, P = Math.cos(M), O = Math.sin(M), F = P * P, R = O * O, G = Array(I).fill(0), L = Array(I).fill(0), q = F * C[T][T] - 2 * P * O * C[T][N] + R * C[N][N], K = R * C[T][T] + 2 * P * O * C[T][N] + F * C[N][N], X = 0; X < I; X++)
      G[X] = P * C[T][X] - O * C[N][X], L[X] = O * C[T][X] + P * C[N][X];
    C[T][T] = q, C[N][N] = K, C[T][N] = 0, C[N][T] = 0;
    for (var H = 0; H < I; H++)
      H !== T && H !== N && (C[T][H] = G[H], C[H][T] = G[H], C[N][H] = L[H], C[H][N] = L[H]);
    return C;
  }
  function x(C) {
    for (var M = C.length, T = 0, N = [0, 1], I = 0; I < M; I++)
      for (var P = I + 1; P < M; P++)
        Math.abs(T) < Math.abs(C[I][P]) && (T = Math.abs(C[I][P]), N = [I, P]);
    return [N, T];
  }
  function A(C) {
    for (var M = C.length, T = 0, N = [0, 1], I = 0; I < M; I++)
      for (var P = I + 1; P < M; P++)
        a(T) < a(C[I][P]) && (T = a(C[I][P]), N = [I, P]);
    return [N, T];
  }
  function w(C, M, T) {
    var N = C.length, I = Array(N), P;
    if (T) {
      P = Array(N);
      for (var O = 0; O < N; O++)
        P[O] = Array(N);
    }
    for (var F = 0; F < N; F++) {
      for (var R = 0, G = C[0], L = 0; L < C.length; L++)
        a(C[L]) < a(G) && (R = L, G = C[R]);
      if (I[F] = C.splice(R, 1)[0], T)
        for (var q = 0; q < N; q++)
          P[F][q] = M[q][R], M[q].splice(R, 1);
    }
    if (!T) return {
      values: I
    };
    var K = P.map((X, H) => ({
      value: I[H],
      vector: X
    }));
    return {
      values: I,
      eigenvectors: K
    };
  }
  return m;
}
var G8e = "eigs", V8e = ["config", "typed", "matrix", "addScalar", "equal", "subtract", "abs", "atan", "cos", "sin", "multiplyScalar", "divideScalar", "inv", "bignumber", "multiply", "add", "larger", "column", "flatten", "number", "complex", "sqrt", "diag", "size", "reshape", "qr", "usolve", "usolveAll", "im", "re", "smaller", "matrixFromColumns", "dot"], dq = /* @__PURE__ */ me(G8e, V8e, (e) => {
  var {
    config: t,
    typed: r,
    matrix: n,
    addScalar: a,
    subtract: i,
    equal: o,
    abs: s,
    atan: u,
    cos: c,
    sin: l,
    multiplyScalar: d,
    divideScalar: f,
    inv: m,
    bignumber: h,
    multiply: p,
    add: g,
    larger: v,
    column: y,
    flatten: _,
    number: S,
    complex: b,
    sqrt: x,
    diag: A,
    size: w,
    reshape: C,
    qr: M,
    usolve: T,
    usolveAll: N,
    im: I,
    re: P,
    smaller: O,
    matrixFromColumns: F,
    dot: R
  } = e, G = U8e({
    config: t,
    addScalar: a,
    subtract: i,
    column: y,
    flatten: _,
    equal: o,
    abs: s,
    atan: u,
    cos: c,
    sin: l,
    multiplyScalar: d,
    inv: m,
    bignumber: h,
    complex: b,
    multiply: p,
    add: g
  }), L = z8e({
    config: t,
    addScalar: a,
    subtract: i,
    multiply: p,
    multiplyScalar: d,
    flatten: _,
    divideScalar: f,
    sqrt: x,
    abs: s,
    bignumber: h,
    diag: A,
    size: w,
    reshape: C,
    qr: M,
    inv: m,
    usolve: T,
    usolveAll: N,
    equal: o,
    complex: b,
    larger: v,
    smaller: O,
    matrixFromColumns: F,
    dot: R
  });
  return r("eigs", {
    // The conversion to matrix in the first two implementations,
    // just to convert back to an array right away in
    // computeValuesAndVectors, is unfortunate, and should perhaps be
    // streamlined. It is done because the Matrix object carries some
    // type information about its entries, and so constructing the matrix
    // is a roundabout way of doing type detection.
    Array: function(te) {
      return q(n(te));
    },
    "Array, number|BigNumber": function(te, re) {
      return q(n(te), {
        precision: re
      });
    },
    "Array, Object"($, te) {
      return q(n($), te);
    },
    Matrix: function(te) {
      return q(te, {
        matricize: !0
      });
    },
    "Matrix, number|BigNumber": function(te, re) {
      return q(te, {
        precision: re,
        matricize: !0
      });
    },
    "Matrix, Object": function(te, re) {
      var ie = {
        matricize: !0
      };
      return Ei(ie, re), q(te, ie);
    }
  });
  function q($) {
    var te, re = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, ie = "eigenvectors" in re ? re.eigenvectors : !0, oe = (te = re.precision) !== null && te !== void 0 ? te : t.relTol, se = K($, oe, ie);
    return re.matricize && (se.values = n(se.values), ie && (se.eigenvectors = se.eigenvectors.map((he) => {
      var {
        value: ge,
        vector: De
      } = he;
      return {
        value: ge,
        vector: n(De)
      };
    }))), ie && Object.defineProperty(se, "vectors", {
      enumerable: !1,
      // to make sure that the eigenvectors can still be
      // converted to string.
      get: () => {
        throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors");
      }
    }), se;
  }
  function K($, te, re) {
    var ie = $.toArray(), oe = $.size();
    if (oe.length !== 2 || oe[0] !== oe[1])
      throw new RangeError("Matrix must be square (size: ".concat(Br(oe), ")"));
    var se = oe[0];
    if (H(ie, se, te) && (W(ie, se), X(ie, se, te))) {
      var he = ee($, ie, se);
      return G(ie, se, te, he, re);
    }
    var ge = ee($, ie, se);
    return L(ie, se, te, ge, re);
  }
  function X($, te, re) {
    for (var ie = 0; ie < te; ie++)
      for (var oe = ie; oe < te; oe++)
        if (v(h(s(i($[ie][oe], $[oe][ie]))), re))
          return !1;
    return !0;
  }
  function H($, te, re) {
    for (var ie = 0; ie < te; ie++)
      for (var oe = 0; oe < te; oe++)
        if (v(h(s(I($[ie][oe]))), re))
          return !1;
    return !0;
  }
  function W($, te) {
    for (var re = 0; re < te; re++)
      for (var ie = 0; ie < te; ie++)
        $[re][ie] = P($[re][ie]);
  }
  function ee($, te, re) {
    var ie = $.datatype();
    if (ie === "number" || ie === "BigNumber" || ie === "Complex")
      return ie;
    for (var oe = !1, se = !1, he = !1, ge = 0; ge < re; ge++)
      for (var De = 0; De < re; De++) {
        var ae = te[ge][De];
        if (_r(ae) || vm(ae))
          oe = !0;
        else if (hr(ae))
          se = !0;
        else if (Mu(ae))
          he = !0;
        else
          throw TypeError("Unsupported type in Matrix: " + Nn(ae));
      }
    if (se && he && console.warn("Complex BigNumbers not supported, this operation will lose precission."), he) {
      for (var ce = 0; ce < re; ce++)
        for (var _e = 0; _e < re; _e++)
          te[ce][_e] = b(te[ce][_e]);
      return "Complex";
    }
    if (se) {
      for (var le = 0; le < re; le++)
        for (var ue = 0; ue < re; ue++)
          te[le][ue] = h(te[le][ue]);
      return "BigNumber";
    }
    if (oe) {
      for (var be = 0; be < re; be++)
        for (var Se = 0; Se < re; Se++)
          te[be][Se] = S(te[be][Se]);
      return "number";
    } else
      throw TypeError("Matrix contains unsupported types only.");
  }
}), hB = "expm", q8e = ["typed", "abs", "add", "identity", "inv", "multiply"], H8e = /* @__PURE__ */ me(hB, q8e, (e) => {
  var {
    typed: t,
    abs: r,
    add: n,
    identity: a,
    inv: i,
    multiply: o
  } = e;
  return t(hB, {
    Matrix: function(d) {
      var f = d.size();
      if (f.length !== 2 || f[0] !== f[1])
        throw new RangeError("Matrix must be square (size: " + Br(f) + ")");
      for (var m = f[0], h = 1e-15, p = s(d), g = u(p, h), v = g.q, y = g.j, _ = o(d, Math.pow(2, -y)), S = a(m), b = a(m), x = 1, A = _, w = -1, C = 1; C <= v; C++)
        C > 1 && (A = o(A, _), w = -w), x = x * (v - C + 1) / ((2 * v - C + 1) * C), S = n(S, o(x, A)), b = n(b, o(x * w, A));
      for (var M = o(i(b), S), T = 0; T < y; T++)
        M = o(M, M);
      return Td(d) ? d.createSparseMatrix(M) : M;
    }
  });
  function s(l) {
    for (var d = l.size()[0], f = 0, m = 0; m < d; m++) {
      for (var h = 0, p = 0; p < d; p++)
        h += r(l.get([m, p]));
      f = Math.max(h, f);
    }
    return f;
  }
  function u(l, d) {
    for (var f = 30, m = 0; m < f; m++)
      for (var h = 0; h <= m; h++) {
        var p = m - h;
        if (c(l, h, p) < d)
          return {
            q: h,
            j: p
          };
      }
    throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)");
  }
  function c(l, d, f) {
    for (var m = 1, h = 2; h <= d; h++)
      m *= h;
    for (var p = m, g = d + 1; g <= 2 * d; g++)
      p *= g;
    var v = p * (2 * d + 1);
    return 8 * Math.pow(l / Math.pow(2, f), 2 * d) * m * m / (p * v);
  }
}), vB = "sqrtm", K8e = ["typed", "abs", "add", "multiply", "map", "sqrt", "subtract", "inv", "size", "max", "identity"], X8e = /* @__PURE__ */ me(vB, K8e, (e) => {
  var {
    typed: t,
    abs: r,
    add: n,
    multiply: a,
    map: i,
    sqrt: o,
    subtract: s,
    inv: u,
    size: c,
    max: l,
    identity: d
  } = e, f = 1e3, m = 1e-6;
  function h(p) {
    var g, v = 0, y = p, _ = d(c(p));
    do {
      var S = y;
      if (y = a(0.5, n(S, u(_))), _ = a(0.5, n(_, u(S))), g = l(r(s(y, S))), g > m && ++v > f)
        throw new Error("computing square root of matrix: iterative method could not converge");
    } while (g > m);
    return y;
  }
  return t(vB, {
    "Array | Matrix": function(g) {
      var v = Zt(g) ? g.size() : Sr(g);
      switch (v.length) {
        case 1:
          if (v[0] === 1)
            return i(g, o);
          throw new RangeError("Matrix must be square (size: " + Br(v) + ")");
        case 2: {
          var y = v[0], _ = v[1];
          if (y === _)
            return h(g);
          throw new RangeError("Matrix must be square (size: " + Br(v) + ")");
        }
        default:
          throw new RangeError("Matrix must be at most two dimensional (size: " + Br(v) + ")");
      }
    }
  });
}), gB = "sylvester", j8e = ["typed", "schur", "matrixFromColumns", "matrix", "multiply", "range", "concat", "transpose", "index", "subset", "add", "subtract", "identity", "lusolve", "abs"], Y8e = /* @__PURE__ */ me(gB, j8e, (e) => {
  var {
    typed: t,
    schur: r,
    matrixFromColumns: n,
    matrix: a,
    multiply: i,
    range: o,
    concat: s,
    transpose: u,
    index: c,
    subset: l,
    add: d,
    subtract: f,
    identity: m,
    lusolve: h,
    abs: p
  } = e;
  return t(gB, {
    "Matrix, Matrix, Matrix": g,
    "Array, Matrix, Matrix": function(y, _, S) {
      return g(a(y), _, S);
    },
    "Array, Array, Matrix": function(y, _, S) {
      return g(a(y), a(_), S);
    },
    "Array, Matrix, Array": function(y, _, S) {
      return g(a(y), _, a(S));
    },
    "Matrix, Array, Matrix": function(y, _, S) {
      return g(y, a(_), S);
    },
    "Matrix, Array, Array": function(y, _, S) {
      return g(y, a(_), a(S));
    },
    "Matrix, Matrix, Array": function(y, _, S) {
      return g(y, _, a(S));
    },
    "Array, Array, Array": function(y, _, S) {
      return g(a(y), a(_), a(S)).toArray();
    }
  });
  function g(v, y, _) {
    for (var S = y.size()[0], b = v.size()[0], x = r(v), A = x.T, w = x.U, C = r(i(-1, y)), M = C.T, T = C.U, N = i(i(u(w), _), T), I = o(0, b), P = [], O = (he, ge) => s(he, ge, 1), F = (he, ge) => s(he, ge, 0), R = 0; R < S; R++)
      if (R < S - 1 && p(l(M, c(R + 1, R))) > 1e-5) {
        for (var G = F(l(N, c(I, R)), l(N, c(I, R + 1))), L = 0; L < R; L++)
          G = d(G, F(i(P[L], l(M, c(L, R))), i(P[L], l(M, c(L, R + 1)))));
        var q = i(m(b), i(-1, l(M, c(R, R)))), K = i(m(b), i(-1, l(M, c(R + 1, R)))), X = i(m(b), i(-1, l(M, c(R, R + 1)))), H = i(m(b), i(-1, l(M, c(R + 1, R + 1)))), W = F(O(d(A, q), K), O(X, d(A, H))), ee = h(W, G);
        P[R] = ee.subset(c(o(0, b), 0)), P[R + 1] = ee.subset(c(o(b, 2 * b), 0)), R++;
      } else {
        for (var $ = l(N, c(I, R)), te = 0; te < R; te++)
          $ = d($, i(P[te], l(M, c(te, R))));
        var re = l(M, c(R, R)), ie = f(A, i(re, m(b)));
        P[R] = h(ie, $);
      }
    var oe = a(n(...P)), se = i(w, i(oe, u(T)));
    return se;
  }
}), yB = "schur", W8e = ["typed", "matrix", "identity", "multiply", "qr", "norm", "subtract"], Z8e = /* @__PURE__ */ me(yB, W8e, (e) => {
  var {
    typed: t,
    matrix: r,
    identity: n,
    multiply: a,
    qr: i,
    norm: o,
    subtract: s
  } = e;
  return t(yB, {
    Array: function(l) {
      var d = u(r(l));
      return {
        U: d.U.valueOf(),
        T: d.T.valueOf()
      };
    },
    Matrix: function(l) {
      return u(l);
    }
  });
  function u(c) {
    var l = c.size()[0], d = c, f = n(l), m = 0, h;
    do {
      h = d;
      var p = i(d), g = p.Q, v = p.R;
      if (d = a(v, g), f = a(f, g), m++ > 100)
        break;
    } while (o(s(d, h)) > 1e-4);
    return {
      U: f,
      T: d
    };
  }
}), bB = "lyap", Q8e = ["typed", "matrix", "sylvester", "multiply", "transpose"], $8e = /* @__PURE__ */ me(bB, Q8e, (e) => {
  var {
    typed: t,
    matrix: r,
    sylvester: n,
    multiply: a,
    transpose: i
  } = e;
  return t(bB, {
    "Matrix, Matrix": function(s, u) {
      return n(s, i(s), a(-1, u));
    },
    "Array, Matrix": function(s, u) {
      return n(r(s), i(r(s)), a(-1, u));
    },
    "Matrix, Array": function(s, u) {
      return n(s, i(r(s)), r(a(-1, u)));
    },
    "Array, Array": function(s, u) {
      return n(r(s), i(r(s)), r(a(-1, u))).toArray();
    }
  });
}), J8e = "divide", eSe = ["typed", "matrix", "multiply", "equalScalar", "divideScalar", "inv"], fq = /* @__PURE__ */ me(J8e, eSe, (e) => {
  var {
    typed: t,
    matrix: r,
    multiply: n,
    equalScalar: a,
    divideScalar: i,
    inv: o
  } = e, s = Ri({
    typed: t,
    equalScalar: a
  }), u = Fu({
    typed: t
  });
  return t("divide", uU({
    // we extend the signatures of divideScalar with signatures dealing with matrices
    "Array | Matrix, Array | Matrix": function(l, d) {
      return n(l, o(d));
    },
    "DenseMatrix, any": function(l, d) {
      return u(l, d, i, !1);
    },
    "SparseMatrix, any": function(l, d) {
      return s(l, d, i, !1);
    },
    "Array, any": function(l, d) {
      return u(r(l), d, i, !1).valueOf();
    },
    "any, Array | Matrix": function(l, d) {
      return n(l, o(d));
    }
  }, i.signatures));
}), xB = "distance", tSe = ["typed", "addScalar", "subtractScalar", "divideScalar", "multiplyScalar", "deepEqual", "sqrt", "abs"], rSe = /* @__PURE__ */ me(xB, tSe, (e) => {
  var {
    typed: t,
    addScalar: r,
    subtractScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    deepEqual: o,
    sqrt: s,
    abs: u
  } = e;
  return t(xB, {
    "Array, Array, Array": function(b, x, A) {
      if (b.length === 2 && x.length === 2 && A.length === 2) {
        if (!l(b))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
        if (!l(x))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
        if (!l(A))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
        if (o(x, A))
          throw new TypeError("LinePoint1 should not be same with LinePoint2");
        var w = n(A[1], x[1]), C = n(x[0], A[0]), M = n(a(A[0], x[1]), a(x[0], A[1]));
        return g(b[0], b[1], w, C, M);
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Object, Object, Object": function(b, x, A) {
      if (Object.keys(b).length === 2 && Object.keys(x).length === 2 && Object.keys(A).length === 2) {
        if (!l(b))
          throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
        if (!l(x))
          throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");
        if (!l(A))
          throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");
        if (o(h(x), h(A)))
          throw new TypeError("LinePoint1 should not be same with LinePoint2");
        if ("pointX" in b && "pointY" in b && "lineOnePtX" in x && "lineOnePtY" in x && "lineTwoPtX" in A && "lineTwoPtY" in A) {
          var w = n(A.lineTwoPtY, x.lineOnePtY), C = n(x.lineOnePtX, A.lineTwoPtX), M = n(a(A.lineTwoPtX, x.lineOnePtY), a(x.lineOnePtX, A.lineTwoPtY));
          return g(b.pointX, b.pointY, w, C, M);
        } else
          throw new TypeError("Key names do not match");
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Array, Array": function(b, x) {
      if (b.length === 2 && x.length === 3) {
        if (!l(b))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
        if (!d(x))
          throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
        return g(b[0], b[1], x[0], x[1], x[2]);
      } else if (b.length === 3 && x.length === 6) {
        if (!d(b))
          throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
        if (!m(x))
          throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");
        return v(b[0], b[1], b[2], x[0], x[1], x[2], x[3], x[4], x[5]);
      } else if (b.length === x.length && b.length > 0) {
        if (!f(b))
          throw new TypeError("All values of an array should be numbers or BigNumbers");
        if (!f(x))
          throw new TypeError("All values of an array should be numbers or BigNumbers");
        return y(b, x);
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Object, Object": function(b, x) {
      if (Object.keys(b).length === 2 && Object.keys(x).length === 3) {
        if (!l(b))
          throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
        if (!d(x))
          throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");
        if ("pointX" in b && "pointY" in b && "xCoeffLine" in x && "yCoeffLine" in x && "constant" in x)
          return g(b.pointX, b.pointY, x.xCoeffLine, x.yCoeffLine, x.constant);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(b).length === 3 && Object.keys(x).length === 6) {
        if (!d(b))
          throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");
        if (!m(x))
          throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");
        if ("pointX" in b && "pointY" in b && "x0" in x && "y0" in x && "z0" in x && "a" in x && "b" in x && "c" in x)
          return v(b.pointX, b.pointY, b.pointZ, x.x0, x.y0, x.z0, x.a, x.b, x.c);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(b).length === 2 && Object.keys(x).length === 2) {
        if (!l(b))
          throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");
        if (!l(x))
          throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");
        if ("pointOneX" in b && "pointOneY" in b && "pointTwoX" in x && "pointTwoY" in x)
          return y([b.pointOneX, b.pointOneY], [x.pointTwoX, x.pointTwoY]);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(b).length === 3 && Object.keys(x).length === 3) {
        if (!d(b))
          throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");
        if (!d(x))
          throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");
        if ("pointOneX" in b && "pointOneY" in b && "pointOneZ" in b && "pointTwoX" in x && "pointTwoY" in x && "pointTwoZ" in x)
          return y([b.pointOneX, b.pointOneY, b.pointOneZ], [x.pointTwoX, x.pointTwoY, x.pointTwoZ]);
        throw new TypeError("Key names do not match");
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    Array: function(b) {
      if (!p(b))
        throw new TypeError("Incorrect array format entered for pairwise distance calculation");
      return _(b);
    }
  });
  function c(S) {
    return typeof S == "number" || hr(S);
  }
  function l(S) {
    return S.constructor !== Array && (S = h(S)), c(S[0]) && c(S[1]);
  }
  function d(S) {
    return S.constructor !== Array && (S = h(S)), c(S[0]) && c(S[1]) && c(S[2]);
  }
  function f(S) {
    return Array.isArray(S) || (S = h(S)), S.every(c);
  }
  function m(S) {
    return S.constructor !== Array && (S = h(S)), c(S[0]) && c(S[1]) && c(S[2]) && c(S[3]) && c(S[4]) && c(S[5]);
  }
  function h(S) {
    for (var b = Object.keys(S), x = [], A = 0; A < b.length; A++)
      x.push(S[b[A]]);
    return x;
  }
  function p(S) {
    if (S[0].length === 2 && c(S[0][0]) && c(S[0][1])) {
      if (S.some((b) => b.length !== 2 || !c(b[0]) || !c(b[1])))
        return !1;
    } else if (S[0].length === 3 && c(S[0][0]) && c(S[0][1]) && c(S[0][2])) {
      if (S.some((b) => b.length !== 3 || !c(b[0]) || !c(b[1]) || !c(b[2])))
        return !1;
    } else
      return !1;
    return !0;
  }
  function g(S, b, x, A, w) {
    var C = u(r(r(a(x, S), a(A, b)), w)), M = s(r(a(x, x), a(A, A)));
    return i(C, M);
  }
  function v(S, b, x, A, w, C, M, T, N) {
    var I = [n(a(n(w, b), N), a(n(C, x), T)), n(a(n(C, x), M), a(n(A, S), N)), n(a(n(A, S), T), a(n(w, b), M))];
    I = s(r(r(a(I[0], I[0]), a(I[1], I[1])), a(I[2], I[2])));
    var P = s(r(r(a(M, M), a(T, T)), a(N, N)));
    return i(I, P);
  }
  function y(S, b) {
    for (var x = S.length, A = 0, w = 0, C = 0; C < x; C++)
      w = n(S[C], b[C]), A = r(a(w, w), A);
    return s(A);
  }
  function _(S) {
    for (var b = [], x = [], A = [], w = 0; w < S.length - 1; w++)
      for (var C = w + 1; C < S.length; C++)
        S[0].length === 2 ? (x = [S[w][0], S[w][1]], A = [S[C][0], S[C][1]]) : S[0].length === 3 && (x = [S[w][0], S[w][1], S[w][2]], A = [S[C][0], S[C][1], S[C][2]]), b.push(y(x, A));
    return b;
  }
}), nSe = "intersect", aSe = ["typed", "config", "abs", "add", "addScalar", "matrix", "multiply", "multiplyScalar", "divideScalar", "subtract", "smaller", "equalScalar", "flatten", "isZero", "isNumeric"], iSe = /* @__PURE__ */ me(nSe, aSe, (e) => {
  var {
    typed: t,
    config: r,
    abs: n,
    add: a,
    addScalar: i,
    matrix: o,
    multiply: s,
    multiplyScalar: u,
    divideScalar: c,
    subtract: l,
    smaller: d,
    equalScalar: f,
    flatten: m,
    isZero: h,
    isNumeric: p
  } = e;
  return t("intersect", {
    "Array, Array, Array": g,
    "Array, Array, Array, Array": v,
    "Matrix, Matrix, Matrix": function(T, N, I) {
      var P = g(T.valueOf(), N.valueOf(), I.valueOf());
      return P === null ? null : o(P);
    },
    "Matrix, Matrix, Matrix, Matrix": function(T, N, I, P) {
      var O = v(T.valueOf(), N.valueOf(), I.valueOf(), P.valueOf());
      return O === null ? null : o(O);
    }
  });
  function g(M, T, N) {
    if (M = y(M), T = y(T), N = y(N), !S(M))
      throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
    if (!S(T))
      throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
    if (!b(N))
      throw new TypeError("Array with 4 numbers expected as third argument");
    return C(M[0], M[1], M[2], T[0], T[1], T[2], N[0], N[1], N[2], N[3]);
  }
  function v(M, T, N, I) {
    if (M = y(M), T = y(T), N = y(N), I = y(I), M.length === 2) {
      if (!_(M))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
      if (!_(T))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
      if (!_(N))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
      if (!_(I))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");
      return x(M, T, N, I);
    } else if (M.length === 3) {
      if (!S(M))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
      if (!S(T))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
      if (!S(N))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");
      if (!S(I))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");
      return w(M[0], M[1], M[2], T[0], T[1], T[2], N[0], N[1], N[2], I[0], I[1], I[2]);
    } else
      throw new TypeError("Arrays with two or thee dimensional points expected");
  }
  function y(M) {
    return M.length === 1 ? M[0] : M.length > 1 && Array.isArray(M[0]) && M.every((T) => Array.isArray(T) && T.length === 1) ? m(M) : M;
  }
  function _(M) {
    return M.length === 2 && p(M[0]) && p(M[1]);
  }
  function S(M) {
    return M.length === 3 && p(M[0]) && p(M[1]) && p(M[2]);
  }
  function b(M) {
    return M.length === 4 && p(M[0]) && p(M[1]) && p(M[2]) && p(M[3]);
  }
  function x(M, T, N, I) {
    var P = M, O = N, F = l(P, T), R = l(O, I), G = l(u(F[0], R[1]), u(R[0], F[1]));
    if (h(G) || d(n(G), r.relTol))
      return null;
    var L = u(R[0], P[1]), q = u(R[1], P[0]), K = u(R[0], O[1]), X = u(R[1], O[0]), H = c(i(l(l(L, q), K), X), G);
    return a(s(F, H), P);
  }
  function A(M, T, N, I, P, O, F, R, G, L, q, K) {
    var X = u(l(M, T), l(N, I)), H = u(l(P, O), l(F, R)), W = u(l(G, L), l(q, K));
    return i(i(X, H), W);
  }
  function w(M, T, N, I, P, O, F, R, G, L, q, K) {
    var X = A(M, F, L, F, T, R, q, R, N, G, K, G), H = A(L, F, I, M, q, R, P, T, K, G, O, N), W = A(M, F, I, M, T, R, P, T, N, G, O, N), ee = A(L, F, L, F, q, R, q, R, K, G, K, G), $ = A(I, M, I, M, P, T, P, T, O, N, O, N), te = l(u(X, H), u(W, ee)), re = l(u($, ee), u(H, H));
    if (h(re)) return null;
    var ie = c(te, re), oe = c(i(X, u(ie, H)), ee), se = i(M, u(ie, l(I, M))), he = i(T, u(ie, l(P, T))), ge = i(N, u(ie, l(O, N))), De = i(F, u(oe, l(L, F))), ae = i(R, u(oe, l(q, R))), ce = i(G, u(oe, l(K, G)));
    return f(se, De) && f(he, ae) && f(ge, ce) ? [se, he, ge] : null;
  }
  function C(M, T, N, I, P, O, F, R, G, L) {
    var q = u(M, F), K = u(I, F), X = u(T, R), H = u(P, R), W = u(N, G), ee = u(O, G), $ = l(l(l(L, q), X), W), te = l(l(l(i(i(K, H), ee), q), X), W), re = c($, te), ie = i(M, u(re, l(I, M))), oe = i(T, u(re, l(P, T))), se = i(N, u(re, l(O, N)));
    return [ie, oe, se];
  }
}), _B = "sum", oSe = ["typed", "config", "add", "numeric"], mq = /* @__PURE__ */ me(_B, oSe, (e) => {
  var {
    typed: t,
    config: r,
    add: n,
    numeric: a
  } = e;
  return t(_B, {
    // sum([a, b, c, d, ...])
    "Array | Matrix": i,
    // sum([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": o,
    // sum(a, b, c, d, ...)
    "...": function(u) {
      if (_1(u))
        throw new TypeError("Scalar values expected in function sum");
      return i(u);
    }
  });
  function i(s) {
    var u;
    return yl(s, function(c) {
      try {
        u = u === void 0 ? c : n(u, c);
      } catch (l) {
        throw So(l, "sum", c);
      }
    }), u === void 0 && (u = a(0, r.number)), typeof u == "string" && (u = a(u, $d(u, r))), u;
  }
  function o(s, u) {
    try {
      var c = H3(s, u, n);
      return c;
    } catch (l) {
      throw So(l, "sum");
    }
  }
}), y2 = "cumsum", sSe = ["typed", "add", "unaryPlus"], pq = /* @__PURE__ */ me(y2, sSe, (e) => {
  var {
    typed: t,
    add: r,
    unaryPlus: n
  } = e;
  return t(y2, {
    // sum([a, b, c, d, ...])
    Array: a,
    Matrix: function(c) {
      return c.create(a(c.valueOf()));
    },
    // sum([a, b, c, d, ...], dim)
    "Array, number | BigNumber": o,
    "Matrix, number | BigNumber": function(c, l) {
      return c.create(o(c.valueOf(), l));
    },
    // cumsum(a, b, c, d, ...)
    "...": function(c) {
      if (_1(c))
        throw new TypeError("All values expected to be scalar in function cumsum");
      return a(c);
    }
  });
  function a(u) {
    try {
      return i(u);
    } catch (c) {
      throw So(c, y2);
    }
  }
  function i(u) {
    if (u.length === 0)
      return [];
    for (var c = [n(u[0])], l = 1; l < u.length; ++l)
      c.push(r(c[l - 1], u[l]));
    return c;
  }
  function o(u, c) {
    var l = Sr(u);
    if (c < 0 || c >= l.length)
      throw new ou(c, l.length);
    try {
      return s(u, c);
    } catch (d) {
      throw So(d, y2);
    }
  }
  function s(u, c) {
    var l, d, f;
    if (c <= 0) {
      var m = u[0][0];
      if (Array.isArray(m)) {
        for (f = $U(u), d = [], l = 0; l < f.length; l++)
          d[l] = s(f[l], c - 1);
        return d;
      } else
        return i(u);
    } else {
      for (d = [], l = 0; l < u.length; l++)
        d[l] = s(u[l], c - 1);
      return d;
    }
  }
}), SB = "mean", uSe = ["typed", "add", "divide"], hq = /* @__PURE__ */ me(SB, uSe, (e) => {
  var {
    typed: t,
    add: r,
    divide: n
  } = e;
  return t(SB, {
    // mean([a, b, c, d, ...])
    "Array | Matrix": i,
    // mean([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": a,
    // mean(a, b, c, d, ...)
    "...": function(s) {
      if (_1(s))
        throw new TypeError("Scalar values expected in function mean");
      return i(s);
    }
  });
  function a(o, s) {
    try {
      var u = H3(o, s, r), c = Array.isArray(o) ? Sr(o) : o.size();
      return n(u, c[s]);
    } catch (l) {
      throw So(l, "mean");
    }
  }
  function i(o) {
    var s, u = 0;
    if (yl(o, function(c) {
      try {
        s = s === void 0 ? c : r(s, c), u++;
      } catch (l) {
        throw So(l, "mean", c);
      }
    }), u === 0)
      throw new Error("Cannot calculate the mean of an empty array");
    return n(s, u);
  }
}), AB = "median", cSe = ["typed", "add", "divide", "compare", "partitionSelect"], lSe = /* @__PURE__ */ me(AB, cSe, (e) => {
  var {
    typed: t,
    add: r,
    divide: n,
    compare: a,
    partitionSelect: i
  } = e;
  function o(c) {
    try {
      c = $r(c.valueOf());
      var l = c.length;
      if (l === 0)
        throw new Error("Cannot calculate median of an empty array");
      if (l % 2 === 0) {
        for (var d = l / 2 - 1, f = i(c, d + 1), m = c[d], h = 0; h < d; ++h)
          a(c[h], m) > 0 && (m = c[h]);
        return u(m, f);
      } else {
        var p = i(c, (l - 1) / 2);
        return s(p);
      }
    } catch (g) {
      throw So(g, "median");
    }
  }
  var s = t({
    "number | BigNumber | Complex | Unit": function(l) {
      return l;
    }
  }), u = t({
    "number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit": function(l, d) {
      return n(r(l, d), 2);
    }
  });
  return t(AB, {
    // median([a, b, c, d, ...])
    "Array | Matrix": o,
    // median([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(l, d) {
      throw new Error("median(A, dim) is not yet supported");
    },
    // median(a, b, c, d, ...)
    "...": function(l) {
      if (_1(l))
        throw new TypeError("Scalar values expected in function median");
      return o(l);
    }
  });
}), wB = "mad", dSe = ["typed", "abs", "map", "median", "subtract"], fSe = /* @__PURE__ */ me(wB, dSe, (e) => {
  var {
    typed: t,
    abs: r,
    map: n,
    median: a,
    subtract: i
  } = e;
  return t(wB, {
    // mad([a, b, c, d, ...])
    "Array | Matrix": o,
    // mad(a, b, c, d, ...)
    "...": function(u) {
      return o(u);
    }
  });
  function o(s) {
    if (s = $r(s.valueOf()), s.length === 0)
      throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");
    try {
      var u = a(s);
      return a(n(s, function(c) {
        return r(i(c, u));
      }));
    } catch (c) {
      throw c instanceof TypeError && c.message.includes("median") ? new TypeError(c.message.replace("median", "mad")) : So(c, "mad");
    }
  }
}), z5 = "unbiased", CB = "variance", mSe = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"], vq = /* @__PURE__ */ me(CB, mSe, (e) => {
  var {
    typed: t,
    add: r,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: s
  } = e;
  return t(CB, {
    // variance([a, b, c, d, ...])
    "Array | Matrix": function(d) {
      return u(d, z5);
    },
    // variance([a, b, c, d, ...], normalization)
    "Array | Matrix, string": u,
    // variance([a, b, c, c, ...], dim)
    "Array | Matrix, number | BigNumber": function(d, f) {
      return c(d, f, z5);
    },
    // variance([a, b, c, c, ...], dim, normalization)
    "Array | Matrix, number | BigNumber, string": c,
    // variance(a, b, c, d, ...)
    "...": function(d) {
      return u(d, z5);
    }
  });
  function u(l, d) {
    var f, m = 0;
    if (l.length === 0)
      throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
    if (yl(l, function(g) {
      try {
        f = f === void 0 ? g : r(f, g), m++;
      } catch (v) {
        throw So(v, "variance", g);
      }
    }), m === 0) throw new Error("Cannot calculate variance of an empty array");
    var h = i(f, m);
    if (f = void 0, yl(l, function(g) {
      var v = n(g, h);
      f = f === void 0 ? a(v, v) : r(f, a(v, v));
    }), s(f))
      return f;
    switch (d) {
      case "uncorrected":
        return i(f, m);
      case "biased":
        return i(f, m + 1);
      case "unbiased": {
        var p = hr(f) ? f.mul(0) : 0;
        return m === 1 ? p : i(f, m - 1);
      }
      default:
        throw new Error('Unknown normalization "' + d + '". Choose "unbiased" (default), "uncorrected", or "biased".');
    }
  }
  function c(l, d, f) {
    try {
      if (l.length === 0)
        throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
      return o(l, d, (m) => u(m, f));
    } catch (m) {
      throw So(m, "variance");
    }
  }
}), EB = "quantileSeq", pSe = ["typed", "?bignumber", "add", "subtract", "divide", "multiply", "partitionSelect", "compare", "isInteger", "smaller", "smallerEq", "larger"], gq = /* @__PURE__ */ me(EB, pSe, (e) => {
  var {
    typed: t,
    bignumber: r,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: s,
    compare: u,
    isInteger: c,
    smaller: l,
    smallerEq: d,
    larger: f
  } = e, m = NS({
    typed: t,
    isInteger: c
  });
  return t(EB, {
    "Array | Matrix, number | BigNumber": (y, _) => p(y, _, !1),
    "Array | Matrix, number | BigNumber, number": (y, _, S) => h(y, _, !1, S, p),
    "Array | Matrix, number | BigNumber, boolean": p,
    "Array | Matrix, number | BigNumber, boolean, number": (y, _, S, b) => h(y, _, S, b, p),
    "Array | Matrix, Array | Matrix": (y, _) => g(y, _, !1),
    "Array | Matrix, Array | Matrix, number": (y, _, S) => h(y, _, !1, S, g),
    "Array | Matrix, Array | Matrix, boolean": g,
    "Array | Matrix, Array | Matrix, boolean, number": (y, _, S, b) => h(y, _, S, b, g)
  });
  function h(y, _, S, b, x) {
    return m(y, b, (A) => x(A, _, S));
  }
  function p(y, _, S) {
    var b, x = y.valueOf();
    if (l(_, 0))
      throw new Error("N/prob must be non-negative");
    if (d(_, 1))
      return _r(_) ? v(x, _, S) : r(v(x, _, S));
    if (f(_, 1)) {
      if (!c(_))
        throw new Error("N must be a positive integer");
      if (f(_, 4294967295))
        throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");
      var A = n(_, 1);
      b = [];
      for (var w = 0; l(w, _); w++) {
        var C = i(w + 1, A);
        b.push(v(x, C, S));
      }
      return _r(_) ? b : r(b);
    }
  }
  function g(y, _, S) {
    for (var b = y.valueOf(), x = _.valueOf(), A = [], w = 0; w < x.length; ++w)
      A.push(v(b, x[w], S));
    return A;
  }
  function v(y, _, S) {
    var b = $r(y), x = b.length;
    if (x === 0)
      throw new Error("Cannot calculate quantile of an empty sequence");
    var A = _r(_) ? _ * (x - 1) : _.times(x - 1), w = _r(_) ? Math.floor(A) : A.floor().toNumber(), C = _r(_) ? A % 1 : A.minus(w);
    if (c(A))
      return S ? b[A] : s(b, _r(_) ? A : A.valueOf());
    var M, T;
    if (S)
      M = b[w], T = b[w + 1];
    else {
      T = s(b, w + 1), M = b[w];
      for (var N = 0; N < w; ++N)
        u(b[N], M) > 0 && (M = b[N]);
    }
    return n(o(M, a(1, C)), o(T, C));
  }
}), DB = "std", hSe = ["typed", "map", "sqrt", "variance"], yq = /* @__PURE__ */ me(DB, hSe, (e) => {
  var {
    typed: t,
    map: r,
    sqrt: n,
    variance: a
  } = e;
  return t(DB, {
    // std([a, b, c, d, ...])
    "Array | Matrix": i,
    // std([a, b, c, d, ...], normalization)
    "Array | Matrix, string": i,
    // std([a, b, c, c, ...], dim)
    "Array | Matrix, number | BigNumber": i,
    // std([a, b, c, c, ...], dim, normalization)
    "Array | Matrix, number | BigNumber, string": i,
    // std(a, b, c, d, ...)
    "...": function(s) {
      return i(s);
    }
  });
  function i(o, s) {
    if (o.length === 0)
      throw new SyntaxError("Function std requires one or more parameters (0 provided)");
    try {
      var u = a.apply(null, arguments);
      return bs(u) ? r(u, n) : n(u);
    } catch (c) {
      throw c instanceof TypeError && c.message.includes(" variance") ? new TypeError(c.message.replace(" variance", " std")) : c;
    }
  }
}), MB = "corr", vSe = ["typed", "matrix", "mean", "sqrt", "sum", "add", "subtract", "multiply", "pow", "divide"], gSe = /* @__PURE__ */ me(MB, vSe, (e) => {
  var {
    typed: t,
    matrix: r,
    sqrt: n,
    sum: a,
    add: i,
    subtract: o,
    multiply: s,
    pow: u,
    divide: c
  } = e;
  return t(MB, {
    "Array, Array": function(m, h) {
      return l(m, h);
    },
    "Matrix, Matrix": function(m, h) {
      var p = l(m.toArray(), h.toArray());
      return Array.isArray(p) ? r(p) : p;
    }
  });
  function l(f, m) {
    var h = [];
    if (Array.isArray(f[0]) && Array.isArray(m[0])) {
      if (f.length !== m.length)
        throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");
      for (var p = 0; p < f.length; p++) {
        if (f[p].length !== m[p].length)
          throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");
        h.push(d(f[p], m[p]));
      }
      return h;
    } else {
      if (f.length !== m.length)
        throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");
      return d(f, m);
    }
  }
  function d(f, m) {
    var h = f.length, p = a(f), g = a(m), v = f.reduce((x, A, w) => i(x, s(A, m[w])), 0), y = a(f.map((x) => u(x, 2))), _ = a(m.map((x) => u(x, 2))), S = o(s(h, v), s(p, g)), b = n(s(o(s(h, y), u(p, 2)), o(s(h, _), u(g, 2))));
    return c(S, b);
  }
}), IB = "combinations", ySe = ["typed"], bSe = /* @__PURE__ */ me(IB, ySe, (e) => {
  var {
    typed: t
  } = e;
  return t(IB, {
    "number, number": SG,
    "BigNumber, BigNumber": function(n, a) {
      var i = n.constructor, o, s, u = n.minus(a), c = new i(1);
      if (!TB(n) || !TB(a))
        throw new TypeError("Positive integer value expected in function combinations");
      if (a.gt(n))
        throw new TypeError("k must be less than n in function combinations");
      if (o = c, a.lt(u))
        for (s = c; s.lte(u); s = s.plus(c))
          o = o.times(a.plus(s)).dividedBy(s);
      else
        for (s = c; s.lte(a); s = s.plus(c))
          o = o.times(u.plus(s)).dividedBy(s);
      return o;
    }
    // TODO: implement support for collection in combinations
  });
});
function TB(e) {
  return e.isInteger() && e.gte(0);
}
var NB = "combinationsWithRep", xSe = ["typed"], _Se = /* @__PURE__ */ me(NB, xSe, (e) => {
  var {
    typed: t
  } = e;
  return t(NB, {
    "number, number": function(n, a) {
      if (!Ut(n) || n < 0)
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (!Ut(a) || a < 0)
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (n < 1)
        throw new TypeError("k must be less than or equal to n + k - 1");
      if (a < n - 1) {
        var i = el(n, n + a - 1);
        return i / el(1, a);
      }
      var o = el(a + 1, n + a - 1);
      return o / el(1, n - 1);
    },
    "BigNumber, BigNumber": function(n, a) {
      var i = n.constructor, o, s, u = new i(1), c = n.minus(u);
      if (!PB(n) || !PB(a))
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (n.lt(u))
        throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");
      if (o = u, a.lt(c))
        for (s = u; s.lte(c); s = s.plus(u))
          o = o.times(a.plus(s)).dividedBy(s);
      else
        for (s = u; s.lte(a); s = s.plus(u))
          o = o.times(c.plus(s)).dividedBy(s);
      return o;
    }
  });
});
function PB(e) {
  return e.isInteger() && e.gte(0);
}
var BB = "gamma", SSe = ["typed", "config", "multiplyScalar", "pow", "BigNumber", "Complex"], ASe = /* @__PURE__ */ me(BB, SSe, (e) => {
  var {
    typed: t,
    config: r,
    multiplyScalar: n,
    pow: a,
    BigNumber: i,
    Complex: o
  } = e;
  function s(c) {
    if (c.im === 0)
      return qy(c.re);
    if (c.re < 0.5) {
      var l = new o(1 - c.re, -c.im), d = new o(Math.PI * c.re, Math.PI * c.im);
      return new o(Math.PI).div(d.sin()).div(s(l));
    }
    c = new o(c.re - 1, c.im);
    for (var f = new o(Pp[0], 0), m = 1; m < Pp.length; ++m) {
      var h = new o(Pp[m], 0);
      f = f.add(h.div(c.add(m)));
    }
    var p = new o(c.re + wG + 0.5, c.im), g = Math.sqrt(2 * Math.PI), v = p.pow(c.add(0.5)), y = p.neg().exp();
    return f.mul(g).mul(v).mul(y);
  }
  return t(BB, {
    number: qy,
    Complex: s,
    BigNumber: function(l) {
      if (l.isInteger())
        return l.isNegative() || l.isZero() ? new i(1 / 0) : u(l.minus(1));
      if (!l.isFinite())
        return new i(l.isNegative() ? NaN : 1 / 0);
      throw new Error("Integer BigNumber expected");
    }
  });
  function u(c) {
    if (c < 8)
      return new i([1, 1, 2, 6, 24, 120, 720, 5040][c]);
    var l = r.precision + (Math.log(c.toNumber()) | 0), d = i.clone({
      precision: l
    });
    if (c % 2 === 1)
      return c.times(u(new i(c - 1)));
    for (var f = c, m = new d(c), h = c.toNumber(); f > 2; )
      f -= 2, h += f, m = m.times(h);
    return new i(m.toPrecision(i.precision));
  }
}), OB = "lgamma", wSe = ["Complex", "typed"], CSe = /* @__PURE__ */ me(OB, wSe, (e) => {
  var {
    Complex: t,
    typed: r
  } = e, n = 7, a = 7, i = [-0.029550653594771242, 0.00641025641025641, -0.0019175269175269176, 8417508417508417e-19, -5952380952380953e-19, 7936507936507937e-19, -0.002777777777777778, 0.08333333333333333];
  return r(OB, {
    number: Hy,
    Complex: o,
    BigNumber: function() {
      throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber");
    }
  });
  function o(c) {
    var l = 6.283185307179586, d = 1.1447298858494002, f = 0.1;
    if (c.isNaN())
      return new t(NaN, NaN);
    if (c.im === 0)
      return new t(Hy(c.re), 0);
    if (c.re >= n || Math.abs(c.im) >= a)
      return s(c);
    if (c.re <= f) {
      var m = xpe(l, c.im) * Math.floor(0.5 * c.re + 0.25), h = c.mul(Math.PI).sin().log(), p = o(new t(1 - c.re, -c.im));
      return new t(d, m).sub(h).sub(p);
    } else return c.im >= 0 ? u(c) : u(c.conjugate()).conjugate();
  }
  function s(c) {
    for (var l = c.sub(0.5).mul(c.log()).sub(c).add(CG), d = new t(1, 0).div(c), f = d.div(c), m = i[0], h = i[1], p = 2 * f.re, g = f.re * f.re + f.im * f.im, v = 2; v < 8; v++) {
      var y = h;
      h = -g * m + i[v], m = p * m + y;
    }
    var _ = d.mul(f.mul(m).add(h));
    return l.add(_);
  }
  function u(c) {
    var l = 0, d = 0, f = c;
    for (c = c.add(1); c.re <= n; ) {
      f = f.mul(c);
      var m = f.im < 0 ? 1 : 0;
      m !== 0 && d === 0 && l++, d = m, c = c.add(1);
    }
    return s(c).sub(f.log()).sub(new t(0, l * 2 * Math.PI * 1));
  }
}), FB = "factorial", ESe = ["typed", "gamma"], DSe = /* @__PURE__ */ me(FB, ESe, (e) => {
  var {
    typed: t,
    gamma: r
  } = e;
  return t(FB, {
    number: function(a) {
      if (a < 0)
        throw new Error("Value must be non-negative");
      return r(a + 1);
    },
    BigNumber: function(a) {
      if (a.isNegative())
        throw new Error("Value must be non-negative");
      return r(a.plus(1));
    },
    "Array | Matrix": t.referToSelf((n) => (a) => Tr(a, n))
  });
}), RB = "kldivergence", MSe = ["typed", "matrix", "divide", "sum", "multiply", "map", "dotDivide", "log", "isNumeric"], ISe = /* @__PURE__ */ me(RB, MSe, (e) => {
  var {
    typed: t,
    matrix: r,
    divide: n,
    sum: a,
    multiply: i,
    map: o,
    dotDivide: s,
    log: u,
    isNumeric: c
  } = e;
  return t(RB, {
    "Array, Array": function(f, m) {
      return l(r(f), r(m));
    },
    "Matrix, Array": function(f, m) {
      return l(f, r(m));
    },
    "Array, Matrix": function(f, m) {
      return l(r(f), m);
    },
    "Matrix, Matrix": function(f, m) {
      return l(f, m);
    }
  });
  function l(d, f) {
    var m = f.size().length, h = d.size().length;
    if (m > 1)
      throw new Error("first object must be one dimensional");
    if (h > 1)
      throw new Error("second object must be one dimensional");
    if (m !== h)
      throw new Error("Length of two vectors must be equal");
    var p = a(d);
    if (p === 0)
      throw new Error("Sum of elements in first object must be non zero");
    var g = a(f);
    if (g === 0)
      throw new Error("Sum of elements in second object must be non zero");
    var v = n(d, a(d)), y = n(f, a(f)), _ = a(i(v, o(s(v, y), (S) => u(S))));
    return c(_) ? _ : Number.NaN;
  }
}), LB = "multinomial", TSe = ["typed", "add", "divide", "multiply", "factorial", "isInteger", "isPositive"], NSe = /* @__PURE__ */ me(LB, TSe, (e) => {
  var {
    typed: t,
    add: r,
    divide: n,
    multiply: a,
    factorial: i,
    isInteger: o,
    isPositive: s
  } = e;
  return t(LB, {
    "Array | Matrix": function(c) {
      var l = 0, d = 1;
      return yl(c, function(f) {
        if (!o(f) || !s(f))
          throw new TypeError("Positive integer value expected in function multinomial");
        l = r(l, f), d = a(d, i(f));
      }), n(i(l), d);
    }
  });
}), kB = "permutations", PSe = ["typed", "factorial"], BSe = /* @__PURE__ */ me(kB, PSe, (e) => {
  var {
    typed: t,
    factorial: r
  } = e;
  return t(kB, {
    "number | BigNumber": r,
    "number, number": function(a, i) {
      if (!Ut(a) || a < 0)
        throw new TypeError("Positive integer value expected in function permutations");
      if (!Ut(i) || i < 0)
        throw new TypeError("Positive integer value expected in function permutations");
      if (i > a)
        throw new TypeError("second argument k must be less than or equal to first argument n");
      return el(a - i + 1, a);
    },
    "BigNumber, BigNumber": function(a, i) {
      var o, s;
      if (!zB(a) || !zB(i))
        throw new TypeError("Positive integer value expected in function permutations");
      if (i.gt(a))
        throw new TypeError("second argument k must be less than or equal to first argument n");
      var u = a.mul(0).add(1);
      for (o = u, s = a.minus(i).plus(1); s.lte(a); s = s.plus(1))
        o = o.times(s);
      return o;
    }
    // TODO: implement support for collection in permutations
  });
});
function zB(e) {
  return e.isInteger() && e.gte(0);
}
var VS = { exports: {} };
VS.exports;
(function(e) {
  (function(t, r, n) {
    function a(u) {
      var c = this, l = s();
      c.next = function() {
        var d = 2091639 * c.s0 + c.c * 23283064365386963e-26;
        return c.s0 = c.s1, c.s1 = c.s2, c.s2 = d - (c.c = d | 0);
      }, c.c = 1, c.s0 = l(" "), c.s1 = l(" "), c.s2 = l(" "), c.s0 -= l(u), c.s0 < 0 && (c.s0 += 1), c.s1 -= l(u), c.s1 < 0 && (c.s1 += 1), c.s2 -= l(u), c.s2 < 0 && (c.s2 += 1), l = null;
    }
    function i(u, c) {
      return c.c = u.c, c.s0 = u.s0, c.s1 = u.s1, c.s2 = u.s2, c;
    }
    function o(u, c) {
      var l = new a(u), d = c && c.state, f = l.next;
      return f.int32 = function() {
        return l.next() * 4294967296 | 0;
      }, f.double = function() {
        return f() + (f() * 2097152 | 0) * 11102230246251565e-32;
      }, f.quick = f, d && (typeof d == "object" && i(d, l), f.state = function() {
        return i(l, {});
      }), f;
    }
    function s() {
      var u = 4022871197, c = function(l) {
        l = String(l);
        for (var d = 0; d < l.length; d++) {
          u += l.charCodeAt(d);
          var f = 0.02519603282416938 * u;
          u = f >>> 0, f -= u, f *= u, u = f >>> 0, f -= u, u += f * 4294967296;
        }
        return (u >>> 0) * 23283064365386963e-26;
      };
      return c;
    }
    r && r.exports ? r.exports = o : this.alea = o;
  })(
    Qs,
    e
  );
})(VS);
var OSe = VS.exports, qS = { exports: {} };
qS.exports;
(function(e) {
  (function(t, r, n) {
    function a(s) {
      var u = this, c = "";
      u.x = 0, u.y = 0, u.z = 0, u.w = 0, u.next = function() {
        var d = u.x ^ u.x << 11;
        return u.x = u.y, u.y = u.z, u.z = u.w, u.w ^= u.w >>> 19 ^ d ^ d >>> 8;
      }, s === (s | 0) ? u.x = s : c += s;
      for (var l = 0; l < c.length + 64; l++)
        u.x ^= c.charCodeAt(l) | 0, u.next();
    }
    function i(s, u) {
      return u.x = s.x, u.y = s.y, u.z = s.z, u.w = s.w, u;
    }
    function o(s, u) {
      var c = new a(s), l = u && u.state, d = function() {
        return (c.next() >>> 0) / 4294967296;
      };
      return d.double = function() {
        do
          var f = c.next() >>> 11, m = (c.next() >>> 0) / 4294967296, h = (f + m) / (1 << 21);
        while (h === 0);
        return h;
      }, d.int32 = c.next, d.quick = d, l && (typeof l == "object" && i(l, c), d.state = function() {
        return i(c, {});
      }), d;
    }
    r && r.exports ? r.exports = o : this.xor128 = o;
  })(
    Qs,
    e
  );
})(qS);
var FSe = qS.exports, HS = { exports: {} };
HS.exports;
(function(e) {
  (function(t, r, n) {
    function a(s) {
      var u = this, c = "";
      u.next = function() {
        var d = u.x ^ u.x >>> 2;
        return u.x = u.y, u.y = u.z, u.z = u.w, u.w = u.v, (u.d = u.d + 362437 | 0) + (u.v = u.v ^ u.v << 4 ^ (d ^ d << 1)) | 0;
      }, u.x = 0, u.y = 0, u.z = 0, u.w = 0, u.v = 0, s === (s | 0) ? u.x = s : c += s;
      for (var l = 0; l < c.length + 64; l++)
        u.x ^= c.charCodeAt(l) | 0, l == c.length && (u.d = u.x << 10 ^ u.x >>> 4), u.next();
    }
    function i(s, u) {
      return u.x = s.x, u.y = s.y, u.z = s.z, u.w = s.w, u.v = s.v, u.d = s.d, u;
    }
    function o(s, u) {
      var c = new a(s), l = u && u.state, d = function() {
        return (c.next() >>> 0) / 4294967296;
      };
      return d.double = function() {
        do
          var f = c.next() >>> 11, m = (c.next() >>> 0) / 4294967296, h = (f + m) / (1 << 21);
        while (h === 0);
        return h;
      }, d.int32 = c.next, d.quick = d, l && (typeof l == "object" && i(l, c), d.state = function() {
        return i(c, {});
      }), d;
    }
    r && r.exports ? r.exports = o : this.xorwow = o;
  })(
    Qs,
    e
  );
})(HS);
var RSe = HS.exports, KS = { exports: {} };
KS.exports;
(function(e) {
  (function(t, r, n) {
    function a(s) {
      var u = this;
      u.next = function() {
        var l = u.x, d = u.i, f, m;
        return f = l[d], f ^= f >>> 7, m = f ^ f << 24, f = l[d + 1 & 7], m ^= f ^ f >>> 10, f = l[d + 3 & 7], m ^= f ^ f >>> 3, f = l[d + 4 & 7], m ^= f ^ f << 7, f = l[d + 7 & 7], f = f ^ f << 13, m ^= f ^ f << 9, l[d] = m, u.i = d + 1 & 7, m;
      };
      function c(l, d) {
        var f, m = [];
        if (d === (d | 0))
          m[0] = d;
        else
          for (d = "" + d, f = 0; f < d.length; ++f)
            m[f & 7] = m[f & 7] << 15 ^ d.charCodeAt(f) + m[f + 1 & 7] << 13;
        for (; m.length < 8; ) m.push(0);
        for (f = 0; f < 8 && m[f] === 0; ++f) ;
        for (f == 8 ? m[7] = -1 : m[f], l.x = m, l.i = 0, f = 256; f > 0; --f)
          l.next();
      }
      c(u, s);
    }
    function i(s, u) {
      return u.x = s.x.slice(), u.i = s.i, u;
    }
    function o(s, u) {
      s == null && (s = +/* @__PURE__ */ new Date());
      var c = new a(s), l = u && u.state, d = function() {
        return (c.next() >>> 0) / 4294967296;
      };
      return d.double = function() {
        do
          var f = c.next() >>> 11, m = (c.next() >>> 0) / 4294967296, h = (f + m) / (1 << 21);
        while (h === 0);
        return h;
      }, d.int32 = c.next, d.quick = d, l && (l.x && i(l, c), d.state = function() {
        return i(c, {});
      }), d;
    }
    r && r.exports ? r.exports = o : this.xorshift7 = o;
  })(
    Qs,
    e
  );
})(KS);
var LSe = KS.exports, XS = { exports: {} };
XS.exports;
(function(e) {
  (function(t, r, n) {
    function a(s) {
      var u = this;
      u.next = function() {
        var l = u.w, d = u.X, f = u.i, m, h;
        return u.w = l = l + 1640531527 | 0, h = d[f + 34 & 127], m = d[f = f + 1 & 127], h ^= h << 13, m ^= m << 17, h ^= h >>> 15, m ^= m >>> 12, h = d[f] = h ^ m, u.i = f, h + (l ^ l >>> 16) | 0;
      };
      function c(l, d) {
        var f, m, h, p, g, v = [], y = 128;
        for (d === (d | 0) ? (m = d, d = null) : (d = d + "\0", m = 0, y = Math.max(y, d.length)), h = 0, p = -32; p < y; ++p)
          d && (m ^= d.charCodeAt((p + 32) % d.length)), p === 0 && (g = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, p >= 0 && (g = g + 1640531527 | 0, f = v[p & 127] ^= m + g, h = f == 0 ? h + 1 : 0);
        for (h >= 128 && (v[(d && d.length || 0) & 127] = -1), h = 127, p = 4 * 128; p > 0; --p)
          m = v[h + 34 & 127], f = v[h = h + 1 & 127], m ^= m << 13, f ^= f << 17, m ^= m >>> 15, f ^= f >>> 12, v[h] = m ^ f;
        l.w = g, l.X = v, l.i = h;
      }
      c(u, s);
    }
    function i(s, u) {
      return u.i = s.i, u.w = s.w, u.X = s.X.slice(), u;
    }
    function o(s, u) {
      s == null && (s = +/* @__PURE__ */ new Date());
      var c = new a(s), l = u && u.state, d = function() {
        return (c.next() >>> 0) / 4294967296;
      };
      return d.double = function() {
        do
          var f = c.next() >>> 11, m = (c.next() >>> 0) / 4294967296, h = (f + m) / (1 << 21);
        while (h === 0);
        return h;
      }, d.int32 = c.next, d.quick = d, l && (l.X && i(l, c), d.state = function() {
        return i(c, {});
      }), d;
    }
    r && r.exports ? r.exports = o : this.xor4096 = o;
  })(
    Qs,
    // window object or global
    e
  );
})(XS);
var kSe = XS.exports, jS = { exports: {} };
jS.exports;
(function(e) {
  (function(t, r, n) {
    function a(s) {
      var u = this, c = "";
      u.next = function() {
        var d = u.b, f = u.c, m = u.d, h = u.a;
        return d = d << 25 ^ d >>> 7 ^ f, f = f - m | 0, m = m << 24 ^ m >>> 8 ^ h, h = h - d | 0, u.b = d = d << 20 ^ d >>> 12 ^ f, u.c = f = f - m | 0, u.d = m << 16 ^ f >>> 16 ^ h, u.a = h - d | 0;
      }, u.a = 0, u.b = 0, u.c = -1640531527, u.d = 1367130551, s === Math.floor(s) ? (u.a = s / 4294967296 | 0, u.b = s | 0) : c += s;
      for (var l = 0; l < c.length + 20; l++)
        u.b ^= c.charCodeAt(l) | 0, u.next();
    }
    function i(s, u) {
      return u.a = s.a, u.b = s.b, u.c = s.c, u.d = s.d, u;
    }
    function o(s, u) {
      var c = new a(s), l = u && u.state, d = function() {
        return (c.next() >>> 0) / 4294967296;
      };
      return d.double = function() {
        do
          var f = c.next() >>> 11, m = (c.next() >>> 0) / 4294967296, h = (f + m) / (1 << 21);
        while (h === 0);
        return h;
      }, d.int32 = c.next, d.quick = d, l && (typeof l == "object" && i(l, c), d.state = function() {
        return i(c, {});
      }), d;
    }
    r && r.exports ? r.exports = o : this.tychei = o;
  })(
    Qs,
    e
  );
})(jS);
var zSe = jS.exports, bq = { exports: {} };
const USe = {}, GSe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: USe
}, Symbol.toStringTag, { value: "Module" })), VSe = /* @__PURE__ */ M1e(GSe);
(function(e) {
  (function(t, r, n) {
    var a = 256, i = 6, o = 52, s = "random", u = n.pow(a, i), c = n.pow(2, o), l = c * 2, d = a - 1, f;
    function m(S, b, x) {
      var A = [];
      b = b == !0 ? { entropy: !0 } : b || {};
      var w = v(g(
        b.entropy ? [S, _(r)] : S ?? y(),
        3
      ), A), C = new h(A), M = function() {
        for (var T = C.g(i), N = u, I = 0; T < c; )
          T = (T + I) * a, N *= a, I = C.g(1);
        for (; T >= l; )
          T /= 2, N /= 2, I >>>= 1;
        return (T + I) / N;
      };
      return M.int32 = function() {
        return C.g(4) | 0;
      }, M.quick = function() {
        return C.g(4) / 4294967296;
      }, M.double = M, v(_(C.S), r), (b.pass || x || function(T, N, I, P) {
        return P && (P.S && p(P, C), T.state = function() {
          return p(C, {});
        }), I ? (n[s] = T, N) : T;
      })(
        M,
        w,
        "global" in b ? b.global : this == n,
        b.state
      );
    }
    function h(S) {
      var b, x = S.length, A = this, w = 0, C = A.i = A.j = 0, M = A.S = [];
      for (x || (S = [x++]); w < a; )
        M[w] = w++;
      for (w = 0; w < a; w++)
        M[w] = M[C = d & C + S[w % x] + (b = M[w])], M[C] = b;
      (A.g = function(T) {
        for (var N, I = 0, P = A.i, O = A.j, F = A.S; T--; )
          N = F[P = d & P + 1], I = I * a + F[d & (F[P] = F[O = d & O + N]) + (F[O] = N)];
        return A.i = P, A.j = O, I;
      })(a);
    }
    function p(S, b) {
      return b.i = S.i, b.j = S.j, b.S = S.S.slice(), b;
    }
    function g(S, b) {
      var x = [], A = typeof S, w;
      if (b && A == "object")
        for (w in S)
          try {
            x.push(g(S[w], b - 1));
          } catch {
          }
      return x.length ? x : A == "string" ? S : S + "\0";
    }
    function v(S, b) {
      for (var x = S + "", A, w = 0; w < x.length; )
        b[d & w] = d & (A ^= b[d & w] * 19) + x.charCodeAt(w++);
      return _(b);
    }
    function y() {
      try {
        var S;
        return f && (S = f.randomBytes) ? S = S(a) : (S = new Uint8Array(a), (t.crypto || t.msCrypto).getRandomValues(S)), _(S);
      } catch {
        var b = t.navigator, x = b && b.plugins;
        return [+/* @__PURE__ */ new Date(), t, x, t.screen, _(r)];
      }
    }
    function _(S) {
      return String.fromCharCode.apply(0, S);
    }
    if (v(n.random(), r), e.exports) {
      e.exports = m;
      try {
        f = VSe;
      } catch {
      }
    } else
      n["seed" + s] = m;
  })(
    // global: `self` in browsers (including strict mode and web workers),
    // otherwise `this` in Node and other environments
    typeof self < "u" ? self : Qs,
    [],
    // pool: entropy pool starts empty
    Math
    // math: package containing random, pow, and seedrandom
  );
})(bq);
var qSe = bq.exports, HSe = OSe, KSe = FSe, XSe = RSe, jSe = LSe, YSe = kSe, WSe = zSe, bm = qSe;
bm.alea = HSe;
bm.xor128 = KSe;
bm.xorwow = XSe;
bm.xorshift7 = jSe;
bm.xor4096 = YSe;
bm.tychei = WSe;
var ZSe = bm;
const xq = /* @__PURE__ */ jh(ZSe);
var QSe = /* @__PURE__ */ xq(Date.now());
function l1(e) {
  var t;
  function r(a) {
    t = a === null ? QSe : xq(String(a));
  }
  r(e);
  function n() {
    return t();
  }
  return n;
}
var UB = "pickRandom", $Se = ["typed", "config", "?on"], JSe = /* @__PURE__ */ me(UB, $Se, (e) => {
  var {
    typed: t,
    config: r,
    on: n
  } = e, a = l1(r.randomSeed);
  return n && n("config", function(o, s) {
    o.randomSeed !== s.randomSeed && (a = l1(o.randomSeed));
  }), t(UB, {
    "Array | Matrix": function(s) {
      return i(s, {});
    },
    "Array | Matrix, Object": function(s, u) {
      return i(s, u);
    },
    "Array | Matrix, number": function(s, u) {
      return i(s, {
        number: u
      });
    },
    "Array | Matrix, Array | Matrix": function(s, u) {
      return i(s, {
        weights: u
      });
    },
    "Array | Matrix, Array | Matrix, number": function(s, u, c) {
      return i(s, {
        number: c,
        weights: u
      });
    },
    "Array | Matrix, number, Array | Matrix": function(s, u, c) {
      return i(s, {
        number: u,
        weights: c
      });
    }
  });
  function i(o, s) {
    var {
      number: u,
      weights: c,
      elementWise: l = !0
    } = s, d = typeof u > "u";
    d && (u = 1);
    var f = Zt(o) ? o.create : Zt(c) ? c.create : null;
    o = o.valueOf(), c && (c = c.valueOf()), l === !0 && (o = $r(o), c = $r(c));
    var m = 0;
    if (typeof c < "u") {
      if (c.length !== o.length)
        throw new Error("Weights must have the same length as possibles");
      for (var h = 0, p = c.length; h < p; h++) {
        if (!_r(c[h]) || c[h] < 0)
          throw new Error("Weights must be an array of positive numbers");
        m += c[h];
      }
    }
    for (var g = o.length, v = [], y; v.length < u; ) {
      if (typeof c > "u")
        y = o[Math.floor(a() * g)];
      else
        for (var _ = a() * m, S = 0, b = o.length; S < b; S++)
          if (_ -= c[S], _ < 0) {
            y = o[S];
            break;
          }
      v.push(y);
    }
    return d ? v[0] : f ? f(v) : v;
  }
});
function YS(e, t) {
  var r = [];
  if (e = e.slice(0), e.length > 1)
    for (var n = 0, a = e.shift(); n < a; n++)
      r.push(YS(e, t));
  else
    for (var i = 0, o = e.shift(); i < o; i++)
      r.push(t());
  return r;
}
var GB = "random", eAe = ["typed", "config", "?on"], tAe = /* @__PURE__ */ me(GB, eAe, (e) => {
  var {
    typed: t,
    config: r,
    on: n
  } = e, a = l1(r.randomSeed);
  return n && n("config", function(s, u) {
    s.randomSeed !== u.randomSeed && (a = l1(s.randomSeed));
  }), t(GB, {
    "": () => o(0, 1),
    number: (s) => o(0, s),
    "number, number": (s, u) => o(s, u),
    "Array | Matrix": (s) => i(s, 0, 1),
    "Array | Matrix, number": (s, u) => i(s, 0, u),
    "Array | Matrix, number, number": (s, u, c) => i(s, u, c)
  });
  function i(s, u, c) {
    var l = YS(s.valueOf(), () => o(u, c));
    return Zt(s) ? s.create(l) : l;
  }
  function o(s, u) {
    return s + a() * (u - s);
  }
}), VB = "randomInt", rAe = ["typed", "config", "?on"], nAe = /* @__PURE__ */ me(VB, rAe, (e) => {
  var {
    typed: t,
    config: r,
    on: n
  } = e, a = l1(r.randomSeed);
  return n && n("config", function(s, u) {
    s.randomSeed !== u.randomSeed && (a = l1(s.randomSeed));
  }), t(VB, {
    "": () => o(0, 1),
    number: (s) => o(0, s),
    "number, number": (s, u) => o(s, u),
    "Array | Matrix": (s) => i(s, 0, 1),
    "Array | Matrix, number": (s, u) => i(s, 0, u),
    "Array | Matrix, number, number": (s, u, c) => i(s, u, c)
  });
  function i(s, u, c) {
    var l = YS(s.valueOf(), () => o(u, c));
    return Zt(s) ? s.create(l) : l;
  }
  function o(s, u) {
    return Math.floor(s + a() * (u - s));
  }
}), qB = "stirlingS2", aAe = ["typed", "addScalar", "subtractScalar", "multiplyScalar", "divideScalar", "pow", "factorial", "combinations", "isNegative", "isInteger", "number", "?bignumber", "larger"], iAe = /* @__PURE__ */ me(qB, aAe, (e) => {
  var {
    typed: t,
    addScalar: r,
    subtractScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    pow: o,
    factorial: s,
    combinations: u,
    isNegative: c,
    isInteger: l,
    number: d,
    bignumber: f,
    larger: m
  } = e, h = [], p = [];
  return t(qB, {
    "number | BigNumber, number | BigNumber": function(v, y) {
      if (!l(v) || c(v) || !l(y) || c(y))
        throw new TypeError("Non-negative integer value expected in function stirlingS2");
      if (m(y, v))
        throw new TypeError("k must be less than or equal to n in function stirlingS2");
      var _ = !(_r(v) && _r(y)), S = _ ? p : h, b = _ ? f : d, x = d(v), A = d(y);
      if (S[x] && S[x].length > A)
        return S[x][A];
      for (var w = 0; w <= x; ++w)
        if (S[w] || (S[w] = [b(w === 0 ? 1 : 0)]), w !== 0)
          for (var C = S[w], M = S[w - 1], T = C.length; T <= w && T <= A; ++T)
            T === w ? C[T] = 1 : C[T] = r(a(b(T), M[T]), M[T - 1]);
      return S[x][A];
    }
  });
}), HB = "bellNumbers", oAe = ["typed", "addScalar", "isNegative", "isInteger", "stirlingS2"], sAe = /* @__PURE__ */ me(HB, oAe, (e) => {
  var {
    typed: t,
    addScalar: r,
    isNegative: n,
    isInteger: a,
    stirlingS2: i
  } = e;
  return t(HB, {
    "number | BigNumber": function(s) {
      if (!a(s) || n(s))
        throw new TypeError("Non-negative integer value expected in function bellNumbers");
      for (var u = 0, c = 0; c <= s; c++)
        u = r(u, i(s, c));
      return u;
    }
  });
}), KB = "catalan", uAe = ["typed", "addScalar", "divideScalar", "multiplyScalar", "combinations", "isNegative", "isInteger"], cAe = /* @__PURE__ */ me(KB, uAe, (e) => {
  var {
    typed: t,
    addScalar: r,
    divideScalar: n,
    multiplyScalar: a,
    combinations: i,
    isNegative: o,
    isInteger: s
  } = e;
  return t(KB, {
    "number | BigNumber": function(c) {
      if (!s(c) || o(c))
        throw new TypeError("Non-negative integer value expected in function catalan");
      return n(i(a(c, 2), c), r(c, 1));
    }
  });
}), XB = "composition", lAe = ["typed", "addScalar", "combinations", "isNegative", "isPositive", "isInteger", "larger"], dAe = /* @__PURE__ */ me(XB, lAe, (e) => {
  var {
    typed: t,
    addScalar: r,
    combinations: n,
    isPositive: a,
    isNegative: i,
    isInteger: o,
    larger: s
  } = e;
  return t(XB, {
    "number | BigNumber, number | BigNumber": function(c, l) {
      if (!o(c) || !a(c) || !o(l) || !a(l))
        throw new TypeError("Positive integer value expected in function composition");
      if (s(l, c))
        throw new TypeError("k must be less than or equal to n in function composition");
      return n(r(c, -1), r(l, -1));
    }
  });
}), jB = "leafCount", fAe = ["parse", "typed"], mAe = /* @__PURE__ */ me(jB, fAe, (e) => {
  var {
    parse: t,
    typed: r
  } = e;
  function n(a) {
    var i = 0;
    return a.forEach((o) => {
      i += n(o);
    }), i || 1;
  }
  return r(jB, {
    Node: function(i) {
      return n(i);
    }
  });
});
function YB(e) {
  return Vr(e) || Da(e) && e.isUnary() && Vr(e.args[0]);
}
function e3(e) {
  return !!(Vr(e) || (vl(e) || Da(e)) && e.args.every(e3) || pc(e) && e3(e.content));
}
function WB(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function U5(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? WB(Object(r), !0).forEach(function(n) {
      $a(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : WB(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
var pAe = "simplifyUtil", hAe = ["FunctionNode", "OperatorNode", "SymbolNode"], WS = /* @__PURE__ */ me(pAe, hAe, (e) => {
  var {
    FunctionNode: t,
    OperatorNode: r,
    SymbolNode: n
  } = e, a = !0, i = !1, o = "defaultF", s = {
    /*      */
    add: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /**/
    unaryPlus: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /* */
    subtract: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    },
    /* */
    multiply: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /*   */
    divide: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    },
    /*    */
    paren: {
      trivial: a,
      total: a,
      commutative: a,
      associative: i
    },
    /* */
    defaultF: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    }
  }, u = {
    divide: {
      total: i
    },
    log: {
      total: i
    }
  }, c = {
    subtract: {
      total: i
    },
    abs: {
      trivial: a
    },
    log: {
      total: a
    }
  };
  function l(_, S) {
    var b = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : s, x = o;
    if (typeof _ == "string" ? x = _ : Da(_) ? x = _.fn.toString() : vl(_) ? x = _.name : pc(_) && (x = "paren"), Tt(b, x)) {
      var A = b[x];
      if (Tt(A, S))
        return A[S];
      if (Tt(s, x))
        return s[x][S];
    }
    if (Tt(b, o)) {
      var w = b[o];
      return Tt(w, S) ? w[S] : s[o][S];
    }
    if (Tt(s, x)) {
      var C = s[x];
      if (Tt(C, S))
        return C[S];
    }
    return s[o][S];
  }
  function d(_) {
    var S = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : s;
    return l(_, "commutative", S);
  }
  function f(_) {
    var S = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : s;
    return l(_, "associative", S);
  }
  function m(_, S) {
    var b = U5({}, _);
    for (var x in S)
      Tt(_, x) ? b[x] = U5(U5({}, S[x]), _[x]) : b[x] = S[x];
    return b;
  }
  function h(_, S) {
    if (!_.args || _.args.length === 0)
      return _;
    _.args = p(_, S);
    for (var b = 0; b < _.args.length; b++)
      h(_.args[b], S);
  }
  function p(_, S) {
    var b, x = [], A = function w(C) {
      for (var M = 0; M < C.args.length; M++) {
        var T = C.args[M];
        Da(T) && b === T.op ? w(T) : x.push(T);
      }
    };
    return f(_, S) ? (b = _.op, A(_), x) : _.args;
  }
  function g(_, S) {
    if (!(!_.args || _.args.length === 0)) {
      for (var b = y(_), x = _.args.length, A = 0; A < x; A++)
        g(_.args[A], S);
      if (x > 2 && f(_, S)) {
        for (var w = _.args.pop(); _.args.length > 0; )
          w = b([_.args.pop(), w]);
        _.args = w.args;
      }
    }
  }
  function v(_, S) {
    if (!(!_.args || _.args.length === 0)) {
      for (var b = y(_), x = _.args.length, A = 0; A < x; A++)
        v(_.args[A], S);
      if (x > 2 && f(_, S)) {
        for (var w = _.args.shift(); _.args.length > 0; )
          w = b([w, _.args.shift()]);
        _.args = w.args;
      }
    }
  }
  function y(_) {
    return Da(_) ? function(S) {
      try {
        return new r(_.op, _.fn, S, _.implicit);
      } catch (b) {
        return console.error(b), [];
      }
    } : function(S) {
      return new t(new n(_.name), S);
    };
  }
  return {
    createMakeNodeFunction: y,
    hasProperty: l,
    isCommutative: d,
    isAssociative: f,
    mergeContext: m,
    flatten: h,
    allChildren: p,
    unflattenr: g,
    unflattenl: v,
    defaultContext: s,
    realContext: u,
    positiveContext: c
  };
}), vAe = "simplify", gAe = ["config", "typed", "parse", "add", "subtract", "multiply", "divide", "pow", "isZero", "equal", "resolve", "simplifyConstant", "simplifyCore", "?fraction", "?bignumber", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], yAe = /* @__PURE__ */ me(vAe, gAe, (e) => {
  var {
    config: t,
    typed: r,
    parse: n,
    add: a,
    subtract: i,
    multiply: o,
    divide: s,
    pow: u,
    isZero: c,
    equal: l,
    resolve: d,
    simplifyConstant: f,
    simplifyCore: m,
    fraction: h,
    bignumber: p,
    mathWithTransform: g,
    matrix: v,
    AccessorNode: y,
    ArrayNode: _,
    ConstantNode: S,
    FunctionNode: b,
    IndexNode: x,
    ObjectNode: A,
    OperatorNode: w,
    ParenthesisNode: C,
    SymbolNode: M
  } = e, {
    hasProperty: T,
    isCommutative: N,
    isAssociative: I,
    mergeContext: P,
    flatten: O,
    unflattenr: F,
    unflattenl: R,
    createMakeNodeFunction: G,
    defaultContext: L,
    realContext: q,
    positiveContext: K
  } = WS({
    FunctionNode: b,
    OperatorNode: w,
    SymbolNode: M
  });
  r.addConversion({
    from: "Object",
    to: "Map",
    convert: Np
  });
  var X = r("simplify", {
    Node: ie,
    "Node, Map": (le, ue) => ie(le, !1, ue),
    "Node, Map, Object": (le, ue, be) => ie(le, !1, ue, be),
    "Node, Array": ie,
    "Node, Array, Map": ie,
    "Node, Array, Map, Object": ie
  });
  r.removeConversion({
    from: "Object",
    to: "Map",
    convert: Np
  }), X.defaultContext = L, X.realContext = q, X.positiveContext = K;
  function H(le) {
    return le.transform(function(ue, be, Se) {
      return pc(ue) ? H(ue.content) : ue;
    });
  }
  var W = {
    true: !0,
    false: !0,
    e: !0,
    i: !0,
    Infinity: !0,
    LN2: !0,
    LN10: !0,
    LOG2E: !0,
    LOG10E: !0,
    NaN: !0,
    phi: !0,
    pi: !0,
    SQRT1_2: !0,
    SQRT2: !0,
    tau: !0
    // null: false,
    // undefined: false,
    // version: false,
  };
  X.rules = [
    m,
    // { l: 'n+0', r: 'n' },     // simplifyCore
    // { l: 'n^0', r: '1' },     // simplifyCore
    // { l: '0*n', r: '0' },     // simplifyCore
    // { l: 'n/n', r: '1'},      // simplifyCore
    // { l: 'n^1', r: 'n' },     // simplifyCore
    // { l: '+n1', r:'n1' },     // simplifyCore
    // { l: 'n--n1', r:'n+n1' }, // simplifyCore
    {
      l: "log(e)",
      r: "1"
    },
    // temporary rules
    // Note initially we tend constants to the right because like-term
    // collection prefers the left, and we would rather collect nonconstants
    {
      s: "n-n1 -> n+-n1",
      // temporarily replace 'subtract' so we can further flatten the 'add' operator
      assuming: {
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "n-n -> 0",
      // partial alternative when we can't always subtract
      assuming: {
        subtract: {
          total: !1
        }
      }
    },
    {
      s: "-(cl*v) -> v * (-cl)",
      // make non-constant terms positive
      assuming: {
        multiply: {
          commutative: !0
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "-(cl*v) -> (-cl) * v",
      // non-commutative version, part 1
      assuming: {
        multiply: {
          commutative: !1
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "-(v*cl) -> v * (-cl)",
      // non-commutative version, part 2
      assuming: {
        multiply: {
          commutative: !1
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      l: "-(n1/n2)",
      r: "-n1/n2"
    },
    {
      l: "-v",
      r: "v * (-1)"
    },
    // finish making non-constant terms positive
    {
      l: "(n1 + n2)*(-1)",
      r: "n1*(-1) + n2*(-1)",
      repeat: !0
    },
    // expand negations to achieve as much sign cancellation as possible
    {
      l: "n/n1^n2",
      r: "n*n1^-n2"
    },
    // temporarily replace 'divide' so we can further flatten the 'multiply' operator
    {
      l: "n/n1",
      r: "n*n1^-1"
    },
    {
      s: "(n1*n2)^n3 -> n1^n3 * n2^n3",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
    },
    {
      s: "(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    // expand nested exponentiation
    {
      s: "(n ^ n1) ^ n2 -> n ^ (n1 * n2)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // 1/(1/n) = n needs 1/n to exist
    },
    // collect like factors; into a sum, only do this for nonconstants
    {
      l: " vd   * ( vd   * n1 + n2)",
      r: "vd^2       * n1 +  vd   * n2"
    },
    {
      s: " vd   * (vd^n4 * n1 + n2)   ->  vd^(1+n4)  * n1 +  vd   * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
      // v*1/v = v^(1+-1) needs 1/v
    },
    {
      s: "vd^n3 * ( vd   * n1 + n2)   ->  vd^(n3+1)  * n1 + vd^n3 * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
    },
    {
      s: "vd^n3 * (vd^n4 * n1 + n2)   ->  vd^(n3+n4) * n1 + vd^n3 * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
    },
    {
      l: "n*n",
      r: "n^2"
    },
    {
      s: "n * n^n1 -> n^(n1+1)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // n*1/n = n^(-1+1) needs 1/n
    },
    {
      s: "n^n1 * n^n2 -> n^(n1+n2)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // ditto for n^2*1/n^2
    },
    // Unfortunately, to deal with more complicated cancellations, it
    // becomes necessary to simplify constants twice per pass. It's not
    // terribly expensive compared to matching rules, so this should not
    // pose a performance problem.
    f,
    // First: before collecting like terms
    // collect like terms
    {
      s: "n+n -> 2*n",
      assuming: {
        add: {
          total: !0
        }
      }
      // 2 = 1 + 1 needs to exist
    },
    {
      l: "n+-n",
      r: "0"
    },
    {
      l: "vd*n + vd",
      r: "vd*(n+1)"
    },
    // NOTE: leftmost position is special:
    {
      l: "n3*n1 + n3*n2",
      r: "n3*(n1+n2)"
    },
    // All sub-monomials tried there.
    {
      l: "n3^(-n4)*n1 +   n3  * n2",
      r: "n3^(-n4)*(n1 + n3^(n4+1) *n2)"
    },
    {
      l: "n3^(-n4)*n1 + n3^n5 * n2",
      r: "n3^(-n4)*(n1 + n3^(n4+n5)*n2)"
    },
    // noncommutative additional cases (term collection & factoring)
    {
      s: "n*vd + vd -> (n+1)*vd",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "vd + n*vd -> (1+n)*vd",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3 + n2*n3 -> (n1+n2)*n3",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n^n1 * n -> n^(n1+1)",
      assuming: {
        divide: {
          total: !0
        },
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3^(-n4) + n2 * n3    -> (n1 + n2*n3^(n4 +  1))*n3^(-n4)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      l: "n*cd + cd",
      r: "(n+1)*cd"
    },
    {
      s: "cd*n + cd -> cd*(n+1)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "cd + cd*n -> cd*(1+n)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    f,
    // Second: before returning expressions to "standard form"
    // make factors positive (and undo 'make non-constant terms positive')
    {
      s: "(-n)*n1 -> -(n*n1)",
      assuming: {
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "n1*(-n) -> -(n1*n)",
      // in case * non-commutative
      assuming: {
        subtract: {
          total: !0
        },
        multiply: {
          commutative: !1
        }
      }
    },
    // final ordering of constants
    {
      s: "ce+ve -> ve+ce",
      assuming: {
        add: {
          commutative: !0
        }
      },
      imposeContext: {
        add: {
          commutative: !1
        }
      }
    },
    {
      s: "vd*cd -> cd*vd",
      assuming: {
        multiply: {
          commutative: !0
        }
      },
      imposeContext: {
        multiply: {
          commutative: !1
        }
      }
    },
    // undo temporary rules
    // { l: '(-1) * n', r: '-n' }, // #811 added test which proved this is redundant
    {
      l: "n+-n1",
      r: "n-n1"
    },
    // undo replace 'subtract'
    {
      l: "n+-(n1)",
      r: "n-(n1)"
    },
    {
      s: "n*(n1^-1) -> n/n1",
      // undo replace 'divide'; for * commutative
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      s: "n*n1^-n2 -> n/n1^n2",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      s: "n^-1 -> 1/n",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      l: "n^1",
      r: "n"
    },
    // can be produced by power cancellation
    {
      s: "n*(n1/n2) -> (n*n1)/n2",
      // '*' before '/'
      assuming: {
        multiply: {
          associative: !0
        }
      }
    },
    {
      s: "n-(n1+n2) -> n-n1-n2",
      // '-' before '+'
      assuming: {
        addition: {
          associative: !0,
          commutative: !0
        }
      }
    },
    // { l: '(n1/n2)/n3', r: 'n1/(n2*n3)' },
    // { l: '(n*n1)/(n*n2)', r: 'n1/n2' },
    // simplifyConstant can leave an extra factor of 1, which can always
    // be eliminated, since the identity always commutes
    {
      l: "1*n",
      r: "n",
      imposeContext: {
        multiply: {
          commutative: !0
        }
      }
    },
    {
      s: "n1/(n2/n3) -> (n1*n3)/n2",
      assuming: {
        multiply: {
          associative: !0
        }
      }
    },
    {
      l: "n1/(-n2)",
      r: "-n1/n2"
    }
  ];
  function ee(le, ue) {
    var be = {};
    if (le.s) {
      var Se = le.s.split("->");
      if (Se.length === 2)
        be.l = Se[0], be.r = Se[1];
      else
        throw SyntaxError("Could not parse rule: " + le.s);
    } else
      be.l = le.l, be.r = le.r;
    be.l = H(n(be.l)), be.r = H(n(be.r));
    for (var Ne of ["imposeContext", "repeat", "assuming"])
      Ne in le && (be[Ne] = le[Ne]);
    if (le.evaluate && (be.evaluate = n(le.evaluate)), I(be.l, ue)) {
      var J = !N(be.l, ue), Z;
      J && (Z = re());
      var de = G(be.l), ye = re();
      be.expanded = {}, be.expanded.l = de([be.l, ye]), O(be.expanded.l, ue), F(be.expanded.l, ue), be.expanded.r = de([be.r, ye]), J && (be.expandedNC1 = {}, be.expandedNC1.l = de([Z, be.l]), be.expandedNC1.r = de([Z, be.r]), be.expandedNC2 = {}, be.expandedNC2.l = de([Z, be.expanded.l]), be.expandedNC2.r = de([Z, be.expanded.r]));
    }
    return be;
  }
  function $(le, ue) {
    for (var be = [], Se = 0; Se < le.length; Se++) {
      var Ne = le[Se], J = void 0, Z = typeof Ne;
      switch (Z) {
        case "string":
          Ne = {
            s: Ne
          };
        case "object":
          J = ee(Ne, ue);
          break;
        case "function":
          J = Ne;
          break;
        default:
          throw TypeError("Unsupported type of rule: " + Z);
      }
      be.push(J);
    }
    return be;
  }
  var te = 0;
  function re() {
    return new M("_p" + te++);
  }
  function ie(le, ue) {
    var be = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Eh(), Se = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, Ne = Se.consoleDebug;
    ue = $(ue || X.rules, Se.context);
    var J = d(le, be);
    J = H(J);
    for (var Z = {}, de = J.toString({
      parenthesis: "all"
    }); !Z[de]; ) {
      Z[de] = !0, te = 0;
      var ye = de;
      Ne && console.log("Working on: ", de);
      for (var Ae = 0; Ae < ue.length; Ae++) {
        var Ce = "";
        if (typeof ue[Ae] == "function" ? (J = ue[Ae](J, Se), Ne && (Ce = ue[Ae].name)) : (O(J, Se.context), J = se(J, ue[Ae], Se.context), Ne && (Ce = "".concat(ue[Ae].l.toString(), " -> ").concat(ue[Ae].r.toString()))), Ne) {
          var Ie = J.toString({
            parenthesis: "all"
          });
          Ie !== ye && (console.log("Applying", Ce, "produced", Ie), ye = Ie);
        }
        R(J, Se.context);
      }
      de = J.toString({
        parenthesis: "all"
      });
    }
    return J;
  }
  function oe(le, ue, be) {
    var Se = le;
    if (le)
      for (var Ne = 0; Ne < le.length; ++Ne) {
        var J = se(le[Ne], ue, be);
        J !== le[Ne] && (Se === le && (Se = le.slice()), Se[Ne] = J);
      }
    return Se;
  }
  function se(le, ue, be) {
    if (ue.assuming) {
      for (var Se in ue.assuming)
        for (var Ne in ue.assuming[Se])
          if (T(Se, Ne, be) !== ue.assuming[Se][Ne])
            return le;
    }
    var J = P(ue.imposeContext, be), Z = le;
    if (Z instanceof w || Z instanceof b) {
      var de = oe(Z.args, ue, be);
      de !== Z.args && (Z = Z.clone(), Z.args = de);
    } else if (Z instanceof C) {
      if (Z.content) {
        var ye = se(Z.content, ue, be);
        ye !== Z.content && (Z = new C(ye));
      }
    } else if (Z instanceof _) {
      var Ae = oe(Z.items, ue, be);
      Ae !== Z.items && (Z = new _(Ae));
    } else if (Z instanceof y) {
      var Ce = Z.object;
      Z.object && (Ce = se(Z.object, ue, be));
      var Ie = Z.index;
      Z.index && (Ie = se(Z.index, ue, be)), (Ce !== Z.object || Ie !== Z.index) && (Z = new y(Ce, Ie));
    } else if (Z instanceof x) {
      var Ue = oe(Z.dimensions, ue, be);
      Ue !== Z.dimensions && (Z = new x(Ue));
    } else if (Z instanceof A) {
      var Xe = !1, je = {};
      for (var ht in Z.properties)
        je[ht] = se(Z.properties[ht], ue, be), je[ht] !== Z.properties[ht] && (Xe = !0);
      Xe && (Z = new A(je));
    }
    var xt = ue.r, dt = ce(ue.l, Z, J)[0];
    if (!dt && ue.expanded && (xt = ue.expanded.r, dt = ce(ue.expanded.l, Z, J)[0]), !dt && ue.expandedNC1 && (xt = ue.expandedNC1.r, dt = ce(ue.expandedNC1.l, Z, J)[0], dt || (xt = ue.expandedNC2.r, dt = ce(ue.expandedNC2.l, Z, J)[0])), dt) {
      var Le = Z.implicit;
      Z = xt.clone(), Le && "implicit" in xt && (Z.implicit = !0), Z = Z.transform(function(j) {
        return j.isSymbolNode && Tt(dt.placeholders, j.name) ? dt.placeholders[j.name].clone() : j;
      });
    }
    return ue.repeat && Z !== le && (Z = se(Z, ue, be)), Z;
  }
  function he(le, ue) {
    var be = [], Se, Ne, J = G(le);
    if (N(le, ue))
      for (var Z = 0; Z < le.args.length; Z++)
        Ne = le.args.slice(0), Ne.splice(Z, 1), Se = Ne.length === 1 ? Ne[0] : J(Ne), be.push(J([le.args[Z], Se]));
    else
      for (var de = 1; de < le.args.length; de++) {
        var ye = le.args[0];
        de > 1 && (ye = J(le.args.slice(0, de))), Ne = le.args.slice(de), Se = Ne.length === 1 ? Ne[0] : J(Ne), be.push(J([ye, Se]));
      }
    return be;
  }
  function ge(le, ue) {
    var be = {
      placeholders: {}
    };
    if (!le.placeholders && !ue.placeholders)
      return be;
    if (le.placeholders) {
      if (!ue.placeholders)
        return le;
    } else return ue;
    for (var Se in le.placeholders)
      if (Tt(le.placeholders, Se) && (be.placeholders[Se] = le.placeholders[Se], Tt(ue.placeholders, Se) && !_e(le.placeholders[Se], ue.placeholders[Se])))
        return null;
    for (var Ne in ue.placeholders)
      Tt(ue.placeholders, Ne) && (be.placeholders[Ne] = ue.placeholders[Ne]);
    return be;
  }
  function De(le, ue) {
    var be = [];
    if (le.length === 0 || ue.length === 0)
      return be;
    for (var Se, Ne = 0; Ne < le.length; Ne++)
      for (var J = 0; J < ue.length; J++)
        Se = ge(le[Ne], ue[J]), Se && be.push(Se);
    return be;
  }
  function ae(le) {
    if (le.length === 0)
      return le;
    for (var ue = le.reduce(De), be = [], Se = {}, Ne = 0; Ne < ue.length; Ne++) {
      var J = JSON.stringify(ue[Ne]);
      Se[J] || (Se[J] = !0, be.push(ue[Ne]));
    }
    return be;
  }
  function ce(le, ue, be, Se) {
    var Ne = [{
      placeholders: {}
    }];
    if (le instanceof w && ue instanceof w || le instanceof b && ue instanceof b) {
      if (le instanceof w) {
        if (le.op !== ue.op || le.fn !== ue.fn)
          return [];
      } else if (le instanceof b && le.name !== ue.name)
        return [];
      if (ue.args.length === 1 && le.args.length === 1 || !I(ue, be) && ue.args.length === le.args.length || Se) {
        for (var J = [], Z = 0; Z < le.args.length; Z++) {
          var de = ce(le.args[Z], ue.args[Z], be);
          if (de.length === 0)
            break;
          J.push(de);
        }
        if (J.length !== le.args.length) {
          if (!N(ue, be) || // exact match in order needed
          le.args.length === 1)
            return [];
          if (le.args.length > 2)
            throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");
          var ye = ce(le.args[0], ue.args[1], be);
          if (ye.length === 0)
            return [];
          var Ae = ce(le.args[1], ue.args[0], be);
          if (Ae.length === 0)
            return [];
          J = [ye, Ae];
        }
        Ne = ae(J);
      } else if (ue.args.length >= 2 && le.args.length === 2) {
        for (var Ce = he(ue, be), Ie = [], Ue = 0; Ue < Ce.length; Ue++) {
          var Xe = ce(le, Ce[Ue], be, !0);
          Ie = Ie.concat(Xe);
        }
        return Ie;
      } else {
        if (le.args.length > 2)
          throw Error("Unexpected non-binary associative function: " + le.toString());
        return [];
      }
    } else if (le instanceof M) {
      if (le.name.length === 0)
        throw new Error("Symbol in rule has 0 length...!?");
      if (W[le.name]) {
        if (le.name !== ue.name)
          return [];
      } else
        switch (le.name[1] >= "a" && le.name[1] <= "z" ? le.name.substring(0, 2) : le.name[0]) {
          case "n":
          case "_p":
            Ne[0].placeholders[le.name] = ue;
            break;
          case "c":
          case "cl":
            if (Vr(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "v":
            if (!Vr(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "vl":
            if (Wa(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "cd":
            if (YB(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "vd":
            if (!YB(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "ce":
            if (e3(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          case "ve":
            if (!e3(ue))
              Ne[0].placeholders[le.name] = ue;
            else
              return [];
            break;
          default:
            throw new Error("Invalid symbol in rule: " + le.name);
        }
    } else if (le instanceof S) {
      if (!l(le.value, ue.value))
        return [];
    } else
      return [];
    return Ne;
  }
  function _e(le, ue) {
    if (le instanceof S && ue instanceof S) {
      if (!l(le.value, ue.value))
        return !1;
    } else if (le instanceof M && ue instanceof M) {
      if (le.name !== ue.name)
        return !1;
    } else if (le instanceof w && ue instanceof w || le instanceof b && ue instanceof b) {
      if (le instanceof w) {
        if (le.op !== ue.op || le.fn !== ue.fn)
          return !1;
      } else if (le instanceof b && le.name !== ue.name)
        return !1;
      if (le.args.length !== ue.args.length)
        return !1;
      for (var be = 0; be < le.args.length; be++)
        if (!_e(le.args[be], ue.args[be]))
          return !1;
    } else
      return !1;
    return !0;
  }
  return X;
}), bAe = "simplifyConstant", xAe = ["typed", "config", "mathWithTransform", "matrix", "?fraction", "?bignumber", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode"], _Ae = /* @__PURE__ */ me(bAe, xAe, (e) => {
  var {
    typed: t,
    config: r,
    mathWithTransform: n,
    matrix: a,
    fraction: i,
    bignumber: o,
    AccessorNode: s,
    ArrayNode: u,
    ConstantNode: c,
    FunctionNode: l,
    IndexNode: d,
    ObjectNode: f,
    OperatorNode: m,
    SymbolNode: h
  } = e, {
    isCommutative: p,
    isAssociative: g,
    allChildren: v,
    createMakeNodeFunction: y
  } = WS({
    FunctionNode: l,
    OperatorNode: m,
    SymbolNode: h
  }), _ = t("simplifyConstant", {
    Node: (O) => A(P(O, {})),
    "Node, Object": function(F, R) {
      return A(P(F, R));
    }
  });
  function S(O) {
    return vm(O) ? O.valueOf() : O instanceof Array ? O.map(S) : Zt(O) ? a(S(O.valueOf())) : O;
  }
  function b(O, F, R) {
    try {
      return n[O].apply(null, F);
    } catch {
      return F = F.map(S), C(n[O].apply(null, F), R);
    }
  }
  var x = t({
    Fraction: T,
    number: function(F) {
      return F < 0 ? M(new c(-F)) : new c(F);
    },
    BigNumber: function(F) {
      return F < 0 ? M(new c(-F)) : new c(F);
    },
    bigint: function(F) {
      return F < 0n ? M(new c(-F)) : new c(F);
    },
    Complex: function(F) {
      throw new Error("Cannot convert Complex number to Node");
    },
    string: function(F) {
      return new c(F);
    },
    Matrix: function(F) {
      return new u(F.valueOf().map((R) => x(R)));
    }
  });
  function A(O) {
    return gn(O) ? O : x(O);
  }
  function w(O, F) {
    var R = F && F.exactFractions !== !1;
    if (R && isFinite(O) && i) {
      var G = i(O), L = F && typeof F.fractionsLimit == "number" ? F.fractionsLimit : 1 / 0;
      if (G.valueOf() === O && G.n < L && G.d < L)
        return G;
    }
    return O;
  }
  var C = t({
    "string, Object": function(F, R) {
      var G = $d(F, r);
      if (G === "BigNumber")
        return o === void 0 && LS(), o(F);
      if (G === "bigint")
        return BigInt(F);
      if (G === "Fraction")
        return i === void 0 && wV(), i(F);
      var L = parseFloat(F);
      return w(L, R);
    },
    "Fraction, Object": function(F, R) {
      return F;
    },
    // we don't need options here
    "BigNumber, Object": function(F, R) {
      return F;
    },
    // we don't need options here
    "number, Object": function(F, R) {
      return w(F, R);
    },
    "bigint, Object": function(F, R) {
      return F;
    },
    "Complex, Object": function(F, R) {
      return F.im !== 0 ? F : w(F.re, R);
    },
    "Matrix, Object": function(F, R) {
      return a(w(F.valueOf()));
    },
    "Array, Object": function(F, R) {
      return F.map(w);
    }
  });
  function M(O) {
    return new m("-", "unaryMinus", [O]);
  }
  function T(O) {
    var F, R = O.s * O.n;
    return R < 0 ? F = new m("-", "unaryMinus", [new c(-R)]) : F = new c(R), O.d === 1 ? F : new m("/", "divide", [F, new c(O.d)]);
  }
  function N(O, F, R) {
    if (!gm(F))
      return new s(A(O), A(F));
    if (cs(O) || Zt(O)) {
      for (var G = Array.from(F.dimensions); G.length > 0; )
        if (Vr(G[0]) && typeof G[0].value != "string") {
          var L = C(G.shift().value, R);
          cs(O) ? O = O.items[L - 1] : (O = O.valueOf()[L - 1], O instanceof Array && (O = a(O)));
        } else if (G.length > 1 && Vr(G[1]) && typeof G[1].value != "string") {
          var q = C(G[1].value, R), K = [], X = cs(O) ? O.items : O.valueOf();
          for (var H of X)
            if (cs(H))
              K.push(H.items[q - 1]);
            else if (Zt(O))
              K.push(H[q - 1]);
            else
              break;
          if (K.length === X.length)
            cs(O) ? O = new u(K) : O = a(K), G.splice(1, 1);
          else
            break;
        } else
          break;
      return G.length === F.dimensions.length ? new s(A(O), F) : G.length > 0 ? (F = new d(G), new s(A(O), F)) : O;
    }
    if (Kh(O) && F.dimensions.length === 1 && Vr(F.dimensions[0])) {
      var W = F.dimensions[0].value;
      return W in O.properties ? O.properties[W] : new c();
    }
    return new s(A(O), F);
  }
  function I(O, F, R, G) {
    var L = F.shift(), q = F.reduce((K, X) => {
      if (!gn(X)) {
        var H = K.pop();
        if (gn(H))
          return [H, X];
        try {
          return K.push(b(O, [H, X], G)), K;
        } catch {
          K.push(H);
        }
      }
      K.push(A(K.pop()));
      var W = K.length === 1 ? K[0] : R(K);
      return [R([W, A(X)])];
    }, [L]);
    return q.length === 1 ? q[0] : R([q[0], x(q[1])]);
  }
  function P(O, F) {
    switch (O.type) {
      case "SymbolNode":
        return O;
      case "ConstantNode":
        switch (typeof O.value) {
          case "number":
            return C(O.value, F);
          case "bigint":
            return C(O.value, F);
          case "string":
            return O.value;
          default:
            if (!isNaN(O.value)) return C(O.value, F);
        }
        return O;
      case "FunctionNode":
        if (n[O.name] && n[O.name].rawArgs)
          return O;
        {
          var R = ["add", "multiply"];
          if (!R.includes(O.name)) {
            var G = O.args.map((se) => P(se, F));
            if (!G.some(gn))
              try {
                return b(O.name, G, F);
              } catch {
              }
            if (O.name === "size" && G.length === 1 && cs(G[0])) {
              for (var L = [], q = G[0]; cs(q); )
                L.push(q.items.length), q = q.items[0];
              return a(L);
            }
            return new l(O.name, G.map(A));
          }
        }
      case "OperatorNode": {
        var K = O.fn.toString(), X, H, W = y(O);
        if (Da(O) && O.isUnary())
          X = [P(O.args[0], F)], gn(X[0]) ? H = W(X) : H = b(K, X, F);
        else if (g(O, F.context))
          if (X = v(O, F.context), X = X.map((se) => P(se, F)), p(K, F.context)) {
            for (var ee = [], $ = [], te = 0; te < X.length; te++)
              gn(X[te]) ? $.push(X[te]) : ee.push(X[te]);
            ee.length > 1 ? (H = I(K, ee, W, F), $.unshift(H), H = I(K, $, W, F)) : H = I(K, X, W, F);
          } else
            H = I(K, X, W, F);
        else
          X = O.args.map((se) => P(se, F)), H = I(K, X, W, F);
        return H;
      }
      case "ParenthesisNode":
        return P(O.content, F);
      case "AccessorNode":
        return N(P(O.object, F), P(O.index, F), F);
      case "ArrayNode": {
        var re = O.items.map((se) => P(se, F));
        return re.some(gn) ? new u(re.map(A)) : a(re);
      }
      case "IndexNode":
        return new d(O.dimensions.map((se) => _(se, F)));
      case "ObjectNode": {
        var ie = {};
        for (var oe in O.properties)
          ie[oe] = _(O.properties[oe], F);
        return new f(ie);
      }
      case "AssignmentNode":
      case "BlockNode":
      case "FunctionAssignmentNode":
      case "RangeNode":
      case "ConditionalNode":
      default:
        throw new Error("Unimplemented node type in simplifyConstant: ".concat(O.type));
    }
  }
  return _;
}), ZB = "simplifyCore", SAe = ["typed", "parse", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], AAe = /* @__PURE__ */ me(ZB, SAe, (e) => {
  var {
    typed: t,
    parse: r,
    equal: n,
    isZero: a,
    add: i,
    subtract: o,
    multiply: s,
    divide: u,
    pow: c,
    AccessorNode: l,
    ArrayNode: d,
    ConstantNode: f,
    FunctionNode: m,
    IndexNode: h,
    ObjectNode: p,
    OperatorNode: g,
    ParenthesisNode: v,
    SymbolNode: y
  } = e, _ = new f(0), S = new f(1), b = new f(!0), x = new f(!1);
  function A(T) {
    return Da(T) && ["and", "not", "or"].includes(T.op);
  }
  var {
    hasProperty: w,
    isCommutative: C
  } = WS({
    FunctionNode: m,
    OperatorNode: g,
    SymbolNode: y
  });
  function M(T) {
    var N = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, I = N ? N.context : void 0;
    if (w(T, "trivial", I)) {
      if (vl(T) && T.args.length === 1)
        return M(T.args[0], N);
      var P = !1, O = 0;
      if (T.forEach(($) => {
        ++O, O === 1 && (P = M($, N));
      }), O === 1)
        return P;
    }
    var F = T;
    if (vl(F)) {
      var R = Tbe(F.name);
      if (R) {
        if (F.args.length > 2 && w(F, "associative", I))
          for (; F.args.length > 2; ) {
            var G = F.args.pop(), L = F.args.pop();
            F.args.push(new g(R, F.name, [G, L]));
          }
        F = new g(R, F.name, F.args);
      } else
        return new m(M(F.fn), F.args.map(($) => M($, N)));
    }
    if (Da(F) && F.isUnary()) {
      var q = M(F.args[0], N);
      if (F.op === "~" && Da(q) && q.isUnary() && q.op === "~" || F.op === "not" && Da(q) && q.isUnary() && q.op === "not" && A(q.args[0]))
        return q.args[0];
      var K = !0;
      if (F.op === "-" && Da(q) && (q.isBinary() && q.fn === "subtract" && (F = new g("-", "subtract", [q.args[1], q.args[0]]), K = !1), q.isUnary() && q.op === "-"))
        return q.args[0];
      if (K) return new g(F.op, F.fn, [q]);
    }
    if (Da(F) && F.isBinary()) {
      var X = M(F.args[0], N), H = M(F.args[1], N);
      if (F.op === "+") {
        if (Vr(X) && a(X.value))
          return H;
        if (Vr(H) && a(H.value))
          return X;
        Da(H) && H.isUnary() && H.op === "-" && (H = H.args[0], F = new g("-", "subtract", [X, H]));
      }
      if (F.op === "-")
        return Da(H) && H.isUnary() && H.op === "-" ? M(new g("+", "add", [X, H.args[0]]), N) : Vr(X) && a(X.value) ? M(new g("-", "unaryMinus", [H])) : Vr(H) && a(H.value) ? X : new g(F.op, F.fn, [X, H]);
      if (F.op === "*") {
        if (Vr(X)) {
          if (a(X.value))
            return _;
          if (n(X.value, 1))
            return H;
        }
        if (Vr(H)) {
          if (a(H.value))
            return _;
          if (n(H.value, 1))
            return X;
          if (C(F, I))
            return new g(F.op, F.fn, [H, X], F.implicit);
        }
        return new g(F.op, F.fn, [X, H], F.implicit);
      }
      if (F.op === "/")
        return Vr(X) && a(X.value) ? _ : Vr(H) && n(H.value, 1) ? X : new g(F.op, F.fn, [X, H]);
      if (F.op === "^" && Vr(H)) {
        if (a(H.value))
          return S;
        if (n(H.value, 1))
          return X;
      }
      if (F.op === "and") {
        if (Vr(X))
          if (X.value) {
            if (A(H)) return H;
            if (Vr(H))
              return H.value ? b : x;
          } else
            return x;
        if (Vr(H))
          if (H.value) {
            if (A(X)) return X;
          } else
            return x;
      }
      if (F.op === "or") {
        if (Vr(X)) {
          if (X.value)
            return b;
          if (A(H)) return H;
        }
        if (Vr(H)) {
          if (H.value)
            return b;
          if (A(X)) return X;
        }
      }
      return new g(F.op, F.fn, [X, H]);
    }
    if (Da(F))
      return new g(F.op, F.fn, F.args.map(($) => M($, N)));
    if (cs(F))
      return new d(F.items.map(($) => M($, N)));
    if (Xd(F))
      return new l(M(F.object, N), M(F.index, N));
    if (gm(F))
      return new h(F.dimensions.map(($) => M($, N)));
    if (Kh(F)) {
      var W = {};
      for (var ee in F.properties)
        W[ee] = M(F.properties[ee], N);
      return new p(W);
    }
    return F;
  }
  return t(ZB, {
    Node: M,
    "Node,Object": M
  });
}), wAe = "resolve", CAe = ["typed", "parse", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode"], EAe = /* @__PURE__ */ me(wAe, CAe, (e) => {
  var {
    typed: t,
    parse: r,
    ConstantNode: n,
    FunctionNode: a,
    OperatorNode: i,
    ParenthesisNode: o
  } = e;
  function s(u, c) {
    var l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
    if (!c)
      return u;
    if (Wa(u)) {
      if (l.has(u.name)) {
        var d = Array.from(l).join(", ");
        throw new ReferenceError("recursive loop of variable definitions among {".concat(d, "}"));
      }
      var f = c.get(u.name);
      if (gn(f)) {
        var m = new Set(l);
        return m.add(u.name), s(f, c, m);
      } else return typeof f == "number" ? r(String(f)) : f !== void 0 ? new n(f) : u;
    } else if (Da(u)) {
      var h = u.args.map(function(g) {
        return s(g, c, l);
      });
      return new i(u.op, u.fn, h, u.implicit);
    } else {
      if (pc(u))
        return new o(s(u.content, c, l));
      if (vl(u)) {
        var p = u.args.map(function(g) {
          return s(g, c, l);
        });
        return new a(u.name, p);
      }
    }
    return u.map((g) => s(g, c, l));
  }
  return t("resolve", {
    Node: s,
    "Node, Map | null | undefined": s,
    "Node, Object": (u, c) => s(u, Np(c)),
    // For arrays and matrices, we map `self` rather than `_resolve`
    // because resolve is fairly expensive anyway, and this way
    // we get nice error messages if one entry in the array has wrong type.
    "Array | Matrix": t.referToSelf((u) => (c) => c.map((l) => u(l))),
    "Array | Matrix, null | undefined": t.referToSelf((u) => (c) => c.map((l) => u(l))),
    "Array, Object": t.referTo("Array,Map", (u) => (c, l) => u(c, Np(l))),
    "Matrix, Object": t.referTo("Matrix,Map", (u) => (c, l) => u(c, Np(l))),
    "Array | Matrix, Map": t.referToSelf((u) => (c, l) => c.map((d) => u(d, l)))
  });
}), QB = "symbolicEqual", DAe = ["parse", "simplify", "typed", "OperatorNode"], MAe = /* @__PURE__ */ me(QB, DAe, (e) => {
  var {
    parse: t,
    simplify: r,
    typed: n,
    OperatorNode: a
  } = e;
  function i(o, s) {
    var u = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, c = new a("-", "subtract", [o, s]), l = r(c, {}, u);
    return Vr(l) && !l.value;
  }
  return n(QB, {
    "Node, Node": i,
    "Node, Node, Object": i
  });
}), $B = "derivative", IAe = ["typed", "config", "parse", "simplify", "equal", "isZero", "numeric", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], TAe = /* @__PURE__ */ me($B, IAe, (e) => {
  var {
    typed: t,
    config: r,
    parse: n,
    simplify: a,
    equal: i,
    isZero: o,
    numeric: s,
    ConstantNode: u,
    FunctionNode: c,
    OperatorNode: l,
    ParenthesisNode: d,
    SymbolNode: f
  } = e;
  function m(_, S) {
    var b = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
      simplify: !0
    }, x = {};
    g(x, _, S.name);
    var A = v(_, x);
    return b.simplify ? a(A) : A;
  }
  t.addConversion({
    from: "identifier",
    to: "SymbolNode",
    convert: n
  });
  var h = t($B, {
    "Node, SymbolNode": m,
    "Node, SymbolNode, Object": m
    /* TODO: implement and test syntax with order of derivatives -> implement as an option {order: number}
    'Node, SymbolNode, ConstantNode': function (expr, variable, {order}) {
      let res = expr
      for (let i = 0; i < order; i++) {
        let constNodes = {}
        constTag(constNodes, expr, variable.name)
        res = _derivative(res, constNodes)
      }
      return res
    }
    */
  });
  t.removeConversion({
    from: "identifier",
    to: "SymbolNode",
    convert: n
  }), h._simplify = !0, h.toTex = function(_) {
    return p.apply(null, _.args);
  };
  var p = t("_derivTex", {
    "Node, SymbolNode": function(S, b) {
      return Vr(S) && Nn(S.value) === "string" ? p(n(S.value).toString(), b.toString(), 1) : p(S.toTex(), b.toString(), 1);
    },
    "Node, ConstantNode": function(S, b) {
      if (Nn(b.value) === "string")
        return p(S, n(b.value));
      throw new Error("The second parameter to 'derivative' is a non-string constant");
    },
    "Node, SymbolNode, ConstantNode": function(S, b, x) {
      return p(S.toString(), b.name, x.value);
    },
    "string, string, number": function(S, b, x) {
      var A;
      return x === 1 ? A = "{d\\over d" + b + "}" : A = "{d^{" + x + "}\\over d" + b + "^{" + x + "}}", A + "\\left[".concat(S, "\\right]");
    }
  }), g = t("constTag", {
    "Object, ConstantNode, string": function(S, b) {
      return S[b] = !0, !0;
    },
    "Object, SymbolNode, string": function(S, b, x) {
      return b.name !== x ? (S[b] = !0, !0) : !1;
    },
    "Object, ParenthesisNode, string": function(S, b, x) {
      return g(S, b.content, x);
    },
    "Object, FunctionAssignmentNode, string": function(S, b, x) {
      return b.params.includes(x) ? g(S, b.expr, x) : (S[b] = !0, !0);
    },
    "Object, FunctionNode | OperatorNode, string": function(S, b, x) {
      if (b.args.length > 0) {
        for (var A = g(S, b.args[0], x), w = 1; w < b.args.length; ++w)
          A = g(S, b.args[w], x) && A;
        if (A)
          return S[b] = !0, !0;
      }
      return !1;
    }
  }), v = t("_derivative", {
    "ConstantNode, Object": function(S) {
      return y(0);
    },
    "SymbolNode, Object": function(S, b) {
      return b[S] !== void 0 ? y(0) : y(1);
    },
    "ParenthesisNode, Object": function(S, b) {
      return new d(v(S.content, b));
    },
    "FunctionAssignmentNode, Object": function(S, b) {
      return b[S] !== void 0 ? y(0) : v(S.expr, b);
    },
    "FunctionNode, Object": function(S, b) {
      if (b[S] !== void 0)
        return y(0);
      var x = S.args[0], A, w = !1, C = !1, M;
      switch (S.name) {
        case "cbrt":
          w = !0, M = new l("*", "multiply", [y(3), new l("^", "pow", [x, new l("/", "divide", [y(2), y(3)])])]);
          break;
        case "sqrt":
        case "nthRoot":
          if (S.args.length === 1)
            w = !0, M = new l("*", "multiply", [y(2), new c("sqrt", [x])]);
          else if (S.args.length === 2)
            return A = new l("/", "divide", [y(1), S.args[1]]), b[A] = b[S.args[1]], v(new l("^", "pow", [x, A]), b);
          break;
        case "log10":
          A = y(10);
        case "log":
          if (!A && S.args.length === 1)
            M = x.clone(), w = !0;
          else if (S.args.length === 1 && A || S.args.length === 2 && b[S.args[1]] !== void 0)
            M = new l("*", "multiply", [x.clone(), new c("log", [A || S.args[1]])]), w = !0;
          else if (S.args.length === 2)
            return v(new l("/", "divide", [new c("log", [x]), new c("log", [S.args[1]])]), b);
          break;
        case "pow":
          if (S.args.length === 2)
            return b[A] = b[S.args[1]], v(new l("^", "pow", [x, S.args[1]]), b);
          break;
        case "exp":
          M = new c("exp", [x.clone()]);
          break;
        case "sin":
          M = new c("cos", [x.clone()]);
          break;
        case "cos":
          M = new l("-", "unaryMinus", [new c("sin", [x.clone()])]);
          break;
        case "tan":
          M = new l("^", "pow", [new c("sec", [x.clone()]), y(2)]);
          break;
        case "sec":
          M = new l("*", "multiply", [S, new c("tan", [x.clone()])]);
          break;
        case "csc":
          C = !0, M = new l("*", "multiply", [S, new c("cot", [x.clone()])]);
          break;
        case "cot":
          C = !0, M = new l("^", "pow", [new c("csc", [x.clone()]), y(2)]);
          break;
        case "asin":
          w = !0, M = new c("sqrt", [new l("-", "subtract", [y(1), new l("^", "pow", [x.clone(), y(2)])])]);
          break;
        case "acos":
          w = !0, C = !0, M = new c("sqrt", [new l("-", "subtract", [y(1), new l("^", "pow", [x.clone(), y(2)])])]);
          break;
        case "atan":
          w = !0, M = new l("+", "add", [new l("^", "pow", [x.clone(), y(2)]), y(1)]);
          break;
        case "asec":
          w = !0, M = new l("*", "multiply", [new c("abs", [x.clone()]), new c("sqrt", [new l("-", "subtract", [new l("^", "pow", [x.clone(), y(2)]), y(1)])])]);
          break;
        case "acsc":
          w = !0, C = !0, M = new l("*", "multiply", [new c("abs", [x.clone()]), new c("sqrt", [new l("-", "subtract", [new l("^", "pow", [x.clone(), y(2)]), y(1)])])]);
          break;
        case "acot":
          w = !0, C = !0, M = new l("+", "add", [new l("^", "pow", [x.clone(), y(2)]), y(1)]);
          break;
        case "sinh":
          M = new c("cosh", [x.clone()]);
          break;
        case "cosh":
          M = new c("sinh", [x.clone()]);
          break;
        case "tanh":
          M = new l("^", "pow", [new c("sech", [x.clone()]), y(2)]);
          break;
        case "sech":
          C = !0, M = new l("*", "multiply", [S, new c("tanh", [x.clone()])]);
          break;
        case "csch":
          C = !0, M = new l("*", "multiply", [S, new c("coth", [x.clone()])]);
          break;
        case "coth":
          C = !0, M = new l("^", "pow", [new c("csch", [x.clone()]), y(2)]);
          break;
        case "asinh":
          w = !0, M = new c("sqrt", [new l("+", "add", [new l("^", "pow", [x.clone(), y(2)]), y(1)])]);
          break;
        case "acosh":
          w = !0, M = new c("sqrt", [new l("-", "subtract", [new l("^", "pow", [x.clone(), y(2)]), y(1)])]);
          break;
        case "atanh":
          w = !0, M = new l("-", "subtract", [y(1), new l("^", "pow", [x.clone(), y(2)])]);
          break;
        case "asech":
          w = !0, C = !0, M = new l("*", "multiply", [x.clone(), new c("sqrt", [new l("-", "subtract", [y(1), new l("^", "pow", [x.clone(), y(2)])])])]);
          break;
        case "acsch":
          w = !0, C = !0, M = new l("*", "multiply", [new c("abs", [x.clone()]), new c("sqrt", [new l("+", "add", [new l("^", "pow", [x.clone(), y(2)]), y(1)])])]);
          break;
        case "acoth":
          w = !0, C = !0, M = new l("-", "subtract", [y(1), new l("^", "pow", [x.clone(), y(2)])]);
          break;
        case "abs":
          M = new l("/", "divide", [new c(new f("abs"), [x.clone()]), x.clone()]);
          break;
        case "gamma":
        default:
          throw new Error('Cannot process function "' + S.name + '" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported');
      }
      var T, N;
      w ? (T = "/", N = "divide") : (T = "*", N = "multiply");
      var I = v(x, b);
      return C && (I = new l("-", "unaryMinus", [I])), new l(T, N, [I, M]);
    },
    "OperatorNode, Object": function(S, b) {
      if (b[S] !== void 0)
        return y(0);
      if (S.op === "+")
        return new l(S.op, S.fn, S.args.map(function(O) {
          return v(O, b);
        }));
      if (S.op === "-") {
        if (S.isUnary())
          return new l(S.op, S.fn, [v(S.args[0], b)]);
        if (S.isBinary())
          return new l(S.op, S.fn, [v(S.args[0], b), v(S.args[1], b)]);
      }
      if (S.op === "*") {
        var x = S.args.filter(function(O) {
          return b[O] !== void 0;
        });
        if (x.length > 0) {
          var A = S.args.filter(function(O) {
            return b[O] === void 0;
          }), w = A.length === 1 ? A[0] : new l("*", "multiply", A), C = x.concat(v(w, b));
          return new l("*", "multiply", C);
        }
        return new l("+", "add", S.args.map(function(O) {
          return new l("*", "multiply", S.args.map(function(F) {
            return F === O ? v(F, b) : F.clone();
          }));
        }));
      }
      if (S.op === "/" && S.isBinary()) {
        var M = S.args[0], T = S.args[1];
        return b[T] !== void 0 ? new l("/", "divide", [v(M, b), T]) : b[M] !== void 0 ? new l("*", "multiply", [new l("-", "unaryMinus", [M]), new l("/", "divide", [v(T, b), new l("^", "pow", [T.clone(), y(2)])])]) : new l("/", "divide", [new l("-", "subtract", [new l("*", "multiply", [v(M, b), T.clone()]), new l("*", "multiply", [M.clone(), v(T, b)])]), new l("^", "pow", [T.clone(), y(2)])]);
      }
      if (S.op === "^" && S.isBinary()) {
        var N = S.args[0], I = S.args[1];
        if (b[N] !== void 0)
          return Vr(N) && (o(N.value) || i(N.value, 1)) ? y(0) : new l("*", "multiply", [S, new l("*", "multiply", [new c("log", [N.clone()]), v(I.clone(), b)])]);
        if (b[I] !== void 0) {
          if (Vr(I)) {
            if (o(I.value))
              return y(0);
            if (i(I.value, 1))
              return v(N, b);
          }
          var P = new l("^", "pow", [N.clone(), new l("-", "subtract", [I, y(1)])]);
          return new l("*", "multiply", [I.clone(), new l("*", "multiply", [v(N, b), P])]);
        }
        return new l("*", "multiply", [new l("^", "pow", [N.clone(), I.clone()]), new l("+", "add", [new l("*", "multiply", [v(N, b), new l("/", "divide", [I.clone(), N.clone()])]), new l("*", "multiply", [v(I, b), new c("log", [N.clone()])])])]);
      }
      throw new Error('Cannot process operator "' + S.op + '" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported');
    }
  });
  function y(_, S) {
    return new u(s(_, $d(String(_), r)));
  }
  return h;
}), JB = "rationalize", NAe = ["config", "typed", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "parse", "simplifyConstant", "simplifyCore", "simplify", "?bignumber", "?fraction", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode", "ParenthesisNode"], PAe = /* @__PURE__ */ me(JB, NAe, (e) => {
  var {
    config: t,
    typed: r,
    equal: n,
    isZero: a,
    add: i,
    subtract: o,
    multiply: s,
    divide: u,
    pow: c,
    parse: l,
    simplifyConstant: d,
    simplifyCore: f,
    simplify: m,
    fraction: h,
    bignumber: p,
    mathWithTransform: g,
    matrix: v,
    AccessorNode: y,
    ArrayNode: _,
    ConstantNode: S,
    FunctionNode: b,
    IndexNode: x,
    ObjectNode: A,
    OperatorNode: w,
    SymbolNode: C,
    ParenthesisNode: M
  } = e;
  function T(F) {
    var R = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, G = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, L = I(), q = N(F, R, !0, L.firstRules), K = q.variables.length, X = {
      exactFractions: !1
    }, H = {
      exactFractions: !0
    };
    if (F = q.expression, K >= 1) {
      F = P(F);
      var W, ee, $ = !0, te = !1;
      F = m(F, L.firstRules, {}, X);
      for (var re; ee = $ ? L.distrDivRules : L.sucDivRules, F = m(F, ee, {}, H), $ = !$, re = F.toString(), re !== W; )
        te = !0, W = re;
      te && (F = m(F, L.firstRulesAgain, {}, X)), F = m(F, L.finalRules, {}, X);
    }
    var ie = [], oe = {};
    return F.type === "OperatorNode" && F.isBinary() && F.op === "/" ? (K === 1 && (F.args[0] = O(F.args[0], ie), F.args[1] = O(F.args[1])), G && (oe.numerator = F.args[0], oe.denominator = F.args[1])) : (K === 1 && (F = O(F, ie)), G && (oe.numerator = F, oe.denominator = null)), G ? (oe.coefficients = ie, oe.variables = q.variables, oe.expression = F, oe) : F;
  }
  return r(JB, {
    Node: T,
    "Node, boolean": (F, R) => T(F, {}, R),
    "Node, Object": T,
    "Node, Object, boolean": T
  });
  function N(F, R, G, L) {
    var q = [], K = m(F, L, R, {
      exactFractions: !1
    });
    G = !!G;
    var X = "+-*" + (G ? "/" : "");
    W(K);
    var H = {};
    return H.expression = K, H.variables = q, H;
    function W(ee) {
      var $ = ee.type;
      if ($ === "FunctionNode")
        throw new Error("There is an unsolved function call");
      if ($ === "OperatorNode")
        if (ee.op === "^") {
          if (ee.args[1].type !== "ConstantNode" || !Ut(parseFloat(ee.args[1].value)))
            throw new Error("There is a non-integer exponent");
          W(ee.args[0]);
        } else {
          if (!X.includes(ee.op))
            throw new Error("Operator " + ee.op + " invalid in polynomial expression");
          for (var te = 0; te < ee.args.length; te++)
            W(ee.args[te]);
        }
      else if ($ === "SymbolNode") {
        var re = ee.name, ie = q.indexOf(re);
        ie === -1 && q.push(re);
      } else if ($ === "ParenthesisNode")
        W(ee.content);
      else if ($ !== "ConstantNode")
        throw new Error("type " + $ + " is not allowed in polynomial expression");
    }
  }
  function I() {
    var F = [
      f,
      // sCore
      {
        l: "n+n",
        r: "2*n"
      },
      {
        l: "n+-n",
        r: "0"
      },
      d,
      // sConstant
      {
        l: "n*(n1^-1)",
        r: "n/n1"
      },
      {
        l: "n*n1^-n2",
        r: "n/n1^n2"
      },
      {
        l: "n1^-1",
        r: "1/n1"
      },
      {
        l: "n*(n1/n2)",
        r: "(n*n1)/n2"
      },
      {
        l: "1*n",
        r: "n"
      }
    ], R = [
      {
        l: "(-n1)/(-n2)",
        r: "n1/n2"
      },
      // Unary division
      {
        l: "(-n1)*(-n2)",
        r: "n1*n2"
      },
      // Unary multiplication
      {
        l: "n1--n2",
        r: "n1+n2"
      },
      // '--' elimination
      {
        l: "n1-n2",
        r: "n1+(-n2)"
      },
      // Subtraction turn into add with un�ry minus
      {
        l: "(n1+n2)*n3",
        r: "(n1*n3 + n2*n3)"
      },
      // Distributive 1
      {
        l: "n1*(n2+n3)",
        r: "(n1*n2+n1*n3)"
      },
      // Distributive 2
      {
        l: "c1*n + c2*n",
        r: "(c1+c2)*n"
      },
      // Joining constants
      {
        l: "c1*n + n",
        r: "(c1+1)*n"
      },
      // Joining constants
      {
        l: "c1*n - c2*n",
        r: "(c1-c2)*n"
      },
      // Joining constants
      {
        l: "c1*n - n",
        r: "(c1-1)*n"
      },
      // Joining constants
      {
        l: "v/c",
        r: "(1/c)*v"
      },
      // variable/constant (new!)
      {
        l: "v/-c",
        r: "-(1/c)*v"
      },
      // variable/constant (new!)
      {
        l: "-v*-c",
        r: "c*v"
      },
      // Inversion constant and variable 1
      {
        l: "-v*c",
        r: "-c*v"
      },
      // Inversion constant and variable 2
      {
        l: "v*-c",
        r: "-c*v"
      },
      // Inversion constant and variable 3
      {
        l: "v*c",
        r: "c*v"
      },
      // Inversion constant and variable 4
      {
        l: "-(-n1*n2)",
        r: "(n1*n2)"
      },
      // Unary propagation
      {
        l: "-(n1*n2)",
        r: "(-n1*n2)"
      },
      // Unary propagation
      {
        l: "-(-n1+n2)",
        r: "(n1-n2)"
      },
      // Unary propagation
      {
        l: "-(n1+n2)",
        r: "(-n1-n2)"
      },
      // Unary propagation
      {
        l: "(n1^n2)^n3",
        r: "(n1^(n2*n3))"
      },
      // Power to Power
      {
        l: "-(-n1/n2)",
        r: "(n1/n2)"
      },
      // Division and Unary
      {
        l: "-(n1/n2)",
        r: "(-n1/n2)"
      }
    ], G = [
      {
        l: "(n1/n2 + n3/n4)",
        r: "((n1*n4 + n3*n2)/(n2*n4))"
      },
      // Sum of fractions
      {
        l: "(n1/n2 + n3)",
        r: "((n1 + n3*n2)/n2)"
      },
      // Sum fraction with number 1
      {
        l: "(n1 + n2/n3)",
        r: "((n1*n3 + n2)/n3)"
      }
    ], L = [
      {
        l: "(n1/(n2/n3))",
        r: "((n1*n3)/n2)"
      },
      // Division simplification
      {
        l: "(n1/n2/n3)",
        r: "(n1/(n2*n3))"
      }
    ], q = {};
    return q.firstRules = F.concat(R, L), q.distrDivRules = G, q.sucDivRules = L, q.firstRulesAgain = F.concat(R), q.finalRules = [
      f,
      // simplify.rules[0]
      {
        l: "n*-n",
        r: "-n^2"
      },
      // Joining multiply with power 1
      {
        l: "n*n",
        r: "n^2"
      },
      // Joining multiply with power 2
      d,
      // simplify.rules[14] old 3rd index in oldRules
      {
        l: "n*-n^n1",
        r: "-n^(n1+1)"
      },
      // Joining multiply with power 3
      {
        l: "n*n^n1",
        r: "n^(n1+1)"
      },
      // Joining multiply with power 4
      {
        l: "n^n1*-n^n2",
        r: "-n^(n1+n2)"
      },
      // Joining multiply with power 5
      {
        l: "n^n1*n^n2",
        r: "n^(n1+n2)"
      },
      // Joining multiply with power 6
      {
        l: "n^n1*-n",
        r: "-n^(n1+1)"
      },
      // Joining multiply with power 7
      {
        l: "n^n1*n",
        r: "n^(n1+1)"
      },
      // Joining multiply with power 8
      {
        l: "n^n1/-n",
        r: "-n^(n1-1)"
      },
      // Joining multiply with power 8
      {
        l: "n^n1/n",
        r: "n^(n1-1)"
      },
      // Joining division with power 1
      {
        l: "n/-n^n1",
        r: "-n^(1-n1)"
      },
      // Joining division with power 2
      {
        l: "n/n^n1",
        r: "n^(1-n1)"
      },
      // Joining division with power 3
      {
        l: "n^n1/-n^n2",
        r: "n^(n1-n2)"
      },
      // Joining division with power 4
      {
        l: "n^n1/n^n2",
        r: "n^(n1-n2)"
      },
      // Joining division with power 5
      {
        l: "n1+(-n2*n3)",
        r: "n1-n2*n3"
      },
      // Solving useless parenthesis 1
      {
        l: "v*(-c)",
        r: "-c*v"
      },
      // Solving useless unary 2
      {
        l: "n1+-n2",
        r: "n1-n2"
      },
      // Solving +- together (new!)
      {
        l: "v*c",
        r: "c*v"
      },
      // inversion constant with variable
      {
        l: "(n1^n2)^n3",
        r: "(n1^(n2*n3))"
      }
      // Power to Power
    ], q;
  }
  function P(F, R, G) {
    var L = F.type, q = arguments.length > 1;
    if (L === "OperatorNode" && F.isBinary()) {
      var K = !1, X;
      if (F.op === "^" && (F.args[0].type === "ParenthesisNode" || F.args[0].type === "OperatorNode") && F.args[1].type === "ConstantNode" && (X = parseFloat(F.args[1].value), K = X >= 2 && Ut(X)), K) {
        if (X > 2) {
          var H = F.args[0], W = new w("^", "pow", [F.args[0].cloneDeep(), new S(X - 1)]);
          F = new w("*", "multiply", [H, W]);
        } else
          F = new w("*", "multiply", [F.args[0], F.args[0].cloneDeep()]);
        q && (G === "content" ? R.content = F : R.args[G] = F);
      }
    }
    if (L === "ParenthesisNode")
      P(F.content, F, "content");
    else if (L !== "ConstantNode" && L !== "SymbolNode")
      for (var ee = 0; ee < F.args.length; ee++)
        P(F.args[ee], F, ee);
    if (!q)
      return F;
  }
  function O(F, R) {
    R === void 0 && (R = []), R[0] = 0;
    var G = {};
    G.cte = 1, G.oper = "+", G.fire = "";
    var L = 0, q = "";
    re(F, null, G), L = R.length - 1;
    for (var K = !0, X, H = L; H >= 0; H--)
      if (R[H] !== 0) {
        var W = new S(K ? R[H] : Math.abs(R[H])), ee = R[H] < 0 ? "-" : "+";
        if (H > 0) {
          var $ = new C(q);
          if (H > 1) {
            var te = new S(H);
            $ = new w("^", "pow", [$, te]);
          }
          R[H] === -1 && K ? W = new w("-", "unaryMinus", [$]) : Math.abs(R[H]) === 1 ? W = $ : W = new w("*", "multiply", [W, $]);
        }
        K ? X = W : ee === "+" ? X = new w("+", "add", [X, W]) : X = new w("-", "subtract", [X, W]), K = !1;
      }
    if (K)
      return new S(0);
    return X;
    function re(ie, oe, se) {
      var he = ie.type;
      if (he === "FunctionNode")
        throw new Error("There is an unsolved function call");
      if (he === "OperatorNode") {
        if (!"+-*^".includes(ie.op)) throw new Error("Operator " + ie.op + " invalid");
        if (oe !== null) {
          if ((ie.fn === "unaryMinus" || ie.fn === "pow") && oe.fn !== "add" && oe.fn !== "subtract" && oe.fn !== "multiply")
            throw new Error("Invalid " + ie.op + " placing");
          if ((ie.fn === "subtract" || ie.fn === "add" || ie.fn === "multiply") && oe.fn !== "add" && oe.fn !== "subtract")
            throw new Error("Invalid " + ie.op + " placing");
          if ((ie.fn === "subtract" || ie.fn === "add" || ie.fn === "unaryMinus") && se.noFil !== 0)
            throw new Error("Invalid " + ie.op + " placing");
        }
        (ie.op === "^" || ie.op === "*") && (se.fire = ie.op);
        for (var ge = 0; ge < ie.args.length; ge++)
          ie.fn === "unaryMinus" && (se.oper = "-"), (ie.op === "+" || ie.fn === "subtract") && (se.fire = "", se.cte = 1, se.oper = ge === 0 ? "+" : ie.op), se.noFil = ge, re(ie.args[ge], ie, se);
      } else if (he === "SymbolNode") {
        if (ie.name !== q && q !== "")
          throw new Error("There is more than one variable");
        if (q = ie.name, oe === null) {
          R[1] = 1;
          return;
        }
        if (oe.op === "^" && se.noFil !== 0)
          throw new Error("In power the variable should be the first parameter");
        if (oe.op === "*" && se.noFil !== 1)
          throw new Error("In multiply the variable should be the second parameter");
        (se.fire === "" || se.fire === "*") && (L < 1 && (R[1] = 0), R[1] += se.cte * (se.oper === "+" ? 1 : -1), L = Math.max(1, L));
      } else if (he === "ConstantNode") {
        var De = parseFloat(ie.value);
        if (oe === null) {
          R[0] = De;
          return;
        }
        if (oe.op === "^") {
          if (se.noFil !== 1) throw new Error("Constant cannot be powered");
          if (!Ut(De) || De <= 0)
            throw new Error("Non-integer exponent is not allowed");
          for (var ae = L + 1; ae < De; ae++) R[ae] = 0;
          De > L && (R[De] = 0), R[De] += se.cte * (se.oper === "+" ? 1 : -1), L = Math.max(De, L);
          return;
        }
        se.cte = De, se.fire === "" && (R[0] += se.cte * (se.oper === "+" ? 1 : -1));
      } else
        throw new Error("Type " + he + " is not allowed");
    }
  }
}), eO = "zpk2tf", BAe = ["typed", "add", "multiply", "Complex", "number"], OAe = /* @__PURE__ */ me(eO, BAe, (e) => {
  var {
    typed: t,
    add: r,
    multiply: n,
    Complex: a,
    number: i
  } = e;
  return t(eO, {
    "Array,Array,number": function(c, l, d) {
      return o(c, l, d);
    },
    "Array,Array": function(c, l) {
      return o(c, l, 1);
    },
    "Matrix,Matrix,number": function(c, l, d) {
      return o(c.valueOf(), l.valueOf(), d);
    },
    "Matrix,Matrix": function(c, l) {
      return o(c.valueOf(), l.valueOf(), 1);
    }
  });
  function o(u, c, l) {
    u.some((y) => y.type === "BigNumber") && (u = u.map((y) => i(y))), c.some((y) => y.type === "BigNumber") && (c = c.map((y) => i(y)));
    for (var d = [a(1, 0)], f = [a(1, 0)], m = 0; m < u.length; m++) {
      var h = u[m];
      typeof h == "number" && (h = a(h, 0)), d = s(d, [a(1, 0), a(-h.re, -h.im)]);
    }
    for (var p = 0; p < c.length; p++) {
      var g = c[p];
      typeof g == "number" && (g = a(g, 0)), f = s(f, [a(1, 0), a(-g.re, -g.im)]);
    }
    for (var v = 0; v < d.length; v++)
      d[v] = n(d[v], l);
    return [d, f];
  }
  function s(u, c) {
    for (var l = [], d = 0; d < u.length + c.length - 1; d++) {
      l[d] = a(0, 0);
      for (var f = 0; f < u.length; f++)
        d - f >= 0 && d - f < c.length && (l[d] = r(l[d], n(u[f], c[d - f])));
    }
    return l;
  }
}), tO = "freqz", FAe = ["typed", "add", "multiply", "Complex", "divide", "matrix"], RAe = /* @__PURE__ */ me(tO, FAe, (e) => {
  var {
    typed: t,
    add: r,
    multiply: n,
    Complex: a,
    divide: i,
    matrix: o
  } = e;
  return t(tO, {
    "Array, Array": function(l, d) {
      var f = u(512);
      return s(l, d, f);
    },
    "Array, Array, Array": function(l, d, f) {
      return s(l, d, f);
    },
    "Array, Array, number": function(l, d, f) {
      if (f < 0)
        throw new Error("w must be a positive number");
      var m = u(f);
      return s(l, d, m);
    },
    "Matrix, Matrix": function(l, d) {
      var f = u(512), {
        w: m,
        h
      } = s(l.valueOf(), d.valueOf(), f);
      return {
        w: o(m),
        h: o(h)
      };
    },
    "Matrix, Matrix, Matrix": function(l, d, f) {
      var {
        h: m
      } = s(l.valueOf(), d.valueOf(), f.valueOf());
      return {
        h: o(m),
        w: o(f)
      };
    },
    "Matrix, Matrix, number": function(l, d, f) {
      if (f < 0)
        throw new Error("w must be a positive number");
      var m = u(f), {
        h
      } = s(l.valueOf(), d.valueOf(), m);
      return {
        h: o(h),
        w: o(m)
      };
    }
  });
  function s(c, l, d) {
    for (var f = [], m = [], h = 0; h < d.length; h++) {
      for (var p = a(0, 0), g = a(0, 0), v = 0; v < c.length; v++)
        p = r(p, n(c[v], a(Math.cos(-v * d[h]), Math.sin(-v * d[h]))));
      for (var y = 0; y < l.length; y++)
        g = r(g, n(l[y], a(Math.cos(-y * d[h]), Math.sin(-y * d[h]))));
      f.push(p), m.push(g);
    }
    for (var _ = [], S = 0; S < f.length; S++)
      _.push(i(f[S], m[S]));
    return {
      h: _,
      w: d
    };
  }
  function u(c) {
    for (var l = [], d = 0; d < c; d++)
      l.push(d / c * Math.PI);
    return l;
  }
}), LAe = "reviver", kAe = ["classes"], zAe = /* @__PURE__ */ me(LAe, kAe, (e) => {
  var {
    classes: t
  } = e;
  return function(n, a) {
    var i = t[a && a.mathjs];
    return i && typeof i.fromJSON == "function" ? i.fromJSON(a) : a;
  };
}), UAe = "replacer", GAe = [], VAe = /* @__PURE__ */ me(UAe, GAe, () => function(t, r) {
  return typeof r == "number" && (!isFinite(r) || isNaN(r)) ? {
    mathjs: "number",
    value: String(r)
  } : typeof r == "bigint" ? {
    mathjs: "bigint",
    value: String(r)
  } : r;
}), qAe = "13.0.1", HAe = /* @__PURE__ */ me("true", [], () => !0), KAe = /* @__PURE__ */ me("false", [], () => !1), XAe = /* @__PURE__ */ me("null", [], () => null), jAe = /* @__PURE__ */ _s("Infinity", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(1 / 0) : 1 / 0;
}), YAe = /* @__PURE__ */ _s("NaN", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(NaN) : NaN;
}), _q = /* @__PURE__ */ _s("pi", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? GS(r) : s0e;
}), WAe = /* @__PURE__ */ _s("tau", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? Uye(r) : u0e;
}), ZAe = /* @__PURE__ */ _s("e", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? kye(r) : c0e;
}), QAe = /* @__PURE__ */ _s("phi", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? zye(r) : l0e;
}), $Ae = /* @__PURE__ */ _s("LN2", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(2).ln() : Math.LN2;
}), JAe = /* @__PURE__ */ _s("LN10", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(10).ln() : Math.LN10;
}), e7e = /* @__PURE__ */ _s("LOG2E", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(1).div(new r(2).ln()) : Math.LOG2E;
}), t7e = /* @__PURE__ */ _s("LOG10E", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(1).div(new r(10).ln()) : Math.LOG10E;
}), r7e = /* @__PURE__ */ _s(
  // eslint-disable-line camelcase
  "SQRT1_2",
  ["config", "?BigNumber"],
  (e) => {
    var {
      config: t,
      BigNumber: r
    } = e;
    return t.number === "BigNumber" ? new r("0.5").sqrt() : Math.SQRT1_2;
  }
), n7e = /* @__PURE__ */ _s("SQRT2", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? new r(2).sqrt() : Math.SQRT2;
}), a7e = /* @__PURE__ */ _s("i", ["Complex"], (e) => {
  var {
    Complex: t
  } = e;
  return t.I;
}), i7e = /* @__PURE__ */ me("PI", ["pi"], (e) => {
  var {
    pi: t
  } = e;
  return t;
}), o7e = /* @__PURE__ */ me("E", ["e"], (e) => {
  var {
    e: t
  } = e;
  return t;
}), s7e = /* @__PURE__ */ me("version", [], () => qAe);
function _s(e, t, r) {
  return me(e, t, r, {
    recreateOnConfigChange: !0
  });
}
var u7e = /* @__PURE__ */ gr("speedOfLight", "299792458", "m s^-1"), c7e = /* @__PURE__ */ gr("gravitationConstant", "6.67430e-11", "m^3 kg^-1 s^-2"), l7e = /* @__PURE__ */ gr("planckConstant", "6.62607015e-34", "J s"), d7e = /* @__PURE__ */ gr("reducedPlanckConstant", "1.0545718176461565e-34", "J s"), f7e = /* @__PURE__ */ gr("magneticConstant", "1.25663706212e-6", "N A^-2"), m7e = /* @__PURE__ */ gr("electricConstant", "8.8541878128e-12", "F m^-1"), p7e = /* @__PURE__ */ gr("vacuumImpedance", "376.730313667", "ohm"), h7e = /* @__PURE__ */ gr("coulomb", "8.987551792261171e9", "N m^2 C^-2"), v7e = /* @__PURE__ */ gr("elementaryCharge", "1.602176634e-19", "C"), g7e = /* @__PURE__ */ gr("bohrMagneton", "9.2740100783e-24", "J T^-1"), y7e = /* @__PURE__ */ gr("conductanceQuantum", "7.748091729863649e-5", "S"), b7e = /* @__PURE__ */ gr("inverseConductanceQuantum", "12906.403729652257", "ohm"), x7e = /* @__PURE__ */ gr("magneticFluxQuantum", "2.0678338484619295e-15", "Wb"), _7e = /* @__PURE__ */ gr("nuclearMagneton", "5.0507837461e-27", "J T^-1"), S7e = /* @__PURE__ */ gr("klitzing", "25812.807459304513", "ohm"), A7e = /* @__PURE__ */ gr("bohrRadius", "5.29177210903e-11", "m"), w7e = /* @__PURE__ */ gr("classicalElectronRadius", "2.8179403262e-15", "m"), C7e = /* @__PURE__ */ gr("electronMass", "9.1093837015e-31", "kg"), E7e = /* @__PURE__ */ gr("fermiCoupling", "1.1663787e-5", "GeV^-2"), D7e = Y3("fineStructure", 0.0072973525693), M7e = /* @__PURE__ */ gr("hartreeEnergy", "4.3597447222071e-18", "J"), I7e = /* @__PURE__ */ gr("protonMass", "1.67262192369e-27", "kg"), T7e = /* @__PURE__ */ gr("deuteronMass", "3.3435830926e-27", "kg"), N7e = /* @__PURE__ */ gr("neutronMass", "1.6749271613e-27", "kg"), P7e = /* @__PURE__ */ gr("quantumOfCirculation", "3.6369475516e-4", "m^2 s^-1"), B7e = /* @__PURE__ */ gr("rydberg", "10973731.568160", "m^-1"), O7e = /* @__PURE__ */ gr("thomsonCrossSection", "6.6524587321e-29", "m^2"), F7e = Y3("weakMixingAngle", 0.2229), R7e = Y3("efimovFactor", 22.7), L7e = /* @__PURE__ */ gr("atomicMass", "1.66053906660e-27", "kg"), k7e = /* @__PURE__ */ gr("avogadro", "6.02214076e23", "mol^-1"), z7e = /* @__PURE__ */ gr("boltzmann", "1.380649e-23", "J K^-1"), U7e = /* @__PURE__ */ gr("faraday", "96485.33212331001", "C mol^-1"), G7e = /* @__PURE__ */ gr("firstRadiation", "3.7417718521927573e-16", "W m^2"), V7e = /* @__PURE__ */ gr("loschmidt", "2.686780111798444e25", "m^-3"), q7e = /* @__PURE__ */ gr("gasConstant", "8.31446261815324", "J K^-1 mol^-1"), H7e = /* @__PURE__ */ gr("molarPlanckConstant", "3.990312712893431e-10", "J s mol^-1"), K7e = /* @__PURE__ */ gr("molarVolume", "0.022413969545014137", "m^3 mol^-1"), X7e = Y3("sackurTetrode", -1.16487052358), j7e = /* @__PURE__ */ gr("secondRadiation", "0.014387768775039337", "m K"), Y7e = /* @__PURE__ */ gr("stefanBoltzmann", "5.67037441918443e-8", "W m^-2 K^-4"), W7e = /* @__PURE__ */ gr("wienDisplacement", "2.897771955e-3", "m K"), Z7e = /* @__PURE__ */ gr("molarMass", "0.99999999965e-3", "kg mol^-1"), Q7e = /* @__PURE__ */ gr("molarMassC12", "11.9999999958e-3", "kg mol^-1"), $7e = /* @__PURE__ */ gr("gravity", "9.80665", "m s^-2"), J7e = /* @__PURE__ */ gr("planckLength", "1.616255e-35", "m"), ewe = /* @__PURE__ */ gr("planckMass", "2.176435e-8", "kg"), twe = /* @__PURE__ */ gr("planckTime", "5.391245e-44", "s"), rwe = /* @__PURE__ */ gr("planckCharge", "1.87554603778e-18", "C"), nwe = /* @__PURE__ */ gr("planckTemperature", "1.416785e+32", "K");
function gr(e, t, r) {
  var n = ["config", "Unit", "BigNumber"];
  return me(e, n, (a) => {
    var {
      config: i,
      Unit: o,
      BigNumber: s
    } = a, u = i.number === "BigNumber" ? new s(t) : parseFloat(t), c = new o(u, r);
    return c.fixPrefix = !0, c;
  });
}
function Y3(e, t) {
  var r = ["config", "BigNumber"];
  return me(e, r, (n) => {
    var {
      config: a,
      BigNumber: i
    } = n;
    return a.number === "BigNumber" ? new i(t) : t;
  });
}
var awe = "apply", iwe = ["typed", "isInteger"], owe = /* @__PURE__ */ me(awe, iwe, (e) => {
  var {
    typed: t,
    isInteger: r
  } = e, n = NS({
    typed: t,
    isInteger: r
  });
  return t("apply", {
    "...any": function(i) {
      var o = i[1];
      _r(o) ? i[1] = o - 1 : hr(o) && (i[1] = o.minus(1));
      try {
        return n.apply(null, i);
      } catch (s) {
        throw wo(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), swe = "column", uwe = ["typed", "Index", "matrix", "range"], cwe = /* @__PURE__ */ me(swe, uwe, (e) => {
  var {
    typed: t,
    Index: r,
    matrix: n,
    range: a
  } = e, i = RS({
    typed: t,
    Index: r,
    matrix: n,
    range: a
  });
  return t("column", {
    "...any": function(s) {
      var u = s.length - 1, c = s[u];
      _r(c) && (s[u] = c - 1);
      try {
        return i.apply(null, s);
      } catch (l) {
        throw wo(l);
      }
    }
  });
}, {
  isTransformFunction: !0
});
function ZS(e, t, r) {
  var n = e.filter(function(u) {
    return Wa(u) && !(u.name in t) && !r.has(u.name);
  })[0];
  if (!n)
    throw new Error('No undefined variable found in inline expression "' + e + '"');
  var a = n.name, i = /* @__PURE__ */ new Map(), o = new yU(r, i, /* @__PURE__ */ new Set([a])), s = e.compile();
  return function(c) {
    return i.set(a, c), s.evaluate(o);
  };
}
var lwe = "filter", dwe = ["typed"], fwe = /* @__PURE__ */ me(lwe, dwe, (e) => {
  var {
    typed: t
  } = e;
  function r(a, i, o) {
    var s, u;
    return a[0] && (s = a[0].compile().evaluate(o)), a[1] && (Wa(a[1]) || x1(a[1]) ? u = a[1].compile().evaluate(o) : u = ZS(a[1], i, o)), n(s, u);
  }
  r.rawArgs = !0;
  var n = t("filter", {
    "Array, function": rO,
    "Matrix, function": function(i, o) {
      return i.create(rO(i.toArray(), o));
    },
    "Array, RegExp": Uy,
    "Matrix, RegExp": function(i, o) {
      return i.create(Uy(i.toArray(), o));
    }
  });
  return r;
}, {
  isTransformFunction: !0
});
function rO(e, t) {
  return KU(e, function(r, n, a) {
    return C1(t, r, [n + 1], a, "filter");
  });
}
var mwe = "forEach", pwe = ["typed"], hwe = /* @__PURE__ */ me(mwe, pwe, (e) => {
  var {
    typed: t
  } = e;
  function r(a, i, o) {
    var s, u;
    return a[0] && (s = a[0].compile().evaluate(o)), a[1] && (Wa(a[1]) || x1(a[1]) ? u = a[1].compile().evaluate(o) : u = ZS(a[1], i, o)), n(s, u);
  }
  r.rawArgs = !0;
  var n = t("forEach", {
    "Array | Matrix, function": function(i, o) {
      var s = function u(c, l) {
        if (Array.isArray(c))
          q3(c, function(d, f) {
            u(d, l.concat(f + 1));
          });
        else
          return C1(o, c, l, i, "forEach");
      };
      s(i.valueOf(), []);
    }
  });
  return r;
}, {
  isTransformFunction: !0
}), vwe = "index", gwe = ["Index", "getMatrixDataType"], ywe = /* @__PURE__ */ me(vwe, gwe, (e) => {
  var {
    Index: t,
    getMatrixDataType: r
  } = e;
  return function() {
    for (var a = [], i = 0, o = arguments.length; i < o; i++) {
      var s = arguments[i];
      if (L3(s))
        s.start--, s.end -= s.step > 0 ? 0 : 2;
      else if (s && s.isSet === !0)
        s = s.map(function(c) {
          return c - 1;
        });
      else if (en(s) || Zt(s))
        r(s) !== "boolean" && (s = s.map(function(c) {
          return c - 1;
        }));
      else if (_r(s))
        s--;
      else if (hr(s))
        s = s.toNumber() - 1;
      else if (typeof s != "string") throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
      a[i] = s;
    }
    var u = new t();
    return t.apply(u, a), u;
  };
}, {
  isTransformFunction: !0
}), bwe = "map", xwe = ["typed"], _we = /* @__PURE__ */ me(bwe, xwe, (e) => {
  var {
    typed: t
  } = e;
  function r(a, i, o) {
    var s, u;
    return a[0] && (s = a[0].compile().evaluate(o)), a[1] && (Wa(a[1]) || x1(a[1]) ? u = a[1].compile().evaluate(o) : u = ZS(a[1], i, o)), n(s, u);
  }
  r.rawArgs = !0;
  var n = t("map", {
    "Array, function": function(i, o) {
      return nO(i, o, i);
    },
    "Matrix, function": function(i, o) {
      return i.create(nO(i.valueOf(), o, i));
    }
  });
  return r;
}, {
  isTransformFunction: !0
});
function nO(e, t, r) {
  function n(a, i) {
    return Array.isArray(a) ? sl(a, function(o, s) {
      return n(o, i.concat(s + 1));
    }) : C1(t, a, i, r, "map");
  }
  return n(e, []);
}
function tf(e) {
  if (e.length === 2 && bs(e[0])) {
    e = e.slice();
    var t = e[1];
    _r(t) ? e[1] = t - 1 : hr(t) && (e[1] = t.minus(1));
  }
  return e;
}
var Swe = "max", Awe = ["typed", "config", "numeric", "larger"], wwe = /* @__PURE__ */ me(Swe, Awe, (e) => {
  var {
    typed: t,
    config: r,
    numeric: n,
    larger: a
  } = e, i = jV({
    typed: t,
    config: r,
    numeric: n,
    larger: a
  });
  return t("max", {
    "...any": function(s) {
      s = tf(s);
      try {
        return i.apply(null, s);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Cwe = "mean", Ewe = ["typed", "add", "divide"], Dwe = /* @__PURE__ */ me(Cwe, Ewe, (e) => {
  var {
    typed: t,
    add: r,
    divide: n
  } = e, a = hq({
    typed: t,
    add: r,
    divide: n
  });
  return t("mean", {
    "...any": function(o) {
      o = tf(o);
      try {
        return a.apply(null, o);
      } catch (s) {
        throw wo(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Mwe = "min", Iwe = ["typed", "config", "numeric", "smaller"], Twe = /* @__PURE__ */ me(Mwe, Iwe, (e) => {
  var {
    typed: t,
    config: r,
    numeric: n,
    smaller: a
  } = e, i = YV({
    typed: t,
    config: r,
    numeric: n,
    smaller: a
  });
  return t("min", {
    "...any": function(s) {
      s = tf(s);
      try {
        return i.apply(null, s);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Nwe = "range", Pwe = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], Bwe = /* @__PURE__ */ me(Nwe, Pwe, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: s,
    largerEq: u,
    add: c,
    isPositive: l
  } = e, d = kS({
    typed: t,
    config: r,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: s,
    largerEq: u,
    add: c,
    isPositive: l
  });
  return t("range", {
    "...any": function(m) {
      var h = m.length - 1, p = m[h];
      return typeof p != "boolean" && m.push(!0), d.apply(null, m);
    }
  });
}, {
  isTransformFunction: !0
}), Owe = "row", Fwe = ["typed", "Index", "matrix", "range"], Rwe = /* @__PURE__ */ me(Owe, Fwe, (e) => {
  var {
    typed: t,
    Index: r,
    matrix: n,
    range: a
  } = e, i = DV({
    typed: t,
    Index: r,
    matrix: n,
    range: a
  });
  return t("row", {
    "...any": function(s) {
      var u = s.length - 1, c = s[u];
      _r(c) && (s[u] = c - 1);
      try {
        return i.apply(null, s);
      } catch (l) {
        throw wo(l);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Lwe = "subset", kwe = ["typed", "matrix", "zeros", "add"], zwe = /* @__PURE__ */ me(Lwe, kwe, (e) => {
  var {
    typed: t,
    matrix: r,
    zeros: n,
    add: a
  } = e, i = IV({
    typed: t,
    matrix: r,
    zeros: n,
    add: a
  });
  return t("subset", {
    "...any": function(s) {
      try {
        return i.apply(null, s);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Uwe = "concat", Gwe = ["typed", "matrix", "isInteger"], Vwe = /* @__PURE__ */ me(Uwe, Gwe, (e) => {
  var {
    typed: t,
    matrix: r,
    isInteger: n
  } = e, a = FS({
    typed: t,
    matrix: r,
    isInteger: n
  });
  return t("concat", {
    "...any": function(o) {
      var s = o.length - 1, u = o[s];
      _r(u) ? o[s] = u - 1 : hr(u) && (o[s] = u.minus(1));
      try {
        return a.apply(null, o);
      } catch (c) {
        throw wo(c);
      }
    }
  });
}, {
  isTransformFunction: !0
}), aO = "diff", qwe = ["typed", "matrix", "subtract", "number", "bignumber"], Hwe = /* @__PURE__ */ me(aO, qwe, (e) => {
  var {
    typed: t,
    matrix: r,
    subtract: n,
    number: a,
    bignumber: i
  } = e, o = AV({
    typed: t,
    matrix: r,
    subtract: n,
    number: a,
    bignumber: i
  });
  return t(aO, {
    "...any": function(u) {
      u = tf(u);
      try {
        return o.apply(null, u);
      } catch (c) {
        throw wo(c);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Kwe = "std", Xwe = ["typed", "map", "sqrt", "variance"], jwe = /* @__PURE__ */ me(Kwe, Xwe, (e) => {
  var {
    typed: t,
    map: r,
    sqrt: n,
    variance: a
  } = e, i = yq({
    typed: t,
    map: r,
    sqrt: n,
    variance: a
  });
  return t("std", {
    "...any": function(s) {
      s = tf(s);
      try {
        return i.apply(null, s);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), iO = "sum", Ywe = ["typed", "config", "add", "numeric"], Wwe = /* @__PURE__ */ me(iO, Ywe, (e) => {
  var {
    typed: t,
    config: r,
    add: n,
    numeric: a
  } = e, i = mq({
    typed: t,
    config: r,
    add: n,
    numeric: a
  });
  return t(iO, {
    "...any": function(s) {
      s = tf(s);
      try {
        return i.apply(null, s);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Zwe = "quantileSeq", Qwe = ["typed", "bignumber", "add", "subtract", "divide", "multiply", "partitionSelect", "compare", "isInteger", "smaller", "smallerEq", "larger"], $we = /* @__PURE__ */ me(Zwe, Qwe, (e) => {
  var {
    typed: t,
    bignumber: r,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: s,
    compare: u,
    isInteger: c,
    smaller: l,
    smallerEq: d,
    larger: f
  } = e, m = gq({
    typed: t,
    bignumber: r,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: s,
    compare: u,
    isInteger: c,
    smaller: l,
    smallerEq: d,
    larger: f
  });
  return t("quantileSeq", {
    "Array | Matrix, number | BigNumber": m,
    "Array | Matrix, number | BigNumber, number": (p, g, v) => m(p, g, h(v)),
    "Array | Matrix, number | BigNumber, boolean": m,
    "Array | Matrix, number | BigNumber, boolean, number": (p, g, v, y) => m(p, g, v, h(y)),
    "Array | Matrix, Array | Matrix": m,
    "Array | Matrix, Array | Matrix, number": (p, g, v) => m(p, g, h(v)),
    "Array | Matrix, Array | Matrix, boolean": m,
    "Array | Matrix, Array | Matrix, boolean, number": (p, g, v, y) => m(p, g, v, h(y))
  });
  function h(p) {
    return tf([[], p])[1];
  }
}, {
  isTransformFunction: !0
}), oO = "cumsum", Jwe = ["typed", "add", "unaryPlus"], e9e = /* @__PURE__ */ me(oO, Jwe, (e) => {
  var {
    typed: t,
    add: r,
    unaryPlus: n
  } = e, a = pq({
    typed: t,
    add: r,
    unaryPlus: n
  });
  return t(oO, {
    "...any": function(o) {
      if (o.length === 2 && bs(o[0])) {
        var s = o[1];
        _r(s) ? o[1] = s - 1 : hr(s) && (o[1] = s.minus(1));
      }
      try {
        return a.apply(null, o);
      } catch (u) {
        throw wo(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), sO = "variance", t9e = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"], r9e = /* @__PURE__ */ me(sO, t9e, (e) => {
  var {
    typed: t,
    add: r,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: s
  } = e, u = vq({
    typed: t,
    add: r,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: s
  });
  return t(sO, {
    "...any": function(l) {
      l = tf(l);
      try {
        return u.apply(null, l);
      } catch (d) {
        throw wo(d);
      }
    }
  });
}, {
  isTransformFunction: !0
}), uO = "print", n9e = ["typed", "matrix", "zeros", "add"], a9e = /* @__PURE__ */ me(uO, n9e, (e) => {
  var {
    typed: t,
    matrix: r,
    zeros: n,
    add: a
  } = e, i = OV({
    typed: t,
    matrix: r,
    zeros: n,
    add: a
  });
  return t(uO, {
    "string, Object | Array": function(u, c) {
      return i(o(u), c);
    },
    "string, Object | Array, number | Object": function(u, c, l) {
      return i(o(u), c, l);
    }
  });
  function o(s) {
    return s.replace(BV, (u) => {
      var c = u.slice(1).split("."), l = c.map(function(d) {
        return !isNaN(d) && d.length > 0 ? parseInt(d) - 1 : d;
      });
      return "$" + l.join(".");
    });
  }
}, {
  isTransformFunction: !0
}), i9e = "and", o9e = ["typed", "matrix", "zeros", "add", "equalScalar", "not", "concat"], s9e = /* @__PURE__ */ me(i9e, o9e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, s = GV({
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  });
  function u(c, l, d) {
    var f = c[0].compile().evaluate(d);
    if (!bs(f) && !s(f, !0))
      return !1;
    var m = c[1].compile().evaluate(d);
    return s(f, m);
  }
  return u.rawArgs = !0, u;
}, {
  isTransformFunction: !0
}), u9e = "or", c9e = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], l9e = /* @__PURE__ */ me(u9e, c9e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = gV({
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  });
  function s(u, c, l) {
    var d = u[0].compile().evaluate(l);
    if (!bs(d) && o(d, !1))
      return !0;
    var f = u[1].compile().evaluate(l);
    return o(d, f);
  }
  return s.rawArgs = !0, s;
}, {
  isTransformFunction: !0
}), d9e = "bitAnd", f9e = ["typed", "matrix", "zeros", "add", "equalScalar", "not", "concat"], m9e = /* @__PURE__ */ me(d9e, f9e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, s = fV({
    typed: t,
    matrix: r,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  });
  function u(c, l, d) {
    var f = c[0].compile().evaluate(d);
    if (!bs(f)) {
      if (isNaN(f))
        return NaN;
      if (f === 0 || f === !1)
        return 0;
    }
    var m = c[1].compile().evaluate(d);
    return s(f, m);
  }
  return u.rawArgs = !0, u;
}, {
  isTransformFunction: !0
}), p9e = "bitOr", h9e = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], v9e = /* @__PURE__ */ me(p9e, h9e, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = mV({
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  });
  function s(u, c, l) {
    var d = u[0].compile().evaluate(l);
    if (!bs(d)) {
      if (isNaN(d))
        return NaN;
      if (d === -1)
        return -1;
      if (d === !0)
        return 1;
    }
    var f = u[1].compile().evaluate(l);
    return o(d, f);
  }
  return s.rawArgs = !0, s;
}, {
  isTransformFunction: !0
});
const g9e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  createAbs: rV,
  createAccessorNode: Ebe,
  createAcos: Qye,
  createAcosh: Jye,
  createAcot: t3e,
  createAcoth: n3e,
  createAcsc: i3e,
  createAcsch: s3e,
  createAdd: eq,
  createAddScalar: nV,
  createAnd: GV,
  createAndTransform: s9e,
  createApply: NS,
  createApplyTransform: owe,
  createArg: Uve,
  createArrayNode: Mbe,
  createAsec: c3e,
  createAsech: d3e,
  createAsin: m3e,
  createAsinh: v3e,
  createAssignmentNode: Pbe,
  createAtan: QV,
  createAtan2: x3e,
  createAtanh: S3e,
  createAtomicMass: L7e,
  createAvogadro: k7e,
  createBellNumbers: sAe,
  createBigNumberClass: OU,
  createBigint: R0e,
  createBignumber: ZG,
  createBin: l2e,
  createBitAnd: fV,
  createBitAndTransform: m9e,
  createBitNot: Bve,
  createBitOr: mV,
  createBitOrTransform: v9e,
  createBitXor: kve,
  createBlockNode: Obe,
  createBohrMagneton: g7e,
  createBohrRadius: A7e,
  createBoltzmann: z7e,
  createBoolean: U0e,
  createCatalan: cAe,
  createCbrt: lhe,
  createCeil: bhe,
  createChain: O8e,
  createChainClass: nxe,
  createClassicalElectronRadius: w7e,
  createClone: n0e,
  createColumn: RS,
  createColumnTransform: cwe,
  createCombinations: bSe,
  createCombinationsWithRep: _Se,
  createCompare: Q2e,
  createCompareNatural: tye,
  createCompareText: aye,
  createCompile: m4e,
  createComplex: QG,
  createComplexClass: RU,
  createComposition: dAe,
  createConcat: FS,
  createConcatTransform: Vwe,
  createConditionalNode: Rbe,
  createConductanceQuantum: y7e,
  createConj: pV,
  createConstantNode: Hbe,
  createCorr: gSe,
  createCos: $V,
  createCosh: C3e,
  createCot: D3e,
  createCoth: I3e,
  createCoulomb: h7e,
  createCount: $ve,
  createCreateUnit: Wye,
  createCross: yV,
  createCsc: N3e,
  createCsch: B3e,
  createCtranspose: NV,
  createCube: _he,
  createCumSum: pq,
  createCumSumTransform: e9e,
  createDeepEqual: yye,
  createDenseMatrixClass: QU,
  createDerivative: TAe,
  createDet: cq,
  createDeuteronMass: T7e,
  createDiag: bV,
  createDiff: AV,
  createDiffTransform: Hwe,
  createDistance: rSe,
  createDivide: fq,
  createDivideScalar: RV,
  createDot: rq,
  createDotDivide: O2e,
  createDotMultiply: Cve,
  createDotPow: P2e,
  createE: ZAe,
  createEfimovFactor: R7e,
  createEigs: dq,
  createElectricConstant: m7e,
  createElectronMass: C7e,
  createElementaryCharge: v7e,
  createEqual: VV,
  createEqualScalar: jG,
  createEqualText: uye,
  createErf: Qge,
  createEvaluate: h4e,
  createExp: Ahe,
  createExpm: H8e,
  createExpm1: Che,
  createFactorial: DSe,
  createFalse: KAe,
  createFaraday: U7e,
  createFermiCoupling: E7e,
  createFft: Uge,
  createFibonacciHeapClass: Oye,
  createFilter: nge,
  createFilterTransform: fwe,
  createFineStructure: D7e,
  createFirstRadiation: G7e,
  createFix: Mhe,
  createFlatten: xV,
  createFloor: iV,
  createForEach: oge,
  createForEachTransform: hwe,
  createFormat: u2e,
  createFraction: $G,
  createFractionClass: LU,
  createFreqz: RAe,
  createFunctionAssignmentNode: Xbe,
  createFunctionNode: c4e,
  createGamma: ASe,
  createGasConstant: q7e,
  createGcd: $he,
  createGetMatrixDataType: _V,
  createGravitationConstant: c7e,
  createGravity: $7e,
  createHartreeEnergy: M7e,
  createHasNumericValue: b0e,
  createHelp: P8e,
  createHelpClass: exe,
  createHex: p2e,
  createHypot: pbe,
  createI: a7e,
  createIdentity: SV,
  createIfft: Vge,
  createIm: hV,
  createImmutableDenseMatrixClass: WV,
  createIndex: _be,
  createIndexClass: ZV,
  createIndexNode: Ybe,
  createIndexTransform: ywe,
  createInfinity: jAe,
  createIntersect: iSe,
  createInv: lq,
  createInverseConductanceQuantum: b7e,
  createInvmod: _ve,
  createIsInteger: JU,
  createIsNaN: A0e,
  createIsNegative: h0e,
  createIsNumeric: g0e,
  createIsPositive: KG,
  createIsPrime: b2e,
  createIsZero: XG,
  createKldivergence: ISe,
  createKlitzing: S7e,
  createKron: dge,
  createLN10: JAe,
  createLN2: $Ae,
  createLOG10E: t7e,
  createLOG2E: e7e,
  createLarger: KV,
  createLargerEq: XV,
  createLcm: rve,
  createLeafCount: mAe,
  createLeftShift: H2e,
  createLgamma: CSe,
  createLog: E2e,
  createLog10: ave,
  createLog1p: M2e,
  createLog2: ove,
  createLoschmidt: V7e,
  createLsolve: R2e,
  createLsolveAll: z2e,
  createLup: S4e,
  createLusolve: W4e,
  createLyap: $8e,
  createMad: fSe,
  createMagneticConstant: f7e,
  createMagneticFluxQuantum: x7e,
  createMap: mge,
  createMapTransform: _we,
  createMatrix: JG,
  createMatrixClass: kU,
  createMatrixFromColumns: eV,
  createMatrixFromFunction: W0e,
  createMatrixFromRows: Q0e,
  createMax: jV,
  createMaxTransform: wwe,
  createMean: hq,
  createMeanTransform: Dwe,
  createMedian: lSe,
  createMin: YV,
  createMinTransform: Twe,
  createMod: PS,
  createMode: a2e,
  createMolarMass: Z7e,
  createMolarMassC12: Q7e,
  createMolarPlanckConstant: H7e,
  createMolarVolume: K7e,
  createMultinomial: NSe,
  createMultiply: sV,
  createMultiplyScalar: oV,
  createNaN: YAe,
  createNeutronMass: N7e,
  createNode: wbe,
  createNorm: tq,
  createNot: Kve,
  createNthRoot: dve,
  createNthRoots: T2e,
  createNuclearMagneton: _7e,
  createNull: XAe,
  createNumber: WG,
  createNumeric: FV,
  createObjectNode: Zbe,
  createOct: f2e,
  createOnes: yge,
  createOperatorNode: $be,
  createOr: gV,
  createOrTransform: l9e,
  createParenthesisNode: e4e,
  createParse: d4e,
  createParser: x4e,
  createParserClass: y4e,
  createPartitionSelect: Aye,
  createPermutations: BSe,
  createPhi: QAe,
  createPi: _q,
  createPickRandom: JSe,
  createPinv: k8e,
  createPlanckCharge: rwe,
  createPlanckConstant: l7e,
  createPlanckLength: J7e,
  createPlanckMass: ewe,
  createPlanckTemperature: nwe,
  createPlanckTime: twe,
  createPolynomialRoot: Q4e,
  createPow: LV,
  createPrint: OV,
  createPrintTransform: a9e,
  createProd: o2e,
  createProtonMass: I7e,
  createQr: oq,
  createQuantileSeq: gq,
  createQuantileSeqTransform: $we,
  createQuantumOfCirculation: P7e,
  createRandom: tAe,
  createRandomInt: nAe,
  createRange: kS,
  createRangeClass: G1e,
  createRangeNode: r4e,
  createRangeTransform: Bwe,
  createRationalize: PAe,
  createRe: vV,
  createReducedPlanckConstant: d7e,
  createRelationalNode: a4e,
  createReplacer: VAe,
  createReshape: EV,
  createResize: Age,
  createResolve: EAe,
  createResultSet: Ppe,
  createReviver: zAe,
  createRightArithShift: X2e,
  createRightLogShift: Y2e,
  createRotate: Cge,
  createRotationMatrix: Dge,
  createRound: kV,
  createRow: DV,
  createRowTransform: Rwe,
  createRydberg: B7e,
  createSQRT1_2: r7e,
  createSQRT2: n7e,
  createSackurTetrode: X7e,
  createSchur: Z8e,
  createSec: F3e,
  createSech: L3e,
  createSecondRadiation: j7e,
  createSetCartesian: j3e,
  createSetDifference: W3e,
  createSetDistinct: Q3e,
  createSetIntersect: J3e,
  createSetIsSubset: tbe,
  createSetMultiplicity: nbe,
  createSetPowerset: ibe,
  createSetSize: sbe,
  createSetSymDifference: cbe,
  createSetUnion: dbe,
  createSign: uV,
  createSimplify: yAe,
  createSimplifyConstant: _Ae,
  createSimplifyCore: AAe,
  createSin: JV,
  createSinh: U3e,
  createSize: MV,
  createSlu: j4e,
  createSmaller: qV,
  createSmallerEq: HV,
  createSolveODE: Yge,
  createSort: Cye,
  createSpaClass: Lye,
  createSparse: jye,
  createSparseMatrixClass: YG,
  createSpeedOfLight: u7e,
  createSplitUnit: ehe,
  createSqrt: cV,
  createSqrtm: X8e,
  createSquare: vve,
  createSqueeze: Nge,
  createStd: yq,
  createStdTransform: jwe,
  createStefanBoltzmann: Y7e,
  createStirlingS2: iAe,
  createString: k0e,
  createSubset: IV,
  createSubsetTransform: zwe,
  createSubtract: lV,
  createSubtractScalar: aV,
  createSum: mq,
  createSumTransform: Wwe,
  createSylvester: Y8e,
  createSymbolNode: s4e,
  createSymbolicEqual: MAe,
  createTan: V3e,
  createTanh: K3e,
  createTau: WAe,
  createThomsonCrossSection: O7e,
  createTo: g2e,
  createTrace: bbe,
  createTranspose: TV,
  createTrue: HAe,
  createTypeOf: C0e,
  createTyped: SU,
  createUnaryMinus: tV,
  createUnaryPlus: nhe,
  createUnequal: xye,
  createUnitClass: qye,
  createUnitFunction: Kye,
  createUppercaseE: o7e,
  createUppercasePi: i7e,
  createUsolve: zV,
  createUsolveAll: UV,
  createVacuumImpedance: p7e,
  createVariance: vq,
  createVarianceTransform: r9e,
  createVersion: s7e,
  createWeakMixingAngle: F7e,
  createWienDisplacement: W7e,
  createXgcd: bve,
  createXor: Yve,
  createZeros: PV,
  createZeta: r2e,
  createZpk2tf: OAe
}, Symbol.toStringTag, { value: "Module" }));
var xm = /* @__PURE__ */ OU({
  config: gi
}), W3 = /* @__PURE__ */ RU({}), QS = /* @__PURE__ */ LU({}), $S = /* @__PURE__ */ kU({}), eo = /* @__PURE__ */ QU({
  Matrix: $S
}), b2 = /* @__PURE__ */ _q({
  BigNumber: xm,
  config: gi
}), qt = /* @__PURE__ */ SU({
  BigNumber: xm,
  Complex: W3,
  DenseMatrix: eo,
  Fraction: QS
}), qf = /* @__PURE__ */ rV({
  typed: qt
}), D1 = /* @__PURE__ */ nV({
  typed: qt
}), y9e = /* @__PURE__ */ QV({
  typed: qt
}), JS = /* @__PURE__ */ QG({
  Complex: W3,
  typed: qt
}), Z3 = /* @__PURE__ */ pV({
  typed: qt
}), L2 = /* @__PURE__ */ $V({
  typed: qt
}), su = /* @__PURE__ */ jG({
  config: gi,
  typed: qt
}), b9e = /* @__PURE__ */ _V({
  typed: qt
}), x9e = /* @__PURE__ */ hV({
  typed: qt
}), Sq = /* @__PURE__ */ JU({
  typed: qt
}), _9e = /* @__PURE__ */ KG({
  config: gi,
  typed: qt
}), Aq = /* @__PURE__ */ XG({
  equalScalar: su,
  typed: qt
}), M1 = /* @__PURE__ */ oV({
  typed: qt
}), eA = /* @__PURE__ */ WG({
  typed: qt
}), S9e = /* @__PURE__ */ vV({
  typed: qt
}), A9e = /* @__PURE__ */ uV({
  BigNumber: xm,
  Fraction: QS,
  complex: JS,
  typed: qt
}), wq = /* @__PURE__ */ JV({
  typed: qt
}), Q3 = /* @__PURE__ */ YG({
  Matrix: $S,
  equalScalar: su,
  typed: qt
}), Zh = /* @__PURE__ */ aV({
  typed: qt
}), tA = /* @__PURE__ */ ZG({
  BigNumber: xm,
  typed: qt
}), $3 = /* @__PURE__ */ cV({
  Complex: W3,
  config: gi,
  typed: qt
}), J3 = /* @__PURE__ */ tV({
  typed: qt
}), Cq = /* @__PURE__ */ $G({
  Fraction: QS,
  typed: qt
}), sn = /* @__PURE__ */ JG({
  DenseMatrix: eo,
  Matrix: $S,
  SparseMatrix: Q3,
  typed: qt
}), w9e = /* @__PURE__ */ FV({
  bignumber: tA,
  fraction: Cq,
  number: eA
}), C9e = /* @__PURE__ */ EV({
  isInteger: Sq,
  matrix: sn,
  typed: qt
}), rA = /* @__PURE__ */ MV({
  matrix: sn,
  config: gi,
  typed: qt
}), Eq = /* @__PURE__ */ TV({
  matrix: sn,
  typed: qt
}), nA = /* @__PURE__ */ PV({
  BigNumber: xm,
  config: gi,
  matrix: sn,
  typed: qt
}), rf = /* @__PURE__ */ FS({
  isInteger: Sq,
  matrix: sn,
  typed: qt
}), E9e = /* @__PURE__ */ NV({
  conj: Z3,
  transpose: Eq,
  typed: qt
}), D9e = /* @__PURE__ */ bV({
  DenseMatrix: eo,
  SparseMatrix: Q3,
  matrix: sn,
  typed: qt
}), _m = /* @__PURE__ */ RV({
  numeric: w9e,
  typed: qt
}), Dq = /* @__PURE__ */ VV({
  DenseMatrix: eo,
  concat: rf,
  equalScalar: su,
  matrix: sn,
  typed: qt
}), Mq = /* @__PURE__ */ xV({
  matrix: sn,
  typed: qt
}), Qh = /* @__PURE__ */ SV({
  BigNumber: xm,
  DenseMatrix: eo,
  SparseMatrix: Q3,
  config: gi,
  matrix: sn,
  typed: qt
}), M9e = /* @__PURE__ */ XV({
  DenseMatrix: eo,
  concat: rf,
  config: gi,
  matrix: sn,
  typed: qt
}), I9e = /* @__PURE__ */ eV({
  flatten: Mq,
  matrix: sn,
  size: rA,
  typed: qt
}), T9e = /* @__PURE__ */ oq({
  addScalar: D1,
  complex: JS,
  conj: Z3,
  divideScalar: _m,
  equal: Dq,
  identity: Qh,
  isZero: Aq,
  matrix: sn,
  multiplyScalar: M1,
  sign: A9e,
  sqrt: $3,
  subtractScalar: Zh,
  typed: qt,
  unaryMinus: J3,
  zeros: nA
}), N9e = /* @__PURE__ */ kV({
  BigNumber: xm,
  DenseMatrix: eo,
  config: gi,
  equalScalar: su,
  matrix: sn,
  typed: qt,
  zeros: nA
}), eb = /* @__PURE__ */ qV({
  DenseMatrix: eo,
  concat: rf,
  config: gi,
  matrix: sn,
  typed: qt
}), Iq = /* @__PURE__ */ lV({
  DenseMatrix: eo,
  concat: rf,
  equalScalar: su,
  matrix: sn,
  subtractScalar: Zh,
  typed: qt,
  unaryMinus: J3
}), P9e = /* @__PURE__ */ zV({
  DenseMatrix: eo,
  divideScalar: _m,
  equalScalar: su,
  matrix: sn,
  multiplyScalar: M1,
  subtractScalar: Zh,
  typed: qt
}), Qc = /* @__PURE__ */ eq({
  DenseMatrix: eo,
  SparseMatrix: Q3,
  addScalar: D1,
  concat: rf,
  equalScalar: su,
  matrix: sn,
  typed: qt
}), aA = /* @__PURE__ */ rq({
  addScalar: D1,
  conj: Z3,
  multiplyScalar: M1,
  size: rA,
  typed: qt
}), B9e = /* @__PURE__ */ WV({
  DenseMatrix: eo,
  smaller: eb
}), O9e = /* @__PURE__ */ ZV({
  ImmutableDenseMatrix: B9e,
  getMatrixDataType: b9e
}), iA = /* @__PURE__ */ KV({
  DenseMatrix: eo,
  concat: rf,
  config: gi,
  matrix: sn,
  typed: qt
}), F9e = /* @__PURE__ */ PS({
  DenseMatrix: eo,
  concat: rf,
  config: gi,
  equalScalar: su,
  matrix: sn,
  round: N9e,
  typed: qt,
  zeros: nA
}), au = /* @__PURE__ */ sV({
  addScalar: D1,
  dot: aA,
  equalScalar: su,
  matrix: sn,
  multiplyScalar: M1,
  typed: qt
}), R9e = /* @__PURE__ */ UV({
  DenseMatrix: eo,
  divideScalar: _m,
  equalScalar: su,
  matrix: sn,
  multiplyScalar: M1,
  subtractScalar: Zh,
  typed: qt
}), cO = /* @__PURE__ */ yV({
  matrix: sn,
  multiply: au,
  subtract: Iq,
  typed: qt
}), Tq = /* @__PURE__ */ cq({
  divideScalar: _m,
  isZero: Aq,
  matrix: sn,
  multiply: au,
  subtractScalar: Zh,
  typed: qt,
  unaryMinus: J3
}), L9e = /* @__PURE__ */ HV({
  DenseMatrix: eo,
  concat: rf,
  config: gi,
  matrix: sn,
  typed: qt
}), k9e = /* @__PURE__ */ kS({
  bignumber: tA,
  matrix: sn,
  add: Qc,
  config: gi,
  isPositive: _9e,
  larger: iA,
  largerEq: M9e,
  smaller: eb,
  smallerEq: L9e,
  typed: qt
}), z9e = /* @__PURE__ */ RS({
  Index: O9e,
  matrix: sn,
  range: k9e,
  typed: qt
}), tb = /* @__PURE__ */ lq({
  abs: qf,
  addScalar: D1,
  det: Tq,
  divideScalar: _m,
  identity: Qh,
  matrix: sn,
  multiply: au,
  typed: qt,
  unaryMinus: J3
}), U9e = /* @__PURE__ */ LV({
  Complex: W3,
  config: gi,
  fraction: Cq,
  identity: Qh,
  inv: tb,
  matrix: sn,
  multiply: au,
  number: eA,
  typed: qt
}), G9e = /* @__PURE__ */ fq({
  divideScalar: _m,
  equalScalar: su,
  inv: tb,
  matrix: sn,
  multiply: au,
  typed: qt
}), V9e = /* @__PURE__ */ dq({
  abs: qf,
  add: Qc,
  addScalar: D1,
  atan: y9e,
  bignumber: tA,
  column: z9e,
  complex: JS,
  config: gi,
  cos: L2,
  diag: D9e,
  divideScalar: _m,
  dot: aA,
  equal: Dq,
  flatten: Mq,
  im: x9e,
  inv: tb,
  larger: iA,
  matrix: sn,
  matrixFromColumns: I9e,
  multiply: au,
  multiplyScalar: M1,
  number: eA,
  qr: T9e,
  re: S9e,
  reshape: C9e,
  sin: wq,
  size: rA,
  smaller: eb,
  sqrt: $3,
  subtract: Iq,
  typed: qt,
  usolve: P9e,
  usolveAll: R9e
}), Nq = /* @__PURE__ */ tq({
  abs: qf,
  add: Qc,
  conj: Z3,
  ctranspose: E9e,
  eigs: V9e,
  equalScalar: su,
  larger: iA,
  matrix: sn,
  multiply: au,
  pow: U9e,
  smaller: eb,
  sqrt: $3,
  typed: qt
}), q9e = g9e, oA = { exports: {} };
function sA() {
}
sA.prototype = {
  on: function(e, t, r) {
    var n = this.e || (this.e = {});
    return (n[e] || (n[e] = [])).push({
      fn: t,
      ctx: r
    }), this;
  },
  once: function(e, t, r) {
    var n = this;
    function a() {
      n.off(e, a), t.apply(r, arguments);
    }
    return a._ = t, this.on(e, a, r);
  },
  emit: function(e) {
    var t = [].slice.call(arguments, 1), r = ((this.e || (this.e = {}))[e] || []).slice(), n = 0, a = r.length;
    for (n; n < a; n++)
      r[n].fn.apply(r[n].ctx, t);
    return this;
  },
  off: function(e, t) {
    var r = this.e || (this.e = {}), n = r[e], a = [];
    if (n && t)
      for (var i = 0, o = n.length; i < o; i++)
        n[i].fn !== t && n[i].fn._ !== t && a.push(n[i]);
    return a.length ? r[e] = a : delete r[e], this;
  }
};
oA.exports = sA;
oA.exports.TinyEmitter = sA;
var H9e = oA.exports;
const K9e = /* @__PURE__ */ jh(H9e);
function X9e(e) {
  var t = new K9e();
  return e.on = t.on.bind(t), e.off = t.off.bind(t), e.once = t.once.bind(t), e.emit = t.emit.bind(t), e;
}
function j9e(e, t, r, n) {
  function a(g, v) {
    var y = arguments.length;
    if (y !== 1 && y !== 2)
      throw new Cl("import", y, 1, 2);
    v || (v = {});
    function _(A, w, C) {
      if (Array.isArray(w))
        w.forEach((N) => _(A, N));
      else if (typeof w == "object")
        for (var M in w)
          Tt(w, M) && _(A, w[M], M);
      else if (nh(w) || C !== void 0) {
        var T = nh(w) ? h(w) ? w.fn + ".transform" : w.fn : C;
        if (Tt(A, T) && A[T] !== w && !v.silent)
          throw new Error('Cannot import "' + T + '" twice');
        A[T] = w;
      } else if (!v.silent)
        throw new TypeError("Factory, Object, or Array expected");
    }
    var S = {};
    _(S, g);
    for (var b in S)
      if (Tt(S, b)) {
        var x = S[b];
        if (nh(x))
          c(x, v);
        else if (l(x))
          i(b, x, v);
        else if (!v.silent)
          throw new TypeError("Factory, Object, or Array expected");
      }
  }
  function i(g, v, y) {
    if (y.wrap && typeof v == "function" && (v = u(v)), d(v) && (v = e(g, {
      [v.signature]: v
    })), e.isTypedFunction(r[g]) && e.isTypedFunction(v)) {
      y.override ? v = e(g, v.signatures) : v = e(r[g], v), r[g] = v, delete n[g], o(g, v), r.emit("import", g, function() {
        return v;
      });
      return;
    }
    if (r[g] === void 0 || y.override) {
      r[g] = v, delete n[g], o(g, v), r.emit("import", g, function() {
        return v;
      });
      return;
    }
    if (!y.silent)
      throw new Error('Cannot import "' + g + '": already exists');
  }
  function o(g, v) {
    v && typeof v.transform == "function" ? (r.expression.transform[g] = v.transform, f(g) && (r.expression.mathWithTransform[g] = v.transform)) : (delete r.expression.transform[g], f(g) && (r.expression.mathWithTransform[g] = v));
  }
  function s(g) {
    delete r.expression.transform[g], f(g) ? r.expression.mathWithTransform[g] = r[g] : delete r.expression.mathWithTransform[g];
  }
  function u(g) {
    var v = function() {
      for (var _ = [], S = 0, b = arguments.length; S < b; S++) {
        var x = arguments[S];
        _[S] = x && x.valueOf();
      }
      return g.apply(r, _);
    };
    return g.transform && (v.transform = g.transform), v;
  }
  function c(g, v) {
    var y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : g.fn;
    if (y.includes("."))
      throw new Error("Factory name should not contain a nested path. Name: " + JSON.stringify(y));
    var _ = h(g) ? r.expression.transform : r, S = y in r.expression.transform, b = Tt(_, y) ? _[y] : void 0, x = function() {
      var w = {};
      g.dependencies.map(hU).forEach((M) => {
        if (M.includes("."))
          throw new Error("Factory dependency should not contain a nested path. Name: " + JSON.stringify(M));
        M === "math" ? w.math = r : M === "mathWithTransform" ? w.mathWithTransform = r.expression.mathWithTransform : M === "classes" ? w.classes = r : w[M] = r[M];
      });
      var C = /* @__PURE__ */ g(w);
      if (C && typeof C.transform == "function")
        throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"');
      if (b === void 0 || v.override)
        return C;
      if (e.isTypedFunction(b) && e.isTypedFunction(C))
        return e(b, C);
      if (v.silent)
        return b;
      throw new Error('Cannot import "' + y + '": already exists');
    };
    !g.meta || g.meta.lazy !== !1 ? (O2(_, y, x), b && S ? s(y) : (h(g) || m(g)) && O2(r.expression.mathWithTransform, y, () => _[y])) : (_[y] = x(), b && S ? s(y) : (h(g) || m(g)) && O2(r.expression.mathWithTransform, y, () => _[y])), n[y] = g, r.emit("import", y, x);
  }
  function l(g) {
    return typeof g == "function" || typeof g == "number" || typeof g == "string" || typeof g == "boolean" || g === null || Lo(g) || Mu(g) || hr(g) || vm(g) || Zt(g) || Array.isArray(g);
  }
  function d(g) {
    return typeof g == "function" && typeof g.signature == "string";
  }
  function f(g) {
    return !Tt(p, g);
  }
  function m(g) {
    return !g.fn.includes(".") && // FIXME: make checking on path redundant, check on meta data instead
    !Tt(p, g.fn) && (!g.meta || !g.meta.isClass);
  }
  function h(g) {
    return g !== void 0 && g.meta !== void 0 && g.meta.isTransformFunction === !0 || !1;
  }
  var p = {
    expression: !0,
    type: !0,
    docs: !0,
    error: !0,
    json: !0,
    chain: !0
    // chain method not supported. Note that there is a unit chain too.
  };
  return a;
}
function Pq(e, t) {
  var r = Ei({}, R3, t);
  if (typeof Object.create != "function")
    throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");
  var n = X9e({
    // only here for backward compatibility for legacy factory functions
    isNumber: _r,
    isComplex: Mu,
    isBigNumber: hr,
    isBigInt: Wz,
    isFraction: vm,
    isUnit: Lo,
    isString: Di,
    isArray: en,
    isMatrix: Zt,
    isCollection: bs,
    isDenseMatrix: Ch,
    isSparseMatrix: Td,
    isRange: L3,
    isIndex: qh,
    isBoolean: Zz,
    isResultSet: Qz,
    isHelp: SS,
    isFunction: $z,
    isDate: Jz,
    isRegExp: eU,
    isObject: Hh,
    isNull: tU,
    isUndefined: rU,
    isAccessorNode: Xd,
    isArrayNode: cs,
    isAssignmentNode: nU,
    isBlockNode: aU,
    isConditionalNode: iU,
    isConstantNode: Vr,
    isFunctionAssignmentNode: x1,
    isFunctionNode: vl,
    isIndexNode: gm,
    isNode: gn,
    isObjectNode: Kh,
    isOperatorNode: Da,
    isParenthesisNode: pc,
    isRangeNode: oU,
    isRelationalNode: sU,
    isSymbolNode: Wa,
    isChain: AS
  });
  n.config = ape(r, n.emit), n.expression = {
    transform: {},
    mathWithTransform: {
      config: n.config
    }
  };
  var a = [], i = [];
  function o(l) {
    if (nh(l))
      return l(n);
    var d = l[Object.keys(l)[0]];
    if (nh(d))
      return d(n);
    if (!rpe(l))
      throw console.warn("Factory object with properties `type`, `name`, and `factory` expected", l), new Error("Factory object with properties `type`, `name`, and `factory` expected");
    var f = a.indexOf(l), m;
    return f === -1 ? (l.math === !0 ? m = l.factory(n.type, r, o, n.typed, n) : m = l.factory(n.type, r, o, n.typed), a.push(l), i.push(m)) : m = i[f], m;
  }
  var s = {};
  function u() {
    for (var l = arguments.length, d = new Array(l), f = 0; f < l; f++)
      d[f] = arguments[f];
    return n.typed.apply(n.typed, d);
  }
  u.isTypedFunction = Vf.isTypedFunction;
  var c = j9e(u, o, n, s);
  return n.import = c, n.on("config", () => {
    Object.values(s).forEach((l) => {
      l && l.meta && l.meta.recreateOnConfigChange && c(l, {
        override: !0
      });
    });
  }), n.create = Pq.bind(null, e), n.factory = me, n.import(Object.values(tpe(e))), n.ArgumentsError = Cl, n.DimensionError = Ir, n.IndexError = ou, n;
}
Pq(q9e);
var t3 = { exports: {} };
/**
 * @license
 * Lodash <https://lodash.com/>
 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
 * Released under MIT license <https://lodash.com/license>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 */
t3.exports;
(function(e, t) {
  (function() {
    var r, n = "4.17.21", a = 200, i = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", s = "Invalid `variable` option passed into `_.template`", u = "__lodash_hash_undefined__", c = 500, l = "__lodash_placeholder__", d = 1, f = 2, m = 4, h = 1, p = 2, g = 1, v = 2, y = 4, _ = 8, S = 16, b = 32, x = 64, A = 128, w = 256, C = 512, M = 30, T = "...", N = 800, I = 16, P = 1, O = 2, F = 3, R = 1 / 0, G = 9007199254740991, L = 17976931348623157e292, q = NaN, K = 4294967295, X = K - 1, H = K >>> 1, W = [
      ["ary", A],
      ["bind", g],
      ["bindKey", v],
      ["curry", _],
      ["curryRight", S],
      ["flip", C],
      ["partial", b],
      ["partialRight", x],
      ["rearg", w]
    ], ee = "[object Arguments]", $ = "[object Array]", te = "[object AsyncFunction]", re = "[object Boolean]", ie = "[object Date]", oe = "[object DOMException]", se = "[object Error]", he = "[object Function]", ge = "[object GeneratorFunction]", De = "[object Map]", ae = "[object Number]", ce = "[object Null]", _e = "[object Object]", le = "[object Promise]", ue = "[object Proxy]", be = "[object RegExp]", Se = "[object Set]", Ne = "[object String]", J = "[object Symbol]", Z = "[object Undefined]", de = "[object WeakMap]", ye = "[object WeakSet]", Ae = "[object ArrayBuffer]", Ce = "[object DataView]", Ie = "[object Float32Array]", Ue = "[object Float64Array]", Xe = "[object Int8Array]", je = "[object Int16Array]", ht = "[object Int32Array]", xt = "[object Uint8Array]", dt = "[object Uint8ClampedArray]", Le = "[object Uint16Array]", j = "[object Uint32Array]", xe = /\b__p \+= '';/g, ke = /\b(__p \+=) '' \+/g, Je = /(__e\(.*?\)|\b__t\)) \+\n'';/g, Ct = /&(?:amp|lt|gt|quot|#39);/g, At = /[&<>"']/g, Or = RegExp(Ct.source), qn = RegExp(At.source), Xn = /<%-([\s\S]+?)%>/g, kn = /<%([\s\S]+?)%>/g, fn = /<%=([\s\S]+?)%>/g, la = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, mn = /^\w*$/, pn = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, ba = /[\\^$.*+?()[\]{}|]/g, xa = RegExp(ba.source), to = /^\s+/, zn = /\s/, An = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, jo = /\{\n\/\* \[wrapped with (.+)\] \*/, Yo = /,? & /, Co = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, Lu = /[()=,{}\[\]\/\s]/, ro = /\\(\\)?/g, _a = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, yc = /\w*$/, El = /^[-+]0x[0-9a-f]+$/i, Dl = /^0b[01]+$/i, Ml = /^\[object .+?Constructor\]$/, Il = /^0o[0-7]+$/i, Tl = /^(?:0|[1-9]\d*)$/, Sm = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Nl = /($^)/, bc = /['\n\r\u2028\u2029\\]/g, Kr = "\\ud800-\\udfff", ri = "\\u0300-\\u036f", I1 = "\\ufe20-\\ufe2f", Pl = "\\u20d0-\\u20ff", ku = ri + I1 + Pl, Am = "\\u2700-\\u27bf", $h = "a-z\\xdf-\\xf6\\xf8-\\xff", rb = "\\xac\\xb1\\xd7\\xf7", Wo = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", nb = "\\u2000-\\u206f", ab = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Jh = "A-Z\\xc0-\\xd6\\xd8-\\xde", ev = "\\ufe0e\\ufe0f", tv = rb + Wo + nb + ab, T1 = "['’]", ib = "[" + Kr + "]", rv = "[" + tv + "]", wm = "[" + ku + "]", nv = "\\d+", ob = "[" + Am + "]", av = "[" + $h + "]", iv = "[^" + Kr + tv + nv + Am + $h + Jh + "]", N1 = "\\ud83c[\\udffb-\\udfff]", sb = "(?:" + wm + "|" + N1 + ")", ov = "[^" + Kr + "]", Cm = "(?:\\ud83c[\\udde6-\\uddff]){2}", P1 = "[\\ud800-\\udbff][\\udc00-\\udfff]", Bl = "[" + Jh + "]", lA = "\\u200d", dA = "(?:" + av + "|" + iv + ")", Rq = "(?:" + Bl + "|" + iv + ")", fA = "(?:" + T1 + "(?:d|ll|m|re|s|t|ve))?", mA = "(?:" + T1 + "(?:D|LL|M|RE|S|T|VE))?", pA = sb + "?", hA = "[" + ev + "]?", Lq = "(?:" + lA + "(?:" + [ov, Cm, P1].join("|") + ")" + hA + pA + ")*", kq = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", zq = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", vA = hA + pA + Lq, Uq = "(?:" + [ob, Cm, P1].join("|") + ")" + vA, Gq = "(?:" + [ov + wm + "?", wm, Cm, P1, ib].join("|") + ")", Vq = RegExp(T1, "g"), qq = RegExp(wm, "g"), ub = RegExp(N1 + "(?=" + N1 + ")|" + Gq + vA, "g"), Hq = RegExp([
      Bl + "?" + av + "+" + fA + "(?=" + [rv, Bl, "$"].join("|") + ")",
      Rq + "+" + mA + "(?=" + [rv, Bl + dA, "$"].join("|") + ")",
      Bl + "?" + dA + "+" + fA,
      Bl + "+" + mA,
      zq,
      kq,
      nv,
      Uq
    ].join("|"), "g"), Kq = RegExp("[" + lA + Kr + ku + ev + "]"), Xq = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, jq = [
      "Array",
      "Buffer",
      "DataView",
      "Date",
      "Error",
      "Float32Array",
      "Float64Array",
      "Function",
      "Int8Array",
      "Int16Array",
      "Int32Array",
      "Map",
      "Math",
      "Object",
      "Promise",
      "RegExp",
      "Set",
      "String",
      "Symbol",
      "TypeError",
      "Uint8Array",
      "Uint8ClampedArray",
      "Uint16Array",
      "Uint32Array",
      "WeakMap",
      "_",
      "clearTimeout",
      "isFinite",
      "parseInt",
      "setTimeout"
    ], Yq = -1, jn = {};
    jn[Ie] = jn[Ue] = jn[Xe] = jn[je] = jn[ht] = jn[xt] = jn[dt] = jn[Le] = jn[j] = !0, jn[ee] = jn[$] = jn[Ae] = jn[re] = jn[Ce] = jn[ie] = jn[se] = jn[he] = jn[De] = jn[ae] = jn[_e] = jn[be] = jn[Se] = jn[Ne] = jn[de] = !1;
    var Hn = {};
    Hn[ee] = Hn[$] = Hn[Ae] = Hn[Ce] = Hn[re] = Hn[ie] = Hn[Ie] = Hn[Ue] = Hn[Xe] = Hn[je] = Hn[ht] = Hn[De] = Hn[ae] = Hn[_e] = Hn[be] = Hn[Se] = Hn[Ne] = Hn[J] = Hn[xt] = Hn[dt] = Hn[Le] = Hn[j] = !0, Hn[se] = Hn[he] = Hn[de] = !1;
    var Wq = {
      // Latin-1 Supplement block.
      À: "A",
      Á: "A",
      Â: "A",
      Ã: "A",
      Ä: "A",
      Å: "A",
      à: "a",
      á: "a",
      â: "a",
      ã: "a",
      ä: "a",
      å: "a",
      Ç: "C",
      ç: "c",
      Ð: "D",
      ð: "d",
      È: "E",
      É: "E",
      Ê: "E",
      Ë: "E",
      è: "e",
      é: "e",
      ê: "e",
      ë: "e",
      Ì: "I",
      Í: "I",
      Î: "I",
      Ï: "I",
      ì: "i",
      í: "i",
      î: "i",
      ï: "i",
      Ñ: "N",
      ñ: "n",
      Ò: "O",
      Ó: "O",
      Ô: "O",
      Õ: "O",
      Ö: "O",
      Ø: "O",
      ò: "o",
      ó: "o",
      ô: "o",
      õ: "o",
      ö: "o",
      ø: "o",
      Ù: "U",
      Ú: "U",
      Û: "U",
      Ü: "U",
      ù: "u",
      ú: "u",
      û: "u",
      ü: "u",
      Ý: "Y",
      ý: "y",
      ÿ: "y",
      Æ: "Ae",
      æ: "ae",
      Þ: "Th",
      þ: "th",
      ß: "ss",
      // Latin Extended-A block.
      Ā: "A",
      Ă: "A",
      Ą: "A",
      ā: "a",
      ă: "a",
      ą: "a",
      Ć: "C",
      Ĉ: "C",
      Ċ: "C",
      Č: "C",
      ć: "c",
      ĉ: "c",
      ċ: "c",
      č: "c",
      Ď: "D",
      Đ: "D",
      ď: "d",
      đ: "d",
      Ē: "E",
      Ĕ: "E",
      Ė: "E",
      Ę: "E",
      Ě: "E",
      ē: "e",
      ĕ: "e",
      ė: "e",
      ę: "e",
      ě: "e",
      Ĝ: "G",
      Ğ: "G",
      Ġ: "G",
      Ģ: "G",
      ĝ: "g",
      ğ: "g",
      ġ: "g",
      ģ: "g",
      Ĥ: "H",
      Ħ: "H",
      ĥ: "h",
      ħ: "h",
      Ĩ: "I",
      Ī: "I",
      Ĭ: "I",
      Į: "I",
      İ: "I",
      ĩ: "i",
      ī: "i",
      ĭ: "i",
      į: "i",
      ı: "i",
      Ĵ: "J",
      ĵ: "j",
      Ķ: "K",
      ķ: "k",
      ĸ: "k",
      Ĺ: "L",
      Ļ: "L",
      Ľ: "L",
      Ŀ: "L",
      Ł: "L",
      ĺ: "l",
      ļ: "l",
      ľ: "l",
      ŀ: "l",
      ł: "l",
      Ń: "N",
      Ņ: "N",
      Ň: "N",
      Ŋ: "N",
      ń: "n",
      ņ: "n",
      ň: "n",
      ŋ: "n",
      Ō: "O",
      Ŏ: "O",
      Ő: "O",
      ō: "o",
      ŏ: "o",
      ő: "o",
      Ŕ: "R",
      Ŗ: "R",
      Ř: "R",
      ŕ: "r",
      ŗ: "r",
      ř: "r",
      Ś: "S",
      Ŝ: "S",
      Ş: "S",
      Š: "S",
      ś: "s",
      ŝ: "s",
      ş: "s",
      š: "s",
      Ţ: "T",
      Ť: "T",
      Ŧ: "T",
      ţ: "t",
      ť: "t",
      ŧ: "t",
      Ũ: "U",
      Ū: "U",
      Ŭ: "U",
      Ů: "U",
      Ű: "U",
      Ų: "U",
      ũ: "u",
      ū: "u",
      ŭ: "u",
      ů: "u",
      ű: "u",
      ų: "u",
      Ŵ: "W",
      ŵ: "w",
      Ŷ: "Y",
      ŷ: "y",
      Ÿ: "Y",
      Ź: "Z",
      Ż: "Z",
      Ž: "Z",
      ź: "z",
      ż: "z",
      ž: "z",
      Ĳ: "IJ",
      ĳ: "ij",
      Œ: "Oe",
      œ: "oe",
      ŉ: "'n",
      ſ: "s"
    }, Zq = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': "&quot;",
      "'": "&#39;"
    }, Qq = {
      "&amp;": "&",
      "&lt;": "<",
      "&gt;": ">",
      "&quot;": '"',
      "&#39;": "'"
    }, $q = {
      "\\": "\\",
      "'": "'",
      "\n": "n",
      "\r": "r",
      "\u2028": "u2028",
      "\u2029": "u2029"
    }, Jq = parseFloat, eH = parseInt, gA = typeof Qs == "object" && Qs && Qs.Object === Object && Qs, tH = typeof self == "object" && self && self.Object === Object && self, yi = gA || tH || Function("return this")(), cb = t && !t.nodeType && t, nf = cb && !0 && e && !e.nodeType && e, yA = nf && nf.exports === cb, lb = yA && gA.process, Ss = function() {
      try {
        var Ge = nf && nf.require && nf.require("util").types;
        return Ge || lb && lb.binding && lb.binding("util");
      } catch {
      }
    }(), bA = Ss && Ss.isArrayBuffer, xA = Ss && Ss.isDate, _A = Ss && Ss.isMap, SA = Ss && Ss.isRegExp, AA = Ss && Ss.isSet, wA = Ss && Ss.isTypedArray;
    function Zo(Ge, it, tt) {
      switch (tt.length) {
        case 0:
          return Ge.call(it);
        case 1:
          return Ge.call(it, tt[0]);
        case 2:
          return Ge.call(it, tt[0], tt[1]);
        case 3:
          return Ge.call(it, tt[0], tt[1], tt[2]);
      }
      return Ge.apply(it, tt);
    }
    function rH(Ge, it, tt, Ft) {
      for (var Ar = -1, hn = Ge == null ? 0 : Ge.length; ++Ar < hn; ) {
        var Va = Ge[Ar];
        it(Ft, Va, tt(Va), Ge);
      }
      return Ft;
    }
    function As(Ge, it) {
      for (var tt = -1, Ft = Ge == null ? 0 : Ge.length; ++tt < Ft && it(Ge[tt], tt, Ge) !== !1; )
        ;
      return Ge;
    }
    function nH(Ge, it) {
      for (var tt = Ge == null ? 0 : Ge.length; tt-- && it(Ge[tt], tt, Ge) !== !1; )
        ;
      return Ge;
    }
    function CA(Ge, it) {
      for (var tt = -1, Ft = Ge == null ? 0 : Ge.length; ++tt < Ft; )
        if (!it(Ge[tt], tt, Ge))
          return !1;
      return !0;
    }
    function Ol(Ge, it) {
      for (var tt = -1, Ft = Ge == null ? 0 : Ge.length, Ar = 0, hn = []; ++tt < Ft; ) {
        var Va = Ge[tt];
        it(Va, tt, Ge) && (hn[Ar++] = Va);
      }
      return hn;
    }
    function sv(Ge, it) {
      var tt = Ge == null ? 0 : Ge.length;
      return !!tt && Em(Ge, it, 0) > -1;
    }
    function db(Ge, it, tt) {
      for (var Ft = -1, Ar = Ge == null ? 0 : Ge.length; ++Ft < Ar; )
        if (tt(it, Ge[Ft]))
          return !0;
      return !1;
    }
    function Zn(Ge, it) {
      for (var tt = -1, Ft = Ge == null ? 0 : Ge.length, Ar = Array(Ft); ++tt < Ft; )
        Ar[tt] = it(Ge[tt], tt, Ge);
      return Ar;
    }
    function Fl(Ge, it) {
      for (var tt = -1, Ft = it.length, Ar = Ge.length; ++tt < Ft; )
        Ge[Ar + tt] = it[tt];
      return Ge;
    }
    function fb(Ge, it, tt, Ft) {
      var Ar = -1, hn = Ge == null ? 0 : Ge.length;
      for (Ft && hn && (tt = Ge[++Ar]); ++Ar < hn; )
        tt = it(tt, Ge[Ar], Ar, Ge);
      return tt;
    }
    function aH(Ge, it, tt, Ft) {
      var Ar = Ge == null ? 0 : Ge.length;
      for (Ft && Ar && (tt = Ge[--Ar]); Ar--; )
        tt = it(tt, Ge[Ar], Ar, Ge);
      return tt;
    }
    function mb(Ge, it) {
      for (var tt = -1, Ft = Ge == null ? 0 : Ge.length; ++tt < Ft; )
        if (it(Ge[tt], tt, Ge))
          return !0;
      return !1;
    }
    var iH = pb("length");
    function oH(Ge) {
      return Ge.split("");
    }
    function sH(Ge) {
      return Ge.match(Co) || [];
    }
    function EA(Ge, it, tt) {
      var Ft;
      return tt(Ge, function(Ar, hn, Va) {
        if (it(Ar, hn, Va))
          return Ft = hn, !1;
      }), Ft;
    }
    function uv(Ge, it, tt, Ft) {
      for (var Ar = Ge.length, hn = tt + (Ft ? 1 : -1); Ft ? hn-- : ++hn < Ar; )
        if (it(Ge[hn], hn, Ge))
          return hn;
      return -1;
    }
    function Em(Ge, it, tt) {
      return it === it ? bH(Ge, it, tt) : uv(Ge, DA, tt);
    }
    function uH(Ge, it, tt, Ft) {
      for (var Ar = tt - 1, hn = Ge.length; ++Ar < hn; )
        if (Ft(Ge[Ar], it))
          return Ar;
      return -1;
    }
    function DA(Ge) {
      return Ge !== Ge;
    }
    function MA(Ge, it) {
      var tt = Ge == null ? 0 : Ge.length;
      return tt ? vb(Ge, it) / tt : q;
    }
    function pb(Ge) {
      return function(it) {
        return it == null ? r : it[Ge];
      };
    }
    function hb(Ge) {
      return function(it) {
        return Ge == null ? r : Ge[it];
      };
    }
    function IA(Ge, it, tt, Ft, Ar) {
      return Ar(Ge, function(hn, Va, Un) {
        tt = Ft ? (Ft = !1, hn) : it(tt, hn, Va, Un);
      }), tt;
    }
    function cH(Ge, it) {
      var tt = Ge.length;
      for (Ge.sort(it); tt--; )
        Ge[tt] = Ge[tt].value;
      return Ge;
    }
    function vb(Ge, it) {
      for (var tt, Ft = -1, Ar = Ge.length; ++Ft < Ar; ) {
        var hn = it(Ge[Ft]);
        hn !== r && (tt = tt === r ? hn : tt + hn);
      }
      return tt;
    }
    function gb(Ge, it) {
      for (var tt = -1, Ft = Array(Ge); ++tt < Ge; )
        Ft[tt] = it(tt);
      return Ft;
    }
    function lH(Ge, it) {
      return Zn(it, function(tt) {
        return [tt, Ge[tt]];
      });
    }
    function TA(Ge) {
      return Ge && Ge.slice(0, OA(Ge) + 1).replace(to, "");
    }
    function Qo(Ge) {
      return function(it) {
        return Ge(it);
      };
    }
    function yb(Ge, it) {
      return Zn(it, function(tt) {
        return Ge[tt];
      });
    }
    function B1(Ge, it) {
      return Ge.has(it);
    }
    function NA(Ge, it) {
      for (var tt = -1, Ft = Ge.length; ++tt < Ft && Em(it, Ge[tt], 0) > -1; )
        ;
      return tt;
    }
    function PA(Ge, it) {
      for (var tt = Ge.length; tt-- && Em(it, Ge[tt], 0) > -1; )
        ;
      return tt;
    }
    function dH(Ge, it) {
      for (var tt = Ge.length, Ft = 0; tt--; )
        Ge[tt] === it && ++Ft;
      return Ft;
    }
    var fH = hb(Wq), mH = hb(Zq);
    function pH(Ge) {
      return "\\" + $q[Ge];
    }
    function hH(Ge, it) {
      return Ge == null ? r : Ge[it];
    }
    function Dm(Ge) {
      return Kq.test(Ge);
    }
    function vH(Ge) {
      return Xq.test(Ge);
    }
    function gH(Ge) {
      for (var it, tt = []; !(it = Ge.next()).done; )
        tt.push(it.value);
      return tt;
    }
    function bb(Ge) {
      var it = -1, tt = Array(Ge.size);
      return Ge.forEach(function(Ft, Ar) {
        tt[++it] = [Ar, Ft];
      }), tt;
    }
    function BA(Ge, it) {
      return function(tt) {
        return Ge(it(tt));
      };
    }
    function Rl(Ge, it) {
      for (var tt = -1, Ft = Ge.length, Ar = 0, hn = []; ++tt < Ft; ) {
        var Va = Ge[tt];
        (Va === it || Va === l) && (Ge[tt] = l, hn[Ar++] = tt);
      }
      return hn;
    }
    function cv(Ge) {
      var it = -1, tt = Array(Ge.size);
      return Ge.forEach(function(Ft) {
        tt[++it] = Ft;
      }), tt;
    }
    function yH(Ge) {
      var it = -1, tt = Array(Ge.size);
      return Ge.forEach(function(Ft) {
        tt[++it] = [Ft, Ft];
      }), tt;
    }
    function bH(Ge, it, tt) {
      for (var Ft = tt - 1, Ar = Ge.length; ++Ft < Ar; )
        if (Ge[Ft] === it)
          return Ft;
      return -1;
    }
    function xH(Ge, it, tt) {
      for (var Ft = tt + 1; Ft--; )
        if (Ge[Ft] === it)
          return Ft;
      return Ft;
    }
    function Mm(Ge) {
      return Dm(Ge) ? SH(Ge) : iH(Ge);
    }
    function uu(Ge) {
      return Dm(Ge) ? AH(Ge) : oH(Ge);
    }
    function OA(Ge) {
      for (var it = Ge.length; it-- && zn.test(Ge.charAt(it)); )
        ;
      return it;
    }
    var _H = hb(Qq);
    function SH(Ge) {
      for (var it = ub.lastIndex = 0; ub.test(Ge); )
        ++it;
      return it;
    }
    function AH(Ge) {
      return Ge.match(ub) || [];
    }
    function wH(Ge) {
      return Ge.match(Hq) || [];
    }
    var CH = function Ge(it) {
      it = it == null ? yi : Im.defaults(yi.Object(), it, Im.pick(yi, jq));
      var tt = it.Array, Ft = it.Date, Ar = it.Error, hn = it.Function, Va = it.Math, Un = it.Object, xb = it.RegExp, EH = it.String, ws = it.TypeError, lv = tt.prototype, DH = hn.prototype, Tm = Un.prototype, dv = it["__core-js_shared__"], fv = DH.toString, wn = Tm.hasOwnProperty, MH = 0, FA = function() {
        var E = /[^.]+$/.exec(dv && dv.keys && dv.keys.IE_PROTO || "");
        return E ? "Symbol(src)_1." + E : "";
      }(), mv = Tm.toString, IH = fv.call(Un), TH = yi._, NH = xb(
        "^" + fv.call(wn).replace(ba, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
      ), pv = yA ? it.Buffer : r, Ll = it.Symbol, hv = it.Uint8Array, RA = pv ? pv.allocUnsafe : r, vv = BA(Un.getPrototypeOf, Un), LA = Un.create, kA = Tm.propertyIsEnumerable, gv = lv.splice, zA = Ll ? Ll.isConcatSpreadable : r, O1 = Ll ? Ll.iterator : r, af = Ll ? Ll.toStringTag : r, yv = function() {
        try {
          var E = lf(Un, "defineProperty");
          return E({}, "", {}), E;
        } catch {
        }
      }(), PH = it.clearTimeout !== yi.clearTimeout && it.clearTimeout, BH = Ft && Ft.now !== yi.Date.now && Ft.now, OH = it.setTimeout !== yi.setTimeout && it.setTimeout, bv = Va.ceil, xv = Va.floor, _b = Un.getOwnPropertySymbols, FH = pv ? pv.isBuffer : r, UA = it.isFinite, RH = lv.join, LH = BA(Un.keys, Un), qa = Va.max, Li = Va.min, kH = Ft.now, zH = it.parseInt, GA = Va.random, UH = lv.reverse, Sb = lf(it, "DataView"), F1 = lf(it, "Map"), Ab = lf(it, "Promise"), Nm = lf(it, "Set"), R1 = lf(it, "WeakMap"), L1 = lf(Un, "create"), _v = R1 && new R1(), Pm = {}, GH = df(Sb), VH = df(F1), qH = df(Ab), HH = df(Nm), KH = df(R1), Sv = Ll ? Ll.prototype : r, k1 = Sv ? Sv.valueOf : r, VA = Sv ? Sv.toString : r;
      function fe(E) {
        if (da(E) && !Dr(E) && !(E instanceof Xr)) {
          if (E instanceof Cs)
            return E;
          if (wn.call(E, "__wrapped__"))
            return q7(E);
        }
        return new Cs(E);
      }
      var Bm = /* @__PURE__ */ function() {
        function E() {
        }
        return function(B) {
          if (!na(B))
            return {};
          if (LA)
            return LA(B);
          E.prototype = B;
          var z = new E();
          return E.prototype = r, z;
        };
      }();
      function Av() {
      }
      function Cs(E, B) {
        this.__wrapped__ = E, this.__actions__ = [], this.__chain__ = !!B, this.__index__ = 0, this.__values__ = r;
      }
      fe.templateSettings = {
        /**
         * Used to detect `data` property values to be HTML-escaped.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        escape: Xn,
        /**
         * Used to detect code to be evaluated.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        evaluate: kn,
        /**
         * Used to detect `data` property values to inject.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        interpolate: fn,
        /**
         * Used to reference the data object in the template text.
         *
         * @memberOf _.templateSettings
         * @type {string}
         */
        variable: "",
        /**
         * Used to import variables into the compiled template.
         *
         * @memberOf _.templateSettings
         * @type {Object}
         */
        imports: {
          /**
           * A reference to the `lodash` function.
           *
           * @memberOf _.templateSettings.imports
           * @type {Function}
           */
          _: fe
        }
      }, fe.prototype = Av.prototype, fe.prototype.constructor = fe, Cs.prototype = Bm(Av.prototype), Cs.prototype.constructor = Cs;
      function Xr(E) {
        this.__wrapped__ = E, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = K, this.__views__ = [];
      }
      function XH() {
        var E = new Xr(this.__wrapped__);
        return E.__actions__ = Eo(this.__actions__), E.__dir__ = this.__dir__, E.__filtered__ = this.__filtered__, E.__iteratees__ = Eo(this.__iteratees__), E.__takeCount__ = this.__takeCount__, E.__views__ = Eo(this.__views__), E;
      }
      function jH() {
        if (this.__filtered__) {
          var E = new Xr(this);
          E.__dir__ = -1, E.__filtered__ = !0;
        } else
          E = this.clone(), E.__dir__ *= -1;
        return E;
      }
      function YH() {
        var E = this.__wrapped__.value(), B = this.__dir__, z = Dr(E), Y = B < 0, ne = z ? E.length : 0, ve = oX(0, ne, this.__views__), Me = ve.start, Re = ve.end, He = Re - Me, ut = Y ? Re : Me - 1, ct = this.__iteratees__, gt = ct.length, It = 0, Gt = Li(He, this.__takeCount__);
        if (!z || !Y && ne == He && Gt == He)
          return f7(E, this.__actions__);
        var ar = [];
        e:
          for (; He-- && It < Gt; ) {
            ut += B;
            for (var Lr = -1, ir = E[ut]; ++Lr < gt; ) {
              var Gr = ct[Lr], Wr = Gr.iteratee, es = Gr.type, io = Wr(ir);
              if (es == O)
                ir = io;
              else if (!io) {
                if (es == P)
                  continue e;
                break e;
              }
            }
            ar[It++] = ir;
          }
        return ar;
      }
      Xr.prototype = Bm(Av.prototype), Xr.prototype.constructor = Xr;
      function of(E) {
        var B = -1, z = E == null ? 0 : E.length;
        for (this.clear(); ++B < z; ) {
          var Y = E[B];
          this.set(Y[0], Y[1]);
        }
      }
      function WH() {
        this.__data__ = L1 ? L1(null) : {}, this.size = 0;
      }
      function ZH(E) {
        var B = this.has(E) && delete this.__data__[E];
        return this.size -= B ? 1 : 0, B;
      }
      function QH(E) {
        var B = this.__data__;
        if (L1) {
          var z = B[E];
          return z === u ? r : z;
        }
        return wn.call(B, E) ? B[E] : r;
      }
      function $H(E) {
        var B = this.__data__;
        return L1 ? B[E] !== r : wn.call(B, E);
      }
      function JH(E, B) {
        var z = this.__data__;
        return this.size += this.has(E) ? 0 : 1, z[E] = L1 && B === r ? u : B, this;
      }
      of.prototype.clear = WH, of.prototype.delete = ZH, of.prototype.get = QH, of.prototype.has = $H, of.prototype.set = JH;
      function xc(E) {
        var B = -1, z = E == null ? 0 : E.length;
        for (this.clear(); ++B < z; ) {
          var Y = E[B];
          this.set(Y[0], Y[1]);
        }
      }
      function eK() {
        this.__data__ = [], this.size = 0;
      }
      function tK(E) {
        var B = this.__data__, z = wv(B, E);
        if (z < 0)
          return !1;
        var Y = B.length - 1;
        return z == Y ? B.pop() : gv.call(B, z, 1), --this.size, !0;
      }
      function rK(E) {
        var B = this.__data__, z = wv(B, E);
        return z < 0 ? r : B[z][1];
      }
      function nK(E) {
        return wv(this.__data__, E) > -1;
      }
      function aK(E, B) {
        var z = this.__data__, Y = wv(z, E);
        return Y < 0 ? (++this.size, z.push([E, B])) : z[Y][1] = B, this;
      }
      xc.prototype.clear = eK, xc.prototype.delete = tK, xc.prototype.get = rK, xc.prototype.has = nK, xc.prototype.set = aK;
      function _c(E) {
        var B = -1, z = E == null ? 0 : E.length;
        for (this.clear(); ++B < z; ) {
          var Y = E[B];
          this.set(Y[0], Y[1]);
        }
      }
      function iK() {
        this.size = 0, this.__data__ = {
          hash: new of(),
          map: new (F1 || xc)(),
          string: new of()
        };
      }
      function oK(E) {
        var B = Rv(this, E).delete(E);
        return this.size -= B ? 1 : 0, B;
      }
      function sK(E) {
        return Rv(this, E).get(E);
      }
      function uK(E) {
        return Rv(this, E).has(E);
      }
      function cK(E, B) {
        var z = Rv(this, E), Y = z.size;
        return z.set(E, B), this.size += z.size == Y ? 0 : 1, this;
      }
      _c.prototype.clear = iK, _c.prototype.delete = oK, _c.prototype.get = sK, _c.prototype.has = uK, _c.prototype.set = cK;
      function sf(E) {
        var B = -1, z = E == null ? 0 : E.length;
        for (this.__data__ = new _c(); ++B < z; )
          this.add(E[B]);
      }
      function lK(E) {
        return this.__data__.set(E, u), this;
      }
      function dK(E) {
        return this.__data__.has(E);
      }
      sf.prototype.add = sf.prototype.push = lK, sf.prototype.has = dK;
      function cu(E) {
        var B = this.__data__ = new xc(E);
        this.size = B.size;
      }
      function fK() {
        this.__data__ = new xc(), this.size = 0;
      }
      function mK(E) {
        var B = this.__data__, z = B.delete(E);
        return this.size = B.size, z;
      }
      function pK(E) {
        return this.__data__.get(E);
      }
      function hK(E) {
        return this.__data__.has(E);
      }
      function vK(E, B) {
        var z = this.__data__;
        if (z instanceof xc) {
          var Y = z.__data__;
          if (!F1 || Y.length < a - 1)
            return Y.push([E, B]), this.size = ++z.size, this;
          z = this.__data__ = new _c(Y);
        }
        return z.set(E, B), this.size = z.size, this;
      }
      cu.prototype.clear = fK, cu.prototype.delete = mK, cu.prototype.get = pK, cu.prototype.has = hK, cu.prototype.set = vK;
      function qA(E, B) {
        var z = Dr(E), Y = !z && ff(E), ne = !z && !Y && Vl(E), ve = !z && !Y && !ne && Lm(E), Me = z || Y || ne || ve, Re = Me ? gb(E.length, EH) : [], He = Re.length;
        for (var ut in E)
          (B || wn.call(E, ut)) && !(Me && // Safari 9 has enumerable `arguments.length` in strict mode.
          (ut == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
          ne && (ut == "offset" || ut == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
          ve && (ut == "buffer" || ut == "byteLength" || ut == "byteOffset") || // Skip index properties.
          Cc(ut, He))) && Re.push(ut);
        return Re;
      }
      function HA(E) {
        var B = E.length;
        return B ? E[Ob(0, B - 1)] : r;
      }
      function gK(E, B) {
        return Lv(Eo(E), uf(B, 0, E.length));
      }
      function yK(E) {
        return Lv(Eo(E));
      }
      function wb(E, B, z) {
        (z !== r && !lu(E[B], z) || z === r && !(B in E)) && Sc(E, B, z);
      }
      function z1(E, B, z) {
        var Y = E[B];
        (!(wn.call(E, B) && lu(Y, z)) || z === r && !(B in E)) && Sc(E, B, z);
      }
      function wv(E, B) {
        for (var z = E.length; z--; )
          if (lu(E[z][0], B))
            return z;
        return -1;
      }
      function bK(E, B, z, Y) {
        return kl(E, function(ne, ve, Me) {
          B(Y, ne, z(ne), Me);
        }), Y;
      }
      function KA(E, B) {
        return E && Uu(B, ni(B), E);
      }
      function xK(E, B) {
        return E && Uu(B, Mo(B), E);
      }
      function Sc(E, B, z) {
        B == "__proto__" && yv ? yv(E, B, {
          configurable: !0,
          enumerable: !0,
          value: z,
          writable: !0
        }) : E[B] = z;
      }
      function Cb(E, B) {
        for (var z = -1, Y = B.length, ne = tt(Y), ve = E == null; ++z < Y; )
          ne[z] = ve ? r : i4(E, B[z]);
        return ne;
      }
      function uf(E, B, z) {
        return E === E && (z !== r && (E = E <= z ? E : z), B !== r && (E = E >= B ? E : B)), E;
      }
      function Es(E, B, z, Y, ne, ve) {
        var Me, Re = B & d, He = B & f, ut = B & m;
        if (z && (Me = ne ? z(E, Y, ne, ve) : z(E)), Me !== r)
          return Me;
        if (!na(E))
          return E;
        var ct = Dr(E);
        if (ct) {
          if (Me = uX(E), !Re)
            return Eo(E, Me);
        } else {
          var gt = ki(E), It = gt == he || gt == ge;
          if (Vl(E))
            return h7(E, Re);
          if (gt == _e || gt == ee || It && !ne) {
            if (Me = He || It ? {} : O7(E), !Re)
              return He ? QK(E, xK(Me, E)) : ZK(E, KA(Me, E));
          } else {
            if (!Hn[gt])
              return ne ? E : {};
            Me = cX(E, gt, Re);
          }
        }
        ve || (ve = new cu());
        var Gt = ve.get(E);
        if (Gt)
          return Gt;
        ve.set(E, Me), cw(E) ? E.forEach(function(ir) {
          Me.add(Es(ir, B, z, ir, E, ve));
        }) : sw(E) && E.forEach(function(ir, Gr) {
          Me.set(Gr, Es(ir, B, z, Gr, E, ve));
        });
        var ar = ut ? He ? Kb : Hb : He ? Mo : ni, Lr = ct ? r : ar(E);
        return As(Lr || E, function(ir, Gr) {
          Lr && (Gr = ir, ir = E[Gr]), z1(Me, Gr, Es(ir, B, z, Gr, E, ve));
        }), Me;
      }
      function _K(E) {
        var B = ni(E);
        return function(z) {
          return XA(z, E, B);
        };
      }
      function XA(E, B, z) {
        var Y = z.length;
        if (E == null)
          return !Y;
        for (E = Un(E); Y--; ) {
          var ne = z[Y], ve = B[ne], Me = E[ne];
          if (Me === r && !(ne in E) || !ve(Me))
            return !1;
        }
        return !0;
      }
      function jA(E, B, z) {
        if (typeof E != "function")
          throw new ws(o);
        return X1(function() {
          E.apply(r, z);
        }, B);
      }
      function U1(E, B, z, Y) {
        var ne = -1, ve = sv, Me = !0, Re = E.length, He = [], ut = B.length;
        if (!Re)
          return He;
        z && (B = Zn(B, Qo(z))), Y ? (ve = db, Me = !1) : B.length >= a && (ve = B1, Me = !1, B = new sf(B));
        e:
          for (; ++ne < Re; ) {
            var ct = E[ne], gt = z == null ? ct : z(ct);
            if (ct = Y || ct !== 0 ? ct : 0, Me && gt === gt) {
              for (var It = ut; It--; )
                if (B[It] === gt)
                  continue e;
              He.push(ct);
            } else ve(B, gt, Y) || He.push(ct);
          }
        return He;
      }
      var kl = x7(zu), YA = x7(Db, !0);
      function SK(E, B) {
        var z = !0;
        return kl(E, function(Y, ne, ve) {
          return z = !!B(Y, ne, ve), z;
        }), z;
      }
      function Cv(E, B, z) {
        for (var Y = -1, ne = E.length; ++Y < ne; ) {
          var ve = E[Y], Me = B(ve);
          if (Me != null && (Re === r ? Me === Me && !Jo(Me) : z(Me, Re)))
            var Re = Me, He = ve;
        }
        return He;
      }
      function AK(E, B, z, Y) {
        var ne = E.length;
        for (z = Fr(z), z < 0 && (z = -z > ne ? 0 : ne + z), Y = Y === r || Y > ne ? ne : Fr(Y), Y < 0 && (Y += ne), Y = z > Y ? 0 : dw(Y); z < Y; )
          E[z++] = B;
        return E;
      }
      function WA(E, B) {
        var z = [];
        return kl(E, function(Y, ne, ve) {
          B(Y, ne, ve) && z.push(Y);
        }), z;
      }
      function bi(E, B, z, Y, ne) {
        var ve = -1, Me = E.length;
        for (z || (z = dX), ne || (ne = []); ++ve < Me; ) {
          var Re = E[ve];
          B > 0 && z(Re) ? B > 1 ? bi(Re, B - 1, z, Y, ne) : Fl(ne, Re) : Y || (ne[ne.length] = Re);
        }
        return ne;
      }
      var Eb = _7(), ZA = _7(!0);
      function zu(E, B) {
        return E && Eb(E, B, ni);
      }
      function Db(E, B) {
        return E && ZA(E, B, ni);
      }
      function Ev(E, B) {
        return Ol(B, function(z) {
          return Ec(E[z]);
        });
      }
      function cf(E, B) {
        B = Ul(B, E);
        for (var z = 0, Y = B.length; E != null && z < Y; )
          E = E[Gu(B[z++])];
        return z && z == Y ? E : r;
      }
      function QA(E, B, z) {
        var Y = B(E);
        return Dr(E) ? Y : Fl(Y, z(E));
      }
      function no(E) {
        return E == null ? E === r ? Z : ce : af && af in Un(E) ? iX(E) : yX(E);
      }
      function Mb(E, B) {
        return E > B;
      }
      function wK(E, B) {
        return E != null && wn.call(E, B);
      }
      function CK(E, B) {
        return E != null && B in Un(E);
      }
      function EK(E, B, z) {
        return E >= Li(B, z) && E < qa(B, z);
      }
      function Ib(E, B, z) {
        for (var Y = z ? db : sv, ne = E[0].length, ve = E.length, Me = ve, Re = tt(ve), He = 1 / 0, ut = []; Me--; ) {
          var ct = E[Me];
          Me && B && (ct = Zn(ct, Qo(B))), He = Li(ct.length, He), Re[Me] = !z && (B || ne >= 120 && ct.length >= 120) ? new sf(Me && ct) : r;
        }
        ct = E[0];
        var gt = -1, It = Re[0];
        e:
          for (; ++gt < ne && ut.length < He; ) {
            var Gt = ct[gt], ar = B ? B(Gt) : Gt;
            if (Gt = z || Gt !== 0 ? Gt : 0, !(It ? B1(It, ar) : Y(ut, ar, z))) {
              for (Me = ve; --Me; ) {
                var Lr = Re[Me];
                if (!(Lr ? B1(Lr, ar) : Y(E[Me], ar, z)))
                  continue e;
              }
              It && It.push(ar), ut.push(Gt);
            }
          }
        return ut;
      }
      function DK(E, B, z, Y) {
        return zu(E, function(ne, ve, Me) {
          B(Y, z(ne), ve, Me);
        }), Y;
      }
      function G1(E, B, z) {
        B = Ul(B, E), E = k7(E, B);
        var Y = E == null ? E : E[Gu(Ms(B))];
        return Y == null ? r : Zo(Y, E, z);
      }
      function $A(E) {
        return da(E) && no(E) == ee;
      }
      function MK(E) {
        return da(E) && no(E) == Ae;
      }
      function IK(E) {
        return da(E) && no(E) == ie;
      }
      function V1(E, B, z, Y, ne) {
        return E === B ? !0 : E == null || B == null || !da(E) && !da(B) ? E !== E && B !== B : TK(E, B, z, Y, V1, ne);
      }
      function TK(E, B, z, Y, ne, ve) {
        var Me = Dr(E), Re = Dr(B), He = Me ? $ : ki(E), ut = Re ? $ : ki(B);
        He = He == ee ? _e : He, ut = ut == ee ? _e : ut;
        var ct = He == _e, gt = ut == _e, It = He == ut;
        if (It && Vl(E)) {
          if (!Vl(B))
            return !1;
          Me = !0, ct = !1;
        }
        if (It && !ct)
          return ve || (ve = new cu()), Me || Lm(E) ? N7(E, B, z, Y, ne, ve) : nX(E, B, He, z, Y, ne, ve);
        if (!(z & h)) {
          var Gt = ct && wn.call(E, "__wrapped__"), ar = gt && wn.call(B, "__wrapped__");
          if (Gt || ar) {
            var Lr = Gt ? E.value() : E, ir = ar ? B.value() : B;
            return ve || (ve = new cu()), ne(Lr, ir, z, Y, ve);
          }
        }
        return It ? (ve || (ve = new cu()), aX(E, B, z, Y, ne, ve)) : !1;
      }
      function NK(E) {
        return da(E) && ki(E) == De;
      }
      function Tb(E, B, z, Y) {
        var ne = z.length, ve = ne, Me = !Y;
        if (E == null)
          return !ve;
        for (E = Un(E); ne--; ) {
          var Re = z[ne];
          if (Me && Re[2] ? Re[1] !== E[Re[0]] : !(Re[0] in E))
            return !1;
        }
        for (; ++ne < ve; ) {
          Re = z[ne];
          var He = Re[0], ut = E[He], ct = Re[1];
          if (Me && Re[2]) {
            if (ut === r && !(He in E))
              return !1;
          } else {
            var gt = new cu();
            if (Y)
              var It = Y(ut, ct, He, E, B, gt);
            if (!(It === r ? V1(ct, ut, h | p, Y, gt) : It))
              return !1;
          }
        }
        return !0;
      }
      function JA(E) {
        if (!na(E) || mX(E))
          return !1;
        var B = Ec(E) ? NH : Ml;
        return B.test(df(E));
      }
      function PK(E) {
        return da(E) && no(E) == be;
      }
      function BK(E) {
        return da(E) && ki(E) == Se;
      }
      function OK(E) {
        return da(E) && qv(E.length) && !!jn[no(E)];
      }
      function e7(E) {
        return typeof E == "function" ? E : E == null ? Io : typeof E == "object" ? Dr(E) ? n7(E[0], E[1]) : r7(E) : Sw(E);
      }
      function Nb(E) {
        if (!K1(E))
          return LH(E);
        var B = [];
        for (var z in Un(E))
          wn.call(E, z) && z != "constructor" && B.push(z);
        return B;
      }
      function FK(E) {
        if (!na(E))
          return gX(E);
        var B = K1(E), z = [];
        for (var Y in E)
          Y == "constructor" && (B || !wn.call(E, Y)) || z.push(Y);
        return z;
      }
      function Pb(E, B) {
        return E < B;
      }
      function t7(E, B) {
        var z = -1, Y = Do(E) ? tt(E.length) : [];
        return kl(E, function(ne, ve, Me) {
          Y[++z] = B(ne, ve, Me);
        }), Y;
      }
      function r7(E) {
        var B = jb(E);
        return B.length == 1 && B[0][2] ? R7(B[0][0], B[0][1]) : function(z) {
          return z === E || Tb(z, E, B);
        };
      }
      function n7(E, B) {
        return Wb(E) && F7(B) ? R7(Gu(E), B) : function(z) {
          var Y = i4(z, E);
          return Y === r && Y === B ? o4(z, E) : V1(B, Y, h | p);
        };
      }
      function Dv(E, B, z, Y, ne) {
        E !== B && Eb(B, function(ve, Me) {
          if (ne || (ne = new cu()), na(ve))
            RK(E, B, Me, z, Dv, Y, ne);
          else {
            var Re = Y ? Y(Qb(E, Me), ve, Me + "", E, B, ne) : r;
            Re === r && (Re = ve), wb(E, Me, Re);
          }
        }, Mo);
      }
      function RK(E, B, z, Y, ne, ve, Me) {
        var Re = Qb(E, z), He = Qb(B, z), ut = Me.get(He);
        if (ut) {
          wb(E, z, ut);
          return;
        }
        var ct = ve ? ve(Re, He, z + "", E, B, Me) : r, gt = ct === r;
        if (gt) {
          var It = Dr(He), Gt = !It && Vl(He), ar = !It && !Gt && Lm(He);
          ct = He, It || Gt || ar ? Dr(Re) ? ct = Re : Sa(Re) ? ct = Eo(Re) : Gt ? (gt = !1, ct = h7(He, !0)) : ar ? (gt = !1, ct = v7(He, !0)) : ct = [] : j1(He) || ff(He) ? (ct = Re, ff(Re) ? ct = fw(Re) : (!na(Re) || Ec(Re)) && (ct = O7(He))) : gt = !1;
        }
        gt && (Me.set(He, ct), ne(ct, He, Y, ve, Me), Me.delete(He)), wb(E, z, ct);
      }
      function a7(E, B) {
        var z = E.length;
        if (z)
          return B += B < 0 ? z : 0, Cc(B, z) ? E[B] : r;
      }
      function i7(E, B, z) {
        B.length ? B = Zn(B, function(ve) {
          return Dr(ve) ? function(Me) {
            return cf(Me, ve.length === 1 ? ve[0] : ve);
          } : ve;
        }) : B = [Io];
        var Y = -1;
        B = Zn(B, Qo(er()));
        var ne = t7(E, function(ve, Me, Re) {
          var He = Zn(B, function(ut) {
            return ut(ve);
          });
          return { criteria: He, index: ++Y, value: ve };
        });
        return cH(ne, function(ve, Me) {
          return WK(ve, Me, z);
        });
      }
      function LK(E, B) {
        return o7(E, B, function(z, Y) {
          return o4(E, Y);
        });
      }
      function o7(E, B, z) {
        for (var Y = -1, ne = B.length, ve = {}; ++Y < ne; ) {
          var Me = B[Y], Re = cf(E, Me);
          z(Re, Me) && q1(ve, Ul(Me, E), Re);
        }
        return ve;
      }
      function kK(E) {
        return function(B) {
          return cf(B, E);
        };
      }
      function Bb(E, B, z, Y) {
        var ne = Y ? uH : Em, ve = -1, Me = B.length, Re = E;
        for (E === B && (B = Eo(B)), z && (Re = Zn(E, Qo(z))); ++ve < Me; )
          for (var He = 0, ut = B[ve], ct = z ? z(ut) : ut; (He = ne(Re, ct, He, Y)) > -1; )
            Re !== E && gv.call(Re, He, 1), gv.call(E, He, 1);
        return E;
      }
      function s7(E, B) {
        for (var z = E ? B.length : 0, Y = z - 1; z--; ) {
          var ne = B[z];
          if (z == Y || ne !== ve) {
            var ve = ne;
            Cc(ne) ? gv.call(E, ne, 1) : Lb(E, ne);
          }
        }
        return E;
      }
      function Ob(E, B) {
        return E + xv(GA() * (B - E + 1));
      }
      function zK(E, B, z, Y) {
        for (var ne = -1, ve = qa(bv((B - E) / (z || 1)), 0), Me = tt(ve); ve--; )
          Me[Y ? ve : ++ne] = E, E += z;
        return Me;
      }
      function Fb(E, B) {
        var z = "";
        if (!E || B < 1 || B > G)
          return z;
        do
          B % 2 && (z += E), B = xv(B / 2), B && (E += E);
        while (B);
        return z;
      }
      function kr(E, B) {
        return $b(L7(E, B, Io), E + "");
      }
      function UK(E) {
        return HA(km(E));
      }
      function GK(E, B) {
        var z = km(E);
        return Lv(z, uf(B, 0, z.length));
      }
      function q1(E, B, z, Y) {
        if (!na(E))
          return E;
        B = Ul(B, E);
        for (var ne = -1, ve = B.length, Me = ve - 1, Re = E; Re != null && ++ne < ve; ) {
          var He = Gu(B[ne]), ut = z;
          if (He === "__proto__" || He === "constructor" || He === "prototype")
            return E;
          if (ne != Me) {
            var ct = Re[He];
            ut = Y ? Y(ct, He, Re) : r, ut === r && (ut = na(ct) ? ct : Cc(B[ne + 1]) ? [] : {});
          }
          z1(Re, He, ut), Re = Re[He];
        }
        return E;
      }
      var u7 = _v ? function(E, B) {
        return _v.set(E, B), E;
      } : Io, VK = yv ? function(E, B) {
        return yv(E, "toString", {
          configurable: !0,
          enumerable: !1,
          value: u4(B),
          writable: !0
        });
      } : Io;
      function qK(E) {
        return Lv(km(E));
      }
      function Ds(E, B, z) {
        var Y = -1, ne = E.length;
        B < 0 && (B = -B > ne ? 0 : ne + B), z = z > ne ? ne : z, z < 0 && (z += ne), ne = B > z ? 0 : z - B >>> 0, B >>>= 0;
        for (var ve = tt(ne); ++Y < ne; )
          ve[Y] = E[Y + B];
        return ve;
      }
      function HK(E, B) {
        var z;
        return kl(E, function(Y, ne, ve) {
          return z = B(Y, ne, ve), !z;
        }), !!z;
      }
      function Mv(E, B, z) {
        var Y = 0, ne = E == null ? Y : E.length;
        if (typeof B == "number" && B === B && ne <= H) {
          for (; Y < ne; ) {
            var ve = Y + ne >>> 1, Me = E[ve];
            Me !== null && !Jo(Me) && (z ? Me <= B : Me < B) ? Y = ve + 1 : ne = ve;
          }
          return ne;
        }
        return Rb(E, B, Io, z);
      }
      function Rb(E, B, z, Y) {
        var ne = 0, ve = E == null ? 0 : E.length;
        if (ve === 0)
          return 0;
        B = z(B);
        for (var Me = B !== B, Re = B === null, He = Jo(B), ut = B === r; ne < ve; ) {
          var ct = xv((ne + ve) / 2), gt = z(E[ct]), It = gt !== r, Gt = gt === null, ar = gt === gt, Lr = Jo(gt);
          if (Me)
            var ir = Y || ar;
          else ut ? ir = ar && (Y || It) : Re ? ir = ar && It && (Y || !Gt) : He ? ir = ar && It && !Gt && (Y || !Lr) : Gt || Lr ? ir = !1 : ir = Y ? gt <= B : gt < B;
          ir ? ne = ct + 1 : ve = ct;
        }
        return Li(ve, X);
      }
      function c7(E, B) {
        for (var z = -1, Y = E.length, ne = 0, ve = []; ++z < Y; ) {
          var Me = E[z], Re = B ? B(Me) : Me;
          if (!z || !lu(Re, He)) {
            var He = Re;
            ve[ne++] = Me === 0 ? 0 : Me;
          }
        }
        return ve;
      }
      function l7(E) {
        return typeof E == "number" ? E : Jo(E) ? q : +E;
      }
      function $o(E) {
        if (typeof E == "string")
          return E;
        if (Dr(E))
          return Zn(E, $o) + "";
        if (Jo(E))
          return VA ? VA.call(E) : "";
        var B = E + "";
        return B == "0" && 1 / E == -R ? "-0" : B;
      }
      function zl(E, B, z) {
        var Y = -1, ne = sv, ve = E.length, Me = !0, Re = [], He = Re;
        if (z)
          Me = !1, ne = db;
        else if (ve >= a) {
          var ut = B ? null : tX(E);
          if (ut)
            return cv(ut);
          Me = !1, ne = B1, He = new sf();
        } else
          He = B ? [] : Re;
        e:
          for (; ++Y < ve; ) {
            var ct = E[Y], gt = B ? B(ct) : ct;
            if (ct = z || ct !== 0 ? ct : 0, Me && gt === gt) {
              for (var It = He.length; It--; )
                if (He[It] === gt)
                  continue e;
              B && He.push(gt), Re.push(ct);
            } else ne(He, gt, z) || (He !== Re && He.push(gt), Re.push(ct));
          }
        return Re;
      }
      function Lb(E, B) {
        return B = Ul(B, E), E = k7(E, B), E == null || delete E[Gu(Ms(B))];
      }
      function d7(E, B, z, Y) {
        return q1(E, B, z(cf(E, B)), Y);
      }
      function Iv(E, B, z, Y) {
        for (var ne = E.length, ve = Y ? ne : -1; (Y ? ve-- : ++ve < ne) && B(E[ve], ve, E); )
          ;
        return z ? Ds(E, Y ? 0 : ve, Y ? ve + 1 : ne) : Ds(E, Y ? ve + 1 : 0, Y ? ne : ve);
      }
      function f7(E, B) {
        var z = E;
        return z instanceof Xr && (z = z.value()), fb(B, function(Y, ne) {
          return ne.func.apply(ne.thisArg, Fl([Y], ne.args));
        }, z);
      }
      function kb(E, B, z) {
        var Y = E.length;
        if (Y < 2)
          return Y ? zl(E[0]) : [];
        for (var ne = -1, ve = tt(Y); ++ne < Y; )
          for (var Me = E[ne], Re = -1; ++Re < Y; )
            Re != ne && (ve[ne] = U1(ve[ne] || Me, E[Re], B, z));
        return zl(bi(ve, 1), B, z);
      }
      function m7(E, B, z) {
        for (var Y = -1, ne = E.length, ve = B.length, Me = {}; ++Y < ne; ) {
          var Re = Y < ve ? B[Y] : r;
          z(Me, E[Y], Re);
        }
        return Me;
      }
      function zb(E) {
        return Sa(E) ? E : [];
      }
      function Ub(E) {
        return typeof E == "function" ? E : Io;
      }
      function Ul(E, B) {
        return Dr(E) ? E : Wb(E, B) ? [E] : V7(bn(E));
      }
      var KK = kr;
      function Gl(E, B, z) {
        var Y = E.length;
        return z = z === r ? Y : z, !B && z >= Y ? E : Ds(E, B, z);
      }
      var p7 = PH || function(E) {
        return yi.clearTimeout(E);
      };
      function h7(E, B) {
        if (B)
          return E.slice();
        var z = E.length, Y = RA ? RA(z) : new E.constructor(z);
        return E.copy(Y), Y;
      }
      function Gb(E) {
        var B = new E.constructor(E.byteLength);
        return new hv(B).set(new hv(E)), B;
      }
      function XK(E, B) {
        var z = B ? Gb(E.buffer) : E.buffer;
        return new E.constructor(z, E.byteOffset, E.byteLength);
      }
      function jK(E) {
        var B = new E.constructor(E.source, yc.exec(E));
        return B.lastIndex = E.lastIndex, B;
      }
      function YK(E) {
        return k1 ? Un(k1.call(E)) : {};
      }
      function v7(E, B) {
        var z = B ? Gb(E.buffer) : E.buffer;
        return new E.constructor(z, E.byteOffset, E.length);
      }
      function g7(E, B) {
        if (E !== B) {
          var z = E !== r, Y = E === null, ne = E === E, ve = Jo(E), Me = B !== r, Re = B === null, He = B === B, ut = Jo(B);
          if (!Re && !ut && !ve && E > B || ve && Me && He && !Re && !ut || Y && Me && He || !z && He || !ne)
            return 1;
          if (!Y && !ve && !ut && E < B || ut && z && ne && !Y && !ve || Re && z && ne || !Me && ne || !He)
            return -1;
        }
        return 0;
      }
      function WK(E, B, z) {
        for (var Y = -1, ne = E.criteria, ve = B.criteria, Me = ne.length, Re = z.length; ++Y < Me; ) {
          var He = g7(ne[Y], ve[Y]);
          if (He) {
            if (Y >= Re)
              return He;
            var ut = z[Y];
            return He * (ut == "desc" ? -1 : 1);
          }
        }
        return E.index - B.index;
      }
      function y7(E, B, z, Y) {
        for (var ne = -1, ve = E.length, Me = z.length, Re = -1, He = B.length, ut = qa(ve - Me, 0), ct = tt(He + ut), gt = !Y; ++Re < He; )
          ct[Re] = B[Re];
        for (; ++ne < Me; )
          (gt || ne < ve) && (ct[z[ne]] = E[ne]);
        for (; ut--; )
          ct[Re++] = E[ne++];
        return ct;
      }
      function b7(E, B, z, Y) {
        for (var ne = -1, ve = E.length, Me = -1, Re = z.length, He = -1, ut = B.length, ct = qa(ve - Re, 0), gt = tt(ct + ut), It = !Y; ++ne < ct; )
          gt[ne] = E[ne];
        for (var Gt = ne; ++He < ut; )
          gt[Gt + He] = B[He];
        for (; ++Me < Re; )
          (It || ne < ve) && (gt[Gt + z[Me]] = E[ne++]);
        return gt;
      }
      function Eo(E, B) {
        var z = -1, Y = E.length;
        for (B || (B = tt(Y)); ++z < Y; )
          B[z] = E[z];
        return B;
      }
      function Uu(E, B, z, Y) {
        var ne = !z;
        z || (z = {});
        for (var ve = -1, Me = B.length; ++ve < Me; ) {
          var Re = B[ve], He = Y ? Y(z[Re], E[Re], Re, z, E) : r;
          He === r && (He = E[Re]), ne ? Sc(z, Re, He) : z1(z, Re, He);
        }
        return z;
      }
      function ZK(E, B) {
        return Uu(E, Yb(E), B);
      }
      function QK(E, B) {
        return Uu(E, P7(E), B);
      }
      function Tv(E, B) {
        return function(z, Y) {
          var ne = Dr(z) ? rH : bK, ve = B ? B() : {};
          return ne(z, E, er(Y, 2), ve);
        };
      }
      function Om(E) {
        return kr(function(B, z) {
          var Y = -1, ne = z.length, ve = ne > 1 ? z[ne - 1] : r, Me = ne > 2 ? z[2] : r;
          for (ve = E.length > 3 && typeof ve == "function" ? (ne--, ve) : r, Me && ao(z[0], z[1], Me) && (ve = ne < 3 ? r : ve, ne = 1), B = Un(B); ++Y < ne; ) {
            var Re = z[Y];
            Re && E(B, Re, Y, ve);
          }
          return B;
        });
      }
      function x7(E, B) {
        return function(z, Y) {
          if (z == null)
            return z;
          if (!Do(z))
            return E(z, Y);
          for (var ne = z.length, ve = B ? ne : -1, Me = Un(z); (B ? ve-- : ++ve < ne) && Y(Me[ve], ve, Me) !== !1; )
            ;
          return z;
        };
      }
      function _7(E) {
        return function(B, z, Y) {
          for (var ne = -1, ve = Un(B), Me = Y(B), Re = Me.length; Re--; ) {
            var He = Me[E ? Re : ++ne];
            if (z(ve[He], He, ve) === !1)
              break;
          }
          return B;
        };
      }
      function $K(E, B, z) {
        var Y = B & g, ne = H1(E);
        function ve() {
          var Me = this && this !== yi && this instanceof ve ? ne : E;
          return Me.apply(Y ? z : this, arguments);
        }
        return ve;
      }
      function S7(E) {
        return function(B) {
          B = bn(B);
          var z = Dm(B) ? uu(B) : r, Y = z ? z[0] : B.charAt(0), ne = z ? Gl(z, 1).join("") : B.slice(1);
          return Y[E]() + ne;
        };
      }
      function Fm(E) {
        return function(B) {
          return fb(xw(bw(B).replace(Vq, "")), E, "");
        };
      }
      function H1(E) {
        return function() {
          var B = arguments;
          switch (B.length) {
            case 0:
              return new E();
            case 1:
              return new E(B[0]);
            case 2:
              return new E(B[0], B[1]);
            case 3:
              return new E(B[0], B[1], B[2]);
            case 4:
              return new E(B[0], B[1], B[2], B[3]);
            case 5:
              return new E(B[0], B[1], B[2], B[3], B[4]);
            case 6:
              return new E(B[0], B[1], B[2], B[3], B[4], B[5]);
            case 7:
              return new E(B[0], B[1], B[2], B[3], B[4], B[5], B[6]);
          }
          var z = Bm(E.prototype), Y = E.apply(z, B);
          return na(Y) ? Y : z;
        };
      }
      function JK(E, B, z) {
        var Y = H1(E);
        function ne() {
          for (var ve = arguments.length, Me = tt(ve), Re = ve, He = Rm(ne); Re--; )
            Me[Re] = arguments[Re];
          var ut = ve < 3 && Me[0] !== He && Me[ve - 1] !== He ? [] : Rl(Me, He);
          if (ve -= ut.length, ve < z)
            return D7(
              E,
              B,
              Nv,
              ne.placeholder,
              r,
              Me,
              ut,
              r,
              r,
              z - ve
            );
          var ct = this && this !== yi && this instanceof ne ? Y : E;
          return Zo(ct, this, Me);
        }
        return ne;
      }
      function A7(E) {
        return function(B, z, Y) {
          var ne = Un(B);
          if (!Do(B)) {
            var ve = er(z, 3);
            B = ni(B), z = function(Re) {
              return ve(ne[Re], Re, ne);
            };
          }
          var Me = E(B, z, Y);
          return Me > -1 ? ne[ve ? B[Me] : Me] : r;
        };
      }
      function w7(E) {
        return wc(function(B) {
          var z = B.length, Y = z, ne = Cs.prototype.thru;
          for (E && B.reverse(); Y--; ) {
            var ve = B[Y];
            if (typeof ve != "function")
              throw new ws(o);
            if (ne && !Me && Fv(ve) == "wrapper")
              var Me = new Cs([], !0);
          }
          for (Y = Me ? Y : z; ++Y < z; ) {
            ve = B[Y];
            var Re = Fv(ve), He = Re == "wrapper" ? Xb(ve) : r;
            He && Zb(He[0]) && He[1] == (A | _ | b | w) && !He[4].length && He[9] == 1 ? Me = Me[Fv(He[0])].apply(Me, He[3]) : Me = ve.length == 1 && Zb(ve) ? Me[Re]() : Me.thru(ve);
          }
          return function() {
            var ut = arguments, ct = ut[0];
            if (Me && ut.length == 1 && Dr(ct))
              return Me.plant(ct).value();
            for (var gt = 0, It = z ? B[gt].apply(this, ut) : ct; ++gt < z; )
              It = B[gt].call(this, It);
            return It;
          };
        });
      }
      function Nv(E, B, z, Y, ne, ve, Me, Re, He, ut) {
        var ct = B & A, gt = B & g, It = B & v, Gt = B & (_ | S), ar = B & C, Lr = It ? r : H1(E);
        function ir() {
          for (var Gr = arguments.length, Wr = tt(Gr), es = Gr; es--; )
            Wr[es] = arguments[es];
          if (Gt)
            var io = Rm(ir), ts = dH(Wr, io);
          if (Y && (Wr = y7(Wr, Y, ne, Gt)), ve && (Wr = b7(Wr, ve, Me, Gt)), Gr -= ts, Gt && Gr < ut) {
            var Aa = Rl(Wr, io);
            return D7(
              E,
              B,
              Nv,
              ir.placeholder,
              z,
              Wr,
              Aa,
              Re,
              He,
              ut - Gr
            );
          }
          var du = gt ? z : this, Mc = It ? du[E] : E;
          return Gr = Wr.length, Re ? Wr = bX(Wr, Re) : ar && Gr > 1 && Wr.reverse(), ct && He < Gr && (Wr.length = He), this && this !== yi && this instanceof ir && (Mc = Lr || H1(Mc)), Mc.apply(du, Wr);
        }
        return ir;
      }
      function C7(E, B) {
        return function(z, Y) {
          return DK(z, E, B(Y), {});
        };
      }
      function Pv(E, B) {
        return function(z, Y) {
          var ne;
          if (z === r && Y === r)
            return B;
          if (z !== r && (ne = z), Y !== r) {
            if (ne === r)
              return Y;
            typeof z == "string" || typeof Y == "string" ? (z = $o(z), Y = $o(Y)) : (z = l7(z), Y = l7(Y)), ne = E(z, Y);
          }
          return ne;
        };
      }
      function Vb(E) {
        return wc(function(B) {
          return B = Zn(B, Qo(er())), kr(function(z) {
            var Y = this;
            return E(B, function(ne) {
              return Zo(ne, Y, z);
            });
          });
        });
      }
      function Bv(E, B) {
        B = B === r ? " " : $o(B);
        var z = B.length;
        if (z < 2)
          return z ? Fb(B, E) : B;
        var Y = Fb(B, bv(E / Mm(B)));
        return Dm(B) ? Gl(uu(Y), 0, E).join("") : Y.slice(0, E);
      }
      function eX(E, B, z, Y) {
        var ne = B & g, ve = H1(E);
        function Me() {
          for (var Re = -1, He = arguments.length, ut = -1, ct = Y.length, gt = tt(ct + He), It = this && this !== yi && this instanceof Me ? ve : E; ++ut < ct; )
            gt[ut] = Y[ut];
          for (; He--; )
            gt[ut++] = arguments[++Re];
          return Zo(It, ne ? z : this, gt);
        }
        return Me;
      }
      function E7(E) {
        return function(B, z, Y) {
          return Y && typeof Y != "number" && ao(B, z, Y) && (z = Y = r), B = Dc(B), z === r ? (z = B, B = 0) : z = Dc(z), Y = Y === r ? B < z ? 1 : -1 : Dc(Y), zK(B, z, Y, E);
        };
      }
      function Ov(E) {
        return function(B, z) {
          return typeof B == "string" && typeof z == "string" || (B = Is(B), z = Is(z)), E(B, z);
        };
      }
      function D7(E, B, z, Y, ne, ve, Me, Re, He, ut) {
        var ct = B & _, gt = ct ? Me : r, It = ct ? r : Me, Gt = ct ? ve : r, ar = ct ? r : ve;
        B |= ct ? b : x, B &= ~(ct ? x : b), B & y || (B &= ~(g | v));
        var Lr = [
          E,
          B,
          ne,
          Gt,
          gt,
          ar,
          It,
          Re,
          He,
          ut
        ], ir = z.apply(r, Lr);
        return Zb(E) && z7(ir, Lr), ir.placeholder = Y, U7(ir, E, B);
      }
      function qb(E) {
        var B = Va[E];
        return function(z, Y) {
          if (z = Is(z), Y = Y == null ? 0 : Li(Fr(Y), 292), Y && UA(z)) {
            var ne = (bn(z) + "e").split("e"), ve = B(ne[0] + "e" + (+ne[1] + Y));
            return ne = (bn(ve) + "e").split("e"), +(ne[0] + "e" + (+ne[1] - Y));
          }
          return B(z);
        };
      }
      var tX = Nm && 1 / cv(new Nm([, -0]))[1] == R ? function(E) {
        return new Nm(E);
      } : d4;
      function M7(E) {
        return function(B) {
          var z = ki(B);
          return z == De ? bb(B) : z == Se ? yH(B) : lH(B, E(B));
        };
      }
      function Ac(E, B, z, Y, ne, ve, Me, Re) {
        var He = B & v;
        if (!He && typeof E != "function")
          throw new ws(o);
        var ut = Y ? Y.length : 0;
        if (ut || (B &= ~(b | x), Y = ne = r), Me = Me === r ? Me : qa(Fr(Me), 0), Re = Re === r ? Re : Fr(Re), ut -= ne ? ne.length : 0, B & x) {
          var ct = Y, gt = ne;
          Y = ne = r;
        }
        var It = He ? r : Xb(E), Gt = [
          E,
          B,
          z,
          Y,
          ne,
          ct,
          gt,
          ve,
          Me,
          Re
        ];
        if (It && vX(Gt, It), E = Gt[0], B = Gt[1], z = Gt[2], Y = Gt[3], ne = Gt[4], Re = Gt[9] = Gt[9] === r ? He ? 0 : E.length : qa(Gt[9] - ut, 0), !Re && B & (_ | S) && (B &= ~(_ | S)), !B || B == g)
          var ar = $K(E, B, z);
        else B == _ || B == S ? ar = JK(E, B, Re) : (B == b || B == (g | b)) && !ne.length ? ar = eX(E, B, z, Y) : ar = Nv.apply(r, Gt);
        var Lr = It ? u7 : z7;
        return U7(Lr(ar, Gt), E, B);
      }
      function I7(E, B, z, Y) {
        return E === r || lu(E, Tm[z]) && !wn.call(Y, z) ? B : E;
      }
      function T7(E, B, z, Y, ne, ve) {
        return na(E) && na(B) && (ve.set(B, E), Dv(E, B, r, T7, ve), ve.delete(B)), E;
      }
      function rX(E) {
        return j1(E) ? r : E;
      }
      function N7(E, B, z, Y, ne, ve) {
        var Me = z & h, Re = E.length, He = B.length;
        if (Re != He && !(Me && He > Re))
          return !1;
        var ut = ve.get(E), ct = ve.get(B);
        if (ut && ct)
          return ut == B && ct == E;
        var gt = -1, It = !0, Gt = z & p ? new sf() : r;
        for (ve.set(E, B), ve.set(B, E); ++gt < Re; ) {
          var ar = E[gt], Lr = B[gt];
          if (Y)
            var ir = Me ? Y(Lr, ar, gt, B, E, ve) : Y(ar, Lr, gt, E, B, ve);
          if (ir !== r) {
            if (ir)
              continue;
            It = !1;
            break;
          }
          if (Gt) {
            if (!mb(B, function(Gr, Wr) {
              if (!B1(Gt, Wr) && (ar === Gr || ne(ar, Gr, z, Y, ve)))
                return Gt.push(Wr);
            })) {
              It = !1;
              break;
            }
          } else if (!(ar === Lr || ne(ar, Lr, z, Y, ve))) {
            It = !1;
            break;
          }
        }
        return ve.delete(E), ve.delete(B), It;
      }
      function nX(E, B, z, Y, ne, ve, Me) {
        switch (z) {
          case Ce:
            if (E.byteLength != B.byteLength || E.byteOffset != B.byteOffset)
              return !1;
            E = E.buffer, B = B.buffer;
          case Ae:
            return !(E.byteLength != B.byteLength || !ve(new hv(E), new hv(B)));
          case re:
          case ie:
          case ae:
            return lu(+E, +B);
          case se:
            return E.name == B.name && E.message == B.message;
          case be:
          case Ne:
            return E == B + "";
          case De:
            var Re = bb;
          case Se:
            var He = Y & h;
            if (Re || (Re = cv), E.size != B.size && !He)
              return !1;
            var ut = Me.get(E);
            if (ut)
              return ut == B;
            Y |= p, Me.set(E, B);
            var ct = N7(Re(E), Re(B), Y, ne, ve, Me);
            return Me.delete(E), ct;
          case J:
            if (k1)
              return k1.call(E) == k1.call(B);
        }
        return !1;
      }
      function aX(E, B, z, Y, ne, ve) {
        var Me = z & h, Re = Hb(E), He = Re.length, ut = Hb(B), ct = ut.length;
        if (He != ct && !Me)
          return !1;
        for (var gt = He; gt--; ) {
          var It = Re[gt];
          if (!(Me ? It in B : wn.call(B, It)))
            return !1;
        }
        var Gt = ve.get(E), ar = ve.get(B);
        if (Gt && ar)
          return Gt == B && ar == E;
        var Lr = !0;
        ve.set(E, B), ve.set(B, E);
        for (var ir = Me; ++gt < He; ) {
          It = Re[gt];
          var Gr = E[It], Wr = B[It];
          if (Y)
            var es = Me ? Y(Wr, Gr, It, B, E, ve) : Y(Gr, Wr, It, E, B, ve);
          if (!(es === r ? Gr === Wr || ne(Gr, Wr, z, Y, ve) : es)) {
            Lr = !1;
            break;
          }
          ir || (ir = It == "constructor");
        }
        if (Lr && !ir) {
          var io = E.constructor, ts = B.constructor;
          io != ts && "constructor" in E && "constructor" in B && !(typeof io == "function" && io instanceof io && typeof ts == "function" && ts instanceof ts) && (Lr = !1);
        }
        return ve.delete(E), ve.delete(B), Lr;
      }
      function wc(E) {
        return $b(L7(E, r, X7), E + "");
      }
      function Hb(E) {
        return QA(E, ni, Yb);
      }
      function Kb(E) {
        return QA(E, Mo, P7);
      }
      var Xb = _v ? function(E) {
        return _v.get(E);
      } : d4;
      function Fv(E) {
        for (var B = E.name + "", z = Pm[B], Y = wn.call(Pm, B) ? z.length : 0; Y--; ) {
          var ne = z[Y], ve = ne.func;
          if (ve == null || ve == E)
            return ne.name;
        }
        return B;
      }
      function Rm(E) {
        var B = wn.call(fe, "placeholder") ? fe : E;
        return B.placeholder;
      }
      function er() {
        var E = fe.iteratee || c4;
        return E = E === c4 ? e7 : E, arguments.length ? E(arguments[0], arguments[1]) : E;
      }
      function Rv(E, B) {
        var z = E.__data__;
        return fX(B) ? z[typeof B == "string" ? "string" : "hash"] : z.map;
      }
      function jb(E) {
        for (var B = ni(E), z = B.length; z--; ) {
          var Y = B[z], ne = E[Y];
          B[z] = [Y, ne, F7(ne)];
        }
        return B;
      }
      function lf(E, B) {
        var z = hH(E, B);
        return JA(z) ? z : r;
      }
      function iX(E) {
        var B = wn.call(E, af), z = E[af];
        try {
          E[af] = r;
          var Y = !0;
        } catch {
        }
        var ne = mv.call(E);
        return Y && (B ? E[af] = z : delete E[af]), ne;
      }
      var Yb = _b ? function(E) {
        return E == null ? [] : (E = Un(E), Ol(_b(E), function(B) {
          return kA.call(E, B);
        }));
      } : f4, P7 = _b ? function(E) {
        for (var B = []; E; )
          Fl(B, Yb(E)), E = vv(E);
        return B;
      } : f4, ki = no;
      (Sb && ki(new Sb(new ArrayBuffer(1))) != Ce || F1 && ki(new F1()) != De || Ab && ki(Ab.resolve()) != le || Nm && ki(new Nm()) != Se || R1 && ki(new R1()) != de) && (ki = function(E) {
        var B = no(E), z = B == _e ? E.constructor : r, Y = z ? df(z) : "";
        if (Y)
          switch (Y) {
            case GH:
              return Ce;
            case VH:
              return De;
            case qH:
              return le;
            case HH:
              return Se;
            case KH:
              return de;
          }
        return B;
      });
      function oX(E, B, z) {
        for (var Y = -1, ne = z.length; ++Y < ne; ) {
          var ve = z[Y], Me = ve.size;
          switch (ve.type) {
            case "drop":
              E += Me;
              break;
            case "dropRight":
              B -= Me;
              break;
            case "take":
              B = Li(B, E + Me);
              break;
            case "takeRight":
              E = qa(E, B - Me);
              break;
          }
        }
        return { start: E, end: B };
      }
      function sX(E) {
        var B = E.match(jo);
        return B ? B[1].split(Yo) : [];
      }
      function B7(E, B, z) {
        B = Ul(B, E);
        for (var Y = -1, ne = B.length, ve = !1; ++Y < ne; ) {
          var Me = Gu(B[Y]);
          if (!(ve = E != null && z(E, Me)))
            break;
          E = E[Me];
        }
        return ve || ++Y != ne ? ve : (ne = E == null ? 0 : E.length, !!ne && qv(ne) && Cc(Me, ne) && (Dr(E) || ff(E)));
      }
      function uX(E) {
        var B = E.length, z = new E.constructor(B);
        return B && typeof E[0] == "string" && wn.call(E, "index") && (z.index = E.index, z.input = E.input), z;
      }
      function O7(E) {
        return typeof E.constructor == "function" && !K1(E) ? Bm(vv(E)) : {};
      }
      function cX(E, B, z) {
        var Y = E.constructor;
        switch (B) {
          case Ae:
            return Gb(E);
          case re:
          case ie:
            return new Y(+E);
          case Ce:
            return XK(E, z);
          case Ie:
          case Ue:
          case Xe:
          case je:
          case ht:
          case xt:
          case dt:
          case Le:
          case j:
            return v7(E, z);
          case De:
            return new Y();
          case ae:
          case Ne:
            return new Y(E);
          case be:
            return jK(E);
          case Se:
            return new Y();
          case J:
            return YK(E);
        }
      }
      function lX(E, B) {
        var z = B.length;
        if (!z)
          return E;
        var Y = z - 1;
        return B[Y] = (z > 1 ? "& " : "") + B[Y], B = B.join(z > 2 ? ", " : " "), E.replace(An, `{
/* [wrapped with ` + B + `] */
`);
      }
      function dX(E) {
        return Dr(E) || ff(E) || !!(zA && E && E[zA]);
      }
      function Cc(E, B) {
        var z = typeof E;
        return B = B ?? G, !!B && (z == "number" || z != "symbol" && Tl.test(E)) && E > -1 && E % 1 == 0 && E < B;
      }
      function ao(E, B, z) {
        if (!na(z))
          return !1;
        var Y = typeof B;
        return (Y == "number" ? Do(z) && Cc(B, z.length) : Y == "string" && B in z) ? lu(z[B], E) : !1;
      }
      function Wb(E, B) {
        if (Dr(E))
          return !1;
        var z = typeof E;
        return z == "number" || z == "symbol" || z == "boolean" || E == null || Jo(E) ? !0 : mn.test(E) || !la.test(E) || B != null && E in Un(B);
      }
      function fX(E) {
        var B = typeof E;
        return B == "string" || B == "number" || B == "symbol" || B == "boolean" ? E !== "__proto__" : E === null;
      }
      function Zb(E) {
        var B = Fv(E), z = fe[B];
        if (typeof z != "function" || !(B in Xr.prototype))
          return !1;
        if (E === z)
          return !0;
        var Y = Xb(z);
        return !!Y && E === Y[0];
      }
      function mX(E) {
        return !!FA && FA in E;
      }
      var pX = dv ? Ec : m4;
      function K1(E) {
        var B = E && E.constructor, z = typeof B == "function" && B.prototype || Tm;
        return E === z;
      }
      function F7(E) {
        return E === E && !na(E);
      }
      function R7(E, B) {
        return function(z) {
          return z == null ? !1 : z[E] === B && (B !== r || E in Un(z));
        };
      }
      function hX(E) {
        var B = Gv(E, function(Y) {
          return z.size === c && z.clear(), Y;
        }), z = B.cache;
        return B;
      }
      function vX(E, B) {
        var z = E[1], Y = B[1], ne = z | Y, ve = ne < (g | v | A), Me = Y == A && z == _ || Y == A && z == w && E[7].length <= B[8] || Y == (A | w) && B[7].length <= B[8] && z == _;
        if (!(ve || Me))
          return E;
        Y & g && (E[2] = B[2], ne |= z & g ? 0 : y);
        var Re = B[3];
        if (Re) {
          var He = E[3];
          E[3] = He ? y7(He, Re, B[4]) : Re, E[4] = He ? Rl(E[3], l) : B[4];
        }
        return Re = B[5], Re && (He = E[5], E[5] = He ? b7(He, Re, B[6]) : Re, E[6] = He ? Rl(E[5], l) : B[6]), Re = B[7], Re && (E[7] = Re), Y & A && (E[8] = E[8] == null ? B[8] : Li(E[8], B[8])), E[9] == null && (E[9] = B[9]), E[0] = B[0], E[1] = ne, E;
      }
      function gX(E) {
        var B = [];
        if (E != null)
          for (var z in Un(E))
            B.push(z);
        return B;
      }
      function yX(E) {
        return mv.call(E);
      }
      function L7(E, B, z) {
        return B = qa(B === r ? E.length - 1 : B, 0), function() {
          for (var Y = arguments, ne = -1, ve = qa(Y.length - B, 0), Me = tt(ve); ++ne < ve; )
            Me[ne] = Y[B + ne];
          ne = -1;
          for (var Re = tt(B + 1); ++ne < B; )
            Re[ne] = Y[ne];
          return Re[B] = z(Me), Zo(E, this, Re);
        };
      }
      function k7(E, B) {
        return B.length < 2 ? E : cf(E, Ds(B, 0, -1));
      }
      function bX(E, B) {
        for (var z = E.length, Y = Li(B.length, z), ne = Eo(E); Y--; ) {
          var ve = B[Y];
          E[Y] = Cc(ve, z) ? ne[ve] : r;
        }
        return E;
      }
      function Qb(E, B) {
        if (!(B === "constructor" && typeof E[B] == "function") && B != "__proto__")
          return E[B];
      }
      var z7 = G7(u7), X1 = OH || function(E, B) {
        return yi.setTimeout(E, B);
      }, $b = G7(VK);
      function U7(E, B, z) {
        var Y = B + "";
        return $b(E, lX(Y, xX(sX(Y), z)));
      }
      function G7(E) {
        var B = 0, z = 0;
        return function() {
          var Y = kH(), ne = I - (Y - z);
          if (z = Y, ne > 0) {
            if (++B >= N)
              return arguments[0];
          } else
            B = 0;
          return E.apply(r, arguments);
        };
      }
      function Lv(E, B) {
        var z = -1, Y = E.length, ne = Y - 1;
        for (B = B === r ? Y : B; ++z < B; ) {
          var ve = Ob(z, ne), Me = E[ve];
          E[ve] = E[z], E[z] = Me;
        }
        return E.length = B, E;
      }
      var V7 = hX(function(E) {
        var B = [];
        return E.charCodeAt(0) === 46 && B.push(""), E.replace(pn, function(z, Y, ne, ve) {
          B.push(ne ? ve.replace(ro, "$1") : Y || z);
        }), B;
      });
      function Gu(E) {
        if (typeof E == "string" || Jo(E))
          return E;
        var B = E + "";
        return B == "0" && 1 / E == -R ? "-0" : B;
      }
      function df(E) {
        if (E != null) {
          try {
            return fv.call(E);
          } catch {
          }
          try {
            return E + "";
          } catch {
          }
        }
        return "";
      }
      function xX(E, B) {
        return As(W, function(z) {
          var Y = "_." + z[0];
          B & z[1] && !sv(E, Y) && E.push(Y);
        }), E.sort();
      }
      function q7(E) {
        if (E instanceof Xr)
          return E.clone();
        var B = new Cs(E.__wrapped__, E.__chain__);
        return B.__actions__ = Eo(E.__actions__), B.__index__ = E.__index__, B.__values__ = E.__values__, B;
      }
      function _X(E, B, z) {
        (z ? ao(E, B, z) : B === r) ? B = 1 : B = qa(Fr(B), 0);
        var Y = E == null ? 0 : E.length;
        if (!Y || B < 1)
          return [];
        for (var ne = 0, ve = 0, Me = tt(bv(Y / B)); ne < Y; )
          Me[ve++] = Ds(E, ne, ne += B);
        return Me;
      }
      function SX(E) {
        for (var B = -1, z = E == null ? 0 : E.length, Y = 0, ne = []; ++B < z; ) {
          var ve = E[B];
          ve && (ne[Y++] = ve);
        }
        return ne;
      }
      function AX() {
        var E = arguments.length;
        if (!E)
          return [];
        for (var B = tt(E - 1), z = arguments[0], Y = E; Y--; )
          B[Y - 1] = arguments[Y];
        return Fl(Dr(z) ? Eo(z) : [z], bi(B, 1));
      }
      var wX = kr(function(E, B) {
        return Sa(E) ? U1(E, bi(B, 1, Sa, !0)) : [];
      }), CX = kr(function(E, B) {
        var z = Ms(B);
        return Sa(z) && (z = r), Sa(E) ? U1(E, bi(B, 1, Sa, !0), er(z, 2)) : [];
      }), EX = kr(function(E, B) {
        var z = Ms(B);
        return Sa(z) && (z = r), Sa(E) ? U1(E, bi(B, 1, Sa, !0), r, z) : [];
      });
      function DX(E, B, z) {
        var Y = E == null ? 0 : E.length;
        return Y ? (B = z || B === r ? 1 : Fr(B), Ds(E, B < 0 ? 0 : B, Y)) : [];
      }
      function MX(E, B, z) {
        var Y = E == null ? 0 : E.length;
        return Y ? (B = z || B === r ? 1 : Fr(B), B = Y - B, Ds(E, 0, B < 0 ? 0 : B)) : [];
      }
      function IX(E, B) {
        return E && E.length ? Iv(E, er(B, 3), !0, !0) : [];
      }
      function TX(E, B) {
        return E && E.length ? Iv(E, er(B, 3), !0) : [];
      }
      function NX(E, B, z, Y) {
        var ne = E == null ? 0 : E.length;
        return ne ? (z && typeof z != "number" && ao(E, B, z) && (z = 0, Y = ne), AK(E, B, z, Y)) : [];
      }
      function H7(E, B, z) {
        var Y = E == null ? 0 : E.length;
        if (!Y)
          return -1;
        var ne = z == null ? 0 : Fr(z);
        return ne < 0 && (ne = qa(Y + ne, 0)), uv(E, er(B, 3), ne);
      }
      function K7(E, B, z) {
        var Y = E == null ? 0 : E.length;
        if (!Y)
          return -1;
        var ne = Y - 1;
        return z !== r && (ne = Fr(z), ne = z < 0 ? qa(Y + ne, 0) : Li(ne, Y - 1)), uv(E, er(B, 3), ne, !0);
      }
      function X7(E) {
        var B = E == null ? 0 : E.length;
        return B ? bi(E, 1) : [];
      }
      function PX(E) {
        var B = E == null ? 0 : E.length;
        return B ? bi(E, R) : [];
      }
      function BX(E, B) {
        var z = E == null ? 0 : E.length;
        return z ? (B = B === r ? 1 : Fr(B), bi(E, B)) : [];
      }
      function OX(E) {
        for (var B = -1, z = E == null ? 0 : E.length, Y = {}; ++B < z; ) {
          var ne = E[B];
          Y[ne[0]] = ne[1];
        }
        return Y;
      }
      function j7(E) {
        return E && E.length ? E[0] : r;
      }
      function FX(E, B, z) {
        var Y = E == null ? 0 : E.length;
        if (!Y)
          return -1;
        var ne = z == null ? 0 : Fr(z);
        return ne < 0 && (ne = qa(Y + ne, 0)), Em(E, B, ne);
      }
      function RX(E) {
        var B = E == null ? 0 : E.length;
        return B ? Ds(E, 0, -1) : [];
      }
      var LX = kr(function(E) {
        var B = Zn(E, zb);
        return B.length && B[0] === E[0] ? Ib(B) : [];
      }), kX = kr(function(E) {
        var B = Ms(E), z = Zn(E, zb);
        return B === Ms(z) ? B = r : z.pop(), z.length && z[0] === E[0] ? Ib(z, er(B, 2)) : [];
      }), zX = kr(function(E) {
        var B = Ms(E), z = Zn(E, zb);
        return B = typeof B == "function" ? B : r, B && z.pop(), z.length && z[0] === E[0] ? Ib(z, r, B) : [];
      });
      function UX(E, B) {
        return E == null ? "" : RH.call(E, B);
      }
      function Ms(E) {
        var B = E == null ? 0 : E.length;
        return B ? E[B - 1] : r;
      }
      function GX(E, B, z) {
        var Y = E == null ? 0 : E.length;
        if (!Y)
          return -1;
        var ne = Y;
        return z !== r && (ne = Fr(z), ne = ne < 0 ? qa(Y + ne, 0) : Li(ne, Y - 1)), B === B ? xH(E, B, ne) : uv(E, DA, ne, !0);
      }
      function VX(E, B) {
        return E && E.length ? a7(E, Fr(B)) : r;
      }
      var qX = kr(Y7);
      function Y7(E, B) {
        return E && E.length && B && B.length ? Bb(E, B) : E;
      }
      function HX(E, B, z) {
        return E && E.length && B && B.length ? Bb(E, B, er(z, 2)) : E;
      }
      function KX(E, B, z) {
        return E && E.length && B && B.length ? Bb(E, B, r, z) : E;
      }
      var XX = wc(function(E, B) {
        var z = E == null ? 0 : E.length, Y = Cb(E, B);
        return s7(E, Zn(B, function(ne) {
          return Cc(ne, z) ? +ne : ne;
        }).sort(g7)), Y;
      });
      function jX(E, B) {
        var z = [];
        if (!(E && E.length))
          return z;
        var Y = -1, ne = [], ve = E.length;
        for (B = er(B, 3); ++Y < ve; ) {
          var Me = E[Y];
          B(Me, Y, E) && (z.push(Me), ne.push(Y));
        }
        return s7(E, ne), z;
      }
      function Jb(E) {
        return E == null ? E : UH.call(E);
      }
      function YX(E, B, z) {
        var Y = E == null ? 0 : E.length;
        return Y ? (z && typeof z != "number" && ao(E, B, z) ? (B = 0, z = Y) : (B = B == null ? 0 : Fr(B), z = z === r ? Y : Fr(z)), Ds(E, B, z)) : [];
      }
      function WX(E, B) {
        return Mv(E, B);
      }
      function ZX(E, B, z) {
        return Rb(E, B, er(z, 2));
      }
      function QX(E, B) {
        var z = E == null ? 0 : E.length;
        if (z) {
          var Y = Mv(E, B);
          if (Y < z && lu(E[Y], B))
            return Y;
        }
        return -1;
      }
      function $X(E, B) {
        return Mv(E, B, !0);
      }
      function JX(E, B, z) {
        return Rb(E, B, er(z, 2), !0);
      }
      function ej(E, B) {
        var z = E == null ? 0 : E.length;
        if (z) {
          var Y = Mv(E, B, !0) - 1;
          if (lu(E[Y], B))
            return Y;
        }
        return -1;
      }
      function tj(E) {
        return E && E.length ? c7(E) : [];
      }
      function rj(E, B) {
        return E && E.length ? c7(E, er(B, 2)) : [];
      }
      function nj(E) {
        var B = E == null ? 0 : E.length;
        return B ? Ds(E, 1, B) : [];
      }
      function aj(E, B, z) {
        return E && E.length ? (B = z || B === r ? 1 : Fr(B), Ds(E, 0, B < 0 ? 0 : B)) : [];
      }
      function ij(E, B, z) {
        var Y = E == null ? 0 : E.length;
        return Y ? (B = z || B === r ? 1 : Fr(B), B = Y - B, Ds(E, B < 0 ? 0 : B, Y)) : [];
      }
      function oj(E, B) {
        return E && E.length ? Iv(E, er(B, 3), !1, !0) : [];
      }
      function sj(E, B) {
        return E && E.length ? Iv(E, er(B, 3)) : [];
      }
      var uj = kr(function(E) {
        return zl(bi(E, 1, Sa, !0));
      }), cj = kr(function(E) {
        var B = Ms(E);
        return Sa(B) && (B = r), zl(bi(E, 1, Sa, !0), er(B, 2));
      }), lj = kr(function(E) {
        var B = Ms(E);
        return B = typeof B == "function" ? B : r, zl(bi(E, 1, Sa, !0), r, B);
      });
      function dj(E) {
        return E && E.length ? zl(E) : [];
      }
      function fj(E, B) {
        return E && E.length ? zl(E, er(B, 2)) : [];
      }
      function mj(E, B) {
        return B = typeof B == "function" ? B : r, E && E.length ? zl(E, r, B) : [];
      }
      function e4(E) {
        if (!(E && E.length))
          return [];
        var B = 0;
        return E = Ol(E, function(z) {
          if (Sa(z))
            return B = qa(z.length, B), !0;
        }), gb(B, function(z) {
          return Zn(E, pb(z));
        });
      }
      function W7(E, B) {
        if (!(E && E.length))
          return [];
        var z = e4(E);
        return B == null ? z : Zn(z, function(Y) {
          return Zo(B, r, Y);
        });
      }
      var pj = kr(function(E, B) {
        return Sa(E) ? U1(E, B) : [];
      }), hj = kr(function(E) {
        return kb(Ol(E, Sa));
      }), vj = kr(function(E) {
        var B = Ms(E);
        return Sa(B) && (B = r), kb(Ol(E, Sa), er(B, 2));
      }), gj = kr(function(E) {
        var B = Ms(E);
        return B = typeof B == "function" ? B : r, kb(Ol(E, Sa), r, B);
      }), yj = kr(e4);
      function bj(E, B) {
        return m7(E || [], B || [], z1);
      }
      function xj(E, B) {
        return m7(E || [], B || [], q1);
      }
      var _j = kr(function(E) {
        var B = E.length, z = B > 1 ? E[B - 1] : r;
        return z = typeof z == "function" ? (E.pop(), z) : r, W7(E, z);
      });
      function Z7(E) {
        var B = fe(E);
        return B.__chain__ = !0, B;
      }
      function Sj(E, B) {
        return B(E), E;
      }
      function kv(E, B) {
        return B(E);
      }
      var Aj = wc(function(E) {
        var B = E.length, z = B ? E[0] : 0, Y = this.__wrapped__, ne = function(ve) {
          return Cb(ve, E);
        };
        return B > 1 || this.__actions__.length || !(Y instanceof Xr) || !Cc(z) ? this.thru(ne) : (Y = Y.slice(z, +z + (B ? 1 : 0)), Y.__actions__.push({
          func: kv,
          args: [ne],
          thisArg: r
        }), new Cs(Y, this.__chain__).thru(function(ve) {
          return B && !ve.length && ve.push(r), ve;
        }));
      });
      function wj() {
        return Z7(this);
      }
      function Cj() {
        return new Cs(this.value(), this.__chain__);
      }
      function Ej() {
        this.__values__ === r && (this.__values__ = lw(this.value()));
        var E = this.__index__ >= this.__values__.length, B = E ? r : this.__values__[this.__index__++];
        return { done: E, value: B };
      }
      function Dj() {
        return this;
      }
      function Mj(E) {
        for (var B, z = this; z instanceof Av; ) {
          var Y = q7(z);
          Y.__index__ = 0, Y.__values__ = r, B ? ne.__wrapped__ = Y : B = Y;
          var ne = Y;
          z = z.__wrapped__;
        }
        return ne.__wrapped__ = E, B;
      }
      function Ij() {
        var E = this.__wrapped__;
        if (E instanceof Xr) {
          var B = E;
          return this.__actions__.length && (B = new Xr(this)), B = B.reverse(), B.__actions__.push({
            func: kv,
            args: [Jb],
            thisArg: r
          }), new Cs(B, this.__chain__);
        }
        return this.thru(Jb);
      }
      function Tj() {
        return f7(this.__wrapped__, this.__actions__);
      }
      var Nj = Tv(function(E, B, z) {
        wn.call(E, z) ? ++E[z] : Sc(E, z, 1);
      });
      function Pj(E, B, z) {
        var Y = Dr(E) ? CA : SK;
        return z && ao(E, B, z) && (B = r), Y(E, er(B, 3));
      }
      function Bj(E, B) {
        var z = Dr(E) ? Ol : WA;
        return z(E, er(B, 3));
      }
      var Oj = A7(H7), Fj = A7(K7);
      function Rj(E, B) {
        return bi(zv(E, B), 1);
      }
      function Lj(E, B) {
        return bi(zv(E, B), R);
      }
      function kj(E, B, z) {
        return z = z === r ? 1 : Fr(z), bi(zv(E, B), z);
      }
      function Q7(E, B) {
        var z = Dr(E) ? As : kl;
        return z(E, er(B, 3));
      }
      function $7(E, B) {
        var z = Dr(E) ? nH : YA;
        return z(E, er(B, 3));
      }
      var zj = Tv(function(E, B, z) {
        wn.call(E, z) ? E[z].push(B) : Sc(E, z, [B]);
      });
      function Uj(E, B, z, Y) {
        E = Do(E) ? E : km(E), z = z && !Y ? Fr(z) : 0;
        var ne = E.length;
        return z < 0 && (z = qa(ne + z, 0)), Hv(E) ? z <= ne && E.indexOf(B, z) > -1 : !!ne && Em(E, B, z) > -1;
      }
      var Gj = kr(function(E, B, z) {
        var Y = -1, ne = typeof B == "function", ve = Do(E) ? tt(E.length) : [];
        return kl(E, function(Me) {
          ve[++Y] = ne ? Zo(B, Me, z) : G1(Me, B, z);
        }), ve;
      }), Vj = Tv(function(E, B, z) {
        Sc(E, z, B);
      });
      function zv(E, B) {
        var z = Dr(E) ? Zn : t7;
        return z(E, er(B, 3));
      }
      function qj(E, B, z, Y) {
        return E == null ? [] : (Dr(B) || (B = B == null ? [] : [B]), z = Y ? r : z, Dr(z) || (z = z == null ? [] : [z]), i7(E, B, z));
      }
      var Hj = Tv(function(E, B, z) {
        E[z ? 0 : 1].push(B);
      }, function() {
        return [[], []];
      });
      function Kj(E, B, z) {
        var Y = Dr(E) ? fb : IA, ne = arguments.length < 3;
        return Y(E, er(B, 4), z, ne, kl);
      }
      function Xj(E, B, z) {
        var Y = Dr(E) ? aH : IA, ne = arguments.length < 3;
        return Y(E, er(B, 4), z, ne, YA);
      }
      function jj(E, B) {
        var z = Dr(E) ? Ol : WA;
        return z(E, Vv(er(B, 3)));
      }
      function Yj(E) {
        var B = Dr(E) ? HA : UK;
        return B(E);
      }
      function Wj(E, B, z) {
        (z ? ao(E, B, z) : B === r) ? B = 1 : B = Fr(B);
        var Y = Dr(E) ? gK : GK;
        return Y(E, B);
      }
      function Zj(E) {
        var B = Dr(E) ? yK : qK;
        return B(E);
      }
      function Qj(E) {
        if (E == null)
          return 0;
        if (Do(E))
          return Hv(E) ? Mm(E) : E.length;
        var B = ki(E);
        return B == De || B == Se ? E.size : Nb(E).length;
      }
      function $j(E, B, z) {
        var Y = Dr(E) ? mb : HK;
        return z && ao(E, B, z) && (B = r), Y(E, er(B, 3));
      }
      var Jj = kr(function(E, B) {
        if (E == null)
          return [];
        var z = B.length;
        return z > 1 && ao(E, B[0], B[1]) ? B = [] : z > 2 && ao(B[0], B[1], B[2]) && (B = [B[0]]), i7(E, bi(B, 1), []);
      }), Uv = BH || function() {
        return yi.Date.now();
      };
      function eY(E, B) {
        if (typeof B != "function")
          throw new ws(o);
        return E = Fr(E), function() {
          if (--E < 1)
            return B.apply(this, arguments);
        };
      }
      function J7(E, B, z) {
        return B = z ? r : B, B = E && B == null ? E.length : B, Ac(E, A, r, r, r, r, B);
      }
      function ew(E, B) {
        var z;
        if (typeof B != "function")
          throw new ws(o);
        return E = Fr(E), function() {
          return --E > 0 && (z = B.apply(this, arguments)), E <= 1 && (B = r), z;
        };
      }
      var t4 = kr(function(E, B, z) {
        var Y = g;
        if (z.length) {
          var ne = Rl(z, Rm(t4));
          Y |= b;
        }
        return Ac(E, Y, B, z, ne);
      }), tw = kr(function(E, B, z) {
        var Y = g | v;
        if (z.length) {
          var ne = Rl(z, Rm(tw));
          Y |= b;
        }
        return Ac(B, Y, E, z, ne);
      });
      function rw(E, B, z) {
        B = z ? r : B;
        var Y = Ac(E, _, r, r, r, r, r, B);
        return Y.placeholder = rw.placeholder, Y;
      }
      function nw(E, B, z) {
        B = z ? r : B;
        var Y = Ac(E, S, r, r, r, r, r, B);
        return Y.placeholder = nw.placeholder, Y;
      }
      function aw(E, B, z) {
        var Y, ne, ve, Me, Re, He, ut = 0, ct = !1, gt = !1, It = !0;
        if (typeof E != "function")
          throw new ws(o);
        B = Is(B) || 0, na(z) && (ct = !!z.leading, gt = "maxWait" in z, ve = gt ? qa(Is(z.maxWait) || 0, B) : ve, It = "trailing" in z ? !!z.trailing : It);
        function Gt(Aa) {
          var du = Y, Mc = ne;
          return Y = ne = r, ut = Aa, Me = E.apply(Mc, du), Me;
        }
        function ar(Aa) {
          return ut = Aa, Re = X1(Gr, B), ct ? Gt(Aa) : Me;
        }
        function Lr(Aa) {
          var du = Aa - He, Mc = Aa - ut, Aw = B - du;
          return gt ? Li(Aw, ve - Mc) : Aw;
        }
        function ir(Aa) {
          var du = Aa - He, Mc = Aa - ut;
          return He === r || du >= B || du < 0 || gt && Mc >= ve;
        }
        function Gr() {
          var Aa = Uv();
          if (ir(Aa))
            return Wr(Aa);
          Re = X1(Gr, Lr(Aa));
        }
        function Wr(Aa) {
          return Re = r, It && Y ? Gt(Aa) : (Y = ne = r, Me);
        }
        function es() {
          Re !== r && p7(Re), ut = 0, Y = He = ne = Re = r;
        }
        function io() {
          return Re === r ? Me : Wr(Uv());
        }
        function ts() {
          var Aa = Uv(), du = ir(Aa);
          if (Y = arguments, ne = this, He = Aa, du) {
            if (Re === r)
              return ar(He);
            if (gt)
              return p7(Re), Re = X1(Gr, B), Gt(He);
          }
          return Re === r && (Re = X1(Gr, B)), Me;
        }
        return ts.cancel = es, ts.flush = io, ts;
      }
      var tY = kr(function(E, B) {
        return jA(E, 1, B);
      }), rY = kr(function(E, B, z) {
        return jA(E, Is(B) || 0, z);
      });
      function nY(E) {
        return Ac(E, C);
      }
      function Gv(E, B) {
        if (typeof E != "function" || B != null && typeof B != "function")
          throw new ws(o);
        var z = function() {
          var Y = arguments, ne = B ? B.apply(this, Y) : Y[0], ve = z.cache;
          if (ve.has(ne))
            return ve.get(ne);
          var Me = E.apply(this, Y);
          return z.cache = ve.set(ne, Me) || ve, Me;
        };
        return z.cache = new (Gv.Cache || _c)(), z;
      }
      Gv.Cache = _c;
      function Vv(E) {
        if (typeof E != "function")
          throw new ws(o);
        return function() {
          var B = arguments;
          switch (B.length) {
            case 0:
              return !E.call(this);
            case 1:
              return !E.call(this, B[0]);
            case 2:
              return !E.call(this, B[0], B[1]);
            case 3:
              return !E.call(this, B[0], B[1], B[2]);
          }
          return !E.apply(this, B);
        };
      }
      function aY(E) {
        return ew(2, E);
      }
      var iY = KK(function(E, B) {
        B = B.length == 1 && Dr(B[0]) ? Zn(B[0], Qo(er())) : Zn(bi(B, 1), Qo(er()));
        var z = B.length;
        return kr(function(Y) {
          for (var ne = -1, ve = Li(Y.length, z); ++ne < ve; )
            Y[ne] = B[ne].call(this, Y[ne]);
          return Zo(E, this, Y);
        });
      }), r4 = kr(function(E, B) {
        var z = Rl(B, Rm(r4));
        return Ac(E, b, r, B, z);
      }), iw = kr(function(E, B) {
        var z = Rl(B, Rm(iw));
        return Ac(E, x, r, B, z);
      }), oY = wc(function(E, B) {
        return Ac(E, w, r, r, r, B);
      });
      function sY(E, B) {
        if (typeof E != "function")
          throw new ws(o);
        return B = B === r ? B : Fr(B), kr(E, B);
      }
      function uY(E, B) {
        if (typeof E != "function")
          throw new ws(o);
        return B = B == null ? 0 : qa(Fr(B), 0), kr(function(z) {
          var Y = z[B], ne = Gl(z, 0, B);
          return Y && Fl(ne, Y), Zo(E, this, ne);
        });
      }
      function cY(E, B, z) {
        var Y = !0, ne = !0;
        if (typeof E != "function")
          throw new ws(o);
        return na(z) && (Y = "leading" in z ? !!z.leading : Y, ne = "trailing" in z ? !!z.trailing : ne), aw(E, B, {
          leading: Y,
          maxWait: B,
          trailing: ne
        });
      }
      function lY(E) {
        return J7(E, 1);
      }
      function dY(E, B) {
        return r4(Ub(B), E);
      }
      function fY() {
        if (!arguments.length)
          return [];
        var E = arguments[0];
        return Dr(E) ? E : [E];
      }
      function mY(E) {
        return Es(E, m);
      }
      function pY(E, B) {
        return B = typeof B == "function" ? B : r, Es(E, m, B);
      }
      function hY(E) {
        return Es(E, d | m);
      }
      function vY(E, B) {
        return B = typeof B == "function" ? B : r, Es(E, d | m, B);
      }
      function gY(E, B) {
        return B == null || XA(E, B, ni(B));
      }
      function lu(E, B) {
        return E === B || E !== E && B !== B;
      }
      var yY = Ov(Mb), bY = Ov(function(E, B) {
        return E >= B;
      }), ff = $A(/* @__PURE__ */ function() {
        return arguments;
      }()) ? $A : function(E) {
        return da(E) && wn.call(E, "callee") && !kA.call(E, "callee");
      }, Dr = tt.isArray, xY = bA ? Qo(bA) : MK;
      function Do(E) {
        return E != null && qv(E.length) && !Ec(E);
      }
      function Sa(E) {
        return da(E) && Do(E);
      }
      function _Y(E) {
        return E === !0 || E === !1 || da(E) && no(E) == re;
      }
      var Vl = FH || m4, SY = xA ? Qo(xA) : IK;
      function AY(E) {
        return da(E) && E.nodeType === 1 && !j1(E);
      }
      function wY(E) {
        if (E == null)
          return !0;
        if (Do(E) && (Dr(E) || typeof E == "string" || typeof E.splice == "function" || Vl(E) || Lm(E) || ff(E)))
          return !E.length;
        var B = ki(E);
        if (B == De || B == Se)
          return !E.size;
        if (K1(E))
          return !Nb(E).length;
        for (var z in E)
          if (wn.call(E, z))
            return !1;
        return !0;
      }
      function CY(E, B) {
        return V1(E, B);
      }
      function EY(E, B, z) {
        z = typeof z == "function" ? z : r;
        var Y = z ? z(E, B) : r;
        return Y === r ? V1(E, B, r, z) : !!Y;
      }
      function n4(E) {
        if (!da(E))
          return !1;
        var B = no(E);
        return B == se || B == oe || typeof E.message == "string" && typeof E.name == "string" && !j1(E);
      }
      function DY(E) {
        return typeof E == "number" && UA(E);
      }
      function Ec(E) {
        if (!na(E))
          return !1;
        var B = no(E);
        return B == he || B == ge || B == te || B == ue;
      }
      function ow(E) {
        return typeof E == "number" && E == Fr(E);
      }
      function qv(E) {
        return typeof E == "number" && E > -1 && E % 1 == 0 && E <= G;
      }
      function na(E) {
        var B = typeof E;
        return E != null && (B == "object" || B == "function");
      }
      function da(E) {
        return E != null && typeof E == "object";
      }
      var sw = _A ? Qo(_A) : NK;
      function MY(E, B) {
        return E === B || Tb(E, B, jb(B));
      }
      function IY(E, B, z) {
        return z = typeof z == "function" ? z : r, Tb(E, B, jb(B), z);
      }
      function TY(E) {
        return uw(E) && E != +E;
      }
      function NY(E) {
        if (pX(E))
          throw new Ar(i);
        return JA(E);
      }
      function PY(E) {
        return E === null;
      }
      function BY(E) {
        return E == null;
      }
      function uw(E) {
        return typeof E == "number" || da(E) && no(E) == ae;
      }
      function j1(E) {
        if (!da(E) || no(E) != _e)
          return !1;
        var B = vv(E);
        if (B === null)
          return !0;
        var z = wn.call(B, "constructor") && B.constructor;
        return typeof z == "function" && z instanceof z && fv.call(z) == IH;
      }
      var a4 = SA ? Qo(SA) : PK;
      function OY(E) {
        return ow(E) && E >= -G && E <= G;
      }
      var cw = AA ? Qo(AA) : BK;
      function Hv(E) {
        return typeof E == "string" || !Dr(E) && da(E) && no(E) == Ne;
      }
      function Jo(E) {
        return typeof E == "symbol" || da(E) && no(E) == J;
      }
      var Lm = wA ? Qo(wA) : OK;
      function FY(E) {
        return E === r;
      }
      function RY(E) {
        return da(E) && ki(E) == de;
      }
      function LY(E) {
        return da(E) && no(E) == ye;
      }
      var kY = Ov(Pb), zY = Ov(function(E, B) {
        return E <= B;
      });
      function lw(E) {
        if (!E)
          return [];
        if (Do(E))
          return Hv(E) ? uu(E) : Eo(E);
        if (O1 && E[O1])
          return gH(E[O1]());
        var B = ki(E), z = B == De ? bb : B == Se ? cv : km;
        return z(E);
      }
      function Dc(E) {
        if (!E)
          return E === 0 ? E : 0;
        if (E = Is(E), E === R || E === -R) {
          var B = E < 0 ? -1 : 1;
          return B * L;
        }
        return E === E ? E : 0;
      }
      function Fr(E) {
        var B = Dc(E), z = B % 1;
        return B === B ? z ? B - z : B : 0;
      }
      function dw(E) {
        return E ? uf(Fr(E), 0, K) : 0;
      }
      function Is(E) {
        if (typeof E == "number")
          return E;
        if (Jo(E))
          return q;
        if (na(E)) {
          var B = typeof E.valueOf == "function" ? E.valueOf() : E;
          E = na(B) ? B + "" : B;
        }
        if (typeof E != "string")
          return E === 0 ? E : +E;
        E = TA(E);
        var z = Dl.test(E);
        return z || Il.test(E) ? eH(E.slice(2), z ? 2 : 8) : El.test(E) ? q : +E;
      }
      function fw(E) {
        return Uu(E, Mo(E));
      }
      function UY(E) {
        return E ? uf(Fr(E), -G, G) : E === 0 ? E : 0;
      }
      function bn(E) {
        return E == null ? "" : $o(E);
      }
      var GY = Om(function(E, B) {
        if (K1(B) || Do(B)) {
          Uu(B, ni(B), E);
          return;
        }
        for (var z in B)
          wn.call(B, z) && z1(E, z, B[z]);
      }), mw = Om(function(E, B) {
        Uu(B, Mo(B), E);
      }), Kv = Om(function(E, B, z, Y) {
        Uu(B, Mo(B), E, Y);
      }), VY = Om(function(E, B, z, Y) {
        Uu(B, ni(B), E, Y);
      }), qY = wc(Cb);
      function HY(E, B) {
        var z = Bm(E);
        return B == null ? z : KA(z, B);
      }
      var KY = kr(function(E, B) {
        E = Un(E);
        var z = -1, Y = B.length, ne = Y > 2 ? B[2] : r;
        for (ne && ao(B[0], B[1], ne) && (Y = 1); ++z < Y; )
          for (var ve = B[z], Me = Mo(ve), Re = -1, He = Me.length; ++Re < He; ) {
            var ut = Me[Re], ct = E[ut];
            (ct === r || lu(ct, Tm[ut]) && !wn.call(E, ut)) && (E[ut] = ve[ut]);
          }
        return E;
      }), XY = kr(function(E) {
        return E.push(r, T7), Zo(pw, r, E);
      });
      function jY(E, B) {
        return EA(E, er(B, 3), zu);
      }
      function YY(E, B) {
        return EA(E, er(B, 3), Db);
      }
      function WY(E, B) {
        return E == null ? E : Eb(E, er(B, 3), Mo);
      }
      function ZY(E, B) {
        return E == null ? E : ZA(E, er(B, 3), Mo);
      }
      function QY(E, B) {
        return E && zu(E, er(B, 3));
      }
      function $Y(E, B) {
        return E && Db(E, er(B, 3));
      }
      function JY(E) {
        return E == null ? [] : Ev(E, ni(E));
      }
      function eW(E) {
        return E == null ? [] : Ev(E, Mo(E));
      }
      function i4(E, B, z) {
        var Y = E == null ? r : cf(E, B);
        return Y === r ? z : Y;
      }
      function tW(E, B) {
        return E != null && B7(E, B, wK);
      }
      function o4(E, B) {
        return E != null && B7(E, B, CK);
      }
      var rW = C7(function(E, B, z) {
        B != null && typeof B.toString != "function" && (B = mv.call(B)), E[B] = z;
      }, u4(Io)), nW = C7(function(E, B, z) {
        B != null && typeof B.toString != "function" && (B = mv.call(B)), wn.call(E, B) ? E[B].push(z) : E[B] = [z];
      }, er), aW = kr(G1);
      function ni(E) {
        return Do(E) ? qA(E) : Nb(E);
      }
      function Mo(E) {
        return Do(E) ? qA(E, !0) : FK(E);
      }
      function iW(E, B) {
        var z = {};
        return B = er(B, 3), zu(E, function(Y, ne, ve) {
          Sc(z, B(Y, ne, ve), Y);
        }), z;
      }
      function oW(E, B) {
        var z = {};
        return B = er(B, 3), zu(E, function(Y, ne, ve) {
          Sc(z, ne, B(Y, ne, ve));
        }), z;
      }
      var sW = Om(function(E, B, z) {
        Dv(E, B, z);
      }), pw = Om(function(E, B, z, Y) {
        Dv(E, B, z, Y);
      }), uW = wc(function(E, B) {
        var z = {};
        if (E == null)
          return z;
        var Y = !1;
        B = Zn(B, function(ve) {
          return ve = Ul(ve, E), Y || (Y = ve.length > 1), ve;
        }), Uu(E, Kb(E), z), Y && (z = Es(z, d | f | m, rX));
        for (var ne = B.length; ne--; )
          Lb(z, B[ne]);
        return z;
      });
      function cW(E, B) {
        return hw(E, Vv(er(B)));
      }
      var lW = wc(function(E, B) {
        return E == null ? {} : LK(E, B);
      });
      function hw(E, B) {
        if (E == null)
          return {};
        var z = Zn(Kb(E), function(Y) {
          return [Y];
        });
        return B = er(B), o7(E, z, function(Y, ne) {
          return B(Y, ne[0]);
        });
      }
      function dW(E, B, z) {
        B = Ul(B, E);
        var Y = -1, ne = B.length;
        for (ne || (ne = 1, E = r); ++Y < ne; ) {
          var ve = E == null ? r : E[Gu(B[Y])];
          ve === r && (Y = ne, ve = z), E = Ec(ve) ? ve.call(E) : ve;
        }
        return E;
      }
      function fW(E, B, z) {
        return E == null ? E : q1(E, B, z);
      }
      function mW(E, B, z, Y) {
        return Y = typeof Y == "function" ? Y : r, E == null ? E : q1(E, B, z, Y);
      }
      var vw = M7(ni), gw = M7(Mo);
      function pW(E, B, z) {
        var Y = Dr(E), ne = Y || Vl(E) || Lm(E);
        if (B = er(B, 4), z == null) {
          var ve = E && E.constructor;
          ne ? z = Y ? new ve() : [] : na(E) ? z = Ec(ve) ? Bm(vv(E)) : {} : z = {};
        }
        return (ne ? As : zu)(E, function(Me, Re, He) {
          return B(z, Me, Re, He);
        }), z;
      }
      function hW(E, B) {
        return E == null ? !0 : Lb(E, B);
      }
      function vW(E, B, z) {
        return E == null ? E : d7(E, B, Ub(z));
      }
      function gW(E, B, z, Y) {
        return Y = typeof Y == "function" ? Y : r, E == null ? E : d7(E, B, Ub(z), Y);
      }
      function km(E) {
        return E == null ? [] : yb(E, ni(E));
      }
      function yW(E) {
        return E == null ? [] : yb(E, Mo(E));
      }
      function bW(E, B, z) {
        return z === r && (z = B, B = r), z !== r && (z = Is(z), z = z === z ? z : 0), B !== r && (B = Is(B), B = B === B ? B : 0), uf(Is(E), B, z);
      }
      function xW(E, B, z) {
        return B = Dc(B), z === r ? (z = B, B = 0) : z = Dc(z), E = Is(E), EK(E, B, z);
      }
      function _W(E, B, z) {
        if (z && typeof z != "boolean" && ao(E, B, z) && (B = z = r), z === r && (typeof B == "boolean" ? (z = B, B = r) : typeof E == "boolean" && (z = E, E = r)), E === r && B === r ? (E = 0, B = 1) : (E = Dc(E), B === r ? (B = E, E = 0) : B = Dc(B)), E > B) {
          var Y = E;
          E = B, B = Y;
        }
        if (z || E % 1 || B % 1) {
          var ne = GA();
          return Li(E + ne * (B - E + Jq("1e-" + ((ne + "").length - 1))), B);
        }
        return Ob(E, B);
      }
      var SW = Fm(function(E, B, z) {
        return B = B.toLowerCase(), E + (z ? yw(B) : B);
      });
      function yw(E) {
        return s4(bn(E).toLowerCase());
      }
      function bw(E) {
        return E = bn(E), E && E.replace(Sm, fH).replace(qq, "");
      }
      function AW(E, B, z) {
        E = bn(E), B = $o(B);
        var Y = E.length;
        z = z === r ? Y : uf(Fr(z), 0, Y);
        var ne = z;
        return z -= B.length, z >= 0 && E.slice(z, ne) == B;
      }
      function wW(E) {
        return E = bn(E), E && qn.test(E) ? E.replace(At, mH) : E;
      }
      function CW(E) {
        return E = bn(E), E && xa.test(E) ? E.replace(ba, "\\$&") : E;
      }
      var EW = Fm(function(E, B, z) {
        return E + (z ? "-" : "") + B.toLowerCase();
      }), DW = Fm(function(E, B, z) {
        return E + (z ? " " : "") + B.toLowerCase();
      }), MW = S7("toLowerCase");
      function IW(E, B, z) {
        E = bn(E), B = Fr(B);
        var Y = B ? Mm(E) : 0;
        if (!B || Y >= B)
          return E;
        var ne = (B - Y) / 2;
        return Bv(xv(ne), z) + E + Bv(bv(ne), z);
      }
      function TW(E, B, z) {
        E = bn(E), B = Fr(B);
        var Y = B ? Mm(E) : 0;
        return B && Y < B ? E + Bv(B - Y, z) : E;
      }
      function NW(E, B, z) {
        E = bn(E), B = Fr(B);
        var Y = B ? Mm(E) : 0;
        return B && Y < B ? Bv(B - Y, z) + E : E;
      }
      function PW(E, B, z) {
        return z || B == null ? B = 0 : B && (B = +B), zH(bn(E).replace(to, ""), B || 0);
      }
      function BW(E, B, z) {
        return (z ? ao(E, B, z) : B === r) ? B = 1 : B = Fr(B), Fb(bn(E), B);
      }
      function OW() {
        var E = arguments, B = bn(E[0]);
        return E.length < 3 ? B : B.replace(E[1], E[2]);
      }
      var FW = Fm(function(E, B, z) {
        return E + (z ? "_" : "") + B.toLowerCase();
      });
      function RW(E, B, z) {
        return z && typeof z != "number" && ao(E, B, z) && (B = z = r), z = z === r ? K : z >>> 0, z ? (E = bn(E), E && (typeof B == "string" || B != null && !a4(B)) && (B = $o(B), !B && Dm(E)) ? Gl(uu(E), 0, z) : E.split(B, z)) : [];
      }
      var LW = Fm(function(E, B, z) {
        return E + (z ? " " : "") + s4(B);
      });
      function kW(E, B, z) {
        return E = bn(E), z = z == null ? 0 : uf(Fr(z), 0, E.length), B = $o(B), E.slice(z, z + B.length) == B;
      }
      function zW(E, B, z) {
        var Y = fe.templateSettings;
        z && ao(E, B, z) && (B = r), E = bn(E), B = Kv({}, B, Y, I7);
        var ne = Kv({}, B.imports, Y.imports, I7), ve = ni(ne), Me = yb(ne, ve), Re, He, ut = 0, ct = B.interpolate || Nl, gt = "__p += '", It = xb(
          (B.escape || Nl).source + "|" + ct.source + "|" + (ct === fn ? _a : Nl).source + "|" + (B.evaluate || Nl).source + "|$",
          "g"
        ), Gt = "//# sourceURL=" + (wn.call(B, "sourceURL") ? (B.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++Yq + "]") + `
`;
        E.replace(It, function(ir, Gr, Wr, es, io, ts) {
          return Wr || (Wr = es), gt += E.slice(ut, ts).replace(bc, pH), Gr && (Re = !0, gt += `' +
__e(` + Gr + `) +
'`), io && (He = !0, gt += `';
` + io + `;
__p += '`), Wr && (gt += `' +
((__t = (` + Wr + `)) == null ? '' : __t) +
'`), ut = ts + ir.length, ir;
        }), gt += `';
`;
        var ar = wn.call(B, "variable") && B.variable;
        if (!ar)
          gt = `with (obj) {
` + gt + `
}
`;
        else if (Lu.test(ar))
          throw new Ar(s);
        gt = (He ? gt.replace(xe, "") : gt).replace(ke, "$1").replace(Je, "$1;"), gt = "function(" + (ar || "obj") + `) {
` + (ar ? "" : `obj || (obj = {});
`) + "var __t, __p = ''" + (Re ? ", __e = _.escape" : "") + (He ? `, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
` : `;
`) + gt + `return __p
}`;
        var Lr = _w(function() {
          return hn(ve, Gt + "return " + gt).apply(r, Me);
        });
        if (Lr.source = gt, n4(Lr))
          throw Lr;
        return Lr;
      }
      function UW(E) {
        return bn(E).toLowerCase();
      }
      function GW(E) {
        return bn(E).toUpperCase();
      }
      function VW(E, B, z) {
        if (E = bn(E), E && (z || B === r))
          return TA(E);
        if (!E || !(B = $o(B)))
          return E;
        var Y = uu(E), ne = uu(B), ve = NA(Y, ne), Me = PA(Y, ne) + 1;
        return Gl(Y, ve, Me).join("");
      }
      function qW(E, B, z) {
        if (E = bn(E), E && (z || B === r))
          return E.slice(0, OA(E) + 1);
        if (!E || !(B = $o(B)))
          return E;
        var Y = uu(E), ne = PA(Y, uu(B)) + 1;
        return Gl(Y, 0, ne).join("");
      }
      function HW(E, B, z) {
        if (E = bn(E), E && (z || B === r))
          return E.replace(to, "");
        if (!E || !(B = $o(B)))
          return E;
        var Y = uu(E), ne = NA(Y, uu(B));
        return Gl(Y, ne).join("");
      }
      function KW(E, B) {
        var z = M, Y = T;
        if (na(B)) {
          var ne = "separator" in B ? B.separator : ne;
          z = "length" in B ? Fr(B.length) : z, Y = "omission" in B ? $o(B.omission) : Y;
        }
        E = bn(E);
        var ve = E.length;
        if (Dm(E)) {
          var Me = uu(E);
          ve = Me.length;
        }
        if (z >= ve)
          return E;
        var Re = z - Mm(Y);
        if (Re < 1)
          return Y;
        var He = Me ? Gl(Me, 0, Re).join("") : E.slice(0, Re);
        if (ne === r)
          return He + Y;
        if (Me && (Re += He.length - Re), a4(ne)) {
          if (E.slice(Re).search(ne)) {
            var ut, ct = He;
            for (ne.global || (ne = xb(ne.source, bn(yc.exec(ne)) + "g")), ne.lastIndex = 0; ut = ne.exec(ct); )
              var gt = ut.index;
            He = He.slice(0, gt === r ? Re : gt);
          }
        } else if (E.indexOf($o(ne), Re) != Re) {
          var It = He.lastIndexOf(ne);
          It > -1 && (He = He.slice(0, It));
        }
        return He + Y;
      }
      function XW(E) {
        return E = bn(E), E && Or.test(E) ? E.replace(Ct, _H) : E;
      }
      var jW = Fm(function(E, B, z) {
        return E + (z ? " " : "") + B.toUpperCase();
      }), s4 = S7("toUpperCase");
      function xw(E, B, z) {
        return E = bn(E), B = z ? r : B, B === r ? vH(E) ? wH(E) : sH(E) : E.match(B) || [];
      }
      var _w = kr(function(E, B) {
        try {
          return Zo(E, r, B);
        } catch (z) {
          return n4(z) ? z : new Ar(z);
        }
      }), YW = wc(function(E, B) {
        return As(B, function(z) {
          z = Gu(z), Sc(E, z, t4(E[z], E));
        }), E;
      });
      function WW(E) {
        var B = E == null ? 0 : E.length, z = er();
        return E = B ? Zn(E, function(Y) {
          if (typeof Y[1] != "function")
            throw new ws(o);
          return [z(Y[0]), Y[1]];
        }) : [], kr(function(Y) {
          for (var ne = -1; ++ne < B; ) {
            var ve = E[ne];
            if (Zo(ve[0], this, Y))
              return Zo(ve[1], this, Y);
          }
        });
      }
      function ZW(E) {
        return _K(Es(E, d));
      }
      function u4(E) {
        return function() {
          return E;
        };
      }
      function QW(E, B) {
        return E == null || E !== E ? B : E;
      }
      var $W = w7(), JW = w7(!0);
      function Io(E) {
        return E;
      }
      function c4(E) {
        return e7(typeof E == "function" ? E : Es(E, d));
      }
      function eZ(E) {
        return r7(Es(E, d));
      }
      function tZ(E, B) {
        return n7(E, Es(B, d));
      }
      var rZ = kr(function(E, B) {
        return function(z) {
          return G1(z, E, B);
        };
      }), nZ = kr(function(E, B) {
        return function(z) {
          return G1(E, z, B);
        };
      });
      function l4(E, B, z) {
        var Y = ni(B), ne = Ev(B, Y);
        z == null && !(na(B) && (ne.length || !Y.length)) && (z = B, B = E, E = this, ne = Ev(B, ni(B)));
        var ve = !(na(z) && "chain" in z) || !!z.chain, Me = Ec(E);
        return As(ne, function(Re) {
          var He = B[Re];
          E[Re] = He, Me && (E.prototype[Re] = function() {
            var ut = this.__chain__;
            if (ve || ut) {
              var ct = E(this.__wrapped__), gt = ct.__actions__ = Eo(this.__actions__);
              return gt.push({ func: He, args: arguments, thisArg: E }), ct.__chain__ = ut, ct;
            }
            return He.apply(E, Fl([this.value()], arguments));
          });
        }), E;
      }
      function aZ() {
        return yi._ === this && (yi._ = TH), this;
      }
      function d4() {
      }
      function iZ(E) {
        return E = Fr(E), kr(function(B) {
          return a7(B, E);
        });
      }
      var oZ = Vb(Zn), sZ = Vb(CA), uZ = Vb(mb);
      function Sw(E) {
        return Wb(E) ? pb(Gu(E)) : kK(E);
      }
      function cZ(E) {
        return function(B) {
          return E == null ? r : cf(E, B);
        };
      }
      var lZ = E7(), dZ = E7(!0);
      function f4() {
        return [];
      }
      function m4() {
        return !1;
      }
      function fZ() {
        return {};
      }
      function mZ() {
        return "";
      }
      function pZ() {
        return !0;
      }
      function hZ(E, B) {
        if (E = Fr(E), E < 1 || E > G)
          return [];
        var z = K, Y = Li(E, K);
        B = er(B), E -= K;
        for (var ne = gb(Y, B); ++z < E; )
          B(z);
        return ne;
      }
      function vZ(E) {
        return Dr(E) ? Zn(E, Gu) : Jo(E) ? [E] : Eo(V7(bn(E)));
      }
      function gZ(E) {
        var B = ++MH;
        return bn(E) + B;
      }
      var yZ = Pv(function(E, B) {
        return E + B;
      }, 0), bZ = qb("ceil"), xZ = Pv(function(E, B) {
        return E / B;
      }, 1), _Z = qb("floor");
      function SZ(E) {
        return E && E.length ? Cv(E, Io, Mb) : r;
      }
      function AZ(E, B) {
        return E && E.length ? Cv(E, er(B, 2), Mb) : r;
      }
      function wZ(E) {
        return MA(E, Io);
      }
      function CZ(E, B) {
        return MA(E, er(B, 2));
      }
      function EZ(E) {
        return E && E.length ? Cv(E, Io, Pb) : r;
      }
      function DZ(E, B) {
        return E && E.length ? Cv(E, er(B, 2), Pb) : r;
      }
      var MZ = Pv(function(E, B) {
        return E * B;
      }, 1), IZ = qb("round"), TZ = Pv(function(E, B) {
        return E - B;
      }, 0);
      function NZ(E) {
        return E && E.length ? vb(E, Io) : 0;
      }
      function PZ(E, B) {
        return E && E.length ? vb(E, er(B, 2)) : 0;
      }
      return fe.after = eY, fe.ary = J7, fe.assign = GY, fe.assignIn = mw, fe.assignInWith = Kv, fe.assignWith = VY, fe.at = qY, fe.before = ew, fe.bind = t4, fe.bindAll = YW, fe.bindKey = tw, fe.castArray = fY, fe.chain = Z7, fe.chunk = _X, fe.compact = SX, fe.concat = AX, fe.cond = WW, fe.conforms = ZW, fe.constant = u4, fe.countBy = Nj, fe.create = HY, fe.curry = rw, fe.curryRight = nw, fe.debounce = aw, fe.defaults = KY, fe.defaultsDeep = XY, fe.defer = tY, fe.delay = rY, fe.difference = wX, fe.differenceBy = CX, fe.differenceWith = EX, fe.drop = DX, fe.dropRight = MX, fe.dropRightWhile = IX, fe.dropWhile = TX, fe.fill = NX, fe.filter = Bj, fe.flatMap = Rj, fe.flatMapDeep = Lj, fe.flatMapDepth = kj, fe.flatten = X7, fe.flattenDeep = PX, fe.flattenDepth = BX, fe.flip = nY, fe.flow = $W, fe.flowRight = JW, fe.fromPairs = OX, fe.functions = JY, fe.functionsIn = eW, fe.groupBy = zj, fe.initial = RX, fe.intersection = LX, fe.intersectionBy = kX, fe.intersectionWith = zX, fe.invert = rW, fe.invertBy = nW, fe.invokeMap = Gj, fe.iteratee = c4, fe.keyBy = Vj, fe.keys = ni, fe.keysIn = Mo, fe.map = zv, fe.mapKeys = iW, fe.mapValues = oW, fe.matches = eZ, fe.matchesProperty = tZ, fe.memoize = Gv, fe.merge = sW, fe.mergeWith = pw, fe.method = rZ, fe.methodOf = nZ, fe.mixin = l4, fe.negate = Vv, fe.nthArg = iZ, fe.omit = uW, fe.omitBy = cW, fe.once = aY, fe.orderBy = qj, fe.over = oZ, fe.overArgs = iY, fe.overEvery = sZ, fe.overSome = uZ, fe.partial = r4, fe.partialRight = iw, fe.partition = Hj, fe.pick = lW, fe.pickBy = hw, fe.property = Sw, fe.propertyOf = cZ, fe.pull = qX, fe.pullAll = Y7, fe.pullAllBy = HX, fe.pullAllWith = KX, fe.pullAt = XX, fe.range = lZ, fe.rangeRight = dZ, fe.rearg = oY, fe.reject = jj, fe.remove = jX, fe.rest = sY, fe.reverse = Jb, fe.sampleSize = Wj, fe.set = fW, fe.setWith = mW, fe.shuffle = Zj, fe.slice = YX, fe.sortBy = Jj, fe.sortedUniq = tj, fe.sortedUniqBy = rj, fe.split = RW, fe.spread = uY, fe.tail = nj, fe.take = aj, fe.takeRight = ij, fe.takeRightWhile = oj, fe.takeWhile = sj, fe.tap = Sj, fe.throttle = cY, fe.thru = kv, fe.toArray = lw, fe.toPairs = vw, fe.toPairsIn = gw, fe.toPath = vZ, fe.toPlainObject = fw, fe.transform = pW, fe.unary = lY, fe.union = uj, fe.unionBy = cj, fe.unionWith = lj, fe.uniq = dj, fe.uniqBy = fj, fe.uniqWith = mj, fe.unset = hW, fe.unzip = e4, fe.unzipWith = W7, fe.update = vW, fe.updateWith = gW, fe.values = km, fe.valuesIn = yW, fe.without = pj, fe.words = xw, fe.wrap = dY, fe.xor = hj, fe.xorBy = vj, fe.xorWith = gj, fe.zip = yj, fe.zipObject = bj, fe.zipObjectDeep = xj, fe.zipWith = _j, fe.entries = vw, fe.entriesIn = gw, fe.extend = mw, fe.extendWith = Kv, l4(fe, fe), fe.add = yZ, fe.attempt = _w, fe.camelCase = SW, fe.capitalize = yw, fe.ceil = bZ, fe.clamp = bW, fe.clone = mY, fe.cloneDeep = hY, fe.cloneDeepWith = vY, fe.cloneWith = pY, fe.conformsTo = gY, fe.deburr = bw, fe.defaultTo = QW, fe.divide = xZ, fe.endsWith = AW, fe.eq = lu, fe.escape = wW, fe.escapeRegExp = CW, fe.every = Pj, fe.find = Oj, fe.findIndex = H7, fe.findKey = jY, fe.findLast = Fj, fe.findLastIndex = K7, fe.findLastKey = YY, fe.floor = _Z, fe.forEach = Q7, fe.forEachRight = $7, fe.forIn = WY, fe.forInRight = ZY, fe.forOwn = QY, fe.forOwnRight = $Y, fe.get = i4, fe.gt = yY, fe.gte = bY, fe.has = tW, fe.hasIn = o4, fe.head = j7, fe.identity = Io, fe.includes = Uj, fe.indexOf = FX, fe.inRange = xW, fe.invoke = aW, fe.isArguments = ff, fe.isArray = Dr, fe.isArrayBuffer = xY, fe.isArrayLike = Do, fe.isArrayLikeObject = Sa, fe.isBoolean = _Y, fe.isBuffer = Vl, fe.isDate = SY, fe.isElement = AY, fe.isEmpty = wY, fe.isEqual = CY, fe.isEqualWith = EY, fe.isError = n4, fe.isFinite = DY, fe.isFunction = Ec, fe.isInteger = ow, fe.isLength = qv, fe.isMap = sw, fe.isMatch = MY, fe.isMatchWith = IY, fe.isNaN = TY, fe.isNative = NY, fe.isNil = BY, fe.isNull = PY, fe.isNumber = uw, fe.isObject = na, fe.isObjectLike = da, fe.isPlainObject = j1, fe.isRegExp = a4, fe.isSafeInteger = OY, fe.isSet = cw, fe.isString = Hv, fe.isSymbol = Jo, fe.isTypedArray = Lm, fe.isUndefined = FY, fe.isWeakMap = RY, fe.isWeakSet = LY, fe.join = UX, fe.kebabCase = EW, fe.last = Ms, fe.lastIndexOf = GX, fe.lowerCase = DW, fe.lowerFirst = MW, fe.lt = kY, fe.lte = zY, fe.max = SZ, fe.maxBy = AZ, fe.mean = wZ, fe.meanBy = CZ, fe.min = EZ, fe.minBy = DZ, fe.stubArray = f4, fe.stubFalse = m4, fe.stubObject = fZ, fe.stubString = mZ, fe.stubTrue = pZ, fe.multiply = MZ, fe.nth = VX, fe.noConflict = aZ, fe.noop = d4, fe.now = Uv, fe.pad = IW, fe.padEnd = TW, fe.padStart = NW, fe.parseInt = PW, fe.random = _W, fe.reduce = Kj, fe.reduceRight = Xj, fe.repeat = BW, fe.replace = OW, fe.result = dW, fe.round = IZ, fe.runInContext = Ge, fe.sample = Yj, fe.size = Qj, fe.snakeCase = FW, fe.some = $j, fe.sortedIndex = WX, fe.sortedIndexBy = ZX, fe.sortedIndexOf = QX, fe.sortedLastIndex = $X, fe.sortedLastIndexBy = JX, fe.sortedLastIndexOf = ej, fe.startCase = LW, fe.startsWith = kW, fe.subtract = TZ, fe.sum = NZ, fe.sumBy = PZ, fe.template = zW, fe.times = hZ, fe.toFinite = Dc, fe.toInteger = Fr, fe.toLength = dw, fe.toLower = UW, fe.toNumber = Is, fe.toSafeInteger = UY, fe.toString = bn, fe.toUpper = GW, fe.trim = VW, fe.trimEnd = qW, fe.trimStart = HW, fe.truncate = KW, fe.unescape = XW, fe.uniqueId = gZ, fe.upperCase = jW, fe.upperFirst = s4, fe.each = Q7, fe.eachRight = $7, fe.first = j7, l4(fe, function() {
        var E = {};
        return zu(fe, function(B, z) {
          wn.call(fe.prototype, z) || (E[z] = B);
        }), E;
      }(), { chain: !1 }), fe.VERSION = n, As(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(E) {
        fe[E].placeholder = fe;
      }), As(["drop", "take"], function(E, B) {
        Xr.prototype[E] = function(z) {
          z = z === r ? 1 : qa(Fr(z), 0);
          var Y = this.__filtered__ && !B ? new Xr(this) : this.clone();
          return Y.__filtered__ ? Y.__takeCount__ = Li(z, Y.__takeCount__) : Y.__views__.push({
            size: Li(z, K),
            type: E + (Y.__dir__ < 0 ? "Right" : "")
          }), Y;
        }, Xr.prototype[E + "Right"] = function(z) {
          return this.reverse()[E](z).reverse();
        };
      }), As(["filter", "map", "takeWhile"], function(E, B) {
        var z = B + 1, Y = z == P || z == F;
        Xr.prototype[E] = function(ne) {
          var ve = this.clone();
          return ve.__iteratees__.push({
            iteratee: er(ne, 3),
            type: z
          }), ve.__filtered__ = ve.__filtered__ || Y, ve;
        };
      }), As(["head", "last"], function(E, B) {
        var z = "take" + (B ? "Right" : "");
        Xr.prototype[E] = function() {
          return this[z](1).value()[0];
        };
      }), As(["initial", "tail"], function(E, B) {
        var z = "drop" + (B ? "" : "Right");
        Xr.prototype[E] = function() {
          return this.__filtered__ ? new Xr(this) : this[z](1);
        };
      }), Xr.prototype.compact = function() {
        return this.filter(Io);
      }, Xr.prototype.find = function(E) {
        return this.filter(E).head();
      }, Xr.prototype.findLast = function(E) {
        return this.reverse().find(E);
      }, Xr.prototype.invokeMap = kr(function(E, B) {
        return typeof E == "function" ? new Xr(this) : this.map(function(z) {
          return G1(z, E, B);
        });
      }), Xr.prototype.reject = function(E) {
        return this.filter(Vv(er(E)));
      }, Xr.prototype.slice = function(E, B) {
        E = Fr(E);
        var z = this;
        return z.__filtered__ && (E > 0 || B < 0) ? new Xr(z) : (E < 0 ? z = z.takeRight(-E) : E && (z = z.drop(E)), B !== r && (B = Fr(B), z = B < 0 ? z.dropRight(-B) : z.take(B - E)), z);
      }, Xr.prototype.takeRightWhile = function(E) {
        return this.reverse().takeWhile(E).reverse();
      }, Xr.prototype.toArray = function() {
        return this.take(K);
      }, zu(Xr.prototype, function(E, B) {
        var z = /^(?:filter|find|map|reject)|While$/.test(B), Y = /^(?:head|last)$/.test(B), ne = fe[Y ? "take" + (B == "last" ? "Right" : "") : B], ve = Y || /^find/.test(B);
        ne && (fe.prototype[B] = function() {
          var Me = this.__wrapped__, Re = Y ? [1] : arguments, He = Me instanceof Xr, ut = Re[0], ct = He || Dr(Me), gt = function(Gr) {
            var Wr = ne.apply(fe, Fl([Gr], Re));
            return Y && It ? Wr[0] : Wr;
          };
          ct && z && typeof ut == "function" && ut.length != 1 && (He = ct = !1);
          var It = this.__chain__, Gt = !!this.__actions__.length, ar = ve && !It, Lr = He && !Gt;
          if (!ve && ct) {
            Me = Lr ? Me : new Xr(this);
            var ir = E.apply(Me, Re);
            return ir.__actions__.push({ func: kv, args: [gt], thisArg: r }), new Cs(ir, It);
          }
          return ar && Lr ? E.apply(this, Re) : (ir = this.thru(gt), ar ? Y ? ir.value()[0] : ir.value() : ir);
        });
      }), As(["pop", "push", "shift", "sort", "splice", "unshift"], function(E) {
        var B = lv[E], z = /^(?:push|sort|unshift)$/.test(E) ? "tap" : "thru", Y = /^(?:pop|shift)$/.test(E);
        fe.prototype[E] = function() {
          var ne = arguments;
          if (Y && !this.__chain__) {
            var ve = this.value();
            return B.apply(Dr(ve) ? ve : [], ne);
          }
          return this[z](function(Me) {
            return B.apply(Dr(Me) ? Me : [], ne);
          });
        };
      }), zu(Xr.prototype, function(E, B) {
        var z = fe[B];
        if (z) {
          var Y = z.name + "";
          wn.call(Pm, Y) || (Pm[Y] = []), Pm[Y].push({ name: B, func: z });
        }
      }), Pm[Nv(r, v).name] = [{
        name: "wrapper",
        func: r
      }], Xr.prototype.clone = XH, Xr.prototype.reverse = jH, Xr.prototype.value = YH, fe.prototype.at = Aj, fe.prototype.chain = wj, fe.prototype.commit = Cj, fe.prototype.next = Ej, fe.prototype.plant = Mj, fe.prototype.reverse = Ij, fe.prototype.toJSON = fe.prototype.valueOf = fe.prototype.value = Tj, fe.prototype.first = fe.prototype.head, O1 && (fe.prototype[O1] = Dj), fe;
    }, Im = CH();
    nf ? ((nf.exports = Im)._ = Im, cb._ = Im) : yi._ = Im;
  }).call(Qs);
})(t3, t3.exports);
t3.exports;
function lO(e) {
  const t = e.map((r) => r);
  return G9e(t, Nq(t));
}
function Y9e(e, t = [0, 0, 1], r) {
  if (!r) {
    const N = cO(t, [1, 0, 0]);
    Nq(N) < 1e-5 ? r = [0, 0, 1] : r = [1, 0, 0];
  }
  const n = r, a = lO(t), i = lO(n.map((N, I) => N - aA(n, a) * a[I])), o = cO(a, i);
  let s = 90, u = 90, c = 90, l, d, f;
  typeof e == "number" ? l = d = f = e : e.length === 1 ? l = d = f = e[0] : e.length === 3 ? [l, d, f] = e : [l, d, f, s, u, c] = e;
  const m = 2 * Number.EPSILON;
  let h = qf(s - 90) < m ? 0 : L2(s * b2 / 180), p = qf(u - 90) < m ? 0 : L2(u * b2 / 180), g, v;
  qf(c - 90) < m ? (g = 0, v = 1) : qf(c + 90) < m ? (g = 0, v = -1) : (g = L2(c * b2 / 180), v = wq(c * b2 / 180));
  const y = [l, 0, 0], _ = [d * g, d * v, 0], S = p, b = (h - p * g) / v, x = 1 - S * S - b * b;
  if (x < 0) throw new Error("cz_sqr is negative, which is not possible");
  const A = $3(x), w = [f * S, f * b, f * A], C = sn([y, _, w]), M = sn([i, o, a]);
  return au(C, Eq(M)).toArray();
}
const gp = 5e-3;
function r3(e, t = e.length, r = []) {
  if (t === 0) return [];
  if (t === 1) return [...r, ...e.map((n) => [n])];
  if (e.length === t) return r3(e, t - 1, [e.slice()]);
  for (let n = 0; n < e.length - 1; n++)
    for (let a = n + 1; a < e.length; a++)
      r.push([e[n], e[a]]);
  return r3(e, t - 1, r);
}
function W9e(e, t) {
  return e.every((r, n) => r === t[n]);
}
function dO(e) {
  return W9e(e, [0, 0, 0]);
}
function Z9e(e) {
  const t = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, r = e != null && e.lattice ? Bq(e == null ? void 0 : e.lattice) : void 0, n = e.atoms.map((a, i) => n3(a, {
    lattice: r,
    order: i
  }));
  return t.lattice = r, t.atoms = n, t;
}
function Q9e(e) {
  if (!e.lattice)
    return e;
  const t = Z9e({
    lattice: e.lattice,
    atoms: e.atoms
  }), { atoms: r } = t, n = J9e(r, e.lattice);
  return t.atoms = [...t.atoms, ...n], t;
}
function $9e(e) {
  const t = [], r = [];
  return e.atoms.map((n) => {
    t.push(n.element), r.push(n.xyz);
  }), {
    elements: t,
    xyzs: r,
    lattice: e.lattice
  };
}
function fO(e, t) {
  let r = [0, 0, 0];
  e.forEach((a, i) => {
    a && (r = Qc(r, au(t[i], a)));
  });
  const n = Qh(4).toArray();
  return r.forEach((a, i) => {
    n[3][i] = a;
  }), n;
}
function mO(e, t) {
  const [r, n, a] = e, i = 1 / (t[0][3] * r + t[1][3] * n + t[2][3] * a + t[3][3] || 1), o = (t[0][0] * r + t[1][0] * n + t[2][0] * a + t[3][0]) * i, s = (t[0][1] * r + t[1][1] * n + t[2][1] * a + t[3][1]) * i, u = (t[0][2] * r + t[1][2] * n + t[2][2] * a + t[3][2]) * i;
  return [o, s, u];
}
function Bq(e) {
  const { a: t, b: r, c: n, alpha: a, beta: i, gamma: o, spacegroup: s } = e, u = e.matrix || Y9e([t, r, n, a, i, o]), c = tb(u), l = u[0], d = u[1], f = u[2], m = Tq(u);
  return {
    spacegroup: s,
    a: t,
    b: r,
    c: n,
    volume: m,
    alpha: a,
    beta: i,
    gamma: o,
    vecA: l,
    vecB: d,
    vecC: f,
    matrix: u,
    invertMatrix: c
  };
}
function n3(e, t) {
  const { element: r } = e, { order: n, lattice: a, symmetry: i } = t || {};
  if (!e.abc && !e.xyz)
    throw new Error("createAtom: Need xyz or abc!");
  if (!a && !e.xyz)
    throw new Error("createAtom: Need xyz or lattice!");
  let o = (() => {
    const { xyz: c, abc: l } = e;
    if (!a)
      return;
    if (!l)
      return au(c, a.invertMatrix);
    if (!i || dO(i))
      return l;
    const d = fO(i, Qh(3).toArray());
    return mO(l, d);
  })(), s = (() => {
    const { xyz: c, abc: l } = e;
    if (!a)
      return c;
    if (!c)
      return au(l, a.matrix);
    if (!i || dO(i))
      return c;
    const d = fO(i, a.matrix);
    return mO(c, d);
  })();
  return o && o.some((c) => c < 0 || c > 1) && (o = F9e(o, 1), s = au(o, a.matrix)), {
    element: r,
    xyz: s,
    abc: o,
    order: n,
    symmetry: i
  };
}
function J9e(e, t) {
  const r = [];
  return e.forEach((n, a) => {
    const { abc: i } = n;
    if (!(!i || i[0] === void 0)) {
      {
        const o = [];
        Math.abs(i[0]) <= gp && o.push(0), Math.abs(i[1]) <= gp && o.push(1), Math.abs(i[2]) <= gp && o.push(2), r3(o).map((c) => [
          Number(c.includes(0)),
          Number(c.includes(1)),
          Number(c.includes(2))
        ]).forEach((c) => {
          const l = n3(n, {
            order: a,
            lattice: t,
            symmetry: c
          });
          r.push(l);
        });
      }
      {
        const o = [];
        Math.abs(1 - i[0]) <= gp && o.push(0), Math.abs(1 - i[1]) <= gp && o.push(1), Math.abs(1 - i[2]) <= gp && o.push(2), r3(o).map((c) => [
          -Number(c.includes(0)),
          -Number(c.includes(1)),
          -Number(c.includes(2))
        ]).forEach((c) => {
          const l = n3(n, {
            order: a,
            lattice: t,
            symmetry: c
          });
          r.push(l);
        });
      }
    }
  }), r;
}
function eCe(e) {
  const t = e[0], r = e[1], n = e[2], a = [0, 0, 0], i = t, o = r, s = Qc(t, r), u = n, c = Qc(t, n), l = Qc(r, n), d = Qc(Qc(t, r), n);
  return [a, i, o, s, u, c, l, d];
}
function tCe(e) {
  const [t, r, n, a, i, o, s, u] = e;
  return [
    [t, r],
    [t, n],
    [r, a],
    [n, a],
    [t, i],
    [r, o],
    [n, s],
    [a, u],
    [i, o],
    [i, s],
    [o, u],
    [s, u]
  ];
}
function rCe(e) {
  const { length: t, angle: r, spacegroup: n, atoms: a } = e, i = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, o = (() => {
    if (!t || !r || !n)
      return;
    const [u, c, l] = t, [d, f, m] = r, h = {
      symbol: n[1],
      no: n[0]
    };
    return Bq({
      spacegroup: h,
      a: u,
      b: c,
      c: l,
      alpha: d,
      beta: f,
      gamma: m
    });
  })(), s = a.map((u, c) => {
    const l = {
      element: u.formula,
      xyz: u.cart_coord,
      abc: u.frac_coord
    };
    return n3(l, {
      lattice: o,
      order: c
    });
  });
  return i.lattice = o, i.atoms = s, i;
}
const {
  SvelteComponent: nCe,
  append: Si,
  attr: li,
  destroy_each: aCe,
  detach: uA,
  element: yu,
  ensure_array_like: pO,
  flush: w0,
  init: iCe,
  insert: cA,
  listen: x2,
  noop: hO,
  null_to_empty: a3,
  run_all: oCe,
  safe_not_equal: sCe,
  set_data: Oq,
  space: kf,
  text: Fq
} = window.__gradio__svelte__internal;
function vO(e, t, r) {
  const n = e.slice();
  return n[30] = t[r], n;
}
function gO(e) {
  let t, r, n, a;
  return {
    c() {
      t = yu("div"), r = yu("div"), n = Fq(
        /*tooltipText*/
        e[2]
      ), li(r, "class", a3("tooltip-inner") + " svelte-gvaj6l"), li(t, "class", "tooltip svelte-gvaj6l"), li(t, "style", a = `top: ${/*mousePosition*/
      e[1].y - 45}px;left: ${/*mousePosition*/
      e[1].x - 8}px;`);
    },
    m(i, o) {
      cA(i, t, o), Si(t, r), Si(r, n);
    },
    p(i, o) {
      o[0] & /*tooltipText*/
      4 && Oq(
        n,
        /*tooltipText*/
        i[2]
      ), o[0] & /*mousePosition*/
      2 && a !== (a = `top: ${/*mousePosition*/
      i[1].y - 45}px;left: ${/*mousePosition*/
      i[1].x - 8}px;`) && li(t, "style", a);
    },
    d(i) {
      i && uA(t);
    }
  };
}
function yO(e) {
  let t, r, n, a, i = (
    /*atom*/
    e[30] + ""
  ), o, s;
  return {
    c() {
      t = yu("div"), r = yu("div"), a = kf(), o = Fq(i), s = kf(), li(r, "style", n = `background-color: ${bO(dy[
        /*atom*/
        e[30].toUpperCase()
      ])}`), li(r, "class", a3("atom-model-legend-item-ball") + " svelte-gvaj6l"), li(t, "class", a3("atom-model-legend-item") + " svelte-gvaj6l");
    },
    m(u, c) {
      cA(u, t, c), Si(t, r), Si(t, a), Si(t, o), Si(t, s);
    },
    p(u, c) {
      c[0] & /*atomList*/
      16 && n !== (n = `background-color: ${bO(dy[
        /*atom*/
        u[30].toUpperCase()
      ])}`) && li(r, "style", n), c[0] & /*atomList*/
      16 && i !== (i = /*atom*/
      u[30] + "") && Oq(o, i);
    },
    d(u) {
      u && uA(t);
    }
  };
}
function uCe(e) {
  let t, r, n, a, i, o, s, u, c, l, d, f, m, h, p, g = !!/*tooltipText*/
  e[2] && gO(e), v = pO(
    /*atomList*/
    e[4]
  ), y = [];
  for (let _ = 0; _ < v.length; _ += 1)
    y[_] = yO(vO(e, v, _));
  return {
    c() {
      t = yu("div"), r = yu("div"), n = kf(), g && g.c(), a = kf(), i = yu("div");
      for (let _ = 0; _ < y.length; _ += 1)
        y[_].c();
      o = kf(), s = yu("div"), u = yu("button"), u.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.02 3.334l-.012 9.333M3.336 8h9.333" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></svg>', c = kf(), l = yu("button"), l.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.336 8h9.333" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></svg>', d = kf(), f = yu("button"), f.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.0026 14.6673C11.6845 14.6673 14.6693 11.6825 14.6693 8.00065C14.6693 4.31875 11.6845 1.33398 8.0026 1.33398C4.32071 1.33398 1.33594 4.31875 1.33594 8.00065C1.33594 11.6825 4.32071 14.6673 8.0026 14.6673Z" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 12.334V14.6673" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M12 8H14.6667" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1.33594 8H3.66927" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 3.66732V1.33398" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><circle cx="8" cy="8" r="1" stroke="#A2A5C4"></circle></svg>', li(r, "id", `material-viewer-canvas-${/*key*/
      e[5]}`), li(r, "style", "width: 100%;height: 100%;min-height: 240px;"), li(i, "class", a3("atom-model-legend-container") + " svelte-gvaj6l"), li(u, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), li(l, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), li(f, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), li(s, "class", "material-viewer-toolbar svelte-gvaj6l"), li(t, "class", "material-viewer-container svelte-gvaj6l"), li(t, "style", m = `height: ${/*height*/
      e[0]}px;`);
    },
    m(_, S) {
      cA(_, t, S), Si(t, r), Si(t, n), g && g.m(t, null), Si(t, a), Si(t, i);
      for (let b = 0; b < y.length; b += 1)
        y[b] && y[b].m(i, null);
      Si(t, o), Si(t, s), Si(s, u), Si(s, c), Si(s, l), Si(s, d), Si(s, f), h || (p = [
        x2(
          r,
          "mousemove",
          /*mousemove_handler*/
          e[10]
        ),
        x2(
          u,
          "click",
          /*click_handler*/
          e[11]
        ),
        x2(
          l,
          "click",
          /*click_handler_1*/
          e[12]
        ),
        x2(
          f,
          "click",
          /*click_handler_2*/
          e[13]
        )
      ], h = !0);
    },
    p(_, S) {
      if (/*tooltipText*/
      _[2] ? g ? g.p(_, S) : (g = gO(_), g.c(), g.m(t, a)) : g && (g.d(1), g = null), S[0] & /*atomList*/
      16) {
        v = pO(
          /*atomList*/
          _[4]
        );
        let b;
        for (b = 0; b < v.length; b += 1) {
          const x = vO(_, v, b);
          y[b] ? y[b].p(x, S) : (y[b] = yO(x), y[b].c(), y[b].m(i, null));
        }
        for (; b < y.length; b += 1)
          y[b].d(1);
        y.length = v.length;
      }
      S[0] & /*height*/
      1 && m !== (m = `height: ${/*height*/
      _[0]}px;`) && li(t, "style", m);
    },
    i: hO,
    o: hO,
    d(_) {
      _ && uA(t), g && g.d(), aCe(y, _), h = !1, oCe(p);
    }
  };
}
function bO(e) {
  let t = e.toString(16);
  for (; t.length < 6; )
    t = "0" + t;
  return "#" + t;
}
function cCe(e, t, r) {
  var n = this && this.__awaiter || function(T, N, I, P) {
    function O(F) {
      return F instanceof I ? F : new I(function(R) {
        R(F);
      });
    }
    return new (I || (I = Promise))(function(F, R) {
      function G(K) {
        try {
          q(P.next(K));
        } catch (X) {
          R(X);
        }
      }
      function L(K) {
        try {
          q(P.throw(K));
        } catch (X) {
          R(X);
        }
      }
      function q(K) {
        K.done ? F(K.value) : O(K.value).then(G, L);
      }
      q((P = P.apply(T, N || [])).next());
    });
  };
  let { gradio: a } = t, { materialFile: i = "" } = t, { value: o = "" } = t, { value_is_output: s = !1 } = t, { height: u } = t;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  let c = new Yz();
  const d = (() => {
    function T() {
      return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
    }
    return `${T() + T()}-${T()}-${T()}-${T()}-${T()}${T()}${T()}`;
  })();
  function f() {
    a.dispatch("change"), s || a.dispatch("input");
  }
  let m = { x: -1e3, y: -1e3 }, h = "", p = [];
  const g = (T, N) => n(void 0, void 0, void 0, function* () {
    if (T) {
      const I = eCe(T.matrix), P = tCe(I);
      return c.managers.representation.createOther({
        data: P,
        type: qe.CustomLines,
        params: { alpha: 1 }
      });
    }
  }), v = (T, N) => {
    var I;
    const P = {
      vecA: D.unitX,
      vecB: D.unitY,
      vecC: D.unitZ
    }, O = (() => {
      if (!T)
        return {};
      const F = T.matrix;
      return {
        vecA: D.normalize(D.zero(), D.create.apply(null, F[0])),
        vecB: D.normalize(D.zero(), D.create.apply(null, F[1])),
        vecC: D.normalize(D.zero(), D.create.apply(null, F[2]))
      };
    })();
    return (I = c == null ? void 0 : c.canvas3d) === null || I === void 0 ? void 0 : I.setProps({
      camera: {
        helper: {
          axes: {
            name: "on",
            params: Object.assign(Object.assign({}, P), O)
          }
        }
      }
    });
  };
  function y() {
    return n(this, void 0, void 0, function* () {
      if (!c.canvas3d) return;
      const T = $9e(Q9e(rCe(JSON.parse(i)[0]))), [N] = yield c.managers.representation.createMolecular({
        format: xr.Material,
        reprType: qe.BallAndStick,
        data: T,
        theme: {
          [Mt.ATOM]: {
            color: { name: "material-element-symbol" }
          }
        }
      }), I = /* @__PURE__ */ new Set(), P = yield c.managers.cell.getStructure(N);
      P && (QL(P, (O) => {
        I.add(O.typeSymbol);
      }), r(4, p = new Array(...I.values())), g(T.lattice), v(T.lattice));
    });
  }
  function _() {
    r(3, c.managers.representation.showPolarHydrogenOnly = !1, c), c.createCanvas(document.getElementById(`material-viewer-canvas-${d}`)), c.managers.selection.structure.setGranularity(Qr.Atom), c.managers.events.setAllowSelect(!1), c.managers.highlight.info.subscribe((T) => {
      var N;
      if (((N = T.info) === null || N === void 0 ? void 0 : N.granularity) === Qr.Atom) {
        const { atomName: I, x: P, y: O, z: F } = T.info;
        r(2, h = `${I} (${[P, O, F].map((R) => R.toFixed(3)).join(", ")})`);
      } else
        r(2, h = "");
    }), window.__material_viewer = c, setTimeout(() => c.refresh(), 50);
  }
  const S = setInterval(
    () => {
      var T;
      !((T = document.getElementById(`material-viewer-canvas-${d}`)) === null || T === void 0) && T.clientHeight && !c.canvas3d && (clearInterval(S), _(), y());
    },
    500
  );
  function b() {
    c.canvas3d && (c.clear(), y());
  }
  const x = () => {
    setTimeout(
      () => {
        c.refresh({ fixCamera: !0 });
      },
      0
    );
  }, A = (T) => {
    r(1, m = { x: T.offsetX, y: T.offsetY });
  }, w = () => c.managers.camera.zoomIn(), C = () => c.managers.camera.zoomOut(), M = () => c.managers.camera.reset();
  return e.$$set = (T) => {
    "gradio" in T && r(7, a = T.gradio), "materialFile" in T && r(8, i = T.materialFile), "value" in T && r(6, o = T.value), "value_is_output" in T && r(9, s = T.value_is_output), "height" in T && r(0, u = T.height);
  }, e.$$.update = () => {
    e.$$.dirty[0] & /*value*/
    64 && o === null && r(6, o = ""), e.$$.dirty[0] & /*value*/
    64 && f(), e.$$.dirty[0] & /*mousePosition*/
    2, e.$$.dirty[0] & /*tooltipText*/
    4, e.$$.dirty[0] & /*materialFile*/
    256 && b(), e.$$.dirty[0] & /*height*/
    1 && x();
  }, [
    u,
    m,
    h,
    c,
    p,
    d,
    o,
    a,
    i,
    s,
    A,
    w,
    C,
    M
  ];
}
class lCe extends nCe {
  constructor(t) {
    super(), iCe(
      this,
      t,
      cCe,
      uCe,
      sCe,
      {
        gradio: 7,
        materialFile: 8,
        value: 6,
        value_is_output: 9,
        height: 0
      },
      null,
      [-1, -1]
    );
  }
  get gradio() {
    return this.$$.ctx[7];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), w0();
  }
  get materialFile() {
    return this.$$.ctx[8];
  }
  set materialFile(t) {
    this.$$set({ materialFile: t }), w0();
  }
  get value() {
    return this.$$.ctx[6];
  }
  set value(t) {
    this.$$set({ value: t }), w0();
  }
  get value_is_output() {
    return this.$$.ctx[9];
  }
  set value_is_output(t) {
    this.$$set({ value_is_output: t }), w0();
  }
  get height() {
    return this.$$.ctx[0];
  }
  set height(t) {
    this.$$set({ height: t }), w0();
  }
}
const {
  SvelteComponent: dCe,
  attr: G5,
  create_component: fCe,
  destroy_component: mCe,
  detach: pCe,
  element: hCe,
  flush: Gi,
  init: vCe,
  insert: gCe,
  mount_component: yCe,
  safe_not_equal: bCe,
  transition_in: xCe,
  transition_out: _Ce
} = window.__gradio__svelte__internal;
function SCe(e) {
  let t, r, n, a;
  return r = new lCe({
    props: {
      gradio: (
        /*gradio*/
        e[1]
      ),
      materialFile: (
        /*materialFile*/
        e[2]
      ),
      value: (
        /*value*/
        e[0]
      ),
      value_is_output: (
        /*value_is_output*/
        e[3]
      ),
      height: (
        /*height*/
        e[4]
      )
    }
  }), {
    c() {
      t = hCe("div"), fCe(r.$$.fragment), G5(t, "class", "material-viewer-index-container svelte-1d67499"), G5(t, "style", n = `height: ${/*height*/
      e[4]}px;`);
    },
    m(i, o) {
      gCe(i, t, o), yCe(r, t, null), a = !0;
    },
    p(i, [o]) {
      const s = {};
      o & /*gradio*/
      2 && (s.gradio = /*gradio*/
      i[1]), o & /*materialFile*/
      4 && (s.materialFile = /*materialFile*/
      i[2]), o & /*value*/
      1 && (s.value = /*value*/
      i[0]), o & /*value_is_output*/
      8 && (s.value_is_output = /*value_is_output*/
      i[3]), o & /*height*/
      16 && (s.height = /*height*/
      i[4]), r.$set(s), (!a || o & /*height*/
      16 && n !== (n = `height: ${/*height*/
      i[4]}px;`)) && G5(t, "style", n);
    },
    i(i) {
      a || (xCe(r.$$.fragment, i), a = !0);
    },
    o(i) {
      _Ce(r.$$.fragment, i), a = !1;
    },
    d(i) {
      i && pCe(t), mCe(r);
    }
  };
}
function ACe(e, t, r) {
  this && this.__awaiter;
  let { gradio: n } = t, { materialFile: a = "" } = t, { label: i = "Textbox" } = t, { elem_id: o = "" } = t, { elem_classes: s = [] } = t, { visible: u = !0 } = t, { value: c = "" } = t, { placeholder: l = "" } = t, { show_label: d } = t, { scale: f = null } = t, { min_width: m = void 0 } = t, { loading_status: h = void 0 } = t, { value_is_output: p = !1 } = t, { interactive: g } = t, { rtl: v = !1 } = t, { height: y } = t;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  function _() {
    n.dispatch("change"), p || n.dispatch("input");
  }
  return e.$$set = (S) => {
    "gradio" in S && r(1, n = S.gradio), "materialFile" in S && r(2, a = S.materialFile), "label" in S && r(5, i = S.label), "elem_id" in S && r(6, o = S.elem_id), "elem_classes" in S && r(7, s = S.elem_classes), "visible" in S && r(8, u = S.visible), "value" in S && r(0, c = S.value), "placeholder" in S && r(9, l = S.placeholder), "show_label" in S && r(10, d = S.show_label), "scale" in S && r(11, f = S.scale), "min_width" in S && r(12, m = S.min_width), "loading_status" in S && r(13, h = S.loading_status), "value_is_output" in S && r(3, p = S.value_is_output), "interactive" in S && r(14, g = S.interactive), "rtl" in S && r(15, v = S.rtl), "height" in S && r(4, y = S.height);
  }, e.$$.update = () => {
    e.$$.dirty & /*value*/
    1 && c === null && r(0, c = ""), e.$$.dirty & /*value*/
    1 && _();
  }, [
    c,
    n,
    a,
    p,
    y,
    i,
    o,
    s,
    u,
    l,
    d,
    f,
    m,
    h,
    g,
    v
  ];
}
class wCe extends dCe {
  constructor(t) {
    super(), vCe(this, t, ACe, SCe, bCe, {
      gradio: 1,
      materialFile: 2,
      label: 5,
      elem_id: 6,
      elem_classes: 7,
      visible: 8,
      value: 0,
      placeholder: 9,
      show_label: 10,
      scale: 11,
      min_width: 12,
      loading_status: 13,
      value_is_output: 3,
      interactive: 14,
      rtl: 15,
      height: 4
    });
  }
  get gradio() {
    return this.$$.ctx[1];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), Gi();
  }
  get materialFile() {
    return this.$$.ctx[2];
  }
  set materialFile(t) {
    this.$$set({ materialFile: t }), Gi();
  }
  get label() {
    return this.$$.ctx[5];
  }
  set label(t) {
    this.$$set({ label: t }), Gi();
  }
  get elem_id() {
    return this.$$.ctx[6];
  }
  set elem_id(t) {
    this.$$set({ elem_id: t }), Gi();
  }
  get elem_classes() {
    return this.$$.ctx[7];
  }
  set elem_classes(t) {
    this.$$set({ elem_classes: t }), Gi();
  }
  get visible() {
    return this.$$.ctx[8];
  }
  set visible(t) {
    this.$$set({ visible: t }), Gi();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(t) {
    this.$$set({ value: t }), Gi();
  }
  get placeholder() {
    return this.$$.ctx[9];
  }
  set placeholder(t) {
    this.$$set({ placeholder: t }), Gi();
  }
  get show_label() {
    return this.$$.ctx[10];
  }
  set show_label(t) {
    this.$$set({ show_label: t }), Gi();
  }
  get scale() {
    return this.$$.ctx[11];
  }
  set scale(t) {
    this.$$set({ scale: t }), Gi();
  }
  get min_width() {
    return this.$$.ctx[12];
  }
  set min_width(t) {
    this.$$set({ min_width: t }), Gi();
  }
  get loading_status() {
    return this.$$.ctx[13];
  }
  set loading_status(t) {
    this.$$set({ loading_status: t }), Gi();
  }
  get value_is_output() {
    return this.$$.ctx[3];
  }
  set value_is_output(t) {
    this.$$set({ value_is_output: t }), Gi();
  }
  get interactive() {
    return this.$$.ctx[14];
  }
  set interactive(t) {
    this.$$set({ interactive: t }), Gi();
  }
  get rtl() {
    return this.$$.ctx[15];
  }
  set rtl(t) {
    this.$$set({ rtl: t }), Gi();
  }
  get height() {
    return this.$$.ctx[4];
  }
  set height(t) {
    this.$$set({ height: t }), Gi();
  }
}
export {
  wCe as default
};
