const {
  SvelteComponent: nI,
  assign: rI,
  create_slot: iI,
  detach: aI,
  element: oI,
  get_all_dirty_from_scope: sI,
  get_slot_changes: uI,
  get_spread_update: cI,
  init: lI,
  insert: dI,
  safe_not_equal: fI,
  set_dynamic_element_data: j3,
  set_style: Hi,
  toggle_class: so,
  transition_in: F8,
  transition_out: G8,
  update_slot_base: mI
} = window.__gradio__svelte__internal;
function pI(e) {
  let t, n, r;
  const i = (
    /*#slots*/
    e[18].default
  ), a = iI(
    i,
    e,
    /*$$scope*/
    e[17],
    null
  );
  let o = [
    { "data-testid": (
      /*test_id*/
      e[7]
    ) },
    { id: (
      /*elem_id*/
      e[2]
    ) },
    {
      class: n = "block " + /*elem_classes*/
      e[3].join(" ") + " svelte-nl1om8"
    }
  ], s = {};
  for (let u = 0; u < o.length; u += 1)
    s = rI(s, o[u]);
  return {
    c() {
      t = oI(
        /*tag*/
        e[14]
      ), a && a.c(), j3(
        /*tag*/
        e[14]
      )(t, s), so(
        t,
        "hidden",
        /*visible*/
        e[10] === !1
      ), so(
        t,
        "padded",
        /*padding*/
        e[6]
      ), so(
        t,
        "border_focus",
        /*border_mode*/
        e[5] === "focus"
      ), so(
        t,
        "border_contrast",
        /*border_mode*/
        e[5] === "contrast"
      ), so(t, "hide-container", !/*explicit_call*/
      e[8] && !/*container*/
      e[9]), Hi(
        t,
        "height",
        /*get_dimension*/
        e[15](
          /*height*/
          e[0]
        )
      ), Hi(t, "width", typeof /*width*/
      e[1] == "number" ? `calc(min(${/*width*/
      e[1]}px, 100%))` : (
        /*get_dimension*/
        e[15](
          /*width*/
          e[1]
        )
      )), Hi(
        t,
        "border-style",
        /*variant*/
        e[4]
      ), Hi(
        t,
        "overflow",
        /*allow_overflow*/
        e[11] ? "visible" : "hidden"
      ), Hi(
        t,
        "flex-grow",
        /*scale*/
        e[12]
      ), Hi(t, "min-width", `calc(min(${/*min_width*/
      e[13]}px, 100%))`), Hi(t, "border-width", "var(--block-border-width)");
    },
    m(u, c) {
      dI(u, t, c), a && a.m(t, null), r = !0;
    },
    p(u, c) {
      a && a.p && (!r || c & /*$$scope*/
      131072) && mI(
        a,
        i,
        u,
        /*$$scope*/
        u[17],
        r ? uI(
          i,
          /*$$scope*/
          u[17],
          c,
          null
        ) : sI(
          /*$$scope*/
          u[17]
        ),
        null
      ), j3(
        /*tag*/
        u[14]
      )(t, s = cI(o, [
        (!r || c & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          u[7]
        ) },
        (!r || c & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          u[2]
        ) },
        (!r || c & /*elem_classes*/
        8 && n !== (n = "block " + /*elem_classes*/
        u[3].join(" ") + " svelte-nl1om8")) && { class: n }
      ])), so(
        t,
        "hidden",
        /*visible*/
        u[10] === !1
      ), so(
        t,
        "padded",
        /*padding*/
        u[6]
      ), so(
        t,
        "border_focus",
        /*border_mode*/
        u[5] === "focus"
      ), so(
        t,
        "border_contrast",
        /*border_mode*/
        u[5] === "contrast"
      ), so(t, "hide-container", !/*explicit_call*/
      u[8] && !/*container*/
      u[9]), c & /*height*/
      1 && Hi(
        t,
        "height",
        /*get_dimension*/
        u[15](
          /*height*/
          u[0]
        )
      ), c & /*width*/
      2 && Hi(t, "width", typeof /*width*/
      u[1] == "number" ? `calc(min(${/*width*/
      u[1]}px, 100%))` : (
        /*get_dimension*/
        u[15](
          /*width*/
          u[1]
        )
      )), c & /*variant*/
      16 && Hi(
        t,
        "border-style",
        /*variant*/
        u[4]
      ), c & /*allow_overflow*/
      2048 && Hi(
        t,
        "overflow",
        /*allow_overflow*/
        u[11] ? "visible" : "hidden"
      ), c & /*scale*/
      4096 && Hi(
        t,
        "flex-grow",
        /*scale*/
        u[12]
      ), c & /*min_width*/
      8192 && Hi(t, "min-width", `calc(min(${/*min_width*/
      u[13]}px, 100%))`);
    },
    i(u) {
      r || (F8(a, u), r = !0);
    },
    o(u) {
      G8(a, u), r = !1;
    },
    d(u) {
      u && aI(t), a && a.d(u);
    }
  };
}
function hI(e) {
  let t, n = (
    /*tag*/
    e[14] && pI(e)
  );
  return {
    c() {
      n && n.c();
    },
    m(r, i) {
      n && n.m(r, i), t = !0;
    },
    p(r, [i]) {
      /*tag*/
      r[14] && n.p(r, i);
    },
    i(r) {
      t || (F8(n, r), t = !0);
    },
    o(r) {
      G8(n, r), t = !1;
    },
    d(r) {
      n && n.d(r);
    }
  };
}
function vI(e, t, n) {
  let { $$slots: r = {}, $$scope: i } = t, { height: a = void 0 } = t, { width: o = void 0 } = t, { elem_id: s = "" } = t, { elem_classes: u = [] } = t, { variant: c = "solid" } = t, { border_mode: l = "base" } = t, { padding: d = !0 } = t, { type: m = "normal" } = t, { test_id: p = void 0 } = t, { explicit_call: v = !1 } = t, { container: f = !0 } = t, { visible: y = !0 } = t, { allow_overflow: h = !0 } = t, { scale: g = null } = t, { min_width: x = 0 } = t, C = m === "fieldset" ? "fieldset" : "div";
  const b = (_) => {
    if (_ !== void 0) {
      if (typeof _ == "number")
        return _ + "px";
      if (typeof _ == "string")
        return _;
    }
  };
  return e.$$set = (_) => {
    "height" in _ && n(0, a = _.height), "width" in _ && n(1, o = _.width), "elem_id" in _ && n(2, s = _.elem_id), "elem_classes" in _ && n(3, u = _.elem_classes), "variant" in _ && n(4, c = _.variant), "border_mode" in _ && n(5, l = _.border_mode), "padding" in _ && n(6, d = _.padding), "type" in _ && n(16, m = _.type), "test_id" in _ && n(7, p = _.test_id), "explicit_call" in _ && n(8, v = _.explicit_call), "container" in _ && n(9, f = _.container), "visible" in _ && n(10, y = _.visible), "allow_overflow" in _ && n(11, h = _.allow_overflow), "scale" in _ && n(12, g = _.scale), "min_width" in _ && n(13, x = _.min_width), "$$scope" in _ && n(17, i = _.$$scope);
  }, [
    a,
    o,
    s,
    u,
    c,
    l,
    d,
    p,
    v,
    f,
    y,
    h,
    g,
    x,
    C,
    b,
    m,
    i,
    r
  ];
}
class gI extends nI {
  constructor(t) {
    super(), lI(this, t, vI, hI, fI, {
      height: 0,
      width: 1,
      elem_id: 2,
      elem_classes: 3,
      variant: 4,
      border_mode: 5,
      padding: 6,
      type: 16,
      test_id: 7,
      explicit_call: 8,
      container: 9,
      visible: 10,
      allow_overflow: 11,
      scale: 12,
      min_width: 13
    });
  }
}
const {
  SvelteComponent: yI,
  append: S2,
  attr: rs,
  bubble: bI,
  create_component: _I,
  destroy_component: xI,
  detach: V8,
  element: C2,
  init: SI,
  insert: z8,
  listen: CI,
  mount_component: AI,
  safe_not_equal: II,
  set_data: wI,
  set_style: Gc,
  space: PI,
  text: EI,
  toggle_class: Ei,
  transition_in: TI,
  transition_out: MI
} = window.__gradio__svelte__internal;
function K3(e) {
  let t, n;
  return {
    c() {
      t = C2("span"), n = EI(
        /*label*/
        e[1]
      ), rs(t, "class", "svelte-1lrphxw");
    },
    m(r, i) {
      z8(r, t, i), S2(t, n);
    },
    p(r, i) {
      i & /*label*/
      2 && wI(
        n,
        /*label*/
        r[1]
      );
    },
    d(r) {
      r && V8(t);
    }
  };
}
function DI(e) {
  let t, n, r, i, a, o, s, u = (
    /*show_label*/
    e[2] && K3(e)
  );
  return i = new /*Icon*/
  e[0]({}), {
    c() {
      t = C2("button"), u && u.c(), n = PI(), r = C2("div"), _I(i.$$.fragment), rs(r, "class", "svelte-1lrphxw"), Ei(
        r,
        "small",
        /*size*/
        e[4] === "small"
      ), Ei(
        r,
        "large",
        /*size*/
        e[4] === "large"
      ), Ei(
        r,
        "medium",
        /*size*/
        e[4] === "medium"
      ), t.disabled = /*disabled*/
      e[7], rs(
        t,
        "aria-label",
        /*label*/
        e[1]
      ), rs(
        t,
        "aria-haspopup",
        /*hasPopup*/
        e[8]
      ), rs(
        t,
        "title",
        /*label*/
        e[1]
      ), rs(t, "class", "svelte-1lrphxw"), Ei(
        t,
        "pending",
        /*pending*/
        e[3]
      ), Ei(
        t,
        "padded",
        /*padded*/
        e[5]
      ), Ei(
        t,
        "highlight",
        /*highlight*/
        e[6]
      ), Ei(
        t,
        "transparent",
        /*transparent*/
        e[9]
      ), Gc(t, "color", !/*disabled*/
      e[7] && /*_color*/
      e[12] ? (
        /*_color*/
        e[12]
      ) : "var(--block-label-text-color)"), Gc(t, "--bg-color", /*disabled*/
      e[7] ? "auto" : (
        /*background*/
        e[10]
      )), Gc(
        t,
        "margin-left",
        /*offset*/
        e[11] + "px"
      );
    },
    m(c, l) {
      z8(c, t, l), u && u.m(t, null), S2(t, n), S2(t, r), AI(i, r, null), a = !0, o || (s = CI(
        t,
        "click",
        /*click_handler*/
        e[14]
      ), o = !0);
    },
    p(c, [l]) {
      /*show_label*/
      c[2] ? u ? u.p(c, l) : (u = K3(c), u.c(), u.m(t, n)) : u && (u.d(1), u = null), (!a || l & /*size*/
      16) && Ei(
        r,
        "small",
        /*size*/
        c[4] === "small"
      ), (!a || l & /*size*/
      16) && Ei(
        r,
        "large",
        /*size*/
        c[4] === "large"
      ), (!a || l & /*size*/
      16) && Ei(
        r,
        "medium",
        /*size*/
        c[4] === "medium"
      ), (!a || l & /*disabled*/
      128) && (t.disabled = /*disabled*/
      c[7]), (!a || l & /*label*/
      2) && rs(
        t,
        "aria-label",
        /*label*/
        c[1]
      ), (!a || l & /*hasPopup*/
      256) && rs(
        t,
        "aria-haspopup",
        /*hasPopup*/
        c[8]
      ), (!a || l & /*label*/
      2) && rs(
        t,
        "title",
        /*label*/
        c[1]
      ), (!a || l & /*pending*/
      8) && Ei(
        t,
        "pending",
        /*pending*/
        c[3]
      ), (!a || l & /*padded*/
      32) && Ei(
        t,
        "padded",
        /*padded*/
        c[5]
      ), (!a || l & /*highlight*/
      64) && Ei(
        t,
        "highlight",
        /*highlight*/
        c[6]
      ), (!a || l & /*transparent*/
      512) && Ei(
        t,
        "transparent",
        /*transparent*/
        c[9]
      ), l & /*disabled, _color*/
      4224 && Gc(t, "color", !/*disabled*/
      c[7] && /*_color*/
      c[12] ? (
        /*_color*/
        c[12]
      ) : "var(--block-label-text-color)"), l & /*disabled, background*/
      1152 && Gc(t, "--bg-color", /*disabled*/
      c[7] ? "auto" : (
        /*background*/
        c[10]
      )), l & /*offset*/
      2048 && Gc(
        t,
        "margin-left",
        /*offset*/
        c[11] + "px"
      );
    },
    i(c) {
      a || (TI(i.$$.fragment, c), a = !0);
    },
    o(c) {
      MI(i.$$.fragment, c), a = !1;
    },
    d(c) {
      c && V8(t), u && u.d(), xI(i), o = !1, s();
    }
  };
}
function BI(e, t, n) {
  let r, { Icon: i } = t, { label: a = "" } = t, { show_label: o = !1 } = t, { pending: s = !1 } = t, { size: u = "small" } = t, { padded: c = !0 } = t, { highlight: l = !1 } = t, { disabled: d = !1 } = t, { hasPopup: m = !1 } = t, { color: p = "var(--block-label-text-color)" } = t, { transparent: v = !1 } = t, { background: f = "var(--background-fill-primary)" } = t, { offset: y = 0 } = t;
  function h(g) {
    bI.call(this, e, g);
  }
  return e.$$set = (g) => {
    "Icon" in g && n(0, i = g.Icon), "label" in g && n(1, a = g.label), "show_label" in g && n(2, o = g.show_label), "pending" in g && n(3, s = g.pending), "size" in g && n(4, u = g.size), "padded" in g && n(5, c = g.padded), "highlight" in g && n(6, l = g.highlight), "disabled" in g && n(7, d = g.disabled), "hasPopup" in g && n(8, m = g.hasPopup), "color" in g && n(13, p = g.color), "transparent" in g && n(9, v = g.transparent), "background" in g && n(10, f = g.background), "offset" in g && n(11, y = g.offset);
  }, e.$$.update = () => {
    e.$$.dirty & /*highlight, color*/
    8256 && n(12, r = l ? "var(--color-accent)" : p);
  }, [
    i,
    a,
    o,
    s,
    u,
    c,
    l,
    d,
    m,
    v,
    f,
    y,
    r,
    p,
    h
  ];
}
class RI extends yI {
  constructor(t) {
    super(), SI(this, t, BI, DI, II, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5,
      highlight: 6,
      disabled: 7,
      hasPopup: 8,
      color: 13,
      transparent: 9,
      background: 10,
      offset: 11
    });
  }
}
const {
  SvelteComponent: kI,
  append: J0,
  attr: La,
  detach: OI,
  init: NI,
  insert: LI,
  noop: $0,
  safe_not_equal: FI,
  set_style: uo,
  svg_element: $f
} = window.__gradio__svelte__internal;
function GI(e) {
  let t, n, r, i;
  return {
    c() {
      t = $f("svg"), n = $f("g"), r = $f("path"), i = $f("path"), La(r, "d", "M18,6L6.087,17.913"), uo(r, "fill", "none"), uo(r, "fill-rule", "nonzero"), uo(r, "stroke-width", "2px"), La(n, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), La(i, "d", "M4.364,4.364L19.636,19.636"), uo(i, "fill", "none"), uo(i, "fill-rule", "nonzero"), uo(i, "stroke-width", "2px"), La(t, "width", "100%"), La(t, "height", "100%"), La(t, "viewBox", "0 0 24 24"), La(t, "version", "1.1"), La(t, "xmlns", "http://www.w3.org/2000/svg"), La(t, "xmlns:xlink", "http://www.w3.org/1999/xlink"), La(t, "xml:space", "preserve"), La(t, "stroke", "currentColor"), uo(t, "fill-rule", "evenodd"), uo(t, "clip-rule", "evenodd"), uo(t, "stroke-linecap", "round"), uo(t, "stroke-linejoin", "round");
    },
    m(a, o) {
      LI(a, t, o), J0(t, n), J0(n, r), J0(t, i);
    },
    p: $0,
    i: $0,
    o: $0,
    d(a) {
      a && OI(t);
    }
  };
}
class VI extends kI {
  constructor(t) {
    super(), NI(this, t, null, GI, FI, {});
  }
}
const zI = [
  { color: "red", primary: 600, secondary: 100 },
  { color: "green", primary: 600, secondary: 100 },
  { color: "blue", primary: 600, secondary: 100 },
  { color: "yellow", primary: 500, secondary: 100 },
  { color: "purple", primary: 600, secondary: 100 },
  { color: "teal", primary: 600, secondary: 100 },
  { color: "orange", primary: 600, secondary: 100 },
  { color: "cyan", primary: 600, secondary: 100 },
  { color: "lime", primary: 500, secondary: 100 },
  { color: "pink", primary: 600, secondary: 100 }
], X3 = {
  inherit: "inherit",
  current: "currentColor",
  transparent: "transparent",
  black: "#000",
  white: "#fff",
  slate: {
    50: "#f8fafc",
    100: "#f1f5f9",
    200: "#e2e8f0",
    300: "#cbd5e1",
    400: "#94a3b8",
    500: "#64748b",
    600: "#475569",
    700: "#334155",
    800: "#1e293b",
    900: "#0f172a",
    950: "#020617"
  },
  gray: {
    50: "#f9fafb",
    100: "#f3f4f6",
    200: "#e5e7eb",
    300: "#d1d5db",
    400: "#9ca3af",
    500: "#6b7280",
    600: "#4b5563",
    700: "#374151",
    800: "#1f2937",
    900: "#111827",
    950: "#030712"
  },
  zinc: {
    50: "#fafafa",
    100: "#f4f4f5",
    200: "#e4e4e7",
    300: "#d4d4d8",
    400: "#a1a1aa",
    500: "#71717a",
    600: "#52525b",
    700: "#3f3f46",
    800: "#27272a",
    900: "#18181b",
    950: "#09090b"
  },
  neutral: {
    50: "#fafafa",
    100: "#f5f5f5",
    200: "#e5e5e5",
    300: "#d4d4d4",
    400: "#a3a3a3",
    500: "#737373",
    600: "#525252",
    700: "#404040",
    800: "#262626",
    900: "#171717",
    950: "#0a0a0a"
  },
  stone: {
    50: "#fafaf9",
    100: "#f5f5f4",
    200: "#e7e5e4",
    300: "#d6d3d1",
    400: "#a8a29e",
    500: "#78716c",
    600: "#57534e",
    700: "#44403c",
    800: "#292524",
    900: "#1c1917",
    950: "#0c0a09"
  },
  red: {
    50: "#fef2f2",
    100: "#fee2e2",
    200: "#fecaca",
    300: "#fca5a5",
    400: "#f87171",
    500: "#ef4444",
    600: "#dc2626",
    700: "#b91c1c",
    800: "#991b1b",
    900: "#7f1d1d",
    950: "#450a0a"
  },
  orange: {
    50: "#fff7ed",
    100: "#ffedd5",
    200: "#fed7aa",
    300: "#fdba74",
    400: "#fb923c",
    500: "#f97316",
    600: "#ea580c",
    700: "#c2410c",
    800: "#9a3412",
    900: "#7c2d12",
    950: "#431407"
  },
  amber: {
    50: "#fffbeb",
    100: "#fef3c7",
    200: "#fde68a",
    300: "#fcd34d",
    400: "#fbbf24",
    500: "#f59e0b",
    600: "#d97706",
    700: "#b45309",
    800: "#92400e",
    900: "#78350f",
    950: "#451a03"
  },
  yellow: {
    50: "#fefce8",
    100: "#fef9c3",
    200: "#fef08a",
    300: "#fde047",
    400: "#facc15",
    500: "#eab308",
    600: "#ca8a04",
    700: "#a16207",
    800: "#854d0e",
    900: "#713f12",
    950: "#422006"
  },
  lime: {
    50: "#f7fee7",
    100: "#ecfccb",
    200: "#d9f99d",
    300: "#bef264",
    400: "#a3e635",
    500: "#84cc16",
    600: "#65a30d",
    700: "#4d7c0f",
    800: "#3f6212",
    900: "#365314",
    950: "#1a2e05"
  },
  green: {
    50: "#f0fdf4",
    100: "#dcfce7",
    200: "#bbf7d0",
    300: "#86efac",
    400: "#4ade80",
    500: "#22c55e",
    600: "#16a34a",
    700: "#15803d",
    800: "#166534",
    900: "#14532d",
    950: "#052e16"
  },
  emerald: {
    50: "#ecfdf5",
    100: "#d1fae5",
    200: "#a7f3d0",
    300: "#6ee7b7",
    400: "#34d399",
    500: "#10b981",
    600: "#059669",
    700: "#047857",
    800: "#065f46",
    900: "#064e3b",
    950: "#022c22"
  },
  teal: {
    50: "#f0fdfa",
    100: "#ccfbf1",
    200: "#99f6e4",
    300: "#5eead4",
    400: "#2dd4bf",
    500: "#14b8a6",
    600: "#0d9488",
    700: "#0f766e",
    800: "#115e59",
    900: "#134e4a",
    950: "#042f2e"
  },
  cyan: {
    50: "#ecfeff",
    100: "#cffafe",
    200: "#a5f3fc",
    300: "#67e8f9",
    400: "#22d3ee",
    500: "#06b6d4",
    600: "#0891b2",
    700: "#0e7490",
    800: "#155e75",
    900: "#164e63",
    950: "#083344"
  },
  sky: {
    50: "#f0f9ff",
    100: "#e0f2fe",
    200: "#bae6fd",
    300: "#7dd3fc",
    400: "#38bdf8",
    500: "#0ea5e9",
    600: "#0284c7",
    700: "#0369a1",
    800: "#075985",
    900: "#0c4a6e",
    950: "#082f49"
  },
  blue: {
    50: "#eff6ff",
    100: "#dbeafe",
    200: "#bfdbfe",
    300: "#93c5fd",
    400: "#60a5fa",
    500: "#3b82f6",
    600: "#2563eb",
    700: "#1d4ed8",
    800: "#1e40af",
    900: "#1e3a8a",
    950: "#172554"
  },
  indigo: {
    50: "#eef2ff",
    100: "#e0e7ff",
    200: "#c7d2fe",
    300: "#a5b4fc",
    400: "#818cf8",
    500: "#6366f1",
    600: "#4f46e5",
    700: "#4338ca",
    800: "#3730a3",
    900: "#312e81",
    950: "#1e1b4b"
  },
  violet: {
    50: "#f5f3ff",
    100: "#ede9fe",
    200: "#ddd6fe",
    300: "#c4b5fd",
    400: "#a78bfa",
    500: "#8b5cf6",
    600: "#7c3aed",
    700: "#6d28d9",
    800: "#5b21b6",
    900: "#4c1d95",
    950: "#2e1065"
  },
  purple: {
    50: "#faf5ff",
    100: "#f3e8ff",
    200: "#e9d5ff",
    300: "#d8b4fe",
    400: "#c084fc",
    500: "#a855f7",
    600: "#9333ea",
    700: "#7e22ce",
    800: "#6b21a8",
    900: "#581c87",
    950: "#3b0764"
  },
  fuchsia: {
    50: "#fdf4ff",
    100: "#fae8ff",
    200: "#f5d0fe",
    300: "#f0abfc",
    400: "#e879f9",
    500: "#d946ef",
    600: "#c026d3",
    700: "#a21caf",
    800: "#86198f",
    900: "#701a75",
    950: "#4a044e"
  },
  pink: {
    50: "#fdf2f8",
    100: "#fce7f3",
    200: "#fbcfe8",
    300: "#f9a8d4",
    400: "#f472b6",
    500: "#ec4899",
    600: "#db2777",
    700: "#be185d",
    800: "#9d174d",
    900: "#831843",
    950: "#500724"
  },
  rose: {
    50: "#fff1f2",
    100: "#ffe4e6",
    200: "#fecdd3",
    300: "#fda4af",
    400: "#fb7185",
    500: "#f43f5e",
    600: "#e11d48",
    700: "#be123c",
    800: "#9f1239",
    900: "#881337",
    950: "#4c0519"
  }
};
zI.reduce(
  (e, { color: t, primary: n, secondary: r }) => ({
    ...e,
    [t]: {
      primary: X3[t][n],
      secondary: X3[t][r]
    }
  }),
  {}
);
function vl(e) {
  let t = ["", "k", "M", "G", "T", "P", "E", "Z"], n = 0;
  for (; e > 1e3 && n < t.length - 1; )
    e /= 1e3, n++;
  let r = t[n];
  return (Number.isInteger(e) ? e : e.toFixed(1)) + r;
}
function fm() {
}
function UI(e, t) {
  return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
}
const U8 = typeof window < "u";
let Y3 = U8 ? () => window.performance.now() : () => Date.now(), H8 = U8 ? (e) => requestAnimationFrame(e) : fm;
const _l = /* @__PURE__ */ new Set();
function q8(e) {
  _l.forEach((t) => {
    t.c(e) || (_l.delete(t), t.f());
  }), _l.size !== 0 && H8(q8);
}
function HI(e) {
  let t;
  return _l.size === 0 && H8(q8), {
    promise: new Promise((n) => {
      _l.add(t = { c: e, f: n });
    }),
    abort() {
      _l.delete(t);
    }
  };
}
const Vc = [];
function qI(e, t = fm) {
  let n;
  const r = /* @__PURE__ */ new Set();
  function i(s) {
    if (UI(e, s) && (e = s, n)) {
      const u = !Vc.length;
      for (const c of r)
        c[1](), Vc.push(c, e);
      if (u) {
        for (let c = 0; c < Vc.length; c += 2)
          Vc[c][0](Vc[c + 1]);
        Vc.length = 0;
      }
    }
  }
  function a(s) {
    i(s(e));
  }
  function o(s, u = fm) {
    const c = [s, u];
    return r.add(c), r.size === 1 && (n = t(i, a) || fm), s(e), () => {
      r.delete(c), r.size === 0 && n && (n(), n = null);
    };
  }
  return { set: i, update: a, subscribe: o };
}
function W3(e) {
  return Object.prototype.toString.call(e) === "[object Date]";
}
function A2(e, t, n, r) {
  if (typeof n == "number" || W3(n)) {
    const i = r - n, a = (n - t) / (e.dt || 1 / 60), o = e.opts.stiffness * i, s = e.opts.damping * a, u = (o - s) * e.inv_mass, c = (a + u) * e.dt;
    return Math.abs(c) < e.opts.precision && Math.abs(i) < e.opts.precision ? r : (e.settled = !1, W3(n) ? new Date(n.getTime() + c) : n + c);
  } else {
    if (Array.isArray(n))
      return n.map(
        (i, a) => A2(e, t[a], n[a], r[a])
      );
    if (typeof n == "object") {
      const i = {};
      for (const a in n)
        i[a] = A2(e, t[a], n[a], r[a]);
      return i;
    } else
      throw new Error(`Cannot spring ${typeof n} values`);
  }
}
function Z3(e, t = {}) {
  const n = qI(e), { stiffness: r = 0.15, damping: i = 0.8, precision: a = 0.01 } = t;
  let o, s, u, c = e, l = e, d = 1, m = 0, p = !1;
  function v(y, h = {}) {
    l = y;
    const g = u = {};
    return e == null || h.hard || f.stiffness >= 1 && f.damping >= 1 ? (p = !0, o = Y3(), c = y, n.set(e = l), Promise.resolve()) : (h.soft && (m = 1 / ((h.soft === !0 ? 0.5 : +h.soft) * 60), d = 0), s || (o = Y3(), p = !1, s = HI((x) => {
      if (p)
        return p = !1, s = null, !1;
      d = Math.min(d + m, 1);
      const C = {
        inv_mass: d,
        opts: f,
        settled: !0,
        dt: (x - o) * 60 / 1e3
      }, b = A2(C, c, e, l);
      return o = x, c = e, n.set(e = b), C.settled && (s = null), !C.settled;
    })), new Promise((x) => {
      s.promise.then(() => {
        g === u && x();
      });
    }));
  }
  const f = {
    set: v,
    update: (y, h) => v(y(l, e), h),
    subscribe: n.subscribe,
    stiffness: r,
    damping: i,
    precision: a
  };
  return f;
}
const {
  SvelteComponent: jI,
  append: Fa,
  attr: an,
  component_subscribe: Q3,
  detach: KI,
  element: XI,
  init: YI,
  insert: WI,
  noop: J3,
  safe_not_equal: ZI,
  set_style: e1,
  svg_element: Ga,
  toggle_class: $3
} = window.__gradio__svelte__internal, { onMount: QI } = window.__gradio__svelte__internal;
function JI(e) {
  let t, n, r, i, a, o, s, u, c, l, d, m;
  return {
    c() {
      t = XI("div"), n = Ga("svg"), r = Ga("g"), i = Ga("path"), a = Ga("path"), o = Ga("path"), s = Ga("path"), u = Ga("g"), c = Ga("path"), l = Ga("path"), d = Ga("path"), m = Ga("path"), an(i, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), an(i, "fill", "#FF7C00"), an(i, "fill-opacity", "0.4"), an(i, "class", "svelte-43sxxs"), an(a, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), an(a, "fill", "#FF7C00"), an(a, "class", "svelte-43sxxs"), an(o, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), an(o, "fill", "#FF7C00"), an(o, "fill-opacity", "0.4"), an(o, "class", "svelte-43sxxs"), an(s, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), an(s, "fill", "#FF7C00"), an(s, "class", "svelte-43sxxs"), e1(r, "transform", "translate(" + /*$top*/
      e[1][0] + "px, " + /*$top*/
      e[1][1] + "px)"), an(c, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), an(c, "fill", "#FF7C00"), an(c, "fill-opacity", "0.4"), an(c, "class", "svelte-43sxxs"), an(l, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), an(l, "fill", "#FF7C00"), an(l, "class", "svelte-43sxxs"), an(d, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), an(d, "fill", "#FF7C00"), an(d, "fill-opacity", "0.4"), an(d, "class", "svelte-43sxxs"), an(m, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), an(m, "fill", "#FF7C00"), an(m, "class", "svelte-43sxxs"), e1(u, "transform", "translate(" + /*$bottom*/
      e[2][0] + "px, " + /*$bottom*/
      e[2][1] + "px)"), an(n, "viewBox", "-1200 -1200 3000 3000"), an(n, "fill", "none"), an(n, "xmlns", "http://www.w3.org/2000/svg"), an(n, "class", "svelte-43sxxs"), an(t, "class", "svelte-43sxxs"), $3(
        t,
        "margin",
        /*margin*/
        e[0]
      );
    },
    m(p, v) {
      WI(p, t, v), Fa(t, n), Fa(n, r), Fa(r, i), Fa(r, a), Fa(r, o), Fa(r, s), Fa(n, u), Fa(u, c), Fa(u, l), Fa(u, d), Fa(u, m);
    },
    p(p, [v]) {
      v & /*$top*/
      2 && e1(r, "transform", "translate(" + /*$top*/
      p[1][0] + "px, " + /*$top*/
      p[1][1] + "px)"), v & /*$bottom*/
      4 && e1(u, "transform", "translate(" + /*$bottom*/
      p[2][0] + "px, " + /*$bottom*/
      p[2][1] + "px)"), v & /*margin*/
      1 && $3(
        t,
        "margin",
        /*margin*/
        p[0]
      );
    },
    i: J3,
    o: J3,
    d(p) {
      p && KI(t);
    }
  };
}
function $I(e, t, n) {
  let r, i;
  var a = this && this.__awaiter || function(p, v, f, y) {
    function h(g) {
      return g instanceof f ? g : new f(function(x) {
        x(g);
      });
    }
    return new (f || (f = Promise))(function(g, x) {
      function C(A) {
        try {
          _(y.next(A));
        } catch (I) {
          x(I);
        }
      }
      function b(A) {
        try {
          _(y.throw(A));
        } catch (I) {
          x(I);
        }
      }
      function _(A) {
        A.done ? g(A.value) : h(A.value).then(C, b);
      }
      _((y = y.apply(p, v || [])).next());
    });
  };
  let { margin: o = !0 } = t;
  const s = Z3([0, 0]);
  Q3(e, s, (p) => n(1, r = p));
  const u = Z3([0, 0]);
  Q3(e, u, (p) => n(2, i = p));
  let c;
  function l() {
    return a(this, void 0, void 0, function* () {
      yield Promise.all([s.set([125, 140]), u.set([-125, -140])]), yield Promise.all([s.set([-125, 140]), u.set([125, -140])]), yield Promise.all([s.set([-125, 0]), u.set([125, -0])]), yield Promise.all([s.set([125, 0]), u.set([-125, 0])]);
    });
  }
  function d() {
    return a(this, void 0, void 0, function* () {
      yield l(), c || d();
    });
  }
  function m() {
    return a(this, void 0, void 0, function* () {
      yield Promise.all([s.set([125, 0]), u.set([-125, 0])]), d();
    });
  }
  return QI(() => (m(), () => c = !0)), e.$$set = (p) => {
    "margin" in p && n(0, o = p.margin);
  }, [o, r, i, s, u];
}
class ew extends jI {
  constructor(t) {
    super(), YI(this, t, $I, JI, ZI, { margin: 0 });
  }
}
const {
  SvelteComponent: tw,
  append: sc,
  attr: $a,
  binding_callbacks: ey,
  check_outros: I2,
  create_component: j8,
  create_slot: K8,
  destroy_component: X8,
  destroy_each: Y8,
  detach: Gt,
  element: Io,
  empty: Jl,
  ensure_array_like: wm,
  get_all_dirty_from_scope: W8,
  get_slot_changes: Z8,
  group_outros: w2,
  init: nw,
  insert: Vt,
  mount_component: Q8,
  noop: P2,
  safe_not_equal: rw,
  set_data: Ra,
  set_style: uu,
  space: Pa,
  text: Wn,
  toggle_class: _a,
  transition_in: Wa,
  transition_out: wo,
  update_slot_base: J8
} = window.__gradio__svelte__internal, { tick: iw } = window.__gradio__svelte__internal, { onDestroy: aw } = window.__gradio__svelte__internal, { createEventDispatcher: ow } = window.__gradio__svelte__internal, sw = (e) => ({}), ty = (e) => ({}), uw = (e) => ({}), ny = (e) => ({});
function ry(e, t, n) {
  const r = e.slice();
  return r[41] = t[n], r[43] = n, r;
}
function iy(e, t, n) {
  const r = e.slice();
  return r[41] = t[n], r;
}
function cw(e) {
  let t, n, r, i, a = (
    /*i18n*/
    e[1]("common.error") + ""
  ), o, s, u;
  n = new RI({
    props: {
      Icon: VI,
      label: (
        /*i18n*/
        e[1]("common.clear")
      ),
      disabled: !1
    }
  }), n.$on(
    "click",
    /*click_handler*/
    e[32]
  );
  const c = (
    /*#slots*/
    e[30].error
  ), l = K8(
    c,
    e,
    /*$$scope*/
    e[29],
    ty
  );
  return {
    c() {
      t = Io("div"), j8(n.$$.fragment), r = Pa(), i = Io("span"), o = Wn(a), s = Pa(), l && l.c(), $a(t, "class", "clear-status svelte-vopvsi"), $a(i, "class", "error svelte-vopvsi");
    },
    m(d, m) {
      Vt(d, t, m), Q8(n, t, null), Vt(d, r, m), Vt(d, i, m), sc(i, o), Vt(d, s, m), l && l.m(d, m), u = !0;
    },
    p(d, m) {
      const p = {};
      m[0] & /*i18n*/
      2 && (p.label = /*i18n*/
      d[1]("common.clear")), n.$set(p), (!u || m[0] & /*i18n*/
      2) && a !== (a = /*i18n*/
      d[1]("common.error") + "") && Ra(o, a), l && l.p && (!u || m[0] & /*$$scope*/
      536870912) && J8(
        l,
        c,
        d,
        /*$$scope*/
        d[29],
        u ? Z8(
          c,
          /*$$scope*/
          d[29],
          m,
          sw
        ) : W8(
          /*$$scope*/
          d[29]
        ),
        ty
      );
    },
    i(d) {
      u || (Wa(n.$$.fragment, d), Wa(l, d), u = !0);
    },
    o(d) {
      wo(n.$$.fragment, d), wo(l, d), u = !1;
    },
    d(d) {
      d && (Gt(t), Gt(r), Gt(i), Gt(s)), X8(n), l && l.d(d);
    }
  };
}
function lw(e) {
  let t, n, r, i, a, o, s, u, c, l = (
    /*variant*/
    e[8] === "default" && /*show_eta_bar*/
    e[18] && /*show_progress*/
    e[6] === "full" && ay(e)
  );
  function d(x, C) {
    if (
      /*progress*/
      x[7]
    ) return mw;
    if (
      /*queue_position*/
      x[2] !== null && /*queue_size*/
      x[3] !== void 0 && /*queue_position*/
      x[2] >= 0
    ) return fw;
    if (
      /*queue_position*/
      x[2] === 0
    ) return dw;
  }
  let m = d(e), p = m && m(e), v = (
    /*timer*/
    e[5] && uy(e)
  );
  const f = [gw, vw], y = [];
  function h(x, C) {
    return (
      /*last_progress_level*/
      x[15] != null ? 0 : (
        /*show_progress*/
        x[6] === "full" ? 1 : -1
      )
    );
  }
  ~(a = h(e)) && (o = y[a] = f[a](e));
  let g = !/*timer*/
  e[5] && hy(e);
  return {
    c() {
      l && l.c(), t = Pa(), n = Io("div"), p && p.c(), r = Pa(), v && v.c(), i = Pa(), o && o.c(), s = Pa(), g && g.c(), u = Jl(), $a(n, "class", "progress-text svelte-vopvsi"), _a(
        n,
        "meta-text-center",
        /*variant*/
        e[8] === "center"
      ), _a(
        n,
        "meta-text",
        /*variant*/
        e[8] === "default"
      );
    },
    m(x, C) {
      l && l.m(x, C), Vt(x, t, C), Vt(x, n, C), p && p.m(n, null), sc(n, r), v && v.m(n, null), Vt(x, i, C), ~a && y[a].m(x, C), Vt(x, s, C), g && g.m(x, C), Vt(x, u, C), c = !0;
    },
    p(x, C) {
      /*variant*/
      x[8] === "default" && /*show_eta_bar*/
      x[18] && /*show_progress*/
      x[6] === "full" ? l ? l.p(x, C) : (l = ay(x), l.c(), l.m(t.parentNode, t)) : l && (l.d(1), l = null), m === (m = d(x)) && p ? p.p(x, C) : (p && p.d(1), p = m && m(x), p && (p.c(), p.m(n, r))), /*timer*/
      x[5] ? v ? v.p(x, C) : (v = uy(x), v.c(), v.m(n, null)) : v && (v.d(1), v = null), (!c || C[0] & /*variant*/
      256) && _a(
        n,
        "meta-text-center",
        /*variant*/
        x[8] === "center"
      ), (!c || C[0] & /*variant*/
      256) && _a(
        n,
        "meta-text",
        /*variant*/
        x[8] === "default"
      );
      let b = a;
      a = h(x), a === b ? ~a && y[a].p(x, C) : (o && (w2(), wo(y[b], 1, 1, () => {
        y[b] = null;
      }), I2()), ~a ? (o = y[a], o ? o.p(x, C) : (o = y[a] = f[a](x), o.c()), Wa(o, 1), o.m(s.parentNode, s)) : o = null), /*timer*/
      x[5] ? g && (w2(), wo(g, 1, 1, () => {
        g = null;
      }), I2()) : g ? (g.p(x, C), C[0] & /*timer*/
      32 && Wa(g, 1)) : (g = hy(x), g.c(), Wa(g, 1), g.m(u.parentNode, u));
    },
    i(x) {
      c || (Wa(o), Wa(g), c = !0);
    },
    o(x) {
      wo(o), wo(g), c = !1;
    },
    d(x) {
      x && (Gt(t), Gt(n), Gt(i), Gt(s), Gt(u)), l && l.d(x), p && p.d(), v && v.d(), ~a && y[a].d(x), g && g.d(x);
    }
  };
}
function ay(e) {
  let t, n = `translateX(${/*eta_level*/
  (e[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      t = Io("div"), $a(t, "class", "eta-bar svelte-vopvsi"), uu(t, "transform", n);
    },
    m(r, i) {
      Vt(r, t, i);
    },
    p(r, i) {
      i[0] & /*eta_level*/
      131072 && n !== (n = `translateX(${/*eta_level*/
      (r[17] || 0) * 100 - 100}%)`) && uu(t, "transform", n);
    },
    d(r) {
      r && Gt(t);
    }
  };
}
function dw(e) {
  let t;
  return {
    c() {
      t = Wn("processing |");
    },
    m(n, r) {
      Vt(n, t, r);
    },
    p: P2,
    d(n) {
      n && Gt(t);
    }
  };
}
function fw(e) {
  let t, n = (
    /*queue_position*/
    e[2] + 1 + ""
  ), r, i, a, o;
  return {
    c() {
      t = Wn("queue: "), r = Wn(n), i = Wn("/"), a = Wn(
        /*queue_size*/
        e[3]
      ), o = Wn(" |");
    },
    m(s, u) {
      Vt(s, t, u), Vt(s, r, u), Vt(s, i, u), Vt(s, a, u), Vt(s, o, u);
    },
    p(s, u) {
      u[0] & /*queue_position*/
      4 && n !== (n = /*queue_position*/
      s[2] + 1 + "") && Ra(r, n), u[0] & /*queue_size*/
      8 && Ra(
        a,
        /*queue_size*/
        s[3]
      );
    },
    d(s) {
      s && (Gt(t), Gt(r), Gt(i), Gt(a), Gt(o));
    }
  };
}
function mw(e) {
  let t, n = wm(
    /*progress*/
    e[7]
  ), r = [];
  for (let i = 0; i < n.length; i += 1)
    r[i] = sy(iy(e, n, i));
  return {
    c() {
      for (let i = 0; i < r.length; i += 1)
        r[i].c();
      t = Jl();
    },
    m(i, a) {
      for (let o = 0; o < r.length; o += 1)
        r[o] && r[o].m(i, a);
      Vt(i, t, a);
    },
    p(i, a) {
      if (a[0] & /*progress*/
      128) {
        n = wm(
          /*progress*/
          i[7]
        );
        let o;
        for (o = 0; o < n.length; o += 1) {
          const s = iy(i, n, o);
          r[o] ? r[o].p(s, a) : (r[o] = sy(s), r[o].c(), r[o].m(t.parentNode, t));
        }
        for (; o < r.length; o += 1)
          r[o].d(1);
        r.length = n.length;
      }
    },
    d(i) {
      i && Gt(t), Y8(r, i);
    }
  };
}
function oy(e) {
  let t, n = (
    /*p*/
    e[41].unit + ""
  ), r, i, a = " ", o;
  function s(l, d) {
    return (
      /*p*/
      l[41].length != null ? hw : pw
    );
  }
  let u = s(e), c = u(e);
  return {
    c() {
      c.c(), t = Pa(), r = Wn(n), i = Wn(" | "), o = Wn(a);
    },
    m(l, d) {
      c.m(l, d), Vt(l, t, d), Vt(l, r, d), Vt(l, i, d), Vt(l, o, d);
    },
    p(l, d) {
      u === (u = s(l)) && c ? c.p(l, d) : (c.d(1), c = u(l), c && (c.c(), c.m(t.parentNode, t))), d[0] & /*progress*/
      128 && n !== (n = /*p*/
      l[41].unit + "") && Ra(r, n);
    },
    d(l) {
      l && (Gt(t), Gt(r), Gt(i), Gt(o)), c.d(l);
    }
  };
}
function pw(e) {
  let t = vl(
    /*p*/
    e[41].index || 0
  ) + "", n;
  return {
    c() {
      n = Wn(t);
    },
    m(r, i) {
      Vt(r, n, i);
    },
    p(r, i) {
      i[0] & /*progress*/
      128 && t !== (t = vl(
        /*p*/
        r[41].index || 0
      ) + "") && Ra(n, t);
    },
    d(r) {
      r && Gt(n);
    }
  };
}
function hw(e) {
  let t = vl(
    /*p*/
    e[41].index || 0
  ) + "", n, r, i = vl(
    /*p*/
    e[41].length
  ) + "", a;
  return {
    c() {
      n = Wn(t), r = Wn("/"), a = Wn(i);
    },
    m(o, s) {
      Vt(o, n, s), Vt(o, r, s), Vt(o, a, s);
    },
    p(o, s) {
      s[0] & /*progress*/
      128 && t !== (t = vl(
        /*p*/
        o[41].index || 0
      ) + "") && Ra(n, t), s[0] & /*progress*/
      128 && i !== (i = vl(
        /*p*/
        o[41].length
      ) + "") && Ra(a, i);
    },
    d(o) {
      o && (Gt(n), Gt(r), Gt(a));
    }
  };
}
function sy(e) {
  let t, n = (
    /*p*/
    e[41].index != null && oy(e)
  );
  return {
    c() {
      n && n.c(), t = Jl();
    },
    m(r, i) {
      n && n.m(r, i), Vt(r, t, i);
    },
    p(r, i) {
      /*p*/
      r[41].index != null ? n ? n.p(r, i) : (n = oy(r), n.c(), n.m(t.parentNode, t)) : n && (n.d(1), n = null);
    },
    d(r) {
      r && Gt(t), n && n.d(r);
    }
  };
}
function uy(e) {
  let t, n = (
    /*eta*/
    e[0] ? `/${/*formatted_eta*/
    e[19]}` : ""
  ), r, i;
  return {
    c() {
      t = Wn(
        /*formatted_timer*/
        e[20]
      ), r = Wn(n), i = Wn("s");
    },
    m(a, o) {
      Vt(a, t, o), Vt(a, r, o), Vt(a, i, o);
    },
    p(a, o) {
      o[0] & /*formatted_timer*/
      1048576 && Ra(
        t,
        /*formatted_timer*/
        a[20]
      ), o[0] & /*eta, formatted_eta*/
      524289 && n !== (n = /*eta*/
      a[0] ? `/${/*formatted_eta*/
      a[19]}` : "") && Ra(r, n);
    },
    d(a) {
      a && (Gt(t), Gt(r), Gt(i));
    }
  };
}
function vw(e) {
  let t, n;
  return t = new ew({
    props: { margin: (
      /*variant*/
      e[8] === "default"
    ) }
  }), {
    c() {
      j8(t.$$.fragment);
    },
    m(r, i) {
      Q8(t, r, i), n = !0;
    },
    p(r, i) {
      const a = {};
      i[0] & /*variant*/
      256 && (a.margin = /*variant*/
      r[8] === "default"), t.$set(a);
    },
    i(r) {
      n || (Wa(t.$$.fragment, r), n = !0);
    },
    o(r) {
      wo(t.$$.fragment, r), n = !1;
    },
    d(r) {
      X8(t, r);
    }
  };
}
function gw(e) {
  let t, n, r, i, a, o = `${/*last_progress_level*/
  e[15] * 100}%`, s = (
    /*progress*/
    e[7] != null && cy(e)
  );
  return {
    c() {
      t = Io("div"), n = Io("div"), s && s.c(), r = Pa(), i = Io("div"), a = Io("div"), $a(n, "class", "progress-level-inner svelte-vopvsi"), $a(a, "class", "progress-bar svelte-vopvsi"), uu(a, "width", o), $a(i, "class", "progress-bar-wrap svelte-vopvsi"), $a(t, "class", "progress-level svelte-vopvsi");
    },
    m(u, c) {
      Vt(u, t, c), sc(t, n), s && s.m(n, null), sc(t, r), sc(t, i), sc(i, a), e[31](a);
    },
    p(u, c) {
      /*progress*/
      u[7] != null ? s ? s.p(u, c) : (s = cy(u), s.c(), s.m(n, null)) : s && (s.d(1), s = null), c[0] & /*last_progress_level*/
      32768 && o !== (o = `${/*last_progress_level*/
      u[15] * 100}%`) && uu(a, "width", o);
    },
    i: P2,
    o: P2,
    d(u) {
      u && Gt(t), s && s.d(), e[31](null);
    }
  };
}
function cy(e) {
  let t, n = wm(
    /*progress*/
    e[7]
  ), r = [];
  for (let i = 0; i < n.length; i += 1)
    r[i] = py(ry(e, n, i));
  return {
    c() {
      for (let i = 0; i < r.length; i += 1)
        r[i].c();
      t = Jl();
    },
    m(i, a) {
      for (let o = 0; o < r.length; o += 1)
        r[o] && r[o].m(i, a);
      Vt(i, t, a);
    },
    p(i, a) {
      if (a[0] & /*progress_level, progress*/
      16512) {
        n = wm(
          /*progress*/
          i[7]
        );
        let o;
        for (o = 0; o < n.length; o += 1) {
          const s = ry(i, n, o);
          r[o] ? r[o].p(s, a) : (r[o] = py(s), r[o].c(), r[o].m(t.parentNode, t));
        }
        for (; o < r.length; o += 1)
          r[o].d(1);
        r.length = n.length;
      }
    },
    d(i) {
      i && Gt(t), Y8(r, i);
    }
  };
}
function ly(e) {
  let t, n, r, i, a = (
    /*i*/
    e[43] !== 0 && yw()
  ), o = (
    /*p*/
    e[41].desc != null && dy(e)
  ), s = (
    /*p*/
    e[41].desc != null && /*progress_level*/
    e[14] && /*progress_level*/
    e[14][
      /*i*/
      e[43]
    ] != null && fy()
  ), u = (
    /*progress_level*/
    e[14] != null && my(e)
  );
  return {
    c() {
      a && a.c(), t = Pa(), o && o.c(), n = Pa(), s && s.c(), r = Pa(), u && u.c(), i = Jl();
    },
    m(c, l) {
      a && a.m(c, l), Vt(c, t, l), o && o.m(c, l), Vt(c, n, l), s && s.m(c, l), Vt(c, r, l), u && u.m(c, l), Vt(c, i, l);
    },
    p(c, l) {
      /*p*/
      c[41].desc != null ? o ? o.p(c, l) : (o = dy(c), o.c(), o.m(n.parentNode, n)) : o && (o.d(1), o = null), /*p*/
      c[41].desc != null && /*progress_level*/
      c[14] && /*progress_level*/
      c[14][
        /*i*/
        c[43]
      ] != null ? s || (s = fy(), s.c(), s.m(r.parentNode, r)) : s && (s.d(1), s = null), /*progress_level*/
      c[14] != null ? u ? u.p(c, l) : (u = my(c), u.c(), u.m(i.parentNode, i)) : u && (u.d(1), u = null);
    },
    d(c) {
      c && (Gt(t), Gt(n), Gt(r), Gt(i)), a && a.d(c), o && o.d(c), s && s.d(c), u && u.d(c);
    }
  };
}
function yw(e) {
  let t;
  return {
    c() {
      t = Wn(" /");
    },
    m(n, r) {
      Vt(n, t, r);
    },
    d(n) {
      n && Gt(t);
    }
  };
}
function dy(e) {
  let t = (
    /*p*/
    e[41].desc + ""
  ), n;
  return {
    c() {
      n = Wn(t);
    },
    m(r, i) {
      Vt(r, n, i);
    },
    p(r, i) {
      i[0] & /*progress*/
      128 && t !== (t = /*p*/
      r[41].desc + "") && Ra(n, t);
    },
    d(r) {
      r && Gt(n);
    }
  };
}
function fy(e) {
  let t;
  return {
    c() {
      t = Wn("-");
    },
    m(n, r) {
      Vt(n, t, r);
    },
    d(n) {
      n && Gt(t);
    }
  };
}
function my(e) {
  let t = (100 * /*progress_level*/
  (e[14][
    /*i*/
    e[43]
  ] || 0)).toFixed(1) + "", n, r;
  return {
    c() {
      n = Wn(t), r = Wn("%");
    },
    m(i, a) {
      Vt(i, n, a), Vt(i, r, a);
    },
    p(i, a) {
      a[0] & /*progress_level*/
      16384 && t !== (t = (100 * /*progress_level*/
      (i[14][
        /*i*/
        i[43]
      ] || 0)).toFixed(1) + "") && Ra(n, t);
    },
    d(i) {
      i && (Gt(n), Gt(r));
    }
  };
}
function py(e) {
  let t, n = (
    /*p*/
    (e[41].desc != null || /*progress_level*/
    e[14] && /*progress_level*/
    e[14][
      /*i*/
      e[43]
    ] != null) && ly(e)
  );
  return {
    c() {
      n && n.c(), t = Jl();
    },
    m(r, i) {
      n && n.m(r, i), Vt(r, t, i);
    },
    p(r, i) {
      /*p*/
      r[41].desc != null || /*progress_level*/
      r[14] && /*progress_level*/
      r[14][
        /*i*/
        r[43]
      ] != null ? n ? n.p(r, i) : (n = ly(r), n.c(), n.m(t.parentNode, t)) : n && (n.d(1), n = null);
    },
    d(r) {
      r && Gt(t), n && n.d(r);
    }
  };
}
function hy(e) {
  let t, n, r, i;
  const a = (
    /*#slots*/
    e[30]["additional-loading-text"]
  ), o = K8(
    a,
    e,
    /*$$scope*/
    e[29],
    ny
  );
  return {
    c() {
      t = Io("p"), n = Wn(
        /*loading_text*/
        e[9]
      ), r = Pa(), o && o.c(), $a(t, "class", "loading svelte-vopvsi");
    },
    m(s, u) {
      Vt(s, t, u), sc(t, n), Vt(s, r, u), o && o.m(s, u), i = !0;
    },
    p(s, u) {
      (!i || u[0] & /*loading_text*/
      512) && Ra(
        n,
        /*loading_text*/
        s[9]
      ), o && o.p && (!i || u[0] & /*$$scope*/
      536870912) && J8(
        o,
        a,
        s,
        /*$$scope*/
        s[29],
        i ? Z8(
          a,
          /*$$scope*/
          s[29],
          u,
          uw
        ) : W8(
          /*$$scope*/
          s[29]
        ),
        ny
      );
    },
    i(s) {
      i || (Wa(o, s), i = !0);
    },
    o(s) {
      wo(o, s), i = !1;
    },
    d(s) {
      s && (Gt(t), Gt(r)), o && o.d(s);
    }
  };
}
function bw(e) {
  let t, n, r, i, a;
  const o = [lw, cw], s = [];
  function u(c, l) {
    return (
      /*status*/
      c[4] === "pending" ? 0 : (
        /*status*/
        c[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(n = u(e)) && (r = s[n] = o[n](e)), {
    c() {
      t = Io("div"), r && r.c(), $a(t, "class", i = "wrap " + /*variant*/
      e[8] + " " + /*show_progress*/
      e[6] + " svelte-vopvsi"), _a(t, "hide", !/*status*/
      e[4] || /*status*/
      e[4] === "complete" || /*show_progress*/
      e[6] === "hidden"), _a(
        t,
        "translucent",
        /*variant*/
        e[8] === "center" && /*status*/
        (e[4] === "pending" || /*status*/
        e[4] === "error") || /*translucent*/
        e[11] || /*show_progress*/
        e[6] === "minimal"
      ), _a(
        t,
        "generating",
        /*status*/
        e[4] === "generating"
      ), _a(
        t,
        "border",
        /*border*/
        e[12]
      ), uu(
        t,
        "position",
        /*absolute*/
        e[10] ? "absolute" : "static"
      ), uu(
        t,
        "padding",
        /*absolute*/
        e[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(c, l) {
      Vt(c, t, l), ~n && s[n].m(t, null), e[33](t), a = !0;
    },
    p(c, l) {
      let d = n;
      n = u(c), n === d ? ~n && s[n].p(c, l) : (r && (w2(), wo(s[d], 1, 1, () => {
        s[d] = null;
      }), I2()), ~n ? (r = s[n], r ? r.p(c, l) : (r = s[n] = o[n](c), r.c()), Wa(r, 1), r.m(t, null)) : r = null), (!a || l[0] & /*variant, show_progress*/
      320 && i !== (i = "wrap " + /*variant*/
      c[8] + " " + /*show_progress*/
      c[6] + " svelte-vopvsi")) && $a(t, "class", i), (!a || l[0] & /*variant, show_progress, status, show_progress*/
      336) && _a(t, "hide", !/*status*/
      c[4] || /*status*/
      c[4] === "complete" || /*show_progress*/
      c[6] === "hidden"), (!a || l[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && _a(
        t,
        "translucent",
        /*variant*/
        c[8] === "center" && /*status*/
        (c[4] === "pending" || /*status*/
        c[4] === "error") || /*translucent*/
        c[11] || /*show_progress*/
        c[6] === "minimal"
      ), (!a || l[0] & /*variant, show_progress, status*/
      336) && _a(
        t,
        "generating",
        /*status*/
        c[4] === "generating"
      ), (!a || l[0] & /*variant, show_progress, border*/
      4416) && _a(
        t,
        "border",
        /*border*/
        c[12]
      ), l[0] & /*absolute*/
      1024 && uu(
        t,
        "position",
        /*absolute*/
        c[10] ? "absolute" : "static"
      ), l[0] & /*absolute*/
      1024 && uu(
        t,
        "padding",
        /*absolute*/
        c[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(c) {
      a || (Wa(r), a = !0);
    },
    o(c) {
      wo(r), a = !1;
    },
    d(c) {
      c && Gt(t), ~n && s[n].d(), e[33](null);
    }
  };
}
var _w = function(e, t, n, r) {
  function i(a) {
    return a instanceof n ? a : new n(function(o) {
      o(a);
    });
  }
  return new (n || (n = Promise))(function(a, o) {
    function s(l) {
      try {
        c(r.next(l));
      } catch (d) {
        o(d);
      }
    }
    function u(l) {
      try {
        c(r.throw(l));
      } catch (d) {
        o(d);
      }
    }
    function c(l) {
      l.done ? a(l.value) : i(l.value).then(s, u);
    }
    c((r = r.apply(e, t || [])).next());
  });
};
let t1 = [], ep = !1;
function xw(e) {
  return _w(this, arguments, void 0, function* (t, n = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && n !== !0)) {
      if (t1.push(t), !ep) ep = !0;
      else return;
      yield iw(), requestAnimationFrame(() => {
        let r = [0, 0];
        for (let i = 0; i < t1.length; i++) {
          const o = t1[i].getBoundingClientRect();
          (i === 0 || o.top + window.scrollY <= r[0]) && (r[0] = o.top + window.scrollY, r[1] = i);
        }
        window.scrollTo({ top: r[0] - 20, behavior: "smooth" }), ep = !1, t1 = [];
      });
    }
  });
}
function Sw(e, t, n) {
  let r, { $$slots: i = {}, $$scope: a } = t;
  this && this.__awaiter;
  const o = ow();
  let { i18n: s } = t, { eta: u = null } = t, { queue_position: c } = t, { queue_size: l } = t, { status: d } = t, { scroll_to_output: m = !1 } = t, { timer: p = !0 } = t, { show_progress: v = "full" } = t, { message: f = null } = t, { progress: y = null } = t, { variant: h = "default" } = t, { loading_text: g = "Loading..." } = t, { absolute: x = !0 } = t, { translucent: C = !1 } = t, { border: b = !1 } = t, { autoscroll: _ } = t, A, I = !1, w = 0, E = 0, D = null, T = null, P = 0, M = null, R, O = null, L = !0;
  const F = () => {
    n(0, u = n(27, D = n(19, U = null))), n(25, w = performance.now()), n(26, E = 0), I = !0, G();
  };
  function G() {
    requestAnimationFrame(() => {
      n(26, E = (performance.now() - w) / 1e3), I && G();
    });
  }
  function V() {
    n(26, E = 0), n(0, u = n(27, D = n(19, U = null))), I && (I = !1);
  }
  aw(() => {
    I && V();
  });
  let U = null;
  function q(j) {
    ey[j ? "unshift" : "push"](() => {
      O = j, n(16, O), n(7, y), n(14, M), n(15, R);
    });
  }
  const H = () => {
    o("clear_status");
  };
  function K(j) {
    ey[j ? "unshift" : "push"](() => {
      A = j, n(13, A);
    });
  }
  return e.$$set = (j) => {
    "i18n" in j && n(1, s = j.i18n), "eta" in j && n(0, u = j.eta), "queue_position" in j && n(2, c = j.queue_position), "queue_size" in j && n(3, l = j.queue_size), "status" in j && n(4, d = j.status), "scroll_to_output" in j && n(22, m = j.scroll_to_output), "timer" in j && n(5, p = j.timer), "show_progress" in j && n(6, v = j.show_progress), "message" in j && n(23, f = j.message), "progress" in j && n(7, y = j.progress), "variant" in j && n(8, h = j.variant), "loading_text" in j && n(9, g = j.loading_text), "absolute" in j && n(10, x = j.absolute), "translucent" in j && n(11, C = j.translucent), "border" in j && n(12, b = j.border), "autoscroll" in j && n(24, _ = j.autoscroll), "$$scope" in j && n(29, a = j.$$scope);
  }, e.$$.update = () => {
    e.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    436207617 && (u === null && n(0, u = D), u != null && D !== u && (n(28, T = (performance.now() - w) / 1e3 + u), n(19, U = T.toFixed(1)), n(27, D = u))), e.$$.dirty[0] & /*eta_from_start, timer_diff*/
    335544320 && n(17, P = T === null || T <= 0 || !E ? null : Math.min(E / T, 1)), e.$$.dirty[0] & /*progress*/
    128 && y != null && n(18, L = !1), e.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (y != null ? n(14, M = y.map((j) => {
      if (j.index != null && j.length != null)
        return j.index / j.length;
      if (j.progress != null)
        return j.progress;
    })) : n(14, M = null), M ? (n(15, R = M[M.length - 1]), O && (R === 0 ? n(16, O.style.transition = "0", O) : n(16, O.style.transition = "150ms", O))) : n(15, R = void 0)), e.$$.dirty[0] & /*status*/
    16 && (d === "pending" ? F() : V()), e.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && A && m && (d === "pending" || d === "complete") && xw(A, _), e.$$.dirty[0] & /*status, message*/
    8388624, e.$$.dirty[0] & /*timer_diff*/
    67108864 && n(20, r = E.toFixed(1));
  }, [
    u,
    s,
    c,
    l,
    d,
    p,
    v,
    y,
    h,
    g,
    x,
    C,
    b,
    A,
    M,
    R,
    O,
    P,
    L,
    U,
    r,
    o,
    m,
    f,
    _,
    w,
    E,
    D,
    T,
    a,
    i,
    q,
    H,
    K
  ];
}
class Cw extends tw {
  constructor(t) {
    super(), nw(
      this,
      t,
      Sw,
      bw,
      rw,
      {
        i18n: 1,
        eta: 0,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 22,
        timer: 5,
        show_progress: 6,
        message: 23,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 24
      },
      null,
      [-1, -1]
    );
  }
}
/*! *****************************************************************************
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 E2 = function(e, t) {
  return E2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
    n.__proto__ = r;
  } || function(n, r) {
    for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]);
  }, E2(e, t);
};
function Zr(e, t) {
  if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
  function n() {
    this.constructor = e;
  }
  E2(e, t), e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
}
var B = function() {
  return B = Object.assign || function(e) {
    for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
    return e;
  }, B.apply(this, arguments);
};
function ie(e, t, n, r) {
  return new (n || (n = Promise))(function(i, a) {
    function o(c) {
      try {
        u(r.next(c));
      } catch (l) {
        a(l);
      }
    }
    function s(c) {
      try {
        u(r.throw(c));
      } catch (l) {
        a(l);
      }
    }
    function u(c) {
      var l;
      c.done ? i(c.value) : (l = c.value, l instanceof n ? l : new n(function(d) {
        d(l);
      })).then(o, s);
    }
    u((r = r.apply(e, [])).next());
  });
}
function ne(e, t) {
  var n, r, i, a, o = { label: 0, sent: function() {
    if (1 & i[0]) throw i[1];
    return i[1];
  }, trys: [], ops: [] };
  return a = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (a[Symbol.iterator] = function() {
    return this;
  }), a;
  function s(u) {
    return function(c) {
      return function(l) {
        if (n) throw new TypeError("Generator is already executing.");
        for (; o; ) try {
          if (n = 1, r && (i = 2 & l[0] ? r.return : l[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, l[1])).done) return i;
          switch (r = 0, i && (l = [2 & l[0], i.value]), l[0]) {
            case 0:
            case 1:
              i = l;
              break;
            case 4:
              return o.label++, { value: l[1], done: !1 };
            case 5:
              o.label++, r = l[1], l = [0];
              continue;
            case 7:
              l = o.ops.pop(), o.trys.pop();
              continue;
            default:
              if (i = o.trys, !((i = i.length > 0 && i[i.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
                o = 0;
                continue;
              }
              if (l[0] === 3 && (!i || l[1] > i[0] && l[1] < i[3])) {
                o.label = l[1];
                break;
              }
              if (l[0] === 6 && o.label < i[1]) {
                o.label = i[1], i = l;
                break;
              }
              if (i && o.label < i[2]) {
                o.label = i[2], o.ops.push(l);
                break;
              }
              i[2] && o.ops.pop(), o.trys.pop();
              continue;
          }
          l = t.call(e, o);
        } catch (d) {
          l = [6, d], r = 0;
        } finally {
          n = i = 0;
        }
        if (5 & l[0]) throw l[1];
        return { value: l[0] ? l[1] : void 0, done: !0 };
      }([u, c]);
    };
  }
}
function T2(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
  if (n) return n.call(e);
  if (e && typeof e.length == "number") return { next: function() {
    return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e };
  } };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function Pm(e, t) {
  var n = typeof Symbol == "function" && e[Symbol.iterator];
  if (!n) return e;
  var r, i, a = n.call(e), o = [];
  try {
    for (; (t === void 0 || t-- > 0) && !(r = a.next()).done; ) o.push(r.value);
  } catch (s) {
    i = { error: s };
  } finally {
    try {
      r && !r.done && (n = a.return) && n.call(a);
    } finally {
      if (i) throw i.error;
    }
  }
  return o;
}
function Pe(e, t, n) {
  if (n || arguments.length === 2) for (var r, i = 0, a = t.length; i < a; i++) !r && i in t || (r || (r = Array.prototype.slice.call(t, 0, i)), r[i] = t[i]);
  return e.concat(r || Array.prototype.slice.call(t));
}
function fs(e) {
  return typeof e == "function";
}
function $8(e) {
  var t = e(function(n) {
    Error.call(n), n.stack = new Error().stack;
  });
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
var tp = $8(function(e) {
  return function(t) {
    e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
` + t.map(function(n, r) {
      return r + 1 + ") " + n.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = t;
  };
});
function M2(e, t) {
  if (e) {
    var n = e.indexOf(t);
    0 <= n && e.splice(n, 1);
  }
}
var S0 = function() {
  function e(n) {
    this.initialTeardown = n, this.closed = !1, this._parentage = null, this._teardowns = null;
  }
  var t;
  return e.prototype.unsubscribe = function() {
    var n, r, i, a, o;
    if (!this.closed) {
      this.closed = !0;
      var s = this._parentage;
      if (s) if (this._parentage = null, Array.isArray(s)) try {
        for (var u = T2(s), c = u.next(); !c.done; c = u.next())
          c.value.remove(this);
      } catch (f) {
        n = { error: f };
      } finally {
        try {
          c && !c.done && (r = u.return) && r.call(u);
        } finally {
          if (n) throw n.error;
        }
      }
      else s.remove(this);
      var l = this.initialTeardown;
      if (fs(l)) try {
        l();
      } catch (f) {
        o = f instanceof tp ? f.errors : [f];
      }
      var d = this._teardowns;
      if (d) {
        this._teardowns = null;
        try {
          for (var m = T2(d), p = m.next(); !p.done; p = m.next()) {
            var v = p.value;
            try {
              vy(v);
            } catch (f) {
              o = o ?? [], f instanceof tp ? o = Pe(Pe([], Pm(o)), Pm(f.errors)) : o.push(f);
            }
          }
        } catch (f) {
          i = { error: f };
        } finally {
          try {
            p && !p.done && (a = m.return) && a.call(m);
          } finally {
            if (i) throw i.error;
          }
        }
      }
      if (o) throw new tp(o);
    }
  }, e.prototype.add = function(n) {
    var r;
    if (n && n !== this) if (this.closed) vy(n);
    else {
      if (n instanceof e) {
        if (n.closed || n._hasParent(this)) return;
        n._addParent(this);
      }
      (this._teardowns = (r = this._teardowns) !== null && r !== void 0 ? r : []).push(n);
    }
  }, e.prototype._hasParent = function(n) {
    var r = this._parentage;
    return r === n || Array.isArray(r) && r.includes(n);
  }, e.prototype._addParent = function(n) {
    var r = this._parentage;
    this._parentage = Array.isArray(r) ? (r.push(n), r) : r ? [r, n] : n;
  }, e.prototype._removeParent = function(n) {
    var r = this._parentage;
    r === n ? this._parentage = null : Array.isArray(r) && M2(r, n);
  }, e.prototype.remove = function(n) {
    var r = this._teardowns;
    r && M2(r, n), n instanceof e && n._removeParent(this);
  }, e.EMPTY = ((t = new e()).closed = !0, t), e;
}(), e7 = S0.EMPTY;
function t7(e) {
  return e instanceof S0 || e && "closed" in e && fs(e.remove) && fs(e.add) && fs(e.unsubscribe);
}
function vy(e) {
  fs(e) ? e() : e.unsubscribe();
}
var n7 = { onUnhandledError: null, onStoppedNotification: null, Promise: void 0, useDeprecatedSynchronousErrorHandling: !1, useDeprecatedNextContext: !1 }, Aw = { setTimeout: function() {
  for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
  return setTimeout.apply(void 0, Pe([], Pm(e)));
}, clearTimeout: function(e) {
  return clearTimeout(e);
}, delegate: void 0 };
function Em() {
}
function mm(e) {
  e();
}
var r7 = function(e) {
  function t(n) {
    var r = e.call(this) || this;
    return r.isStopped = !1, n ? (r.destination = n, t7(n) && n.add(r)) : r.destination = Iw, r;
  }
  return Zr(t, e), t.create = function(n, r, i) {
    return new D2(n, r, i);
  }, t.prototype.next = function(n) {
    this.isStopped || this._next(n);
  }, t.prototype.error = function(n) {
    this.isStopped || (this.isStopped = !0, this._error(n));
  }, 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(n) {
    this.destination.next(n);
  }, t.prototype._error = function(n) {
    try {
      this.destination.error(n);
    } finally {
      this.unsubscribe();
    }
  }, t.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, t;
}(S0), D2 = function(e) {
  function t(n, r, i) {
    var a, o = e.call(this) || this;
    if (fs(n)) a = n;
    else if (n) {
      var s;
      a = n.next, r = n.error, i = n.complete, o && n7.useDeprecatedNextContext ? (s = Object.create(n)).unsubscribe = function() {
        return o.unsubscribe();
      } : s = n, a = a == null ? void 0 : a.bind(s), r = r == null ? void 0 : r.bind(s), i = i == null ? void 0 : i.bind(s);
    }
    return o.destination = { next: a ? np(a) : Em, error: np(r ?? i7), complete: i ? np(i) : Em }, o;
  }
  return Zr(t, e), t;
}(r7);
function np(e, t) {
  return function() {
    for (var n = [], r = 0; r < arguments.length; r++) n[r] = arguments[r];
    try {
      e.apply(void 0, Pe([], Pm(n)));
    } catch (i) {
      (function(a) {
        Aw.setTimeout(function() {
          throw a;
        });
      })(i);
    }
  };
}
function i7(e) {
  throw e;
}
var Iw = { closed: !0, next: Em, error: i7, complete: Em }, ww = typeof Symbol == "function" && Symbol.observable || "@@observable";
function Pw(e) {
  return e;
}
var gy = function() {
  function e(t) {
    t && (this._subscribe = t);
  }
  return e.prototype.lift = function(t) {
    var n = new e();
    return n.source = this, n.operator = t, n;
  }, e.prototype.subscribe = function(t, n, r) {
    var i, a = this, o = (i = t) && i instanceof r7 || function(s) {
      return s && fs(s.next) && fs(s.error) && fs(s.complete);
    }(i) && t7(i) ? t : new D2(t, n, r);
    return mm(function() {
      var s = a, u = s.operator, c = s.source;
      o.add(u ? u.call(o, c) : c ? a._subscribe(o) : a._trySubscribe(o));
    }), o;
  }, e.prototype._trySubscribe = function(t) {
    try {
      return this._subscribe(t);
    } catch (n) {
      t.error(n);
    }
  }, e.prototype.forEach = function(t, n) {
    var r = this;
    return new (n = yy(n))(function(i, a) {
      var o = new D2({ next: function(s) {
        try {
          t(s);
        } catch (u) {
          a(u), o.unsubscribe();
        }
      }, error: a, complete: i });
      r.subscribe(o);
    });
  }, e.prototype._subscribe = function(t) {
    var n;
    return (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t);
  }, e.prototype[ww] = function() {
    return this;
  }, e.prototype.pipe = function() {
    for (var t, n = [], r = 0; r < arguments.length; r++) n[r] = arguments[r];
    return ((t = n).length === 0 ? Pw : t.length === 1 ? t[0] : function(i) {
      return t.reduce(function(a, o) {
        return o(a);
      }, i);
    })(this);
  }, e.prototype.toPromise = function(t) {
    var n = this;
    return new (t = yy(t))(function(r, i) {
      var a;
      n.subscribe(function(o) {
        return a = o;
      }, function(o) {
        return i(o);
      }, function() {
        return r(a);
      });
    });
  }, e.create = function(t) {
    return new e(t);
  }, e;
}();
function yy(e) {
  var t;
  return (t = e ?? n7.Promise) !== null && t !== void 0 ? t : Promise;
}
var Ew = $8(function(e) {
  return function() {
    e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
}), $n = function(e) {
  function t() {
    var n = e.call(this) || this;
    return n.closed = !1, n.observers = [], n.isStopped = !1, n.hasError = !1, n.thrownError = null, n;
  }
  return Zr(t, e), t.prototype.lift = function(n) {
    var r = new by(this, this);
    return r.operator = n, r;
  }, t.prototype._throwIfClosed = function() {
    if (this.closed) throw new Ew();
  }, t.prototype.next = function(n) {
    var r = this;
    mm(function() {
      var i, a;
      if (r._throwIfClosed(), !r.isStopped) {
        var o = r.observers.slice();
        try {
          for (var s = T2(o), u = s.next(); !u.done; u = s.next())
            u.value.next(n);
        } catch (c) {
          i = { error: c };
        } finally {
          try {
            u && !u.done && (a = s.return) && a.call(s);
          } finally {
            if (i) throw i.error;
          }
        }
      }
    });
  }, t.prototype.error = function(n) {
    var r = this;
    mm(function() {
      if (r._throwIfClosed(), !r.isStopped) {
        r.hasError = r.isStopped = !0, r.thrownError = n;
        for (var i = r.observers; i.length; ) i.shift().error(n);
      }
    });
  }, t.prototype.complete = function() {
    var n = this;
    mm(function() {
      if (n._throwIfClosed(), !n.isStopped) {
        n.isStopped = !0;
        for (var r = n.observers; r.length; ) r.shift().complete();
      }
    });
  }, t.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = null;
  }, Object.defineProperty(t.prototype, "observed", { get: function() {
    var n;
    return ((n = this.observers) === null || n === void 0 ? void 0 : n.length) > 0;
  }, enumerable: !1, configurable: !0 }), t.prototype._trySubscribe = function(n) {
    return this._throwIfClosed(), e.prototype._trySubscribe.call(this, n);
  }, t.prototype._subscribe = function(n) {
    return this._throwIfClosed(), this._checkFinalizedStatuses(n), this._innerSubscribe(n);
  }, t.prototype._innerSubscribe = function(n) {
    var r = this, i = r.hasError, a = r.isStopped, o = r.observers;
    return i || a ? e7 : (o.push(n), new S0(function() {
      return M2(o, n);
    }));
  }, t.prototype._checkFinalizedStatuses = function(n) {
    var r = this, i = r.hasError, a = r.thrownError, o = r.isStopped;
    i ? n.error(a) : o && n.complete();
  }, t.prototype.asObservable = function() {
    var n = new gy();
    return n.source = this, n;
  }, t.create = function(n, r) {
    return new by(n, r);
  }, t;
}(gy), by = function(e) {
  function t(n, r) {
    var i = e.call(this) || this;
    return i.destination = n, i.source = r, i;
  }
  return Zr(t, e), t.prototype.next = function(n) {
    var r, i;
    (i = (r = this.destination) === null || r === void 0 ? void 0 : r.next) === null || i === void 0 || i.call(r, n);
  }, t.prototype.error = function(n) {
    var r, i;
    (i = (r = this.destination) === null || r === void 0 ? void 0 : r.error) === null || i === void 0 || i.call(r, n);
  }, t.prototype.complete = function() {
    var n, r;
    (r = (n = this.destination) === null || n === void 0 ? void 0 : n.complete) === null || r === void 0 || r.call(n);
  }, t.prototype._subscribe = function(n) {
    var r, i;
    return (i = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(n)) !== null && i !== void 0 ? i : e7;
  }, t;
}($n), cu = function(e) {
  function t(n) {
    var r = e.call(this) || this;
    return r._value = n, r;
  }
  return Zr(t, e), Object.defineProperty(t.prototype, "value", { get: function() {
    return this.getValue();
  }, enumerable: !1, configurable: !0 }), t.prototype._subscribe = function(n) {
    var r = e.prototype._subscribe.call(this, n);
    return !r.closed && n.next(this._value), r;
  }, t.prototype.getValue = function() {
    var n = this, r = n.hasError, i = n.thrownError, a = n._value;
    if (r) throw i;
    return this._throwIfClosed(), a;
  }, t.prototype.next = function(n) {
    e.prototype.next.call(this, this._value = n);
  }, t;
}($n), nr = 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();
  };
}(), bn = 1e-6;
function On(e, t, n) {
  return Math.abs(e - t) <= n;
}
var Nn, Qr, qt, vr, _y, Zd, xy = Math.PI / 2, a7 = Math.PI / 180;
function Bn(e) {
  return e * a7;
}
function $r(e) {
  return e / a7;
}
function o7(e, t) {
  return e * t;
}
function J() {
  return J.zero();
}
function xi(e, t, n) {
  return Math.max(t, Math.min(n, e));
}
function fr(e, t, n) {
  return e + (t - e) * n;
}
function pm(e, t, n, r, i, a) {
  var o = (n - e) * a, s = (r - t) * a, u = i * i;
  return (2 * t - 2 * n + o + s) * (i * u) + (-3 * t + 3 * n - 2 * o - s) * u + o * i + t;
}
function rp(e, t, n, r) {
  var i = 1 - r;
  return i * i * e + 2 * i * r * t + r * r * n;
}
function s7(e, t, n) {
  var r;
  return r = function(i, a, o) {
    return (i - a) / (o - a);
  }(n, e, t), (n = xi(r, 0, 1)) * n * (3 - 2 * n);
}
function S() {
  return S.zero();
}
function br() {
  return br.zero();
}
function ge() {
  return ge.zero();
}
function vt() {
  return vt.zero();
}
function Mn() {
  return Mn.zero();
}
function Tw(e, t) {
  return e - t;
}
function fi(e, t) {
  e === void 0 && (e = 0), t === void 0 && (t = Number.MAX_SAFE_INTEGER);
  var n = e;
  return function() {
    var r = n;
    return n = (n + 1) % t, r;
  };
}
(function(e) {
  function t() {
    var f = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return f[0] = 0, f;
  }
  function n() {
    var f = t();
    return f[0] = 1, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = 1, f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = 1, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }
  function r(f) {
    return f[0] = 1, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = 1, f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = 1, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }
  function i(f) {
    for (var y = 0; y < 16; y++) f[y] = 0;
    return f;
  }
  e.zero = t, e.identity = n, e.setIdentity = r, e.setZero = i, e.ofRows = function(f) {
    for (var y = t(), h = 0; h < 4; h++) for (var g = f[h], x = 0; x < 4; x++) y[4 * x + h] = g[x];
    return y;
  };
  var a = n();
  function o(f, y, h) {
    for (var g = 0; g < 16; g++) if (Math.abs(f[g] - y[g]) > h) return !1;
    return !0;
  }
  function s(f, y, h, g) {
    f[4 * h + y] = g;
  }
  function u(f, y) {
    return f[0] = y[0], f[1] = y[1], f[2] = y[2], f[3] = y[3], f[4] = y[4], f[5] = y[5], f[6] = y[6], f[7] = y[7], f[8] = y[8], f[9] = y[9], f[10] = y[10], f[11] = y[11], f[12] = y[12], f[13] = y[13], f[14] = y[14], f[15] = y[15], f;
  }
  function c(f, y) {
    var h = y[0], g = y[1], x = y[2], C = y[3], b = y[4], _ = y[5], A = y[6], I = y[7], w = y[8], E = y[9], D = y[10], T = y[11], P = y[12], M = y[13], R = y[14], O = y[15], L = h * _ - g * b, F = h * A - x * b, G = h * I - C * b, V = g * A - x * _, U = g * I - C * _, q = x * I - C * A, H = w * M - E * P, K = w * R - D * P, j = w * O - T * P, W = E * R - D * M, Z = E * O - T * M, Y = D * O - T * R, te = L * Y - F * Z + G * W + V * j - U * K + q * H;
    return !!te && (te = 1 / te, f[0] = (_ * Y - A * Z + I * W) * te, f[1] = (x * Z - g * Y - C * W) * te, f[2] = (M * q - R * U + O * V) * te, f[3] = (D * U - E * q - T * V) * te, f[4] = (A * j - b * Y - I * K) * te, f[5] = (h * Y - x * j + C * K) * te, f[6] = (R * G - P * q - O * F) * te, f[7] = (w * q - D * G + T * F) * te, f[8] = (b * Z - _ * j + I * H) * te, f[9] = (g * j - h * Z - C * H) * te, f[10] = (P * U - M * G + O * L) * te, f[11] = (E * G - w * U - T * L) * te, f[12] = (_ * K - b * W - A * H) * te, f[13] = (h * W - g * K + x * H) * te, f[14] = (M * F - P * V - R * L) * te, f[15] = (w * V - E * F + D * L) * te, !0);
  }
  function l(f, y, h) {
    var g = y[0], x = y[1], C = y[2], b = y[3], _ = y[4], A = y[5], I = y[6], w = y[7], E = y[8], D = y[9], T = y[10], P = y[11], M = y[12], R = y[13], O = y[14], L = y[15], F = h[0], G = h[1], V = h[2], U = h[3];
    return f[0] = F * g + G * _ + V * E + U * M, f[1] = F * x + G * A + V * D + U * R, f[2] = F * C + G * I + V * T + U * O, f[3] = F * b + G * w + V * P + U * L, F = h[4], G = h[5], V = h[6], U = h[7], f[4] = F * g + G * _ + V * E + U * M, f[5] = F * x + G * A + V * D + U * R, f[6] = F * C + G * I + V * T + U * O, f[7] = F * b + G * w + V * P + U * L, F = h[8], G = h[9], V = h[10], U = h[11], f[8] = F * g + G * _ + V * E + U * M, f[9] = F * x + G * A + V * D + U * R, f[10] = F * C + G * I + V * T + U * O, f[11] = F * b + G * w + V * P + U * L, F = h[12], G = h[13], V = h[14], U = h[15], f[12] = F * g + G * _ + V * E + U * M, f[13] = F * x + G * A + V * D + U * R, f[14] = F * C + G * I + V * T + U * O, f[15] = F * b + G * w + V * P + U * L, f;
  }
  function d(f, y, h) {
    var g = h[0], x = h[1], C = h[2], b = Math.sqrt(g * g + x * x + C * C);
    if (Math.abs(b) < bn) return r(f);
    g *= b = 1 / b, x *= b, C *= b;
    var _ = Math.sin(y), A = Math.cos(y), I = 1 - A;
    return f[0] = g * g * I + A, f[1] = x * g * I + C * _, f[2] = C * g * I - x * _, f[3] = 0, f[4] = g * x * I - C * _, f[5] = x * x * I + A, f[6] = C * x * I + g * _, f[7] = 0, f[8] = g * C * I + x * _, f[9] = x * C * I - g * _, f[10] = C * C * I + A, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }
  e.isIdentity = function(f, y) {
    return o(f, a, y === void 0 ? bn : y);
  }, e.hasNaN = function(f) {
    for (var y = 0; y < 16; y++) if (isNaN(f[y])) return !0;
    return !1;
  }, e.areEqual = o, e.setValue = s, e.getValue = function(f, y, h) {
    return f[4 * h + y];
  }, e.toArray = function(f, y, h) {
    return y[h + 0] = f[0], y[h + 1] = f[1], y[h + 2] = f[2], y[h + 3] = f[3], y[h + 4] = f[4], y[h + 5] = f[5], y[h + 6] = f[6], y[h + 7] = f[7], y[h + 8] = f[8], y[h + 9] = f[9], y[h + 10] = f[10], y[h + 11] = f[11], y[h + 12] = f[12], y[h + 13] = f[13], y[h + 14] = f[14], y[h + 15] = f[15], y;
  }, e.fromArray = function(f, y, h) {
    return f[0] = y[h + 0], f[1] = y[h + 1], f[2] = y[h + 2], f[3] = y[h + 3], f[4] = y[h + 4], f[5] = y[h + 5], f[6] = y[h + 6], f[7] = y[h + 7], f[8] = y[h + 8], f[9] = y[h + 9], f[10] = y[h + 10], f[11] = y[h + 11], f[12] = y[h + 12], f[13] = y[h + 13], f[14] = y[h + 14], f[15] = y[h + 15], f;
  }, e.fromBasis = function(f, y, h, g) {
    return i(f), s(f, 0, 0, y[0]), s(f, 1, 0, y[1]), s(f, 2, 0, y[2]), s(f, 0, 1, h[0]), s(f, 1, 1, h[1]), s(f, 2, 1, h[2]), s(f, 0, 2, g[0]), s(f, 1, 2, g[1]), s(f, 2, 2, g[2]), s(f, 3, 3, 1), f;
  }, e.copy = u, e.clone = function(f) {
    return u(t(), f);
  }, e.getTranslation = function(f, y) {
    return f[0] = y[12], f[1] = y[13], f[2] = y[14], f;
  }, e.getScaling = function(f, y) {
    var h = y[0], g = y[1], x = y[2], C = y[4], b = y[5], _ = y[6], A = y[8], I = y[9], w = y[10];
    return f[0] = Math.sqrt(h * h + g * g + x * x), f[1] = Math.sqrt(C * C + b * b + _ * _), f[2] = Math.sqrt(A * A + I * I + w * w), f;
  }, e.getRotation = function(f, y) {
    var h = y[0] + y[5] + y[10], g = 0;
    return h > 0 ? (g = 2 * Math.sqrt(h + 1), f[3] = 0.25 * g, f[0] = (y[6] - y[9]) / g, f[1] = (y[8] - y[2]) / g, f[2] = (y[1] - y[4]) / g) : y[0] > y[5] && y[0] > y[10] ? (g = 2 * Math.sqrt(1 + y[0] - y[5] - y[10]), f[3] = (y[6] - y[9]) / g, f[0] = 0.25 * g, f[1] = (y[1] + y[4]) / g, f[2] = (y[8] + y[2]) / g) : y[5] > y[10] ? (g = 2 * Math.sqrt(1 + y[5] - y[0] - y[10]), f[3] = (y[8] - y[2]) / g, f[0] = (y[1] + y[4]) / g, f[1] = 0.25 * g, f[2] = (y[6] + y[9]) / g) : (g = 2 * Math.sqrt(1 + y[10] - y[0] - y[5]), f[3] = (y[1] - y[4]) / g, f[0] = (y[8] + y[2]) / g, f[1] = (y[6] + y[9]) / g, f[2] = 0.25 * g), f;
  }, e.extractRotation = function(f, y) {
    var h = 1 / Math.sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]), g = 1 / Math.sqrt(y[4] * y[4] + y[5] * y[5] + y[6] * y[6]), x = 1 / Math.sqrt(y[8] * y[8] + y[9] * y[9] + y[10] * y[10]);
    return f[0] = y[0] * h, f[1] = y[1] * h, f[2] = y[2] * h, f[3] = 0, f[4] = y[4] * g, f[5] = y[5] * g, f[6] = y[6] * g, f[7] = 0, f[8] = y[8] * x, f[9] = y[9] * x, f[10] = y[10] * x, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }, e.transpose = function(f, y) {
    if (f === y) {
      var h = y[1], g = y[2], x = y[3], C = y[6], b = y[7], _ = y[11];
      f[1] = y[4], f[2] = y[8], f[3] = y[12], f[4] = h, f[6] = y[9], f[7] = y[13], f[8] = g, f[9] = C, f[11] = y[14], f[12] = x, f[13] = b, f[14] = _;
    } else f[0] = y[0], f[1] = y[4], f[2] = y[8], f[3] = y[12], f[4] = y[1], f[5] = y[5], f[6] = y[9], f[7] = y[13], f[8] = y[2], f[9] = y[6], f[10] = y[10], f[11] = y[14], f[12] = y[3], f[13] = y[7], f[14] = y[11], f[15] = y[15];
    return f;
  }, e.tryInvert = c, e.invert = function(f, y) {
    return c(f, y) || console.warn("non-invertible matrix.", y), f;
  }, e.mul = l, e.mulOffset = function(f, y, h, g, x, C) {
    var b = y[0 + x], _ = y[1 + x], A = y[2 + x], I = y[3 + x], w = y[4 + x], E = y[5 + x], D = y[6 + x], T = y[7 + x], P = y[8 + x], M = y[9 + x], R = y[10 + x], O = y[11 + x], L = y[12 + x], F = y[13 + x], G = y[14 + x], V = y[15 + x], U = h[0 + C], q = h[1 + C], H = h[2 + C], K = h[3 + C];
    return f[0 + g] = U * b + q * w + H * P + K * L, f[1 + g] = U * _ + q * E + H * M + K * F, f[2 + g] = U * A + q * D + H * R + K * G, f[3 + g] = U * I + q * T + H * O + K * V, U = h[4 + C], q = h[5 + C], H = h[6 + C], K = h[7 + C], f[4 + g] = U * b + q * w + H * P + K * L, f[5 + g] = U * _ + q * E + H * M + K * F, f[6 + g] = U * A + q * D + H * R + K * G, f[7 + g] = U * I + q * T + H * O + K * V, U = h[8 + C], q = h[9 + C], H = h[10 + C], K = h[11 + C], f[8 + g] = U * b + q * w + H * P + K * L, f[9 + g] = U * _ + q * E + H * M + K * F, f[10 + g] = U * A + q * D + H * R + K * G, f[11 + g] = U * I + q * T + H * O + K * V, U = h[12 + C], q = h[13 + C], H = h[14 + C], K = h[15 + C], f[12 + g] = U * b + q * w + H * P + K * L, f[13 + g] = U * _ + q * E + H * M + K * F, f[14 + g] = U * A + q * D + H * R + K * G, f[15 + g] = U * I + q * T + H * O + K * V, f;
  }, e.mul3 = function(f, y, h, g) {
    return l(f, l(f, y, h), g);
  }, e.translate = function(f, y, h) {
    var g, x, C, b, _, A, I, w, E, D, T, P, M = h[0], R = h[1], O = h[2];
    return y === f ? (f[12] = y[0] * M + y[4] * R + y[8] * O + y[12], f[13] = y[1] * M + y[5] * R + y[9] * O + y[13], f[14] = y[2] * M + y[6] * R + y[10] * O + y[14], f[15] = y[3] * M + y[7] * R + y[11] * O + y[15]) : (g = y[0], x = y[1], C = y[2], b = y[3], _ = y[4], A = y[5], I = y[6], w = y[7], E = y[8], D = y[9], T = y[10], P = y[11], f[0] = g, f[1] = x, f[2] = C, f[3] = b, f[4] = _, f[5] = A, f[6] = I, f[7] = w, f[8] = E, f[9] = D, f[10] = T, f[11] = P, f[12] = g * M + _ * R + E * O + y[12], f[13] = x * M + A * R + D * O + y[13], f[14] = C * M + I * R + T * O + y[14], f[15] = b * M + w * R + P * O + y[15]), f;
  }, e.fromTranslation = function(f, y) {
    return f[0] = 1, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = 1, f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = 1, f[11] = 0, f[12] = y[0], f[13] = y[1], f[14] = y[2], f[15] = 1, f;
  }, e.setTranslation = function(f, y) {
    return f[12] = y[0], f[13] = y[1], f[14] = y[2], f;
  }, e.setAxes = function(f, y, h, g) {
    return f[0] = h[0], f[4] = h[1], f[8] = h[2], f[1] = g[0], f[5] = g[1], f[9] = g[2], f[2] = y[0], f[6] = y[1], f[10] = y[2], f;
  }, e.rotate = function(f, y, h, g) {
    var x = g[0], C = g[1], b = g[2], _ = Math.sqrt(x * x + C * C + b * b);
    if (Math.abs(_) < bn) return n();
    x *= _ = 1 / _, C *= _, b *= _;
    var A = Math.sin(h), I = Math.cos(h), w = 1 - I, E = y[0], D = y[1], T = y[2], P = y[3], M = y[4], R = y[5], O = y[6], L = y[7], F = y[8], G = y[9], V = y[10], U = y[11], q = x * x * w + I, H = C * x * w + b * A, K = b * x * w - C * A, j = x * C * w - b * A, W = C * C * w + I, Z = b * C * w + x * A, Y = x * b * w + C * A, te = C * b * w - x * A, ee = b * b * w + I;
    return f[0] = E * q + M * H + F * K, f[1] = D * q + R * H + G * K, f[2] = T * q + O * H + V * K, f[3] = P * q + L * H + U * K, f[4] = E * j + M * W + F * Z, f[5] = D * j + R * W + G * Z, f[6] = T * j + O * W + V * Z, f[7] = P * j + L * W + U * Z, f[8] = E * Y + M * te + F * ee, f[9] = D * Y + R * te + G * ee, f[10] = T * Y + O * te + V * ee, f[11] = P * Y + L * te + U * ee, y !== f && (f[12] = y[12], f[13] = y[13], f[14] = y[14], f[15] = y[15]), f;
  }, e.fromRotation = d, e.scale = function(f, y, h) {
    var g = h[0], x = h[1], C = h[2];
    return f[0] = y[0] * g, f[1] = y[1] * g, f[2] = y[2] * g, f[3] = y[3] * g, f[4] = y[4] * x, f[5] = y[5] * x, f[6] = y[6] * x, f[7] = y[7] * x, f[8] = y[8] * C, f[9] = y[9] * C, f[10] = y[10] * C, f[11] = y[11] * C, f[12] = y[12], f[13] = y[13], f[14] = y[14], f[15] = y[15], f;
  }, e.scaleUniformly = function(f, y, h) {
    return f[0] = y[0] * h, f[1] = y[1] * h, f[2] = y[2] * h, f[3] = y[3] * h, f[4] = y[4] * h, f[5] = y[5] * h, f[6] = y[6] * h, f[7] = y[7] * h, f[8] = y[8] * h, f[9] = y[9] * h, f[10] = y[10] * h, f[11] = y[11] * h, f[12] = y[12], f[13] = y[13], f[14] = y[14], f[15] = y[15], f;
  }, e.fromScaling = function(f, y) {
    return f[0] = y[0], f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = y[1], f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = y[2], f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }, e.fromUniformScaling = function(f, y) {
    return f[0] = y, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = y, f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = y, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }, e.fromMat3 = function(f, y) {
    return f[0] = y[0], f[1] = y[1], f[2] = y[2], f[4] = y[3], f[5] = y[4], f[6] = y[5], f[8] = y[6], f[9] = y[7], f[10] = y[8], f;
  }, e.makeTable = function(f) {
    for (var y = "", h = 0; h < 4; h++) {
      for (var g = 0; g < 4; g++) y += f[4 * g + h].toString(), g < 3 && (y += " ");
      h < 3 && (y += `
`);
    }
    return y;
  }, e.determinant = function(f) {
    var y = f[0], h = f[1], g = f[2], x = f[3], C = f[4], b = f[5], _ = f[6], A = f[7], I = f[8], w = f[9], E = f[10], D = f[11], T = f[12], P = f[13], M = f[14], R = f[15];
    return (y * b - h * C) * (E * R - D * M) - (y * _ - g * C) * (w * R - D * P) + (y * A - x * C) * (w * M - E * P) + (h * _ - g * b) * (I * R - D * T) - (h * A - x * b) * (I * M - E * T) + (g * A - x * _) * (I * P - w * T);
  }, e.isRotationAndTranslation = function(f, y) {
    return function(h, g) {
      var x = h[0], C = h[1], b = h[2], _ = h[3], A = h[4], I = h[5], w = h[6], E = h[7], D = h[8], T = h[9], P = h[10], M = h[11], R = h[15];
      return !(!(On(R, 1, g) && On(_, 0, g) && On(E, 0, g) && On(M, 0, g)) || !On(Math.abs(x * (I * P - w * T) - C * (A * P - w * D) + b * (A * T - I * D)), 1, g));
    }(f, y !== void 0 ? y : bn);
  }, e.isTranslationAndUniformScaling = function(f, y) {
    return function(h, g) {
      var x = h[0];
      return On(h[1], 0, g) && On(h[2], 0, g) && On(h[3], 0, g) && On(h[4], 0, g) && On(h[5], x, g) && On(h[6], 0, g) && On(h[7], 0, g) && On(h[8], 0, g) && On(h[9], 0, g) && On(h[10], x, g) && On(h[11], 0, g) && On(h[15], 1, g);
    }(f, y !== void 0 ? y : bn);
  }, e.fromQuat = function(f, y) {
    var h = y[0], g = y[1], x = y[2], C = y[3], b = h + h, _ = g + g, A = x + x, I = h * b, w = g * b, E = g * _, D = x * b, T = x * _, P = x * A, M = C * b, R = C * _, O = C * A;
    return f[0] = 1 - E - P, f[1] = w + O, f[2] = D - R, f[3] = 0, f[4] = w - O, f[5] = 1 - I - P, f[6] = T + M, f[7] = 0, f[8] = D + R, f[9] = T - M, f[10] = 1 - I - E, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, f;
  }, e.perspective = function(f, y, h, g, x, C, b) {
    var _ = 2 * C / (h - y), A = 2 * C / (g - x), I = (h + y) / (h - y), w = (g + x) / (g - x), E = -(b + C) / (b - C), D = -2 * b * C / (b - C);
    return f[0] = _, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = A, f[6] = 0, f[7] = 0, f[8] = I, f[9] = w, f[10] = E, f[11] = -1, f[12] = 0, f[13] = 0, f[14] = D, f[15] = 0, f;
  }, e.ortho = function(f, y, h, g, x, C, b) {
    var _ = 1 / (h - y), A = 1 / (g - x), I = 1 / (b - C), w = (h + y) * _, E = (g + x) * A, D = (b + C) * I;
    return f[0] = 2 * _, f[1] = 0, f[2] = 0, f[3] = 0, f[4] = 0, f[5] = 2 * A, f[6] = 0, f[7] = 0, f[8] = 0, f[9] = 0, f[10] = -2 * I, f[11] = 0, f[12] = -w, f[13] = -E, f[14] = -D, f[15] = 1, f;
  }, e.lookAt = function(f, y, h, g) {
    var x, C, b, _, A, I, w, E, D, T, P = y[0], M = y[1], R = y[2], O = g[0], L = g[1], F = g[2], G = h[0], V = h[1], U = h[2];
    return Math.abs(P - G) < bn && Math.abs(M - V) < bn && Math.abs(R - U) < bn ? r(f) : (w = P - G, E = M - V, D = R - U, x = L * (D *= T = 1 / Math.sqrt(w * w + E * E + D * D)) - F * (E *= T), C = F * (w *= T) - O * D, b = O * E - L * w, (T = Math.sqrt(x * x + C * C + b * b)) ? (x *= T = 1 / T, C *= T, b *= T) : (x = 0, C = 0, b = 0), _ = E * b - D * C, A = D * x - w * b, I = w * C - E * x, (T = Math.sqrt(_ * _ + A * A + I * I)) ? (_ *= T = 1 / T, A *= T, I *= T) : (_ = 0, A = 0, I = 0), f[0] = x, f[1] = _, f[2] = w, f[3] = 0, f[4] = C, f[5] = A, f[6] = E, f[7] = 0, f[8] = b, f[9] = I, f[10] = D, f[11] = 0, f[12] = -(x * P + C * M + b * R), f[13] = -(_ * P + A * M + I * R), f[14] = -(w * P + E * M + D * R), f[15] = 1, f);
  }, e.targetTo = function(f, y, h, g) {
    var x = y[0], C = y[1], b = y[2], _ = g[0], A = g[1], I = g[2], w = x - h[0], E = C - h[1], D = b - h[2], T = w * w + E * E + D * D;
    T > 0 && (w *= T = 1 / Math.sqrt(T), E *= T, D *= T);
    var P = A * D - I * E, M = I * w - _ * D, R = _ * E - A * w;
    return (T = P * P + M * M + R * R) > 0 && (P *= T = 1 / Math.sqrt(T), M *= T, R *= T), f[0] = P, f[1] = M, f[2] = R, f[3] = 0, f[4] = E * R - D * M, f[5] = D * P - w * R, f[6] = w * M - E * P, f[7] = 0, f[8] = w, f[9] = E, f[10] = D, f[11] = 0, f[12] = x, f[13] = C, f[14] = b, f[15] = 1, f;
  }, e.fromPermutation = function(f, y) {
    i(f);
    for (var h = 0; h < 4; h++)
      s(f, h, y[h], 1);
    return f;
  }, e.getMaxScaleOnAxis = function(f) {
    var y = f[0] * f[0] + f[1] * f[1] + f[2] * f[2], h = f[4] * f[4] + f[5] * f[5] + f[6] * f[6], g = f[8] * f[8] + f[9] * f[9] + f[10] * f[10];
    return Math.sqrt(Math.max(y, h, g));
  };
  var m = [1, 0, 0], p = [0, 1, 0], v = [0, 0, 1];
  e.rotX90 = d(t(), Bn(90), m), e.rotX180 = d(t(), Bn(180), m), e.rotY90 = d(t(), Bn(90), p), e.rotY180 = d(t(), Bn(180), p), e.rotY270 = d(t(), Bn(270), p), e.rotZ90 = d(t(), Bn(90), v), e.rotZ180 = d(t(), Bn(180), v), 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 = n();
})(J || (J = {})), function(e) {
  function t() {
    var T = [0.1, 0, 0];
    return T[0] = 0, T;
  }
  function n(T, P, M) {
    var R = t();
    return R[0] = T, R[1] = P, R[2] = M, R;
  }
  function r(T, P) {
    return T[0] = P[0], T[1] = P[1], T[2] = P[2], T;
  }
  function i(T, P, M) {
    return T[0] = P[0] + M[0], T[1] = P[1] + M[1], T[2] = P[2] + M[2], T;
  }
  function a(T, P, M) {
    return T[0] = P[0] - M[0], T[1] = P[1] - M[1], T[2] = P[2] - M[2], T;
  }
  function o(T, P, M) {
    return T[0] = P[0] * M, T[1] = P[1] * M, T[2] = P[2] * M, T;
  }
  function s(T, P, M, R) {
    return T[0] = P[0] + M[0] * R, T[1] = P[1] + M[1] * R, T[2] = P[2] + M[2] * R, T;
  }
  function u(T) {
    var P = T[0], M = T[1], R = T[2];
    return P * P + M * M + R * R;
  }
  function c(T, P) {
    return T[0] = -P[0], T[1] = -P[1], T[2] = -P[2], T;
  }
  function l(T, P) {
    var M = P[0], R = P[1], O = P[2], L = M * M + R * R + O * O;
    return L > 0 && (L = 1 / Math.sqrt(L), T[0] = P[0] * L, T[1] = P[1] * L, T[2] = P[2] * L), T;
  }
  function d(T, P) {
    return T[0] * P[0] + T[1] * P[1] + T[2] * P[2];
  }
  function m(T, P, M) {
    var R = P[0], O = P[1], L = P[2], F = M[0], G = M[1], V = M[2];
    return T[0] = O * V - L * G, T[1] = L * F - R * V, T[2] = R * G - O * F, T;
  }
  e.zero = t, e.clone = function(T) {
    var P = t();
    return P[0] = T[0], P[1] = T[1], P[2] = T[2], P;
  }, e.hasNaN = function(T) {
    return isNaN(T[0]) || isNaN(T[1]) || isNaN(T[2]);
  }, e.setNaN = function(T) {
    return T[0] = NaN, T[1] = NaN, T[2] = NaN, T;
  }, e.fromObj = function(T) {
    return n(T.x, T.y, T.z);
  }, e.toObj = function(T) {
    return { x: T[0], y: T[1], z: T[2] };
  }, e.fromArray = function(T, P, M) {
    return T[0] = P[M + 0], T[1] = P[M + 1], T[2] = P[M + 2], T;
  }, e.toArray = function(T, P, M) {
    return P[M + 0] = T[0], P[M + 1] = T[1], P[M + 2] = T[2], P;
  }, e.create = n, e.ofArray = function(T) {
    var P = t();
    return P[0] = T[0], P[1] = T[1], P[2] = T[2], P;
  }, e.set = function(T, P, M, R) {
    return T[0] = P, T[1] = M, T[2] = R, T;
  }, e.copy = r, e.add = i, e.sub = a, e.mul = function(T, P, M) {
    return T[0] = P[0] * M[0], T[1] = P[1] * M[1], T[2] = P[2] * M[2], T;
  }, e.div = function(T, P, M) {
    return T[0] = P[0] / M[0], T[1] = P[1] / M[1], T[2] = P[2] / M[2], T;
  }, e.scale = o, e.scaleAndAdd = s, e.scaleAndSub = function(T, P, M, R) {
    return T[0] = P[0] - M[0] * R, T[1] = P[1] - M[1] * R, T[2] = P[2] - M[2] * R, T;
  }, e.addScalar = function(T, P, M) {
    return T[0] = P[0] + M, T[1] = P[1] + M, T[2] = P[2] + M, T;
  }, e.subScalar = function(T, P, M) {
    return T[0] = P[0] - M, T[1] = P[1] - M, T[2] = P[2] - M, T;
  }, e.round = function(T, P) {
    return T[0] = Math.round(P[0]), T[1] = Math.round(P[1]), T[2] = Math.round(P[2]), T;
  }, e.ceil = function(T, P) {
    return T[0] = Math.ceil(P[0]), T[1] = Math.ceil(P[1]), T[2] = Math.ceil(P[2]), T;
  }, e.floor = function(T, P) {
    return T[0] = Math.floor(P[0]), T[1] = Math.floor(P[1]), T[2] = Math.floor(P[2]), T;
  }, e.trunc = function(T, P) {
    return T[0] = Math.trunc(P[0]), T[1] = Math.trunc(P[1]), T[2] = Math.trunc(P[2]), T;
  }, e.abs = function(T, P) {
    return T[0] = Math.abs(P[0]), T[1] = Math.abs(P[1]), T[2] = Math.abs(P[2]), T;
  }, e.min = function(T, P, M) {
    return T[0] = Math.min(P[0], M[0]), T[1] = Math.min(P[1], M[1]), T[2] = Math.min(P[2], M[2]), T;
  }, e.max = function(T, P, M) {
    return T[0] = Math.max(P[0], M[0]), T[1] = Math.max(P[1], M[1]), T[2] = Math.max(P[2], M[2]), T;
  }, e.distance = function(T, P) {
    var M = P[0] - T[0], R = P[1] - T[1], O = P[2] - T[2];
    return Math.sqrt(M * M + R * R + O * O);
  }, e.squaredDistance = function(T, P) {
    var M = P[0] - T[0], R = P[1] - T[1], O = P[2] - T[2];
    return M * M + R * R + O * O;
  }, e.magnitude = function(T) {
    var P = T[0], M = T[1], R = T[2];
    return Math.sqrt(P * P + M * M + R * R);
  }, e.squaredMagnitude = u, e.setMagnitude = function(T, P, M) {
    return o(T, l(T, P), M);
  }, e.negate = c, e.inverse = function(T, P) {
    return T[0] = 1 / P[0], T[1] = 1 / P[1], T[2] = 1 / P[2], T;
  }, e.normalize = l, e.dot = d, e.cross = m, e.lerp = function(T, P, M, R) {
    var O = P[0], L = P[1], F = P[2];
    return T[0] = O + R * (M[0] - O), T[1] = L + R * (M[1] - L), T[2] = F + R * (M[2] - F), T;
  };
  var p = t();
  function v(T, P) {
    var M = Math.sqrt(u(T) * u(P));
    if (M === 0) return Math.PI / 2;
    var R = d(T, P) / M;
    return Math.acos(xi(R, -1, 1));
  }
  e.slerp = function(T, P, M, R) {
    var O = xi(d(P, M), -1, 1), L = Math.acos(O) * R;
    return s(p, M, P, -O), l(p, p), i(T, o(T, P, Math.cos(L)), o(p, p, Math.sin(L)));
  }, e.hermite = function(T, P, M, R, O, L) {
    var F = L * L, G = F * (2 * L - 3) + 1, V = F * (L - 2) + L, U = F * (L - 1), q = F * (3 - 2 * L);
    return T[0] = P[0] * G + M[0] * V + R[0] * U + O[0] * q, T[1] = P[1] * G + M[1] * V + R[1] * U + O[1] * q, T[2] = P[2] * G + M[2] * V + R[2] * U + O[2] * q, T;
  }, e.bezier = function(T, P, M, R, O, L) {
    var F = 1 - L, G = F * F, V = L * L, U = G * F, q = 3 * L * G, H = 3 * V * F, K = V * L;
    return T[0] = P[0] * U + M[0] * q + R[0] * H + O[0] * K, T[1] = P[1] * U + M[1] * q + R[1] * H + O[1] * K, T[2] = P[2] * U + M[2] * q + R[2] * H + O[2] * K, T;
  }, e.quadraticBezier = function(T, P, M, R, O) {
    return T[0] = rp(P[0], M[0], R[0], O), T[1] = rp(P[1], M[1], R[1], O), T[2] = rp(P[2], M[2], R[2], O), T;
  }, e.spline = function(T, P, M, R, O, L, F) {
    return T[0] = pm(P[0], M[0], R[0], O[0], L, F), T[1] = pm(P[1], M[1], R[1], O[1], L, F), T[2] = pm(P[2], M[2], R[2], O[2], L, F), T;
  }, e.random = function(T, P) {
    var M = 2 * Math.random() * Math.PI, R = 2 * Math.random() - 1, O = Math.sqrt(1 - R * R) * P;
    return T[0] = Math.cos(M) * O, T[1] = Math.sin(M) * O, T[2] = R * P, T;
  }, e.transformMat4 = function(T, P, M) {
    var R = P[0], O = P[1], L = P[2], F = 1 / (M[3] * R + M[7] * O + M[11] * L + M[15] || 1);
    return T[0] = (M[0] * R + M[4] * O + M[8] * L + M[12]) * F, T[1] = (M[1] * R + M[5] * O + M[9] * L + M[13]) * F, T[2] = (M[2] * R + M[6] * O + M[10] * L + M[14]) * F, T;
  }, e.transformMat4Offset = function(T, P, M, R, O, L) {
    var F = P[0 + O], G = P[1 + O], V = P[2 + O], U = 1 / (M[3 + L] * F + M[7 + L] * G + M[11 + L] * V + M[15 + L] || 1);
    return T[0 + R] = (M[0 + L] * F + M[4 + L] * G + M[8 + L] * V + M[12 + L]) * U, T[1 + R] = (M[1 + L] * F + M[5 + L] * G + M[9 + L] * V + M[13 + L]) * U, T[2 + R] = (M[2 + L] * F + M[6 + L] * G + M[10 + L] * V + M[14 + L]) * U, T;
  }, e.transformMat3 = function(T, P, M) {
    var R = P[0], O = P[1], L = P[2];
    return T[0] = R * M[0] + O * M[3] + L * M[6], T[1] = R * M[1] + O * M[4] + L * M[7], T[2] = R * M[2] + O * M[5] + L * M[8], T;
  }, e.transformQuat = function(T, P, M) {
    var R = P[0], O = P[1], L = P[2], F = M[0], G = M[1], V = M[2], U = M[3], q = U * R + G * L - V * O, H = U * O + V * R - F * L, K = U * L + F * O - G * R, j = -F * R - G * O - V * L;
    return T[0] = q * U + j * -F + H * -V - K * -G, T[1] = H * U + j * -G + K * -F - q * -V, T[2] = K * U + j * -V + q * -G - H * -F, T;
  }, e.angle = v;
  var f = t(), y = t(), h = t(), g = t(), x = t(), C = t(), b = t();
  e.dihedralAngle = function(T, P, M, R) {
    a(f, T, P), a(y, M, P), a(h, P, M), a(g, R, M), m(x, f, y), m(C, h, g);
    var O = v(x, C);
    return m(b, x, C), d(y, b) > 0 ? O : -O;
  }, e.directionFromSpherical = function(T, P, M, R) {
    return e.set(T, R * Math.cos(M) * Math.sin(P), R * Math.sin(M) * Math.sin(P), R * Math.cos(P));
  }, e.exactEquals = function(T, P) {
    return T[0] === P[0] && T[1] === P[1] && T[2] === P[2];
  }, e.equals = function(T, P) {
    var M = T[0], R = T[1], O = T[2], L = P[0], F = P[1], G = P[2];
    return Math.abs(M - L) <= bn * Math.max(1, Math.abs(M), Math.abs(L)) && Math.abs(R - F) <= bn * Math.max(1, Math.abs(R), Math.abs(F)) && Math.abs(O - G) <= bn * Math.max(1, Math.abs(O), Math.abs(G));
  };
  var _ = t();
  e.makeRotation = function(T, P, M) {
    var R = v(P, M);
    if (Math.abs(R) < 1e-4) return J.setIdentity(T);
    if (Math.abs(R - Math.PI) < bn) return J.fromScaling(T, e.negUnit);
    var O = m(_, P, M);
    return J.fromRotation(T, R, O);
  }, e.isZero = function(T) {
    return T[0] === 0 && T[1] === 0 && T[2] === 0;
  }, e.projectPointOnVector = function(T, P, M, R) {
    return a(T, P, R), i(T, o(T, M, d(M, T) / u(M)), R);
  };
  var A = t();
  function I(T, P, M) {
    return o(T, M, d(M, P) / u(M));
  }
  e.projectPointOnPlane = function(T, P, M, R) {
    return l(A, M), a(T, P, R), a(T, P, o(A, A, d(T, A)));
  }, e.projectOnVector = I;
  var w = t();
  e.projectOnPlane = function(T, P, M) {
    return I(w, P, M), a(T, P, w);
  }, e.orthogonalize = function(T, P, M) {
    return l(T, m(T, m(T, P, M), P));
  }, e.matchDirection = function(T, P, M) {
    return d(P, M) > 0 ? r(T, P) : c(T, r(T, P)), T;
  };
  var E = t(), D = t();
  e.triangleNormal = function(T, P, M, R) {
    return a(E, M, P), a(D, R, P), l(T, m(T, E, D));
  }, e.toString = function(T, P) {
    return "[".concat(T[0].toPrecision(P), " ").concat(T[1].toPrecision(P), " ").concat(T[2].toPrecision(P), "]");
  }, e.origin = n(0, 0, 0), e.unit = n(1, 1, 1), e.negUnit = n(-1, -1, -1), e.unitX = n(1, 0, 0), e.unitY = n(0, 1, 0), e.unitZ = n(0, 0, 1), e.negUnitX = n(-1, 0, 0), e.negUnitY = n(0, -1, 0), e.negUnitZ = n(0, 0, -1);
}(S || (S = {})), function(e) {
  function t() {
    var b = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return b[0] = 0, b;
  }
  function n() {
    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 r(b, _) {
    return b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[4], b[4] = _[5], b[5] = _[6], b[6] = _[8], b[7] = _[9], b[8] = _[10], b;
  }
  e.zero = t, e.identity = n, 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, _, A) {
    return _[A + 0] = b[0], _[A + 1] = b[1], _[A + 2] = b[2], _[A + 3] = b[3], _[A + 4] = b[4], _[A + 5] = b[5], _[A + 6] = b[6], _[A + 7] = b[7], _[A + 8] = b[8], _;
  }, e.fromArray = function(b, _, A) {
    return b[0] = _[A + 0], b[1] = _[A + 1], b[2] = _[A + 2], b[3] = _[A + 3], b[4] = _[A + 4], b[5] = _[A + 5], b[6] = _[A + 6], b[7] = _[A + 7], b[8] = _[A + 8], b;
  }, e.fromMat4 = r, e.create = function(b, _, A, I, w, E, D, T, P) {
    var M = t();
    return M[0] = b, M[1] = _, M[2] = A, M[3] = I, M[4] = w, M[5] = E, M[6] = D, M[7] = T, M[8] = P, M;
  };
  var i = n();
  function a(b, _, A) {
    for (var I = 0; I < 9; I++) if (Math.abs(b[I] - _[I]) > A) return !1;
    return !0;
  }
  function o(b, _) {
    return b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[3], b[4] = _[4], b[5] = _[5], b[6] = _[6], b[7] = _[7], b[8] = _[8], b;
  }
  function s(b, _) {
    if (b === _) {
      var A = _[1], I = _[2], w = _[5];
      b[1] = _[3], b[2] = _[6], b[3] = A, b[5] = _[7], b[6] = I, b[7] = w;
    } else b[0] = _[0], b[1] = _[3], b[2] = _[6], b[3] = _[1], b[4] = _[4], b[5] = _[7], b[6] = _[2], b[7] = _[5], b[8] = _[8];
    return b;
  }
  function u(b, _) {
    var A = _[0], I = _[1], w = _[2], E = _[3], D = _[4], T = _[5], P = _[6], M = _[7], R = _[8], O = R * D - T * M, L = -R * E + T * P, F = M * E - D * P, G = A * O + I * L + w * F;
    return G ? (G = 1 / G, b[0] = O * G, b[1] = (-R * I + w * M) * G, b[2] = (T * I - w * D) * G, b[3] = L * G, b[4] = (R * A - w * P) * G, b[5] = (-T * A + w * E) * G, b[6] = F * G, b[7] = (-M * A + I * P) * G, b[8] = (D * A - I * E) * G, b) : (console.warn("non-invertible matrix.", _), b);
  }
  function c(b) {
    var _ = b[0], A = b[1], I = b[2], w = b[3], E = b[4], D = b[5], T = b[6], P = b[7], M = b[8];
    return _ * (M * E - D * P) + A * (-M * w + D * T) + I * (P * w - E * T);
  }
  function l(b) {
    return b[0] + b[4] + b[8];
  }
  function d(b, _, A) {
    return b[0] = _[0] - A[0], b[1] = _[1] - A[1], b[2] = _[2] - A[2], b[3] = _[3] - A[3], b[4] = _[4] - A[4], b[5] = _[5] - A[5], b[6] = _[6] - A[6], b[7] = _[7] - A[7], b[8] = _[8] - A[8], b;
  }
  function m(b, _, A) {
    return b[0] = _[0] * A, b[1] = _[1] * A, b[2] = _[2] * A, b[3] = _[3] * A, b[4] = _[4] * A, b[5] = _[5] * A, b[6] = _[6] * A, b[7] = _[7] * A, b[8] = _[8] * A, b;
  }
  e.isIdentity = function(b, _) {
    return a(b, i, _ === void 0 ? bn : _);
  }, e.hasNaN = function(b) {
    for (var _ = 0; _ < 9; _++) if (isNaN(b[_])) return !0;
    return !1;
  }, e.clone = function(b) {
    return o(t(), b);
  }, e.areEqual = a, e.setValue = function(b, _, A, I) {
    b[3 * A + _] = I;
  }, e.getValue = function(b, _, A) {
    return b[3 * A + _];
  }, e.copy = o, e.transpose = s, e.invert = u, e.symmtricFromUpper = function(b, _) {
    return b === _ ? (b[3] = _[1], b[6] = _[2], b[7] = _[5]) : (b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[1], b[4] = _[4], b[5] = _[5], b[6] = _[2], b[7] = _[5], b[8] = _[8]), b;
  }, e.symmtricFromLower = function(b, _) {
    return b === _ ? (b[1] = _[3], b[2] = _[6], b[5] = _[7]) : (b[0] = _[0], b[1] = _[3], b[2] = _[6], b[3] = _[3], b[4] = _[4], b[5] = _[7], b[6] = _[6], b[7] = _[7], b[8] = _[8]), b;
  }, e.determinant = c, e.trace = l, e.sub = d, e.add = function(b, _, A) {
    return b[0] = _[0] + A[0], b[1] = _[1] + A[1], b[2] = _[2] + A[2], b[3] = _[3] + A[3], b[4] = _[4] + A[4], b[5] = _[5] + A[5], b[6] = _[6] + A[6], b[7] = _[7] + A[7], b[8] = _[8] + A[8], b;
  }, e.mul = function(b, _, A) {
    var I = _[0], w = _[1], E = _[2], D = _[3], T = _[4], P = _[5], M = _[6], R = _[7], O = _[8], L = A[0], F = A[1], G = A[2], V = A[3], U = A[4], q = A[5], H = A[6], K = A[7], j = A[8];
    return b[0] = L * I + F * D + G * M, b[1] = L * w + F * T + G * R, b[2] = L * E + F * P + G * O, b[3] = V * I + U * D + q * M, b[4] = V * w + U * T + q * R, b[5] = V * E + U * P + q * O, b[6] = H * I + K * D + j * M, b[7] = H * w + K * T + j * R, b[8] = H * E + K * P + j * O, b;
  }, e.subScalar = function(b, _, A) {
    return b[0] = _[0] - A, b[1] = _[1] - A, b[2] = _[2] - A, b[3] = _[3] - A, b[4] = _[4] - A, b[5] = _[5] - A, b[6] = _[6] - A, b[7] = _[7] - A, b[8] = _[8] - A, b;
  }, e.addScalar = function(b, _, A) {
    return b[0] = _[0] + A, b[1] = _[1] + A, b[2] = _[2] + A, b[3] = _[3] + A, b[4] = _[4] + A, b[5] = _[5] + A, b[6] = _[6] + A, b[7] = _[7] + A, b[8] = _[8] + A, b;
  }, e.mulScalar = m;
  var p = Math.PI / 3, v = t();
  e.symmetricEigenvalues = function(b, _) {
    var A = _[1] * _[1] + _[2] * _[2] + _[5] * _[5];
    if (A === 0) b[0] = _[0], b[1] = _[4], b[2] = _[8];
    else {
      var I = l(_) / 3, w = _[0] - I, E = _[4] - I, D = _[8] - I, T = w * w + E * E + D * D + 2 * A, P = Math.sqrt(T / 6);
      m(v, e.Identity, I), d(v, _, v), m(v, v, 1 / P);
      var M = c(v) / 2, R = M <= -1 ? p : M >= 1 ? 0 : Math.acos(M) / 3;
      b[0] = I + 2 * P * Math.cos(R), b[2] = I + 2 * P * Math.cos(R + 2 * p), b[1] = 3 * I - b[0] - b[2];
    }
    return b;
  };
  var f = [0.1, 0, 0], y = [0.1, 0, 0], h = [0.1, 0, 0], g = [0.1, 0, 0], x = [0.1, 0, 0], C = [0.1, 0, 0];
  e.eigenvector = function(b, _, A) {
    S.set(f, _[0] - A, _[1], _[2]), S.set(y, _[1], _[4] - A, _[5]), S.set(h, _[2], _[5], _[8] - A), S.cross(g, f, y), S.cross(x, f, h), S.cross(C, y, h);
    var I = S.dot(g, g), w = S.dot(x, x), E = S.dot(C, C), D = I, T = 0;
    return w > D && (D = w, T = 1), E > D && (T = 2), T === 0 ? S.scale(b, g, 1 / Math.sqrt(I)) : T === 1 ? S.scale(b, x, 1 / Math.sqrt(w)) : S.scale(b, C, 1 / Math.sqrt(E)), b;
  }, e.directionTransform = function(b, _) {
    return r(b, _), u(b, b), s(b, b), b;
  }, e.Identity = n();
}(br || (br = {})), function(e) {
  function t() {
    var n = [0.1, 0];
    return n[0] = 0, n;
  }
  e.zero = t, e.clone = function(n) {
    var r = t();
    return r[0] = n[0], r[1] = n[1], r;
  }, e.create = function(n, r) {
    var i = t();
    return i[0] = n, i[1] = r, i;
  }, e.hasNaN = function(n) {
    return isNaN(n[0]) || isNaN(n[1]);
  }, e.toArray = function(n, r, i) {
    return r[i + 0] = n[0], r[i + 1] = n[1], r;
  }, e.fromArray = function(n, r, i) {
    return n[0] = r[i + 0], n[1] = r[i + 1], n;
  }, e.copy = function(n, r) {
    return n[0] = r[0], n[1] = r[1], n;
  }, e.set = function(n, r, i) {
    return n[0] = r, n[1] = i, n;
  }, e.add = function(n, r, i) {
    return n[0] = r[0] + i[0], n[1] = r[1] + i[1], n;
  }, e.sub = function(n, r, i) {
    return n[0] = r[0] - i[0], n[1] = r[1] - i[1], n;
  }, e.mul = function(n, r, i) {
    return n[0] = r[0] * i[0], n[1] = r[1] * i[1], n;
  }, e.div = function(n, r, i) {
    return n[0] = r[0] / i[0], n[1] = r[1] / i[1], n;
  }, e.scale = function(n, r, i) {
    return n[0] = r[0] * i, n[1] = r[1] * i, n;
  }, e.round = function(n, r) {
    return n[0] = Math.round(r[0]), n[1] = Math.round(r[1]), n;
  }, e.ceil = function(n, r) {
    return n[0] = Math.ceil(r[0]), n[1] = Math.ceil(r[1]), n;
  }, e.floor = function(n, r) {
    return n[0] = Math.floor(r[0]), n[1] = Math.floor(r[1]), n;
  }, e.distance = function(n, r) {
    var i = r[0] - n[0], a = r[1] - n[1];
    return Math.sqrt(i * i + a * a);
  }, e.squaredDistance = function(n, r) {
    var i = r[0] - n[0], a = r[1] - n[1];
    return i * i + a * a;
  }, e.magnitude = function(n) {
    var r = n[0], i = n[1];
    return Math.sqrt(r * r + i * i);
  }, e.squaredMagnitude = function(n) {
    var r = n[0], i = n[1];
    return r * r + i * i;
  }, e.inverse = function(n, r) {
    return n[0] = 1 / r[0], n[1] = 1 / r[1], n;
  }, e.areEqual = function(n, r) {
    return n[0] === r[0] && n[1] === r[1];
  }, e.toString = function(n, r) {
    return "[".concat(n[0].toPrecision(r), " ").concat(n[1].toPrecision(r), "}]");
  }, e.normalize = function(n, r) {
    var i = r[0], a = r[1], o = i * i + a * a;
    return o > 0 && (o = 1 / Math.sqrt(o), n[0] = r[0] * o, n[1] = r[1] * o), n;
  };
}(ge || (ge = {})), function(e) {
  function t() {
    var r = [0.1, 0, 0, 0];
    return r[0] = 0, r;
  }
  function n(r, i) {
    return r[0] = i.center[0], r[1] = i.center[1], r[2] = i.center[2], r[3] = i.radius, r;
  }
  e.zero = t, e.clone = function(r) {
    var i = t();
    return i[0] = r[0], i[1] = r[1], i[2] = r[2], i[3] = r[3], i;
  }, e.create = function(r, i, a, o) {
    var s = t();
    return s[0] = r, s[1] = i, s[2] = a, s[3] = o, s;
  }, e.fromSphere = n, e.ofSphere = function(r) {
    return n(t(), r);
  }, e.hasNaN = function(r) {
    return isNaN(r[0]) || isNaN(r[1]) || isNaN(r[2]) || isNaN(r[3]);
  }, e.toArray = function(r, i, a) {
    return i[a + 0] = r[0], i[a + 1] = r[1], i[a + 2] = r[2], i[a + 3] = r[3], i;
  }, e.fromArray = function(r, i, a) {
    return r[0] = i[a + 0], r[1] = i[a + 1], r[2] = i[a + 2], r[3] = i[a + 3], r;
  }, e.toVec3Array = function(r, i, a) {
    i[a + 0] = r[0], i[a + 1] = r[1], i[a + 2] = r[2];
  }, e.fromVec3Array = function(r, i, a) {
    return r[0] = i[a + 0], r[1] = i[a + 1], r[2] = i[a + 2], r[3] = 0, r;
  }, e.copy = function(r, i) {
    return r[0] = i[0], r[1] = i[1], r[2] = i[2], r[3] = i[3], r;
  }, e.set = function(r, i, a, o, s) {
    return r[0] = i, r[1] = a, r[2] = o, r[3] = s, r;
  }, e.add = function(r, i, a) {
    return r[0] = i[0] + a[0], r[1] = i[1] + a[1], r[2] = i[2] + a[2], r[3] = i[3] + a[3], r;
  }, e.distance = function(r, i) {
    var a = i[0] - r[0], o = i[1] - r[1], s = i[2] - r[2], u = i[3] - r[3];
    return Math.sqrt(a * a + o * o + s * s + u * u);
  }, e.scale = function(r, i, a) {
    return r[0] = i[0] * a, r[1] = i[1] * a, r[2] = i[2] * a, r[4] = i[4] * a, r;
  }, e.round = function(r, i) {
    return r[0] = Math.round(i[0]), r[1] = Math.round(i[1]), r[2] = Math.round(i[2]), r[3] = Math.round(i[3]), r;
  }, e.ceil = function(r, i) {
    return r[0] = Math.ceil(i[0]), r[1] = Math.ceil(i[1]), r[2] = Math.ceil(i[2]), r[3] = Math.ceil(i[3]), r;
  }, e.floor = function(r, i) {
    return r[0] = Math.floor(i[0]), r[1] = Math.floor(i[1]), r[2] = Math.floor(i[2]), r[3] = Math.floor(i[3]), r;
  }, e.squaredDistance = function(r, i) {
    var a = i[0] - r[0], o = i[1] - r[1], s = i[2] - r[2], u = i[3] - r[3];
    return a * a + o * o + s * s + u * u;
  }, e.norm = function(r) {
    var i = r[0], a = r[1], o = r[2], s = r[3];
    return Math.sqrt(i * i + a * a + o * o + s * s);
  }, e.squaredNorm = function(r) {
    var i = r[0], a = r[1], o = r[2], s = r[3];
    return i * i + a * a + o * o + s * s;
  }, e.transformMat4 = function(r, i, a) {
    var o = i[0], s = i[1], u = i[2], c = i[3];
    return r[0] = a[0] * o + a[4] * s + a[8] * u + a[12] * c, r[1] = a[1] * o + a[5] * s + a[9] * u + a[13] * c, r[2] = a[2] * o + a[6] * s + a[10] * u + a[14] * c, r[3] = a[3] * o + a[7] * s + a[11] * u + a[15] * c, r;
  }, e.dot = function(r, i) {
    return r[0] * i[0] + r[1] * i[1] + r[2] * i[2] + r[3] * i[3];
  }, e.inverse = function(r, i) {
    return r[0] = 1 / i[0], r[1] = 1 / i[1], r[2] = 1 / i[2], r[3] = 1 / i[3], r;
  }, e.exactEquals = function(r, i) {
    return r[0] === i[0] && r[1] === i[1] && r[2] === i[2] && r[3] === i[3];
  }, e.equals = function(r, i) {
    var a = r[0], o = r[1], s = r[2], u = r[3], c = i[0], l = i[1], d = i[2], m = i[3];
    return Math.abs(a - c) <= bn * Math.max(1, Math.abs(a), Math.abs(c)) && Math.abs(o - l) <= bn * Math.max(1, Math.abs(o), Math.abs(l)) && Math.abs(s - d) <= bn * Math.max(1, Math.abs(s), Math.abs(d)) && Math.abs(u - m) <= bn * Math.max(1, Math.abs(u), Math.abs(m));
  }, e.toString = function(r, i) {
    return "[".concat(r[0].toPrecision(i), " ").concat(r[1].toPrecision(i), " ").concat(r[2].toPrecision(i), "  ").concat(r[3].toPrecision(i), "]");
  };
}(vt || (vt = {})), function(e) {
  function t() {
    var v = [0.1, 0, 0, 0];
    return v[0] = 0, v;
  }
  function n() {
    var v = t();
    return v[3] = 1, v;
  }
  function r(v, f, y) {
    y *= 0.5;
    var h = Math.sin(y);
    return v[0] = h * f[0], v[1] = h * f[1], v[2] = h * f[2], v[3] = Math.cos(y), v;
  }
  function i(v, f, y, h) {
    var g, x, C, b, _, A = f[0], I = f[1], w = f[2], E = f[3], D = y[0], T = y[1], P = y[2], M = y[3];
    return (x = A * D + I * T + w * P + E * M) < 0 && (x = -x, D = -D, T = -T, P = -P, M = -M), 1 - x > 1e-6 ? (g = Math.acos(x), C = Math.sin(g), b = Math.sin((1 - h) * g) / C, _ = Math.sin(h * g) / C) : (b = 1 - h, _ = h), v[0] = b * A + _ * D, v[1] = b * I + _ * T, v[2] = b * w + _ * P, v[3] = b * E + _ * M, v;
  }
  function a(v, f) {
    var y, h = f[0] + f[4] + f[8];
    if (h > 0) y = Math.sqrt(h + 1), v[3] = 0.5 * y, y = 0.5 / y, v[0] = (f[5] - f[7]) * y, v[1] = (f[6] - f[2]) * y, v[2] = (f[1] - f[3]) * y;
    else {
      var g = 0;
      f[4] > f[0] && (g = 1), f[8] > f[3 * g + g] && (g = 2);
      var x = (g + 1) % 3, C = (g + 2) % 3;
      y = Math.sqrt(f[3 * g + g] - f[3 * x + x] - f[3 * C + C] + 1), v[g] = 0.5 * y, y = 0.5 / y, v[3] = (f[3 * x + C] - f[3 * C + x]) * y, v[x] = (f[3 * x + g] + f[3 * g + x]) * y, v[C] = (f[3 * C + g] + f[3 * g + C]) * y;
    }
    return v;
  }
  e.zero = t, e.identity = n, e.setIdentity = function(v) {
    v[0] = 0, v[1] = 0, v[2] = 0, v[3] = 1;
  }, e.hasNaN = function(v) {
    return isNaN(v[0]) || isNaN(v[1]) || isNaN(v[2]) || isNaN(v[3]);
  }, e.create = function(v, f, y, h) {
    var g = n();
    return g[0] = v, g[1] = f, g[2] = y, g[3] = h, g;
  }, e.setAxisAngle = r, e.getAxisAngle = function(v, f) {
    var y = 2 * Math.acos(f[3]), h = Math.sin(y / 2);
    return h !== 0 ? (v[0] = f[0] / h, v[1] = f[1] / h, v[2] = f[2] / h) : (v[0] = 1, v[1] = 0, v[2] = 0), y;
  }, e.multiply = function(v, f, y) {
    var h = f[0], g = f[1], x = f[2], C = f[3], b = y[0], _ = y[1], A = y[2], I = y[3];
    return v[0] = h * I + C * b + g * A - x * _, v[1] = g * I + C * _ + x * b - h * A, v[2] = x * I + C * A + h * _ - g * b, v[3] = C * I - h * b - g * _ - x * A, v;
  }, e.rotateX = function(v, f, y) {
    y *= 0.5;
    var h = f[0], g = f[1], x = f[2], C = f[3], b = Math.sin(y), _ = Math.cos(y);
    return v[0] = h * _ + C * b, v[1] = g * _ + x * b, v[2] = x * _ - g * b, v[3] = C * _ - h * b, v;
  }, e.rotateY = function(v, f, y) {
    y *= 0.5;
    var h = f[0], g = f[1], x = f[2], C = f[3], b = Math.sin(y), _ = Math.cos(y);
    return v[0] = h * _ - x * b, v[1] = g * _ + C * b, v[2] = x * _ + h * b, v[3] = C * _ - g * b, v;
  }, e.rotateZ = function(v, f, y) {
    y *= 0.5;
    var h = f[0], g = f[1], x = f[2], C = f[3], b = Math.sin(y), _ = Math.cos(y);
    return v[0] = h * _ + g * b, v[1] = g * _ - h * b, v[2] = x * _ + C * b, v[3] = C * _ - x * b, v;
  }, e.calculateW = function(v, f) {
    var y = f[0], h = f[1], g = f[2];
    return v[0] = y, v[1] = h, v[2] = g, v[3] = Math.sqrt(Math.abs(1 - y * y - h * h - g * g)), v;
  }, e.slerp = i, e.invert = function(v, f) {
    var y = f[0], h = f[1], g = f[2], x = f[3], C = y * y + h * h + g * g + x * x, b = C ? 1 / C : 0;
    return v[0] = -y * b, v[1] = -h * b, v[2] = -g * b, v[3] = x * b, v;
  }, e.conjugate = function(v, f) {
    return v[0] = -f[0], v[1] = -f[1], v[2] = -f[2], v[3] = f[3], v;
  }, e.fromMat3 = a;
  var o = [0, 0, 0];
  function s(v, f) {
    var y = f[0], h = f[1], g = f[2], x = f[3], C = y * y + h * h + g * g + x * x;
    return C > 0 && (C = 1 / Math.sqrt(C), v[0] = y * C, v[1] = h * C, v[2] = g * C, v[3] = x * C), v;
  }
  e.fromUnitVec3 = function(v, f, y) {
    var h = S.dot(f, y) + 1;
    return h < bn ? (h = 0, Math.abs(f[0]) > Math.abs(f[2]) ? S.set(o, -f[1], f[0], 0) : S.set(o, 0, -f[2], f[1])) : S.cross(o, f, y), v[0] = o[0], v[1] = o[1], v[2] = o[2], v[3] = h, s(v, v), v;
  }, e.clone = function(v) {
    var f = t();
    return f[0] = v[0], f[1] = v[1], f[2] = v[2], f[3] = v[3], f;
  }, e.toArray = function(v, f, y) {
    return f[y + 0] = v[0], f[y + 1] = v[1], f[y + 2] = v[2], f[y + 3] = v[3], f;
  }, e.fromArray = function(v, f, y) {
    return v[0] = f[y + 0], v[1] = f[y + 1], v[2] = f[y + 2], v[3] = f[y + 3], v;
  }, e.copy = function(v, f) {
    return v[0] = f[0], v[1] = f[1], v[2] = f[2], v[3] = f[3], v;
  }, e.set = function(v, f, y, h, g) {
    return v[0] = f, v[1] = y, v[2] = h, v[3] = g, v;
  }, e.exactEquals = function(v, f) {
    return v[0] === f[0] && v[1] === f[1] && v[2] === f[2] && v[3] === f[3];
  }, e.equals = function(v, f) {
    var y = v[0], h = v[1], g = v[2], x = v[3], C = f[0], b = f[1], _ = f[2], A = f[3];
    return Math.abs(y - C) <= bn * Math.max(1, Math.abs(y), Math.abs(C)) && Math.abs(h - b) <= bn * Math.max(1, Math.abs(h), Math.abs(b)) && Math.abs(g - _) <= bn * Math.max(1, Math.abs(g), Math.abs(_)) && Math.abs(x - A) <= bn * Math.max(1, Math.abs(x), Math.abs(A));
  }, e.add = function(v, f, y) {
    return v[0] = f[0] + y[0], v[1] = f[1] + y[1], v[2] = f[2] + y[2], v[3] = f[3] + y[3], v;
  }, e.normalize = s;
  var u = [0, 0, 0], c = [1, 0, 0], l = [0, 1, 0];
  e.rotationTo = function(v, f, y) {
    var h = S.dot(f, y);
    return h < -0.999999 ? (S.cross(u, c, f), S.magnitude(u) < 1e-6 && S.cross(u, l, f), S.normalize(u, u), r(v, u, Math.PI), v) : h > 0.999999 ? (v[0] = 0, v[1] = 0, v[2] = 0, v[3] = 1, v) : (S.cross(u, f, y), v[0] = u[0], v[1] = u[1], v[2] = u[2], v[3] = 1 + h, s(v, v));
  };
  var d = t(), m = t();
  e.sqlerp = function(v, f, y, h, g, x) {
    return i(d, f, g, x), i(m, y, h, x), i(v, d, m, 2 * x * (1 - x)), v;
  };
  var p = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  e.setAxes = function(v, f, y, h) {
    return p[0] = y[0], p[3] = y[1], p[6] = y[2], p[1] = h[0], p[4] = h[1], p[7] = h[2], p[2] = -f[0], p[5] = -f[1], p[8] = -f[2], s(v, a(v, p));
  }, e.toString = function(v, f) {
    return "[".concat(v[0].toPrecision(f), " ").concat(v[1].toPrecision(f), " ").concat(v[2].toPrecision(f), "  ").concat(v[3].toPrecision(f), "]");
  }, e.Identity = n();
}(Mn || (Mn = {})), function(e) {
  function t(o, s, u) {
    var c = function(y, h, g) {
      for (var x = [], C = 0; C < h.length; C++) x[C] = h[h.length - C - 1];
      var b = [1];
      for (C = 1; C < y.length; C++) b[C] = y[x[C - 1]];
      return { dimensions: y, axisOrderFastToSlow: x, axisOrderSlowToFast: h, accessDimensions: b, defaultCtor: g || Float64Array };
    }(o, s, u), l = n(c), d = l.get, m = l.set, p = l.add, v = l.dataOffset, f = l.getCoords;
    return { rank: o.length, dimensions: o, axisOrderSlowToFast: s, create: r(c), get: d, set: m, add: p, dataOffset: v, getCoords: f };
  }
  function n(o) {
    var s = o.dimensions, u = o.axisOrderFastToSlow;
    switch (s.length) {
      case 1:
        return { get: function(P, M) {
          return P[M];
        }, set: function(P, M, R) {
          return P[M] = R;
        }, add: function(P, M, R) {
          return P[M] += R;
        }, dataOffset: function(P) {
          return P;
        }, getCoords: function(P, M) {
          return M[0] = P, M;
        } };
      case 2:
        if (u[0] === 0 && u[1] === 1) {
          var c = s[0];
          return { get: function(P, M, R) {
            return P[R * c + M];
          }, set: function(P, M, R, O) {
            return P[R * c + M] = O;
          }, add: function(P, M, R, O) {
            return P[R * c + M] += O;
          }, dataOffset: function(P, M) {
            return M * c + P;
          }, getCoords: function(P, M) {
            return M[0] = P % c, M[1] = Math.floor(P / c), M;
          } };
        }
        if (u[0] === 1 && u[1] === 0) {
          var l = s[1];
          return { get: function(P, M, R) {
            return P[M * l + R];
          }, set: function(P, M, R, O) {
            return P[M * l + R] = O;
          }, add: function(P, M, R, O) {
            return P[M * l + R] += O;
          }, dataOffset: function(P, M) {
            return P * l + M;
          }, getCoords: function(P, M) {
            return M[0] = Math.floor(P / l), M[1] = P % l, M;
          } };
        }
        throw new Error("bad axis order");
      case 3:
        if (u[0] === 0 && u[1] === 1 && u[2] === 2) {
          var d = s[0], m = s[1], p = d * m;
          return { get: function(P, M, R, O) {
            return P[M + R * d + O * p];
          }, set: function(P, M, R, O, L) {
            return P[M + R * d + O * p] = L;
          }, add: function(P, M, R, O, L) {
            return P[M + R * d + O * p] += L;
          }, dataOffset: function(P, M, R) {
            return P + M * d + R * p;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / d);
            return M[0] = P % d, M[1] = R % m, M[2] = Math.floor(R / m), M;
          } };
        }
        if (u[0] === 0 && u[1] === 2 && u[2] === 1) {
          var v = s[0], f = s[2], y = v * f;
          return { get: function(P, M, R, O) {
            return P[M + O * v + R * y];
          }, set: function(P, M, R, O, L) {
            return P[M + O * v + R * y] = L;
          }, add: function(P, M, R, O, L) {
            return P[M + O * v + R * y] += L;
          }, dataOffset: function(P, M, R) {
            return P + R * v + M * y;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / v);
            return M[0] = P % v, M[1] = Math.floor(R / f), M[2] = R % f, M;
          } };
        }
        if (u[0] === 1 && u[1] === 0 && u[2] === 2) {
          var h = s[1], g = s[0], x = h * g;
          return { get: function(P, M, R, O) {
            return P[R + M * h + O * x];
          }, set: function(P, M, R, O, L) {
            return P[R + M * h + O * x] = L;
          }, add: function(P, M, R, O, L) {
            return P[R + M * h + O * x] += L;
          }, dataOffset: function(P, M, R) {
            return M + P * h + R * x;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / h);
            return M[0] = R % g, M[1] = P % h, M[2] = Math.floor(R / g), M;
          } };
        }
        if (u[0] === 1 && u[1] === 2 && u[2] === 0) {
          var C = s[1], b = s[2], _ = C * b;
          return { get: function(P, M, R, O) {
            return P[R + O * C + M * _];
          }, set: function(P, M, R, O, L) {
            return P[R + O * C + M * _] = L;
          }, add: function(P, M, R, O, L) {
            return P[R + O * C + M * _] += L;
          }, dataOffset: function(P, M, R) {
            return M + R * C + P * _;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / C);
            return M[0] = Math.floor(R / b), M[1] = P % C, M[2] = R % b, M;
          } };
        }
        if (u[0] === 2 && u[1] === 0 && u[2] === 1) {
          var A = s[2], I = s[0], w = A * I;
          return { get: function(P, M, R, O) {
            return P[O + M * A + R * w];
          }, set: function(P, M, R, O, L) {
            return P[O + M * A + R * w] = L;
          }, add: function(P, M, R, O, L) {
            return P[O + M * A + R * w] += L;
          }, dataOffset: function(P, M, R) {
            return R + P * A + M * w;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / A);
            return M[0] = R % I, M[1] = Math.floor(R / I), M[2] = P % A, M;
          } };
        }
        if (u[0] === 2 && u[1] === 1 && u[2] === 0) {
          var E = s[2], D = s[1], T = E * D;
          return { get: function(P, M, R, O) {
            return P[O + R * E + M * T];
          }, set: function(P, M, R, O, L) {
            return P[O + R * E + M * T] = L;
          }, add: function(P, M, R, O, L) {
            return P[O + R * E + M * T] += L;
          }, dataOffset: function(P, M, R) {
            return R + M * E + P * T;
          }, getCoords: function(P, M) {
            var R = Math.floor(P / E);
            return M[0] = Math.floor(R / D), M[1] = R % D, M[2] = P % E, M;
          } };
        }
        throw new Error("bad axis order");
      default:
        return { get: function(P) {
          for (var M = [], R = 1; R < arguments.length; R++) M[R - 1] = arguments[R];
          return P[i(o, M)];
        }, set: function(P) {
          for (var M = [], R = 1; R < arguments.length; R++) M[R - 1] = arguments[R];
          return P[i(o, M)] = M[M.length - 1];
        }, add: function(P) {
          for (var M = [], R = 1; R < arguments.length; R++) M[R - 1] = arguments[R];
          return P[i(o, M)] += M[M.length - 1];
        }, dataOffset: function() {
          for (var P = [], M = 0; M < arguments.length; M++) P[M] = arguments[M];
          return i(o, P);
        }, getCoords: function(P, M) {
          return function(R, O, L) {
            for (var F = R.dimensions, G = R.axisOrderFastToSlow, V = F.length, U = O, q = 0; q < V; q++) {
              var H = F[G[q]];
              L[G[q]] = U % H, U = Math.floor(U / H);
            }
            return L[G[V + 1]] = U, L;
          }(o, P, M);
        } };
    }
  }
  function r(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 i(o, s) {
    for (var u = o.accessDimensions, c = o.axisOrderFastToSlow, l = u.length - 1, d = u[l] * s[c[l]], m = l - 1; m >= 0; m--) d = (d + s[c[m]]) * u[m];
    return d;
  }
  function a(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 m = 0; m < l; m++) J.setValue(o, d, m, s.get(u, d, m));
    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 m = 0; m < l; m++) br.setValue(o, d, m, s.get(u, d, m));
    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 a(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 a(c, s);
    };
  };
}(Nn || (Nn = {})), function(e) {
  e.create = function(t) {
    return t;
  }, e.has = function(t, n) {
    return !!(t & n);
  }, e.hasAll = function(t, n) {
    return !!n && (t & n) === n;
  };
}(Qr || (Qr = {})), function(e) {
  e.create = function(i) {
    return i === void 0 && (i = 512), { current: [], offset: 0, capacity: i, chunks: [] };
  }, e.getString = function(i) {
    return i.chunks.length ? (i.offset > 0 && (i.chunks[i.chunks.length] = i.current.length === i.offset ? i.current.join("") : i.current.slice(0, i.offset).join("")), i.chunks.join("")) : i.current.length === i.offset ? i.current.join("") : i.current.splice(0, i.offset).join("");
  }, e.getSize = function(i) {
    for (var a = 0, o = 0, s = i.chunks; o < s.length; o++)
      a += s[o].length;
    for (var u = 0; u < i.offset; u++) a += i.current[u].length;
    return a;
  }, e.getChunks = function(i) {
    return i.offset > 0 && (i.current.length === i.offset ? i.chunks[i.chunks.length] = i.current.join("") : i.chunks[i.chunks.length] = i.current.slice(0, i.offset).join(""), i.offset = 0), i.chunks;
  };
  var t = [];
  function n(i, a) {
    a > 0 && r(i, t[a]);
  }
  function r(i, a) {
    i.offset === i.capacity && (i.chunks[i.chunks.length] = i.current.join(""), i.offset = 0), i.current[i.offset++] = a;
  }
  (function() {
    for (var i = "", a = 0; a < 512; a++) t[a] = i, i += " ";
  })(), e.newline = function(i) {
    r(i, `
`);
  }, e.whitespace = n, e.whitespace1 = function(i) {
    r(i, " ");
  }, e.write = function(i, a) {
    a && (i.offset === i.capacity && (i.chunks[i.chunks.length] = i.current.join(""), i.offset = 0), i.current[i.offset++] = a);
  }, e.writeSafe = r, e.writePadLeft = function(i, a, o) {
    a ? (n(i, o - a.length), r(i, a)) : n(i, o);
  }, e.writePadRight = function(i, a, o) {
    if (a) {
      var s = o - a.length;
      r(i, a), n(i, s);
    } else n(i, o);
  }, e.writeInteger = function(i, a) {
    r(i, "" + a);
  }, e.writeIntegerAndSpace = function(i, a) {
    r(i, a + " ");
  }, e.writeIntegerPadLeft = function(i, a, o) {
    var s = "" + a;
    n(i, o - s.length), r(i, s);
  }, e.writeIntegerPadRight = function(i, a, o) {
    var s = "" + a, u = o - s.length;
    r(i, s), n(i, u);
  }, e.writeFloat = function(i, a, o) {
    r(i, "" + Math.round(o * a) / o);
  }, e.writeFloatPadLeft = function(i, a, o, s) {
    var u = "" + Math.round(o * a) / o;
    n(i, s - u.length), r(i, u);
  }, e.writeFloatPadRight = function(i, a, o, s) {
    var u = "" + Math.round(o * a) / o, c = s - u.length;
    r(i, u), n(i, c);
  };
}(qt || (qt = {})), function(e) {
  var t = typeof btoa < "u" ? btoa : function(r) {
    return Buffer.from(r).toString("base64");
  }, n = [];
  e.create22 = function() {
    for (var r = +/* @__PURE__ */ new Date() + nr(), i = 0; i < 16; i++) n[i] = String.fromCharCode((r + 255 * Math.random()) % 255 | 0), r = Math.floor(r / 255);
    return t(n.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }, e.createv4 = function() {
    var r = +/* @__PURE__ */ new Date() + nr(), i = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
      var o = (r + 16 * Math.random()) % 16 | 0;
      return r = Math.floor(r / 16), (a === "x" ? o : 3 & o | 8).toString(16);
    });
    return i;
  }, e.is = function(r) {
    return typeof r == "string";
  };
}(vr || (vr = {})), 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;
  }(), n = 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;
  }(), r = 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;
  }(), i = 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;
  }(), a = 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, m = this.flatten(); d < m.length; d++)
        c(m[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, Tw);
      }(c), this._flat = c, this._flat;
    }, u.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, u;
  }();
  function o(u) {
    return new a(u);
  }
  function s(u, c) {
    return new r(u, c);
  }
  e.always = function(u) {
    return new i(u);
  }, e.never = new t(), e.ofSet = o, e.singleton = function(u) {
    return new n(u);
  }, e.ofUniqueIndices = function(u) {
    var c = u.length;
    if (c === 0) return new t();
    if (c === 1) return new n(u[0]);
    for (var l = 0, d = 0, m = u; d < m.length; d++)
      (y = m[d]) > l && (l = y);
    if (c === l) return new i(c);
    if (c / l < 1 / 12) {
      for (var p = /* @__PURE__ */ new Set(), v = 0, f = u; v < f.length; v++) {
        var y = f[v];
        p.add(y);
      }
      return new a(p);
    }
    for (var h = new Int8Array(l + 1), g = 0, x = u; g < x.length; g++)
      h[y = x[g]] = 1;
    return new r(h, u.length);
  }, e.ofMask = s, e.hasAny = function(u, c) {
    for (var l = 0, d = c; l < d.length; l++) {
      var m = d[l];
      if (u.has(m)) return !0;
    }
    return !1;
  }, e.complement = function(u, c) {
    var l = 0, d = 0;
    if (c.forEach(function(v) {
      u.has(v) || (l++, v > d && (d = v));
    }), l / d < 1 / 12) {
      var m = /* @__PURE__ */ new Set();
      return c.forEach(function(v) {
        u.has(v) || m.add(v);
      }), o(m);
    }
    var p = new Uint8Array(d + 1);
    return c.forEach(function(v) {
      u.has(v) || (p[v] = 1);
    }), s(p, l);
  };
}(_y || (_y = {})), function(e) {
  e.create = function(t) {
    return { ref: t };
  }, e.set = function(t, n) {
    return t.ref = n, t;
  };
}(Zd || (Zd = {}));
var lu, k, Mw = fi(0, 2147483647);
function Or() {
  return Or.zero();
}
function _o() {
  return _o.zero();
}
function ye(e) {
  return e;
}
function Rt(e, t, n, r) {
  return { label: e, description: n, list: r, type: t };
}
function Dc(e, t, n) {
  var r = {};
  for (var i in e) {
    var a = e[i];
    a = ye.saturate(a, t), a = ye.darken(a, -n), r[i] = a;
  }
  return r;
}
(function(e) {
  e.create = function(t, n) {
    return { id: Mw(), version: 0, value: t, metadata: n };
  }, e.withValue = function(t, n) {
    return { id: t.id, version: t.version + 1, value: n, metadata: t.metadata };
  };
})(lu || (lu = {})), function(e) {
  function t(n, r) {
    return Zd.set(n, lu.withValue(n.ref, r));
  }
  e.create = function(n, r) {
    return Zd.create(lu.create(n, r));
  }, e.update = t, e.set = function(n, r) {
    return Zd.set(n, r);
  }, e.updateIfChanged = function(n, r) {
    return n.ref.value !== r ? t(n, r) : n;
  };
}(k || (k = {})), function(e) {
  function t() {
    var g = [0.1, 0, 0];
    return g[0] = 0, g;
  }
  function n(g, x) {
    var C = x[0], b = x[1], _ = x[2], A = Math.sqrt(b * b + _ * _), I = ($r(Math.atan2(_, b)) + 360) % 360;
    return Math.round(1e4 * A) === 0 && (I = Number.NaN), g[0] = I, g[1] = A, g[2] = C, g;
  }
  function r(g, x, C) {
    return g[0] = x[0] - o * C, g[1] = x[1], g[2] = x[2], g;
  }
  e.zero = t, e.create = function(g, x, C) {
    var b = t();
    return b[0] = g, b[1] = x, b[2] = C, b;
  }, e.fromColor = function(g, x) {
    var C = ye.toRgb(x), b = function(E, D, T) {
      E = y(E), D = y(D), T = y(T);
      var P = h((0.4124564 * E + 0.3575761 * D + 0.1804375 * T) / s), M = h((0.2126729 * E + 0.7151522 * D + 0.072175 * T) / u), R = h((0.0193339 * E + 0.119192 * D + 0.9503041 * T) / c);
      return [P, M, R];
    }(C[0], C[1], C[2]), _ = b[0], A = b[1], I = b[2], w = 116 * A - 16;
    return g[0] = w < 0 ? 0 : w, g[1] = 500 * (_ - A), g[2] = 200 * (A - I), g;
  }, e.fromHcl = function(g, x) {
    return _o.toLab(g, x);
  }, e.toColor = function(g) {
    var x = (g[0] + 16) / 116, C = isNaN(g[1]) ? x : x + g[1] / 500, b = isNaN(g[2]) ? x : x - g[2] / 200;
    x = u * f(x);
    var _ = v(3.2404542 * (C = s * f(C)) - 1.5371385 * x - 0.4985314 * (b = c * f(b))), A = v(-0.969266 * C + 1.8760108 * x + 0.041556 * b), I = v(0.0556434 * C - 0.2040259 * x + 1.0572252 * b);
    return ye.fromRgb(Math.round(xi(_, 0, 255)), Math.round(xi(A, 0, 255)), Math.round(xi(I, 0, 255)));
  }, e.toHcl = n, e.copy = function(g, x) {
    return g[0] = x[0], g[1] = x[1], g[2] = x[2], g;
  }, e.darken = r, e.lighten = function(g, x, C) {
    return r(g, x, -C);
  };
  var i = [0, 0, 0];
  function a(g, x, C) {
    return n(i, x), _o.toLab(g, _o.saturate(i, i, C));
  }
  e.saturate = a, e.desaturate = function(g, x, C) {
    return a(g, x, -C);
  };
  var o = 18, s = 0.95047, u = 1, c = 1.08883, l = 0.137931034, d = 0.206896552, m = 0.12841855, p = 8856452e-9;
  function v(g) {
    return 255 * (g <= 304e-5 ? 12.92 * g : 1.055 * Math.pow(g, 1 / 2.4) - 0.055);
  }
  function f(g) {
    return g > d ? g * g * g : m * (g - l);
  }
  function y(g) {
    return (g /= 255) <= 0.04045 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
  }
  function h(g) {
    return g > p ? Math.pow(g, 1 / 3) : g / m + l;
  }
}(Or || (Or = {})), 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 m = t();
    return m[0] = c, m[1] = l, m[2] = d, m;
  };
  var n = [0, 0, 0];
  e.fromColor = function(c, l) {
    return Or.toHcl(c, Or.fromColor(n, l));
  }, e.fromLab = function(c, l) {
    return Or.toHcl(c, l);
  };
  var r = [0, 0, 0];
  function i(c, l) {
    var d = l[0], m = l[1], p = l[2];
    return isNaN(d) && (d = 0), d = Bn(d), c[0] = p, c[1] = Math.cos(d) * m, c[2] = Math.sin(d) * m, c;
  }
  function a(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 Or.toColor(i(r, c));
  }, e.toLab = i, e.copy = function(c, l) {
    return c[0] = l[0], c[1] = l[1], c[2] = l[2], c;
  }, e.saturate = a, e.desaturate = function(c, l, d) {
    return a(c, l, -d);
  };
  var o = [0, 0, 0];
  function s(c, l, d) {
    return i(o, l), Or.toHcl(c, Or.darken(o, o, d));
  }
  e.darken = s, e.lighten = function(c, l, d) {
    return s(c, l, -d);
  };
  var u = 18;
}(_o || (_o = {})), function(e) {
  function t(c, l, d) {
    return c << 16 | l << 8 | d;
  }
  function n(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 = n, e.fromArray = function(c, l) {
    return t(c[l], c[l + 1], c[l + 2]);
  }, e.fromNormalizedArray = function(c, l) {
    return n(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 m = c >> 16 & 255, p = c >> 8 & 255, v = 255 & c;
    return m + ((l >> 16 & 255) - m) * d << 16 | p + ((l >> 8 & 255) - p) * d << 8 | v + ((255 & l) - v) * d;
  };
  var r = [0, 0, 0];
  function i(c, l) {
    return _o.fromColor(r, c), _o.toColor(_o.saturate(r, r, l));
  }
  e.saturate = i, e.desaturate = function(c, l) {
    return i(c, -l);
  };
  var a = [0, 0, 0];
  function o(c, l) {
    return Or.fromColor(a, c), Or.toColor(Or.darken(a, a, 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 n(s((c >> 16 & 255) / 255), s((c >> 8 & 255) / 255), s((255 & c) / 255));
  }, e.linearToSRGB = function(c) {
    return n(u((c >> 16 & 255) / 255), u((c >> 8 & 255) / 255), u((255 & c) / 255));
  };
}(ye || (ye = {}));
var Dw = function(e) {
  return e.toUpperCase();
};
function Ag(e) {
  return e.toLowerCase().replace(/^\w|\s\w/g, Dw);
}
function To(e) {
  return Ag(function(t, n) {
    return n === void 0 && (n = " "), t.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, "$1".concat(n, "$2"));
  }(function(t) {
    return t.replace(/_/g, " ");
  }(function(t) {
    return t.replace(/-/g, " ");
  }(e))));
}
function Qn(e, t, n, r) {
  var i = r.length;
  if (i > n - t) return !1;
  for (var a = 0; a < i; a++) if (e.charCodeAt(t + a) !== r.charCodeAt(a)) return !1;
  return !0;
}
function Ig(e) {
  return e.replace(/<\/?[^>]+>/g, "");
}
var he, Fi = { "orange-red": Rt("Orange-Red", "sequential", "Orange-Red, sequential color scheme from ColorBrewer 2.0", [16775148, 16705736, 16635038, 16628612, 16551257, 15689032, 14102559, 11730944, 8323072]), "purple-blue": Rt("Purple-Blue", "sequential", "Purple-Blue, sequential color scheme from ColorBrewer 2.0", [16775163, 15525874, 13685222, 10927579, 7645647, 3576e3, 356528, 285325, 145496]), "blue-purple": Rt("Blue-Purple", "sequential", "Blue-Purple, sequential color scheme from ColorBrewer 2.0", [16252157, 14740724, 12571622, 10403034, 9213638, 9202609, 8929693, 8458108, 5046347]), oranges: Rt("Oranges", "sequential", "", [16774635, 16705230, 16634018, 16625259, 16616764, 15821075, 14239745, 10892803, 8333060]), "blue-green": Rt("Blue-Green", "sequential", "", [16252157, 15070713, 13429990, 10082505, 6734500, 4304502, 2329413, 27948, 17435]), "yellow-orange-brown": Rt("Yellow-Orange-Brown", "sequential", "", [16777189, 16775100, 16704401, 16696399, 16685353, 15495188, 13388802, 10040324, 6694150]), "yellow-green": Rt("Yellow-Green", "sequential", "", [16777189, 16252089, 14282915, 11394446, 7915129, 4303709, 2327619, 26679, 17705]), reds: Rt("Reds", "sequential", "", [16774640, 16703698, 16563105, 16552562, 16476746, 15678252, 13309981, 10817301, 6750221]), "red-purple": Rt("Red-Purple", "sequential", "", [16775155, 16638173, 16565696, 16424885, 16214177, 14496919, 11403646, 7995767, 4784234]), greens: Rt("Greens", "sequential", "", [16252149, 15070688, 13101504, 10607003, 7652470, 4303709, 2329413, 27948, 17435]), "yellow-green-blue": Rt("Yellow-Green-Blue", "sequential", "", [16777177, 15595697, 13101492, 8375739, 4306628, 1937856, 2252456, 2438292, 531800]), purples: Rt("Purples", "sequential", "", [16579581, 15724021, 14342891, 12369372, 10394312, 8420794, 6967715, 5515151, 4128893]), "green-blue": Rt("Green-Blue", "sequential", "", [16252144, 14742491, 13429701, 11066805, 8113348, 5157843, 2854078, 551084, 540801]), greys: Rt("Greys", "sequential", "", [16777215, 15790320, 14277081, 12434877, 9868950, 7566195, 5395026, 2434341, 0]), "yellow-orange-red": Rt("Yellow-Orange-Red", "sequential", "", [16777164, 16772512, 16701814, 16691788, 16616764, 16535082, 14883356, 12386342, 8388646]), "purple-red": Rt("Purple-Red", "sequential", "", [16250105, 15196655, 13941210, 13210823, 14640560, 15149450, 13505110, 9961539, 6750239]), blues: Rt("Blues", "sequential", "", [16251903, 14609399, 13032431, 10406625, 7057110, 4362950, 2191797, 545180, 536683]), "purple-blue-green": Rt("Purple-Blue-Green", "sequential", "", [16775163, 15524592, 13685222, 10927579, 6793679, 3576e3, 164234, 93273, 83510]), spectral: Rt("Spectral", "diverging", "", [10355010, 13975119, 16018755, 16625249, 16703627, 16777151, 15136152, 11263396, 6734501, 3311805, 6180770]), "red-yellow-green": Rt("Red-Yellow-Green", "diverging", "", [10813478, 14102567, 16018755, 16625249, 16703627, 16777151, 14282635, 10934634, 6733155, 1742928, 26679]), "red-blue": Rt("Red-Blue", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16250871, 13755888, 9618910, 4428739, 2188972, 340065]), "pink-yellow-green": Rt("Pink-Yellow-Green", "diverging", "", [9306450, 12917629, 14579630, 15840986, 16638191, 16250871, 15136208, 12116358, 8371265, 5083681, 2581529]), "purple-green": Rt("Purple-Green", "diverging", "", [4194379, 7744131, 10055851, 12756431, 15193320, 16250871, 14282963, 10935200, 5942881, 1800247, 17435]), "red-yellow-blue": Rt("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": Rt("Brown-White-Green", "diverging", "", [5517317, 9195786, 12550445, 14664317, 16181443, 16119285, 13101797, 8441281, 3512207, 91742, 15408]), "red-grey": Rt("Red-Grey", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16777215, 14737632, 12237498, 8882055, 5066061, 1710618]), "orange-purple": Rt("Orange-Purple", "diverging", "", [8338184, 11753478, 14713364, 16627811, 16703670, 16250871, 14211819, 11709394, 8418220, 5515144, 2949195]), "set-2": Rt("Set-2", "qualitative", "", [6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), accent: Rt("Accent", "qualitative", "", [8374655, 12496596, 16629894, 16777113, 3697840, 15729279, 12540695, 6710886]), "set-1": Rt("Set-1", "qualitative", "", [14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329]), "set-3": Rt("Set-3", "qualitative", "", [9294791, 16777139, 12499674, 16482418, 8434131, 16626786, 11787881, 16567781, 14277081, 12353725, 13429701, 16772463]), "dark-2": Rt("Dark-2", "qualitative", "", [1810039, 14245634, 7696563, 15149450, 6727198, 15117058, 10909213, 6710886]), paired: Rt("Paired", "qualitative", "", [10931939, 2062516, 11722634, 3383340, 16489113, 14883356, 16629615, 16744192, 13284054, 6962586, 16777113, 11622696]), "pastel-2": Rt("Pastel-2", "qualitative", "", [11789005, 16633260, 13358568, 16042724, 15136201, 16773806, 15852236, 13421772]), "pastel-1": Rt("Pastel-1", "qualitative", "", [16495790, 11783651, 13429701, 14601188, 16701862, 16777164, 15063229, 16636652, 15921906]), "many-distinct": Rt("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: Rt("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: Rt("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: Rt("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: Rt("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: Rt("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: Rt("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: Rt("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: Rt("Rainbow", "sequential", "", [3367393, 3516485, 16383744, 15501073, 12526114]), "red-white-blue": Rt("Red-White-Blue", "diverging", "", [12526114, 16777215, 3367393]) }, Sy = Object.keys(Fi).map(function(e) {
  return [e, Fi[e].label, Ag(Fi[e].type)];
});
function bs(e) {
  return e in Fi ? Fi[e] : (console.warn("unknown color list named '".concat(e, "'")), Fi["red-yellow-blue"]);
}
function io(e) {
  return { kind: "table-legend", table: e };
}
function hm(e, t, n) {
  return e[t] - e[n];
}
function uc(e, t, n) {
  var r = e[t];
  e[t] = e[n], e[n] = r;
}
function u7(e, t, n, r) {
  var i = n + r >> 1;
  return t(e, n, r) > 0 ? t(e, n, i) > 0 ? t(e, i, r) > 0 ? i : r : n : t(e, r, i) > 0 ? t(e, i, n) > 0 ? i : n : r;
}
function Bw(e, t, n) {
  var r = e.cmp, i = e.swap, a = e.data, o = e.parts, s = t + 1, u = n;
  for (i(a, t, u7(a, r, t, n)); r(a, u, t) > 0; ) --u;
  for (var c = t + 1; c <= u; c++) {
    var l = r(a, c, t);
    if (l > 0) {
      for (i(a, c, u), --u; r(a, u, t) > 0; ) --u;
      c--;
    } else l === 0 && (i(a, c, s), s++);
  }
  for (c = t; c < s; c++) i(a, c, t + u - c);
  o[0] = u - s + t + 1, o[1] = u;
}
function Rw(e, t, n) {
  for (var r = e.data, i = e.cmp, a = e.swap, o = t + 1; o <= n; o++) for (var s = o - 1; s >= t && i(r, s, s + 1) > 0; ) a(r, s, s + 1), s -= 1;
}
function Tm(e, t, n) {
  for (var r = e.parts; t < n; ) {
    if (n - t < 16) return void Rw(e, t, n);
    Bw(e, t, n);
    var i = r[0], a = r[1];
    i - t < n - a ? (Tm(e, t, i - 1), t = a + 1) : (Tm(e, a + 1, n), n = i - 1);
  }
}
function kw(e, t, n, r) {
  var i = n + 1, a = r;
  uc(e, n, u7(e, hm, n, r));
  for (var o = e[n]; e[a] > o; ) --a;
  for (var s = n + 1; s <= a; s++) {
    var u = e[s];
    if (u > o) {
      for (uc(e, s, a), --a; e[a] > o; ) --a;
      s--;
    } else u === o && (uc(e, s, i), ++i);
  }
  for (s = n; s < i; s++) uc(e, s, n + a - s);
  t[0] = a - i + n + 1, t[1] = a;
}
function Ow(e, t, n) {
  for (var r = t + 1; r <= n; r++) {
    for (var i = e[r], a = r - 1; a >= t && e[a] > i; ) e[a + 1] = e[a], a -= 1;
    e[a + 1] = i;
  }
}
function B2(e, t, n, r) {
  for (; n < r; ) {
    if (r - n < 16) return void Ow(e, n, r);
    kw(e, t, n, r);
    var i = t[0], a = t[1];
    i - n < r - a ? (B2(e, t, n, i - 1), n = a + 1) : (B2(e, t, a + 1, r), r = i - 1);
  }
}
function to(e, t) {
  return t === void 0 && (t = hm), function(n, r, i, a) {
    return a === void 0 && (a = hm), a === hm ? B2(n, [0, 0], r, i - 1) : Tm({ data: n, cmp: a, swap: uc, parts: [0, 0] }, r, i - 1), n;
  }(e, 0, e.length, t);
}
function c7(e, t, n, r, i) {
  return Tm({ data: e, cmp: r, swap: i, parts: [0, 0] }, t, n - 1), e;
}
function Nw(e, t, n) {
  return e[t].key < e[n].key ? -1 : 1;
}
function ip(e, t, n) {
  var r = n && n.start || 0, i = n && n.end || e.length;
  if (i - r <= 0) throw new Error("Can only bucket non-empty collections.");
  return function(a, o, s, u, c) {
    for (var l = /* @__PURE__ */ new Map(), d = [], m = o(a[0]), p = !0, v = u; v < c; v++) {
      var f = o(a[v]);
      if (l.has(f)) l.get(f).count++, m !== f && (p = !1);
      else {
        var y = { key: f, count: 1, offset: v };
        l.set(f, y), d[d.length] = y;
      }
      m = f;
    }
    var h = new Int32Array(d.length + 1);
    h[d.length] = c;
    var g = !0;
    if (s) {
      v = 1;
      for (var x = d.length; v < x; v++) if (d[v - 1].key > d[v].key) {
        g = !1;
        break;
      }
    }
    if (p && g) {
      for (v = 0; v < d.length; v++) h[v] = d[v].offset;
      return h;
    }
    s && !g && c7(d, 0, d.length, Nw, uc);
    var C = 0;
    for (v = 0; v < d.length; v++) {
      var b = d[v];
      b.offset = C, C += b.count;
    }
    var _ = new Int32Array(c - u);
    for (v = u; v < c; v++) f = o(a[v]), _[(y = l.get(f)).offset++] = a[v];
    for (v = 0, x = _.length; v < x; v++) a[v + u] = _[v];
    for (h[0] = u, v = 1; v < d.length; v++) h[v] = d[v - 1].offset + u;
    return h;
  }(e, t, !(!n || !n.sort), r, i);
}
Sy.filter(function(e) {
  return Fi[e[0]].type === "diverging" || Fi[e[0]].type === "sequential";
}), Sy.filter(function(e) {
  return Fi[e[0]].type === "qualitative";
}), function(e) {
  function t(r) {
    var i = r.growBy * r.elementSize;
    r.currentSize = i, r.currentIndex = 0, r.currentChunk = new r.ctor(i), r.allocatedSize += i, r.chunks[r.chunks.length] = r.currentChunk;
  }
  function n(r, i) {
    var a = r.ctor, o = r.chunks, s = r.currentIndex;
    if (!o.length) return new a(0);
    if (o.length === 1 && (i || s === r.allocatedSize)) return o[0];
    for (var u = 0, c = 0, l = o.length - 1; c < l; c++) u += o[c].length;
    var d = new a(u += r.currentIndex), m = 0;
    if (d.buffer) for (c = 0, l = o.length - 1; c < l; c++) d.set(o[c], m), m += o[c].length;
    else for (c = 0, l = o.length - 1; c < l; c++) {
      for (var p = o[c], v = 0, f = p.length; v < f; v++) d[m + v] = p[v];
      m += p.length;
    }
    var y = o[o.length - 1];
    if (d.buffer && s >= r.currentSize) d.set(y, m);
    else for (v = 0, f = y.length; v < f; v++) d[m + v] = y[v];
    return d;
  }
  e.is = function(r) {
    return r.creator && r.chunkSize;
  }, e.add4 = function(r, i, a, o, s) {
    r.currentIndex >= r.currentSize && t(r);
    var u = r.currentChunk, c = r.currentIndex;
    return u[c] = i, u[c + 1] = a, u[c + 2] = o, u[c + 3] = s, r.currentIndex += 4, r.elementCount++;
  }, e.add3 = function(r, i, a, o) {
    r.currentIndex >= r.currentSize && t(r);
    var s = r.currentChunk, u = r.currentIndex;
    return s[u] = i, s[u + 1] = a, s[u + 2] = o, r.currentIndex += 3, r.elementCount++;
  }, e.add2 = function(r, i, a) {
    r.currentIndex >= r.currentSize && t(r);
    var o = r.currentChunk, s = r.currentIndex;
    return o[s] = i, o[s + 1] = a, r.currentIndex += 2, r.elementCount++;
  }, e.add = function(r, i) {
    return r.currentIndex >= r.currentSize && t(r), r.currentChunk[r.currentIndex] = i, r.currentIndex += 1, r.elementCount++;
  }, e.addRepeat = function(r, i, a) {
    for (var o = 0; o < i; o++) r.currentIndex >= r.currentSize && t(r), r.currentChunk[r.currentIndex++] = a, r.elementCount++;
    return r.elementCount;
  }, e.addMany = function(r, i) {
    for (var a = r.elementSize, o = 0, s = i.length; o < s; o += a) {
      r.currentIndex >= r.currentSize && t(r);
      for (var u = r.currentChunk, c = 0; c < a; c++) u[r.currentIndex++] = i[o + c];
      r.elementCount++;
    }
    return r.elementCount;
  }, e.compact = function(r, i) {
    return i === void 0 && (i = !1), n(r, i);
  }, e._compact = n, e.create = function(r, i, a, o) {
    var s = { ctor: r, elementSize: i, growBy: Math.max(1, Math.ceil(a)), 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 r(o * i), s.allocatedSize = o * i, s.currentSize = s.currentChunk.length, s.chunks[0] = s.currentChunk, s;
    var u = o;
    if (u.length % i != 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;
  };
}(he || (he = {}));
var X, Jt, R2, rr, Lw = function() {
  function e(t, n) {
    this.getHash = t, this.areEqual = n, this.id = 0, this.byHash = /* @__PURE__ */ new Map(), this.groups = [];
  }
  return e.prototype.createGroup = function(t, n) {
    var r = this.id++, i = [t];
    return this.groups[r] = i, { id: r, keys: i, value: n };
  }, e.prototype.add = function(t, n) {
    var r = this.getHash(n);
    if (this.byHash.has(r)) {
      for (var i = this.byHash.get(r), a = 0, o = i.length; a < o; a++) {
        var s = i[a];
        if (this.areEqual(n, s.value)) return s.keys[s.keys.length] = t, s.value;
      }
      var u = this.createGroup(t, n);
      return i[i.length] = u, u.value;
    }
    return u = this.createGroup(t, n), this.byHash.set(r, [u]), u.value;
  }, e;
}();
function l7(e) {
  var t = e ^ e >> 4;
  return t = (3735928559 ^ t) + (t << 5), t ^= t >> 11;
}
function $l(e, t) {
  var n = 23;
  return n = 31 * (n = 31 * n + e | 0) + t | 0, n = (3735928559 ^ (n ^= n >> 4)) + (n << 5), n ^= n >> 11;
}
function k2(e) {
  for (var t = 0, n = 0, r = e.length; n < r; n++) t = (t << 5) - t + e.charCodeAt(n++) | 0;
  return t;
}
function Ta(e, t) {
  return (e + t) * (e + t + 1) / 2 + t;
}
function Mm(e, t) {
  return e < t ? Ta(e, t) : Ta(t, e);
}
function di(e) {
  for (var t = 2166136261, n = 0, r = e.length; n < r; ++n) t ^= e[n], t += (t << 1) + (t << 4) + (t << 7) + (t << 8) + (t << 24);
  return t >>> 0;
}
function Dm(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 kf(e, t) {
  var n = t && t.array !== void 0 ? t.array : Array, r = Dm(e, t), i = r.start, a = r.end;
  return { array: new n(a - i), start: i, end: a };
}
function Nr(e, t, n) {
  var r = kf(e, n);
  return function(i, a, o) {
    for (var s = 0, u = a.length; s < u; s++) a[s] = i(o + s);
    return a;
  }(t, r.array, r.start);
}
function wg(e) {
  return !!e.buffer && typeof e.byteLength == "number" && typeof e.BYTES_PER_ELEMENT == "number";
}
function Bm(e, t) {
  var n = e.constructor, r = e.buffer, i = e.length, a = e.byteOffset, o = e.BYTES_PER_ELEMENT, s = Dm(i, t), u = s.start, c = s.end;
  return u === 0 && c === i ? e : new n(r, a + o * u, Math.min(i, c - u));
}
function ec(e, t, n) {
  for (; t < n && e.charCodeAt(t) === 32; ) t++;
  return bu(e, t, n);
}
function bu(e, t, n) {
  var r = t, i = 0, a = 1;
  for (e.charCodeAt(r) === 45 ? (a = -1, ++r) : e.charCodeAt(r) === 43 && ++r; r < n; r++) {
    var o = e.charCodeAt(r) - 48;
    if (o > 9 || o < 0) return a * i | 0;
    i = 10 * i + o | 0;
  }
  return a * i;
}
function Cy(e, t, n, r) {
  return t.charCodeAt(n) === 43 && n++, e * Math.pow(10, bu(t, n, r));
}
function fc(e, t, n) {
  var r = t, i = 1, a = 0, o = 0, s = 1;
  for (e.charCodeAt(r) === 45 ? (i = -1, ++r) : e.charCodeAt(r) === 43 && ++r; r < n; ) {
    var u = e.charCodeAt(r) - 48;
    if (!(u >= 0 && u < 10)) {
      if (u === -2) {
        for (++r; r < n; ) {
          if (!((u = e.charCodeAt(r) - 48) >= 0 && u < 10)) return u === 53 || u === 21 ? Cy(i * (a + o / s), e, r + 1, n) : i * (a + o / s);
          o = 10 * o + u, s *= 10, ++r;
        }
        return i * (a + o / s);
      }
      if (u === 53 || u === 21) return Cy(i * a, e, r + 1, n);
      break;
    }
    a = 10 * a + u, ++r;
  }
  return i * a;
}
function Ay(e, t, n, r) {
  return { schema: n, __array: void 0, isDefined: r === 0, rowCount: t, value: function(i) {
    return e;
  }, valueKind: function(i) {
    return r;
  }, toArray: function(i) {
    for (var a = kf(t, i).array, o = 0, s = a.length; o < s; o++) a[o] = e;
    return a;
  }, areValuesEqual: function(i, a) {
    return !0;
  } };
}
function n1(e) {
  var t = e.value, n = e.valueKind, r = e.areValuesEqual, i = e.rowCount;
  return { schema: e.schema, __array: void 0, isDefined: !0, rowCount: i, value: t, valueKind: n || function(a) {
    return 0;
  }, toArray: function(a) {
    for (var o = kf(i, a), s = o.array, u = o.start, c = 0, l = s.length; c < l; c++) s[c] = t(c + u);
    return s;
  }, areValuesEqual: r || function(a, o) {
    return t(a) === t(o);
  } };
}
function as(e) {
  var t = e.array, n = e.schema, r = e.valueKind, i = t.length, a = n.valueType === "str" ? function(s) {
    var u = t[s];
    return typeof u == "string" ? u : "" + u;
  } : function(s) {
    return t[s];
  }, o = wg(t);
  return { schema: n, __array: t, isDefined: !0, rowCount: i, value: a, valueKind: r || function(s) {
    return 0;
  }, toArray: n.valueType === "str" ? function(s) {
    for (var u = Dm(i, s), c = u.start, l = u.end, d = new (s && s.array !== void 0 ? s.array : t.constructor)(l - c), m = 0, p = l - c; m < p; m++) {
      var v = t[c + m];
      d[m] = typeof v == "string" ? v : "" + v;
    }
    return d;
  } : o ? function(s) {
    return Bm(t, s);
  } : function(s) {
    var u = Dm(i, 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), m = 0, p = l - c; m < p; m++) d[m] = t[c + m];
    return d;
  }, areValuesEqual: function(s, u) {
    return t[s] === t[u];
  } };
}
function Fw(e, t, n) {
  return e.isDefined ? t === 0 && n === e.rowCount ? e : e.__array && wg(e.__array) ? function(r, i, a) {
    var o = Bm(r.__array, { start: i, end: a }), s = r.valueKind;
    return as({ array: o, schema: r.schema, valueKind: function(u) {
      return s(i + u);
    } });
  }(e, t, n) : function(r, i, a) {
    var o = r.value, s = r.valueKind, u = r.areValuesEqual, c = i === 0 ? o : function(d) {
      return o(d + i);
    }, l = a - i;
    return { schema: r.schema, __array: void 0, isDefined: r.isDefined, rowCount: l, value: c, valueKind: i === 0 ? s : function(d) {
      return s(d + i);
    }, toArray: function(d) {
      for (var m = kf(l, d).array, p = 0, v = m.length; p < v; p++) m[p] = o(p + i);
      return m;
    }, areValuesEqual: i === 0 ? u : function(d, m) {
      return u(d + i, m + i);
    } };
  }(e, t, n) : X.Undefined(n - t, e.schema);
}
function Gw(e, t, n) {
  return e.rowCount === 0 || n && function(r, i) {
    if (r.length !== i) return !1;
    for (var a = 0, o = r.length; a < o; a++) if (r[a] !== a) return !1;
    return !0;
  }(t, e.rowCount) ? e : e.__array && typeof e.value(0) == typeof e.__array[0] ? function(r, i) {
    for (var a = r.__array, o = new a.constructor(i.length), s = 0, u = i.length; s < u; s++) o[s] = a[i[s]];
    var c = r.valueKind;
    return as({ array: o, schema: r.schema, valueKind: function(l) {
      return c(i[l]);
    } });
  }(e, t) : function(r, i) {
    var a = r.value, o = r.valueKind, s = r.areValuesEqual, u = function(l) {
      return a(i[l]);
    }, c = i.length;
    return { schema: r.schema, __array: void 0, isDefined: r.isDefined, rowCount: c, value: u, valueKind: function(l) {
      return o(i[l]);
    }, toArray: function(l) {
      for (var d = kf(c, l).array, m = 0, p = d.length; m < p; m++) d[m] = a(i[m]);
      return d;
    }, areValuesEqual: function(l, d) {
      return s(i[l], i[d]);
    } };
  }(e, t);
}
function Pg(e) {
  if (Array.from) return Array.from(e);
  for (var t = []; ; ) {
    var n = e.next(), r = n.done, i = n.value;
    if (r) break;
    t[t.length] = i;
  }
  return t;
}
function O2(e, t, n) {
  for (var r = t - e + 1, i = new Int32Array(r), a = 0; a < r; a++) i[a] = a + e;
  return i;
}
function Vw(e, t) {
  for (var n = new (function(a) {
    var o = a.constructor;
    if (!o) throw new Error("data does not define a constructor and it should");
    return o;
  }(e))(t.length), r = 0, i = t.length; r < i; r++) n[r] = e[t[r]];
  return n;
}
(function(e) {
  var t;
  function n(i, a) {
    return Ay(a.T, i, a, 1);
  }
  function r(i) {
    return n1(i);
  }
  (function(i) {
    function a(o, s) {
      return s === void 0 && (s = i.float), { "@type": "tensor", T: o.create(), space: o, valueType: "tensor", baseType: s };
    }
    i.str = { "@type": "str", T: "", valueType: "str" }, i.int = { "@type": "int", T: 0, valueType: "int" }, i.coord = { "@type": "coord", T: 0, valueType: "float" }, i.float = { "@type": "float", T: 0, valueType: "float" }, i.Str = function(o) {
      return o === void 0 && (o = ""), { "@type": "str", T: o, valueType: "str" };
    }, i.Int = function(o) {
      return o === void 0 && (o = 0), { "@type": "int", T: o, valueType: "int" };
    }, i.Float = function(o) {
      return o === void 0 && (o = 0), { "@type": "float", T: o, valueType: "float" };
    }, i.Tensor = a, i.Vector = function(o, s) {
      return s === void 0 && (s = i.float), a(Nn.Vector(o, s["@type"] === "int" ? Int32Array : Float64Array), s);
    }, i.Matrix = function(o, s, u) {
      return u === void 0 && (u = i.float), a(Nn.ColumnMajorMatrix(o, s, u["@type"] === "int" ? Int32Array : Float64Array), u);
    }, i.Aliased = function(o, s) {
      return s !== void 0 ? B(B({}, o), { T: s }) : o;
    }, i.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(i) {
    return !!i && !!i.schema && !!i.value;
  }, e.Undefined = n, e.ofConst = function(i, a, o) {
    return Ay(i, a, o, 0);
  }, e.ofLambda = r, e.range = function(i, a) {
    return r({ value: function(o) {
      return o + i;
    }, rowCount: Math.max(a - i + 1, 0), schema: t.int });
  }, e.ofArray = function(i) {
    return as(i);
  }, e.ofIntArray = function(i) {
    return as({ array: i, schema: t.int });
  }, e.ofFloatArray = function(i) {
    return as({ array: i, schema: t.float });
  }, e.ofStringArray = function(i) {
    return as({ array: i, schema: t.str });
  }, e.ofStringAliasArray = function(i) {
    return as({ array: i, schema: t.Aliased(t.str) });
  }, e.ofStringListArray = function(i, a) {
    return a === void 0 && (a = ","), as({ array: i, schema: t.List(a, function(o) {
      return o;
    }) });
  }, e.ofIntTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return n1({ value: function(u) {
      return bu(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: a, schema: t.int });
  }, e.ofFloatTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return n1({ value: function(u) {
      return fc(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: a, schema: t.float });
  }, e.ofStringTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return n1({ value: function(u) {
      var c = o.substring(s[2 * u], s[2 * u + 1]);
      return c === "." || c === "?" ? "" : c;
    }, rowCount: a, schema: t.str });
  }, e.window = function(i, a, o) {
    return Fw(i, a, o);
  }, e.view = function(i, a, o) {
    return o === void 0 && (o = !0), Gw(i, a, o);
  }, e.createFirstIndexMap = function(i) {
    return function(a) {
      for (var o = /* @__PURE__ */ new Map(), s = 0, u = a.rowCount; s < u; s++) {
        var c = a.value(s);
        o.has(c) || o.set(a.value(s), s);
      }
      return o;
    }(i);
  }, e.createIndexer = function(i) {
    return function(a) {
      for (var o = /* @__PURE__ */ new Map(), s = 0, u = a.rowCount; s < u; s++) {
        var c = a.value(s);
        o.has(c) || o.set(a.value(s), s);
      }
      return function(l) {
        return o.has(l) ? o.get(l) : -1;
      };
    }(i);
  }, e.mapToArray = function(i, a, o) {
    return function(s, u, c) {
      for (var l = new c(s.rowCount), d = 0, m = s.rowCount; d < m; d++) l[d] = u(s.value(d));
      return l;
    }(i, a, o || Array);
  }, e.areEqual = function(i, a) {
    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, m = 0, p = u.rowCount; m < p; m++) if (l[m] !== d[m]) return !1;
        return !0;
      }(o, s) : function(u, c) {
        for (var l = u.value, d = c.value, m = 0, p = u.rowCount; m < p; m++) if (l(m) !== d(m)) return !1;
        return !0;
      }(o, s));
    }(i, a);
  }, e.indicesOf = function(i, a) {
    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;
    }(i, a);
  }, e.asArrayColumn = function(i, a) {
    return i.__array ? i : i.isDefined ? as({ array: i.toArray({ array: a }), schema: i.schema, valueKind: i.valueKind }) : n(i.rowCount, i.schema);
  }, e.copyToArray = function(i, a, o) {
    if (o === void 0 && (o = 0), i.isDefined) {
      var s = i.__array;
      if (s) for (var u = 0, c = s.length; u < c; u++) a[o + u] = s[u];
      else for (u = 0, c = i.rowCount; u < c; u++) a[o + u] = i.value(u);
    }
  }, e.isIdentity = function(i) {
    for (var a = 0, o = i.rowCount; a < o; a++) if (a !== i.value(a)) return !1;
    return !0;
  };
})(X || (X = {})), function(e) {
  function t(r, i, a) {
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(i);
    o._rowCount = a.length, o._columns = s, o._schema = i;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      o[l] = X.view(r[l], a);
    }
    return o;
  }
  function n(r, i) {
    for (var a = /* @__PURE__ */ Object.create(null), o = r._columns, s = 0; s < o.length; s++) {
      var u = o[s];
      a[u] = r[u].value(i);
    }
    return a;
  }
  e.is = function(r) {
    return r && typeof r._rowCount == "number" && !!r._columns && !!r._schema;
  }, e.pickColumns = function(r, i, a) {
    a === void 0 && (a = {});
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(r);
    o._rowCount = i._rowCount, o._columns = s, o._schema = r;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      if (i[l]) o[l] = i[l];
      else {
        if (!a[l]) throw Error("Cannot find column '".concat(l, "'."));
        o[l] = a[l];
      }
    }
    return o;
  }, e.ofColumns = function(r, i) {
    var a = Object.keys(i), o = i[a[0]].rowCount;
    return B({ _rowCount: o, _columns: a, _schema: r }, i);
  }, e.ofPartialColumns = function(r, i, a) {
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(r);
    o._rowCount = a, o._columns = s, o._schema = r;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      o[l] = l in i ? i[l] : X.Undefined(a, r[l]);
    }
    return o;
  }, e.ofUndefinedColumns = function(r, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(r);
    a._rowCount = i, a._columns = o, a._schema = r;
    for (var s = 0, u = o; s < u.length; s++) {
      var c = u[s];
      a[c] = X.Undefined(i, r[c]);
    }
    return a;
  }, e.ofRows = function(r, i) {
    var a = /* @__PURE__ */ Object.create(null), o = i.length, s = Object.keys(r);
    a._rowCount = o, a._columns = s, a._schema = r;
    for (var u = function(d) {
      a[d] = X.ofLambda({ rowCount: o, schema: r[d], value: function(m) {
        return i[m][d];
      }, valueKind: function(m) {
        return i[m][d] === void 0 ? 1 : 0;
      } });
    }, c = 0, l = s; c < l.length; c++)
      u(l[c]);
    return a;
  }, e.ofArrays = function(r, i) {
    var a, o = /* @__PURE__ */ Object.create(null), s = Object.keys(r);
    o._rowCount = 0, o._columns = s, o._schema = r;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      i[l] !== void 0 ? (o[l] = X.ofArray({ array: i[l], schema: r[l] }), o._rowCount = (a = i[l]) === null || a === void 0 ? void 0 : a.length) : o[l] = X.Undefined(o._rowCount, r[l]);
    }
    return o;
  }, e.view = t, e.pick = function(r, i, a) {
    for (var o = [], s = 0, u = r._rowCount; s < u; ++s) a(s) && o.push(s);
    return t(r, i, o);
  }, e.window = function(r, i, a, o) {
    if (a === 0 && o === r._rowCount) return r;
    var s = /* @__PURE__ */ Object.create(null), u = Object.keys(i);
    s._rowCount = o - a, s._columns = u, s._schema = i;
    for (var c = 0, l = u; c < l.length; c++) {
      var d = l[c];
      s[d] = X.window(r[d], a, o);
    }
    return s;
  }, e.concat = function(r, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(i);
    a._rowCount = 0;
    for (var s = 0, u = r; s < u.length; s++) {
      var c = u[s];
      a._rowCount += c._rowCount;
    }
    for (var l = {}, d = 0, m = o; d < m.length; d++)
      l[m[d]] = new Array(a._rowCount);
    a._columns = o, a._schema = i;
    for (var p = 0, v = 0, f = r; v < f.length; v++) {
      c = f[v];
      for (var y = 0, h = o; y < h.length; y++) {
        var g = h[y];
        X.copyToArray(c[g], l[g], p);
      }
      p += c._rowCount;
    }
    for (var x = 0, C = o; x < C.length; x++)
      a[g = C[x]] = X.ofArray({ array: l[g], schema: i[g] });
    return a;
  }, e.columnToArray = function(r, i, a) {
    r[i] = X.asArrayColumn(r[i], a);
  }, e.sort = function(r, i) {
    for (var a = new Int32Array(r._rowCount), o = 0, s = a.length; o < s; o++) a[o] = o;
    to(a, function(p, v, f) {
      return i(v, f);
    });
    var u = !0;
    for (o = 0, s = a.length; o < s; o++) if (a[o] !== o) {
      u = !1;
      break;
    }
    if (u) return r;
    var c = /* @__PURE__ */ Object.create(null);
    c._rowCount = r._rowCount, c._columns = r._columns, c._schema = r._schema;
    for (var l = 0, d = r._columns; l < d.length; l++) {
      var m = d[l];
      c[m] = X.view(r[m], a, !1);
    }
    return c;
  }, e.areEqual = function(r, i) {
    if (r._rowCount !== i._rowCount || r._columns.length !== i._columns.length) return !1;
    for (var a = 0, o = r._columns; a < o.length; a++)
      if (!i[c = o[a]]) return !1;
    for (var s = 0, u = r._columns; s < u.length; s++) {
      var c = u[s];
      if (!X.areEqual(r[c], i[c])) return !1;
    }
    return !0;
  }, e.getRow = n, e.pickRow = function(r, i) {
    for (var a = 0, o = r._rowCount; a < o; ++a) if (i(a)) return n(r, a);
  }, e.getRows = function(r) {
    for (var i = [], a = r._rowCount, o = 0; o < a; o++) i[o] = n(r, o);
    return i;
  }, e.toArrays = function(r) {
    for (var i = {}, a = r._columns, o = 0; o < a.length; o++) {
      var s = a[o];
      i[s] = r[s].toArray();
    }
    return i;
  }, e.formatToString = function(r) {
    var i = qt.create(), a = r._columns, o = r._rowCount, s = 1;
    qt.write(i, "|");
    for (var u = 0; u < a.length; u++) qt.write(i, a[u]), qt.write(i, "|"), s += a[u].length + 1;
    qt.newline(i), qt.write(i, new Array(s + 1).join("-")), qt.newline(i);
    for (var c = 0; c < o; c++) {
      for (qt.write(i, "|"), u = 0; u < a.length; u++) {
        var l = r[a[u]];
        l.valueKind(c) === 0 ? (qt.write(i, l.value(c)), qt.write(i, "|")) : qt.write(i, ".|");
      }
      qt.newline(i);
    }
    return qt.getString(i);
  };
}(Jt || (Jt = {})), function(e) {
  e.ofTables = function(t, n, r) {
    var i = Object.keys(r), a = /* @__PURE__ */ Object.create(null), o = [];
    a._name = t, a._tableNames = o, a._schema = n;
    for (var s = 0, u = i; s < u.length; s++) {
      var c = u[s];
      Jt.is(r[c]) && (a[c] = r[c], o[o.length] = c);
    }
    return a;
  }, e.getTablesAsRows = function(t) {
    for (var n = {}, r = 0, i = t._tableNames; r < i.length; r++) {
      var a = i[r];
      n[a] = Jt.getRows(t[a]);
    }
    return n;
  };
}(R2 || (R2 = {})), function(e) {
  e.Zero = 0;
  var t, n, r = (t = new ArrayBuffer(8), n = new ArrayBuffer(8), { _int32: new Int32Array(t), _float64: new Float64Array(t), _int32_1: new Int32Array(n), _float64_1: new Float64Array(n) }), i = r._int32, a = r._float64, o = r._int32_1, s = r._float64_1;
  e.is = function(u) {
    return typeof u == "number";
  }, e.create = function(u, c) {
    return i[0] = u, i[1] = c, a[0];
  }, e.diff = function(u) {
    return a[0] = u, i[1] - i[0];
  }, e.fst = function(u) {
    return a[0] = u, i[0];
  }, e.snd = function(u) {
    return a[0] = u, i[1];
  }, e.areEqual = function(u, c) {
    return a[0] = u, s[0] = c, i[0] === o[0] && i[1] === o[1];
  }, e.compare = function(u, c) {
    a[0] = u, s[0] = c;
    var l = i[0] - o[0];
    return l !== 0 ? l : i[1] - o[1];
  }, e.compareInArray = function(u, c, l) {
    a[0] = u[c], s[0] = u[l];
    var d = i[0] - o[0];
    return d !== 0 ? d : i[1] - o[1];
  }, e.hashCode = function(u) {
    return a[0] = u, $l(i[0], i[1]);
  }, e.toString = function(u) {
    return a[0] = u, "(".concat(i[0], ", ").concat(i[1], ")");
  };
}(rr || (rr = {}));
var d7 = rr.Zero;
function Iy(e, t) {
  return t < e ? rr.create(e, e) : rr.create(e, t + 1);
}
function Eg(e, t) {
  return t <= e ? rr.create(e, e) : rr.create(e, t);
}
function zw(e) {
  return e < 0 ? rr.create(0, 0) : rr.create(0, e);
}
var Uw = rr.is, _s = rr.fst, Au = rr.snd, Rm = rr.fst;
function km(e) {
  return rr.snd(e) - 1;
}
var mc = rr.diff, Hw = rr.hashCode, qw = rr.toString;
function jw(e, t) {
  return rr.fst(e) <= t && t < rr.snd(e);
}
function Kw(e, t) {
  var n = _s(e);
  return t >= n && t < Au(e) ? t - n : -1;
}
function Xw(e, t) {
  return rr.fst(e) + t;
}
var oe, Yw = rr.areEqual;
function f7(e, t) {
  var n = mc(e), r = mc(t);
  return n === 0 && r === 0 || n > 0 && r > 0 && km(e) >= Rm(t) && Rm(e) <= km(t);
}
function Ww(e, t) {
  return mc(e) ? !mc(t) || _s(e) <= _s(t) && Au(e) >= Au(t) : mc(t) === 0;
}
function N2(e, t) {
  var n = _s(e);
  if (t <= n) return 0;
  var r = Au(e);
  return t >= r ? r - n : t - n;
}
function Zw(e, t, n) {
  var r = _s(n), i = _s(e);
  if (t <= r + i) return r;
  var a = Au(n);
  return t >= a + i ? a : t - i;
}
function m7(e, t, n) {
  return Eg(N2(e, t), N2(e, n + 1));
}
function Qw(e, t) {
  return f7(e, t) ? Eg(Math.max(_s(e), _s(t)), Math.min(Au(e), Au(t))) : d7;
}
function Jw(e, t) {
  return mc(m7(e, Rm(t), km(t)));
}
(function(e) {
  e.Empty = d7, e.ofSingleton = function(t) {
    return Iy(t, t);
  }, e.ofRange = Iy, e.ofBounds = Eg, e.ofLength = zw, e.is = Uw, e.has = jw, e.indexOf = Kw, e.getAt = Xw, e.start = _s, e.end = Au, e.min = Rm, e.max = km, e.size = mc, e.hashCode = Hw, e.toString = qw, e.areEqual = Yw, e.areIntersecting = f7, e.isSubInterval = Ww, e.findPredecessorIndex = N2, e.findPredecessorIndexInInterval = Zw, e.findRange = m7, e.intersectionSize = Jw, e.intersect = Qw;
})(oe || (oe = {}));
var ff = [];
function $w(e) {
  return [e];
}
function eP(e) {
  return e;
}
function tP(e) {
  return to(e), e;
}
function wy(e, t) {
  if (t < e) return [];
  for (var n = new Int32Array(t - e + 1), r = e; r <= t; r++) n[r - e] = r;
  return n;
}
function nP(e) {
  return e && (Array.isArray(e) || !!e.buffer);
}
function p7(e) {
  return e[e.length - 1] - e[0] + 1 === e.length;
}
function L2(e) {
  return e[0];
}
function F2(e) {
  return e[e.length - 1] + 1;
}
function rP(e) {
  return e[0];
}
function iP(e) {
  return e[e.length - 1];
}
function h7(e) {
  return e.length;
}
function aP(e) {
  var t = e.length;
  return t ? t > 2 ? function(n, r, i, a) {
    var o = 23;
    return o = 31 * (o = 31 * (o = 31 * (o = 31 * o + n | 0) + r | 0) + i | 0) + a | 0, o = (3735928559 ^ (o ^= o >> 4)) + (o << 5), o ^ o >> 11;
  }(t, e[0], e[t - 1], e[t >> 1]) : function(n, r, i) {
    var a = 23;
    return a = 31 * (a = 31 * (a = 31 * a + n | 0) + r | 0) + i | 0, a = (3735928559 ^ (a ^= a >> 4)) + (a << 5), a ^ a >> 11;
  }(t, e[0], e[t - 1]) : 0;
}
function oP(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 v7(e, t) {
  var n = e.length;
  return n === 0 ? -1 : e[0] <= t && t <= e[n - 1] ? b7(e, t, 0, n) : -1;
}
function sP(e, t, n) {
  return g7(e, t, oe.start(n), oe.end(n));
}
function g7(e, t, n, r) {
  return e.length === 0 || r <= n ? -1 : e[n] <= t && t <= e[r - 1] ? b7(e, t, n, r) : -1;
}
function uP(e, t) {
  return v7(e, t) >= 0;
}
function y7(e, t) {
  if (e === t) return !0;
  var n = e.length;
  if (n !== t.length || e[0] !== t[0] || e[n - 1] !== t[n - 1]) return !1;
  if (p7(e)) return !0;
  n--;
  for (var r = 1; r < n; r++) if (e[r] !== t[r]) return !1;
  return !0;
}
function cc(e, t) {
  var n = e.length;
  return t <= e[0] ? 0 : t > e[n - 1] ? n : _7(e, t, 0, n);
}
function cP(e, t, n) {
  var r = oe.start(n), i = oe.end(n), a = e[r];
  return t <= a ? r : i > r && t > e[i - 1] ? i : t - a <= 11 ? function(o, s, u, c) {
    for (var l = u; l < c; l++) if (s <= o[l]) return l;
    return c;
  }(e, t, r + 1, i) : _7(e, t, r, i);
}
function lP(e, t, n) {
  return oe.ofBounds(cc(e, t), cc(e, n + 1));
}
function b7(e, t, n, r) {
  for (var i = n, a = r - 1; i <= a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (t === e[o]) return o;
      return -1;
    }
    var s = i + a >> 1, u = e[s];
    if (t < u) a = s - 1;
    else {
      if (!(t > u)) return s;
      i = s + 1;
    }
  }
  return -1;
}
function _7(e, t, n, r) {
  for (var i = n, a = r - 1; i < a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (t <= e[o]) return o;
      return a + 1;
    }
    var s = i + a >> 1, u = e[s];
    if (t < u) a = s - 1;
    else {
      if (!(t > u)) return s;
      i = s + 1;
    }
  }
  return i > a ? a + 1 : e[i] >= t ? i : i + 1;
}
function dP(e, t) {
  if (e === t) return !0;
  for (var n = Bc(e, t), r = n.startI, i = n.startJ, a = n.endI, o = n.endJ; r < a && i < o; ) {
    var s = e[r], u = t[i];
    if (s < u) r++;
    else {
      if (!(s > u)) return !0;
      i++;
    }
  }
  return !1;
}
function fP(e, t) {
  if (e === t) return !0;
  var n = t.length, r = Bc(e, t), i = r.startI, a = r.startJ, o = r.endI, s = r.endJ;
  if (s - a < n || o - i < n) return !1;
  for (var u = 0; i < o && a < s; ) {
    var c = e[i], l = t[a];
    c < l ? i++ : c > l ? a++ : (i++, a++, u++);
  }
  return u === n;
}
function x7(e, t) {
  if (e === t) return e;
  var n = e.length, r = t.length;
  if (n === 0) return t;
  if (r === 0) return e;
  if (e[0] > t[0]) return x7(t, e);
  var i = Bc(e, t), a = i.startI, o = i.startJ, s = i.endI, u = i.endJ, c = Tg(e, t, a, o, s, u);
  if (c === n && c === r || c === r) return e;
  if (c === n) return t;
  var l = new Int32Array(n + r - c), d = 0, m = 0, p = 0;
  for (d = 0; d < a; d++) l[p++] = e[d];
  for (; m < u && e[a] > t[m]; ) l[p++] = t[m++];
  for (; d < s && m < u; ) {
    var v = e[d], f = t[m];
    v < f ? (l[p++] = v, d++) : v > f ? (l[p++] = f, m++) : (l[p++] = v, d++, m++);
  }
  for (; d < s; d++) l[p++] = e[d];
  for (; m < u; m++) l[p++] = t[m];
  for (; d < n; d++) l[p++] = e[d];
  for (; m < r; m++) l[p++] = t[m];
  return l;
}
function mP(e, t) {
  if (e === t) return h7(e);
  var n = Bc(e, t);
  return Tg(e, t, n.startI, n.startJ, n.endI, n.endJ);
}
function Tg(e, t, n, r, i, a) {
  for (var o = n, s = r, u = 0; o < i && s < a; ) {
    var c = e[o], l = t[s];
    c < l ? o++ : c > l ? s++ : (o++, s++, u++);
  }
  return u;
}
function pP(e, t) {
  if (e === t) return e;
  var n = Bc(e, t), r = n.startI, i = n.startJ, a = n.endI, o = n.endJ, s = Tg(e, t, r, i, a, o), u = e.length, c = t.length;
  if (!s) return ff;
  if (s === u && s === c || s === c) return t;
  if (s === u) return e;
  for (var l = new Int32Array(s), d = 0, m = r, p = i; m < a && p < o; ) {
    var v = e[m], f = t[p];
    v < f ? m++ : (v > f || (l[d++] = v, m++), p++);
  }
  return l;
}
function hP(e, t) {
  if (e === t) return ff;
  for (var n = e.length, r = Bc(e, t), i = r.startI, a = r.startJ, o = r.endI, s = r.endJ, u = i, c = a, l = 0; u < o && c < s; )
    (v = e[u]) < (f = t[c]) ? u++ : v > f ? c++ : (u++, c++, l++);
  if (!l) return e;
  if (l >= n) return ff;
  for (var d = new Int32Array(n - l), m = 0, p = 0; p < i; p++) d[m++] = e[p];
  for (u = i, c = a; u < o && c < s; ) {
    var v, f;
    (v = e[u]) < (f = t[c]) ? (d[m++] = v, u++) : (v > f || u++, c++);
  }
  for (; u < n; u++) d[m++] = e[u];
  return d;
}
function vP(e) {
  if (e.length < 2) return e;
  for (var t = 1, n = 0, r = e.length - 1; n < r; n++) e[n] !== e[n + 1] && t++;
  if (t === e.length) return e;
  var i = new Int32Array(t), a = 0;
  for (n = 0, r = e.length - 1; n < r; n++) e[n] !== e[n + 1] && (i[a++] = e[n]);
  return i[a] = e[e.length - 1], i;
}
function gP(e, t) {
  if (y7(e, t)) return O2(0, e.length - 1);
  for (var n = Bc(e, t), r = n.startI, i = n.startJ, a = n.endI, o = n.endJ, s = r, u = i, c = 0; s < a && u < o; )
    (p = e[s]) < (v = t[u]) ? s++ : p > v ? u++ : (s++, u++, c++);
  var l = e.length;
  if (!c) return ff;
  if (c === l) return O2(0, e.length - 1);
  var d = new Int32Array(c), m = 0;
  for (s = r, u = i; s < a && u < o; ) {
    var p, v;
    (p = e[s]) < (v = t[u]) ? s++ : (p > v || (d[m++] = s, s++), u++);
  }
  return d;
}
var _e, Ho = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
function Bc(e, t) {
  var n = e.length, r = t.length, i = n / r;
  return n >= 128 || r >= 128 || i <= 0.34 || i >= 2.99 ? (Ho.startI = cc(e, L2(t)), Ho.startJ = cc(t, L2(e)), Ho.endI = cc(e, F2(t)), Ho.endJ = cc(t, F2(e))) : (Ho.startI = 0, Ho.startJ = 0, Ho.endI = n, Ho.endJ = r), Ho;
}
(function(e) {
  e.Empty = ff, e.ofUnsortedArray = tP, e.ofSingleton = $w, e.ofSortedArray = eP, e.ofRange = wy, e.ofBounds = function(t, n) {
    return wy(t, n - 1);
  }, e.is = nP, e.isRange = p7, e.has = uP, e.indexOf = v7, e.indexOfInInterval = sP, e.indexOfInRange = g7, e.start = L2, e.end = F2, e.min = rP, e.max = iP, e.size = h7, e.hashCode = aP, e.toString = oP, e.areEqual = y7, e.areIntersecting = dP, e.isSubset = fP, e.union = x7, e.intersect = pP, e.subtract = hP, e.findPredecessorIndex = cc, e.findPredecessorIndexInInterval = cP, e.findRange = lP, e.intersectionSize = mP, e.deduplicate = vP, e.indicesOf = gP;
})(_e || (_e = {}));
var ve, Po = oe.Empty, yP = oe.ofSingleton, bP = oe.ofRange, _P = oe.ofBounds;
function eo(e) {
  return e.length ? _e.isRange(e) ? oe.ofRange(e[0], e[e.length - 1]) : e : Po;
}
function pc(e) {
  return oe.is(e) ? oe.size(e) : _e.size(e);
}
function xP(e, t) {
  return oe.is(e) ? oe.has(e, t) : _e.has(e, t);
}
function SP(e, t) {
  return oe.is(e) ? oe.indexOf(e, t) : _e.indexOf(e, t);
}
function G2(e, t) {
  return oe.is(e) ? oe.getAt(e, t) : e[t];
}
function wl(e) {
  return oe.is(e) ? oe.min(e) : _e.min(e);
}
function Pl(e) {
  return oe.is(e) ? oe.max(e) : _e.max(e);
}
function CP(e) {
  return oe.is(e) ? oe.start(e) : _e.start(e);
}
function AP(e) {
  return oe.is(e) ? oe.end(e) : _e.end(e);
}
function IP(e) {
  return oe.is(e) ? oe.hashCode(e) : _e.hashCode(e);
}
function wP(e, t) {
  return oe.is(e) ? oe.is(t) ? oe.areEqual(e, t) : Py(e, t) : oe.is(t) ? Py(t, e) : _e.areEqual(e, t);
}
function PP(e, t) {
  return oe.is(e) ? oe.is(t) ? oe.areIntersecting(e, t) : Ey(t, e) : oe.is(t) ? Ey(e, t) : _e.areIntersecting(e, t);
}
function EP(e, t) {
  return oe.is(e) ? oe.is(t) ? oe.isSubInterval(e, t) : function(n, r) {
    var i = oe.min(n), a = oe.max(n);
    if (a - i + 1 == 0) return !1;
    var o = _e.min(r), s = _e.max(r);
    return o >= i && s <= a;
  }(e, t) : oe.is(t) ? function(n, r) {
    var i = oe.min(r), a = oe.max(r);
    if (a - i + 1 == 0) return !0;
    var o = _e.min(n), s = _e.max(n);
    if (i < o || a > s) return !1;
    var u = _e.findRange(n, i, a);
    return oe.size(u) === oe.size(r);
  }(e, t) : _e.isSubset(e, t);
}
function TP(e, t) {
  return oe.is(e) ? oe.findPredecessorIndex(e, t) : _e.findPredecessorIndex(e, t);
}
function MP(e, t, n) {
  return oe.is(e) ? oe.findPredecessorIndexInInterval(e, t, n) : _e.findPredecessorIndexInInterval(e, t, n);
}
function DP(e, t, n) {
  return oe.is(e) ? oe.findRange(e, t, n) : _e.findRange(e, t, n);
}
function BP(e, t) {
  return oe.is(e) ? oe.is(t) ? oe.intersectionSize(e, t) : My(t, e) : oe.is(t) ? My(e, t) : _e.intersectionSize(e, t);
}
function RP(e, t) {
  return oe.is(e) ? oe.is(t) ? function(n, r) {
    if (oe.areEqual(n, r)) return n;
    var i = oe.size(n), a = oe.size(r);
    if (!a) return n;
    if (!i) return r;
    var o, s, u, c, l = oe.min(n), d = oe.min(r);
    if (function(v, f) {
      var y = pc(v), h = pc(f);
      return y === 0 && h === 0 || y > 0 && h > 0 && Pl(v) >= wl(f) && wl(v) <= Pl(f);
    }(n, r)) return oe.ofRange(Math.min(l, d), Math.max(oe.max(n), oe.max(r)));
    l < d ? (o = i, s = l, u = a, c = d) : (o = a, s = d, u = i, c = l);
    for (var m = new Int32Array(i + a), p = 0; p < o; p++) m[p] = p + s;
    for (p = 0; p < u; p++) m[p + o] = p + c;
    return eo(m);
  }(e, t) : Ty(t, e) : oe.is(t) ? Ty(e, t) : eo(_e.union(e, t));
}
function kP(e, t) {
  return oe.is(e) ? oe.is(t) ? oe.intersect(e, t) : Dy(t, e) : oe.is(t) ? Dy(e, t) : eo(_e.intersect(e, t));
}
function OP(e, t) {
  return oe.is(e) ? oe.is(t) ? function(n, r) {
    if (oe.areEqual(n, r)) return Po;
    if (!oe.areIntersecting(n, r)) return n;
    var i = oe.min(n), a = oe.max(n), o = oe.min(r), s = oe.max(r);
    if (a < i || s < o) return n;
    if (oe.isSubInterval(r, n)) return Po;
    if (oe.isSubInterval(n, r)) {
      var u = o - i, c = a - s;
      if (u <= 0) return oe.ofRange(s + 1, s + c);
      if (c <= 0) return oe.ofRange(i, i + u - 1);
      for (var l = new Int32Array(u + c), d = 0, m = 0; m < u; m++) l[d++] = i + m;
      for (m = 1; m <= c; m++) l[d++] = s + m;
      return eo(l);
    }
    return i < o ? oe.ofRange(i, o - 1) : oe.ofRange(s + 1, a);
  }(e, t) : function(n, r) {
    var i = oe.min(n), a = oe.max(n);
    if (a < i) return n;
    var o = a - i + 1, s = _e.findRange(r, i, a), u = oe.start(s), c = oe.end(s), l = c - u;
    if (l === 0) return n;
    var d = o - l;
    if (d <= 0) return Po;
    for (var m = new Int32Array(d), p = r.length - 1, v = r[Math.min(u, p)], f = r[Math.min(c, p)], y = 0, h = i; h < v; h++) m[y++] = h;
    for (h = v; h <= f; h++) _e.indexOfInInterval(r, h, s) < 0 && (m[y++] = h);
    for (h = f + 1; h <= a; h++) m[y++] = h;
    return eo(m);
  }(e, t) : oe.is(t) ? function(n, r) {
    var i = oe.min(r), a = oe.max(r);
    if (a < i) return n;
    var o = _e.findRange(n, i, a), s = oe.start(o), u = oe.end(o), c = n.length - (u - s);
    if (c <= 0) return Po;
    if (c === n.length) return n;
    for (var l = new Int32Array(c), d = 0, m = 0; m < s; m++) l[d++] = n[m];
    m = u;
    for (var p = n.length; m < p; m++) l[d++] = n[m];
    return eo(l);
  }(e, t) : eo(_e.subtract(e, t));
}
function Py(e, t) {
  return oe.size(e) === _e.size(t) && oe.start(e) === _e.start(t) && oe.end(e) === _e.end(t);
}
function Ey(e, t) {
  return e.length !== 0 && oe.size(_e.findRange(e, oe.min(t), oe.max(t))) !== 0;
}
function NP(e, t) {
  return pc(e) ? !pc(t) || wl(e) <= wl(t) && Pl(e) >= Pl(t) : pc(t) === 0;
}
function Ty(e, t) {
  var n = oe.size(t);
  if (!n) return e;
  if (NP(t, e)) return t;
  for (var r = oe.min(t), i = oe.max(t), a = _e.findRange(e, r, i), o = oe.start(a), s = oe.end(a), u = new Int32Array(o + (e.length - s) + n), c = 0, l = 0; l < o; l++) u[c++] = e[l];
  for (l = r; l <= i; l++) u[c++] = l;
  l = s;
  for (var d = e.length; l < d; l++) u[c++] = e[l];
  return eo(u);
}
function My(e, t) {
  if (!oe.size(t)) return 0;
  var n = _e.findRange(e, oe.min(t), oe.max(t));
  return oe.end(n) - oe.start(n);
}
function Dy(e, t) {
  if (!oe.size(t)) return Po;
  var n = _e.findRange(e, oe.min(t), oe.max(t)), r = oe.start(n), i = oe.end(n), a = i - r;
  if (!a) return Po;
  if (a === e.length) return e;
  for (var o = new Int32Array(a), s = 0, u = r; u < i; u++) o[s++] = e[u];
  return eo(o);
}
function LP(e, t, n) {
  if (t === n) return e;
  var r = pc(e), i = t.length, a = n.length;
  if (r === 0 || i === 0 || a === 0) return Po;
  for (var o = _e.findPredecessorIndex(n, t[wl(e)]), s = _e.findPredecessorIndex(n, t[Pl(e)] + 1), u = 0, c = 0, l = 0, d = o; l < r && d < s; )
    (p = t[G2(e, l)]) < (v = n[d]) ? l++ : (p > v || (u++, l++), d++);
  if (u === 0) return Po;
  if (u === i && u === a) return e;
  var m = new Int32Array(u);
  for (c = 0, l = 0, d = o; l < r && d < s; ) {
    var p, v;
    (p = t[G2(e, l)]) < (v = n[d]) ? l++ : (p > v || (m[c++] = d, l++), d++);
  }
  return eo(m);
}
function S7(e) {
  for (var t = _e.ofSortedArray(e), n = _e.max(t), r = new Int32Array(n), i = 0, a = e.length - 1; i < a; i++) for (var o = e[i], s = e[i + 1]; o < s; o++) r[o] = i;
  return { offsets: t, index: r, count: e.length - 1 };
}
function FP(e, t) {
  for (var n = oe.start(t), r = new Int32Array(e.length + 1), i = 0, a = e.length; i < a; i++) r[i] = e[i] - n;
  return r[e.length] = oe.end(t) - n, S7(r);
}
function GP(e) {
  return e.count;
}
function VP(e, t) {
  return e.index[t];
}
function zP(e, t, n) {
  var r = e.offsets, i = n >= ve.max(r) ? -1 : ve.findPredecessorIndex(r, n - 1);
  return ve.findRange(t, ve.getAt(r, i), ve.getAt(r, i + 1) - 1);
}
(function(e) {
  e.Empty = Po, e.ofSingleton = yP, e.ofRange = bP, e.ofBounds = _P, e.ofSortedArray = eo, e.has = xP, e.indexOf = SP, e.getAt = G2, e.min = wl, e.max = Pl, e.start = CP, e.end = AP, e.size = pc, e.hashCode = IP, e.areEqual = wP, e.areIntersecting = PP, e.isSubset = EP, e.union = RP, e.intersect = kP, e.indexedIntersect = LP, e.subtract = OP, e.findPredecessorIndex = TP, e.findPredecessorIndexInInterval = MP, e.findRange = DP, e.intersectionSize = BP, e.forEach = function(t, n, r) {
    return function(i, a, o) {
      if (oe.is(i)) for (var s = oe.min(i), u = s, c = oe.max(i); u <= c; u++) a(u, u - s, o);
      else for (u = 0, c = i.length; u < c; u++) a(i[u], u, o);
      return o;
    }(t, n, r);
  }, e.forEachSegment = function(t, n, r, i) {
    return function(a, o, s, u) {
      if (oe.is(a)) for (var c = 0, l = oe.min(a), d = oe.max(a); l <= d; l++) {
        for (var m = o(l), p = l + 1; p < d && o(p) === m; ) p++;
        l = p - 1, s(m, c, u), c++;
      }
      else for (c = 0, l = 0, d = a.length; l < d; l++) {
        for (m = o(a[l]), p = l + 1; p < d && o(a[p]) === m; ) p++;
        l = p - 1, s(m, c, u), c++;
      }
      return u;
    }(t, n, r, i);
  }, e.isInterval = function(t) {
    return oe.is(t);
  }, e.isSortedArray = function(t) {
    return !oe.is(t);
  }, e.toArray = function(t) {
    var n = [];
    return e.forEach(t, function(r) {
      return n.push(r);
    }), n;
  }, e.toString = function(t) {
    return function(n) {
      return oe.is(n) ? oe.toString(n) : _e.toString(n);
    }(t);
  };
})(ve || (ve = {}));
var St, UP = function() {
  function e(t, n, r, i) {
    this.segments = t, this.segmentMap = n, this.set = r, this.segmentMin = 0, this.segmentMax = 0, this.setRange = oe.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = i, this.updateSegmentRange();
  }
  return e.prototype.move = function() {
    for (; this.hasNext; ) {
      if (this.updateValue()) {
        this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && oe.size(this.setRange) > 0;
        break;
      }
      this.updateSegmentRange();
    }
    return this.value;
  }, e.prototype.updateValue = function() {
    var t = this.segments[this.segmentMin + 1], n = ve.findPredecessorIndexInInterval(this.set, t, this.setRange);
    return this.value.start = oe.start(this.setRange), this.value.end = n, this.setRange = oe.ofBounds(n, oe.end(this.setRange)), n > this.value.start;
  }, e.prototype.updateSegmentRange = function() {
    var t = oe.min(this.setRange), n = oe.max(this.setRange);
    n < t ? this.hasNext = !1 : (this.segmentMin = this.segmentMap[ve.getAt(this.set, t)], this.segmentMax = this.segmentMap[ve.getAt(this.set, n)], this.hasNext = this.segmentMax >= this.segmentMin);
  }, e.prototype.setSegment = function(t) {
    this.setRange = oe.ofBounds(t.start, t.end), this.updateSegmentRange();
  }, e;
}();
function HP(e, t, n) {
  var r = n !== void 0 ? oe.ofBounds(n.start, n.end) : oe.ofBounds(0, ve.size(t));
  return new UP(e.offsets, e.index, t, r);
}
(function(e) {
  e.create = S7, e.ofOffsets = FP, e.count = GP, e.getSegment = VP, e.projectValue = zP, e.transientSegments = HP;
})(St || (St = {}));
var Ro, qP = function() {
  function e(t) {
    this.head = t > 0 ? 0 : -1, this.prev = new Int32Array(t), this.next = new Int32Array(t);
    for (var n = 0; n < t; n++) this.next[n] = n + 1, this.prev[n] = n - 1;
    this.prev[0] = -1, this.next[t - 1] = -1;
  }
  return e.prototype.remove = function(t) {
    var n = this.prev, r = this.next, i = n[t], a = r[t];
    i >= 0 && (r[i] = a, n[t] = -1), a >= 0 && (n[a] = i, r[t] = -1), t === this.head && (this.head = i < 0 ? a : i);
  }, 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(n) {
    return Pg(n.keys());
  }, e.Mutable = t, e.asImmutable = function(n) {
    return n;
  }, e.copy = function(n) {
    for (var r = t(), i = n.keys(); ; ) {
      var a = i.next(), o = a.done, s = a.value;
      if (o) break;
      r.set(s, n.get(s));
    }
    return r;
  }, e.addFrom = function(n, r) {
    for (var i = r.keys(); ; ) {
      var a = i.next(), o = a.done, s = a.value;
      if (o) break;
      n.set(s, r.get(s));
    }
    return n;
  };
})(Ro || (Ro = {}));
var Om, jP = 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;
}(), By = function() {
  function e(t, n) {
    this.max = n, this.value = 0, this.hasNext = !1, this.value = t - 1, this.hasNext = n >= t;
  }
  return e.prototype.move = function() {
    return ++this.value, this.hasNext = this.value < this.max, this.value;
  }, e;
}(), KP = function() {
  function e(t) {
    this.value = t, this.hasNext = !0;
  }
  return e.prototype.move = function() {
    return this.hasNext = !1, this.value;
  }, e;
}(), XP = function() {
  function e(t, n) {
    this.base = t, this.f = n, 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;
}(), YP = function() {
  function e(t, n) {
    this.base = t, this.p = n, 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 By(0, -1), e.Array = function(t) {
    return new jP(t);
  }, e.Value = function(t) {
    return new KP(t);
  }, e.Range = function(t, n) {
    return new By(t, n);
  }, e.map = function(t, n) {
    return new XP(t, n);
  }, e.filter = function(t, n) {
    return new YP(t, n);
  }, e.forEach = function(t, n, r) {
    for (; t.hasNext; )
      if (n(t.move(), r)) return r;
    return r;
  };
})(Om || (Om = {}));
var ko, Ii, WP = { domain: [0, 1], reverse: !1, listOrName: "red-yellow-blue", minLabel: "", maxLabel: "" };
function Mg(e) {
  return Object.keys(e);
}
function Tr(e) {
  throw new Error("unreachable");
}
function Dg(e) {
  return typeof (e == null ? void 0 : e.then) == "function";
}
(function(e) {
  e.create = function(t) {
    var n = B(B({}, WP), t), r = n.domain, i = n.reverse, a = n.listOrName, o = typeof a == "string" ? bs(a).list : a, s = i ? o.slice().reverse() : o, u = s.length - 1, c = 0, l = 0, d = 0;
    function m(b, _) {
      c = (d = _) - (l = b) || 1;
    }
    m(r[0], r[1]);
    var p, v = mr(t.minLabel, l.toString()), f = mr(t.maxLabel, d.toString()), y = s.every(function(b) {
      return Array.isArray(b);
    });
    if (y) {
      var h = Pe([], s, !0);
      h.sort(function(b, _) {
        return b[1] - _[1];
      });
      var g = h.map(function(b) {
        return b[0];
      }), x = _e.ofSortedArray(h.map(function(b) {
        return b[1];
      })), C = g.length - 1;
      p = function(b) {
        var _ = xi((b - l) / c, 0, 1), A = _e.findPredecessorIndex(x, _);
        if (A === 0) return g[l];
        if (A > C) return g[C];
        var I = x[A - 1], w = xi((_ - I) / (x[A] - I), 0, 1);
        return ye.interpolate(g[A - 1], g[A], w);
      };
    } else p = function(b) {
      var _ = Math.min(s.length - 1, Math.max(0, (b - l) / c * u)), A = Math.floor(_), I = s[A], w = s[Math.ceil(_)];
      return ye.interpolate(I, w, _ - A);
    };
    return { color: p, colorToArray: function(b, _, A) {
      ye.toArray(p(b), _, A);
    }, normalizedColorToArray: function(b, _, A) {
      ye.toArrayNormalized(p(b), _, A);
    }, setDomain: m, get legend() {
      return /* @__PURE__ */ function(b, _, A) {
        return { kind: "scale-legend", minLabel: b, maxLabel: _, colors: A };
      }(v, f, s);
    } };
  };
})(ko || (ko = {})), function(e) {
  e.toArray = function(t) {
    return Pg(t.values());
  }, e.isSuperset = function(t, n) {
    var r = !0;
    return n.forEach(function(i) {
      t.has(i) || (r = !1);
    }), r;
  }, e.add = function(t) {
    for (var n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];
    for (var i = 0; i < n.length; i++) n[i].forEach(function(a) {
      return t.add(a);
    });
    return t;
  }, e.union = function(t, n) {
    var r = new Set(t);
    return n.forEach(function(i) {
      return r.add(i);
    }), r;
  }, e.unionMany = function() {
    for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
    if (t.length === 0) return /* @__PURE__ */ new Set();
    t.length === 1 && new Set(t[0]);
    for (var r = new Set(t[0]), i = 1, a = t.length; i < a; i++) t[i].forEach(function(o) {
      return r.add(o);
    });
    return r;
  }, e.unionManyArrays = function(t) {
    if (t.length === 0) return /* @__PURE__ */ new Set();
    for (var n = new Set(t[0]), r = 1; r < t.length; r++) for (var i = 0, a = t[r]; i < a.length; i++) {
      var o = a[i];
      n.add(o);
    }
    return n;
  }, e.intersection = function(t, n) {
    var r = /* @__PURE__ */ new Set();
    return n.forEach(function(i) {
      t.has(i) && r.add(i);
    }), r;
  }, e.areIntersecting = function(t, n) {
    var r = !1;
    return n.forEach(function(i) {
      t.has(i) && (r = !0);
    }), r;
  }, e.intersectionSize = function(t, n) {
    var r = 0;
    return n.forEach(function(i) {
      t.has(i) && (r += 1);
    }), r;
  }, e.difference = function(t, n) {
    var r = new Set(t);
    return n.forEach(function(i) {
      return r.delete(i);
    }), r;
  }, e.differenceSize = function(t, n) {
    var r = t.size;
    return t.forEach(function(i) {
      n.has(i) && (r -= 1);
    }), r;
  }, e.areEqual = function(t, n) {
    if (t.size !== n.size) return !1;
    var r = !0;
    return n.forEach(function(i) {
      t.has(i) || (r = !1);
    }), r;
  };
}(Ii || (Ii = {}));
var Bg = function() {
};
function Si(e, t) {
  var n = e.length;
  if (n !== t.length) return !1;
  for (var r = 0; r < n; r++) if (e[r] !== t[r]) return !1;
  return !0;
}
var C7 = Object.prototype.hasOwnProperty;
function Iu(e, t) {
  if (e === t) return !0;
  var n = Array.isArray(e), r = Array.isArray(t);
  if (n && r) {
    if (e.length !== t.length) return !1;
    for (var i = 0; i < e.length; i++) if (!Iu(e[i], t[i])) return !1;
    return !0;
  }
  if (n !== r) return !1;
  if (e && t && typeof e == "object" && typeof t == "object") {
    var a = Object.keys(e);
    if (a.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 (i = 0; i < a.length; i++) if (!C7.call(t, a[i])) return !1;
    for (i = 0; i < a.length; i++) if (!Iu(e[a[i]], t[a[i]])) return !1;
    return !0;
  }
  return !1;
}
function V2(e, t) {
  if (e === t) return !0;
  var n = Array.isArray(e), r = Array.isArray(t);
  return n && r ? ZP(e, t) : n === r && !(!e || !t || typeof e != "object" || typeof t != "object") && A7(e, t);
}
function A7(e, t) {
  if (e === t) return !0;
  if (!e || !t) return !1;
  var n = Object.keys(e);
  if (Object.keys(t).length !== n.length) return !1;
  for (var r = 0, i = n; r < i.length; r++) {
    var a = i[r];
    if (!C7.call(e, a) || e[a] !== t[a]) return !1;
  }
  return !0;
}
function ZP(e, t) {
  if (e === t) return !0;
  if (!e || !t || e.length !== t.length) return !1;
  for (var n = 0, r = e.length; n < r; ++n) if (e[n] !== t[n]) return !1;
  return !0;
}
function mr(e, t) {
  return e !== void 0 ? e : t;
}
function ap(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 Ry(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 El, _c, ky = { noScroll: !0, noMiddleClickScroll: !0, noContextMenu: !0, noPinchZoom: !0, noTextSelect: !0, preventGestures: !1, mask: function(e, t) {
  return !0;
}, pixelScale: 1 };
function Oy() {
  return { drag: new $n(), interactionEnd: new $n(), click: new $n(), move: new $n(), wheel: new $n(), pinch: new $n(), gesture: new $n(), resize: new $n(), leave: new $n(), enter: new $n(), modifiers: new $n(), key: new $n() };
}
(function(e) {
  function t(n) {
    return n === void 0 && (n = {}), { shift: !!n.shift, alt: !!n.alt, control: !!n.control, meta: !!n.meta };
  }
  e.None = t(), e.areEqual = function(n, r) {
    return n.shift === r.shift && n.alt === r.alt && n.control === r.control && n.meta === r.meta;
  }, e.size = function(n) {
    if (!n) return 0;
    var r = 0;
    return n.shift && r++, n.alt && r++, n.control && r++, n.meta && r++, r;
  }, e.create = t;
})(El || (El = {})), function(e) {
  e.has = Qr.has, e.create = Qr.create;
}(_c || (_c = {}));
var z2, QP = ["Backspace", "Delete"];
function Pr() {
  return Pr.zero();
}
(function(e) {
  e.create = function(t) {
    t === void 0 && (t = {});
    var n = B(B({}, ky), t), r = n.noScroll, i = n.noContextMenu;
    return B(B({ noScroll: r, noContextMenu: i, width: 0, height: 0, pixelRatio: 1 }, Oy()), { dispose: Bg });
  }, e.fromElement = function(t, n) {
    n === void 0 && (n = {});
    var r = B(B({}, ky), n), i = r.noScroll, a = r.noMiddleClickScroll, o = r.noContextMenu, s = r.noPinchZoom, u = r.noTextSelect, c = r.mask, l = r.pixelScale, d = r.preventGestures, m = t.clientWidth * _(), p = t.clientHeight * _(), v = 0, f = 0, y = ge(), h = ge(), g = ge(), x = ge(), C = ge(), b = { shift: !1, alt: !1, control: !1, meta: !1 };
    function _() {
      return window.devicePixelRatio * l;
    }
    function A() {
      return B({}, b);
    }
    var I, w, E = 0, D = !1, T = _c.create(0), P = 0, M = !1, R = Oy(), O = R.drag, L = R.interactionEnd, F = R.wheel, G = R.pinch, V = R.gesture, U = R.click, q = R.move, H = R.leave, K = R.enter, j = R.resize, W = R.modifiers, Z = R.key;
    return t.addEventListener("contextmenu", Y, !1), t.addEventListener("wheel", Ce, !1), t.addEventListener("mousedown", xe, !1), window.addEventListener("mousemove", Xe, !1), window.addEventListener("mouseup", Ee, !1), t.addEventListener("mouseenter", Je, !1), t.addEventListener("mouseleave", lt, !1), t.addEventListener("touchstart", Oe, !1), t.addEventListener("touchmove", je, !1), t.addEventListener("touchend", ze, !1), t.addEventListener("gesturechange", we, !1), t.addEventListener("gesturestart", Te, !1), t.addEventListener("gestureend", Qe, !1), window.addEventListener("blur", ee), window.addEventListener("keyup", ue, !1), window.addEventListener("keydown", $, !1), window.addEventListener("keypress", se, !1), window.addEventListener("resize", st, !1), B(B({ get noScroll() {
      return i;
    }, set noScroll(pe) {
      i = pe;
    }, get noContextMenu() {
      return o;
    }, set noContextMenu(pe) {
      o = pe;
    }, get width() {
      return m;
    }, get height() {
      return p;
    }, get pixelRatio() {
      return _();
    } }, R), { dispose: function() {
      D || (D = !0, t.removeEventListener("contextmenu", Y, !1), t.removeEventListener("wheel", Ce, !1), t.removeEventListener("mousedown", xe, !1), window.removeEventListener("mousemove", Xe, !1), window.removeEventListener("mouseup", Ee, !1), t.removeEventListener("mouseenter", Je, !1), t.removeEventListener("mouseleave", lt, !1), t.removeEventListener("touchstart", Oe, !1), t.removeEventListener("touchmove", je, !1), t.removeEventListener("touchend", ze, !1), t.removeEventListener("gesturechange", we, !1), t.removeEventListener("gesturestart", Te, !1), t.removeEventListener("gestureend", Qe, !1), window.removeEventListener("blur", ee), window.removeEventListener("keyup", ue, !1), window.removeEventListener("keydown", $, !1), window.removeEventListener("keypress", se, !1), window.removeEventListener("resize", st, !1));
    } });
    function Y(pe) {
      c(pe.clientX, pe.clientY) && o && pe.preventDefault();
    }
    function te(pe) {
      b.alt = pe.altKey, b.shift = pe.shiftKey, b.control = pe.ctrlKey, b.meta = pe.metaKey;
    }
    function ee() {
      (T || b.shift || b.alt || b.meta || b.control) && (T = 0, b.shift = b.alt = b.control = b.meta = !1);
    }
    function $(pe) {
      var We = !1;
      !b.alt && pe.altKey && (We = !0, b.alt = !0), !b.shift && pe.shiftKey && (We = !0, b.shift = !0), !b.control && pe.ctrlKey && (We = !0, b.control = !0), !b.meta && pe.metaKey && (We = !0, b.meta = !0), We && M && W.next(A());
    }
    function ue(pe) {
      var We = !1;
      b.alt && !pe.altKey && (We = !0, b.alt = !1), b.shift && !pe.shiftKey && (We = !0, b.shift = !1), b.control && !pe.ctrlKey && (We = !0, b.control = !1), b.meta && !pe.metaKey && (We = !0, b.meta = !1), We && M && W.next(A()), QP.includes(pe.key) && se(pe);
    }
    function se(pe) {
      Z.next({ key: pe.key, modifiers: A() });
    }
    function be(pe) {
      var We = pe.touches[0], gt = pe.touches[1];
      return { clientX: (We.clientX + gt.clientX) / 2, clientY: (We.clientY + gt.clientY) / 2, pageX: (We.pageX + gt.pageX) / 2, pageY: (We.pageY + gt.pageY) / 2 };
    }
    function ke(pe) {
      var We = pe.touches[0].pageX - pe.touches[1].pageX, gt = pe.touches[0].pageY - pe.touches[1].pageY;
      return Math.sqrt(We * We + gt * gt);
    }
    function Oe(pe) {
      if (pe.preventDefault(), pe.touches.length === 1) T = P = 1, He(pe.touches[0]);
      else if (pe.touches.length === 2) {
        T = 0, P = 2, He(be(pe));
        var We = ke(pe);
        v = We, G.next({ distance: We, fraction: 1, fractionDelta: 0, delta: 0, isStart: !0, buttons: T, button: P, modifiers: A() });
      } else pe.touches.length === 3 && (T = P = 8, He(be(pe)));
    }
    function ze(pe) {
      Ye();
    }
    function je(pe) {
      if (P = 0, s && (pe.preventDefault(), pe.stopPropagation(), pe.originalEvent && (pe.originalEvent.preventDefault(), pe.originalEvent.stopPropagation())), pe.touches.length === 1) T = 1, le(pe.touches[0]);
      else if (pe.touches.length === 2) {
        var We = ke(pe), gt = v - We;
        if (Math.abs(gt) < 4) T = 2, le(be(pe));
        else {
          T = 4, te(pe);
          var cn = v / We;
          G.next({ delta: gt, fraction: cn, fractionDelta: f - cn, distance: We, isStart: !1, buttons: T, button: P, modifiers: A() }), f = cn;
        }
        v = We;
      } else pe.touches.length === 3 && (T = 8, le(be(pe)));
    }
    function xe(pe) {
      te(pe), T = ap(pe), P = Ry(pe), a && T === 4 && pe.preventDefault, He(pe);
    }
    function Xe(pe) {
      te(pe), T = ap(pe), P = 0, le(pe);
    }
    function Ee(pe) {
      te(pe), T = ap(pe), P = Ry(pe), function(We) {
        if (E = 0, !!c(We.clientX, We.clientY) && (It(g, We), ge.distance(g, y) < 4)) {
          var gt = We.pageX, cn = We.pageY, Kt = g[0], hn = g[1];
          U.next({ x: Kt, y: hn, pageX: gt, pageY: cn, buttons: T, button: P, modifiers: A() });
        }
      }(pe), Ye();
    }
    function Ye() {
      L.next(void 0);
    }
    function He(pe) {
      c(pe.clientX, pe.clientY) && (It(h, pe), ge.copy(y, h), ft(h) && (E = 1));
    }
    function le(pe) {
      var We;
      It(g, pe);
      var gt, cn = pe.pageX, Kt = pe.pageY, hn = g[0], jt = g[1], Rn = ft(g);
      if (q.next({ x: hn, y: jt, pageX: cn, pageY: Kt, buttons: T, button: P, modifiers: A(), inside: Rn }), E !== 0 && (u && ((We = pe.preventDefault) === null || We === void 0 || We.call(pe)), ge.div(x, ge.sub(x, g, h), ((gt = C)[0] = t.clientWidth, gt[1] = t.clientHeight, gt)), !(ge.magnitude(x) < bn))) {
        var ur = E === 1;
        if (!ur || c(pe.clientX, pe.clientY)) {
          var ir = x[0], Hn = x[1];
          O.next({ x: hn, y: jt, dx: ir, dy: Hn, pageX: cn, pageY: Kt, buttons: T, button: P, modifiers: A(), isStart: ur }), ge.copy(h, g), E = 2;
        }
      }
    }
    function Ce(pe) {
      if (c(pe.clientX, pe.clientY)) {
        It(g, pe);
        var We = pe.pageX, gt = pe.pageY, cn = g[0], Kt = g[1];
        i && pe.preventDefault();
        var hn = function(jt) {
          var Rn = 10, ur = 40, ir = 800, Hn = 0, Dn = 0, Dr = 0, En = 0, Tn = 0;
          return "detail" in jt && (Dn = jt.detail), "wheelDelta" in jt && (Dn = -jt.wheelDelta / 120), "wheelDeltaY" in jt && (Dn = -jt.wheelDeltaY / 120), "wheelDeltaX" in jt && (Hn = -jt.wheelDeltaX / 120), "axis" in jt && jt.axis === jt.HORIZONTAL_AXIS && (Hn = Dn, Dn = 0), Dr = Hn * Rn, En = Dn * Rn, "deltaY" in jt && (En = jt.deltaY), "deltaX" in jt && (Dr = jt.deltaX), "deltaZ" in jt && (Tn = jt.deltaZ), (Dr || En || Tn) && jt.deltaMode && (jt.deltaMode === 1 ? (Dr *= ur, En *= ur, Tn *= ur) : (Dr *= ir, En *= ir, Tn *= ir)), Dr && !Hn && (Hn = Dr < 1 ? -1 : 1), En && !Dn && (Dn = En < 1 ? -1 : 1), { spinX: Hn, spinY: Dn, dx: Dr, dy: En, dz: Tn };
        }(pe);
        T = P = 4, (hn.dx || hn.dy || hn.dz) && F.next(B(B({ x: cn, y: Kt, pageX: We, pageY: gt }, hn), { buttons: T, button: P, modifiers: A() }));
      }
    }
    function Ae(pe) {
      var We, gt;
      d && (pe.preventDefault(), (We = pe.stopImmediatePropagation) === null || We === void 0 || We.call(pe), (gt = pe.stopPropagation) === null || gt === void 0 || gt.call(pe));
    }
    function Te(pe) {
      Ae(pe), I = pe.scale, w = pe.rotation, V.next({ scale: pe.scale, rotation: pe.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0 });
    }
    function Re(pe, We) {
      V.next({ scale: pe.scale, rotation: pe.rotation, deltaRotation: w - pe.rotation, deltaScale: I - pe.scale, isEnd: We }), w = pe.rotation, I = pe.scale;
    }
    function we(pe) {
      Ae(pe), Re(pe);
    }
    function Qe(pe) {
      Ae(pe), Re(pe, !0);
    }
    function Je(pe) {
      M = !0, K.next(void 0);
    }
    function lt(pe) {
      M = !1, H.next(void 0);
    }
    function st(pe) {
      j.next({});
    }
    function ft(pe) {
      if (t instanceof Window || t instanceof Document || t === document.body) return !0;
      var We = t.getBoundingClientRect();
      return pe[0] >= 0 && pe[1] >= 0 && pe[0] < We.width && pe[1] < We.height;
    }
    function It(pe, We) {
      m = t.clientWidth * _(), p = t.clientHeight * _();
      var gt = We.clientX || 0, cn = We.clientY || 0, Kt = t.getBoundingClientRect();
      return pe[0] = gt - Kt.left, pe[1] = cn - Kt.top, pe;
    }
  };
})(z2 || (z2 = {})), function(e) {
  e.zero = function() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }, e.create = function(t, n, r, i) {
    return { x: t, y: n, width: r, height: i };
  }, e.clone = function(t) {
    return B({}, t);
  }, e.copy = function(t, n) {
    return Object.assign(t, n);
  }, e.set = function(t, n, r, i, a) {
    return t.x = n, t.y = r, t.width = i, t.height = a, t;
  }, e.toVec4 = function(t, n) {
    return t[0] = n.x, t[1] = n.y, t[2] = n.width, t[3] = n.height, t;
  }, e.equals = function(t, n) {
    return t.x === n.x && t.y === n.y && t.width === n.width && t.height === n.height;
  };
}(Pr || (Pr = {}));
var co = vt();
function Od(e, t, n, r) {
  var i = n.x, a = n.y, o = n.width, s = n.height, u = t[0] - i, c = s - t[1] - 1 - a, l = t[2];
  return e[0] = 2 * u / o - 1, e[1] = 2 * c / s - 1, e[2] = 2 * l - 1, S.transformMat4(e, e, r);
}
var I7 = Object.prototype.hasOwnProperty;
function JP(e, t) {
  if (!e) return !t;
  if (!t) return !1;
  var n = Object.keys(e);
  if (Object.keys(t).length !== n.length) return !1;
  for (var r = 0, i = n; r < i.length; r++) {
    var a = i[r];
    if (!I7.call(e, a) || e[a] !== t[a]) return !1;
  }
  return !0;
}
function xs(e) {
  if (e === null || typeof e != "object") return e;
  if (e instanceof Array) {
    for (var t = [], n = 0, r = e.length; n < r; n++) t[n] = xs(e[n]);
    return t;
  }
  if (typeof e == "object" && !("prototype" in e)) {
    t = {};
    for (var i in e) I7.call(e, i) && (t[i] = xs(e[i]));
    return t;
  }
  throw new Error(`Can't clone, type "`.concat(typeof e, '" unsupported'));
}
function w7(e, t) {
  if (e) for (var n = 0, r = Object.keys(e); n < r.length; n++) {
    var i = r[n];
    t(e[i], i);
  }
}
var U2 = typeof setImmediate < "u" ? typeof window < "u" ? { setImmediate: function(e) {
  for (var t, n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];
  return (t = window).setImmediate.apply(t, Pe([e], n, !1));
}, clearImmediate: function(e) {
  return window.clearImmediate(e);
} } : { setImmediate, clearImmediate } : function() {
  var e, t, n, r, i, a, o, s, u = (e = typeof window < "u" && window, t = typeof self < "u" && typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope && self, n = typeof global < "u" && global, e || n || t), c = {}, l = typeof document < "u" ? document : void 0, d = 1;
  function m(v) {
    delete c[v];
  }
  function p(v) {
    var f = c[v];
    m(v), function(y) {
      var h = y.callback, g = y.args;
      switch (g.length) {
        case 0:
          h();
          break;
        case 1:
          h(g[0]);
          break;
        case 2:
          h(g[0], g[1]);
          break;
        case 3:
          h(g[0], g[1], g[2]);
          break;
        default:
          h.apply(void 0, g);
      }
    }(f);
  }
  return typeof process < "u" && {}.toString.call(process) === "[object process]" ? r = function(v) {
    process.nextTick(function() {
      p(v);
    });
  } : function() {
    if (u && u.postMessage && !u.importScripts) {
      var v = !0, f = u.onmessage;
      return u.onmessage = function() {
        v = !1;
      }, u.postMessage("", "*"), u.onmessage = f, v;
    }
  }() ? (o = "setImmediate$" + Math.random() + "$", s = function(v) {
    v.source === u && typeof v.data == "string" && v.data.indexOf(o) === 0 && p(+v.data.slice(o.length));
  }, window.addEventListener ? window.addEventListener("message", s, !1) : window.attachEvent("onmessage", s), r = function(v) {
    window.postMessage(o + v, "*");
  }) : typeof MessageChannel < "u" ? ((a = new MessageChannel()).port1.onmessage = function(v) {
    p(v.data);
  }, r = function(v) {
    a.port2.postMessage(v);
  }) : l && "onreadystatechange" in l.createElement("script") ? (i = l.documentElement, r = function(v) {
    var f = l.createElement("script");
    f.onreadystatechange = function() {
      p(v), f.onreadystatechange = null, i.removeChild(f), f = null;
    }, i.appendChild(f);
  }) : r = function(v) {
    setTimeout(p, 0, v);
  }, { setImmediate: function(v) {
    for (var f = [], y = 1; y < arguments.length; y++) f[y - 1] = arguments[y];
    typeof v != "function" && (v = new Function("" + v));
    var h = { callback: v, args: f };
    return c[d] = h, r(d), d++;
  }, clearImmediate: m };
}();
function $P(e) {
  U2.setImmediate(e);
}
var Qd, Rg = { setImmediate: U2.setImmediate, clearImmediate: U2.clearImmediate, immediatePromise: function() {
  return new Promise($P);
}, delay: function(e, t) {
  return t === void 0 && (t = void 0), new Promise(function(n) {
    return setTimeout(n, e, t);
  });
} }, P7 = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), Xt = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), op = typeof performance < "u" && !!performance.mark && performance.measure && !P7;
function eE(e, t, n) {
  n === void 0 && (n = 250);
  var r = function(i, a, o) {
    var s = { abortRequested: !1, treeAborted: !1, reason: "" };
    return { updateRateMs: o, lastNotified: nr(), observer: a, abortToken: s, taskId: i.id, root: { progress: E7(i), children: [] }, tryAbort: tE(s) };
  }(e, t, n);
  return kg(e, new nE(r, r.root));
}
function E7(e) {
  return { taskId: e.id, taskName: e.name, message: "", startedTime: 0, canAbort: !0, isIndeterminate: !0, current: 0, max: 0 };
}
function tE(e) {
  return function(t) {
    e.abortRequested = !0, e.reason = t || e.reason;
  };
}
function T7(e) {
  return { progress: B({}, e.progress), children: e.children.map(T7) };
}
function M7(e) {
  return e.progress.canAbort && e.children.every(M7);
}
function kg(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          Qd.markStart(e), t.node.progress.startedTime = nr(), i.label = 1;
        case 1:
          return i.trys.push([1, 3, , 7]), [4, e.f(t)];
        case 2:
          return n = i.sent(), Qd.markEnd(e), Qd.measure(e), t.info.abortToken.abortRequested && D7(t.info), [2, n];
        case 3:
          return r = i.sent(), At.isAbort(r) ? (t.isAborted = !0, t.node.children.length > 0 ? [4, new Promise(function(a) {
            t.onChildrenFinished = a;
          })] : [3, 5]) : [3, 6];
        case 4:
          i.sent(), i.label = 5;
        case 5:
          e.onAbort && e.onAbort(), i.label = 6;
        case 6:
          throw r;
        case 7:
          return [2];
      }
    });
  });
}
function D7(e) {
  throw e.abortToken.treeAborted || (e.abortToken.treeAborted = !0, B7(e.root), R7(e, nr())), At.Aborted(e.abortToken.reason);
}
function B7(e) {
  var t = e.progress;
  t.isIndeterminate = !0, t.canAbort = !1, t.message = "Aborting...";
  for (var n = 0, r = e.children; n < r.length; n++)
    B7(r[n]);
}
function R7(e, t) {
  e.lastNotified = t;
  var n = function(r) {
    return { root: T7(r.root), canAbort: M7(r.root), requestAbort: r.tryAbort };
  }(e);
  e.observer(n);
}
(function(e) {
  function t(r) {
    return "startTask".concat(r.id);
  }
  function n(r) {
    return "endTask".concat(r.id);
  }
  e.markStart = function(r) {
    op && performance.mark(t(r));
  }, e.markEnd = function(r) {
    op && performance.mark(n(r));
  }, e.measure = function(r) {
    op && performance.measure("✳️ ".concat(r.name), t(r), n(r));
  };
})(Qd || (Qd = {}));
var At, Ny, Ly, nE = function() {
  function e(t, n) {
    this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = n, this.info = t;
  }
  return e.prototype.checkAborted = function() {
    this.info.abortToken.abortRequested && (this.isAborted = !0, D7(this.info));
  }, Object.defineProperty(e.prototype, "shouldUpdate", { get: function() {
    return this.checkAborted(), nr() - this.lastUpdatedTime > this.info.updateRateMs;
  }, enumerable: !1, configurable: !0 }), e.prototype.updateProgress = function(t) {
    if (this.checkAborted(), t) {
      var n = this.node.progress;
      typeof t == "string" ? (n.message = t, n.isIndeterminate = !0) : (t.canAbort !== void 0 && (n.canAbort = t.canAbort), t.message !== void 0 && (n.message = t.message), t.current !== void 0 && (n.current = t.current), t.max !== void 0 && (n.max = t.max), n.isIndeterminate = n.current === void 0 || n.max === void 0, t.isIndeterminate !== void 0 && (n.isIndeterminate = t.isIndeterminate));
    }
  }, e.prototype.update = function(t, n) {
    if (this.lastUpdatedTime = nr(), this.updateProgress(t), !n) return R7(this.info, this.lastUpdatedTime), this.checkAborted(), Rg.immediatePromise();
  }, e.prototype.runChild = function(t, n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c;
      return ne(this, function(l) {
        switch (l.label) {
          case 0:
            this.updateProgress(n), r = { progress: E7(t), children: [] }, (i = this.node.children).push(r), a = new e(this.info, r), l.label = 1;
          case 1:
            return l.trys.push([1, 3, 4, 5]), [4, kg(t, a)];
          case 2:
            return [2, l.sent()];
          case 3:
            if (o = l.sent(), At.isAbort(o) && this.isAborted) return [2, void 0];
            throw o;
          case 4:
            if ((s = i.indexOf(r)) >= 0) {
              for (u = s, c = i.length - 1; u < c; u++) i[u] = i[u + 1];
              i.pop();
            }
            return i.length === 0 && this.onChildrenFinished && this.onChildrenFinished(), [7];
          case 5:
            return [2];
        }
      });
    });
  }, e;
}(), Ji = new (function() {
  function e() {
    this.shouldUpdate = !1, this.isSynchronous = !0;
  }
  return e.prototype.update = function(t, n) {
  }, e;
}())();
function mf(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s, u, c, l, d;
    return ne(this, function(m) {
      switch (m.label) {
        case 0:
          if (a = Math.max(t, 0), o = 0, s = 0, e.isSynchronous) return r(Number.MAX_SAFE_INTEGER, n), [2, n];
          u = nr(), c = 0, l = 0, m.label = 1;
        case 1:
          return (c = r(a, n)) > 0 ? (o += c, d = nr() - u, l += d, s += d, e.shouldUpdate ? [4, i(e, n, o)] : [3, 3]) : [3, 4];
        case 2:
          m.sent(), a = Math.round(l * o / s) + 1, u = nr(), l = 0, m.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return e.shouldUpdate ? [4, i(e, n, o)] : [3, 6];
        case 5:
          m.sent(), m.label = 6;
        case 6:
          return [2, n];
      }
    });
  });
}
function du(e, t) {
  return e[t] | e[t + 1] << 8;
}
function ic(e, t) {
  return 16777216 * e[t + 3] + (e[t + 2] << 16 | e[t + 1] << 8 | e[t]);
}
function rE(e) {
  return e.length < 2 ? "0" + e : e;
}
function iE(e, t, n) {
  for (var r, i = "", a = 0; a < n; a++) i += "%" + rE(e[t + a].toString(16));
  try {
    r = decodeURIComponent(i);
  } catch {
    return function(s, u, c) {
      for (var l = "", d = 0; d < c; d++) l += String.fromCharCode(s[u + d]);
      return l;
    }(e, t, n);
  }
  return r;
}
(function(e) {
  var t = function() {
    function a(o, s, u) {
      this.name = o, this.f = s, this.onAbort = u, this.id = i();
    }
    return a.prototype.run = function(o, s) {
      return s === void 0 && (s = 250), o ? eE(this, o, s) : this.f(Ji);
    }, a.prototype.runAsChild = function(o, s) {
      return o.isSynchronous ? this.f(Ji) : function(u, c, l) {
        return u.runChild(c, l);
      }(o, this, s);
    }, a.prototype.runInContext = function(o) {
      return o.isSynchronous ? this.f(Ji) : function(s, u) {
        return kg(u, s);
      }(o, this);
    }, a;
  }();
  function n(a) {
    var o = a;
    return !!a && typeof o.id == "number" && typeof o.name == "string" && !!o.run;
  }
  function r(a, o, s) {
    return new t(a, o, s);
  }
  e.is = n, e.isAbort = function(a) {
    return !!a && !!a.isAborted;
  }, e.Aborted = function(a) {
    return { isAborted: !0, reason: a, toString: function() {
      return "Aborted".concat(a ? ": " + a : "");
    } };
  }, e.create = r, e.constant = function(a, o) {
    var s = this;
    return r(a, function(u) {
      return ie(s, 0, void 0, function() {
        return ne(this, function(c) {
          return [2, o];
        });
      });
    });
  }, e.empty = function() {
    var a = this;
    return r("", function(o) {
      return ie(a, 0, void 0, function() {
        return ne(this, function(s) {
          return [2];
        });
      });
    });
  }, e.fail = function(a, o) {
    var s = this;
    return r(a, function(u) {
      return ie(s, 0, void 0, function() {
        return ne(this, function(c) {
          throw new Error(o);
        });
      });
    });
  }, e.resolveInContext = function(a, o) {
    return n(a) ? o ? a.runInContext(o) : a.run() : a;
  };
  var i = fi(0, 1073741823);
})(At || (At = {})), function(e) {
  e.Synchronous = Ji;
}(Ny || (Ny = {})), function(e) {
  function t(n, r) {
    r === void 0 && (r = "");
    var i = n.progress;
    if (!n.children.length) return i.isIndeterminate ? "".concat(r).concat(i.taskName, ": ").concat(i.message) : "".concat(r).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message);
    var a = r + "  |_ ", o = n.children.map(function(s) {
      return t(s, a);
    });
    return i.isIndeterminate ? "".concat(r).concat(i.taskName, ": ").concat(i.message, `
`).concat(o.join(`
`)) : "".concat(r).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message, `
`).concat(o.join(`
`));
  }
  e.format = function(n) {
    return t(n.root);
  };
}(Ly || (Ly = {}));
var aE = function() {
  for (var e = new Uint32Array(256), t = 0; t < 256; t++) {
    for (var n = t, r = 0; r < 8; r++) 1 & n ? n = 3988292384 ^ n >>> 1 : n >>>= 1;
    e[t] = n;
  }
  return e;
}();
function oE(e, t, n) {
  return 4294967295 ^ function(r, i, a, o) {
    for (var s = 0; s < o; s++) r = aE[255 & (r ^ i[a + s])] ^ r >>> 8;
    return r;
  }(4294967295, e, t, n);
}
var oa, zc, xt = (oa = Uint16Array, zc = Uint32Array, { next_code: new oa(16), bl_count: new oa(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 oa(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 zc(32), flmap: new oa(512), fltree: [], fdmap: new oa(32), fdtree: [], lmap: new oa(32768), ltree: [], ttree: [], dmap: new oa(32768), dtree: [], imap: new oa(512), itree: [], rev15: new oa(32768), lhst: new zc(286), dhst: new zc(30), ihst: new zc(19), lits: new zc(15e3), strt: new oa(65536), prev: new oa(32768) });
function Jd(e, t, n) {
  for (var r = e.length, i = xt.rev15, a = 0; a < r; a += 2) if (e[a + 1] !== 0) for (var o = a >> 1, s = e[a + 1], u = o << 4 | s, c = t - s, l = e[a] << c, d = l + (1 << c); l !== d; )
    n[i[l] >>> 15 - t] = u, l++;
}
function $d(e, t) {
  for (var n = e.length, r = xt.bl_count, i = 0; i <= t; i++) r[i] = 0;
  for (i = 1; i < n; i += 2) r[e[i]]++;
  var a = xt.next_code, o = 0;
  r[0] = 0;
  for (var s = 1; s <= t; s++) o = o + r[s - 1] << 1, a[s] = o;
  for (var u = 0; u < n; u += 2) {
    var c = e[u + 1];
    c !== 0 && (e[u] = a[c], a[c]++);
  }
}
function Fy(e, t) {
  for (var n = xt.rev15, r = 15 - t, i = 0; i < e.length; i += 2) {
    var a = e[i] << t - e[i + 1];
    e[i] = n[a] >>> r;
  }
}
function sE(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          if (t[0] === 3 && t[1] === 0) return [2, n || new Uint8Array(0)];
          r = function(a, o) {
            var s = o === void 0;
            return o === void 0 && (o = new Uint8Array(a.length >>> 2 << 3)), { data: a, buf: o, noBuf: s, BFINAL: 0, off: 0, pos: 0 };
          }(t, n), i.label = 1;
        case 1:
          return r.BFINAL !== 0 ? [3, 4] : e.shouldUpdate ? [4, e.update({ message: "Inflating blocks...", current: r.pos, max: t.length })] : [3, 3];
        case 2:
          i.sent(), i.label = 3;
        case 3:
          return function(a, o) {
            for (var s = a.data, u = a.noBuf, c = a.buf, l = a.BFINAL, d = a.off, m = a.pos, p = 0; l === 0 && p < o; ) {
              var v = void 0, f = void 0, y = 0, h = 0;
              l = up(s, m, 1), p += 1;
              var g = up(s, m + 1, 2);
              if (m += 3, g !== 0) {
                if (u && (c = sp(c, d + (1 << 17))), g === 1) v = xt.flmap, f = xt.fdmap, y = 511, h = 31;
                else {
                  if (g !== 2) throw new Error("unknown BTYPE ".concat(g));
                  var x = nu(s, m, 5) + 257, C = nu(s, m + 5, 5) + 1, b = nu(s, m + 10, 4) + 4;
                  m += 14;
                  for (var _ = 0; _ < 38; _ += 2) xt.itree[_] = 0, xt.itree[_ + 1] = 0;
                  var A = 1;
                  for (_ = 0; _ < b; _++) {
                    var I = nu(s, m + 3 * _, 3);
                    xt.itree[1 + (xt.ordr[_] << 1)] = I, I > A && (A = I);
                  }
                  m += 3 * b, $d(xt.itree, A), Jd(xt.itree, A, xt.imap), v = xt.lmap, f = xt.dmap, m = uE(xt.imap, (1 << A) - 1, x + C, s, m, xt.ttree);
                  var w = Gy(xt.ttree, 0, x, xt.ltree);
                  y = (1 << w) - 1;
                  var E = Gy(xt.ttree, x, C, xt.dtree);
                  h = (1 << E) - 1, $d(xt.ltree, w), Jd(xt.ltree, w, v), $d(xt.dtree, E), Jd(xt.dtree, E, f);
                }
                for (; ; ) {
                  var D = v[H2(s, m) & y];
                  m += 15 & D;
                  var T = D >>> 4;
                  if (!(T >>> 8)) c[d++] = T;
                  else {
                    if (T === 256) break;
                    var P = d + T - 254;
                    if (T > 264) {
                      var M = xt.ldef[T - 257];
                      P = d + (M >>> 3) + nu(s, m, 7 & M), m += 7 & M;
                    }
                    var R = f[H2(s, m) & h];
                    m += 15 & R;
                    var O = R >>> 4, L = xt.ddef[O], F = (L >>> 4) + up(s, m, 15 & L);
                    for (m += 15 & L, u && (c = sp(c, d + (1 << 17))); d < P; ) c[d] = c[d++ - F], c[d] = c[d++ - F], c[d] = c[d++ - F], c[d] = c[d++ - F];
                    d = P;
                  }
                }
              } else {
                7 & m && (m += 8 - (7 & m));
                var G = 4 + (m >>> 3), V = s[G - 4] | s[G - 3] << 8;
                u && (c = sp(c, d + V)), c.set(new Uint8Array(s.buffer, s.byteOffset + G, V), d), m = G + V << 3, d += V;
              }
            }
            a.buf = c, a.BFINAL = l, a.off = d, a.pos = m;
          }(r, 100), [3, 1];
        case 4:
          return [2, r.buf.length === r.off ? r.buf : r.buf.slice(0, r.off)];
      }
    });
  });
}
function sp(e, t) {
  var n = e.length;
  if (t <= n) return e;
  var r = new Uint8Array(Math.max(n << 1, t));
  return r.set(e, 0), r;
}
function uE(e, t, n, r, i, a) {
  for (var o = 0; o < n; ) {
    var s = e[H2(r, i) & t];
    i += 15 & s;
    var u = s >>> 4;
    if (u <= 15) a[o] = u, o++;
    else {
      var c = 0, l = 0;
      u === 16 ? (l = 3 + nu(r, i, 2), i += 2, c = a[o - 1]) : u === 17 ? (l = 3 + nu(r, i, 3), i += 3) : u === 18 && (l = 11 + nu(r, i, 7), i += 7);
      for (var d = o + l; o < d; ) a[o] = c, o++;
    }
  }
  return i;
}
function Gy(e, t, n, r) {
  for (var i = 0, a = 0, o = r.length >>> 1; a < n; ) {
    var s = e[a + t];
    r[a << 1] = 0, r[1 + (a << 1)] = s, s > i && (i = s), a++;
  }
  for (; a < o; ) r[a << 1] = 0, r[1 + (a << 1)] = 0, a++;
  return i;
}
function nu(e, t, n) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8) >>> (7 & t) & (1 << n) - 1;
}
function up(e, t, n) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t) & (1 << n) - 1;
}
function H2(e, t) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t);
}
function k7(e, t, n) {
  return n === void 0 && (n = !1), ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c, l, d, m, p, v, f;
    return ne(this, function(y) {
      switch (y.label) {
        case 0:
          for (r = /* @__PURE__ */ Object.create(null), i = new Uint8Array(t), a = i.length - 4; ic(i, a) !== 101010256; ) a--;
          o = a, o += 4, s = du(i, o += 4), o += 2, o += 2, u = ic(i, o += 4), o += 4, o = u, c = 0, y.label = 1;
        case 1:
          return c < s ? (o += 4, o += 4, o += 4, o += 4, l = ic(i, o += 4), d = ic(i, o += 4), m = du(i, o += 4), p = du(i, o + 2), v = du(i, o + 4), o += 6, f = ic(i, o += 8), o += 4, o += m + p + v, [4, cE(e, i, f, r, l, d, n)]) : [3, 4];
        case 2:
          y.sent(), y.label = 3;
        case 3:
          return c++, [3, 1];
        case 4:
          return [2, r];
      }
    });
  });
}
function cE(e, t, n, r, i, a, o) {
  return ie(this, 0, void 0, function() {
    var s, u, c, l, d, m;
    return ne(this, function(p) {
      switch (p.label) {
        case 0:
          return n += 4, n += 2, s = du(t, n += 2), n += 2, n += 4, n += 4, u = du(t, n += 8), c = du(t, n += 2), l = iE(t, n += 2, u), n += u, n += c, o ? (r[l] = { size: a, csize: i }, [2]) : (d = new Uint8Array(t.buffer, n), s !== 0 ? [3, 1] : (r[l] = new Uint8Array(d.buffer.slice(n, n + i)), [3, 4]));
        case 1:
          return s !== 8 ? [3, 3] : (m = new Uint8Array(a), [4, O7(e, d, m)]);
        case 2:
          return p.sent(), r[l] = m, [3, 4];
        case 3:
          throw new Error("unknown compression method: ".concat(s));
        case 4:
          return [2];
      }
    });
  });
}
function O7(e, t, n) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(r) {
      return [2, sE(e, t, n)];
    });
  });
}
function lE(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c, l, d;
    return ne(this, function(m) {
      switch (m.label) {
        case 0:
          if (r = t[3], i = 10, 4 & r && (a = du(t, i), i += a), 8 & r) {
            for (o = i; t[o] !== 0; ) ++o;
            i = o + 1;
          }
          if (16 & r) {
            for (o = i; t[o] !== 0; ) ++o;
            i = o + 1;
          }
          return 1 & r && (i += 2), s = function(p) {
            return 0 | p;
          }(ic(t, t.length - 8)), u = ic(t, t.length - 4), n === void 0 && (n = new Uint8Array(u)), c = new Uint8Array(t.buffer, t.byteOffset + i, t.length - i - 8), [4, O7(e, c, n)];
        case 1:
          return l = m.sent(), d = oE(l, 0, l.length), s !== d && console.error("ungzip: checksums don't match"), [2, l];
      }
    });
  });
}
function r1(e, t, n) {
  for (var r = 0, i = n.length; r < i; r++) {
    var a = n.charCodeAt(r);
    if (a < 128) e[t++] = a >>> 0 & 127;
    else if (a < 2048) e[t++] = a >>> 6 & 31 | 192, e[t++] = a >>> 0 & 63 | 128;
    else if (a < 65536) e[t++] = a >>> 12 & 15 | 224, e[t++] = a >>> 6 & 63 | 128, e[t++] = a >>> 0 & 63 | 128;
    else {
      if (!(a < 1114112)) throw new Error("bad codepoint " + a);
      e[t++] = a >>> 18 & 7 | 240, e[t++] = a >>> 12 & 63 | 128, e[t++] = a >>> 6 & 63 | 128, e[t++] = a >>> 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, xt.rev15[e] = (t >>> 16 | t << 16) >>> 17;
  }
  function n(r, i, a) {
    for (; i-- != 0; ) r.push(0, a);
  }
  for (e = 0; e < 32; e++) xt.ldef[e] = xt.of0[e] << 3 | xt.exb[e], xt.ddef[e] = xt.df0[e] << 4 | xt.dxb[e];
  n(xt.fltree, 144, 8), n(xt.fltree, 112, 9), n(xt.fltree, 24, 7), n(xt.fltree, 8, 8), $d(xt.fltree, 9), Jd(xt.fltree, 9, xt.flmap), Fy(xt.fltree, 9), n(xt.fdtree, 32, 5), $d(xt.fdtree, 5), Jd(xt.fdtree, 5, xt.fdmap), Fy(xt.fdtree, 5), n(xt.itree, 19, 0), n(xt.ltree, 286, 0), n(xt.dtree, 30, 0), n(xt.ttree, 320, 0);
})();
var dE = function() {
  for (var e = [], t = 0; t < 1024; t++) e[t] = String.fromCharCode(t);
  return e;
}();
function N7(e) {
  throw new Error(e);
}
var Vy = typeof TextDecoder < "u" ? new TextDecoder() : void 0;
function L7(e, t, n) {
  if (Vy) {
    var r = t || n !== e.length ? e.subarray(t, t + n) : e;
    return Vy.decode(r);
  }
  return function(i, a, o) {
    for (var s = dE, u = void 0, c = 0, l = [], d = a, m = a + o; d < m; d++) {
      var p = i[d];
      128 & p ? (224 & p) == 192 ? l[c++] = s[(15 & p) << 6 | 63 & i[++d]] : (240 & p) == 224 ? l[c++] = String.fromCharCode((15 & p) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : (248 & p) == 240 ? l[c++] = String.fromCharCode((7 & p) << 18 | (63 & i[++d]) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : N7("Invalid byte " + p.toString(16)) : l[c++] = s[p], 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, n);
}
function F7(e) {
  for (var t = 0, n = 0, r = e.length; n < r; n++) {
    var i = e.charCodeAt(n);
    i < 128 ? t += 1 : i < 2048 ? t += 2 : i < 65536 ? t += 3 : i < 1114112 ? t += 4 : N7("bad codepoint " + i);
  }
  return t;
}
var Za, fE = XMLHttpRequest;
function i1(e, t) {
  return function(n, r) {
    var i = this, a = void 0;
    return At.create("Read File", function(o) {
      return ie(i, 0, void 0, function() {
        var s, u;
        return ne(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, , 5, 6]), a = new FileReader(), s = r === "zip" ? Za.None : (l = n.name, /\.gz$/i.test(l) ? Za.Gzip : /\.zip$/i.test(l) ? Za.Zip : Za.None), r === "binary" || r === "zip" || s !== Za.None ? a.readAsArrayBuffer(n) : a.readAsText(n), [4, o.update({ message: "Opening file...", canAbort: !0 })];
            case 1:
              return c.sent(), [4, G7(o, "Reading...", a)];
            case 2:
              return u = c.sent(), [4, o.update({ message: "Processing file...", canAbort: !1 })];
            case 3:
              return c.sent(), [4, hE(o, u, r, s)];
            case 4:
              return [2, c.sent()];
            case 5:
              return a = void 0, [7];
            case 6:
              return [2];
          }
          var l;
        });
      });
    }, function() {
      a && a.abort();
    });
  }(e, t);
}
function zy(e) {
  return typeof e == "string" ? Hy(e, e, "string") : Hy(e.title, e.url, e.type || "string", e.body, e.headers);
}
function Uy(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 G7(e, t, n) {
  return new Promise(function(r, i) {
    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");
    }(n)) {
      var a = n.error;
      a != null ? i(a ?? Uy(n instanceof XMLHttpRequest)) : r(n);
    } else {
      var o = !1;
      n.onerror = function(s) {
        if (!o) {
          var u = s.target.error;
          i(u ?? Uy(n instanceof XMLHttpRequest));
        }
      }, n.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, i(u);
        }
      }, n.onload = function(s) {
        r(n);
      };
    }
  });
}
(function(e) {
  e[e.None = 0] = "None", e[e.Gzip = 1] = "Gzip", e[e.Zip = 2] = "Zip";
})(Za || (Za = {}));
var mE = /^(__MACOSX|.DS_Store)/;
function pE(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          switch (n) {
            case Za.None:
              return [3, 1];
            case Za.Gzip:
              return [3, 2];
            case Za.Zip:
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return [2, t];
        case 2:
          return [2, lE(e, t)];
        case 3:
          return [4, k7(e, t.buffer)];
        case 4:
          if (r = a.sent(), i = Object.keys(r).filter(function(o) {
            return !mE.test(o);
          }), i.length !== 1) throw new Error("can only decompress zip files with a single entry");
          return [2, r[i[0]]];
        case 5:
          return [2];
      }
    });
  });
}
function hE(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          if (i = t.result, (a = i instanceof ArrayBuffer ? new Uint8Array(i) : i) === null) throw new Error("no data given");
          if (r === Za.None) return [3, 4];
          if (!(a instanceof Uint8Array)) throw new Error("need Uint8Array for decompression");
          return [4, pE(e, a, r)];
        case 1:
          return o = s.sent(), n !== "string" ? [3, 3] : [4, e.update({ message: "Decoding text..." })];
        case 2:
          return s.sent(), a = L7(o, 0, o.length), [3, 4];
        case 3:
          a = o, s.label = 4;
        case 4:
          return n === "binary" && a instanceof Uint8Array ? [2, a] : [3, 5];
        case 5:
          return n === "zip" && a instanceof Uint8Array ? [4, k7(e, a.buffer)] : [3, 7];
        case 6:
          return [2, s.sent()];
        case 7:
          if (n === "string" && typeof a == "string") return [2, a];
          if (n === "xml" && typeof a == "string") return [2, new DOMParser().parseFromString(a, "application/xml")];
          if (n === "json" && typeof a == "string") return [2, JSON.parse(a)];
          s.label = 8;
        case 8:
          throw new Error("could not get requested response data '".concat(n, "'"));
      }
    });
  });
}
var Ka, cp = function() {
  function e() {
  }
  return e.get = function() {
    return this.pool.length ? this.pool.pop() : new fE();
  }, 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 Hy(e, t, n, r, i) {
  var a = this, o = void 0;
  return At.create(e || "Download", function(s) {
    return ie(a, 0, void 0, function() {
      var u, c, l, d, m, p, v;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            if ((o = cp.get()).open(r ? "post" : "get", t, !0), i) for (u = 0, c = i; u < c.length; u++) l = c[u], d = l[0], m = l[1], o.setRequestHeader(d, m);
            return o.responseType = function(y) {
              switch (y) {
                case "json":
                  return "json";
                case "xml":
                  return "document";
                case "string":
                  return "text";
                case "binary":
                case "zip":
                  return "arraybuffer";
              }
            }(n), o.send(r), [4, s.update({ message: "Waiting for server...", canAbort: !0 })];
          case 1:
            return f.sent(), [4, G7(s, "Downloading...", o)];
          case 2:
            return p = f.sent(), o = void 0, [4, s.update({ message: "Parsing response...", canAbort: !1 })];
          case 3:
            return f.sent(), v = function(y, h) {
              if (y.status >= 200 && y.status < 400) {
                var g = y.response;
                if (cp.deposit(y), (h === "binary" || h === "zip") && g instanceof ArrayBuffer) return new Uint8Array(g);
                if (h === "string" && typeof g == "string" || h === "xml" && g instanceof XMLDocument || h === "json" && typeof g == "object") return g;
                throw new Error("could not get requested response data '".concat(h, "'"));
              }
              throw cp.deposit(y), new Error("Download failed with status code ".concat(y.status));
            }(p, n), [2, v];
        }
      });
    });
  }, function() {
    o && (o.abort(), o = void 0);
  });
}
(function(e) {
  function t(n, r) {
    return B({ kind: "url", id: vr.create22(), url: n }, r);
  }
  e.Url = t, e.File = function(n) {
    return { kind: "file", id: vr.create22(), name: n.name, file: n };
  }, e.isUrl = function(n) {
    return (n == null ? void 0 : n.kind) === "url";
  }, e.isFile = function(n) {
    return (n == null ? void 0 : n.kind) === "file";
  }, e.Wrapper = function(n, r, i) {
    return { data: n, dispose: function() {
      i.release(r);
    } };
  }, e.getUrl = function(n) {
    return typeof n == "string" ? n : n.url;
  }, e.getUrlAsset = function(n, r, i) {
    return typeof r == "string" ? n.tryFindUrl(r, i) || t(r, { body: i }) : r;
  };
})(Ka || (Ka = {}));
var N, ds = function() {
  function e() {
    this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "assets", { get: function() {
    return Pg(this._assets.values());
  }, enumerable: !1, configurable: !0 }), e.prototype.tryFindUrl = function(t, n) {
    for (var r = this.assets.values(); ; ) {
      var i = r.next();
      if (i.done) return;
      var a = i.value.asset;
      if (Ka.isUrl(a) && a.url === t && (a.body || "") === (n || "")) return a;
    }
  }, e.prototype.set = function(t, n) {
    this._assets.set(t.id, { asset: t, file: n, 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, n, r) {
    var i = this;
    return r === void 0 && (r = !0), Ka.isUrl(t) ? At.create("Download ".concat(t.title || t.url), function(a) {
      return ie(i, 0, void 0, function() {
        var o, s, u, c, l, d, m, p, v;
        return ne(this, function(f) {
          switch (f.label) {
            case 0:
              return this._assets.has(t.id) ? ((o = this._assets.get(t.id)).refCount++, u = (s = Ka).Wrapper, [4, i1(o.file, n).runInContext(a)]) : [3, 2];
            case 1:
              return [2, u.apply(s, [f.sent(), t, this])];
            case 2:
              return r ? [3, 4] : (l = (c = Ka).Wrapper, [4, zy(B(B({}, t), { type: n })).runInContext(a)]);
            case 3:
              return [2, l.apply(c, [f.sent(), t, this])];
            case 4:
              return [4, zy(B(B({}, t), { type: "binary" })).runInContext(a)];
            case 5:
              return d = f.sent(), m = new File([d], "raw-data"), this._assets.set(t.id, { asset: t, file: m, refCount: 1 }), v = (p = Ka).Wrapper, [4, i1(m, n).runInContext(a)];
            case 6:
              return [2, v.apply(p, [f.sent(), t, this])];
          }
        });
      });
    }) : At.create("Read ".concat(t.name), function(a) {
      return ie(i, 0, void 0, function() {
        var o, s, u, c, l;
        return ne(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 = Ka).Wrapper, [4, i1(o.file, n).runInContext(a)]) : [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 r && this._assets.set(t.id, { asset: t, file: t.file, refCount: 1 }), l = (c = Ka).Wrapper, [4, i1(t.file, n).runInContext(a)];
            case 3:
              return [2, l.apply(c, [d.sent(), t, this])];
          }
        });
      });
    });
  }, e.prototype.release = function(t) {
    var n = this._assets.get(t.id);
    n && (n.refCount--, n.refCount <= 0 && this._assets.delete(t.id));
  }, e;
}();
function Nm(e) {
  for (var t = -1 / 0, n = 0, r = e.length; n < r; ++n) e[n] > t && (t = e[n]);
  return t;
}
function vE(e) {
  for (var t = 1 / 0, n = 0, r = e.length; n < r; ++n) e[n] < t && (t = e[n]);
  return t;
}
function Ki(e) {
  for (var t = 1 / 0, n = -1 / 0, r = 0, i = e.length; r < i; ++r) e[r] < t && (t = e[r]), e[r] > n && (n = e[r]);
  return [t, n];
}
function vm(e, t, n) {
  t === void 0 && (t = 1), n === void 0 && (n = 0);
  for (var r = e.length, i = 0, a = n; a < r; a += t) i += e[a];
  return i;
}
function gE(e, t, n) {
  return t === void 0 && (t = 1), n === void 0 && (n = 0), vm(e, t, n) / (e.length / t);
}
function yE(e) {
  for (var t = e.length, n = 0, r = 0; r < t; ++r) {
    var i = e[r];
    n += i * i;
  }
  return Math.sqrt(n / t);
}
function Oo(e, t) {
  for (var n = 0, r = t ? Math.min(t, e.length) : e.length; n < r; ++n) e[n] = n;
  return e;
}
function Ca(e, t) {
  return !(e.indexOf(t) >= 0) && (e.push(t), !0);
}
function gm(e, t) {
  var n = e.indexOf(t);
  if (n < 0) return !1;
  for (var r = n, i = e.length - 1; r < i; r++) e[r] = e[r + 1];
  return e.pop(), !0;
}
function Lm(e, t) {
  for (var n = 0, r = 0, i = e.length; r < i; ++r) t.includes(e[r]) && (n += 1);
  return n;
}
(function(e) {
  function t(b, _) {
    return _ && (_.label && (b.label = _.label), _.description && (b.description = _.description), _.legend && (b.legend = _.legend), _.fieldLabels && (b.fieldLabels = _.fieldLabels), _.isHidden && (b.isHidden = _.isHidden), _.shortLabel && (b.shortLabel = _.shortLabel), _.twoColumns && (b.twoColumns = _.twoColumns), _.isEssential && (b.isEssential = _.isEssential), _.category && (b.category = _.category), _.hideIf && (b.hideIf = _.hideIf), _.help && (b.help = _.help)), b;
  }
  function n(b, _, A) {
    return t({ type: "select", defaultValue: C(b, _), options: _, cycle: A == null ? void 0 : A.cycle }, A);
  }
  function r(b, _) {
    return _ && (_.min !== void 0 && (b.min = _.min), _.max !== void 0 && (b.max = _.max), _.step !== void 0 && (b.step = _.step)), b;
  }
  function i(b, _) {
    var A = t({ type: "group", defaultValue: (_ == null ? void 0 : _.customDefault) || s(b), params: b }, _);
    return _ != null && _.presets && (A.presets = _.presets), _ != null && _.isExpanded && (A.isExpanded = _.isExpanded), _ != null && _.isFlat && (A.isFlat = _.isFlat), _ != null && _.pivot && (A.pivot = _.pivot), A;
  }
  function a() {
    return s(this.element);
  }
  function o() {
    throw new Error("getValue not set. Fix runtime.");
  }
  function s(b) {
    for (var _ = {}, A = 0, I = Object.keys(b); A < I.length; A++) {
      var w = I[A];
      b[w].isOptional || (_[w] = b[w].defaultValue);
    }
    return _;
  }
  function u(b, _) {
    return function() {
      return b(_);
    };
  }
  function c(b, _, A) {
    if (_) {
      if (b.type === "value-ref") (I = _).ref ? I.getValue = u(b.resolveRef, I.ref) : I.getValue = function() {
        throw new Error("Unset ref in ValueRef value.");
      };
      else if (b.type === "data-ref")
        (I = _).ref ? I.getValue = u(A, I.ref) : I.getValue = function() {
          throw new Error("Unset ref in ValueRef value.");
        };
      else if (b.type === "group") m(b.params, _, A);
      else if (b.type === "mapped") {
        var I = _;
        c(b.map(I.name), I.params, A);
      } else if (b.type === "object-list") {
        if (!d(b.element)) return;
        for (var w = 0, E = _; w < E.length; w++) {
          var D = E[w];
          m(b.element, D, 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 _ = 0, A = b.select.options; _ < A.length; _++) {
      var I = A[_][0];
      if (l(b.map(I))) return !0;
    }
    else if (b.type === "object-list") return d(b.element);
    return !1;
  }
  function d(b) {
    for (var _ = 0, A = Object.keys(b); _ < A.length; _++)
      if (l(b[A[_]])) return !0;
    return !1;
  }
  function m(b, _, A) {
    for (var I = 0, w = Object.keys(b); I < w.length; I++) {
      var E = w[I];
      c(b[E], _ == null ? void 0 : _[E], A);
    }
  }
  function p(b, _, A) {
    if (_ === A) return !0;
    if (typeof _ != "object" || typeof A != "object") return !1;
    for (var I = 0, w = Object.keys(b); I < w.length; I++) {
      var E = w[I];
      if (!v(b[E], _[E], A[E])) return !1;
    }
    return !0;
  }
  function v(b, _, A) {
    if (_ === A) return !0;
    if (b.type === "group") return p(b.params, _, A);
    if (b.type === "mapped") {
      var I = A;
      return (T = _).name === I.name && v(b.map(T.name), T.params, I.params);
    }
    if (b.type === "multi-select") {
      if (I = A, (T = _).length !== I.length) return !1;
      if (T.length < 10) {
        for (var w = 0, E = T.length; w < E; w++) if (T[w] !== I[w] && I.indexOf(T[w]) < 0) return !1;
      } else {
        var D = new Set(I);
        for (w = 0, E = T.length; w < E; w++) if (T[w] !== I[w] && !D.has(T[w])) return !1;
      }
      return !0;
    }
    if (b.type === "interval") return _[0] === A[0] && _[1] === A[1];
    if (b.type === "line-graph") {
      if (I = A, (T = _).length !== I.length) return !1;
      for (w = 0, E = T.length; w < E; w++) if (!ge.areEqual(T[w], I[w])) return !1;
      return !0;
    }
    if (b.type === "vec3") return S.equals(_, A);
    if (b.type === "mat4") return J.areEqual(_, A, bn);
    if (b.type === "script")
      return I = A, (T = _).language === I.language && T.expression === I.expression;
    if (b.type === "object-list") {
      I = A;
      var T, P = (T = _).length;
      if (P !== I.length) return !1;
      for (w = 0; w < P; w++) if (!p(b.element, T[w], I[w])) return !1;
      return !0;
    }
    return typeof _ == "object" && typeof A == "object" && A7(_, A);
  }
  function f(b, _, A) {
    if (_ === void 0) return B({}, A);
    if (A === void 0) return B({}, _);
    for (var I = /* @__PURE__ */ Object.create(null), w = 0, E = Object.keys(b); w < E.length; w++) {
      var D = E[w];
      I[D] = y(b[D], _[D], A[D]);
    }
    return I;
  }
  function y(b, _, A) {
    if (_ === void 0) return typeof A != "object" || Array.isArray(A) ? A : B({}, A);
    if (A === void 0) return typeof _ != "object" || Array.isArray(_) ? _ : B({}, _);
    if (b.type === "group") return f(b.params, _, A);
    if (b.type === "mapped") {
      var I = _, w = A;
      if (I.name !== w.name) return B({}, w);
      var E = b.map(w.name);
      return { name: w.name, params: y(E, I.params, w.params) };
    }
    return b.type === "value" ? A : typeof _ == "object" && typeof A == "object" ? Array.isArray(A) ? A : B(B({}, _), A) : A;
  }
  function h(b, _) {
    for (var A = 0, I = b.options; A < I.length; A++)
      if (I[A][0] === _) return !0;
    return !1;
  }
  function g(b, _, A) {
    if (_ == null) return A ? b.defaultValue : void 0;
    if (b.type === "value") return _;
    if (b.type === "group") {
      for (var I = /* @__PURE__ */ Object.create(null), w = 0, E = Object.keys(b.params); w < E.length; w++) {
        var D = E[w], T = b.params[D];
        _[D] === void 0 ? A && (I[D] = T.defaultValue) : I[D] = g(T, _[D], A);
      }
      return I;
    }
    if (b.type === "mapped") {
      var P = _;
      return typeof P.name != "string" ? b.defaultValue : P.params === void 0 ? A ? b.defaultValue : void 0 : h(b.select, P.name) ? (T = b.map(P.name), { name: P.name, params: g(T, P.params, A) }) : b.defaultValue;
    }
    return b.type === "select" ? h(b, _) ? _ : b.defaultValue : b.type === "multi-select" ? Array.isArray(_) ? (I = _.filter(function(M) {
      return h(this, M);
    }, b), _.length > 0 && I.length === 0 ? b.defaultValue : I) : b.defaultValue : b.type === "object-list" ? Array.isArray(_) ? _.map(function(M) {
      return x(b.element, M, A ? "all" : "skip");
    }) : b.defaultValue : _;
  }
  function x(b, _, A) {
    if (typeof _ != "object" || _ === null) return A ? s(b) : _;
    for (var I = /* @__PURE__ */ Object.create(null), w = 0, E = Object.keys(b); w < E.length; w++) {
      var D = E[w], T = b[D];
      _[D] === void 0 ? A === "all" && (I[D] = T.defaultValue) : I[D] = g(T, _[D], A !== "skip");
    }
    return I;
  }
  function C(b, _) {
    for (var A = 0, I = _; A < I.length; A++)
      if (I[A][0] === b) return b;
    return _.length > 0 ? _[0][0] : void 0;
  }
  e.Essential = { isEssential: !0 }, e.Optional = function(b) {
    var _ = B({}, b);
    return _.isOptional = !0, _;
  }, e.Value = function(b, _) {
    return t({ type: "value", defaultValue: b }, _);
  }, e.Select = n, e.MultiSelect = function(b, _, A) {
    var I = t({ type: "multi-select", defaultValue: b, options: _ }, A);
    return A != null && A.emptyValue && (I.emptyValue = A.emptyValue), I;
  }, e.Boolean = function(b, _) {
    return t({ type: "boolean", defaultValue: b }, _);
  }, e.Text = function(b, _) {
    return b === void 0 && (b = ""), t({ type: "text", defaultValue: b }, _);
  }, e.Color = function(b, _) {
    var A = t({ type: "color", defaultValue: b }, _);
    return _ != null && _.isExpanded && (A.isExpanded = _.isExpanded), A;
  }, e.ColorList = function(b, _) {
    var A;
    if (typeof b == "string") {
      var I = bs(b);
      A = { kind: I.type !== "qualitative" ? "interpolate" : "set", colors: I.list };
    } else A = b;
    return t({ type: "color-list", presetKind: (_ == null ? void 0 : _.presetKind) || "all", defaultValue: A, offsets: !!(_ != null && _.offsets) }, _);
  }, e.Vec3 = function(b, _, A) {
    return t(r({ type: "vec3", defaultValue: b }, _), A);
  }, e.Mat4 = function(b, _) {
    return t({ type: "mat4", defaultValue: b }, _);
  }, e.Url = function(b, _) {
    return t({ type: "url", defaultValue: typeof b == "string" ? Ka.Url(b) : Ka.Url(b.url, { body: b.body }) }, _);
  }, e.File = function(b) {
    var _ = t({ type: "file", defaultValue: null }, b);
    return b != null && b.accept && (_.accept = b.accept), _;
  }, e.FileList = function(b) {
    var _ = t({ type: "file-list", defaultValue: null }, b);
    return b != null && b.accept && (_.accept = b.accept), _;
  }, e.Numeric = function(b, _, A) {
    var I = t(r({ type: "number", defaultValue: b }, _), A);
    return A != null && A.immediateUpdate && (I.immediateUpdate = !0), I;
  }, e.Interval = function(b, _, A) {
    return t(r({ type: "interval", defaultValue: b }, _), A);
  }, e.LineGraph = function(b, _) {
    return t({ type: "line-graph", defaultValue: b }, _);
  }, e.Group = i, e.EmptyGroup = function(b) {
    return i({}, b);
  }, e.Mapped = function(b, _, A, I) {
    var w = C(b, _);
    return t({ type: "mapped", defaultValue: { name: w, params: A(w).defaultValue }, select: n(w, _, I), map: A }, I);
  }, e.MappedStatic = function(b, _, A) {
    var I = A != null && A.options ? A.options : Object.keys(_).map(function(E) {
      return [E, _[E].label || To(E)];
    }), w = C(b, I);
    return t({ type: "mapped", defaultValue: { name: w, params: _[w].defaultValue }, select: n(w, I, A), map: function(E) {
      return _[E];
    } }, A);
  }, e.ObjectList = function(b, _, A) {
    return t({ type: "object-list", element: b, getLabel: _, ctor: a, defaultValue: (A == null ? void 0 : A.defaultValue) || [] }, A);
  }, e.ValueRef = function(b, _, A) {
    var I;
    return t({ type: "value-ref", defaultValue: { ref: (I = A == null ? void 0 : A.defaultRef) !== null && I !== void 0 ? I : "", getValue: o }, getOptions: b, resolveRef: _ }, A);
  }, e.DataRef = function(b) {
    var _;
    return t({ type: "data-ref", defaultValue: { ref: (_ = b == null ? void 0 : b.defaultRef) !== null && _ !== void 0 ? _ : "", getValue: o } }, b);
  }, e.Converted = function(b, _, A) {
    return { type: "converted", defaultValue: _(A.defaultValue), converted: A, fromValue: b, toValue: _ };
  }, e.Conditioned = function(b, _, A, I, w) {
    var E = Object.keys(_).map(function(D) {
      return [D, D];
    });
    return t({ type: "conditioned", select: n(A(b), E, w), defaultValue: b, conditionParams: _, conditionForValue: A, conditionedValue: I }, w);
  }, e.Script = function(b, _) {
    return t({ type: "script", defaultValue: b }, _);
  }, e.For = function(b) {
    return 0;
  }, e.getDefaultValues = s, e.resolveRefs = m, e.setDefaultValues = function(b, _) {
    for (var A = 0, I = Object.keys(b); A < I.length; A++) {
      var w = I[A];
      b[w].isOptional || (b[w].defaultValue = _[w]);
    }
  }, e.clone = function(b) {
    return xs(b);
  }, e.validate = function(b, _) {
  }, e.areEqual = p, e.isParamEqual = v, e.merge = f, e.mergeParam = y, e.normalizeParams = x, e.objectToOptions = function(b, _) {
    for (var A = [], I = 0, w = Object.keys(b); I < w.length; I++) {
      var E = w[I];
      if (_) {
        var D = _(E, b[E]);
        A.push(typeof D == "string" ? [E, D] : [E, D[0], D[1]]);
      } else typeof b[E] == "string" ? A.push([E, b[E]]) : A.push([E, _ === null ? E : To(E)]);
    }
    return A;
  }, e.arrayToOptions = function(b, _) {
    for (var A = [], I = 0, w = b; I < w.length; I++) {
      var E = w[I];
      _ ? A.push([E, _(E)]) : A.push([E, _ === null ? E : To(E)]);
    }
    return A;
  }, e.optionLabel = function(b, _) {
    for (var A = 0, I = b.options; A < I.length; A++) {
      var w = I[A];
      if (w[0] === _) return w[1];
    }
    return "";
  };
})(N || (N = {}));
var q2, j2 = { backgroundColor: N.Color(ye(0), { description: "Background color of the 3D canvas" }), pickingAlphaThreshold: N.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "The minimum opacity value needed for an object to be pickable." }), interiorDarkening: N.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), interiorColorFlag: N.Boolean(!0, { label: "Use Interior Color" }), interiorColor: N.Color(ye.fromNormalizedRgb(0.3, 0.3, 0.3)), highlightColor: N.Color(ye.fromNormalizedRgb(1, 0.4, 0.6)), selectColor: N.Color(ye.fromNormalizedRgb(0.2, 1, 0.1)), highlightStrength: N.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), selectStrength: N.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), markerPriority: N.Select(1, [[1, "Highlight"], [2, "Select"]]), xrayEdgeFalloff: N.Numeric(1, { min: 0, max: 3, step: 0.1 }), light: N.ObjectList({ inclination: N.Numeric(180, { min: 0, max: 180, step: 1 }), azimuth: N.Numeric(0, { min: 0, max: 360, step: 1 }), color: N.Color(ye.fromNormalizedRgb(1, 1, 1)), intensity: N.Numeric(0.6, { min: 0, max: 1, step: 0.01 }) }, function(e) {
  return ye.toHexString(e.color);
}, { defaultValue: [{ inclination: 180, azimuth: 0, color: ye.fromNormalizedRgb(1, 1, 1), intensity: 0.6 }] }), ambientColor: N.Color(ye.fromNormalizedRgb(1, 1, 1)), ambientIntensity: N.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), invalidColor: N.Color(ye(16410214)), invalidStrength: N.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) }, qy = S(), lp = S();
function jy(e, t) {
  for (var n = t || { direction: new Array(15).fill(0), color: new Array(15).fill(0) }, r = n.direction, i = n.color, a = 0, o = e.length; a < o; ++a) {
    var s = e[a];
    S.directionFromSpherical(qy, Bn(s.inclination), Bn(s.azimuth), 1), S.toArray(qy, r, 3 * a), S.scale(lp, ye.toVec3Normalized(lp, s.color), s.intensity), S.toArray(lp, i, 3 * a);
  }
  return { count: e.length, direction: r, color: i };
}
function er(e, t, n) {
  return t === void 0 && (t = ""), n === void 0 && (n = ""), er.create(e, t, n);
}
(function(e) {
  e.create = function(t, n) {
    n === void 0 && (n = {});
    var r = t.gl, i = t.state, a = t.stats, o = N.merge(j2, N.getDefaultValues(j2), n), s = jy(o.light), u = Pr(), c = ge.create(r.drawingBufferWidth, r.drawingBufferHeight), l = ye.toVec3Normalized(S(), o.backgroundColor), d = !1, m = t.resources.texture("image-depth", "depth", "ushort", "nearest"), p = [["tDepth", m]], v = J(), f = J(), y = J(), h = J(), g = J(), x = J(), C = J(), b = S(), _ = ge(), A = S();
    S.scale(A, ye.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity);
    var I = { uModel: k.create(J.identity()), uView: k.create(v), uInvView: k.create(f), uModelView: k.create(y), uInvModelView: k.create(h), uInvProjection: k.create(g), uProjection: k.create(J()), uModelViewProjection: k.create(x), uInvModelViewProjection: k.create(C), uIsOrtho: k.create(1), uViewOffset: k.create(_), uPixelRatio: k.create(t.pixelRatio), uViewport: k.create(Pr.toVec4(vt(), u)), uDrawingBufferSize: k.create(c), uCameraPosition: k.create(S()), uCameraDir: k.create(b), uNear: k.create(1), uFar: k.create(1e4), uFogNear: k.create(1), uFogFar: k.create(1e4), uFogColor: k.create(l), uRenderWboit: k.create(!1), uMarkingDepthTest: k.create(!1), uPickType: k.create(0), uMarkingType: k.create(0), uTransparentBackground: k.create(!1), uLightDirection: k.create(s.direction), uLightColor: k.create(s.color), uAmbientColor: k.create(A), uPickingAlphaThreshold: k.create(o.pickingAlphaThreshold), uInteriorDarkening: k.create(o.interiorDarkening), uInteriorColorFlag: k.create(o.interiorColorFlag), uInteriorColor: k.create(ye.toVec3Normalized(S(), o.interiorColor)), uHighlightColor: k.create(ye.toVec3Normalized(S(), o.highlightColor)), uSelectColor: k.create(ye.toVec3Normalized(S(), o.selectColor)), uHighlightStrength: k.create(o.highlightStrength), uSelectStrength: k.create(o.selectStrength), uMarkerPriority: k.create(o.markerPriority), uXrayEdgeFalloff: k.create(o.xrayEdgeFalloff), uInvalidColor: k.create(ye.toVec3Normalized(S(), o.invalidColor)), uInvalidStrength: k.create(o.invalidStrength) }, w = Object.entries(I), E = !0, D = function(R, O) {
      if (!R.state.disposed && R.state.visible && (R.state.pickable || O !== "pick")) {
        var L = !1;
        R.values.dLightCount.ref.value !== s.count && (k.update(R.values.dLightCount, s.count), L = !0), L && R.update();
        var F = R.getProgram(O);
        if (i.currentProgramId !== F.id && (E = !0, F.use()), E && (F.setUniforms(w), E = !1), R.values.dGeometryType.ref.value === "directVolume") {
          if (O !== "colorWboit" && O !== "colorBlended") return;
          i.disable(r.CULL_FACE), i.frontFace(r.CCW), O === "colorBlended" && (i.disable(r.DEPTH_TEST), i.depthMask(!1));
        } else R.values.uDoubleSided ? R.values.uDoubleSided.ref.value || R.values.hasReflection.ref.value ? i.disable(r.CULL_FACE) : i.enable(r.CULL_FACE) : i.disable(r.CULL_FACE), R.values.dFlipSided && R.values.dFlipSided.ref.value ? (i.frontFace(r.CW), i.cullFace(r.FRONT)) : (i.frontFace(r.CCW), i.cullFace(r.BACK));
        R.render(O, p);
      }
    }, T = function(R, O, L, F, G) {
      (function(K, j, W) {
        for (var Z = 0, Y = K.length; Z < Y; ++Z) if (K[Z][0] === j) return void (K[Z][1] = W);
        K.push([j, W]);
      })(p, "tDepth", L || m), k.update(I.uModel, R.view), k.update(I.uModelView, J.mul(y, R.view, O.view)), k.update(I.uInvModelView, J.invert(h, y)), k.update(I.uModelViewProjection, J.mul(x, y, O.projection)), k.update(I.uInvModelViewProjection, J.invert(C, x)), k.updateIfChanged(I.uRenderWboit, F), k.updateIfChanged(I.uMarkingDepthTest, G), i.enable(r.SCISSOR_TEST), i.colorMask(!0, !0, !0, !0);
      var V = u.x, U = u.y, q = u.width, H = u.height;
      r.viewport(V, U, q, H), r.scissor(V, U, q, H), E = !0, i.currentRenderItemId = -1;
    }, P = function(R, O, L) {
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, L, !1, !1);
      for (var F = R.renderables, G = 0, V = F.length; G < V; ++G) {
        var U = F[G];
        U.state.opaque && D(U, "colorBlended");
      }
    }, M = function(R, O, L) {
      i.enable(r.DEPTH_TEST), T(R, O, L, !1, !1);
      var F = R.renderables;
      d ? i.blendFunc(r.ONE, r.ONE_MINUS_SRC_ALPHA) : i.blendFuncSeparate(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA), i.enable(r.BLEND), i.depthMask(!0);
      for (var G = 0, V = F.length; G < V; ++G)
        !(U = F[G]).state.opaque && U.state.writeDepth && D(U, "colorBlended");
      for (i.depthMask(!1), G = 0, V = F.length; G < V; ++G) {
        var U;
        (U = F[G]).state.opaque || U.state.writeDepth || D(U, "colorBlended");
      }
    };
    return { clear: function(R, O) {
      i.enable(r.SCISSOR_TEST), i.enable(r.DEPTH_TEST), i.colorMask(!0, !0, !0, !0), i.depthMask(!0), d && !O ? i.clearColor(0, 0, 0, 0) : R ? i.clearColor(l[0], l[1], l[2], 1) : i.clearColor(1, 1, 1, 1), r.clear(r.COLOR_BUFFER_BIT | r.DEPTH_BUFFER_BIT);
    }, clearDepth: function() {
      i.enable(r.SCISSOR_TEST), i.enable(r.DEPTH_TEST), i.depthMask(!0), r.clear(r.DEPTH_BUFFER_BIT);
    }, update: function(R) {
      k.update(I.uView, R.view), k.update(I.uInvView, J.invert(f, R.view)), k.update(I.uProjection, R.projection), k.update(I.uInvProjection, J.invert(g, R.projection)), k.updateIfChanged(I.uIsOrtho, R.state.mode === "orthographic" ? 1 : 0), k.update(I.uViewOffset, R.viewOffset.enabled ? ge.set(_, 16 * R.viewOffset.offsetX, 16 * R.viewOffset.offsetY) : ge.set(_, 0, 0)), k.update(I.uCameraPosition, R.state.position), k.update(I.uCameraDir, S.normalize(b, S.sub(b, R.state.target, R.state.position))), k.updateIfChanged(I.uFar, R.far), k.updateIfChanged(I.uNear, R.near), k.updateIfChanged(I.uFogFar, R.fogFar), k.updateIfChanged(I.uFogNear, R.fogNear), k.updateIfChanged(I.uTransparentBackground, d);
    }, renderPick: function(R, O, L, F, G) {
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, F, !1, !1), k.updateIfChanged(I.uPickType, G);
      for (var V = R.renderables, U = 0, q = V.length; U < q; ++U) V[U].state.colorOnly || D(V[U], L);
    }, renderDepth: function(R, O, L) {
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, L, !1, !1);
      for (var F = R.renderables, G = 0, V = F.length; G < V; ++G) D(F[G], "depth");
    }, renderMarkingDepth: function(R, O, L) {
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, L, !1, !1), k.updateIfChanged(I.uMarkingType, 1);
      for (var F = R.renderables, G = 0, V = F.length; G < V; ++G)
        F[G].values.markerAverage.ref.value !== 1 && D(F[G], "marking");
    }, renderMarkingMask: function(R, O, L) {
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, L, !1, !!L), k.updateIfChanged(I.uMarkingType, 2);
      for (var F = R.renderables, G = 0, V = F.length; G < V; ++G)
        F[G].values.markerAverage.ref.value > 0 && D(F[G], "marking");
    }, renderBlended: function(R, O, L) {
      P(R, O, L), M(R, O, L);
    }, renderBlendedOpaque: P, renderBlendedTransparent: M, renderBlendedVolumeOpaque: function(R, O, L) {
      var F;
      i.blendFunc(r.ONE, r.ONE_MINUS_SRC_ALPHA), i.enable(r.BLEND), T(R, O, L, !1, !1);
      for (var G = R.renderables, V = 0, U = G.length; V < U; ++V) {
        var q = G[V];
        xi(q.values.alpha.ref.value * q.state.alphaFactor, 0, 1) !== 1 || q.values.transparencyAverage.ref.value === 1 || !((F = q.values.dXrayShaded) === null || F === void 0) && F.ref.value || D(q, "colorBlended");
      }
    }, renderBlendedVolumeTransparent: function(R, O, L) {
      var F;
      i.blendFunc(r.ONE, r.ONE_MINUS_SRC_ALPHA), i.enable(r.BLEND), T(R, O, L, !1, !1);
      for (var G = R.renderables, V = 0, U = G.length; V < U; ++V) {
        var q = G[V];
        (xi(q.values.alpha.ref.value * q.state.alphaFactor, 0, 1) < 1 || q.values.transparencyAverage.ref.value > 0 || !((F = q.values.dXrayShaded) === null || F === void 0) && F.ref.value) && D(q, "colorBlended");
      }
    }, renderWboitOpaque: function(R, O, L) {
      var F, G;
      i.disable(r.BLEND), i.enable(r.DEPTH_TEST), i.depthMask(!0), T(R, O, L, !1, !1);
      for (var V = R.renderables, U = 0, q = V.length; U < q; ++U) {
        var H = V[U];
        xi(H.values.alpha.ref.value * H.state.alphaFactor, 0, 1) !== 1 || H.values.transparencyAverage.ref.value === 1 || H.values.dGeometryType.ref.value === "directVolume" || ((F = H.values.dPointStyle) === null || F === void 0 ? void 0 : F.ref.value) === "fuzzy" || !((G = H.values.dXrayShaded) === null || G === void 0) && G.ref.value || D(H, "colorWboit");
      }
    }, renderWboitTransparent: function(R, O, L) {
      var F, G;
      T(R, O, L, !0, !1);
      for (var V = R.renderables, U = 0, q = V.length; U < q; ++U) {
        var H = V[U];
        (xi(H.values.alpha.ref.value * H.state.alphaFactor, 0, 1) < 1 || H.values.transparencyAverage.ref.value > 0 || H.values.dGeometryType.ref.value === "directVolume" || ((F = H.values.dPointStyle) === null || F === void 0 ? void 0 : F.ref.value) === "fuzzy" || H.values.uBackgroundColor || !((G = H.values.dXrayShaded) === null || G === void 0) && G.ref.value) && D(H, "colorWboit");
      }
    }, setProps: function(R) {
      R.backgroundColor !== void 0 && R.backgroundColor !== o.backgroundColor && (o.backgroundColor = R.backgroundColor, ye.toVec3Normalized(l, o.backgroundColor), k.update(I.uFogColor, S.copy(I.uFogColor.ref.value, l))), R.pickingAlphaThreshold !== void 0 && R.pickingAlphaThreshold !== o.pickingAlphaThreshold && (o.pickingAlphaThreshold = R.pickingAlphaThreshold, k.update(I.uPickingAlphaThreshold, o.pickingAlphaThreshold)), R.interiorDarkening !== void 0 && R.interiorDarkening !== o.interiorDarkening && (o.interiorDarkening = R.interiorDarkening, k.update(I.uInteriorDarkening, o.interiorDarkening)), R.interiorColorFlag !== void 0 && R.interiorColorFlag !== o.interiorColorFlag && (o.interiorColorFlag = R.interiorColorFlag, k.update(I.uInteriorColorFlag, o.interiorColorFlag)), R.interiorColor !== void 0 && R.interiorColor !== o.interiorColor && (o.interiorColor = R.interiorColor, k.update(I.uInteriorColor, ye.toVec3Normalized(I.uInteriorColor.ref.value, o.interiorColor))), R.highlightColor !== void 0 && R.highlightColor !== o.highlightColor && (o.highlightColor = R.highlightColor, k.update(I.uHighlightColor, ye.toVec3Normalized(I.uHighlightColor.ref.value, o.highlightColor))), R.selectColor !== void 0 && R.selectColor !== o.selectColor && (o.selectColor = R.selectColor, k.update(I.uSelectColor, ye.toVec3Normalized(I.uSelectColor.ref.value, o.selectColor))), R.highlightStrength !== void 0 && R.highlightStrength !== o.highlightStrength && (o.highlightStrength = R.highlightStrength, k.update(I.uHighlightStrength, o.highlightStrength)), R.selectStrength !== void 0 && R.selectStrength !== o.selectStrength && (o.selectStrength = R.selectStrength, k.update(I.uSelectStrength, o.selectStrength)), R.markerPriority !== void 0 && R.markerPriority !== o.markerPriority && (o.markerPriority = R.markerPriority, k.update(I.uMarkerPriority, o.markerPriority)), R.xrayEdgeFalloff !== void 0 && R.xrayEdgeFalloff !== o.xrayEdgeFalloff && (o.xrayEdgeFalloff = R.xrayEdgeFalloff, k.update(I.uXrayEdgeFalloff, o.xrayEdgeFalloff)), R.light === void 0 || Iu(R.light, o.light) || (o.light = R.light, Object.assign(s, jy(R.light, s)), k.update(I.uLightDirection, s.direction), k.update(I.uLightColor, s.color)), R.ambientColor !== void 0 && R.ambientColor !== o.ambientColor && (o.ambientColor = R.ambientColor, S.scale(A, ye.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity), k.update(I.uAmbientColor, A)), R.ambientIntensity !== void 0 && R.ambientIntensity !== o.ambientIntensity && (o.ambientIntensity = R.ambientIntensity, S.scale(A, ye.toArrayNormalized(o.ambientColor, A, 0), o.ambientIntensity), k.update(I.uAmbientColor, A)), R.invalidColor !== void 0 && R.invalidColor !== o.invalidColor && (o.invalidColor = R.invalidColor, k.update(I.uInvalidColor, ye.toVec3Normalized(I.uInvalidColor.ref.value, o.invalidColor))), R.invalidStrength !== void 0 && R.invalidStrength !== o.invalidStrength && (o.invalidStrength = R.invalidStrength, k.update(I.uInvalidStrength, o.invalidStrength));
    }, setViewport: function(R, O, L, F) {
      r.viewport(R, O, L, F), r.scissor(R, O, L, F), R === u.x && O === u.y && L === u.width && F === u.height || (Pr.set(u, R, O, L, F), k.update(I.uViewport, vt.set(I.uViewport.ref.value, R, O, L, F)));
    }, setTransparentBackground: function(R) {
      d = R;
    }, setDrawingBufferSize: function(R, O) {
      R === c[0] && O === c[1] || k.update(I.uDrawingBufferSize, ge.set(c, R, O));
    }, setPixelRatio: function(R) {
      k.update(I.uPixelRatio, R);
    }, 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: a.drawCount, instanceCount: a.instanceCount, instancedDrawCount: a.instancedDrawCount };
    }, dispose: function() {
    } };
  };
})(q2 || (q2 = {})), function(e) {
  function t(r) {
    return r.triggers.map(n.format).join(" or ");
  }
  function n(r, i) {
    return n.create(r, i);
  }
  e.create = function(r, i, a) {
    return i === void 0 && (i = ""), a === void 0 && (a = ""), { triggers: r, action: i, description: a };
  }, e.Empty = { triggers: [], action: "", description: "" }, e.isEmpty = function(r) {
    return r.triggers.length === 0 || r.triggers.every(function(i) {
      return i.buttons === void 0 && i.modifiers === void 0;
    });
  }, e.match = function(r, i, a) {
    return r.triggers.some(function(o) {
      return n.match(o, i, a);
    });
  }, e.formatTriggers = t, e.format = function(r, i) {
    return i === void 0 && (i = ""), function(a, o) {
      var s = Object.keys(o), u = Object.values(o);
      return new (Function.bind.apply(Function, Pe(Pe([void 0], s, !1), ["return `".concat(a, "`;")], !1)))().apply(void 0, u);
    }(r.description || To(i), { triggers: "<i>" + t(r) + "</i>" });
  }, e.Trigger = n, function(r) {
    r.create = function(i, a) {
      return { buttons: i, modifiers: a };
    }, r.Empty = {}, r.match = function(i, a, o) {
      var s = i.buttons, u = i.modifiers;
      return s !== void 0 && (s === a || _c.has(s, a)) && (!u || El.areEqual(u, o));
    }, r.format = function(i) {
      var a = [], o = function(u) {
        var c = [];
        return u === void 0 ? c.push("any mouse button") : u === 0 ? c.push("mouse hover") : (a1.has(u, 1) && c.push("left mouse button"), a1.has(u, 2) && c.push("right mouse button"), a1.has(u, 4) && c.push("wheel/middle mouse button"), a1.has(u, 8) && c.push("three fingers")), c.join(" + ");
      }(i.buttons);
      o && a.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(" + ");
      }(i.modifiers);
      return s && a.push(s), a.join(" + ");
    };
  }(n = e.Trigger || (e.Trigger = {}));
}(er || (er = {}));
var wi, a1 = _c;
(function(e) {
  e.create = function() {
    var t = new bE(), n = function() {
      return t.create();
    };
    return n.dispose = function() {
      return t.dispose();
    }, n.behavior = function(r) {
      return t.behavior(r);
    }, n;
  };
})(wi || (wi = {}));
var K2, bE = function() {
  function e() {
    this._eventList = [], this._disposed = !1;
  }
  return e.prototype.create = function() {
    var t = new $n();
    return this._eventList.push(t), t;
  }, e.prototype.behavior = function(t) {
    var n = new cu(t);
    return this._eventList.push(n), n;
  }, e.prototype.dispose = function() {
    if (!this._disposed) {
      for (var t = 0, n = this._eventList; t < n.length; t++)
        n[t].complete();
      this._disposed = !0;
    }
  }, e;
}(), Rs = El, ks = er.Trigger, _E = { dragRotate: er([ks(1, Rs.create())], "Rotate", "Drag using ${triggers}"), dragRotateZ: er([ks(1, Rs.create({ shift: !0 }))], "Rotate around z-axis", "Drag using ${triggers}"), dragPan: er([ks(2, Rs.create()), ks(1, Rs.create({ control: !0 }))], "Pan", "Drag using ${triggers}"), dragZoom: er.Empty, dragFocus: er([ks(8, Rs.create())], "Focus", "Drag using ${triggers}"), dragFocusZoom: er([ks(4, Rs.create())], "Focus and zoom", "Drag using ${triggers}"), scrollZoom: er([ks(4, Rs.create())], "Zoom", "Scroll using ${triggers}"), scrollFocus: er([ks(4, Rs.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"), scrollFocusZoom: er.Empty }, V7 = { noScroll: N.Boolean(!0, { isHidden: !0 }), rotateSpeed: N.Numeric(5, { min: 1, max: 10, step: 1 }), zoomSpeed: N.Numeric(7, { min: 1, max: 15, step: 1 }), panSpeed: N.Numeric(1, { min: 0.1, max: 5, step: 0.1 }), animate: N.MappedStatic("off", { off: N.EmptyGroup(), spin: N.Group({ speed: N.Numeric(1, { min: -20, max: 20, step: 1 }) }, { description: "Spin the 3D scene around the x-axis in view space" }), rock: N.Group({ speed: N.Numeric(0.3, { min: -5, max: 5, step: 0.1 }), angle: N.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: N.Boolean(!0, { isHidden: !0 }), dynamicDampingFactor: N.Numeric(0.2, {}, { isHidden: !0 }), minDistance: N.Numeric(0.01, {}, { isHidden: !0 }), maxDistance: N.Numeric(1e150, {}, { isHidden: !0 }), gestureScaleFactor: N.Numeric(1, {}, { isHidden: !0 }), maxWheelDelta: N.Numeric(0.02, {}, { isHidden: !0 }), bindings: N.Value(_E, { isHidden: !0 }), autoAdjustMinMaxDistance: N.MappedStatic("on", { off: N.EmptyGroup(), on: N.Group({ minDistanceFactor: N.Numeric(0), minDistancePadding: N.Numeric(5), maxDistanceFactor: N.Numeric(10), maxDistanceMin: N.Numeric(20) }) }, { isHidden: !0 }) };
(function(e) {
  e.create = function(t, n, r) {
    r === void 0 && (r = {});
    var i = wi.create(), a = B(B({}, N.getDefaultValues(V7)), r), o = Pr.clone(n.viewport), s = !1, u = i.behavior(!1), c = i.behavior([]), l = i.behavior(!1), d = t.drag.subscribe(function(xe) {
      var Xe = xe.x, Ee = xe.y, Ye = xe.pageX, He = xe.pageY, le = xe.buttons, Ce = xe.modifiers, Ae = xe.isStart, Te = ue(Xe, Ee);
      if (!(u.value && c.value.includes("drag") && (l.value || le !== 1)) && !(Ae && Te) && !(!Ae && !y)) {
        y = !0, je();
        var Re = er.match(a.bindings.dragRotate, le, Ce), we = er.match(a.bindings.dragRotateZ, le, Ce), Qe = er.match(a.bindings.dragPan, le, Ce), Je = er.match(a.bindings.dragZoom, le, Ce), lt = er.match(a.bindings.dragFocus, le, Ce), st = er.match(a.bindings.dragFocusZoom, le, Ce);
        if (function(It, pe) {
          ge.set(V, (It - 0.5 * o.width - o.x) / (0.5 * o.width), (o.height + 2 * (o.y - pe)) / o.width);
        }(Ye, He), function(It, pe) {
          ge.set(G, (It - o.x) / o.width, (pe - o.y) / o.height);
        }(Ye, He), Ae && (Re && (ge.copy(C, V), ge.copy(x, C)), we && (ge.copy(I, V), ge.copy(A, I)), (Je || st) && (ge.copy(E, G), ge.copy(D, E)), lt && (ge.copy(T, G), ge.copy(P, T)), Qe && (ge.copy(M, G), ge.copy(R, M))), Re && ge.copy(C, V), we && ge.copy(I, V), (Je || st) && ge.copy(D, G), lt && ge.copy(P, G), st) {
          var ft = S.distance(n.state.position, n.state.target);
          n.setState({ radius: ft / 5 });
        }
        Qe && ge.copy(R, G);
      }
    }), m = t.interactionEnd.subscribe(function() {
      y = !1;
    }), p = t.wheel.subscribe(function(xe) {
      var Xe = xe.x, Ee = xe.y, Ye = xe.spinX, He = xe.spinY, le = xe.dz, Ce = xe.buttons, Ae = xe.modifiers;
      if (!ue(Xe, Ee)) {
        var Te = function() {
          for (var Re = [], we = 0; we < arguments.length; we++) Re[we] = arguments[we];
          for (var Qe = 0, Je = 0, lt = 0, st = Re.length; lt < st; ++lt) {
            var ft = Re[lt], It = Math.abs(ft);
            It > Je && (Qe = ft, Je = It);
          }
          return Qe;
        }(0.075 * Ye, 0.075 * He, 1e-4 * le);
        Te < -a.maxWheelDelta ? Te = -a.maxWheelDelta : Te > a.maxWheelDelta && (Te = a.maxWheelDelta), er.match(a.bindings.scrollZoom, Ce, Ae) && (D[1] += Te), er.match(a.bindings.scrollFocus, Ce, Ae) && (P[1] += Te);
      }
    }), v = t.pinch.subscribe(function(xe) {
      var Xe = xe.fractionDelta, Ee = xe.buttons, Ye = xe.modifiers;
      er.match(a.bindings.scrollZoom, Ee, Ye) && (y = !0, D[1] += a.gestureScaleFactor * Xe);
    }), f = t.gesture.subscribe(function(xe) {
      var Xe = xe.deltaScale;
      y = !0, D[1] += a.gestureScaleFactor * Xe;
    }), y = !1, h = S(), g = S(), x = ge(), C = ge(), b = S(), _ = 0, A = ge(), I = ge(), w = 0, E = ge(), D = ge(), T = ge(), P = ge(), M = ge(), R = ge(), O = S.clone(n.target), L = S.clone(n.position), F = S.clone(n.up), G = ge(), V = ge();
    function U() {
      var xe = t.width / t.height;
      return a.rotateSpeed * t.pixelRatio * xe;
    }
    var q = S(), H = Mn(), K = S(), j = S(), W = S(), Z = S(), Y = Mn(), te = ge(), ee = S(), $ = S();
    function ue(xe, Xe) {
      return xe *= t.pixelRatio, Xe *= t.pixelRatio, xe > o.x + o.width || t.height - Xe > o.y + o.height || xe < o.x || t.height - Xe < o.y;
    }
    var se = -1;
    function be(xe) {
      var Xe, Ee, Ye, He, le;
      se !== xe && (se > 0 && (a.animate.name === "spin" ? function(Ce) {
        if (!(a.animate.name !== "spin" || a.animate.params.speed === 0 || y)) {
          var Ae = a.animate.params.speed / 1e3;
          ke[0] = 60 * Math.min(Math.abs(Ce), 125) / 1e3 * Ae, ge.add(C, x, ke);
        }
      }(xe - se) : a.animate.name === "rock" && function(Ce) {
        if (!(a.animate.name !== "rock" || a.animate.params.speed === 0 || y)) {
          var Ae = Ce / 1e3 * a.animate.params.speed, Te = Bn(a.animate.params.angle) / U(), Re = Math.sin(Oe * Math.PI * 2) * Te, we = Math.sin((Oe + Ae) * Math.PI * 2) * Te;
          ze[0] = we - Re, ge.add(C, x, ze), (Oe += Ae) >= 1 && (Oe = 0);
        }
      }(xe - se)), S.sub(g, n.position, n.target), function() {
        var Ce = C[0] - x[0], Ae = C[1] - x[1];
        S.set(Z, Ce, Ae, 0);
        var Te = S.magnitude(Z) * U();
        Te ? (S.sub(g, n.position, n.target), S.normalize(K, g), S.normalize(j, n.up), S.normalize(W, S.cross(W, j, K)), S.setMagnitude(j, j, Ae), S.setMagnitude(W, W, Ce), S.add(Z, j, W), S.normalize(q, S.cross(q, Z, g)), Mn.setAxisAngle(H, q, Te), S.transformQuat(g, g, H), S.transformQuat(n.up, n.up, H), S.copy(b, q), _ = Te) : !a.staticMoving && _ && (_ *= Math.sqrt(1 - a.dynamicDampingFactor), S.sub(g, n.position, n.target), Mn.setAxisAngle(H, b, _), S.transformQuat(g, g, H), S.transformQuat(n.up, n.up, H)), ge.copy(x, C);
      }(), Xe = I[0] - A[0], Ee = I[1] - A[1], (Ye = a.rotateSpeed * (-Xe + Ee) * -0.05) ? (S.sub(g, n.position, n.target), Mn.setAxisAngle(Y, g, Ye), S.transformQuat(n.up, n.up, Y), w = Ye) : !a.staticMoving && w && (w *= Math.sqrt(1 - a.dynamicDampingFactor), S.sub(g, n.position, n.target), Mn.setAxisAngle(Y, g, w), S.transformQuat(n.up, n.up, Y)), ge.copy(A, I), (He = 1 + (D[1] - E[1]) * a.zoomSpeed) !== 1 && He > 0 && S.scale(g, g, He), a.staticMoving ? ge.copy(E, D) : E[1] += (D[1] - E[1]) * a.dynamicDampingFactor, function() {
        var Ce = (P[1] - T[1]) * a.zoomSpeed;
        if (Ce !== 0) {
          var Ae = Math.max(1, n.state.radius + n.state.radius * Ce);
          n.setState({ radius: Ae });
        }
        a.staticMoving ? ge.copy(T, P) : T[1] += (P[1] - T[1]) * a.dynamicDampingFactor;
      }(), function() {
        if (ge.sub(te, ge.copy(te, R), M), ge.squaredMagnitude(te)) {
          var Ce = t.pixelRatio * a.panSpeed;
          te[0] *= 1 / n.zoom * n.viewport.width * Ce, te[1] *= 1 / n.zoom * n.viewport.height * Ce, S.cross($, S.copy($, g), n.up), S.setMagnitude($, $, te[0]), S.setMagnitude(ee, n.up, te[1]), S.add($, $, ee), S.add(n.position, n.position, $), S.add(n.target, n.target, $), a.staticMoving ? ge.copy(M, R) : (ge.sub(te, R, M), ge.scale(te, te, a.dynamicDampingFactor), ge.add(M, M, te));
        }
      }(), S.add(n.position, n.target, g), le = Math.min(Math.max(1e3 * n.state.radiusMax, 0.01), a.maxDistance), S.squaredMagnitude(g) > le * le && (S.setMagnitude(g, g, le), S.add(n.position, n.target, g), ge.copy(E, D), ge.copy(T, P)), S.squaredMagnitude(g) < a.minDistance * a.minDistance && (S.setMagnitude(g, g, a.minDistance), S.add(n.position, n.target, g), ge.copy(E, D), ge.copy(T, P)), S.squaredDistance(h, n.position) > bn && S.copy(h, n.position), se = xe);
    }
    var ke = ge.create(5e-3, 0), Oe = 0, ze = ge.create(5e-3, 0);
    function je() {
      Oe = 0;
    }
    return { viewport: o, get isAnimating() {
      return a.animate.name !== "off";
    }, get props() {
      return a;
    }, setProps: function(xe) {
      var Xe;
      ((Xe = xe.animate) === null || Xe === void 0 ? void 0 : Xe.name) === "rock" && a.animate.name !== "rock" && je(), Object.assign(a, xe);
    }, get isEditing() {
      return u.value;
    }, get disabledInteraction() {
      return c.value;
    }, get isLockCamera() {
      return l.value;
    }, start: function(xe) {
      se = -1, be(xe);
    }, update: be, reset: function() {
      S.copy(n.target, O), S.copy(n.position, L), S.copy(n.up, F), S.sub(g, n.position, n.target), S.copy(h, n.position);
    }, dispose: function() {
      s || (s = !0, d.unsubscribe(), p.unsubscribe(), v.unsubscribe(), f.unsubscribe(), m.unsubscribe());
    }, setEditState: function(xe) {
      u.next(xe);
    }, setLockCameraState: function(xe) {
      l.next(xe);
    }, setDisabledInteractionState: function(xe) {
      c.next(xe);
    } };
  };
})(K2 || (K2 = {}));
var z7 = fi(), xE = { 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
` }, SE = /^(?!\/\/)\s*#include\s+(\S+)/gm, CE = /#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, AE = /[ \t]*\/\/.*\n/g, IE = /[ \t]*\/\*[\s\S]*?\*\//g, wE = /\n{2,}/g;
function Ky(e) {
  return e.replace(SE, function(t, n) {
    var r = xE[n];
    if (!r) throw new Error("empty chunk, '".concat(n, "'"));
    return r;
  }).trim().replace(AE, `
`).replace(IE, `
`).replace(wE, `
`);
}
function PE(e, t, n, r) {
  for (var i = "", a = parseInt(t); a < parseInt(n); ++a) i += r.replace(/\[\s*i\s*\]/g, "[".concat(a, "]")).replace(/UNROLLED_LOOP_INDEX/g, "".concat(a));
  return i;
}
function Xy(e, t) {
  return function(n) {
    return n.replace(CE, PE);
  }(function(n, r) {
    return r.dLightCount && (n = n.replace(/dLightCount/g, "".concat(r.dLightCount.ref.value))), r.dClipObjectCount && (n = n.replace(/dClipObjectCount/g, "".concat(r.dClipObjectCount.ref.value))), n;
  }(e, t));
}
function Pn(e, t, n, r, i, a) {
  return r === void 0 && (r = {}), i === void 0 && (i = {}), { id: z7(), name: e, vert: Ky(t), frag: Ky(n), extensions: r, outTypes: i, ignoreDefine: a };
}
function Of(e, t, n) {
  var r;
  return t.startsWith("color") ? e === "dLightCount" && !!(!((r = n.dIgnoreLight) === null || r === void 0) && r.ref.value) : ["dColorType", "dUsePalette", "dLightCount", "dOverpaintType", "dOverpaint", "dSubstanceType", "dSubstance"].includes(e);
}
function C0(e, t, n) {
  return e === "dLightCount" || Of(e, t, n);
}
var EE = Pn("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" }, {}, C0), TE = Pn("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" }, {}, Of), ME = Pn("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" }, {}, Of), DE = Pn("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" }, {}, C0), BE = Pn("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" }, {}, C0), Yy = Pn("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" }, {}, Of), RE = Pn("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" }, {}, Of), kE = Pn("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" }, {}, C0);
function Wy(e, t) {
  var n;
  if (e === void 0) return "";
  var r = ((n = e.dRenderVariant) === null || n === void 0 ? void 0 : n.ref.value) || "", i = [];
  for (var a in e) if (!(t != null && t(a, r, e))) {
    var o = e[a].ref.value;
    o !== void 0 && (typeof o == "string" ? i.push("#define ".concat(a, "_").concat(o)) : typeof o == "number" ? i.push("#define ".concat(a, " ").concat(o)) : typeof o == "boolean" ? o && i.push("#define ".concat(a)) : Tr());
  }
  return i.join(`
`) + `
`;
}
var OE = `#version 300 es
#define attribute in
#define varying out
#define texture2D texture
`, NE = `
#define varying in
#define texture2D texture
#define texture2DLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth

#define depthTextureSupport
`;
function LE(e, t, n, r) {
  var i = Wy(n, r.ignoreDefine), a = Wy(n, r.ignoreDefine), o = Et(e) ? OE : "", s = Et(e) ? function(c, l, d, m) {
    var p = ["#version 300 es", "layout(location = 0) out highp ".concat(m[0] || "vec4", " out_FragData0;")];
    if (d.fragDepth && p.push("#define enabledFragDepth"), d.drawBuffers) {
      p.push("#define requiredDrawBuffers");
      for (var v = 1, f = c.getParameter(c.MAX_DRAW_BUFFERS); v < f; ++v) p.push("layout(location = ".concat(v, ") out highp ").concat(m[v] || "vec4", " out_FragData").concat(v, ";"));
    }
    return d.shaderTextureLod && p.push("#define enabledShaderTextureLod"), p.push(NE), p.join(`
`) + `
`;
  }(e, 0, r.extensions, r.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, r.extensions), u = Et(e) ? function(c) {
    return c.replace(/gl_FragData\[([0-9]+)\]/g, "out_FragData$1");
  }(r.frag) : r.frag;
  return { id: z7(), name: r.name, vert: "".concat(o).concat(i).concat(Xy(r.vert, n)), frag: "".concat(s).concat(a).concat(Xy(u, n)), extensions: r.extensions, outTypes: r.outTypes };
}
function FE(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 GE(e, t, n) {
  e.uniform1f(t, n);
}
function VE(e, t, n) {
  e.uniform1fv(t, n);
}
function zE(e, t, n) {
  e.uniform1i(t, n);
}
function UE(e, t, n) {
  e.uniform1iv(t, n);
}
function HE(e, t, n) {
  e.uniform2fv(t, n);
}
function qE(e, t, n) {
  e.uniform3fv(t, n);
}
function jE(e, t, n) {
  e.uniform4fv(t, n);
}
function KE(e, t, n) {
  e.uniformMatrix3fv(t, !1, n);
}
function XE(e, t, n) {
  e.uniformMatrix4fv(t, !1, n);
}
function Zy(e) {
  switch (e) {
    case "f":
      return GE;
    case "f[]":
      return VE;
    case "i":
    case "t":
    case "b":
      return zE;
    case "i[]":
    case "t[]":
    case "b[]":
      return UE;
    case "v2":
    case "v2[]":
      return HE;
    case "v3":
    case "v3[]":
      return qE;
    case "v4":
    case "v4[]":
      return jE;
    case "m3":
    case "m3[]":
      return KE;
    case "m4":
    case "m4[]":
      return XE;
  }
}
var YE = fi();
function Qy(e) {
  var t = e.createBuffer();
  if (t === null) throw new Error("Could not create WebGL buffer");
  return t;
}
function Jy(e, t, n, r) {
  var i = Qy(e), a = function(m, p) {
    switch (p) {
      case "static":
        return m.STATIC_DRAW;
      case "dynamic":
        return m.DYNAMIC_DRAW;
      case "stream":
        return m.STREAM_DRAW;
    }
  }(e, n), o = function(m, p) {
    switch (p) {
      case "attribute":
        return m.ARRAY_BUFFER;
      case "elements":
        return m.ELEMENT_ARRAY_BUFFER;
      case "uniform":
        return m.UNIFORM_BUFFER;
    }
  }(e, r), s = function(m, p) {
    return p instanceof Uint8Array ? m.UNSIGNED_BYTE : p instanceof Int8Array ? m.BYTE : p instanceof Uint16Array ? m.UNSIGNED_SHORT : p instanceof Int16Array ? m.SHORT : p instanceof Uint32Array ? m.UNSIGNED_INT : p instanceof Int32Array ? m.INT : p instanceof Float32Array ? m.FLOAT : void Tr();
  }(e, t), u = t.BYTES_PER_ELEMENT, c = t.length;
  function l(m) {
    e.bindBuffer(o, i), e.bufferData(o, m, a);
  }
  l(t);
  var d = !1;
  return { id: YE(), _usageHint: a, _bufferType: o, _dataType: s, _bpe: u, length: c, getBuffer: function() {
    return i;
  }, updateData: l, updateSubData: function(m, p, v) {
    e.bindBuffer(o, i), v - p === m.length ? e.bufferSubData(o, 0, m) : e.bufferSubData(o, p * u, m.subarray(p, p + v));
  }, reset: function() {
    i = Qy(e), l(t);
  }, destroy: function() {
    d || (e.deleteBuffer(i), d = !0);
  } };
}
function WE(e, t, n) {
  switch (t) {
    case "int32":
      switch (n) {
        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 (n) {
        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(n, "'"));
}
var ZE = fi();
function X2(e) {
  var t = e.createProgram();
  if (t === null) throw new Error("Could not create WebGL program");
  return t;
}
function QE(e, t, n, r, i) {
  var a, o, s = i.defineValues, u = i.shaderCode, c = i.schema, l = X2(e), d = ZE(), m = LE(e, n, s, u), p = r("vert", m.vert), v = r("frag", m.frag);
  function f() {
    p.attach(l), v.attach(l), e.linkProgram(l), Xt && function(h, g) {
      if (!h.getProgramParameter(g, h.LINK_STATUS)) throw new Error(`Could not compile WebGL program. 

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

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

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, nT = new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]);
function $y(e, t) {
  var n = Fm(e, { type: "vert", source: eT }), r = Fm(e, { type: "frag", source: tT });
  if (!n || !r) return !1;
  var i = X2(e);
  e.attachShader(i, n), e.attachShader(i, r), e.linkProgram(i), e.useProgram(i);
  var a = e.getAttribLocation(i, "aPosition"), o = e.getUniformLocation(i, "uColor");
  if (!o) return Xt && console.log("error getting 'uColor' uniform location"), !1;
  var s = e.createBuffer();
  e.bindBuffer(e.ARRAY_BUFFER, s), e.bufferData(e.ARRAY_BUFFER, nT, e.STATIC_DRAW), e.enableVertexAttribArray(a), e.vertexAttribPointer(a, 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 Xt && 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 m = new Uint8Array(4);
  if (e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, m), m[0] !== 0 || m[1] < 248 || m[2] < 248 || m[3] < 254) return Xt && console.log("not able to actually render to '".concat(t, "' texture")), !1;
  if (t === e.FLOAT) {
    e.bindFramebuffer(e.FRAMEBUFFER, d);
    var p = new Float32Array(4);
    e.readPixels(0, 0, 1, 1, e.RGBA, e.FLOAT, p);
    var v = e.getError();
    if (v) return Xt && console.log("error reading float pixels: '".concat(j7(e, v), "'")), !1;
  }
  return !0;
}
var hc, U7 = fi();
function Og(e) {
  var t = e.checkFramebufferStatus(e.FRAMEBUFFER);
  if (t !== e.FRAMEBUFFER_COMPLETE) {
    var n = function(r, i) {
      switch (i) {
        case r.FRAMEBUFFER_COMPLETE:
          return "complete";
        case r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
          return "incomplete attachment";
        case r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
          return "incomplete missing attachment";
        case r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
          return "incomplete dimensions";
        case r.FRAMEBUFFER_UNSUPPORTED:
          return "unsupported";
      }
      if (Et(r)) switch (i) {
        case r.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
          return "incomplete multisample";
        case r.RENDERBUFFER_SAMPLES:
          return "renderbuffer samples";
      }
      return "unknown error";
    }(e, t);
    throw new Error("Framebuffer status: ".concat(n));
  }
}
function e4(e) {
  var t = e.createFramebuffer();
  if (t === null) throw new Error("Could not create WebGL framebuffer");
  return t;
}
function t4(e) {
  var t = function(h) {
    if (Et(h)) return { drawArraysInstanced: h.drawArraysInstanced.bind(h), drawElementsInstanced: h.drawElementsInstanced.bind(h), vertexAttribDivisor: h.vertexAttribDivisor.bind(h), VERTEX_ATTRIB_ARRAY_DIVISOR: h.VERTEX_ATTRIB_ARRAY_DIVISOR };
    var g = h.getExtension("ANGLE_instanced_arrays");
    return g === null ? null : { drawArraysInstanced: g.drawArraysInstancedANGLE.bind(g), drawElementsInstanced: g.drawElementsInstancedANGLE.bind(g), vertexAttribDivisor: g.vertexAttribDivisorANGLE.bind(g), VERTEX_ATTRIB_ARRAY_DIVISOR: g.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE };
  }(e);
  if (t === null) throw new Error('Could not find support for "instanced_arrays"');
  var n = function(h) {
    return Et(h) ? {} : h.getExtension("OES_element_index_uint");
  }(e);
  if (n === null) throw new Error('Could not find support for "element_index_uint"');
  var r = function(h) {
    if (Et(h)) return { FRAGMENT_SHADER_DERIVATIVE_HINT: h.FRAGMENT_SHADER_DERIVATIVE_HINT };
    var g = h.getExtension("OES_standard_derivatives");
    return g === null ? null : { FRAGMENT_SHADER_DERIVATIVE_HINT: g.FRAGMENT_SHADER_DERIVATIVE_HINT_OES };
  }(e);
  if (r === null) throw new Error('Could not find support for "standard_derivatives"');
  var i = function(h) {
    return Et(h) ? {} : h.getExtension("OES_texture_float");
  }(e);
  Xt && i === null && console.log('Could not find support for "texture_float"');
  var a = function(h) {
    return h.getExtension("OES_texture_float_linear");
  }(e);
  Xt && a === null && console.log('Could not find support for "texture_float_linear"');
  var o = function(h) {
    if (Et(h)) return { HALF_FLOAT: h.HALF_FLOAT };
    var g = h.getExtension("OES_texture_half_float");
    return g === null ? null : { HALF_FLOAT: g.HALF_FLOAT_OES };
  }(e);
  Xt && o === null && console.log('Could not find support for "texture_half_float"');
  var s = function(h) {
    return h.getExtension("OES_texture_half_float_linear");
  }(e);
  Xt && s === null && console.log('Could not find support for "texture_half_float_linear"');
  var u = function(h) {
    if (Et(h)) return { UNSIGNED_INT_24_8: h.UNSIGNED_INT_24_8 };
    var g = h.getExtension("WEBGL_depth_texture");
    return g === null ? null : { UNSIGNED_INT_24_8: g.UNSIGNED_INT_24_8_WEBGL };
  }(e);
  Xt && u === null && console.log('Could not find support for "depth_texture"');
  var c = function(h) {
    if (Et(h)) return { MIN: h.MIN, MAX: h.MAX };
    var g = h.getExtension("EXT_blend_minmax");
    return g === null ? null : { MIN: g.MIN_EXT, MAX: g.MAX_EXT };
  }(e);
  Xt && c === null && console.log('Could not find support for "blend_minmax"');
  var l = function(h) {
    if (Et(h)) return { VERTEX_ARRAY_BINDING: h.VERTEX_ARRAY_BINDING, bindVertexArray: h.bindVertexArray.bind(h), createVertexArray: h.createVertexArray.bind(h), deleteVertexArray: h.deleteVertexArray.bind(h), isVertexArray: h.isVertexArray.bind(h) };
    var g = h.getExtension("OES_vertex_array_object");
    return g === null ? null : { VERTEX_ARRAY_BINDING: g.VERTEX_ARRAY_BINDING_OES, bindVertexArray: g.bindVertexArrayOES.bind(g), createVertexArray: g.createVertexArrayOES.bind(g), deleteVertexArray: g.deleteVertexArrayOES.bind(g), isVertexArray: g.isVertexArrayOES.bind(g) };
  }(e);
  Xt && l === null && console.log('Could not find support for "vertex_array_object"');
  var d = function(h) {
    return Et(h) ? {} : h.getExtension("EXT_frag_depth");
  }(e);
  Xt && d === null && console.log('Could not find support for "frag_depth"');
  var m = function(h) {
    if (Et(h)) return h.getExtension("EXT_color_buffer_float") === null ? null : (h.getExtension("EXT_float_blend"), { RGBA32F: h.RGBA32F });
    var g = h.getExtension("WEBGL_color_buffer_float");
    return g === null ? (h.getExtension("OES_texture_float"), $y(h, h.FLOAT) ? { RGBA32F: 34836 } : null) : (h.getExtension("EXT_float_blend"), { RGBA32F: g.RGBA32F_EXT });
  }(e);
  Xt && m === null && console.log('Could not find support for "color_buffer_float"');
  var p = function(h) {
    if (Et(h)) return h.getExtension("EXT_color_buffer_half_float") === null ? null : (h.getExtension("EXT_float_blend"), { RGBA16F: h.RGBA16F });
    var g = h.getExtension("EXT_color_buffer_half_float");
    return g === null ? (h.getExtension("OES_texture_half_float"), $y(h, 36193) ? { RGBA16F: 34842 } : null) : (h.getExtension("EXT_float_blend"), { RGBA16F: g.RGBA16F_EXT });
  }(e);
  Xt && p === null && console.log('Could not find support for "color_buffer_half_float"');
  var v = function(h) {
    if (Et(h)) return { drawBuffers: h.drawBuffers.bind(h), COLOR_ATTACHMENT0: h.COLOR_ATTACHMENT0, COLOR_ATTACHMENT1: h.COLOR_ATTACHMENT1, COLOR_ATTACHMENT2: h.COLOR_ATTACHMENT2, COLOR_ATTACHMENT3: h.COLOR_ATTACHMENT3, COLOR_ATTACHMENT4: h.COLOR_ATTACHMENT4, COLOR_ATTACHMENT5: h.COLOR_ATTACHMENT5, COLOR_ATTACHMENT6: h.COLOR_ATTACHMENT6, COLOR_ATTACHMENT7: h.COLOR_ATTACHMENT7, DRAW_BUFFER0: h.DRAW_BUFFER0, DRAW_BUFFER1: h.DRAW_BUFFER1, DRAW_BUFFER2: h.DRAW_BUFFER2, DRAW_BUFFER3: h.DRAW_BUFFER3, DRAW_BUFFER4: h.DRAW_BUFFER4, DRAW_BUFFER5: h.DRAW_BUFFER5, DRAW_BUFFER6: h.DRAW_BUFFER6, DRAW_BUFFER7: h.DRAW_BUFFER7, MAX_COLOR_ATTACHMENTS: h.MAX_COLOR_ATTACHMENTS, MAX_DRAW_BUFFERS: h.MAX_DRAW_BUFFERS };
    var g = h.getExtension("WEBGL_draw_buffers");
    return g === null ? null : { drawBuffers: g.drawBuffersWEBGL.bind(g), COLOR_ATTACHMENT0: g.COLOR_ATTACHMENT0_WEBGL, COLOR_ATTACHMENT1: g.COLOR_ATTACHMENT1_WEBGL, COLOR_ATTACHMENT2: g.COLOR_ATTACHMENT2_WEBGL, COLOR_ATTACHMENT3: g.COLOR_ATTACHMENT3_WEBGL, COLOR_ATTACHMENT4: g.COLOR_ATTACHMENT4_WEBGL, COLOR_ATTACHMENT5: g.COLOR_ATTACHMENT5_WEBGL, COLOR_ATTACHMENT6: g.COLOR_ATTACHMENT6_WEBGL, COLOR_ATTACHMENT7: g.COLOR_ATTACHMENT7_WEBGL, DRAW_BUFFER0: g.DRAW_BUFFER0_WEBGL, DRAW_BUFFER1: g.DRAW_BUFFER1_WEBGL, DRAW_BUFFER2: g.DRAW_BUFFER2_WEBGL, DRAW_BUFFER3: g.DRAW_BUFFER3_WEBGL, DRAW_BUFFER4: g.DRAW_BUFFER4_WEBGL, DRAW_BUFFER5: g.DRAW_BUFFER5_WEBGL, DRAW_BUFFER6: g.DRAW_BUFFER6_WEBGL, DRAW_BUFFER7: g.DRAW_BUFFER7_WEBGL, MAX_COLOR_ATTACHMENTS: g.MAX_COLOR_ATTACHMENTS_WEBGL, MAX_DRAW_BUFFERS: g.MAX_DRAW_BUFFERS_WEBGL };
  }(e);
  Xt && v === null && console.log('Could not find support for "draw_buffers"');
  var f = function(h) {
    return Et(h) ? {} : h.getExtension("EXT_shader_texture_lod");
  }(e);
  Xt && f === null && console.log('Could not find support for "shader_texture_lod"');
  var y = function(h) {
    if (Et(h)) return { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: h.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, SRGB8_ALPHA8: h.SRGB8_ALPHA8, SRGB8: h.SRGB8, SRGB: h.SRGB };
    var g = h.getExtension("EXT_sRGB");
    return g === null ? null : { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: g.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT, SRGB8_ALPHA8: g.SRGB8_ALPHA8_EXT, SRGB8: g.SRGB_ALPHA_EXT, SRGB: g.SRGB_EXT };
  }(e);
  return Xt && y === null && console.log('Could not find support for "sRGB"'), { instancedArrays: t, standardDerivatives: r, textureFloat: i, textureFloatLinear: a, textureHalfFloat: o, textureHalfFloatLinear: s, elementIndexUint: n, depthTexture: u, blendMinMax: c, vertexArrayObject: l, fragDepth: d, colorBufferFloat: m, colorBufferHalfFloat: p, drawBuffers: v, shaderTextureLod: f, sRGB: y };
}
function n4(e, t, n) {
  var r = /* @__PURE__ */ new Map();
  return { get: function(i) {
    var a, o, s = e(i), u = r.get(s);
    return u || (a = t(i), o === void 0 && (o = 0), u = { value: a, usageCount: o }, r.set(s, u)), u.usageCount += 1, function(c) {
      return { free: function() {
        c.usageCount -= 1;
      }, value: c.value };
    }(u);
  }, clear: function() {
    r.forEach(function(i, a) {
      i.usageCount <= 0 && (i.usageCount < 0 && console.warn("Reference usageCount below zero."), n(i.value), r.delete(a));
    });
  }, get count() {
    return r.size;
  }, dispose: function() {
    r.forEach(function(i) {
      return n(i.value);
    }), r.clear();
  } };
}
(function(e) {
  e.create = function(t, n, r) {
    return { array: t, width: n, height: r };
  }, e.flipY = function(t) {
    for (var n = t.array, r = t.width, i = t.height, a = 4 * r, o = 0, s = i / 2; o < s; ++o) for (var u = 0, c = a; u < c; ++u) {
      var l = o * a + u, d = (i - o - 1) * a + u, m = n[l];
      n[l] = n[d], n[d] = m;
    }
    return t;
  }, e.divideByAlpha = function(t) {
    for (var n = t.array, r = n instanceof Uint8Array ? 255 : 1, i = 0, a = n.length; i < a; i += 4) {
      var o = n[i + 3] / r;
      o !== 0 ? (n[i] /= o, n[i + 1] /= o, n[i + 2] /= o) : (n[i] = 0, n[i + 1] = 0, n[i + 2] = 0);
    }
    return t;
  };
})(hc || (hc = {}));
var rT = fi();
function r4(e) {
  var t = e.createRenderbuffer();
  if (t === null) throw new Error("Could not create WebGL renderbuffer");
  return t;
}
function iT(e, t, n, r, i) {
  var a = r4(e), o = function() {
    return e.bindRenderbuffer(e.RENDERBUFFER, a);
  }, s = function(d, m) {
    switch (m) {
      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 (Et(d)) return d.DEPTH_COMPONENT32F;
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    }
  }(e, t), u = function(d, m) {
    switch (m) {
      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, n);
  function c() {
    o(), e.renderbufferStorage(e.RENDERBUFFER, s, r, i);
  }
  c();
  var l = !1;
  return { id: rT(), bind: o, attachFramebuffer: function(d) {
    d.bind(), o(), e.framebufferRenderbuffer(e.FRAMEBUFFER, u, e.RENDERBUFFER, a), Xt && Og(e);
  }, setSize: function(d, m) {
    r = d, i = m, c();
  }, reset: function() {
    a = r4(e), c();
  }, destroy: function() {
    l || (e.deleteRenderbuffer(a), l = !0);
  } };
}
var H7 = fi();
function i4(e, t, n) {
  switch (t) {
    case "alpha":
      return Et(e) && n === "float" ? e.RED : Et(e) && n === "int" ? e.RED_INTEGER : e.ALPHA;
    case "rgb":
      return Et(e) && n === "int" ? e.RGB_INTEGER : e.RGB;
    case "rgba":
      return Et(e) && n === "int" ? e.RGBA_INTEGER : e.RGBA;
    case "depth":
      return e.DEPTH_COMPONENT;
  }
}
function a4(e, t) {
  switch (t) {
    case "nearest":
      return e.NEAREST;
    case "linear":
      return e.LINEAR;
  }
}
function o1(e, t, n) {
  switch (n) {
    case "depth":
      return e.DEPTH_ATTACHMENT;
    case "stencil":
      return e.STENCIL_ATTACHMENT;
    case "color0":
    case 0:
      return e.COLOR_ATTACHMENT0;
  }
  if (t.drawBuffers) switch (n) {
    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 o4(e) {
  return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement;
}
function s4(e, t, n) {
  return t === n.TEXTURE_3D;
}
function u4(e) {
  var t = e.createTexture();
  if (t === null) throw new Error("Could not create WebGL texture");
  return t;
}
function Y2(e, t, n, r, i, a) {
  var o = H7(), s = u4(e);
  if (n.endsWith("float32") && i !== "float" || n.endsWith("float16") && i !== "fp16" || n.endsWith("uint8") && i !== "ubyte" || n.endsWith("int32") && i !== "int" || n.endsWith("depth") && i !== "ushort" && i !== "float") throw new Error("texture kind '".concat(n, "' and type '").concat(i, "' are incompatible"));
  var u = function(b, _) {
    switch (_) {
      case "image-uint8":
      case "image-float32":
      case "image-float16":
      case "image-depth":
        return b.TEXTURE_2D;
    }
    if (Et(b)) switch (_) {
      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(_, "'"));
  }(e, n), c = a4(e, a), l = i4(e, r, i), d = function(b, _, A) {
    if (Et(b)) switch (_) {
      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 i4(b, _, A);
  }(e, r, i), m = function(b, _, A) {
    switch (A) {
      case "ubyte":
        return b.UNSIGNED_BYTE;
      case "ushort":
        return b.UNSIGNED_SHORT;
      case "float":
        return b.FLOAT;
      case "fp16":
        if (_.textureHalfFloat) return _.textureHalfFloat.HALF_FLOAT;
        throw new Error('extension "texture_half_float" unavailable');
      case "int":
        if (Et(b)) return b.INT;
        throw new Error('texture type "int" requires webgl2');
    }
  }(e, t, i);
  function p() {
    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);
  }
  p();
  var v, f = 0, y = 0, h = 0, g = !1;
  function x(b, _, A) {
    if (b === 0 || _ === 0 || Et(e) && u === e.TEXTURE_3D && A === 0) throw new Error("empty textures are not allowed");
    if (f !== b || y !== _ || h !== (A || 0)) if (f = b, y = _, h = A || 0, e.bindTexture(u, s), u === e.TEXTURE_2D) e.texImage2D(u, 0, d, f, y, 0, l, m, null);
    else {
      if (!Et(e) || u !== e.TEXTURE_3D || h === void 0) throw new Error("unknown texture target");
      e.texImage3D(u, 0, d, f, y, h, 0, l, m, null);
    }
  }
  function C(b, _) {
    if (_ === void 0 && (_ = !1), b.width === 0 || b.height === 0 || !o4(b) && Et(e) && s4(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), o4(b)) f = b.width, y = b.height, e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.bindTexture(e.TEXTURE_2D, s), e.texImage2D(e.TEXTURE_2D, 0, d, l, m, b);
    else if (function(I, w, E) {
      return w === E.TEXTURE_2D;
    }(0, u, e)) {
      var A = b.filter ? a4(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), _ ? e.texSubImage2D(u, 0, 0, 0, b.width, b.height, l, m, b.array) : (f = b.width, y = b.height, e.texImage2D(u, 0, d, f, y, 0, l, m, b.array));
    } else {
      if (!Et(e) || !s4(0, u, e)) throw new Error("unknown texture target");
      e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), _ ? e.texSubImage3D(u, 0, 0, 0, 0, b.width, b.height, b.depth, l, m, b.array) : (f = b.width, y = b.height, h = b.depth, e.texImage3D(u, 0, d, f, y, h, 0, l, m, b.array));
    }
    e.bindTexture(u, null), v = b;
  }
  return x(1, 1, Et(e) && u === e.TEXTURE_3D ? 1 : 0), { id: o, target: u, format: l, internalFormat: d, type: m, filter: c, getWidth: function() {
    return f;
  }, getHeight: function() {
    return y;
  }, getDepth: function() {
    return h;
  }, getByteCount: function() {
    return function(b, _, A, I, w) {
      var E = function(D) {
        switch (D) {
          case "alpha":
            return 1;
          case "rgb":
            return 3;
          case "rgba":
          case "depth":
            return 4;
        }
      }(b) * function(D) {
        switch (D) {
          case "ubyte":
            return 1;
          case "ushort":
          case "fp16":
            return 2;
          case "float":
          case "int":
            return 4;
        }
      }(_);
      return E * A * I * (w || 1);
    }(r, i, f, y, h);
  }, define: x, load: C, 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, _, A) {
    if (b.bind(), u === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, o1(e, t, _), e.TEXTURE_2D, s, 0);
    else {
      if (!Et(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, o1(e, t, _), s, 0, A);
    }
  }, detachFramebuffer: function(b, _) {
    if (b.bind(), u === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, o1(e, t, _), e.TEXTURE_2D, null, 0);
    else {
      if (!Et(e) || u !== e.TEXTURE_3D) throw new Error("unknown texture target");
      e.framebufferTextureLayer(e.FRAMEBUFFER, o1(e, t, _), null, 0, 0);
    }
  }, reset: function() {
    s = u4(e), p();
    var b = [f, y, h];
    f = 0, y = 0, h = 0, x(b[0], b[1], b[2]), v && C(v);
  }, destroy: function() {
    g || (e.deleteTexture(s), g = !0);
  } };
}
function c4(e, t, n) {
  var r = new Image();
  r.onload = function() {
    n.load(r), k.update(t, n);
  }, r.src = e;
}
function Ni(e) {
  var t, n = (t = e == null ? void 0 : e.TEXTURE_2D) !== null && t !== void 0 ? t : 3553;
  return { id: H7(), target: n, 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(r) {
    e && (e.activeTexture(e.TEXTURE0 + r), e.bindTexture(n, null));
  }, unbind: function(r) {
    e && (e.activeTexture(e.TEXTURE0 + r), e.bindTexture(n, null));
  }, attachFramebuffer: function() {
  }, detachFramebuffer: function() {
  }, reset: function() {
  }, destroy: function() {
  } };
}
var aT = fi();
function l4(e) {
  var t = e.vertexArrayObject;
  if (!t) throw new Error("VertexArrayObject not supported");
  var n = t.createVertexArray();
  if (!n) throw new Error("Could not create WebGL vertex array");
  return n;
}
function d4(e) {
  var t = e.vertexArrayObject;
  if (t === null) throw new Error("VertexArrayObject not supported");
  return t;
}
function f4(e) {
  return B(B({}, e.value), { destroy: function() {
    e.free();
  } });
}
function oT(e, t, n, r) {
  var i = { 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 a(c, l) {
    return i[c].add(l), n.resourceCounts[c] += 1, B(B({}, l), { destroy: function() {
      l.destroy(), i[c].delete(l), n.resourceCounts[c] -= 1;
    } });
  }
  var o = n4(function(c) {
    return JSON.stringify(c);
  }, function(c) {
    return a("shader", $E(e, c));
  }, function(c) {
    c.destroy();
  });
  function s(c, l) {
    return f4(o.get({ type: c, source: l }));
  }
  var u = n4(function(c) {
    var l, d = [c.shaderCode.id], m = ((l = c.defineValues.dRenderVariant) === null || l === void 0 ? void 0 : l.ref.value) || "";
    return Object.keys(c.defineValues).forEach(function(p) {
      var v, f;
      !((f = (v = c.shaderCode).ignoreDefine) === null || f === void 0) && f.call(v, p, m, c.defineValues) || d.push(k2(p), function(y) {
        return typeof y == "boolean" ? y ? 1 : 0 : typeof y == "number" ? 1e4 * y : k2(y);
      }(c.defineValues[p].ref.value));
    }), di(d).toString();
  }, function(c) {
    return a("program", QE(e, t, r, s, c));
  }, function(c) {
    c.destroy();
  });
  return { attribute: function(c, l, d, m) {
    return a("attribute", function(p, v, f, y, h, g, x) {
      x === void 0 && (x = "dynamic");
      var C = f.instancedArrays, b = Jy(p, y, x, "attribute"), _ = b._bufferType, A = b._dataType, I = b._bpe;
      return B(B({}, b), { bind: function(w) {
        if (p.bindBuffer(_, b.getBuffer()), h === 16) for (var E = 0; E < 4; ++E) v.enableVertexAttrib(w + E), p.vertexAttribPointer(w + E, 4, A, !1, 16 * I, 4 * E * I), C.vertexAttribDivisor(w + E, g);
        else v.enableVertexAttrib(w), p.vertexAttribPointer(w, h, A, !1, 0, 0), C.vertexAttribDivisor(w, g);
      } });
    }(e, t, r, c, l, d, m));
  }, elements: function(c, l) {
    return a("elements", function(d, m, p) {
      p === void 0 && (p = "static");
      var v = Jy(d, m, p, "elements");
      return B(B({}, v), { bind: function() {
        d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, v.getBuffer());
      } });
    }(e, c, l));
  }, framebuffer: function() {
    return a("framebuffer", function(c) {
      var l = e4(c), d = !1;
      return { id: U7(), bind: function() {
        return c.bindFramebuffer(c.FRAMEBUFFER, l);
      }, reset: function() {
        l = e4(c);
      }, destroy: function() {
        d || (c.deleteFramebuffer(l), d = !0);
      } };
    }(e));
  }, program: function(c, l, d) {
    return f4(u.get({ defineValues: c, shaderCode: l, schema: d }));
  }, renderbuffer: function(c, l, d, m) {
    return a("renderbuffer", iT(e, c, l, d, m));
  }, shader: s, texture: function(c, l, d, m) {
    return a("texture", Y2(e, r, c, l, d, m));
  }, vertexArray: function(c, l, d) {
    return a("vertexArray", function(m, p, v, f, y) {
      var h = aT(), g = l4(p), x = d4(p);
      function C() {
        x.bindVertexArray(g), y && y.bind(), v.bindAttributes(f), x.bindVertexArray(null);
      }
      C();
      var b = !1;
      return { id: h, bind: function() {
        x.bindVertexArray(g);
      }, update: C, reset: function() {
        g = l4(p), x = d4(p), C();
      }, destroy: function() {
        b || (y && (x.bindVertexArray(g), m.bindBuffer(m.ELEMENT_ARRAY_BUFFER, null)), x.deleteVertexArray(g), b = !0);
      } };
    }(e, r, c, l, d));
  }, getByteCounts: function() {
    var c = 0;
    i.texture.forEach(function(m) {
      c += m.getByteCount();
    });
    var l = 0;
    i.attribute.forEach(function(m) {
      l += 4 * m.length;
    });
    var d = 0;
    return i.elements.forEach(function(m) {
      d += 4 * m.length;
    }), { texture: c, attribute: l, elements: d };
  }, reset: function() {
    i.attribute.forEach(function(c) {
      return c.reset();
    }), i.elements.forEach(function(c) {
      return c.reset();
    }), i.framebuffer.forEach(function(c) {
      return c.reset();
    }), i.renderbuffer.forEach(function(c) {
      return c.reset();
    }), i.shader.forEach(function(c) {
      return c.reset();
    }), i.program.forEach(function(c) {
      return c.reset();
    }), i.vertexArray.forEach(function(c) {
      return c.reset();
    }), i.texture.forEach(function(c) {
      return c.reset();
    });
  }, destroy: function() {
    i.attribute.forEach(function(c) {
      return c.destroy();
    }), i.elements.forEach(function(c) {
      return c.destroy();
    }), i.framebuffer.forEach(function(c) {
      return c.destroy();
    }), i.renderbuffer.forEach(function(c) {
      return c.destroy();
    }), i.shader.forEach(function(c) {
      return c.destroy();
    }), i.program.forEach(function(c) {
      return c.destroy();
    }), i.vertexArray.forEach(function(c) {
      return c.destroy();
    }), i.texture.forEach(function(c) {
      return c.destroy();
    }), o.clear(), u.clear();
  } };
}
var q7 = fi();
function j7(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 K7(e) {
  var t = e.getError();
  if (t !== e.NO_ERROR) throw new Error("WebGL error: '".concat(j7(e, t), "'"));
}
function s1(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null);
}
var X7 = new Uint8Array(4);
function Y7(e, t, n) {
  e.getSyncParameter(t, e.SYNC_STATUS) === e.SIGNALED ? (e.deleteSync(t), n()) : Rg.setImmediate(Y7, e, t, n);
}
function m4(e, t) {
  var n = e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE, 0);
  n ? Rg.setImmediate(Y7, e, n, t) : (console.warn("Could not create a WebGLSync object"), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, X7), t());
}
var Gm, p4, h4 = !1;
function v4(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, X7);
}
function dp(e, t, n, r, i, a) {
  if (Xt && Og(e), a instanceof Uint8Array) e.readPixels(t, n, r, i, e.RGBA, e.UNSIGNED_BYTE, a);
  else if (a instanceof Float32Array) e.readPixels(t, n, r, i, e.RGBA, e.FLOAT, a);
  else {
    if (!(a instanceof Int32Array && Et(e))) throw new Error("unsupported readPixels buffer type");
    e.readPixels(t, n, r, i, e.RGBA_INTEGER, e.INT, a);
  }
  Xt && K7(e);
}
function sT(e, t) {
  var n = this;
  t === void 0 && (t = {});
  var r = t4(e), i = function(h) {
    var g = {}, x = h.getParameter(h.FRONT_FACE), C = h.getParameter(h.CULL_FACE_MODE), b = h.getParameter(h.DEPTH_WRITEMASK), _ = h.getParameter(h.COLOR_WRITEMASK), A = h.getParameter(h.COLOR_CLEAR_VALUE), I = h.getParameter(h.BLEND_SRC_RGB), w = h.getParameter(h.BLEND_DST_RGB), E = h.getParameter(h.BLEND_SRC_ALPHA), D = h.getParameter(h.BLEND_DST_ALPHA), T = h.getParameter(h.BLEND_EQUATION_RGB), P = h.getParameter(h.BLEND_EQUATION_ALPHA), M = h.getParameter(h.MAX_VERTEX_ATTRIBS), R = [], O = function() {
      for (var L = 0; L < M; ++L) R[L] = 0;
    };
    return O(), { currentProgramId: -1, currentMaterialId: -1, currentRenderItemId: -1, enable: function(L) {
      g[L] !== !0 && (h.enable(L), g[L] = !0);
    }, disable: function(L) {
      g[L] !== !1 && (h.disable(L), g[L] = !1);
    }, frontFace: function(L) {
      L !== x && (h.frontFace(L), x = L);
    }, cullFace: function(L) {
      L !== C && (h.cullFace(L), C = L);
    }, depthMask: function(L) {
      L !== b && (h.depthMask(L), b = L);
    }, colorMask: function(L, F, G, V) {
      L === _[0] && F === _[1] && G === _[2] && V === _[3] || (h.colorMask(L, F, G, V), _[0] = L, _[1] = F, _[2] = G, _[3] = V);
    }, clearColor: function(L, F, G, V) {
      L === A[0] && F === A[1] && G === A[2] && V === A[3] || (h.clearColor(L, F, G, V), A[0] = L, A[1] = F, A[2] = G, A[3] = V);
    }, blendFunc: function(L, F) {
      L === I && F === w && L === E && F === D || (h.blendFunc(L, F), I = L, w = F, E = L, D = F);
    }, blendFuncSeparate: function(L, F, G, V) {
      L === I && F === w && G === E && V === D || (h.blendFuncSeparate(L, F, G, V), I = L, w = F, E = G, D = V);
    }, blendEquation: function(L) {
      L === T && L === P || (h.blendEquation(L), T = L, P = L);
    }, blendEquationSeparate: function(L, F) {
      L === T && F === P || (h.blendEquationSeparate(L, F), T = L, P = F);
    }, enableVertexAttrib: function(L) {
      h.enableVertexAttribArray(L), R[L] = 1;
    }, clearVertexAttribsState: O, disableUnusedVertexAttribs: function() {
      for (var L = 0; L < M; ++L) R[L] === 0 && h.disableVertexAttribArray(L);
    }, reset: function() {
      g = {}, x = h.getParameter(h.FRONT_FACE), C = h.getParameter(h.CULL_FACE_MODE), b = h.getParameter(h.DEPTH_WRITEMASK), _ = h.getParameter(h.COLOR_WRITEMASK), A = h.getParameter(h.COLOR_CLEAR_VALUE), I = h.getParameter(h.BLEND_SRC_RGB), w = h.getParameter(h.BLEND_DST_RGB), E = h.getParameter(h.BLEND_SRC_ALPHA), D = h.getParameter(h.BLEND_DST_ALPHA), T = h.getParameter(h.BLEND_EQUATION_RGB), P = h.getParameter(h.BLEND_EQUATION_ALPHA), M = h.getParameter(h.MAX_VERTEX_ATTRIBS), R.length = 0;
      for (var L = 0; L < M; ++L) R[L] = 0;
    } };
  }(e), a = { resourceCounts: { attribute: 0, elements: 0, framebuffer: 0, program: 0, renderbuffer: 0, shader: 0, texture: 0, vertexArray: 0 }, drawCount: 0, instanceCount: 0, instancedDrawCount: 0 }, o = oT(e, i, a, r), s = { maxTextureSize: e.getParameter(e.MAX_TEXTURE_SIZE), max3dTextureSize: Et(e) ? e.getParameter(e.MAX_3D_TEXTURE_SIZE) : 0, maxRenderbufferSize: e.getParameter(e.MAX_RENDERBUFFER_SIZE), maxDrawBuffers: r.drawBuffers ? e.getParameter(r.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 cu(0);
  if (Et(e)) {
    var d = e.createBuffer(), m = void 0, p = void 0, v = !1, f = function() {
      e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.getBufferSubData(e.PIXEL_PACK_BUFFER, 0, m), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), v = !1, p(), p = void 0, m = void 0;
    };
    u = function(h, g, x, C, b) {
      return new Promise(function(_, A) {
        v ? A("Can not call multiple readPixelsAsync at the same time") : (v = !0, e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.bufferData(e.PIXEL_PACK_BUFFER, x * C * 4, e.STREAM_READ), e.readPixels(h, g, x, C, e.RGBA, e.UNSIGNED_BYTE, 0), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), p = _, m = b, m4(e, f));
      });
    };
  } else u = function(h, g, x, C, b) {
    return ie(n, 0, void 0, function() {
      return ne(this, function(_) {
        return dp(e, h, g, x, C, b), [2];
      });
    });
  };
  var y = /* @__PURE__ */ new Set();
  return { gl: e, isWebGL2: Et(e), get pixelRatio() {
    return (typeof window < "u" && window.devicePixelRatio || 1) * (t.pixelScale || 1);
  }, extensions: r, state: i, stats: a, 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(h) {
    Object.assign(r, t4(e)), i.reset(), i.currentMaterialId = -1, i.currentProgramId = -1, i.currentRenderItemId = -1, o.reset(), y.forEach(function(g) {
      return g.reset();
    }), h == null || h(), c = !1, l.next(nr());
  }, createRenderTarget: function(h, g, x, C, b) {
    var _ = function(A, I, w, E, D, T, P) {
      D === void 0 && (D = !0), T === void 0 && (T = "uint8"), P === void 0 && (P = "nearest");
      var M = I.framebuffer(), R = T === "fp16" ? I.texture("image-float16", "rgba", "fp16", P) : T === "float32" ? I.texture("image-float32", "rgba", "float", P) : I.texture("image-uint8", "rgba", "ubyte", P), O = D ? Et(A) ? I.renderbuffer("depth32f", "depth", w, E) : I.renderbuffer("depth16", "depth", w, E) : null;
      function L() {
        R.define(w, E), R.attachFramebuffer(M, "color0"), O && O.attachFramebuffer(M);
      }
      L();
      var F = !1;
      return { id: q7(), texture: R, framebuffer: M, getWidth: function() {
        return w;
      }, getHeight: function() {
        return E;
      }, bind: function() {
        M.bind();
      }, setSize: function(G, V) {
        w === G && E === V || (w = G, E = V, R.define(w, E), O && O.setSize(w, E));
      }, reset: function() {
        L();
      }, destroy: function() {
        F || (R.destroy(), M.destroy(), O && O.destroy(), F = !0);
      } };
    }(e, o, h, g, x, C, b);
    return y.add(_), B(B({}, _), { destroy: function() {
      _.destroy(), y.delete(_);
    } });
  }, unbindFramebuffer: function() {
    return s1(e);
  }, readPixels: function(h, g, x, C, b) {
    dp(e, h, g, x, C, b);
  }, readPixelsAsync: u, waitForGpuCommandsComplete: function() {
    return function(h) {
      return new Promise(function(g) {
        Et(h) ? m4(h, g) : (h4 || (console.info("Sync object not supported in WebGL"), h4 = !0), v4(h), g());
      });
    }(e);
  }, waitForGpuCommandsCompleteSync: function() {
    return v4(e);
  }, getDrawingBufferPixelData: function() {
    return function(h) {
      var g = h.drawingBufferWidth, x = h.drawingBufferHeight, C = new Uint8Array(g * x * 4);
      return s1(h), h.viewport(0, 0, g, x), dp(h, 0, 0, g, x, C), hc.flipY(hc.create(C, g, x));
    }(e);
  }, clear: function(h, g, x, C) {
    s1(e), i.enable(e.SCISSOR_TEST), i.depthMask(!0), i.colorMask(!0, !0, !0, !0), i.clearColor(h, g, x, C), 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(h) {
    var g, x;
    o.destroy(), function(C) {
      for (var b = C.getParameter(C.MAX_TEXTURE_IMAGE_UNITS), _ = 0; _ < b; ++_) C.activeTexture(C.TEXTURE0 + _), C.bindTexture(C.TEXTURE_2D, null), C.bindTexture(C.TEXTURE_CUBE_MAP, null), Et(C) && (C.bindTexture(C.TEXTURE_2D_ARRAY, null), C.bindTexture(C.TEXTURE_3D, null));
      var A = C.createBuffer();
      C.bindBuffer(C.ARRAY_BUFFER, A);
      var I = C.getParameter(C.MAX_VERTEX_ATTRIBS);
      for (_ = 0; _ < I; ++_) C.vertexAttribPointer(_, 1, C.FLOAT, !1, 0, 0);
      C.bindBuffer(C.ARRAY_BUFFER, null), C.bindBuffer(C.ELEMENT_ARRAY_BUFFER, null), C.bindRenderbuffer(C.RENDERBUFFER, null), s1(C);
    }(e), h != null && h.doNotForceWebGLContextLoss || ((g = e.getExtension("WEBGL_lose_context")) === null || g === void 0 || g.loseContext(), (x = e.getExtension("STACKGL_destroy_context")) === null || x === void 0 || x.destroy());
  } };
}
function fp(e, t) {
  return { value: e, unit: t };
}
function no(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: vr.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 = i(c, u), l = i(l, u), d = i(d, u)) : Si(o.xyzOrdering.index, u) || (c = r(c, o.xyzOrdering.index, u), l = r(l, o.xyzOrdering.index, u), d = r(d, o.xyzOrdering.index, u)) : o.xyzOrdering.isIdentity || (c = a(c, o.xyzOrdering.index), l = a(l, o.xyzOrdering.index), d = a(d, o.xyzOrdering.index)) : u && (o.xyzOrdering.isIdentity ? (o.xyzOrdering.isIdentity = !1, o.xyzOrdering.index = u, n(c, u), n(l, u), n(d, u)) : Si(o.xyzOrdering.index, u) || (c = r(c, o.xyzOrdering.index, u), l = r(l, o.xyzOrdering.index, u), d = r(d, o.xyzOrdering.index, u))), o.xyzOrdering.frozen = !0, { id: vr.create22(), atomId: s, occupancy: X.ofConst(1, o.elementCount, X.Schema.int), B_iso_or_equiv: X.ofConst(0, o.elementCount, X.Schema.float), xyzDefined: !0, x: c, y: l, z: d };
  };
  var t = [0.123];
  function n(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 r(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 i(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 a(o, s) {
    for (var u = new Float32Array(o.length), c = 0, l = o.length; c < l; c++) u[s[c]] = o[c];
    return u;
  }
})(Gm || (Gm = {})), function(e) {
  e.create = function(t, n, r, i) {
    return { id: vr.create22(), label: t, basic: n, sourceData: i, bonds: r };
  };
}(p4 || (p4 = {})), function(e) {
  e.getUUID = function(t) {
    return t.__key || (t.__key = vr.create22()), t.__key;
  };
}(no || (no = {}));
var Ui, ed = 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, n) {
    var r = this._refs.get(t) || 0;
    r += n ? 1 : -1, this._refs.set(t, Math.max(r, 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, n) {
    var r = this._assets.get(t);
    if (r) for (var i = 0, a = r; i < a.length; i++)
      a[i].dispose();
    n ? this._assets.set(t, n) : this._assets.delete(t);
  }, e.prototype.dispose = function() {
    this._assets.forEach(function(t) {
      for (var n = 0, r = t; n < r.length; n++)
        r[n].dispose();
    });
  }, e;
}();
function W7(e, t, n, r, i) {
  for (var a = e.b, o = e.offset, s = [], u = 0, c = t.length; u < c; ++u) for (var l = t[u], d = o[l], m = o[l + 1]; d < m; ++d) {
    var p = a[d];
    if (!i.has(p)) {
      if (_e.has(n, p)) return !0;
      i.add(p), s[s.length] = p;
    }
  }
  return r > 1 && W7(e, s, n, r - 1, i);
}
(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, m = u.a, p = u.b, v = u.offset, f = 0, y = s.a.length; f < y; f++) if (c[f] !== m[f]) return !1;
    for (f = 0, y = s.b.length; f < y; f++) if (l[f] !== p[f]) return !1;
    for (f = 0, y = s.offset.length; f < y; f++) if (d[f] !== v[f]) return !1;
    for (var h = 0, g = Object.keys(s.edgeProps); h < g.length; h++) {
      var x = g[h], C = s.edgeProps[x], b = u.edgeProps[x];
      if (!b) return !1;
      for (f = 0, y = C.length; f < y; f++) if (C[f] !== b[f]) return !1;
    }
    return !0;
  };
  var t = function() {
    function s(u, c, l, d, m, p) {
      this.offset = u, this.a = c, this.b = l, this.edgeCount = d, this.props = p, this.vertexCount = u.length - 1, this.edgeProps = m || {};
    }
    return s.prototype.getEdgeIndex = function(u, c) {
      var l, d;
      u < c ? (l = u, d = c) : (l = c, d = u);
      for (var m = this.offset[l], p = this.offset[l + 1]; m < p; m++) if (this.b[m] === d) return m;
      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 n(s, u, c, l, d, m) {
    return new t(s, u, c, l, d, m);
  }
  e.create = n;
  var r = 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), m = 0, p = this.xs.length; m < p; m++) d[this.xs[m]]++;
      for (m = 0, p = this.ys.length; m < p; m++) d[this.ys[m]]++;
      var v = 0;
      for (m = 0; m < this.vertexCount; m++) this.offsets[m] = v, v += d[m];
      this.offsets[this.vertexCount] = v, this.slotCount = v, this.a = new Int32Array(v), this.b = new Int32Array(v);
    }
    return s.prototype.createGraph = function(u, c) {
      return n(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 = r;
  var i = 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), m = 0, p = this.xs.length; m < p; m++) d[this.xs[m]]++;
      var v = 0;
      for (m = 0; m < this.vertexCount; m++) this.offsets[m] = v, v += d[m];
      this.offsets[this.vertexCount] = v, this.slotCount = v, this.a = new Int32Array(v), this.b = new Int32Array(v);
    }
    return s.prototype.createGraph = function(u) {
      return n(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 = i;
  var a = 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 m = Ta(l, d);
      return !this.included.has(m) && (this.included.add(m), 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 r(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 = a, e.fromVertexPairs = o, e.induceByVertices = function(s, u) {
    for (var c = s.b, l = s.offset, d = s.vertexCount, m = s.edgeProps, p = new Int32Array(d), v = 0, f = u.length; v < f; v++) p[u[v]] = v + 1;
    var y = 0;
    for (v = 0; v < d; v++) if (p[v] !== 0) for (var h = l[v], g = l[v + 1]; h < g; h++) c[h] > v && p[c[h]] !== 0 && y++;
    var x = new Int32Array(u.length + 1), C = new Int32Array(2 * y), b = new Int32Array(2 * y), _ = new Int32Array(2 * y), A = 0, I = 0;
    for (v = 0; v < d; v++) if (p[v] !== 0) {
      var w = p[v] - 1;
      for (h = l[v], g = l[v + 1]; h < g; h++) {
        var E = p[c[h]];
        E !== 0 && (b[A] = w, _[A] = E - 1, C[A] = h, A++);
      }
      x[++I] = A;
    }
    for (var D = {}, T = 0, P = Object.keys(m); T < P.length; T++) {
      var M = P[T];
      D[M] = Vw(m[M], C);
    }
    return n(x, b, _, y, D);
  }, 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 m = new Int32Array(u);
    for (l = 0, d = u; l < d; l++) m[l] = -1;
    var p = 0;
    m[0] = p;
    var v = s.offset, f = s.b, y = [0], h = function(A) {
      return new qP(A);
    }(u);
    for (h.remove(0); y.length > 0; ) {
      for (var g = y.pop(), x = m[g], C = v[g], b = v[g + 1]; C < b; C++) {
        var _ = f[C];
        h.has(_) && (h.remove(_), y.push(_), m[_] = x);
      }
      y.length === 0 && h.head >= 0 && (y.push(h.head), m[h.head] = ++p, h.remove(h.head));
    }
    return { componentCount: u, componentIndex: m };
  }, 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(), m = 0, p = u.length; m < p; ++m) d.add(u[m]);
    return W7(s, u, c, l, d);
  };
})(Ui || (Ui = {}));
var Mo, gr, Fe, xl, uT = function() {
  function e() {
    this.map = /* @__PURE__ */ new Map(), this.applicable = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, n, r) {
    this.map.set(t, n), r && this.applicable.set(t, r);
  }, 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 n = this.applicable.get(t.sourceData.kind);
    return !n || n(t);
  }, e;
}();
function cT(e, t, n, r) {
  for (var i = new Ui.EdgeBuilder(r, e, t), a = new Int32Array(i.slotCount), o = new Int8Array(i.slotCount), s = new Array(i.slotCount), u = new Array(i.slotCount), c = 0, l = i.edgeCount; c < l; c++) i.addNextEdge(), i.assignProperty(a, n.key ? n.key[c] : -1), i.assignProperty(o, n.order ? n.order[c] : 1), i.assignProperty(s, n.distance ? n.distance[c] : -1), i.assignProperty(u, n.flag ? n.flag[c] : 1);
  return i.createGraph({ key: a, order: o, distance: s, flag: u });
}
function en(e) {
  return function(t) {
    return function(n, r) {
      var i = n.data, a = n.indices, o = n.count, s = r.valueType, u = s === "str" ? function(c) {
        return i.substring(a[2 * c], a[2 * c + 1]);
      } : s === "int" ? function(c) {
        return bu(i, a[2 * c], a[2 * c + 1]) || 0;
      } : function(c) {
        return fc(i, a[2 * c], a[2 * c + 1]) || 0;
      };
      return { schema: r, __array: void 0, isDefined: !0, rowCount: o, value: u, valueKind: function(c) {
        return 0;
      }, toArray: function(c) {
        return Nr(o, u, c);
      }, areValuesEqual: Z7(n) };
    }(e, t);
  };
}
function Z7(e) {
  var t = e.data, n = e.indices;
  return function(r, i) {
    var a = n[2 * r], o = n[2 * i], s = n[2 * r + 1] - a;
    if (s !== n[2 * i + 1] - o) return !1;
    for (var u = 0; u < s; u++) if (t.charCodeAt(u + a) !== t.charCodeAt(u + o)) return !1;
    return !0;
  };
}
function lT(e) {
  for (var t = e.count, n = e.indices, r = 0; r < t; ++r) if (n[2 * r] !== n[2 * r + 1]) return !1;
  return !0;
}
function Q7(e, t) {
  return { name: t, blocks: e };
}
function Ng(e, t, n, r) {
  return r === void 0 && (r = []), { categoryNames: e, header: n, categories: t, saveFrames: r, getField: function(i) {
    var a = i.split("."), o = a[0], s = a[1];
    return t[o].getField(s || "");
  } };
}
function Wr(e, t, n, r) {
  return { rowCount: t, name: e, fieldNames: Pe([], n, !0), getField: function(i) {
    return r[i];
  } };
}
function tc(e, t, n) {
  return function(r, i, a) {
    for (var o = /* @__PURE__ */ Object.create(null), s = 0, u = Object.keys(r); s < u.length; s++) {
      var c = u[s];
      o[c] = mT(c, r[c], i, a);
    }
    return R2.ofTables(i.header, r, o);
  }(e, t, n);
}
function mp(e, t, n, r) {
  return { schema: e, __array: t.__array, isDefined: t.isDefined, rowCount: t.rowCount, value: n, valueKind: t.valueKind, areValuesEqual: t.areValuesEqual, toArray: r };
}
function dT(e, t, n) {
  var r = e.space, i = t.fieldNames.includes("".concat(n, "[0]")) || t.fieldNames.includes("".concat(n, "[0][0]")) || t.fieldNames.includes("".concat(n, "[0][0][0]")), a = i ? 0 : 1, o = t.fieldNames.includes("".concat(n, "_1")) || t.fieldNames.includes("".concat(n, "_11")) || t.fieldNames.includes("".concat(n, "_111")) ? "underscore" : "brackets", s = function(l, d, m, p) {
    var v = m ? 0 : 1;
    switch (d) {
      case 1:
        return p === "brackets" ? function(f) {
          return "".concat(l, "[").concat(f + v, "]");
        } : function(f) {
          return "".concat(l, "_").concat(f + v);
        };
      case 2:
        return p === "brackets" ? function(f, y) {
          return "".concat(l, "[").concat(f + v, "][").concat(y + v, "]");
        } : function(f, y) {
          return "".concat(l, "_").concat(f + v).concat(y + v);
        };
      case 3:
        return p === "brackets" ? function(f, y, h) {
          return "".concat(l, "[").concat(f + v, "][").concat(y + v, "][").concat(h + v, "]");
        } : function(f, y, h) {
          return "".concat(l, "_").concat(f + v).concat(y + v).concat(h + v);
        };
      default:
        throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    }
  }(n, r.rank, i, o), u = t.getField(s(a, a, a)) || X.Undefined(t.rowCount, e), c = function(l) {
    return function(d, m, p, v) {
      var f = m.create();
      if (m.rank === 1) for (var y = m.dimensions[0], h = 0; h < y; h++) {
        var g = d.getField(v(h));
        m.set(f, h, g ? g.float(p) : 0);
      }
      else if (m.rank === 2) {
        y = m.dimensions[0];
        var x = m.dimensions[1];
        for (h = 0; h < y; h++) for (var C = 0; C < x; C++) g = d.getField(v(h, C)), m.set(f, h, C, g ? g.float(p) : 0);
      } else {
        if (m.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
        var b = m.dimensions[0], _ = m.dimensions[1], A = m.dimensions[2];
        for (h = 0; h < b; h++) for (C = 0; C < _; C++) for (var I = 0; I < A; I++) g = d.getField(v(h, C, I)), m.set(f, h, C, I, g ? g.float(p) : 0);
      }
      return f;
    }(t, r, l, s);
  };
  return { schema: e, __array: void 0, isDefined: u.isDefined, rowCount: t.rowCount, value: c, valueKind: u.valueKind, areValuesEqual: function(l, d) {
    return Nn.areEqualExact(c(l), c(d));
  }, toArray: function(l) {
    return Nr(t.rowCount, c, l);
  } };
}
(function(e) {
  e.create = function(t, n) {
    var r = t.name, i = new uT();
    return { descriptor: t, formatRegistry: i, isApplicable: function(a) {
      return i.isApplicable(a);
    }, get: function(a) {
      var o = n != null && n.asDynamic ? a._dynamicPropertyData : a._staticPropertyData;
      if (o[r]) return o[r];
      if (!a.customProperties.has(t)) {
        var s = i.get(a.sourceData.kind);
        if (s) return o[r] = s(a), a.customProperties.add(t), o[r];
      }
    }, set: function(a, o) {
      n != null && n.asDynamic ? a._dynamicPropertyData[r] = o : a._staticPropertyData[r] = o;
    }, delete: function(a) {
      n != null && n.asDynamic ? delete a._dynamicPropertyData[r] : delete a._staticPropertyData[r];
    } };
  };
})(Mo || (Mo = {})), function(e) {
  e.Descriptor = { name: "index_pair_bonds" }, e.Provider = Mo.create(e.Descriptor, { asDynamic: !0 }), e.DefaultProps = { maxDistance: -1 }, e.fromData = function(t, n) {
    n === void 0 && (n = {});
    var r = B(B({}, e.DefaultProps), n), i = t.pairs, a = t.count;
    return { bonds: cT(i.indexA.toArray(), i.indexB.toArray(), { key: i.key && i.key.toArray(), order: i.order && i.order.toArray(), distance: i.distance && i.distance.toArray(), flag: i.flag && i.flag.toArray() }, a), maxDistance: r.maxDistance };
  };
}(gr || (gr = {})), function(e) {
  function t(n, r) {
    var i = Object.keys(r);
    return { rowCount: i.length > 0 ? r[i[0]].rowCount : 0, name: n, fieldNames: i, getField: function(a) {
      return r[a];
    } };
  }
  e.empty = function(n) {
    return { rowCount: 0, name: n, fieldNames: [], getField: function(r) {
    } };
  }, e.ofFields = t, e.ofTable = function(n, r) {
    for (var i = {}, a = 0, o = r._columns; a < o.length; a++) {
      var s = o[a];
      i[s] = Fe.ofColumn(r[s]);
    }
    return t(n, i);
  };
}(Wr || (Wr = {})), function(e) {
  function t(r) {
    var i = r.length, a = function(u) {
      var c = r[u];
      return c && c !== "." && c !== "?" ? c : "";
    }, o = function(u) {
      var c = r[u];
      return bu(c, 0, c.length) || 0;
    }, s = function(u) {
      var c = r[u];
      return fc(c, 0, c.length) || 0;
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: i, str: a, int: o, float: s, valueKind: function(u) {
      var c = r[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 r[u] === r[c];
    }, toStringArray: function(u) {
      return u ? Nr(i, a, u) : r;
    }, toIntArray: function(u) {
      return Nr(i, o, u);
    }, toFloatArray: function(u) {
      return Nr(i, s, u);
    } };
  }
  function n(r) {
    var i, a, o, s = r.rowCount, u = r.valueKind, c = r.areValuesEqual, l = r.isDefined;
    switch (r.schema.valueType) {
      case "float":
      case "int":
        i = function(m) {
          return "" + r.value(m);
        }, a = r.value, o = r.value;
        break;
      case "str":
        i = r.value, a = function(m) {
          var p = r.value(m);
          return bu(p, 0, p.length) || 0;
        }, o = function(m) {
          var p = r.value(m);
          return fc(p, 0, p.length) || 0;
        };
        break;
      case "list":
        var d = r.schema.separator;
        i = function(m) {
          return r.value(m).join(d);
        }, a = function(m) {
          return NaN;
        }, o = function(m) {
          return NaN;
        };
        break;
      default:
        throw new Error("unsupported valueType '".concat(r.schema.valueType, "'"));
    }
    return { __array: void 0, binaryEncoding: void 0, isDefined: l, rowCount: s, str: i, int: a, float: o, valueKind: u, areValuesEqual: c, toStringArray: function(m) {
      return Nr(s, i, m);
    }, toIntArray: function(m) {
      return Nr(s, a, m);
    }, toFloatArray: function(m) {
      return Nr(s, o, m);
    } };
  }
  e.ofString = function(r) {
    return t([r]);
  }, e.ofStrings = t, e.ofNumbers = function(r) {
    var i = r.length, a = function(u) {
      return "" + r[u];
    }, o = function(u) {
      return r[u];
    }, s = function(u) {
      return !u || u.array && r instanceof u.array ? r : Nr(i, o, u);
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: i, str: a, int: o, float: o, valueKind: function(u) {
      return 0;
    }, areValuesEqual: function(u, c) {
      return r[u] === r[c];
    }, toStringArray: function(u) {
      return Nr(i, a, u);
    }, toIntArray: s, toFloatArray: s };
  }, e.ofTokens = function(r) {
    var i = r.data, a = r.indices, o = r.count, s = function(l) {
      var d = i.substring(a[2 * l], a[2 * l + 1]);
      return d === "." || d === "?" ? "" : d;
    }, u = function(l) {
      return bu(i, a[2 * l], a[2 * l + 1]) || 0;
    }, c = function(l) {
      return fc(i, a[2 * l], a[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 = a[2 * l], m = a[2 * l + 1] - d;
      if (m > 1) return 0;
      if (m === 0) return 1;
      var p = i.charCodeAt(d);
      return p === 46 ? 1 : p === 63 ? 2 : 0;
    }, areValuesEqual: Z7(r), toStringArray: function(l) {
      return Nr(o, s, l);
    }, toIntArray: function(l) {
      return Nr(o, u, l);
    }, toFloatArray: function(l) {
      return Nr(o, c, l);
    } };
  }, e.ofColumn = n, e.ofUndefined = function(r, i) {
    return n(X.Undefined(r, i));
  };
}(Fe || (Fe = {})), function(e) {
  function t(n) {
    return n.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
  }
  e.canonical = t, e.equal = function(n, r) {
    return t(n) === t(r);
  }, e.create = function(n, r, i) {
    i === void 0 && (i = !1);
    var a = "".concat(n).concat(r ? ".".concat(r) : "");
    return i ? t(a) : a;
  };
}(xl || (xl = {}));
var xn, J7 = function(e, t, n) {
  this._isDefined = n;
  var r = Object.keys(t);
  this._rowCount = e.rowCount, this._columns = r, this._schema = t;
  for (var i = /* @__PURE__ */ Object.create(null), a = function(c) {
    Object.defineProperty(o, c, { get: function() {
      if (i[c]) return i[c];
      var l = t[c];
      if (l.valueType === "list") i[c] = function(p, v, f) {
        var y = p.separator, h = p.itemParse, g = v.getField(f), x = g ? function(C) {
          return g.str(C).split(y).map(function(b) {
            return h(b.trim());
          }).filter(function(b) {
            return !!b;
          });
        } : function(C) {
          return [];
        };
        return { schema: p, __array: void 0, isDefined: !!g, rowCount: v.rowCount, value: x, valueKind: g ? g.valueKind : function() {
          return 1;
        }, areValuesEqual: function(C, b) {
          return Si(x(C), x(b));
        }, toArray: function(C) {
          return Nr(v.rowCount, x, C);
        } };
      }(l, e, c);
      else if (l.valueType === "tensor") i[c] = dT(l, e, c);
      else {
        var d = function(p) {
          switch (p.valueType) {
            case "str":
              return function(v, f, y) {
                return mp(p, v, v.str, v.toStringArray);
              };
            case "int":
              return function(v, f, y) {
                return mp(p, v, v.int, v.toIntArray);
              };
            case "float":
              return function(v, f, y) {
                return mp(p, v, v.float, v.toFloatArray);
              };
            case "list":
              throw new Error("Use createListColumn instead.");
            case "tensor":
              throw new Error("Use createTensorColumn instead.");
          }
        }(l), m = e.getField(c);
        i[c] = m ? d(m, e, c) : X.Undefined(e.rowCount, l);
      }
      return i[c];
    }, enumerable: !0, configurable: !1 });
  }, o = this, s = 0, u = r; s < u.length; s++) a(u[s]);
};
function fT(e, t, n, r) {
  var i = xl.create(t, e), a = xl.canonical(i);
  if (a in n) return n[a];
  if (r && i in r) for (var o = 0, s = r[i]; o < s.length; o++) {
    var u = s[o], c = xl.canonical(u);
    if (c in n) return n[c];
  }
}
function mT(e, t, n, r) {
  var i = n.categories[e];
  if (r) {
    for (var a = function(p) {
      for (var v = /* @__PURE__ */ Object.create(null), f = 0, y = Object.keys(p.categories); f < y.length; f++) for (var h = y[f], g = 0, x = p.categories[h].fieldNames; g < x.length; g++) {
        var C = x[g];
        v[xl.create(h, C, !0)] = p.categories[h].getField(C);
      }
      return v;
    }(n), o = /* @__PURE__ */ Object.create(null), s = [], u = 0, c = 0, l = Object.keys(t); c < l.length; c++) {
      var d = l[c], m = fT(d, e, a, r);
      m && (o[d] = m, s.push(d), u = m.rowCount);
    }
    i = { rowCount: u, name: e, fieldNames: Pe([], s, !0), getField: function(p) {
      return o[p];
    } };
  }
  return new J7(i || Wr.empty(e), t, !!i);
}
function pp(e, t, n) {
  for (var r = new Float32Array(e), i = 0; i < r.length; i++) r[i] = t + n * i;
  return r;
}
function pT(e) {
  return 0;
}
function hp(e) {
  return function(t) {
    return e[t];
  };
}
function A0(e) {
  return e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
}
function hT(e, t) {
  var n = e.matrix, r = t.x, i = t.y, a = t.z, o = n[0], s = n[4], u = n[8], c = n[12];
  return A0(n) ? function(l) {
    return o * r[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = r[l], m = i[l], p = a[l], v = n[3] * d + n[7] * m + n[11] * p + n[15] || 1;
    return (o * d + s * m + u * p + c) / v;
  };
}
function vT(e, t) {
  var n = e.matrix, r = t.x, i = t.y, a = t.z, o = n[1], s = n[5], u = n[9], c = n[13];
  return A0(n) ? function(l) {
    return o * r[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = r[l], m = i[l], p = a[l], v = n[3] * d + n[7] * m + n[11] * p + n[15] || 1;
    return (o * d + s * m + u * p + c) / v;
  };
}
function gT(e, t) {
  var n = e.matrix, r = t.x, i = t.y, a = t.z, o = n[2], s = n[6], u = n[10], c = n[14];
  return A0(n) ? function(l) {
    return o * r[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = r[l], m = i[l], p = a[l], v = n[3] * d + n[7] * m + n[11] * p + n[15] || 1;
    return (o * d + s * m + u * p + c) / v;
  };
}
(function(e) {
  function t(o, s, u) {
    var c = u || {}, l = c.assembly, d = c.ncsId, m = c.hkl, p = c.spgrOp, v = m ? S.clone(m) : S();
    p = mr(p, -1), d = d || -1;
    var f = J.isIdentity(s), y = function(h, g) {
      if (!h) return "";
      if (h.assembly) return function(A) {
        return !!A && !!A.matrix && !!A.inverse && typeof A.name == "string";
      }(h) ? h.suffix : g ? "" : "_".concat(h.assembly.operId);
      if (h.spgrOp !== void 0 && h.hkl !== void 0 && h.spgrOp !== -1) {
        var x = h.hkl, C = x[0], b = x[1], _ = x[2];
        return "-".concat(h.spgrOp + 1, "_").concat(5 + C).concat(5 + b).concat(5 + _);
      }
      return h.ncsId !== -1 ? "_".concat(h.ncsId) : "";
    }(u, f);
    return f ? { name: o, assembly: l, matrix: s, inverse: J.identity(), isIdentity: !0, hkl: v, spgrOp: p, ncsId: d, suffix: y } : (J.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: J.invert(J(), s), isIdentity: !1, hkl: v, spgrOp: p, ncsId: d, suffix: y });
  }
  e.DefaultName = "1_555", e.Default = t(e.DefaultName, J.identity()), e.RotationTranslationEpsilon = 5e-3, e.create = t, e.checkIfRotationAndTranslation = function(o, s) {
    for (var u = J.identity(), c = 0; c < 3; c++) for (var l = 0; l < 3; l++) J.setValue(u, c, l, br.getValue(o, c, l));
    return J.setTranslation(u, s), J.isRotationAndTranslation(u, e.RotationTranslationEpsilon);
  }, e.ofRotationAndOffset = function(o, s, u, c) {
    for (var l = J.identity(), d = 0; d < 3; d++) for (var m = 0; m < 3; m++) J.setValue(l, d, m, br.getValue(s, d, m));
    return J.setTranslation(l, u), t(o, l, { ncsId: c });
  };
  var n = Mn.identity(), r = Mn(), i = Mn(), a = S();
  e.lerpFromIdentity = function(o, s, u) {
    var c = s.inverse;
    if (s.isIdentity) return J.copy(o, c);
    var l = 1 - u;
    J.getRotation(r, c), Mn.slerp(r, n, r, l);
    var d = Mn.getAxisAngle(a, r);
    return J.fromRotation(o, d, a), J.setValue(o, 0, 3, l * J.getValue(c, 0, 3)), J.setValue(o, 1, 3, l * J.getValue(c, 1, 3)), J.setValue(o, 2, 3, l * J.getValue(c, 2, 3)), o;
  }, e.slerp = function(o, s, u, c) {
    if (Math.abs(c) <= 1e-5) return J.copy(o, s);
    if (Math.abs(c - 1) <= 1e-5) return J.copy(o, u);
    J.getRotation(r, s), J.getRotation(i, u), Mn.slerp(i, r, i, c);
    var l = Mn.getAxisAngle(a, i);
    return J.fromRotation(o, l, a), J.setValue(o, 0, 3, fr(J.getValue(s, 0, 3), J.getValue(u, 0, 3), c)), J.setValue(o, 1, 3, fr(J.getValue(s, 1, 3), J.getValue(u, 1, 3), c)), J.setValue(o, 2, 3, fr(J.getValue(s, 2, 3), J.getValue(u, 2, 3), c)), o;
  }, e.compose = function(o, s) {
    var u = J.mul(J(), 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(m, p) {
      return m.isIdentity ? { x: hp(p.x), y: hp(p.y), z: hp(p.z) } : { x: hT(m, p), y: vT(m, p), z: gT(m, p) };
    }(o, s);
    return { operator: o, coordinates: s, invariantPosition: c, position: l, x: d.x, y: d.y, z: d.z, r: u || pT };
  }, e.createCoordinateMapper = function(o, s) {
    return o.isIdentity ? function(u) {
      var c = u.x, l = u.y, d = u.z;
      return function(m, p) {
        return p[0] = c[m], p[1] = l[m], p[2] = d[m], p;
      };
    }(s) : function(u, c) {
      var l = u.matrix, d = c.x, m = c.y, p = c.z;
      return A0(l) ? function(v, f) {
        var y = d[v], h = m[v], g = p[v];
        return f[0] = l[0] * y + l[4] * h + l[8] * g + l[12], f[1] = l[1] * y + l[5] * h + l[9] * g + l[13], f[2] = l[2] * y + l[6] * h + l[10] * g + l[14], f;
      } : function(v, f) {
        return f[0] = d[v], f[1] = m[v], f[2] = p[v], S.transformMat4(f, f, l), f;
      };
    }(o, s);
  };
})(xn || (xn = {}));
var vp = [[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]], yT = [[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]], bT = [[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]], pf = { "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 _T(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 Ma, ki, wu, or, $7 = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, n = Object.keys(pf); t < n.length; t++) {
    var r = n[t];
    e[pf[r]] = r;
  }
  return e;
}(), xT = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, n = Object.keys(pf); t < n.length; t++) {
    var r = n[t], i = pf[r];
    e[i] = _T(i);
  }
  return e;
}();
function g4(e) {
  var t = typeof e == "number" ? function(n) {
    switch (n) {
      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 r = 0;
    return n > 146 && ++r, n > 148 && ++r, n > 155 && ++r, n > 160 && ++r, n > 161 && ++r, n > 166 && ++r, n > 167 && ++r, n - 1 + r;
  }(e) : pf[e];
  return t === void 0 || $7[t] === void 0 ? -1 : t;
}
function ss() {
  return ss.empty();
}
function gp(e, t, n, r) {
  r = e[t], e[t] = e[n], e[n] = r;
}
function ST(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(n, r, i) {
    var a = g4(n);
    if (a < 0) return console.warn("Unknown spacegroup '".concat(n, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero;
    var o = r[0] * r[1] * r[2], s = i[0], u = i[1], c = i[2], l = r[0], d = r[1], m = r[2], p = Math.cos(u), v = (Math.cos(s) - Math.cos(u) * Math.cos(c)) / Math.sin(c), f = Math.sqrt(1 - p * p - v * v), y = [l, 0, 0], h = [Math.cos(c) * d, Math.sin(c) * d, 0], g = [p * m, v * m, f * m], x = J.ofRows([[y[0], h[0], g[0], 0], [0, h[1], g[1], 0], [0, 0, g[2], 0], [0, 0, 0, 1]]);
    return { index: a, size: r, volume: o, anglesInRadians: i, toFractional: J.invert(J.zero(), x), fromFractional: x };
  }
  e.Zero = t("P 1", S.create(1, 1, 1), S.create(Math.PI / 2, Math.PI / 2, Math.PI / 2)), e.isZero = function(n) {
    return !n || n.index === 0 && n.size[0] === 1 && n.size[1] === 1 && n.size[1] === 1;
  }, e.create = t, e.createMaterial = function(n, r, i, a, o, s) {
    var u = g4(n);
    return u < 0 ? (console.warn("Unknown spacegroup '".concat(n, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero) : { index: u, size: r, volume: a, anglesInRadians: i, toFractional: o, fromFractional: s };
  };
})(Ma || (Ma = {})), function(e) {
  function t(m) {
    var p = bT[m.index].map(function(v) {
      return y = vp[(f = yT[v])[0]], h = vp[f[1]], g = vp[f[2]], J.ofRows([y, h, g, [0, 0, 0, 1]]);
      var f, y, h, g;
    });
    return { name: $7[m.index], num: xT[m.index], cell: m, operators: p };
  }
  e.ZeroP1 = t(Ma.Zero), e.create = t;
  var n = S(), r = J();
  function i(m, p, v, f, y, h) {
    return S.set(n, v, f, y), J.fromTranslation(r, n), J.mul(h, J.mul(h, J.mul(h, m.cell.fromFractional, r), m.operators[p]), m.cell.toFractional);
  }
  e.setOperatorMatrix = i, e.getSymmetryOperator = function(m, p, v, f, y) {
    var h = i(m, p, v, f, y, J.zero());
    return xn.create("".concat(p + 1, "_").concat(5 + v).concat(5 + f).concat(5 + y), h, { hkl: S.create(v, f, y), spgrOp: p });
  };
  var a = S(), o = S(), s = S(), u = S();
  function c(m, p, v) {
    var f = [];
    if (m > 0 ? f.push("+X") : m < 0 && f.push("-X"), p > 0 ? f.push("+Y") : p < 0 && f.push("-Y"), v > 0 ? f.push("+Z") : v < 0 && f.push("-Z"), f.length === 1) return f[0].charAt(0) === "+" ? f[0].substr(1) : f[0];
    if (f.length === 2) {
      var y = f[0].charAt(0), h = f[1].charAt(0);
      if (y === "+") return "".concat(f[0].substr(1)).concat(f[1]);
      if (h === "+") return "".concat(f[1].substr(1)).concat(f[0]);
    }
    throw new Error("unknown rotation '".concat(f, "', ").concat(m, " ").concat(p, " ").concat(v));
  }
  function l(m) {
    switch (m) {
      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(m, p) {
    return p === "" ? m : m.length > 2 ? "".concat(m, "+").concat(p) : m.charAt(0) === "-" ? "".concat(p).concat(m) : "".concat(p, "+").concat(m);
  }
  e.getSymmetryOperatorRef = function(m, p, v, f, y, h) {
    var g = J.zero();
    S.set(n, v, f, y), S.floor(a, h), J.copy(g, m.operators[p]), S.floor(o, S.transformMat4(o, h, g)), J.getTranslation(u, g), S.sub(u, u, o), S.add(u, u, a), S.add(u, u, n), J.setTranslation(g, u), J.mul(g, m.cell.fromFractional, g), J.mul(g, g, m.cell.toFractional), S.sub(s, o, a);
    var x = v - s[0], C = f - s[1], b = y - s[2];
    return xn.create("".concat(p + 1, "_").concat(5 + x).concat(5 + C).concat(5 + b), g, { hkl: S.create(x, C, b), spgrOp: p });
  }, e.getOperatorXyz = function(m) {
    return [d(c(m[0], m[4], m[8]), l(m[12])), d(c(m[1], m[5], m[9]), l(m[13])), d(c(m[2], m[6], m[10]), l(m[14]))].join(",");
  };
}(ki || (ki = {})), function(e) {
  e.add = function(t, n, r) {
    t.squaredDistances[t.count] = r, t.indices[t.count++] = n;
  }, e.reset = function(t) {
    t.count = 0;
  }, e.create = function() {
    return { count: 0, indices: [], squaredDistances: [] };
  }, e.copy = function(t, n) {
    for (var r = 0; r < n.count; ++r) t.indices[r] = n.indices[r], t.squaredDistances[r] = n.squaredDistances[r];
    return t.count = n.count, t;
  };
}(wu || (wu = {})), function(e) {
  function t() {
    return { origin: S(), dirA: S(), dirB: S(), dirC: S() };
  }
  function n(o, s) {
    return S.copy(o.origin, s.origin), S.copy(o.dirA, s.dirA), S.copy(o.dirB, s.dirB), S.copy(o.dirC, s.dirC), o;
  }
  function r(o, s) {
    return S.set(o, 2 * S.magnitude(s.dirA), 2 * S.magnitude(s.dirB), 2 * S.magnitude(s.dirC));
  }
  e.create = function(o, s, u, c) {
    return { origin: o, dirA: s, dirB: u, dirC: c };
  }, e.empty = t, e.copy = n, e.clone = function(o) {
    return n(t(), o);
  }, e.size = r;
  var i = S();
  e.volume = function(o) {
    return r(i, o), i[0] * i[1] * i[2];
  }, e.normalize = function(o, s) {
    return S.copy(o.origin, s.origin), S.normalize(o.dirA, s.dirA), S.normalize(o.dirB, s.dirB), S.normalize(o.dirC, s.dirC), o;
  };
  var a = br();
  e.transform = function(o, s, u) {
    S.transformMat4(o.origin, s.origin, u);
    var c = br.directionTransform(a, u);
    return S.transformMat3(o.dirA, s.dirA, c), S.transformMat3(o.dirB, s.dirB, c), S.transformMat3(o.dirC, s.dirC, c), o;
  }, e.scale = function(o, s, u) {
    return S.scale(o.dirA, s.dirA, u), S.scale(o.dirB, s.dirB, u), S.scale(o.dirC, s.dirC, u), o;
  };
}(ss || (ss = {})), function(e) {
  e.create = function(t, n, r) {
    r === void 0 && (r = Float32Array);
    var i = t * n;
    return { data: new r(i), size: i, cols: t, rows: n };
  }, e.get = function(t, n, r) {
    return t.data[t.rows * r + n];
  }, e.set = function(t, n, r, i) {
    return t.data[t.rows * r + n] = i, t;
  }, e.add = function(t, n, r, i) {
    return t.data[t.rows * r + n] += i, 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, n, r) {
    return { data: t, size: n * r, cols: n, rows: r };
  }, e.transpose = function(t, n) {
    if (t.cols !== n.rows || t.rows !== n.cols) throw new Error("transpose: matrix dimensions incompatible");
    if (t.data === n.data) throw new Error("transpose: matrices share memory");
    for (var r = n.rows, i = n.cols, a = n.data, o = t.data, s = 0, u = 0, c = 0; s < r; c += 1, u += i, ++s) for (var l = c, d = 0; d < i; l += r, d++) o[l] = a[u + d];
    return t;
  }, e.multiplyABt = function(t, n, r) {
    for (var i = n.cols, a = n.rows, o = r.rows, s = n.data, u = r.data, c = t.data, l = 0, d = 0, m = 0; l < a; d += i, l++) for (var p = 0, v = 0; v < o; m++, v++) {
      for (var f = 0, y = d, h = 0; h < i; y++, p++, h++) f += s[y] * u[p];
      c[m] = f;
    }
    return t;
  }, e.meanRows = function(t) {
    for (var n = t.rows, r = t.cols, i = t.data, a = new Array(r), o = 0; o < r; ++o) a[o] = 0;
    for (var s = 0, u = 0; s < n; ++s) for (o = 0; o < r; ++o, ++u) a[o] += i[u];
    for (o = 0; o < r; ++o) a[o] /= n;
    return a;
  }, e.subRows = function(t, n) {
    for (var r = t.rows, i = t.cols, a = t.data, o = 0, s = 0; o < r; ++o) for (var u = 0; u < i; ++u, ++s) a[s] -= n[u];
    return t;
  };
}(or || (or = {}));
var _u, CT = 1192092896e-16, AT = 1e-37;
function IT(e, t, n, r) {
  var i = 0, a = 0, o = e.rows, s = e.cols, u = o, c = s;
  u < c && (i = 1, a = u, u = c, c = a);
  var l = or.create(u, u), d = or.create(1, c), m = or.create(c, c);
  if (i === 0) or.transpose(l, e);
  else {
    for (a = 0; a < s * o; a++) l.data[a] = e.data[a];
    for (; a < c * u; a++) l.data[a] = 0;
  }
  if (function(p, v, f, y, h, g, x, C) {
    for (var b = 2 * CT, _ = AT, A = 0, I = 0, w = 0, E = 0, D = Math.max(g, 30), T = 0, P = 0, M = 0, R = 0, O = 0, L = 0, F = 0, G = 0, V = 0, U = 0, q = 0, H = 0, K = 0, j = 0, W = 0, Z = 0, Y = 0, te = 4660, ee = 0, $ = 0, ue = 0, se = new Float64Array(x << 3); A < x; A++) {
      for (w = 0, q = 0; w < g; w++) q += (G = p[A * v + w]) * G;
      if (se[A] = q, y) {
        for (w = 0; w < x; w++) y[A * h + w] = 0;
        y[A * h + A] = 1;
      }
    }
    for (; E < D; E++) {
      for (O = 0, A = 0; A < x - 1; A++) for (I = A + 1; I < x; I++) {
        for (T = A * v | 0, P = I * v | 0, W = se[A], Z = 0, Y = se[I], w = 2, Z += p[T] * p[P], Z += p[T + 1] * p[P + 1]; w < g; w++) Z += p[T + w] * p[P + w];
        if (!(Math.abs(Z) <= b * Math.sqrt(W * Y))) {
          for (K = ST(Z *= 2, H = W - Y), H < 0 ? (j = 0.5 * (K - H), L = Z / (K * (F = Math.sqrt(j / K)) * 2)) : F = Z / (K * (L = Math.sqrt((K + H) / (2 * K))) * 2), W = 0, Y = 0, w = 2, V = L * p[T] + F * p[P], U = -F * p[T] + L * p[P], p[T] = V, p[P] = U, W += V * V, Y += U * U, V = L * p[T + 1] + F * p[P + 1], U = -F * p[T + 1] + L * p[P + 1], p[T + 1] = V, p[P + 1] = U, W += V * V, Y += U * U; w < g; w++) V = L * p[T + w] + F * p[P + w], U = -F * p[T + w] + L * p[P + w], p[T + w] = V, p[P + w] = U, W += V * V, Y += U * U;
          if (se[A] = W, se[I] = Y, O = 1, y) for (R = I * h | 0, w = 2, V = L * y[M = A * h | 0] + F * y[R], U = -F * y[M] + L * y[R], y[M] = V, y[R] = U, V = L * y[M + 1] + F * y[R + 1], U = -F * y[M + 1] + L * y[R + 1], y[M + 1] = V, y[R + 1] = U; w < x; w++) V = L * y[M + w] + F * y[R + w], U = -F * y[M + w] + L * y[R + w], y[M + w] = V, y[R + w] = U;
        }
      }
      if (O === 0) break;
    }
    for (A = 0; A < x; A++) {
      for (w = 0, q = 0; w < g; w++) q += (G = p[A * v + w]) * G;
      se[A] = Math.sqrt(q);
    }
    for (A = 0; A < x - 1; A++) {
      for (I = A, w = A + 1; w < x; w++) se[I] < se[w] && (I = w);
      if (A !== I && (gp(se, A, I, q), y)) {
        for (w = 0; w < g; w++) gp(p, A * v + w, I * v + w, G);
        for (w = 0; w < x; w++) gp(y, A * h + w, I * h + w, G);
      }
    }
    for (A = 0; A < x; A++) f[A] = se[A];
    if (y) for (A = 0; A < C; A++) {
      for (q = A < x ? se[A] : 0; q <= _; ) {
        for ($ = 1 / g, w = 0; w < g; w++) ee = 256 & (te = 214013 * te + 2531011) >> 16 ? $ : -$, p[A * v + w] = ee;
        for (E = 0; E < 2; E++) for (I = 0; I < A; I++) {
          for (q = 0, w = 0; w < g; w++) q += p[A * v + w] * p[I * v + w];
          for (ue = 0, w = 0; w < g; w++) G = p[A * v + w] - q * p[I * v + w], p[A * v + w] = G, ue += Math.abs(G);
          for (ue = ue ? 1 / ue : 0, w = 0; w < g; w++) p[A * v + w] *= ue;
        }
        for (q = 0, w = 0; w < g; w++) q += (G = p[A * v + w]) * G;
        q = Math.sqrt(q);
      }
      for (F = 1 / q, w = 0; w < g; w++) p[A * v + w] *= F;
    }
  }(l.data, u, d.data, m.data, c, u, c, u), t) {
    for (a = 0; a < c; a++) t.data[a] = d.data[a];
    for (; a < s; a++) t.data[a] = 0;
  }
  i === 0 ? (n && or.transpose(n, l), r && or.transpose(r, m)) : (n && or.transpose(n, m), r && or.transpose(r, l));
}
function de() {
  return de.zero();
}
function sn() {
  return sn.zero();
}
function xc(e, t, n) {
  return new wT(e, t, n);
}
(function(e) {
  function t(s) {
    if (s.length === 3) return ss.create(S.fromArray(S(), s, 0), S.create(1, 0, 0), S.create(0, 1, 0), S.create(0, 1, 0));
    var u = or.fromArray(s, 3, s.length / 3), c = u.rows, l = c / 3, d = or.create(3, 3), m = or.create(1, 3), p = or.create(3, 3), v = or.create(3, 3), f = or.meanRows(u), y = or.subRows(or.clone(u), f), h = or.transpose(or.create(c, 3), y);
    or.multiplyABt(d, h, h), IT(d, m, p, v);
    var g = S.create(f[0], f[1], f[2]), x = S.create(p.data[0], p.data[3], p.data[6]), C = S.create(p.data[1], p.data[4], p.data[7]), b = S.create(p.data[2], p.data[5], p.data[8]);
    return S.scale(x, x, Math.sqrt(m.data[0] / l)), S.scale(C, C, Math.sqrt(m.data[1] / l)), S.scale(b, b, Math.sqrt(m.data[2] / l)), ss.create(g, x, C, b);
  }
  e.ofPositions = function(s) {
    var u = t(s);
    return { momentsAxes: u, boxAxes: o(s, u) };
  }, e.calculateMomentsAxes = t;
  var n = S(), r = S(), i = S(), a = S();
  function o(s, u) {
    if (s.length === 3) return ss.clone(u);
    for (var c = -1 / 0, l = -1 / 0, d = -1 / 0, m = -1 / 0, p = -1 / 0, v = -1 / 0, f = S(), y = S(), h = u.origin, g = S.normalize(r, u.dirA), x = S.normalize(i, u.dirB), C = S.normalize(a, u.dirC), b = 0, _ = s.length; b < _; b += 3) {
      S.projectPointOnVector(f, S.fromArray(f, s, b), g, h);
      var A = S.dot(g, S.normalize(y, S.sub(y, f, h))), I = S.distance(f, h);
      A > 0 ? I > c && (c = I) : I > l && (l = I), S.projectPointOnVector(f, S.fromArray(f, s, b), x, h);
      var w = S.dot(x, S.normalize(y, S.sub(y, f, h))), E = S.distance(f, h);
      w > 0 ? E > d && (d = E) : E > m && (m = E), S.projectPointOnVector(f, S.fromArray(f, s, b), C, h);
      var D = S.dot(C, S.normalize(y, S.sub(y, f, h))), T = S.distance(f, h);
      D > 0 ? T > p && (p = T) : T > v && (v = T);
    }
    var P = S.setMagnitude(S(), g, (c + l) / 2), M = S.setMagnitude(S(), x, (d + m) / 2), R = S.setMagnitude(S(), C, (p + v) / 2), O = S(), L = function(F, G, V) {
      S.copy(n, h), S.scaleAndAdd(n, n, g, F), S.scaleAndAdd(n, n, x, G), S.scaleAndAdd(n, n, C, V), S.add(O, O, n);
    };
    return L(c, d, p), L(c, d, -v), L(c, -m, -v), L(c, -m, p), L(-l, -m, -v), L(-l, -m, p), L(-l, d, p), L(-l, d, -v), S.scale(O, O, 1 / 8), ss.create(O, P, M, R);
  }
  e.calculateBoxAxes = o;
})(_u || (_u = {})), function(e) {
  function t(s) {
    return s.extrema !== void 0;
  }
  function n(s, u) {
    return { center: s, radius: u };
  }
  function r(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 = n, e.zero = function() {
    return { center: S(), radius: 0 };
  }, e.clone = function(s) {
    var u = n(S.clone(s.center), s.radius);
    return t(s) && (u.extrema = s.extrema.map(function(c) {
      return S.clone(c);
    })), u;
  }, e.set = function(s, u, c) {
    return S.copy(s.center, u), s.radius = c, s;
  }, e.copy = function(s, u) {
    return S.copy(s.center, u.center), s.radius = u.radius, t(u) && r(s, u.extrema.map(function(c) {
      return S.clone(c);
    })), s;
  }, e.setExtrema = r, e.computeBounding = function(s) {
    for (var u = s.x, c = s.y, l = s.z, d = s.indices, m = 0, p = 0, v = 0, f = 0, y = ve.size(d), h = 0; h < y; h++)
      m += u[g = ve.getAt(d, h)], p += c[g], v += l[g];
    for (y > 0 && (m /= y, p /= y, v /= y), h = 0; h < y; h++) {
      var g, x = u[g = ve.getAt(d, h)] - m, C = c[g] - p, b = l[g] - v, _ = x * x + C * C + b * b;
      _ > f && (f = _);
    }
    return { center: S.create(m, p, v), radius: Math.sqrt(f) };
  }, e.transform = function(s, u, c) {
    return S.transformMat4(s.center, u.center, c), s.radius = u.radius * J.getMaxScaleOnAxis(c), t(u) && r(s, u.extrema.map(function(l) {
      return S.transformMat4(S(), l, c);
    })), s;
  }, e.translate = function(s, u, c) {
    return S.add(s.center, u.center, c), t(u) && r(s, u.extrema.map(function(l) {
      return S.add(S(), l, c);
    })), s;
  }, e.toArray = function(s, u, c) {
    S.toArray(s.center, u, c), u[c + 3] = s.radius;
  }, e.fromArray = function(s, u, c) {
    return S.fromArray(s.center, u, c), s.radius = u[c + 3], s;
  }, e.fromBox3D = function(s, u) {
    return S.scale(s.center, S.add(s.center, u.max, u.min), 0.5), s.radius = S.distance(s.center, u.max), e.setExtrema(s, [S.create(u.min[0], u.min[1], u.min[2]), S.create(u.max[0], u.max[1], u.max[2]), S.create(u.max[0], u.min[1], u.min[2]), S.create(u.min[0], u.max[1], u.max[2]), S.create(u.min[0], u.min[1], u.max[2]), S.create(u.max[0], u.min[1], u.max[2]), S.create(u.max[0], u.max[1], u.min[2]), S.create(u.min[0], u.max[1], u.min[2])]), s;
  }, e.fromAxes3D = function(s, u) {
    return S.copy(s.center, u.origin), s.radius = Math.max(S.magnitude(u.dirA), S.magnitude(u.dirB), S.magnitude(u.dirC)), s;
  };
  var i = S();
  e.fromDimensionsAndTransform = function(s, u, c) {
    var l = u[0], d = u[1], m = u[2], p = S.create(0, 0, 0);
    S.transformMat4(p, p, c);
    var v = S.create(l, d, m);
    S.transformMat4(v, v, c);
    var f = S.create(l, 0, 0);
    S.transformMat4(f, f, c);
    var y = S.create(0, d, m);
    S.transformMat4(y, y, c);
    var h = S.create(0, 0, m);
    S.transformMat4(h, h, c);
    var g = S.create(l, 0, m);
    S.transformMat4(g, g, c);
    var x = S.create(l, d, 0);
    S.transformMat4(x, x, c);
    var C = S.create(0, d, 0);
    S.transformMat4(C, C, c), S.add(i, p, v), S.scale(i, i, 0.5);
    var b = Math.max(S.distance(p, v), S.distance(f, y));
    return e.set(s, i, b / 2), e.setExtrema(s, [p, v, f, y, h, g, x, C]), s;
  };
  var a = S();
  e.addVec3 = function(s, u, c) {
    return S.distance(u.center, c) < u.radius ? e.copy(s, u) : (S.sub(a, u.center, c), S.sub(a, u.center, a), S.setMagnitude(a, a, u.radius), S.scale(s.center, S.add(a, a, c), 0.5), s.radius = S.distance(s.center, c), s);
  }, e.expandBySphere = function(s, u, c) {
    return S.copy(s.center, u.center), s.radius = Math.max(u.radius, S.distance(u.center, c.center) + c.radius), t(u) && t(c) && r(s, Pe(Pe([], u.extrema.map(function(l) {
      return S.clone(l);
    }), !0), c.extrema.map(function(l) {
      return S.clone(l);
    }), !0)), s;
  };
  var o = S();
  e.expand = function(s, u, c) {
    var l, d;
    if (S.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 m = new Float32Array(3 * u.extrema.length), p = 0; p < u.extrema.length; p++) S.toArray(u.extrema[p], m, 3 * p);
      var v = _u.calculateMomentsAxes(m);
      ss.scale(v, ss.normalize(v, v), c), r(s, u.extrema.map(function(f) {
        S.normalize(o, S.sub(o, f, u.center));
        var y = S.clone(f), h = S.dot(o, v.dirA) < 0 ? -1 : 1;
        S.scaleAndAdd(y, y, v.dirA, h);
        var g = S.dot(o, v.dirB) < 0 ? -1 : 1;
        S.scaleAndAdd(y, y, v.dirB, g);
        var x = S.dot(o, v.dirC) < 0 ? -1 : 1;
        return S.scaleAndAdd(y, y, v.dirC, x), S.distance(s.center, y) > s.radius && (u.extrema.length >= 14 && S.normalize(o, S.sub(o, y, u.center)), S.scaleAndAdd(y, s.center, o, s.radius)), y;
      }));
    }
    return s;
  }, e.exactEquals = function(s, u) {
    return s.radius === u.radius && S.exactEquals(s.center, u.center);
  }, e.equals = function(s, u) {
    var c = s.radius, l = u.radius;
    return Math.abs(c - l) <= bn * Math.max(1, Math.abs(c), Math.abs(l)) && S.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 (S.distance(s.center, d) > s.radius) return !1;
      }
      return !0;
    }
    return S.distance(s.center, u.center) + u.radius <= s.radius;
  }, e.overlaps = function(s, u) {
    return S.distance(s.center, u.center) <= s.radius + u.radius;
  }, e.distance = function(s, u) {
    return S.distance(s.center, u.center) - s.radius + u.radius;
  };
}(de || (de = {})), function(e) {
  function t() {
    return { min: S(), max: S() };
  }
  function n(c, l) {
    return S.copy(c.min, l.min), S.copy(c.max, l.max), c;
  }
  function r(c, l) {
    e.setEmpty(c);
    for (var d = 0, m = l.length; d < m; d++) e.add(c, l[d]);
    return c;
  }
  function i(c, l) {
    return S.sub(c, l.max, l.min);
  }
  e.create = function(c, l) {
    return { min: c, max: l };
  }, e.zero = t, e.copy = n, e.clone = function(c) {
    return n(t(), c);
  }, e.fromSphere3D = function(c, l) {
    if (de.hasExtrema(l) && l.extrema.length >= 14) return r(c, l.extrema);
    var d = S.create(l.radius, l.radius, l.radius);
    return S.sub(c.min, l.center, d), S.add(c.max, l.center, d), c;
  }, e.fromVec3Array = r, e.computeBounding = function(c) {
    for (var l = S.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), d = S.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), m = c.x, p = c.y, v = c.z, f = c.indices, y = 0, h = ve.size(f); y < h; y++) {
      var g = ve.getAt(f, y);
      l[0] = Math.min(m[g], l[0]), l[1] = Math.min(p[g], l[1]), l[2] = Math.min(v[g], l[2]), d[0] = Math.max(m[g], d[0]), d[1] = Math.max(p[g], d[1]), d[2] = Math.max(v[g], d[2]);
    }
    return { min: l, max: d };
  }, e.size = i;
  var a = S();
  function o(c) {
    return S.set(c.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), S.set(c.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), c;
  }
  function s(c, l) {
    return S.min(c.min, c.min, l), S.max(c.max, c.max, l), c;
  }
  e.volume = function(c) {
    return i(a, c), a[0] * a[1] * a[2];
  }, e.setEmpty = o, e.add = s, e.expand = function(c, l, d) {
    return S.sub(c.min, l.min, d), S.add(c.max, l.max, d), c;
  }, e.scale = function(c, l, d) {
    return S.scale(c.min, l.min, d), S.scale(c.max, l.max, d), c;
  };
  var u = S();
  e.transform = function(c, l, d) {
    var m = l.min, p = m[0], v = m[1], f = m[2], y = l.max, h = y[0], g = y[1], x = y[2];
    return o(c), s(c, S.transformMat4(u, S.set(u, p, v, f), d)), s(c, S.transformMat4(u, S.set(u, p, v, x), d)), s(c, S.transformMat4(u, S.set(u, p, g, f), d)), s(c, S.transformMat4(u, S.set(u, p, g, x), d)), s(c, S.transformMat4(u, S.set(u, h, v, f), d)), s(c, S.transformMat4(u, S.set(u, h, v, x), d)), s(c, S.transformMat4(u, S.set(u, h, g, f), d)), s(c, S.transformMat4(u, S.set(u, h, g, x), 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]);
  };
}(sn || (sn = {}));
var Ne, wT = function() {
  function e(t, n, r) {
    var i = function(a, o, s) {
      var u, c, l = sn.expand(sn(), o.box, S.create(0.5, 0.5, 0.5)), d = a.indices, m = sn.size(S.zero(), l), p = ve.size(d), v = typeof s == "number" ? s : 32, f = Array.isArray(s) && s;
      if (f) c = [Math.ceil(m[0] / f[0]), Math.ceil(m[1] / f[1]), Math.ceil(m[2] / f[2])], u = f;
      else if (p > 0) {
        var y = Math.ceil(p / v), h = Math.pow(y / (m[0] * m[1] * m[2]), 1 / 3);
        c = [Math.ceil(m[0] * h), Math.ceil(m[1] * h), Math.ceil(m[2] * h)], u = [m[0] / c[0], m[1] / c[1], m[2] / c[2]];
      } else u = m, c = [1, 1, 1];
      var g = { x: a.x, y: a.y, z: a.z, indices: d, radius: a.radius }, x = { size: c, data: g, expandedBox: l, boundingBox: o.box, boundingSphere: o.sphere, elementCount: p, delta: u };
      return function(C) {
        for (var b = C.expandedBox, _ = C.size, A = _[0], I = _[1], w = _[2], E = C.data, D = E.x, T = E.y, P = E.z, M = E.radius, R = E.indices, O = C.elementCount, L = C.delta, F = A * I * w, G = b.min, V = G[0], U = G[1], q = G[2], H = 0, K = 0, j = new Uint32Array(F), W = new Int32Array(O), Z = 0; Z < O; Z++) {
          var Y = ve.getAt(R, Z), te = (Math.floor((D[Y] - V) / L[0]) * I + Math.floor((T[Y] - U) / L[1])) * w + Math.floor((P[Y] - q) / L[2]);
          (j[te] += 1) === 1 && (K += 1), W[Z] = te;
        }
        if (M) for (Z = 0; Z < O; Z++)
          M[Y = ve.getAt(R, Z)] > H && (H = M[Y]);
        for (var ee = new Int32Array(K), $ = (Y = 0, 0); Y < F; Y++) {
          var ue = j[Y];
          ue > 0 && (j[Y] = $ + 1, ee[$] = ue, $ += 1);
        }
        var se = new Uint32Array(K);
        for (Y = 1; Y < K; ++Y) se[Y] += se[Y - 1] + ee[Y - 1];
        var be = new Int32Array(K), ke = new Int32Array(O);
        for (Y = 0; Y < O; Y++) {
          var Oe = j[W[Y]];
          if (Oe > 0) {
            var ze = Oe - 1;
            ke[se[ze] + be[ze]] = Y, be[ze] += 1;
          }
        }
        return { size: C.size, bucketArray: ke, bucketCounts: ee, bucketOffset: se, grid: j, delta: L, min: C.expandedBox.min, data: C.data, maxRadius: H, expandedBox: C.expandedBox, boundingBox: C.boundingBox, boundingSphere: C.boundingSphere };
      }(x);
    }(t, n, r);
    this.ctx = { grid: i, x: 0.1, y: 0.1, z: 0.1, radius: 0.1, isCheck: !1 }, this.boundary = { box: i.boundingBox, sphere: i.boundingSphere }, this.buckets = { offset: i.bucketOffset, count: i.bucketCounts, array: i.bucketArray }, this.result = wu.create();
  }
  return e.prototype.find = function(t, n, r, i, a) {
    this.ctx.x = t, this.ctx.y = n, this.ctx.z = r, this.ctx.radius = i, this.ctx.isCheck = !1;
    var o = a ?? this.result;
    return y4(this.ctx, o), o;
  }, e.prototype.check = function(t, n, r, i) {
    return this.ctx.x = t, this.ctx.y = n, this.ctx.z = r, this.ctx.radius = i, this.ctx.isCheck = !0, y4(this.ctx, this.result);
  }, e;
}();
function y4(e, t) {
  var n = e.grid, r = n.min, i = n.size, a = i[0], o = i[1], s = i[2], u = n.bucketOffset, c = n.bucketCounts, l = n.bucketArray, d = n.grid, m = n.data, p = m.x, v = m.y, f = m.z, y = m.indices, h = m.radius, g = n.delta, x = n.maxRadius, C = e.radius, b = e.isCheck, _ = e.x, A = e.y, I = e.z, w = C + x, E = w * w;
  wu.reset(t);
  var D = Math.max(0, Math.floor((_ - w - r[0]) / g[0])), T = Math.max(0, Math.floor((A - w - r[1]) / g[1])), P = Math.max(0, Math.floor((I - w - r[2]) / g[2])), M = Math.min(a - 1, Math.floor((_ + w - r[0]) / g[0])), R = Math.min(o - 1, Math.floor((A + w - r[1]) / g[1])), O = Math.min(s - 1, Math.floor((I + w - r[2]) / g[2]));
  if (D > M || T > R || P > O) return !1;
  for (var L = D; L <= M; L++) for (var F = T; F <= R; F++) for (var G = P; G <= O; G++) {
    var V = d[(L * o + F) * s + G];
    if (V !== 0) for (var U = V - 1, q = u[U], H = q + c[U], K = q; K < H; K++) {
      var j = ve.getAt(y, l[K]), W = p[j] - _, Z = v[j] - A, Y = f[j] - I, te = W * W + Z * Z + Y * Y;
      if (te <= E) {
        if (x > 0 && Math.sqrt(te) - h[j] > C) continue;
        if (b) return !0;
        wu.add(t, l[K], te);
      }
    }
  }
  return t.count > 0;
}
(function(e) {
  function t(i, a, o) {
    return { kind: "element-location", structure: i, unit: a, element: o || 0 };
  }
  e.create = t, e.clone = function(i) {
    return t(i.structure, i.unit, i.element);
  }, e.set = function(i, a, o, s) {
    return a && (i.structure = a), o && (i.unit = o), s !== void 0 && (i.element = s), i;
  }, e.copy = function(i, a) {
    return i.unit = a.unit, i.element = a.element, i;
  }, e.is = function(i) {
    return !!i && i.kind === "element-location";
  }, e.areEqual = function(i, a) {
    return i.unit === a.unit && i.element === a.element;
  };
  var n = S.zero(), r = S.zero();
  e.distance = function(i, a) {
    return i.unit.conformation.position(i.element, n), a.unit.conformation.position(a.element, r), S.distance(n, r);
  }, e.residueIndex = function(i) {
    return i.unit.model.atomicHierarchy.residueAtomSegments.index[i.element];
  }, e.chainIndex = function(i) {
    return i.unit.model.atomicHierarchy.chainAtomSegments.index[i.element];
  };
})(Ne || (Ne = {}));
var PT = function() {
  function e(t, n) {
    this.getHash = t, this.areEqual = n, this.size = 0, this.byHash = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t) {
    var n = this.getHash(t);
    if (this.byHash.has(n)) {
      for (var r = this.byHash.get(n), i = 0, a = r.length; i < a; i++) if (this.areEqual(t, r[i])) return !1;
      return r[r.length] = t, this.size++, !0;
    }
    return this.byHash.set(n, [t]), this.size++, !0;
  }, e.prototype.has = function(t) {
    var n = this.getHash(t);
    if (!this.byHash.has(n)) return !1;
    for (var r = this.byHash.get(n), i = 0, a = r.length; i < a; i++) if (this.areEqual(t, r[i])) return !0;
    return !1;
  }, e;
}();
function Lg(e, t) {
  return new PT(e, t);
}
function b4() {
  return new ET();
}
function _4(e) {
  return { previous: null, next: null, inList: !0, value: e };
}
var yn, ae, Gr, et, Ot, ET = function() {
  function e() {
    this.count = 0, this.first = null, this.last = null;
  }
  return e.prototype.addFirst = function(t) {
    var n = _4(t);
    return n.inList = !0, this.first && (this.first.previous = n), n.next = this.first, this.first = n, this.count++, this.last || (this.last = n), n;
  }, e.prototype.addLast = function(t) {
    var n = _4(t);
    return this.last !== null && (this.last.next = n), n.previous = this.last, this.last = n, this.first === null && (this.first = n), n.inList = !0, this.count++, n;
  }, 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 n = this.first; n !== null; ) {
      if (n.value === t) return n;
      n = n.next;
    }
  }, e;
}();
function De(e, t) {
  var n = t || {}, r = n.description, i = r === void 0 ? void 0 : r, a = n.isOptional, o = a !== void 0 && a, s = n.isRest, u = s !== void 0 && s, c = n.defaultValue;
  return { type: e, isOptional: o, isRest: u, defaultValue: c === void 0 ? void 0 : c, description: i };
}
function Nd(e, t, n, r) {
  var i = function(a) {
    return Gr.Apply(Gr.Symbol(i.id), a);
  };
  return i.info = { namespace: "", name: e, description: r }, i.id = "", i.args = t, i.type = n, i;
}
function Vm(e) {
  var t = e;
  return typeof t == "function" && !!t.info && !!t.args && typeof t.info.namespace == "string" && !!t.type;
}
function it(e, t, n) {
  return Nd("", e, t, n);
}
function e9(e) {
  n9("", "", e);
}
function t9(e) {
  var t = [];
  return r9(e, t), t;
}
function x4(e) {
  var t = /([a-z])([A-Z])([a-z]|$)/g;
  return e.replace(t, function(n, r, i, a) {
    return "".concat(r, "-").concat(i.toLocaleLowerCase()).concat(a);
  }).replace(t, function(n, r, i, a) {
    return "".concat(r, "-").concat(i.toLocaleLowerCase()).concat(a);
  });
}
function n9(e, t, n) {
  if (Vm(n)) return n.info.namespace = e, n.info.name = n.info.name || x4(t), void (n.id = "".concat(n.info.namespace, ".").concat(n.info.name));
  for (var r = "".concat(n["@namespace"] || x4(t)), i = e ? "".concat(e, ".").concat(r) : r, a = 0, o = Object.keys(n); a < o.length; a++) {
    var s = o[a];
    (typeof n[s] == "object" || Vm(n[s])) && n9(i, s, n[s]);
  }
}
function r9(e, t) {
  if (Vm(e)) t.push(e);
  else for (var n = 0, r = Object.keys(e); n < r.length; n++) {
    var i = r[n];
    (typeof e[i] == "object" || Vm(e[i])) && r9(e[i], t);
  }
}
function Cr(e, t) {
  return it(et.Dictionary({ 0: De(e) }), e, t);
}
function Os(e, t) {
  return it(et.List(e, { nonEmpty: !0 }), e, t);
}
function lo(e, t, n) {
  return it(et.Dictionary({ 0: De(e), 1: De(e) }), t, n);
}
(function(e) {
  e.create = function() {
    return { keys: /* @__PURE__ */ new Set(), array: [] };
  }, e.add = function(t, n, r) {
    var i = t.keys, a = t.array;
    return !i.has(n) && (i.add(n), a[a.length] = r, !0);
  }, e.has = function(t, n) {
    return t.keys.has(n);
  };
})(yn || (yn = {})), function(e) {
  function t(r, i, a) {
    return { kind: "value", namespace: r, name: i, parent: a };
  }
  function n(r, i, a, o) {
    for (var s = /* @__PURE__ */ Object.create(null), u = 0, c = o; u < c.length; u++)
      s[c[u]] = !0;
    return { kind: "oneof", namespace: r, name: i, type: a, values: s };
  }
  e.Variable = function(r, i, a) {
    return { kind: "variable", name: r, type: i, isConstraint: a };
  }, e.Value = t, e.Container = function(r, i, a, o) {
    return { kind: "container", namespace: r, name: i, child: a, alias: o };
  }, e.Union = function(r) {
    return { kind: "union", types: r };
  }, e.OneOf = n, e.Any = { kind: "any" }, e.AnyValue = { kind: "any-value" }, e.Num = t("", "Number"), e.Str = t("", "String"), e.Bool = n("", "Bool", e.Str, ["true", "false"]), e.oneOfValues = function(r) {
    var i = r.values;
    return Object.keys(i).sort();
  };
}(ae || (ae = {})), function(e) {
  function t(r) {
    return !!r && !!r.head && typeof r == "object";
  }
  function n(r) {
    return !!r && typeof r.name == "string";
  }
  e.Symbol = function(r) {
    return { name: r };
  }, e.Apply = function(r, i) {
    return i ? { head: r, args: i } : { head: r };
  }, e.isArgumentsArray = function(r) {
    return !!r && Array.isArray(r);
  }, e.isArgumentsMap = function(r) {
    return !!r && !Array.isArray(r);
  }, e.isLiteral = function(r) {
    return !t(r) && !n(r);
  }, e.isApply = t, e.isSymbol = n;
}(Gr || (Gr = {})), function(e) {
  function t(n) {
    return { kind: "dictionary", map: n, "@type": 0 };
  }
  e.None = t({}), e.Dictionary = t, e.List = function(n, r) {
    var i = (r || {}).nonEmpty;
    return { kind: "list", type: n, nonEmpty: i !== void 0 && i, "@type": 0 };
  };
}(et || (et = {})), function(e) {
  e.AnyVar = ae.Variable("a", ae.Any), e.AnyValueVar = ae.Variable("a", ae.Any), e.ConstrainedVar = ae.Variable("a", ae.Any, !0), e.Regex = ae.Value("Core", "Regex"), e.Set = function(t) {
    return ae.Container("Core", "Set", t || e.AnyValueVar);
  }, e.List = function(t) {
    return ae.Container("Core", "List", t || e.AnyVar);
  }, e.Fn = function(t, n) {
    return ae.Container("Core", "Fn", t || e.AnyVar, n);
  }, e.Flags = function(t, n) {
    return ae.Container("Core", "Flags", t, n);
  }, e.BitFlags = e.Flags(ae.Num, "BitFlags");
}(Ot || (Ot = {})), et.Dictionary({ 0: De(ae.Num), 1: De(ae.Num) }), De(ae.Str);
var Fg = { "@header": "Language Primitives", type: { "@header": "Types", bool: it(et.Dictionary({ 0: De(ae.AnyValue) }), ae.Bool, "Convert a value to boolean."), num: it(et.Dictionary({ 0: De(ae.AnyValue) }), ae.Num, "Convert a value to number."), str: it(et.Dictionary({ 0: De(ae.AnyValue) }), ae.Str, "Convert a value to string."), regex: it(et.Dictionary({ 0: De(ae.Str, { description: "Expression" }), 1: De(ae.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" }) }), Ot.Regex, "Creates a regular expression from a string using the ECMAscript syntax."), list: it(et.List(Ot.AnyVar), Ot.List()), set: it(et.List(Ot.AnyValueVar), Ot.Set()), bitflags: it(et.Dictionary({ 0: De(ae.Num) }), Ot.BitFlags, "Interpret a number as bitflags."), compositeKey: it(et.List(ae.AnyValue), ae.AnyValue) }, logic: { "@header": "Logic", not: Cr(ae.Bool), and: Os(ae.Bool), or: Os(ae.Bool) }, ctrl: { "@header": "Control", eval: it(et.Dictionary({ 0: De(Ot.Fn(Ot.AnyVar)) }), Ot.AnyVar, "Evaluate a function."), fn: it(et.Dictionary({ 0: De(Ot.AnyVar) }), Ot.Fn(Ot.AnyVar), 'Wrap an expression to a "lazy" function.'), if: it(et.Dictionary({ 0: De(ae.Bool, { description: "Condition" }), 1: De(ae.Variable("a", ae.Any), { description: "If true" }), 2: De(ae.Variable("b", ae.Any), { description: "If false" }) }), ae.Union([ae.Variable("a", ae.Any), ae.Variable("b", ae.Any)])), assoc: it(et.Dictionary({ 0: De(ae.Str, { description: "Name" }), 1: De(ae.Variable("a", ae.Any), { description: "Value to assign" }) }), ae.Variable("a", ae.Any)) }, rel: { "@header": "Relational", eq: lo(ae.Variable("a", ae.AnyValue, !0), ae.Bool), neq: lo(ae.Variable("a", ae.AnyValue, !0), ae.Bool), lt: lo(ae.Num, ae.Bool), lte: lo(ae.Num, ae.Bool), gr: lo(ae.Num, ae.Bool), gre: lo(ae.Num, ae.Bool), inRange: it(et.Dictionary({ 0: De(ae.Num, { description: "Value to test" }), 1: De(ae.Num, { description: "Minimum value" }), 2: De(ae.Num, { description: "Maximum value" }) }), ae.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.") }, math: { "@header": "Math", add: Os(ae.Num), sub: Os(ae.Num), mult: Os(ae.Num), div: lo(ae.Num, ae.Num), pow: lo(ae.Num, ae.Num), mod: lo(ae.Num, ae.Num), min: Os(ae.Num), max: Os(ae.Num), floor: Cr(ae.Num), ceil: Cr(ae.Num), roundInt: Cr(ae.Num), abs: Cr(ae.Num), sqrt: Cr(ae.Num), cbrt: Cr(ae.Num), sin: Cr(ae.Num), cos: Cr(ae.Num), tan: Cr(ae.Num), asin: Cr(ae.Num), acos: Cr(ae.Num), atan: Cr(ae.Num), sinh: Cr(ae.Num), cosh: Cr(ae.Num), tanh: Cr(ae.Num), exp: Cr(ae.Num), log: Cr(ae.Num), log10: Cr(ae.Num), atan2: lo(ae.Num, ae.Num) }, str: { "@header": "Strings", concat: Os(ae.Str), match: it(et.Dictionary({ 0: De(Ot.Regex), 1: De(ae.Str) }), ae.Bool) }, list: { "@header": "Lists", getAt: it(et.Dictionary({ 0: De(Ot.List()), 1: De(ae.Num) }), Ot.AnyVar), equal: it(et.Dictionary({ 0: De(Ot.List()), 1: De(Ot.List()) }), ae.Bool) }, set: { "@header": "Sets", has: it(et.Dictionary({ 0: De(Ot.Set(Ot.ConstrainedVar)), 1: De(Ot.ConstrainedVar) }), ae.Bool, "Check if the the 1st argument includes the value of the 2nd."), isSubset: it(et.Dictionary({ 0: De(Ot.Set(Ot.ConstrainedVar)), 1: De(Ot.Set(Ot.ConstrainedVar)) }), ae.Bool, "Check if the the 1st argument is a subset of the 2nd.") }, flags: { "@header": "Flags", hasAny: it(et.Dictionary({ 0: De(Ot.Flags(Ot.ConstrainedVar)), 1: De(Ot.Flags(Ot.ConstrainedVar)) }), ae.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."), hasAll: it(et.Dictionary({ 0: De(Ot.Flags(Ot.ConstrainedVar)), 1: De(Ot.Flags(Ot.ConstrainedVar)) }), ae.Bool, "Check if the the 1st argument has all 2nd one's flags.") } };
e9(Fg);
var Ue, TT = t9(Fg);
function kt(e, t) {
  return it(et.Dictionary({ 0: De(Ue.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), e, t);
}
function ud(e, t) {
  return it(et.None, e, t);
}
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, n = TT; t < n.length; t++) {
    var r = n[t];
    e[r.id] = r;
  }
})(), function(e) {
  e.ElementSymbol = ae.Value("Structure", "ElementSymbol"), e.AtomName = ae.Value("Structure", "AtomName"), e.BondFlag = ae.OneOf("Structure", "BondFlag", ae.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), e.BondFlags = Ot.Flags(e.BondFlag, "BondFlags"), e.SecondaryStructureFlag = ae.OneOf("Structure", "SecondaryStructureFlag", ae.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), e.SecondaryStructureFlags = Ot.Flags(e.SecondaryStructureFlag, "SecondaryStructureFlag"), e.RingFingerprint = ae.Value("Structure", "RingFingerprint"), e.EntityType = ae.OneOf("Structure", "EntityType", ae.Str, ["polymer", "non-polymer", "water", "branched"]), e.EntitySubtype = ae.OneOf("Structure", "EntitySubtype", ae.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), e.ObjectPrimitive = ae.OneOf("Structure", "ObjectPrimitive", ae.Str, ["atomistic", "sphere", "gaussian", "other"]), e.ResidueId = ae.Value("Structure", "ResidueId"), e.ElementSet = ae.Value("Structure", "ElementSet"), e.ElementSelection = ae.Value("Structure", "ElementSelection"), e.ElementReference = ae.Value("Structure", "ElementReference"), e.ElementSelectionQuery = Ot.Fn(e.ElementSelection, "ElementSelectionQuery");
}(Ue || (Ue = {}));
var Q = { core: Fg, structureQuery: { "@header": "Structure Queries", type: { "@header": "Types", elementSymbol: it(et.Dictionary({ 0: De(ae.Str) }), Ue.ElementSymbol, "Create element symbol representation from a string value."), atomName: it(et.Dictionary({ 0: De(ae.AnyValue) }), Ue.AtomName, "Convert a value to an atom name."), entityType: it(et.Dictionary({ 0: De(Ue.EntityType) }), Ue.EntityType, "Create normalized representation of entity type: ".concat(ae.oneOfValues(Ue.EntityType).join(", "), ".")), bondFlags: it(et.List(Ue.BondFlag), Ue.BondFlags, "Create bond flags representation from a list of strings. Allowed flags: ".concat(ae.oneOfValues(Ue.BondFlag).join(", "), ".")), ringFingerprint: it(et.List(Ue.ElementSymbol, { nonEmpty: !0 }), Ue.RingFingerprint, "Create ring fingerprint from the supplied atom element list."), secondaryStructureFlags: it(et.List(Ue.SecondaryStructureFlag), Ue.SecondaryStructureFlags, "Create secondary structure flags representation from a list of strings. Allowed flags: ".concat(ae.oneOfValues(Ue.SecondaryStructureFlag).join(", "), ".")), authResidueId: it(et.Dictionary({ 0: De(ae.Str, { description: "auth_asym_id" }), 1: De(ae.Num, { description: "auth_seq_id" }), 2: De(ae.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), Ue.ResidueId, 'Residue identifier based on "auth_" annotation.'), labelResidueId: it(et.Dictionary({ 0: De(ae.Str, { description: "label_entity_id" }), 1: De(ae.Str, { description: "label_asym_id" }), 2: De(ae.Num, { description: "label_seq_id" }), 3: De(ae.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), Ue.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`) }, slot: { "@header": "Iteration Slots", element: it(et.None, Ue.ElementReference, "A reference to the current element."), elementSetReduce: it(et.None, ae.Variable("a", ae.AnyValue, !0), "Current value of the element set reducer.") }, generator: { "@header": "Generators", all: it(et.None, Ue.ElementSelectionQuery, "The entire structure."), atomGroups: it(et.Dictionary({ "entity-test": De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }), "chain-test": De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }), "residue-test": De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }), "atom-test": De(ae.Bool, { isOptional: !0, defaultValue: !0 }), "group-by": De(ae.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" }) }), Ue.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."), bondedAtomicPairs: it(et.Dictionary({ 0: De(ae.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." }) }), Ue.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."), rings: it(et.Dictionary({ fingerprint: De(Ue.RingFingerprint, { isOptional: !0 }), "only-aromatic": De(ae.Bool, { isOptional: !0, defaultValue: !1 }) }), Ue.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."), queryInSelection: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), query: De(Ue.ElementSelectionQuery), "in-complement": De(ae.Bool, { isOptional: !0, defaultValue: !1 }) }), Ue.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."), empty: it(et.None, Ue.ElementSelectionQuery, "Nada.") }, modifier: { "@header": "Selection Modifications", queryEach: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), query: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Query every atom set in the input selection separately."), intersectBy: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), by: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."), exceptBy: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), by: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."), unionBy: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), by: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."), union: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."), cluster: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), "min-distance": De(ae.Num, { isOptional: !0, defaultValue: 0 }), "max-distance": De(ae.Num), "min-size": De(ae.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }), "max-size": De(ae.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 }) }), Ue.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: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), radius: De(ae.Num), "atom-radius": De(ae.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": De(ae.Bool, { isOptional: !0 }) }), Ue.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."), surroundingLigands: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), radius: De(ae.Num), "include-water": De(ae.Bool, { isOptional: !0, defaultValue: !0 }) }), Ue.ElementSelectionQuery, "Find all ligands components around the source query."), includeConnected: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), "bond-test": De(ae.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), "layer-count": De(ae.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }), "fixed-point": De(ae.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }), "as-whole-residues": De(ae.Bool, { isOptional: !0 }) }), Ue.ElementSelectionQuery, "Pick all atom sets that are connected to the target."), wholeResidues: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Expand the selection to whole residues."), expandProperty: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), property: De(ae.AnyValue) }), Ue.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: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), test: De(ae.Bool) }), Ue.ElementSelectionQuery, "Pick all atom sets that satisfy the test."), first: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Take the 1st atom set in the sequence."), withSameAtomProperties: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), source: De(Ue.ElementSelectionQuery), property: De(ae.Any) }), Ue.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."), intersectedBy: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), by: De(Ue.ElementSelectionQuery) }), Ue.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."), within: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), target: De(Ue.ElementSelectionQuery), "min-radius": De(ae.Num, { isOptional: !0, defaultValue: 0 }), "max-radius": De(ae.Num), "atom-radius": De(ae.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: De(ae.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." }) }), Ue.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."), isConnectedTo: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery), target: De(Ue.ElementSelectionQuery), "bond-test": De(ae.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), disjunct: De(ae.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: De(ae.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." }) }), Ue.ElementSelectionQuery, "Pick all atom sets that are connected to the target.") }, combinator: { "@header": "Selection Combinators", intersect: it(et.List(Ue.ElementSelectionQuery), Ue.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."), merge: it(et.List(Ue.ElementSelectionQuery), Ue.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."), distanceCluster: it(et.Dictionary({ matrix: De(Ot.List(Ot.List(ae.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }), selections: De(Ot.List(Ue.ElementSelectionQuery), { description: "A list of held selections." }) }), Ue.ElementSelectionQuery, "Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.") }, atomSet: { "@header": "Atom Sets", atomCount: it(et.None, ae.Num), countQuery: it(et.Dictionary({ 0: De(Ue.ElementSelectionQuery) }), ae.Num, "Counts the number of occurences of a specific query inside the current atom set."), reduce: it(et.Dictionary({ initial: De(ae.Variable("a", ae.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: De(ae.Variable("a", ae.AnyValue, !0), { description: "Expression executed for each atom in the set" }) }), ae.Variable("a", ae.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: it(et.Dictionary({ 0: De(Ot.ConstrainedVar) }), Ot.Set(Ot.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: kt(Ue.ElementSymbol), vdw: kt(ae.Num, "Van der Waals radius"), mass: kt(ae.Num, "Atomic weight"), atomicNumber: kt(ae.Num, "Atomic number"), x: kt(ae.Num, "Cartesian X coordinate"), y: kt(ae.Num, "Cartesian Y coordinate"), z: kt(ae.Num, "Cartesian Z coordinate"), atomKey: kt(ae.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."), bondCount: it(et.Dictionary({ 0: De(Ue.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }), flags: De(Ue.BondFlags, { isOptional: !0, defaultValue: "covalent" }) }), ae.Num, "Number of bonds (by default only covalent bonds are counted)."), sourceIndex: kt(ae.Num, "Index of the atom/element in the input file."), operatorName: kt(ae.Str, "Name of the symmetry operator applied to this element."), modelIndex: kt(ae.Num, "Index of the model in the input file."), modelLabel: kt(ae.Str, "Label/header of the model in the input file.") }, topology: { connectedComponentKey: kt(ae.AnyValue, "Unique value for each connected component.") }, macromolecular: { "@header": "Macromolecular Properties (derived from the mmCIF format)", authResidueId: kt(Ue.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"), labelResidueId: kt(Ue.ResidueId, "type.label-residue-id symbol executed on current atom's residue"), residueKey: kt(ae.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: kt(ae.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"), entityKey: kt(ae.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"), isHet: kt(ae.Bool, "Equivalent to atom_site.group_PDB !== ATOM"), id: kt(ae.Num, "_atom_site.id"), label_atom_id: kt(Ue.AtomName), label_alt_id: kt(ae.Str), label_comp_id: kt(ae.Str), label_asym_id: kt(ae.Str), label_entity_id: kt(ae.Str), label_seq_id: kt(ae.Num), auth_atom_id: kt(Ue.AtomName), auth_comp_id: kt(ae.Str), auth_asym_id: kt(ae.Str), auth_seq_id: kt(ae.Num), pdbx_PDB_ins_code: kt(ae.Str), pdbx_formal_charge: kt(ae.Num), occupancy: kt(ae.Num), B_iso_or_equiv: kt(ae.Num), entityType: kt(Ue.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"), entitySubtype: kt(Ue.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: kt(ae.Str, "The PRD ID of the entity."), entityDescription: kt(Ot.List(ae.Str)), objectPrimitive: kt(Ue.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"), secondaryStructureKey: kt(ae.AnyValue, "Unique value for each secondary structure element."), secondaryStructureFlags: kt(Ue.SecondaryStructureFlags), isModified: kt(ae.Bool, "True if the atom belongs to modification of a standard residue."), modifiedParentName: kt(ae.Str, "'3-letter' code of the modifed parent residue."), isNonStandard: kt(ae.Bool, "True if this is a non-standard residue."), chemCompType: kt(ae.Str, "Type of the chemical component as defined in mmCIF.") } }, bondProperty: { "@header": "Bond Properties", flags: ud(Ue.BondFlags), order: ud(ae.Num), length: ud(ae.Num), atomA: ud(Ue.ElementReference), atomB: ud(Ue.ElementReference) } }, internal: { "@header": "Internal Queries", generator: { "@header": "Generators", bundleElement: it(et.Dictionary({ groupedUnits: De(ae.Any), set: De(ae.Any), ranges: De(ae.Any) }), ae.Any), bundle: it(et.Dictionary({ elements: De(ae.Any) }), Ue.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."), current: it(et.None, Ue.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.") } } };
e9(Q);
var ot, MT = t9(Q);
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, n = MT; t < n.length; t++) {
    var r = n[t];
    e[r.id] = r;
  }
})(), function(e) {
  e.core = Q.core, e.struct = Q.structureQuery, e.internal = Q.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, n = e.struct.atomProperty.macromolecular, r = e.struct.atomProperty.topology;
  function i(u) {
    return t[u]();
  }
  function a(u) {
    return r[u]();
  }
  function o(u) {
    return n[u]();
  }
  e.acp = i, e.atp = a, e.ammp = o;
  var s = e.struct.atomSet.propertySet;
  e.acpSet = function(u) {
    return s([i(u)]);
  }, e.atpSet = function(u) {
    return s([a(u)]);
  }, e.ammpSet = function(u) {
    return s([o(u)]);
  };
}(ot || (ot = {}));
var sa, ua, DT = /* @__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"]), Ze = { Blue: 37052, Green: 42577, Yellow: 16765952, Orange: 16021792, Pink: 16162465, Purple: 10830745, LightBlue: 9424105, Brown: 10582605, Red: 15539236, Secondary: 15854817 };
(sa = {})[0] = "Hexose", sa[1] = "HexNAc", sa[2] = "Hexosamine", sa[3] = "Hexuronate", sa[4] = "Deoxyhexose", sa[5] = "DeoxyhexNAc", sa[6] = "Di-deoxyhexose", sa[7] = "Pentose", sa[8] = "Deoxynonulosonate", sa[9] = "Di-deoxynonulosonate", sa[10] = "Unknown", sa[11] = "Assigned", (ua = {})[0] = 0, ua[1] = 1, ua[2] = 2, ua[3] = 3, ua[4] = 4, ua[5] = 5, ua[6] = 6, ua[7] = 7, ua[8] = 8, ua[9] = 9, ua[10] = 10, ua[11] = 11;
var Ns, i9 = { abbr: "Unk", name: "Unknown", color: Ze.Secondary, type: 10 }, zm = [{ abbr: "Glc", name: "Glucose", color: Ze.Blue, type: 0 }, { abbr: "Man", name: "Mannose", color: Ze.Green, type: 0 }, { abbr: "Gal", name: "Galactose", color: Ze.Yellow, type: 0 }, { abbr: "Gul", name: "Gulose", color: Ze.Orange, type: 0 }, { abbr: "Alt", name: "Altrose", color: Ze.Pink, type: 0 }, { abbr: "All", name: "Allose", color: Ze.Purple, type: 0 }, { abbr: "Tal", name: "Talose", color: Ze.LightBlue, type: 0 }, { abbr: "Ido", name: "Idose", color: Ze.Brown, type: 0 }, { abbr: "GlcNAc", name: "N-Acetyl Glucosamine", color: Ze.Blue, type: 1 }, { abbr: "ManNAc", name: "N-Acetyl Mannosamine", color: Ze.Green, type: 1 }, { abbr: "GalNAc", name: "N-Acetyl Galactosamine", color: Ze.Yellow, type: 1 }, { abbr: "GulNAc", name: "N-Acetyl Gulosamine", color: Ze.Orange, type: 1 }, { abbr: "AltNAc", name: "N-Acetyl Altrosamine", color: Ze.Pink, type: 1 }, { abbr: "AllNAc", name: "N-Acetyl Allosamine", color: Ze.Purple, type: 1 }, { abbr: "TalNAc", name: "N-Acetyl Talosamine", color: Ze.LightBlue, type: 1 }, { abbr: "IdoNAc", name: "N-Acetyl Idosamine", color: Ze.Brown, type: 1 }, { abbr: "GlcN", name: "Glucosamine", color: Ze.Blue, type: 2 }, { abbr: "ManN", name: "Mannosamine", color: Ze.Green, type: 2 }, { abbr: "GalN", name: "Galactosamine", color: Ze.Yellow, type: 2 }, { abbr: "GulN", name: "Gulosamine", color: Ze.Orange, type: 2 }, { abbr: "AltN", name: "Altrosamine", color: Ze.Pink, type: 2 }, { abbr: "AllN", name: "Allosamine", color: Ze.Purple, type: 2 }, { abbr: "TalN", name: "Talosamine", color: Ze.LightBlue, type: 2 }, { abbr: "IdoN", name: "Idosamine", color: Ze.Brown, type: 2 }, { abbr: "GlcA", name: "Glucuronic Acid", color: Ze.Blue, type: 3 }, { abbr: "ManA", name: "Mannuronic Acid", color: Ze.Green, type: 3 }, { abbr: "GalA", name: "Galacturonic Acid", color: Ze.Yellow, type: 3 }, { abbr: "GulA", name: "Guluronic Acid", color: Ze.Orange, type: 3 }, { abbr: "AltA", name: "Altruronic Acid", color: Ze.Pink, type: 3 }, { abbr: "AllA", name: "Alluronic Acid", color: Ze.Purple, type: 3 }, { abbr: "TalA", name: "Taluronic Acid", color: Ze.LightBlue, type: 3 }, { abbr: "IdoA", name: "Iduronic Acid", color: Ze.Brown, type: 3 }, { abbr: "Qui", name: "Quinovose", color: Ze.Blue, type: 4 }, { abbr: "Rha", name: "Rhamnose", color: Ze.Green, type: 4 }, { abbr: "6dGul", name: "6-Deoxy Gulose", color: Ze.Orange, type: 4 }, { abbr: "6dAlt", name: "6-Deoxy Altrose", color: Ze.Pink, type: 4 }, { abbr: "6dTal", name: "6-Deoxy Talose", color: Ze.LightBlue, type: 4 }, { abbr: "Fuc", name: "Fucose", color: Ze.Red, type: 4 }, { abbr: "QuiNAc", name: "N-Acetyl Quinovosamine", color: Ze.Blue, type: 5 }, { abbr: "RhaNAc", name: "N-Acetyl Rhamnosamine", color: Ze.Green, type: 5 }, { abbr: "6dAltNAc", name: "N-Acetyl 6-Deoxy Altrosamine", color: Ze.Pink, type: 5 }, { abbr: "6dTalNAc", name: "N-Acetyl 6-Deoxy Talosamine", color: Ze.LightBlue, type: 5 }, { abbr: "FucNAc", name: "N-Acetyl Fucosamine", color: Ze.Red, type: 5 }, { abbr: "Oli", name: "Olivose", color: Ze.Blue, type: 6 }, { abbr: "Tyv", name: "Tyvelose", color: Ze.Green, type: 6 }, { abbr: "Abe", name: "Abequose", color: Ze.Orange, type: 6 }, { abbr: "Par", name: "Paratose", color: Ze.Pink, type: 6 }, { abbr: "Dig", name: "Digitoxose", color: Ze.Purple, type: 6 }, { abbr: "Col", name: "Colitose", color: Ze.LightBlue, type: 6 }, { abbr: "Ara", name: "Arabinose", color: Ze.Green, type: 7 }, { abbr: "Lyx", name: "Lyxose", color: Ze.Yellow, type: 7 }, { abbr: "Xyl", name: "Xylose", color: Ze.Orange, type: 7 }, { abbr: "Rib", name: "Ribose", color: Ze.Pink, type: 7 }, { abbr: "Kdn", name: "Keto-Deoxy Nonulonic Acid", color: Ze.Green, type: 8 }, { abbr: "Neu5Ac", name: "N-Acetyl Neuraminic Acid", color: Ze.Purple, type: 8 }, { abbr: "Neu5Gc", name: "N-Glycolyl Neuraminic Acid", color: Ze.LightBlue, type: 8 }, { abbr: "Neu", name: "Neuraminic Acid", color: Ze.Brown, type: 8 }, { abbr: "Sia", name: "Sialic acid", color: Ze.Red, type: 8 }, { abbr: "Pse", name: "Pseudaminic Acid", color: Ze.Green, type: 9 }, { abbr: "Leg", name: "Legionaminic Acid", color: Ze.Yellow, type: 9 }, { abbr: "Aci", name: "Acinetaminic Acid", color: Ze.Pink, type: 9 }, { abbr: "4eLeg", name: "4-Epilegionaminic Acid", color: Ze.LightBlue, type: 9 }, { abbr: "Bac", name: "Bacillosamine", color: Ze.Blue, type: 10 }, { abbr: "LDmanHep", name: "L-Glycero-D-Manno Heptose", color: Ze.Green, type: 10 }, { abbr: "Kdo", name: "Keto-Deoxy Octulonic Acid", color: Ze.Yellow, type: 10 }, { abbr: "Dha", name: "3-Deoxy Lyxo-Heptulosaric Acid", color: Ze.Orange, type: 10 }, { abbr: "DDmanHep", name: "D-Glycero-D-Manno-Heptose", color: Ze.Pink, type: 10 }, { abbr: "MurNAc", name: "N-Acetyl Muramic Acid", color: Ze.Purple, type: 10 }, { abbr: "MurNGc", name: "N-Glycolyl Muramic Acid", color: Ze.LightBlue, type: 10 }, { abbr: "Mur", name: "Muramic Acid", color: Ze.Brown, type: 10 }, { abbr: "Api", name: "Apicose", color: Ze.Green, type: 11 }, { abbr: "Fru", name: "Fructose", color: Ze.Green, type: 11 }, { abbr: "Tag", name: "Tagatose", color: Ze.Yellow, type: 11 }, { abbr: "Sor", name: "Sorbose", color: Ze.Orange, type: 11 }, { abbr: "Psi", name: "Psicose", color: Ze.Pink, type: 11 }], BT = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, n = zm.length; t < n; ++t) {
    var r = zm[t];
    e.set(r.abbr, r);
  }
  return e;
}(), RT = [["Glc-family", Ze.Blue], ["Man-family", Ze.Green], ["Gal-family", Ze.Yellow], ["Gul-family", Ze.Orange], ["Alt-family", Ze.Pink], ["All-family", Ze.Purple], ["Tal-family", Ze.LightBlue], ["Ido-family", Ze.Brown], ["Fuc-family", Ze.Red], ["Generic/Unknown/Secondary", Ze.Secondary]], kT = { 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"] }, OT = { 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"] }, xu = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, n = zm.length; t < n; ++t) {
    var r = zm[t], i = kT[r.abbr];
    if (i) for (var a = 0, o = i.length; a < o; ++a) e.set(i[a], r);
    var s = OT[r.abbr];
    if (s) for (a = 0, o = s.length; a < o; ++a) e.set(s[a], r);
  }
  return DT.forEach(function(u) {
    e.has(u) || e.set(u, i9);
  }), e;
}(), a9 = /* @__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"]), Nf = /* @__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"]), NT = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = [], n = 65; n <= 90; n++) t[t.length] = String.fromCharCode(n);
  for (n = 97; n <= 122; n++) t[t.length] = String.fromCharCode(n);
  for (n = 48; n <= 57; n++) t[t.length] = String.fromCharCode(n);
  for (var r = 0, i = t; r < i.length; r++) {
    var a = i[r];
    e[a] = a.toUpperCase();
    for (var o = 0, s = t; o < s.length; o++) {
      var u = s[o];
      e[a + u] = (a + u).toUpperCase();
      for (var c = 0, l = t; c < l.length; c++) {
        var d = l[c];
        e[a + u + d] = (a + u + d).toUpperCase();
      }
    }
  }
  return e;
}();
function Tl(e) {
  return NT[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], Tl(e[1])];
}));
var Ft, Bt, LT = ((Ns = {})[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() }, Ns[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"]) }, Ns[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"]) }, Ns[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"]) }, Ns[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"]) }, Ns[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"]) }, Ns[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"]) }, Ns), Gg = /* @__PURE__ */ new Set(["CA", "C", "N", "O", "O1", "O2", "OC1", "OC2", "OT1", "OT2", "OX1", "OXT", "H", "H1", "H2", "H3", "HA", "HN", "HXT", "BB"]), FT = /* @__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*"]), o9 = /* @__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"]), s9 = /* @__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"]), GT = /* @__PURE__ */ new Set(["D-GAMMA-PEPTIDE, C-DELTA LINKING", "L-GAMMA-PEPTIDE, C-DELTA LINKING"]), VT = /* @__PURE__ */ new Set(["D-BETA-PEPTIDE, C-GAMMA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), zT = /* @__PURE__ */ new Set(["D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS"]), u9 = /* @__PURE__ */ new Set(["PEPTIDE LINKING", "PEPTIDE-LIKE"]), UT = Ii.unionMany(o9, s9, u9), c9 = /* @__PURE__ */ new Set(["DNA LINKING", "L-DNA LINKING", "DNA OH 5 PRIME TERMINUS", "DNA OH 3 PRIME TERMINUS"]), l9 = /* @__PURE__ */ new Set(["RNA LINKING", "L-RNA LINKING", "RNA OH 5 PRIME TERMINUS", "RNA OH 3 PRIME TERMINUS"]), d9 = /* @__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"]), HT = /* @__PURE__ */ new Set(["NON-POLYMER", "OTHER"]), qT = /* @__PURE__ */ new Set(["ION"]), jT = /* @__PURE__ */ new Set(["LIPID"]), td = /* @__PURE__ */ new Set(["SOL", "WAT", "HOH", "H2O", "W", "DOD", "D3O", "TIP", "TIP3", "TIP4", "SPC"]), f9 = /* @__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"]), m9 = /* @__PURE__ */ new Set(["DAL", "DAR", "DSG", "DAS", "DCY", "DGL", "DGN", "DHI", "DIL", "DLE", "DLY", "MED", "DPN", "DPR", "DSN", "DTH", "DTR", "DTY", "DVA", "DNE"]), Lf = Ii.unionMany(f9, m9), I0 = /* @__PURE__ */ new Set(["A", "C", "T", "G", "I", "U", "N"]), w0 = /* @__PURE__ */ new Set(["DA", "DC", "DT", "DG", "DI", "DU", "DN"]), Vg = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), KT = /* @__PURE__ */ new Set(["A", "G", "I", "DA", "DG", "DI", "APN", "GPN"]), XT = /* @__PURE__ */ new Set(["C", "T", "U", "DC", "DT", "DU", "CPN", "TPN"]), zg = Ii.unionMany(I0, w0, Vg), p9 = function(e) {
  return KT.has(e.toUpperCase());
}, h9 = function(e) {
  return XT.has(e.toUpperCase());
}, Ug = Ii.unionMany(Lf, zg);
function Ff(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), Vg.has(t) ? 8 : UT.has(e) ? 5 : l9.has(e) ? 6 : c9.has(e) ? 7 : d9.has(e) ? 9 : td.has(t) ? 2 : Nf.has(t) ? 3 : a9.has(t) ? 4 : HT.has(e) ? xu.has(t) ? 9 : Lf.has(t) ? 5 : I0.has(t) ? 6 : w0.has(t) ? 7 : 1 : 0;
}
function YT(e, t) {
  return e = e.toUpperCase(), t === 5 ? GT.has(e) ? 2 : VT.has(e) ? 3 : zT.has(e) ? 0 : 1 : t === 6 ? 4 : t === 7 ? 5 : t === 8 ? 6 : 0;
}
function v9(e) {
  return e = e.toUpperCase(), Lf.has(e) ? "peptide linking" : I0.has(e) ? "RNA linking" : w0.has(e) ? "DNA linking" : xu.has(e) ? "saccharide" : "other";
}
function WT(e) {
  return e = e.toUpperCase(), td.has(e) ? "water" : Ug.has(e) ? "polymer" : xu.has(e) ? "branched" : "non-polymer";
}
function ZT(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), s9.has(t) ? "polypeptide(L)" : o9.has(t) ? "polypeptide(D)" : l9.has(t) ? "polyribonucleotide" : c9.has(t) ? "polydeoxyribonucleotide" : d9.has(t) || xu.has(e) ? "oligosaccharide" : Vg.has(e) ? "peptide nucleic acid" : f9.has(e) ? "polypeptide(L)" : m9.has(e) ? "polypeptide(D)" : I0.has(e) ? "polyribonucleotide" : w0.has(e) ? "polydeoxyribonucleotide" : qT.has(t) || Nf.has(e) ? "ion" : jT.has(t) || a9.has(e) ? "lipid" : u9.has(t) ? "peptide-like" : "other";
}
function Hg(e) {
  return nd(e) || g9(e);
}
function nd(e) {
  return e === 7 || e === 6 || e === 8;
}
function g9(e) {
  return e === 5;
}
(function(e) {
  e.is = Qr.has, e.create = Qr.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 };
})(Ft || (Ft = {})), function(e) {
  function t(n) {
    switch (n) {
      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 = Qr.has, e.create = function(n) {
    return Qr.create(n);
  }, e.isCovalent = function(n) {
    return !!(1 & n);
  }, e.isAll = function(n) {
    return n === Math.pow(2, 6) - 1;
  }, e.Names = { covalent: 1, "metal-coordination": 2, "hydrogen-bond": 4, disulfide: 8, aromatic: 16, computed: 32 }, e.isName = function(n) {
    return n in e.Names;
  }, e.fromName = t, e.fromNames = function(n) {
    for (var r = 0, i = 0, a = n.length; i < a; ++i) r |= t(n[i]);
    return r;
  };
}(Bt || (Bt = {}));
var yp = { 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] }, Ml = function() {
  function e() {
    this.count = 0, this.center = S(), this.radiusSq = 0;
  }
  return e.prototype.reset = function() {
    S.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
  }, e.prototype.includeStep = function(t) {
    S.add(this.center, this.center, t), this.count++;
  }, e.prototype.finishedIncludeStep = function() {
    this.count !== 0 && S.scale(this.center, this.center, 1 / this.count);
  }, e.prototype.radiusStep = function(t) {
    var n = S.squaredDistance(t, this.center);
    n > this.radiusSq && (this.radiusSq = n);
  }, e.prototype.radiusSphereStep = function(t, n) {
    var r = S.distance(t, this.center) + n, i = r * r;
    i > this.radiusSq && (this.radiusSq = i);
  }, e.prototype.getSphere = function(t) {
    return t || (t = de()), S.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(), n = S(), r = S();
  e.fromArrays = function(i, a) {
    var o = i.x, s = i.y, u = i.z;
    t.reset();
    for (var c = o.length, l = 0; l < c; l++) S.set(n, o[l], s[l], u[l]), t.includeStep(n);
    for (t.finishedIncludeStep(), l = 0; l < c; l++) S.set(n, o[l], s[l], u[l]), t.radiusStep(n);
    return S.copy(a.center, t.center), a.radius = Math.sqrt(t.radiusSq), a;
  }, e.fromProvider = function(i, a, o) {
    t.reset();
    for (var s = 0; s < i; s++) a(s, n), t.includeStep(n);
    for (t.finishedIncludeStep(), s = 0; s < i; s++) a(s, n), t.radiusStep(n);
    return S.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  }, e.fromPairProvider = function(i, a, o) {
    t.reset();
    for (var s = 0; s < i; s++) a(s, n, r), t.includeStep(n), t.includeStep(r);
    for (t.finishedIncludeStep(), s = 0; s < i; s++) a(s, n, r), t.radiusStep(n), t.radiusStep(r);
    return S.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  };
})(Ml || (Ml = {}));
var Sc = function() {
  function e(t) {
    this.map = t;
    var n = 0, r = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
    this.map.forEach(function(o) {
      o.forEach(function(s) {
        n += s.edgeCount, s.connectedIndices.forEach(function(u) {
          s.getEdges(u).forEach(function(c) {
            var l = s.unitA, d = s.unitB, m = e.getEdgeKey(u, l, c.indexB, d);
            i.set(m, r.length);
            var p = e.getVertexKey(u, l), v = a.get(p);
            v === void 0 ? a.set(p, [r.length]) : v.push(r.length), r.push(B(B({}, c), { indexA: u, unitA: l, unitB: d }));
          });
        });
      });
    }), this.edgeCount = n, this.edges = r, this.edgeKeyIndex = i, this.vertexKeyIndex = a;
  }
  return e.prototype.getConnectedUnits = function(t) {
    return this.map.has(t) ? this.map.get(t) : y9;
  }, e.prototype.getEdgeIndex = function(t, n, r, i) {
    var a = e.getEdgeKey(t, n, r, i), o = this.edgeKeyIndex.get(a);
    return o !== void 0 ? o : -1;
  }, e.prototype.hasEdge = function(t, n, r, i) {
    return this.getEdgeIndex(t, n, r, i) !== -1;
  }, e.prototype.getEdge = function(t, n, r, i) {
    var a = this.getEdgeIndex(t, n, r, i);
    return a !== -1 ? this.edges[a] : void 0;
  }, e.prototype.getEdgeIndices = function(t, n) {
    return this.vertexKeyIndex.get(e.getVertexKey(t, n)) || [];
  }, e;
}();
(function(e) {
  var t = function() {
    function i(a, o, s, u, c) {
      this.unitA = a, this.unitB = o, this.edgeCount = s, this.connectedIndices = u, this.edgeMap = c;
    }
    return i.prototype.hasEdges = function(a) {
      return this.edgeMap.has(a);
    }, i.prototype.getEdges = function(a) {
      return this.edgeMap.has(a) ? this.edgeMap.get(a) : y9;
    }, Object.defineProperty(i.prototype, "areUnitsOrdered", { get: function() {
      return this.unitA < this.unitB;
    }, enumerable: !1, configurable: !0 }), i;
  }();
  function n(i, a, o) {
    i.has(a) ? i.get(a).push(o) : i.set(a, [o]);
  }
  e.UnitPairEdges = t, e.getEdgeKey = function(i, a, o, s) {
    return "".concat(i, "|").concat(a, "|").concat(o, "|").concat(s);
  }, e.getVertexKey = function(i, a) {
    return "".concat(i, "|").concat(a);
  };
  var r = function() {
    function i() {
      this.map = /* @__PURE__ */ new Map();
    }
    return i.prototype.startUnitPair = function(a, o) {
      this.uA = a, this.uB = o, this.mapAB = /* @__PURE__ */ new Map(), this.mapBA = /* @__PURE__ */ new Map(), this.linkedA = yn.create(), this.linkedB = yn.create(), this.linkCount = 0;
    }, i.prototype.finishUnitPair = function() {
      this.linkCount !== 0 && (n(this.map, this.uA, new t(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), n(this.map, this.uB, new t(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA)));
    }, i.prototype.add = function(a, o, s) {
      n(this.mapAB, a, { indexB: o, props: s }), n(this.mapBA, o, { indexB: a, props: s }), yn.add(this.linkedA, a, a), yn.add(this.linkedB, o, o), this.linkCount += 1;
    }, i.prototype.getMap = function() {
      return this.map;
    }, i;
  }();
  e.Builder = r;
})(Sc || (Sc = {}));
var W2, y9 = [];
(function(e) {
  e.Empty = Ui.create([], [], [], 0, { flags: [], order: [] });
})(W2 || (W2 = {}));
var Um = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return Zr(t, e), t.prototype.getBondFromLocation = function(n) {
    return me.isAtomic(n.aUnit) && me.isAtomic(n.bUnit) ? this.getEdge(n.aIndex, n.aUnit.id, n.bIndex, n.bUnit.id) : void 0;
  }, t.prototype.getBondIndexFromLocation = function(n) {
    return me.isAtomic(n.aUnit) && me.isAtomic(n.bUnit) ? this.getEdgeIndex(n.aIndex, n.aUnit.id, n.bIndex, n.bUnit.id) : -1;
  }, t;
}(Sc);
(function(e) {
  var t = function(n) {
    function r() {
      return n !== null && n.apply(this, arguments) || this;
    }
    return Zr(r, n), r;
  }(Sc.UnitPairEdges);
  e.UnitPairBonds = t;
})(Um || (Um = {}));
var b9 = { forceCompute: !1, noCompute: !1, maxRadius: 4 }, hf = { 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 }, QT = { 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 }, _9 = { 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 }, x9 = { 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 }, S4 = 2.001, Hm = function() {
  for (var e = /* @__PURE__ */ new Set(), t = 0, n = ["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 < n.length; t++) {
    var r = n[t];
    e.add(hf[r]);
  }
  return e;
}();
function S9(e, t) {
  return e < t ? (e + t) * (e + t + 1) / 2 + t : (e + t) * (e + t + 1) / 2 + e;
}
function fu(e) {
  var t = hf[e];
  return t === void 0 ? -1 : t;
}
function gl(e) {
  if (e < 0) return S4;
  var t = QT[e];
  return t === void 0 ? S4 : t;
}
function Z2(e, t, n, r, i) {
  var a = function(o, s, u) {
    if (o < 0 || s < 0) return -1;
    var c = (u ? x9 : _9)[S9(o, s)];
    return c === void 0 ? -1 : c;
  }(e, t, i);
  return a > 0 ? a : t < 0 ? n : (n + r) / 1.95;
}
var JT = hf.H;
function mu(e) {
  return e === JT;
}
var $T = /* @__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 eM(e, t, n) {
  var r;
  return t = (r = t < n ? [t, n] : [n, t])[0], n = r[1], Lf.has(e) && t === "C" && n === "O" || zg.has(e) && t === "OP1" && n === "P" ? 2 : $T.get("".concat(e, "|").concat(t, "|").concat(n)) || 1;
}
var tM = /* @__PURE__ */ new Map([["LYS|NZ|RET|C15", 2]]);
function C9(e, t, n, r) {
  var i, a;
  return e > n && (e = (i = [n, e])[0], n = i[1], t = (a = [r, t])[0], r = a[1]), tM.get("".concat(e, "|").concat(t, "|").concat(n, "|").concat(r)) || 1;
}
var Du = X.Schema, z = Du.str, re = Du.int, bt = Du.float, bp = Du.coord, qe = Du.Aliased, Ls = Du.Matrix, u1 = Du.Vector, ku = Du.List, wt = { atom_site: { auth_asym_id: z, auth_atom_id: z, auth_comp_id: z, auth_seq_id: re, B_iso_or_equiv: bt, Cartn_x: bp, Cartn_y: bp, Cartn_z: bp, group_PDB: qe(z), id: re, label_alt_id: z, label_asym_id: z, label_atom_id: z, label_comp_id: z, label_entity_id: z, label_seq_id: re, occupancy: bt, type_symbol: z, pdbx_PDB_ins_code: z, pdbx_PDB_model_num: re, pdbx_formal_charge: re, pdbx_label_index: re, pdbx_sifts_xref_db_name: z, pdbx_sifts_xref_db_acc: z, pdbx_sifts_xref_db_num: z, pdbx_sifts_xref_db_res: z, ihm_model_id: re, cdr: re, em_confidence: z }, atom_site_anisotrop: { id: re, type_symbol: z, U: Ls(3, 3), U_esd: Ls(3, 3), pdbx_auth_seq_id: z, pdbx_auth_asym_id: z, pdbx_auth_atom_id: z, pdbx_auth_comp_id: z, pdbx_label_seq_id: re, pdbx_label_alt_id: z, pdbx_label_asym_id: z, pdbx_label_atom_id: z, pdbx_label_comp_id: z, pdbx_PDB_ins_code: z }, atom_sites: { entry_id: z, fract_transf_matrix: Ls(3, 3), fract_transf_vector: u1(3) }, audit_author: { name: z, pdbx_ordinal: re, identifier_ORCID: z }, audit_conform: { dict_location: z, dict_name: z, dict_version: z }, cell: { angle_alpha: bt, angle_beta: bt, angle_gamma: bt, entry_id: z, length_a: bt, length_b: bt, length_c: bt, Z_PDB: re, pdbx_unique_axis: z }, chem_comp: { formula: z, formula_weight: bt, id: z, mon_nstd_flag: qe(z), name: z, type: qe(z), pdbx_synonyms: ku(";", function(e) {
  return e;
}) }, chem_comp_bond: { atom_id_1: z, atom_id_2: z, comp_id: z, value_order: qe(z), pdbx_ordinal: re, pdbx_stereo_config: qe(z), pdbx_aromatic_flag: qe(z) }, citation: { book_publisher: z, country: z, id: z, journal_abbrev: z, journal_id_ASTM: z, journal_id_CSD: z, journal_id_ISSN: z, journal_volume: z, page_first: z, page_last: z, title: z, year: re, pdbx_database_id_DOI: z, pdbx_database_id_PubMed: re }, citation_author: { citation_id: z, name: z, ordinal: re }, database_2: { database_id: qe(z), database_code: z }, entity: { details: z, formula_weight: bt, id: z, src_method: qe(z), type: qe(z), pdbx_description: ku(",", function(e) {
  return e;
}), pdbx_number_of_molecules: re, pdbx_mutation: z, pdbx_fragment: z, pdbx_ec: ku(",", function(e) {
  return e;
}) }, entity_poly: { entity_id: z, nstd_linkage: qe(z), nstd_monomer: qe(z), type: qe(z), pdbx_strand_id: ku(",", function(e) {
  return e;
}), pdbx_seq_one_letter_code: z, pdbx_seq_one_letter_code_can: z, pdbx_target_identifier: z }, entity_poly_seq: { entity_id: z, hetero: qe(z), mon_id: z, num: re }, entry: { id: z }, exptl: { entry_id: z, method: qe(z) }, software: { classification: z, date: z, description: z, name: z, type: qe(z), version: z, pdbx_ordinal: re }, struct: { entry_id: z, title: z, pdbx_descriptor: z }, struct_asym: { details: z, entity_id: z, id: z, pdbx_modified: z, pdbx_blank_PDB_chainid_flag: qe(z) }, struct_conf: { beg_label_asym_id: z, beg_label_comp_id: z, beg_label_seq_id: re, beg_auth_asym_id: z, beg_auth_comp_id: z, beg_auth_seq_id: re, conf_type_id: qe(z), details: z, end_label_asym_id: z, end_label_comp_id: z, end_label_seq_id: re, end_auth_asym_id: z, end_auth_comp_id: z, end_auth_seq_id: re, id: z, pdbx_beg_PDB_ins_code: z, pdbx_end_PDB_ins_code: z, pdbx_PDB_helix_class: z, pdbx_PDB_helix_length: re, pdbx_PDB_helix_id: z }, struct_conn: { conn_type_id: qe(z), details: z, id: z, ptnr1_label_asym_id: z, ptnr1_label_atom_id: z, ptnr1_label_comp_id: z, ptnr1_label_seq_id: re, ptnr1_auth_asym_id: z, ptnr1_auth_comp_id: z, ptnr1_auth_seq_id: re, ptnr1_symmetry: z, ptnr2_label_asym_id: z, ptnr2_label_atom_id: z, ptnr2_label_comp_id: z, ptnr2_label_seq_id: re, ptnr2_auth_asym_id: z, ptnr2_auth_comp_id: z, ptnr2_auth_seq_id: re, ptnr2_symmetry: z, pdbx_ptnr1_PDB_ins_code: z, pdbx_ptnr1_label_alt_id: z, pdbx_ptnr1_standard_comp_id: z, pdbx_ptnr2_PDB_ins_code: z, pdbx_ptnr2_label_alt_id: z, pdbx_ptnr3_PDB_ins_code: z, pdbx_ptnr3_label_alt_id: z, pdbx_ptnr3_label_asym_id: z, pdbx_ptnr3_label_atom_id: z, pdbx_ptnr3_label_comp_id: z, pdbx_ptnr3_label_seq_id: re, pdbx_PDB_id: z, pdbx_dist_value: bt, pdbx_value_order: qe(z) }, struct_conn_type: { criteria: z, id: qe(z), reference: z }, struct_keywords: { entry_id: z, text: ku(",", function(e) {
  return e;
}), pdbx_keywords: z }, struct_ncs_oper: { code: qe(z), details: z, id: re, matrix: Ls(3, 3), vector: u1(3) }, struct_sheet_range: { beg_label_asym_id: z, beg_label_comp_id: z, beg_label_seq_id: re, end_label_asym_id: z, end_label_comp_id: z, end_label_seq_id: re, beg_auth_asym_id: z, beg_auth_comp_id: z, beg_auth_seq_id: re, end_auth_asym_id: z, end_auth_comp_id: z, end_auth_seq_id: re, id: z, sheet_id: z, pdbx_beg_PDB_ins_code: z, pdbx_end_PDB_ins_code: z }, struct_site: { details: z, id: z, pdbx_num_residues: re, pdbx_evidence_code: z, pdbx_auth_asym_id: z, pdbx_auth_comp_id: z, pdbx_auth_seq_id: z, pdbx_auth_ins_code: z }, struct_site_gen: { details: z, id: z, label_alt_id: z, label_asym_id: z, label_atom_id: z, label_comp_id: z, label_seq_id: re, auth_asym_id: z, auth_comp_id: z, auth_seq_id: z, site_id: z, symmetry: z, pdbx_auth_ins_code: z, pdbx_num_res: re }, symmetry: { entry_id: z, cell_setting: qe(z), Int_Tables_number: re, space_group_name_Hall: z, "space_group_name_H-M": z }, pdbx_database_status: { status_code: qe(z), status_code_sf: qe(z), status_code_mr: qe(z), entry_id: z, recvd_initial_deposition_date: z, SG_entry: qe(z), deposit_site: qe(z), process_site: qe(z), status_code_cs: qe(z), methods_development_category: qe(z), pdb_format_compatible: qe(z) }, pdbx_nonpoly_scheme: { asym_id: z, entity_id: z, mon_id: z, pdb_strand_id: z, ndb_seq_num: z, pdb_seq_num: z, auth_seq_num: z, pdb_mon_id: z, auth_mon_id: z, pdb_ins_code: z }, pdbx_database_related: { db_name: z, details: z, db_id: z, content_type: qe(z) }, pdbx_entity_nonpoly: { entity_id: z, comp_id: z, name: z }, pdbx_chem_comp_synonyms: { name: z, comp_id: z, provenance: qe(z) }, pdbx_chem_comp_identifier: { comp_id: z, identifier: z, type: qe(z), program: z, program_version: z }, pdbx_unobs_or_zero_occ_residues: { id: re, polymer_flag: qe(z), occupancy_flag: qe(re), PDB_model_num: re, auth_asym_id: z, auth_comp_id: z, auth_seq_id: z, PDB_ins_code: z, label_asym_id: z, label_comp_id: z, label_seq_id: re }, pdbx_struct_mod_residue: { id: re, auth_asym_id: z, auth_comp_id: z, auth_seq_id: re, PDB_ins_code: z, label_asym_id: z, label_comp_id: z, label_seq_id: re, parent_comp_id: z, details: z }, pdbx_struct_oper_list: { id: z, type: qe(z), name: z, symmetry_operation: z, matrix: Ls(3, 3), vector: u1(3) }, pdbx_struct_assembly: { method_details: z, oligomeric_details: z, oligomeric_count: re, details: z, id: z }, pdbx_struct_assembly_gen: { asym_id_list: ku(",", function(e) {
  return e;
}), assembly_id: z, oper_expression: z }, pdbx_reference_entity_list: { prd_id: z, ref_entity_id: z, type: qe(z), details: z, component_id: re }, pdbx_reference_entity_link: { link_id: re, prd_id: z, details: z, ref_entity_id_1: z, ref_entity_id_2: z, entity_seq_num_1: re, entity_seq_num_2: re, comp_id_1: z, comp_id_2: z, atom_id_1: z, atom_id_2: z, value_order: qe(z), component_1: re, component_2: re, link_class: qe(z) }, pdbx_reference_entity_poly_link: { link_id: re, prd_id: z, ref_entity_id: z, component_id: re, entity_seq_num_1: re, entity_seq_num_2: re, comp_id_1: z, comp_id_2: z, atom_id_1: z, atom_id_2: z, value_order: qe(z) }, pdbx_molecule: { prd_id: z, instance_id: re, asym_id: z }, pdbx_molecule_features: { prd_id: z, class: qe(z), type: qe(z), name: z, details: z }, entity_src_nat: { entity_id: z, pdbx_organism_scientific: z, pdbx_plasmid_name: z, pdbx_src_id: re, pdbx_beg_seq_num: re, pdbx_end_seq_num: re }, entity_src_gen: { entity_id: z, pdbx_gene_src_gene: ku(",", function(e) {
  return e;
}), pdbx_gene_src_scientific_name: z, plasmid_name: z, pdbx_src_id: re, pdbx_beg_seq_num: re, pdbx_end_seq_num: re }, pdbx_entity_src_syn: { organism_scientific: z, entity_id: z, pdbx_src_id: re, pdbx_beg_seq_num: re, pdbx_end_seq_num: re }, pdbx_entity_branch_descriptor: { entity_id: z, descriptor: z, type: qe(z), program: z, program_version: z, ordinal: re }, pdbx_entity_instance_feature: { details: z, feature_type: qe(z), auth_asym_id: z, asym_id: z, auth_seq_num: z, seq_num: re, comp_id: z, auth_comp_id: z, ordinal: re }, pdbx_entity_branch_list: { entity_id: z, hetero: qe(z), comp_id: z, num: re }, pdbx_entity_branch_link: { link_id: re, details: z, entity_id: z, entity_branch_list_num_1: re, entity_branch_list_num_2: re, comp_id_1: z, comp_id_2: z, atom_id_1: z, leaving_atom_id_1: z, atom_stereo_config_1: qe(z), atom_id_2: z, leaving_atom_id_2: z, atom_stereo_config_2: qe(z), value_order: qe(z) }, pdbx_entity_branch: { entity_id: z, type: qe(z) }, pdbx_branch_scheme: { entity_id: z, hetero: qe(z), asym_id: z, mon_id: z, num: re, pdb_asym_id: z, pdb_seq_num: z, pdb_mon_id: z, auth_asym_id: z, auth_seq_num: z, auth_mon_id: z }, pdbx_chem_comp_related: { comp_id: z, related_comp_id: z, relationship_type: qe(z), details: z }, ihm_starting_model_details: { starting_model_id: z, entity_id: z, entity_description: z, asym_id: z, entity_poly_segment_id: re, starting_model_source: qe(z), starting_model_auth_asym_id: z, starting_model_sequence_offset: re, dataset_list_id: re }, ihm_starting_comparative_models: { id: re, starting_model_id: z, starting_model_auth_asym_id: z, starting_model_seq_id_begin: re, starting_model_seq_id_end: re, template_auth_asym_id: z, template_seq_id_begin: re, template_seq_id_end: re, template_sequence_identity: bt, template_sequence_identity_denominator: qe(re), template_dataset_list_id: re, alignment_file_id: re }, ihm_starting_model_seq_dif: { id: re, entity_id: z, asym_id: z, seq_id: re, comp_id: z, starting_model_id: z, db_asym_id: z, db_seq_id: re, db_comp_id: z, details: z }, ihm_model_representation: { id: re, name: z, details: z }, ihm_model_representation_details: { id: re, representation_id: re, entity_poly_segment_id: re, entity_id: z, entity_description: z, entity_asym_id: z, model_object_primitive: qe(z), starting_model_id: z, model_mode: qe(z), model_granularity: qe(z), model_object_count: re }, ihm_struct_assembly_details: { id: re, assembly_id: re, parent_assembly_id: re, entity_description: z, entity_id: z, asym_id: z, entity_poly_segment_id: re }, ihm_struct_assembly: { id: re, name: z, description: z }, ihm_modeling_protocol: { id: re, num_steps: re, protocol_name: z }, ihm_modeling_protocol_details: { id: re, protocol_id: re, step_id: re, struct_assembly_id: re, dataset_group_id: re, struct_assembly_description: z, step_name: z, step_method: z, num_models_begin: re, num_models_end: re, multi_scale_flag: qe(z), multi_state_flag: qe(z), ordered_flag: qe(z), script_file_id: re, software_id: re }, ihm_multi_state_modeling: { state_id: re, state_group_id: re, population_fraction: bt, population_fraction_sd: bt, state_type: z, state_name: z, experiment_type: qe(z), details: z }, ihm_modeling_post_process: { id: re, protocol_id: re, analysis_id: re, step_id: re, type: qe(z), feature: qe(z), num_models_begin: re, num_models_end: re }, ihm_ensemble_info: { ensemble_id: re, ensemble_name: z, post_process_id: re, model_group_id: re, ensemble_clustering_method: qe(z), ensemble_clustering_feature: qe(z), num_ensemble_models: re, num_ensemble_models_deposited: re, ensemble_precision_value: bt, ensemble_file_id: re }, ihm_model_list: { model_id: re, model_name: z, assembly_id: re, protocol_id: re, representation_id: re }, ihm_model_group: { id: re, name: z, details: z }, ihm_model_group_link: { model_id: re, group_id: re }, ihm_model_representative: { id: re, model_group_id: re, model_id: re, selection_criteria: qe(z) }, ihm_dataset_list: { id: re, data_type: qe(z), database_hosted: qe(z) }, ihm_dataset_group: { id: re, name: z, application: qe(z), details: z }, ihm_dataset_group_link: { dataset_list_id: re, group_id: re }, ihm_related_datasets: { dataset_list_id_derived: re, dataset_list_id_primary: re }, ihm_dataset_related_db_reference: { id: re, dataset_list_id: re, db_name: qe(z), accession_code: z, version: z, details: z }, ihm_external_reference_info: { reference_id: re, reference_provider: z, reference_type: qe(z), reference: z, refers_to: qe(z), associated_url: z }, ihm_external_files: { id: re, reference_id: re, file_path: z, content_type: qe(z), file_size_bytes: bt, details: z }, ihm_dataset_external_reference: { id: re, dataset_list_id: re, file_id: re }, ihm_localization_density_files: { id: re, file_id: re, ensemble_id: re, entity_id: z, entity_poly_segment_id: re, asym_id: z }, ihm_predicted_contact_restraint: { id: re, group_id: re, entity_id_1: z, entity_id_2: z, asym_id_1: z, asym_id_2: z, comp_id_1: z, comp_id_2: z, seq_id_1: re, seq_id_2: re, rep_atom_1: qe(z), rep_atom_2: qe(z), distance_lower_limit: bt, distance_upper_limit: bt, probability: bt, restraint_type: qe(z), model_granularity: qe(z), dataset_list_id: re, software_id: re }, ihm_cross_link_list: { id: re, group_id: re, entity_description_1: z, entity_description_2: z, entity_id_1: z, entity_id_2: z, comp_id_1: z, comp_id_2: z, seq_id_1: re, seq_id_2: re, linker_type: qe(z), dataset_list_id: re }, ihm_cross_link_restraint: { id: re, group_id: re, entity_id_1: z, entity_id_2: z, asym_id_1: z, asym_id_2: z, comp_id_1: z, comp_id_2: z, seq_id_1: re, seq_id_2: re, atom_id_1: z, atom_id_2: z, restraint_type: qe(z), conditional_crosslink_flag: qe(z), model_granularity: qe(z), distance_threshold: bt, psi: bt, sigma_1: bt, sigma_2: bt }, ihm_cross_link_result_parameters: { id: re, restraint_id: re, model_id: re, psi: bt, sigma_1: bt, sigma_2: bt }, ihm_2dem_class_average_restraint: { id: re, dataset_list_id: re, number_raw_micrographs: re, pixel_size_width: bt, pixel_size_height: bt, image_resolution: bt, image_segment_flag: qe(z), number_of_projections: re, struct_assembly_id: re, details: z }, ihm_2dem_class_average_fitting: { id: re, restraint_id: re, model_id: re, cross_correlation_coefficient: bt, rot_matrix: Ls(3, 3), tr_vector: u1(3) }, ihm_3dem_restraint: { id: re, dataset_list_id: re, model_id: re, struct_assembly_id: re, fitting_method: z, number_of_gaussians: re, cross_correlation_coefficient: bt }, ihm_sas_restraint: { id: re, dataset_list_id: re, model_id: re, struct_assembly_id: re, profile_segment_flag: qe(z), fitting_atom_type: z, fitting_method: z, fitting_state: qe(z), radius_of_gyration: bt, chi_value: bt, details: z }, ihm_starting_model_coord: { ordinal_id: re, starting_model_id: z, group_PDB: qe(z), id: re, type_symbol: z, entity_id: z, atom_id: z, comp_id: z, seq_id: re, asym_id: z, Cartn_x: bt, Cartn_y: bt, Cartn_z: bt, B_iso_or_equiv: bt }, ihm_sphere_obj_site: { id: re, entity_id: z, seq_id_begin: re, seq_id_end: re, asym_id: z, Cartn_x: bt, Cartn_y: bt, Cartn_z: bt, object_radius: bt, rmsf: bt, model_id: re }, ihm_gaussian_obj_site: { id: re, entity_id: z, seq_id_begin: re, seq_id_end: re, asym_id: z, mean_Cartn_x: bt, mean_Cartn_y: bt, mean_Cartn_z: bt, weight: bt, covariance_matrix: Ls(3, 3), model_id: re }, ihm_gaussian_obj_ensemble: { id: re, entity_id: z, seq_id_begin: re, seq_id_end: re, asym_id: z, mean_Cartn_x: bt, mean_Cartn_y: bt, mean_Cartn_z: bt, weight: bt, covariance_matrix: Ls(3, 3), ensemble_id: re }, ihm_feature_list: { feature_id: re, feature_type: qe(z), entity_type: qe(z) }, ihm_poly_residue_feature: { ordinal_id: re, feature_id: re, entity_id: z, asym_id: z, comp_id_begin: z, comp_id_end: z, seq_id_begin: re, seq_id_end: re }, ihm_derived_distance_restraint: { id: re, group_id: re, feature_id_1: re, feature_id_2: re, group_conditionality: qe(z), random_exclusion_fraction: bt, distance_upper_limit: bt, restraint_type: qe(z), dataset_list_id: re }, ma_model_list: { ordinal_id: re, model_id: re, model_group_id: re, model_name: z, model_group_name: z, model_type: qe(z), data_id: re }, ma_target_entity: { entity_id: z, data_id: re, origin: qe(z) }, ma_target_entity_instance: { asym_id: z, entity_id: z, details: z }, ma_target_ref_db_details: { target_entity_id: z, db_name: qe(z), db_code: z, db_accession: z, seq_db_isoform: z, seq_db_align_begin: z, seq_db_align_end: z, ncbi_taxonomy_id: z, organism_scientific: z }, ma_data: { id: re, content_type: qe(z), content_type_other_details: z, name: z }, ma_software_group: { ordinal_id: re, group_id: re, software_id: re }, ma_qa_metric: { id: re, name: z, type: qe(z), mode: qe(z), software_group_id: re }, ma_qa_metric_global: { ordinal_id: re, model_id: re, metric_id: re, metric_value: bt }, ma_qa_metric_local: { ordinal_id: re, model_id: re, label_asym_id: z, label_seq_id: re, label_comp_id: z, metric_id: re, metric_value: bt } }, nM = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function qm(e) {
  for (var t = e.data, n = e.encoding.length - 1; n >= 0; n--) t = rM(t, e.encoding[n]);
  return t;
}
function rM(e, t) {
  switch (t.kind) {
    case "ByteArray":
      switch (t.type) {
        case 4:
          return e;
        case 1:
          return function(n) {
            return new Int8Array(n.buffer, n.byteOffset);
          }(e);
        case 2:
          return function(n) {
            return Uc(n, 2, Int16Array);
          }(e);
        case 5:
          return function(n) {
            return Uc(n, 2, Uint16Array);
          }(e);
        case 3:
          return function(n) {
            return Uc(n, 4, Int32Array);
          }(e);
        case 6:
          return function(n) {
            return Uc(n, 4, Uint32Array);
          }(e);
        case 32:
          return function(n) {
            return Uc(n, 4, Float32Array);
          }(e);
        case 33:
          return function(n) {
            return Uc(n, 8, Float64Array);
          }(e);
        default:
          Tr(t.type);
      }
    case "FixedPoint":
      return function(n, r) {
        for (var i = n.length, a = A4(r.srcType, i), o = 1 / r.factor, s = 0; s < i; s++) a[s] = o * n[s];
        return a;
      }(e, t);
    case "IntervalQuantization":
      return function(n, r) {
        for (var i = n.length, a = A4(r.srcType, i), o = (r.max - r.min) / (r.numSteps - 1), s = r.min, u = 0; u < i; u++) a[u] = s + o * n[u];
        return a;
      }(e, t);
    case "RunLength":
      return function(n, r) {
        for (var i = C4(r.srcType, r.srcSize), a = 0, o = 0, s = n.length; o < s; o += 2) for (var u = n[o], c = n[o + 1], l = 0; l < c; ++l) i[a++] = u;
        return i;
      }(e, t);
    case "Delta":
      return function(n, r) {
        var i = n.length, a = C4(r.srcType, i);
        if (!i) return n;
        a[0] = n[0] + (0 | r.origin);
        for (var o = 1; o < i; ++o) a[o] = n[o] + a[o - 1];
        return a;
      }(e, t);
    case "IntegerPacking":
      return function(n, r) {
        return n.length === r.srcSize ? n : r.isUnsigned ? function(i, a) {
          for (var o = a.byteCount === 1 ? 255 : 65535, s = i.length, u = new Int32Array(a.srcSize), c = 0, l = 0; c < s; ) {
            for (var d = 0, m = i[c]; m === o; ) d += m, m = i[++c];
            d += m, u[l] = d, c++, l++;
          }
          return u;
        }(n, r) : function(i, a) {
          for (var o = a.byteCount === 1 ? 127 : 32767, s = -o - 1, u = i.length, c = new Int32Array(a.srcSize), l = 0, d = 0; l < u; ) {
            for (var m = 0, p = i[l]; p === o || p === s; ) m += p, p = i[++l];
            m += p, c[d] = m, l++, d++;
          }
          return c;
        }(n, r);
      }(e, t);
    case "StringArray":
      return function(n, r) {
        var i = qm({ encoding: r.offsetEncoding, data: r.offsets }), a = qm({ encoding: r.dataEncoding, data: n }), o = r.stringData, s = new Array(i.length);
        s[0] = "";
        for (var u = 1, c = i.length; u < c; u++) s[u] = o.substring(i[u - 1], i[u]);
        var l = 0, d = new Array(a.length);
        for (u = 0, c = a.length; u < c; u++) d[l++] = s[a[u] + 1];
        return d;
      }(e, t);
  }
}
function C4(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:
      Tr();
  }
}
function A4(e, t) {
  switch (e) {
    case 32:
      return new Float32Array(t);
    case 33:
      return new Float64Array(t);
    default:
      Tr();
  }
}
function Uc(e, t, n) {
  return new n(nM ? e.buffer : function(r, i) {
    for (var a = new ArrayBuffer(r.length), o = new Uint8Array(a), s = 0, u = r.length; s < u; s += i) for (var c = 0; c < i; c++) o[s + i - c - 1] = r[s + c];
    return a;
  }(e, t));
}
var eu, Ld, Q2;
function iM(e, t, n) {
  var r, i = 1;
  for (r = 0; r < t; r++) {
    var a = i * e;
    if (Math.abs(Math.round(a) - a) <= n) return r;
    i *= 10;
  }
  return -1;
}
function I4(e, t) {
  return parseFloat(e.toPrecision(t));
}
function J2(e) {
  return Ld.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 n = 0, r = t.length; n < r; n++) if (n < 0) return !1;
    return !0;
  };
})(eu || (eu = {})), function(e) {
  function t(l, d) {
    return l >= 0 ? Math.ceil((l + 1) / d) : Math.ceil((l + 1) / (-d - 1));
  }
  function n(l, d, m) {
    var p = l.limit8, v = l.limit16;
    d.pack8 += t(m, p), d.pack16 += t(m, v), d.count += 1;
  }
  function r(l, d) {
    l.pack8 += t(d, 127), l.pack16 += t(d, 32767), l.count += 1;
  }
  function i(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 a(l, d) {
    for (var m = { pack8: 0, pack16: 0, count: 0 }, p = 0, v = l.length; p < v; p++) n(d, m, l[p]);
    return B(B({}, i(m)), { kind: "pack" });
  }
  function o(l, d) {
    for (var m = { pack8: 0, pack16: 0, count: 0 }, p = l[0], v = 1, f = l.length; v < f; v++) r(m, l[v] - p), p = l[v];
    return B(B({}, i(m)), { kind: "delta" });
  }
  function s(l, d) {
    for (var m = { pack8: 0, pack16: 0, count: 0 }, p = 1, v = 1, f = l.length; v < f; v++) l[v - 1] !== l[v] ? (n(d, m, l[v - 1]), n(d, m, p), p = 1) : p++;
    return n(d, m, l[l.length - 1]), n(d, m, p), B(B({}, i(m)), { kind: "rle" });
  }
  function u(l, d) {
    for (var m = { pack8: 0, pack16: 0, count: 0 }, p = 1, v = 0, f = 0, y = 1, h = l.length; y < h; y++) {
      var g = l[y] - v;
      f !== g ? (r(m, f), r(m, p), p = 1) : p++, f = g, v = l[y];
    }
    return r(m, f), r(m, p), B(B({}, i(m)), { kind: "delta-rle" });
  }
  function c(l) {
    var d = function(p) {
      for (var v = !1, f = 0, y = p.length; f < y; f++) if (p[f] < 0) {
        v = !0;
        break;
      }
      return v ? { signed: v, limit8: 127, limit16: 32767 } : { signed: v, limit8: 255, limit16: 65535 };
    }(l), m = [a(l, d), s(l, d), o(l), u(l)];
    return m.sort(function(p, v) {
      return p.length - v.length;
    }), m;
  }
  e.getSize = c, e.classify = function(l) {
    if (l.length < 2) return Dt.by(Dt.byteArray);
    switch (c(l)[0].kind) {
      case "pack":
        return Dt.by(Dt.integerPacking);
      case "rle":
        return Dt.by(Dt.runLength).and(Dt.integerPacking);
      case "delta":
        return Dt.by(Dt.delta).and(Dt.integerPacking);
      case "delta-rle":
        return Dt.by(Dt.delta).and(Dt.runLength).and(Dt.integerPacking);
      default:
        Tr();
    }
  };
}(Ld || (Ld = {})), function(e) {
  e.classify = function(t) {
    var n = function(d, m, p) {
      for (var v = 1, f = 0, y = 0, h = d.length; y < h; y++) {
        if (v >= 0) {
          var g = iM(d[y], m, p);
          g < 0 ? v = -1 : g > v && (v = g);
        }
        var x = Math.abs(d[y]);
        if (x > p) {
          var C = Math.floor(Math.log10(Math.abs(x))) + 1;
          C > f && (f = C);
        }
      }
      return { mantissaDigits: v, integerDigits: f };
    }(t, 4, 1e-6), r = n.mantissaDigits, i = n.integerDigits;
    if (r < 0 || r + i > 10) return Dt.by(Dt.byteArray);
    if (r === 0) return Ld.classify(t);
    for (var a = function(d) {
      for (var m = 1, p = 0; p < d; p++) m *= 10;
      return m;
    }(r), o = new Int32Array(t.length), s = 0, u = t.length; s < u; s++) o[s] = Math.round(a * t[s]);
    var c = Ld.getSize(o)[0], l = Dt.by(Dt.fixedPoint(a));
    switch (c.kind) {
      case "pack":
        return l.and(Dt.integerPacking);
      case "rle":
        return l.and(Dt.runLength).and(Dt.integerPacking);
      case "delta":
        return l.and(Dt.delta).and(Dt.integerPacking);
      case "delta-rle":
        return l.and(Dt.delta).and(Dt.runLength).and(Dt.integerPacking);
      default:
        Tr();
    }
  };
}(Q2 || (Q2 = {}));
var pu, Dt, $2, Qi, ev, w4 = 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 n = [], r = 0, i = this.providers; r < i.length; r++) {
      var a = (0, i[r])(t);
      if (!a.encodings.length) throw new Error("Encodings must be non-empty.");
      t = a.data;
      for (var o = 0, s = a.encodings; o < s.length; o++) {
        var u = s[o];
        n.push(u);
      }
    }
    if (!(t instanceof Uint8Array)) throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
    return { encoding: n, data: t };
  }, e;
}();
function _p(e) {
  return function(t, n) {
    return n[e].value(t);
  };
}
function aM(e) {
  return function(t, n) {
    return n[e].value(t).join(n[e].schema.separator);
  };
}
function xp(e) {
  for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
  return function(r, i) {
    var a;
    return (a = i[e].schema.space).get.apply(a, Pe([i[e].value(r)], t, !1));
  };
}
function Fd(e) {
  return function(t, n) {
    return n[e].valueKind(t);
  };
}
function oM(e, t) {
  var n = [], r = Fd(e);
  if (t.rank === 1) for (var i = t.dimensions[0], a = 0; a < i; a++) {
    var o = "".concat(e, "[").concat(a + 1, "]");
    n.push({ name: o, type: 2, value: xp(e, a), valueKind: r });
  }
  else if (t.rank === 2) {
    i = t.dimensions[0];
    var s = t.dimensions[1];
    for (a = 0; a < i; a++) for (var u = 0; u < s; u++) {
      var c = "".concat(e, "[").concat(a + 1, "][").concat(u + 1, "]");
      n.push({ name: c, type: 2, value: xp(e, a, u), valueKind: r });
    }
  } 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], m = t.dimensions[2];
    for (a = 0; a < l; a++) for (u = 0; u < d; u++) for (var p = 0; p < m; p++) {
      var v = "".concat(e, "[").concat(a + 1, "][").concat(u + 1, "][").concat(p + 1, "]");
      n.push({ name: v, type: 2, value: xp(e, a, u, p), valueKind: r });
    }
  }
  return n;
}
function P4(e) {
  for (var t = [], n = 0, r = Object.keys(e); n < r.length; n++) {
    var i = r[n], a = e[i];
    a.valueType === "int" ? t.push({ name: i, type: 1, value: _p(i), valueKind: Fd(i) }) : a.valueType === "float" ? t.push({ name: i, type: 2, value: _p(i), valueKind: Fd(i) }) : a.valueType === "str" ? t.push({ name: i, type: 0, value: _p(i), valueKind: Fd(i) }) : a.valueType === "list" ? t.push({ name: i, type: 0, value: aM(i), valueKind: Fd(i) }) : a.valueType === "tensor" ? t.push.apply(t, oM(i, a.space)) : Tr(a.valueType);
  }
  return t;
}
function tv(e) {
  return e.fields.some(function(t) {
    return !!t.shouldInclude;
  }) ? e.fields.filter(function(t) {
    return !t.shouldInclude || e.source.some(function(n) {
      return t.shouldInclude(n.data);
    });
  }) : e.fields;
}
function A9(e, t) {
  var n = e.instance(t), r = n.source.filter(function(o) {
    return o.rowCount > 0;
  });
  if (!r.length) return { instance: n, rowCount: 0, source: [] };
  var i = r.reduce(function(o, s) {
    return o + s.rowCount;
  }, 0), a = r.map(function(o) {
    return { data: o.data, keys: function() {
      return o.keys ? o.keys() : Om.Range(0, o.rowCount - 1);
    }, rowCount: o.rowCount };
  });
  return { instance: n, rowCount: i, source: a };
}
(function(e) {
  function t(r) {
    return new w4([r]);
  }
  function n(r) {
    switch (r.kind) {
      case "ByteArray":
        return Dt.byteArray;
      case "FixedPoint":
        return Dt.fixedPoint(r.factor);
      case "IntervalQuantization":
        return Dt.intervalQuantizaiton(r.min, r.max, r.numSteps);
      case "RunLength":
        return Dt.runLength;
      case "Delta":
        return Dt.delta;
      case "IntegerPacking":
        return Dt.integerPacking;
      case "StringArray":
        return Dt.stringArray;
    }
  }
  e.by = t, e.fromEncoding = function(r) {
    for (var i = t(n(r[0])), a = 1; a < r.length; a++) i = i.and(n(r[a]));
    return i;
  };
})(pu || (pu = {})), function(e) {
  var t, n;
  e.by = function(s) {
    return new w4([s]);
  };
  var r = ((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), i = ((n = {})[2] = 2, n[5] = 2, n[3] = 4, n[6] = 4, n[32] = 4, n[33] = 8, n);
  function a(s) {
    var u = eu.getDataType(s);
    if (u === 1) return function(v) {
      return { encodings: [{ kind: "ByteArray", type: 1 }], data: new Uint8Array(v.buffer, v.byteOffset) };
    }(s);
    if (u === 4) return /* @__PURE__ */ function(v) {
      return { encodings: [{ kind: "ByteArray", type: 4 }], data: v };
    }(s);
    for (var c = new Uint8Array(s.length * i[u]), l = r[u], d = new DataView(c.buffer), m = 0, p = s.length; m < p; m++) l(d, m, s[m]);
    return { encodings: [{ kind: "ByteArray", type: u }], data: c };
  }
  function o(s, u) {
    for (var c = -u - 1, l = 0, d = 0, m = s.length; d < m; d++) {
      var p = s[d];
      p === 0 ? l += 1 : p > 0 ? (l += Math.ceil(p / u), p % u == 0 && (l += 1)) : (l += Math.ceil(p / c), p % c == 0 && (l += 1));
    }
    return l;
  }
  e.byteArray = a, e.fixedPoint = function(s) {
    return function(u) {
      return function(c, l) {
        for (var d = eu.getDataType(c), m = new Int32Array(c.length), p = 0, v = c.length; p < v; p++) m[p] = Math.round(c[p] * l);
        return { encodings: [{ kind: "FixedPoint", factor: l, srcType: d }], data: m };
      }(u, s);
    };
  }, e.intervalQuantizaiton = function(s, u, c, l) {
    return l === void 0 && (l = Int32Array), function(d) {
      return function(m, p, v, f, y) {
        var h = eu.getDataType(m);
        if (!m.length) return { encodings: [{ kind: "IntervalQuantization", min: p, max: v, numSteps: f, srcType: h }], data: new Int32Array(0) };
        if (v < p) {
          var g = p;
          p = v, v = g;
        }
        for (var x = (v - p) / (f - 1), C = new y(m.length), b = 0, _ = m.length; b < _; b++) {
          var A = m[b];
          C[b] = A <= p ? 0 : A >= v ? f - 1 : 0 | Math.round((A - p) / x);
        }
        return { encodings: [{ kind: "IntervalQuantization", min: p, max: v, numSteps: f, srcType: h }], data: C };
      }(d, s, u, c, l);
    };
  }, e.runLength = function(s) {
    var u = eu.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 m = new Int32Array(c), p = 0, v = 1;
    for (l = 1, d = s.length; l < d; l++) s[l - 1] !== s[l] ? (m[p] = s[l - 1], m[p + 1] = v, v = 1, p += 2) : ++v;
    return m[p] = s[s.length - 1], m[p + 1] = v, { encodings: [{ kind: "RunLength", srcType: u, srcSize: s.length }], data: m };
  }, e.delta = function(s) {
    if (!eu.isSignedIntegerDataType(s)) throw new Error("Only signed integer types can be encoded using delta encoding.");
    var u = eu.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, m = s.length; d < m; 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(p) {
        for (var v = 0, f = p.length; v < f; v++) if (p[v] < 0) return !0;
        return !1;
      }(c), d = o(c, l ? 127 : 255), m = o(c, l ? 32767 : 65535);
      return 4 * c.length < 2 * m ? { isSigned: l, size: c.length, bytesPerElement: 4 } : 2 * m < d ? { isSigned: l, size: m, bytesPerElement: 2 } : { isSigned: l, size: d, bytesPerElement: 1 };
    }(s);
    return u.bytesPerElement === 4 ? a(s) : function(c, l) {
      for (var d = l.isSigned ? l.bytesPerElement === 1 ? 127 : 32767 : l.bytesPerElement === 1 ? 255 : 65535, m = -d - 1, p = c.length, v = l.isSigned ? l.bytesPerElement === 1 ? new Int8Array(l.size) : new Int16Array(l.size) : l.bytesPerElement === 1 ? new Uint8Array(l.size) : new Uint16Array(l.size), f = 0, y = 0; y < p; y++) {
        var h = c[y];
        if (h >= 0) for (; h >= d; ) v[f] = d, ++f, h -= d;
        else for (; h <= m; ) v[f] = m, ++f, h -= m;
        v[f] = h, ++f;
      }
      var g = a(v);
      return { encodings: [{ kind: "IntegerPacking", byteCount: l.bytesPerElement, isUnsigned: !l.isSigned, srcSize: p }, g.encodings[0]], data: g.data };
    }(s, u);
  }, e.stringArray = function(s) {
    var u = /* @__PURE__ */ Object.create(null), c = [], l = new Int32Array(s.length), d = he.create(Int32Array, 1, Math.min(1024, s.length < 32 ? s.length + 1 : Math.round(s.length / 8) + 1));
    he.add(d, 0);
    for (var m = 0, p = 0, v = 0, f = s; v < f.length; v++) {
      var y = f[v];
      if (y != null) {
        var h = u[y];
        h === void 0 && (m += y.length, c[h = c.length] = y, u[y] = h, he.add(d, m)), l[p++] = h;
      } else l[p++] = -1;
    }
    var g = he.compact(d), x = J2(g).encode(g), C = J2(l).encode(l);
    return { encodings: [{ kind: "StringArray", dataEncoding: C.encoding, stringData: c.join(""), offsetEncoding: x.encoding, offsets: x.data }], data: C.data };
  };
}(Dt || (Dt = {})), function(e) {
  function t(r, i, a) {
    return { name: r, type: 1, value: i, valueKind: a && a.valueKind, defaultFormat: a ? { encoder: a.encoder, typedArray: a.typedArray } : void 0, shouldInclude: a && a.shouldInclude };
  }
  e.str = function(r, i, a) {
    return { name: r, type: 0, value: i, valueKind: a && a.valueKind, defaultFormat: a && a.encoder ? { encoder: a.encoder } : void 0, shouldInclude: a && a.shouldInclude };
  }, e.int = t, e.float = function(r, i, a) {
    return { name: r, type: 2, value: i, valueKind: a && a.valueKind, defaultFormat: a ? { encoder: a.encoder, typedArray: a.typedArray, digitCount: a.digitCount !== void 0 ? a.digitCount : void 0 } : void 0, shouldInclude: a && a.shouldInclude };
  }, e.index = function(r) {
    return t(r, function(i, a, o) {
      return o + 1;
    }, { typedArray: Int32Array, encoder: Dt.by(Dt.delta).and(Dt.runLength).and(Dt.integerPacking) });
  };
  var n = function() {
    function r() {
      this.fields = [];
    }
    return r.prototype.index = function(i) {
      return this.fields.push(e.index(i)), this;
    }, r.prototype.str = function(i, a, o) {
      return this.fields.push(e.str(i, a, o)), this;
    }, r.prototype.int = function(i, a, o) {
      return this.fields.push(e.int(i, a, o)), this;
    }, r.prototype.vec = function(i, a, o) {
      for (var s = 0; s < a.length; s++) this.fields.push(e.int("".concat(i, "[").concat(s + 1, "]"), a[s], o));
      return this;
    }, r.prototype.float = function(i, a, o) {
      return this.fields.push(e.float(i, a, o)), this;
    }, r.prototype.many = function(i) {
      for (var a = 0; a < i.length; a++) this.fields.push(i[a]);
      return this;
    }, r.prototype.add = function(i) {
      return this.fields.push(i), this;
    }, r.prototype.getFields = function() {
      return this.fields;
    }, r;
  }();
  e.Builder = n, e.build = function() {
    return new n();
  };
}($2 || ($2 = {})), function(e) {
  e.Empty = { fields: [], source: [] }, e.filterOf = function(t) {
    for (var n = [], r = [], i = [], a = [], 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], m = c ? d ? a : r : d ? i : n;
        m[m.length] = u, d && !n.includes(l[0]) && (n[n.length] = l[0]);
      }
    }
    var p = i.map(function(v) {
      return v.split(".")[0];
    });
    return { includeCategory: function(v) {
      return !r.includes(v) && (n.length <= 0 || n.indexOf(v) !== -1);
    }, includeField: function(v, f) {
      var y = v + "." + f;
      return !a.includes(y) && (!p.includes(v) || i.includes(y));
    } };
  }, e.DefaultFilter = { includeCategory: function(t) {
    return !0;
  }, includeField: function(t, n) {
    return !0;
  } }, e.DefaultFormatter = { getFormat: function(t, n) {
  } }, e.ofTable = function(t, n) {
    return n ? { fields: P4(t._schema), source: [{ data: t, rowCount: n.length, keys: function() {
      return Om.Array(n);
    } }] } : { fields: P4(t._schema), source: [{ data: t, rowCount: t._rowCount }] };
  };
}(Qi || (Qi = {})), function(e) {
  function t(n, r, i) {
    n.startDataBlock(r);
    for (var a = function(u) {
      n.writeCategory({ name: u, instance: function() {
        return Qi.ofTable(i[u]);
      } });
    }, o = 0, s = i._tableNames; o < s.length; o++)
      a(s[o]);
  }
  e.writeDatabase = t, e.writeDatabaseCollection = function(n, r) {
    for (var i = 0, a = Object.keys(r); i < a.length; i++) {
      var o = a[i];
      t(n, o, r[o]);
    }
  };
}(ev || (ev = {}));
var sM = function() {
  function e() {
    this.builder = qt.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = Qi.DefaultFilter, this.formatter = Qi.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || Qi.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || Qi.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlockCreated = !0, qt.write(this.builder, "data_".concat((t || "").replace(/[ \n\t]/g, "").toUpperCase(), `
#
`));
  }, e.prototype.writeCategory = function(t, n, r) {
    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 (r != null && r.ignoreFilter || this.filter.includeCategory(t.name)) {
      var i = A9(t, n), a = i.instance, o = i.rowCount, s = i.source;
      o && (o === 1 ? function(u, c, l, d, m, p) {
        var v = tv(c), f = l[0], y = f.data, h = v.reduce(function(_, A) {
          return m.includeField(u.name, A.name) ? Math.max(_, A.name.length) : 0;
        }, 0);
        if (h !== 0) {
          h += u.name.length + 6;
          for (var g = f.keys().move(), x = T4(u.name, c.fields, p), C = 0; C < v.length; C++) {
            var b = v[C];
            m.includeField(u.name, b.name) && (qt.writePadRight(d, "_".concat(u.name, ".").concat(b.name), h), E4(d, y, g, b, x[C], 0) || qt.newline(d));
          }
          qt.write(d, `#
`);
        }
      }(t, a, s, this.builder, this.filter, this.formatter) : function(u, c, l, d, m, p) {
        var v = tv(c), f = m === Qi.DefaultFilter ? v : v.filter(function(D) {
          return m.includeField(u.name, D.name);
        }), y = f.length;
        if (y !== 0) {
          var h = T4(u.name, f, p);
          M4(d, "loop_");
          for (var g = 0; g < y; g++) M4(d, "_".concat(u.name, ".").concat(f[g].name));
          for (var x = 0, C = 0; C < l.length; C++) {
            var b = l[C], _ = b.data;
            if (b.rowCount !== 0) for (var A = b.keys(); A.hasNext; ) {
              for (var I = A.move(), w = !1, E = 0; E < y; E++) w = E4(d, _, I, f[E], h[E], x);
              w || qt.newline(d), x++;
            }
          }
          qt.write(d, `#
`);
        }
      }(t, a, s, this.builder, this.filter, this.formatter));
    }
  }, e.prototype.encode = function() {
    this.encoded = !0;
  }, e.prototype.writeTo = function(t) {
    for (var n = qt.getChunks(this.builder), r = 0, i = n.length; r < i; r++) t.writeString(n[r]);
  }, e.prototype.getSize = function() {
    return qt.getSize(this.builder);
  }, e.prototype.getData = function() {
    return qt.getString(this.builder);
  }, e;
}();
function E4(e, t, n, r, i, a) {
  var o, s = r.valueKind, u = s ? s(n, t) : 0;
  if (u !== 0) u === 1 ? function(d) {
    qt.writeSafe(d, ". ");
  }(e) : function(d) {
    qt.writeSafe(d, "? ");
  }(e);
  else {
    var c = r.value(n, t, a), l = r.type;
    if (l === 0) return typeof (o = c) == "string" && o.indexOf(`
`) >= 0 ? (c1(e, c), !0) : function(d, m) {
      if (!m) return qt.writeSafe(d, ". "), !1;
      for (var p = m.charCodeAt(0), v = !1, f = 0, y = !1, h = !1, g = 0, x = m.length - 1; g <= x; g++)
        switch (m.charCodeAt(g)) {
          case 9:
          case 32:
            v = !0;
            break;
          case 10:
            return c1(d, m), !0;
          case 34:
            if (g && g === x) break;
            if (y) return c1(d, m), !0;
            h = !0, v = !0, f = 0;
            break;
          case 39:
            if (g && g === x) break;
            if (h) return c1(d, m), !0;
            y = !0, v = !0, f = 1;
        }
      return v || p !== 35 && p !== 36 && p !== 59 && p !== 91 && p !== 93 && p !== 95 || (v = !0), v ? (qt.writeSafe(d, f ? '"' : "'"), qt.writeSafe(d, m), qt.writeSafe(d, f ? '" ' : "' ")) : (qt.writeSafe(d, m), qt.writeSafe(d, " ")), !1;
    }(e, c);
    l === 1 ? function(d, m) {
      qt.writeInteger(d, m), qt.whitespace1(d);
    }(e, c) : function(d, m, p) {
      qt.writeFloat(d, m, p), qt.whitespace1(d);
    }(e, c, i);
  }
  return !1;
}
function T4(e, t, n) {
  for (var r, i = [], a = 0, o = t; a < o.length; a++) {
    var s = o[a], u = n.getFormat(e, s.name);
    u && u.digitCount !== void 0 ? i[i.length] = s.type === 2 ? Math.pow(10, Math.max(0, Math.min(u.digitCount, 15))) : 0 : i[i.length] = s.type === 2 ? Math.pow(10, (r = s).defaultFormat && r.defaultFormat.digitCount !== void 0 ? Math.max(0, Math.min(r.defaultFormat.digitCount, 16)) : 6) : 0;
  }
  return i;
}
function M4(e, t) {
  qt.write(e, t), qt.newline(e);
}
function c1(e, t) {
  qt.writeSafe(e, `
;` + t), qt.writeSafe(e, `
;
`);
}
function uM(e) {
  var t = new ArrayBuffer(ym(e)), n = new DataView(t), r = new Uint8Array(t);
  return bm(e, n, r, 0), r;
}
function ym(e) {
  var t = typeof e;
  if (t === "string") {
    var n = F7(e);
    if (n < 32) return 1 + n;
    if (n < 256) return 2 + n;
    if (n < 65536) return 3 + n;
    if (n < 4294967296) return 5 + n;
  }
  if (e instanceof Uint8Array) {
    var r = e.byteLength;
    if (r < 256) return 2 + r;
    if (r < 65536) return 3 + r;
    if (r < 4294967296) return 5 + r;
  }
  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 i, a = 0;
    if (Array.isArray(e)) {
      i = e.length;
      for (var o = 0; o < i; o++) a += ym(e[o]);
    } else {
      var s = Object.keys(e);
      for (i = s.length, o = 0; o < i; o++) {
        var u = s[o];
        a += ym(u) + ym(e[u]);
      }
    }
    if (i < 16) return 1 + a;
    if (i < 65536) return 3 + a;
    if (i < 4294967296) return 5 + a;
    throw new Error("Array or object too long 0x" + i.toString(16));
  }
  throw new Error("Unknown type " + t);
}
function bm(e, t, n, r) {
  var i = typeof e;
  if (i === "string") {
    var a = F7(e);
    if (a < 32) return t.setUint8(r, 160 | a), r1(n, r + 1, e), 1 + a;
    if (a < 256) return t.setUint8(r, 217), t.setUint8(r + 1, a), r1(n, r + 2, e), 2 + a;
    if (a < 65536) return t.setUint8(r, 218), t.setUint16(r + 1, a), r1(n, r + 3, e), 3 + a;
    if (a < 4294967296) return t.setUint8(r, 219), t.setUint32(r + 1, a), r1(n, r + 5, e), 5 + a;
  }
  if (e instanceof Uint8Array) {
    var o = e.byteLength, s = new Uint8Array(t.buffer);
    if (o < 256) return t.setUint8(r, 196), t.setUint8(r + 1, o), s.set(e, r + 2), 2 + o;
    if (o < 65536) return t.setUint8(r, 197), t.setUint16(r + 1, o), s.set(e, r + 3), 3 + o;
    if (o < 4294967296) return t.setUint8(r, 198), t.setUint32(r + 1, o), s.set(e, r + 5), 5 + o;
  }
  if (i === "number") {
    if (!isFinite(e)) throw new Error("Number not finite: " + e);
    if (Math.floor(e) !== e) return t.setUint8(r, 203), t.setFloat64(r + 1, e), 9;
    if (e >= 0) {
      if (e < 128) return t.setUint8(r, e), 1;
      if (e < 256) return t.setUint8(r, 204), t.setUint8(r + 1, e), 2;
      if (e < 65536) return t.setUint8(r, 205), t.setUint16(r + 1, e), 3;
      if (e < 4294967296) return t.setUint8(r, 206), t.setUint32(r + 1, e), 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32) return t.setInt8(r, e), 1;
    if (e >= -128) return t.setUint8(r, 208), t.setInt8(r + 1, e), 2;
    if (e >= -32768) return t.setUint8(r, 209), t.setInt16(r + 1, e), 3;
    if (e >= -2147483648) return t.setUint8(r, 210), t.setInt32(r + 1, e), 5;
    throw new Error("Number too small -0x" + (-e).toString(16).substr(1));
  }
  if (e == null) return t.setUint8(r, 192), 1;
  if (i === "boolean") return t.setUint8(r, e ? 195 : 194), 1;
  if (i === "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(r, u | (l ? 144 : 128)), c = 1) : u < 65536 ? (t.setUint8(r, l ? 220 : 222), t.setUint16(r + 1, u), c = 3) : u < 4294967296 && (t.setUint8(r, l ? 221 : 223), t.setUint32(r + 1, u), c = 5), l) for (var m = 0; m < u; m++) c += bm(e[m], t, n, r + c);
    else {
      m = 0;
      for (var p = d.length; m < p; m++) {
        var v = d[m];
        c += bm(v, t, n, r + c), c += bm(e[v], t, n, r + c);
      }
    }
    return c;
  }
  throw new Error("Unknown type " + i);
}
var Ar, vf, Do, cM = function() {
  function e(t, n, r) {
    this.autoClassify = r, this.dataBlocks = [], this.filter = Qi.DefaultFilter, this.formatter = Qi.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = n, this.data = { encoder: t, version: "0.3.0", dataBlocks: this.dataBlocks };
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || Qi.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || Qi.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlocks.push({ header: (t || "").replace(/[ \n\t]/g, "").toUpperCase(), categories: [] });
  }, e.prototype.writeCategory = function(t, n, r) {
    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 (r != null && r.ignoreFilter || this.filter.includeCategory(t.name)) {
      var i = A9(t, n), a = i.instance, o = i.rowCount, s = i.source;
      if (o) {
        for (var u = { name: "_" + t.name, columns: [], rowCount: o }, c = 0, l = tv(a); c < l.length; c++) {
          var d = l[c];
          if (this.filter.includeField(t.name, d.name)) {
            var m = this.formatter.getFormat(t.name, d.name);
            u.columns.push(dM(t.name, d, s, o, m, this.binaryEncodingProvider, this.autoClassify));
          }
        }
        u.columns.length && this.dataBlocks[this.dataBlocks.length - 1].categories.push(u);
      }
    }
  }, e.prototype.encode = function() {
    this.encodedData || (this.encodedData = uM(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 lM(e, t) {
  return e === 0 ? pu.by(Dt.stringArray) : e === 1 ? J2(t) : (n = t, Q2.classify(n));
  var n;
}
function dM(e, t, n, r, i, a, o) {
  var s = function(f, y, h, g) {
    for (var x = f.type === 0, C = new y(h), b = new Uint8Array(h), _ = f.valueKind, A = f.value, I = !0, w = 0, E = 0; E < g.length; E++) for (var D = g[E].data, T = g[E].keys(); T.hasNext; ) {
      var P = T.move(), M = _ ? _(P, D) : 0;
      if (M !== 0) b[w] = M, x && (C[w] = ""), I = !1;
      else {
        var R = A(P, D, w);
        typeof R != "string" || R ? b[w] = 0 : (b[w] = 1, I = !1), C[w] = R;
      }
      w++;
    }
    return { array: C, allPresent: I, mask: b };
  }(t, function(f, y) {
    return y && y.typedArray ? y.typedArray : f.defaultFormat && f.defaultFormat.typedArray ? f.defaultFormat.typedArray : f.type === 0 ? Array : f.type === 1 ? Int32Array : Float64Array;
  }(t, i), r, n), u = s.array, c = s.allPresent, l = s.mask, d = function(f, y, h, g) {
    return h && h.encoder ? h.encoder : y.defaultFormat && y.defaultFormat.encoder ? y.defaultFormat.encoder : g ? g.get(f, y.name) : void 0;
  }(e, t, i, a);
  d || (d = o ? lM(t.type, u) : function(f) {
    return f === 0 ? pu.by(Dt.stringArray) : pu.by(Dt.byteArray);
  }(t.type));
  var m = d.encode(u), p = void 0;
  if (!c) {
    var v = pu.by(Dt.runLength).and(Dt.byteArray).encode(l);
    p = v.data.length < l.length ? v : pu.by(Dt.byteArray).encode(l);
  }
  return { name: t.name, data: m, mask: p };
}
function l1(e, t, n, r, i, a) {
  for (var o = new Ui.EdgeBuilder(i, 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, r[c]), o.assignProperty(u, n[c]);
  return o.createGraph({ flags: s, order: u }, { canRemap: a });
}
(function(e) {
  e.Encoder = ev, e.Category = Qi, e.Field = $2, e.Encoding = Dt, e.createEncoder = function(r) {
    var i = r || {}, a = i.binary, o = a !== void 0 && a, s = i.encoderName;
    return o ? new cM(s === void 0 ? "mol*" : s, r ? r.binaryEncodingPovider : void 0, !!r && !!r.binaryAutoClassifyEncoding) : new sM();
  }, e.fields = function() {
    return e.Field.build();
  };
  var t = e.Encoding;
  function n(r) {
    var i = r.precision;
    if (i !== void 0) {
      var a = Math.pow(10, i), o = t.by(t.fixedPoint(a));
      switch (r.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 (r.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(r, i) {
    return { fields: r, source: [i] };
  }, e.createEncodingProviderFromCifFrame = function(r) {
    return { get: function(i, a) {
      var o = r.categories[i];
      if (o) {
        var s = o.getField(a);
        return s && s.binaryEncoding ? pu.fromEncoding(s.binaryEncoding) : void 0;
      }
    } };
  }, e.createEncodingProviderFromJsonConfig = function(r) {
    return { get: function(i, a) {
      for (var o = 0; o < r.length; o++) {
        var s = r[o];
        if (s.categoryName === i && s.columnName === a) return n(s);
      }
    } };
  };
})(Ar || (Ar = {})), function(e) {
  e.Descriptor = { name: "chem_comp_bond", cifExport: { prefix: "", categories: [{ name: "chem_comp_bond", instance: function(n) {
    var r = e.Provider.get(n.firstModel);
    if (!r) return Ar.Category.Empty;
    var i = r.data;
    if (!i) return Ar.Category.Empty;
    for (var a = n.structures[0].uniqueResidueNames, o = i.comp_id, s = i._rowCount, u = [], c = 0; c < s; c++) a.has(o.value(c)) && (u[u.length] = c);
    return Ar.Category.ofTable(i, u);
  } }] } }, e.Provider = Mo.create(e.Descriptor), e.chemCompBondFromTable = function(n, r) {
    return Jt.pick(r, wt.chem_comp_bond, function(i) {
      return n.properties.chemicalComponentMap.has(r.comp_id.value(i));
    });
  }, e.getEntriesFromChemCompBond = function(n) {
    var r = /* @__PURE__ */ new Map();
    function i(C) {
      if (r.has(C)) return r.get(C);
      var b = new t(C);
      return r.set(C, b), b;
    }
    for (var a = n.comp_id, o = n.atom_id_1, s = n.atom_id_2, u = n.value_order, c = n.pdbx_aromatic_flag, l = n._rowCount, d = i(a.value(0)), m = 0; m < l; m++) {
      var p = a.value(m), v = o.value(m), f = s.value(m), y = u.value(m), h = c.value(m) === "Y";
      d.id !== p && (d = i(p));
      var g = 1, x = 1;
      switch (h && (g |= 16), y.toLowerCase()) {
        case "delo":
          g |= 16;
          break;
        case "doub":
          x = 2;
          break;
        case "trip":
          x = 3;
          break;
        case "quad":
          x = 4;
      }
      d.add(v, f, x, g);
    }
    return r;
  };
  var t = function() {
    function n(r) {
      this.id = r, this.map = /* @__PURE__ */ new Map();
    }
    return n.prototype.add = function(r, i, a, o, s) {
      s === void 0 && (s = !0);
      var u = this.map.get(r);
      if (u !== void 0)
        u.get(i) === void 0 && u.set(i, { order: a, flags: o });
      else {
        var c = /* @__PURE__ */ new Map();
        c.set(i, { order: a, flags: o }), this.map.set(r, c);
      }
      s && this.add(i, r, a, o, !1);
    }, n;
  }();
  e.Entry = t;
}(vf || (vf = {})), function(e) {
  function t(n, r) {
    for (var i = n.units, a = 0, o = i.length; a < o; a++) if (_e.indexOf(i[a].elements, r) >= 0) return !0;
    return !1;
  }
  e.Descriptor = { name: "struct_conn", cifExport: { prefix: "", categories: [{ name: "struct_conn", instance: function(n) {
    var r = e.Provider.get(n.firstModel);
    if (!r || r.entries.length === 0) return Ar.Category.Empty;
    for (var i = n.structures[0], a = [], o = 0, s = r.entries; o < s.length; o++) {
      var u = s[o];
      t(i, u.partnerA.atomIndex) && t(i, u.partnerB.atomIndex) && (a[a.length] = u.rowIndex);
    }
    return Ar.Category.ofTable(r.data, a);
  } }] } }, e.Provider = Mo.create(e.Descriptor), e.isExhaustive = function(n) {
    var r = e.Provider.get(n);
    return !!r && r.data.id.rowCount / n.atomicConformation.atomId.rowCount > 0.95;
  }, e.getAtomIndexFromEntries = function(n) {
    for (var r = /* @__PURE__ */ new Map(), i = 0, a = n; i < a.length; i++) {
      var o = a[i], s = o.partnerA.atomIndex, u = o.partnerB.atomIndex;
      r.has(s) ? r.get(s).push(o) : r.set(s, [o]), r.has(u) ? r.get(u).push(o) : r.set(u, [o]);
    }
    return r;
  }, e.getEntriesFromStructConn = function(n, r) {
    for (var i = n.conn_type_id, a = n.pdbx_dist_value, o = n.pdbx_value_order, s = { label_asym_id: n.ptnr1_label_asym_id, label_seq_id: n.ptnr1_label_seq_id, auth_seq_id: n.ptnr1_auth_seq_id, label_atom_id: n.ptnr1_label_atom_id, label_alt_id: n.pdbx_ptnr1_label_alt_id, ins_code: n.pdbx_ptnr1_PDB_ins_code, symmetry: n.ptnr1_symmetry }, u = { label_asym_id: n.ptnr2_label_asym_id, label_seq_id: n.ptnr2_label_seq_id, auth_seq_id: n.ptnr2_auth_seq_id, label_atom_id: n.ptnr2_label_atom_id, label_alt_id: n.pdbx_ptnr2_label_alt_id, ins_code: n.pdbx_ptnr2_PDB_ins_code, symmetry: n.ptnr2_symmetry }, c = function(h, g) {
      if (g.label_asym_id.valueKind(h) === 0) {
        var x = g.label_asym_id.value(h), C = r.atomicHierarchy.index.findEntity(x);
        if (!(C < 0)) {
          var b = r.atomicHierarchy.index.findResidue(r.entities.data.id.value(C), x, g.auth_seq_id.value(h), g.ins_code.value(h));
          if (!(b < 0)) {
            var _ = g.label_atom_id.value(h);
            if (_) {
              var A = r.atomicHierarchy.index.findAtomOnResidue(b, _, g.label_alt_id.value(h));
              if (!(A < 0)) return { residueIndex: b, atomIndex: A, symmetry: g.symmetry.value(h) };
            }
          }
        }
      }
    }, l = [], d = 0; d < n._rowCount; d++) {
      var m = c(d, s), p = c(d, u);
      if (m !== void 0 && p !== void 0) {
        var v = i.value(d), f = 0, y = 1;
        switch ((o.value(d) || "").toLowerCase()) {
          case "sing":
            y = 1;
            break;
          case "doub":
            y = 2;
            break;
          case "trip":
            y = 3;
            break;
          case "quad":
            y = 4;
            break;
          default:
            y = C9(n.ptnr1_label_comp_id.value(d), n.ptnr1_label_atom_id.value(d), n.ptnr2_label_comp_id.value(d), n.ptnr2_label_atom_id.value(d));
        }
        switch (v) {
          case "covale":
            f = 1;
            break;
          case "disulf":
            f = 9;
            break;
          case "hydrog":
            f = 4;
            break;
          case "metalc":
            f = 2;
        }
        l.push({ rowIndex: d, flags: f, order: y, distance: a.value(d), partnerA: m, partnerB: p });
      }
    }
    return l;
  };
}(Do || (Do = {}));
var D4 = S(), B4 = S();
function fM(e, t, n) {
  return e.conformation.position(t, D4), e.conformation.position(n, B4), S.distance(D4, B4);
}
var mM = /* @__PURE__ */ new Set();
function pM(e, t) {
  var n = B(B({}, b9), t);
  return n.noCompute || pn.isCoarseGrained(e.model) ? W2.Empty : pn.isMaterial(e.model) && (n.isMaterial = !0, gr.Provider.get(e.model)) ? function(r) {
    var i = gr.Provider.get(r.model);
    return i ? l1(Array.from(i.bonds.a || []), Array.from(i.bonds.b || []), Array.from(i.bonds.edgeProps.order || []), Array.from(i.bonds.edgeProps.flag || []), i.bonds.vertexCount, !1) : l1([], [], [], [], 0, !1);
  }(e) : !n.forceCompute && gr.Provider.get(e.model) ? function(r) {
    for (var i = gr.Provider.get(r.model), a = r.elements, o = r.model.atomicHierarchy.atoms.type_symbol, s = r.elements.length, u = i.bonds, c = u.offset, l = u.b, d = u.edgeProps, m = d.order, p = d.distance, v = d.flag, f = r.model.atomicHierarchy.atomSourceIndex, y = pn.getInvertedAtomSourceIndex(r.model).invertedIndex, h = [], g = [], x = [], C = [], b = 0; b < s; b++) for (var _ = a[b], A = fu(o.value(_)), I = mu(A), w = f.value(_), E = c[w], D = c[w + 1]; E < D; ++E) {
      var T = y[l[E]];
      if (!(_ >= T)) {
        var P = _e.indexOf(r.elements, T);
        if (!(P < 0)) {
          var M = fu(o.value(T)), R = p[E], O = fM(r, _, T), L = !1;
          r.model.sourceData.kind === "mol" || r.model.sourceData.kind === "sdf" || r.model.sourceData.kind === "mol2" ? L = !0 : R >= 0 ? L = On(O, R, 0.3) : A === -1 || M === -1 ? L = !0 : I && mu(M) && (L = !1), L && (h[h.length] = b, g[g.length] = P, C[C.length] = m[E], x[x.length] = v[E]);
        }
      }
    }
    return l1(h, g, C, x, s, !1);
  }(e) : function(r, i) {
    for (var a = i.maxRadius, o = i.isMaterial, s = r.model.atomicConformation, u = s.x, c = s.y, l = s.z, d = r.elements.length, m = r.elements, p = r.residueIndex, v = r.chainIndex, f = r.model.atomicHierarchy.atoms, y = f.type_symbol, h = f.label_atom_id, g = f.label_alt_id, x = f.label_comp_id, C = r.model.atomicHierarchy.residues.label_seq_id, b = r.model.atomicHierarchy.index, _ = r.model.sequence.byEntityKey, A = r.lookup3d, I = Do.Provider.get(r.model), w = vf.Provider.get(r.model), E = Do.isExhaustive(r.model), D = [], T = [], P = [], M = [], R = -1, O = void 0, L = !0, F = !0, G = !0, V = mM, U = 0; U < d; U++) {
      var q = m[U], H = y.value(q);
      L && H !== "H" && H !== "O" && (L = !1);
      var K = i.forceCompute ? void 0 : I && I.byAtomIndex.get(q), j = !1;
      if (K) for (var W = 0, Z = K; W < Z.length; W++) {
        var Y = Z[W], te = Y.partnerA, ee = Y.partnerB;
        if (te.symmetry === ee.symmetry) {
          var $ = te.atomIndex === q ? ee : te;
          (Re = _e.indexOf(r.elements, $.atomIndex)) < 0 || m[Re] < q || (D[D.length] = U, T[T.length] = Re, P[P.length] = Y.flags, M[M.length] = Y.order, j || V.clear(), j = !0, V.add(Re));
        }
      }
      if (!E) {
        var ue = p[q], se = C.value(ue), be = x.value(q);
        if (!i.forceCompute && ue !== R) if (w && w.entries.has(be)) {
          var ke = _[b.getEntityFromChain(v[q])];
          O = ke && ke.sequence.microHet.has(se) ? void 0 : w.entries.get(be).map;
        } else O = void 0;
        R = ue;
        for (var Oe = fu(H), ze = h.value(q), je = O ? O.get(ze) : void 0, xe = A.find(u[q], c[q], l[q], a), Xe = xe.indices, Ee = xe.count, Ye = xe.squaredDistances, He = mu(Oe), le = gl(Oe), Ce = g.value(q), Ae = Hm.has(Oe), Te = 0; Te < Ee; Te++) {
          var Re = Xe[Te];
          if (!j || !V.has(Re)) {
            var we = m[Re];
            if (!(we <= q)) {
              var Qe = g.value(we);
              if (!Ce || !Qe || Ce === Qe) {
                var Je = fu(y.value(we)), lt = mu(Je);
                if (!He || !lt) {
                  var st = (Ae || Hm.has(Je)) && !(He || lt), ft = p[we];
                  if (ue === ft && je) {
                    var It = je.get(h.value(we));
                    if (It) {
                      D[D.length] = U, T[T.length] = Re, M[M.length] = It.order;
                      var pe = It.flags;
                      st && (o ? pe = 33 : (1 | pe && (pe ^= 1), pe |= 2)), P[P.length] = pe;
                    }
                  } else {
                    var We = Math.sqrt(Ye[Te]);
                    if (We !== 0 && We <= Z2(Oe, Je, le, gl(Je), o)) {
                      D[D.length] = U, T[T.length] = Re, M[M.length] = eM(be, ze, h.value(we)), P[P.length] = 32 | (st && !o ? 2 : 1);
                      var gt = C.value(ft);
                      se === gt && (F = !1), Math.abs(se - gt) > 1 && (G = !1);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    return l1(D, T, M, P, d, L || F && G);
  }(e, n);
}
var R4 = S(), k4 = S();
function O4(e, t, n, r) {
  return e.conformation.position(t, R4), n.conformation.position(r, k4), S.distance(R4, k4);
}
var hM = J(), Ou = S(), rt, vM = B(B({}, b9), { ignoreWater: !0, ignoreIon: !0 });
function gM(e, t) {
  var n = new Sc.Builder(), r = e.models.some(function(i) {
    return gr.Provider.get(i);
  });
  return t.noCompute || e.isCoarseGrained && !r || Be.eachUnitPair(e, function(i, a) {
    (function(o, s, u, c) {
      var l = u.maxRadius, d = o.elements, m = o.residueIndex, p = o.model.atomicConformation, v = p.x, f = p.y, y = p.z, h = s.elements, g = s.residueIndex, x = o.elements.length, C = o.model.atomicHierarchy.atoms, b = C.type_symbol, _ = C.label_alt_id, A = C.label_atom_id, I = C.label_comp_id, w = s.model.atomicHierarchy.atoms, E = w.type_symbol, D = w.label_alt_id, T = w.label_atom_id, P = w.label_comp_id, M = o.model.atomicHierarchy.residues.auth_seq_id, R = s.model.atomicHierarchy.residues.auth_seq_id, O = o.model.atomicConformation.occupancy, L = s.model.atomicConformation.occupancy, F = O.isDefined && L.isDefined, G = o.model === s.model && Do.Provider.get(o.model), V = !u.forceCompute && o.model === s.model && gr.Provider.get(o.model), U = o.model.atomicHierarchy.atomSourceIndex, q = (V ? pn.getInvertedAtomSourceIndex(s.model) : { invertedIndex: void 0 }).invertedIndex, H = o.model === s.model && Do.isExhaustive(o.model), K = J.mul(hM, s.conformation.operator.inverse, o.conformation.operator.matrix), j = !J.isIdentity(K), W = s.boundary.sphere, Z = W.center, Y = W.radius, te = (Y + l) * (Y + l);
      c.startUnitPair(o.id, s.id);
      for (var ee = 0; ee < x; ee++) {
        var $ = d[ee];
        if (S.set(Ou, v[$], f[$], y[$]), j && S.transformMat4(Ou, Ou, K), !(S.squaredDistance(Ou, Z) > te)) if (u.forceCompute || !V) {
          var ue = u.forceCompute ? void 0 : G && G.byAtomIndex.get($);
          if (ue && ue.length) {
            for (var se = !1, be = 0, ke = ue; be < ke.length; be++) {
              var Oe = ke[be], ze = Oe.partnerA, je = Oe.partnerB, xe = ze.atomIndex === $ ? je : ze;
              (En = _e.indexOf(s.elements, xe.atomIndex)) < 0 || O4(o, $, s, xe.atomIndex) > l || (c.add(ee, En, { order: Oe.order, flag: Oe.flags }), se = !0);
            }
            if (se) continue;
          }
          if (!H) {
            var Xe = O.value($), Ee = s.lookup3d.find(Ou[0], Ou[1], Ou[2], l), Ye = Ee.indices, He = Ee.count, le = Ee.squaredDistances;
            if (He !== 0) for (var Ce = fu(b.value($)), Ae = mu(Ce), Te = gl(Ce), Re = _.value($), we = Hm.has(Ce), Qe = A.value($), Je = I.value(m[$]), lt = 0; lt < He; lt++) {
              Tn = h[En = Ye[lt]];
              var st = D.value(Tn);
              if (!(Re && st && Re !== st || F && L.value(Tn) < 1 && Xe < 1 && M.value($) === R.value(Tn))) {
                var ft = mu(Hr = fu(E.value(Tn)));
                if (!Ae || !ft) {
                  var It = (we || Hm.has(Hr)) && !(Ae || ft);
                  if (!It && (qn = Math.sqrt(le[lt])) !== 0 && qn <= Z2(Ce, Hr, Te, gl(Hr))) {
                    var pe = T.value(Tn), We = P.value(g[Tn]);
                    c.add(ee, En, { order: C9(Je, We, Qe, pe), flag: 32 | (It ? 2 : 1) });
                  }
                }
              }
            }
          }
        } else for (var gt = V.maxDistance, cn = V.bonds, Kt = cn.offset, hn = cn.b, jt = cn.edgeProps, Rn = jt.order, ur = jt.distance, ir = jt.flag, Hn = U.value($), Dn = Kt[Hn], Dr = Kt[Hn + 1]; Dn < Dr; ++Dn) {
          var En, Tn = q[hn[Dn]];
          if (!((En = _e.indexOf(s.elements, Tn)) < 0)) {
            var mi = fu(b.value($)), Hr = fu(b.value(Tn)), Vo = ur[Dn], qn = O4(o, $, s, Tn), kn = !1;
            Vo >= 0 ? kn = On(qn, Vo, 0.3) : gt >= 0 ? kn = qn < gt : (kn = qn < Z2(mi, Hr, gl(mi), gl(Hr)), mu(mi) && mu(Hr) && (kn = !1)), kn && c.add(ee, En, { order: Rn[Dn], flag: ir[Dn] });
          }
        }
      }
      c.finishUnitPair();
    })(i, a, t, n);
  }, { maxRadius: t.maxRadius, validUnit: function(i) {
    return me.isAtomic(i);
  }, validUnitPair: function(i, a) {
    return t.validUnitPair(e, i, a);
  } }), new Um(n.getMap());
}
function yM(e, t) {
  var n = B(B({}, vM), t);
  return gM(e, B(B({}, n), { validUnitPair: t && t.validUnitPair || function(r, i, a) {
    var o = i.model.atomicHierarchy.derived.residue.moleculeType, s = a.model.atomicHierarchy.derived.residue.moleculeType, u = !(me.isAtomic(i) && o[i.residueIndex[i.elements[0]]] === 2 || me.isAtomic(a) && s[a.residueIndex[a.elements[0]]] === 2), c = i.model === a.model, l = !me.isAtomic(i) || o[i.residueIndex[i.elements[0]]] !== 3 || c && N4(i), d = !me.isAtomic(a) || s[a.residueIndex[a.elements[0]]] !== 3 || c && N4(a), m = l && d;
    return Be.validUnitPair(r, i, a) && (u || !n.ignoreWater) && (m || !n.ignoreIon);
  } }));
}
function N4(e) {
  if (!me.isAtomic(e)) return !1;
  var t = e.elements, n = Do.Provider.get(e.model);
  if (n) {
    for (var r = 0, i = t.length; r < i; r++) if (n.byAtomIndex.get(t[r])) return !0;
  }
  return !1;
}
function bM(e) {
  for (var t = function(a) {
    for (var o = St.transientSegments(a.model.atomicHierarchy.residueAtomSegments, a.elements), s = 0; o.hasNext; ) {
      var u = o.move();
      s = Math.max(s, u.end - u.start);
    }
    return s;
  }(e), n = function(a, 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: a, bonds: a.bonds, altLoc: a.model.atomicHierarchy.atoms.label_alt_id };
  }(e, t), r = St.transientSegments(e.model.atomicHierarchy.residueAtomSegments, e.elements); r.hasNext; ) {
    var i = r.move();
    _M(n, i.start, i.end);
  }
  return n.rings;
}
function L4(e) {
  e.count = e.endVertex - e.startVertex;
  for (var t = e.isRingAtom, n = e.pred, r = e.color, i = e.depth, a = e.marked, o = 0; o < e.count; o++) t[o] = 0, n[o] = -1, a[o] = -1, r[o] = 0, i[o] = 0;
  e.currentColor = 0, e.currentAltLoc = "", e.hasAltLoc = !1;
}
function F4(e) {
  for (var t = e.depth, n = 0; n < e.count; n++) t[n] = e.count + 1;
}
function G4(e, t) {
  var n = e.bonds.offset, r = e.startVertex + t, i = n[r], a = n[r + 1] - i;
  return !(a <= 1 || e.isRingAtom[t] && a === 2);
}
function _M(e, t, n) {
  if (e.startVertex = t, e.endVertex = n, !(e.endVertex - e.startVertex < 3)) {
    e.currentRings = [];
    for (var r = e.unit.elements, i = [], a = e.startVertex; a < e.endVertex; a++)
      Ca(i, u = e.altLoc.value(r[a]));
    gm(i, "");
    var o = 1;
    if (i.length === 0)
      for (L4(e), a = 0; a < e.count; a++) G4(e, a) && (F4(e), o = V4(e, a, o));
    else for (var s = 0; s < i.length; s++)
      for (L4(e), e.hasAltLoc = !0, e.currentAltLoc = i[s], a = 0; a < e.count; a++) {
        var u;
        G4(e, a) && ((u = e.altLoc.value(r[e.startVertex + a])) && u !== e.currentAltLoc || (F4(e), o = V4(e, a, o)));
      }
    a = 0;
    for (var c = e.currentRings.length; a < c; a++) e.rings.push(e.currentRings[a]);
  }
}
function xM(e, t, n, r) {
  if (n < t) return !1;
  for (var i = e.pred, a = e.color, o = e.left, s = e.right, u = ++e.currentColor, c = t, l = 0; l < 5 && (a[c] = u, !((c = i[c]) < 0)); l++) ;
  var d = 0, m = 0, p = !1, v = 0;
  for (c = n, l = 0; l < 5; l++) {
    if (a[c] === u) {
      v = c, p = !0;
      break;
    }
    if (s[m++] = c, (c = i[c]) < 0) break;
  }
  if (!p) return !1;
  for (c = t, l = 0; l < 5 && (o[d++] = c, v !== c) && !((c = i[c]) < 0); l++) ;
  var f = d + m;
  if (f < 3) return !1;
  var y = new Int32Array(f), h = 0;
  for (l = 0; l < d; l++) y[h++] = e.startVertex + o[l], r[o[l]] = 1;
  for (l = m - 1; l >= 0; l--) y[h++] = e.startVertex + s[l], r[s[l]] = 1;
  to(y);
  for (var g = 0, x = e.currentRings.length; g < x; g++) {
    var C = e.currentRings[g];
    if (y.length === C.length) {
      if (_e.areEqual(y, C)) return !1;
    } else if (y.length > C.length && _e.isSubset(y, C)) return !1;
  }
  return e.currentRings.push(_e.ofSortedArray(y)), !0;
}
function V4(e, t, n) {
  var r = e.bonds, i = e.startVertex, a = e.endVertex, o = e.isRingAtom, s = e.marked, u = e.queue, c = e.pred, l = e.depth, d = e.unit.elements, m = r.b, p = r.edgeProps.flags, v = r.offset;
  s[t] = n, l[t] = 0, u[0] = t;
  for (var f = 0, y = 1; f < y; ) for (var h = u[f++], g = l[h], x = i + h, C = v[x], b = v[x + 1], _ = C; _ < b; _++) {
    var A = m[_];
    if (!(A < i || A >= a) && Bt.isCovalent(p[_])) {
      if (e.hasAltLoc) {
        var I = e.altLoc.value(d[A]);
        if (I && e.currentAltLoc !== I) continue;
      }
      var w = A - i;
      if (s[w] !== n) {
        var E = Math.min(l[w], g + 1);
        E > 5 || (l[w] = E, s[w] = n, u[y++] = w, c[w] = h);
      } else if (c[w] !== h && c[h] !== w && xM(e, h, w, o)) return n + 1;
    }
  }
  return n + 1;
}
function z4(e) {
  for (var t = e.length, n = new Int32Array(2 * t), r = 0; r < n.length; r++) n[r] = -1;
  for (var i = "", a = "", o = 0, s = 1; s < n.length; s++) {
    for (r = n[s - o - 1]; r !== -1 && (i = e[s % t]) !== (a = e[(o + r + 1) % t]); ) i < a && (o = s - r - 1), r = n[r];
    r === -1 && (i = e[s % t]) !== (a = e[(o + r + 1) % t]) ? (i < a && (o = s), n[s - o] = -1) : n[s - o] = r + 1;
  }
  return o;
}
function U4(e, t) {
  var n, r = e.length, i = [];
  for (n = 0; n < r - 1; n++) i.push(e[(n + t) % r]), i.push("-");
  return i.push(e[(n + t) % r]), i.join("");
}
function I9(e, t) {
  switch (e.kind) {
    case 0:
      return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[t]];
    case 1:
    case 2:
      var n = function(i, a) {
        var o = i.coarseElements.entityKey[a], s = i.model.sequence.byEntityKey[o].sequence, u = i.coarseElements.seq_id_begin.value(a);
        return s.compId.value(u - 1);
      }(e, t), r = e.model.properties.chemicalComponentMap.get(n);
      if (r) return Ff(r.type, n);
  }
  return 0;
}
(function(e) {
  function t(a, o, s, u, c, l) {
    return { kind: "bond-location", aStructure: a, aUnit: o, aIndex: s, bStructure: u, bUnit: c, bIndex: l };
  }
  function n(a, o) {
    return a.aStructure.label === o.aStructure.label && a.bStructure.label === o.bStructure.label && a.aIndex === o.aIndex && a.bIndex === o.bIndex && a.aUnit.id === o.aUnit.id && a.bUnit.id === o.bUnit.id;
  }
  function r(a, o) {
    return { kind: "bond-loci", structure: a, bonds: o };
  }
  e.Location = t, e.isLocation = function(a) {
    return !!a && a.kind === "bond-location";
  }, e.areLocationsEqual = n, e.Loci = r, e.isLoci = function(a) {
    return !!a && a.kind === "bond-loci";
  }, e.areLociEqual = function(a, o) {
    if (a.structure !== o.structure || a.bonds.length !== o.bonds.length) return !1;
    for (var s = 0, u = a.bonds.length; s < u; ++s) if (!n(a.bonds[s], o.bonds[s])) return !1;
    return !0;
  }, e.isLociEmpty = function(a) {
    return a.bonds.length === 0;
  }, e.remapLoci = function(a, o) {
    if (o === a.structure) return a;
    var s = [];
    return a.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], m = _e.indexOf(c.elements, d);
          if (m !== -1) {
            var p = u.bUnit.elements[u.bIndex], v = _e.indexOf(l.elements, p);
            v !== -1 && s.push(t(a.structure, c, m, a.structure, l, v));
          }
        }
      }
    }), r(o, s);
  }, e.toStructureElementLoci = function(a) {
    for (var o = [], s = /* @__PURE__ */ new Map(), u = 0, c = a.bonds; u < c.length; u++) {
      var l = c[u], d = l.aIndex, m = l.aUnit, p = l.bIndex, v = l.bUnit;
      m === v ? s.has(m.id) ? s.get(m.id).push(d, p) : s.set(m.id, [d, p]) : (s.has(m.id) ? s.get(m.id).push(d) : s.set(m.id, [d]), s.has(v.id) ? s.get(v.id).push(p) : s.set(v.id, [p]));
    }
    return s.forEach(function(f, y) {
      o.push({ unit: a.structure.unitMap.get(y), indices: _e.deduplicate(_e.ofUnsortedArray(f)) });
    }), Se(a.structure, o);
  }, e.toFirstStructureElementLoci = function(a) {
    var o = a.bonds[0], s = o.aUnit, u = o.aIndex;
    return Se(a.structure, [{ unit: s, indices: ve.ofSingleton(u) }]);
  }, e.getType = function(a, o) {
    if (o.aUnit === o.bUnit) {
      var s = o.aUnit.bonds, u = s.getEdgeIndex(o.aIndex, o.bIndex);
      return u < 0 ? Bt.create(0) : Bt.create(s.edgeProps.flags[u]);
    }
    var c = a.interUnitBonds.getBondFromLocation(o);
    return c ? Bt.create(c.props.flag) : Bt.create(0);
  }, e.getOrder = function(a, 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 = a.interUnitBonds.getBondFromLocation(o);
    return c ? c.props.order : 0;
  }, e.getIntraUnitBondCount = function(a) {
    for (var o = 0, s = 0, u = a.units.length; s < u; ++s) {
      var c = a.units[s];
      me.isAtomic(c) && (o += c.bonds.edgeCount);
    }
    return o;
  };
  var i = function() {
    function a() {
      this.current = {}, this.hasNext = !1;
    }
    return a.prototype.move = function() {
      return this.advance(), this.current;
    }, a.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;
    }, a.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;
    }, a;
  }();
  e.ElementBondIterator = i, e.getBoundingSphere = function(a, o) {
    return Ml.fromPairProvider(a.bonds.length, function(s, u, c) {
      var l = a.bonds[s], d = l.aUnit, m = l.aIndex, p = l.bUnit, v = l.bIndex;
      d.conformation.position(d.elements[m], u), p.conformation.position(p.elements[v], c);
    }, o);
  };
})(rt || (rt = {}));
var SM = /* @__PURE__ */ new Set();
function hu(e, t) {
  var n = LT[e];
  if (n !== void 0) {
    var r = n[t];
    if (r !== void 0) return r;
  }
  return SM;
}
var H4 = S.zero();
function w9(e, t) {
  for (var n = e.conformation.position, r = new Float32Array(3 * t.length), i = e.elements, a = 0, o = t.length; a < o; ++a) n(i[t[a]], H4), S.toArray(H4, r, 3 * a);
  return r;
}
var Ea, dn, jm = function() {
  function e(t, n) {
    this.unit = n, this.all = t;
  }
  return Object.defineProperty(e.prototype, "index", { get: function() {
    return this._index || (this._index = function(t, n) {
      for (var r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0, o = t.length; a < o; a++) for (var s = 0, u = (p = t[a]).length; s < u; s++) {
        var c = p[s];
        r.has(c) ? r.get(c).push(a) : r.set(c, [a]);
      }
      for (var l = 0, d = n.length; l < d; l++) for (s = 0, u = (p = t[a = n[l]]).length; s < u; s++) c = p[s], i.has(c) ? i.get(c).push(a) : i.set(c, [a]);
      var m = new Ui.UniqueEdgeBuilder(t.length);
      for (a = 0, o = t.length; a < o; a++) {
        var p;
        for (s = 0, u = (p = t[a]).length; s < u; s++) {
          c = p[s];
          var v = r.get(c);
          if (v.length !== 1) for (var f = 0, y = v.length; f < y; f++) {
            var h = v[f];
            a >= h || m.addEdge(a, h);
          }
        }
      }
      var g = Ui.connectedComponents(m.getGraph()), x = g.componentIndex, C = [];
      for (s = 0; s < g.componentCount; s++) C[s] = [];
      for (a = 0, o = t.length; a < o; a++) C[x[a]].push(a);
      return { elementRingIndices: r, elementAromaticRingIndices: i, ringComponentIndex: x, ringComponents: C };
    }(this.all, this.aromaticRings)), this._index;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "byFingerprint", { get: function() {
    return this._byFingerprint || (this._byFingerprint = function(t, n) {
      for (var r = /* @__PURE__ */ new Map(), i = 0, a = 0, o = n.length; a < o; a++) {
        var s = n[a], u = Ea.fingerprint(t, s);
        r.has(u) ? r.get(u).push(i) : r.set(u, [i]), i++;
      }
      return r;
    }(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, n) {
      for (var r = [], i = 0, a = n.length; i < a; ++i) Ea.isAromatic(t, n[i]) && r.push(i);
      return r;
    }(this.unit, this.all)), this._aromaticRings;
  }, enumerable: !1, configurable: !0 }), e;
}();
function CM(e, t) {
  for (var n = e.elements, r = e.model.atomicHierarchy.residueAtomSegments.index, i = r[n[t[0]]], a = 1, o = t.length; a < o; a++) if (i !== r[n[t[a]]]) return -1;
  return i;
}
function AM(e, t, n) {
  var r = e.byFingerprint.get(t);
  if (r) for (var i = 0, a = r.length; i < a; i++) {
    var o = r[i], s = CM(e.unit, e.all[o]);
    s >= 0 && (n.has(s) ? n.get(s).push(o) : n.set(s, [o]));
  }
}
function IM(e) {
  for (var t = [], n = e.elements, r = e.model.coarseHierarchy, i = r.spheres, a = r.gaussians, o = me.isSpheres(e) ? i.polymerRanges : a.polymerRanges, s = dn.transientSegments(o, n); s.hasNext; ) for (var u = s.move(), c = u.start, l = u.end, d = c; d < l; ++d) t.push(n[d]);
  return _e.ofSortedArray(t);
}
function wM(e) {
  for (var t = [], n = e.elements, r = e.model.coarseHierarchy, i = r.spheres, a = r.gaussians, o = me.isSpheres(e) ? i.gapRanges : a.gapRanges, s = dn.transientSegments(o, n); s.hasNext; ) {
    var u = s.move(), c = u.start, l = u.end;
    t.push(n[c], n[l - 1]);
  }
  return _e.ofSortedArray(t);
}
(function(e) {
  function t(r) {
    return function(i) {
      for (var a = i.length, o = new Array(a), s = 0; s < a; s++) o[s] = i[a - s - 1];
      var u = z4(i), c = z4(o), l = !1;
      for (s = 0; s < a; s++) {
        var d = i[(s + u) % a], m = o[(s + c) % a];
        if (d !== m) {
          l = d < m;
          break;
        }
      }
      return l ? U4(i, u) : U4(o, c);
    }(r);
  }
  e.fingerprint = function(r, i) {
    for (var a = r.elements, o = r.model.atomicHierarchy.atoms.type_symbol, s = [], u = 0, c = i.length; u < c; u++) s[s.length] = o.value(a[i[u]]);
    return t(s);
  }, e.elementFingerprint = t;
  var n = /* @__PURE__ */ new Set(["B", "C", "N", "O", "SI", "P", "S", "GE", "AS", "SN", "SB", "BI"]);
  e.isAromatic = function(r, i) {
    var a = r.elements, o = r.bonds, s = o.b, u = o.offset, c = o.edgeProps.flags, l = r.model.atomicHierarchy.atoms, d = l.type_symbol;
    if (l.label_comp_id.value(r.elements[i[0]]) === "PRO") return !1;
    for (var m = 0, p = !1, v = 0, f = i.length; v < f; ++v) {
      var y = i[v];
      !p && n.has(d.value(a[y])) && (p = !0);
      for (var h = u[y], g = u[y + 1]; h < g; ++h) Bt.is(16, c[h]) && _e.has(i, s[h]) && (m += 1);
    }
    if (m === 2 * i.length) return !0;
    if (!p || i.length < 5) return !1;
    var x = _u.calculateMomentsAxes(w9(r, i));
    return S.magnitude(x.dirC) < 0.05;
  }, e.getAltId = function(r, i) {
    for (var a = r.model.atomicHierarchy.atoms.label_alt_id, o = r.elements, s = 0, u = i.length; s < u; ++s) {
      var c = o[i[s]], l = a.value(c);
      if (l) return l;
    }
    return "";
  };
})(Ea || (Ea = {})), function(e) {
  e.create = function(t) {
    var n = bM(t);
    return new e(n, t);
  }, e.byFingerprintAndResidue = function(t, n) {
    for (var r = /* @__PURE__ */ new Map(), i = 0, a = n.length; i < a; i++)
      AM(t, n[i], r);
    return r;
  };
}(jm || (jm = {})), function(e) {
  function t(l) {
    return l[l.length - 1];
  }
  function n(l) {
    return l.length / 2;
  }
  function r(l, d) {
    return l[2 * d];
  }
  function i(l, d) {
    return l[2 * d + 1] + 1;
  }
  function a(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, m) {
    if (a(l, m) > ve.max(d) || t(l) < ve.min(d)) return -1;
    for (var p = m, v = n(l); p < v; ++p) {
      var f = oe.ofRange(a(l, p), o(l, p));
      if (ve.areIntersecting(f, d)) return p;
    }
    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, m = 0, p = l.length; m < p; m += 2) d += l[m + 1] - l[m] + 1;
    return d;
  }, e.count = n, e.startAt = r, e.endAt = i, e.minAt = a, e.maxAt = o, e.areEqual = function(l, d) {
    if (l.length !== d.length) return !1;
    for (var m = 0, p = l.length; m < p; ++m) if (l[m] !== d[m]) return !1;
    return !0;
  }, e.forEach = function(l, d) {
    for (var m = 0, p = 0, v = l.length; p < v; p += 2) for (var f = l[p], y = l[p + 1]; f <= y; ++f) d(f, m), ++m;
  }, e.has = function(l, d) {
    return s(l, d) !== -1;
  }, e.hasFrom = function(l, d, m) {
    return u(l, d, m) !== -1;
  }, e.firstIntersectionIndex = s, e.firstIntersectionIndexFrom = u, e.transientSegments = function(l, d) {
    return new c(l, d);
  };
  var c = function() {
    function l(d, m) {
      this.ranges = d, this.set = m, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = s(d, m), this.hasNext = this.curIndex !== -1;
    }
    return l.prototype.updateValue = function() {
      this.value.index = this.curIndex, this.value.start = ve.findPredecessorIndex(this.set, r(this.ranges, this.curIndex)), this.value.end = ve.findPredecessorIndex(this.set, i(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;
}(dn || (dn = {}));
var q4 = S.zero();
function j4(e) {
  var t = function(n) {
    for (var r = n.conformation.invariantPosition, i = n.elements, a = new Float32Array(3 * i.length), o = 0, s = i.length; o < s; o++) r(i[o], q4), S.toArray(q4, a, 3 * o);
    return a;
  }(e);
  return _u.ofPositions(t);
}
var ka = function() {
  function e(t) {
    this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new Ml(), this.dir = function(n) {
      var r;
      switch (n) {
        case "6":
          r = Pe([], d1, !0);
          break;
        case "14":
          r = Pe(Pe([], d1, !0), Sp, !0);
          break;
        case "26":
          r = Pe(Pe(Pe([], d1, !0), Sp, !0), K4, !0);
          break;
        case "98":
          r = Pe(Pe(Pe(Pe(Pe(Pe([], d1, !0), Sp, !0), K4, !0), PM, !0), EM, !0), TM, !0);
      }
      return r.map(function(i) {
        var a = S.create(i[0], i[1], i[2]);
        return S.normalize(a, a);
      });
    }(t), this.reset();
  }
  return e.prototype.computeExtrema = function(t, n) {
    var r = S.dot(this.dir[t], n);
    r < this.minDist[t] && (this.minDist[t] = r, S.copy(this.extrema[2 * t], n)), r > this.maxDist[t] && (this.maxDist[t] = r, S.copy(this.extrema[2 * t + 1], n));
  }, e.prototype.computeSphereExtrema = function(t, n, r) {
    var i = S.dot(this.dir[t], n);
    i - r < this.minDist[t] && (this.minDist[t] = i - r, S.scaleAndSub(this.extrema[2 * t], n, this.dir[t], r)), i + r > this.maxDist[t] && (this.maxDist[t] = i + r, S.scaleAndAdd(this.extrema[2 * t + 1], n, this.dir[t], r));
  }, e.prototype.includeSphere = function(t) {
    if (de.hasExtrema(t) && t.extrema.length > 1) for (var n = 0, r = t.extrema; n < r.length; n++) {
      var i = r[n];
      this.includePosition(i);
    }
    else this.includePositionRadius(t.center, t.radius);
  }, e.prototype.includePosition = function(t) {
    for (var n = 0, r = this.dir.length; n < r; ++n) this.computeExtrema(n, t);
  }, e.prototype.includePositionRadius = function(t, n) {
    for (var r = 0, i = this.dir.length; r < i; ++r) this.computeSphereExtrema(r, t, n);
  }, 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 (de.hasExtrema(t) && t.extrema.length > 1) for (var n = 0, r = t.extrema; n < r.length; n++) {
      var i = r[n];
      this.radiusPosition(i);
    }
    else this.radiusPositionRadius(t.center, t.radius);
  }, e.prototype.radiusPosition = function(t) {
    this.centroidHelper.radiusStep(t);
  }, e.prototype.radiusPositionRadius = function(t, n) {
    this.centroidHelper.radiusSphereStep(t, n);
  }, e.prototype.getSphere = function(t) {
    return de.setExtrema(this.centroidHelper.getSphere(t), Pe([], this.extrema, !0));
  }, e.prototype.getBox = function(t) {
    return sn.fromVec3Array(t || sn(), this.extrema);
  }, e.prototype.reset = function() {
    for (var t = 0, n = this.dir.length; t < n; ++t) this.minDist[t] = 1 / 0, this.maxDist[t] = -1 / 0, this.extrema[2 * t] = S(), this.extrema[2 * t + 1] = S();
    this.centroidHelper.reset();
  }, e;
}(), d1 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], Sp = [[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]], K4 = [[1, 1, 0], [1, -1, 0], [1, 0, 1], [1, 0, -1], [0, 1, 1], [0, 1, -1]], PM = [[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]], EM = [[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]], TM = [[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]], X4 = S.set, MM = new ka("14"), DM = new ka("98"), f1 = S();
function Dl(e) {
  var t = e.x, n = e.y, r = e.z, i = e.radius, a = e.indices, o = ve.size(a);
  if (o > 25e4) {
    var s = sn.computeBounding(e);
    return { box: s, sphere: de.fromBox3D(de(), s) };
  }
  var u = function(p) {
    return p > 1e4 ? MM : DM;
  }(o);
  u.reset();
  for (var c = 0; c < o; c++) {
    var l = ve.getAt(a, c);
    X4(f1, t[l], n[l], r[l]), u.includePositionRadius(f1, i && i[l] || 0);
  }
  for (u.finishedIncludeStep(), c = 0; c < o; c++)
    l = ve.getAt(a, c), X4(f1, t[l], n[l], r[l]), u.radiusPositionRadius(f1, i && i[l] || 0);
  var d = u.getSphere();
  if (!i && de.hasExtrema(d) && o <= d.extrema.length) {
    var m = [];
    for (c = 0; c < o; c++)
      l = ve.getAt(a, c), m.push(S.create(t[l], n[l], r[l]));
    de.setExtrema(d, m);
  }
  return { box: u.getBox(), sphere: d };
}
var Km, Vr, me, Xm, BM = function() {
  function e() {
    this.data = /* @__PURE__ */ new Map();
  }
  return e.prototype.get = function(t) {
    var n = _e.hashCode(t);
    if (this.data.has(n)) for (var r = 0, i = this.data.get(n); r < i.length; r++) {
      var a = i[r], o = a[0], s = a[1];
      if (_e.areEqual(t, o)) return s;
    }
  }, e.prototype.set = function(t, n) {
    var r = _e.hashCode(t);
    if (this.data.has(r)) {
      for (var i = this.data.get(r), a = 0, o = i; a < o.length; a++) {
        var s = o[a];
        if (_e.areEqual(t, s[0])) return void (s[1] = n);
      }
      i.push([t, n]);
    } else this.data.set(r, [[t, n]]);
  }, e.get = function(t) {
    return t._dynamicPropertyData.ElementSetIntraBondCache || (t._dynamicPropertyData.ElementSetIntraBondCache = new e()), t._dynamicPropertyData.ElementSetIntraBondCache;
  }, e;
}(), nv = function() {
  function e(t, n, r) {
    this.operatorsProvider = r, this.id = t, this.details = n;
  }
  return Object.defineProperty(e.prototype, "operatorGroups", { get: function() {
    return this._operators || (this._operators = this.operatorsProvider()), this._operators;
  }, enumerable: !1, configurable: !0 }), e;
}();
function RM(e, t, n) {
  if (!e._rowCount) return [];
  for (var r = function(o) {
    for (var s = o.id, u = o.matrix, c = o.vector, l = o._schema, d = /* @__PURE__ */ new Map(), m = 0, p = o._rowCount; m < p; m++) {
      var v = Nn.toMat4(J(), l.matrix.space, u.value(m)), f = Nn.toVec3(S(), l.vector.space, c.value(m));
      J.setTranslation(v, f), J.setValue(v, 3, 3, 1), d.set(s.value(m), v);
    }
    return d;
  }(n), i = [], a = 0; a < e._rowCount; a++) i[i.length] = kM(e, t, a, r);
  return i;
}
function kM(e, t, n, r) {
  for (var i = e.id.value(n), a = e.details.value(n), 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) === i && (o[o.length] = { assemblyId: i, expression: u.value(l), asymIds: c.value(l) });
  return nv.create(i, a, /* @__PURE__ */ function(m, p) {
    return function() {
      for (var v = [], f = 0, y = 0; y < m.length; y++) {
        var h = m[y], g = OM(LM(h.expression)), x = NM(p, g, f, h.assemblyId), C = Cn.generators.atoms({ chainTest: Cn.pred.and(Cn.pred.eq(function(b) {
          return Me.unit.operator_name(b.element);
        }, xn.DefaultName), Cn.pred.inSet(function(b) {
          return Me.chain.label_asym_id(b.element);
        }, h.asymIds)) });
        v[v.length] = { selector: C, operators: x }, f += x.length;
      }
      return v;
    };
  }(o, r));
}
function OM(e) {
  for (var t = [], n = [], r = 0; r < e.length; r++) n[r] = "";
  return P9(e, t, e.length - 1, n), t;
}
function P9(e, t, n, r) {
  if (n < 0) t[t.length] = r.slice(0);
  else for (var i = e[n], a = i.length, o = 0; o < a; o++) r[n] = i[o], P9(e, t, n - 1, r);
}
function NM(e, t, n, r) {
  for (var i = [], a = n, o = 0, s = t; o < s.length; o++) {
    for (var u = s[o], c = J.identity(), l = 0; l < u.length; l++) J.mul(c, c, e.get(u[l]));
    a++, i[i.length] = xn.create("ASM_".concat(a), c, { assembly: { id: r, operId: a, operList: u } });
  }
  return i;
}
function LM(e) {
  for (var t, n = /\(?([^\(\)]+)\)?]*/g, r = [], i = []; t = n.exec(e); ) r[r.length] = t[1];
  return r.forEach(function(a) {
    var o = [];
    a.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();
    }), i[i.length] = o;
  }), i;
}
function FM(e) {
  if (e._rowCount !== 0) {
    for (var t = e.id, n = e.matrix, r = e.vector, i = wt.struct_ncs_oper.matrix.space, a = wt.struct_ncs_oper.vector.space, o = [], s = 0; s < e._rowCount; s++) {
      var u = Nn.toMat3(br(), i, n.value(s)), c = Nn.toVec3(S(), a, r.value(s));
      if (xn.checkIfRotationAndTranslation(u, c) && (e.code.value(s) !== "given" || br.isIdentity(u) || S.isZero(c))) {
        var l = t.value(s);
        o[o.length] = xn.ofRotationAndOffset("ncs_".concat(l), u, c, l);
      }
    }
    return o;
  }
}
function GM(e) {
  var t = e.bonds, n = t.b, r = t.edgeProps, i = t.offset;
  r.order;
  for (var a = r.flags, o = e.rings.elementAromaticRingIndices, s = [], u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = function(g, x, C) {
    var b = s.length;
    s.push(_e.ofUnsortedArray([g, x, C])), u.set(Mm(g, x), C), c.has(g) ? c.get(g).push(b) : c.set(g, [b]);
  }, d = 0; d < e.elements.length; d++)
    if (!o.has(d) && !(i[d + 1] - i[d] + 1 < 2)) {
      for (var m = [], p = i[d], v = i[d + 1]; p < v; p++) {
        var f = a[p];
        Bt.is(f, 16) && m.push(n[p]);
      }
      if (m.length >= 2) {
        l(d, m[0], m[1]);
        for (var y = 1, h = m.length; y < h; y++) l(d, m[y], m[0]);
      }
    }
  return { getThirdElement: function(g, x) {
    return u.get(Mm(g, x));
  }, getTripletIndices: function(g) {
    return c.get(g);
  }, triplets: s };
}
function E9() {
  return { result: Xm.create(), closeUnitsResult: wu.create(), unitGroupResult: wu.create() };
}
(function(e) {
  e.create = function(t, n, r) {
    return new e(t, n, r);
  };
})(nv || (nv = {})), function(e) {
  e.Default = { assemblies: [], spacegroup: ki.ZeroP1, isNonStandardCrystalFrame: !1 }, e.findAssembly = function(t, n) {
    var r = n.toLocaleLowerCase(), i = Vr.Provider.get(t);
    return i ? function(a, o) {
      for (var s = 0, u = a.length; s < u; s++) if (o(a[s])) return a[s];
    }(i.assemblies, function(a) {
      return a.id.toLowerCase() === r;
    }) : void 0;
  }, e.getUnitcellLabel = function(t) {
    var n = t.spacegroup, r = n.cell, i = n.name, a = n.num, o = r.size, s = r.anglesInRadians, u = o[0].toFixed(2), c = o[1].toFixed(2), l = o[2].toFixed(2), d = $r(s[0]).toFixed(2), m = $r(s[1]).toFixed(2), p = $r(s[2]).toFixed(2), v = [];
    return v.push("Unit Cell <b>".concat(i, "</b> #").concat(a)), v.push("".concat(u, "×").concat(c, "×").concat(l, " Å")), v.push("α=".concat(d, "° β=").concat(m, "° γ=").concat(p, "°")), v.join(" | ");
  };
}(Km || (Km = {})), function(e) {
  e.Descriptor = { name: "model_symmetry" }, e.Provider = Mo.create(e.Descriptor), e.fromData = function(t) {
    var n = RM(t.pdbx_struct_assembly, t.pdbx_struct_assembly_gen, t.pdbx_struct_oper_list), r = function(i, a) {
      if (i._rowCount === 0 || a._rowCount === 0) return ki.ZeroP1;
      var o = a.length_a.value(0), s = a.length_b.value(0), u = a.length_c.value(0);
      if (o === 0 || s === 0 || u === 0) return ki.ZeroP1;
      var c = a.angle_alpha.value(0), l = a.angle_beta.value(0), d = a.angle_gamma.value(0);
      if (c === 0 || l === 0 || d === 0) return ki.ZeroP1;
      var m = function(v) {
        var f = v.Int_Tables_number.value(0), y = v["space_group_name_H-M"].value(0);
        return v.Int_Tables_number.isDefined ? v["space_group_name_H-M"].isDefined ? y : f : y;
      }(i), p = Ma.create(m, S.create(o, s, u), S.scale(S(), S.create(c, l, d), Math.PI / 180));
      return ki.create(p);
    }(t.symmetry, t.cell);
    return { assemblies: n, spacegroup: r, isNonStandardCrystalFrame: (t.atom_sites._rowCount, !1), ncsOperators: FM(t.struct_ncs_oper) };
  }, e.fromCell = function(t, n) {
    var r = Ma.create("P 1", t, n);
    return { assemblies: [], spacegroup: ki.create(r), isNonStandardCrystalFrame: !1 };
  };
}(Vr || (Vr = {})), function(e) {
  function t(h) {
    for (var g = [], x = 0, C = h.length; x < C; x++) g.push(h[x].id);
    return di(g);
  }
  function n(h) {
    var g = {};
    return { elements: h[0].elements, units: h, get unitIndexMap() {
      return g.unitIndexMap || (g.unitIndexMap = function(x) {
        for (var C = Ro.Mutable(), b = 0, _ = x.length; b < _; b++) C.set(x[b].id, b);
        return C;
      }(h)), g.unitIndexMap;
    }, hashCode: r(h[0]), transformHash: t(h) };
  }
  function r(h) {
    return $l(h.invariantId, _e.hashCode(h.elements));
  }
  var i;
  e.isAtomic = function(h) {
    return h.kind === 0;
  }, e.isCoarse = function(h) {
    return h.kind === 1 || h.kind === 2;
  }, e.isSpheres = function(h) {
    return h.kind === 1;
  }, e.isGaussians = function(h) {
    return h.kind === 2;
  }, e.create = function(h, g, x, C, b, _, A, I, w) {
    switch (b) {
      case 0:
        return new a(h, g, x, C, _, I, xn.createMapping(A, _.atomicConformation, void 0), w ?? o());
      case 1:
        return m(h, g, x, C, _, 1, I, xn.createMapping(A, _.coarseConformation.spheres, function(E) {
          var D = E.coarseConformation.spheres.radius;
          return function(T) {
            return D[T];
          };
        }(_)), w ?? c());
      case 2:
        return m(h, g, x, C, _, 2, I, xn.createMapping(A, _.coarseConformation.gaussians, function(E) {
          return 0;
        }), w ?? c());
    }
  }, e.SymmetryGroup = n, function(h) {
    h.areInvariantElementsEqual = function(g, x) {
      return g.hashCode === x.hashCode && _e.areEqual(g.elements, x.elements);
    }, h.getUnitSymmetryGroupsIndexMap = function(g) {
      for (var x = Ro.Mutable(), C = 0, b = g.length; C < b; ++C) for (var _ = g[C], A = 0, I = _.units.length; A < I; ++A) x.set(_.units[A].id, C);
      return x;
    };
  }(n = e.SymmetryGroup || (e.SymmetryGroup = {})), e.conformationId = function(h) {
    return e.isAtomic(h) ? h.model.atomicConformation.id : h.model.coarseConformation.id;
  }, e.hashUnit = r, (i = e.Traits || (e.Traits = {})).is = Qr.has, i.create = Qr.create;
  var a = function() {
    function h(g, x, C, b, _, A, I, w) {
      this.kind = 0, this.objectPrimitive = "atomistic", this.id = g, this.invariantId = x, this.chainGroupId = C, this.traits = b, this.model = _, this.elements = A, this.conformation = I, this.residueIndex = _.atomicHierarchy.residueAtomSegments.index, this.chainIndex = _.atomicHierarchy.chainAtomSegments.index, this.props = w;
    }
    return h.prototype.getChild = function(g) {
      return g.length === this.elements.length ? this : new h(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, g, this.conformation, o());
    }, h.prototype.applyOperator = function(g, x, C) {
      C === void 0 && (C = !1);
      var b = C ? x : xn.compose(this.conformation.operator, x);
      return new h(g, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, xn.createMapping(b, this.model.atomicConformation, this.conformation.r), this.props);
    }, h.prototype.remapModel = function(g, x, C) {
      var b, _;
      C || (C = B(B({}, this.props), { bonds: x && !(!((_ = (b = this.props.bonds) === null || b === void 0 ? void 0 : b.props) === null || _ === void 0) && _.canRemap) ? void 0 : p(this, this.props.bonds, g, x) }), e.isSameConformation(this, g) || (C.boundary = void 0, C.lookup3d = void 0, C.principalAxes = void 0));
      var A = this.conformation.operator, I = Vr.Provider.get(g);
      if (A.spgrOp !== -1 && I && I !== Vr.Provider.get(this.model)) {
        var w = A.hkl, E = w[0], D = w[1], T = w[2], P = I.spacegroup.cell.toFractional, M = S.transformMat4(S(), pn.getCenter(g), P);
        A = ki.getSymmetryOperatorRef(I.spacegroup, A.spgrOp, E, D, T, M);
      }
      var R = this.model.atomicConformation !== g.atomicConformation || A !== this.conformation.operator ? xn.createMapping(A, g.atomicConformation) : this.conformation;
      return new h(this.id, this.invariantId, this.chainGroupId, this.traits, g, this.elements, R, C);
    }, Object.defineProperty(h.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var g = this.model.atomicConformation, x = g.x, C = g.y, b = g.z;
      return this.props.boundary = Dl({ x, y: C, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var g = this.model.atomicConformation, x = g.x, C = g.y, b = g.z;
      return this.props.lookup3d = xc({ x, y: C, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = j4(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "bonds", { get: function() {
      if (this.props.bonds) return this.props.bonds;
      var g = BM.get(this.model), x = g.get(this.elements);
      return x || (x = pM(this), g.set(this.elements, x)), this.props.bonds = x, this.props.bonds;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "rings", { get: function() {
      return this.props.rings || (this.props.rings = jm.create(this)), this.props.rings;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "resonance", { get: function() {
      return this.props.resonance || (this.props.resonance = function(g) {
        return { delocalizedTriplets: GM(g) };
      }(this)), this.props.resonance;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = function(g) {
        for (var x = [], C = g.elements, b = g.model, _ = g.model.atomicHierarchy.residueAtomSegments, A = b.atomicHierarchy.derived.residue.traceElementIndex, I = dn.transientSegments(g.model.atomicRanges.polymerRanges, C), w = St.transientSegments(_, C); I.hasNext; ) {
          var E = I.move();
          for (w.setSegment(E); w.hasNext; ) {
            var D = w.move(), T = D.start, P = D.end, M = D.index;
            if (ve.areIntersecting(oe.ofRange(C[T], C[P - 1]), C)) {
              var R = A[M];
              x.push(R === -1 ? _.offsets[M] : R);
            }
          }
        }
        return _e.ofSortedArray(x);
      }(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = function(g) {
        for (var x = [], C = g.elements, b = g.model, _ = g.residueIndex, A = g.model.atomicHierarchy.residueAtomSegments, I = b.atomicHierarchy.derived.residue.traceElementIndex, w = dn.transientSegments(g.model.atomicRanges.gapRanges, g.elements); w.hasNext; ) {
          var E = w.move(), D = _[C[E.start]], T = _[C[E.end - 1]], P = I[D], M = I[T];
          x.push(P === -1 ? A.offsets[D] : P), x.push(M === -1 ? A.offsets[T] : M);
        }
        return _e.ofSortedArray(x);
      }(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "nucleotideElements", { get: function() {
      return this.props.nucleotideElements || (this.props.nucleotideElements = function(g) {
        for (var x = [], C = g.elements, b = g.model, _ = b.atomicHierarchy, A = _.chainAtomSegments, I = _.residueAtomSegments, w = b.atomicHierarchy.derived.residue, E = w.moleculeType, D = w.traceElementIndex, T = St.transientSegments(A, C), P = St.transientSegments(I, C); T.hasNext; ) for (P.setSegment(T.move()); P.hasNext; ) {
          var M = P.move().index;
          if (nd(E[M])) {
            var R = D[M];
            x.push(R === -1 ? I.offsets[M] : R);
          }
        }
        return _e.ofSortedArray(x);
      }(this)), this.props.nucleotideElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "proteinElements", { get: function() {
      return this.props.proteinElements || (this.props.proteinElements = function(g) {
        for (var x = [], C = g.elements, b = g.model, _ = b.atomicHierarchy, A = _.chainAtomSegments, I = _.residueAtomSegments, w = b.atomicHierarchy.derived.residue, E = w.moleculeType, D = w.traceElementIndex, T = St.transientSegments(A, C), P = St.transientSegments(I, C); T.hasNext; ) for (P.setSegment(T.move()); P.hasNext; ) {
          var M = P.move().index;
          if (g9(E[M])) {
            var R = D[M];
            x.push(R === -1 ? I.offsets[M] : R);
          }
        }
        return _e.ofSortedArray(x);
      }(this)), this.props.proteinElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "residueCount", { get: function() {
      if (this.props.residueCount !== void 0) return this.props.residueCount;
      for (var g = 0, x = St.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements); x.hasNext; ) x.move(), g += 1;
      return this.props.residueCount = g, this.props.residueCount;
    }, enumerable: !1, configurable: !0 }), h.prototype.getResidueIndex = function(g) {
      return this.residueIndex[this.elements[g]];
    }, h;
  }();
  function o() {
    return {};
  }
  e.Atomic = a;
  var s = function() {
    function h(g, x, C, b, _, A, I, w, E) {
      this.kind = A, this.objectPrimitive = A === 1 ? "sphere" : "gaussian", this.id = g, this.invariantId = x, this.chainGroupId = C, this.traits = b, this.model = _, this.elements = I, this.conformation = w, this.coarseElements = A === 1 ? _.coarseHierarchy.spheres : _.coarseHierarchy.gaussians, this.coarseConformation = A === 1 ? _.coarseConformation.spheres : _.coarseConformation.gaussians, this.props = E;
    }
    return h.prototype.getChild = function(g) {
      return g.length === this.elements.length ? this : m(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, g, this.conformation, c());
    }, h.prototype.applyOperator = function(g, x, C) {
      C === void 0 && (C = !1);
      var b = C ? x : xn.compose(this.conformation.operator, x);
      return m(g, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, xn.createMapping(b, this.getCoarseConformation(), this.conformation.r), this.props);
    }, h.prototype.remapModel = function(g, x, C) {
      var b = this.getCoarseConformation(), _ = u(this.kind, g);
      C || (C = B({}, this.props), e.isSameConformation(this, g) || (C.boundary = void 0, C.lookup3d = void 0, C.principalAxes = void 0));
      var A = b !== _ ? xn.createMapping(this.conformation.operator, _) : this.conformation;
      return new h(this.id, this.invariantId, this.chainGroupId, this.traits, g, this.kind, this.elements, A, C);
    }, Object.defineProperty(h.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var g = this.getCoarseConformation(), x = g.x, C = g.y, b = g.z;
      return this.props.boundary = Dl({ x, y: C, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var g = this.getCoarseConformation(), x = g.x, C = g.y, b = g.z;
      return this.props.lookup3d = xc({ x, y: C, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = j4(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = IM(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = wM(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), h.prototype.getCoarseConformation = function() {
      return u(this.kind, this.model);
    }, h;
  }();
  function u(h, g) {
    return h === 1 ? g.coarseConformation.spheres : g.coarseConformation.gaussians;
  }
  function c() {
    return {};
  }
  var l = function(h) {
    function g() {
      return h !== null && h.apply(this, arguments) || this;
    }
    return Zr(g, h), g;
  }(s);
  e.Spheres = l;
  var d = function(h) {
    function g() {
      return h !== null && h.apply(this, arguments) || this;
    }
    return Zr(g, h), g;
  }(s);
  function m(h, g, x, C, b, _, A, I, w) {
    return new s(h, g, x, C, b, _, A, I, w);
  }
  function p(h, g, x, C) {
    var b;
    if (g) {
      if (h.model.atomicConformation.id === x.atomicConformation.id) return g;
      var _ = gr.Provider.get(h.model);
      if (_) {
        var A = gr.Provider.get(x);
        return A && _ !== A ? void 0 : g;
      }
      return !((b = g.props) === null || b === void 0) && b.canRemap || !C || v(h, x) ? g : void 0;
    }
  }
  function v(h, g) {
    var x = pn.CoordinatesHistory.get(pn.getRoot(g));
    if (x) return x.areEqual(h.elements, h.kind, g);
    for (var C = h.elements, b = h.conformation.coordinates, _ = b.x, A = b.y, I = b.z, w = f(h.kind, g), E = w.x, D = w.y, T = w.z, P = 0, M = C.length; P < M; P++) {
      var R = C[P];
      if (_[R] !== E[R] || A[R] !== D[R] || I[R] !== T[R]) return !1;
    }
    return !0;
  }
  function f(h, g) {
    return h === 0 ? g.atomicConformation : h === 1 ? g.coarseConformation.spheres : g.coarseConformation.gaussians;
  }
  function y(h, g) {
    return h === 0 ? g.atomicHierarchy : h === 1 ? g.coarseHierarchy.spheres : g.coarseHierarchy.gaussians;
  }
  e.Gaussians = d, e.areSameChainOperatorGroup = function(h, g) {
    return h.chainGroupId === g.chainGroupId && h.conformation.operator.name === g.conformation.operator.name;
  }, e.areOperatorsEqual = function(h, g) {
    return J.areEqual(h.conformation.operator.matrix, g.conformation.operator.matrix, 1e-6);
  }, e.areConformationsEqual = function(h, g) {
    return !!_e.areEqual(h.elements, g.elements) && v(h, g.model);
  }, e.isSameConformation = v, e.getModelConformationOfKind = f, e.getConformation = function(h) {
    return f(h.kind, h.model);
  }, e.getModelHierarchyOfKind = y, e.getHierarchy = function(h) {
    return y(h.kind, h.model);
  };
}(me || (me = {})), function(e) {
  e.add = function(t, n, r, i) {
    t.indices[t.count] = r, t.units[t.count] = n, t.squaredDistances[t.count] = i, t.count++;
  }, e.create = function() {
    return { count: 0, indices: [], units: [], squaredDistances: [] };
  }, e.copy = function(t, n) {
    for (var r = 0; r < n.count; ++r) t.indices[r] = n.indices[r], t.units[r] = n.units[r], t.squaredDistances[r] = n.squaredDistances[r];
    return t.count = n.count, t;
  };
}(Xm || (Xm = {}));
var Ke, Ci, VM = function() {
  function e(t) {
    this.structure = t, this.pivot = S(), this.findContext = E9();
    for (var n = t.units, r = t.boundary, i = n.length, a = new Float32Array(i), o = new Float32Array(i), s = new Float32Array(i), u = new Float32Array(i), c = S(), l = 0; l < i; l++) {
      var d = n[l], m = d.boundary.sphere;
      S.transformMat4(c, m.center, d.conformation.operator.matrix), a[l] = c[0], o[l] = c[1], s[l] = c[2], u[l] = m.radius;
    }
    var p = { x: a, y: o, z: s, radius: u, indices: ve.ofBounds(0, i) };
    this.unitLookup = xc(p, r);
  }
  return e.prototype.findUnitIndices = function(t, n, r, i) {
    return this.unitLookup.find(t, n, r, i);
  }, e.prototype.find = function(t, n, r, i, a) {
    return this._find(t, n, r, i, a ?? this.findContext);
  }, e.prototype._find = function(t, n, r, i, a) {
    wu.reset(a.result);
    var o = this.structure.units, s = this.unitLookup.find(t, n, r, i, a.closeUnitsResult);
    if (s.count === 0) return a.result;
    for (var u = 0, c = s.count; u < c; u++) {
      var l = o[s.indices[u]];
      S.set(this.pivot, t, n, r), l.conformation.operator.isIdentity || S.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      for (var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i, a.unitGroupResult), m = 0, p = d.count; m < p; m++) Xm.add(a.result, l, d.indices[m], d.squaredDistances[m]);
    }
    return a.result;
  }, e.prototype.findIntoBuilder = function(t, n, r, i, a) {
    var o = this.structure.units, s = this.unitLookup.find(t, n, r, i);
    if (s.count !== 0) for (var u = 0, c = s.count; u < c; u++) {
      var l = o[s.indices[u]];
      S.set(this.pivot, t, n, r), l.conformation.operator.isIdentity || S.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i);
      if (d.count !== 0) {
        var m = l.elements;
        a.beginUnit(l.id);
        for (var p = 0, v = d.count; p < v; p++) a.addElement(m[d.indices[p]]);
        a.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderIf = function(t, n, r, i, a, o) {
    var s = this.structure.units, u = this.unitLookup.find(t, n, r, i);
    if (u.count !== 0) for (var c = Ne.create(this.structure), l = 0, d = u.count; l < d; l++) {
      var m = s[u.indices[l]];
      S.set(this.pivot, t, n, r), m.conformation.operator.isIdentity || S.transformMat4(this.pivot, this.pivot, m.conformation.operator.inverse);
      var p = m.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i);
      if (p.count !== 0) {
        var v = m.elements;
        c.unit = m, a.beginUnit(m.id);
        for (var f = 0, y = p.count; f < y; f++) c.element = v[p.indices[f]], o(c) && a.addElement(c.element);
        a.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderWithRadius = function(t, n, r, i, a, o, s, u) {
    var c = this.structure.units, l = this.unitLookup.find(t, n, r, o);
    if (l.count !== 0) for (var d = Ne.create(this.structure), m = i + a + o, p = 0, v = l.count; p < v; p++) {
      var f = c[l.indices[p]];
      S.set(this.pivot, t, n, r), f.conformation.operator.isIdentity || S.transformMat4(this.pivot, this.pivot, f.conformation.operator.inverse);
      var y = f.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], m);
      if (y.count !== 0) {
        var h = f.elements;
        d.unit = f, u.beginUnit(f.id);
        for (var g = 0, x = y.count; g < x; g++) {
          d.element = h[y.indices[g]];
          var C = s(d);
          Math.sqrt(y.squaredDistances[g]) - i - C > o || u.addElement(h[y.indices[g]]);
        }
        u.commitUnit();
      }
    }
  }, e.prototype.check = function(t, n, r, i) {
    var a = this.structure.units, o = this.unitLookup.find(t, n, r, i);
    if (o.count === 0) return !1;
    for (var s = 0, u = o.count; s < u; s++) {
      var c = a[o.indices[s]];
      if (S.set(this.pivot, t, n, r), c.conformation.operator.isIdentity || S.transformMat4(this.pivot, this.pivot, c.conformation.operator.inverse), c.lookup3d.check(this.pivot[0], this.pivot[1], this.pivot[2], i)) return !0;
    }
    return !1;
  }, Object.defineProperty(e.prototype, "boundary", { get: function() {
    return this.structure.boundary;
  }, enumerable: !1, configurable: !0 }), e;
}();
function Ym(e, t) {
  if (t.length === 0) return Be.Empty;
  if (t.length === 1) return t[0];
  for (var n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = 0, a = t; i < a.length; i++) for (var o = a[i].units, s = 0, u = o.length; s < u; s++) {
    var c = o[s];
    if (n.has(c.id)) {
      if (r.has(c.id)) continue;
      var l = _e.union(n.get(c.id), c.elements);
      n.set(c.id, l), l.length === e.unitMap.get(c.id).elements.length && r.add(c.id);
    } else n.set(c.id, c.elements), c.elements.length === e.unitMap.get(c.id).elements.length && r.add(c.id);
  }
  var d = e.subsetBuilder(!0);
  return n.forEach(zM, d), d.getStructure();
}
function zM(e, t) {
  this.setUnit(t, e);
}
function qg(e, t) {
  if (e === t) return !0;
  var n, r;
  e.units.length < t.units.length ? (n = e, r = t) : (n = t, r = e);
  for (var i = n.units, a = r.unitMap, o = 0, s = i.length; o < s; o++) {
    var u = i[o];
    if (a.has(u.id)) {
      var c = a.get(u.id);
      if (_e.areIntersecting(u.elements, c.elements)) return !0;
    }
  }
  return !1;
}
function T9(e, t) {
  if (e === t) return Be.Empty;
  if (!qg(e, t)) return e;
  for (var n = e.units, r = t.unitMap, i = [], a = 0, o = n.length; a < o; a++) {
    var s = n[a];
    if (r.has(s.id)) {
      var u = r.get(s.id), c = _e.subtract(s.elements, u.elements);
      c.length > 0 && (i[i.length] = s.getChild(c));
    } else i[i.length] = s;
  }
  return Be.create(i, { parent: e.parent || t.parent });
}
function rv(e) {
  return Bt.isCovalent(e.atomicBond.type);
}
function M9(e, t, n) {
  return { groupedUnits: e, ranges: t, set: n };
}
function D9(e) {
  return function(t) {
    var n = { hash: t.inputStructure.hashCode, elements: e };
    return Ke.Sequence(t.inputStructure, [Ci.toStructure(n, t.inputStructure)]);
  };
}
(function(e) {
  function t(l, d) {
    return { kind: "singletons", source: l, structure: d };
  }
  function n(l, d) {
    return { kind: "sequence", source: l, structures: d };
  }
  function r(l) {
    return t(l, Be.Empty);
  }
  function i(l) {
    return l.kind === "singletons";
  }
  function a(l) {
    return i(l) ? l.structure.units.length === 0 : l.structures.length === 0;
  }
  function o(l) {
    return a(l) ? Be.Empty : i(l) ? l.structure : Ym(l.source, l.structures);
  }
  function s(l, d, m) {
    return d.length === 0 ? r(l) : m ? t(l, Ym(l, d)) : n(l, d);
  }
  e.Singletons = t, e.Sequence = n, e.Empty = r, e.isSingleton = i, e.isEmpty = a, e.structureCount = function(l) {
    return i(l) ? l.structure.elementCount : l.structures.length;
  }, e.unionStructure = o, e.toLociWithCurrentUnits = function(l) {
    for (var d = [], m = l.source.unitMap, p = 0, v = o(l).units; p < v.length; p++) {
      var f = v[p];
      f === m.get(f.id) ? d[d.length] = { unit: f, indices: ve.ofBounds(0, f.elements.length) } : d[d.length] = { unit: f, indices: ve.ofSortedArray(_e.indicesOf(m.get(f.id).elements, f.elements)) };
    }
    return Se(l.source, d);
  }, e.toLociWithSourceUnits = function(l) {
    for (var d = [], m = l.source.unitMap, p = 0, v = o(l).units; p < v.length; p++) {
      var f = v[p];
      if (m.has(f.id)) {
        var y = m.get(f.id);
        d[d.length] = y === f ? { unit: y, indices: ve.ofBounds(0, y.elements.length) } : { unit: y, indices: ve.ofSortedArray(_e.indicesOf(y.elements, f.elements)) };
      }
    }
    return Se(l.source, d);
  };
  var u = function() {
    function l(d) {
      this.source = d, this.structures = [], this.allSingletons = !0;
    }
    return l.prototype.add = function(d) {
      var m = d.elementCount;
      m !== 0 && (this.structures[this.structures.length] = d, m !== 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 = Lg(Be.hashCode, Be.areUnitIdsAndIndicesEqual);
    }
    return l.prototype.add = function(d) {
      var m = d.elementCount;
      m !== 0 && this.uniqueSets.add(d) && (this.structures[this.structures.length] = d, m !== 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 m = 0;
    if (e.isSingleton(l)) for (var p = 0, v = l.structure.units; p < v.length; p++) for (var f = v[p], y = f.elements, h = 0, g = y.length; h < g; h++)
      d(Be.create([f.getChild(_e.ofSingleton(y[h]))], { parent: l.source }), m++);
    else for (var x = 0, C = l.structures; x < C.length; x++)
      d(C[x], m++);
  }, e.withInputStructure = function(l, d) {
    return i(l) ? t(d, l.structure) : n(d, l.structures);
  };
})(Ke || (Ke = {})), function(e) {
  function t(i) {
    for (var a = [], o = 0, s = i.elements; o < s.length; o++) {
      var u = (x = s[o]).unit, c = x.indices;
      if (ve.size(c) !== 0) {
        var l = [], d = [];
        if (ve.isInterval(c)) ve.size(c) === 1 ? d.push(oe.min(c)) : l.push(oe.min(c), oe.max(c));
        else for (var m = 0, p = c.length; m < p; ) {
          var v = m;
          for (m++; m < p && c[m - 1] + 1 === c[m]; ) m++;
          var f = m;
          if (f - v > 2) l.push(c[v], c[f - 1]);
          else for (var y = v; y < f; y++) d[d.length] = c[y];
        }
        a.push({ unit: u, set: _e.ofSortedArray(d), ranges: dn.ofSortedRanges(l) });
      }
    }
    for (var h = /* @__PURE__ */ new Map(), g = (m = 0, a.length); m < g; ++m) {
      var x, C, b = $l(di((x = a[m]).ranges), di(x.set));
      h.has(b) ? (C = h.get(b).groupedUnits).has(x.unit.invariantId) ? C.get(x.unit.invariantId).push(x.unit.id) : C.set(x.unit.invariantId, [x.unit.id]) : ((C = /* @__PURE__ */ new Map()).set(x.unit.invariantId, [x.unit.id]), h.set(b, { groupedUnits: C, set: x.set, ranges: x.ranges }));
    }
    var _ = [];
    return h.forEach(function(A) {
      var I = [];
      A.groupedUnits.forEach(function(w) {
        return I.push(_e.ofUnsortedArray(w));
      }), I.sort(function(w, E) {
        return w[0] - E[0];
      }), _.push({ groupedUnits: I, set: A.set, ranges: A.ranges });
    }), { hash: i.structure.hashCode, elements: _ };
  }
  function n(i, a) {
    for (var o = [], s = 0, u = i.length; s < u; ++s) {
      var c = i[s];
      a.unitMap.has(c) && o.push(a.unitMap.get(c));
    }
    return o;
  }
  function r(i) {
    return ot.internal.generator.bundleElement({ groupedUnits: ot.core.type.list(i.groupedUnits.map(function(a) {
      return ot.core.type.list(a);
    })), ranges: ot.core.type.list(i.ranges), set: ot.core.type.list(i.set) });
  }
  e.Empty = { hash: -1, elements: [] }, e.fromSubStructure = function(i, a) {
    return t(Ke.toLociWithSourceUnits(Ke.Singletons(i, a)));
  }, e.fromSelection = function(i) {
    return t(Ke.toLociWithSourceUnits(i));
  }, e.fromLoci = t, e.toLoci = function(i, a) {
    i.hash !== -1 && (i.hash, a.hashCode);
    for (var o = [], s = 0, u = i.elements; s < u.length; s++) for (var c = u[s], l = function(p) {
      var v = n(p, a);
      if (v.length === 0) return "continue";
      var f = void 0;
      if (c.ranges.length === 0) f = c.set;
      else if (c.set.length === 0) if (c.ranges.length === 2) f = oe.ofRange(c.ranges[0], c.ranges[1]);
      else {
        var y = new Int32Array(dn.size(c.ranges));
        dn.forEach(c.ranges, function(_, A) {
          return y[A] = _;
        }), f = _e.ofSortedArray(y);
      }
      else {
        var h = dn.size(c.ranges), g = new Int32Array(c.set.length + h);
        dn.forEach(c.ranges, function(_, A) {
          return g[A] = _;
        }), g.set(c.set, h), f = _e.ofUnsortedArray(g);
      }
      for (var x = 0, C = v; x < C.length; x++) {
        var b = C[x];
        o.push({ unit: b, indices: f });
      }
    }, d = 0, m = c.groupedUnits; d < m.length; d++)
      l(m[d]);
    return Se(a, o);
  }, e.toStructure = function(i, a) {
    i.hash !== -1 && (i.hash, a.hashCode);
    for (var o = [], s = 0, u = i.elements; s < u.length; s++) for (var c = u[s], l = function(p) {
      var v = n(p, a);
      if (v.length === 0) return "continue";
      var f = v[0].elements, y = dn.size(c.ranges), h = c.set.length, g = new Int32Array(h + y), x = void 0;
      if (y === 0) {
        for (var C = 0, b = h; C < b; ++C) g[C] = f[c.set[C]];
        x = _e.ofSortedArray(g);
      } else if (h === 0) dn.forEach(c.ranges, function(w, E) {
        return g[E] = f[w];
      }), x = _e.ofSortedArray(g);
      else if (_e.min(c.set) > dn.max(c.ranges)) {
        for (dn.forEach(c.ranges, function(w, E) {
          return g[E] = f[w];
        }), C = 0, b = h; C < b; ++C) g[C + y] = f[c.set[C]];
        x = _e.ofSortedArray(g);
      } else if (dn.min(c.ranges) > _e.max(c.set)) {
        for (C = 0, b = h; C < b; ++C) g[C] = f[c.set[C]];
        dn.forEach(c.ranges, function(w, E) {
          return g[E + h] = f[w];
        }), x = _e.ofSortedArray(g);
      } else {
        for (dn.forEach(c.ranges, function(w, E) {
          return g[E] = f[w];
        }), C = 0, b = h; C < b; ++C) g[C + y] = f[c.set[C]];
        x = _e.ofUnsortedArray(g);
      }
      for (var _ = 0, A = v; _ < A.length; _++) {
        var I = A[_];
        o.push(I.getChild(x));
      }
    }, d = 0, m = c.groupedUnits; d < m.length; d++)
      l(m[d]);
    return Be.create(o, { parent: a });
  }, e.toExpression = function(i) {
    return ot.internal.generator.bundle({ elements: ot.core.type.list(i.elements.map(r)) });
  }, e.areEqual = function(i, a) {
    if (i.elements.length !== a.elements.length) return !1;
    for (var o = 0, s = i.elements.length; o < s; ++o) {
      var u = i.elements[o], c = a.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) || !dn.areEqual(u.ranges, c.ranges)) return !1;
    }
    return !0;
  };
}(Ci || (Ci = {}));
var Y4, UM = Object.freeze({ __proto__: null, atomicHet: function() {
  return function(e) {
    for (var t = e.inputStructure, n = Ne.create(t), r = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        n.unit = o;
        var s = o.elements;
        if (n.element = s[0], Me.entity.type(n) !== "water") {
          if (Me.entity.type(n) === "polymer") {
            for (var u = St.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
            if (c >= 8) continue;
          }
          r.push(o);
        }
      }
    }
    return Ke.Singletons(t, Be.create(r, { parent: t }));
  };
}, atomicSequence: function() {
  return function(e) {
    for (var t = e.inputStructure, n = Ne.create(t), r = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        n.unit = o;
        var s = o.elements;
        if (n.element = s[0], Me.entity.type(n) === "polymer") {
          for (var u = St.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
          c < 8 || r.push(o);
        }
      }
    }
    return Ke.Singletons(t, Be.create(r, { parent: t }));
  };
}, bundleElementImpl: M9, bundleGenerator: D9, defaultBondTest: rv, spheres: function() {
  return function(e) {
    for (var t = e.inputStructure, n = [], r = 0, i = t.units; r < i.length; r++) {
      var a = i[r];
      a.kind === 1 && n.push(a);
    }
    return Ke.Singletons(t, Be.create(n, { parent: t }));
  };
}, water: function() {
  return function(e) {
    for (var t = e.inputStructure, n = Ne.create(t), r = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        n.unit = o;
        var s = o.elements;
        n.element = s[0], Me.entity.type(n) === "water" && r.push(o);
      }
    }
    return Ke.Singletons(t, Be.create(r, { parent: t }));
  };
} }), Cc = function() {
  function e(t, n) {
    this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = nr(), this.element = Ne.create(void 0), this.currentStructure = void 0, this.atomicBond = new W4(), this.currentSelection = void 0, this.inputStructure = t, this.timeoutMs = n && n.timeoutMs || 0, this.currentSelection = n && n.currentSelection;
  }
  return e.prototype.pushCurrentElement = function() {
    return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = Ne.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 W4(), 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 && nr() - 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;
}(), W4 = function() {
  function e() {
    this.a = Ne.create(void 0), this.aIndex = 0, this.b = Ne.create(void 0), this.bIndex = 0, this.type = 0, this.order = 0, this.testFn = rv;
  }
  return e.prototype.setStructure = function(t) {
    this.a.structure = t, this.b.structure = t;
  }, e.prototype.setTestFn = function(t) {
    this.testFn = t || rv;
  }, e.prototype.test = function(t, n) {
    return !!this.testFn(t) || !!n && (this.swap(), this.testFn(t));
  }, e.prototype.swap = function() {
    var t = this.aIndex;
    this.aIndex = this.bIndex, this.bIndex = t;
    var n = this.a.unit;
    this.a.unit = this.b.unit, this.b.unit = n;
    var r = this.a.element;
    this.a.element = this.b.element, this.b.element = r;
  }, Object.defineProperty(e.prototype, "length", { get: function() {
    return Ne.distance(this.a, this.b);
  }, enumerable: !1, configurable: !0 }), e;
}();
(function(e) {
  e.run = function(t, n, r) {
    return t(new Cc(n, r));
  };
})(Y4 || (Y4 = {}));
var Cp = function() {
  function e(t) {
    this.source = t, this.set = Lg(Be.hashCode, Be.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 ? Ke.Singletons(this.source, Ym(this.source, this.structures)) : Ke.Sequence(this.source, this.structures);
  }, e;
}(), HM = function() {
  function e(t) {
    this.source = t, this.builders = [], this.builderMap = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, n, r) {
    var i = this.builderMap.get(t);
    i || (i = this.source.subsetBuilder(!0), this.builders[this.builders.length] = i, this.builderMap.set(t, i)), i.addToUnit(n, r);
  }, e.prototype.allSingletons = function() {
    for (var t = 0, n = this.builders.length; t < n; t++) if (this.builders[t].elementCount > 1) return !1;
    return !0;
  }, e.prototype.singletonSelection = function() {
    for (var t = this.source.subsetBuilder(!0), n = Ne.create(this.source), r = 0, i = this.builders.length; r < i; r++) this.builders[r].setSingletonLocation(n), t.addToUnit(n.unit.id, n.element);
    return Ke.Singletons(this.source, t.getStructure());
  }, e.prototype.fullSelection = function() {
    for (var t = new Array(this.builders.length), n = 0, r = this.builders.length; n < r; n++) t[n] = this.builders[n].getStructure();
    return Ke.Sequence(this.source, t);
  }, e.prototype.getSelection = function() {
    return this.builders.length === 0 ? Ke.Empty(this.source) : this.allSingletons() ? this.singletonSelection() : this.fullSelection();
  }, e;
}(), iv = function(e) {
  return Ke.Sequence(e.inputStructure, []);
}, B9 = function(e) {
  return Ke.Singletons(e.inputStructure, e.inputStructure);
};
function Fs(e) {
  return !0;
}
function qM(e) {
  return 0;
}
function Ap(e) {
  if (!(e && (e.atomTest || e.residueTest || e.chainTest || e.entityTest || e.unitTest || e.groupBy))) return B9;
  if (e.atomTest && !e.residueTest && !e.chainTest && !e.entityTest && !e.unitTest && !e.groupBy) return t = e.atomTest, function(r) {
    var i = r.inputStructure, a = i.units, o = r.pushCurrentElement(), s = i.subsetBuilder(!0);
    o.structure = i;
    for (var u = 0, c = a; u < c.length; u++) {
      var l = c[u];
      o.unit = l;
      var d = l.elements;
      s.beginUnit(l.id);
      for (var m = 0, p = d.length; m < p; m++) o.element = d[m], t(r) && s.addElement(o.element);
      s.commitUnit(), r.throwIfTimedOut();
    }
    return r.popCurrentElement(), Ke.Singletons(i, s.getStructure());
  };
  var t, n = { unitTest: e.unitTest || Fs, entityTest: e.entityTest || Fs, chainTest: e.chainTest || Fs, residueTest: e.residueTest || Fs, atomTest: e.atomTest || Fs, groupBy: e.groupBy || qM };
  return e.groupBy ? function(r) {
    var i = r.unitTest, a = r.entityTest, o = r.chainTest, s = r.residueTest, u = r.atomTest, c = r.groupBy;
    return function(l) {
      var d = l.inputStructure, m = d.units, p = l.pushCurrentElement(), v = new HM(d);
      p.structure = d;
      for (var f = 0, y = m; f < y.length; f++) {
        var h = y[f];
        if (p.unit = h, i(l)) {
          var g = h.elements, x = h.model;
          if (h.kind === 0) for (var C = St.transientSegments(x.atomicHierarchy.chainAtomSegments, g), b = St.transientSegments(x.atomicHierarchy.residueAtomSegments, g); C.hasNext; ) {
            var _ = C.move();
            if (p.element = g[_.start], a(l) && o(l)) for (b.setSegment(_); b.hasNext; ) {
              var A = b.move();
              if (p.element = g[A.start], s(l)) for (var I = A.start, w = A.end; I < w; I++) p.element = g[I], u(l) && v.add(c(l), h.id, p.element);
            }
          }
          else {
            var E = x.coarseHierarchy.spheres.chainElementSegments;
            for (C = St.transientSegments(E, g); C.hasNext; )
              if (_ = C.move(), p.element = g[_.start], a(l) && o(l)) for (I = _.start, w = _.end; I < w; I++) p.element = g[I], s(l) && v.add(c(l), h.id, p.element);
          }
          l.throwIfTimedOut();
        }
      }
      return l.popCurrentElement(), v.getSelection();
    };
  }(n) : function(r) {
    var i = r.unitTest, a = r.entityTest, o = r.chainTest, s = r.residueTest, u = r.atomTest;
    return function(c) {
      var l = c.inputStructure, d = l.units, m = c.pushCurrentElement(), p = l.subsetBuilder(!0), v = s === Fs && u === Fs, f = u === Fs;
      m.structure = l;
      for (var y = 0, h = d; y < h.length; y++) {
        var g = h[y];
        if (m.unit = g, i(c)) {
          var x = g.elements, C = g.model;
          if (p.beginUnit(g.id), g.kind === 0) for (var b = St.transientSegments(g.model.atomicHierarchy.chainAtomSegments, x), _ = St.transientSegments(g.model.atomicHierarchy.residueAtomSegments, x); b.hasNext; ) {
            var A = b.move();
            if (m.element = x[A.start], a(c) && o(c)) if (v) p.addElementRange(x, A.start, A.end);
            else for (_.setSegment(A); _.hasNext; ) {
              var I = _.move();
              if (m.element = x[I.start], s(c)) if (f) p.addElementRange(x, I.start, I.end);
              else for (var w = I.start, E = I.end; w < E; w++) m.element = x[w], u(c) && p.addElement(m.element);
            }
          }
          else {
            var D = C.coarseHierarchy.spheres.chainElementSegments;
            for (b = St.transientSegments(D, x); b.hasNext; )
              if (A = b.move(), m.element = x[A.start], a(c) && o(c)) if (v) p.addElementRange(x, A.start, A.end);
              else for (w = A.start, E = A.end; w < E; w++) m.element = x[w], s(c) && p.addElement(m.element);
          }
          p.commitUnit(), c.throwIfTimedOut();
        }
      }
      return c.popCurrentElement(), Ke.Singletons(l, p.getStructure());
    };
  }(n);
}
function Ip(e, t, n) {
  for (var r = new Int32Array(t.length), i = 0, a = t.length; i < a; i++) r[i] = e.elements[t[i]];
  return Be.create([e.getChild(_e.ofSortedArray(r))], { parent: n });
}
var Ge, _r, jM = Object.freeze({ __proto__: null, all: B9, atoms: Ap, bondedAtomicPairs: function(e) {
  return function(t) {
    var n = t.inputStructure, r = n.interUnitBonds, i = Ke.UniqueBuilder(t.inputStructure);
    t.pushCurrentBond();
    var a = t.atomicBond;
    a.setTestFn(e), a.setStructure(n);
    for (var o = 0, s = n.units; o < s.length; o++) {
      var u = s[o];
      if (u.kind === 0) {
        var c = u.bonds, l = c.offset, d = c.b, m = c.edgeProps, p = m.flags, v = m.order;
        a.a.unit = u, a.b.unit = u;
        for (var f = 0, y = u.elements.length; f < y; f++) {
          a.aIndex = f, a.a.element = u.elements[f];
          for (var h = l[f], g = l[f + 1]; h < g; h++)
            a.bIndex = d[h], a.b.element = u.elements[d[h]], a.type = p[h], a.order = v[h], a.test(t, !1) && ((b = n.subsetBuilder(!1)).beginUnit(u.id), b.addElement(a.a.element), b.addElement(a.b.element), b.commitUnit(), i.add(b.getStructure()));
        }
      }
    }
    for (var x = 0, C = r.edges; x < C.length; x++) {
      var b, _ = C[x];
      a.a.unit = n.unitMap.get(_.unitA), a.a.element = a.a.unit.elements[_.indexA], a.aIndex = _.indexA, a.b.unit = n.unitMap.get(_.unitA), a.b.element = a.b.unit.elements[_.indexB], a.bIndex = _.indexB, a.order = _.props.order, a.type = _.props.flag, a.test(t, !1) && ((b = n.subsetBuilder(!1)).addToUnit(a.a.unit.id, a.a.element), b.addToUnit(a.b.unit.id, a.b.element), i.add(b.getStructure()));
    }
    return t.popCurrentBond(), i.getSelection();
  };
}, chains: function(e) {
  return Ap(B(B({}, e), { groupBy: function(t) {
    return Me.chain.key(t.element);
  } }));
}, none: iv, querySelection: function(e, t, n) {
  return n === void 0 && (n = !1), function(r) {
    var i = e(r);
    if (Ke.structureCount(i) === 0) return i;
    var a = n ? T9(r.inputStructure, Ke.unionStructure(i)) : Ke.unionStructure(i);
    if (a.elementCount === 0) return Ke.Empty(r.inputStructure);
    r.throwIfTimedOut(), r.pushInputStructure(a);
    var o = t(r);
    return r.popInputStructure(), Ke.withInputStructure(o, r.inputStructure);
  };
}, residues: function(e) {
  return Ap(B(B({}, e), { groupBy: function(t) {
    return Me.residue.key(t.element);
  } }));
}, rings: function(e, t) {
  return function(n) {
    var r = n.inputStructure.units, i = Ke.LinearBuilder(n.inputStructure);
    if (e && e.length !== 0) {
      for (var a = yn.create(), o = 0; o < e.length; o++) yn.add(a, e[o], e[o]);
      for (var s = 0, u = r; s < u.length; s++)
        if (h = u[s], me.isAtomic(h)) for (var c = h.rings, l = 0, d = a.array; l < d.length; l++) {
          var m = d[l];
          if (c.byFingerprint.has(m)) for (var p = 0, v = c.byFingerprint.get(m); p < v.length; p++)
            C = v[p], t && !c.aromaticRings.includes(C) || i.add(Ip(h, c.all[C], n.inputStructure));
        }
    } else for (var f = 0, y = r; f < y.length; f++) {
      var h = y[f];
      if (me.isAtomic(h)) if (t) for (var g = 0, x = h.rings.aromaticRings; g < x.length; g++) {
        var C = x[g];
        i.add(Ip(h, h.rings.all[C], n.inputStructure));
      }
      else for (var b = 0, _ = h.rings.all; b < _.length; b++) {
        var C = _[b];
        i.add(Ip(h, C, n.inputStructure));
      }
    }
    return i.getSelection();
  };
} }), P0 = function() {
  function e(t) {
    this.parent = t, this.ids = [], this.unitMap = Ro.Mutable(), this.parentId = -1, this.currentUnit = yn.create(), this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, n) {
    var r = this.unitMap.get(t);
    if (r) yn.add(r, n, n) && this.elementCount++;
    else {
      var i = yn.create();
      yn.add(i, n, n), this.unitMap.set(t, i), this.ids[this.ids.length] = t, this.elementCount++;
    }
  }, e.prototype.has = function(t, n) {
    var r = this.unitMap.get(t);
    return !!r && yn.has(r, n);
  }, 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 ? yn.create() : this.currentUnit;
  }, e.prototype.addElement = function(t) {
    yn.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 Be.Empty;
    var t = [];
    to(this.ids);
    for (var n = kl.UnitEquivalenceBuilder(), r = 0, i = this.ids.length; r < i; r++) {
      var a = this.ids[r], o = this.parent.unitMap.get(a), s = this.unitMap.get(a).array, u = s.length;
      if (s.length !== o.elements.length) {
        u > 1 && to(s);
        var c = o.getChild(_e.ofSortedArray(s)), l = n.add(c.id, c);
        c !== l && (c = l.applyOperator(c.id, c.conformation.operator, !0)), t[t.length] = c;
      } else t[t.length] = o, n.add(o.id, o);
    }
    return Be.create(t, { parent: this.parent });
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function Le(e) {
  return { data: e, position: 0, length: e.length, lineNumber: 1, tokenStart: 0, tokenEnd: 0 };
}
function Z4(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 Q4(e) {
  return !(e.length - e.position < 2) && e.data.charCodeAt(e.position + 1) === 39 && e.data.charCodeAt(e.position + 2) === 39;
}
function KM(e, t, n) {
  var r, i = n - t, a = e.tokenStart - t, o = e.tokenEnd - e.tokenStart;
  if (o < i) return !1;
  for (r = t; r < n; ++r) if (e.data.charCodeAt(r) !== e.data.charCodeAt(r + a)) return !1;
  return i === o || e.data.charCodeAt(r + a) === 46;
}
function R9(e) {
  var t;
  for (t = e.tokenStart; t < e.tokenEnd; ++t) if (e.data.charCodeAt(t) === 46) return t;
  return t;
}
function k9(e, t) {
  return e.data.substring(e.tokenStart, t);
}
function av(e) {
  return e.data.substring(e.tokenStart, e.tokenEnd);
}
function J4(e) {
  var t = function(r) {
    for (var i = 10; r.position < r.length; ) {
      var a = r.data.charCodeAt(r.position);
      switch (a) {
        case 9:
        case 32:
          i = a, ++r.position;
          break;
        case 10:
          i !== 13 && ++r.lineNumber, i = a, ++r.position;
          break;
        case 13:
          i = a, ++r.position, ++r.lineNumber;
          break;
        default:
          return i;
      }
    }
    return i;
  }(e);
  if (e.position >= e.length) e.tokenType = 6;
  else {
    e.tokenStart = e.position, e.tokenEnd = e.position, e.isEscaped = !1;
    var n = e.data.charCodeAt(e.position);
    switch (n) {
      case 35:
        (function(r) {
          for (; r.position < r.length; ) {
            var i = r.data.charCodeAt(r.position);
            if (i === 10 || i === 13) return;
            ++r.position;
          }
        })(e), e.tokenType = 5;
        break;
      case 39:
        if (Q4(e)) {
          (function(r) {
            for (r.position += 3; r.position < r.length; ) {
              if (r.data.charCodeAt(r.position) === 39 && Q4(r)) return r.tokenStart += 3, r.tokenEnd = r.position, r.isEscaped = !0, void (r.position += 3);
              ++r.position;
            }
            r.tokenEnd = r.position;
          })(e), e.tokenType = 3;
          break;
        }
      case 34:
        (function(r, i) {
          var a, o;
          for (++r.position; r.position < r.length; ) if ((o = r.data.charCodeAt(r.position)) === i) switch (a = r.data.charCodeAt(r.position + 1)) {
            case 9:
            case 10:
            case 13:
            case 32:
              return r.tokenStart++, r.tokenEnd = r.position, r.isEscaped = !0, void ++r.position;
            default:
              if (a === void 0) return r.tokenStart++, r.tokenEnd = r.position, r.isEscaped = !0, void ++r.position;
              ++r.position;
          }
          else {
            if (o === 10 || o === 13) return void (r.tokenEnd = r.position);
            ++r.position;
          }
          r.tokenEnd = r.position;
        })(e, n), e.tokenType = 3;
        break;
      case 59:
        t === 10 || t === 13 ? function(r) {
          for (var i, a = 59, o = r.position + 1; o < r.length; ) {
            if ((i = r.data.charCodeAt(o)) === 59 && (a === 10 || a === 13)) {
              for (r.position = o + 1, r.tokenStart++, o--, i = r.data.charCodeAt(o); i === 10 || i === 13; ) o--, i = r.data.charCodeAt(o);
              return r.tokenEnd = o + 1, void (r.isEscaped = !0);
            }
            (i === 13 || i === 10 && a !== 13) && r.lineNumber++, a = i, ++o;
          }
          r.position = o;
        }(e) : Z4(e), e.tokenType = 3;
        break;
      default:
        e.isImportGet ? function(r) {
          for (; r.position < r.length; ) {
            if (r.data.charCodeAt(r.position) === 93) return ++r.position, r.tokenEnd = r.position, void (r.isImportGet = !1);
            ++r.position;
          }
        }(e) : Z4(e), e.isEscaped ? e.tokenType = 3 : e.data.charCodeAt(e.tokenStart) === 95 ? (e.inSaveFrame && function(r) {
          return r.tokenEnd - r.tokenStart == 11 && r.data.charCodeAt(r.tokenStart + 1) === 105 && r.data.charCodeAt(r.tokenStart + 2) === 109 && r.data.charCodeAt(r.tokenStart + 3) === 112 && r.data.charCodeAt(r.tokenStart + 4) === 111 && r.data.charCodeAt(r.tokenStart + 5) === 114 && r.data.charCodeAt(r.tokenStart + 6) === 116 && r.data.charCodeAt(r.tokenStart + 7) === 46 && r.data.charCodeAt(r.tokenStart + 8) === 103 && r.data.charCodeAt(r.tokenStart + 9) === 101 && r.data.charCodeAt(r.tokenStart + 10) === 116;
        }(e) && (e.isImportGet = !0), e.tokenType = 4) : e.tokenEnd - e.tokenStart >= 5 && e.data.charCodeAt(e.tokenStart + 4) === 95 ? function(r) {
          var i = r.data.charCodeAt(r.tokenStart);
          return !(i !== 68 && i !== 100 || (i = r.data.charCodeAt(r.tokenStart + 1)) !== 65 && i !== 97 || (i = r.data.charCodeAt(r.tokenStart + 2)) !== 84 && i !== 116 || (i = r.data.charCodeAt(r.tokenStart + 3)) !== 65 && i !== 97);
        }(e) ? e.tokenType = 0 : function(r) {
          var i = r.data.charCodeAt(r.tokenStart);
          return !(i !== 83 && i !== 115 || (i = r.data.charCodeAt(r.tokenStart + 1)) !== 65 && i !== 97 || (i = r.data.charCodeAt(r.tokenStart + 2)) !== 86 && i !== 118 || (i = r.data.charCodeAt(r.tokenStart + 3)) !== 69 && i !== 101);
        }(e) ? e.tokenType = 1 : function(r) {
          if (r.tokenEnd - r.tokenStart != 5) return !1;
          var i = r.data.charCodeAt(r.tokenStart);
          return !(i !== 76 && i !== 108 || (i = r.data.charCodeAt(r.tokenStart + 1)) !== 79 && i !== 111 || (i = r.data.charCodeAt(r.tokenStart + 2)) !== 79 && i !== 111 || (i = r.data.charCodeAt(r.tokenStart + 3)) !== 80 && i !== 112);
        }(e) ? e.tokenType = 2 : e.tokenType = 3 : e.tokenType = 3;
    }
  }
}
function ru(e) {
  for (J4(e); e.tokenType === 5; ) J4(e);
}
function m1() {
  return { categoryNames: [], categoryData: /* @__PURE__ */ Object.create(null) };
}
function ov(e, t) {
  for (var n = /* @__PURE__ */ Object.create(null), r = 0, i = e; r < i.length; r++) {
    var a = i[r], o = t[a];
    n[a] = Wr(o.name, o.rowCount, o.fieldNames, o.fields);
  }
  return n;
}
function $4(e, t, n) {
  return Ng(e.categoryNames, ov(e.categoryNames, e.categoryData), t, n);
}
function sv(e, t, n, r, i) {
  var a;
  if (t in e.categoryData) {
    var o = e.categoryData[t];
    (a = o.fieldNames).push.apply(a, r), Object.assign(o.fields, i);
  } else e.categoryData[t] = { name: t, rowCount: n, fieldNames: r, fields: i }, e.categoryNames.push(t);
}
function XM(e, t) {
  for (var n = t.tokenizer, r = t.tokens, i = t.fieldCount, a = t.tokenCount, o = 0; n.tokenType === 3 && o < e; ) Ge.add(r[a++ % i], n.tokenStart, n.tokenEnd), ru(n), o++;
  return t.tokenCount = a, o;
}
function YM(e, t) {
  return e.update({ message: "Parsing...", current: t.tokenizer.position, max: t.tokenizer.data.length });
}
function WM(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m;
    return ne(this, function(p) {
      switch (p.label) {
        case 0:
          for (n = e.lineNumber, ru(e), r = k9(e, R9(e)), i = function(v) {
            var f;
            for (f = v.tokenStart; f < v.tokenEnd; ++f) if (v.data.charCodeAt(f) === 46) return !1;
            return !0;
          }(e), a = []; e.tokenType === 4; ) a[a.length] = i ? av(e) : av(e).substring(r.length + 1), ru(e);
          for (o = r === "_atom_site" ? e.data.length / 100 | 0 : 32, s = [], u = a.length, m = 0; m < u; m++) s[m] = Ge.create(e.data, o);
          return c = { fieldCount: u, tokenCount: 0, tokenizer: e, tokens: s }, [4, mf(e.runtimeCtx, 1e6, c, XM, YM)];
        case 1:
          if (p.sent(), c.tokenCount % u != 0) return [2, { hasError: !0, errorLine: e.lineNumber, errorMessage: "The number of values for loop starting at line ".concat(n, " is not a multiple of the number of columns.") }];
          if (l = c.tokenCount / u | 0, i) for (m = 0; m < u; m++) d = { "": Fe.ofTokens(s[m]) }, sv(t, a[m].substr(1), l, [""], d);
          else {
            for (d = /* @__PURE__ */ Object.create(null), m = 0; m < u; m++) d[a[m]] = Fe.ofTokens(s[m]);
            sv(t, r.substr(1), l, a, d);
          }
          return [2, { hasError: !1, errorLine: 0, errorMessage: "" }];
      }
    });
  });
}
function Hc(e, t) {
  return _r.error(t, e);
}
function ZM(e) {
  return _r.success(e);
}
function QM(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d;
    return ne(this, function(m) {
      switch (m.label) {
        case 0:
          n = [], r = function(f, y) {
            return { data: f, length: f.length, position: 0, tokenStart: 0, tokenEnd: 0, tokenType: 6, lineNumber: 1, isEscaped: !1, isImportGet: !1, inSaveFrame: !1, runtimeCtx: y };
          }(e, t), i = "", a = m1(), o = [], s = m1(), p = s.categoryNames, v = ov(s.categoryNames, s.categoryData), u = { categoryNames: p, header: "", categories: v }, c = "", t.update({ message: "Parsing...", current: 0, max: e.length }), ru(r), m.label = 1;
        case 1:
          return r.tokenType === 6 ? [3, 7] : (l = r.tokenType) !== 0 ? [3, 2] : r.inSaveFrame ? [2, Hc(r.lineNumber, "Unexpected data block inside a save frame.")] : (a.categoryNames.length > 0 && n.push($4(a, i, o)), i = e.substring(r.tokenStart + 5, r.tokenEnd), a = m1(), o = [], ru(r), [3, 6]);
        case 2:
          if (l !== 1) return [3, 3];
          if (r.tokenEnd - r.tokenStart == 5) s.categoryNames.length > 0 && (o[o.length] = function(f, y) {
            return Ng(f.categoryNames, ov(f.categoryNames, f.categoryData), y);
          }(s, c)), r.inSaveFrame = !1;
          else {
            if (r.inSaveFrame) return [2, Hc(r.lineNumber, "Save frames cannot be nested.")];
            r.inSaveFrame = !0, c = e.substring(r.tokenStart + 5, r.tokenEnd), s = m1();
          }
          return ru(r), [3, 6];
        case 3:
          return l !== 2 ? [3, 5] : [4, WM(r, r.inSaveFrame ? s : a)];
        case 4:
          return (d = m.sent()).hasError ? [2, Hc(d.errorLine, d.errorMessage)] : [3, 6];
        case 5:
          if (l !== 4) return console.log(r.tokenType, Le.getTokenString(r)), [2, Hc(r.lineNumber, "Unexpected token. Expected data_, loop_, or data name.")];
          if (d = function(f, y) {
            for (var h = f.tokenStart, g = R9(f), x = k9(f, g), C = /* @__PURE__ */ Object.create(null), b = [], _ = !0; _; ) {
              if (f.tokenType !== 4 || !KM(f, h, g)) {
                _ = !1;
                break;
              }
              var A = av(f).substring(x.length + 1);
              if (ru(f), f.tokenType !== 3) return { hasError: !0, errorLine: f.lineNumber, errorMessage: "Expected value." };
              C[A] = Fe.ofTokens({ data: f.data, indices: [f.tokenStart, f.tokenEnd], count: 1 }), b[b.length] = A, ru(f);
            }
            return sv(y, x.substr(1), 1, b, C), { hasError: !1, errorLine: 0, errorMessage: "" };
          }(r, r.inSaveFrame ? s : a), d.hasError) return [2, Hc(d.errorLine, d.errorMessage)];
          m.label = 6;
        case 6:
          return [3, 1];
        case 7:
          return r.inSaveFrame ? [2, Hc(r.lineNumber, "Unfinished save frame (".concat(u.header, ")."))] : ((a.categoryNames.length > 0 || o.length > 0) && n.push($4(a, i, o)), [2, ZM(Q7(n))]);
      }
      var p, v;
    });
  });
}
function JM(e) {
  var t = this;
  return At.create("Parse CIF", function(n) {
    return ie(t, 0, void 0, function() {
      return ne(this, function(r) {
        switch (r.label) {
          case 0:
            return [4, QM(e, n)];
          case 1:
            return [2, r.sent()];
        }
      });
    });
  });
}
function wp(e, t) {
  for (var n = {}, r = 0; r < t; r++)
    n[Wm(e)] = Wm(e);
  return n;
}
function Pp(e, t) {
  for (var n = new Uint8Array(t), r = e.offset, i = 0; i < t; i++) n[i] = e.buffer[i + r];
  return e.offset += t, n;
}
function p1(e, t) {
  var n = L7(e.buffer, e.offset, t);
  return e.offset += t, n;
}
function Ep(e, t) {
  for (var n = new Array(t), r = 0; r < t; r++) n[r] = Wm(e);
  return n;
}
function Wm(e) {
  var t, n, r = e.buffer[e.offset];
  if (!(128 & r)) return e.offset++, r;
  if ((240 & r) == 128) return n = 15 & r, e.offset++, wp(e, n);
  if ((240 & r) == 144) return n = 15 & r, e.offset++, Ep(e, n);
  if ((224 & r) == 160) return n = 31 & r, e.offset++, p1(e, n);
  if (!(224 & ~r)) return t = e.dataView.getInt8(e.offset), e.offset++, t;
  switch (r) {
    case 192:
      return e.offset++, null;
    case 194:
      return e.offset++, !1;
    case 195:
      return e.offset++, !0;
    case 196:
      return n = e.dataView.getUint8(e.offset + 1), e.offset += 2, Pp(e, n);
    case 197:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, Pp(e, n);
    case 198:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, Pp(e, n);
    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 n = e.dataView.getUint8(e.offset + 1), e.offset += 2, p1(e, n);
    case 218:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, p1(e, n);
    case 219:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, p1(e, n);
    case 220:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, Ep(e, n);
    case 221:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, Ep(e, n);
    case 222:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, wp(e, n);
    case 223:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, wp(e, n);
  }
  throw new Error("Unknown type 0x" + r.toString(16));
}
function $M(e) {
  for (var t = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null), r = 0, i = e.columns; r < i.length; r++) {
    var a = i[r];
    t[a.name] = a;
  }
  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 n[o] || (n[o] = function(u) {
      var c = u.mask ? qm(u.mask) : void 0, l = qm(u.data), d = wg(l), m = d ? c ? function(h) {
        return c[h] === 0 ? "" + l[h] : "";
      } : function(h) {
        return "" + l[h];
      } : c ? function(h) {
        return c[h] === 0 ? l[h] : "";
      } : function(h) {
        return l[h];
      }, p = d ? function(h) {
        return l[h];
      } : function(h) {
        var g = l[h];
        return bu(g, 0, g.length);
      }, v = d ? function(h) {
        return l[h];
      } : function(h) {
        var g = l[h];
        return fc(g, 0, g.length);
      }, f = c ? function(h) {
        return c[h];
      } : function(h) {
        return 0;
      }, y = l.length;
      return { __array: l, binaryEncoding: u.data.encoding, isDefined: !0, rowCount: y, str: m, int: p, float: v, valueKind: f, areValuesEqual: function(h, g) {
        return l[h] === l[g];
      }, toStringArray: function(h) {
        return Nr(y, m, h);
      }, toIntArray: d ? function(h) {
        return Bm(l, h);
      } : function(h) {
        return Nr(y, p, h);
      }, toFloatArray: d ? function(h) {
        return Bm(l, h);
      } : function(h) {
        return Nr(y, v, h);
      } };
    }(s)), n[o];
  } };
}
function eD(e) {
  var t = this;
  return At.create("Parse BinaryCIF", function(n) {
    return ie(t, 0, void 0, function() {
      var r, i, a;
      return ne(this, function(o) {
        r = [0, 3];
        try {
          return i = Wm({ 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;
          }(r, i.version.match(/(\d)\.(\d)\.\d/).slice(1).map(function(u) {
            return +u;
          })) ? (a = Q7(i.dataBlocks.map(function(u) {
            for (var c = /* @__PURE__ */ Object.create(null), l = 0, d = u.categories; l < d.length; l++) {
              var m = d[l];
              c[m.name.substr(1)] = $M(m);
            }
            return Ng(u.categories.map(function(p) {
              return p.name.substr(1);
            }), c, u.header);
          })), [2, _r.success(a)]) : [2, _r.error("Unsupported format version. Current ".concat(i.version, ", required ").concat(r.join("."), "."))];
        } catch (u) {
          return [2, _r.error("" + u)];
        }
        var s;
        return [2];
      });
    });
  });
}
(function(e) {
  function t(o) {
    return o.data.substring(o.tokenStart, o.tokenEnd);
  }
  function n(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 r(o) {
    return o.tokenStart = o.position, n(o);
  }
  function i(o, s, u) {
    for (var c = 0, l = 0; l < s; l++) {
      if (!r(o)) return c;
      Ge.addUnchecked(u, o.tokenStart, o.tokenEnd), c++;
    }
    return c;
  }
  function a(o, s, u) {
    for (var c = o.data, l = s, d = u - 1, m = c.charCodeAt(l); (m === 9 || m === 32) && l <= d; ) m = c.charCodeAt(++l);
    for (m = c.charCodeAt(d); (m === 9 || m === 32) && d >= l; ) m = 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 = n, e.markStart = function(o) {
    o.tokenStart = o.position;
  }, e.markLine = r, e.readLine = function(o) {
    return r(o), t(o);
  }, e.readLineTrim = function(o) {
    r(o);
    var s = o.position;
    return a(o, o.tokenStart, o.tokenEnd), o.position = s, t(o);
  }, e.markLines = function(o, s) {
    var u = Ge.create(o.data, 2 * s);
    return i(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), ie(this, 0, void 0, function() {
      var l, d, m;
      return ne(this, function(p) {
        switch (p.label) {
          case 0:
            return l = o.length, d = Ge.create(o.data, 2 * s), m = 0, [4, mf(u, c, o, function(v, f) {
              var y = Math.min(s - m, v);
              return i(f, y, d), m += y, y;
            }, function(v, f) {
              return v.update({ message: "Parsing...", current: f.position, max: l });
            })];
          case 1:
            return p.sent(), [2, d];
        }
      });
    });
  }, e.readAllLines = function(o) {
    for (var s = e(o), u = Ge.create(s.data, Math.max(o.length / 80, 2)); r(s); ) Ge.add(u, s.tokenStart, s.tokenEnd);
    return u;
  }, e.readAllLinesAsync = function(o, s, u) {
    return u === void 0 && (u = 1e5), ie(this, 0, void 0, function() {
      var c, l;
      return ne(this, function(d) {
        switch (d.label) {
          case 0:
            return c = e(o), l = Ge.create(c.data, Math.max(o.length / 80, 2)), [4, mf(s, u, c, function(m, p) {
              return function(v, f, y) {
                for (var h = 0, g = 0; g < f; g++) {
                  if (!r(v)) return h;
                  Ge.add(y, v.tokenStart, v.tokenEnd), h++;
                }
              }(p, m, l), p.position < p.length ? m : 0;
            }, function(m, p) {
              return m.update({ message: "Parsing...", current: p.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 = a;
})(Le || (Le = {})), function(e) {
  function t(n, r, i) {
    var a = n;
    a.offset > a.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;
    }(a), a.indices[a.offset++] = r, a.indices[a.offset++] = i, n.count++;
  }
  e.add = t, e.addToken = function(n, r) {
    t(n, r.tokenStart, r.tokenEnd);
  }, e.addUnchecked = function(n, r, i) {
    n.indices[n.offset++] = r, n.indices[n.offset++] = i, n.count++;
  }, e.create = function(n, r) {
    return { data: n, indicesLenMinus2: (r = Math.max(10, r)) - 2 | 0, count: 0, offset: 0, indices: new Uint32Array(r) };
  };
}(Ge || (Ge = {})), function(e) {
  e.error = function(r, i) {
    return i === void 0 && (i = -1), new t(r, i);
  }, e.success = function(r, i) {
    return i === void 0 && (i = []), new n(r, i);
  };
  var t = function() {
    function r(i, a) {
      this.message = i, this.line = a, this.isError = !0;
    }
    return r.prototype.toString = function() {
      return this.line >= 0 ? "[Line ".concat(this.line, "] ").concat(this.message) : this.message;
    }, r;
  }();
  e.Error = t;
  var n = function(r, i) {
    this.result = r, this.warnings = i, this.isError = !1;
  };
  e.Success = n;
}(_r || (_r = {}));
var rd = X.Schema, Ut = rd.str, tD = rd.float, e5 = rd.List, qi = rd.Aliased, cd = rd.int, qc = rd.coord, nD = { chem_comp: { formula: Ut, formula_weight: tD, id: Ut, mon_nstd_parent_comp_id: e5(",", function(e) {
  return e;
}), name: Ut, one_letter_code: Ut, three_letter_code: Ut, type: qi(Ut), pdbx_synonyms: e5(";", function(e) {
  return e;
}), pdbx_type: Ut, pdbx_ambiguous_flag: Ut, pdbx_replaced_by: Ut, pdbx_replaces: Ut, pdbx_formal_charge: cd, pdbx_model_coordinates_details: Ut, pdbx_model_coordinates_db_code: Ut, pdbx_ideal_coordinates_details: Ut, pdbx_ideal_coordinates_missing_flag: qi(Ut), pdbx_model_coordinates_missing_flag: qi(Ut), pdbx_initial_date: Ut, pdbx_modified_date: Ut, pdbx_release_status: qi(Ut), pdbx_processing_site: qi(Ut) }, chem_comp_atom: { alt_atom_id: Ut, atom_id: Ut, charge: cd, model_Cartn_x: qc, model_Cartn_y: qc, model_Cartn_z: qc, comp_id: Ut, type_symbol: Ut, pdbx_align: cd, pdbx_ordinal: cd, pdbx_model_Cartn_x_ideal: qc, pdbx_model_Cartn_y_ideal: qc, pdbx_model_Cartn_z_ideal: qc, pdbx_stereo_config: qi(Ut), pdbx_aromatic_flag: qi(Ut), pdbx_leaving_atom_flag: qi(Ut) }, chem_comp_bond: { atom_id_1: Ut, atom_id_2: Ut, comp_id: Ut, value_order: qi(Ut), pdbx_ordinal: cd, pdbx_stereo_config: qi(Ut), pdbx_aromatic_flag: qi(Ut) }, pdbx_chem_comp_descriptor: { comp_id: Ut, descriptor: Ut, type: qi(Ut), program: Ut, program_version: Ut }, pdbx_chem_comp_identifier: { comp_id: Ut, identifier: Ut, type: qi(Ut), program: Ut, program_version: Ut } }, E0 = X.Schema, ut = E0.str, rD = E0.float, pi = E0.Aliased, ca = E0.int, iD = { pdbx_reference_molecule: { prd_id: ut, formula_weight: rD, formula: ut, type: pi(ut), type_evidence_code: ut, class: pi(ut), class_evidence_code: ut, name: ut, represent_as: pi(ut), chem_comp_id: ut, compound_details: ut, description: ut, representative_PDB_id_code: ut, release_status: pi(ut), replaces: ut, replaced_by: ut }, pdbx_reference_entity_list: { prd_id: ut, ref_entity_id: ut, type: pi(ut), details: ut, component_id: ca }, pdbx_reference_entity_nonpoly: { prd_id: ut, ref_entity_id: ut, name: ut, chem_comp_id: ut }, pdbx_reference_entity_link: { link_id: ca, prd_id: ut, details: ut, ref_entity_id_1: ut, ref_entity_id_2: ut, entity_seq_num_1: ca, entity_seq_num_2: ca, comp_id_1: ut, comp_id_2: ut, atom_id_1: ut, atom_id_2: ut, value_order: pi(ut), component_1: ca, component_2: ca, link_class: pi(ut) }, pdbx_reference_entity_poly_link: { link_id: ca, prd_id: ut, ref_entity_id: ut, component_id: ca, entity_seq_num_1: ca, entity_seq_num_2: ca, comp_id_1: ut, comp_id_2: ut, atom_id_1: ut, atom_id_2: ut, value_order: pi(ut) }, pdbx_reference_entity_poly: { prd_id: ut, ref_entity_id: ut, type: pi(ut), db_code: ut, db_name: ut }, pdbx_reference_entity_poly_seq: { prd_id: ut, ref_entity_id: ut, mon_id: ut, parent_mon_id: ut, num: ca, observed: pi(ut), hetero: pi(ut) }, pdbx_reference_entity_sequence: { prd_id: ut, ref_entity_id: ut, type: pi(ut), NRP_flag: pi(ut), one_letter_codes: ut }, pdbx_reference_entity_src_nat: { prd_id: ut, ref_entity_id: ut, ordinal: ca, organism_scientific: ut, taxid: ut, db_code: ut, db_name: ut }, pdbx_prd_audit: { prd_id: ut, date: ut, processing_site: pi(ut), action_type: pi(ut) } }, O9 = X.Schema, Jn = O9.str, aD = { datablock: { id: Jn, description: Jn }, dictionary: { title: Jn, datablock_id: Jn, version: Jn }, dictionary_history: { version: Jn, update: Jn, revision: Jn }, sub_category: { id: Jn, description: Jn }, category_group_list: { id: Jn, parent_id: Jn, description: Jn }, item_type_list: { code: Jn, primitive_code: Jn, construct: Jn, detail: Jn }, item_units_list: { code: Jn, detail: Jn }, item_units_conversion: { from_code: Jn, to_code: Jn, operator: Jn, factor: O9.float } }, Gf = X.Schema, Gd = Gf.str, h1 = Gf.int, qo = Gf.float, v1 = Gf.Aliased, tu = Gf.Vector;
v1(Gd), v1(Gd), v1(Gd), v1(Gd), tu(3), tu(3);
var uv, Ac, oD = { volume_data_3d_info: { name: Gd, axis_order: tu(3, h1), origin: tu(3), dimensions: tu(3), sample_rate: h1, sample_count: tu(3, h1), spacegroup_number: h1, spacegroup_cell_size: tu(3), spacegroup_cell_angles: tu(3), mean_source: qo, mean_sampled: qo, sigma_source: qo, sigma_sampled: qo, min_source: qo, min_sampled: qo, max_source: qo, max_sampled: qo }, volume_data_3d: { values: qo } }, T0 = X.Schema, Ln = T0.float, Tp = T0.int, mn = T0.str, sD = { cell: { angle_alpha: Ln, angle_beta: Ln, angle_gamma: Ln, formula_units_z: Tp, length_a: Ln, length_b: Ln, length_c: Ln, volume: Ln }, chemical: { melting_point: Ln, name_common: mn, name_systematic: mn }, chemical_formula: { moiety: mn, sum: mn, weight: Ln }, space_group: { crystal_system: mn, it_number: Tp, "name_h-m_full": mn }, space_group_symop: { operation_xyz: mn }, geom_bond: { atom_site_label_1: mn, atom_site_label_2: mn, distance: Ln, publ_flag: mn, site_symmetry_1: mn, site_symmetry_2: mn, valence: Ln }, audit: { block_doi: mn }, database_code: { cod: mn, csd: mn, depnum_ccdc_archive: mn, depnum_ccdc_fiz: mn, icsd: mn, mdf: mn, nbs: mn }, atom_site: { adp_type: mn, calc_flag: mn, disorder_assembly: mn, disorder_group: mn, fract_x: Ln, fract_y: Ln, fract_z: Ln, label: mn, occupancy: Ln, refinement_flags: mn, site_symmetry_multiplicity: Tp, type_symbol: mn, u_iso_or_equiv: Ln }, atom_site_aniso: { label: mn, u_11: Ln, u: (0, T0.Matrix)(3, 3), u_12: Ln, u_13: Ln, u_22: Ln, u_23: Ln, u_33: Ln }, atom_type: { description: mn, symbol: mn }, atom_type_scat: { dispersion_imag: Ln, dispersion_real: Ln, source: mn } }, uD = { "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"] }, N9 = function(e) {
  return typeof e == "string" ? JM(e) : eD(e);
}, L9 = { mmCIF: function(e) {
  return tc(wt, e);
}, CCD: function(e) {
  return tc(nD, e);
}, BIRD: function(e) {
  return tc(iD, e);
}, dic: function(e) {
  return tc(aD, e);
}, cifCore: function(e) {
  return tc(sD, e, uD);
}, densityServer: function(e) {
  return tc(oD, e);
} }, cD = { type_symbol: X.Schema.Aliased(wt.atom_site.type_symbol), label_atom_id: wt.atom_site.label_atom_id, auth_atom_id: wt.atom_site.auth_atom_id, label_alt_id: wt.atom_site.label_alt_id, label_comp_id: wt.atom_site.label_comp_id, auth_comp_id: wt.atom_site.auth_comp_id, pdbx_formal_charge: wt.atom_site.pdbx_formal_charge, cdr: wt.atom_site.cdr, B_iso_or_equiv: wt.atom_site.B_iso_or_equiv, em_confidence: wt.atom_site.em_confidence }, lD = { group_PDB: wt.atom_site.group_PDB, label_seq_id: wt.atom_site.label_seq_id, auth_seq_id: wt.atom_site.auth_seq_id, pdbx_PDB_ins_code: wt.atom_site.pdbx_PDB_ins_code }, dD = { label_asym_id: wt.atom_site.label_asym_id, auth_asym_id: wt.atom_site.auth_asym_id, label_entity_id: wt.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 };
  };
})(uv || (uv = {})), function(e) {
  function t(r, i) {
    return r.residueAtomSegments.index[r.chainAtomSegments.offsets[i]];
  }
  function n(r, i) {
    return r.residueAtomSegments.index[r.chainAtomSegments.offsets[i + 1] - 1] + 1;
  }
  e.chainStartResidueIndex = t, e.chainEndResidueIndexExcl = n, e.chainResidueCount = function(r, i) {
    return n(r, i) - t(r, i);
  };
}(Ac || (Ac = {}));
var gf, Bl = { 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 }, fD = { 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 }, mD = { 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 }, pD = 1.7, hD = 0;
function M0(e) {
  var t = Bl[e];
  return t === void 0 ? pD : fD[t];
}
function yf(e) {
  var t = Bl[e];
  return t === void 0 ? hD : t;
}
function F9(e, t, n, r) {
  return { type: e, key: t, elements: n, getIndex: r };
}
function vD(e, t, n, r, i, a) {
  for (var o = e.residues, s = o.auth_seq_id, u = o.label_seq_id, c = o.pdbx_PDB_ins_code, l = n.endSeqId, d = n.endInsCode, m = n.key, p = n.type, v = t === "label" ? u : s, f = r; f < i; ) {
    var y = v.value(f);
    if (a.type[f] = p, a.key[f] = m, y > l || y === l && c.value(f) === d) break;
    f++;
  }
}
(function(e) {
  e.Descriptor = { name: "model_secondary_structure" }, e.Provider = Mo.create(e.Descriptor), e.fromStruct = function(t, n, r) {
    var i = /* @__PURE__ */ new Map(), a = [{ 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, n);
    (function(c, l, d, m) {
      if (c._rowCount)
        for (var p = c.beg_label_asym_id, v = c.beg_label_seq_id, f = c.beg_auth_seq_id, y = c.pdbx_beg_PDB_ins_code, h = c.end_label_seq_id, g = c.end_auth_seq_id, x = c.pdbx_end_PDB_ins_code, C = c.pdbx_PDB_helix_class, b = c.conf_type_id, _ = c.details, A = l === "label" ? v : f, I = l === "label" ? h : g, w = 0, E = c._rowCount; w < E; w++) {
          var D = Ft.create(C.valueKind(w) === 0 ? Ft.SecondaryStructurePdb[C.value(w)] : b.valueKind(w) === 0 ? Ft.SecondaryStructureMmcif[b.value(w)] : 536870912), T = { kind: "helix", flags: D, type_id: b.valueKind(w) === 0 ? b.value(w) : "HELIX_P", helix_class: C.value(w), details: _.valueKind(w) === 0 ? _.value(w) : void 0 }, P = { startSeqId: A.value(w), startInsCode: y.value(w), endSeqId: I.value(w), endInsCode: x.value(w), type: D, key: m.length };
          m[m.length] = T;
          var M = p.value(w);
          if (d.has(M)) {
            var R = d.get(M);
            R.has(P.startSeqId) ? R.get(P.startSeqId).push(P) : R.set(P.startSeqId, [P]);
          } else d.set(M, /* @__PURE__ */ new Map([[P.startSeqId, [P]]]));
        }
    })(t, o, i, a), function(c, l, d, m, p) {
      if (c._rowCount)
        for (var v = c.beg_label_asym_id, f = c.beg_label_seq_id, y = c.beg_auth_seq_id, h = c.pdbx_beg_PDB_ins_code, g = c.end_label_seq_id, x = c.end_auth_seq_id, C = c.pdbx_end_PDB_ins_code, b = c.sheet_id, _ = l === "label" ? f : y, A = l === "label" ? g : x, I = /* @__PURE__ */ new Map(), w = m + 1, E = 0, D = c._rowCount; E < D; E++) {
          var T = b.value(E), P = void 0;
          I.has(T) ? P = I.get(T) : (P = w++, I.set(T, P));
          var M = Ft.create(8388612), R = { kind: "sheet", flags: M, sheet_id: T, symmetry: void 0 }, O = { startSeqId: _.value(E), startInsCode: h.value(E), endSeqId: A.value(E), endInsCode: C.value(E), type: M, key: p.length };
          p[p.length] = R;
          var L = v.value(E);
          if (d.has(L)) {
            var F = d.get(L);
            F.has(O.startSeqId) ? F.get(O.startSeqId).push(O) : F.set(O.startSeqId, [O]);
          } else d.set(L, /* @__PURE__ */ new Map([[O.startSeqId, [O]]]));
        }
    }(n, o, i, t._rowCount, a);
    var s = r.residues._rowCount, u = { type: new Int32Array(s), key: new Int32Array(s), elements: a };
    return i.size > 0 && function(c, l, d, m) {
      for (var p = c.chainAtomSegments.count, v = c.chains.label_asym_id, f = c.residues, y = f.auth_seq_id, h = f.label_seq_id, g = f.pdbx_PDB_ins_code, x = l === "label" ? h : y, C = 0; C < p; C++) {
        var b = Ac.chainStartResidueIndex(c, C), _ = Ac.chainEndResidueIndexExcl(c, C), A = v.value(C);
        if (d.has(A)) for (var I = d.get(A), w = b; w < _; w++) {
          var E = x.value(w);
          if (I.has(E)) for (var D = 0, T = I.get(E); D < T.length; D++) {
            var P = T[D], M = g.value(w);
            P.startInsCode === M && vD(c, l, P, w, _, m);
          }
        }
      }
    }(r, o, i, u), F9(u.type, u.key, u.elements, function(c) {
      return c;
    });
  };
})(gf || (gf = {}));
var Su, ef, gD = { U: wt.atom_site_anisotrop.U, U_esd: wt.atom_site_anisotrop.U_esd };
(function(e) {
  e.Schema = gD, e.Descriptor = { name: "atom_site_anisotrop", cifExport: { prefix: "", categories: [{ name: "atom_site_anisotrop", instance: function(t) {
    return e.Provider.get(t.firstModel) && _n.is(t.firstModel.sourceData) ? Ar.Category.ofTable(t.firstModel.sourceData.data.db.atom_site_anisotrop) : Ar.Category.Empty;
  } }] } }, e.Provider = Mo.create(e.Descriptor), e.getElementToAnsiotrop = function(t, n) {
    var r = new Int32Array(t.rowCount);
    r.fill(-1);
    for (var i = 0, a = t.rowCount; i < a; i++) r[t.value(i)] = i;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), i = 0, a = n.rowCount; i < a; ++i) {
      var s = r[n.value(i)];
      s !== -1 && (o[s] = i);
    }
    return o;
  }, e.getElementToAnsiotropFromLabel = function(t, n) {
    for (var r = {}, i = 0, a = t.rowCount; i < a; i++) r[t.value(i)] = i;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), i = 0, a = n.rowCount; i < a; ++i) {
      var s = r[n.value(i)];
      s !== void 0 && (o[s] = i);
    }
    return o;
  };
})(Su || (Su = {})), function(e) {
  var t, n = "molstar_global_model_transform_info";
  function r(i) {
    return e.Provider.get(i);
  }
  e.Schema = ((t = {})[n] = { matrix: X.Schema.Matrix(4, 4, X.Schema.float) }, t), e.Descriptor = no({ name: n, cifExport: { categories: [{ name: n, instance: function(i) {
    var a = r(i.firstModel);
    if (!a) return Ar.Category.Empty;
    var o = Jt.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
    return Ar.Category.ofTable(o);
  } }], prefix: "molstar" } }), e.Provider = Mo.create(e.Descriptor), e.attach = function(i, a) {
    i.customProperties.has(e.Descriptor) || i.customProperties.add(e.Descriptor), e.Provider.set(i, a);
  }, e.get = r, e.fromMmCif = function(i) {
    if (_n.is(i.sourceData)) {
      var a = i.sourceData.data.frame.categories[n];
      if (a) {
        var o, s = (o = e.Schema[n], new J7(a, o, !0));
        if (s._rowCount !== 0) return s.matrix.value(0);
      }
    }
  }, e.hasData = function(i) {
    if (!_n.is(i.sourceData)) return !1;
    var a = i.sourceData.data.frame.categories[n];
    return !!a && a.rowCount > 0;
  }, e.writeMmCif = function(i, a) {
    i.writeCategory({ name: n, instance: function() {
      var o = Jt.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
      return Ar.Category.ofTable(o);
    } });
  };
}(ef || (ef = {})), wt.atom_site.label_comp_id, wt.atom_site.label_seq_id, wt.atom_site.pdbx_PDB_ins_code, wt.atom_site.label_asym_id, wt.atom_site.label_entity_id, wt.atom_site.auth_atom_id, wt.atom_site.auth_seq_id, wt.atom_site.auth_asym_id, B(B({}, wt.chem_comp_bond), { molstar_protonation_variant: X.Schema.Str() });
var yD = B(B({}, wt.chem_comp), { type: X.Schema.Aliased(X.Schema.str) });
function bD(e, t) {
  var n = t.ihm_model_group, r = t.ihm_model_group_link, i = Jt.pickRow(r, function(o) {
    return r.model_id.value(o) === e;
  });
  if (i) {
    var a = Jt.pickRow(n, function(o) {
      return n.id.value(o) === i.group_id;
    });
    if (a) return a.name;
  }
  return "";
}
function t5(e) {
  for (var t = 0, n = e.rowCount; t < n; t++) if (e.valueKind(t) === 0) return !0;
  return !1;
}
function g1(e, t, n) {
  e[t].isDefined && t5(e[t]) || (e[t] = e[n]), e[n].isDefined && t5(e[n]) || (e[n] = e[t]);
}
var _n, Gi = { entry: wt.entry, struct: wt.struct, struct_asym: wt.struct_asym, ihm_model_list: wt.ihm_model_list, ihm_model_group: wt.ihm_model_group, ihm_model_group_link: wt.ihm_model_group_link, entity: wt.entity, entity_poly: wt.entity_poly, entity_poly_seq: wt.entity_poly_seq, pdbx_entity_branch: wt.pdbx_entity_branch, chem_comp: yD, pdbx_chem_comp_identifier: wt.pdbx_chem_comp_identifier, atom_site: wt.atom_site, ihm_sphere_obj_site: wt.ihm_sphere_obj_site, ihm_gaussian_obj_site: wt.ihm_gaussian_obj_site, pdbx_unobs_or_zero_occ_residues: wt.pdbx_unobs_or_zero_occ_residues, pdbx_molecule: wt.pdbx_molecule };
function Bu(e, t) {
  t === void 0 && (t = !1);
  for (var n = /* @__PURE__ */ Object.create(null), r = 0, i = Object.keys(Gi); r < i.length; r++) {
    var a = i[r];
    n[a] = a in e ? e[a] : Jt.ofUndefinedColumns(Gi[a], 0);
  }
  return t && (n.atom_site = function(o) {
    var s = Jt.ofColumns(o._schema, o);
    return g1(s, "label_atom_id", "auth_atom_id"), g1(s, "label_comp_id", "auth_comp_id"), g1(s, "label_seq_id", "auth_seq_id"), g1(s, "label_asym_id", "auth_asym_id"), s;
  }(n.atom_site)), n;
}
function G9(e) {
  var t = _n.fromFrame(e), n = Bu(t.data.db, !0);
  return At.create("Create mmCIF Model", function(r) {
    return Ps(n, t, r);
  });
}
Vr.Provider.formatRegistry.add("mmCIF", function(e) {
  if (_n.is(e.sourceData)) return Vr.fromData(e.sourceData.data.db);
}), gf.Provider.formatRegistry.add("mmCIF", function(e) {
  if (_n.is(e.sourceData)) {
    var t = e.sourceData.data.db, n = t.struct_conf, r = t.struct_sheet_range;
    return gf.fromStruct(n, r, e.atomicHierarchy);
  }
}), Su.Provider.formatRegistry.add("mmCIF", function(e) {
  if (_n.is(e.sourceData)) {
    var t = e.sourceData.data.db.atom_site_anisotrop;
    return { data: Jt.ofColumns(Su.Schema, t), elementToAnsiotrop: Su.getElementToAnsiotrop(e.atomicConformation.atomId, t.id) };
  }
}, function(e) {
  return !!_n.is(e.sourceData) && e.sourceData.data.db.atom_site_anisotrop.U.isDefined;
}), vf.Provider.formatRegistry.add("mmCIF", function(e) {
  if (_n.is(e.sourceData)) {
    var t = e.sourceData.data.db.chem_comp_bond;
    if (t._rowCount !== 0) return { data: t, entries: vf.getEntriesFromChemCompBond(t) };
  }
}), Do.Provider.formatRegistry.add("mmCIF", function(e) {
  if (_n.is(e.sourceData)) {
    var t = e.sourceData.data.db.struct_conn;
    if (t._rowCount !== 0) {
      var n = Do.getEntriesFromStructConn(t, e);
      return { data: t, byAtomIndex: Do.getAtomIndexFromEntries(n), entries: n };
    }
  }
}), ef.Provider.formatRegistry.add("mmCIF", ef.fromMmCif, ef.hasData), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mmCIF";
  }, e.fromFrame = function(t, n, r) {
    return n || (n = L9.mmCIF(t)), { kind: "mmCIF", name: n._name, data: { db: n, frame: t, source: r } };
  };
}(_n || (_n = {}));
var yt, _D = 9, y1 = -27.888, xD = -0.5, n5 = -9.9;
function SD(e, t, n, r) {
  var i = S.distance(e, r), a = S.distance(t, r), o = S.distance(t, n), s = S.distance(e, n), u = y1 / i - y1 / a + (y1 / o - y1 / s);
  return u < n5 ? n5 : u;
}
function CD(e, t, n) {
  for (var r = t.residueIndices, i = t.cIndices, a = 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 = r.length, m = [], p = [], v = [], f = S(), y = S(), h = S(), g = S(), x = S(), C = S(), b = S(), _ = 0, A = r.length; _ < A; ++_) {
    var I = _, w = r[_], E = s[I], D = i[I], T = l[w];
    if (E !== -1 && D !== -1 && u.findAtomOnResidue(w, "OXT") === -1) {
      c(E, f), c(D, y), c(T, h);
      for (var P = n.find(h[0], h[1], h[2], _D), M = P.indices, R = P.count, O = 0; O < R; ++O) {
        var L = M[O];
        if (L !== I && L - 1 !== I && L + 1 !== I) {
          var F = o[L];
          if (F !== -1) {
            c(F, g);
            var G = a[L];
            if (G === -1) {
              if (L === 0) continue;
              var V = L - 1, U = s[V], q = i[V];
              if (U === -1 || q === -1) continue;
              c(U, b), c(q, C), S.sub(x, C, b);
              var H = S.distance(b, C);
              S.scaleAndAdd(x, g, x, 1 / H);
            } else c(G, x);
            var K = SD(f, y, g, x);
            K > xD || (m[m.length] = I, p[p.length] = L, v[v.length] = K);
          }
        }
      }
    }
  }
  return function(j, W, Z, Y) {
    for (var te = new Ui.DirectedEdgeBuilder(j, W, Z), ee = new Float32Array(te.slotCount), $ = 0, ue = te.edgeCount; $ < ue; $++) te.addNextEdge(), te.assignProperty(ee, Y[$]);
    return te.createGraph({ energies: Y });
  }(d, m, p, v);
}
(function(e) {
  e.is = Qr.has, e.create = Qr.create;
})(yt || (yt = {}));
var b1 = function(e, t, n) {
  this.partner1 = Math.min(e, t), this.partner2 = Math.max(e, t), this.type = n;
};
function AD(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 ID(e, t) {
  return e.type === t.type && t.firstStart - e.firstEnd < 6 && e.firstStart < t.firstStart && t.nextLadder === 0 && (e.type === 0 ? r5(e, t) : r5(t, e));
}
function r5(e, t) {
  return t.secondStart - e.secondEnd > 0 && (t.secondStart - e.secondEnd < 6 && t.firstStart - e.firstEnd < 3 || t.secondStart - e.secondEnd < 3);
}
function i5(e) {
  return yt.is(e, 8) || yt.is(e, 1) || yt.is(e, 16);
}
var Rl, wD = { oldDefinition: N.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: N.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" }) };
function V9(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _;
    return ne(this, function(A) {
      for (n = function(I) {
        for (var w = I.model.atomicHierarchy.index, E = I.proteinElements, D = I.residueIndex, T = E.length, P = new Uint32Array(T), M = new Int32Array(T), R = new Int32Array(T), O = new Int32Array(T), L = new Int32Array(T), F = 0; F < T; ++F) {
          var G = D[E[F]];
          P[F] = G, M[F] = w.findAtomOnResidue(G, "C"), R[F] = w.findAtomOnResidue(G, "H"), O[F] = w.findAtomOnResidue(G, "O"), L[F] = w.findAtomOnResidue(G, "N");
        }
        return { residueIndices: _e.ofSortedArray(P), cIndices: M, hIndices: R, oIndices: O, nIndices: L };
      }(e), r = n.residueIndices, i = function(I, w) {
        for (var E = I.model.atomicConformation, D = E.x, T = E.y, P = E.z, M = I.model.atomicHierarchy.derived.residue.traceElementIndex, R = new Uint32Array(w.length), O = 0, L = w.length; O < L; ++O) R[O] = M[w[O]];
        var F = { x: D, y: T, z: P, indices: _e.ofSortedArray(R) };
        return xc(F, Dl(F));
      }(e, r), a = CD(e, n, i), o = r.length, s = new Uint32Array(o), u = function(I, w) {
        var E = w.cIndices, D = w.nIndices, T = w.residueIndices, P = I.conformation.position, M = I.model.atomicHierarchy.index, R = I.model.atomicHierarchy.derived.residue.traceElementIndex, O = T.length, L = function(ee, $) {
          return ee === -1 ? S.setNaN($) : P(ee, $);
        }, F = S(), G = S(), V = S(), U = S(), q = S(), H = S(), K = S(), j = S(), W = S();
        if (O === 0) return { phi: new Float32Array(0), psi: new Float32Array(0) };
        var Z = new Float32Array(O - 1), Y = new Float32Array(O - 1);
        L(-1, F), L(-1, G), L(-1, V), L(E[0], U), L(R[T[0]], q), L(D[0], H), L(E[1], K), L(R[T[1]], j), L(D[1], W);
        for (var te = 0; te < O - 1; ++te) M.findAtomOnResidue(T[te], "OXT") === -1 && (Z[te] = $r(S.dihedralAngle(F, H, q, U)), Y[te] = $r(S.dihedralAngle(H, q, U, W)), F = U, G = q, V = H, U = K, q = j, H = W, L(E[te + 1], K), L(R[T[te + 1]], j), L(D[te + 1], W));
        return { phi: Z, psi: Y };
      }(e, n), c = [], l = [], d = t.oldDefinition ? TD : DD, m = t.oldOrdering ? MD : BD, function(I) {
        for (var w = I.proteinInfo, E = I.hbonds, D = I.flags, T = [1024, 2048, 4096, 128, 256, 512], P = 0; P < 3; P++) for (var M = 0, R = w.residueIndices.length - 1; M < R; ++M) if (E.getDirectedEdgeIndex(M, M + P + 3) !== -1) if (D[M] |= T[P + 3] | T[P], I.params.oldDefinition) for (var O = 1; O < P + 3; ++O) D[M + O] |= 64 | T[P + 3];
        else for (O = 0; O <= P + 3; ++O) D[M + O] |= 64 | T[P + 3];
      }(p = { params: t, getResidueFlag: d, getFlagName: m, unit: e, proteinInfo: n, flags: s, hbonds: a, torsionAngles: u, ladders: c, bridges: l }), function(I) {
        for (var w = I.proteinInfo, E = I.flags, D = w.residueIndices.length, T = [1024, 2048, 4096, 128, 256, 512], P = [0, 0, 0, 8, 1, 16], M = I.params.oldOrdering ? [4, 3, 5] : [3, 4, 5], R = 0; R < M.length; R++) for (var O = M[R], L = 1, F = D - O; L < F; L++) {
          var G = yt.create(E[L]), V = yt.create(E[L - 1]), U = yt.create(E[L + 1]);
          if (I.params.oldOrdering) {
            if (O === 3 && (yt.is(G, 1) || yt.is(U, 1)) || O === 5 && (yt.is(G, 1) || yt.is(G, 8) || yt.is(U, 1) || yt.is(U, 8))) continue;
          } else if (O === 4 && (yt.is(G, 8) || yt.is(U, 8)) || O === 5 && (yt.is(G, 1) || yt.is(G, 8) || yt.is(U, 1) || yt.is(U, 8))) continue;
          if (yt.is(G, T[O]) && yt.is(G, T[O - 3]) && yt.is(V, T[O]) && yt.is(V, T[O - 3])) if (I.params.oldDefinition) for (var q = 0; q < O; q++) E[L + q] |= P[O];
          else for (q = -1; q <= O; q++) E[L + q] |= P[O];
        }
      }(p), function(I) {
        var w = I.unit, E = I.flags, D = I.proteinInfo, T = w.conformation.position, P = w.model.atomicHierarchy.derived.residue.traceElementIndex, M = D.residueIndices, R = D.nIndices, O = M.length, L = function(ke, Oe) {
          return ke === -1 ? S.setNaN(Oe) : T(ke, Oe);
        }, F = S(), G = S(), V = S(), U = S(), q = S(), H = S(), K = S();
        e: for (var j = 2; j < O - 2; j++) {
          for (var W = 0; W < 4; W++) {
            var Z = j + W - 2;
            if (L(P[Z], U), L(R[Z + 1], q), S.squaredDistance(U, q) > 6.25) continue e;
          }
          var Y = M[j - 2], te = M[j], ee = M[j + 2], $ = P[Y], ue = P[te], se = P[ee];
          L($, F), L(ue, G), L(se, V), S.sub(H, F, G), S.sub(K, G, V);
          var be = $r(S.angle(H, K));
          be && be > 70 && (E[j] |= 32);
        }
      }(p), function(I) {
        for (var w, E, D = I.proteinInfo, T = I.hbonds, P = I.flags, M = I.bridges, R = T.offset, O = T.b, L = 0, F = D.residueIndices.length; L < F; ++L) for (var G = R[L], V = R[L + 1]; G < V; G++) {
          var U = O[G];
          L > U || ((w = L + 1) !== (E = U) && T.getDirectedEdgeIndex(E, w + 1) !== -1 && (P[w] |= 2, P[E] |= 2, M[M.length] = new b1(w, E, 0)), (w = L) !== (E = U - 1) && T.getDirectedEdgeIndex(E - 1, w) !== -1 && (P[w] |= 2, P[E] |= 2, M[M.length] = new b1(E, w, 0)), (w = L) !== (E = U) && T.getDirectedEdgeIndex(E, w) !== -1 && (P[w] |= 2, P[E] |= 2, M[M.length] = new b1(E, w, 1)), (w = L + 1) !== (E = U - 1) && T.getDirectedEdgeIndex(E - 1, w + 1) !== -1 && (P[w] |= 2, P[E] |= 2, M[M.length] = new b1(E, w, 1)));
        }
        M.sort(function(q, H) {
          return q.partner1 > H.partner1 ? 1 : q.partner1 < H.partner1 ? -1 : 0;
        });
      }(p), function(I) {
        for (var w = I.bridges, E = I.ladders, D = 0; D < w.length; D++) {
          for (var T = w[D], P = !1, M = 0; M < E.length; M++) {
            var R = E[M];
            AD(R, T) && (P = !0, R.firstEnd++, T.type === 0 ? R.secondEnd++ : R.secondStart--);
          }
          P || (E[E.length] = { previousLadder: 0, nextLadder: 0, firstStart: T.partner1, firstEnd: T.partner1, secondStart: T.partner2, secondEnd: T.partner2, type: T.type });
        }
        for (var O = 0; O < E.length; O++) for (var L = E[O], F = O; F < E.length; F++) {
          var G = E[F];
          ID(L, G) && (L.nextLadder = F, G.previousLadder = O);
        }
      }(p), function(I) {
        for (var w = I.ladders, E = I.flags, D = 0; D < w.length; D++) {
          for (var T = w[D], P = T.firstStart; P <= T.firstEnd; P++) {
            var M = T.firstStart - P, R = T.secondStart - M;
            T.firstStart !== T.firstEnd ? (E[P] |= 4, E[R] |= 4) : (!i5(E[P]) && yt.is(E[P], 4) && (E[P] |= 2), !i5(E[R]) && yt.is(E[R], 4) && (E[R] |= 2));
          }
          if (T.nextLadder !== 0) {
            var O = w[T.nextLadder];
            for (P = T.firstStart; P <= O.firstEnd; P++) E[P] |= 4;
            if (T.type === 0) for (P = T.secondStart; P <= O.secondEnd; P++) E[P] |= 4;
            else for (P = O.secondEnd; P <= T.secondStart; P++) E[P] |= 4;
          }
        }
      }(p), v = function(I, w) {
        for (var E = new Uint32Array(I.length), D = 0, T = I.length; D < T; ++D) {
          var P = yt.create(I[D]);
          E[D] = w(P);
        }
        return E;
      }(s, d), f = new Uint32Array(o), y = [], h = [], g = function(I) {
        return _e.indexOf(r, I);
      }, x = 0, C = r.length; x < C; ++x) b = v[x], f[x] = b, _ = d(s[x]), h.length !== 0 && _ === h[h.length - 1].flags || (h[h.length] = PD(ED(b), s[x], d)), y[x] = h.length - 1;
      return [2, F9(f, y, h, g)];
    });
  });
}
function PD(e, t, n) {
  return e === "helix" ? { kind: "helix", flags: n(t) } : e === "sheet" ? { kind: "sheet", flags: n(t) } : e === "turn" || e === "bend" ? { kind: "turn", flags: n(t) } : { kind: "none" };
}
function ED(e) {
  return e === Ft.SecondaryStructureDssp.H || e === Ft.SecondaryStructureDssp.G || e === Ft.SecondaryStructureDssp.I ? "helix" : e === Ft.SecondaryStructureDssp.B || e === Ft.SecondaryStructureDssp.E ? "sheet" : e === Ft.SecondaryStructureDssp.T ? "turn" : e === Ft.SecondaryStructureDssp.S ? "bend" : "none";
}
function TD(e) {
  return yt.is(e, 1) ? Ft.SecondaryStructureDssp.H : yt.is(e, 4) ? Ft.SecondaryStructureDssp.E : yt.is(e, 2) ? Ft.SecondaryStructureDssp.B : yt.is(e, 8) ? Ft.SecondaryStructureDssp.G : yt.is(e, 16) ? Ft.SecondaryStructureDssp.I : yt.is(e, 64) ? Ft.SecondaryStructureDssp.T : yt.is(e, 32) ? Ft.SecondaryStructureDssp.S : 0;
}
function MD(e) {
  return yt.is(e, 1) ? "H" : yt.is(e, 4) ? "E" : yt.is(e, 2) ? "B" : yt.is(e, 8) ? "G" : yt.is(e, 16) ? "I" : yt.is(e, 64) ? "T" : yt.is(e, 32) ? "S" : "-";
}
function DD(e) {
  return yt.is(e, 16) ? Ft.SecondaryStructureDssp.I : yt.is(e, 1) ? Ft.SecondaryStructureDssp.H : yt.is(e, 4) ? Ft.SecondaryStructureDssp.E : yt.is(e, 2) ? Ft.SecondaryStructureDssp.B : yt.is(e, 8) ? Ft.SecondaryStructureDssp.G : yt.is(e, 64) ? Ft.SecondaryStructureDssp.T : yt.is(e, 32) ? Ft.SecondaryStructureDssp.S : 0;
}
function BD(e) {
  return yt.is(e, 16) ? "I" : yt.is(e, 1) ? "H" : yt.is(e, 4) ? "E" : yt.is(e, 2) ? "B" : yt.is(e, 8) ? "G" : yt.is(e, 64) ? "T" : yt.is(e, 32) ? "S" : "-";
}
function z9(e) {
  var t = "model";
  if (e) {
    t = "model";
    for (var n = 0, r = e.models.length; n < r; ++n) {
      var i = e.models[n];
      if (!pn.isFromPdbArchive(i) && !pn.hasSecondaryStructure(i)) {
        t = "dssp";
        break;
      }
    }
  }
  return { type: N.MappedStatic(t, { model: N.EmptyGroup({ label: "Model" }), dssp: N.Group(wD, { label: "DSSP", isFlat: !0 }) }, { options: [["model", "Model"], ["dssp", "DSSP"]] }) };
}
(function(e) {
  function t(n) {
    var r = this, i = n.descriptor.name, a = n.type === "root" ? "inheritedPropertyData" : "currentPropertyData", o = function(u) {
      return i in u[a] || (u[a][i] = { props: B({}, N.getDefaultValues(n.getParams(u))), data: lu.create(void 0) }), u[a][i];
    }, s = function(u, c, l) {
      var d = o(u);
      u[a][i] = { props: c, data: lu.withValue(d.data, l) };
    };
    return { label: n.label, descriptor: n.descriptor, isHidden: n.isHidden, getParams: function(u) {
      var c = N.clone(n.getParams(u));
      return N.setDefaultValues(c, o(u).props), c;
    }, defaultParams: n.defaultParams, isApplicable: n.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), ie(r, 0, void 0, function() {
        var m, p, v, f, y, h;
        return ne(this, function(g) {
          switch (g.label) {
            case 0:
              return d && c.customPropertyDescriptors.reference(n.descriptor, !0), n.type === "root" && (c = c.root), m = o(c.root).props, p = o(c), v = N.merge(n.defaultParams, m, l), p.data.value && N.areEqual(n.defaultParams, p.props, v) ? [2] : [4, n.obtain(u, c, v)];
            case 1:
              return f = g.sent(), y = f.value, h = f.assets, c.customPropertyDescriptors.add(n.descriptor), c.customPropertyDescriptors.assets(n.descriptor, h), s(c, v, y), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customPropertyDescriptors.reference(n.descriptor, c);
    }, get: function(u) {
      return o(u).data;
    }, set: function(u, c, l) {
      c === void 0 && (c = {}), n.type === "root" && (u = u.root);
      var d = o(u), m = N.merge(n.defaultParams, d.props, c);
      N.areEqual(n.defaultParams, d.props, m) || (s(u, m, l), u.customPropertyDescriptors.assets(n.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(n, r, i) {
    var a = this, o = { value: N.Value(i, { isHidden: !0 }) };
    return t({ label: To(n), descriptor: no({ name: n }), isHidden: !0, type: r, defaultParams: o, getParams: function() {
      return { value: N.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return ie(a, 0, void 0, function() {
        return ne(this, function(l) {
          return [2, B(B({}, N.getDefaultValues(o)), c)];
        });
      });
    } });
  };
})(Rl || (Rl = {}));
var a5 = z9(), ei = Rl.createProvider({ label: "Secondary Structure", descriptor: no({ name: "molstar_computed_secondary_structure" }), type: "root", defaultParams: a5, getParams: z9, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, n) {
  return ie(void 0, 0, void 0, function() {
    var r, i, a;
    return ne(this, function(o) {
      switch (o.label) {
        case 0:
          switch (r = B(B({}, N.getDefaultValues(a5)), n), r.type.name) {
            case "dssp":
              return [3, 1];
            case "model":
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return i = {}, [4, RD(t, r.type.params)];
        case 2:
          return [2, (i.value = o.sent(), i)];
        case 3:
          return a = {}, [4, kD(t)];
        case 4:
          return [2, (a.value = o.sent(), a)];
        case 5:
          return [2];
      }
    });
  });
} });
function RD(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          n = /* @__PURE__ */ new Map(), r = 0, i = e.unitSymmetryGroups.length, s.label = 1;
        case 1:
          return r < i ? (a = e.unitSymmetryGroups[r].units[0], !me.isAtomic(a) || pn.isCoarseGrained(a.model) ? [3, 3] : [4, V9(a, t)]) : [3, 4];
        case 2:
          o = s.sent(), n.set(a.invariantId, o), s.label = 3;
        case 3:
          return ++r, [3, 1];
        case 4:
          return [2, n];
      }
    });
  });
}
function kD(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a;
    return ne(this, function(o) {
      switch (o.label) {
        case 0:
          t = /* @__PURE__ */ new Map(), n = 0, r = e.unitSymmetryGroups.length, o.label = 1;
        case 1:
          return n < r ? (i = e.unitSymmetryGroups[n].units[0], me.isAtomic(i) ? pn.isFromPdbArchive(i.model) || pn.hasSecondaryStructure(i.model) ? [3, 3] : [4, V9(i, { oldDefinition: !0, oldOrdering: !0 })] : [3, 4]) : [3, 5];
        case 2:
          return a = o.sent(), t.set(i.invariantId, a), [3, 4];
        case 3:
          (a = gf.Provider.get(i.model)) && t.set(i.invariantId, a), o.label = 4;
        case 4:
          return ++n, [3, 1];
        case 5:
          return [2, t];
      }
    });
  });
}
function An() {
  throw new Error("Property only available for atomic models.");
}
function jo(e) {
  throw e ? new Error("Property only available for coarse models (".concat(e, ").")) : new Error("Property only available for coarse models.");
}
var Vd = { 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 me.isAtomic(e.unit) ? e.unit.model.atomicConformation.atomId.value(e.element) : An();
}, occupancy: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicConformation.occupancy.value(e.element) : An();
}, B_iso_or_equiv: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicConformation.B_iso_or_equiv.value(e.element) : An();
}, sourceIndex: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atomSourceIndex.value(e.element) : e.element;
}, type_symbol: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element) : An();
}, label_atom_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_atom_id.value(e.element) : An();
}, auth_atom_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_atom_id.value(e.element) : An();
}, label_alt_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_alt_id.value(e.element) : An();
}, label_comp_id: jg, auth_comp_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_comp_id.value(e.element) : An();
}, pdbx_formal_charge: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.element) : An();
}, vdw_radius: function(e) {
  return me.isAtomic(e.unit) ? M0(e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element)) : An();
}, cdr: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.cdr.value(e.element) : An();
}, em_confidence: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.em_confidence.value(e.element) : An();
} };
function jg(e) {
  return me.isAtomic(e.unit) || An(), e.unit.model.atomicHierarchy.atoms.label_comp_id.value(e.element);
}
function cv(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.label_seq_id.value(e.unit.residueIndex[e.element]) : An();
}
function o5(e) {
  me.isAtomic(e.unit) || An();
  var t = e.unit.model.sequence.byEntityKey[gi(e)];
  return t && t.sequence.microHet.get(cv(e)) || [jg(e)];
}
var OD = { key: function(e) {
  return me.isAtomic(e.unit) ? e.unit.residueIndex[e.element] : An();
}, group_PDB: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.group_PDB.value(e.unit.residueIndex[e.element]) : An();
}, label_seq_id: cv, auth_seq_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.auth_seq_id.value(e.unit.residueIndex[e.element]) : An();
}, pdbx_PDB_ins_code: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.unit.residueIndex[e.element]) : An();
}, isNonStandard: function(e) {
  return me.isAtomic(e.unit) ? o5(e).some(function(t) {
    return e.unit.model.properties.chemicalComponentMap.get(t).mon_nstd_flag[0] === "n";
  }) : An();
}, hasMicroheterogeneity: function(e) {
  me.isAtomic(e.unit) || An();
  var t = e.unit.model.sequence.byEntityKey[gi(e)];
  return t && t.sequence.microHet.has(cv(e));
}, microheterogeneityCompIds: o5, secondary_structure_type: function(e) {
  var t;
  me.isAtomic(e.unit) || An();
  var n = (t = ei.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return n ? n.type[n.getIndex(e.unit.residueIndex[e.element])] : 536870912;
}, secondary_structure_key: function(e) {
  var t;
  me.isAtomic(e.unit) || An();
  var n = (t = ei.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return n ? n.key[n.getIndex(e.unit.residueIndex[e.element])] : -1;
}, chem_comp_type: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.properties.chemicalComponentMap.get(jg(e)).type : An();
} }, ND = { key: function(e) {
  return me.isAtomic(e.unit) ? e.unit.chainIndex[e.element] : An();
}, label_asym_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_asym_id.value(e.unit.chainIndex[e.element]) : An();
}, auth_asym_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.auth_asym_id.value(e.unit.chainIndex[e.element]) : An();
}, label_entity_id: function(e) {
  return me.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_entity_id.value(e.unit.chainIndex[e.element]) : An();
} }, LD = { key: Vd.key, entityKey: function(e) {
  return me.isCoarse(e.unit) ? e.unit.coarseElements.entityKey[e.element] : jo();
}, x: Vd.x, y: Vd.y, z: Vd.z, asym_id: function(e) {
  return me.isCoarse(e.unit) ? e.unit.coarseElements.asym_id.value(e.element) : jo();
}, entity_id: function(e) {
  return me.isCoarse(e.unit) ? e.unit.coarseElements.entity_id.value(e.element) : jo();
}, seq_id_begin: function(e) {
  return me.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_begin.value(e.element) : jo();
}, seq_id_end: function(e) {
  return me.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_end.value(e.element) : jo();
}, sphere_radius: function(e) {
  return me.isSpheres(e.unit) ? e.unit.coarseConformation.radius[e.element] : jo("spheres");
}, sphere_rmsf: function(e) {
  return me.isSpheres(e.unit) ? e.unit.coarseConformation.rmsf[e.element] : jo("spheres");
}, gaussian_weight: function(e) {
  return me.isGaussians(e.unit) ? e.unit.coarseConformation.weight[e.element] : jo("gaussians");
}, gaussian_covariance_matrix: function(e) {
  return me.isGaussians(e.unit) ? e.unit.coarseConformation.covariance_matrix[e.element] : jo("gaussians");
} };
function gi(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 FD = { key: gi, id: function(e) {
  return e.unit.model.entities.data.id.value(gi(e));
}, type: function(e) {
  return e.unit.model.entities.data.type.value(gi(e));
}, src_method: function(e) {
  return e.unit.model.entities.data.src_method.value(gi(e));
}, pdbx_description: function(e) {
  return e.unit.model.entities.data.pdbx_description.value(gi(e));
}, formula_weight: function(e) {
  return e.unit.model.entities.data.formula_weight.value(gi(e));
}, pdbx_number_of_molecules: function(e) {
  return e.unit.model.entities.data.pdbx_number_of_molecules.value(gi(e));
}, details: function(e) {
  return e.unit.model.entities.data.details.value(gi(e));
}, pdbx_mutation: function(e) {
  return e.unit.model.entities.data.pdbx_mutation.value(gi(e));
}, pdbx_fragment: function(e) {
  return e.unit.model.entities.data.pdbx_fragment.value(gi(e));
}, pdbx_ec: function(e) {
  return e.unit.model.entities.data.pdbx_ec.value(gi(e));
}, subtype: function(e) {
  return e.unit.model.entities.subtype.value(gi(e));
}, prd_id: function(e) {
  var t, n;
  return (n = (t = e.unit.model.entities.prd_id) === null || t === void 0 ? void 0 : t.value(gi(e))) !== null && n !== void 0 ? n : "";
} }, GD = [], VD = { id: function(e) {
  return e.unit.id;
}, chainGroupId: function(e) {
  return e.unit.chainGroupId;
}, multiChain: function(e) {
  return me.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) || xn.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) || GD;
}, struct_ncs_oper_id: function(e) {
  return e.unit.conformation.operator.ncsId;
} }, Me = { constant: { true: function(e) {
  return !0;
}, false: function(e) {
  return !1;
}, zero: function(e) {
  return 0;
} }, atom: Vd, residue: OD, chain: ND, entity: FD, unit: VD, coarse: LD }, tf = function() {
  function e(t) {
    var n;
    this.index = /* @__PURE__ */ new Map(), this.checkOperator = !1, this.checkOperator = (n = t == null ? void 0 : t.checkOperator) !== null && n !== void 0 && n;
  }
  return e.prototype.add = function(t) {
    var n = this.index.get(t.label_asym_id);
    n || (n = /* @__PURE__ */ new Map(), this.index.set(t.label_asym_id, n));
    var r = n.get(t.label_seq_id);
    return r || (r = [], n.set(t.label_seq_id, r)), !this._find(t, r) && (r.push(t), !0);
  }, e.prototype.hasLabelAsymId = function(t) {
    return this.index.has(t);
  }, e.prototype.has = function(t) {
    var n, r, i = s5(t);
    if (this.index.has(i)) {
      var a = this.index.get(i), o = u5(t);
      if (a.has(o)) for (var s = a.get(o), u = c5(t), c = l5(t), l = d5(t), d = (n = f5(t)) !== null && n !== void 0 ? n : "1_555", m = 0, p = s; m < p.length; m++) {
        var v = p[m];
        if (v.label_comp_id === u && v.label_alt_id === c && v.ins_code === l && (!this.checkOperator || ((r = v.operator_name) !== null && r !== void 0 ? r : "1_555") === d)) return v;
      }
    }
  }, e.getLabel = function(t, n) {
    var r;
    return n === void 0 && (n = !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(n ? " " + ((r = t.operator_name) !== null && r !== void 0 ? r : "1_555") : "");
  }, e.getEntryFromLocation = function(t) {
    var n;
    return { label_asym_id: s5(t), label_comp_id: c5(t), label_seq_id: u5(t), label_alt_id: l5(t), ins_code: d5(t), operator_name: (n = f5(t)) !== null && n !== void 0 ? n : "1_555" };
  }, e.prototype._find = function(t, n) {
    for (var r, i, a = 0, o = n; a < o.length; a++) {
      var s = o[a];
      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 || ((r = s.operator_name) !== null && r !== void 0 ? r : "1_555") === ((i = t.operator_name) !== null && i !== void 0 ? i : "1_555"))) return !0;
    }
    return !1;
  }, e;
}(), s5 = Me.chain.label_asym_id, u5 = Me.residue.label_seq_id, c5 = Me.atom.label_comp_id, l5 = Me.atom.label_alt_id, d5 = Me.residue.pdbx_PDB_ins_code, f5 = Me.unit.operator_name;
function Sl(e, t, n) {
  for (var r = t.subsetBuilder(!0), i = 0, a = n.units; i < a.length; i++) {
    var o = a[i];
    if (o.kind === 0) {
      var s = o.model.atomicHierarchy.residueAtomSegments, u = t.unitMap.get(o.id).elements, c = o.elements;
      r.beginUnit(o.id);
      for (var l = St.transientSegments(s, c); l.hasNext; ) for (var d = l.move().index, m = s.offsets[d], p = s.offsets[d + 1]; m < p; m++) _e.has(u, m) && r.addElement(m);
      r.commitUnit(), e.throwIfTimedOut();
    } else r.setUnit(o.id, o.elements);
  }
  return r.getStructure();
}
function Mp(e, t, n, r) {
  for (var i = new P0(t), a = t.lookup3d, o = r.radius, s = 0, u = n.units; s < u.length; s++) {
    for (var c = u[s], l = c.conformation, d = l.x, m = l.y, p = l.z, v = c.elements, f = 0, y = v.length; f < y; f++) {
      var h = v[f];
      a.findIntoBuilder(d(h), m(h), p(h), o, i);
    }
    e.throwIfTimedOut();
  }
  return r.wholeResidues ? Sl(e, t, i.getStructure()) : i.getStructure();
}
function m5(e, t, n, r) {
  var i = new P0(t), a = t.lookup3d, o = r.elementRadius, s = r.elementRadiusClosure, u = r.sourceMaxRadius, c = r.radius;
  e.pushCurrentElement(), e.element.structure = n;
  for (var l = 0, d = n.units; l < d.length; l++) {
    var m = d[l];
    e.element.unit = m;
    for (var p = m.conformation, v = p.x, f = p.y, y = p.z, h = m.elements, g = 0, x = h.length; g < x; g++) {
      var C = h[g];
      e.element.element = C;
      var b = o(e);
      a.findIntoBuilderWithRadius(v(C), f(C), y(C), b, u, c, s, i);
    }
    e.throwIfTimedOut();
  }
  return e.popCurrentElement(), r.wholeResidues ? Sl(e, t, i.getStructure()) : i.getStructure();
}
function zD(e, t) {
  return function(n) {
    return e.element.structure = n.structure, e.element.unit = n.unit, e.element.element = n.element, t(e);
  };
}
function UD(e, t) {
  var n = 0;
  e.element.structure = e.inputStructure;
  for (var r = 0, i = e.inputStructure.units; r < i.length; r++) {
    var a = i[r];
    e.element.unit = a;
    for (var o = a.elements, s = 0, u = o.length; s < u; s++) {
      var c = o[s];
      e.element.element = c;
      var l = t(e);
      l > n && (n = l);
    }
  }
  return e.throwIfTimedOut(), n;
}
function p5(e, t, n) {
  var r = function(i, a) {
    for (var o = i.inputStructure, s = o.interUnitBonds, u = new P0(o), c = i.atomicBond, l = 0, d = a.units; l < d.length; l++) {
      var m = d[l];
      if (m.kind === 0) {
        var p = o.unitMap.get(m.id), v = p.bonds, f = v.offset, y = v.b, h = v.edgeProps, g = h.flags, x = h.order;
        for (c.setStructure(o), c.a.unit = p, c.b.unit = p, V = 0, U = m.elements.length; V < U; V++) {
          u.addToUnit(m.id, m.elements[V]);
          for (var C = _e.indexOf(p.elements, m.elements[V]), b = f[C], _ = f[C + 1]; b < _; b++) {
            var A = y[b], I = p.elements[A];
            _e.has(m.elements, I) || u.has(m.id, I) || (c.aIndex = C, c.a.element = m.elements[V], c.bIndex = A, c.b.element = I, c.type = g[b], c.order = x[b], c.test(i, !0) && u.addToUnit(m.id, I));
          }
        }
        for (var w = 0, E = s.getConnectedUnits(p.id); w < E.length; w++) for (var D = E[w], T = a.unitMap.get(D.unitB), P = o.unitMap.get(D.unitB), M = 0, R = D.connectedIndices; M < R.length; M++) {
          var O = R[M];
          if (_e.has(m.elements, p.elements[O])) for (var L = 0, F = D.getEdges(O); L < F.length; L++) {
            var G = F[L];
            I = P.elements[G.indexB], T && _e.has(T.elements, I) || u.has(D.unitB, I) || (c.a.unit = p, c.aIndex = O, c.a.element = p.elements[O], c.b.unit = P, c.bIndex = G.indexB, c.b.element = I, c.type = G.props.flag, c.order = G.props.order, c.test(i, !0) && u.addToUnit(D.unitB, I));
          }
        }
      } else {
        u.beginUnit(m.id);
        for (var V = 0, U = m.elements.length; V < U; V++) u.addElement(m.elements[V]);
        u.commitUnit();
      }
    }
    return u.getStructure();
  }(e, n);
  return t ? Sl(e, e.inputStructure, r) : r;
}
var HD = Me.entity.type;
function qD(e) {
  return HD(e) === "water";
}
var Zm, Qm, jD = function() {
  function e() {
    this.vertices = /* @__PURE__ */ new Map(), this.edges = /* @__PURE__ */ new Map();
  }
  return e.prototype.addVertex = function(t, n) {
    this.vertices.has(n) || (this.vertices.set(n, t), this.edges.set(n, []));
  }, e.prototype.addEdge = function(t, n) {
    var r = tf.getLabel(t), i = tf.getLabel(n);
    this.addVertex(t, r), this.addVertex(n, i), Ca(this.edges.get(r), i), Ca(this.edges.get(i), r);
  }, e.prototype.addComponent = function(t, n) {
    var r = tf.getLabel(t);
    if (this.vertices.has(r)) {
      var i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = [r];
      for (a.add(r), n.add(t); o.length > 0; ) {
        var s = o.pop();
        i.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 (!i.has(d) && (o.push(d), !a.has(d))) {
            a.add(d);
            var m = this.vertices.get(d);
            u.operator_name === m.operator_name ? n.add(B(B({}, m), { operator_name: t.operator_name })) : n.add(m);
          }
        }
      }
    } else n.add(t);
  }, e;
}(), KD = Object.freeze({ __proto__: null, exceptBy: function(e, t) {
  return function(n) {
    var r = e(n);
    if (Ke.structureCount(r) === 0) return r;
    var i = t(n);
    if (Ke.structureCount(i) === 0) return r;
    var a = Ke.unionStructure(i), o = Ke.UniqueBuilder(n.inputStructure);
    return Ke.forEach(r, function(s, u) {
      var c = T9(s, a);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && n.throwIfTimedOut();
    }), o.getSelection();
  };
}, expandProperty: function(e, t) {
  return function(n) {
    var r = e(n), i = /* @__PURE__ */ new Map(), a = [];
    n.pushCurrentElement(), Ke.forEach(r, function(C, b) {
      n.element.structure = C;
      for (var _ = 0, A = C.units; _ < A.length; _++) {
        var I = A[_];
        n.element.unit = I;
        for (var w = I.elements, E = 0, D = w.length; E < D; E++) {
          n.element.element = w[E];
          var T = t(n), P = void 0;
          i.has(T) ? P = i.get(T) : (P = yn.create(), i.set(T, P)), yn.add(P, b, b);
        }
      }
      a[b] = n.inputStructure.subsetBuilder(!0), b % 10 == 0 && n.throwIfTimedOut();
    }), n.element.structure = n.inputStructure;
    for (var o = 0, s = n.inputStructure.units; o < s.length; o++) {
      var u = s[o];
      n.element.unit = u;
      for (var c = u.elements, l = 0, d = c.length; l < d; l++) {
        n.element.element = c[l];
        var m = t(n);
        if (i.has(m)) for (var p = i.get(m).array, v = 0, f = p.length; v < f; v++) a[p[v]].addToUnit(u.id, c[l]);
      }
    }
    n.popCurrentElement();
    for (var y = Ke.UniqueBuilder(n.inputStructure), h = 0, g = a; h < g.length; h++) {
      var x = g[h];
      y.add(x.getStructure());
    }
    return y.getSelection();
  };
}, includeConnected: function(e) {
  var t = e.query, n = e.layerCount, r = e.wholeResidues, i = e.bondTest, a = e.fixedPoint, o = Math.max(n, 0);
  return function(s) {
    var u = Ke.UniqueBuilder(s.inputStructure), c = t(s);
    return s.pushCurrentBond(), s.atomicBond.setTestFn(i), Ke.forEach(c, function(l, d) {
      var m = l;
      if (a) for (; ; ) {
        var p = m.elementCount;
        if ((m = p5(s, r, m)).elementCount === p) break;
      }
      else for (var v = 0; v < o; v++) m = p5(s, r, m);
      u.add(m), d % 10 == 0 && s.throwIfTimedOut();
    }), s.popCurrentBond(), u.getSelection();
  };
}, includeSurroundings: function(e, t) {
  return function(n) {
    var r = e(n);
    if (t.elementRadius) {
      var i = B(B({}, t), { elementRadius: t.elementRadius, elementRadiusClosure: zD(n, t.elementRadius), sourceMaxRadius: UD(n, t.elementRadius) });
      if (Ke.isSingleton(r)) {
        var a = m5(n, n.inputStructure, r.structure, i);
        return Ke.Singletons(n.inputStructure, a);
      }
      for (var o = new Cp(n.inputStructure), s = 0, u = r.structures; s < u.length; s++) {
        var c = u[s];
        o.add(m5(n, n.inputStructure, c, i));
      }
      return o.getSelection();
    }
    if (Ke.isSingleton(r))
      return a = Mp(n, n.inputStructure, r.structure, t), Ke.Singletons(n.inputStructure, a);
    o = new Cp(n.inputStructure);
    for (var l = 0, d = r.structures; l < d.length; l++)
      c = d[l], o.add(Mp(n, n.inputStructure, c, t));
    return o.getSelection();
  };
}, intersectBy: function(e, t) {
  return function(n) {
    var r = e(n);
    if (Ke.structureCount(r) === 0) return r;
    var i = t(n);
    if (Ke.structureCount(i) === 0) return Ke.Empty(n.inputStructure);
    var a = Ke.unionStructure(i), o = Ke.UniqueBuilder(n.inputStructure);
    return Ke.forEach(r, function(s, u) {
      var c = function(l, d) {
        if (l === d) return l;
        if (!qg(l, d)) return Be.Empty;
        var m, p;
        l.units.length < d.units.length ? (m = l, p = d) : (m = d, p = l);
        for (var v = m.units, f = p.unitMap, y = [], h = 0, g = v.length; h < g; h++) {
          var x = v[h];
          if (f.has(x.id)) {
            var C = f.get(x.id);
            if (_e.areIntersecting(x.elements, C.elements)) {
              var b = _e.intersect(x.elements, C.elements);
              y[y.length] = x.getChild(b);
            }
          }
        }
        return Be.create(y, { parent: l.parent || d.parent });
      }(a, s);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && n.throwIfTimedOut();
    }), o.getSelection();
  };
}, querySelection: function(e, t) {
  return function(n) {
    var r = e(n);
    if (Ke.structureCount(r) === 0) return r;
    var i = Ke.UniqueBuilder(n.inputStructure), a = function(o) {
      return i.add(o);
    };
    return Ke.forEach(r, function(o, s) {
      n.pushInputStructure(o), Ke.forEach(t(n), a), n.popInputStructure(), s % 10 == 0 && n.throwIfTimedOut();
    }), i.getSelection();
  };
}, surroundingLigands: function(e) {
  var t = e.query, n = e.radius, r = e.includeWater;
  return function(i) {
    for (var a = Ke.unionStructure(t(i)), o = Sl(i, i.inputStructure, Mp(i, i.inputStructure, a, { radius: n })), s = function(q) {
      var H = q.models[0], K = /* @__PURE__ */ new Set();
      if (!_n.is(H.sourceData)) return K;
      for (var j = H.sourceData.data.db.pdbx_molecule, W = j._rowCount, Z = j.asym_id, Y = 0; Y < W; Y++) K.add(Z.value(Y));
      return K;
    }(i.inputStructure), u = function(q) {
      var H, K, j = q.models[0], W = new jD();
      if (!_n.is(j.sourceData)) return W;
      for (var Z = j.sourceData.data.db.struct_conn, Y = Z.conn_type_id, te = Z.ptnr1_label_asym_id, ee = Z.ptnr1_label_comp_id, $ = Z.ptnr1_label_seq_id, ue = Z.ptnr1_symmetry, se = Z.pdbx_ptnr1_label_alt_id, be = Z.pdbx_ptnr1_PDB_ins_code, ke = Z.ptnr2_label_asym_id, Oe = Z.ptnr2_label_comp_id, ze = Z.ptnr2_label_seq_id, je = Z.ptnr2_symmetry, xe = Z.pdbx_ptnr2_label_alt_id, Xe = Z.pdbx_ptnr2_PDB_ins_code, Ee = 0; Ee < Z._rowCount; Ee++) {
        var Ye = Y.value(Ee);
        if (Ye === "covale" || Ye === "metalc") {
          var He = { label_asym_id: te.value(Ee), label_comp_id: ee.value(Ee), label_seq_id: $.value(Ee), label_alt_id: se.value(Ee), ins_code: be.value(Ee), operator_name: (H = ue.value(Ee)) !== null && H !== void 0 ? H : "1_555" }, le = { label_asym_id: ke.value(Ee), label_comp_id: Oe.value(Ee), label_seq_id: ze.value(Ee), label_alt_id: xe.value(Ee), ins_code: Xe.value(Ee), operator_name: (K = je.value(Ee)) !== null && K !== void 0 ? K : "1_555" };
          W.addEdge(He, le);
        }
      }
      return W;
    }(i.inputStructure), c = Ne.create(o), l = /* @__PURE__ */ new Map(), d = new tf({ checkOperator: !0 }), m = 0, p = o.units; m < p.length; m++)
      if ((M = p[m]).kind === 0) {
        c.unit = M;
        for (var v = M.elements, f = St.transientSegments(M.model.atomicHierarchy.chainAtomSegments, v), y = St.transientSegments(M.model.atomicHierarchy.residueAtomSegments, v); f.hasNext; ) {
          var h = f.move();
          c.element = v[h.start];
          var g = Me.chain.label_asym_id(c), x = Me.unit.operator_name(c);
          if (s.has(g)) l.has(g) ? Ca(l.get(g), x) : l.set(g, [x]);
          else {
            var C = Me.entity.type(c);
            if (C !== "water" && C !== "polymer") for (y.setSegment(h); y.hasNext; ) {
              var b = y.move();
              c.element = v[b.start], u.addComponent(tf.getEntryFromLocation(c), d);
            }
          }
        }
        i.throwIfTimedOut();
      }
    for (var _ = i.inputStructure.subsetBuilder(!0), A = 0, I = i.inputStructure.units; A < I.length; A++)
      if ((M = I[A]).kind === 0) {
        for (c.unit = M, v = M.elements, f = St.transientSegments(M.model.atomicHierarchy.chainAtomSegments, v), y = St.transientSegments(M.model.atomicHierarchy.residueAtomSegments, v), _.beginUnit(M.id); f.hasNext; )
          if (h = f.move(), c.element = v[h.start], g = Me.chain.label_asym_id(c), x = Me.unit.operator_name(c), l.has(g) && l.get(g).indexOf(x) >= 0) _.addElementRange(v, h.start, h.end);
          else if (d.hasLabelAsymId(g)) for (y.setSegment(h); y.hasNext; )
            b = y.move(), c.element = v[b.start], d.has(c) && _.addElementRange(v, b.start, b.end);
        _.commitUnit(), i.throwIfTimedOut();
      }
    var w = Ym(i.inputStructure, [_.getStructure(), a]);
    if (r) {
      for (var E = new P0(i.inputStructure), D = i.inputStructure.lookup3d, T = 0, P = w.units; T < P.length; T++) {
        for (var M, R = (M = P[T]).conformation, O = R.x, L = R.y, F = R.z, G = 0, V = (v = M.elements).length; G < V; G++) {
          var U = v[G];
          D.findIntoBuilderIf(O(U), L(U), F(U), n, E, qD), E.addToUnit(M.id, U);
        }
        i.throwIfTimedOut();
      }
      return Ke.Sequence(i.inputStructure, [E.getStructure()]);
    }
    return Ke.Sequence(i.inputStructure, [w]);
  };
}, union: function(e) {
  return function(t) {
    var n = Ke.LinearBuilder(t.inputStructure);
    return n.add(Ke.unionStructure(e(t))), n.getSelection();
  };
}, wholeResidues: function(e) {
  return function(t) {
    var n = e(t);
    if (Ke.isSingleton(n)) return Ke.Singletons(t.inputStructure, Sl(t, t.inputStructure, n.structure));
    for (var r = new Cp(t.inputStructure), i = 0, a = n.structures; i < a.length; i++) {
      var o = a[i];
      r.add(Sl(t, t.inputStructure, o));
    }
    return r.getSelection();
  };
} });
function Dp(e, t, n) {
  var r = e.currentStructure.units, i = e.pushCurrentElement();
  i.structure = e.currentStructure;
  for (var a = 0, o = r; a < o.length; a++) {
    var s = o[a];
    i.unit = s;
    var u = s.elements, c = void 0;
    if (c = me.isAtomic(s) ? t.atomic : t.coarse) {
      for (var l = 0, d = u.length; l < d; l++) i.element = u[l], n.add(c(e));
      e.throwIfTimedOut();
    }
  }
  return e.popCurrentElement(), n;
}
(function(e) {
  var t = S.zero();
  function n(a, o, s, u, c, l, d) {
    var m = o.elements, p = o.conformation.position, v = t;
    a.element.unit = o;
    for (var f = !1, y = 0, h = m.length; y < h; y++) {
      var g = m[y];
      a.element.element = g;
      var x = Math.max(0, S.distance(s, p(g, v)) - u - d(a));
      if (x < c) return 0;
      x < l && (f = !0);
    }
    return f ? 1 : 2;
  }
  function r(a, o, s, u, c, l, d) {
    for (var m = o.units, p = !1, v = 0, f = m.length; v < f; v++) {
      var y = n(a, m[v], s, u, c, l, d);
      if (y === 0) return 0;
      y === 1 && (p = !0);
    }
    return p ? 1 : 2;
  }
  e.toPoint = r;
  var i = S.zero();
  e.check = function(a, o, s, u, c, l) {
    if (o.elementCount === 0 || s.elementCount === 0) return 0;
    var d = o.units, m = !1;
    a.element.structure = o;
    for (var p = 0, v = d.length; p < v; p++) {
      var f = d[p], y = f.elements, h = f.conformation.position;
      a.element.unit = f;
      for (var g = 0, x = y.length; g < x; g++) {
        var C = y[g];
        a.element.element = C;
        var b = r(a, s, h(C, i), l(a), u, c, l);
        if (b === 0) return 0;
        b === 1 && (m = !0);
      }
    }
    return m;
  };
})(Zm || (Zm = {})), function(e) {
  var t = S.zero();
  function n(a, o, s, u, c, l) {
    var d = o.elements, m = o.conformation.position, p = t;
    a.element.unit = o;
    for (var v = 0, f = d.length; v < f; v++) {
      var y = d[v];
      if (a.element.element = y, Math.max(0, S.distance(s, m(y, p)) - u - l(a)) <= c) return !0;
    }
    return !1;
  }
  function r(a, o, s, u, c, l) {
    for (var d = o.units, m = 0, p = d.length; m < p; m++) if (n(a, d[m], s, u, c, l)) return !0;
    return !1;
  }
  e.toPoint = r;
  var i = S.zero();
  e.check = function(a, o, s, u, c) {
    if (o.elementCount === 0 || s.elementCount === 0) return 0;
    var l = o.units;
    a.element.structure = o;
    for (var d = 0, m = l.length; d < m; d++) {
      var p = l[d];
      a.element.unit = p;
      for (var v = p.elements, f = p.conformation.position, y = 0, h = v.length; y < h; y++) {
        var g = v[y];
        if (a.element.element = g, r(a, s, f(g, i), c(a), u, c)) return !0;
      }
    }
    return !1;
  };
}(Qm || (Qm = {}));
var XD = Object.freeze({ __proto__: null, areIntersectedBy: function(e, t) {
  return function(n) {
    var r = Ke.unionStructure(t(n)), i = Ke.LinearBuilder(n.inputStructure);
    return Ke.forEach(e(n), function(a, o) {
      qg(r, a) && i.add(a), o % 10 && n.throwIfTimedOut();
    }), i.getSelection();
  };
}, first: function(e) {
  return function(t) {
    var n = e(t), r = Ke.LinearBuilder(t.inputStructure);
    if (n.kind === "singletons") {
      if (n.structure.elementCount > 0) {
        var i = n.structure.units[0], a = Be.create([i.getChild(_e.ofSingleton(i.elements[0]))], { parent: t.inputStructure });
        r.add(a);
      }
    } else n.structures.length > 0 && r.add(n.structures[0]);
    return r.getSelection();
  };
}, getCurrentStructureProperties: Dp, isConnectedTo: function(e) {
  var t = e.query, n = e.target, r = e.disjunct, i = e.invert, a = e.bondTest;
  return function(o) {
    var s = n(o);
    if (Ke.isEmpty(s)) return s;
    var u = t(o);
    if (Ke.isEmpty(u)) return u;
    var c = { queryCtx: o, input: o.inputStructure, disjunct: r, target: Ke.unionStructure(s) }, l = Ke.LinearBuilder(o.inputStructure);
    return o.pushCurrentBond(), o.atomicBond.setTestFn(a), Ke.forEach(u, function(d, m) {
      (function(p, v) {
        var f = p.queryCtx, y = p.input, h = p.target, g = p.disjunct, x = f.atomicBond, C = y.interUnitBonds;
        x.setStructure(y);
        for (var b = 0, _ = v.units; b < _.length; b++) {
          var A = _[b];
          if (me.isAtomic(A)) for (var I = y.unitMap.get(A.id), w = I.bonds, E = w.offset, D = w.b, T = w.edgeProps, P = T.flags, M = T.order, R = C.getConnectedUnits(A.id), O = R.length, L = A.elements, F = I.elements, G = 0, V = L.length; G < V; G++) {
            var U = _e.indexOf(F, L[G]);
            x.a.unit = I, x.b.unit = I;
            for (var q = E[U], H = E[U + 1]; q < H; q++) if (x.b.element = I.elements[D[q]], (!g || !_e.has(A.elements, x.b.element)) && h.hasElement(x.b) && (x.aIndex = U, x.a.element = L[G], x.bIndex = D[q], x.type = P[q], x.order = M[q], x.test(f, !0))) return !0;
            for (var K = 0; K < O; K++) for (var j = R[K], W = y.unitMap.get(j.unitB), Z = W.elements, Y = j.getEdges(U), te = 0, ee = Y.length; te < ee; te++) {
              var $ = Y[te];
              if (x.b.unit = W, x.b.element = Z[$.indexB], h.hasElement(x.b) && (!g || !v.hasElement(x.b)) && (x.a.unit = I, x.aIndex = U, x.a.element = L[G], x.bIndex = $.indexB, x.type = $.props.flag, x.order = $.props.order, x.test(f, !0))) return !0;
            }
          }
        }
        return !1;
      }(c, d) || i) && l.add(d), m % 5 == 0 && o.throwIfTimedOut();
    }), o.popCurrentBond(), l.getSelection();
  };
}, pick: function(e, t) {
  return function(n) {
    var r = e(n), i = Ke.LinearBuilder(n.inputStructure);
    return n.pushCurrentElement(), Ke.forEach(r, function(a, o) {
      n.currentStructure = a, t(n) && i.add(a), o % 100 && n.throwIfTimedOut();
    }), n.popCurrentStructure(), i.getSelection();
  };
}, withSameAtomProperties: function(e, t, n) {
  return function(r) {
    var i = e(r), a = function(s, u, c) {
      var l = /* @__PURE__ */ new Set(), d = u(s);
      return s.pushCurrentElement(), Ke.forEach(d, function(m, p) {
        s.currentStructure = m, Dp(s, c, l), p % 10 && s.throwIfTimedOut();
      }), s.popCurrentElement(), l;
    }(r, t, n), o = Ke.LinearBuilder(r.inputStructure);
    return r.pushCurrentStructure(), Ke.forEach(i, function(s, u) {
      r.currentStructure = s;
      var c = Dp(r, n, /* @__PURE__ */ new Set());
      Ii.isSuperset(c, a) && o.add(s), u % 10 && r.throwIfTimedOut();
    }), r.popCurrentStructure(), o.getSelection();
  };
}, within: function(e) {
  return function(t) {
    var n = { 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 n.minRadius === 0 && e.minRadius === void 0 ? function(r) {
      var i = r.queryCtx, a = r.selection, o = r.target, s = r.maxRadius, u = r.invert, c = Ke.unionStructure(o).lookup3d, l = Ke.LinearBuilder(i.inputStructure), d = S.zero();
      return Ke.forEach(a, function(m, p) {
        for (var v = m.units, f = !1, y = 0, h = v.length; y < h; y++) {
          for (var g = v[y], x = g.elements, C = g.conformation, b = C.position, _ = C.r, A = 0, I = x.length; A < I; A++) {
            var w = x[A];
            if (b(w, d), c.check(d[0], d[1], d[2], s + _(w))) {
              f = !0;
              break;
            }
          }
          if (f) break;
        }
        u && (f = !f), f && l.add(m), p % 10 == 0 && i.throwIfTimedOut();
      }), l.getSelection();
    }(n) : n.minRadius === 0 ? function(r) {
      var i = r.queryCtx, a = r.selection, o = r.target, s = r.maxRadius, u = r.invert, c = r.elementRadius, l = Ke.unionStructure(o), d = Ke.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), Ke.forEach(a, function(m, p) {
        var v = function(f, y, h, g, x) {
          return y.elementCount === 0 || h.elementCount === 0 || (y.elementCount <= h.elementCount ? Qm.check(f, y, h, g, x) : Qm.check(f, h, y, g, x));
        }(i, l, m, s, c);
        u && (v = !v), v && d.add(m), p % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), d.getSelection();
    }(n) : function(r) {
      var i = r.queryCtx, a = r.selection, o = r.target, s = r.minRadius, u = r.maxRadius, c = r.invert, l = r.elementRadius, d = Ke.unionStructure(o), m = Ke.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), Ke.forEach(a, function(p, v) {
        var f = function(y, h, g, x, C, b) {
          return h.elementCount === 0 || g.elementCount === 0 || (h.elementCount <= g.elementCount ? Zm.check(y, h, g, x, C, b) : Zm.check(y, g, h, x, C, b));
        }(i, d, p, s, u, l);
        c && (f = !f), f && m.add(p), v % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), m.getSelection();
    }(n);
  };
} }), lv, YD = Object.freeze({ __proto__: null, intersect: function(e) {
  return e.length === 0 ? iv : e.length === 1 ? e[0] : function(t) {
    for (var n = [], r = 0; r < e.length; r++) n.push(e[r](t));
    var i = 0, a = Ke.structureCount(n[0]);
    for (r = 1; r < n.length; r++) {
      var o = Ke.structureCount(n[r]);
      o < a && (i = r, a = o);
    }
    t.throwIfTimedOut();
    var s = Lg(function(l) {
      return l.hashCode;
    }, Be.areUnitIdsAndIndicesEqual);
    Ke.forEach(n[i], function(l) {
      return s.add(l);
    });
    for (var u = Ke.UniqueBuilder(t.inputStructure), c = 0; c < n.length; c++) c !== i && (Ke.forEach(n[c], function(l) {
      s.has(l) && u.add(l);
    }), t.throwIfTimedOut());
    return u.getSelection();
  };
}, merge: function(e) {
  return e.length === 0 ? iv : e.length === 1 ? e[0] : function(t) {
    for (var n = Ke.UniqueBuilder(t.inputStructure), r = function(a) {
      Ke.forEach(e[a](t), function(o, s) {
        n.add(o), a % 100 && t.throwIfTimedOut();
      });
    }, i = 0; i < e.length; i++) r(i);
    return n.getSelection();
  };
} });
(function(e) {
  function t(r) {
    return !0;
  }
  function n(r) {
    return !1;
  }
  e.eq = function(r, i) {
    return function(a) {
      return r(a) === i;
    };
  }, e.lt = function(r, i) {
    return function(a) {
      return r(a) < i;
    };
  }, e.lte = function(r, i) {
    return function(a) {
      return r(a) <= i;
    };
  }, e.gt = function(r, i) {
    return function(a) {
      return r(a) > i;
    };
  }, e.gte = function(r, i) {
    return function(a) {
      return r(a) >= i;
    };
  }, e.inSet = function(r, i) {
    if (function(s) {
      return !!s && !!s.has;
    }(i)) return function(s) {
      return i.has(r(s));
    };
    if (i.length === 0) return n;
    for (var a = /* @__PURE__ */ new Set(), o = 0; o < i.length; o++) a.add(i[o]);
    return function(s) {
      return a.has(r(s));
    };
  }, e.and = function() {
    for (var r = [], i = 0; i < arguments.length; i++) r[i] = arguments[i];
    switch (r.length) {
      case 0:
        return t;
      case 1:
        return r[0];
      case 2:
        var a = r[0], o = r[1];
        return function(E) {
          return a(E) && o(E);
        };
      case 3:
        var s = r[0], u = r[1], c = r[2];
        return function(E) {
          return s(E) && u(E) && c(E);
        };
      case 4:
        var l = r[0], d = r[1], m = r[2], p = r[3];
        return function(E) {
          return l(E) && d(E) && m(E) && p(E);
        };
      case 5:
        var v = r[0], f = r[1], y = r[2], h = r[3], g = r[4];
        return function(E) {
          return v(E) && f(E) && y(E) && h(E) && g(E);
        };
      case 6:
        var x = r[0], C = r[1], b = r[2], _ = r[3], A = r[4], I = r[5];
        return function(E) {
          return x(E) && C(E) && b(E) && _(E) && A(E) && I(E);
        };
      default:
        var w = r.length;
        return function(E) {
          for (var D = 0; D < w; D++) if (!r[D]) return !1;
          return !0;
        };
    }
  }, e.or = function() {
    for (var r = [], i = 0; i < arguments.length; i++) r[i] = arguments[i];
    switch (r.length) {
      case 0:
        return n;
      case 1:
        return r[0];
      case 2:
        var a = r[0], o = r[1];
        return function(E) {
          return a(E) || o(E);
        };
      case 3:
        var s = r[0], u = r[1], c = r[2];
        return function(E) {
          return s(E) || u(E) || c(E);
        };
      case 4:
        var l = r[0], d = r[1], m = r[2], p = r[3];
        return function(E) {
          return l(E) || d(E) || m(E) || p(E);
        };
      case 5:
        var v = r[0], f = r[1], y = r[2], h = r[3], g = r[4];
        return function(E) {
          return v(E) || f(E) || y(E) || h(E) || g(E);
        };
      case 6:
        var x = r[0], C = r[1], b = r[2], _ = r[3], A = r[4], I = r[5];
        return function(E) {
          return x(E) || C(E) || b(E) || _(E) || A(E) || I(E);
        };
      default:
        var w = r.length;
        return function(E) {
          for (var D = 0; D < w; D++) if (r[D]) return !0;
          return !1;
        };
    }
  };
})(lv || (lv = {}));
var kl, Cn = { generators: jM, filters: XD, modifiers: KD, combinators: YD, pred: lv, internal: UM };
function U9(e, t, n, r, i, a) {
  var o = e.spacegroup, s = e.ncsOperators, u = [], c = o.cell.toFractional, l = S.transformMat4(S(), a, c), d = ki.getSymmetryOperatorRef(o, t, n, r, i, l);
  if (s && s.length) for (var m = 0, p = s.length; m < p; ++m) {
    var v = s[m], f = J.mul(J(), d.matrix, v.matrix), y = xn.create("".concat(d.name, " ").concat(v.name), f, { assembly: d.assembly, ncsId: v.ncsId, hkl: d.hkl, spgrOp: d.spgrOp });
    u.push(y);
  }
  else u.push(d);
  return u;
}
function h5(e, t, n, r) {
  var i = e.spacegroup, a = e.ncsOperators, o = a && a.length || 0, s = [];
  !o && t[0] <= 0 && n[0] >= 0 && t[1] <= 0 && n[1] >= 0 && t[2] <= 0 && n[2] >= 0 && (s[0] = ki.getSymmetryOperator(i, 0, 0, 0, 0));
  for (var u = 0; u < i.operators.length; u++) for (var c = t[0]; c <= n[0]; c++) for (var l = t[1]; l <= n[1]; l++) for (var d = t[2]; d <= n[2]; d++) (o || u !== 0 || c !== 0 || l !== 0 || d !== 0) && s.push.apply(s, U9(e, u, c, l, d, r));
  return s;
}
function v5(e, t) {
  for (var n = Be.Builder({ label: e.label, dynamicBonds: e.dynamicBonds }), r = e.units, i = 0, a = t; i < a.length; i++) for (var o = a[i], s = 0, u = r; s < u.length; s++) {
    var c = u[s];
    n.addWithOperator(c, o);
  }
  return n.getStructure();
}
(function(e) {
  function t(r, i) {
    return r.invariantId === i.invariantId && r.model.id === i.model.id && _e.areEqual(r.elements, i.elements);
  }
  function n() {
    return function(r, i) {
      return new Lw(r, i);
    }(me.hashUnit, t);
  }
  e.buildAssembly = function(r, i) {
    var a = this;
    return At.create("Build Assembly", function(o) {
      return ie(a, 0, void 0, function() {
        var s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _;
        return ne(this, function(A) {
          if ((s = r.models).length !== 1) throw new Error("Can only build assemblies from structures based on 1 model.");
          if (!(u = Km.findAssembly(s[0], i))) throw new Error("Assembly '".concat(i, "' is not defined."));
          for (c = xn.create(u.id, J.identity(), { assembly: { id: u.id, operId: 0, operList: [] } }), l = Be.Builder({ coordinateSystem: c, label: r.label, dynamicBonds: r.dynamicBonds }), d = new Cc(r), m = 0, p = u.operatorGroups; m < p.length; m++) if (v = p[m], f = v.selector(d), Ke.structureCount(f) !== 0) for (y = Ke.unionStructure(f).units, h = 0, g = v.operators; h < g.length; h++) for (x = g[h], C = 0, b = y; C < b.length; C++) _ = b[C], l.addWithOperator(_, x);
          return [2, l.getStructure()];
        });
      });
    });
  }, e.buildSymmetryAssembly = function(r, i, a) {
    var o = this;
    return At.create("Build Symmetry Assembly", function(s) {
      return ie(o, 0, void 0, function() {
        var u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O;
        return ne(this, function(L) {
          if ((u = r.models).length !== 1) throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
          for (c = S(), l = Be.Builder({ label: r.label, representativeModel: u[0], dynamicBonds: r.dynamicBonds }), d = new Cc(r), m = 0, p = i; m < p.length; m++) if (v = p[m], F = v.asymIds, f = Cn.generators.atoms({ chainTest: Cn.pred.and(Cn.pred.eq(function(G) {
            return Me.unit.operator_name(G.element);
          }, xn.DefaultName), Cn.pred.inSet(function(G) {
            return Me.chain.label_asym_id(G.element);
          }, F)) }), y = f(d), Ke.structureCount(y) !== 0) for (h = Ke.unionStructure(y).units, g = 0, x = v.operators; g < x.length; g++) for (C = x[g], b = C.index, _ = C.shift, A = _[0], I = _[1], w = _[2], E = U9(a, b, A, I, w, c), D = 0, T = h; D < T.length; D++) for (P = T[D], M = 0, R = E; M < R.length; M++) O = R[M], l.addWithOperator(P, O);
          var F;
          return [2, l.getStructure()];
        });
      });
    });
  }, e.builderSymmetryMates = function(r, i) {
    return At.create("Find Symmetry Mates", function(a) {
      return function(o, s, u) {
        return ie(this, 0, void 0, function() {
          function c(R, O) {
            return "".concat(R.invariantId, "|").concat(O.name);
          }
          var l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M;
          return ne(this, function(R) {
            switch (R.label) {
              case 0:
                if ((l = s.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
                return (d = Vr.Provider.get(l[0])) ? (m = d.spacegroup, Ma.isZero(m.cell) ? [2, s] : o.shouldUpdate ? [4, o.update("Initialing...")] : [3, 2]) : [2, s];
              case 1:
                R.sent(), R.label = 2;
              case 2:
                p = pn.getCenter(l[0]), v = function(O, L) {
                  return O._operators_333 && S.equals(L, O._operators_333.ref) || (O._operators_333 = { ref: S.clone(L), operators: h5(O, S.create(-3, -3, -3), S.create(3, 3, 3), L) }), O._operators_333.operators;
                }(d, p), f = s.lookup3d, y = /* @__PURE__ */ new Set(), h = Be.Builder({ label: s.label, dynamicBonds: s.dynamicBonds }), g = s.units, x = S.zero(), C = 0, b = v, R.label = 3;
              case 3:
                if (!(C < b.length)) return [3, 6];
                for (_ = b[C], A = 0, I = g; A < I.length; A++) for (w = I[A], E = w.lookup3d.boundary.sphere, S.transformMat4(x, E.center, _.matrix), D = f.findUnitIndices(x[0], x[1], x[2], E.radius + u), T = 0, P = D.count; T < P; T++) g[D.indices[T]].lookup3d.check(x[0], x[1], x[2], E.radius + u) && (M = c(w, _), y.has(M) || (h.addWithOperator(w, _), y.add(M)));
                return o.shouldUpdate ? [4, o.update("Building symmetry...")] : [3, 5];
              case 4:
                R.sent(), R.label = 5;
              case 5:
                return C++, [3, 3];
              case 6:
                return [2, h.getStructure()];
            }
          });
        });
      }(a, r, i);
    });
  }, e.buildSymmetryRange = function(r, i, a) {
    return At.create("Build Symmetry", function(o) {
      return function(s, u, c, l) {
        return ie(this, 0, void 0, function() {
          var d, m, p, v, f;
          return ne(this, function(y) {
            if ((d = u.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
            return (m = Vr.Provider.get(d[0])) ? (p = m.spacegroup, Ma.isZero(p.cell) ? [2, u] : (v = pn.getCenter(d[0]), f = h5(m, c, l, v), [2, v5(u, f)])) : [2, u];
          });
        });
      }(0, r, i, a);
    });
  }, e.buildNcs = function(r) {
    return At.create("Build NCS", function(i) {
      return function(a, o) {
        return ie(this, 0, void 0, function() {
          var s, u, c;
          return ne(this, function(l) {
            if ((s = o.models).length !== 1) throw new Error("Can only build NCS from structures based on 1 model.");
            return (u = Vr.Provider.get(s[0])) && (c = u.ncsOperators) && c.length ? [2, v5(o, c)] : [2, o];
          });
        });
      }(0, r);
    });
  }, e.areUnitsEquivalent = t, e.UnitEquivalenceBuilder = n, e.computeTransformGroups = function(r) {
    for (var i = n(), a = 0, o = r.units; a < o.length; a++) {
      var s = o[a];
      i.add(s.id, s);
    }
    for (var u = [], c = 0, l = i.groups; c < l.length; c++) {
      var d = l[c];
      u.push(me.SymmetryGroup(d.map(function(m) {
        return r.unitMap.get(m);
      })));
    }
    return u;
  }, e.areTransformGroupsEquivalent = function(r, i) {
    if (r.length !== i.length) return !1;
    for (var a = 0, o = r.length; a < o; ++a) {
      var s = r[a].units, u = i[a].units;
      if (s.length !== u.length || r[a].hashCode !== i[a].hashCode) return !1;
      for (var c = 0, l = s.length; c < l; c++) if (s[c].conformation !== u[c].conformation) return !1;
    }
    return !0;
  };
})(kl || (kl = {}));
var WD = function() {
  function e(t, n) {
    this.parent = t, this.isSorted = n, this.ids = [], this.unitMap = Ro.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, n) {
    var r = this.unitMap.get(t);
    r ? r[r.length] = n : (this.unitMap.set(t, [n]), 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, n, r) {
    for (var i = n; i < r; i++) this.currentUnit[this.currentUnit.length] = t[i], 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, n) {
    this.ids[this.ids.length] = t, this.unitMap.set(t, n), this.elementCount += n.length;
  }, e.prototype._getStructure = function(t) {
    if (this.isEmpty) return Be.Empty;
    var n = [];
    to(this.ids);
    for (var r = kl.UnitEquivalenceBuilder(), i = 0, a = this.ids.length; i < a; i++) {
      var o = this.ids[i], s = this.parent.unitMap.get(o), u = this.unitMap.get(o), c = !1;
      t && (this.isSorted || to(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 && to(u);
        var d = s.getChild(_e.ofSortedArray(u)), m = r.add(d.id, d);
        d !== m && (d = m.applyOperator(d.id, d.conformation.operator, !0)), n[n.length] = d;
      } else n[n.length] = s, r.add(s.id, s);
    }
    return Be.create(n, { 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 n = this.ids[0];
    t.unit = this.parent.unitMap.get(n), t.element = this.unitMap.get(n)[0];
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function g5(e, t) {
  for (var n = 1; t--; ) n *= e--;
  return n;
}
var ZD = function() {
  function e(t, n) {
    this.array = t, this.hasNext = !1, this.index = (1 << n) - 1, this.size = function(r, i) {
      return i > r ? 0 : g5(r, i) / g5(i, i);
    }(t.length, n), this.maxIndex = 1 << t.length, this.value = new Array(n), this.hasNext = n > 0 && n <= t.length;
  }
  return e.prototype.move = function() {
    if (this.hasNext) {
      for (var t = 0, n = 0, r = this.index; r; r >>>= 1, t++) 1 & r && (this.value[n++] = this.array[t]);
      this.index = function(i) {
        var a = i & -i, o = i + a;
        return o | ((o & -o) / a >> 1) - 1;
      }(this.index), this.hasNext = this.index < this.maxIndex;
    }
    return this.value;
  }, e;
}();
function H9(e, t) {
  for (var n = [], r = new ZD(e, t); r.hasNext; ) n.push(r.move().slice());
  return n;
}
var Nu = [], QD = { links: Nu, terminalLinks: Nu, elements: Nu, partialElements: Nu, getElementIndices: function() {
  return Nu;
}, getLinkIndices: function() {
  return Nu;
}, getTerminalLinkIndices: function() {
  return Nu;
} }, dr = Tl("C"), zd = Tl("O"), JD = [Ea.elementFingerprint([dr, dr, dr, zd]), Ea.elementFingerprint([dr, dr, dr, dr, zd]), Ea.elementFingerprint([dr, dr, dr, dr, dr, zd]), Ea.elementFingerprint([dr, dr, dr, dr, dr, dr, zd])];
function $D(e, t) {
  for (var n = -1, r = -1, i = -1, a = -1, o = e.elements, s = e.model.atomicHierarchy.atoms, u = s.type_symbol, c = s.label_atom_id, l = e.bonds, d = l.b, m = l.offset, p = 0, v = t.length; p < v; ++p) {
    var f = o[t[p]];
    if (u.value(f) === dr) {
      for (var y = 0, h = 0, g = m[t[p]], x = m[t[p] + 1]; g < x; ++g) {
        var C = o[d[g]], b = u.value(C);
        b === zd ? ++y : b === dr && ++h;
      }
      if (y === 2) {
        n = f;
        break;
      }
      y === 1 && h === 1 ? r = f : c.value(f).startsWith("C1") ? i = f : a = f;
    }
  }
  return n !== -1 ? n : r !== -1 ? r : i !== -1 ? i : a !== -1 ? a : o[t[0]];
}
function eB(e, t, n, r) {
  var i = t.conformation.position;
  return S.normalize(e, S.sub(e, r, i(n, e))), e;
}
function y5(e, t) {
  var n = e.elements;
  return e.model.atomicHierarchy.atoms.label_atom_id.value(n[t]);
}
function tB(e, t) {
  if (t && t.length) {
    for (var n = e.unit, r = e.all, i = /* @__PURE__ */ new Set(), a = H9(Oo(new Array(t.length)), 2), o = 0, s = a.length; o < s; ++o) {
      var u = a[o], c = r[t[u[0]]], l = r[t[u[1]]];
      _e.areIntersecting(c, l) && Ea.getAltId(n, c) === Ea.getAltId(n, l) && (i.add(t[u[0]]), i.add(t[u[1]]));
    }
    if (i.size) {
      var d = [];
      for (o = 0, s = t.length; o < s; ++o) i.has(t[o]) || d.push(t[o]);
      return d;
    }
    return t;
  }
}
function nB(e, t) {
  return t.properties.saccharideComponentMap.get(e);
}
function rB(e) {
  if (e.models.reduce(function(ue, se) {
    return ue + se.properties.saccharideComponentMap.size;
  }, 0) === 0) return QD;
  var t = [], n = [], r = [], i = [], a = /* @__PURE__ */ new Map();
  function o(ue, se, be) {
    return "".concat(ue, "|").concat(se, "|").concat(be);
  }
  function s(ue, se) {
    a.has(ue) ? a.get(ue).push(se) : a.set(ue, [se]);
  }
  function u(ue, se) {
    S.sub(r[ue].geometry.direction, r[se].geometry.center, r[ue].geometry.center), S.normalize(r[ue].geometry.direction, r[ue].geometry.direction);
  }
  var c = S.zero();
  function l(ue, se, be) {
    var ke = be.conformation.position, Oe = r[ue].geometry;
    S.sub(Oe.direction, ke(be.elements[se], c), Oe.center), S.normalize(Oe.direction, Oe.direction);
  }
  for (var d = 0, m = e.units.length; d < m; ++d) {
    var p = e.units[d];
    if (me.isAtomic(p)) for (var v = p.model, f = p.rings, y = v.atomicHierarchy, h = y.chainAtomSegments, g = y.residueAtomSegments, x = y.atoms.label_comp_id, C = St.transientSegments(h, p.elements), b = St.transientSegments(g, p.elements), _ = void 0; C.hasNext; ) for (b.setSegment(C.move()); b.hasNext; ) {
      var A = b.move().index, I = nB(x.value(g.offsets[A]), v);
      if (I) {
        _ || (_ = jm.byFingerprintAndResidue(f, JD));
        var w = tB(f, _.get(A));
        if (w && w.length) {
          for (var E = [], D = 0, T = w.length; D < T; ++D) {
            var P = f.all[w[D]], M = $D(p, P), R = _u.calculateMomentsAxes(w9(p, P)), O = S.copy(S.zero(), R.origin), L = S.copy(S.zero(), R.dirC), F = eB(S.zero(), p, M, O);
            S.orthogonalize(F, L, F);
            var G = Ea.getAltId(p, P), V = r.length;
            E.push(V), s(o(A, p.id, G), V), G && s(o(A, p.id, ""), V), r.push({ geometry: { center: O, normal: L, direction: F }, component: I, ringIndex: w[D], altId: G, unit: p, residueIndex: A });
          }
          var U = H9(Oo(new Array(w.length)), 2);
          for (D = 0, T = U.length; D < T; ++D) {
            var q = U[D], H = f.all[w[q[0]]], K = f.all[w[q[1]]];
            if (Ui.areVertexSetsConnected(p.bonds, H, K, 3)) {
              var j = E[q[0]], W = E[q[1]];
              r[j].altId === r[W].altId && (u(j, W), u(W, j), t.push({ carbohydrateIndexA: j, carbohydrateIndexB: W }), t.push({ carbohydrateIndexA: W, carbohydrateIndexB: j }));
            }
          }
        } else i.push({ unit: p, residueIndex: A, component: I });
      }
    }
  }
  function Z(ue, se) {
    return a.get(o(ue.getResidueIndex(se), ue.id, function(be, ke) {
      var Oe = be.elements;
      return be.model.atomicHierarchy.atoms.label_alt_id.value(Oe[ke]);
    }(ue, se))) || [];
  }
  for (d = 0, m = r.length; d < m; ++d) {
    var Y = r[d];
    for (p = Y.unit, D = d + 1; D < m; ++D) {
      var te = r[D];
      if (p === te.unit && Y.residueIndex !== te.residueIndex) {
        var ee = p.rings.all[Y.ringIndex], $ = p.rings.all[te.ringIndex];
        Ui.areVertexSetsConnected(p.bonds, ee, $, 3) && (u(d, D), u(D, d), t.push({ carbohydrateIndexA: d, carbohydrateIndexB: D }), t.push({ carbohydrateIndexA: D, carbohydrateIndexB: d }));
      }
    }
  }
  for (d = 0, m = e.units.length; d < m; ++d)
    p = e.units[d], me.isAtomic(p) && e.interUnitBonds.getConnectedUnits(p.id).forEach(function(ue) {
      ue.connectedIndices.forEach(function(se) {
        ue.getEdges(se).forEach(function(be) {
          var ke = be.props, Oe = be.indexB;
          if (Bt.isCovalent(ke.flag)) {
            var ze = e.unitMap.get(ue.unitA), je = e.unitMap.get(ue.unitB), xe = Z(ze, se), Xe = Z(je, Oe);
            if (xe.length > 0 && Xe.length > 0) for (var Ee = xe.length, Ye = Xe.length, He = 0, le = Math.max(Ee, Ye); He < le; ++He) {
              var Ce = xe[Math.min(He, Ee - 1)], Ae = Xe[Math.min(He, Ye - 1)];
              ((we = y5(ze, se)).startsWith("O1") || we.startsWith("C1")) && u(Ce, Ae), t.push({ carbohydrateIndexA: Ce, carbohydrateIndexB: Ae });
            }
            else if (Xe.length === 0) for (var Te = 0, Re = xe; Te < Re.length; Te++) {
              var we;
              Ce = Re[Te], ((we = y5(ze, se)).startsWith("O1") || we.startsWith("C1")) && l(Ce, Oe, je), n.push({ carbohydrateIndex: Ce, elementIndex: Oe, elementUnit: je, fromCarbohydrate: !0 });
            }
            else if (xe.length === 0) for (var Qe = 0, Je = Xe; Qe < Je.length; Qe++)
              Ae = Je[Qe], n.push({ carbohydrateIndex: Ae, elementIndex: se, elementUnit: ze, fromCarbohydrate: !1 });
          }
        });
      });
    });
  return B({ links: t, terminalLinks: n, elements: r, partialElements: i }, function(ue, se, be) {
    function ke(Kt, hn) {
      return Ta(Kt.id, hn);
    }
    function Oe(Kt, hn, jt) {
      var Rn = [], ur = Kt.get(ke(hn, jt));
      if (ur !== void 0) for (var ir = 0, Hn = ur; ir < Hn.length; ir++)
        Ca(Rn, Hn[ir]);
      return Rn;
    }
    for (var ze = /* @__PURE__ */ new Map(), je = 0, xe = ue.length; je < xe; ++je) for (var Xe = ue[je], Ee = Xe.unit, Ye = Xe.ringIndex, He = 0, le = (pe = Ee.rings.all[Ye]).length; He < le; ++He) {
      var Ce = ke(Ee, Ee.elements[pe[He]]);
      (gt = ze.get(Ce)) === void 0 ? ze.set(Ce, [je]) : gt.push(je);
    }
    function Ae(Kt, hn) {
      return Oe(ze, Kt, hn);
    }
    var Te = /* @__PURE__ */ new Map();
    for (je = 0, xe = se.length; je < xe; ++je) {
      var Re = ue[se[je].carbohydrateIndexA];
      for (Ee = Re.unit, Ye = Re.ringIndex, He = 0, le = (pe = Ee.rings.all[Ye]).length; He < le; ++He)
        Ce = ke(Ee, Ee.elements[pe[He]]), (gt = Te.get(Ce)) === void 0 ? Te.set(Ce, [je]) : gt.push(je);
    }
    function we(Kt, hn) {
      return Oe(Te, Kt, hn);
    }
    var Qe = /* @__PURE__ */ new Map();
    for (je = 0, xe = be.length; je < xe; ++je) {
      var Je = be[je], lt = Je.fromCarbohydrate, st = Je.carbohydrateIndex, ft = Je.elementUnit, It = Je.elementIndex;
      if (lt) {
        var pe, We = ue[st];
        for (Ee = We.unit, Ye = We.ringIndex, He = 0, le = (pe = Ee.rings.all[Ye]).length; He < le; ++He)
          Ce = ke(Ee, Ee.elements[pe[He]]), (gt = Qe.get(Ce)) === void 0 ? Qe.set(Ce, [je]) : gt.push(je);
      } else {
        var gt;
        Ce = ke(ft, ft.elements[It]), (gt = Qe.get(Ce)) === void 0 ? Qe.set(Ce, [je]) : gt.push(je);
      }
    }
    function cn(Kt, hn) {
      return Oe(Qe, Kt, hn);
    }
    return { getElementIndices: Ae, getLinkIndices: we, getTerminalLinkIndices: cn };
  }(r, t, n));
}
var _1 = de(), iB = new ka("14"), aB = new ka("98");
function oB(e) {
  var t = e.units, n = function(u) {
    return u > 500 ? iB : aB;
  }(t.length);
  n.reset();
  for (var r = 0, i = t.length; r < i; r++) {
    var a = (o = t[r]).boundary;
    (s = o.conformation.operator).isIdentity ? n.includeSphere(a.sphere) : (de.transform(_1, a.sphere, s.matrix), n.includeSphere(_1));
  }
  for (n.finishedIncludeStep(), r = 0, i = t.length; r < i; r++) {
    var o, s;
    a = (o = t[r]).boundary, (s = o.conformation.operator).isIdentity ? n.radiusSphere(a.sphere) : (de.transform(_1, a.sphere, s.matrix), n.radiusSphere(_1));
  }
  return { box: n.getBox(), sphere: n.getSphere() };
}
var Be = function() {
  function e(t, n, r, i, a) {
    this.units = t, this.unitMap = n, this.unitIndexMap = r, this.state = i, this._child = a == null ? void 0 : a.child, this._target = a == null ? void 0 : a.target, this._proxy = void 0;
  }
  return e.prototype.subsetBuilder = function(t) {
    return new WD(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 + rt.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 ed()), 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 n = t.units, r = 0, i = 0, a = n.length; i < a; i++) r += n[i].polymerElements.length;
      return r;
    }(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 n = t.units, r = 0, i = 0, a = n.length; i < a; i++) r += n[i].gapElements.length / 2;
      return r;
    }(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 n = t.units, r = 0, i = 0, a = n.length; i < a; i++) n[i].polymerElements.length > 0 && (r += 1);
      return r;
    }(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 n = t.unitSymmetryGroups, r = 0, i = 0, a = n.length; i < a; i++) r += n[i].elements.length;
      return r;
    }(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 n = t.units, r = 0, i = 0, a = n.length; i < a; i++) {
        var o = n[i];
        if (me.isAtomic(o)) for (var s = o.elements, u = o.residueIndex, c = -1, l = -1, d = 0, m = s.length; d < m; ++d) (c = u[s[d]]) !== l && (r += 1, l = c);
      }
      return r;
    }(this)), this.state.atomicResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarseGrained", { get: function() {
    return this.models.some(function(t) {
      return pn.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 = di(this.units.map(function(t) {
      return t.id;
    }))), this.state.transformHash;
  }, enumerable: !1, configurable: !0 }), e.prototype.computeHash = function() {
    for (var t = 23, n = 0, r = this.units.length; n < r; n++) {
      var i = this.units[n];
      t = 31 * (t = 31 * t + i.id | 0) + _e.hashCode(i.elements) | 0;
    }
    return (t = l7(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 = oB(this)), this.state.boundary;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "lookup3d", { get: function() {
    return this.state.lookup3d || (this.state.lookup3d = new VM(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 Um(/* @__PURE__ */ new Map()) : this.state.interUnitBonds = yM(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 = kl.computeTransformGroups(this)), this.state.unitSymmetryGroups;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "unitSymmetryGroupsIndexMap", { get: function() {
    return this.state.unitSymmetryGroupsIndexMap || (this.state.unitSymmetryGroupsIndexMap = me.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 = rB(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 n = t.units, r = yn.create(), i = 0, a = n; i < a.length; i++) {
        var o = a[i];
        yn.add(r, o.model.id, o.model);
      }
      return r.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 n = Me.residue.microheterogeneityCompIds, r = /* @__PURE__ */ new Set(), i = Ne.create(t), a = 0, o = t.unitSymmetryGroups; a < o.length; a++) {
        var s = o[a].units[0];
        if (me.isAtomic(s)) {
          var u = St.transientSegments(s.model.atomicHierarchy.residueAtomSegments, s.elements);
          for (i.unit = s; u.hasNext; ) {
            var c = u.move();
            i.element = s.elements[c.start];
            for (var l = 0, d = n(i); l < d.length; l++) {
              var m = d[l];
              r.add(m);
            }
          }
        }
      }
      return r;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueElementSymbols", { get: function() {
    return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = function(t) {
      for (var n = Me.atom.type_symbol, r = /* @__PURE__ */ new Set(), i = Ne.create(t), a = 0, o = t.unitSymmetryGroups; a < o.length; a++) {
        var s = o[a].units[0];
        if (me.isAtomic(s)) {
          i.unit = s;
          for (var u = 0, c = s.elements.length; u < c; ++u) i.element = s.elements[u], r.add(n(i));
        }
      }
      return r;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "entityIndices", { get: function() {
    return this.state.entityIndices || (this.state.entityIndices = function(t) {
      for (var n = t.units, r = Ne.create(t), i = yn.create(), a = 0, o = n; a < o.length; a++) {
        var s = o[a], u = s.kind === 0 ? Me.entity.key : Me.coarse.entityKey;
        r.unit = s;
        for (var c = s.elements, l = St.transientSegments(s.model.atomicHierarchy.chainAtomSegments, c); l.hasNext; ) {
          var d = l.move();
          r.element = c[d.start];
          var m = u(r);
          yn.add(i, m, m);
        }
      }
      return to(i.array), i.array;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueAtomicResidueIndices", { get: function() {
    return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = function(t) {
      for (var n = /* @__PURE__ */ new Map(), r = [], i = t.unitSymmetryGroups, a = 0, o = i; a < o.length; a++) {
        var s = o[a].units[0];
        if (me.isAtomic(s)) {
          var u = void 0;
          n.has(s.model.id) ? u = n.get(s.model.id) : (u = yn.create(), r.push(s.model.id), n.set(s.model.id, u));
          for (var c = St.transientSegments(s.model.atomicHierarchy.residueAtomSegments, s.elements); c.hasNext; ) {
            var l = c.move();
            yn.add(u, l.index, l.index);
          }
        }
      }
      for (var d = /* @__PURE__ */ new Map(), m = 0, p = r; m < p.length; m++) {
        var v = p[m], f = n.get(v).array;
        to(f), d.set(v, f);
      }
      return d;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isAtomic", { get: function() {
    for (var t = 0, n = this.units; t < n.length; t++) {
      var r = n[t];
      if (!me.isAtomic(r)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasAtomic", { get: function() {
    for (var t = 0, n = this.units; t < n.length; t++) {
      var r = n[t];
      if (me.isAtomic(r)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarse", { get: function() {
    for (var t = 0, n = this.units; t < n.length; t++) {
      var r = n[t];
      if (!me.isCoarse(r)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasCoarse", { get: function() {
    for (var t = 0, n = this.units; t < n.length; t++) {
      var r = n[t];
      if (me.isCoarse(r)) 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 n = t.units, r = t.elementCount, i = t.unitIndexMap, a = new Uint32Array(n.length), o = new Uint32Array(r), s = new Uint32Array(r), u = 0, c = 0, l = n.length; u < l; ++u) {
        a[u] = c;
        for (var d = n[u].elements, m = 0, p = d.length; m < p; ++m) {
          var v = c + m;
          o[v] = u, s[v] = d[m];
        }
        c += d.length;
      }
      return { cumulativeUnitElementCount: a, unitIndices: o, elementIndices: s, getSerialIndex: function(f, y) {
        return a[i.get(f.id)] + ve.indexOf(f.elements, y);
      } };
    }(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 n = this.state, r = n.dynamicBonds, i = n.interUnitBonds, a = n.parent, o = [], s = 0, u = this.unitSymmetryGroups; s < u.length; s++) {
      var c = u[s], l = c.units[0].remapModel(t, r);
      o.push(l);
      for (var d = 1, m = c.units.length; d < m; ++d) {
        var p = c.units[d];
        o.push(p.remapModel(t, r, l.props));
      }
    }
    return e.create(o, { parent: a == null ? void 0 : a.remapModel(t), label: this.label, interUnitBonds: r ? void 0 : i, dynamicBonds: r });
  }, 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), n = this.coordinateSystem.isIdentity ? t : e.transform(t, this.coordinateSystem.matrix);
      this._proxy = new e(n.units, n.unitMap, n.unitIndexMap, B(B({}, n.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 sB(e, t, n) {
  return e[t].id - e[n].id;
}
(function(e) {
  function t(h) {
    return { kind: "structure-loci", structure: h };
  }
  function n(h, g) {
    g === void 0 && (g = {});
    for (var x = Ro.Mutable(), C = Ro.Mutable(), b = 0, _ = !0, A = h.length > 0 ? h[0].id : 0, I = 0, w = h.length; I < w; I++) {
      var E = h[I];
      x.set(E.id, E), b += E.elements.length, E.id < A && (_ = !1), A = E.id;
    }
    for (_ || c7(h, 0, h.length, sB, uc), I = 0, w = h.length; I < w; I++) C.set(h[I].id, I);
    var D = { hashCode: -1, transformHash: -1, elementCount: b, bondCount: -1, uniqueElementCount: -1, atomicResidueCount: -1, polymerResidueCount: -1, polymerGapCount: -1, polymerUnitCount: -1, dynamicBonds: !1, coordinateSystem: xn.Default, label: "" };
    return g.parent && (D.parent = g.parent.parent || g.parent), g.interUnitBonds && (D.interUnitBonds = g.interUnitBonds), g.dynamicBonds ? D.dynamicBonds = g.dynamicBonds : g.parent && (D.dynamicBonds = g.parent.dynamicBonds), g.coordinateSystem ? D.coordinateSystem = g.coordinateSystem : g.parent && (D.coordinateSystem = g.parent.coordinateSystem), g.label ? D.label = g.label : g.parent && (D.label = g.parent.label), g.masterModel ? D.masterModel = g.masterModel : g.parent && (D.masterModel = g.parent.masterModel), g.representativeModel ? D.representativeModel = g.representativeModel : g.parent && (D.representativeModel = g.parent.representativeModel), new e(h, x, C, D);
  }
  function r(h, g) {
    g === void 0 && (g = {});
    for (var x = h.atomicHierarchy.chainAtomSegments, C = h.atomicHierarchy.index, b = h.atomicHierarchy.chains.auth_asym_id, _ = h.atomicChainOperatorMappinng, A = new o(B({ label: h.label }, g)), I = 0; I < x.count; I++) {
      var w = _.get(I) || xn.Default, E = x.offsets[I];
      Ac.chainResidueCount(h.atomicHierarchy, I), x.offsets[I + 1], x.offsets[I];
      var D = !1;
      if (i(h, I)) for (; I + 1 < x.count && i(h, I + 1) && _.get(I) === _.get(I + 1); )
        D = !0, I++;
      else for (; I + 1 < x.count && x.offsets[I + 1] - x.offsets[I] == 1 && x.offsets[I + 2] - x.offsets[I + 1] == 1 && !(C.getEntityFromChain(I) !== C.getEntityFromChain(I + 1) || b.value(I) !== b.value(I + 1) || _.get(I) !== _.get(I + 1)); )
        D = !0, I++;
      var T = _e.ofBounds(E, x.offsets[I + 1]);
      A.addUnit(0, h, w, T, D ? 1 : 0);
    }
    var P = h.coarseHierarchy;
    return P.isDefined && (P.spheres.count > 0 && a(A, h, h.coarseHierarchy.spheres, 1), P.gaussians.count > 0 && a(A, h, h.coarseHierarchy.gaussians, 2)), A.getStructure();
  }
  function i(h, g) {
    var x = h.atomicHierarchy.index.getEntityFromChain(g);
    return h.entities.data.type.value(x) === "water";
  }
  function a(h, g, x, C) {
    for (var b = x.chainElementSegments, _ = 0; _ < b.count; _++) {
      var A = _e.ofBounds(b.offsets[_], b.offsets[_ + 1]);
      h.addUnit(C, g, xn.Default, A, 0);
    }
  }
  e.Empty = n([]), e.Loci = t, e.toStructureElementLoci = function(h) {
    for (var g = [], x = 0, C = h.units; x < C.length; x++) {
      var b = C[x];
      g.push({ unit: b, indices: oe.ofBounds(0, b.elements.length) });
    }
    return Se(h, g);
  }, e.toSubStructureElementLoci = function(h, g) {
    return Ke.toLociWithSourceUnits(Ke.Singletons(h, g));
  }, e.isLoci = function(h) {
    return !!h && h.kind === "structure-loci";
  }, e.areLociEqual = function(h, g) {
    return h.structure === g.structure;
  }, e.isLociEmpty = function(h) {
    return h.structure.isEmpty;
  }, e.remapLoci = function(h, g) {
    return g === h.structure ? h : t(g);
  }, e.create = n, e.ofTrajectory = function(h, g) {
    return ie(this, 0, void 0, function() {
      var x, C, b, _, A, I, w, E, D, T, P, M, R;
      return ne(this, function(O) {
        switch (O.label) {
          case 0:
            if (h.frameCount === 0) return [2, e.Empty];
            x = [], C = void 0, b = 0, _ = 0, A = h.frameCount, O.label = 1;
          case 1:
            return _ < A ? [4, At.resolveInContext(h.getFrameAtIndex(_), g)] : [3, 4];
          case 2:
            for (I = O.sent(), C || (C = I), w = r(I), E = 0, D = w.units.length; E < D; ++E) T = w.units[E], P = T.invariantId + b, M = T.chainGroupId + b, R = me.create(x.length, P, M, T.traits, T.kind, T.model, T.conformation.operator, T.elements), x.push(R);
            b = x.length, O.label = 3;
          case 3:
            return ++_, [3, 1];
          case 4:
            return [2, n(x, { representativeModel: C, label: C.label })];
        }
      });
    });
  }, e.ofModel = r, e.transform = function(h, g) {
    if (J.isIdentity(g)) return h;
    if (!J.isRotationAndTranslation(g, xn.RotationTranslationEpsilon)) throw new Error("Only rotation/translation combination can be applied.");
    for (var x = [], C = 0, b = h.units; C < b.length; C++) {
      var _ = b[C], A = _.conformation.operator, I = xn.create(A.name, g, A);
      x.push(_.applyOperator(_.id, I));
    }
    var w = h.coordinateSystem;
    return n(x, { parent: h, coordinateSystem: xn.compose(xn.create(w.name, g, w), w) });
  };
  var o = function() {
    function h(g) {
      g === void 0 && (g = {}), this.props = g, this.units = [], this.invariantId = fi(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = S(), this.singleElementUnits = /* @__PURE__ */ new Map();
    }
    return h.prototype.beginChainGroup = function() {
      this.chainGroupId++, this.inChainGroup = !0;
    }, h.prototype.endChainGroup = function() {
      this.inChainGroup = !1;
    }, h.prototype.addUnit = function(g, x, C, b, _, A) {
      A === void 0 && (A = this.invariantId());
      var I = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, w = me.create(A, A, I, _, g, x, C, b);
      return this.add(w);
    }, h.prototype.add = function(g) {
      if (g.elements.length === 1) {
        g.conformation.position(g.elements[0], this.p);
        var x = [g.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
        if (this.singleElementUnits.has(x)) return this.singleElementUnits.get(x);
        this.singleElementUnits.set(x, g);
      }
      return this.units.push(g), g;
    }, h.prototype.addWithOperator = function(g, x, C) {
      return C === void 0 && (C = !1), this.add(g.applyOperator(this.units.length, x, C));
    }, h.prototype.getStructure = function() {
      return n(this.units, this.props);
    }, Object.defineProperty(h.prototype, "isEmpty", { get: function() {
      return this.units.length === 0;
    }, enumerable: !1, configurable: !0 }), h;
  }();
  function s(h, g) {
    if (h === g) return !0;
    if (h.elementCount !== g.elementCount) return !1;
    var x = h.units.length;
    if (x !== g.units.length) return !1;
    for (var C = 0; C < x; C++) if (h.units[C].id !== g.units[C].id) return !1;
    return !0;
  }
  function u(h, g) {
    return h === g || h.hashCode === g.hashCode && kl.areTransformGroupsEquivalent(h.unitSymmetryGroups, g.unitSymmetryGroups);
  }
  e.StructureBuilder = o, e.Builder = function(h) {
    return h === void 0 && (h = {}), new o(h);
  }, e.hashCode = function(h) {
    return h.hashCode;
  }, e.conformationHash = function(h) {
    return k2(h.units.map(function(g) {
      return me.conformationId(g);
    }).join("|"));
  }, e.areUnitIdsEqual = s, e.areUnitIdsAndIndicesEqual = function(h, g) {
    if (!s(h, g)) return !1;
    for (var x = 0, C = h.units.length; x < C; x++) if (!_e.areEqual(h.units[x].elements, g.units[x].elements)) return !1;
    return !0;
  }, e.areHierarchiesEqual = function(h, g) {
    if (h.hashCode !== g.hashCode) return !1;
    var x = h.models.length;
    if (x !== g.models.length) return !1;
    for (var C = 0; C < x; C++) if (!pn.areHierarchiesEqual(h.models[C], g.models[C])) return !1;
    return !0;
  }, e.areEquivalent = u, e.areRootsEquivalent = function(h, g) {
    return u(h.root, g.root);
  }, e.areRootsEqual = function(h, g) {
    return h.root === g.root;
  };
  var c = function() {
    function h(g) {
      this.structure = g, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = Ne.create(g), this.hasNext = g.elementCount > 0, this.hasNext && (this.elements = g.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = g.units[0]);
    }
    return h.prototype.move = function() {
      return this.advance(), this.current.element = this.elements[this.idx], this.current;
    }, h.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));
    }, h;
  }();
  e.ElementLocationIterator = c;
  var l = S();
  function d(h, g, x) {
    for (var C = h.elements, b = h.conformation, _ = b.position, A = b.r, I = l, w = Number.MAX_VALUE, E = 0, D = C.length; E < D; E++) {
      var T = C[E], P = S.distance(g, _(T, I)) - x - A(T);
      P < w && (w = P);
    }
    return w;
  }
  function m(h, g, x) {
    for (var C = h.units, b = Number.MAX_VALUE, _ = 0, A = C.length; _ < A; _++) {
      var I = d(C[_], g, x);
      I < b && (b = I);
    }
    return b;
  }
  e.minDistanceToPoint = m;
  var p, v = S();
  function f(h) {
    return h.unitSymmetryGroups.filter(function(g) {
      return g.units[0].polymerElements.length > 0;
    });
  }
  e.distance = function(h, g) {
    if (h.elementCount === 0 || g.elementCount === 0) return 0;
    for (var x = h.units, C = Number.MAX_VALUE, b = 0, _ = x.length; b < _; b++) for (var A = x[b], I = A.elements, w = A.conformation, E = w.position, D = w.r, T = 0, P = I.length; T < P; T++) {
      var M = I[T], R = m(g, E(M, v), D(M));
      R < C && (C = R);
    }
    return C;
  }, e.elementDescription = function(h) {
    return h.elementCount === 1 ? "1 element" : "".concat(h.elementCount, " elements");
  }, e.validUnitPair = function(h, g, x) {
    return !0;
  }, e.eachUnitPair = function(h, g, x) {
    var C = x.maxRadius, b = x.validUnit, _ = x.validUnitPair;
    if (h.units.some(function(O) {
      return b(O);
    })) for (var A = h.lookup3d, I = S(), w = 0, E = h.units; w < E.length; w++) {
      var D = E[w];
      if (b(D)) {
        var T = D.boundary.sphere;
        S.transformMat4(I, T.center, D.conformation.operator.matrix);
        for (var P = A.findUnitIndices(I[0], I[1], I[2], T.radius + C + 9999), M = 0; M < P.count; M++) {
          var R = h.units[P.indices[M]];
          !b(R) || D.id >= R.id || !_(D, R) || (R.elements.length >= D.elements.length ? g(D, R) : g(R, D));
        }
      }
    }
  }, e.eachAtomicHierarchyElement = function(h, g) {
    for (var x = g.chain, C = g.residue, b = g.atom, _ = Ne.create(h), A = 0, I = h.units; A < I.length; A++) {
      var w = I[A];
      if (w.kind === 0) {
        _.unit = w;
        for (var E = w.elements, D = St.transientSegments(w.model.atomicHierarchy.chainAtomSegments, E), T = St.transientSegments(w.model.atomicHierarchy.residueAtomSegments, E); D.hasNext; ) {
          var P = D.move();
          if (x && (_.element = E[P.start], x(_)), C || b) for (T.setSegment(P); T.hasNext; ) {
            var M = T.move();
            if (C && (_.element = E[M.start], C(_)), b) for (var R = M.start, O = M.end; R < O; R++) _.element = E[R], b(_);
          }
        }
      }
    }
  }, e.DefaultSizeThresholds = { smallResidueCount: 10, mediumResidueCount: 5e3, largeResidueCount: 3e4, highSymmetryUnitCount: 10, fiberResidueCount: 15 }, function(h) {
    h[h.Small = 0] = "Small", h[h.Medium = 1] = "Medium", h[h.Large = 2] = "Large", h[h.Huge = 3] = "Huge", h[h.Gigantic = 4] = "Gigantic";
  }(p = e.Size || (e.Size = {})), e.getSize = function(h, g, x) {
    g === void 0 && (g = {}), x === void 0 && (x = 1);
    var C = B(B({}, e.DefaultSizeThresholds), g);
    return h.polymerResidueCount >= C.largeResidueCount * x ? function(b, _) {
      var A = f(b);
      return A.length >= 1 && A[0].units.length > _.highSymmetryUnitCount;
    }(h, C) ? p.Huge : p.Gigantic : function(b, _) {
      var A = f(b);
      return A.length === 1 && A[0].units.length > 2 && A[0].units[0].polymerElements.length < _.fiberResidueCount;
    }(h, C) || h.polymerResidueCount < C.smallResidueCount * x ? p.Small : h.polymerResidueCount < C.mediumResidueCount * x ? p.Medium : p.Large;
  }, e.Index = Rl.createSimple("index", "root");
  var y = "__PrincipalAxes__";
  e.getPrincipalAxes = function(h) {
    if (h.currentPropertyData[y]) return h.currentPropertyData[y];
    var g = Se.getPrincipalAxes(e.toStructureElementLoci(h));
    return h.currentPropertyData[y] = g, g;
  };
})(Be || (Be = {}));
var Ic, Cl, b5, _5, x5, uB = rr.diff;
function Se(e, t) {
  return { kind: "element-loci", structure: e, elements: t };
}
(function(e) {
  function t(C) {
    for (var b = 0, _ = C.elements; b < _.length; b++) {
      var A = _[b];
      if (ve.size(A.indices) > 0) return !1;
    }
    return !0;
  }
  function n(C) {
    for (var b = 0, _ = 0, A = C.elements; _ < A.length; _++) {
      var I = A[_].indices;
      b += typeof I == "number" ? uB(I) : I.length;
    }
    return b;
  }
  function r(C) {
    return t(C) ? C : e(C.structure, [{ unit: C.elements[0].unit, indices: ve.ofSingleton(ve.start(C.elements[0].indices)) }]);
  }
  function i(C) {
    return C.length > 3 && _e.isRange(C) ? oe.ofRange(C[0], C[C.length - 1]) : _e.ofSortedArray(C);
  }
  function a(C, b) {
    for (var _ = [], A = /* @__PURE__ */ new Set(), I = 0, w = C.elements; I < w.length; I++) {
      var E = w[I];
      if (s(E)) _[_.length] = E;
      else if (E.unit.kind === 0) {
        for (var D = E.unit.elements, T = E.unit.model.atomicHierarchy, P = E.unit.model.atomicHierarchy.atoms.label_alt_id, M = T.residueAtomSegments, R = M.index, O = M.offsets, L = [], F = E.indices, G = ve.size(F), V = 0; V < G; ) {
          A.clear();
          var U = D[ve.getAt(F, V)], q = R[U];
          for (A.add(P.value(U)), V++; V < G; ) {
            var H = D[ve.getAt(F, V)];
            if (R[H] !== q) break;
            A.add(P.value(H)), V++;
          }
          for (var K = A.has(""), j = O[q], W = O[q + 1]; j < W; j++) {
            var Z = ve.indexOf(D, j);
            if (Z >= 0) {
              var Y = P.value(j);
              b && !K && Y && !A.has(Y) || (L[L.length] = Z);
            }
          }
        }
        _[_.length] = { unit: E.unit, indices: i(L) };
      } else _[_.length] = E;
    }
    return e(C.structure, _);
  }
  function o(C) {
    switch (C.kind) {
      case 0:
        return C.model.atomicHierarchy.chainAtomSegments;
      case 1:
        return C.model.coarseHierarchy.spheres.chainElementSegments;
      case 2:
        return C.model.coarseHierarchy.gaussians.chainElementSegments;
    }
  }
  function s(C) {
    return C.unit.elements.length === ve.size(C.indices);
  }
  function u(C, b, _) {
    for (var A = o(C).index, I = C.elements, w = 0, E = 0, D = I.length; E < D; E++) {
      var T = A[I[E]];
      b.has(T) && w++;
    }
    if (w !== C.elements.length) {
      var P = new Int32Array(w);
      for (w = 0, E = 0, D = I.length; E < D; E++)
        T = A[I[E]], b.has(T) && (P[w++] = E);
      P.length > 0 && (_[_.length] = { unit: C, indices: i(P) });
    } else _[_.length] = { unit: C, indices: oe.ofBounds(0, w) };
  }
  function c(C, b, _, A, I) {
    for (var w = o(C.elements[0].unit).index, E = /* @__PURE__ */ new Set(), D = b; D < _; D++) for (var T = C.elements[D], P = T.indices, M = T.unit.elements, R = 0, O = ve.size(P); R < O; R++) E.add(w[M[ve.getAt(P, R)]]);
    if (A) for (var L = C.elements[0].unit, F = 0, G = C.structure.units; F < G.length; F++) {
      var V = G[F];
      me.areSameChainOperatorGroup(V, L) && u(V, E, I);
    }
    else for (D = b; D < _; D++) u(C.elements[D].unit, E, I);
  }
  function l(C) {
    for (var b = [], _ = 0, A = C.elements.length; _ < A; _++) {
      var I = C.elements[_];
      if (me.Traits.is(I.unit.traits, 2)) {
        for (var w = _; _ < A && me.areSameChainOperatorGroup(C.elements[_].unit, I.unit); ) _++;
        var E = _;
        _--, c(C, w, E, !0, b);
      } else s(I) ? b[b.length] = I : c(C, _, _ + 1, !1, b);
    }
    return e(C.structure, b);
  }
  function d(C) {
    return "".concat(C.unit.model.id, "|").concat(Me.entity.id(C));
  }
  function m(C, b) {
    for (var _ = [], A = 0, I = ve.size(b); A < I; ++A) _.push(C[ve.getAt(b, A)]);
    return _e.ofSortedArray(_);
  }
  function p(C, b) {
    return _e.isRange(C) && _e.areEqual(C, b) ? oe.ofLength(C.length) : i(_e.indicesOf(C, b));
  }
  e.is = function(C) {
    return !!C && C.kind === "element-loci";
  }, e.areEqual = function(C, b) {
    if (C.structure !== b.structure || C.elements.length !== b.elements.length) return !1;
    for (var _ = 0, A = C.elements.length; _ < A; ++_) {
      var I = C.elements[_], w = b.elements[_];
      if (I.unit.id !== w.unit.id || !ve.areEqual(I.indices, w.indices)) return !1;
    }
    return !0;
  }, e.isEmpty = t, e.isWholeStructure = function(C) {
    return n(C) === C.structure.elementCount;
  }, e.size = n, e.all = function(C) {
    return e(C, C.units.map(function(b) {
      return { unit: b, indices: ve.ofBounds(0, b.elements.length) };
    }));
  }, e.none = function(C) {
    return e(C, []);
  }, e.getFirstLocation = function(C, b) {
    if (!t(C)) {
      var _ = C.elements[0].unit, A = _.elements[ve.getAt(C.elements[0].indices, 0)];
      return b ? (b.structure = C.structure, b.unit = C.elements[0].unit, b.element = A, b) : Ne.create(C.structure, _, A);
    }
  }, e.firstElement = r, e.firstResidue = function(C) {
    return t(C) ? C : a(r(C));
  }, e.firstChain = function(C) {
    return t(C) ? C : l(r(C));
  }, e.toStructure = function(C) {
    for (var b = [], _ = function(w) {
      var E = w.unit, D = w.indices, T = new Int32Array(ve.size(D));
      ve.forEach(D, function(P, M) {
        return T[M] = E.elements[P];
      }), b.push(E.getChild(_e.ofSortedArray(T)));
    }, A = 0, I = C.elements; A < I.length; A++)
      _(I[A]);
    return Be.create(b, { parent: C.structure.parent });
  }, e.remap = function(C, b) {
    if (b === C.structure) return C;
    var _ = [];
    return C.elements.forEach(function(A) {
      if (b.unitMap.has(A.unit.id)) {
        var I = b.unitMap.get(A.unit.id), w = ve.indexedIntersect(A.indices, A.unit.elements, I.elements);
        ve.size(w) > 0 && _.push({ unit: I, indices: w });
      }
    }), e(b, _);
  }, e.union = function C(b, _) {
    if (b.elements.length > _.elements.length) return C(_, b);
    if (e.isEmpty(b)) return _;
    for (var A = /* @__PURE__ */ new Map(), I = 0, w = b.elements; I < w.length; I++) {
      var E = w[I];
      A.set(E.unit.id, E.indices);
    }
    for (var D = [], T = 0, P = _.elements; T < P.length; T++)
      E = P[T], A.has(E.unit.id) ? (D[D.length] = { unit: E.unit, indices: ve.union(A.get(E.unit.id), E.indices) }, A.delete(E.unit.id)) : D[D.length] = E;
    return A.forEach(function(M, R) {
      D[D.length] = { unit: b.structure.unitMap.get(R), indices: M };
    }), e(b.structure, D);
  }, e.subtract = function(C, b) {
    for (var _ = /* @__PURE__ */ new Map(), A = 0, I = b.elements; A < I.length; A++) {
      var w = I[A];
      _.set(w.unit.id, w.indices);
    }
    for (var E = [], D = 0, T = C.elements; D < T.length; D++)
      if (w = T[D], _.has(w.unit.id)) {
        var P = ve.subtract(w.indices, _.get(w.unit.id));
        if (ve.size(P) === 0) continue;
        E[E.length] = { unit: w.unit, indices: P };
      } else E[E.length] = w;
    return e(C.structure, E);
  }, e.intersect = function(C, b) {
    for (var _ = /* @__PURE__ */ new Map(), A = 0, I = C.elements; A < I.length; A++) {
      var w = I[A];
      _.set(w.unit.id, w.indices);
    }
    for (var E = [], D = 0, T = b.elements; D < T.length; D++)
      if (w = T[D], _.has(w.unit.id)) {
        var P = ve.intersect(_.get(w.unit.id), w.indices);
        ve.size(P) !== 0 && (E[E.length] = { unit: w.unit, indices: P });
      }
    return e(C.structure, E);
  }, e.areIntersecting = function C(b, _) {
    if (b.elements.length > _.elements.length) return C(_, b);
    if (e.isEmpty(b)) return e.isEmpty(_);
    for (var A = /* @__PURE__ */ new Map(), I = 0, w = b.elements; I < w.length; I++) {
      var E = w[I];
      A.set(E.unit.id, E.indices);
    }
    for (var D = 0, T = _.elements; D < T.length; D++)
      if (E = T[D], A.has(E.unit.id) && ve.areIntersecting(A.get(E.unit.id), E.indices)) return !0;
    return !1;
  }, e.isSubset = function(C, b) {
    if (e.isEmpty(C)) return e.isEmpty(b);
    for (var _ = /* @__PURE__ */ new Map(), A = 0, I = C.elements; A < I.length; A++) {
      var w = I[A];
      _.set(w.unit.id, w.indices);
    }
    for (var E = !1, D = 0, T = b.elements; D < T.length; D++)
      if (w = T[D], _.has(w.unit.id)) {
        if (!ve.isSubset(_.get(w.unit.id), w.indices)) return !1;
        E = !0;
      }
    return E;
  }, e.extendToWholeResidues = a, e.extendToWholeChains = l, e.extendToWholeEntities = function(C) {
    for (var b = [], _ = Ne.create(C.structure), A = /* @__PURE__ */ new Set(), I = C.structure.units, w = 0, E = C.elements.length; w < E; w++) {
      var D = C.elements[w];
      _.unit = D.unit, _.element = D.unit.elements[0], A.add(d(_));
    }
    w = 0;
    for (var T = I.length; w < T; ++w) {
      var P = I[w];
      if (_.unit = P, _.element = P.elements[0], A.has(d(_))) {
        var M = ve.ofBounds(0, P.elements.length);
        b[b.length] = { unit: P, indices: M };
      }
    }
    return e(C.structure, b);
  }, e.extendToWholeModels = function(C) {
    for (var b = [], _ = /* @__PURE__ */ new Set(), A = C.structure.units, I = 0, w = C.elements.length; I < w; I++) {
      var E = C.elements[I];
      _.add(E.unit.model.id);
    }
    I = 0;
    for (var D = A.length; I < D; ++I) {
      var T = A[I];
      if (_.has(T.model.id)) {
        var P = ve.ofBounds(0, T.elements.length);
        b[b.length] = { unit: T, indices: P };
      }
    }
    return e(C.structure, b);
  }, e.extendToAllInstances = function(C) {
    for (var b = [], _ = /* @__PURE__ */ new Map(), A = 0, I = C.elements.length; A < I; A++) {
      var w = C.elements[A], E = w.unit.model, D = m(w.unit.elements, w.indices);
      _.has(E) ? _.set(E, _e.union(D, _.get(E))) : _.set(E, D);
    }
    A = 0;
    for (var T = C.structure.units.length; A < T; ++A) {
      var P = C.structure.units[A];
      if (D = _.get(P.model)) {
        var M = p(P.elements, D);
        ve.size(M) && (b[b.length] = { unit: P, indices: M });
      }
    }
    return e(C.structure, b);
  }, e.extendToWholeOperators = function(C) {
    for (var b = [], _ = /* @__PURE__ */ new Set(), A = C.structure.units, I = 0, w = C.elements.length; I < w; I++) {
      var E = C.elements[I];
      _.add(E.unit.conformation.operator.name);
    }
    I = 0;
    for (var D = A.length; I < D; ++I) {
      var T = A[I];
      if (_.has(T.conformation.operator.name)) {
        var P = ve.ofBounds(0, T.elements.length);
        b[b.length] = { unit: T, indices: P };
      }
    }
    return e(C.structure, b);
  };
  var v = new ka("98"), f = S();
  e.getBoundary = function(C, b) {
    v.reset();
    for (var _ = 0, A = C.elements; _ < A.length; _++) for (var I = (O = A[_]).indices, w = O.unit.conformation.position, E = O.unit.conformation.r, D = O.unit.elements, T = 0, P = ve.size(I); T < P; T++)
      w(L = D[ve.getAt(I, T)], f), b && S.transformMat4(f, f, b), v.includePositionRadius(f, E(L));
    v.finishedIncludeStep();
    for (var M = 0, R = C.elements; M < R.length; M++) {
      var O;
      for (I = (O = R[M]).indices, w = O.unit.conformation.position, E = O.unit.conformation.r, D = O.unit.elements, T = 0, P = ve.size(I); T < P; T++) {
        var L;
        w(L = D[ve.getAt(I, T)], f), b && S.transformMat4(f, f, b), v.radiusPositionRadius(f, E(L));
      }
    }
    return { box: v.getBox(), sphere: v.getSphere() };
  };
  var y = S();
  function h(C, b, _) {
    _ === void 0 && (_ = 0);
    for (var A = _, I = 0, w = C.elements; I < w.length; I++) {
      for (var E = w[I], D = E.indices, T = E.unit.conformation.position, P = E.unit.elements, M = ve.size(D), R = 0; R < M; R++)
        T(P[ve.getAt(D, R)], y), S.toArray(y, b, A + 3 * R);
      A += 3 * M;
    }
    return b;
  }
  function g(C, b) {
    return me.isAtomic(C) ? C.model.atomicHierarchy.atomSourceIndex.value(b) : b;
  }
  function x(C, b, _, A, I) {
    to(b);
    for (var w = [], E = [], D = 0, T = b.length; D < T; ) {
      var P = D;
      for (D++; D < T && b[D - 1] + 1 === b[D]; ) D++;
      var M = D;
      if (M - P > 12) w[w.length] = b[P], w[w.length] = b[M - 1];
      else for (var R = P; R < M; R++) E[E.length] = b[R];
    }
    return _ ? { atom: { set: E, ranges: w }, chain: { opName: [C] }, entity: { modelLabel: A, modelIndex: I } } : { atom: { set: E, ranges: w }, chain: { opName: [C] } };
  }
  e.toPositionsArray = h, e.getPrincipalAxes = function(C) {
    var b = n(C), _ = h(C, new Float32Array(3 * b));
    return _u.ofPositions(_);
  }, e.getPrincipalAxesMany = function(C) {
    var b = 0;
    C.forEach(function(I) {
      b += n(I);
    });
    var _ = new Float32Array(3 * b), A = 0;
    return C.forEach(function(I) {
      h(I, _, A), A += 3 * n(I);
    }), _u.ofPositions(_);
  }, e.toExpression = function(C) {
    var b;
    if (e.isEmpty(C)) return ot.struct.generator.empty();
    for (var _ = C.structure.models, A = /* @__PURE__ */ new Map(), I = 0, w = C.elements; I < w.length; I++) {
      var E = (V = w[I]).indices, D = V.unit.elements, T = V.unit.conformation.operator.name, P = void 0;
      A.has(T) ? P = A.get(T).xs : (P = yn.create(), A.set(T, { modelLabel: V.unit.model.label, modelIndex: V.unit.model.modelNum, xs: P }));
      for (var M = 0, R = ve.size(E); M < R; M++) {
        var O = g(V.unit, D[ve.getAt(E, M)]);
        yn.add(P, O, O);
      }
    }
    for (var L = [], F = A.keys(); ; ) {
      var G = F.next();
      if (G.done) break;
      var V = A.get(G.value);
      L.push(x(G.value, V.xs.array, _.length > 1, V.modelLabel, V.modelIndex));
    }
    for (var U = /* @__PURE__ */ new Map(), q = (M = 0, L.length); M < q; ++M) {
      var H = L[M], K = $l(di(H.atom.ranges), di(H.atom.set));
      T = "".concat(K, "|").concat(H.entity ? H.entity.modelLabel + H.entity.modelIndex : ""), U.has(T) ? (b = U.get(T).chain.opName).push.apply(b, H.chain.opName) : U.set(T, H);
    }
    var j = [];
    return U.forEach(function(W) {
      var Z = W.atom, Y = Z.ranges, te = Z.set, ee = W.chain.opName, $ = ot.struct.atomProperty.core.operatorName(), ue = ot.struct.atomProperty.core.sourceIndex(), se = [];
      te.length > 0 && (se[se.length] = ot.core.set.has([ot.core.type.set(te), ue]));
      for (var be = 0, ke = Y.length / 2; be < ke; be++) se[se.length] = ot.core.rel.inRange([ue, Y[2 * be], Y[2 * be + 1]]);
      if (W.entity) {
        var Oe = W.entity, ze = Oe.modelLabel, je = Oe.modelIndex;
        j.push(ot.struct.generator.atomGroups({ "atom-test": se.length > 1 ? ot.core.logic.or(se) : se[0], "chain-test": ee.length > 1 ? ot.core.set.has([ot.core.type.set(ee), $]) : ot.core.rel.eq([$, ee[0]]), "entity-test": ot.core.logic.and([ot.core.rel.eq([ot.struct.atomProperty.core.modelLabel(), ze]), ot.core.rel.eq([ot.struct.atomProperty.core.modelIndex(), je])]) }));
      } else j.push(ot.struct.generator.atomGroups({ "atom-test": se.length > 1 ? ot.core.logic.or(se) : se[0], "chain-test": ee.length > 1 ? ot.core.set.has([ot.core.type.set(ee), $]) : ot.core.rel.eq([$, ee[0]]) }));
    }), ot.struct.modifier.union([j.length === 1 ? j[0] : ot.struct.combinator.merge(j.map(function(W) {
      return ot.struct.modifier.union([W]);
    }))]);
  };
})(Se || (Se = {})), function(e) {
  function t() {
    return { elementCount: 0, conformationCount: 0, residueCount: 0, chainCount: 0, unitCount: 0, structureCount: 0, firstElementLoc: Ne.create(void 0), firstConformationLoc: Ne.create(void 0), firstResidueLoc: Ne.create(void 0), firstChainLoc: Ne.create(void 0), firstUnitLoc: Ne.create(void 0), firstStructureLoc: Ne.create(void 0) };
  }
  function n(o, s, u) {
    var c = o.get(s) || 0;
    o.set(s, c + u);
  }
  function r(o, s, u) {
    var c = u.indices, l = u.unit, d = l.elements, m = ve.size(c), p = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
    if (m > 0 && Ne.set(o.firstElementLoc, s, l, d[ve.start(c)]), m === d.length) o.unitCount += 1, o.unitCount === 1 && Ne.set(o.firstUnitLoc, s, l, d[ve.start(c)]);
    else if (m === 1) {
      if (me.Traits.is(l.traits, 1)) return;
      o.elementCount += 1, o.elementCount === 1 && Ne.set(o.firstElementLoc, s, l, d[ve.start(c)]);
    } else if (me.isAtomic(l)) for (var f = l.model.atomicHierarchy.residueAtomSegments, y = f.index, h = f.offsets, g = l.model.atomicHierarchy.atoms.label_alt_id, x = 0, C = function() {
      p.clear();
      var b = 0, _ = d[ve.getAt(c, x)], A = y[_];
      for (n(p, g.value(_), 1), ++x, ++b; x < m; ) {
        var I = d[ve.getAt(c, x)];
        if (y[I] !== A) break;
        n(p, g.value(I), 1), ++x, ++b;
      }
      if (h[A + 1] - h[A] === b) o.residueCount += 1, o.residueCount === 1 && Ne.set(o.firstResidueLoc, s, l, h[A]);
      else {
        v.clear();
        for (var w = h[A], E = h[A + 1]; w < E; ++w) n(v, g.value(w), 1);
        v.get("") === p.get("") && p.forEach(function(D, T) {
          if (v.get(T) === D) {
            if (T !== "" && (o.conformationCount += 1, o.conformationCount === 1)) {
              for (var P = h[A], M = h[A + 1]; P < M; ++P) if (T === g.value(P)) {
                Ne.set(o.firstConformationLoc, s, l, P);
                break;
              }
            }
            b -= D;
          }
        }), o.elementCount += b;
      }
    }; x < m; ) C();
    else o.elementCount += m, o.elementCount === 1 && Ne.set(o.firstElementLoc, s, l, d[ve.start(c)]);
  }
  function i(o, s, u) {
    var c = u.indices, l = u.unit, d = ve.size(c);
    if (d !== 0) {
      var m = l.elements;
      if (me.Traits.is(l.traits, 1)) {
        var p = me.isAtomic(l) ? l.model.atomicHierarchy.chainAtomSegments : me.isSpheres(l) ? l.model.coarseHierarchy.spheres.chainElementSegments : me.isGaussians(l) ? l.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
        if (p) for (var v = p.index, f = p.offsets, y = 0; y < d; ) {
          var h = 0, g = m[ve.getAt(c, y)], x = v[g];
          for (++y, ++h; y < d && v[m[ve.getAt(c, y)]] === x; )
            ++y, ++h;
          f[x + 1] - f[x] === h ? (o.chainCount += 1, o.chainCount === 1 && Ne.set(o.firstChainLoc, s, l, f[x])) : d === 1 && (o.elementCount += 1, o.elementCount === 1 && Ne.set(o.firstElementLoc, s, l, g));
        }
        else console.warn("StructureElement loci stats: unknown unit type");
      } else d === m.length && (o.chainCount += 1, o.chainCount === 1 && Ne.set(o.firstChainLoc, s, l, m[ve.start(c)]));
    }
  }
  function a(o, s, u, c, l) {
    var d = u[c], m = me.isAtomic(d.unit) ? d.unit.model.atomicHierarchy.chainAtomSegments : me.isSpheres(d.unit) ? d.unit.model.coarseHierarchy.spheres.chainElementSegments : me.isGaussians(d.unit) ? d.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (m) {
      for (var p = m.index, v = m.offsets, f = /* @__PURE__ */ new Map(), y = c; y < l; y++) {
        var h = (d = u[y]).indices, g = d.unit;
        if ((I = ve.size(h)) !== 0) {
          var x = g.elements;
          if (me.Traits.is(g.traits, 1)) for (var C = 0; C < I; ) {
            var b = 0, _ = p[w = x[ve.getAt(h, C)]];
            for (++C, ++b; C < I && p[x[ve.getAt(h, C)]] === _; )
              ++C, ++b;
            n(f, _, b);
          }
          else n(f, p[w = x[ve.start(h)]], x.length);
        }
      }
      var A = -1;
      if (f.forEach(function(E, D) {
        v[D + 1] - v[D] === E && (o.chainCount += 1, o.chainCount === 1 && (A = D));
      }), !(A < 0)) for (y = c; y < l; y++) {
        var I;
        if (h = (d = u[y]).indices, g = d.unit, (I = ve.size(h)) !== 0) for (x = g.elements, C = 0; C < I; ) {
          var w;
          if ((_ = p[w = x[ve.getAt(h, C)]]) === A) return void Ne.set(o.firstChainLoc, s, g, w);
        }
      }
    } else console.warn("StructureElement loci stats: unknown unit type");
  }
  e.create = t, e.ofLoci = function(o) {
    var s = t();
    if (Se.isEmpty(o)) return s;
    var u = !1;
    if (Se.isWholeStructure(o)) {
      if (s.structureCount += 1, s.structureCount === 1) {
        var c = o.elements[0], l = c.unit, d = c.indices;
        Ne.set(s.firstStructureLoc, o.structure, l, l.elements[ve.min(d)]);
      }
    } else for (var m = 0, p = o.elements; m < p.length; m++) {
      var v = p[m];
      r(s, o.structure, v), me.Traits.is(v.unit.traits, 2) ? u = !0 : i(s, o.structure, v);
    }
    if (u) {
      for (var f = 0, y = o.elements.length; f < y; f++)
        if (v = o.elements[f], me.Traits.is(v.unit.traits, 2)) {
          for (var h = f; f < y && me.areSameChainOperatorGroup(o.elements[f].unit, v.unit); ) f++;
          var g = f;
          f--, g - h == 1 ? i(s, o.structure, v) : a(s, o.structure, o.elements, h, g);
        }
    }
    return s;
  }, e.add = function(o, s, u) {
    return s.elementCount === 1 && u.elementCount === 0 ? Ne.copy(o.firstElementLoc, s.firstElementLoc) : s.elementCount === 0 && u.elementCount === 1 && Ne.copy(o.firstElementLoc, u.firstElementLoc), s.conformationCount === 1 && u.conformationCount === 0 ? Ne.copy(o.firstConformationLoc, s.firstConformationLoc) : s.conformationCount === 0 && u.conformationCount === 1 && Ne.copy(o.firstConformationLoc, u.firstConformationLoc), s.residueCount === 1 && u.residueCount === 0 ? Ne.copy(o.firstResidueLoc, s.firstResidueLoc) : s.residueCount === 0 && u.residueCount === 1 && Ne.copy(o.firstResidueLoc, u.firstResidueLoc), s.chainCount === 1 && u.chainCount === 0 ? Ne.copy(o.firstChainLoc, s.firstChainLoc) : s.chainCount === 0 && u.chainCount === 1 && Ne.copy(o.firstChainLoc, u.firstChainLoc), s.unitCount === 1 && u.unitCount === 0 ? Ne.copy(o.firstUnitLoc, s.firstUnitLoc) : s.unitCount === 0 && u.unitCount === 1 && Ne.copy(o.firstUnitLoc, u.firstUnitLoc), s.structureCount === 1 && u.structureCount === 0 ? Ne.copy(o.firstStructureLoc, s.firstStructureLoc) : s.structureCount === 0 && u.structureCount === 1 && Ne.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;
  };
}(Ic || (Ic = {})), function(e) {
  function t(n) {
    var r = this, i = n.descriptor.name, a = n.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", o = function(u) {
      return i in u[a] || (u[a][i] = { props: B({}, N.getDefaultValues(n.getParams(u))), data: lu.create(void 0) }), u[a][i];
    }, s = function(u, c, l) {
      var d = o(u);
      u[a][i] = { props: c, data: lu.withValue(d.data, l) };
    };
    return { label: n.label, descriptor: n.descriptor, isHidden: n.isHidden, getParams: function(u) {
      var c = N.clone(n.getParams(u));
      return N.setDefaultValues(c, o(u).props), c;
    }, defaultParams: n.defaultParams, isApplicable: n.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), ie(r, 0, void 0, function() {
        var m, p, v, f, y;
        return ne(this, function(h) {
          switch (h.label) {
            case 0:
              return d && c.customProperties.reference(n.descriptor, !0), m = o(c), p = N.merge(n.defaultParams, m.props, l), m.data.value && N.areEqual(n.defaultParams, m.props, p) ? [2] : [4, n.obtain(u, c, p)];
            case 1:
              return v = h.sent(), f = v.value, y = v.assets, c.customProperties.add(n.descriptor), c.customProperties.assets(n.descriptor, y), s(c, p, f), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customProperties.reference(n.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 = N.merge(n.defaultParams, l.props, c);
      N.areEqual(n.defaultParams, l.props, d) || (s(u, d, void 0), u.customProperties.assets(n.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(n, r, i) {
    var a = this, o = { value: N.Value(i, { isHidden: !0 }) };
    return t({ label: To(n), descriptor: no({ name: n }), isHidden: !0, type: r, defaultParams: o, getParams: function() {
      return { value: N.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return ie(a, 0, void 0, function() {
        var l;
        return ne(this, function(d) {
          return [2, { value: (l = c.value) !== null && l !== void 0 ? l : i }];
        });
      });
    } });
  };
}(Cl || (Cl = {})), function(e) {
  var t = this;
  function n(i) {
    if (!_n.is(i.sourceData)) return !1;
    var a = i.sourceData.data.db.atom_site, o = a.pdbx_sifts_xref_db_name, s = a.pdbx_sifts_xref_db_acc, u = a.pdbx_sifts_xref_db_num, c = a.pdbx_sifts_xref_db_res;
    return o.isDefined && s.isDefined && u.isDefined && c.isDefined;
  }
  function r(i) {
    if (_n.is(i.sourceData)) {
      var a = i.sourceData.data.db.atom_site, o = a.pdbx_sifts_xref_db_name, s = a.pdbx_sifts_xref_db_acc, u = a.pdbx_sifts_xref_db_num, c = a.pdbx_sifts_xref_db_res;
      if (o.isDefined && s.isDefined && u.isDefined && c.isDefined) {
        for (var l = i.atomicHierarchy.atomSourceIndex, d = i.atomicHierarchy.residueAtomSegments, m = d.count, p = d.offsets, v = new Array(m), f = new Array(m), y = new Array(m), h = new Array(m), g = 0; g < m; g++) {
          var x = l.value(p[g]);
          o.valueKind(x) === 0 ? (v[g] = o.value(x), f[g] = s.value(x), y[g] = u.value(x), h[g] = c.value(x)) : (v[g] = "", f[g] = "", y[g] = "", h[g] = "");
        }
        return { dbName: v, accession: f, num: y, residue: h };
      }
    }
  }
  e.Provider = Cl.createProvider({ label: "SIFTS Mapping", descriptor: no({ name: "sifts_sequence_mapping" }), type: "static", defaultParams: {}, getParams: function() {
    return {};
  }, isApplicable: function(i) {
    return n(i);
  }, obtain: function(i, a) {
    return ie(t, 0, void 0, function() {
      return ne(this, function(o) {
        return [2, { value: r(a) }];
      });
    });
  } }), e.isAvailable = n, e.getKey = function(i) {
    var a = i.unit.model, o = e.Provider.get(a).value;
    if (!o) return "";
    var s = i.unit.elements[i.element], u = a.atomicHierarchy.residueAtomSegments.index[s];
    return o.accession[u];
  }, e.getLabel = function(i) {
    var a = i.unit.model, o = e.Provider.get(a).value;
    if (o) {
      var s = i.unit.elements[i.element], u = a.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]);
    }
  };
}(b5 || (b5 = {})), Ar.Field, Ar.Encodings, Ar.Field, Ar.Category, Ar.Category, Ar.Category, function(e) {
  e.create = function(t) {
    var n = Array.isArray(t) ? t : [t];
    return { structures: n, firstModel: n[0].model, cache: /* @__PURE__ */ Object.create(null) };
  };
}(_5 || (_5 = {})), function(e) {
  e.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
}(x5 || (x5 = {}));
var cB = { molstar_atom_site_operator_mapping: { label_asym_id: X.Schema.Str(), auth_asym_id: X.Schema.Str(), operator_name: X.Schema.Str(), suffix: X.Schema.Str(), assembly_id: X.Schema.Str(), assembly_operator_id: X.Schema.Int(), symmetry_operator_index: X.Schema.Int(), symmetry_hkl: X.Schema.Vector(3), ncs_id: X.Schema.Int() } }, S5 = function(e, t) {
  return t[e].operator.assembly === void 0 ? 1 : 0;
}, Bp = function(e, t) {
  return t[e].operator.spgrOp === -1 ? 1 : 0;
};
function nf(e, t) {
  return t ? t.length === 1 ? Ta(t.charCodeAt(0), e) : t.length === 2 ? Ta(t.charCodeAt(0), Ta(t.charCodeAt(1), e)) : "".concat(e, " ").concat(t) : e;
}
function lB(e, t, n, r) {
  if (e.has(t))
    (i = e.get(t)).has(n) || i.set(n, r);
  else {
    var i = /* @__PURE__ */ new Map();
    e.set(t, i), i.set(n, r);
  }
}
function dB(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
Ar.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 n;
  return ((n = t[e].operator.assembly) === null || n === void 0 ? void 0 : n.id) || "";
}, { valueKind: S5 }).int("assembly_operator_id", function(e, t) {
  var n;
  return ((n = t[e].operator.assembly) === null || n === void 0 ? void 0 : n.operId) || 0;
}, { valueKind: S5 }).int("symmetry_operator_index", function(e, t) {
  return t[e].operator.spgrOp;
}, { valueKind: Bp }).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: Bp }).int("ncs_id", function(e, t) {
  return t[e].operator.ncsId;
}, { valueKind: Bp }).getFields();
var ld = uv.EmptyResidueKey(), fB = 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 n = this.map.label_asym_id.get(t);
    return n !== void 0 ? n : -1;
  }, e.prototype.findChainLabel = function(t) {
    var n = this.entityIndex(t.label_entity_id);
    if (n < 0 || !this.map.entity_index_label_asym_id.has(n)) return -1;
    var r = this.map.entity_index_label_asym_id.get(n);
    return r && r.has(t.label_asym_id) ? r.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 n = this.map.auth_asym_id_auth_seq_id.get(t.auth_asym_id);
    return n.has(t.auth_seq_id) ? n.get(t.auth_seq_id) : -1;
  }, e.prototype.findResidue = function(t, n, r, i) {
    var a;
    arguments.length === 1 ? a = t : (ld.label_entity_id = t, ld.label_asym_id = n, ld.auth_seq_id = r, ld.pdbx_PDB_ins_code = i, a = ld);
    var o = this.findChainLabel(a);
    if (o < 0) return -1;
    var s = this.map.chain_index_auth_seq_id.get(o), u = nf(a.auth_seq_id, a.pdbx_PDB_ins_code || "");
    return s.has(u) ? s.get(u) : -1;
  }, e.prototype.findResidueAuth = function(t) {
    var n = this.findChainAuth(t);
    if (n < 0) return -1;
    var r = this.map.chain_index_auth_seq_id.get(n), i = nf(t.auth_seq_id, t.pdbx_PDB_ins_code || "");
    return r.has(i) ? r.get(i) : -1;
  }, e.prototype.findResidueInsertion = function(t) {
    var n = this.findChainLabel(t);
    if (n < 0) return -1;
    var r = this.map.chain_index_label_seq_id.get(n), i = nf(t.label_seq_id, t.pdbx_PDB_ins_code || "");
    if (r.has(i)) return r.get(i);
    var a = _e.findPredecessorIndex(this.map.label_seq_id, t.label_seq_id), o = Ac.chainStartResidueIndex(this.map.segments, n);
    if (a < o) return o;
    var s = Ac.chainEndResidueIndexExcl(this.map.segments, n) - 1;
    return a >= s ? s : a;
  }, e.prototype.findAtom = function(t) {
    var n = this.findResidue(t);
    return n < 0 ? -1 : t.label_alt_id === void 0 ? Rp(this.residueOffsets[n], this.residueOffsets[n + 1], this.map.label_atom_id, t.label_atom_id) : kp(this.residueOffsets[n], this.residueOffsets[n + 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 n = this.findResidueAuth(t);
    return n < 0 ? -1 : t.label_alt_id === void 0 ? Rp(this.residueOffsets[n], this.residueOffsets[n + 1], this.map.auth_atom_id, t.auth_atom_id) : kp(this.residueOffsets[n], this.residueOffsets[n + 1], this.map.auth_atom_id, this.map.label_alt_id, t.auth_atom_id, t.label_alt_id);
  }, e.prototype.findAtomOnResidue = function(t, n, r) {
    return r === void 0 ? Rp(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, n) : kp(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, this.map.label_alt_id, n, r);
  }, e.prototype.findAtomsOnResidue = function(t, n) {
    return function(r, i, a, o) {
      for (var s = r; s < i; s++) if (o.has(a.value(s))) return s;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, n);
  }, e.prototype.findElementOnResidue = function(t, n) {
    return function(r, i, a, o) {
      for (var s = r; s < i; s++) if (a.value(s) === o) return s;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.type_symbol, n);
  }, e;
}();
function Rp(e, t, n, r) {
  for (var i = e; i < t; i++) if (n.value(i) === r) return i;
  return -1;
}
function kp(e, t, n, r, i, a) {
  for (var o = e; o < t; o++) if (n.value(o) === i && r.value(o) === a) return o;
  return -1;
}
function mB(e, t, n) {
  for (var r = function(E, D, T) {
    return { entities: E, segments: T, label_seq_id: _e.ofSortedArray(D.residues.label_seq_id.toArray({ array: Int32Array })), label_atom_id: D.atoms.label_atom_id, auth_atom_id: D.atoms.auth_atom_id, label_alt_id: D.atoms.label_alt_id, type_symbol: D.atoms.type_symbol, chain_index_entity_index: new Int32Array(D.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, n), i = e.residues, a = i.label_seq_id, o = i.auth_seq_id, s = i.pdbx_PDB_ins_code, u = e.chains, c = u.label_entity_id, l = u.label_asym_id, d = u.auth_asym_id, m = oe.ofBounds(0, e.atoms._rowCount), p = St.transientSegments(n.chainAtomSegments, m); p.hasNext; ) {
    var v = p.move(), f = v.index, y = t.getEntityIndex(c.value(f));
    y < 0 && dB(c.value(f)), r.chain_index_entity_index[f] = y;
    var h = d.value(f), g = r.auth_asym_id_auth_seq_id.get(h);
    g || (g = /* @__PURE__ */ new Map(), r.auth_asym_id_auth_seq_id.set(h, g));
    var x = l.value(f);
    r.label_asym_id.has(x) || r.label_asym_id.set(x, y), lB(r.entity_index_label_asym_id, y, x, f);
    var C = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
    r.chain_index_label_seq_id.set(f, C), r.chain_index_auth_seq_id.set(f, b);
    for (var _ = St.transientSegments(n.residueAtomSegments, m, v); _.hasNext; ) {
      var A = _.move().index, I = o.value(A), w = s.value(A);
      C.set(nf(a.value(A), w), A), b.set(nf(I, w), A), g.set(I, f);
    }
  }
  return new fB(r);
}
function pB(e, t, n, r, i, a) {
  var o = function(m) {
    if (m._rowCount === 0) return { residues: [], chains: [] };
    for (var p = m._rowCount, v = [0], f = [0], y = m.label_entity_id, h = m.label_asym_id, g = m.label_seq_id, x = m.auth_seq_id, C = m.pdbx_PDB_ins_code, b = 1; b < p; b++) {
      var _ = !y.areValuesEqual(b - 1, b) || !h.areValuesEqual(b - 1, b);
      (_ || !g.areValuesEqual(b - 1, b) || !x.areValuesEqual(b - 1, b) || !C.areValuesEqual(b - 1, b)) && (v[v.length] = b), _ && (f[f.length] = b);
    }
    return { residues: v, chains: f };
  }(e), s = function(m, p, v) {
    var f = Jt.ofColumns(cD, { type_symbol: X.ofArray({ array: X.mapToArray(m.type_symbol, Tl), schema: X.Schema.Aliased(X.Schema.str) }), label_atom_id: m.label_atom_id, auth_atom_id: m.auth_atom_id, label_alt_id: m.label_alt_id, label_comp_id: m.label_comp_id, auth_comp_id: m.auth_comp_id, pdbx_formal_charge: m.pdbx_formal_charge, cdr: m.cdr, B_iso_or_equiv: m.B_iso_or_equiv, em_confidence: m.em_confidence }), y = Jt.view(m, lD, v.residues), h = Jt.view(m, dD, v.chains);
    if (!y.label_seq_id.isDefined) {
      for (var g = new Int32Array(y.label_seq_id.rowCount), x = v.residues, C = v.chains, b = 0, _ = 0, A = 0, I = g.length; A < I; ++A) x[A] >= C[b + 1] && (b += 1, _ = 0), g[A] = ++_;
      y.label_seq_id = X.ofIntArray(g);
    }
    return Jt.columnToArray(y, "label_seq_id", Int32Array), Jt.columnToArray(y, "auth_seq_id", Int32Array), { atoms: f, residues: y, chains: h, atomSourceIndex: p };
  }(e, t, o), u = function(m, p) {
    var v = /* @__PURE__ */ new Map();
    if (!_n.is(p)) return v;
    var f = tc(cB, p.data.frame).molstar_atom_site_operator_mapping;
    if (f._rowCount === 0) return v;
    for (var y = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = 0; g < f._rowCount; g++) {
      var x = f.assembly_operator_id.valueKind(g) === 0 ? { id: f.assembly_id.value(g), operList: [], operId: f.assembly_operator_id.value(g) } : void 0, C = xn.create(f.operator_name.value(g), J.identity(), { assembly: x, spgrOp: f.symmetry_operator_index.valueKind(g) === 0 ? f.symmetry_operator_index.value(g) : void 0, hkl: S.ofArray(f.symmetry_hkl.value(g)), ncsId: f.ncs_id.value(g) }), b = f.suffix.value(g), _ = f.label_asym_id.value(g);
      y.set("".concat(_).concat(b), { name: _, operator: C });
      var A = f.auth_asym_id.value(g);
      h.set("".concat(A).concat(b), A);
    }
    var I = m.chains, w = I.label_asym_id, E = I.auth_asym_id, D = new Array(w.rowCount), T = new Array(w.rowCount);
    for (g = 0; g < w.rowCount; g++) if (_ = w.value(g), A = E.value(g), y.has(_)) {
      var P = y.get(_), M = P.name;
      C = P.operator, v.set(g, C), D[g] = M, T[g] = h.get(A) || A;
    } else D[g] = _, T[g] = A;
    return m.chains.label_asym_id = X.ofArray({ array: D, valueKind: m.chains.label_asym_id.valueKind, schema: m.chains.label_asym_id.schema }), m.chains.auth_asym_id = X.ofArray({ array: T, valueKind: m.chains.auth_asym_id.valueKind, schema: m.chains.auth_asym_id.schema }), v;
  }(s, i);
  if (a && function(m, p) {
    return Jt.areEqual(m.chains, p.chains) && Jt.areEqual(m.residues, p.residues) && Jt.areEqual(m.atoms, p.atoms);
  }(a.atomicHierarchy, s)) return { sameAsPrevious: !0, hierarchy: a.atomicHierarchy, chainOperatorMapping: u };
  var c = { residueAtomSegments: St.ofOffsets(o.residues, oe.ofBounds(0, e._rowCount)), chainAtomSegments: St.ofOffsets(o.chains, oe.ofBounds(0, e._rowCount)) }, l = mB(s, n, c), d = function(m, p, v, f) {
    for (var y = m.atoms, h = y.label_comp_id, g = y.type_symbol, x = y._rowCount, C = m.residues._rowCount, b = p.residueAtomSegments.offsets, _ = new Uint8Array(x), A = 0; A < x; ++A) _[A] = yf(g.value(A));
    var I = new Int32Array(C), w = new Int32Array(C), E = new Int32Array(C), D = new Uint8Array(C), T = new Uint8Array(C), P = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map();
    for (A = 0; A < C; ++A) {
      var R = h.value(b[A]), O = f, L = void 0, F = void 0;
      if (P.has(R)) L = P.get(R), F = M.get(R);
      else {
        var G = void 0;
        O.has(R) ? G = O.get(R).type : (P7 || console.info("chemComp not found", R), G = v9(R)), F = YT(G, L = Ff(G, R)), P.set(R, L), M.set(R, F);
      }
      D[A] = L, T[A] = F;
      var V = hu(F, "trace"), U = v.findAtomsOnResidue(A, V);
      if (U === -1) {
        var q = hu(F, "coarseBackbone");
        (U = v.findAtomsOnResidue(A, q)) === -1 && Hg(L) && (U = v.findElementOnResidue(A, Tl("C")));
      }
      I[A] = U;
      var H = hu(F, "directionFrom");
      w[A] = v.findAtomsOnResidue(A, H);
      var K = hu(F, "directionTo");
      E[A] = v.findAtomsOnResidue(A, K);
    }
    return { atom: { atomicNumber: _ }, residue: { traceElementIndex: I, directionFromElementIndex: w, directionToElementIndex: E, moleculeType: D, polymerType: T } };
  }(s, c, l, r);
  return { sameAsPrevious: !1, hierarchy: B(B(B({}, s), c), { index: l, derived: d }), chainOperatorMapping: u };
}
function q9(e, t, n, r, i, a) {
  var o = pB(e, t, n, r, i, a), s = o.sameAsPrevious, u = o.hierarchy, c = o.chainOperatorMapping, l = function(d) {
    return { id: vr.create22(), atomId: d.id, occupancy: d.occupancy.isDefined ? d.occupancy : X.ofConst(1, d._rowCount, X.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 dv, C5 = { chainKey: [], entityKey: [], findSequenceKey: function() {
  return -1;
}, findChainKey: function() {
  return -1;
}, getEntityFromChain: function() {
  return -1;
}, count: 0, entity_id: X.Undefined(0, X.Schema.str), asym_id: X.Undefined(0, X.Schema.str), seq_id_begin: X.Undefined(0, X.Schema.int), seq_id_end: X.Undefined(0, X.Schema.int), chainElementSegments: St.create([]), polymerRanges: dn.ofSortedRanges([]), gapRanges: dn.ofSortedRanges([]) };
function hB(e, t, n) {
  if (e.has(t)) return e.get(t);
  var r = n.index++;
  return e.set(t, r), r;
}
function vB(e, t) {
  if (e.has(t)) return e.get(t);
  var n = /* @__PURE__ */ new Map();
  return e.set(t, n), n;
}
function gB(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
function A5(e, t) {
  for (var n = e.entity_id, r = e.asym_id, i = e.seq_id_begin, a = 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), m = new Int32Array(o), p = new Int32Array(s.count), v = 0; v < o; v++) m[v] = t.getEntityIndex(n.value(v)), m[v] < 0 && gB(n.value(v));
  for (var f = 0; f < s.count; f++) {
    var y = s.offsets[f], h = s.offsets[f + 1], g = m[y];
    p[f] = g;
    var x = hB(vB(c, g), r.value(y), l);
    for (v = y; v < h; v++) d[v] = x;
    var C = [], b = [];
    for (v = y; v < h; v++) {
      var _ = i.value(v), A = a.value(v);
      C.push(v), b.push(_, A);
    }
    var I = { elementIndices: C, seqRanges: dn.ofSortedRanges(b) };
    u.set(x, I);
  }
  var w = function(D, T, P) {
    var M = D.getEntityIndex;
    return { findChainKey: function(R, O) {
      var L = M(R);
      if (L < 0) return -1;
      var F = T.get(L);
      return F.has(O) ? F.get(O) : -1;
    }, findSequenceKey: function(R, O, L) {
      var F = M(R);
      if (F < 0) return -1;
      var G = T.get(F);
      if (G === void 0) return -1;
      var V = G.get(O);
      if (V === void 0) return -1;
      var U = P.get(V), q = U.elementIndices, H = U.seqRanges, K = dn.firstIntersectionIndex(H, ve.ofSingleton(L));
      return K !== -1 ? q[K] : -1;
    } };
  }(t, c, u), E = w.findChainKey;
  return { chainKey: d, entityKey: m, findSequenceKey: w.findSequenceKey, findChainKey: E, getEntityFromChain: function(D) {
    return p[D];
  } };
}
function I5(e, t) {
  for (var n = [], r = [], i = St.transientSegments(e.chainElementSegments, oe.ofBounds(0, e.count)), a = e.seq_id_begin, o = e.seq_id_end; i.hasNext; ) for (var s = i.move(), u = s.start, c = s.end, l = -1, d = -1, m = u; m < c; ++m) {
    var p = o.value(m);
    m === u ? (l = m, d = o.value(m)) : a.value(m) - d > 1 && (n.push(l, m - 1), r.push(m - 1, m), l = m), m === c - 1 && n.push(l, m), d = p;
  }
  return { polymerRanges: dn.ofSortedRanges(n), gapRanges: dn.ofSortedRanges(r) };
}
(function(e) {
  e.Empty = { isDefined: !1, spheres: C5, gaussians: C5 };
})(dv || (dv = {}));
var j9 = { hierarchy: dv.Empty, conformation: void 0 };
function yB(e, t) {
  var n = e.ihm_sphere_obj_site, r = e.ihm_gaussian_obj_site;
  if (n._rowCount === 0 && r._rowCount === 0) return j9;
  var i = w5(n), a = function(m) {
    return { x: m.Cartn_x.toArray({ array: Float32Array }), y: m.Cartn_y.toArray({ array: Float32Array }), z: m.Cartn_z.toArray({ array: Float32Array }), radius: m.object_radius.toArray({ array: Float32Array }), rmsf: m.rmsf.toArray({ array: Float32Array }) };
  }(n), o = A5(i, e.entities), s = I5(i), u = w5(r), c = function(m) {
    for (var p = Gi.ihm_gaussian_obj_site.covariance_matrix.space, v = [], f = m.covariance_matrix, y = 0, h = f.rowCount; y < h; y++) v[y] = Nn.toMat3(br(), p, f.value(y));
    return { x: m.mean_Cartn_x.toArray({ array: Float32Array }), y: m.mean_Cartn_y.toArray({ array: Float32Array }), z: m.mean_Cartn_z.toArray({ array: Float32Array }), weight: m.weight.toArray({ array: Float32Array }), covariance_matrix: v };
  }(r), l = A5(u, e.entities), d = I5(u);
  return { hierarchy: { isDefined: !0, spheres: B(B(B({}, i), o), s), gaussians: B(B(B({}, u), l), d) }, conformation: { id: vr.create22(), spheres: a, gaussians: c } };
}
function w5(e) {
  var t = e.entity_id, n = e.seq_id_begin, r = e.seq_id_end, i = e.asym_id;
  return B({ count: t.rowCount, entity_id: t, asym_id: i, seq_id_begin: n, seq_id_end: r }, function(a, o, s) {
    for (var u = [0], c = 1, l = a.rowCount; c < l; c++) !a.areValuesEqual(c - 1, c) && (u[u.length] = c);
    return { chainElementSegments: St.ofOffsets(u, oe.ofBounds(0, a.rowCount)) };
  }(i));
}
var Ud, fv, bB = { 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" }, _B = { DA: "A", DC: "C", DG: "G", DT: "T", DU: "U" }, xB = { A: "A", C: "C", G: "G", T: "T", U: "U" };
function P5(e) {
  return bB[e] || "X";
}
function E5(e) {
  return xB[e] || "X";
}
function T5(e) {
  return _B[e] || "X";
}
function K9(e, t, n, r) {
  if (!e.entity_poly_seq || !e.entity_poly_seq._rowCount) return fv.fromHierarchy(t, n, r);
  for (var i = e.entity_poly_seq, a = i.entity_id, o = i.num, s = i.mon_id, u = {}, c = [], l = a.rowCount, d = 0; d < l; ) {
    for (var m = d; d < l - 1 && a.areValuesEqual(d, d + 1); ) d++;
    d++;
    var p = a.value(m), v = X.window(s, m, d), f = X.window(o, m, d), y = t.getEntityIndex(p);
    u[y] = { entityId: p, sequence: Ud.ofResidueNames(v, f) }, c.push(u[y]);
  }
  return { byEntityKey: u, sequences: c };
}
function X9(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, m, p, v;
    return ne(this, function(f) {
      switch (f.label) {
        case 0:
          return i = O2(n, r - 1), a = t.label_entity_id, o = t.label_asym_id, s = t.label_seq_id, u = ip(i, a.value), e.shouldUpdate ? [4, e.update()] : [3, 2];
        case 1:
          f.sent(), f.label = 2;
        case 2:
          c = 0, l = u.length - 1, f.label = 3;
        case 3:
          if (!(c < l)) return [3, 10];
          d = ip(i, o.value, { start: u[c], end: u[c + 1] }), m = 0, p = d.length - 1, f.label = 4;
        case 4:
          return m < p ? (v = d[m], s.valueKind(v) !== 0 ? [3, 6] : (ip(i, s.value, { sort: !0, start: v, end: d[m + 1] }), e.shouldUpdate ? [4, e.update()] : [3, 6])) : [3, 7];
        case 5:
          f.sent(), f.label = 6;
        case 6:
          return m++, [3, 4];
        case 7:
          return e.shouldUpdate ? [4, e.update()] : [3, 9];
        case 8:
          f.sent(), f.label = 9;
        case 9:
          return c++, [3, 3];
        case 10:
          return function(y) {
            for (var h = 0, g = y.length; h < g; h++) if (y[h] !== h) return !1;
            return !0;
          }(i) && i.length === t._rowCount ? [2, { atom_site: t, sourceIndex: X.ofIntArray(i) }] : [2, { atom_site: Jt.view(t, t._schema, i), sourceIndex: X.ofIntArray(i) }];
      }
    });
  });
}
function M5(e, t, n, r, i) {
  var a = i.residue, o = a.polymerType, s = a.traceElementIndex, u = a.directionFromElementIndex, c = a.directionToElementIndex, l = o[e], d = o[t];
  if (l === 0 || d === 0 || s[e] === -1 || s[t] === -1) return !1;
  var m = r.findAtomsOnResidue(e, hu(l, "backboneStart")), p = r.findAtomsOnResidue(t, hu(d, "backboneEnd"));
  m !== -1 && p !== -1 || (m = r.findAtomsOnResidue(e, hu(l, "coarseBackbone")), p = r.findAtomsOnResidue(t, hu(d, "coarseBackbone")));
  var v = n.x, f = n.y, y = n.z, h = S.create(v[m], f[m], y[m]), g = S.create(v[p], f[p], y[p]), x = u[e] === -1 || c[e] === -1 || u[t] === -1 || c[t] === -1;
  return S.distance(h, g) < (x ? 10 : 3);
}
function Y9(e, t, n, r) {
  for (var i, a, o, s, u = [], c = [], l = /* @__PURE__ */ new Map(), d = St.transientSegments(e.chainAtomSegments, oe.ofBounds(0, e.atoms._rowCount)), m = St.transientSegments(e.residueAtomSegments, oe.ofBounds(0, e.atoms._rowCount)), p = e.index, v = e.derived, f = e.residues.label_seq_id, y = e.chains.label_entity_id, h = v.residue, g = h.moleculeType, x = h.traceElementIndex; d.hasNext; ) {
    var C = d.move();
    m.setSegment(C), i = -1, a = -1, o = -1, s = -1;
    var b = t.getEntityIndex(y.value(C.index)), _ = r.byEntityKey[b], A = _ ? _.sequence.seqId.value(_.sequence.seqId.rowCount - 1) : -1, I = e.residueAtomSegments.index[C.start], w = e.residueAtomSegments.index[C.end - 1], E = f.value(I), D = f.value(w);
    for (E === 1 && D === A && n.xyzDefined && M5(I, w, n, p, v) && (l.set(I, w), l.set(w, I)); m.hasNext; ) {
      var T = m.move(), P = T.index, M = f.value(P);
      if (Hg(g[P]) && x[P] !== -1) if (s !== -1) if (M !== i + 1) u.push(s, o - 1), c.push(a, T.end - 1), s = T.start;
      else if (m.hasNext) {
        var R = e.residueAtomSegments.index[T.start], O = e.residueAtomSegments.index[o - 1];
        n.xyzDefined && !M5(R, O, n, e.index, v) && (u.push(s, o - 1), c.push(a, T.end - 1), s = T.start);
      } else u.push(s, T.end - 1);
      else s = T.start;
      else s !== -1 && (u.push(s, o - 1), s = -1);
      a = T.start, o = T.end, i = M;
    }
  }
  return { polymerRanges: dn.ofSortedRanges(u), gapRanges: dn.ofSortedRanges(c), cyclicPolymerMap: l };
}
function W9(e) {
  var t = /* @__PURE__ */ new Map();
  return function(n) {
    if (t.has(n)) return t.get(n);
    var r = e(n);
    return t.set(n, r), r;
  };
}
function SB(e) {
  for (var t = /* @__PURE__ */ new Map(), n = function(s, u, c) {
    return "".concat(s, "|").concat(u, "|").concat(c);
  }, r = e.pdbx_unobs_or_zero_occ_residues, i = 0, a = r._rowCount; i < a; ++i) {
    var o = n(r.PDB_model_num.value(i), r.label_asym_id.value(i), r.label_seq_id.value(i));
    t.set(o, { polymer_flag: r.polymer_flag.value(i), occupancy_flag: r.occupancy_flag.value(i) });
  }
  return { has: function(s, u, c) {
    return t.has(n(s, u, c));
  }, get: function(s, u, c) {
    return t.get(n(s, u, c));
  }, size: t.size };
}
function CB(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.chem_comp._rowCount > 0) for (var n = e.chem_comp.id, r = 0, i = n.rowCount; r < i; ++r) t.set(n.value(r), Jt.getRow(e.chem_comp, r));
  else Z9(e).forEach(function(a) {
    t.set(a, function(o) {
      return { formula: "", formula_weight: 0, id: o, name: o, mon_nstd_flag: Ug.has(o) ? "y" : "n", pdbx_synonyms: [], type: v9(o) };
    }(a));
  });
  return t;
}
function AB(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.pdbx_chem_comp_identifier._rowCount > 0) {
    for (var n = e.pdbx_chem_comp_identifier, r = n.comp_id, i = n.type, a = n.identifier, o = 0, s = r.rowCount; o < s; ++o) if (i.value(o) === "SNFG CARBOHYDRATE SYMBOL" || i.value(o) === "SNFG CARB SYMBOL") {
      var u = a.value(o), c = BT.get(u);
      c ? t.set(r.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 (i = l.type, o = 0, s = d.rowCount; o < s; ++o) {
      var m = d.value(o);
      if (!t.has(m)) {
        var p = i.value(o);
        xu.has(m) ? t.set(m, xu.get(m)) : Ff(p, m) === 9 && t.set(m, i9);
      }
    }
  } else {
    var v = Z9(e);
    xu.forEach(function(f, y) {
      !t.has(y) && v.has(y) && t.set(y, f);
    });
  }
  return t;
}
(function(e) {
  e.getSequenceString = function(r) {
    var i = r.code.toArray();
    return (i instanceof Array ? i : Array.from(i)).join("");
  }, e.ofResidueNames = function(r, i) {
    if (i.rowCount === 0) throw new Error("cannot be empty");
    var a = function(o) {
      for (var s = 0, u = Math.min(o.rowCount, 10); s < u; s++) {
        var c = o.value(s) || "";
        if (P5(c) !== "X") return "protein";
        if (E5(c) !== "X") return "RNA";
        if (T5(c) !== "X") return "DNA";
      }
      return "generic";
    }(r);
    return new t(a, r, i);
  };
  var t = function() {
    function r(i, a, o) {
      this.kind = i, this.microHet = /* @__PURE__ */ new Map();
      for (var s = function(b, _) {
        var A;
        switch (b) {
          case "protein":
            A = P5;
            break;
          case "DNA":
            A = T5;
            break;
          case "RNA":
            A = E5;
            break;
          case "generic":
            A = function() {
              return "X";
            };
            break;
          default:
            Tr();
        }
        return A;
      }(i), u = [], c = [], l = [], d = /* @__PURE__ */ new Map(), m = 0, p = /* @__PURE__ */ new Map(), v = 0, f = o.rowCount; v < f; ++v) {
        var y = o.value(v);
        if (p.has(y)) d.has(y) ? d.get(y).push(a.value(v)) : d.set(y, [c[p.get(y)], a.value(v)]);
        else {
          p.set(y, m);
          var h = a.value(v);
          c[m] = h, l[m] = y, u[m] = s(h), m += 1;
        }
      }
      var g = [];
      for (v = 0, f = m; v < f; ++v) {
        var x = d.get(l[v]);
        if (x) {
          var C = x.map(function(b) {
            var _ = s(b);
            return _ === "X" ? b : _;
          });
          g[v] = "(".concat(C.join("|"), ")");
        } else g[v] = u[v] === "X" ? c[v] : u[v];
      }
      this.length = m, this.code = X.ofStringArray(u), this.compId = X.ofStringArray(c), this.seqId = X.ofIntArray(l), this.label = X.ofStringArray(g), this.microHet = d, this.indexMap = p;
    }
    return r.prototype.index = function(i) {
      return this.indexMap.get(i);
    }, r;
  }();
  e.ofSequenceRanges = function(r, i) {
    return new n("generic", r, i);
  };
  var n = function() {
    function r(i, a, o) {
      this.kind = i, this.seqIdStart = a, 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), m = this.seqIdEnd.value(c);
        d < u && (u = d), s < m && (s = m);
      }
      var p = s - u + 1;
      this.code = X.ofConst("X", p, X.Schema.str), this.label = X.ofConst("", p, X.Schema.str), this.seqId = X.ofLambda({ value: function(v) {
        return v + u + 1;
      }, rowCount: p, schema: X.Schema.int }), this.compId = X.ofConst("", p, X.Schema.str), this.length = p, this.minSeqId = u;
    }
    return r.prototype.index = function(i) {
      return i - this.minSeqId;
    }, r;
  }();
})(Ud || (Ud = {})), function(e) {
  var t = { byEntityKey: {}, sequences: [] };
  function n() {
    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 r(o, s) {
    var u = s.atoms.label_comp_id, c = s.residues.label_seq_id, l = s.chainAtomSegments, d = s.residueAtomSegments, m = l.count, p = l.offsets, v = {}, f = [];
    if (m === 1 && p[0] === 0 && p[1] === 0) return { byEntityKey: v, sequences: f };
    for (var y = 0, h = s.chains._rowCount; y < h; y++) {
      var g = s.index.getEntityFromChain(y);
      if (v[g] === void 0 && o.data.type.value(g) === "polymer") {
        var x = y;
        for (y++; y < h && g === s.index.getEntityFromChain(y) && o.data.type.value(g) !== "polymer"; ) y++;
        y--;
        for (var C = d.index[p[x]], b = d.index[p[y + 1] - 1] + 1, _ = X.window(c, C, b), A = [], I = C; I < b; ++I) A.push(u.value(d.offsets[I]));
        var w = X.ofStringArray(A);
        v[g] = { entityId: o.data.id.value(g), sequence: Ud.ofResidueNames(w, _) }, f.push(v[g]);
      }
    }
    return { byEntityKey: v, sequences: f };
  }
  function i(o, s) {
    return n(a(o, s.spheres), a(o, s.gaussians));
  }
  function a(o, s) {
    var u = s.chainElementSegments, c = s.seq_id_begin, l = s.seq_id_end, d = u.count, m = u.offsets, p = {}, v = [];
    if (d === 1 && m[0] === 0 && m[1] === 0) return { byEntityKey: p, sequences: v };
    for (var f = 0, y = d; f < y; f++) {
      var h = s.getEntityFromChain(f);
      if (p[h] === void 0) {
        var g = f;
        for (f++; f < y && h === s.getEntityFromChain(f); ) f++;
        f--;
        var x = m[g], C = m[f + 1] - 1, b = X.window(c, x, C), _ = X.window(l, x, C);
        p[h] = { entityId: o.data.id.value(h), sequence: Ud.ofSequenceRanges(b, _) }, v.push(p[h]);
      }
    }
    return { byEntityKey: p, sequences: v };
  }
  e.fromHierarchy = function(o, s, u) {
    return n(r(o, s), u.isDefined ? i(o, u) : t);
  }, e.fromAtomicHierarchy = r, e.fromCoarseHierarchy = i, e.fromCoarseElements = a;
}(fv || (fv = {}));
var Z9 = W9(function(e) {
  for (var t = /* @__PURE__ */ new Set(), n = e.atom_site, r = n.label_comp_id, i = n.auth_comp_id, a = r.isDefined ? r : i, o = 0, s = a.rowCount; o < s; ++o) t.add(a.value(o));
  return t;
});
function Q9(e, t) {
  for (var n = /* @__PURE__ */ new Map(), r = e.chains, i = r.auth_asym_id, a = r.label_asym_id, o = r.label_entity_id, s = 0, u = e.chains._rowCount; s < u; s++) {
    var c = a.value(s);
    n.set(c, { id: c, auth_id: i.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), m = (s = 0, c.rowCount); s < m; ++s) {
    var p = c.value(s);
    n.has(p) || n.set(p, { id: p, auth_id: "", entity_id: d.value(s) });
  }
  return n;
}
var IB = X.Schema.Aliased(X.Schema.Str(""));
function J9(e) {
  var t;
  if (e.entity.id.isDefined) t = e.entity;
  else {
    for (var n = /* @__PURE__ */ new Set(), r = [], i = [], a = e.atom_site, o = a.label_entity_id, s = a.label_comp_id, u = 0, c = e.atom_site._rowCount; u < c; u++) {
      var l = o.value(u);
      n.has(l) || (r.push(l), i.push(WT(s.value(u))), n.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), n.has(l) || (r.push(l), i.push("polymer"), n.add(l));
    var m = e.ihm_gaussian_obj_site.entity_id;
    for (u = 0, c = e.ihm_gaussian_obj_site._rowCount; u < c; u++)
      l = m.value(u), n.has(l) || (r.push(l), i.push("polymer"), n.add(l));
    t = Jt.ofPartialColumns(Gi.entity, { id: X.ofArray({ array: r, schema: Gi.entity.id }), type: X.ofArray({ array: i, schema: Gi.entity.type }) }, r.length);
  }
  var p = X.createIndexer(t.id), v = new Array(t._rowCount);
  v.fill("other");
  var f = /* @__PURE__ */ new Set(), y = !1;
  if (e.entity_poly && e.entity_poly.type.isDefined) {
    var h = e.entity_poly, g = h.entity_id, x = h.type, C = h._rowCount;
    for (u = 0; u < C; ++u)
      v[p(l = g.value(u))] = x.value(u), f.add(l);
  } else y = !0;
  if (e.pdbx_entity_branch && e.pdbx_entity_branch.entity_id.isDefined) {
    var b = e.pdbx_entity_branch;
    for (g = b.entity_id, x = b.type, C = b._rowCount, u = 0; u < C; ++u)
      v[p(l = g.value(u))] = x.value(u), f.add(l);
  } else y = !0;
  if (f.size < v.length && (y = !0), y) {
    var _ = /* @__PURE__ */ new Map();
    if (e.chem_comp) {
      var A = e.chem_comp, I = A.id;
      for (x = A.type, u = 0, c = e.chem_comp._rowCount; u < c; u++) _.set(I.value(u), x.value(u));
    }
    if (e.atom_site) {
      var w = e.atom_site;
      for (o = w.label_entity_id, s = w.label_comp_id, u = 0, c = e.atom_site._rowCount; u < c; u++)
        if (l = o.value(u), !f.has(l)) {
          var E = s.value(u), D = _.get(E) || "";
          v[p(l)] = ZT(E, D), f.add(l);
        }
    }
  }
  return { data: t, subtype: X.ofArray({ array: v, schema: IB }), getEntityIndex: p };
}
function $9(e, t, n) {
  var r;
  if (!e.pdbx_molecule || !e.pdbx_molecule.prd_id.isDefined) return t;
  var i = new Array(t.data._rowCount);
  i.fill("");
  for (var a = e.pdbx_molecule, o = a.asym_id, s = a.prd_id, u = a._rowCount, c = 0; c < u; ++c) {
    var l = o.value(c), d = (r = n.get(l)) === null || r === void 0 ? void 0 : r.entity_id;
    d !== void 0 && (i[t.getEntityIndex(d)] = s.value(c));
  }
  var m = X.ofArray({ array: i, schema: X.Schema.str });
  return B(B({}, t), { prd_id: m });
}
var pn, D5, bf = 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 Ps(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          return r = function(u, c) {
            return { missingResidues: SB(u), chemicalComponentMap: CB(u), saccharideComponentMap: AB(u) };
          }(e), e.ihm_model_list._rowCount > 0 ? [4, PB(n, e, r, t)] : [3, 2];
        case 1:
          return a = s.sent(), [3, 4];
        case 2:
          return [4, wB(n, e, r, t)];
        case 3:
          a = s.sent(), s.label = 4;
        case 4:
          for (i = a, o = 0; o < i.length; o++) pn.TrajectoryInfo.set(i[o], { index: o, size: i.length });
          return [2, new bf(i)];
      }
    });
  });
}
function ex(e, t) {
  var n = e.rowCount;
  if (!e.isDefined) return n;
  for (var r = t + 1; r < n && e.areValuesEqual(t, r); ) r++;
  return r;
}
function wB(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, m;
    return ne(this, function(p) {
      switch (p.label) {
        case 0:
          if (i = [], !t.atom_site) return [3, 3];
          a = t.atom_site.id.rowCount, o = J9(t), s = 0, p.label = 1;
        case 1:
          return s < a ? (u = ex(t.atom_site.pdbx_PDB_model_num, s), [4, X9(e, t.atom_site, s, u)]) : [3, 3];
        case 2:
          return c = p.sent(), l = c.atom_site, d = c.sourceIndex, m = function(v, f, y, h, g, x, C) {
            var b = q9(f, y, h, g.chemicalComponentMap, x, C), _ = f.pdbx_PDB_model_num.value(0);
            if (C && b.sameAsPrevious) return B(B({}, C), { id: vr.create22(), modelNum: _, atomicConformation: b.conformation, _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
            var A = j9, I = K9(v, h, b.hierarchy, A.hierarchy), w = Y9(b.hierarchy, h, b.conformation, I), E = Q9(b.hierarchy), D = v.entry.id.valueKind(0) === 0 ? v.entry.id.value(0) : x.name, T = [];
            return D && T.push(D), v.struct.title.valueKind(0) === 0 && T.push(v.struct.title.value(0)), { id: vr.create22(), entryId: D, label: T.join(" | "), entry: D, sourceData: x, modelNum: _, parent: void 0, entities: $9(v, h, E), sequence: I, atomicHierarchy: b.hierarchy, atomicConformation: b.conformation, atomicRanges: w, atomicChainOperatorMappinng: b.chainOperatorMapping, coarseHierarchy: A.hierarchy, coarseConformation: A.conformation, properties: B(B({}, g), { structAsymMap: E }), customProperties: new ed(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, l, d, o, n, r, i.length > 0 ? i[i.length - 1] : void 0), i.push(m), s = u, [3, 1];
        case 3:
          return [2, i];
      }
    });
  });
}
function Op(e, t) {
  for (var n = /* @__PURE__ */ new Map(), r = e._rowCount, i = 0; i < r; ) {
    var a = ex(t, i), o = t.value(i);
    n.set(o, { table: Jt.window(e, e._schema, i, a), start: i, end: a }), i = a;
  }
  return n;
}
function PB(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _;
    return ne(this, function(A) {
      switch (A.label) {
        case 0:
          if (i = J9(t), a = t.atom_site.ihm_model_id.isDefined ? t.atom_site.ihm_model_id : t.atom_site.pdbx_PDB_model_num, o = Op(t.atom_site, a), s = Op(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site.model_id), u = Op(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, m = l.model_name, p = 0, A.label = 1;
        case 1:
          return p < t.ihm_model_list._rowCount ? (v = d.value(p), f = void 0, y = void 0, o.has(v) ? (h = o.get(v), [4, X9(e, t.atom_site, h.start, h.end)]) : [3, 3]) : [3, 6];
        case 2:
          return g = A.sent(), x = g.atom_site, C = g.sourceIndex, f = x, y = C, [3, 4];
        case 3:
          f = Jt.window(t.atom_site, t.atom_site._schema, 0, 0), y = X.ofIntArray([]), A.label = 4;
        case 4:
          b = { model_id: v, model_name: m.value(p), model_group_name: bD(v, t), entities: i, atom_site: f, atom_site_sourceIndex: y, ihm_sphere_obj_site: s.has(v) ? s.get(v).table : Jt.window(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site._schema, 0, 0), ihm_gaussian_obj_site: u.has(v) ? u.get(v).table : Jt.window(t.ihm_gaussian_obj_site, t.ihm_gaussian_obj_site._schema, 0, 0) }, _ = function(I, w, E, D) {
            var T = q9(w.atom_site, w.atom_site_sourceIndex, w.entities, E.chemicalComponentMap, D), P = yB(w, E.chemicalComponentMap), M = K9(I, w.entities, T.hierarchy, P.hierarchy), R = Y9(T.hierarchy, w.entities, T.conformation, M), O = I.entry.id.valueKind(0) === 0 ? I.entry.id.value(0) : D.name, L = [];
            O && L.push(O), I.struct.title.valueKind(0) === 0 && L.push(I.struct.title.value(0)), w.model_name && L.push(w.model_name), w.model_group_name && L.push(w.model_group_name);
            var F = Q9(T.hierarchy, I);
            return { id: vr.create22(), entryId: O, label: L.join(" | "), entry: O, sourceData: D, modelNum: w.model_id, parent: void 0, entities: $9(I, w.entities, F), sequence: M, atomicHierarchy: T.hierarchy, atomicConformation: T.conformation, atomicRanges: R, atomicChainOperatorMappinng: T.chainOperatorMapping, coarseHierarchy: P.hierarchy, coarseConformation: P.conformation, properties: B(B({}, E), { structAsymMap: F }), customProperties: new ed(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, b, n, r), c.push(_), A.label = 5;
        case 5:
          return p++, [3, 1];
        case 6:
          return [2, c];
      }
    });
  });
}
function Np(e) {
  for (var t = /* @__PURE__ */ new Map(), n = 0, r = e.length; n < r; n++) t.set(n, e[n]);
  return t;
}
(function(e) {
  function t(h, g) {
    for (var x = [], C = g.frames, b = h.atomicHierarchy.atomSourceIndex, _ = X.isIdentity(b) ? void 0 : b.toArray({ array: Int32Array }), A = u(h), I = 0, w = C.length; I < w; ++I) {
      var E = C[I], D = B(B({}, h), { id: vr.create22(), modelNum: I, atomicConformation: Gm.getAtomicConformation(E, h.atomicConformation.atomId, _), customProperties: new ed(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
      if (E.cell) {
        var T = Vr.fromCell(E.cell.size, E.cell.anglesInRadians);
        Vr.Provider.set(D, T);
      }
      e.TrajectoryInfo.set(D, { index: I, size: C.length }), e.CoarseGrained.set(D, A), x.push(D);
    }
    return { trajectory: x, srcIndexArray: _ };
  }
  e.trajectoryFromModelAndCoordinates = function(h, g) {
    return new bf(t(h, g).trajectory);
  }, e.trajectoryFromTopologyAndCoordinates = function(h, g) {
    var x = this;
    return At.create("Create Trajectory", function(C) {
      return ie(x, 0, void 0, function() {
        var b, _, A, I, w, E, D, T, P, M;
        return ne(this, function(R) {
          switch (R.label) {
            case 0:
              return [4, Ps(h.basic, h.sourceData, C)];
            case 1:
              if ((b = R.sent()).frameCount === 0) throw new Error("found no model");
              for (_ = b.representative, A = t(_, g).trajectory, I = { pairs: h.bonds, count: _.atomicHierarchy.atoms._rowCount }, w = gr.fromData(I), E = u(_), D = 0, T = 0, P = A; T < P.length; T++) M = P[T], gr.Provider.set(M, w), e.TrajectoryInfo.set(M, { index: D++, size: A.length }), e.CoarseGrained.set(M, E);
              return [2, new bf(A)];
          }
        });
      });
    });
  };
  var n = "__Center__";
  e.getCenter = function(h) {
    if (h._dynamicPropertyData[n]) return h._dynamicPropertyData[n];
    var g = function(x, C) {
      var b = [], _ = [], A = [];
      x.x.length && (b.push.apply(b, Ki(x.x)), _.push.apply(_, Ki(x.y)), A.push.apply(A, Ki(x.z))), C && (C.spheres.x.length && (b.push.apply(b, Ki(C.spheres.x)), _.push.apply(_, Ki(C.spheres.y)), A.push.apply(A, Ki(C.spheres.z))), C.gaussians.x.length && (b.push.apply(b, Ki(C.gaussians.x)), _.push.apply(_, Ki(C.gaussians.y)), A.push.apply(A, Ki(C.gaussians.z))));
      var I = Ki(b), w = I[0], E = I[1], D = Ki(_), T = D[0], P = D[1], M = Ki(A), R = M[0], O = w + (E - w) / 2, L = T + (P - T) / 2, F = R + (M[1] - R) / 2;
      return S.create(O, L, F);
    }(h.atomicConformation, h.coarseConformation);
    return h._dynamicPropertyData[n] = g, g;
  };
  var r = "__InvertedAtomSrcIndex__";
  e.getInvertedAtomSourceIndex = function(h) {
    if (h._staticPropertyData[r]) return h._staticPropertyData[r];
    var g = function(x) {
      for (var C = new Int32Array(x.rowCount), b = !1, _ = 0, A = x.rowCount; _ < A; _++) {
        var I = x.value(_);
        I !== _ && (b = !1), C[I] = _;
      }
      return { isIdentity: b, invertedIndex: C };
    }(h.atomicHierarchy.atomSourceIndex);
    return h._staticPropertyData[r] = g, g;
  };
  var i = "__TrajectoryInfo__";
  e.TrajectoryInfo = { get: function(h) {
    return h._dynamicPropertyData[i] || { index: 0, size: 1 };
  }, set: function(h, g) {
    return h._dynamicPropertyData[i] = g;
  } };
  var a = "__AsymIdCount__";
  e.AsymIdCount = { get: function(h) {
    if (h._dynamicPropertyData[a]) return h._dynamicPropertyData[a];
    var g = function(x) {
      var C = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
      return x.properties.structAsymMap.forEach(function(_, A) {
        var I = _.auth_id;
        C.add(I), b.add(A);
      }), { auth: C.size, label: b.size };
    }(h);
    return h._dynamicPropertyData[a] = g, g;
  } }, e.AsymIdOffset = Cl.createSimple("asym_id_offset", "static"), e.Index = Cl.createSimple("index", "static"), e.getRoot = function(h) {
    return h.parent || h;
  }, e.areHierarchiesEqual = function(h, g) {
    return h.atomicHierarchy === g.atomicHierarchy && h.coarseHierarchy === g.coarseHierarchy;
  };
  var o = "__CoordinatesHistory__";
  e.CoordinatesHistory = { get: function(h) {
    return h._staticPropertyData[o];
  }, set: function(h, g) {
    return h._staticPropertyData[o] = g;
  } };
  var s = "__CoarseGrained__";
  function u(h) {
    var g = e.CoarseGrained.get(h);
    if (g === void 0) {
      for (var x = 0, C = h.atomicHierarchy.derived.residue.polymerType, b = 0; b < C.length; ++b) C[b] !== 0 && (x += 1);
      var _ = !1, A = !1, I = h.atomicHierarchy.atoms, w = I.label_atom_id, E = I._rowCount;
      for (b = 0; b < E; ++b) {
        var D = w.value(b);
        if (_ || D !== "BB" || (_ = !0), A || D !== "SC1" || (A = !0), _ && A) break;
      }
      g = _ && A || !(!x || !E) && E / x < 3, e.CoarseGrained.set(h, g);
    }
    return g;
  }
  function c(h) {
    return !!_n.is(h.sourceData) && (h.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || h.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null);
  }
  e.CoarseGrained = { get: function(h) {
    return h._staticPropertyData[s];
  }, set: function(h, g) {
    return h._staticPropertyData[s] = g;
  } }, e.isCoarseGrained = u, e.isMaterial = function(h) {
    var g, x;
    return !!(!((x = (g = h.sourceData) === null || g === void 0 ? void 0 : g.data) === null || x === void 0) && x.isMaterial);
  }, e.isMaterialCrystal = function(h) {
    var g, x, C, b = (g = h.sourceData) === null || g === void 0 ? void 0 : g.data;
    return !(b != null && b.isMaterial) && !!(!((C = (x = b == null ? void 0 : b.molecules) === null || x === void 0 ? void 0 : x[0]) === null || C === void 0) && C.cell);
  }, e.hasCarbohydrate = function(h) {
    return h.properties.saccharideComponentMap.size > 0;
  }, e.hasProtein = function(h) {
    for (var g = h.entities.subtype, x = 0, C = g.rowCount; x < C; ++x) if (g.value(x).startsWith("polypeptide")) return !0;
    return !1;
  }, e.hasNucleic = function(h) {
    for (var g = h.entities.subtype, x = 0, C = g.rowCount; x < C; ++x) {
      var b = g.value(x);
      if (b.endsWith("ribonucleotide hybrid") || b.endsWith("ribonucleotide")) return !0;
    }
    return !1;
  }, e.isFromPdbArchive = function(h) {
    if (!_n.is(h.sourceData)) return !1;
    for (var g = h.sourceData.data.db, x = 0, C = g.database_2.database_id.rowCount; x < C; ++x) if (g.database_2.database_id.value(x) === "PDB") return !0;
    return !1;
  }, e.hasPdbId = c, e.hasSecondaryStructure = function(h) {
    if (!_n.is(h.sourceData)) return !1;
    var g = h.sourceData.data.db;
    return g.struct_conf.id.isDefined || g.struct_sheet_range.id.isDefined;
  };
  var l = S.create(1.5707963, 1.5707963, 1.5707963), d = S.create(1, 1, 1);
  function m(h) {
    if (!_n.is(h.sourceData)) return !1;
    for (var g = h.sourceData.data.db, x = 0; x < g.exptl.method.rowCount; x++)
      if (g.exptl.method.value(x).toUpperCase().indexOf("DIFFRACTION") >= 0) return !0;
    return !1;
  }
  function p(h) {
    if (!_n.is(h.sourceData)) return !1;
    for (var g = h.sourceData.data.db, x = 0; x < g.exptl.method.rowCount; x++)
      if (g.exptl.method.value(x).toUpperCase().indexOf("MICROSCOPY") >= 0) return !0;
    return !1;
  }
  function v(h) {
    if (!_n.is(h.sourceData) || !m(h)) return !1;
    var g = h.sourceData.data.db.pdbx_database_status.status_code_sf;
    return g.isDefined && g.value(0) === "REL";
  }
  function f(h) {
    if (!_n.is(h.sourceData)) return !1;
    for (var g = h.sourceData.data.db, x = g.pdbx_database_related, C = x.db_name, b = x.content_type, _ = 0, A = g.pdbx_database_related._rowCount; _ < A; ++_) if (C.value(_).toUpperCase() === "EMDB" && b.value(_) === "associated EM volume") return !0;
    return !1;
  }
  function y(h) {
    return !!_n.is(h.sourceData) && (v(h) || f(h));
  }
  e.hasCrystalSymmetry = function(h) {
    var g, x = (g = Vr.Provider.get(h)) === null || g === void 0 ? void 0 : g.spacegroup;
    return !(!x || x.num === 1 && S.equals(x.cell.anglesInRadians, l) && S.equals(x.cell.size, d));
  }, e.isFromXray = m, e.isFromEm = p, e.isFromNmr = function(h) {
    if (!_n.is(h.sourceData)) return !1;
    for (var g = h.sourceData.data.db, x = 0; x < g.exptl.method.rowCount; x++)
      if (g.exptl.method.value(x).toUpperCase().indexOf("NMR") >= 0) return !0;
    return !1;
  }, e.hasXrayMap = v, e.hasEmMap = f, e.hasDensityMap = y, e.probablyHasDensityMap = function(h) {
    if (!_n.is(h.sourceData)) return !1;
    var g = h.sourceData.data.db;
    return y(h) || c(h) && (!g.exptl.method.isDefined || m(h) && (!g.pdbx_database_status.status_code_sf.isDefined || g.pdbx_database_status.status_code_sf.valueKind(0) === 2) || p(h) && !g.pdbx_database_related.db_name.isDefined);
  };
})(pn || (pn = {})), function(e) {
  e.getCifDataSource = function(r, i, a) {
    if (!i) return { rowCount: 0 };
    if (a && a[i.id]) return a[i.id];
    var o = i.getElements(r), s = { data: o, rowCount: o.elements.length };
    return a && (a[i.id] = s), s;
  }, e.fromAtomMap = function(r) {
    return new B5(r);
  }, e.fromAtomArray = function(r) {
    return new B5(Np(r));
  };
  var t = function(r) {
    return r.atomicHierarchy.residueAtomSegments;
  };
  e.fromResidueMap = function(r) {
    return new x1("residue", r, t, 0);
  }, e.fromResidueArray = function(r) {
    return new x1("residue", Np(r), t, 0);
  };
  var n = function(r) {
    return r.atomicHierarchy.chainAtomSegments;
  };
  e.fromChainMap = function(r) {
    return new x1("chain", r, n, 0);
  }, e.fromChainArray = function(r) {
    return new x1("chain", Np(r), n, 0);
  }, e.fromEntityMap = function(r) {
    return new EB(r);
  };
}(D5 || (D5 = {}));
var x1 = function() {
  function e(t, n, r, i) {
    this.level = t, this.map = n, this.segmentGetter = r, this.id = vr.create22(), this.kind = i;
  }
  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 n = t.models;
    if (n.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var r = /* @__PURE__ */ new Set(), i = t.unitSymmetryGroups, a = [], o = this.segmentGetter(n[0]), s = 0, u = i; s < u.length; s++) {
      var c = u[s].units[0];
      if (c.kind === this.kind) for (var l = St.transientSegments(o, c.elements); l.hasNext; ) {
        var d = l.move();
        this.has(d.index) && !r.has(d.index) && (r.add(d.index), a[a.length] = Ne.create(t, c, c.elements[d.start]));
      }
    }
    return a.sort(function(m, p) {
      return m.element - p.element;
    }), a;
  }, e.prototype.getElements = function(t) {
    var n = this, r = this.segmentGetter(t.model).index, i = this.getStructureElements(t);
    return { elements: i, property: function(a) {
      return n.get(r[i[a].element]);
    } };
  }, e;
}(), B5 = function() {
  function e(t) {
    this.map = t, this.id = vr.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 n = /* @__PURE__ */ new Set(), r = [], i = 0, a = t.unitSymmetryGroups; i < a.length; i++) {
      var o = a[i].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) && !n.has(l) && (n.add(s[u]), r[r.length] = Ne.create(t, o, l));
      }
    }
    return r.sort(function(d, m) {
      return d.element - m.element;
    }), r;
  }, e.prototype.getElements = function(t) {
    var n = this, r = this.getStructureElements(t);
    return { elements: r, property: function(i) {
      return n.get(r[i].element);
    } };
  }, e;
}(), EB = function() {
  function e(t) {
    this.map = t, this.id = vr.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 n = t.models;
    if (n.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var r = n[0].atomicHierarchy.index, i = /* @__PURE__ */ new Set(), a = t.unitSymmetryGroups, o = [], s = n[0].atomicHierarchy.chainAtomSegments, u = 0, c = a; u < c.length; u++) {
      var l = c[u].units[0];
      if (l.kind === this.kind) for (var d = St.transientSegments(s, l.elements); d.hasNext; ) {
        var m = d.move(), p = r.getEntityFromChain(m.index);
        this.has(p) && !i.has(p) && (i.add(p), o[o.length] = Ne.create(t, l, l.elements[m.start]));
      }
    }
    return o.sort(function(v, f) {
      return v.element - f.element;
    }), o;
  }, e.prototype.getElements = function(t) {
    var n = this, r = this.getStructureElements(t), i = t.model.atomicHierarchy.chainAtomSegments.index, a = t.model.atomicHierarchy.index;
    return { elements: r, property: function(o) {
      return n.get(a.getEntityFromChain(i[r[o].element]));
    } };
  }, e;
}(), S1 = ye(13421772), R5 = {}, TB = { name: "carbohydrate-symbol", label: "Carbohydrate Symbol", category: "Residue Property", factory: function e(t, n) {
  var r;
  if (t.structure) {
    var i = t.structure.carbohydrates, a = i.elements, o = i.getElementIndices, s = function(u, c) {
      if (!me.isAtomic(u)) return S1;
      var l = o(u, c);
      return l.length > 0 ? a[l[0]].component.color : S1;
    };
    r = function(u, c) {
      return c ? Ze.Secondary : Ne.is(u) ? s(u.unit, u.element) : rt.isLocation(u) ? s(u.aUnit, u.aUnit.elements[u.aIndex]) : S1;
    };
  } else r = function() {
    return S1;
  };
  return { factory: e, granularity: "group", color: r, props: n, description: "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).", legend: io(RT) };
}, getParams: function(e) {
  return R5;
}, defaultValues: N.getDefaultValues(R5), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return pn.hasCarbohydrate(t);
  });
} }, tx = ye(14539007), MB = "Gives everything the same, uniform color.", Jm = { value: N.Color(tx) };
function Vf(e, t) {
  var n = mr(t.value, tx);
  return { factory: Vf, granularity: "uniform", color: function() {
    return n;
  }, props: t, description: MB, legend: io([["uniform", n]]) };
}
var DB = { name: "uniform", label: "Uniform", category: "Miscellaneous", factory: Vf, getParams: function(e) {
  return Jm;
}, defaultValues: N.getDefaultValues(Jm), isApplicable: function(e) {
  return !0;
} }, k5 = { value: N.Numeric(1, { min: 0, max: 20, step: 0.1 }) };
function Kg(e, t) {
  var n = t.value;
  return { factory: Kg, granularity: "uniform", size: function() {
    return n;
  }, props: t, description: "Gives everything the same, uniform size." };
}
var BB = { name: "uniform", label: "Uniform", category: "", factory: Kg, getParams: function(e) {
  return k5;
}, defaultValues: N.getDefaultValues(k5), isApplicable: function(e) {
  return !0;
} }, O5 = { scale: N.Numeric(1, { min: 0.1, max: 5, step: 0.1 }) };
function Lp(e, t) {
  return me.isAtomic(e) ? M0(e.model.atomicHierarchy.atoms.type_symbol.value(t)) : me.isSpheres(e) ? e.model.coarseConformation.spheres.radius[t] : 0;
}
var RB = { name: "physical", label: "Physical", category: "", factory: function e(t, n) {
  var r = n.scale === void 0 ? 1 : n.scale;
  return { factory: e, granularity: "group", size: function(i) {
    return Ne.is(i) ? r * Lp(i.unit, i.element) : rt.isLocation(i) ? r * Math.min(Lp(i.aUnit, i.aUnit.elements[i.aIndex]), Lp(i.bUnit, i.bUnit.elements[i.bIndex])) : 1 * r;
  }, props: n, description: "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres." };
}, getParams: function(e) {
  return O5;
}, defaultValues: N.getDefaultValues(O5), isApplicable: function(e) {
  return !!e.structure;
} }, Oi = S();
function Ol(e, t, n, r) {
  for (var i = 0, a = 3 * r; i < a; i += 3) S.fromArray(Oi, t, n + i), S.transformMat4(Oi, Oi, e), S.toArray(Oi, t, n + i);
}
var N5 = S(), Fp = S(), L5 = S(), la = S(), F5 = S();
function nx(e, t, n, r, i) {
  for (var a = 0, o = 3 * i; a < o; a += 3) {
    var s = 3 * t[a], u = 3 * t[a + 1], c = 3 * t[a + 2];
    S.fromArray(N5, e, s), S.fromArray(Fp, e, u), S.fromArray(L5, e, c), S.sub(la, L5, Fp), S.sub(F5, N5, Fp), S.cross(la, la, F5), n[s] += la[0], n[s + 1] += la[1], n[s + 2] += la[2], n[u] += la[0], n[u + 1] += la[1], n[u + 2] += la[2], n[c] += la[0], n[c + 1] += la[1], n[c + 2] += la[2];
  }
  return function(l, d) {
    for (var m = 0, p = 3 * d; m < p; m += 3) {
      var v = l[m], f = l[m + 1], y = l[m + 2], h = 1 / Math.sqrt(v * v + f * f + y * y);
      l[m] = v * h, l[m + 1] = f * h, l[m + 2] = y * h;
    }
    return l;
  }(n, r);
}
function id(e, t, n) {
  n === void 0 && (n = 1);
  for (var r = Nm(e), i = new Int32Array(r + 2), a = new Int32Array(t), o = new Int32Array(t), s = 0, u = t * n; s < u; s += n) ++o[e[s]];
  var c = 0;
  for (s = 0; s < t; s++) i[s] = c, c += o[s];
  i[t] = c;
  var l = new Int32Array(c);
  for (s = 0, u = t * n; s < u; s += n) {
    var d = e[s];
    l[i[d] + a[d]] = s, ++a[d];
  }
  return { indices: l, offsets: i };
}
function hr(e, t, n, r) {
  var i = function(u, c) {
    u = Math.max(u, 2);
    var l = Math.sqrt(u), d = Math.ceil(l), m = (d += (c - d % c) % c) > 0 ? Math.ceil(u / d) : 0;
    return { width: d, height: m, length: d * m * c };
  }(e, t), a = i.length, o = i.width, s = i.height;
  return { array: r = r && r.length >= a ? r : new n(a), width: o, height: s };
}
var xa = S(), kB = new ka("14"), OB = new ka("98");
function rx(e) {
  return e > 1e5 ? kB : OB;
}
function Pu(e, t, n) {
  var r = 3 * n, i = rx(t);
  i.reset();
  for (var a = 0, o = 3 * t; a < o; a += r) S.fromArray(xa, e, a), i.includePosition(xa);
  for (i.finishedIncludeStep(), a = 0, o = 3 * t; a < o; a += r) S.fromArray(xa, e, a), i.radiusPosition(xa);
  var s = i.getSphere();
  if (t <= 98) {
    var u = [];
    for (a = 0, o = 3 * t; a < o; a += r) u.push(S.fromArray(S(), e, a));
    de.setExtrema(s, u);
  }
  return s;
}
var Gp = J();
function Ir(e, t, n) {
  if (n === 1) {
    J.fromArray(Gp, t, 0);
    var r = de.clone(e);
    return J.isIdentity(Gp) ? r : de.transform(r, r, Gp);
  }
  var i = rx(n);
  i.reset();
  var a = e.center, o = e.radius, s = e.extrema;
  if (s && n < 50) {
    for (var u = 0, c = n; u < c; ++u) for (var l = 0, d = s; l < d.length; l++) {
      var m = d[l];
      S.transformMat4Offset(xa, m, t, 0, 0, 16 * u), i.includePosition(xa);
    }
    for (i.finishedIncludeStep(), u = 0, c = n; u < c; ++u) for (var p = 0, v = s; p < v.length; p++)
      m = v[p], S.transformMat4Offset(xa, m, t, 0, 0, 16 * u), i.radiusPosition(xa);
  } else {
    for (u = 0, c = n; u < c; ++u) S.transformMat4Offset(xa, a, t, 0, 0, 16 * u), i.includePositionRadius(xa, o);
    for (i.finishedIncludeStep(), u = 0, c = n; u < c; ++u) S.transformMat4Offset(xa, a, t, 0, 0, 16 * u), i.radiusPositionRadius(xa, o);
  }
  return i.getSphere();
}
var jr = new Uint8Array(772);
function ix(e, t) {
  if (t === 0) return 0;
  var n = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), r = t - 4 >> 2, i = 4 * r, a = 0;
  if (r < 0) for (var o = 0; o < t; ++o) a += e[o] && 1;
  else {
    for (o = 0; o < r; ++o) {
      var s = n[o];
      a += jr[65535 & s] + jr[s >> 16];
    }
    for (o = i; o < t; ++o) a += e[o] && 1;
  }
  return a / t;
}
function Da(e, t) {
  var n = hr(Math.max(1, e), 1, Uint8Array, t && t.tMarker.ref.value.array), r = ix(n.array, e), i = r === 0 ? 0 : -1;
  return t ? (k.updateIfChanged(t.uMarker, 0), k.update(t.tMarker, n), k.update(t.uMarkerTexDim, ge.create(n.width, n.height)), k.updateIfChanged(t.markerAverage, r), k.updateIfChanged(t.markerStatus, i), t) : { uMarker: k.create(0), tMarker: k.create(n), uMarkerTexDim: k.create(ge.create(n.width, n.height)), markerAverage: k.create(r), markerStatus: k.create(i) };
}
jr[1] = 1, jr[2] = 1, jr[3] = 1, jr[256] = 1, jr[512] = 1, jr[768] = 1, jr[257] = 2, jr[513] = 2, jr[769] = 2, jr[258] = 2, jr[514] = 2, jr[770] = 2, jr[259] = 2, jr[515] = 2, jr[771] = 2;
var No = { kind: "null-location" };
function Zn(e, t, n, r, i, a) {
  if (i === void 0 && (i = !1), a === void 0 && (a = function() {
    return !1;
  }), e % n != 0) throw new Error("incompatible groupCount and stride");
  var o = { location: No, 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: n, nonInstanceable: i, move: function() {
    return s && (o.groupIndex = c, o.instanceIndex = l, o.index = l * e + c, o.location = r(c, d ? -1 : l), o.isSecondary = a(c, d ? -1 : l), (c += n) === e ? (++l, u = !0, l < t && (c = 0)) : u = !1, s = c < e), o;
  }, reset: function() {
    o.location = No, 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 wc(e) {
  return { kind: "position-location", position: S() };
}
function ta(e, t, n, r) {
  var i = function(a, o, s, u) {
    switch (Ur.getGranularity(a, s.granularity)) {
      case "uniform":
        return function(c, l, d) {
          return function(m, p) {
            return p ? (k.update(p.uColor, ye.toVec3Normalized(p.uColor.ref.value, m)), k.updateIfChanged(p.dColorType, "uniform"), p) : { uColor: k.create(ye.toVec3Normalized(S(), m)), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(Ni()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ge.create(1, 1)), uColorGridDim: k.create(S.create(1, 1, 1)), uColorGridTransform: k.create(vt.create(0, 0, 0, 1)), dColorType: k.create("uniform"), dUsePalette: k.create(!1) };
          }(l(No, !1), d);
        }(0, s.color, u);
      case "instance":
        return function(c, l, d) {
          var m = c.instanceCount, p = hr(Math.max(1, m), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var v = c.move(), f = v.location, y = v.isSecondary, h = v.instanceIndex;
            ye.toArray(l(f, y), p.array, 3 * h), c.skipInstance();
          }
          return dd(p, "instance", d);
        }(a, s.color, u);
      case "group":
        return function(c, l, d) {
          var m = c.groupCount, p = hr(Math.max(1, m), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext && !c.isNextNewInstance; ) {
            var v = c.move(), f = v.location, y = v.isSecondary, h = v.groupIndex;
            ye.toArray(l(f, y), p.array, 3 * h);
          }
          return dd(p, "group", d);
        }(a, s.color, u);
      case "groupInstance":
        return function(c, l, d) {
          var m = c.groupCount, p = c.instanceCount, v = p * m, f = hr(Math.max(1, v), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var y = c.move(), h = y.location, g = y.isSecondary, x = y.index;
            ye.toArray(l(h, g), f.array, 3 * x);
          }
          return dd(f, "groupInstance", d);
        }(a, s.color, u);
      case "vertex":
        return function(c, l, d) {
          var m = c.groupCount, p = c.stride, v = hr(Math.max(1, m), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(), c.voidInstances(); c.hasNext && !c.isNextNewInstance; ) for (var f = c.move(), y = f.location, h = f.isSecondary, g = f.groupIndex, x = l(y, h), C = 0; C < p; ++C) ye.toArray(x, v.array, 3 * (g + C));
          return dd(v, "vertex", d);
        }(o, s.color, u);
      case "vertexInstance":
        return function(c, l, d) {
          var m = c.groupCount, p = c.instanceCount, v = c.stride, f = p * m, y = hr(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) for (var h = c.move(), g = h.location, x = h.isSecondary, C = h.index, b = l(g, x), _ = 0; _ < v; ++_) ye.toArray(b, y.array, 3 * (C + _));
          return dd(y, "vertexInstance", d);
        }(o, s.color, u);
      case "volume":
        return G5(s.grid, "volume", u);
      case "volumeInstance":
        return G5(s.grid, "volumeInstance", u);
      case "direct":
        return function(c) {
          return c ? (k.updateIfChanged(c.dColorType, "direct"), c) : { uColor: k.create(S()), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(Ni()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ge.create(1, 1)), uColorGridDim: k.create(S.create(1, 1, 1)), uColorGridTransform: k.create(vt.create(0, 0, 0, 1)), dColorType: k.create("direct"), dUsePalette: k.create(!1) };
        }(u);
    }
  }(e, t, n, r);
  return n.palette ? (k.updateIfChanged(i.dUsePalette, !0), function(a, o) {
    var s = !0, u = o.ref.value;
    if (a.colors.length !== u.width || u.filter !== a.filter) s = !1;
    else for (var c = u.array, l = 0, d = 0, m = a.colors; d < m.length; d++) {
      var p = m[d], v = ye.toRgb(p), f = v[0], y = v[1], h = v[2];
      if (c[l++] !== f || c[l++] !== y || c[l++] !== h) {
        s = !1;
        break;
      }
    }
    if (!s) {
      for (var g = new Uint8Array(3 * a.colors.length), x = 0, C = 0, b = a.colors; C < b.length; C++) {
        p = b[C];
        var _ = ye.toRgb(p);
        f = _[0], y = _[1], h = _[2], g[x++] = f, g[x++] = y, g[x++] = h;
      }
      k.update(o, { array: g, height: 1, width: a.colors.length, filter: a.filter });
    }
  }(n.palette, i.tPalette)) : k.updateIfChanged(i.dUsePalette, !1), i;
}
function dd(e, t, n) {
  return n ? (k.update(n.tColor, e), k.update(n.uColorTexDim, ge.create(e.width, e.height)), k.updateIfChanged(n.dColorType, t), n) : { uColor: k.create(S()), tColor: k.create(e), tColorGrid: k.create(Ni()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ge.create(e.width, e.height)), uColorGridDim: k.create(S.create(1, 1, 1)), uColorGridTransform: k.create(vt.create(0, 0, 0, 1)), dColorType: k.create(t), dUsePalette: k.create(!1) };
}
function G5(e, t, n) {
  var r = e.colors, i = e.dimension, a = e.transform, o = r.getWidth(), s = r.getHeight();
  return n ? (k.update(n.tColorGrid, r), k.update(n.uColorTexDim, ge.create(o, s)), k.update(n.uColorGridDim, S.clone(i)), k.update(n.uColorGridTransform, vt.clone(a)), k.updateIfChanged(n.dColorType, t), n) : { uColor: k.create(S()), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(r), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ge.create(o, s)), uColorGridDim: k.create(S.clone(i)), uColorGridTransform: k.create(vt.clone(a)), dColorType: k.create(t), dUsePalette: k.create(!1) };
}
var V5 = br(), NB = J();
function Xg(e, t, n) {
  var r = function(u, c) {
    for (var l = 0; l < c; l++) if (br.fromMat4(V5, J.fromArray(NB, u, 16 * l)), br.determinant(V5) < 0) return !0;
    return !1;
  }(e, t);
  if (n) {
    k.update(n.matrix, n.matrix.ref.value);
    var i = n.transform.ref.value.length >= 16 * t ? n.transform.ref.value : new Float32Array(16 * t);
    i.set(e), k.update(n.transform, i), k.updateIfChanged(n.uInstanceCount, t), k.updateIfChanged(n.instanceCount, t);
    var a = n.aTransform.ref.value.length >= 16 * t ? n.aTransform.ref.value : new Float32Array(16 * t);
    k.update(n.aTransform, a);
    var o = n.extraTransform.ref.value.length >= 16 * t ? n.extraTransform.ref.value : new Float32Array(16 * t);
    k.update(n.extraTransform, mv(o, t));
    var s = n.aInstance.ref.value.length >= t ? n.aInstance.ref.value : new Float32Array(t);
    k.update(n.aInstance, Oo(s, t)), k.update(n.hasReflection, r);
  } else n = { aTransform: k.create(new Float32Array(16 * t)), matrix: k.create(J.identity()), transform: k.create(new Float32Array(e)), extraTransform: k.create(mv(new Float32Array(16 * t), t)), uInstanceCount: k.create(t), instanceCount: k.create(t), aInstance: k.create(Oo(new Float32Array(t))), hasReflection: k.create(r) };
  return ax(n), n;
}
var Yg = new Float32Array(16);
function Wg(e) {
  return Xg(new Float32Array(Yg), 1, e);
}
function mv(e, t) {
  for (var n = 0; n < t; n++) e.set(Yg, 16 * n);
  return e;
}
function ax(e) {
  for (var t = e.aTransform.ref.value, n = e.instanceCount.ref.value, r = e.matrix.ref.value, i = e.transform.ref.value, a = e.extraTransform.ref.value, o = 0; o < n; o++) {
    var s = 16 * o;
    J.mulOffset(t, a, i, s, s, s), J.mulOffset(t, r, t, s, 0, s);
  }
  k.update(e.aTransform, t);
}
J.toArray(J.identity(), Yg, 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 Nl(e) {
  return B(B({}, Nl.Zero), e);
}
function rf() {
}
(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, n, r) {
    return n[r] = 255 * t.metalness, n[r + 1] = 255 * t.roughness, n[r + 2] = 255 * t.bumpiness, n;
  }, e.toString = function(t) {
    var n = t.metalness, r = t.roughness, i = t.bumpiness;
    return "M ".concat(n.toFixed(2), " | R ").concat(r.toFixed(2), " | B ").concat(i.toFixed(2));
  }, e.getParam = function(t) {
    return N.Group({ metalness: N.Numeric(0, { min: 0, max: 1, step: 0.01 }), roughness: N.Numeric(1, { min: 0, max: 1, step: 0.01 }), bumpiness: N.Numeric(0, { min: 0, max: 1, step: 0.01 }) }, B(B({}, 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"]] }));
  };
}(Nl || (Nl = {})), function(e) {
  e.Type = { none: 0, plane: 1, sphere: 2, cube: 3, cylinder: 4, infiniteCone: 5 }, e.Params = { variant: N.Select("pixel", N.arrayToOptions(["instance", "pixel"])), objects: N.ObjectList({ type: N.Select("plane", N.objectToOptions(e.Type, function(a) {
    return To(a);
  })), invert: N.Boolean(!1), position: N.Vec3(S()), rotation: N.Group({ axis: N.Vec3(S.create(1, 0, 0)), angle: N.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" }) }, { isExpanded: !0 }), scale: N.Vec3(S.create(1, 1, 1)) }, function(a) {
    return To(a.type);
  }) };
  var t = Mn(), n = Mn(), r = S(), i = S();
  e.getClip = function(a, 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, m = s.scale, p = 0, v = a.objects.length; p < v; ++p) {
      var f = a.objects[p];
      u[p] = e.Type[f.type], c[p] = f.invert, S.toArray(f.position, l, 3 * p), Mn.toArray(Mn.setAxisAngle(t, f.rotation.axis, Bn(f.rotation.angle)), d, 4 * p), S.toArray(f.scale, m, 3 * p);
    }
    return { variant: a.variant, objects: { count: a.objects.length, type: u, invert: c, position: l, rotation: d, scale: m } };
  }, e.areEqual = function(a, o) {
    if (a.variant !== o.variant || a.objects.count !== o.objects.count) return !1;
    for (var s = a.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] || (S.fromArray(r, s.position, 3 * c), S.fromArray(i, u.position, 3 * c), !S.equals(r, i)) || (S.fromArray(r, s.scale, 3 * c), S.fromArray(i, u.scale, 3 * c), !S.equals(r, i)) || (Mn.fromArray(t, s.rotation, 4 * c), Mn.fromArray(n, u.rotation, 4 * c), !Mn.equals(t, n))) return !1;
    return !0;
  };
}(rf || (rf = {}));
var Ve, LB = Object.keys({ custom: {}, auto: {}, highest: {}, higher: {}, high: {}, medium: {}, low: {}, lower: {}, lowest: {} }), FB = N.arrayToOptions(LB), GB = { smoothColors: N.MappedStatic("auto", { auto: N.Group({}), on: N.Group({ resolutionFactor: N.Numeric(2, { min: 0.5, max: 6, step: 0.1 }), sampleStride: N.Numeric(3, { min: 1, max: 12, step: 1 }) }), off: N.Group({}) }) };
function Vp(e) {
  return !!e.smoothColors;
}
function nc(e, t, n) {
  if ((e.name === "on" || e.name === "auto" && t) && n && n < 3) {
    var r = 3;
    return e.name === "on" ? (n *= e.params.resolutionFactor, r = e.params.sampleStride) : (n *= 2 - s7(0, 1.1, n), (n = Math.max(0.5, n)) > 1.2 && (r = 2)), { resolution: n, stride: r };
  }
}
function z5(e, t, n) {
  return e.fill(0, 4 * t, 4 * n), !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: N.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), quality: N.Select("auto", FB, { isEssential: !0, description: "Visual/rendering quality of the representation." }), material: Nl.getParam(), clip: N.Group(rf.Params) }, e.createSimple = function(t, n, r) {
    return t === void 0 && (t = _t.grey), n === void 0 && (n = 1), r || (r = Wg()), { transform: r, locationIterator: Zn(1, r.instanceCount.ref.value, 1, function() {
      return No;
    }, !1, function() {
      return !1;
    }), theme: { color: Vf(0, { value: t }), size: Kg(0, { value: n }) } };
  }, e.createValues = function(t, n) {
    var r = rf.getClip(t.clip);
    return { alpha: k.create(t.alpha), uAlpha: k.create(t.alpha), uVertexCount: k.create(n.vertexCount), uGroupCount: k.create(n.groupCount), drawCount: k.create(n.drawCount), uMetalness: k.create(t.material.metalness), uRoughness: k.create(t.material.roughness), uBumpiness: k.create(t.material.bumpiness), dLightCount: k.create(1), dClipObjectCount: k.create(r.objects.count), dClipVariant: k.create(r.variant), uClipObjectType: k.create(r.objects.type), uClipObjectInvert: k.create(r.objects.invert), uClipObjectPosition: k.create(r.objects.position), uClipObjectRotation: k.create(r.objects.rotation), uClipObjectScale: k.create(r.objects.scale) };
  }, e.updateValues = function(t, n) {
    k.updateIfChanged(t.alpha, n.alpha), k.updateIfChanged(t.uMetalness, n.material.metalness), k.updateIfChanged(t.uRoughness, n.material.roughness), k.updateIfChanged(t.uBumpiness, n.material.bumpiness);
    var r = rf.getClip(n.clip);
    k.update(t.dClipObjectCount, r.objects.count), k.update(t.dClipVariant, r.variant), k.update(t.uClipObjectType, r.objects.type), k.update(t.uClipObjectInvert, r.objects.invert), k.update(t.uClipObjectPosition, r.objects.position), k.update(t.uClipObjectRotation, r.objects.rotation), k.update(t.uClipObjectScale, r.objects.scale);
  }, e.createRenderableState = function(t) {
    t === void 0 && (t = {});
    var n = t.alpha === void 0 || t.alpha === 1;
    return { disposed: !1, visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, opaque: n, writeDepth: n };
  }, e.updateRenderableState = function(t, n) {
    t.opaque = n.alpha * t.alphaFactor >= 1, t.writeDepth = t.opaque;
  };
})(Ve || (Ve = {}));
var VB = { array: new Uint8Array(4), width: 1, height: 1 };
function ms(e) {
  return { tOverpaint: k.create(VB), uOverpaintTexDim: k.create(ge.create(1, 1)), dOverpaint: k.create(!1), tOverpaintGrid: k.create(Ni()), uOverpaintGridDim: k.create(S.create(1, 1, 1)), uOverpaintGridTransform: k.create(vt.create(0, 0, 0, 1)), dOverpaintType: k.create("groupInstance") };
}
function U5(e, t) {
  for (var n = 0, r = 0; r < t; ++r) n += e[r];
  return n / (255 * t);
}
var zB = { array: new Uint8Array(1), width: 1, height: 1 };
function ps(e) {
  return { tTransparency: k.create(zB), uTransparencyTexDim: k.create(ge.create(1, 1)), dTransparency: k.create(!1), transparencyAverage: k.create(0), tTransparencyGrid: k.create(Ni()), uTransparencyGridDim: k.create(S.create(1, 1, 1)), uTransparencyGridTransform: k.create(vt.create(0, 0, 0, 1)), dTransparencyType: k.create("groupInstance") };
}
var UB = { array: new Uint8Array(1), width: 1, height: 1 };
function hs(e) {
  return { tClipping: k.create(UB), uClippingTexDim: k.create(ge.create(1, 1)), dClipping: k.create(!1) };
}
function H5(e, t, n) {
  return e.fill(0, 4 * t, 4 * n), !0;
}
var ht, HB = { array: new Uint8Array(4), width: 1, height: 1 };
function vs(e) {
  return { tSubstance: k.create(HB), uSubstanceTexDim: k.create(ge.create(1, 1)), dSubstance: k.create(!1), tSubstanceGrid: k.create(Ni()), uSubstanceGridDim: k.create(S.create(1, 1, 1)), uSubstanceGridTransform: k.create(vt.create(0, 0, 0, 1)), dSubstanceType: k.create("groupInstance") };
}
function zp(e, t, n) {
  return e = xi(Math.round(e), 0, 16777215) + 1, t[n + 2] = e % 256, e = Math.floor(e / 256), t[n + 1] = e % 256, e = Math.floor(e / 256), t[n] = e % 256, t;
}
function Zg(e, t, n) {
  return 256 * Math.floor(e) * 256 + 256 * Math.floor(t) + Math.floor(n) - 1;
}
(function(e) {
  function t(p, v, f, y, h, g, x) {
    return x ? function(C, b, _, A, I, w, E) {
      return E.vertexCount = I, E.triangleCount = w, k.update(E.vertexBuffer, C), k.update(E.indexBuffer, b), k.update(E.normalBuffer, _), k.update(E.groupBuffer, A), E;
    }(p, v, f, y, h, g, x) : function(C, b, _, A, I, w) {
      var E, D = de(), T = -1, P = -1, M = { kind: "mesh", vertexCount: I, triangleCount: w, vertexBuffer: k.create(C), indexBuffer: k.create(b), normalBuffer: k.create(_), groupBuffer: k.create(A), get boundingSphere() {
        var R = r(M);
        if (R !== T) {
          var O = Pu(M.vertexBuffer.ref.value, M.vertexCount, 1);
          de.copy(D, O), T = R;
        }
        return D;
      }, get groupMapping() {
        return M.groupBuffer.ref.version !== P && (E = id(M.groupBuffer.ref.value, M.vertexCount), P = M.groupBuffer.ref.version), E;
      }, setBoundingSphere: function(R) {
        de.copy(D, R), T = r(M);
      }, meta: {} };
      return M;
    }(p, v, f, y, h, g);
  }
  function n(p) {
    return t(p ? p.vertexBuffer.ref.value : new Float32Array(0), p ? p.indexBuffer.ref.value : new Uint32Array(0), p ? p.normalBuffer.ref.value : new Float32Array(0), p ? p.groupBuffer.ref.value : new Float32Array(0), 0, 0, p);
  }
  function r(p) {
    return di([p.vertexCount, p.triangleCount, p.vertexBuffer.ref.version, p.indexBuffer.ref.version, p.normalBuffer.ref.version, p.groupBuffer.ref.version]);
  }
  e.create = t, e.createEmpty = n, e.computeNormals = function(p) {
    var v = p.vertexCount, f = p.triangleCount, y = p.vertexBuffer.ref.value, h = p.indexBuffer.ref.value, g = p.normalBuffer.ref.value.length >= 3 * v ? p.normalBuffer.ref.value : new Float32Array(3 * v);
    g === p.normalBuffer.ref.value && g.fill(0, 0, 3 * v), nx(y, h, g, v, f), k.update(p.normalBuffer, g);
  }, e.checkForDuplicateVertices = function(p, v) {
    v === void 0 && (v = 3);
    for (var f = p.vertexBuffer.ref.value, y = /* @__PURE__ */ new Map(), h = function(I, w) {
      return "".concat(I[0].toFixed(w), "|").concat(I[1].toFixed(w), "|").concat(I[2].toFixed(w));
    }, g = 0, x = S(), C = 0, b = p.vertexCount; C < b; ++C) {
      S.fromArray(x, f, 3 * C);
      var _ = h(x, v), A = y.get(_);
      A !== void 0 ? (g += 1, y.set(_, A + 1)) : y.set(_, 1);
    }
    return g;
  };
  var i = br();
  function a(p) {
    for (var v = p.vertexCount, f = p.triangleCount, y = p.indexBuffer.ref.value, h = [], g = 0; g < v; ++g) h[g] = [];
    for (g = 0; g < f; ++g) {
      var x = y[3 * g], C = y[3 * g + 1], b = y[3 * g + 2];
      Ca(h[x], C), Ca(h[x], b), Ca(h[C], x), Ca(h[C], b), Ca(h[b], x), Ca(h[b], C);
    }
    return h;
  }
  function o(p) {
    for (var v = p.triangleCount, f = p.indexBuffer.ref.value, y = /* @__PURE__ */ new Map(), h = function(_, A) {
      var I = Mm(_, A), w = y.get(I) || 0;
      y.set(I, w + 1);
    }, g = 0; g < v; ++g) {
      var x = f[3 * g], C = f[3 * g + 1], b = f[3 * g + 2];
      h(x, C), h(x, b), h(C, b);
    }
    return y;
  }
  function s(p) {
    var v = /* @__PURE__ */ new Set(), f = [0, 0];
    return p.forEach(function(y, h) {
      y === 1 && (function(g, x) {
        var C = Math.floor((Math.sqrt(8 * x + 1) - 1) / 2), b = x - (C * C + C) / 2;
        g[0] = C - b, g[1] = b;
      }(f, h), v.add(f[0]), v.add(f[1]));
    }), v;
  }
  function u(p, v, f) {
    var y = /* @__PURE__ */ new Map(), h = function(g, x) {
      y.has(g) ? Ca(y.get(g), x) : y.set(g, [x]);
    };
    return v.forEach(function(g) {
      for (var x = 0, C = p[g]; x < C.length; x++) {
        var b = C[x];
        v.has(b) && f.get(Mm(g, b)) === 1 && h(g, b);
      }
    }), y;
  }
  function c(p, v, f, y) {
    for (var h, g = p.vertexBuffer, x = p.indexBuffer, C = p.normalBuffer, b = p.triangleCount, _ = g.ref.value, A = x.ref.value, I = C.ref.value, w = he.create(Uint32Array, 3, 1024, b), E = 0, D = 0; D < b; ++D) he.add3(w, A[3 * D], A[3 * D + 1], A[3 * D + 2]), E += 1;
    var T = S(), P = S(), M = S(), R = S(), O = S(), L = S(), F = S(), G = S(), V = S(), U = S(), q = Bn(120), H = /* @__PURE__ */ new Set(), K = Array.from(f.keys()).filter(function(Oe) {
      return f.get(Oe).length < 2;
    }).map(function(Oe) {
      var ze = f.get(Oe);
      return S.fromArray(T, _, 3 * Oe), S.fromArray(P, _, 3 * ze[0]), S.fromArray(M, _, 3 * ze[1]), S.sub(O, P, T), S.sub(L, M, T), [Oe, S.angle(O, L)];
    });
    K.sort(function(Oe, ze) {
      return Oe[1] - ze[1];
    });
    for (var j = 0, W = K; j < W.length; j++) {
      var Z = W[j], Y = Z[0], te = Z[1];
      if (!(H.has(Y) || te > q)) {
        var ee = f.get(Y);
        if ((!v[ee[0]].includes(ee[1]) || !((h = f.get(ee[0])) === null || h === void 0) && h.includes(ee[1])) && (S.fromArray(T, _, 3 * Y), S.fromArray(P, _, 3 * ee[0]), S.fromArray(M, _, 3 * ee[1]), S.sub(O, P, T), S.sub(L, M, T), S.add(G, O, L), !(S.squaredDistance(T, P) >= y))) {
          for (var $ = !1, ue = 0, se = v[Y]; ue < se.length; ue++) {
            var be = se[ue];
            if (!ee.includes(be) && (S.fromArray(R, _, 3 * be), S.sub(F, R, T), S.dot(G, F) < 0)) {
              $ = !0;
              break;
            }
          }
          $ && (S.fromArray(V, I, 3 * Y), S.triangleNormal(U, T, P, M), S.dot(U, V) > 0 ? he.add3(w, Y, ee[0], ee[1]) : he.add3(w, ee[1], ee[0], Y), H.add(Y), H.add(ee[0]), H.add(ee[1]), E += 1);
        }
      }
    }
    var ke = he.compact(w);
    return p.triangleCount = E, k.update(x, ke), p;
  }
  function l(p, v) {
    var f = p.vertexCount, y = v.instanceCount.ref.value, h = wc(), g = h.position, x = p.vertexBuffer.ref.value, C = v.aTransform.ref.value;
    return Zn(f, y, 1, function(b, _) {
      return _ < 0 ? S.fromArray(g, x, 3 * b) : S.transformMat4Offset(g, x, C, 0, 3 * b, 16 * _), h;
    });
  }
  function d(p, v, f, y, h) {
    var g = f.instanceCount, x = f.groupCount, C = ta(f, l(p, v), y.color), b = Da(g * x), _ = ms(), A = ps(), I = vs(), w = hs(), E = { drawCount: 3 * p.triangleCount, vertexCount: p.vertexCount, groupCount: x, instanceCount: g }, D = de.clone(p.boundingSphere), T = Ir(D, v.aTransform.ref.value, g);
    return B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("mesh"), aPosition: p.vertexBuffer, aNormal: p.normalBuffer, aGroup: p.groupBuffer, elements: p.indexBuffer, boundingSphere: k.create(T), invariantBoundingSphere: k.create(D), uInvariantBoundingSphere: k.create(vt.ofSphere(D)) }, C), b), _), A), I), w), v), Ve.createValues(h, E)), { uDoubleSided: k.create(h.doubleSided), dFlatShaded: k.create(h.flatShaded), dFlipSided: k.create(h.flipSided), dIgnoreLight: k.create(h.ignoreLight), dXrayShaded: k.create(h.xrayShaded), uBumpFrequency: k.create(h.bumpFrequency), uBumpAmplitude: k.create(h.bumpAmplitude), meta: k.create(p.meta) });
  }
  function m(p, v) {
    Ve.updateRenderableState(p, v), p.opaque = p.opaque && !v.xrayShaded, p.writeDepth = p.opaque;
  }
  e.transform = function(p, v) {
    var f = p.vertexBuffer.ref.value;
    Ol(v, f, 0, p.vertexCount), J.isTranslationAndUniformScaling(v) || function(y, h, g, x) {
      for (var C = 0, b = 3 * x; C < b; C += 3) S.fromArray(Oi, h, g + C), S.transformMat3(Oi, Oi, y), S.toArray(Oi, h, g + C);
    }(br.directionTransform(i, v), p.normalBuffer.ref.value, 0, p.vertexCount), k.update(p.vertexBuffer, f);
  }, e.getOriginalData = function(p) {
    return ("kind" in p ? p.meta : p.meta.ref.value).originalData;
  }, e.uniformTriangleGroup = function(p, v) {
    v === void 0 && (v = !0);
    var f = p.indexBuffer, y = p.vertexBuffer, h = p.groupBuffer, g = p.normalBuffer, x = p.triangleCount, C = p.vertexCount, b = f.ref.value, _ = y.ref.value, A = h.ref.value, I = g.ref.value, w = he.create(Uint32Array, 3, 1024, x), E = he.create(Float32Array, 3, 1024, _);
    E.currentIndex = 3 * C, E.elementCount = C;
    var D = he.create(Float32Array, 3, 1024, I);
    D.currentIndex = 3 * C, D.elementCount = C;
    var T = he.create(Float32Array, 1, 1024, A);
    T.currentIndex = C, T.elementCount = C;
    var P = S(), M = S(), R = S(), O = S(), L = S(), F = S();
    function G(xe) {
      S.fromArray(P, _, 3 * xe), S.fromArray(O, I, 3 * xe), he.add3(E, P[0], P[1], P[2]), he.add3(D, O[0], O[1], O[2]);
    }
    function V(xe, Xe) {
      S.fromArray(P, _, 3 * xe), S.fromArray(M, _, 3 * Xe), S.scale(P, S.add(P, P, M), 0.5), S.fromArray(O, I, 3 * xe), S.fromArray(L, I, 3 * Xe), S.scale(O, S.add(O, O, L), 0.5), he.add3(E, P[0], P[1], P[2]), he.add3(D, O[0], O[1], O[2]);
    }
    function U(xe, Xe, Ee) {
      S.fromArray(P, _, 3 * xe), S.fromArray(M, _, 3 * Xe), S.fromArray(R, _, 3 * Ee), S.scale(P, S.add(P, S.add(P, P, M), R), 1 / 3), S.fromArray(O, I, 3 * xe), S.fromArray(L, I, 3 * Xe), S.fromArray(F, I, 3 * Ee), S.scale(O, S.add(O, S.add(O, O, L), F), 1 / 3), he.add3(E, P[0], P[1], P[2]), he.add3(D, O[0], O[1], O[2]);
    }
    function q(xe, Xe, Ee, Ye, He) {
      ++K, G(xe), V(xe, Xe), V(xe, Ee), he.add3(w, H, H + 1, H + 2);
      for (var le = 0; le < 3; ++le) he.add(T, Ye);
      for (H += 3, K += 2, G(Xe), G(Ee), V(xe, Xe), V(xe, Ee), he.add3(w, H, H + 1, H + 3), he.add3(w, H, H + 3, H + 2), le = 0; le < 4; ++le) he.add(T, He);
      H += 4;
    }
    var H = C, K = 0;
    if (v) for (var j = 0, W = x; j < W; ++j) {
      var Z = b[3 * j], Y = b[3 * j + 1], te = b[3 * j + 2], ee = A[Z], $ = A[Y], ue = A[te];
      if (ee === $ && ee === ue) ++K, he.add3(w, Z, Y, te);
      else if (ee === $) q(te, Z, Y, ue, ee);
      else if (ee === ue) q(Y, te, Z, $, ue);
      else if ($ === ue) q(Z, Y, te, ee, $);
      else {
        K += 2, G(Z), V(Z, Y), V(Z, te), U(Z, Y, te), he.add3(w, H, H + 1, H + 3), he.add3(w, H, H + 3, H + 2);
        for (var se = 0; se < 4; ++se) he.add(T, ee);
        for (H += 4, K += 2, G(Y), V(Y, te), V(Y, Z), U(Z, Y, te), he.add3(w, H, H + 1, H + 3), he.add3(w, H, H + 3, H + 2), se = 0; se < 4; ++se) he.add(T, $);
        for (H += 4, K += 2, G(te), V(te, Y), V(te, Z), U(Z, Y, te), he.add3(w, H + 3, H + 1, H), he.add3(w, H + 2, H + 3, H), se = 0; se < 4; ++se) he.add(T, ue);
        H += 4;
      }
    }
    else for (j = 0, W = x; j < W; ++j)
      if (Z = b[3 * j], Y = b[3 * j + 1], te = b[3 * j + 2], ee = A[Z], $ = A[Y], ue = A[te], ee !== $ || ee !== ue) {
        ++K, G(Z), G(Y), G(te), he.add3(w, H, H + 1, H + 2);
        var be = $ === ue ? $ : ee;
        for (se = 0; se < 3; ++se) he.add(T, be);
        H += 3;
      } else ++K, he.add3(w, Z, Y, te);
    var ke = he.compact(w), Oe = he.compact(E), ze = he.compact(D), je = he.compact(T);
    return p.vertexCount = H, p.triangleCount = K, k.update(y, Oe), k.update(h, je), k.update(f, ke), k.update(g, ze), p.meta.originalData = { indexBuffer: b, vertexCount: C, triangleCount: x }, p;
  }, e.smoothEdges = function(p, v) {
    (function(C, b) {
      for (var _ = C.indexBuffer, A = C.triangleCount, I = _.ref.value, w = he.create(Uint32Array, 3, 1024, A), E = 0, D = 0; D < A; ++D) {
        var T = I[3 * D], P = I[3 * D + 1], M = I[3 * D + 2];
        b[T].length !== 2 && b[P].length !== 2 && b[M].length !== 2 && (he.add3(w, T, P, M), E += 1);
      }
      var R = he.compact(w);
      C.triangleCount = E, k.update(_, R);
    })(p, a(p));
    for (var f = 0; f < 10; ++f) {
      var y = p.triangleCount, h = o(p), g = a(p);
      if (c(p, g, u(g, s(h), h), v.maxNewEdgeLength * v.maxNewEdgeLength), p.triangleCount === y) break;
    }
    var x = o(p);
    return function(C, b, _) {
      for (var A = _.iterations, I = _.lambda, w = S(), E = S(), D = S(), T = S(), P = -I, M = new Float32Array(C.vertexBuffer.ref.value.length), R = function(L) {
        var F = C.vertexBuffer.ref.value;
        M.set(F), b.forEach(function(V, U) {
          if (V.length === 2) {
            S.fromArray(w, F, 3 * U), S.fromArray(E, F, 3 * V[0]), S.fromArray(D, F, 3 * V[1]);
            var q = 1 / S.distance(w, E), H = 1 / S.distance(w, D);
            S.scale(E, E, q), S.scale(D, D, H), S.add(T, E, D), S.scale(T, T, 1 / (q + H)), S.sub(T, T, w), S.scale(T, T, L), S.add(T, w, T), S.toArray(T, M, 3 * U);
          }
        });
        var G = C.vertexBuffer.ref.value;
        k.update(C.vertexBuffer, M), M = G;
      }, O = 0; O < A; ++O) R(I), R(P);
    }(p, u(a(p), s(x), x), { iterations: v.iterations, lambda: 0.5 }), p;
  }, e.Params = B(B({}, Ve.Params), { doubleSided: N.Boolean(!1, Ve.CustomQualityParamInfo), flipSided: N.Boolean(!1, Ve.ShadingCategory), flatShaded: N.Boolean(!1, Ve.ShadingCategory), ignoreLight: N.Boolean(!1, Ve.ShadingCategory), xrayShaded: N.Boolean(!1, Ve.ShadingCategory), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), bumpAmplitude: N.Numeric(1, { min: 0, max: 5, step: 0.1 }, Ve.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: d, createValuesSimple: function(p, v, f, y, h) {
    var g = Ve.createSimple(f, y, h), x = B(B({}, N.getDefaultValues(e.Params)), v);
    return d(p, g.transform, g.locationIterator, g.theme, x);
  }, updateValues: function(p, v) {
    Ve.updateValues(p, v), k.updateIfChanged(p.uDoubleSided, v.doubleSided), k.updateIfChanged(p.dFlatShaded, v.flatShaded), k.updateIfChanged(p.dFlipSided, v.flipSided), k.updateIfChanged(p.dIgnoreLight, v.ignoreLight), k.updateIfChanged(p.dXrayShaded, v.xrayShaded), k.updateIfChanged(p.uBumpFrequency, v.bumpFrequency), k.updateIfChanged(p.uBumpAmplitude, v.bumpAmplitude);
  }, updateBoundingSphere: function(p, v) {
    var f = de.clone(v.boundingSphere), y = Ir(f, p.aTransform.ref.value, p.instanceCount.ref.value);
    de.equals(y, p.boundingSphere.ref.value) || k.update(p.boundingSphere, y), de.equals(f, p.invariantBoundingSphere.ref.value) || (k.update(p.invariantBoundingSphere, f), k.update(p.uInvariantBoundingSphere, vt.fromSphere(p.uInvariantBoundingSphere.ref.value, f)));
  }, createRenderableState: function(p) {
    var v = Ve.createRenderableState(p);
    return m(v, p), v;
  }, updateRenderableState: m, createPositionIterator: l };
})(ht || (ht = {}));
var Up = 255 / 256, Hp = S.create(16777216, 65536, 256), qB = vt.create(Up / Hp[0], Up / Hp[1], Up / Hp[2], 0.99609375), q5 = vt();
function Es(e, t, n) {
  switch (Ur.getGranularity(e, t.granularity)) {
    case "uniform":
      return function(r, i, a) {
        return function(o, s) {
          return s ? (k.update(s.uSize, o), k.updateIfChanged(s.dSizeType, "uniform"), s) : B(B({ uSize: k.create(o) }, { tSize: k.create(jB), uSizeTexDim: k.create(ge.create(1, 1)) }), { dSizeType: k.create("uniform") });
        }(i(No), a);
      }(0, t.size, n);
    case "group":
      return function(r, i, a) {
        var o = r.groupCount, s = hr(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (r.reset(); r.hasNext && !r.isNextNewInstance; ) {
          var u = r.move();
          zp(i(u.location) * _m, s.array, 3 * u.groupIndex);
        }
        return qp(s, "group", a);
      }(e, t.size, n);
    case "groupInstance":
      return function(r, i, a) {
        var o = r.groupCount, s = r.instanceCount, u = s * o, c = hr(Math.max(1, u), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (r.reset(); r.hasNext; ) {
          var l = r.move();
          zp(i(l.location) * _m, c.array, 3 * l.index);
        }
        return qp(c, "groupInstance", a);
      }(e, t.size, n);
    case "instance":
      return function(r, i, a) {
        var o = r.instanceCount, s = hr(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (r.reset(); r.hasNext && !r.isNextNewInstance; ) {
          var u = r.move();
          zp(i(u.location) * _m, s.array, 3 * u.instanceIndex), r.skipInstance();
        }
        return qp(s, "instance", a);
      }(e, t.size, n);
  }
}
var _m = 100;
function _f(e) {
  switch (e.dSizeType.ref.value) {
    case "uniform":
      return e.uSize.ref.value;
    case "instance":
    case "group":
    case "groupInstance":
      for (var t = 0, n = e.tSize.ref.value.array, r = 0, i = n.length; r < i; r += 3) {
        var a = Zg(n[r], n[r + 1], n[r + 2]);
        t < a && (t = a);
      }
      return t / _m;
  }
}
var Pc, jB = { array: new Uint8Array(3), width: 1, height: 1 };
function qp(e, t, n) {
  return n ? (k.update(n.tSize, e), k.update(n.uSizeTexDim, ge.create(e.width, e.height)), k.updateIfChanged(n.dSizeType, t), n) : { uSize: k.create(0), tSize: k.create(e), uSizeTexDim: k.create(ge.create(e.width, e.height)), dSizeType: k.create(t) };
}
function j5(e, t, n, r, i, a, o) {
  for (var s = 0; s < t; s++) {
    for (var u = 0; u < n; u++) r[u] = e[u * t + s];
    for (K5(r, i, a, o, n), u = 0; u < n; u++) e[u * t + s] = i[u];
  }
  for (u = 0; u < n; u++) {
    for (s = 0; s < t; s++) r[s] = e[u * t + s];
    for (K5(r, i, a, o, t), s = 0; s < t; s++) e[u * t + s] = Math.sqrt(i[s]);
  }
}
function K5(e, t, n, r, i) {
  n[0] = 0, r[0] = Number.MIN_SAFE_INTEGER, r[1] = Number.MAX_SAFE_INTEGER;
  for (var a = 1, o = 0; a < i; a++) {
    for (var s = (e[a] + a * a - (e[n[o]] + n[o] * n[o])) / (2 * a - 2 * n[o]); s <= r[o]; ) o--, s = (e[a] + a * a - (e[n[o]] + n[o] * n[o])) / (2 * a - 2 * n[o]);
    n[++o] = a, r[o] = s, r[o + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (a = 0, o = 0; a < i; a++) {
    for (; r[o + 1] < a; ) o++;
    t[a] = (a - n[o]) * (a - n[o]) + e[n[o]];
  }
}
(function(e) {
  function t(s, u, c, l) {
    return l ? function(d, m, p, v) {
      return v.pointCount = p, k.update(v.centerBuffer, d), k.update(v.groupBuffer, m), v;
    }(s, u, c, l) : function(d, m, p) {
      var v, f = de(), y = -1, h = -1, g = { kind: "points", pointCount: p, centerBuffer: k.create(d), groupBuffer: k.create(m), get boundingSphere() {
        var x = r(g);
        if (x !== y) {
          var C = Pu(g.centerBuffer.ref.value, g.pointCount, 1);
          de.copy(f, C), y = x;
        }
        return f;
      }, get groupMapping() {
        return g.groupBuffer.ref.version !== h && (v = id(g.groupBuffer.ref.value, g.pointCount), h = g.groupBuffer.ref.version), v;
      }, setBoundingSphere: function(x) {
        de.copy(f, x), y = r(g);
      } };
      return g;
    }(s, u, c);
  }
  function n(s) {
    return t(s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function r(s) {
    return di([s.pointCount, s.centerBuffer.ref.version, s.groupBuffer.ref.version]);
  }
  function i(s, u) {
    var c = s.pointCount, l = u.instanceCount.ref.value, d = wc(), m = d.position, p = s.centerBuffer.ref.value, v = u.aTransform.ref.value;
    return Zn(c, l, 1, function(f, y) {
      return y < 0 ? S.fromArray(m, p, 3 * f) : S.transformMat4Offset(m, p, v, 0, 3 * f, 16 * y), d;
    });
  }
  function a(s, u, c, l, d) {
    var m = c.instanceCount, p = c.groupCount, v = ta(c, i(s, u), l.color), f = Es(c, l.size), y = Da(m * p), h = ms(), g = ps(), x = vs(), C = hs(), b = { drawCount: s.pointCount, vertexCount: s.pointCount, groupCount: p, instanceCount: m }, _ = de.clone(s.boundingSphere), A = Ir(_, u.aTransform.ref.value, m);
    return B(B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("points"), aPosition: s.centerBuffer, aGroup: s.groupBuffer, boundingSphere: k.create(A), invariantBoundingSphere: k.create(_), uInvariantBoundingSphere: k.create(vt.ofSphere(_)) }, v), f), y), h), g), x), C), u), Ve.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), dPointSizeAttenuation: k.create(d.pointSizeAttenuation), dPointStyle: k.create(d.pointStyle) });
  }
  function o(s, u) {
    Ve.updateRenderableState(s, u), s.opaque = s.opaque && u.pointStyle !== "fuzzy", s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = n, e.transform = function(s, u) {
    var c = s.centerBuffer.ref.value;
    Ol(u, c, 0, s.pointCount), k.update(s.centerBuffer, c);
  }, e.StyleTypes = { square: "Square", circle: "Circle", fuzzy: "Fuzzy" }, e.StyleTypeNames = Object.keys(e.StyleTypes), e.Params = B(B({}, Ve.Params), { sizeFactor: N.Numeric(3, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: N.Boolean(!1), pointStyle: N.Select("square", N.objectToOptions(e.StyleTypes)) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var m = Ve.createSimple(c, l, d), p = B(B({}, N.getDefaultValues(e.Params)), u);
    return a(s, m.transform, m.locationIterator, m.theme, p);
  }, updateValues: function(s, u) {
    Ve.updateValues(s, u), k.updateIfChanged(s.uSizeFactor, u.sizeFactor), k.updateIfChanged(s.dPointSizeAttenuation, u.pointSizeAttenuation), k.updateIfChanged(s.dPointStyle, u.pointStyle);
  }, updateBoundingSphere: function(s, u) {
    var c = de.clone(u.boundingSphere), l = Ir(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    de.equals(l, s.boundingSphere.ref.value) || k.update(s.boundingSphere, l), de.equals(c, s.invariantBoundingSphere.ref.value) || (k.update(s.invariantBoundingSphere, c), k.update(s.uInvariantBoundingSphere, vt.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = Ve.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
})(Pc || (Pc = {}));
var jp = {}, na, ox = { fontFamily: N.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]), fontQuality: N.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]), fontStyle: N.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]), fontVariant: N.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]), fontWeight: N.Select("normal", [["normal", "Normal"], ["bold", "Bold"]]) }, KB = 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 n = B(B({}, N.getDefaultValues(ox)), t);
    this.props = n;
    var r = 32 * (n.fontQuality + 1);
    this.buffer = r / 8, this.radius = r / 3, this.lineHeight = Math.round(r + 2 * this.buffer + this.radius), this.maxWidth = Math.round(0.75 * this.lineHeight), this.texture = hr(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(n.fontStyle, " ").concat(n.fontVariant, " ").concat(n.fontWeight, " ").concat(r, "px ").concat(n.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 n = this.texture, r = n.array, i = n.width, a = n.height, o = this.scratchData;
      if (this.currentX + this.scratchW > i && (this.currentX = 0, this.currentY += this.scratchH), this.currentY + this.scratchH > a) 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) r[i * (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 n = this.lineHeight, r = this.scratchContext, i = this.scratchData, a = r.measureText(t), o = Math.min(this.maxWidth, Math.ceil(a.width + 2 * this.buffer)), s = o * n;
    r.clearRect(0, 0, o, n), r.fillText(t, this.buffer, this.middle);
    for (var u = r.getImageData(0, 0, o, n), 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 (j5(this.gridOuter, o, n, this.f, this.d, this.v, this.z), j5(this.gridInner, o, n, this.f, this.d, this.v, this.z), c = 0; c < s; c++) {
      var d = this.gridOuter[c] - this.gridInner[c];
      i[c] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));
    }
    this.scratchW = o, this.scratchH = n;
  }, e;
}();
function X5(e, t, n, r) {
  for (var i = 0, a = 0, o = 0, s = 4 * n; o < s; ++o) {
    var u = 2 * o, c = Math.abs(e[u]);
    c > i && (i = c);
    var l = Math.abs(e[u + 1]);
    l > i && (i = l);
    var d = Math.abs(t[o]);
    d > a && (a = d);
  }
  return Math.max(a, r + r * i);
}
(function(e) {
  function t(s, u, c, l, d, m, p, v, f) {
    return f ? function(y, h, g, x, C, b, _, A, I) {
      return I.charCount = A, k.update(I.fontTexture, y), k.update(I.centerBuffer, h), k.update(I.mappingBuffer, g), k.update(I.depthBuffer, x), k.update(I.indexBuffer, C), k.update(I.groupBuffer, b), k.update(I.tcoordBuffer, _), I;
    }(s, u, c, l, d, m, p, v, f) : function(y, h, g, x, C, b, _, A) {
      var I, w = de(), E = -1, D = -1, T = { kind: "text", charCount: A, fontTexture: k.create(y), centerBuffer: k.create(h), mappingBuffer: k.create(g), depthBuffer: k.create(x), indexBuffer: k.create(C), groupBuffer: k.create(b), tcoordBuffer: k.create(_), get boundingSphere() {
        var P = r(T);
        if (P !== E) {
          var M = Pu(T.centerBuffer.ref.value, 4 * T.charCount, 4);
          de.copy(w, M), E = P;
        }
        return w;
      }, get groupMapping() {
        return T.groupBuffer.ref.version !== D && (I = id(T.groupBuffer.ref.value, T.charCount, 4), D = T.groupBuffer.ref.version), I;
      }, setBoundingSphere: function(P) {
        de.copy(w, P), E = r(T);
      } };
      return T;
    }(s, u, c, l, d, m, p, v);
  }
  function n(s) {
    return t(s ? s.fontTexture.ref.value : hr(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 r(s) {
    return di([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 i(s, u) {
    var c = 4 * s.charCount, l = u.instanceCount.ref.value, d = wc(), m = d.position, p = s.centerBuffer.ref.value, v = u.aTransform.ref.value;
    return Zn(c, l, 4, function(f, y) {
      return y < 0 ? S.fromArray(m, p, 3 * f) : S.transformMat4Offset(m, p, v, 0, 3 * f, 16 * y), d;
    });
  }
  function a(s, u, c, l, d) {
    var m = c.instanceCount, p = c.groupCount, v = ta(c, i(s, u), l.color), f = Es(c, l.size), y = Da(m * p), h = ms(), g = ps(), x = vs(), C = hs(), b = { drawCount: 2 * s.charCount * 3, vertexCount: 4 * s.charCount, groupCount: p, instanceCount: m }, _ = X5(s.mappingBuffer.ref.value, s.depthBuffer.ref.value, s.charCount, _f(f)), A = de.expand(de(), s.boundingSphere, _), I = Ir(A, u.aTransform.ref.value, m);
    return B(B(B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("text"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aDepth: s.depthBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: k.create(I), invariantBoundingSphere: k.create(A), uInvariantBoundingSphere: k.create(vt.ofSphere(A)) }, v), f), y), h), g), x), C), u), { aTexCoord: s.tcoordBuffer, tFont: s.fontTexture, padding: k.create(_) }), Ve.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), uBorderWidth: k.create(xi(d.borderWidth, 0, 0.5)), uBorderColor: k.create(ye.toArrayNormalized(d.borderColor, S.zero(), 0)), uOffsetX: k.create(d.offsetX), uOffsetY: k.create(d.offsetY), uOffsetZ: k.create(d.offsetZ), uBackgroundColor: k.create(ye.toArrayNormalized(d.backgroundColor, S.zero(), 0)), uBackgroundOpacity: k.create(d.backgroundOpacity) });
  }
  function o(s, u) {
    Ve.updateRenderableState(s, u), s.pickable = !1, s.opaque = !1, s.writeDepth = !0;
  }
  e.create = t, e.createEmpty = n, e.Params = B(B(B({}, Ve.Params), ox), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), borderWidth: N.Numeric(0, { min: 0, max: 0.5, step: 0.01 }), borderColor: N.Color(_t.grey), offsetX: N.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetY: N.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetZ: N.Numeric(0, { min: 0, max: 10, step: 0.1 }), background: N.Boolean(!1), backgroundMargin: N.Numeric(0.2, { min: 0, max: 1, step: 0.01 }), backgroundColor: N.Color(_t.grey), backgroundOpacity: N.Numeric(1, { min: 0, max: 1, step: 0.01 }), tether: N.Boolean(!1), tetherLength: N.Numeric(1, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: N.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), attachment: N.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: n, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var m = Ve.createSimple(c, l, d), p = B(B({}, N.getDefaultValues(e.Params)), u);
    return a(s, m.transform, m.locationIterator, m.theme, p);
  }, updateValues: function(s, u) {
    Ve.updateValues(s, u), k.updateIfChanged(s.uSizeFactor, u.sizeFactor), k.updateIfChanged(s.uBorderWidth, u.borderWidth), ye.fromNormalizedArray(s.uBorderColor.ref.value, 0) !== u.borderColor && (ye.toArrayNormalized(u.borderColor, s.uBorderColor.ref.value, 0), k.update(s.uBorderColor, s.uBorderColor.ref.value)), k.updateIfChanged(s.uOffsetX, u.offsetX), k.updateIfChanged(s.uOffsetY, u.offsetY), k.updateIfChanged(s.uOffsetZ, u.offsetZ), ye.fromNormalizedArray(s.uBackgroundColor.ref.value, 0) !== u.backgroundColor && (ye.toArrayNormalized(u.backgroundColor, s.uBackgroundColor.ref.value, 0), k.update(s.uBackgroundColor, s.uBackgroundColor.ref.value)), k.updateIfChanged(s.uBackgroundOpacity, u.backgroundOpacity);
  }, updateBoundingSphere: function(s, u) {
    var c = X5(s.aMapping.ref.value, s.aDepth.ref.value, u.charCount, _f(s)), l = de.expand(de(), u.boundingSphere, c), d = Ir(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    de.equals(d, s.boundingSphere.ref.value) || k.update(s.boundingSphere, d), de.equals(l, s.invariantBoundingSphere.ref.value) || (k.update(s.invariantBoundingSphere, l), k.update(s.uInvariantBoundingSphere, vt.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), k.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = Ve.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
})(na || (na = {}));
var zr, Yt, fo = S(), mo = S(), Lu = S(), Y5 = he.add, C1 = he.add3;
(function(e) {
  e.create = function(t, n, r) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024);
    var i = he.create(Float32Array, 1, n, r ? r.groupBuffer.ref.value : t), a = he.create(Float32Array, 3, n, r ? r.startBuffer.ref.value : t), o = he.create(Float32Array, 3, n, r ? r.endBuffer.ref.value : t), s = function(c, l, d, m, p, v, f) {
      for (var y = 0; y < 4; ++y) C1(a, c, l, d), C1(o, m, p, v), Y5(i, f);
    }, u = function(c, l, d, m) {
      var p = S.distance(c, l), v = Math.floor(d / 2), f = 1 / d;
      S.sub(Lu, l, c);
      for (var y = 0; y < v; ++y) {
        var h = f * (2 * y + 1);
        S.setMagnitude(Lu, Lu, p * h), S.add(fo, c, Lu), S.setMagnitude(Lu, Lu, p * f * (2 * (y + 1))), S.add(mo, c, Lu), s(fo[0], fo[1], fo[2], mo[0], mo[1], mo[2], m);
      }
    };
    return { add: s, addVec: function(c, l, d) {
      for (var m = 0; m < 4; ++m) C1(a, c[0], c[1], c[2]), C1(o, l[0], l[1], l[2]), Y5(i, d);
    }, addFixedCountDashes: u, addFixedLengthDashes: function(c, l, d, m) {
      var p = S.distance(c, l);
      u(c, l, p / d, m);
    }, addCage: function(c, l, d) {
      for (var m = l.vertices, p = l.edges, v = 0, f = p.length; v < f; v += 2) S.fromArray(fo, m, 3 * p[v]), S.fromArray(mo, m, 3 * p[v + 1]), S.transformMat4(fo, fo, c), S.transformMat4(mo, mo, c), s(fo[0], fo[1], fo[2], mo[0], mo[1], mo[2], d);
    }, getLines: function() {
      var c = i.elementCount / 4, l = he.compact(i, !0), d = he.compact(a, !0), m = he.compact(o, !0), p = r && c <= r.lineCount ? r.mappingBuffer.ref.value : new Float32Array(8 * c), v = r && c <= r.lineCount ? r.indexBuffer.ref.value : new Uint32Array(6 * c);
      return (!r || c > r.lineCount) && function(f, y, h) {
        for (var g = 0; g < f; ++g) {
          var x = 8 * g;
          y[x] = -1, y[x + 1] = -1, y[x + 2] = 1, y[x + 3] = -1, y[x + 4] = -1, y[x + 5] = 1, y[x + 6] = 1, y[x + 7] = 1;
        }
        for (g = 0; g < f; ++g) {
          var C = 4 * g, b = 6 * g;
          h[b] = C, h[b + 1] = C + 1, h[b + 2] = C + 2, h[b + 3] = C + 1, h[b + 4] = C + 3, h[b + 5] = C + 2;
        }
      }(c, p, v), Yt.create(p, v, l, d, m, c, r);
    } };
  };
})(zr || (zr = {})), function(e) {
  function t(o, s, u, c, l, d, m) {
    return m ? function(p, v, f, y, h, g, x) {
      return g > x.lineCount && (k.update(x.mappingBuffer, p), k.update(x.indexBuffer, v)), x.lineCount = g, k.update(x.groupBuffer, f), k.update(x.startBuffer, y), k.update(x.endBuffer, h), x;
    }(o, s, u, c, l, d, m) : function(p, v, f, y, h, g) {
      var x, C = de(), b = -1, _ = -1, A = { kind: "lines", lineCount: g, mappingBuffer: k.create(p), indexBuffer: k.create(v), groupBuffer: k.create(f), startBuffer: k.create(y), endBuffer: k.create(h), get boundingSphere() {
        var I = r(A);
        if (I !== b) {
          var w = Pu(A.startBuffer.ref.value, 4 * A.lineCount, 4), E = Pu(A.endBuffer.ref.value, 4 * A.lineCount, 4);
          de.expandBySphere(C, w, E), b = I;
        }
        return C;
      }, get groupMapping() {
        return A.groupBuffer.ref.version !== _ && (x = id(A.groupBuffer.ref.value, A.lineCount, 4), _ = A.groupBuffer.ref.version), x;
      }, setBoundingSphere: function(I) {
        de.copy(C, I), b = r(A);
      } };
      return A;
    }(o, s, u, c, l, d);
  }
  function n(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 r(o) {
    return di([o.lineCount, o.mappingBuffer.ref.version, o.indexBuffer.ref.version, o.groupBuffer.ref.version, o.startBuffer.ref.version, o.endBuffer.ref.version]);
  }
  function i(o, s) {
    var u = 4 * o.lineCount, c = s.instanceCount.ref.value, l = wc(), d = l.position, m = o.startBuffer.ref.value, p = o.endBuffer.ref.value, v = s.aTransform.ref.value;
    return Zn(u, c, 2, function(f, y) {
      var h = f % 4 == 0 ? m : p;
      return y < 0 ? S.fromArray(d, h, 3 * f) : S.transformMat4Offset(d, h, v, 0, 3 * f, 16 * y), l;
    });
  }
  function a(o, s, u, c, l) {
    var d = u.instanceCount, m = u.groupCount, p = ta(u, i(o, s), c.color), v = Es(u, c.size), f = Da(d * m), y = ms(), h = ps(), g = vs(), x = hs(), C = { drawCount: 2 * o.lineCount * 3, vertexCount: 4 * o.lineCount, groupCount: m, instanceCount: d }, b = de.clone(o.boundingSphere), _ = Ir(b, s.aTransform.ref.value, d);
    return B(B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("lines"), aMapping: o.mappingBuffer, aGroup: o.groupBuffer, aStart: o.startBuffer, aEnd: o.endBuffer, elements: o.indexBuffer, boundingSphere: k.create(_), invariantBoundingSphere: k.create(b), uInvariantBoundingSphere: k.create(vt.ofSphere(b)) }, p), v), f), y), h), g), x), s), Ve.createValues(l, C)), { uSizeFactor: k.create(l.sizeFactor), dLineSizeAttenuation: k.create(l.lineSizeAttenuation), uDoubleSided: k.create(!0), dFlipSided: k.create(!1) });
  }
  e.create = t, e.createEmpty = n, e.fromMesh = function(o, s) {
    for (var u = o.vertexBuffer.ref.value, c = o.indexBuffer.ref.value, l = o.groupBuffer.ref.value, d = zr.create(3 * o.triangleCount, o.triangleCount / 10, s), m = 0, p = 3 * o.triangleCount; m < p; m += 3) {
      var v = c[m], f = c[m + 1], y = c[m + 2], h = u[3 * v], g = u[3 * v + 1], x = u[3 * v + 2], C = u[3 * f], b = u[3 * f + 1], _ = u[3 * f + 2], A = u[3 * y], I = u[3 * y + 1], w = u[3 * y + 2];
      d.add(h, g, x, C, b, _, l[v]), d.add(h, g, x, A, I, w, l[v]), d.add(C, b, _, A, I, w, l[f]);
    }
    return d.getLines();
  }, e.transform = function(o, s) {
    var u = o.startBuffer.ref.value;
    Ol(s, u, 0, 4 * o.lineCount), k.update(o.startBuffer, u);
    var c = o.endBuffer.ref.value;
    Ol(s, c, 0, 4 * o.lineCount), k.update(o.endBuffer, c);
  }, e.Params = B(B({}, Ve.Params), { sizeFactor: N.Numeric(2, { min: 0, max: 10, step: 0.1 }), lineSizeAttenuation: N.Boolean(!1) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: a, createValuesSimple: function(o, s, u, c, l) {
    var d = Ve.createSimple(u, c, l), m = B(B({}, N.getDefaultValues(e.Params)), s);
    return a(o, d.transform, d.locationIterator, d.theme, m);
  }, updateValues: function(o, s) {
    Ve.updateValues(o, s), k.updateIfChanged(o.uSizeFactor, s.sizeFactor), k.updateIfChanged(o.dLineSizeAttenuation, s.lineSizeAttenuation);
  }, updateBoundingSphere: function(o, s) {
    var u = de.clone(s.boundingSphere), c = Ir(u, o.aTransform.ref.value, o.instanceCount.ref.value);
    de.equals(c, o.boundingSphere.ref.value) || k.update(o.boundingSphere, c), de.equals(u, o.invariantBoundingSphere.ref.value) || (k.update(o.invariantBoundingSphere, u), k.update(o.uInvariantBoundingSphere, vt.fromSphere(o.uInvariantBoundingSphere.ref.value, u)));
  }, createRenderableState: Ve.createRenderableState, updateRenderableState: Ve.updateRenderableState, createPositionIterator: i };
}(Yt || (Yt = {}));
var W5 = S(), Z5 = S(), Q5 = S();
function sx(e, t) {
  for (var n = t.length, r = zf(n / 3), i = 0; i < n; i += 3) S.fromArray(W5, e, 3 * t[i]), S.fromArray(Z5, e, 3 * t[i + 1]), S.fromArray(Q5, e, 3 * t[i + 2]), r.add(W5, Z5, Q5);
  return r.getPrimitive();
}
var A1 = S();
function zf(e, t) {
  t === void 0 && (t = 3 * e);
  var n = new Float32Array(3 * t), r = new Float32Array(3 * t), i = new Uint32Array(3 * e), a = 0, o = 0;
  return { add: function(s, u, c) {
    S.toArray(s, n, a), S.toArray(u, n, a + 3), S.toArray(c, n, a + 6), S.triangleNormal(A1, s, u, c);
    for (var l = 0; l < 3; ++l) S.toArray(A1, r, a + 3 * l), i[o + l] = a / 3 + l;
    a += 9, o += 3;
  }, addQuad: function(s, u, c, l) {
    S.toArray(s, n, a), S.toArray(u, n, a + 3), S.toArray(c, n, a + 6), S.toArray(l, n, a + 9), S.triangleNormal(A1, s, u, c);
    for (var d = 0; d < 4; ++d) S.toArray(A1, r, a + 3 * d);
    var m = a / 3;
    i[o] = m, i[o + 1] = m + 1, i[o + 2] = m + 2, i[o + 3] = m + 2, i[o + 4] = m + 3, i[o + 5] = m, a += 12, o += 6;
  }, getPrimitive: function() {
    return { vertices: n, normals: r, indices: i };
  } };
}
var jc = S(), XB = br();
function D0(e, t) {
  for (var n = e.vertices, r = e.normals, i = br.directionTransform(XB, t), a = 0, o = n.length; a < o; a += 3) S.transformMat4(jc, S.fromArray(jc, n, a), t), S.toArray(jc, n, a), S.transformMat3(jc, S.fromArray(jc, r, a), i), S.toArray(jc, r, a);
  return e;
}
function B0(e, t, n) {
  n === void 0 && (n = -1);
  for (var r = new Float32Array(3 * e), i = n === -1 ? e <= 4 ? Math.sqrt(2) / 2 : 0.6 : n, a = t ? 1 : 0, o = 0, s = e; o < s; ++o) {
    var u = (2 * o + a) / e * Math.PI;
    r[3 * o] = Math.cos(u) * i, r[3 * o + 1] = Math.sin(u) * i, r[3 * o + 2] = 0;
  }
  return r;
}
function R0(e) {
  return { vertices: new Float32Array(e.vertices), edges: new Uint32Array(e.edges) };
}
var Kp = S.zero();
function k0(e, t) {
  for (var n = e.vertices, r = 0, i = n.length; r < i; r += 3) S.transformMat4(Kp, S.fromArray(Kp, n, r), t), S.toArray(Kp, n, r);
  return e;
}
var Xp, Yp, Ri, Wp, Zp, Tt, Kc = S(), Xc = S(), Yc = S(), Wc = S(), Fn = B0(4, !0);
function ux() {
  return Xp || (Xp = function(e) {
    for (var t = zf(12, 24), n = 0; n < 4; ++n) {
      var r = (n + 1) % 4;
      S.set(Kc, Fn[3 * n], Fn[3 * n + 1], -0.5), S.set(Xc, Fn[3 * r], Fn[3 * r + 1], -0.5), S.set(Yc, Fn[3 * r], Fn[3 * r + 1], 0.5), S.set(Wc, Fn[3 * n], Fn[3 * n + 1], 0.5), t.addQuad(Kc, Xc, Yc, Wc);
    }
    return S.set(Kc, Fn[0], Fn[1], -0.5), S.set(Xc, Fn[3], Fn[4], -0.5), S.set(Yc, Fn[6], Fn[7], -0.5), S.set(Wc, Fn[9], Fn[10], -0.5), t.addQuad(Wc, Yc, Xc, Kc), S.set(Kc, Fn[0], Fn[1], 0.5), S.set(Xc, Fn[3], Fn[4], 0.5), S.set(Yc, Fn[6], Fn[7], 0.5), S.set(Wc, Fn[9], Fn[10], 0.5), t.addQuad(Kc, Xc, Yc, Wc), t.getPrimitive();
  }()), Xp;
}
function cx() {
  return Yp || (Yp = /* @__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])), Yp;
}
function J5(e) {
  return e.map(function(t) {
    return { x: t[0], alpha: t[1] };
  });
}
function $5(e, t) {
  for (var n, r, i, a, o, s, u = Pe(Pe([{ 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, m = 0; m < d; ++m) {
    n = u[m + 1].x, r = u[m + 2].x, i = u[m].alpha, a = u[m + 1].alpha, o = u[m + 2].alpha, s = u[m + 3].alpha;
    for (var p = Math.round(256 * (r - n)), v = 0; v < p; ++v) {
      var f = v / p;
      c[l] = Math.max(0, 255 * pm(i, a, o, s, f, 0.5)), ++l;
    }
  }
  var y = { array: c, width: 256, height: 1 };
  return t ? (k.update(t, y), t) : k.create(y);
}
function eb(e, t, n, r) {
  var i = (r - n) / t;
  i === 0 && (i = 1);
  for (var a = new Int32Array(t), o = 0, s = e.length; o < s; o++) {
    var u = Math.floor((e[o] - n) / i);
    u >= t ? u = t - 1 : u < 0 && (u = 0), a[u]++;
  }
  return { min: n, max: r, binWidth: i, counts: a };
}
(function(e) {
  e.One = { transform: { kind: "matrix", matrix: J.identity() }, cells: Nn.create(Nn.Space([1, 1, 1], [0, 1, 2]), Nn.Data1([0])), stats: { min: 0, max: 0, mean: 0, sigma: 0 } };
  var t = J.zero(), n = J.zero();
  e.getGridToCartesianTransform = function(r) {
    if (r.transform.kind === "matrix") return J.copy(J(), r.transform.matrix);
    if (r.transform.kind === "spacegroup") {
      var i = r.cells.space, a = J.fromScaling(t, S.div(S.zero(), sn.size(S.zero(), r.transform.fractionalBox), S.ofArray(i.dimensions))), o = J.fromTranslation(n, r.transform.fractionalBox.min);
      return J.mul3(J.zero(), r.transform.cell.fromFractional, o, a);
    }
    return J.identity();
  }, e.areEquivalent = function(r, i) {
    return r === i;
  }, e.isEmpty = function(r) {
    return r.cells.data.length === 0;
  }, e.getBoundingSphere = function(r, i) {
    i || (i = de());
    var a = r.cells.space.dimensions, o = e.getGridToCartesianTransform(r);
    return de.fromDimensionsAndTransform(i, a, o);
  }, e.getHistogram = function(r, i) {
    var a = r._historams;
    return a || (a = r._historams = {}), a[i] || (a[i] = function(o, s, u) {
      if (u) return eb(o, s, u.min, u.max);
      var c = Ki(o);
      return eb(o, s, c[0], c[1]);
    }(r.cells.data, i, { min: r.stats.min, max: r.stats.max })), a[i];
  };
})(Ri || (Ri = {})), 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 };
  };
}(Wp || (Wp = {})), 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 };
  };
}(Zp || (Zp = {})), function(e) {
  var t;
  e.is = function(a) {
    var o, s, u, c;
    return ((c = (u = (s = (o = a == null ? void 0 : a.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) && (a == null ? void 0 : a.sourceData) && (a == null ? void 0 : a.customProperties) && (a == null ? void 0 : a._propertyData);
  }, function(a) {
    function o(s, u) {
      return s.kind === "absolute" ? s : { kind: "absolute", absoluteValue: a.calcAbsolute(u, s.relativeValue) };
    }
    a.areSame = function(s, u, c) {
      return On(o(s, c).absoluteValue, o(u, c).absoluteValue, c.sigma / 100);
    }, a.absolute = function(s) {
      return { kind: "absolute", absoluteValue: s };
    }, a.relative = function(s) {
      return { kind: "relative", relativeValue: s };
    }, a.calcAbsolute = function(s, u) {
      return u * s.sigma + s.mean;
    }, a.calcRelative = function(s, u) {
      return s.sigma === 0 ? 0 : (u - s.mean) / s.sigma;
    }, a.toAbsolute = o, a.toRelative = function(s, u) {
      return s.kind === "relative" ? s : { kind: "relative", relativeValue: a.calcRelative(u, s.absoluteValue) };
    }, a.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(a, o, s) {
    if (s === "relative") return t.relative(o);
    var u = t.absolute(o);
    if (Zp.is(a.sourceData)) {
      var c = { min: a.sourceData.data.volume_data_3d_info.min_source.value(0), max: a.sourceData.data.volume_data_3d_info.max_source.value(0), mean: a.sourceData.data.volume_data_3d_info.mean_source.value(0), sigma: a.sourceData.data.volume_data_3d_info.sigma_source.value(0) };
      return e.IsoValue.toRelative(u, c);
    }
    return u;
  };
  var n, r = { min: -1, max: 1, mean: 0, sigma: 0.1 };
  function i(a, o) {
    var s = o || r, u = s.min, c = s.max, l = s.mean, d = s.sigma, m = (u - l) / d, p = (c - l) / d, v = a;
    return a.kind === "absolute" ? a.absoluteValue < u ? v = e.IsoValue.absolute(u) : a.absoluteValue > c && (v = e.IsoValue.absolute(c)) : a.relativeValue < m ? v = e.IsoValue.relative(m) : a.relativeValue > p && (v = e.IsoValue.relative(p)), N.Conditioned(v, { absolute: N.Converted(function(f) {
      return e.IsoValue.toAbsolute(f, Ri.One.stats).absoluteValue;
    }, function(f) {
      return e.IsoValue.absolute(f);
    }, N.Numeric(l, { min: u, max: c, step: I4(d / 100, 2) })), relative: N.Converted(function(f) {
      return e.IsoValue.toRelative(f, Ri.One.stats).relativeValue;
    }, function(f) {
      return e.IsoValue.relative(f);
    }, N.Numeric(Math.min(1, p), { min: m, max: p, step: I4(Math.round((c - u) / d) / 100, 2) })) }, function(f) {
      return f.kind === "absolute" ? "absolute" : "relative";
    }, function(f, y) {
      return y === "absolute" ? e.IsoValue.toAbsolute(f, s) : e.IsoValue.toRelative(f, s);
    }, { isEssential: !0 });
  }
  e.createIsoValueParam = i, e.IsoValueParam = i(e.IsoValue.relative(2)), e.One = { label: "", grid: Ri.One, sourceData: { kind: "", name: "", data: {} }, customProperties: new ed(), _propertyData: /* @__PURE__ */ Object.create(null) }, e.areEquivalent = function(a, o) {
    return Ri.areEquivalent(a.grid, o.grid);
  }, e.isEmpty = function(a) {
    return Ri.isEmpty(a.grid);
  }, e.isOrbitals = function(a) {
    return !!Wp.is(a.sourceData) && a.sourceData.data.header.orbitals;
  }, e.Loci = function(a) {
    return { kind: "volume-loci", volume: a };
  }, e.isLoci = function(a) {
    return !!a && a.kind === "volume-loci";
  }, e.areLociEqual = function(a, o) {
    return a.volume === o.volume;
  }, e.isLociEmpty = function(a) {
    return Ri.isEmpty(a.volume.grid);
  }, e.getBoundingSphere = function(a, o) {
    return Ri.getBoundingSphere(a.grid, o);
  }, (n = e.Isosurface || (e.Isosurface = {})).Loci = function(a, o) {
    return { kind: "isosurface-loci", volume: a, isoValue: o };
  }, n.isLoci = function(a) {
    return !!a && a.kind === "isosurface-loci";
  }, n.areLociEqual = function(a, o) {
    return a.volume === o.volume && e.IsoValue.areSame(a.isoValue, o.isoValue, a.volume.grid.stats);
  }, n.isLociEmpty = function(a) {
    return a.volume.grid.cells.data.length === 0;
  }, n.getBoundingSphere = function(a, o, s) {
    return e.getBoundingSphere(a, s);
  }, function(a) {
    a.Loci = function(u, c) {
      return { kind: "cell-loci", volume: u, indices: c };
    }, a.isLoci = function(u) {
      return !!u && u.kind === "cell-loci";
    }, a.areLociEqual = function(u, c) {
      return u.volume === c.volume && ve.areEqual(u.indices, c.indices);
    }, a.isLociEmpty = function(u) {
      return ve.size(u.indices) === 0;
    };
    var o = new ka("98"), s = S();
    a.getBoundingSphere = function(u, c, l) {
      o.reset();
      for (var d = Ri.getGridToCartesianTransform(u.grid), m = u.grid.cells.space.getCoords, p = 0, v = ve.size(c); p < v; p++)
        m(ve.getAt(c, p), s), S.transformMat4(s, s, d), o.includePosition(s);
      for (o.finishedIncludeStep(), p = 0, v = ve.size(c); p < v; p++)
        m(ve.getAt(c, p), s), S.transformMat4(s, s, d), o.radiusPosition(s);
      var f = o.getSphere(l);
      return de.expand(f, f, 10 * J.getMaxScaleOnAxis(d));
    };
  }(e.Cell || (e.Cell = {}));
}(Tt || (Tt = {}));
var $m, ro, Eu, Qp = ux();
function tn(e, t, n) {
  return { type: "attribute", kind: e, itemSize: t, divisor: n };
}
function ce(e, t) {
  return { type: "uniform", kind: e, variant: t };
}
function pt(e, t, n, r) {
  return { type: "texture", kind: e, format: t, dataType: n, filter: r };
}
function Rc(e) {
  return { type: "elements", kind: e };
}
function mt(e, t) {
  return { type: "define", kind: e, options: t };
}
function tr(e) {
  return { type: "value", kind: e };
}
(function(e) {
  function t(u, c, l, d, m, p, v, f, y, h) {
    return h ? function(g, x, C, b, _, A, I, w, E, D) {
      var T = A.getWidth(), P = A.getHeight(), M = A.getDepth();
      return k.update(D.gridDimension, x), k.update(D.gridTexture, A), k.update(D.gridTextureDim, S.set(D.gridTextureDim.ref.value, T, P, M)), k.update(D.gridStats, vt.set(D.gridStats.ref.value, I.min, I.max, I.mean, I.sigma)), k.update(D.bboxMin, g.min), k.update(D.bboxMax, g.max), k.update(D.bboxSize, S.sub(D.bboxSize.ref.value, g.max, g.min)), k.update(D.transform, C), k.update(D.cellDim, _), k.update(D.unitToCartn, b), k.update(D.cartnToUnit, J.invert(J(), b)), k.updateIfChanged(D.packedGroup, w), k.updateIfChanged(D.axisOrder, S.fromArray(D.axisOrder.ref.value, E, 0)), D;
    }(u, c, l, d, m, p, v, f, y, h) : function(g, x, C, b, _, A, I, w, E) {
      var D = de(), T = -1, P = A.getWidth(), M = A.getHeight(), R = A.getDepth(), O = { kind: "direct-volume", gridDimension: k.create(x), gridTexture: k.create(A), gridTextureDim: k.create(S.create(P, M, R)), gridStats: k.create(vt.create(I.min, I.max, I.mean, I.sigma)), bboxMin: k.create(g.min), bboxMax: k.create(g.max), bboxSize: k.create(S.sub(S(), g.max, g.min)), transform: k.create(C), cellDim: k.create(_), unitToCartn: k.create(b), cartnToUnit: k.create(J.invert(J(), b)), get boundingSphere() {
        var L = n(O);
        if (L !== T) {
          var F = function(G, V) {
            return de.fromDimensionsAndTransform(de(), G, V);
          }(O.gridDimension.ref.value, O.transform.ref.value);
          de.copy(D, F), T = L;
        }
        return D;
      }, packedGroup: k.create(w), axisOrder: k.create(E), setBoundingSphere: function(L) {
        de.copy(D, L), T = n(O);
      } };
      return O;
    }(u, c, l, d, m, p, v, f, y);
  }
  function n(u) {
    return di([u.bboxSize.ref.version, u.gridDimension.ref.version, u.gridTexture.ref.version, u.transform.ref.version, u.gridStats.ref.version]);
  }
  function r(u) {
    return t(sn(), S(), J.identity(), J.identity(), S(), Ni(), Ri.One.stats, !1, S.create(0, 1, 2), u);
  }
  function i(u, c) {
    return Math.ceil(S.magnitude(u) * c);
  }
  function a(u, c) {
    return Math.min.apply(Math, u) * (1 / c);
  }
  function o(u) {
    return 1 / u;
  }
  function s(u, c, l, d, m) {
    var p = u.gridTexture, v = u.gridTextureDim, f = u.gridStats, y = u.bboxSize, h = u.bboxMin, g = u.bboxMax, x = u.gridDimension, C = u.transform, b = l.instanceCount, _ = l.groupCount, A = ta(l, e.Utils.createPositionIterator(u, c), d.color), I = Da(b * _), w = ms(), E = ps(), D = vs(), T = hs(), P = x.ref.value, M = P[0], R = P[1], O = P[2], L = { drawCount: Qp.indices.length, vertexCount: M * R * O, groupCount: _, instanceCount: b }, F = de.clone(u.boundingSphere), G = Ir(F, c.aTransform.ref.value, b), V = $5(J5(m.controlPoints));
    return B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("directVolume") }, A), I), w), E), D), T), c), Ve.createValues(m, L)), { aPosition: k.create(Qp.vertices), elements: k.create(Qp.indices), boundingSphere: k.create(G), invariantBoundingSphere: k.create(F), uInvariantBoundingSphere: k.create(vt.ofSphere(F)), uBboxMin: h, uBboxMax: g, uBboxSize: y, uMaxSteps: k.create(i(x.ref.value, m.stepsPerCell)), uStepScale: k.create(a(u.cellDim.ref.value, m.stepsPerCell)), uJumpLength: k.create(m.jumpLength), uTransform: C, uGridDim: x, tTransferTex: V, uTransferScale: k.create(o(m.stepsPerCell)), dGridTexType: k.create(p.ref.value.getDepth() > 0 ? "3d" : "2d"), uGridTexDim: v, tGridTex: p, uGridStats: f, uCellDim: u.cellDim, uCartnToUnit: u.cartnToUnit, uUnitToCartn: u.unitToCartn, dPackedGroup: u.packedGroup, dAxisOrder: k.create(u.axisOrder.ref.value.join("")), dIgnoreLight: k.create(m.ignoreLight), dXrayShaded: k.create(m.xrayShaded) });
  }
  e.create = t, e.createEmpty = r, e.Params = B(B({}, Ve.Params), { ignoreLight: N.Boolean(!1, Ve.ShadingCategory), xrayShaded: N.Boolean(!1, Ve.ShadingCategory), controlPoints: N.LineGraph([ge.create(0.19, 0), ge.create(0.2, 0.05), ge.create(0.25, 0.05), ge.create(0.26, 0), ge.create(0.79, 0), ge.create(0.8, 0.05), ge.create(0.85, 0.05), ge.create(0.86, 0)], { isEssential: !0 }), stepsPerCell: N.Numeric(3, { min: 1, max: 10, step: 1 }), jumpLength: N.Numeric(0, { min: 0, max: 20, step: 0.1 }) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: s, createValuesSimple: function(u, c, l, d, m) {
    var p = Ve.createSimple(l, d, m), v = B(B({}, N.getDefaultValues(e.Params)), c);
    return s(u, p.transform, p.locationIterator, p.theme, v);
  }, updateValues: function(u, c) {
    Ve.updateValues(u, c), k.updateIfChanged(u.dIgnoreLight, c.ignoreLight), k.updateIfChanged(u.dXrayShaded, c.xrayShaded), $5(J5(c.controlPoints), u.tTransferTex), k.updateIfChanged(u.uMaxSteps, i(u.uGridDim.ref.value, c.stepsPerCell)), k.updateIfChanged(u.uStepScale, a(u.uCellDim.ref.value, c.stepsPerCell)), k.updateIfChanged(u.uTransferScale, o(c.stepsPerCell)), k.updateIfChanged(u.uJumpLength, c.jumpLength);
  }, updateBoundingSphere: function(u, c) {
    var l = de.clone(c.boundingSphere), d = Ir(l, u.aTransform.ref.value, u.instanceCount.ref.value);
    de.equals(d, u.boundingSphere.ref.value) || k.update(u.boundingSphere, d), de.equals(l, u.invariantBoundingSphere.ref.value) || (k.update(u.invariantBoundingSphere, l), k.update(u.uInvariantBoundingSphere, vt.fromSphere(u.uInvariantBoundingSphere.ref.value, l)));
  }, createRenderableState: function(u) {
    var c = Ve.createRenderableState(u);
    return c.opaque = !1, c.writeDepth = !1, c;
  }, updateRenderableState: function(u, c) {
    Ve.updateRenderableState(u, c), u.opaque = !1, u.writeDepth = !1;
  }, createPositionIterator: function(u, c) {
    var l = u.transform.ref.value, d = u.gridDimension.ref.value, m = d[0], p = d[1], v = d[2], f = m * p * v, y = c.instanceCount.ref.value, h = wc(), g = h.position, x = c.aTransform.ref.value;
    return Zn(f, y, 1, function(C, b) {
      var _ = Math.floor(C / v);
      return g[0] = Math.floor(_ / p), g[1] = _ % p, g[2] = C % v, S.transformMat4(g, g, l), b >= 0 && S.transformMat4Offset(g, g, x, 0, 0, 16 * b), h;
    });
  } };
})($m || ($m = {})), function(e) {
  function t(s, u, c, l, d, m) {
    return m ? function(p, v, f, y, h, g) {
      return h > g.sphereCount && (k.update(g.mappingBuffer, v), k.update(g.indexBuffer, f)), g.sphereCount = h, k.update(g.centerBuffer, p), k.update(g.groupBuffer, y), g;
    }(s, u, c, l, d, m) : function(p, v, f, y, h) {
      var g, x = de(), C = -1, b = -1, _ = { kind: "spheres", sphereCount: h, centerBuffer: k.create(p), mappingBuffer: k.create(v), indexBuffer: k.create(f), groupBuffer: k.create(y), get boundingSphere() {
        var A = r(_);
        if (A !== C) {
          var I = Pu(_.centerBuffer.ref.value, 4 * _.sphereCount, 4);
          de.copy(x, I), C = A;
        }
        return x;
      }, get groupMapping() {
        return _.groupBuffer.ref.version !== b && (g = id(_.groupBuffer.ref.value, _.sphereCount, 4), b = _.groupBuffer.ref.version), g;
      }, setBoundingSphere: function(A) {
        de.copy(x, A), C = r(_);
      } };
      return _;
    }(s, u, c, l, d);
  }
  function n(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 r(s) {
    return di([s.sphereCount, s.centerBuffer.ref.version, s.mappingBuffer.ref.version, s.indexBuffer.ref.version, s.groupBuffer.ref.version]);
  }
  function i(s, u) {
    var c = 4 * s.sphereCount, l = u.instanceCount.ref.value, d = wc(), m = d.position, p = s.centerBuffer.ref.value, v = u.aTransform.ref.value;
    return Zn(c, l, 4, function(f, y) {
      return y < 0 ? S.fromArray(m, p, 3 * f) : S.transformMat4Offset(m, p, v, 0, 3 * f, 16 * y), d;
    });
  }
  function a(s, u, c, l, d) {
    var m = c.instanceCount, p = c.groupCount, v = ta(c, i(s, u), l.color), f = Es(c, l.size), y = Da(m * p), h = ms(), g = ps(), x = vs(), C = hs(), b = { drawCount: 2 * s.sphereCount * 3, vertexCount: 4 * s.sphereCount, groupCount: p, instanceCount: m }, _ = s.boundingSphere.radius ? _f(f) * d.sizeFactor : 0, A = de.expand(de(), s.boundingSphere, _), I = Ir(A, u.aTransform.ref.value, m);
    return B(B(B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("spheres"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: k.create(I), invariantBoundingSphere: k.create(A), uInvariantBoundingSphere: k.create(vt.ofSphere(A)) }, v), f), y), h), g), x), C), u), { padding: k.create(_) }), Ve.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), uDoubleSided: k.create(d.doubleSided), dIgnoreLight: k.create(d.ignoreLight), dXrayShaded: k.create(d.xrayShaded), uBumpFrequency: k.create(d.bumpFrequency), uBumpAmplitude: k.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    Ve.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = n, e.Params = B(B({}, Ve.Params), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), doubleSided: N.Boolean(!1, Ve.CustomQualityParamInfo), ignoreLight: N.Boolean(!1, Ve.ShadingCategory), xrayShaded: N.Boolean(!1, Ve.ShadingCategory), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), bumpAmplitude: N.Numeric(1, { min: 0, max: 5, step: 0.1 }, Ve.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var m = Ve.createSimple(c, l, d), p = B(B({}, N.getDefaultValues(e.Params)), u);
    return a(s, m.transform, m.locationIterator, m.theme, p);
  }, updateValues: function(s, u) {
    Ve.updateValues(s, u), k.updateIfChanged(s.uSizeFactor, u.sizeFactor), k.updateIfChanged(s.uDoubleSided, u.doubleSided), k.updateIfChanged(s.dIgnoreLight, u.ignoreLight), k.updateIfChanged(s.dXrayShaded, u.xrayShaded), k.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), k.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = u.boundingSphere.radius ? _f(s) * s.uSizeFactor.ref.value : 0, l = de.expand(de(), u.boundingSphere, c), d = Ir(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    de.equals(d, s.boundingSphere.ref.value) || k.update(s.boundingSphere, d), de.equals(l, s.invariantBoundingSphere.ref.value) || (k.update(s.invariantBoundingSphere, l), k.update(s.uInvariantBoundingSphere, vt.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), k.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = Ve.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
}(ro || (ro = {})), function(e) {
  var t = function() {
    function a() {
      this.index = 0, this.textures = [];
    }
    return a.prototype.get = function() {
      return this.textures[this.index];
    }, a.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;
    }, a.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();
      }
    }, a;
  }();
  function n(a, o, s, u, c, l, d) {
    var m = s.getWidth(), p = s.getHeight();
    return d ? (d.vertexCount = a, d.groupCount = o, k.update(d.geoTextureDim, ge.set(d.geoTextureDim.ref.value, m, p)), k.update(d.vertexTexture, s), k.update(d.groupTexture, u), k.update(d.normalTexture, c), d.doubleBuffer.set(s, u, c), de.copy(d.boundingSphere, l), d) : { kind: "texture-mesh", vertexCount: a, groupCount: o, geoTextureDim: k.create(ge.create(m, p)), vertexTexture: k.create(s), groupTexture: k.create(u), normalTexture: k.create(c), doubleBuffer: new t(), boundingSphere: de.clone(l), meta: {} };
  }
  function r(a) {
    return n(0, 0, a ? a.vertexTexture.ref.value : Ni(), a ? a.groupTexture.ref.value : Ni(), a ? a.normalTexture.ref.value : Ni(), a ? a.boundingSphere : de(), a);
  }
  function i(a, o, s, u, c) {
    var l = s.instanceCount, d = s.groupCount, m = ta(s, e.Utils.createPositionIterator(a, o), u.color), p = Da(l * d), v = ms(), f = ps(), y = vs(), h = hs(), g = { drawCount: a.vertexCount, vertexCount: a.vertexCount, groupCount: d, instanceCount: l }, x = de.clone(a.boundingSphere), C = Ir(x, o.aTransform.ref.value, l);
    return B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("textureMesh"), uGeoTexDim: a.geoTextureDim, tPosition: a.vertexTexture, tGroup: a.groupTexture, tNormal: a.normalTexture, boundingSphere: k.create(C), invariantBoundingSphere: k.create(x), uInvariantBoundingSphere: k.create(vt.ofSphere(x)) }, m), p), v), f), y), h), o), Ve.createValues(c, g)), { uDoubleSided: k.create(c.doubleSided), dFlatShaded: k.create(c.flatShaded), dFlipSided: k.create(c.flipSided), dIgnoreLight: k.create(c.ignoreLight), dXrayShaded: k.create(c.xrayShaded), uBumpFrequency: k.create(c.bumpFrequency), uBumpAmplitude: k.create(c.bumpAmplitude), meta: k.create(a.meta) });
  }
  e.DoubleBuffer = t, e.create = n, e.createEmpty = r, e.Params = B(B({}, Ve.Params), { doubleSided: N.Boolean(!1, Ve.CustomQualityParamInfo), flipSided: N.Boolean(!1, Ve.ShadingCategory), flatShaded: N.Boolean(!1, Ve.ShadingCategory), ignoreLight: N.Boolean(!1, Ve.ShadingCategory), xrayShaded: N.Boolean(!1, Ve.ShadingCategory), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), bumpAmplitude: N.Numeric(1, { min: 0, max: 5, step: 0.1 }, Ve.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: i, createValuesSimple: function(a, o, s, u, c) {
    var l = Ve.createSimple(s, u, c), d = B(B({}, N.getDefaultValues(e.Params)), o);
    return i(a, l.transform, l.locationIterator, l.theme, d);
  }, updateValues: function(a, o) {
    Ve.updateValues(a, o), k.updateIfChanged(a.uDoubleSided, o.doubleSided), k.updateIfChanged(a.dFlatShaded, o.flatShaded), k.updateIfChanged(a.dFlipSided, o.flipSided), k.updateIfChanged(a.dIgnoreLight, o.ignoreLight), k.updateIfChanged(a.dXrayShaded, o.xrayShaded), k.updateIfChanged(a.uBumpFrequency, o.bumpFrequency), k.updateIfChanged(a.uBumpAmplitude, o.bumpAmplitude);
  }, updateBoundingSphere: function(a, o) {
    var s = de.clone(o.boundingSphere), u = Ir(s, a.aTransform.ref.value, a.instanceCount.ref.value);
    de.equals(u, a.boundingSphere.ref.value) || k.update(a.boundingSphere, u), de.equals(s, a.invariantBoundingSphere.ref.value) || (k.update(a.invariantBoundingSphere, s), k.update(a.uInvariantBoundingSphere, vt.fromSphere(a.uInvariantBoundingSphere.ref.value, s)));
  }, createRenderableState: Ve.createRenderableState, updateRenderableState: Ve.updateRenderableState, createPositionIterator: function() {
    return Zn(1, 1, 1, function() {
      return No;
    });
  } };
}(Eu || (Eu = {}));
var Ko = { uModel: ce("m4"), uView: ce("m4"), uInvView: ce("m4"), uModelView: ce("m4"), uInvModelView: ce("m4"), uProjection: ce("m4"), uInvProjection: ce("m4"), uModelViewProjection: ce("m4"), uInvModelViewProjection: ce("m4"), uIsOrtho: ce("f"), uPixelRatio: ce("f"), uViewport: ce("v4"), uViewOffset: ce("v2"), uDrawingBufferSize: ce("v2"), uCameraPosition: ce("v3"), uCameraDir: ce("v3"), uNear: ce("f"), uFar: ce("f"), uFogNear: ce("f"), uFogFar: ce("f"), uFogColor: ce("v3"), uTransparentBackground: ce("b"), uLightDirection: ce("v3[]"), uLightColor: ce("v3[]"), uAmbientColor: ce("v3"), uPickingAlphaThreshold: ce("f"), uInteriorDarkening: ce("f"), uInteriorColorFlag: ce("b"), uInteriorColor: ce("v3"), uHighlightColor: ce("v3"), uSelectColor: ce("v3"), uHighlightStrength: ce("f"), uSelectStrength: ce("f"), uMarkerPriority: ce("i"), uXrayEdgeFalloff: ce("f"), uRenderWboit: ce("b"), uMarkingDepthTest: ce("b"), uMarkingType: ce("i"), uPickType: ce("i"), uInvalidColor: ce("v3"), uInvalidStrength: ce("f") }, Xo = { tDepth: pt("texture", "depth", "ushort", "nearest") }, Yo = { uObjectId: ce("i") }, YB = { uColor: ce("v3", "material"), uColorTexDim: ce("v2"), uColorGridDim: ce("v3"), uColorGridTransform: ce("v4"), tColor: pt("image-uint8", "rgb", "ubyte", "nearest"), tPalette: pt("image-uint8", "rgb", "ubyte", "nearest"), tColorGrid: pt("texture", "rgb", "ubyte", "linear"), dColorType: mt("string", ["uniform", "attribute", "instance", "group", "groupInstance", "vertex", "vertexInstance", "volume", "volumeInstance", "direct"]), dUsePalette: mt("boolean") }, Uf = { uSize: ce("f", "material"), uSizeTexDim: ce("v2"), tSize: pt("image-uint8", "rgb", "ubyte", "nearest"), dSizeType: mt("string", ["uniform", "attribute", "instance", "group", "groupInstance"]), uSizeFactor: ce("f") }, WB = { uMarker: ce("f"), uMarkerTexDim: ce("v2"), tMarker: pt("image-uint8", "alpha", "ubyte", "nearest"), markerAverage: tr("number"), markerStatus: tr("number") }, ZB = { uOverpaintTexDim: ce("v2"), tOverpaint: pt("image-uint8", "rgba", "ubyte", "nearest"), dOverpaint: mt("boolean"), uOverpaintGridDim: ce("v3"), uOverpaintGridTransform: ce("v4"), tOverpaintGrid: pt("texture", "rgba", "ubyte", "linear"), dOverpaintType: mt("string", ["groupInstance", "volumeInstance"]) }, QB = { uTransparencyTexDim: ce("v2"), tTransparency: pt("image-uint8", "alpha", "ubyte", "nearest"), dTransparency: mt("boolean"), transparencyAverage: tr("number"), uTransparencyGridDim: ce("v3"), uTransparencyGridTransform: ce("v4"), tTransparencyGrid: pt("texture", "alpha", "ubyte", "linear"), dTransparencyType: mt("string", ["groupInstance", "volumeInstance"]) }, JB = { uSubstanceTexDim: ce("v2"), tSubstance: pt("image-uint8", "rgba", "ubyte", "nearest"), dSubstance: mt("boolean"), uSubstanceGridDim: ce("v3"), uSubstanceGridTransform: ce("v4"), tSubstanceGrid: pt("texture", "rgba", "ubyte", "linear"), dSubstanceType: mt("string", ["groupInstance", "volumeInstance"]) }, $B = { uClippingTexDim: ce("v2"), tClipping: pt("image-uint8", "alpha", "ubyte", "nearest"), dClipping: mt("boolean") }, Ts = B(B(B(B(B(B(B({ dGeometryType: mt("string", ["cylinders", "directVolume", "image", "lines", "mesh", "points", "spheres", "text", "textureMesh"]) }, YB), WB), ZB), QB), JB), $B), { dLightCount: mt("number"), dClipObjectCount: mt("number"), dClipVariant: mt("string", ["instance", "pixel"]), uClipObjectType: ce("i[]"), uClipObjectInvert: ce("b[]"), uClipObjectPosition: ce("v3[]"), uClipObjectRotation: ce("v4[]"), uClipObjectScale: ce("v3[]"), aInstance: tn("float32", 1, 1), aTransform: tn("float32", 16, 1), uAlpha: ce("f", "material"), uMetalness: ce("f", "material"), uRoughness: ce("f", "material"), uBumpiness: ce("f", "material"), uVertexCount: ce("i"), uInstanceCount: ce("i"), uGroupCount: ce("i"), uInvariantBoundingSphere: ce("v4"), drawCount: tr("number"), instanceCount: tr("number"), alpha: tr("number"), matrix: tr("m4"), transform: tr("float32"), extraTransform: tr("float32"), hasReflection: tr("boolean"), boundingSphere: tr("sphere"), invariantBoundingSphere: tr("sphere") }), ci = `
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);
}
`, eR = fi(), Qg = Object.keys({ colorBlended: "", colorWboit: "", pick: "", depth: "", marking: "" }), O0 = Qg.filter(function(e) {
  return e !== "colorWboit";
}), tR = Qg.filter(function(e) {
  return e !== "colorBlended";
}), nR = Object.keys({ compute: "" });
function tb(e, t, n, r, i) {
  return n = B(B({}, n), { dRenderVariant: k.create(t) }), i.dRenderVariant === void 0 && Object.defineProperty(i, "dRenderVariant", { value: mt("string") }), e.resources.program(n, r, i);
}
function Wo(e, t, n, r, i, a, o) {
  return lx(e, t, n, r, i, a, o);
}
function xr(e, t, n, r, i, a) {
  return a === void 0 && (a = -1), lx(e, t, n, r, i, a, nR);
}
function lx(e, t, n, r, i, a, o) {
  var s = eR(), u = e.stats, c = e.state, l = e.resources, d = e.extensions, m = d.instancedArrays, p = d.vertexArrayObject;
  if (i.uVertexCount) {
    var v = i.uVertexCount.ref.value;
    i.aVertex = k.create(Oo(new Float32Array(v))), r.aVertex = tn("float32", 1, 0);
  }
  for (var f = function(te, ee) {
    var $ = {}, ue = {}, se = {}, be = {}, ke = {}, Oe = {};
    return Object.keys(te).forEach(function(ze) {
      var je = te[ze];
      je.type === "attribute" && ($[ze] = ee[ze]), je.type === "define" && (ue[ze] = ee[ze]), je.type === "texture" && ee[ze] !== void 0 && (se[ze] = ee[ze]), je.type === "uniform" && ee[ze] !== void 0 && (je.variant === "material" ? ke[ze] = ee[ze] : je.variant === "buffered" ? Oe[ze] = ee[ze] : be[ze] = ee[ze]);
    }), { attributeValues: $, defineValues: ue, textureValues: se, uniformValues: be, materialUniformValues: ke, bufferedUniformValues: Oe };
  }(r, i), y = f.attributeValues, h = f.defineValues, g = f.textureValues, x = f.uniformValues, C = f.materialUniformValues, b = f.bufferedUniformValues, _ = Object.entries(x), A = Object.entries(C), I = Object.entries(b), w = Object.entries(function(te) {
    var ee = {};
    return Object.keys(te).forEach(function($) {
      ee[$] = k.create(xs(te[$].ref.value));
    }), ee;
  }(b)), E = Object.entries(h), D = function(te) {
    var ee = {};
    return Object.keys(te).forEach(function($) {
      ee[$] = te[$].ref.version;
    }), ee;
  }(i), T = function(te, ee) {
    var $ = te.gl;
    switch (ee) {
      case "points":
        return $.POINTS;
      case "lines":
        return $.LINES;
      case "line-strip":
        return $.LINE_STRIP;
      case "line-loop":
        return $.LINE_LOOP;
      case "triangles":
        return $.TRIANGLES;
      case "triangle-strip":
        return $.TRIANGLE_STRIP;
      case "triangle-fan":
        return $.TRIANGLE_FAN;
    }
  }(e, t), P = {}, M = 0, R = o; M < R.length; M++) {
    var O = R[M];
    P[O] = tb(e, O, h, n, r);
  }
  var L, F = function(te, ee, $) {
    var ue = te.resources, se = [];
    return Object.keys(ee).forEach(function(be) {
      var ke = ee[be];
      if (ke.type === "texture") {
        var Oe = $[be];
        if (Oe) if (ke.kind === "texture") se[se.length] = [be, Oe.ref.value];
        else {
          var ze = ue.texture(ke.kind, ke.format, ke.dataType, ke.filter);
          ze.load(Oe.ref.value), se[se.length] = [be, ze];
        }
      }
    }), se;
  }(e, r, g), G = function(te, ee, $) {
    var ue = [];
    return Object.keys(ee).forEach(function(se) {
      var be = ee[se];
      be.type === "attribute" && (ue[ue.length] = [se, te.resources.attribute($[se].ref.value, be.itemSize, be.divisor)]);
    }), ue;
  }(e, r, y), V = i.elements;
  V && V.ref.value && (L = l.elements(V.ref.value));
  for (var U = {}, q = 0, H = o; q < H.length; q++)
    O = H[q], U[O] = p ? l.vertexArray(P[O], G, L) : null;
  var K = i.drawCount.ref.value, j = i.instanceCount.ref.value;
  u.drawCount += K, u.instanceCount += j, u.instancedDrawCount += j * K;
  var W = { attributes: !1, defines: !1, elements: !1, textures: !1 }, Z = !1, Y = -1;
  return { id: s, materialId: a, getProgram: function(te) {
    return P[te];
  }, render: function(te, ee) {
    if (K !== 0 && j !== 0 && !e.isContextLost) {
      var $ = P[te];
      if ($.id === Y && c.currentRenderItemId === s) $.setUniforms(_), ee && ee.length > 0 ? ($.bindTextures(ee, 0), $.bindTextures(F, ee.length)) : $.bindTextures(F, 0);
      else {
        var ue = U[te];
        $.id === c.currentProgramId && $.id === Y && a !== -1 && a === c.currentMaterialId || ($.id !== c.currentProgramId && $.use(), $.setUniforms(A), c.currentMaterialId = a, Y = $.id), $.setUniforms(_), $.setUniforms(w), ee && ee.length > 0 ? ($.bindTextures(ee, 0), $.bindTextures(F, ee.length)) : $.bindTextures(F, 0), ue ? (ue.bind(), L && L.bind()) : (L && L.bind(), $.bindAttributes(G)), c.currentRenderItemId = s;
      }
      if (Xt) try {
        Og(e.gl);
      } catch (se) {
        throw new Error("Framebuffer error rendering item id ".concat(s, ": '").concat(se, "'"));
      }
      if (L ? m.drawElementsInstanced(T, K, L._dataType, 0, j) : m.drawArraysInstanced(T, 0, K, j), Xt) try {
        K7(e.gl);
      } catch (se) {
        throw new Error("Draw error rendering item id ".concat(s, ": '").concat(se, "'"));
      }
    }
  }, update: function() {
    if (function(we) {
      we.attributes = !1, we.defines = !1, we.elements = !1, we.textures = !1;
    }(W), i.aVertex) {
      var te = i.uVertexCount.ref.value;
      i.aVertex.ref.value.length < te && k.update(i.aVertex, Oo(new Float32Array(te)));
    }
    for (var ee = 0, $ = E.length; ee < $; ++ee) {
      var ue = E[ee], se = ue[0];
      (le = ue[1]).ref.version !== D[se] && (W.defines = !0, D[se] = le.ref.version);
    }
    if (W.defines) for (var be = 0, ke = o; be < ke.length; be++)
      se = ke[be], P[se].destroy(), P[se] = tb(e, se, h, n, r);
    for (i.drawCount.ref.version !== D.drawCount && (u.drawCount += i.drawCount.ref.value - K, u.instancedDrawCount += j * i.drawCount.ref.value - j * K, K = i.drawCount.ref.value, D.drawCount = i.drawCount.ref.version), i.instanceCount.ref.version !== D.instanceCount && (u.instanceCount += i.instanceCount.ref.value - j, u.instancedDrawCount += i.instanceCount.ref.value * K - j * K, j = i.instanceCount.ref.value, D.instanceCount = i.instanceCount.ref.version), ee = 0, $ = G.length; ee < $; ++ee) {
      var Oe = G[ee], ze = (se = Oe[0], Oe[1]);
      if ((le = y[se]).ref.version !== D[se]) {
        if (ze.length >= le.ref.value.length) ze.updateSubData(le.ref.value, 0, ze.length);
        else {
          ze.destroy();
          var je = r[se], xe = je.itemSize, Xe = je.divisor;
          G[ee][1] = l.attribute(le.ref.value, xe, Xe), W.attributes = !0;
        }
        D[se] = le.ref.version;
      }
    }
    if (L && i.elements.ref.version !== D.elements && (L.length >= i.elements.ref.value.length ? L.updateSubData(i.elements.ref.value, 0, L.length) : (L.destroy(), L = l.elements(i.elements.ref.value), W.elements = !0), D.elements = i.elements.ref.version), W.attributes || W.defines || W.elements) for (var Ee = 0, Ye = o; Ee < Ye.length; Ee++) {
      se = Ye[Ee];
      var He = U[se];
      He && He.destroy(), U[se] = p ? l.vertexArray(P[se], G, L) : null;
    }
    for (ee = 0, $ = F.length; ee < $; ++ee) {
      var le, Ce = F[ee], Ae = (se = Ce[0], Ce[1]);
      (le = g[se]).ref.version !== D[se] && (r[se].kind !== "texture" ? (Ae.load(le.ref.value), W.textures = !0) : F[ee][1] = le.ref.value, D[se] = le.ref.version);
    }
    for (ee = 0, $ = I.length; ee < $; ++ee) {
      var Te = I[ee], Re = (se = Te[0], Te[1]);
      Re.ref.version !== D[se] && (k.update(w[ee][1], xs(Re.ref.value)), D[se] = Re.ref.version);
    }
    return W;
  }, destroy: function() {
    if (!Z) {
      for (var te = 0, ee = o; te < ee.length; te++) {
        var $ = ee[te];
        P[$].destroy();
        var ue = U[$];
        ue && ue.destroy();
      }
      F.forEach(function(se) {
        var be = se[0], ke = se[1];
        r[be].kind !== "texture" && ke.destroy();
      }), G.forEach(function(se) {
        return se[0], se[1].destroy();
      }), L && L.destroy(), u.drawCount -= K, u.instanceCount -= j, u.instancedDrawCount -= j * K, Z = !0;
    }
  } };
}
var dx = fi();
function Zo(e, t, n) {
  return { id: dx(), materialId: e.materialId, values: t, state: n, render: function(r, i) {
    t.uAlpha && t.alpha && k.updateIfChanged(t.uAlpha, xi(t.alpha.ref.value * n.alphaFactor, 0, 1)), e.render(r, i);
  }, getProgram: function(r) {
    return e.getProgram(r);
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
function Sr(e, t) {
  return { id: dx(), values: t, render: function() {
    return e.render("compute");
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
var fx = new Float32Array([1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1]), Mr = { drawCount: tr("number"), instanceCount: tr("number"), aPosition: tn("float32", 2, 0), uQuadScale: ce("v2") }, Er = { drawCount: k.create(6), instanceCount: k.create(1), aPosition: k.create(fx), uQuadScale: k.create(ge.create(1, 1)) }, rR = B(B({}, Mr), { tColor: pt("texture", "rgba", "ubyte", "nearest"), uTexSize: ce("v2") }), iR = Pn("copy", ci, `
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 pv(e, t) {
  var n = B(B({}, Er), { tColor: k.create(t), uTexSize: k.create(ge.create(t.getWidth(), t.getHeight())) }), r = B({}, rR);
  return Sr(xr(e, "triangles", iR, r, n), n);
}
var Jp, li, Ur, nb = new Uint32Array([0, 1, 2, 1, 3, 2]), aR = new Float32Array([0, 1, 0, 0, 1, 1, 1, 0]), mx = { nearest: "Nearest", catmulrom: "Catmulrom (Cubic)", mitchell: "Mitchell (Cubic)", bspline: "B-Spline (Cubic)" }, oR = Object.keys(mx);
(function(e) {
  function t(i, a, o, s) {
    return s ? function(u, c, l, d) {
      var m = u.width, p = u.height;
      return k.update(d.imageTexture, u), k.update(d.imageTextureDim, ge.set(d.imageTextureDim.ref.value, m, p)), k.update(d.cornerBuffer, c), k.update(d.groupTexture, l), d;
    }(i, a, o, s) : function(u, c, l) {
      var d = de(), m = -1, p = u.width, v = u.height, f = { kind: "image", imageTexture: k.create(u), imageTextureDim: k.create(ge.create(p, v)), cornerBuffer: k.create(c), groupTexture: k.create(l), get boundingSphere() {
        var y = function(g) {
          return di([g.cornerBuffer.ref.version]);
        }(f);
        if (y !== m) {
          var h = function(g) {
            for (var x = S(), C = [], b = 0, _ = g.length; b < _; b += 3) {
              var A = S.fromArray(S(), g, b);
              C.push(A), S.add(x, x, A);
            }
            S.scale(x, x, 1 / (g.length / 3));
            for (var I = 0, w = 0, E = C; w < E.length; w++) {
              A = E[w];
              var D = S.distance(x, A);
              D > I && (I = D);
            }
            var T = de.create(x, I);
            return de.setExtrema(T, C), T;
          }(f.cornerBuffer.ref.value);
          de.copy(d, h), m = y;
        }
        return d;
      } };
      return f;
    }(i, a, o);
  }
  function n(i) {
    return t(hr(0, 4, Uint8Array), i ? i.cornerBuffer.ref.value : new Float32Array(24), hr(0, 4, Uint8Array), i);
  }
  function r(i, a, o, s, u) {
    var c = o.instanceCount, l = o.groupCount, d = ta(o, e.Utils.createPositionIterator(i, a), s.color), m = Da(c * l), p = ms(), v = ps(), f = vs(), y = hs(), h = { drawCount: nb.length, vertexCount: fx.length / 3, groupCount: l, instanceCount: c }, g = de.clone(i.boundingSphere), x = Ir(g, a.aTransform.ref.value, c);
    return B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("image") }, d), m), p), v), f), y), a), Ve.createValues(u, h)), { aPosition: i.cornerBuffer, aUv: k.create(aR), elements: k.create(nb), aGroup: k.create(Oo(new Float32Array(4))), boundingSphere: k.create(x), invariantBoundingSphere: k.create(g), uInvariantBoundingSphere: k.create(vt.ofSphere(g)), dInterpolation: k.create(u.interpolation), uImageTexDim: i.imageTextureDim, tImageTex: i.imageTexture, tGroupTex: i.groupTexture });
  }
  e.create = t, e.createEmpty = n, e.Params = B(B({}, Ve.Params), { interpolation: N.Select("bspline", N.objectToOptions(mx)) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: r, createValuesSimple: function(i, a, o, s, u) {
    var c = Ve.createSimple(o, s, u), l = B(B({}, N.getDefaultValues(e.Params)), a);
    return r(i, c.transform, c.locationIterator, c.theme, l);
  }, updateValues: function(i, a) {
    Ve.updateValues(i, a), k.updateIfChanged(i.dInterpolation, a.interpolation);
  }, updateBoundingSphere: function(i, a) {
    var o = de.clone(a.boundingSphere), s = Ir(o, i.aTransform.ref.value, i.instanceCount.ref.value);
    de.equals(s, i.boundingSphere.ref.value) || k.update(i.boundingSphere, s), de.equals(o, i.invariantBoundingSphere.ref.value) || (k.update(i.invariantBoundingSphere, o), k.update(i.uInvariantBoundingSphere, vt.fromSphere(i.uInvariantBoundingSphere.ref.value, o)));
  }, createRenderableState: function(i) {
    var a = Ve.createRenderableState(i);
    return a.opaque = !1, a;
  }, updateRenderableState: function(i, a) {
    Ve.updateRenderableState(i, a), i.opaque = !1;
  }, createPositionIterator: function() {
    return Zn(1, 1, 1, function() {
      return No;
    });
  } };
})(Jp || (Jp = {})), function(e) {
  function t(s, u, c, l, d, m, p, v, f) {
    return f ? function(y, h, g, x, C, b, _, A, I) {
      return A > I.cylinderCount && (k.update(I.mappingBuffer, y), k.update(I.indexBuffer, h)), I.cylinderCount = A, k.update(I.groupBuffer, g), k.update(I.startBuffer, x), k.update(I.endBuffer, C), k.update(I.scaleBuffer, b), k.update(I.capBuffer, _), I;
    }(s, u, c, l, d, m, p, v, f) : function(y, h, g, x, C, b, _, A) {
      var I, w = de(), E = -1, D = -1, T = { kind: "cylinders", cylinderCount: A, mappingBuffer: k.create(y), indexBuffer: k.create(h), groupBuffer: k.create(g), startBuffer: k.create(x), endBuffer: k.create(C), scaleBuffer: k.create(b), capBuffer: k.create(_), get boundingSphere() {
        var P = r(T);
        if (P !== E) {
          var M = Pu(T.startBuffer.ref.value, 6 * T.cylinderCount, 6), R = Pu(T.endBuffer.ref.value, 6 * T.cylinderCount, 6);
          de.expandBySphere(w, M, R), E = P;
        }
        return w;
      }, get groupMapping() {
        return T.groupBuffer.ref.version !== D && (I = id(T.groupBuffer.ref.value, T.cylinderCount, 6), D = T.groupBuffer.ref.version), I;
      }, setBoundingSphere: function(P) {
        de.copy(w, P), E = r(T);
      } };
      return T;
    }(s, u, c, l, d, m, p, v);
  }
  function n(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 r(s) {
    return di([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 i(s, u) {
    var c = 6 * s.cylinderCount, l = u.instanceCount.ref.value, d = wc(), m = d.position, p = s.startBuffer.ref.value, v = s.endBuffer.ref.value, f = u.aTransform.ref.value;
    return Zn(c, l, 2, function(y, h) {
      var g = y % 6 == 0 ? p : v;
      return h < 0 ? S.fromArray(m, g, 3 * y) : S.transformMat4Offset(m, g, f, 0, 3 * y, 16 * h), d;
    });
  }
  function a(s, u, c, l, d) {
    var m = c.instanceCount, p = c.groupCount, v = ta(c, i(s, u), l.color), f = Es(c, l.size), y = Da(m * p), h = ms(), g = ps(), x = vs(), C = hs(), b = { drawCount: 4 * s.cylinderCount * 3, vertexCount: 6 * s.cylinderCount, groupCount: p, instanceCount: m }, _ = _f(f) * d.sizeFactor, A = de.clone(s.boundingSphere), I = Ir(A, u.aTransform.ref.value, m);
    return B(B(B(B(B(B(B(B(B(B(B({ dGeometryType: k.create("cylinders"), aMapping: s.mappingBuffer, aGroup: s.groupBuffer, aStart: s.startBuffer, aEnd: s.endBuffer, aScale: s.scaleBuffer, aCap: s.capBuffer, elements: s.indexBuffer, boundingSphere: k.create(I), invariantBoundingSphere: k.create(A), uInvariantBoundingSphere: k.create(vt.ofSphere(A)) }, v), f), y), h), g), x), C), u), { padding: k.create(_) }), Ve.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor * d.sizeAspectRatio), uDoubleSided: k.create(d.doubleSided), dIgnoreLight: k.create(d.ignoreLight), dXrayShaded: k.create(d.xrayShaded), uBumpFrequency: k.create(d.bumpFrequency), uBumpAmplitude: k.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    Ve.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  e.create = t, e.createEmpty = n, e.transform = function(s, u) {
    var c = s.startBuffer.ref.value;
    Ol(u, c, 0, 6 * s.cylinderCount), k.update(s.startBuffer, c);
    var l = s.endBuffer.ref.value;
    Ol(u, l, 0, 6 * s.cylinderCount), k.update(s.endBuffer, l);
  }, e.Params = B(B({}, Ve.Params), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), sizeAspectRatio: N.Numeric(1, { min: 0, max: 3, step: 0.01 }), doubleSided: N.Boolean(!1, Ve.CustomQualityParamInfo), ignoreLight: N.Boolean(!1, Ve.ShadingCategory), xrayShaded: N.Boolean(!1, Ve.ShadingCategory), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), bumpAmplitude: N.Numeric(1, { min: 0, max: 5, step: 0.1 }, Ve.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var m = Ve.createSimple(c, l, d), p = B(B({}, N.getDefaultValues(e.Params)), u);
    return a(s, m.transform, m.locationIterator, m.theme, p);
  }, updateValues: function(s, u) {
    Ve.updateValues(s, u), k.updateIfChanged(s.uSizeFactor, u.sizeFactor * u.sizeAspectRatio), k.updateIfChanged(s.uDoubleSided, u.doubleSided), k.updateIfChanged(s.dIgnoreLight, u.ignoreLight), k.updateIfChanged(s.dXrayShaded, u.xrayShaded), k.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), k.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = de.clone(u.boundingSphere), l = Ir(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    de.equals(l, s.boundingSphere.ref.value) || k.update(s.boundingSphere, l), de.equals(c, s.invariantBoundingSphere.ref.value) || (k.update(s.invariantBoundingSphere, c), k.update(s.uInvariantBoundingSphere, vt.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = Ve.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
}(li || (li = {})), function(e) {
  function t(n) {
    switch (n.kind) {
      case "mesh":
        return 3 * n.triangleCount;
      case "points":
        return n.pointCount;
      case "spheres":
        return 2 * n.sphereCount * 3;
      case "cylinders":
        return 4 * n.cylinderCount * 3;
      case "text":
        return 2 * n.charCount * 3;
      case "lines":
        return 2 * n.lineCount * 3;
      case "direct-volume":
        return 36;
      case "image":
        return 6;
      case "texture-mesh":
        return n.vertexCount;
    }
  }
  e.getDrawCount = t, e.getVertexCount = function(n) {
    switch (n.kind) {
      case "mesh":
      case "texture-mesh":
        return n.vertexCount;
      case "points":
        return n.pointCount;
      case "spheres":
        return 4 * n.sphereCount;
      case "cylinders":
        return 6 * n.cylinderCount;
      case "text":
        return 4 * n.charCount;
      case "lines":
        return 4 * n.lineCount;
      case "direct-volume":
        var r = n.gridDimension.ref.value;
        return r[0] * r[1] * r[2];
      case "image":
        return 4;
    }
  }, e.getGroupCount = function(n) {
    switch (n.kind) {
      case "mesh":
      case "points":
      case "spheres":
      case "cylinders":
      case "text":
      case "lines":
        return t(n) === 0 ? 0 : Nm(n.groupBuffer.ref.value) + 1;
      case "direct-volume":
        return 1;
      case "image":
        return Nm(n.groupTexture.ref.value.array) + 1;
      case "texture-mesh":
        return n.groupCount;
    }
  }, e.getUtils = function(n) {
    switch (n.kind) {
      case "mesh":
        return ht.Utils;
      case "points":
        return Pc.Utils;
      case "spheres":
        return ro.Utils;
      case "cylinders":
        return li.Utils;
      case "text":
        return na.Utils;
      case "lines":
        return Yt.Utils;
      case "direct-volume":
        return $m.Utils;
      case "image":
        return Jp.Utils;
      case "texture-mesh":
        return Eu.Utils;
    }
  }, e.getGranularity = function(n, r) {
    return r === "instance" && n.nonInstanceable ? "group" : r;
  };
}(Ur || (Ur = {}));
var sR = ye(13421772), rb = {};
function Jg(e, t) {
  return { factory: Jg, granularity: "groupInstance", color: function(n) {
    return _i.isLocation(n) ? n.shape.getColor(n.group, n.instance) : sR;
  }, props: t, description: "Assigns colors as defined by the shape object." };
}
var uR = { name: "shape-group", label: "Shape Group", category: "Miscellaneous", factory: Jg, getParams: function(e) {
  return rb;
}, defaultValues: N.getDefaultValues(rb), isApplicable: function(e) {
  return !!e.shape;
} }, cR = B(B({}, Ts), { aPosition: tn("float32", 3, 0), elements: Rc("uint32"), uBboxMin: ce("v3"), uBboxMax: ce("v3"), uBboxSize: ce("v3"), uMaxSteps: ce("i"), uStepScale: ce("f"), uJumpLength: ce("f"), uTransform: ce("m4"), uGridDim: ce("v3"), tTransferTex: pt("image-uint8", "alpha", "ubyte", "linear"), uTransferScale: ce("f"), dGridTexType: mt("string", ["2d", "3d"]), uGridTexDim: ce("v3"), tGridTex: pt("texture", "rgba", "ubyte", "linear"), uGridStats: ce("v4"), uCellDim: ce("v3"), uCartnToUnit: ce("m4"), uUnitToCartn: ce("m4"), dPackedGroup: mt("boolean"), dAxisOrder: mt("string", ["012", "021", "102", "120", "201", "210"]), dIgnoreLight: mt("boolean"), dXrayShaded: mt("boolean") }), lR = B(B({}, Ts), { aGroup: tn("float32", 1, 0), aPosition: tn("float32", 3, 0), aNormal: tn("float32", 3, 0), elements: Rc("uint32"), dFlatShaded: mt("boolean"), uDoubleSided: ce("b"), dFlipSided: mt("boolean"), dIgnoreLight: mt("boolean"), dXrayShaded: mt("boolean"), uBumpFrequency: ce("f"), uBumpAmplitude: ce("f"), meta: tr("unknown") }), dR = B(B(B({}, Ts), Uf), { aGroup: tn("float32", 1, 0), aPosition: tn("float32", 3, 0), dPointSizeAttenuation: mt("boolean"), dPointStyle: mt("string", ["square", "circle", "fuzzy"]) }), fR = B(B(B({}, Ts), Uf), { aGroup: tn("float32", 1, 0), aMapping: tn("float32", 2, 0), aStart: tn("float32", 3, 0), aEnd: tn("float32", 3, 0), elements: Rc("uint32"), dLineSizeAttenuation: mt("boolean"), uDoubleSided: ce("b"), dFlipSided: mt("boolean") }), mR = B(B(B({}, Ts), Uf), { aGroup: tn("float32", 1, 0), aPosition: tn("float32", 3, 0), aMapping: tn("float32", 2, 0), elements: Rc("uint32"), padding: tr("number"), uDoubleSided: ce("b"), dIgnoreLight: mt("boolean"), dXrayShaded: mt("boolean"), uBumpFrequency: ce("f"), uBumpAmplitude: ce("f") }), pR = B(B(B({}, Ts), Uf), { aGroup: tn("float32", 1, 0), aPosition: tn("float32", 3, 0), aMapping: tn("float32", 2, 0), aDepth: tn("float32", 1, 0), elements: Rc("uint32"), aTexCoord: tn("float32", 2, 0), tFont: pt("image-uint8", "alpha", "ubyte", "linear"), padding: tr("number"), uBorderWidth: ce("f"), uBorderColor: ce("v3"), uOffsetX: ce("f"), uOffsetY: ce("f"), uOffsetZ: ce("f"), uBackgroundColor: ce("v3"), uBackgroundOpacity: ce("f") }), hR = B(B({}, Ts), { uGeoTexDim: ce("v2", "buffered"), tPosition: pt("texture", "rgb", "float", "nearest"), tGroup: pt("texture", "alpha", "float", "nearest"), tNormal: pt("texture", "rgb", "float", "nearest"), dFlatShaded: mt("boolean"), uDoubleSided: ce("b"), dFlipSided: mt("boolean"), dIgnoreLight: mt("boolean"), dXrayShaded: mt("boolean"), uBumpFrequency: ce("f"), uBumpAmplitude: ce("f"), meta: tr("unknown") }), vR = B(B({}, Ts), { aGroup: tn("float32", 1, 0), aPosition: tn("float32", 3, 0), aUv: tn("float32", 2, 0), elements: Rc("uint32"), uImageTexDim: ce("v2"), tImageTex: pt("image-uint8", "rgba", "ubyte", "nearest"), tGroupTex: pt("image-uint8", "rgba", "ubyte", "nearest"), dInterpolation: mt("string", oR) }), gR = B(B(B({}, Ts), Uf), { aGroup: tn("float32", 1, 0), aStart: tn("float32", 3, 0), aEnd: tn("float32", 3, 0), aMapping: tn("float32", 3, 0), aScale: tn("float32", 1, 0), aCap: tn("float32", 1, 0), elements: Rc("uint32"), padding: tr("number"), uDoubleSided: ce("b"), dIgnoreLight: mt("boolean"), dXrayShaded: mt("boolean"), uBumpFrequency: ce("f"), uBumpAmplitude: ce("f") }), Ct, _i, yR = fi(0, 2147483647), Ms = fi(0, 2147483647);
function ad(e, t, n, r) {
  return { id: yR(), type: e, values: t, state: n, materialId: r };
}
function bR(e, t, n) {
  switch (t.type) {
    case "mesh":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), lR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", Yy, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "points":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), dR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "points", EE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "spheres":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), mR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", TE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "cylinders":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), gR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", ME, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "text":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), pR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", DE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "lines":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), fR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", BE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "direct-volume":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), cR);
        r.isWebGL2 || (c.uMaxSteps = mt("number"));
        var l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", RE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "image":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), vR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", kE, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
    case "texture-mesh":
      return function(r, i, a, o, s, u) {
        var c = B(B(B(B({}, Ko), Xo), Yo), hR), l = { uObjectId: k.create(i) };
        return Zo(Wo(r, "triangles", Yy, c, B(B({}, a), l), s, u), a, o);
      }(e, t.id, t.values, t.state, t.materialId, n);
  }
  throw new Error("unsupported type");
}
(function(e) {
  function t(n) {
    var r = n.transforms.length, i = _i.Location(n);
    return Zn(n.groupCount, r, 1, function(a, o) {
      return i.group = a, i.instance = o, i;
    });
  }
  e.create = function(n, r, i, a, o, s, u) {
    return { id: vr.create22(), name: n, sourceData: r, geometry: i, transforms: u || [J.identity()], get groupCount() {
      return Ur.getGroupCount(i);
    }, getColor: a, getSize: o, getLabel: s };
  }, e.getTheme = function(n) {
    return { color: Jg(0, {}), size: $g({ shape: n }, {}) };
  }, e.groupIterator = t, e.createTransform = function(n, r) {
    for (var i = r && r.aTransform.ref.value.length >= 16 * n.length ? r.aTransform.ref.value : new Float32Array(16 * n.length), a = 0, o = n.length; a < o; ++a) J.toArray(n[a], i, 16 * a);
    return Xg(i, n.length, r);
  }, e.createRenderObject = function(n, r) {
    var i = e.getTheme(n), a = Ur.getUtils(n.geometry), o = Ms(), s = t(n), u = e.createTransform(n.transforms), c = a.createValues(n.geometry, u, s, i, r), l = a.createRenderableState(r);
    return ad(n.geometry.kind, c, l, o);
  }, e.Loci = function(n) {
    return { kind: "shape-loci", shape: n };
  }, e.isLoci = function(n) {
    return !!n && n.kind === "shape-loci";
  }, e.areLociEqual = function(n, r) {
    return n.shape === r.shape;
  }, e.isLociEmpty = function(n) {
    return n.shape.groupCount === 0;
  };
})(Ct || (Ct = {})), function(e) {
  function t(o) {
    for (var s = 0, u = 0, c = o.groups; u < c.length; u++) {
      var l = c[u];
      s += ve.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, m = l.instance, p = s.groups[u], v = p.ids;
      if (m !== p.instance || !ve.areEqual(d, v)) return !1;
    }
    return !0;
  }, e.isLociEmpty = function(o) {
    return t(o) === 0;
  }, e.size = t;
  var n = new Ml(), r = S.zero();
  function i(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, m = function(y, h) {
      ve.forEach(y, function(g) {
        for (var x = d[g], C = d[g + 1]; x < C; ++x) S.fromArray(r, u, 3 * l[x]), S.transformMat4(r, r, c[h]), n.includeStep(r);
      });
    }, p = 0, v = o; p < v.length; p++) {
      var f = v[p];
      m(f.ids, f.instance);
    }
  }
  function a(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, m = function(y, h) {
      ve.forEach(y, function(g) {
        for (var x = d[g], C = d[g + 1]; x < C; ++x) S.fromArray(r, u, 3 * l[x]), S.transformMat4(r, r, c[h]), n.radiusStep(r);
      });
    }, p = 0, v = o; p < v.length; p++) {
      var f = v[p];
      m(f.ids, f.instance);
    }
  }
  e.getBoundingSphere = function(o, s) {
    s || (s = de()), n.reset();
    var u = 0, c = o.shape, l = c.geometry, d = c.transforms;
    if (l.kind === "mesh" || l.kind === "points") {
      var m = l.kind === "mesh" ? l.vertexBuffer.ref.value : l.centerBuffer.ref.value;
      i(o.groups, l.groupMapping, m, d), n.finishedIncludeStep(), a(o.groups, l.groupMapping, m, d);
    } else if (l.kind === "lines") {
      var p = l.startBuffer.ref.value, v = l.endBuffer.ref.value;
      i(o.groups, l.groupMapping, p, d), i(o.groups, l.groupMapping, v, d), n.finishedIncludeStep(), a(o.groups, l.groupMapping, p, d), a(o.groups, l.groupMapping, v, d);
    } else {
      if (l.kind !== "spheres" && l.kind !== "text") return de.copy(s, l.boundingSphere);
      m = l.centerBuffer.ref.value, i(o.groups, l.groupMapping, m, d), n.finishedIncludeStep(), a(o.groups, l.groupMapping, m, d);
      for (var f = function(x, C) {
        ve.forEach(x, function(b) {
          var _ = o.shape.getSize(b, C);
          u < _ && (u = _);
        });
      }, y = 0, h = o.groups; y < h.length; y++) {
        var g = h[y];
        f(g.ids, g.instance);
      }
    }
    return S.copy(s.center, n.center), s.radius = Math.sqrt(n.radiusSq), de.expand(s, s, u), s;
  };
}(_i || (_i = {}));
var _R = 1, xR = "Assigns sizes as defined by the shape object.", ib = {};
function $g(e, t) {
  return { factory: $g, granularity: "groupInstance", size: function(n) {
    return _i.isLocation(n) ? n.shape.getSize(n.group, n.instance) : _R;
  }, props: t, description: xR };
}
var SR = { name: "shape-group", label: "Shape Group", category: "", factory: $g, getParams: function(e) {
  return ib;
}, defaultValues: N.getDefaultValues(ib), isApplicable: function(e) {
  return !!e.shape;
} }, ab = { bfactorFactor: N.Numeric(0.1, { min: 0, max: 1, step: 0.01 }), rmsfFactor: N.Numeric(0.05, { min: 0, max: 1, step: 0.01 }), baseSize: N.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) };
function ob(e, t, n) {
  return me.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) * n.bfactorFactor : me.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] * n.rmsfFactor : 0;
}
var CR = { name: "uncertainty", label: "Uncertainty/Disorder", category: "", factory: function e(t, n) {
  return { factory: e, granularity: "group", size: function(r) {
    var i = n.baseSize;
    return Ne.is(r) ? i += ob(r.unit, r.element, n) : rt.isLocation(r) && (i += ob(r.aUnit, r.aUnit.elements[r.aIndex], n)), i;
  }, props: n, 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 ab;
}, defaultValues: N.getDefaultValues(ab), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, sb = { hydrogenSize: N.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), oxygenSize: N.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), baseSize: N.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) }, Ai, Ba, AR = { name: "aquasite", label: "Aquasite", category: "", factory: function e(t, n) {
  return { factory: e, granularity: "group", size: function(r) {
    var i = n.baseSize;
    return Ne.is(r) && (i += function(a, o, s) {
      if (me.isAtomic(a)) {
        var u = a.model.atomicHierarchy.atoms.type_symbol.value(o).toUpperCase();
        return u === "H" ? s.hydrogenSize : u === "O" ? s.oxygenSize : 0;
      }
      return 0;
    }(r.unit, r.element, n)), i;
  }, props: n, description: "Aquasite" };
}, getParams: function(e) {
  return sb;
}, defaultValues: N.getDefaultValues(sb), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} };
function ub(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, n) {
    return t.factory === n.factory && Iu(t.props, n.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new px(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { physical: RB, "shape-group": SR, uncertainty: CR, uniform: BB, aquasite: AR };
})(Ai || (Ai = {})), function(e) {
  function t() {
    return { color: Cs.Empty, size: Ai.Empty };
  }
  e.create = function(n, r, i, a) {
    a = a || t();
    var o = i.colorTheme, s = i.sizeTheme;
    return a.color = n.colorThemeRegistry.create(o.name, r, o.params), a.size = n.sizeThemeRegistry.create(s.name, r, s.params), a;
  }, e.createEmpty = t, e.ensureDependencies = function(n, r, i, a) {
    var o, s;
    return ie(this, 0, void 0, function() {
      return ne(this, function(u) {
        switch (u.label) {
          case 0:
            return [4, (o = r.colorThemeRegistry.get(a.colorTheme.name).ensureCustomProperties) === null || o === void 0 ? void 0 : o.attach(n, i)];
          case 1:
            return u.sent(), [4, (s = r.sizeThemeRegistry.get(a.sizeTheme.name).ensureCustomProperties) === null || s === void 0 ? void 0 : s.attach(n, i)];
          case 2:
            return u.sent(), [2];
        }
      });
    });
  }, e.releaseDependencies = function(n, r, i) {
    var a, o;
    (a = n.colorThemeRegistry.get(i.colorTheme.name).ensureCustomProperties) === null || a === void 0 || a.detach(r), (o = n.sizeThemeRegistry.get(i.sizeTheme.name).ensureCustomProperties) === null || o === void 0 || o.detach(r);
  };
}(Ba || (Ba = {}));
var px = function() {
  function e(t, n) {
    var r = this;
    this.emptyProvider = n, this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map(), w7(t, function(i, a) {
      if (i.name !== a) throw new Error("Fix build in themes to have matching names. ".concat(i.name, " ").concat(a));
      r.add(i);
    });
  }
  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 ub(this._list);
  }, enumerable: !1, configurable: !0 }), e.prototype.sort = function() {
    this._list.sort(function(t, n) {
      return t.provider.category === n.provider.category ? t.provider.label < n.provider.label ? -1 : t.provider.label > n.provider.label ? 1 : 0 : t.provider.category < n.provider.category ? -1 : 1;
    });
  }, e.prototype.add = function(t) {
    if (this._map.has(t.name)) throw new Error("".concat(t.name, " already registered."));
    var n = t.name;
    this._list.push({ name: n, provider: t }), this._map.set(n, t), this._name.set(t, n), this.sort();
  }, e.prototype.remove = function(t) {
    this._list.splice(this._list.findIndex(function(r) {
      return r.name === t.name;
    }), 1);
    var n = this._map.get(t.name);
    n && (this._map.delete(t.name), this._name.delete(n));
  }, 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, n, r) {
    r === void 0 && (r = {});
    var i = this.get(t);
    return i.factory(n, B(B({}, N.getDefaultValues(i.getParams(n))), r));
  }, e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(n) {
      return n.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return ub(this.getApplicableList(t));
  }, e;
}(), hx = { hue: N.Interval([1, 360], { min: 0, max: 360, step: 1 }), chroma: N.Interval([40, 70], { min: 0, max: 100, step: 1 }), luminance: N.Interval([15, 85], { min: 0, max: 100, step: 1 }), clusteringStepCount: N.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }), minSampleCount: N.Numeric(800, { min: 100, max: 5e3, step: 100 }, { isHidden: !0 }) };
function cb(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 Zc = 2, Fu = [0, 0, 0], Gu = [0, 0, 0];
function IR(e, t) {
  return Or.toHcl(Fu, e), Or.fromColor(Gu, Or.toColor(e)), Fu[0] >= t.hue[0] && Fu[0] <= t.hue[1] && Fu[1] >= t.chroma[0] && Fu[1] <= t.chroma[1] && Fu[2] >= t.luminance[0] && Fu[2] <= t.luminance[1] && Gu[0] >= e[0] - Zc && Gu[0] <= e[0] + Zc && Gu[1] >= e[1] - Zc && Gu[1] <= e[1] + Zc && Gu[2] >= e[2] - Zc && Gu[2] <= e[2] + Zc;
}
function wR(e, t) {
  t === void 0 && (t = {});
  var n = B(B({}, N.getDefaultValues(hx)), t);
  if (e <= 0) return [];
  var r = function(E, D) {
    for (var T = /* @__PURE__ */ new Map(), P = 1.001 * Math.cbrt(E), M = (D.hue[1] - D.hue[0]) / P, R = (D.chroma[1] - D.chroma[0]) / P, O = (D.luminance[1] - D.luminance[0]) / P, L = D.hue[0]; L <= D.hue[1]; L += M) for (var F = D.chroma[0]; F <= D.chroma[1]; F += R) for (var G = D.luminance[0]; G <= D.luminance[1]; G += O) {
      var V = Or.fromHcl(Or(), _o.create(L, F, G));
      IR(V, D) && T.set(V.toString(), V);
    }
    return Array.from(T.values());
  }(Math.max(n.minSampleCount, 5 * e), n);
  if (r.length < e) throw new Error("Not enough samples to generate distinct colors, increase sample count.");
  for (var i = [], a = [], o = Math.floor(r.length / e), s = 0; s < r.length && (i.push(r[s]), a.push([]), !(i.length >= e)); s += o) ;
  for (var u = 1; u <= n.clusteringStepCount; ++u) {
    var c = xs(a);
    for (s = 0; s < r.length; ++s) {
      for (var l = Number.MAX_SAFE_INTEGER, d = 0, m = 0; m < i.length; m++) {
        var p = cb(r[s], i[m]);
        p < l && (l = p, d = m);
      }
      c[d].push(r[s]);
    }
    var v = xs(i);
    for (s = 0; s < c.length; ++s) {
      for (var f = c[s], y = f.length, h = [], g = [], x = [], C = 0, b = f; C < b.length; C++) {
        var _ = b[C];
        h.push(_[0]), g.push(_[1]), x.push(_[2]);
      }
      var A = vm(h) / y, I = vm(g) / y, w = vm(x) / y;
      i[s] = [A, I, w];
    }
    if (Iu(v, i)) break;
  }
  return function(E) {
    for (var D = E.slice(0), T = [D.shift()]; D.length > 0; ) {
      for (var P = T[T.length - 1], M = 0, R = Number.MIN_SAFE_INTEGER, O = 0; O < D.length; ++O) {
        var L = cb(P, D[O]);
        L > R && (R = L, M = O);
      }
      T.push(D.splice(M, 1)[0]);
    }
    return T;
  }(i).map(function(E) {
    return Or.toColor(E);
  });
}
var vx = { type: "generate", colorList: "red-yellow-blue" };
function aa(e) {
  e === void 0 && (e = {});
  var t = B(B({}, vx), e);
  return { palette: N.MappedStatic(t.type, { colors: N.Group({ list: N.ColorList(t.colorList) }, { isFlat: !0 }), generate: N.Group(B(B({}, hx), { maxCount: N.Numeric(75, { min: 1, max: 250, step: 1 }) }), { isFlat: !0 }) }, { options: [["colors", "Color List"], ["generate", "Generate Distinct"]] }) };
}
N.getDefaultValues(aa());
var lb = { valueLabel: function(e) {
  return "".concat(e + 1);
}, minLabel: "Start", maxLabel: "End" };
function ao(e, t, n) {
  var r, i, a;
  if (n === void 0 && (n = {}), t.palette.name === "colors" && t.palette.params.list.kind === "interpolate") {
    var o = t.palette.params.list, s = [0, e - 1], u = B(B({}, lb), n), c = u.minLabel, l = u.maxLabel, d = o.colors;
    d.length === 0 && (d = bs(vx.colorList).list);
    var m = ko.create({ listOrName: d, domain: s, minLabel: c, maxLabel: l });
    a = m.legend, i = m.color;
  } else {
    var p;
    t.palette.name === "colors" ? (p = t.palette.params.list.colors.map(function(x) {
      return Array.isArray(x) ? x[0] : x;
    }), p.length === 0 && (p = bs("dark-2").list.map(function(x) {
      return Array.isArray(x) ? x[0] : x;
    }))) : (e = Math.min(e, t.palette.params.maxCount), p = wR(e, t.palette.params));
    for (var v = (r = n.valueLabel) !== null && r !== void 0 ? r : lb.valueLabel, f = p.length, y = [], h = 0; h < e; ++h) {
      var g = h % f;
      y[g] === void 0 ? y[g] = [v(h), p[g]] : y[g][0] += ", ".concat(v(h));
    }
    a = io(y), i = function(x) {
      return p[x % f];
    };
  }
  return { color: i, legend: a };
}
var db = ye(16448250), PR = "Gives every chain a color based on its `asym_id` value.", Ec = B({ asymId: N.Select("auth", N.arrayToOptions(["auth", "label"])) }, aa({ type: "colors", colorList: "many-distinct" }));
function fb(e, t) {
  var n = function(r, i) {
    switch (r.kind) {
      case 0:
        return i === "auth" ? Me.chain.auth_asym_id : Me.chain.label_asym_id;
      case 1:
      case 2:
        return Me.coarse.asym_id;
    }
  }(e.unit, t)(e);
  return e.structure.root.models.length > 1 ? gx(e.unit.model, n) : n;
}
function gx(e, t) {
  return "".concat(t, "|").concat((pn.Index.get(e).value || 0) + 1);
}
function N0(e, t) {
  var n, r;
  if (e.structure) {
    var i = Ne.create(e.structure.root), a = function(u, c) {
      for (var l = /* @__PURE__ */ new Map(), d = function(v) {
        var f = pn.AsymIdOffset.get(v).value, y = (c === "auth" ? f == null ? void 0 : f.auth : f == null ? void 0 : f.label) || 0, h = 0;
        v.properties.structAsymMap.forEach(function(g, x) {
          var C = g.auth_id, b = c === "auth" ? C : x, _ = u.models.length > 1 ? gx(v, b) : b;
          l.has(_) || (l.set(_, h + y), ++h);
        });
      }, m = 0, p = u.models; m < p.length; m++) d(p[m]);
      return l;
    }(e.structure.root, t.asymId), o = Array.from(a.keys()), s = ao(a.size, t, { valueLabel: function(u) {
      return o[u];
    } });
    r = s.legend, n = function(u) {
      var c = void 0;
      if (Ne.is(u)) {
        var l = fb(u, t.asymId);
        c = a.get(l);
      } else rt.isLocation(u) && (i.unit = u.aUnit, i.element = u.aUnit.elements[u.aIndex], l = fb(i, t.asymId), c = a.get(l));
      return c === void 0 ? db : s.color(c);
    };
  } else n = function() {
    return db;
  };
  return { factory: N0, granularity: "group", color: n, props: t, description: PR, legend: r };
}
var ER = { name: "chain-id", label: "Chain Id", category: "Chain Property", factory: N0, getParams: function(e) {
  var t, n = N.clone(Ec);
  return !((t = e.structure) === null || t === void 0) && t.models.some(function(r) {
    return r.coarseHierarchy.isDefined;
  }) && (n.asymId.defaultValue = "label"), n;
}, defaultValues: N.getDefaultValues(Ec), isApplicable: function(e) {
  return !!e.structure;
} }, mb = ye(13421772), pb = B({}, aa({ type: "colors", colorList: "red-yellow-blue" })), TR = { name: "element-index", label: "Element Index", category: "Atom Property", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    for (var a = t.structure.root.units, o = a.length, s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = 0, l = 0; l < o; ++l) s.set(l, c), c += a[l].elements.length, u.set(a[l].id, l);
    var d = ao(c, n);
    i = d.legend, r = function(m) {
      if (Ne.is(m)) {
        var p = u.get(m.unit.id), v = ve.findPredecessorIndex(a[p].elements, m.element);
        return d.color(s.get(p) + v);
      }
      return rt.isLocation(m) ? (p = u.get(m.aUnit.id), v = ve.findPredecessorIndex(a[p].elements, m.aUnit.elements[m.aIndex]), d.color(s.get(p) + v)) : mb;
    };
  } else r = function() {
    return mb;
  };
  return { factory: e, granularity: "groupInstance", preferSmoothing: !0, color: r, props: n, 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: i };
}, getParams: function(e) {
  return pb;
}, defaultValues: N.getDefaultValues(pb), isApplicable: function(e) {
  return !!e.structure;
} };
function od(e) {
  var t = {};
  return w7(e, function(n, r) {
    t[r] = N.Color(e[r]);
  }), t;
}
var hb = ye(13421772), MR = "Assigns a color based on the operator name of a transformed chain.", Ll = B({}, aa({ type: "colors", colorList: "many-distinct" }));
function e3(e, t) {
  var n, r;
  if (e.structure) {
    var i = 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), a = Array.from(i.keys()), o = ao(i.size, t, { valueLabel: function(s) {
      return a[s];
    } });
    r = o.legend, n = function(s) {
      var u = void 0;
      if (Ne.is(s)) {
        var c = s.unit.conformation.operator.name;
        u = i.get(c);
      } else if (rt.isLocation(s)) {
        var l = s.aUnit.conformation.operator.name;
        u = i.get(l);
      }
      return u === void 0 ? hb : o.color(u);
    };
  } else n = function() {
    return hb;
  };
  return { factory: e3, granularity: "instance", color: n, props: t, description: MR, legend: r };
}
var DR = { name: "operator-name", label: "Operator Name", category: "Symmetry", factory: e3, getParams: function(e) {
  return N.clone(Ll);
}, defaultValues: N.getDefaultValues(Ll), isApplicable: function(e) {
  return !!e.structure;
} }, vb = ye(16448250), BR = "Gives every chain a color based on its `label_entity_id` value.", Fl = B({}, aa({ type: "colors", colorList: "many-distinct" }));
function fd(e, t) {
  return "".concat(e, "|").concat(t);
}
function gb(e) {
  switch (e.unit.kind) {
    case 0:
      return Me.chain.label_entity_id(e);
    case 1:
    case 2:
      return Me.coarse.entity_id(e);
  }
}
function L0(e, t) {
  var n, r;
  if (e.structure) {
    var i = Ne.create(e.structure.root), a = function(u) {
      for (var c = /* @__PURE__ */ new Map(), l = 0, d = u.models.length; l < d; ++l) {
        for (var m = u.models[l].atomicHierarchy.chains.label_entity_id, p = 0, v = m.rowCount; p < v; ++p) {
          var f = fd(m.value(p), l);
          c.has(f) || c.set(f, c.size);
        }
        var y = u.models[l].coarseHierarchy;
        if (y.isDefined) {
          var h = y.spheres.entity_id;
          for (p = 0, v = h.rowCount; p < v; ++p) f = fd(h.value(p), l), c.has(f) || c.set(f, c.size);
          var g = y.gaussians.entity_id;
          for (p = 0, v = g.rowCount; p < v; ++p) f = fd(g.value(p), l), c.has(f) || c.set(f, c.size);
        }
      }
      return c;
    }(e.structure.root), o = Array.from(a.keys()), s = ao(a.size, t, { valueLabel: function(u) {
      return o[u];
    } });
    r = s.legend, n = function(u) {
      var c = void 0;
      if (Ne.is(u)) {
        var l = fd(gb(u), u.structure.models.indexOf(u.unit.model));
        c = a.get(l);
      } else rt.isLocation(u) && (i.unit = u.aUnit, i.element = u.aUnit.elements[u.aIndex], l = fd(gb(i), i.structure.models.indexOf(i.unit.model)), c = a.get(l));
      return c === void 0 ? vb : s.color(c);
    };
  } else n = function() {
    return vb;
  };
  return { factory: L0, granularity: "group", color: n, props: t, description: BR, legend: r };
}
var RR = { name: "entity-id", label: "Entity Id", category: "Chain Property", factory: L0, getParams: function(e) {
  return N.clone(Fl);
}, defaultValues: N.getDefaultValues(Fl), isApplicable: function(e) {
  return !!e.structure;
} }, hv = "dark-2", I1 = ye(16448250), kR = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).", Gl = B({}, aa({ type: "colors", colorList: hv }));
function yx(e, t) {
  return "".concat(e, "|").concat(t);
}
function OR(e, t, n, r, i, a) {
  return "".concat(e, "|").concat(t, "|").concat(n, "|").concat(a || i || r);
}
function $p(e, t, n, r, i, a, o, s) {
  for (var u = i.entity_id, c = i.pdbx_src_id, l = i.pdbx_beg_seq_num, d = i.pdbx_end_seq_num, m = 0, p = i._rowCount; m < p; ++m) {
    var v = u.value(m), f = yx(n, v), y = void 0;
    if (e.has(f)) y = e.get(f);
    else {
      var h = r.entities.getEntityIndex(v), g = r.sequence.sequences[h].sequence;
      y = new Int16Array(g.length), e.set(f, y);
    }
    var x = o ? o.value(m) : "", C = s ? s.value(m)[0] : "", b = OR(n, v, a.value(m), c.value(m), x, C), _ = l.valueKind(m) === 0 ? l.value(m) : 1, A = d.valueKind(m) === 0 ? d.value(m) : y.length, I = void 0;
    t.has(b) ? I = t.get(b) : (I = t.size + 1, t.set(b, I));
    for (var w = _, E = A; w <= E; ++w) y[w - 1] = I;
  }
}
function bx(e) {
  for (var t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = 0, i = e.length; r < i; ++r) {
    var a = e[r];
    if (_n.is(a.sourceData)) {
      var o = a.sourceData.data.db, s = o.entity_src_gen, u = o.entity_src_nat, c = o.pdbx_entity_src_syn;
      $p(t, n, r, a, s, s.pdbx_gene_src_scientific_name, s.plasmid_name, s.pdbx_gene_src_gene), $p(t, n, r, a, u, u.pdbx_organism_scientific, u.pdbx_plasmid_name), $p(t, n, r, a, c, c.organism_scientific);
    }
  }
  return { seqToSrcByModelEntity: t, srcKeySerialMap: n };
}
function NR(e) {
  var t = 0;
  return Array.from(e.keys()).map(function(n) {
    var r = n.split("|"), i = r[2], a = function(o) {
      o = o.trim();
      var s = parseInt(o, 10);
      return !isNaN(s) && s.toString() === o;
    }(r[3]) ? "Unnamed ".concat(++t) : r[3];
    return "".concat(a).concat(i ? " (".concat(i, ")") : "");
  });
}
function F0(e, t) {
  var n, r;
  if (e.structure) {
    var i = Ne.create(e.structure), a = e.structure.root.models, o = bx(a), s = o.seqToSrcByModelEntity, u = o.srcKeySerialMap, c = NR(u), l = ao(u.size, t, { valueLabel: function(m) {
      return c[m];
    } });
    r = l.legend;
    var d = function(m) {
      var p = yx(a.indexOf(m.unit.model), Me.entity.id(m)), v = s.get(p);
      if (v) {
        var f = v[Me.residue.label_seq_id(m) - 1] - 1;
        return f === -1 ? I1 : l.color(f);
      }
      return I1;
    };
    n = function(m) {
      return Ne.is(m) ? d(m) : rt.isLocation(m) ? (i.unit = m.aUnit, i.element = m.aUnit.elements[m.aIndex], d(i)) : I1;
    };
  } else n = function() {
    return I1;
  };
  return { factory: F0, granularity: "group", color: n, props: t, description: kR, legend: r };
}
var LR = { name: "entity-source", label: "Entity Source", category: "Chain Property", factory: F0, getParams: function(e) {
  var t = N.clone(Gl);
  return e.structure && bx(e.structure.root.models).srcKeySerialMap.size > Fi[hv].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = B(B({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: bs(hv).list } })), t;
}, defaultValues: N.getDefaultValues(Gl), isApplicable: function(e) {
  return !!e.structure;
} }, _x = { 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 }, xx = ye(16777215), Sx = { carbonColor: N.MappedStatic("chain-id", { "chain-id": N.Group(Ec), "entity-id": N.Group(Fl), "entity-source": N.Group(Gl), "operator-name": N.Group(Ll), "element-symbol": N.EmptyGroup(), uniform: N.Group(Jm) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(_x)) }) };
function FR(e) {
  return Sx;
}
function GR(e, t) {
  var n = e[t];
  return n === void 0 ? xx : n;
}
function Cx(e, t) {
  var n = Dc(t.colors.name === "default" ? _x : t.colors.params, t.saturation, t.lightness), r = t.carbonColor, i = r.name === "chain-id" ? N0(e, r.params).color : r.name === "entity-id" ? L0(e, r.params).color : r.name === "entity-source" ? F0(e, r.params).color : r.name === "operator-name" ? e3(e, r.params).color : r.name === "element-symbol" ? void 0 : r.name === "uniform" ? Vf(0, r.params).color : Tr();
  function a(o, s) {
    return i && o === "C" ? i(s, !1) : GR(n, o);
  }
  return { factory: Cx, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(o) {
    if (Ne.is(o)) {
      if (me.isAtomic(o.unit)) return a(o.unit.model.atomicHierarchy.atoms.type_symbol.value(o.element), o);
    } else if (rt.isLocation(o) && me.isAtomic(o.aUnit))
      return a(o.aUnit.model.atomicHierarchy.atoms.type_symbol.value(o.aUnit.elements[o.aIndex]), o);
    return xx;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: io(Object.keys(n).map(function(o) {
    return [o, n[o]];
  })) };
}
var VR = { name: "element-symbol", label: "Element Symbol", category: "Atom Property", factory: Cx, getParams: FR, defaultValues: N.getDefaultValues(Sx), isApplicable: function(e) {
  return !!e.structure;
} }, Ax = { water: 3697840, ion: 15729279, protein: 12496596, RNA: 16629894, DNA: 12540695, PNA: 4367514, saccharide: 8374655 }, vv = ye(16777113), zR = "Assigns a color based on the molecule type of a residue.", gv = { saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(Ax)) }) };
function yb(e, t, n) {
  switch (I9(t, n)) {
    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 vv;
}
function t3(e, t) {
  var n = Dc(t.colors.name === "default" ? Ax : t.colors.params, t.saturation, t.lightness);
  return { factory: t3, granularity: "group", color: function(r) {
    return Ne.is(r) ? yb(n, r.unit, r.element) : rt.isLocation(r) ? yb(n, r.aUnit, r.aUnit.elements[r.aIndex]) : vv;
  }, props: t, description: zR, legend: io(Object.keys(n).map(function(r) {
    return [r, n[r]];
  }).concat([["Other/unknown", vv]])) };
}
var UR = { name: "molecule-type", label: "Molecule Type", category: "Residue Property", factory: t3, getParams: function(e) {
  return gv;
}, defaultValues: N.getDefaultValues(gv), isApplicable: function(e) {
  return !!e.structure;
} }, yv = "dark-2", bb = ye(16448250), _b = B({}, aa({ type: "colors", colorList: yv }));
function xb(e) {
  switch (e.kind) {
    case 0:
      return Me.chain.label_asym_id;
    case 1:
    case 2:
      return Me.coarse.asym_id;
  }
}
function Sb(e) {
  for (var t = /* @__PURE__ */ new Map(), n = 0, r = e.unitSymmetryGroups.length; n < r; ++n) {
    var i = e.unitSymmetryGroups[n].units[0], a = i.model;
    if (me.isAtomic(i)) for (var o = a.atomicHierarchy, s = o.chainAtomSegments, u = o.chains, c = St.transientSegments(s, i.elements); c.hasNext; ) {
      var l = c.move().index, d = u.label_entity_id.value(l), m = a.entities.getEntityIndex(d);
      if (a.entities.data.type.value(m) === "polymer") {
        var p = u.label_asym_id.value(l);
        t.has(p) || t.set(p, t.size);
      }
    }
    else if (me.isCoarse(i)) {
      var v = me.isSpheres(i) ? a.coarseHierarchy.spheres : a.coarseHierarchy.gaussians, f = v.chainElementSegments, y = v.asym_id, h = v.entity_id;
      for (c = St.transientSegments(f, i.elements); c.hasNext; ) {
        l = c.move().index;
        var g = f.offsets[l];
        d = h.value(g), m = a.entities.getEntityIndex(d), a.entities.data.type.value(m) === "polymer" && (p = y.value(g), t.has(p) || t.set(p, t.size));
      }
    }
  }
  return t;
}
var HR = { name: "polymer-id", label: "Polymer Chain Id", category: "Chain Property", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    var a = Ne.create(t.structure), o = Sb(t.structure.root), s = Array.from(o.keys()), u = ao(o.size, n, { valueLabel: function(c) {
      return s[c];
    } });
    i = u.legend, r = function(c) {
      var l = void 0;
      if (Ne.is(c)) {
        var d = xb(c.unit);
        l = o.get(d(c));
      } else rt.isLocation(c) && (d = xb(c.aUnit), a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], l = o.get(d(a)));
      return l === void 0 ? bb : u.color(l);
    };
  } else r = function() {
    return bb;
  };
  return { factory: e, granularity: "group", color: r, props: n, description: "Gives every polymer chain a color based on its `asym_id` value.", legend: i };
}, getParams: function(e) {
  var t = N.clone(_b);
  return e.structure && Sb(e.structure.root).size > Fi[yv].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = B(B({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: bs(yv).list } })), t;
}, defaultValues: N.getDefaultValues(_b), isApplicable: function(e) {
  return !!e.structure;
} }, bv = "dark-2", Cb = ye(13421772), Ab = B({}, aa({ type: "colors", colorList: bv }));
function Ib(e) {
  for (var t = 0, n = e.units, r = 0, i = n.length; r < i; ++r) n[r].polymerElements.length > 0 && ++t;
  return t;
}
var qR = { name: "polymer-index", label: "Polymer Chain Instance", category: "Chain Property", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    var a = ao(Ib(t.structure.root), n);
    i = a.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, a.color(c)), ++c);
    r = function(d) {
      var m;
      return Ne.is(d) ? m = s.get(d.unit.id) : rt.isLocation(d) && (m = s.get(d.aUnit.id)), m !== void 0 ? m : Cb;
    };
  } else r = function() {
    return Cb;
  };
  return { factory: e, granularity: "instance", color: r, props: n, 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: i };
}, getParams: function(e) {
  var t = N.clone(Ab);
  return e.structure && Ib(e.structure.root) > Fi[bv].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = B(B({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: bs(bv).list } })), t;
}, defaultValues: N.getDefaultValues(Ab), isApplicable: function(e) {
  return !!e.structure;
} }, Ix = { 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 }, _v = ye(16711935), wb = { saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(1, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(Ix)) }) };
function Pb(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function Eb(e, t) {
  var n = e.coarseElements.seq_id_begin.value(t);
  if (n === e.coarseElements.seq_id_end.value(t)) {
    var r = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[r].sequence.compId.value(n - 1);
  }
}
function w1(e, t) {
  var n = e[t];
  return n === void 0 ? _v : n;
}
var jR = { name: "residue-name", label: "Residue Name", category: "Residue Property", factory: function e(t, n) {
  var r = Dc(n.colors.name === "default" ? Ix : n.colors.params, n.saturation, n.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (Ne.is(i)) {
      if (me.isAtomic(i.unit)) {
        var a = Pb(i.unit, i.element);
        return w1(r, a);
      }
      if (a = Eb(i.unit, i.element)) return w1(r, a);
    } else if (rt.isLocation(i)) {
      if (me.isAtomic(i.aUnit))
        return a = Pb(i.aUnit, i.aUnit.elements[i.aIndex]), w1(r, a);
      if (a = Eb(i.aUnit, i.aUnit.elements[i.aIndex])) return w1(r, a);
    }
    return _v;
  }, props: n, description: "Assigns a color to every residue according to its name.", legend: io(Object.keys(r).map(function(i) {
    return [i, r[i]];
  }).concat([["Unknown", _v]])) };
}, getParams: function(e) {
  return wb;
}, defaultValues: N.getDefaultValues(wb), isApplicable: function(e) {
  return !!e.structure;
} }, wx = { alphaHelix: 16711808, threeTenHelix: 10485888, piHelix: 6291584, betaTurn: 6324479, betaStrand: 16762880, coil: 16777215, bend: 6740169, turn: 45670, dna: 11403518, rna: 16580962, carbohydrate: 10921722 }, xv = ye(8421504), Tb = { saturation: N.Numeric(-1, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(wx)) }) };
function Mb(e, t, n, r) {
  var i = Ft.create(0);
  if (r && me.isAtomic(t)) {
    var a = r.get(t.invariantId);
    a && (i = a.type[a.getIndex(t.residueIndex[n])]);
  }
  if (Ft.is(i, 2)) return Ft.is(i, 2048) ? e.threeTenHelix : Ft.is(i, 32768) ? e.piHelix : e.alphaHelix;
  if (Ft.is(i, 4)) return e.betaStrand;
  if (Ft.is(i, 8)) return e.bend;
  if (Ft.is(i, 16)) return e.turn;
  var o = I9(t, n);
  return o === 7 ? e.dna : o === 6 ? e.rna : o === 9 ? e.carbohydrate : o === 5 ? e.coil : xv;
}
var KR = { name: "secondary-structure", label: "Secondary Structure", category: "Residue Property", factory: function e(t, n) {
  var r = t.structure && ei.get(t.structure), i = r ? $l(r.id, r.version) : -1, a = Dc(n.colors.name === "default" ? wx : n.colors.params, n.saturation, n.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(o) {
    return Ne.is(o) ? Mb(a, o.unit, o.element, r == null ? void 0 : r.value) : rt.isLocation(o) ? Mb(a, o.aUnit, o.aUnit.elements[o.aIndex], r == null ? void 0 : r.value) : xv;
  }, props: n, contextHash: i, description: "Assigns a color based on the type of secondary structure and basic molecule type.", legend: io(Object.keys(a).map(function(o) {
    return [o, a[o]];
  }).concat([["Other", xv]])) };
}, getParams: function(e) {
  return Tb;
}, defaultValues: N.getDefaultValues(Tb), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? ei.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && ei.ref(e.structure, !1);
} } }, XR = ye(13421772), Db = { list: N.ColorList("turbo", { presetKind: "scale" }) };
function Bb(e, t) {
  var n = e.model;
  switch (e.kind) {
    case 0:
      var r = n.atomicHierarchy.residueAtomSegments.index[t];
      return n.atomicHierarchy.residues.label_seq_id.value(r);
    case 1:
      return Math.round((n.coarseHierarchy.spheres.seq_id_begin.value(t) + n.coarseHierarchy.spheres.seq_id_end.value(t)) / 2);
    case 2:
      return Math.round((n.coarseHierarchy.gaussians.seq_id_begin.value(t) + n.coarseHierarchy.gaussians.seq_id_end.value(t)) / 2);
  }
}
function Rb(e, t) {
  var n = e.model, r = "";
  switch (e.kind) {
    case 0:
      var i = n.atomicHierarchy.chainAtomSegments.index[t];
      r = n.atomicHierarchy.chains.label_entity_id.value(i);
      break;
    case 1:
      r = n.coarseHierarchy.spheres.entity_id.value(t);
      break;
    case 2:
      r = n.coarseHierarchy.gaussians.entity_id.value(t);
  }
  if (r === "") return 0;
  var a = n.entities.getEntityIndex(r);
  if (a === -1) return 0;
  var o = n.sequence.byEntityKey[a];
  return o === void 0 ? 0 : o.sequence.length;
}
var YR = { name: "sequence-id", label: "Sequence Id", category: "Residue Property", factory: function e(t, n) {
  var r = ko.create({ listOrName: n.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (Ne.is(i)) {
      var a = i.unit, o = i.element;
      if ((s = Bb(a, o)) > 0 && (u = Rb(a, o))) return r.setDomain(0, u - 1), r.color(s);
    } else if (rt.isLocation(i)) {
      var s, u, c = i.aUnit, l = i.aIndex;
      if ((s = Bb(c, c.elements[l])) > 0 && (u = Rb(c, c.elements[l]))) return r.setDomain(0, u - 1), r.color(s);
    }
    return XR;
  }, props: n, description: "Gives every polymer residue a color based on its `seq_id` value.", legend: r ? r.legend : void 0 };
}, getParams: function(e) {
  return Db;
}, defaultValues: N.getDefaultValues(Db), isApplicable: function(e) {
  return !!e.structure;
} }, Sv = "dark-2", kb = ye(13421772), Ob = B({}, aa({ type: "colors", colorList: Sv })), WR = { name: "unit-index", label: "Chain Instance", category: "Chain Property", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    var a = t.structure.root.units, o = ao(a.length, n);
    i = o.legend;
    for (var s = /* @__PURE__ */ new Map(), u = 0, c = a.length; u < c; ++u) s.set(a[u].id, o.color(u));
    r = function(l) {
      return Ne.is(l) ? s.get(l.unit.id) : rt.isLocation(l) ? s.get(l.aUnit.id) : kb;
    };
  } else r = function() {
    return kb;
  };
  return { factory: e, granularity: "instance", color: r, props: n, 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: i };
}, getParams: function(e) {
  var t = N.clone(Ob);
  return e.structure && e.structure.root.units.length > Fi[Sv].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = B(B({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: bs(Sv).list } })), t;
}, defaultValues: N.getDefaultValues(Ob), isApplicable: function(e) {
  return !!e.structure;
} }, ZR = ye(16777113), Nb = { domain: N.Interval([0, 100]), list: N.ColorList("red-white-blue", { presetKind: "scale" }) };
function Lb(e, t) {
  return me.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) : me.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] : 0;
}
var QR = { name: "uncertainty", label: "Uncertainty/Disorder", category: "Atom Property", factory: function e(t, n) {
  var r = ko.create({ reverse: !0, domain: n.domain, listOrName: n.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    return Ne.is(i) ? r.color(Lb(i.unit, i.element)) : rt.isLocation(i) ? r.color(Lb(i.aUnit, i.aUnit.elements[i.aIndex])) : ZR;
  }, props: n, 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: r ? r.legend : void 0 };
}, getParams: function(e) {
  return Nb;
}, defaultValues: N.getDefaultValues(Nb), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, JR = ye(15658734), Fb = { style: N.MappedStatic("entity-id", { uniform: N.Group(Jm), "chain-id": N.Group(Ec), "entity-id": N.Group(Fl), "entity-source": N.Group(Gl), "molecule-type": N.Group(gv) }), carbonLightness: N.Numeric(0.8, { min: -6, max: 6, step: 0.1 }) }, $R = { name: "illustrative", label: "Illustrative", category: "Miscellaneous", factory: function e(t, n) {
  var r = n.style.name === "uniform" ? Vf(0, n.style.params) : n.style.name === "chain-id" ? N0(t, n.style.params) : n.style.name === "entity-id" ? L0(t, n.style.params) : n.style.name === "entity-source" ? F0(t, n.style.params) : n.style.name === "molecule-type" ? t3(0, n.style.params) : Tr(n.style), i = r.color, a = r.legend;
  function o(s, u) {
    var c = i(s, !1);
    return u === "C" ? ye.lighten(c, n.carbonLightness) : c;
  }
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(s) {
    if (Ne.is(s) && me.isAtomic(s.unit)) {
      var u = s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);
      return o(s, u);
    }
    if (rt.isLocation(s) && me.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 JR;
  }, props: n, 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: a };
}, getParams: function(e) {
  return N.clone(Fb);
}, defaultValues: N.getDefaultValues(Fb), isApplicable: function(e) {
  return !!e.structure;
} }, Gb = { list: N.ColorList("red-yellow-green", { presetKind: "scale" }), scale: N.Select("DGwif", [["DGwif", "DG water-membrane"], ["DGwoct", "DG water-octanol"], ["Oct-IF", "DG difference"]]) }, ek = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
function Vb(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function zb(e, t) {
  var n = e.coarseElements.seq_id_begin.value(t);
  if (n === e.coarseElements.seq_id_end.value(t)) {
    var r = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[r].sequence.compId.value(n - 1);
  }
}
var tk = { name: "hydrophobicity", label: "Hydrophobicity", category: "Residue Property", factory: function e(t, n) {
  var r = ek[n.scale], i = 1 / 0, a = -1 / 0;
  for (var o in yp) {
    var s = yp[o][r];
    i = Math.min(i, s), a = Math.max(a, s);
  }
  var u = ko.create({ listOrName: n.list.colors, domain: [a, i], minLabel: "Hydrophilic", maxLabel: "Hydrophobic" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(c) {
    var l;
    return Ne.is(c) ? l = me.isAtomic(c.unit) ? Vb(c.unit, c.element) : zb(c.unit, c.element) : rt.isLocation(c) && (l = me.isAtomic(c.aUnit) ? Vb(c.aUnit, c.aUnit.elements[c.aIndex]) : zb(c.aUnit, c.aUnit.elements[c.aIndex])), u.color(l ? function(d, m) {
      var p = yp[d];
      return p === void 0 ? 0 : p[m];
    }(l, r) : 0);
  }, props: n, 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 Gb;
}, defaultValues: N.getDefaultValues(Gb), isApplicable: function(e) {
  return !!e.structure;
} }, Ub = ye(13421772), Hb = B({}, aa({ type: "colors", colorList: "purples" })), nk = { name: "model-index", label: "Model Index", category: "Chain Property", factory: function e(t, n) {
  var r, i, a, 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, ((r = pn.TrajectoryInfo.get(d)) === null || r === void 0 ? void 0 : r.size) || 0);
    }
    var m = ao(u, n);
    o = m.legend;
    for (var p = /* @__PURE__ */ new Map(), v = 0, f = s.length; v < f; ++v) {
      var y = ((i = pn.TrajectoryInfo.get(s[v])) === null || i === void 0 ? void 0 : i.index) || 0;
      p.set(y, m.color(y));
    }
    a = function(h) {
      return Ne.is(h) ? p.get(pn.TrajectoryInfo.get(h.unit.model).index) : rt.isLocation(h) ? p.get(pn.TrajectoryInfo.get(h.aUnit.model).index) : Ub;
    };
  } else a = function() {
    return Ub;
  };
  return { factory: e, granularity: "instance", color: a, props: n, 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 Hb;
}, defaultValues: N.getDefaultValues(Hb), isApplicable: function(e) {
  return !!e.structure && e.structure.elementCount > 0 && pn.TrajectoryInfo.get(e.structure.models[0]).size > 1;
} }, rk = ye(13421772), qb = { domain: N.Interval([0, 1]), list: N.ColorList("purples", { presetKind: "scale" }) };
function jb(e, t) {
  return me.isAtomic(e) ? e.model.atomicConformation.occupancy.value(t) : 0;
}
var ik = { name: "occupancy", label: "Occupancy", category: "Atom Property", factory: function e(t, n) {
  var r = ko.create({ reverse: !1, domain: n.domain, listOrName: n.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    return Ne.is(i) ? r.color(jb(i.unit, i.element)) : rt.isLocation(i) ? r.color(jb(i.aUnit, i.aUnit.elements[i.aIndex])) : rk;
  }, props: n, description: "Assigns a color based on the occupancy of an atom.", legend: r ? r.legend : void 0 };
}, getParams: function(e) {
  return qb;
}, defaultValues: N.getDefaultValues(qb), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.occupancy.isDefined;
  });
} }, Cv = "dark-2", Kb = ye(13421772), Xb = B({}, aa({ type: "colors", colorList: Cv })), Hd = 1e4;
function Av(e) {
  return e.map(function(t) {
    return "".concat(t + Hd).padStart(5, "0");
  }).join("");
}
function Iv(e) {
  var t = function(a, o) {
    return Math.abs(a) < o ? 0 : Math.floor(Math.log10(Math.abs(a))) + 1;
  }(Hd, 0), n = parseInt(e.substr(0, t)), r = parseInt(e.substr(t, t)), i = parseInt(e.substr(t + t, t));
  return [n - Hd, r - Hd, i - Hd];
}
function eh(e) {
  return e.map(function(t) {
    return t + 5;
  }).join("");
}
function Yb(e) {
  for (var t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = 0, i = e.units.length; r < i; ++r) {
    var a = Av(e.units[r].conformation.operator.hkl);
    n.add(a);
  }
  var o = Array.from(n.values()).sort();
  return o.forEach(function(s) {
    return t.set(s, t.size);
  }), { min: Iv(o[0]), max: Iv(o[o.length - 1]), map: t };
}
var Ss, ak = { name: "operator-hkl", label: "Operator HKL", category: "Symmetry", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    var a = Yb(t.structure.root), o = a.min, s = a.max, u = a.map, c = [];
    u.forEach(function(m, p) {
      var v = m % u.size, f = eh(Iv(p));
      c[v] === void 0 ? c[v] = f : c[v] += ", ".concat(f);
    });
    var l = { minLabel: eh(o), maxLabel: eh(s), valueLabel: function(m) {
      return c[m];
    } }, d = ao(u.size, n, l);
    i = d.legend, r = function(m) {
      var p = void 0;
      if (Ne.is(m)) {
        var v = Av(m.unit.conformation.operator.hkl);
        p = u.get(v);
      } else rt.isLocation(m) && (v = Av(m.aUnit.conformation.operator.hkl), p = u.get(v));
      return p === void 0 ? Kb : d.color(p);
    };
  } else r = function() {
    return Kb;
  };
  return { factory: e, granularity: "instance", color: r, props: n, description: "Assigns a color based on the operator HKL value of a transformed chain.", legend: i };
}, getParams: function(e) {
  var t = N.clone(Xb);
  return e.structure && Yb(e.structure.root).map.size > Fi[Cv].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = B(B({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: bs(Cv).list } })), t;
}, defaultValues: N.getDefaultValues(Xb), isApplicable: function(e) {
  return !!e.structure;
} };
(function(e) {
  e.Descriptor = { name: "atom_partial_charge" }, e.Provider = Mo.create(e.Descriptor);
})(Ss || (Ss = {}));
var th = ye(16777113), Wb = { domain: N.Interval([-1, 1]), list: N.ColorList("red-white-blue", { presetKind: "scale" }) };
function Zb(e, t) {
  var n;
  return (n = Ss.Provider.get(e.model)) === null || n === void 0 ? void 0 : n.data.value(t);
}
var ok = { name: "partial-charge", label: "Partial Charge", category: "Atom Property", factory: function e(t, n) {
  var r = ko.create({ domain: n.domain, listOrName: n.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    var a;
    return Ne.is(i) ? (a = Zb(i.unit, i.element)) === void 0 || Number.isNaN(a) ? th : r.color(a) : rt.isLocation(i) ? (a = Zb(i.aUnit, i.aUnit.elements[i.aIndex])) === void 0 || Number.isNaN(a) ? th : r.color(a) : th;
  }, props: n, description: "Assigns a color based on the partial charge of an atom.", legend: r ? r.legend : void 0 };
}, getParams: function(e) {
  return Wb;
}, defaultValues: N.getDefaultValues(Wb), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return Ss.Provider.get(t) !== void 0;
  });
} }, Qb = ye(16448250), Jb = B({}, aa({ type: "colors", colorList: "many-distinct" })), sk = { name: "atom-id", label: "Atom Id", category: "Atom Property", factory: function e(t, n) {
  var r, i;
  if (t.structure) {
    var a = Ne.create(t.structure.root), o = function(c) {
      for (var l = /* @__PURE__ */ new Map(), d = 0, m = c.models; d < m.length; d++) for (var p = m[d].atomicHierarchy.atoms.label_atom_id, v = 0, f = p.rowCount; v < f; ++v) {
        var y = p.value(v);
        l.has(y) || l.set(y, l.size);
      }
      return l;
    }(t.structure.root), s = Array.from(o.keys()), u = ao(o.size, n, { valueLabel: function(c) {
      return s[c];
    } });
    i = u.legend, r = function(c) {
      var l = void 0;
      if (Ne.is(c)) {
        var d = Me.atom.label_atom_id(c);
        l = o.get(d);
      } else rt.isLocation(c) && (a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], d = Me.atom.label_atom_id(a), l = o.get(d));
      return l === void 0 ? Qb : u.color(l);
    };
  } else r = function() {
    return Qb;
  };
  return { factory: e, granularity: "group", preferSmoothing: !0, color: r, props: n, description: "Gives every atom a color based on its `label_atom_id` value.", legend: i };
}, getParams: function(e) {
  return N.clone(Jb);
}, defaultValues: N.getDefaultValues(Jb), isApplicable: function(e) {
  return !!e.structure;
} }, uk = ye(13421772), $b = { colorList: N.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 }) }, ck = { name: "volume-value", label: "Volume Value", category: "Miscellaneous", factory: function e(t, n) {
  for (var r = ko.create({ domain: [0, 1], listOrName: n.colorList.colors }), i = [], a = 0; a < 256; ++a) i[a] = r.color(a / 255);
  var o = { colors: i, filter: "linear" };
  return { factory: e, granularity: "direct", color: function() {
    return uk;
  }, props: n, description: "Assign color based on the given value of a volume cell.", legend: r.legend, palette: o };
}, getParams: function(e) {
  return $b;
}, defaultValues: N.getDefaultValues($b), isApplicable: function(e) {
  return !!e.volume;
} }, lk = ye(13421772), e6 = { list: N.ColorList("turbo", { presetKind: "scale" }) }, dk = { name: "uni-fold", label: "Uni-Fold", category: "Residue Property", factory: function e(t, n) {
  var r = ko.create({ listOrName: n.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", color: function(i) {
    if (Ne.is(i)) {
      if (me.isAtomic(i.unit)) {
        if ((a = i.unit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.element)) >= 90) return ye.fromRgb(148, 164, 239);
        if (a < 90 && a >= 70) return ye.fromRgb(148, 225, 239);
        if (a < 70 && a >= 50) return ye.fromRgb(240, 193, 145);
        if (a < 50) return ye.fromRgb(239, 156, 156);
      }
    } else if (rt.isLocation(i) && me.isAtomic(i.aUnit)) {
      var a;
      if ((a = i.aUnit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.aUnit.elements[i.aIndex])) >= 90) return ye.fromRgb(148, 164, 239);
      if (a < 90 && a >= 70) return ye.fromRgb(148, 225, 239);
      if (a < 70 && a >= 50) return ye.fromRgb(240, 193, 145);
      if (a < 50) return ye.fromRgb(239, 156, 156);
    }
    return lk;
  }, props: n, description: "Fold", legend: r ? r.legend : void 0 };
}, getParams: function(e) {
  return e6;
}, defaultValues: N.getDefaultValues(e6), isApplicable: function(e) {
  return !!e.structure;
} }, Px = { 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 }, fk = ye(16777215), t6 = { carbonColor: N.MappedStatic("chain-id", { "chain-id": N.Group(Ec), "entity-id": N.Group(Fl), "entity-source": N.Group(Gl), "operator-name": N.Group(Ll), "element-symbol": N.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(Px)) }) }, mk = { name: "cdr", label: "CDR", category: "Atom Property", factory: function e(t, n) {
  var r = Dc(n.colors.name === "default" ? Px : n.colors.params, n.saturation, n.lightness);
  return { factory: e, granularity: n.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (Ne.is(i)) {
      if (me.isAtomic(i.unit)) {
        var a = i.unit.model.atomicHierarchy.atoms.cdr, o = i.unit.model.atomicHierarchy.chains.auth_asym_id, s = a.value(i.element), u = o.value(i.unit.chainIndex[i.element]);
        return s !== 0 ? s === 3 && u.toLocaleUpperCase() === "H" ? ye.fromRgb(252, 180, 91) : ye.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? ye.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? ye.fromRgb(148, 223, 247) : ye(16777215);
      }
    } else if (rt.isLocation(i) && me.isAtomic(i.aUnit))
      return a = i.aUnit.model.atomicHierarchy.atoms.cdr, o = i.aUnit.model.atomicHierarchy.chains.auth_asym_id, s = a.value(i.aUnit.elements[i.aIndex]), u = o.value(i.aUnit.chainIndex[i.aIndex]), s !== 0 ? s === 3 && u.toLocaleUpperCase() === "H" ? ye.fromRgb(252, 180, 91) : ye.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? ye.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? ye.fromRgb(148, 223, 247) : ye(16777215);
    return fk;
  }, props: n, description: "CDR", legend: io(Object.keys(r).map(function(i) {
    return [i, r[i]];
  })) };
}, getParams: function(e) {
  return t6;
}, defaultValues: N.getDefaultValues(t6), isApplicable: function(e) {
  return !!e.structure;
} }, n6 = ye(16448250), r6 = B({ themes: N.Value([]) }, aa({ type: "colors", colorList: "many-distinct" })), pk = { name: "multi-theme", label: "Multi Theme", category: "Atom Property", factory: function e(t, n) {
  var r, i = n.themes;
  return r = t.structure ? function(a, o) {
    if (Ne.is(a)) for (var s = 0; s < i.length; s++) {
      var u = i[s];
      if ((c = Ci.toStructure(u.bundle, t.structure)).hasElement(a)) return u.colorTheme.color(a, o);
    }
    else if (rt.isLocation(a) && me.isAtomic(a.aUnit)) for (s = 0; s < i.length; s++) {
      u = i[s];
      var c = Ci.toStructure(u.bundle, t.structure), l = Ne.create(a.aStructure, a.aUnit, a.aUnit.elements[a.aIndex]);
      if (c.hasElement(l)) return u.colorTheme.color(a, o);
    }
    return n6;
  } : function() {
    return n6;
  }, { factory: e, granularity: "group", preferSmoothing: !0, color: r, props: n, description: "Structure allows multi theme based on location" };
}, getParams: function(e) {
  return N.clone(r6);
}, defaultValues: N.getDefaultValues(r6), isApplicable: function(e) {
  return !!e.structure;
} }, Ex = { 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 }, hk = ye(16777215), i6 = { carbonColor: N.MappedStatic("chain-id", { "chain-id": N.Group(Ec), "entity-id": N.Group(Fl), "entity-source": N.Group(Gl), "operator-name": N.Group(Ll), "element-symbol": N.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: N.MappedStatic("default", { default: N.EmptyGroup(), custom: N.Group(od(Ex)) }) }, vk = { name: "em-confidence", label: "EM Confidence", category: "Residue Property", factory: function e(t, n) {
  var r = Dc(n.colors.name === "default" ? Ex : n.colors.params, n.saturation, n.lightness);
  return { factory: e, granularity: n.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (Ne.is(i)) {
      if (me.isAtomic(i.unit)) {
        var a = i.unit.model.atomicHierarchy.atoms.em_confidence;
        switch (!0) {
          case (o = parseFloat(a.value(i.element))) < -1:
            return ye.fromRgb(239, 139, 139);
          case (o >= -1 && o < -0.8):
            return ye.fromRgb(239, 151, 139);
          case (o >= -0.8 && o < -0.6):
            return ye.fromRgb(239, 167, 138);
          case (o >= -0.6 && o < -0.4):
            return ye.fromRgb(239, 190, 136);
          case (o >= -0.4 && o < -0.2):
            return ye.fromRgb(239, 214, 136);
          case (o >= -0.2 && o < 0):
            return ye.fromRgb(239, 236, 135);
          case (o >= 0 && o < 0.2):
            return ye.fromRgb(134, 239, 134);
          case (o >= 0.2 && o < 0.4):
            return ye.fromRgb(134, 239, 227);
          case (o >= 0.4 && o < 0.6):
            return ye.fromRgb(134, 224, 239);
          case (o >= 0.6 && o < 0.8):
            return ye.fromRgb(134, 200, 239);
          case (o >= 0.8 && o <= 1):
            return ye.fromRgb(133, 175, 239);
          case o > 1:
            return ye.fromRgb(134, 153, 239);
          default:
            return ye(16777215);
        }
      }
    } else if (rt.isLocation(i) && me.isAtomic(i.aUnit)) {
      var o;
      switch (a = i.aUnit.model.atomicHierarchy.atoms.em_confidence, !0) {
        case (o = parseFloat(a.value(i.aUnit.elements[i.aIndex]))) < -1:
          return ye.fromRgb(239, 139, 139);
        case (o >= -1 && o < -0.8):
          return ye.fromRgb(239, 151, 139);
        case (o >= -0.8 && o < -0.6):
          return ye.fromRgb(239, 167, 138);
        case (o >= -0.6 && o < -0.4):
          return ye.fromRgb(239, 190, 136);
        case (o >= -0.4 && o < -0.2):
          return ye.fromRgb(239, 214, 136);
        case (o >= -0.2 && o < 0):
          return ye.fromRgb(239, 236, 135);
        case (o >= 0 && o < 0.2):
          return ye.fromRgb(134, 239, 134);
        case (o >= 0.2 && o < 0.4):
          return ye.fromRgb(134, 239, 227);
        case (o >= 0.4 && o < 0.6):
          return ye.fromRgb(134, 224, 239);
        case (o >= 0.6 && o < 0.8):
          return ye.fromRgb(134, 200, 239);
        case (o >= 0.8 && o <= 1):
          return ye.fromRgb(133, 175, 239);
        case o > 1:
          return ye.fromRgb(134, 153, 239);
        default:
          return ye(16777215);
      }
    }
    return hk;
  }, props: n, description: "EM", legend: io(Object.keys(r).map(function(i) {
    return [i, r[i]];
  })) };
}, getParams: function(e) {
  return i6;
}, defaultValues: N.getDefaultValues(i6), isApplicable: function(e) {
  return !!e.structure;
} }, Tx = { 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 }, e0 = window.materialColors, a6 = function() {
  Object.keys(e0.settings).forEach(function(e) {
    Tx[e] = e0.getColorNumber(e);
  });
};
e0 && (a6(), e0.setColorsSubject.subscribe(function() {
  a6();
}));
var nh = Tx, o6 = ye(16777215), Mx = { carbonColor: N.MappedStatic("chain-id", { "chain-id": N.Group(B({}, Ec)), "operator-name": N.Group(B({}, Ll)), "element-symbol": N.Group({}) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: N.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: N.Numeric(0.2, { min: -6, max: 6, step: 0.1 }) };
function gk(e) {
  return Mx;
}
function Dx(e, t) {
  var n = Dc(nh, t.saturation, t.lightness);
  function r(i, a) {
    return function(o, s) {
      var u = o[s];
      return u === void 0 ? o6 : u;
    }(n, i);
  }
  return { factory: Dx, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (Ne.is(i)) {
      if (me.isAtomic(i.unit)) return r(i.unit.model.atomicHierarchy.atoms.type_symbol.value(i.element));
    } else if (rt.isLocation(i) && me.isAtomic(i.aUnit))
      return r(i.aUnit.model.atomicHierarchy.atoms.type_symbol.value(i.aUnit.elements[i.aIndex]));
    return o6;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: io(Object.keys(nh).map(function(i) {
    return [i, nh[i]];
  })) };
}
var Cs, $e, Wt, yk = { name: "material-element-symbol", label: "Material Element Symbol", category: "Atom Property", factory: Dx, getParams: gk, defaultValues: N.getDefaultValues(Mx), isApplicable: function(e) {
  return !!e.structure;
} };
function rh(e, t, n) {
  switch (n) {
    case $e.Highlight:
      e[t] |= 1;
      break;
    case $e.RemoveHighlight:
      e[t] &= -2;
      break;
    case $e.Select:
      e[t] |= 2;
      break;
    case $e.Deselect:
      e[t] &= -3;
      break;
    case $e.Toggle:
      e[t] ^= 2;
      break;
    case $e.Clear:
      e[t] = 0;
  }
}
function wv(e, t, n) {
  if (n === $e.None) return !1;
  if (oe.is(t)) {
    var r = oe.start(t), i = oe.end(t), a = r + 3 >> 2, o = a + (i - 4 * a >> 2);
    if (o <= a) {
      for (var s = r; s < i; ++s) rh(e, s, n);
      return !0;
    }
    var u = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), c = r, l = Math.min(4 * a, i), d = Math.max(r, 4 * o), m = i;
    switch (n) {
      case $e.Highlight:
        for (s = a; s < o; ++s) u[s] |= 16843009;
        break;
      case $e.RemoveHighlight:
        for (s = a; s < o; ++s) u[s] &= -16843010;
        break;
      case $e.Select:
        for (s = a; s < o; ++s) u[s] |= 33686018;
        break;
      case $e.Deselect:
        for (s = a; s < o; ++s) u[s] &= -33686019;
        break;
      case $e.Toggle:
        for (s = a; s < o; ++s) u[s] ^= 33686018;
        break;
      case $e.Clear:
        for (s = a; s < o; ++s) u[s] = 0;
        break;
      default:
        Tr();
    }
    for (s = c; s < l; ++s) rh(e, s, n);
    for (s = d; s < m; ++s) rh(e, s, n);
  } else switch (n) {
    case $e.Highlight:
      s = 0;
      for (var p = t.length; s < p; ++s) e[t[s]] |= 1;
      break;
    case $e.RemoveHighlight:
      for (s = 0, p = t.length; s < p; ++s) e[t[s]] &= -2;
      break;
    case $e.Select:
      for (s = 0, p = t.length; s < p; ++s) e[t[s]] |= 2;
      break;
    case $e.Deselect:
      for (s = 0, p = t.length; s < p; ++s) e[t[s]] &= -3;
      break;
    case $e.Toggle:
      for (s = 0, p = t.length; s < p; ++s) e[t[s]] ^= 2;
      break;
    case $e.Clear:
      for (s = 0, p = t.length; s < p; ++s) e[t[s]] = 0;
      break;
    default:
      Tr();
  }
  return !0;
}
(function(e) {
  e.PaletteScale = 16777215, e.EmptyFactory = function() {
    return e.Empty;
  };
  var t = ye(13421772);
  e.Empty = { factory: e.EmptyFactory, granularity: "uniform", color: function() {
    return t;
  }, props: {} }, e.areEqual = function(n, r) {
    return n.contextHash === r.contextHash && n.factory === r.factory && Iu(n.props, r.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new px(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { "atom-id": sk, "carbohydrate-symbol": TB, "chain-id": ER, "element-index": TR, "element-symbol": VR, "material-element-symbol": yk, "entity-id": RR, "entity-source": LR, hydrophobicity: tk, illustrative: $R, "model-index": nk, "molecule-type": UR, occupancy: ik, "operator-hkl": ak, "operator-name": DR, "partial-charge": ok, "polymer-id": HR, "polymer-index": qR, "residue-name": jR, "secondary-structure": KR, "sequence-id": YR, "shape-group": uR, uncertainty: QR, "unit-index": WR, uniform: DB, "volume-value": ck, "uni-fold": dk, cdr: mk, "em-confidence": vk, "multi-theme": pk };
})(Cs || (Cs = {})), 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";
}($e || ($e = {})), function(e) {
  e.is = Qr.has, e.All = $e.Highlight | $e.RemoveHighlight | $e.Select | $e.Deselect | $e.Toggle | $e.Clear, e.Highlighting = $e.Highlight | $e.RemoveHighlight | $e.Clear, e.Selecting = $e.Select | $e.Deselect | $e.Toggle | $e.Clear, e.isReverse = function(t, n) {
    return t === $e.Highlight && n === $e.RemoveHighlight || t === $e.RemoveHighlight && n === $e.Highlight || t === $e.Select && n === $e.Deselect || t === $e.Deselect && n === $e.Select || t === $e.Toggle && n === $e.Toggle;
  };
}(Wt || (Wt = {}));
var n3 = { kind: "every-loci" };
function Vi(e) {
  return !!e && e.kind === "every-loci";
}
var rn, Sn = { kind: "empty-loci" };
function Cu(e) {
  return !!e && e.kind === "empty-loci";
}
function af(e) {
  return !!e && e.kind === "data-loci";
}
function r3(e, t, n, r, i) {
  return { kind: "data-loci", tag: e, data: t, elements: n, getBoundingSphere: r, getLabel: i };
}
function bk(e) {
  return Object.keys(e).filter(function(t) {
    return !isNaN(t);
  }).map(function(t) {
    return +t;
  }).sort(function(t, n) {
    return t - n;
  }).map(function(t) {
    return e[t];
  });
}
function ih(e, t, n) {
  return e && e[t] !== void 0 ? e[t] : n;
}
function Ie(e) {
  for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
  return { kind: "alias", aliases: t, symbol: e };
}
function P1(e, t) {
  for (var n = [], r = 2; r < arguments.length; r++) n[r - 2] = arguments[r];
  return e.info.namespace = "molscript-macro", e.id = "molscript-macro.".concat(e.info.name), { kind: "macro", symbol: e, translate: t, aliases: Pe([e.info.name], n, !0) };
}
function _k(e) {
  return e.kind === "alias" || e.kind === "macro";
}
(function(e) {
  var t = new ka("98");
  function n(o, s) {
    var u;
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return s || (s = de()), o.kind === "structure-loci" ? de.copy(s, o.structure.boundary.sphere) : o.kind === "element-loci" ? de.copy(s, Se.getBoundary(o).sphere) : o.kind === "bond-loci" ? rt.getBoundingSphere(o, s) : o.kind === "shape-loci" ? de.copy(s, o.shape.geometry.boundingSphere) : o.kind === "group-loci" ? _i.getBoundingSphere(o, s) : o.kind === "data-loci" ? (u = o.getBoundingSphere) === null || u === void 0 ? void 0 : u.call(o, s) : o.kind === "volume-loci" ? Tt.getBoundingSphere(o.volume, s) : o.kind === "isosurface-loci" ? Tt.Isosurface.getBoundingSphere(o.volume, o.isoValue, s) : o.kind === "cell-loci" ? Tt.Cell.getBoundingSphere(o.volume, o.indices, s) : void 0;
  }
  e.getBundleBoundingSphere = function(o) {
    var s = o.loci.map(function(p) {
      return n(p);
    }).filter(function(p) {
      return !!p;
    });
    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, m = s; d < m.length; d++)
      l = m[d], t.radiusPositionRadius(l.center, l.radius);
    return t.getSphere();
  }, e.areEqual = function(o, s) {
    return !(!Vi(o) || !Vi(s)) || !(!Cu(o) || !Cu(s)) || (af(o) && af(s) ? function(u, c) {
      if (!V2(u.data, c.data) || u.tag !== c.tag || u.elements.length !== c.elements.length) return !1;
      for (var l = 0, d = u.elements.length; l < d; ++l) if (!V2(u.elements[l], c.elements[l])) return !1;
      return !0;
    }(o, s) : Be.isLoci(o) && Be.isLoci(s) ? Be.areLociEqual(o, s) : Se.is(o) && Se.is(s) ? Se.areEqual(o, s) : rt.isLoci(o) && rt.isLoci(s) ? rt.areLociEqual(o, s) : Ct.isLoci(o) && Ct.isLoci(s) ? Ct.areLociEqual(o, s) : _i.isLoci(o) && _i.isLoci(s) ? _i.areLociEqual(o, s) : Tt.isLoci(o) && Tt.isLoci(s) ? Tt.areLociEqual(o, s) : Tt.Isosurface.isLoci(o) && Tt.Isosurface.isLoci(s) ? Tt.Isosurface.areLociEqual(o, s) : !(!Tt.Cell.isLoci(o) || !Tt.Cell.isLoci(s)) && Tt.Cell.areLociEqual(o, s));
  }, e.isEvery = function(o) {
    return !!o && o.kind === "every-loci";
  }, e.isEmpty = function(o) {
    return !Vi(o) && (!!Cu(o) || (af(o) ? function(s) {
      return s.elements.length === 0;
    }(o) : Be.isLoci(o) ? Be.isLociEmpty(o) : Se.is(o) ? Se.isEmpty(o) : rt.isLoci(o) ? rt.isLociEmpty(o) : Ct.isLoci(o) ? Ct.isLociEmpty(o) : _i.isLoci(o) ? _i.isLociEmpty(o) : Tt.isLoci(o) ? Tt.isLociEmpty(o) : Tt.Isosurface.isLoci(o) ? Tt.Isosurface.isLociEmpty(o) : !!Tt.Cell.isLoci(o) && Tt.Cell.isLociEmpty(o)));
  }, e.remap = function(o, s) {
    return s instanceof Be && (Se.is(o) ? o = Se.remap(o, s) : Be.isLoci(o) ? o = Be.remapLoci(o, s) : rt.isLoci(o) && (o = rt.remapLoci(o, s))), o;
  }, e.getBoundingSphere = n;
  var r = de.zero();
  e.getCenter = function(o, s) {
    var u = n(o, r);
    return u ? S.copy(s || S(), u.center) : void 0;
  }, e.getPrincipalAxes = function(o) {
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return o.kind === "structure-loci" ? Se.getPrincipalAxes(Be.toStructureElementLoci(o.structure)) : o.kind === "element-loci" ? Se.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 i = { element: function(o) {
    return o;
  }, residue: function(o) {
    return Se.is(o) ? Se.extendToWholeResidues(o, !0) : o;
  }, chain: function(o) {
    return Se.is(o) ? Se.extendToWholeChains(o) : o;
  }, entity: function(o) {
    return Se.is(o) ? Se.extendToWholeEntities(o) : o;
  }, model: function(o) {
    return Se.is(o) ? Se.extendToWholeModels(o) : o;
  }, operator: function(o) {
    return Se.is(o) ? Se.extendToWholeOperators(o) : o;
  }, structure: function(o) {
    return Se.is(o) ? Be.toStructureElementLoci(o.structure) : _i.isLoci(o) ? Ct.Loci(o.shape) : o;
  }, elementInstances: function(o) {
    return Se.is(o) ? Se.extendToAllInstances(o) : o;
  }, residueInstances: function(o) {
    return Se.is(o) ? Se.extendToAllInstances(Se.extendToWholeResidues(o, !0)) : o;
  }, chainInstances: function(o) {
    return Se.is(o) ? Se.extendToAllInstances(Se.extendToWholeChains(o)) : o;
  } };
  function a(o, s) {
    return i[s](o);
  }
  e.GranularityOptions = N.objectToOptions(i, 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") ? [To(o), "With Symmetry"] : To(o);
    }
  }), e.simpleGranularity = function(o) {
    return o.replace("Instances", "");
  }, e.applyGranularity = a, e.normalize = function(o, s, u) {
    return u === void 0 && (u = !1), (s !== "element" || u) && rt.isLoci(o) && (o = rt.toStructureElementLoci(o)), Be.isLoci(o) && (o = Be.toStructureElementLoci(o.structure)), Se.is(o) && (o = Se.remap(o, o.structure.root)), s && (o = a(o, s)), o;
  };
})(rn || (rn = {}));
var xk = [["Core symbols", Ie(Q.core.type.bool, "bool"), Ie(Q.core.type.num, "num"), Ie(Q.core.type.str, "str"), Ie(Q.core.type.regex, "regex"), Ie(Q.core.type.list, "list"), Ie(Q.core.type.set, "set"), Ie(Q.core.type.compositeKey, "composite-key"), Ie(Q.core.logic.not, "not"), Ie(Q.core.logic.and, "and"), Ie(Q.core.logic.or, "or"), Ie(Q.core.ctrl.if, "if"), Ie(Q.core.ctrl.fn, "fn"), Ie(Q.core.ctrl.eval, "eval"), Ie(Q.core.math.add, "add", "+"), Ie(Q.core.math.sub, "sub", "-"), Ie(Q.core.math.mult, "mult", "*"), Ie(Q.core.math.div, "div", "/"), Ie(Q.core.math.pow, "pow", "**"), Ie(Q.core.math.mod, "mod"), Ie(Q.core.math.min, "min"), Ie(Q.core.math.max, "max"), Ie(Q.core.math.floor, "floor"), Ie(Q.core.math.ceil, "ceil"), Ie(Q.core.math.roundInt, "round"), Ie(Q.core.math.abs, "abs"), Ie(Q.core.math.sqrt, "sqrt"), Ie(Q.core.math.cbrt, "cbrt"), Ie(Q.core.math.sin, "sin"), Ie(Q.core.math.cos, "cos"), Ie(Q.core.math.tan, "tan"), Ie(Q.core.math.asin, "asin"), Ie(Q.core.math.acos, "acos"), Ie(Q.core.math.atan, "atan"), Ie(Q.core.math.sinh, "sinh"), Ie(Q.core.math.cosh, "cosh"), Ie(Q.core.math.tanh, "tanh"), Ie(Q.core.math.exp, "exp"), Ie(Q.core.math.log, "log"), Ie(Q.core.math.log10, "log10"), Ie(Q.core.math.atan2, "atan2"), Ie(Q.core.rel.eq, "eq", "="), Ie(Q.core.rel.neq, "neq", "!="), Ie(Q.core.rel.lt, "lt", "<"), Ie(Q.core.rel.lte, "lte", "<="), Ie(Q.core.rel.gr, "gr", ">"), Ie(Q.core.rel.gre, "gre", ">="), Ie(Q.core.rel.inRange, "in-range"), Ie(Q.core.str.concat, "concat"), Ie(Q.core.str.match, "regex.match"), Ie(Q.core.list.getAt, "list.get"), Ie(Q.core.set.has, "set.has"), Ie(Q.core.set.isSubset, "set.subset")], ["Structure", ["Types", Ie(Q.structureQuery.type.entityType, "ent-type"), Ie(Q.structureQuery.type.authResidueId, "auth-resid"), Ie(Q.structureQuery.type.labelResidueId, "label-resid"), Ie(Q.structureQuery.type.ringFingerprint, "ringfp"), Ie(Q.structureQuery.type.bondFlags, "bond-flags")], ["Slots", Ie(Q.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")], ["Generators", Ie(Q.structureQuery.generator.atomGroups, "sel.atom.atom-groups"), Ie(Q.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"), Ie(Q.structureQuery.generator.rings, "sel.atom.rings"), Ie(Q.structureQuery.generator.empty, "sel.atom.empty"), Ie(Q.structureQuery.generator.all, "sel.atom.all"), Ie(Q.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"), P1(Nd("sel.atom.atoms", et.Dictionary({ 0: De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." }) }), Ue.ElementSelection, "A selection of singleton atom sets."), function(e) {
  return ot.struct.generator.atomGroups({ "atom-test": ih(e, 0, !0) });
}), P1(Nd("sel.atom.res", et.Dictionary({ 0: De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." }) }), Ue.ElementSelection, "A selection of atom sets grouped by residue."), function(e) {
  return ot.struct.generator.atomGroups({ "residue-test": ih(e, 0, !0), "group-by": ot.ammp("residueKey") });
}), P1(Nd("sel.atom.chains", et.Dictionary({ 0: De(ae.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." }) }), Ue.ElementSelection, "A selection of atom sets grouped by chain."), function(e) {
  return ot.struct.generator.atomGroups({ "chain-test": ih(e, 0, !0), "group-by": ot.ammp("chainKey") });
})], ["Modifiers", Ie(Q.structureQuery.modifier.queryEach, "sel.atom.query-each"), Ie(Q.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"), Ie(Q.structureQuery.modifier.exceptBy, "sel.atom.except-by"), Ie(Q.structureQuery.modifier.unionBy, "sel.atom.union-by"), Ie(Q.structureQuery.modifier.union, "sel.atom.union"), Ie(Q.structureQuery.modifier.cluster, "sel.atom.cluster"), Ie(Q.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"), Ie(Q.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"), Ie(Q.structureQuery.modifier.includeConnected, "sel.atom.include-connected"), Ie(Q.structureQuery.modifier.expandProperty, "sel.atom.expand-property")], ["Filters", Ie(Q.structureQuery.filter.pick, "sel.atom.pick"), Ie(Q.structureQuery.filter.first, "sel.atom.first"), Ie(Q.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"), Ie(Q.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"), Ie(Q.structureQuery.filter.within, "sel.atom.within"), Ie(Q.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")], ["Combinators", Ie(Q.structureQuery.combinator.intersect, "sel.atom.intersect"), Ie(Q.structureQuery.combinator.merge, "sel.atom.merge"), Ie(Q.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")], ["Atom Set Properties", Ie(Q.structureQuery.atomSet.atomCount, "atom.set.atom-count"), Ie(Q.structureQuery.atomSet.countQuery, "atom.set.count-query"), Ie(Q.structureQuery.atomSet.reduce, "atom.set.reduce"), Ie(Q.structureQuery.atomSet.propertySet, "atom.set.property")], ["Atom Properties", Ie(Q.structureQuery.atomProperty.core.elementSymbol, "atom.el"), Ie(Q.structureQuery.atomProperty.core.vdw, "atom.vdw"), Ie(Q.structureQuery.atomProperty.core.mass, "atom.mass"), Ie(Q.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"), Ie(Q.structureQuery.atomProperty.core.x, "atom.x"), Ie(Q.structureQuery.atomProperty.core.y, "atom.y"), Ie(Q.structureQuery.atomProperty.core.z, "atom.z"), Ie(Q.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"), Ie(Q.structureQuery.atomProperty.core.operatorName, "atom.op-name"), Ie(Q.structureQuery.atomProperty.core.modelIndex, "atom.model-index"), Ie(Q.structureQuery.atomProperty.core.modelLabel, "atom.model-label"), Ie(Q.structureQuery.atomProperty.core.atomKey, "atom.key"), Ie(Q.structureQuery.atomProperty.core.bondCount, "atom.bond-count"), Ie(Q.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"), Ie(Q.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"), Ie(Q.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"), Ie(Q.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"), Ie(Q.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"), Ie(Q.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"), Ie(Q.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"), Ie(Q.structureQuery.atomProperty.macromolecular.id, "atom.id"), Ie(Q.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"), Ie(Q.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"), Ie(Q.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"), Ie(Q.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"), Ie(Q.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"), Ie(Q.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"), Ie(Q.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"), Ie(Q.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"), Ie(Q.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"), Ie(Q.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"), Ie(Q.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"), Ie(Q.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"), Ie(Q.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"), Ie(Q.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"), Ie(Q.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"), Ie(Q.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"), Ie(Q.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"), Ie(Q.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"), Ie(Q.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"), Ie(Q.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"), Ie(Q.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"), Ie(Q.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"), Ie(Q.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent")], ["Bond Properties", Ie(Q.structureQuery.bondProperty.order, "bond.order"), Ie(Q.structureQuery.bondProperty.length, "bond.length"), Ie(Q.structureQuery.bondProperty.atomA, "bond.atom-a"), Ie(Q.structureQuery.bondProperty.atomB, "bond.atom-b"), P1(Nd("bond.is", et.List(Ue.BondFlag), ae.Bool, "Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(ae.oneOfValues(Ue.BondFlag).join(", "))), function(e) {
  return ot.core.flags.hasAny([ot.struct.bondProperty.flags(), ot.struct.type.bondFlags(bk(e))]);
})]]], Bx = [];
(function e(t) {
  for (var n = 0, r = t; n < r.length; n++) {
    var i = r[n];
    _k(i) ? Bx.push(i) : i instanceof Array && e(i);
  }
})(xk);
var Sk = function() {
  for (var e = [], t = /* @__PURE__ */ Object.create(null), n = yn.create(), r = yn.create(), i = 0, a = Bx; i < a.length; i++) {
    for (var o = a[i], 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, m = Object.keys(l.map); d < m.length; d++) {
      c = m[d], isNaN(c) && yn.add(n, c, c);
      var p = l.map[c];
      p.type.kind === "oneof" && ae.oneOfValues(p.type).forEach(function(v) {
        return yn.add(r, v, v);
      });
    }
    else l.type.kind === "oneof" && ae.oneOfValues(l.type).forEach(function(v) {
      return yn.add(r, v, v);
    });
  }
  return { symbolList: e, symbolMap: t, namedArgs: n.array, constants: r.array };
}(), Qc = Sk.symbolMap;
function qd(e) {
  if (Gr.isLiteral(e)) return e;
  if (Gr.isSymbol(e)) {
    if (!Qc[e.name]) return e;
    var t = Qc[e.name];
    if (t.kind === "alias") return Gr.Symbol(Qc[e.name].symbol.id);
    throw t.translate([]);
  }
  var n = Gr.isSymbol(e.head) && !!Qc[e.head.name] && Qc[e.head.name].kind === "macro", r = n ? e.head : qd(e.head), i = r !== e.head;
  if (!e.args) return n ? qd(e.head) : i ? Gr.Apply(r) : e;
  var a, o = !1;
  if (Gr.isArgumentsArray(e.args)) {
    a = [];
    for (var s = 0, u = e.args.length; s < u; s++)
      (d = e.args[s]) !== (m = qd(d)) && (o = !0), a[a.length] = m;
    if (o || (a = e.args), !n && !i && !o) return e;
  } else {
    a = {};
    for (var c = 0, l = Object.keys(e.args); c < l.length; c++) {
      var d, m, p = l[c];
      (d = e.args[p]) !== (m = qd(d)) && (o = !0), a[p] = m;
    }
    if (!n && !i && !o) return e;
    o || (a = e.args);
  }
  if (n) {
    var v = Qc[e.head.name];
    return v.kind !== "macro" ? Gr.Apply(r, a) : v.translate(a);
  }
  return Gr.Apply(r, a);
}
function Ck(e) {
  return qd(e);
}
var Pv, ja = function() {
  function e(t) {
    this._ = t;
  }
  return e.prototype.parse = function(t) {
    var n = this.skip(e.eof)._(t, 0);
    return n.status ? { success: !0, value: n.value } : { success: !1, index: Rx(t, n.furthest), expected: n.expected };
  }, e.prototype.tryParse = function(t) {
    var n = this.parse(t);
    if (n.success) return n.value;
    var r = function(i, a) {
      return "expected ".concat(function(o) {
        return o.length === 1 ? o[0] : "one of " + o.join(", ");
      }(a.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);
      }(i, a));
    }(t, n);
    throw new Error(r);
  }, 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, n) {
    return ah(1, typeof t == "string" ? e.string(t) : t, this, typeof n == "string" ? e.string(n) : n);
  }, e.prototype.thru = function(t) {
    return t(this);
  }, e.prototype.then = function(t) {
    return ah(1, this, t);
  }, e.prototype.many = function() {
    var t = this;
    return new e(function(n, r) {
      for (var i = [], a = void 0; ; ) {
        if (!(a = Aa(t._(n, r), a)).status) return Aa(ii(r, i), a);
        if (r === a.index) throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
        r = a.index, i.push(a.value);
      }
    });
  }, e.prototype.times = function(t, n) {
    var r = this, i = n === void 0 ? t : n;
    return new e(function(a, o) {
      var s, u = [], c = void 0, l = void 0;
      for (s = 0; s < t; s++) {
        if (l = Aa(c = r._(a, o), l), !c.status) return l;
        o = c.index, u.push(c.value);
      }
      for (; s < i && (l = Aa(c = r._(a, o), l), c.status); s += 1) o = c.index, u.push(c.value);
      return Aa(ii(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(n) {
      return Pe(Pe([], n[0], !0), n[1], !0);
    });
  }, e.prototype.map = function(t) {
    var n = this;
    return new e(function(r, i) {
      var a = n._(r, i);
      return a.status ? Aa(ii(a.index, t(a.value)), a) : a;
    });
  }, e.prototype.skip = function(t) {
    return ah(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(n) {
      return { name: t, start: n[0], value: n[1], end: n[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 n = this;
    return new e(function(r, i) {
      var a = n._(r, i);
      return a.status || (a.expected = [t]), a;
    });
  }, e.prototype.fallback = function(t) {
    return this.or(e.succeed(t));
  }, e.prototype.ap = function(t) {
    return e.seq(t, this).map(function(n) {
      return (0, n[0])(n[1]);
    });
  }, e.prototype.chain = function(t) {
    var n = this;
    return new e(function(r, i) {
      var a = n._(r, i);
      return a.status ? Aa(t(a.value)._(r, a.index), a) : a;
    });
  }, e;
}();
function ah(e) {
  for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
  var r = t.length;
  return new ja(function(i, a) {
    for (var o, s, u = a, c = 0; c < r; c++) {
      if (!(o = Aa(t[c]._(i, u), o)).status) return o;
      e === c && (s = o.value), u = o.index;
    }
    return Aa(ii(u, s), o);
  });
}
function ii(e, t) {
  return { status: !0, index: e, value: t };
}
function Qo(e, t) {
  return { status: !1, furthest: e, expected: [t] };
}
function Aa(e, t) {
  if (!t || e.status || t.status || e.furthest > t.furthest) return e;
  var n = e.furthest === t.furthest ? function(r, i) {
    var a = r.length, o = i.length;
    if (a === 0) return i;
    if (o === 0) return r;
    for (var s = /* @__PURE__ */ new Set(), u = [], c = 0; c < a; c++) s.has(r[c]) || (u[u.length] = r[c], s.add(r[c]));
    for (c = 0; c < o; c++) s.has(i[c]) || (u[u.length] = i[c], s.add(i[c]));
    return u.sort(), u;
  }(e.expected, t.expected) : t.expected;
  return { status: e.status, furthest: t.furthest, expected: n };
}
function Rx(e, t) {
  var n = e.slice(0, t).split(`
`);
  return { offset: t, line: n.length, column: n[n.length - 1].length + 1 };
}
function Ak(e) {
  return e instanceof ja;
}
(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(m, p) {
      for (var v, f = new Array(d), y = p, h = 0; h < d; h++) {
        if (!(v = Aa(c[h]._(m, y), v)).status) return v;
        f[h] = v.value, y = v.index;
      }
      return Aa(ii(y, f), v);
    });
  }
  function n() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    return c.length === 0 ? s("zero alternates") : new e(function(d, m) {
      for (var p, v = 0; v < c.length; v++) if ((p = Aa(c[v]._(d, m), p)).status) return p;
      return p;
    });
  }
  function r(c, l) {
    return t(c, l.then(c).many()).map(function(d) {
      return Pe([d[0]], d[1], !0);
    });
  }
  function i(c) {
    var l = "'".concat(c, "'");
    if (c.length === 1) {
      var d = c.charCodeAt(0);
      return new e(function(m, p) {
        return m.charCodeAt(p) === d ? ii(p + 1, c) : Qo(p, l);
      });
    }
    return new e(function(m, p) {
      var v = p + c.length;
      return m.slice(p, v) === c ? ii(v, c) : Qo(p, l);
    });
  }
  function a(c, l) {
    l === void 0 && (l = 0);
    var d = function(p) {
      return RegExp("^(?:" + p.source + ")", function(v) {
        var f = "" + v;
        return f.slice(f.lastIndexOf("/") + 1);
      }(p));
    }(c), m = "" + c;
    return new e(function(p, v) {
      var f = d.exec(p.slice(v));
      if (f) {
        if (0 <= l && l <= f.length) {
          var y = f[0], h = f[l];
          return ii(v + y.length, h);
        }
        return Qo(v, "invalid match group (0 to ".concat(f.length, ") in ").concat(m));
      }
      return Qo(v, m);
    });
  }
  function o(c) {
    return new e(function(l, d) {
      return ii(d, c);
    });
  }
  function s(c) {
    return new e(function(l, d) {
      return Qo(d, c);
    });
  }
  function u(c) {
    return new e(function(l, d) {
      var m = l.charAt(d);
      return d < l.length && c(m) ? ii(d + 1, m) : Qo(d, "a character " + c);
    });
  }
  e.seq = t, e.alt = n, e.sepBy = function(c, l) {
    return r(c, l).or(o([]));
  }, e.sepBy1 = r, e.string = i, e.regexp = a, e.succeed = o, e.fail = s, e.lookahead = function c(l) {
    if (Ak(l)) return new e(function(d, m) {
      var p = l._(d, m);
      return p.status && (p.index = m, p.value = null), p;
    });
    if (typeof l == "string") return c(i(l));
    if (l instanceof RegExp) return c(a(l));
    throw new Error("not a string, regexp, or parser: " + l);
  }, e.notFollowedBy = function(c) {
    return new e(function(l, d) {
      var m = c._(l, d);
      return m.status ? Qo(d, 'not "' + l.slice(d, m.index) + '"') : ii(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 m = d; m < l.length && c(l.charAt(m)); ) m++;
      return ii(m, l.slice(d, m));
    });
  }, e.lazy = function(c) {
    var l = new e(function(d, m) {
      var p = c()._;
      return l._ = p, p(d, m);
    });
    return l;
  }, e.empty = function() {
    return s("empty");
  }, e.index = new e(function(c, l) {
    return ii(l, Rx(c, l));
  }), e.anyChar = new e(function(c, l) {
    return l >= c.length ? Qo(l, "any character") : ii(l + 1, c.charAt(l));
  }), e.all = new e(function(c, l) {
    return ii(c.length, c.slice(l));
  }), e.eof = new e(function(c, l) {
    return l < c.length ? Qo(l, "EOF") : ii(l, null);
  }), e.digit = a(/[0-9]/).desc("a digit"), e.digits = a(/[0-9]*/).desc("optional digits"), e.letter = a(/[a-z]/i).desc("a letter"), e.letters = a(/[a-z]*/i).desc("optional letters"), e.optWhitespace = a(/\s*/).desc("optional whitespace"), e.whitespace = a(/\s+/).desc("whitespace"), e.cr = i("\r"), e.lf = i(`
`), e.crlf = i(`\r
`), e.newline = n(e.crlf, e.lf, e.cr).desc("newline"), e.end = n(e.newline, e.eof);
})(ja || (ja = {})), function(e) {
  var t;
  (function(f) {
    f.str = function(y) {
      return { kind: "string", value: y };
    }, f.symb = function(y) {
      return { kind: "symbol", value: y };
    }, f.list = function(y, h) {
      return { kind: "list", bracket: y, nodes: h };
    }, f.comment = function(y) {
      return { kind: "comment", value: y };
    };
  })(t || (t = {}));
  var n = ja.regexp(/[\n\r\s]*/), r = ja.lazy(function() {
    return ja.alt(i, d, a, o).trim(n);
  }), i = ja.takeWhile(function(f) {
    return f !== "`";
  }).trim("`").map(t.str), a = ja.regexp(/[^()\[\]{};`,\n\r\s]+/).map(t.symb), o = ja.regexp(/\s*;+([^\n\r]*)\n/, 1).map(t.comment), s = r.many(), u = s.wrap("(", ")").map(function(f) {
    return t.list("(", f);
  }), c = s.wrap("[", "]").map(function(f) {
    return t.list("[", f);
  }), l = s.wrap("{", "}").map(function(f) {
    return t.list("{", f);
  }), d = ja.alt(u, c, l), m = r.many();
  function p(f) {
    switch (f.kind) {
      case "string":
        return f.value;
      case "symbol":
        var y = f.value;
        if (y.length > 1) switch (y.charAt(0)) {
          case ".":
            return ot.atomName(y.substr(1));
          case "_":
            return ot.struct.type.elementSymbol([y.substr(1)]);
        }
        return y === "true" || y !== "false" && (function(g) {
          return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(g) && !isNaN(+g);
        }(y) ? +y : Gr.Symbol(y));
      case "list":
        switch (f.bracket) {
          case "[":
            return ot.core.type.list(v(f.nodes).map(p));
          case "{":
            return ot.core.type.set(v(f.nodes).map(p));
          case "(":
            if (f.nodes[0].kind === "comment") throw new Error("Invalid expression");
            var h = p(f.nodes[0]);
            return Gr.Apply(h, function(g) {
              if (!(g.length <= 1)) {
                if (!function(M) {
                  for (var R = 1, O = M.length; R < O; R++) {
                    var L = M[R];
                    if (L.kind === "symbol" && L.value.length > 1 && L.value.charAt(0) === ":") return !0;
                  }
                  return !1;
                }(g)) {
                  for (var x = [], C = 1, b = g.length; C < b; C++)
                    (w = g[C]).kind !== "comment" && (x[x.length] = p(w));
                  return x;
                }
                var _ = {}, A = !0, I = 0;
                for (C = 1, b = g.length; C < b; C++) {
                  var w;
                  if ((w = g[C]).kind !== "comment") if (w.kind === "symbol" && w.value.length > 1 && w.value.charAt(0) === ":") {
                    var E = w.value.substr(1);
                    for (++C; C < b && g[C].kind === "comment"; ) C++;
                    if (C >= b) throw new Error("There must be a value foolowed a named arg ':".concat(E, "'."));
                    if (g[C].kind === "comment") throw new Error("Invalid expression");
                    _[E] = p(g[C]), isNaN(+E) && (A = !1);
                  } else _[I++] = p(w);
                }
                if (A) {
                  var D = Object.keys(_).map(function(M) {
                    return +M;
                  }).sort(function(M, R) {
                    return M - R;
                  }), T = !0;
                  for (C = 0, b = D.length; C < b; C++) if (D[C] !== C) {
                    T = !1;
                    break;
                  }
                  if (T) {
                    var P = [];
                    for (C = 0, b = D.length; C < b; C++) P[C] = _[C];
                    return P;
                  }
                }
                return _;
              }
            }(f.nodes));
          default:
            Tr(f.bracket);
        }
      default:
        Tr();
    }
  }
  function v(f) {
    for (var y = !1, h = 0, g = f.length; h < g; h++) if (f[h].kind === "comment") {
      y = !0;
      break;
    }
    return y ? f.filter(function(x) {
      return x.kind !== "comment";
    }) : f;
  }
  e.parse = function(f) {
    for (var y = function(b) {
      return m.tryParse(b);
    }(f), h = [], g = 0, x = y; g < x.length; g++) {
      var C = x[g];
      C.kind !== "comment" && (h[h.length] = p(C));
    }
    return h;
  };
}(Pv || (Pv = {}));
var s6, Vl, of, t0, Ik = 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 n = 0, r = Object.keys(t.symbols); n < r.length; n++) {
      var i = r[n];
      this.addSymbol(t.symbols[i]);
    }
  }, e.prototype.removeCustomProp = function(t) {
    if (t.symbols) for (var n = 0, r = Object.keys(t.symbols); n < r.length; n++) {
      var i = r[n];
      this.removeSymbol(t.symbols[i]);
    }
  }, e.prototype.getRuntime = function(t) {
    return this.map.get(t);
  }, e;
}(), kx = new Ik(), wk = function(e) {
  this.table = e, this.constQueryContext = new Cc(Be.Empty);
};
(function(e) {
  e.Const = function(t) {
    return { kind: "const", value: t };
  }, e.Dynamic = function(t) {
    return { kind: "dynamic", runtime: t };
  };
})(s6 || (s6 = {})), function(e) {
  e.Const = function(t) {
    return { isConst: !0, fn: function(n) {
      return t;
    } };
  }, e.Dynamic = function(t) {
    return { isConst: !1, fn: t };
  };
}(Vl || (Vl = {})), function(e) {
  e.forEachEval = function(t, n, r, i) {
    if (typeof t.length == "number") for (var a = 0, o = t.length; a < o; a++) r(t[a](n), a, i);
    else {
      a = 0;
      for (var s = 0, u = Object.keys(t); s < u.length; s++)
        r(t[u[s]](n), a++, i);
    }
    return i;
  };
}(of || (of = {})), function(e) {
  e.Const = function(t, n) {
    return new u6(t, n, !0);
  }, e.Dynamic = function(t, n) {
    return new u6(t, n, !1);
  };
}(t0 || (t0 = {}));
var Lo, u6 = function() {
  function e(t, n, r) {
    this.symbol = t, this.fn = n, this.isConst = r;
  }
  return e.prototype.compile = function(t, n) {
    var r, i = !1;
    if (n) if (Gr.isArgumentsArray(n)) {
      r = [], i = !0;
      for (var a = 0, o = n; a < o.length; a++) {
        var s = Ev(t, o[a]);
        i = i && s.isConst, r.push(s.fn);
      }
    } else {
      r = /* @__PURE__ */ Object.create(null), i = !0;
      for (var u = 0, c = Object.keys(n); u < c.length; u++) {
        var l = c[u];
        s = Ev(t, n[l]), i = i && s.isConst, r[l] = s.fn;
      }
    }
    else r = void 0, i = !0;
    return this.isConst && this.isConst && i ? Vl.Const(this.fn(t.constQueryContext, r)) : Vl.Dynamic(Pk(this.fn, r));
  }, e;
}();
function Pk(e, t) {
  return function(n) {
    return e(n, t);
  };
}
function Ev(e, t) {
  if (Gr.isLiteral(t)) return Vl.Const(t);
  if (Gr.isSymbol(t)) {
    var n = e.table.getRuntime(t.name);
    return n ? n.compile(e) : Vl.Const(t.name);
  }
  if (!Gr.isSymbol(t.head)) throw new Error("Can only apply symbols.");
  var r = e.table.getRuntime(t.head.name);
  if (!r) throw new Error("Symbol '".concat(t.head.name, "' is not implemented."));
  return r.compile(e, t.args);
}
function n0(e) {
  return Ev(new wk(kx), e).fn;
}
function vu(e, t) {
  return { expression: e, language: t };
}
function xf(e) {
  return { layers: e };
}
function Sf(e, t) {
  return { kind: e, layers: t };
}
(function(e) {
  function t(r) {
    if (r.language === "mol-script") {
      var i = (a = r.expression, Pv.parse(a));
      if (i.length === 0) throw new Error("No query");
      return Ck(i[0]);
    }
    var a;
    throw new Error("unsupported script language");
  }
  function n(r) {
    return n0(t(r));
  }
  e.is = function(r) {
    return !!r && typeof r.expression == "string" && !!r.language;
  }, e.areEqual = function(r, i) {
    return r.language === i.language && r.expression === i.expression;
  }, e.toExpression = t, e.toQuery = n, e.toLoci = function(r, i) {
    var a = n(r)(new Cc(i));
    return Ke.toLociWithSourceUnits(a);
  }, e.getStructureSelection = function(r, i, a) {
    return n0(typeof r == "function" ? r(ot) : r)(new Cc(i, a));
  };
})(vu || (vu = {})), function(e) {
  function t(n) {
    return n.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(n, r) {
    if (n.layers.length === 0 && r.layers.length === 0) return !0;
    if (n.layers.length !== r.layers.length) return !1;
    for (var i = 0, a = n.layers.length; i < a; ++i)
      if (n.layers[i].clear !== r.layers[i].clear || n.layers[i].color !== r.layers[i].color || !rn.areEqual(n.layers[i].loci, r.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(n, r) {
    for (var i = [], a = 0, o = n.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.color, l = s.clear;
      u = Se.remap(u, r), Se.isEmpty(u) || i.push({ loci: u, color: c, clear: l });
    }
    return { layers: i };
  }, e.merge = function(n) {
    if (t(n)) return n;
    for (var r = n.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Se.none(r), o = 0, s = n.layers.length; o < s; ++o) {
      var u = n.layers[s - o - 1], c = u.loci, l = u.color, d = u.clear;
      if (c = Se.subtract(c, a), a = Se.union(c, a), !Se.isEmpty(c)) {
        var m = d ? -1 : l;
        i.has(m) && (c = Se.union(c, i.get(m))), i.set(m, c);
      }
    }
    var p = [];
    return i.forEach(function(v, f) {
      var y = f === -1, h = y ? ye(0) : f;
      p.push({ loci: v, color: h, clear: y });
    }), { layers: p };
  }, e.filter = function(n, r) {
    if (t(n)) return n;
    for (var i = n.layers[0].loci.structure, a = [], o = 0, s = n.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.color, d = u.clear, m = Se.remap(c, r);
      c = Se.remap(m, i), Se.isEmpty(c) || a.push({ loci: c, color: l, clear: d });
    }
    return { layers: a };
  }, e.ofScript = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.script, c = s.color, l = s.clear, d = vu.toLoci(u, r);
      Se.isEmpty(d) || i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, e.ofBundle = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.bundle, c = s.color, l = s.clear, d = Ci.toLoci(u, r.root);
      i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, e.toBundle = function(n) {
    for (var r = [], i = 0, a = n.layers.length; i < a; ++i) {
      var o = n.layers[i], s = o.loci, u = o.color, c = o.clear, l = Ci.fromLoci(s);
      r.push({ bundle: l, color: u, clear: c });
    }
    return { layers: r };
  };
}(xf || (xf = {})), function(e) {
  function t(n) {
    return n.layers.length === 0;
  }
  e.Empty = { kind: "empty-loci", layers: [] }, e.areEqual = function(n, r) {
    if (n.layers.length === 0 && r.layers.length === 0) return !0;
    if (n.layers.length !== r.layers.length) return !1;
    for (var i = 0, a = n.layers.length; i < a; ++i)
      if (n.layers[i].value !== r.layers[i].value || !rn.areEqual(n.layers[i].loci, r.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(n, r) {
    if (n.kind === "element-loci") {
      for (var i = [], a = 0, o = n.layers; a < o.length; a++) {
        var s = o[a], u = Se.remap(s.loci, r);
        Se.isEmpty(u) || i.push({ loci: u, value: s.value });
      }
      return { kind: "element-loci", layers: i };
    }
    return n;
  }, e.merge = function(n) {
    if (t(n)) return n;
    if (n.kind === "element-loci") {
      for (var r = n.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Se.none(r), o = 0, s = n.layers.length; o < s; ++o) {
        var u = n.layers[s - o - 1], c = u.loci, l = u.value;
        c = Se.subtract(c, a), a = Se.union(c, a), Se.isEmpty(c) || (i.has(l) && (c = Se.union(c, i.get(l))), i.set(l, c));
      }
      var d = [];
      return i.forEach(function(m, p) {
        d.push({ loci: m, value: p });
      }), { kind: "element-loci", layers: d };
    }
    return n;
  }, e.filter = function(n, r) {
    if (t(n)) return n;
    if (n.kind === "element-loci") {
      for (var i = n.layers[0].loci.structure, a = [], o = 0, s = n.layers; o < s.length; o++) {
        var u = s[o], c = u.loci, l = u.value, d = Se.remap(c, r);
        c = Se.remap(d, i), Se.isEmpty(c) || a.push({ loci: c, value: l });
      }
      return { kind: "element-loci", layers: a };
    }
    return n;
  }, e.ofScript = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.script, c = s.value, l = vu.toLoci(u, r);
      Se.isEmpty(l) || i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, e.ofBundle = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.bundle, c = s.value, l = Ci.toLoci(u, r.root);
      i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, e.toBundle = function(n) {
    for (var r = [], i = 0, a = n.layers.length; i < a; ++i) {
      var o = n.layers[i], s = o.loci, u = o.value, c = Ci.fromLoci(s);
      r.push({ bundle: c, value: u });
    }
    return { kind: "element-loci", layers: r };
  };
}(Sf || (Sf = {})), 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;
  };
}(Lo || (Lo = {}));
var Ek = { lowestElementCount: 1e6, lowerElementCount: 5e5, lowElementCount: 1e5, mediumElementCount: 2e4, highElementCount: 2e3, coarseGrainedFactor: 10, elementCountFactor: 1 };
function Tv(e, t) {
  var n = mr(e.quality, "auto"), r = mr(e.detail, 1), i = mr(e.radialSegments, 12), a = mr(e.linearSegments, 8), o = mr(e.resolution, 2), s = mr(e.probePositions, 12), u = mr(e.doubleSided, !0), c = 0;
  if (n === "auto") {
    if (t instanceof Be) n = function(d, m) {
      m === void 0 && (m = {});
      var p = B(B({}, Ek), m), v = d.elementCount * p.elementCountFactor;
      return d.isCoarseGrained && (v *= p.coarseGrainedFactor), v > p.lowestElementCount ? "lowest" : v > p.lowerElementCount ? "lower" : v > p.lowElementCount ? "low" : v > p.mediumElementCount ? "medium" : v > p.highElementCount ? "high" : "higher";
    }(t.root), c = function(d) {
      if (d.root.models.length === 1) {
        var m = Vr.Provider.get(d.root.model);
        if (m && m.spacegroup.name === "P 1" && !Ma.isZero(m.spacegroup.cell)) return m.spacegroup.cell.volume;
      }
      return sn.volume(d.root.boundary.box);
    }(t);
    else if (Tt.is(t)) {
      var l = t.grid.cells.space.dimensions;
      n = (c = l[0] * l[1] * l[2]) < 1e7 ? "medium" : "low";
    }
  }
  switch (n) {
    case "highest":
      r = 3, i = 36, a = 18, o = 0.1, s = 72, u = !0;
      break;
    case "higher":
      r = 3, i = 28, a = 14, o = 0.3, s = 48, u = !0;
      break;
    case "high":
      r = 2, i = 20, a = 10, o = 0.5, s = 36, u = !0;
      break;
    case "medium":
      r = 1, i = 12, a = 8, o = 0.8, s = 24, u = !0;
      break;
    case "low":
      r = 0, i = 8, a = 3, o = 1.3, s = 24, u = !1;
      break;
    case "lower":
      r = 0, i = 4, a = 2, o = 3, s = 12, u = !1;
      break;
    case "lowest":
      r = 0, i = 2, a = 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: r, radialSegments: i, linearSegments: a, resolution: o, probePositions: s, doubleSided: u };
}
function r0(e, t) {
  t === void 0 && (t = 0);
  var n = e[0] * e[1] * e[2], r = Math.sqrt(n), i = Math.pow(2, Math.ceil(Math.log(r) / Math.log(2))), a = e[0] + t, o = e[1] + t, s = 1, u = a;
  return i < a * e[2] ? (a *= u = Math.floor(i / a), o *= s = Math.ceil(e[2] / u)) : a *= e[2], { width: a, height: o, columns: u, rows: s, powerOfTwoSize: o < i ? i : 2 * i };
}
function xm(e, t, n, r, i) {
  var a = e.colorType, o = e.vertexCount, s = e.groupCount, u = e.positionBuffer, c = e.transformBuffer, l = e.groupBuffer, d = e.itemSize, m = a.endsWith("Instance"), p = sn.fromSphere3D(sn(), m ? e.boundingSphere : e.invariantBoundingSphere), v = 1 + t, f = sn.expand(sn(), p, S.create(v, v, v)), y = 1 / t, h = sn.scale(sn(), f, y), g = sn.size(S(), h);
  S.ceil(g, g), S.add(g, g, S.create(2, 2, 2));
  var x = f.min, C = g[0], b = g[1], _ = r0(g), A = _.width, I = _.height, w = new Float32Array(A * I * d), E = new Float32Array(A * I), D = new Uint8Array(A * I * d), T = { array: D, width: A, height: I, filter: "linear" }, P = m ? e.instanceCount : 1, M = e.colorData.array;
  function R(st, ft, It) {
    var pe = Math.floor(It * C % A / C), We = Math.floor(It * C / A);
    return d * (We * b * A + ft * A + (pe * C + st));
  }
  for (var O = g[0], L = g[1], F = g[2], G = S(), V = 0; V < P; ++V) for (var U = 0; U < o; U += n) {
    S.fromArray(G, u, 3 * U), m && S.transformMat4Offset(G, G, c, 0, 0, 16 * V), S.sub(G, G, x), S.scale(G, G, y);
    for (var q = G[0], H = G[1], K = G[2], j = Math.floor(q), W = Math.floor(H), Z = Math.floor(K), Y = (V * s + l[U]) * d, te = Math.max(0, j - 2), ee = Math.max(0, W - 2), $ = Math.max(0, Z - 2), ue = Math.min(O, j + 2 + 2), se = Math.min(L, W + 2 + 2), be = Math.min(F, Z + 2 + 2), ke = te; ke < ue; ++ke) for (var Oe = ke - q, ze = ee; ze < se; ++ze) for (var je = ze - H, xe = $; xe < be; ++xe) {
      var Xe = xe - K, Ee = Math.sqrt(Oe * Oe + je * je + Xe * Xe);
      if (!(Ee > 2)) {
        for (var Ye = 2 - Ee, He = R(ke, ze, xe), le = 0; le < d; ++le) w[He + le] += M[Y + le] * Ye;
        E[He / d] += Ye;
      }
    }
  }
  V = 0;
  for (var Ce = E.length; V < Ce; ++V) {
    var Ae = V * d, Te = E[V];
    for (le = 0; le < d; ++le) D[Ae + le] = Math.round(w[Ae + le] / Te);
  }
  var Re = ge.create(A, I), we = vt.create(x[0], x[1], x[2], y), Qe = m ? "volumeInstance" : "volume";
  if (r) {
    if (!i) {
      var Je = d === 4 ? "rgba" : d === 3 ? "rgb" : "alpha";
      i = r.resources.texture("image-uint8", Je, "ubyte", "linear");
    }
    return i.load(T), { kind: "volume", texture: i, gridTexDim: Re, gridDim: g, gridTransform: we, type: Qe };
  }
  var lt = function(st) {
    var ft = st.vertexCount, It = st.positionBuffer, pe = st.transformBuffer, We = st.grid, gt = st.gridDim, cn = st.gridTexDim, Kt = st.gridTransform, hn = st.vertexStride, jt = st.colorStride, Rn = st.itemOffset || 0, ur = st.outputStride;
    if (ur + Rn > jt) throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
    var ir = st.colorType.endsWith("Instance"), Hn = ir ? st.instanceCount : 1, Dn = hr(Math.max(1, Hn * ft), ur, Uint8Array), Dr = Dn.array, En = gt[0], Tn = gt[1], mi = cn[0], Hr = S.fromArray(S(), Kt, 0), Vo = Kt[3];
    function qn(JA, $A, q3) {
      var eI = Math.floor(q3 * En % mi / En), tI = Math.floor(q3 * En / mi);
      return jt * (tI * Tn * mi + $A * mi + (eI * En + JA));
    }
    for (var kn = S(), zo = S(), Uo = S(), oo = S(), Fc = 0; Fc < Hn; ++Fc) for (var Oa = 0; Oa < ft; ++Oa) {
      S.fromArray(kn, It, Oa * hn), ir && S.transformMat4Offset(kn, kn, pe, 0, 0, 16 * Fc), S.sub(kn, kn, Hr), S.scale(kn, kn, Vo), S.floor(zo, kn), S.ceil(Uo, kn), S.sub(oo, kn, zo), S.sub(kn, Uo, zo), S.div(oo, oo, kn);
      for (var qr = zo[0], Xf = zo[1], Yf = zo[2], Wf = Uo[0], Zf = Uo[1], Qf = Uo[2], Jf = oo[0], H3 = oo[1], EA = oo[2], TA = qn(qr, Xf, Yf) + Rn, MA = qn(Wf, Xf, Yf) + Rn, DA = qn(qr, Xf, Qf) + Rn, BA = qn(Wf, Xf, Qf) + Rn, RA = qn(qr, Zf, Yf) + Rn, kA = qn(Wf, Zf, Yf) + Rn, OA = qn(qr, Zf, Qf) + Rn, NA = qn(Wf, Zf, Qf) + Rn, LA = (Fc * ft + Oa) * ur, Na = 0; Na < ur; ++Na) {
        var FA = We[TA + Na], GA = We[MA + Na], VA = We[DA + Na], zA = We[BA + Na], UA = We[RA + Na], HA = We[kA + Na], qA = We[OA + Na], jA = We[NA + Na], KA = fr(FA, GA, Jf), XA = fr(VA, zA, Jf), YA = fr(UA, HA, Jf), WA = fr(qA, jA, Jf), ZA = fr(KA, YA, H3), QA = fr(XA, WA, H3);
        Dr[LA + Na] = fr(ZA, QA, EA);
      }
    }
    return Dn;
  }({ vertexCount: o, instanceCount: P, transformBuffer: c, positionBuffer: u, colorType: Qe, grid: D, gridDim: g, gridTexDim: Re, gridTransform: we, vertexStride: 3, colorStride: d, outputStride: d });
  return { kind: "vertex", texture: lt, texDim: ge.create(lt.width, lt.height), type: m ? "vertexInstance" : "vertex" };
}
S.set, S.normalize, S.sub, S.addScalar, S.scale, S.toArray;
var Tk = `
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;
}
`, Mk = `
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);
}
`, Dk = `
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
}
`, Bk = { drawCount: tr("number"), instanceCount: tr("number"), stride: tr("number"), uTotalCount: ce("i"), uInstanceCount: ce("i"), uGroupCount: ce("i"), aTransform: tn("float32", 16, 1), aInstance: tn("float32", 1, 1), aSample: tn("float32", 1, 0), uGeoTexDim: ce("v2", "buffered"), tPosition: pt("texture", "rgba", "float", "nearest"), tGroup: pt("texture", "rgba", "float", "nearest"), uColorTexDim: ce("v2"), tColor: pt("texture", "rgba", "ubyte", "nearest"), dColorType: mt("string", ["group", "groupInstance", "vertex", "vertexInstance"]), uCurrentSlice: ce("f"), uCurrentX: ce("f"), uCurrentY: ce("f"), uBboxMin: ce("v3", "material"), uBboxSize: ce("v3", "material"), uResolution: ce("f", "material") }, Yi = "color-accumulate", md = "color-count";
function c6(e, t) {
  for (var n = new Float32Array(e), r = 0; r < e; ++r) n[r] = r * t;
  return n;
}
function Rk(e, t, n, r, i) {
  if (e.namedComputeRenderables[Yi]) {
    var a = S.sub(S(), n.max, n.min), o = e.namedComputeRenderables[Yi].values, s = Math.round(t.vertexCount / i);
    (s > o.drawCount.ref.value || i !== o.stride.ref.value) && k.update(o.aSample, c6(s, i)), k.updateIfChanged(o.drawCount, s), k.updateIfChanged(o.instanceCount, t.instanceCount), k.updateIfChanged(o.stride, i), k.updateIfChanged(o.uTotalCount, t.vertexCount), k.updateIfChanged(o.uInstanceCount, t.instanceCount), k.updateIfChanged(o.uGroupCount, t.groupCount), k.update(o.aTransform, t.transformBuffer), k.update(o.aInstance, t.instanceBuffer), k.update(o.uGeoTexDim, ge.set(o.uGeoTexDim.ref.value, t.positionTexture.getWidth(), t.positionTexture.getHeight())), k.update(o.tPosition, t.positionTexture), k.update(o.tGroup, t.groupTexture), k.update(o.uColorTexDim, ge.set(o.uColorTexDim.ref.value, t.colorData.getWidth(), t.colorData.getHeight())), k.update(o.tColor, t.colorData), k.updateIfChanged(o.dColorType, t.colorType), k.updateIfChanged(o.uCurrentSlice, 0), k.updateIfChanged(o.uCurrentX, 0), k.updateIfChanged(o.uCurrentY, 0), k.update(o.uBboxMin, n.min), k.update(o.uBboxSize, a), k.updateIfChanged(o.uResolution, r), e.namedComputeRenderables[Yi].update();
  } else e.namedComputeRenderables[Yi] = function(u, c, l, d, m) {
    var p = S.sub(S(), l.max, l.min), v = Math.round(c.vertexCount / m), f = { drawCount: k.create(v), instanceCount: k.create(c.instanceCount), stride: k.create(m), uTotalCount: k.create(c.vertexCount), uInstanceCount: k.create(c.instanceCount), uGroupCount: k.create(c.groupCount), aTransform: k.create(c.transformBuffer), aInstance: k.create(c.instanceBuffer), aSample: k.create(c6(v, m)), uGeoTexDim: k.create(ge.create(c.positionTexture.getWidth(), c.positionTexture.getHeight())), tPosition: k.create(c.positionTexture), tGroup: k.create(c.groupTexture), uColorTexDim: k.create(ge.create(c.colorData.getWidth(), c.colorData.getHeight())), tColor: k.create(c.colorData), dColorType: k.create(c.colorType), uCurrentSlice: k.create(0), uCurrentX: k.create(0), uCurrentY: k.create(0), uBboxMin: k.create(l.min), uBboxSize: k.create(p), uResolution: k.create(d) }, y = B({}, Bk), h = Pn("accumulate", Dk, Mk, { drawBuffers: "required" }), g = xr(u, "points", h, y, f);
    return Sr(g, f);
  }(e, t, n, r, i);
  return e.namedComputeRenderables[Yi];
}
var kk = B(B({}, Mr), { tColor: pt("texture", "rgba", "float", "nearest"), tCount: pt("texture", "alpha", "float", "nearest"), uTexSize: ce("v2") }), pd = "color-normalize";
function Ok(e, t, n) {
  if (e.namedComputeRenderables[pd]) {
    var r = e.namedComputeRenderables[pd].values;
    k.update(r.tColor, t), k.update(r.tCount, n), k.update(r.uTexSize, ge.set(r.uTexSize.ref.value, t.getWidth(), t.getHeight())), e.namedComputeRenderables[pd].update();
  } else e.namedComputeRenderables[pd] = function(i, a, o) {
    var s = B(B({}, Er), { tColor: k.create(a), tCount: k.create(o), uTexSize: k.create(ge.create(a.getWidth(), a.getHeight())) }), u = B({}, kk), c = Pn("normalize", ci, Tk), l = xr(i, "triangles", c, u, s);
    return Sr(l, s);
  }(e, t, n);
  return e.namedComputeRenderables[pd];
}
function oh(e, t, n, r, i) {
  var a = r.extensions.drawBuffers;
  if (!a) throw new Error("need WebGL draw buffers");
  var o = r.gl, s = r.resources, u = r.state, c = r.extensions, l = c.colorBufferHalfFloat, d = c.textureHalfFloat, m = e.colorType.endsWith("Instance"), p = sn.fromSphere3D(sn(), m ? e.boundingSphere : e.invariantBoundingSphere), v = 1 + t, f = sn.expand(sn(), p, S.create(v, v, v)), y = 1 / t, h = sn.scale(sn(), f, y), g = sn.size(S(), h);
  S.ceil(g, g), S.add(g, g, S.create(2, 2, 2));
  var x = f.min, C = g[0], b = g[1], _ = g[2], A = function(W) {
    var Z = W[0] * W[1] * W[2], Y = Math.sqrt(Z), te = Math.pow(2, Math.ceil(Math.log(Y) / Math.log(2))), ee = 0, $ = W[1], ue = 1, se = W[2];
    return te < W[0] * W[2] ? (se = Math.floor(te / W[0]), ue = Math.ceil(W[2] / se), ee = se * W[0], $ *= ue) : ee = W[0] * W[2], { texDimX: ee, texDimY: $, texRows: ue, texCols: se, powerOfTwoSize: $ < te ? te : 2 * te };
  }(g), I = A.texDimX, w = A.texDimY, E = A.texCols;
  r.namedFramebuffers[Yi] || (r.namedFramebuffers[Yi] = r.resources.framebuffer());
  var D = r.namedFramebuffers[Yi];
  Et(o) ? (r.namedTextures[Yi] || (r.namedTextures[Yi] = l && d ? s.texture("image-float16", "rgba", "fp16", "nearest") : s.texture("image-float32", "rgba", "float", "nearest")), r.namedTextures[md] || (r.namedTextures[md] = s.texture("image-float32", "alpha", "float", "nearest"))) : (r.namedTextures[Yi] || (r.namedTextures[Yi] = s.texture("image-float32", "rgba", "float", "nearest")), r.namedTextures[md] || (r.namedTextures[md] = s.texture("image-float32", "rgba", "float", "nearest")));
  var T = r.namedTextures[Yi], P = r.namedTextures[md];
  T.define(I, w), P.define(I, w), T.attachFramebuffer(D, 0), P.attachFramebuffer(D, 1);
  var M = Rk(r, e, f, t, n);
  u.currentRenderItemId = -1, D.bind(), a.drawBuffers([a.COLOR_ATTACHMENT0, a.COLOR_ATTACHMENT1]);
  var R = M.values, O = R.uCurrentSlice, L = R.uCurrentX, F = R.uCurrentY;
  (function(W) {
    var Z = W.gl, Y = W.state;
    Y.disable(Z.CULL_FACE), Y.enable(Z.BLEND), Y.disable(Z.DEPTH_TEST), Y.enable(Z.SCISSOR_TEST), Y.depthMask(!1), Y.clearColor(0, 0, 0, 0), Y.blendFunc(Z.ONE, Z.ONE), Y.blendEquation(Z.FUNC_ADD);
  })(r), o.viewport(0, 0, I, w), o.scissor(0, 0, I, w), o.clear(o.COLOR_BUFFER_BIT), k.update(F, 0);
  for (var G = 0, V = 0, U = 0, q = 0; q < _; ++q) G >= E && (G -= E, V += b, U = 0, k.update(F, V)), k.update(L, U), k.update(O, q), o.viewport(U, V, C, b), o.scissor(U, V, C, b), M.render(), ++G, U += C;
  T.detachFramebuffer(D, 0), P.detachFramebuffer(D, 1), a.drawBuffers([o.COLOR_ATTACHMENT0, o.NONE]), i || (i = s.texture("image-uint8", "rgba", "ubyte", "linear")), i.define(I, w);
  var H = Ok(r, T, P);
  u.currentRenderItemId = -1, function(W) {
    var Z = W.gl, Y = W.state;
    Y.disable(Z.CULL_FACE), Y.enable(Z.BLEND), Y.disable(Z.DEPTH_TEST), Y.enable(Z.SCISSOR_TEST), Y.depthMask(!1), Y.clearColor(0, 0, 0, 0), Y.blendFunc(Z.ONE, Z.ONE), Y.blendEquation(Z.FUNC_ADD);
  }(r), i.attachFramebuffer(D, 0), o.viewport(0, 0, I, w), o.scissor(0, 0, I, w), o.clear(o.COLOR_BUFFER_BIT), H.render();
  var K = vt.create(x[0], x[1], x[2], y), j = m ? "volumeInstance" : "volume";
  return { texture: i, gridDim: g, gridTexDim: ge.create(I, w), gridTransform: K, type: j };
}
var Pt, l6, Jc = "color-smoothing-rgba", sh = "color-smoothing-alpha";
function Cf(e) {
  return { layers: e };
}
function Af(e) {
  return { layers: e };
}
(function(e) {
  e.setVisibility = function(t, n) {
    t && (t.state.visible = n);
  }, e.setAlphaFactor = function(t, n) {
    t && (t.state.alphaFactor = n);
  }, e.setPickable = function(t, n) {
    t && (t.state.pickable = n);
  }, e.setColorOnly = function(t, n) {
    t && (t.state.colorOnly = n);
  }, e.mark = function(t, n, r, i, a) {
    if (!t || Cu(n)) return !1;
    var o = t.values, s = o.tMarker, u = o.uMarker, c = o.markerAverage, l = o.markerStatus, d = o.uGroupCount, m = o.instanceCount, p = d.ref.value * m.ref.value, v = s.ref.value.array, f = l.ref.value;
    if (!Vi(n)) {
      var y = 0;
      if (i(n, function(b) {
        return y += oe.size(b), !0;
      }, !0), y === 0) return !1;
      y === p && (n = n3);
    }
    var h = !1, g = -1, x = -1;
    if (Vi(n)) {
      var C = function(b, _) {
        var A = -1, I = -1;
        switch (b) {
          case $e.Highlight:
            _ === 0 || _ === 1 ? (A = 1, I = 1) : _ === 2 || _ === 3 ? (A = 1, I = 3) : A = 1;
            break;
          case $e.RemoveHighlight:
            _ === 0 || _ === 1 ? (A = 0, I = 0) : _ !== 2 && _ !== 3 || (A = 1, I = 2);
            break;
          case $e.Select:
            _ === 1 || _ === 3 ? (A = 1, I = 3) : _ === 0 || _ === 2 ? (A = 1, I = 2) : A = 1;
            break;
          case $e.Deselect:
            _ === 1 || _ === 3 ? (A = 1, I = 1) : _ !== 0 && _ !== 2 || (A = 0, I = 0);
            break;
          case $e.Toggle:
            _ === 1 ? (A = 1, I = 3) : _ === 2 ? (A = 0, I = 0) : _ === 3 ? (A = 1, I = 1) : _ === 0 && (A = 1, I = 2);
            break;
          case $e.Clear:
            A = 0, I = 0;
        }
        return { average: A, status: I };
      }(r, f);
      C.status !== -1 ? (h = f !== C.status) && function(b, _, A) {
        b.fill(_, 0, A);
      }(v, C.status, p) : h = wv(v, oe.ofLength(p), r), g = C.average, x = C.status;
    } else (h = i(n, function(b) {
      return wv(v, b, r);
    }, !0)) && (g = function(b, _) {
      switch (b) {
        case $e.Highlight:
          return 0.5;
        case $e.RemoveHighlight:
          return _ === 0 ? 0 : _ === 2 || _ === 3 ? 0.5 : -1;
        case $e.Select:
          return 0.5;
        case $e.Deselect:
          return _ === 1 || _ === 3 ? 0.5 : _ === 0 ? 0 : -1;
        case $e.Toggle:
          return _ === -1 ? -1 : 0.5;
        case $e.Clear:
          return _ === -1 ? -1 : _ === 0 ? 0 : 0.5;
        case $e.None:
          return -1;
        default:
          Tr();
      }
    }(r, f), a && a.status !== -1 && g === -1 && Wt.isReverse(a.action, r) && rn.areEqual(n, a.loci) && (g = (x = a.status) === 0 ? 0 : 0.5));
    return h && (g === -1 && (g = ix(v, p)) === 0 && (x = 0), a && (a.action = r, a.loci = n, a.status = f), k.updateIfChanged(u, x), x === -1 && k.update(s, s.ref.value), k.updateIfChanged(c, g), k.updateIfChanged(l, x)), h;
  }, e.setOverpaint = function(t, n, r, i, a) {
    if (t) {
      var o = t.values, s = o.tOverpaint, u = o.dOverpaintType, c = o.dOverpaint, l = o.uGroupCount, d = o.instanceCount, m = l.ref.value * d.ref.value;
      (function(w, E) {
        var D = hr(Math.max(1, w), 4, Uint8Array, E && E.tOverpaint.ref.value.array);
        E ? (k.update(E.tOverpaint, D), k.update(E.uOverpaintTexDim, ge.create(D.width, D.height)), k.updateIfChanged(E.dOverpaint, w > 0)) : (k.create(D), k.create(ge.create(D.width, D.height)), k.create(w > 0), k.create(Ni()), k.create(S.create(1, 1, 1)), k.create(vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(n.layers.length ? m : 0, t.values);
      var p = s.ref.value.array;
      i && z5(p, 0, m);
      for (var v = function(w, E) {
        var D = n.layers[w], T = D.loci, P = D.color, M = D.clear;
        r(T, function(R) {
          var O = oe.start(R), L = oe.end(R);
          return M ? z5(p, O, L) : function(F, G, V, U) {
            for (var q = G; q < V; ++q) ye.toArray(U, F, 4 * q), F[4 * q + 3] = 255;
            return !0;
          }(p, O, L, P);
        }, !1);
      }, f = 0, y = n.layers.length; f < y; ++f) v(f);
      if (k.update(s, s.ref.value), k.updateIfChanged(u, "groupInstance"), k.updateIfChanged(c, n.layers.length > 0), n.layers.length !== 0 && a && Vp(a.props)) {
        var h = a.geometry, g = a.props, x = a.webgl;
        if (h.kind === "mesh") {
          var C = h.meta, b = C.resolution, _ = C.overpaintTexture;
          (A = nc(g.smoothColors, !0, b)) && (function(w, E, D, T, P) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(w.dOverpaintType.ref.value)) {
              var M = xm({ vertexCount: w.uVertexCount.ref.value, instanceCount: w.uInstanceCount.ref.value, groupCount: w.uGroupCount.ref.value, transformBuffer: w.aTransform.ref.value, instanceBuffer: w.aInstance.ref.value, positionBuffer: w.aPosition.ref.value, groupBuffer: w.aGroup.ref.value, colorData: w.tOverpaint.ref.value, colorType: w.dOverpaintType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value, itemSize: 4 }, E, D, T, P);
              M.kind === "volume" ? (k.updateIfChanged(w.dOverpaintType, M.type), k.update(w.tOverpaintGrid, M.texture), k.update(w.uOverpaintTexDim, M.gridTexDim), k.update(w.uOverpaintGridDim, M.gridDim), k.update(w.uOverpaintGridTransform, M.gridTransform)) : M.kind === "vertex" && (k.updateIfChanged(w.dOverpaintType, M.type), k.update(w.tOverpaint, M.texture), k.update(w.uOverpaintTexDim, M.texDim));
            }
          }(t.values, A.resolution, A.stride, x, _), h.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        } else if (x && h.kind === "texture-mesh") {
          var A, I = h.meta;
          b = I.resolution, _ = I.overpaintTexture, (A = nc(g.smoothColors, !0, b)) && (function(w, E, D, T, P) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(w.dOverpaintType.ref.value)) {
              D *= 3, T.namedTextures[Jc] || (T.namedTextures[Jc] = T.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var M = T.namedTextures[Jc];
              M.load(w.tOverpaint.ref.value);
              var R = oh({ vertexCount: w.uVertexCount.ref.value, instanceCount: w.uInstanceCount.ref.value, groupCount: w.uGroupCount.ref.value, transformBuffer: w.aTransform.ref.value, instanceBuffer: w.aInstance.ref.value, positionTexture: w.tPosition.ref.value, groupTexture: w.tGroup.ref.value, colorData: M, colorType: w.dOverpaintType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value }, E, D, T, P);
              k.updateIfChanged(w.dOverpaintType, R.type), k.update(w.tOverpaintGrid, R.texture), k.update(w.uOverpaintTexDim, R.gridTexDim), k.update(w.uOverpaintGridDim, R.gridDim), k.update(w.uOverpaintGridTransform, R.gridTransform);
            }
          }(t.values, A.resolution, A.stride, x, _), h.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        }
      }
    }
  }, e.setTransparency = function(t, n, r, i, a) {
    if (t) {
      var o = t.values, s = o.tTransparency, u = o.dTransparencyType, c = o.transparencyAverage, l = o.dTransparency, d = o.uGroupCount, m = o.instanceCount, p = d.ref.value * m.ref.value;
      (function(E, D) {
        var T = hr(Math.max(1, E), 1, Uint8Array, D && D.tTransparency.ref.value.array);
        D ? (k.update(D.tTransparency, T), k.update(D.uTransparencyTexDim, ge.create(T.width, T.height)), k.updateIfChanged(D.dTransparency, E > 0), k.updateIfChanged(D.transparencyAverage, U5(T.array, E))) : (k.create(T), k.create(ge.create(T.width, T.height)), k.create(E > 0), k.create(0), k.create(Ni()), k.create(S.create(1, 1, 1)), k.create(vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(n.layers.length ? p : 0, t.values);
      var v = s.ref.value.array;
      i && function(E, D, T) {
        E.fill(0, D, T);
      }(v, 0, p);
      for (var f = function(E, D) {
        var T = n.layers[E], P = T.loci, M = T.value;
        r(P, function(R) {
          var O = oe.start(R), L = oe.end(R);
          return function(F, G, V, U) {
            for (var q = G; q < V; ++q) F[q] = 255 * U;
            return !0;
          }(v, O, L, M);
        }, !1);
      }, y = 0, h = n.layers.length; y < h; ++y) f(y);
      if (k.update(s, s.ref.value), k.updateIfChanged(c, U5(v, p)), k.updateIfChanged(u, "groupInstance"), k.updateIfChanged(l, n.layers.length > 0), n.layers.length !== 0 && a && Vp(a.props)) {
        var g = a.geometry, x = a.props, C = a.webgl;
        if (g.kind === "mesh") {
          var b = g.meta, _ = b.resolution, A = b.transparencyTexture;
          (I = nc(x.smoothColors, !0, _)) && (function(E, D, T, P, M) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(E.dTransparencyType.ref.value)) {
              var R = xm({ vertexCount: E.uVertexCount.ref.value, instanceCount: E.uInstanceCount.ref.value, groupCount: E.uGroupCount.ref.value, transformBuffer: E.aTransform.ref.value, instanceBuffer: E.aInstance.ref.value, positionBuffer: E.aPosition.ref.value, groupBuffer: E.aGroup.ref.value, colorData: E.tTransparency.ref.value, colorType: E.dTransparencyType.ref.value, boundingSphere: E.boundingSphere.ref.value, invariantBoundingSphere: E.invariantBoundingSphere.ref.value, itemSize: 1 }, D, T, P, M);
              R.kind === "volume" ? (k.updateIfChanged(E.dTransparencyType, R.type), k.update(E.tTransparencyGrid, R.texture), k.update(E.uTransparencyTexDim, R.gridTexDim), k.update(E.uTransparencyGridDim, R.gridDim), k.update(E.uTransparencyGridTransform, R.gridTransform)) : R.kind === "vertex" && (k.updateIfChanged(E.dTransparencyType, R.type), k.update(E.tTransparency, R.texture), k.update(E.uTransparencyTexDim, R.texDim));
            }
          }(t.values, I.resolution, I.stride, C, A), g.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        } else if (C && g.kind === "texture-mesh") {
          var I, w = g.meta;
          _ = w.resolution, A = w.transparencyTexture, (I = nc(x.smoothColors, !0, _)) && (function(E, D, T, P, M) {
            if (/* @__PURE__ */ function(L) {
              return L === "groupInstance";
            }(E.dTransparencyType.ref.value)) {
              T *= 3, P.namedTextures[sh] || (P.namedTextures[sh] = P.resources.texture("image-uint8", "alpha", "ubyte", "nearest"));
              var R = P.namedTextures[sh];
              R.load(E.tTransparency.ref.value);
              var O = oh({ vertexCount: E.uVertexCount.ref.value, instanceCount: E.uInstanceCount.ref.value, groupCount: E.uGroupCount.ref.value, transformBuffer: E.aTransform.ref.value, instanceBuffer: E.aInstance.ref.value, positionTexture: E.tPosition.ref.value, groupTexture: E.tGroup.ref.value, colorData: R, colorType: E.dTransparencyType.ref.value, boundingSphere: E.boundingSphere.ref.value, invariantBoundingSphere: E.invariantBoundingSphere.ref.value }, D, T, P, M);
              k.updateIfChanged(E.dTransparencyType, O.type), k.update(E.tTransparencyGrid, O.texture), k.update(E.uTransparencyTexDim, O.gridTexDim), k.update(E.uTransparencyGridDim, O.gridDim), k.update(E.uTransparencyGridTransform, O.gridTransform);
            }
          }(t.values, I.resolution, I.stride, C, A), g.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        }
      }
    }
  }, e.setSubstance = function(t, n, r, i, a) {
    if (t) {
      var o = t.values, s = o.tSubstance, u = o.dSubstanceType, c = o.dSubstance, l = o.uGroupCount, d = o.instanceCount, m = l.ref.value * d.ref.value;
      (function(w, E) {
        var D = hr(Math.max(1, w), 4, Uint8Array, E && E.tSubstance.ref.value.array);
        E ? (k.update(E.tSubstance, D), k.update(E.uSubstanceTexDim, ge.create(D.width, D.height)), k.updateIfChanged(E.dSubstance, w > 0)) : (k.create(D), k.create(ge.create(D.width, D.height)), k.create(w > 0), k.create(Ni()), k.create(S.create(1, 1, 1)), k.create(vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(n.layers.length ? m : 0, t.values);
      var p = s.ref.value.array;
      i && H5(p, 0, m);
      for (var v = function(w, E) {
        var D = n.layers[w], T = D.loci, P = D.material, M = D.clear;
        r(T, function(R) {
          var O = oe.start(R), L = oe.end(R);
          return M ? H5(p, O, L) : function(F, G, V, U) {
            for (var q = G; q < V; ++q) Nl.toArray(U, F, 4 * q), F[4 * q + 3] = 255;
            return !0;
          }(p, O, L, P);
        }, !1);
      }, f = 0, y = n.layers.length; f < y; ++f) v(f);
      if (k.update(s, s.ref.value), k.updateIfChanged(u, "groupInstance"), k.updateIfChanged(c, n.layers.length > 0), n.layers.length !== 0 && a && Vp(a.props)) {
        var h = a.geometry, g = a.props, x = a.webgl;
        if (h.kind === "mesh") {
          var C = h.meta, b = C.resolution, _ = C.substanceTexture;
          (A = nc(g.smoothColors, !0, b)) && (function(w, E, D, T, P) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(w.dSubstanceType.ref.value)) {
              var M = xm({ vertexCount: w.uVertexCount.ref.value, instanceCount: w.uInstanceCount.ref.value, groupCount: w.uGroupCount.ref.value, transformBuffer: w.aTransform.ref.value, instanceBuffer: w.aInstance.ref.value, positionBuffer: w.aPosition.ref.value, groupBuffer: w.aGroup.ref.value, colorData: w.tSubstance.ref.value, colorType: w.dSubstanceType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value, itemSize: 4 }, E, D, T, P);
              M.kind === "volume" ? (k.updateIfChanged(w.dSubstanceType, M.type), k.update(w.tSubstanceGrid, M.texture), k.update(w.uSubstanceTexDim, M.gridTexDim), k.update(w.uSubstanceGridDim, M.gridDim), k.update(w.uSubstanceGridTransform, M.gridTransform)) : M.kind === "vertex" && (k.updateIfChanged(w.dSubstanceType, M.type), k.update(w.tSubstance, M.texture), k.update(w.uSubstanceTexDim, M.texDim));
            }
          }(t.values, A.resolution, A.stride, x, _), h.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        } else if (x && h.kind === "texture-mesh") {
          var A, I = h.meta;
          b = I.resolution, _ = I.substanceTexture, (A = nc(g.smoothColors, !0, b)) && (function(w, E, D, T, P) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(w.dSubstanceType.ref.value)) {
              D *= 3, T.namedTextures[Jc] || (T.namedTextures[Jc] = T.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var M = T.namedTextures[Jc];
              M.load(w.tSubstance.ref.value);
              var R = oh({ vertexCount: w.uVertexCount.ref.value, instanceCount: w.uInstanceCount.ref.value, groupCount: w.uGroupCount.ref.value, transformBuffer: w.aTransform.ref.value, instanceBuffer: w.aInstance.ref.value, positionTexture: w.tPosition.ref.value, groupTexture: w.tGroup.ref.value, colorData: M, colorType: w.dSubstanceType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value }, E, D, T, P);
              k.updateIfChanged(w.dSubstanceType, R.type), k.update(w.tSubstanceGrid, R.texture), k.update(w.uSubstanceTexDim, R.gridTexDim), k.update(w.uSubstanceGridDim, R.gridDim), k.update(w.uSubstanceGridTransform, R.gridTransform);
            }
          }(t.values, A.resolution, A.stride, x, _), h.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        }
      }
    }
  }, e.setClipping = function(t, n, r, i) {
    if (t) {
      var a = t.values, o = a.tClipping, s = a.dClipping, u = a.uGroupCount, c = a.instanceCount, l = u.ref.value * c.ref.value;
      (function(f, y) {
        var h = hr(Math.max(1, f), 1, Uint8Array, y && y.tClipping.ref.value.array);
        y ? (k.update(y.tClipping, h), k.update(y.uClippingTexDim, ge.create(h.width, h.height)), k.updateIfChanged(y.dClipping, f > 0)) : (k.create(h), k.create(ge.create(h.width, h.height)), k.create(f > 0));
      })(n.layers.length ? l : 0, t.values);
      var d = o.ref.value.array;
      i && function(f, y, h) {
        f.fill(0, y, h);
      }(d, 0, l);
      for (var m = function(f, y) {
        var h = n.layers[f], g = h.loci, x = h.groups;
        r(g, function(C) {
          var b = oe.start(C), _ = oe.end(C);
          return function(A, I, w, E) {
            return A.fill(E, I, w), !0;
          }(d, b, _, x);
        }, !1);
      }, p = 0, v = n.layers.length; p < v; ++p) m(p);
      k.update(o, o.ref.value), k.updateIfChanged(s, n.layers.length > 0);
    }
  }, e.setTransform = function(t, n, r) {
    if (t && (n || r)) {
      var i = t.values;
      n && (J.copy(i.matrix.ref.value, n), k.update(i.matrix, i.matrix.ref.value)), r ? (i.extraTransform.ref.value.set(r), k.update(i.extraTransform, i.extraTransform.ref.value)) : r === null && (mv(i.extraTransform.ref.value, i.instanceCount.ref.value), k.update(i.extraTransform, i.extraTransform.ref.value)), ax(i);
      var a = Ir(i.invariantBoundingSphere.ref.value, i.aTransform.ref.value, i.instanceCount.ref.value);
      k.update(i.boundingSphere, a);
    }
  };
})(Pt || (Pt = {})), function(e) {
  function t(n) {
    return n.layers.length === 0;
  }
  e.Empty = { layers: [] }, function(n) {
    function r(i) {
      switch (i) {
        case "one":
          return 1;
        case "two":
          return 2;
        case "three":
          return 4;
        case "four":
          return 8;
        case "five":
          return 16;
        case "six":
          return 32;
      }
    }
    n.is = Qr.has, n.create = function(i) {
      return Qr.create(i);
    }, n.Names = { one: 1, two: 2, three: 4, four: 8, five: 16, six: 32 }, n.isName = function(i) {
      return i in n.Names;
    }, n.fromName = r, n.fromNames = function(i) {
      for (var a = 0, o = 0, s = i.length; o < s; ++o) a |= r(i[o]);
      return a;
    }, n.toNames = function(i) {
      var a = [];
      return n.is(i, 1) && a.push("one"), n.is(i, 2) && a.push("two"), n.is(i, 4) && a.push("three"), n.is(i, 8) && a.push("four"), n.is(i, 16) && a.push("five"), n.is(i, 32) && a.push("six"), a;
    };
  }(e.Groups || (e.Groups = {})), e.areEqual = function(n, r) {
    if (n.layers.length !== r.layers.length) return !1;
    for (var i = 0, a = n.layers.length; i < a; ++i)
      if (n.layers[i].groups !== r.layers[i].groups || !rn.areEqual(n.layers[i].loci, r.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(n, r) {
    for (var i = [], a = 0, o = n.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.groups;
      u = Se.remap(u, r), Se.isEmpty(u) || i.push({ loci: u, groups: c });
    }
    return { layers: i };
  }, e.merge = function(n) {
    if (t(n)) return n;
    for (var r = n.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Se.none(r), o = 0, s = n.layers.length; o < s; ++o) {
      var u = n.layers[s - o - 1], c = u.loci, l = u.groups;
      c = Se.subtract(c, a), a = Se.union(c, a), Se.isEmpty(c) || (i.has(l) && (c = Se.union(c, i.get(l))), i.set(l, c));
    }
    var d = [];
    return i.forEach(function(m, p) {
      d.push({ loci: m, groups: p });
    }), { layers: d };
  }, e.filter = function(n, r) {
    if (t(n)) return n;
    for (var i = n.layers[0].loci.structure, a = [], o = 0, s = n.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.groups, d = Se.remap(c, r);
      c = Se.remap(d, i), Se.isEmpty(c) || a.push({ loci: c, groups: l });
    }
    return { layers: a };
  }, e.ofScript = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.script, c = s.groups, l = vu.toLoci(u, r);
      Se.isEmpty(l) || i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, e.ofBundle = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.bundle, c = s.groups, l = Ci.toLoci(u, r.root);
      i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, e.toBundle = function(n) {
    for (var r = [], i = 0, a = n.layers.length; i < a; ++i) {
      var o = n.layers[i], s = o.loci, u = o.groups, c = Ci.fromLoci(s);
      r.push({ bundle: c, groups: u });
    }
    return { layers: r };
  };
}(Cf || (Cf = {})), function(e) {
  function t(n) {
    return n.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(n, r) {
    if (n.layers.length === 0 && r.layers.length === 0) return !0;
    if (n.layers.length !== r.layers.length) return !1;
    for (var i = 0, a = n.layers.length; i < a; ++i)
      if (n.layers[i].clear !== r.layers[i].clear || !JP(n.layers[i].material, r.layers[i].material) || !rn.areEqual(n.layers[i].loci, r.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(n, r) {
    for (var i = [], a = 0, o = n.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.material, l = s.clear;
      u = Se.remap(u, r), Se.isEmpty(u) || i.push({ loci: u, material: c, clear: l });
    }
    return { layers: i };
  }, e.merge = function(n) {
    if (t(n)) return n;
    for (var r = n.layers[0].loci.structure, i = void 0, a = /* @__PURE__ */ new Map(), o = Se.none(r), s = 0, u = n.layers.length; s < u; ++s) {
      var c = n.layers[u - s - 1], l = c.loci, d = c.material, m = c.clear;
      l = Se.subtract(l, o), o = Se.union(l, o), Se.isEmpty(l) || (m ? i = i ? Se.union(l, i) : l : (a.has(d) && (l = Se.union(l, a.get(d))), a.set(d, l)));
    }
    var p = [];
    return i && p.push({ loci: i, material: Nl(), clear: !0 }), a.forEach(function(v, f) {
      p.push({ loci: v, material: f, clear: !1 });
    }), { layers: p };
  }, e.filter = function(n, r) {
    if (t(n)) return n;
    for (var i = n.layers[0].loci.structure, a = [], o = 0, s = n.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.material, d = u.clear, m = Se.remap(c, r);
      c = Se.remap(m, i), Se.isEmpty(c) || a.push({ loci: c, material: l, clear: d });
    }
    return { layers: a };
  }, e.ofScript = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.script, c = s.material, l = s.clear, d = vu.toLoci(u, r);
      Se.isEmpty(d) || i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, e.ofBundle = function(n, r) {
    for (var i = [], a = 0, o = n.length; a < o; ++a) {
      var s = n[a], u = s.bundle, c = s.material, l = s.clear, d = Ci.toLoci(u, r.root);
      i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, e.toBundle = function(n) {
    for (var r = [], i = 0, a = n.layers.length; i < a; ++i) {
      var o = n.layers[i], s = o.loci, u = o.material, c = o.clear, l = Ci.fromLoci(s);
      r.push({ bundle: l, material: u, clear: c });
    }
    return { layers: r };
  };
}(Af || (Af = {})), function(e) {
  e.getDetaultParams = function(t, n, r) {
    return N.getDefaultValues(t.getParams(n, r));
  };
}(l6 || (l6 = {}));
var Mt, i0, Nk = { name: "", label: "", description: "", factory: function() {
  return Mt.Empty;
}, getParams: function() {
  return {};
}, defaultValues: {}, defaultColorTheme: Cs.EmptyProvider, defaultSizeTheme: Ai.EmptyProvider, isApplicable: function() {
  return !0;
} };
function d6(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 d6(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 n = t.name;
    this._list.splice(this._list.findIndex(function(i) {
      return i.name === n;
    }), 1);
    var r = this._map.get(n);
    r && (this._map.delete(n), this._name.delete(r));
  }, e.prototype.get = function(t) {
    return this._map.get(t) || Nk;
  }, Object.defineProperty(e.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(n) {
      return n.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return d6(this.getApplicableList(t));
  };
})(), function(e) {
  function t() {
    return { visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, syncManually: !1, transform: J.identity(), overpaint: xf.Empty, transparency: Sf.Empty, substance: Af.Empty, clipping: Cf.Empty, markerActions: Wt.All };
  }
  function n(i, a) {
    a.visible !== void 0 && (i.visible = a.visible), a.alphaFactor !== void 0 && (i.alphaFactor = a.alphaFactor), a.pickable !== void 0 && (i.pickable = a.pickable), a.colorOnly !== void 0 && (i.colorOnly = a.colorOnly), a.overpaint !== void 0 && (i.overpaint = a.overpaint), a.transparency !== void 0 && (i.transparency = a.transparency), a.substance !== void 0 && (i.substance = a.substance), a.clipping !== void 0 && (i.clipping = a.clipping), a.syncManually !== void 0 && (i.syncManually = a.syncManually), a.transform !== void 0 && J.copy(i.transform, a.transform), a.markerActions !== void 0 && (i.markerActions = a.markerActions);
  }
  (function(i) {
    i.areEqual = function(a, o) {
      return a.repr === o.repr && rn.areEqual(a.loci, o.loci);
    }, i.isEmpty = function(a) {
      return rn.isEmpty(a.loci);
    }, i.Empty = { loci: Sn };
  })(e.Loci || (e.Loci = {})), e.createState = t, e.updateState = n, e.StateBuilder = { create: t, update: n }, e.Empty = { label: "", groupCount: 0, renderObjects: [], geometryVersion: -1, props: {}, params: {}, updated: new $n(), state: t(), theme: Ba.createEmpty(), createOrUpdate: function() {
    return At.constant("", void 0);
  }, setState: function() {
  }, setTheme: function() {
  }, getLoci: function() {
    return Sn;
  }, mark: function() {
    return !1;
  }, destroy: function() {
  } };
  var r = function() {
    function i() {
      this.curr = /* @__PURE__ */ new Set(), this.next = /* @__PURE__ */ new Set(), this._version = -1;
    }
    return Object.defineProperty(i.prototype, "version", { get: function() {
      return this._version;
    }, enumerable: !1, configurable: !0 }), i.prototype.add = function(a, o) {
      this.next.add(Ta(a, o));
    }, i.prototype.snapshot = function() {
      var a;
      Ii.areEqual(this.curr, this.next) || (this._version += 1), a = [this.next, this.curr], this.curr = a[0], this.next = a[1], this.next.clear();
    }, i;
  }();
  e.GeometryState = r, e.createMulti = function(i, a, o, s, u) {
    var c, l, d, m = this, p = 0, v = new $n(), f = new r(), y = s.create(), h = Ba.createEmpty(), g = {}, x = Object.keys(u).map(function(C, b) {
      g[b] = C;
      var _ = u[C](a, o);
      return _.setState(y), _;
    });
    return { label: i, updated: v, get groupCount() {
      var C = 0;
      if (l) for (var b = l.visuals, _ = 0, A = x.length; _ < A; ++_) b && !b.includes(g[_]) || (C += x[_].groupCount);
      return C;
    }, get renderObjects() {
      var C = [];
      if (l) for (var b = l.visuals, _ = 0, A = x.length; _ < A; ++_) b && !b.includes(g[_]) || C.push.apply(C, x[_].renderObjects);
      return C;
    }, get geometryVersion() {
      return f.version;
    }, get props() {
      return l;
    }, get params() {
      return c;
    }, createOrUpdate: function(C, b) {
      C === void 0 && (C = {}), b && b !== d && (c = o(a, b), d = b, l || (l = N.getDefaultValues(c))), l || (l = {});
      var _ = Tv(Object.assign({}, l || {}, C || {}), d);
      Object.assign(l, C || {}, _ || {});
      var A = l.visuals;
      return At.create("Creating or updating '".concat(i, "' representation"), function(I) {
        return ie(m, 0, void 0, function() {
          var w, E;
          return ne(this, function(D) {
            switch (D.label) {
              case 0:
                w = 0, E = x.length, D.label = 1;
              case 1:
                return w < E ? A && !A.includes(g[w]) ? [3, 3] : [4, x[w].createOrUpdate(l, d).runInContext(I)] : [3, 5];
              case 2:
                D.sent(), D.label = 3;
              case 3:
                f.add(w, x[w].geometryVersion), D.label = 4;
              case 4:
                return ++w, [3, 1];
              case 5:
                return f.snapshot(), v.next(p++), [2];
            }
          });
        });
      });
    }, get state() {
      return y;
    }, get theme() {
      return h;
    }, getLoci: function(C) {
      for (var b = l.visuals, _ = 0, A = x.length; _ < A; ++_) if (!b || b.includes(g[_])) {
        var I = x[_].getLoci(C);
        if (!Cu(I)) return I;
      }
      return Sn;
    }, mark: function(C, b) {
      for (var _ = !1, A = 0, I = x.length; A < I; ++A) _ = x[A].mark(C, b) || _;
      return _;
    }, setState: function(C) {
      s.update(y, C);
      for (var b = 0, _ = x.length; b < _; ++b) x[b].setState(C);
      v.next(p++);
    }, setTheme: function(C) {
      h = C;
      for (var b = 0, _ = x.length; b < _; ++b) x[b].setTheme(C);
    }, destroy: function() {
      for (var C = 0, b = x.length; C < b; ++C) x[C].destroy();
    } };
  }, e.fromRenderObject = function(i, a) {
    var o = this, s = 0, u = new $n(), c = new r(), l = e.createState(), d = Ba.createEmpty(), m = N.clone(Ve.Params), p = N.getDefaultValues(Ve.Params);
    return { label: i, updated: u, get groupCount() {
      return a.values.uGroupCount.ref.value;
    }, get renderObjects() {
      return [a];
    }, get geometryVersion() {
      return c.version;
    }, get props() {
      return p;
    }, get params() {
      return m;
    }, createOrUpdate: function(v) {
      v === void 0 && (v = {});
      var f = Tv(Object.assign({}, p, v));
      return Object.assign(p, v, f), At.create("Updating '".concat(i, "' representation"), function(y) {
        return ie(o, 0, void 0, function() {
          return ne(this, function(h) {
            return c.add(0, a.id), c.snapshot(), u.next(s++), [2];
          });
        });
      });
    }, get state() {
      return l;
    }, get theme() {
      return d;
    }, getLoci: function() {
      return Sn;
    }, mark: function(v, f) {
      return !1;
    }, setState: function(v) {
      v.visible !== void 0 && Pt.setVisibility(a, v.visible), v.alphaFactor !== void 0 && Pt.setAlphaFactor(a, v.alphaFactor), v.pickable !== void 0 && Pt.setPickable(a, v.pickable), v.colorOnly !== void 0 && Pt.setColorOnly(a, v.colorOnly), v.overpaint, v.transparency, v.substance, v.transform !== void 0 && Pt.setTransform(a, v.transform), e.updateState(l, v);
    }, setTheme: function() {
    }, destroy: function() {
    } };
  };
}(Mt || (Mt = {})), function(e) {
  e.create = function() {
    return { view: J.identity(), position: S.create(0, 0, 0), direction: S.create(0, 0, -1), up: S.create(0, 1, 0) };
  };
  var t = S.zero();
  e.update = function(n) {
    S.add(t, n.position, n.direction), J.lookAt(n.view, n.position, t, n.up);
  };
}(i0 || (i0 = {}));
var zl, Lk = function() {
  function e() {
    this.removeList = b4(), this.removeMap = /* @__PURE__ */ new Map(), this.addList = b4(), 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 n = this.removeMap.get(t);
      this.removeMap.delete(t), this.removeList.remove(n);
    }
    if (!this.addMap.has(t)) {
      var r = this.addList.addLast(t);
      this.addMap.set(t, r);
    }
  }, e.prototype.remove = function(t) {
    if (this.addMap.has(t)) {
      var n = this.addMap.get(t);
      this.addMap.delete(t), this.addList.remove(n);
    }
    if (!this.removeMap.has(t)) {
      var r = this.removeList.addLast(t);
      this.removeMap.set(t, r);
    }
  }, 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;
}(), hd = new ka("98");
function f6(e, t, n) {
  hd.reset();
  for (var r = 0, i = e.length; r < i; ++r) if (!n || e[r].state.visible) {
    var a = e[r].values.boundingSphere.ref.value;
    a.radius && hd.includeSphere(a);
  }
  for (hd.finishedIncludeStep(), r = 0, i = e.length; r < i; ++r) if (!n || e[r].state.visible) {
    var o = e[r].values.boundingSphere.ref.value;
    o.radius && hd.radiusSphere(o);
  }
  return hd.getSphere(t);
}
function Fk(e, t) {
  var n = (e.getProgram("colorBlended") || e.getProgram("colorWboit")).id, r = (t.getProgram("colorBlended") || e.getProgram("colorWboit")).id, i = e.materialId, a = t.materialId;
  return n !== r ? n - r : i !== a ? i - a : e.id - t.id;
}
(function(e) {
  e.create = function(t, n) {
    n === void 0 && (n = Qg);
    var r = /* @__PURE__ */ new Map(), i = [], a = de(), o = de(), s = [], u = [], c = !0, l = !0, d = i0.create(), m = d.view, p = d.position, v = d.direction, f = d.up;
    function y(_) {
      if (r.has(_)) return console.warn("RenderObject with id '".concat(_.id, "' already present")), r.get(_);
      var A = bR(t, _, n);
      return i.push(A), _.type === "direct-volume" ? u.push(A) : s.push(A), r.set(_, A), c = !0, l = !0, A;
    }
    function h(_) {
      var A = r.get(_);
      A && (A.dispose(), gm(i, A), gm(s, A), gm(u, A), r.delete(_), c = !0, l = !0);
    }
    var g = new Lk(), x = -1;
    function C() {
      for (var _ = 23, A = 0, I = i.length; A < I; ++A) i[A].state.visible && (_ = 31 * _ + i[A].id | 0);
      return (_ = l7(_)) === -1 && (_ = 0), _;
    }
    function b() {
      return C() !== x && (l = !0, !0);
    }
    return { view: m, position: p, direction: v, up: f, renderables: i, primitives: { view: m, position: p, direction: v, up: f, renderables: s }, volumes: { view: m, position: p, direction: v, up: f, renderables: u }, syncVisibility: b, update: function(_, A) {
      var I;
      if (i0.update(d), _) for (var w = 0, E = _.length; w < E; ++w) (I = r.get(_[w])) === null || I === void 0 || I.update();
      else for (w = 0, E = i.length; w < E; ++w) i[w].update();
      A ? b() : (c = !0, l = !0);
    }, add: function(_) {
      return g.add(_);
    }, remove: function(_) {
      return g.remove(_);
    }, commit: function(_) {
      return _ === void 0 && (_ = Number.MAX_VALUE), function(A) {
        for (var I = nr(), w = 0; E = g.tryGetRemove(); ) if (h(E), ++w % 100 == 0 && nr() - I > A) return !1;
        for (; ; ) {
          var E;
          if (!(E = g.tryGetAdd())) break;
          if (y(E), ++w % 100 == 0 && nr() - I > A) return !1;
        }
        return i.sort(Fk), !0;
      }(_);
    }, get needsCommit() {
      return !g.isEmpty;
    }, has: function(_) {
      return r.has(_);
    }, clear: function() {
      for (var _ = 0, A = i.length; _ < A; ++_) i[_].dispose();
      i.length = 0, r.clear(), c = !0, l = !0;
    }, forEach: function(_) {
      r.forEach(_);
    }, get count() {
      return i.length;
    }, get boundingSphere() {
      return c && (f6(i, a, !1), c = !1), a;
    }, get boundingSphereVisible() {
      return l && (f6(i, o, !0), l = !1, x = C()), o;
    }, getMarkerAverage: function() {
      if (s.length === 0 && u.length === 0) return 0;
      for (var _ = 0, A = 0, I = s.length; A < I; ++A) _ += s[A].values.markerAverage.ref.value;
      for (A = 0, I = u.length; A < I; ++A) _ += u[A].values.markerAverage.ref.value;
      return _ / (s.length + u.length);
    } };
  };
})(zl || (zl = {}));
var Mv = 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 = Kn.createDefaultSnapshot(), this._target = Kn.createDefaultSnapshot(), this._current = Kn.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, n, r) {
    n === void 0 && (n = 0), (!this.inTransition || n > 0) && Kn.copySnapshot(this._source, this.camera.state), this.inTransition || Kn.copySnapshot(this._target, this.camera.state), Kn.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 && n <= 0 || t.mode !== void 0 && t.mode !== this.camera.state.mode ? this.finish(this._target) : (this.inTransition = !0, this.func = r || e.defaultTransition, (!this.inTransition || n > 0) && (this.start = this.t, this.durationMs = n));
  }, e.prototype.tick = function(t) {
    this.t = t, this.update();
  }, e.prototype.finish = function(t) {
    Kn.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), Kn.copySnapshot(this.camera.state, this._current)) : this.finish(this._target);
    }
  }, e;
}();
(function(e) {
  var t = Mn.identity();
  e.defaultTransition = function(n, r, i, a) {
    Kn.copySnapshot(n, a), Mn.slerp(t, Mn.Identity, Mn.rotationTo(t, i.up, a.up), r), S.transformQuat(n.up, i.up, t), S.lerp(n.target, i.target, a.target, r), S.lerp(n.position, i.position, a.position, r), n.radius = fr(i.radius, a.radius, r), n.radiusMax = fr(i.radiusMax, a.radiusMax, r), n.fov = fr(i.fov, a.fov, r), n.fog = fr(i.fog, a.fog, r);
  };
})(Mv || (Mv = {}));
var m6 = S(), p6 = S(), E1 = vt(), Kn = function() {
  function e(t, n, r) {
    n === void 0 && (n = Pr.create(0, 0, 128, 128)), r === void 0 && (r = {}), this.view = J.identity(), this.projection = J.identity(), this.projectionView = J.identity(), this.inverseProjectionView = J.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 Mv(this), this.stateChanged = new cu(this.state), this.prevProjection = J.identity(), this.prevView = J.identity(), this.deltaDirection = S(), this.newPosition = S(), this.viewport = n, this.pixelScale = r.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) {
    S.copy(this.state.position, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "up", { get: function() {
    return this.state.up;
  }, set: function(t) {
    S.copy(this.state.up, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    return this.state.target;
  }, set: function(t) {
    S.copy(this.state.target, t);
  }, enumerable: !1, configurable: !0 }), e.prototype.update = function() {
    var t = this.state;
    if (t.radiusMax === 0) return !1;
    var n = 2 * Math.tan(t.fov / 2) * S.distance(t.position, t.target);
    switch (this.zoom = this.viewport.height / n, function(i) {
      var a = i.state, o = a.radius, s = a.radiusMax, u = (a.mode, a.fog), c = a.clipFar;
      o < 0.01 && (o = 0.01);
      var l = c ? o : s, d = S.distance(i.position, i.target), m = d - o, p = d + l, v = d - l * (-(50 - u) / 50), f = p;
      m = Math.max(Math.min(s, 5), m), p = Math.max(5, p), m === p && (p = m + 0.01), i.near = m, i.far = 2 * p, i.fogNear = v, i.fogFar = f;
    }(this), this.state.mode) {
      case "orthographic":
        (function(i) {
          var a = i.viewport, o = i.zoom, s = i.near, u = i.far, c = i.viewOffset, l = -a.width / 2, d = a.width / 2, m = a.height / 2, p = -a.height / 2, v = (d - l) / (2 * o), f = (m - p) / (2 * o), y = (d + l) / 2, h = (m + p) / 2, g = y - v, x = y + v, C = h + f, b = h - f;
          if (c.enabled) {
            var _ = o / (c.width / c.fullWidth), A = o / (c.height / c.fullHeight), I = (d - l) / c.width, w = (m - p) / c.height;
            x = (g += I * (c.offsetX / _)) + I * (c.width / _), b = (C -= w * (c.offsetY / A)) - w * (c.height / A);
          }
          J.ortho(i.projection, g, x, C, b, s, u), J.lookAt(i.view, i.position, i.target, i.up);
        })(this);
        break;
      case "perspective":
        (function(i) {
          var a = i.viewport.width / i.viewport.height, o = i.near, s = i.far, u = i.viewOffset, c = o * Math.tan(0.5 * i.state.fov), l = 2 * c, d = a * l, m = -0.5 * d;
          u.enabled && (m += u.offsetX * d / u.fullWidth, c -= u.offsetY * l / u.fullHeight, d *= u.width / u.fullWidth, l *= u.height / u.fullHeight), J.perspective(i.projection, m, m + d, c, c - l, o, s), J.lookAt(i.view, i.position, i.target, i.up);
        })(this);
        break;
      default:
        Tr(this.state.mode);
    }
    var r = !J.areEqual(this.projection, this.prevProjection, bn) || !J.areEqual(this.view, this.prevView, bn);
    if (r) {
      if (J.mul(this.projectionView, this.projection, this.view), !J.tryInvert(this.inverseProjectionView, this.projectionView)) return J.copy(this.view, this.prevView), J.copy(this.projection, this.prevProjection), J.mul(this.projectionView, this.projection, this.view), !1;
      J.copy(this.prevView, this.view), J.copy(this.prevProjection, this.projection);
    }
    return r;
  }, e.prototype.setState = function(t, n) {
    !Number.isNaN(t.radius) && t.radius <= 0.01 || (this.transition.apply(t, n), 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, n, r, i) {
    var a = Math.max(n, 0.01), o = this.getTargetDistance(a);
    S.sub(this.deltaDirection, this.target, this.position), i && S.matchDirection(this.deltaDirection, i, this.deltaDirection), S.setMagnitude(this.deltaDirection, this.deltaDirection, o), S.sub(this.newPosition, t, this.deltaDirection);
    var s = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return s.target = S.clone(t), s.radius = a, s.position = S.clone(this.newPosition), r && S.matchDirection(s.up, r, s.up), s;
  }, e.prototype.getInvariantFocus = function(t, n, r, i) {
    var a = Math.max(n, 0.01), o = this.getTargetDistance(a);
    S.copy(this.deltaDirection, i), S.setMagnitude(this.deltaDirection, this.deltaDirection, o), S.sub(this.newPosition, t, this.deltaDirection);
    var s = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return s.target = S.clone(t), s.radius = a, s.position = S.clone(this.newPosition), S.copy(s.up, r), s;
  }, e.prototype.focus = function(t, n, r, i, a) {
    n > 0 && this.setState(this.getFocus(t, n, i, a), r);
  }, e.prototype.project = function(t, n) {
    return function(r, i, a, o) {
      var s = a.x, u = a.y, c = a.width, l = a.height;
      vt.set(co, i[0], i[1], i[2], 1), vt.transformMat4(co, co, o);
      var d = co[3];
      return d !== 0 && (co[0] /= d, co[1] /= d, co[2] /= d), r[0] = (co[0] + 1) * c * 0.5 + s, r[1] = (1 - co[1]) * l * 0.5 + u, r[2] = 0.5 * (co[2] + 1), r[3] = d === 0 ? 0 : 1 / d, r;
    }(t, n, this.viewport, this.projectionView);
  }, e.prototype.unproject = function(t, n) {
    return Od(t, n, this.viewport, this.inverseProjectionView);
  }, e.prototype.getPixelSize = function(t) {
    return this.project(E1, t), this.unproject(m6, E1), E1[0] += 1, this.unproject(p6, E1), S.distance(m6, p6);
  }, 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, n, r, i, a, o, s) {
    t.fullWidth = n, t.fullHeight = r, t.offsetX = i, t.offsetY = a, t.width = o, t.height = s;
  }, e.copyViewOffset = function(t, n) {
    t.enabled = n.enabled, t.fullWidth = n.fullWidth, t.fullHeight = n.fullHeight, t.offsetX = n.offsetX, t.offsetY = n.offsetY, t.width = n.width, t.height = n.height;
  }, e.targetDistance = function(t, n, r, i) {
    var a = Math.max(t, 0.01), o = i < r ? 1 : r / i;
    return Math.abs(a / o / Math.sin(n / 2));
  }, e.createDefaultSnapshot = function() {
    return { mode: "orthographic", fov: Math.PI / 4, position: S.create(0, 0, 100), up: S.create(0, 1, 0), target: S.create(0, 0, 0), radius: 0, radiusMax: 10, fog: 50, clipFar: !0 };
  }, e.copySnapshot = function(t, n) {
    return n && (n.mode !== void 0 && (t.mode = n.mode), n.fov !== void 0 && (t.fov = n.fov), n.position !== void 0 && S.copy(t.position, n.position), n.up !== void 0 && S.copy(t.up, n.up), n.target !== void 0 && S.copy(t.target, n.target), n.radius !== void 0 && (t.radius = n.radius), n.radiusMax !== void 0 && (t.radiusMax = n.radiusMax), n.fog !== void 0 && (t.fog = n.fog), n.clipFar !== void 0 && (t.clipFar = n.clipFar)), t;
  }, e.areSnapshotsEqual = function(t, n) {
    return t.mode === n.mode && t.fov === n.fov && t.radius === n.radius && t.radiusMax === n.radiusMax && t.fog === n.fog && t.clipFar === n.clipFar && S.exactEquals(t.position, n.position) && S.exactEquals(t.up, n.up) && S.exactEquals(t.target, n.target);
  };
})(Kn || (Kn = {}));
var Gk = { radius: 1, detail: 0 };
function Vk(e, t, n) {
  var r = B(B({}, Gk), n), i = r.radius, a = r.detail, o = /* @__PURE__ */ function() {
    var d = [], m = [], p = /* @__PURE__ */ new Map();
    function v(f) {
      var y = "".concat(f[0].toFixed(5), "|").concat(f[1].toFixed(5), "|").concat(f[2].toFixed(5)), h = p.get(y);
      return h === void 0 && (h = d.length / 3, p.set(y, h), d.push.apply(d, f)), h;
    }
    return { vertices: d, indices: m, add: function(f, y, h) {
      m.push(v(f), v(y), v(h));
    } };
  }(), s = o.vertices, u = o.indices;
  (function(d) {
    for (var m = S(), p = S(), v = S(), f = 0; f < t.length; f += 3) S.fromArray(m, e, 3 * t[f + 0]), S.fromArray(p, e, 3 * t[f + 1]), S.fromArray(v, e, 3 * t[f + 2]), l(m, p, v, d);
  })(a), function(d, m) {
    for (var p = 0, v = d.length; p < v; p += 3) S.fromArray(Oi, d, p), S.normalize(Oi, Oi), S.scale(Oi, Oi, m), S.toArray(Oi, d, p);
  }(s, i);
  var c = new Float32Array(s.length);
  return nx(s, u, c, s.length / 3, u.length / 3), { vertices: new Float32Array(s), normals: new Float32Array(c), indices: new Uint32Array(u) };
  function l(d, m, p, v) {
    for (var f = Math.pow(2, v), y = [], h = 0; h <= f; ++h) {
      y[h] = [];
      var g = S();
      S.lerp(g, d, p, h / f);
      var x = S();
      S.lerp(x, m, p, h / f);
      for (var C = f - h, b = 0; b <= C; ++b) if (b === 0 && h === f) y[h][b] = g;
      else {
        var _ = S();
        S.lerp(_, g, x, b / C), y[h][b] = _;
      }
    }
    for (h = 0; h < f; ++h) for (b = 0; b < 2 * (f - h) - 1; ++b) {
      var A = Math.floor(b / 2);
      b % 2 == 0 ? o.add(y[h][A + 1], y[h + 1][A], y[h][A]) : o.add(y[h][A + 1], y[h + 1][A + 1], y[h + 1][A]);
    }
  }
}
var uh, da = (1 + Math.sqrt(5)) / 2, Ox = (uh || (uh = sx([-1, da, 0, 1, da, 0, -1, -da, 0, 1, -da, 0, 0, -1, da, 0, 1, da, 0, -1, -da, 0, 1, -da, da, 0, -1, da, 0, 1, -da, 0, -1, -da, 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])), uh), zk = Ox.vertices, Uk = Ox.indices;
function Nx(e) {
  return 10 * Math.pow(Math.pow(2, e), 2) + 2;
}
var h6 = /* @__PURE__ */ new Map(), Hk = J.identity();
function qk(e) {
  var t = h6.get(e);
  return t === void 0 && (t = function(n) {
    return Vk(zk, Uk, { detail: n, radius: 1 });
  }(e), h6.set(e, t)), t;
}
function yr(e, t, n, r) {
  nt.addPrimitive(e, function(i, a, o) {
    return J.scaleUniformly(i, J.fromTranslation(i, a), o);
  }(Hk, t, n), qk(r));
}
var po = { radiusTop: 1, radiusBottom: 1, height: 1, radialSegments: 8, heightSegments: 1, topCap: !1, bottomCap: !1, thetaStart: 0, thetaLength: 2 * Math.PI }, v6 = S(), g6 = S(), Ti = S(), Mi = S(), ho = S(), $c = S(), jk = { height: 1, topCap: !0, bottomCap: !0 }, y6 = /* @__PURE__ */ new Map(), b6 = S.create(0, 1, 0), Ao = S(), T1 = S(), _6 = S(), gu = J(), x6 = J(), S6 = S(), yl = S(), ch = S();
function a0(e, t, n, r, i) {
  return S.setMagnitude(T1, n, r / 2), S.add(_6, t, T1), i ? S.matchDirection(ch, b6, T1) : S.copy(ch, b6), S.set(S6, 1, r, 1), S.makeRotation(x6, ch, T1), J.scale(e, x6, S6), J.setTranslation(e, _6);
}
var vo = new Int32Array(9);
function i3(e) {
  var t = function(i) {
    var a, o, s, u, c, l, d, m, p;
    return vo[0] = Math.round(1e3 * ((a = i.radiusTop) !== null && a !== void 0 ? a : po.radiusTop)), vo[1] = Math.round(1e3 * ((o = i.radiusBottom) !== null && o !== void 0 ? o : po.radiusBottom)), vo[2] = Math.round(1e3 * ((s = i.height) !== null && s !== void 0 ? s : po.height)), vo[3] = (u = i.radialSegments) !== null && u !== void 0 ? u : po.radialSegments, vo[4] = (c = i.heightSegments) !== null && c !== void 0 ? c : po.heightSegments, vo[5] = ((l = i.topCap) !== null && l !== void 0 ? l : po.topCap) ? 1 : 0, vo[6] = ((d = i.bottomCap) !== null && d !== void 0 ? d : po.bottomCap) ? 1 : 0, vo[7] = Math.round(1e3 * ((m = i.thetaStart) !== null && m !== void 0 ? m : po.thetaStart)), vo[8] = Math.round(1e3 * ((p = i.thetaLength) !== null && p !== void 0 ? p : po.thetaLength)), di(vo);
  }(e), n = y6.get(t);
  if (n === void 0) {
    if (e.radialSegments && e.radialSegments <= 4) {
      var r = function(i, a) {
        var o = i.length / 3;
        if (o < 3) throw new Error("need at least 3 points to build a prism");
        var s = B(B({}, jk), a), u = s.height, c = s.topCap, l = s.bottomCap, d = 2 * o, m = 4 * o, p = (c ? 1 : 0) + (l ? 1 : 0);
        o === 3 ? (d += p, m += 3 * p) : o === 4 ? (d += 2 * p, m += 4 * p) : (d += p * o, m += p * o * 3);
        var v = zf(d, m), f = 0.5 * u;
        S.set(v6, 0, 0, -f), S.set(g6, 0, 0, f);
        for (var y = 0; y < o; ++y) {
          var h = (y + 1) % o;
          S.set(Ti, i[3 * y], i[3 * y + 1], -f), S.set(Mi, i[3 * h], i[3 * h + 1], -f), S.set(ho, i[3 * h], i[3 * h + 1], f), S.set($c, i[3 * y], i[3 * y + 1], f), v.addQuad(Ti, Mi, ho, $c);
        }
        if (o === 3) c && (S.set(Ti, i[0], i[1], -f), S.set(Mi, i[3], i[4], -f), S.set(ho, i[6], i[7], -f), v.add(ho, Mi, Ti)), l && (S.set(Ti, i[0], i[1], f), S.set(Mi, i[3], i[4], f), S.set(ho, i[6], i[7], f), v.add(Ti, Mi, ho));
        else if (o === 4) c && (S.set(Ti, i[0], i[1], -f), S.set(Mi, i[3], i[4], -f), S.set(ho, i[6], i[7], -f), S.set($c, i[9], i[10], -f), v.addQuad($c, ho, Mi, Ti)), l && (S.set(Ti, i[0], i[1], f), S.set(Mi, i[3], i[4], f), S.set(ho, i[6], i[7], f), S.set($c, i[9], i[10], f), v.addQuad(Ti, Mi, ho, $c));
        else for (y = 0; y < o; ++y) h = (y + 1) % o, c && (S.set(Ti, i[3 * y], i[3 * y + 1], -f), S.set(Mi, i[3 * h], i[3 * h + 1], -f), v.add(v6, Mi, Ti)), l && (S.set(Ti, i[3 * y], i[3 * y + 1], f), S.set(Mi, i[3 * h], i[3 * h + 1], f), v.add(Ti, Mi, g6));
        return v.getPrimitive();
      }(B0(Math.max(3, e.radialSegments), !0, e.radiusTop), e);
      n = D0(r, J.rotX90);
    } else n = function(i) {
      var a = B(B({}, po), i), o = a.radiusTop, s = a.radiusBottom, u = a.height, c = a.radialSegments, l = a.heightSegments, d = a.topCap, m = a.bottomCap, p = a.thetaStart, v = a.thetaLength, f = [], y = [], h = [], g = 0, x = [], C = u / 2;
      return function() {
        for (var _ = S.zero(), A = (s - o) / u, I = 0; I <= l; ++I) {
          for (var w = [], E = I / l, D = E * (s - o) + o, T = 0; T <= c; ++T) {
            var P = T / c * v + p, M = Math.sin(P), R = Math.cos(P);
            y.push(D * M, -E * u + C, D * R), S.normalize(_, S.set(_, M, A, R)), h.push.apply(h, _), w.push(g++);
          }
          x.push(w);
        }
        for (T = 0; T < c; ++T) for (I = 0; I < l; ++I) {
          var O = x[I][T], L = x[I + 1][T], F = x[I + 1][T + 1], G = x[I][T + 1];
          f.push(O, L, G), f.push(L, F, G);
        }
      }(), d && o > 0 && b(!0), m && s > 0 && b(!1), { vertices: new Float32Array(y), normals: new Float32Array(h), indices: new Uint32Array(f) };
      function b(_) {
        for (var A = _ === !0 ? o : s, I = _ === !0 ? 1 : -1, w = g, E = 1; E <= c; ++E) y.push(0, C * I, 0), h.push(0, I, 0), ++g;
        var D = g;
        for (E = 0; E <= c; ++E) {
          var T = E / c * v + p, P = Math.cos(T), M = Math.sin(T);
          y.push(A * M, C * I, A * P), h.push(0, I, 0), ++g;
        }
        for (E = 0; E < c; ++E) {
          var R = w + E, O = D + E;
          _ === !0 ? f.push(O, O + 1, R) : f.push(O + 1, O, R);
        }
      }
    }(e);
    y6.set(t, n);
  }
  return n;
}
function pr(e, t, n, r, i) {
  var a = S.distance(t, n) * r;
  S.sub(Ao, n, t), a0(gu, t, Ao, a, !0), nt.addPrimitive(e, gu, i3(i));
}
function Kk(e, t, n, r, i, a) {
  var o = S.distance(t, n) * r, s = i3(a);
  S.sub(Ao, n, t), S.add(yl, t, i), a0(gu, yl, Ao, o, !0), nt.addPrimitive(e, gu, s), S.sub(yl, t, i), a0(gu, yl, Ao, o, !0), nt.addPrimitive(e, gu, s);
}
function sf(e, t, n, r, i, a) {
  var o = Math.floor(i / 2), s = 1 / i;
  if (r < 1) {
    var u = r / 2 / i;
    r += i % 2 == 1 ? u : -u;
  }
  var c = S.distance(t, n) * r, l = i3(a);
  S.sub(Ao, n, t);
  for (var d = 0; d < o; ++d) {
    var m = s * (2 * d + 1);
    S.setMagnitude(Ao, Ao, c * m), S.add(yl, t, Ao), a0(gu, yl, Ao, c * s, !1), nt.addPrimitive(e, gu, l);
  }
}
var nt, Gn = S(), C6 = br(), Jo = S(), go = S(), Vu = S(), M1 = S(), ji = S.fromArray, Xk = S.triangleNormal, A6 = S.copy, D1 = S.transformMat4, I6 = S.transformMat3, w6 = br.directionTransform, Va = he.add3, lh = he.add;
(function(e) {
  function t(r, i, a, o) {
    var s = r.vertices, u = r.normals, c = r.indices, l = r.groups, d = r.currentGroup, m = s.elementCount;
    Va(s, i[0], i[1], i[2]), Va(s, a[0], a[1], a[2]), Va(s, o[0], o[1], o[2]), Xk(Gn, i, a, o);
    for (var p = 0; p < 3; ++p) Va(u, Gn[0], Gn[1], Gn[2]), lh(l, d);
    Va(c, m, m + 1, m + 2);
  }
  function n(r, i, a) {
    for (var o = a.vertices, s = a.normals, u = a.indices, c = r.vertices, l = r.normals, d = r.indices, m = r.groups, p = r.currentGroup, v = c.elementCount, f = w6(C6, i), y = 0, h = o.length; y < h; y += 3) D1(Gn, ji(Gn, o, y), i), Va(c, Gn[0], Gn[1], Gn[2]), I6(Gn, ji(Gn, s, y), f), Va(l, Gn[0], Gn[1], Gn[2]), lh(m, p);
    for (y = 0, h = u.length; y < h; y += 3) Va(d, u[y] + v, u[y + 1] + v, u[y + 2] + v);
  }
  e.createState = function(r, i, a) {
    return r === void 0 && (r = 2048), i === void 0 && (i = 1024), { currentGroup: -1, vertices: he.create(Float32Array, 3, i, a ? a.vertexBuffer.ref.value : r), normals: he.create(Float32Array, 3, i, a ? a.normalBuffer.ref.value : r), indices: he.create(Uint32Array, 3, 3 * i, a ? a.indexBuffer.ref.value : 3 * r), groups: he.create(Float32Array, 1, i, a ? a.groupBuffer.ref.value : r), mesh: a };
  }, e.addTriangle = t, e.addTriangleStrip = function(r, i, a) {
    ji(Vu, i, 3 * a[0]), ji(M1, i, 3 * a[1]);
    for (var o = 2, s = a.length; o < s; o += 2) A6(Jo, Vu), A6(go, M1), ji(Vu, i, 3 * a[o]), ji(M1, i, 3 * a[o + 1]), t(r, Jo, go, Vu), t(r, go, M1, Vu);
  }, e.addTriangleFan = function(r, i, a) {
    ji(Jo, i, 3 * a[0]);
    for (var o = 2, s = a.length; o < s; ++o) ji(go, i, 3 * a[o - 1]), ji(Vu, i, 3 * a[o]), t(r, Jo, Vu, go);
  }, e.addPrimitive = n, e.addPrimitiveFlipped = function(r, i, a) {
    for (var o = a.vertices, s = a.normals, u = a.indices, c = r.vertices, l = r.normals, d = r.indices, m = r.groups, p = r.currentGroup, v = c.elementCount, f = w6(C6, i), y = 0, h = o.length; y < h; y += 3) D1(Gn, ji(Gn, o, y), i), Va(c, Gn[0], Gn[1], Gn[2]), I6(Gn, ji(Gn, s, y), f), Va(l, -Gn[0], -Gn[1], -Gn[2]), lh(m, p);
    for (y = 0, h = u.length; y < h; y += 3) Va(d, u[y + 2] + v, u[y + 1] + v, u[y] + v);
  }, e.addCage = function(r, i, a, o, s, u) {
    for (var c = a.vertices, l = a.edges, d = { radiusTop: o, radiusBottom: o, radialSegments: u }, m = 0, p = l.length; m < p; m += 2) ji(Jo, c, 3 * l[m]), ji(go, c, 3 * l[m + 1]), D1(Jo, Jo, i), D1(go, go, i), yr(r, Jo, o, s), yr(r, go, o, s), pr(r, Jo, go, 1, d);
  }, e.addMesh = function(r, i, a) {
    n(r, i, { vertices: a.vertexBuffer.ref.value.subarray(0, 3 * a.vertexCount), normals: a.normalBuffer.ref.value.subarray(0, 3 * a.vertexCount), indices: a.indexBuffer.ref.value.subarray(0, 3 * a.triangleCount) });
  }, e.getMesh = function(r) {
    var i = r.vertices, a = r.normals, o = r.indices, s = r.groups, u = r.mesh, c = he.compact(i, !0), l = he.compact(o, !0), d = he.compact(a, !0), m = he.compact(s, !0);
    return ht.create(c, l, d, m, r.vertices.elementCount, r.indices.elementCount, u);
  };
})(nt || (nt = {}));
var a3 = { sceneBoundingSpheres: N.Boolean(!1, { description: "Show full scene bounding spheres." }), visibleSceneBoundingSpheres: N.Boolean(!1, { description: "Show visible scene bounding spheres." }), objectBoundingSpheres: N.Boolean(!1, { description: "Show bounding spheres of visible render objects." }), instanceBoundingSpheres: N.Boolean(!1, { description: "Show bounding spheres of visible instances." }) }, Yk = function() {
  function e(t, n, r) {
    this.objectsData = /* @__PURE__ */ new Map(), this.instancesData = /* @__PURE__ */ new Map(), this.scene = zl.create(t, O0), this.parent = n, this._props = B(B({}, N.getDefaultValues(a3)), r);
  }
  return e.prototype.update = function() {
    var t = this, n = B1(this.scene, this.parent.boundingSphere, this.sceneData, _t.lightgrey, Wk);
    n && (this.sceneData = n);
    var r = B1(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, _t.black, Zk);
    r && (this.visibleSceneData = r), this.parent.forEach(function(i, a) {
      var o = t.objectsData.get(a), s = B1(t.scene, i.values.boundingSphere.ref.value, o, _t.tomato, Qk);
      s && t.objectsData.set(a, s);
      var u = t.instancesData.get(a), c = B1(t.scene, i.values.invariantBoundingSphere.ref.value, u, _t.skyblue, Jk, { aTransform: a.values.aTransform, matrix: a.values.matrix, transform: a.values.transform, extraTransform: a.values.extraTransform, uInstanceCount: a.values.uInstanceCount, instanceCount: a.values.instanceCount, aInstance: a.values.aInstance, hasReflection: a.values.hasReflection });
      c && t.instancesData.set(a, c);
    }), this.objectsData.forEach(function(i, a) {
      t.parent.has(a) || (t.scene.remove(i.renderObject), t.objectsData.delete(a));
    }), this.instancesData.forEach(function(i, a) {
      t.parent.has(a) || (t.scene.remove(i.renderObject), t.instancesData.delete(a));
    }), 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(n, r) {
      var i = t.objectsData.get(r);
      i && (i.renderObject.state.visible = r.state.visible && t._props.objectBoundingSpheres);
      var a = t.instancesData.get(r);
      a && (a.renderObject.state.visible = r.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 B1(e, t, n, r, i, a) {
  if (!n || !de.equals(n.boundingSphere, t)) {
    var o = function(u, c) {
      var l = 2, d = Nx(l), m = nt.createState(d, d / 2, c);
      if (u.radius && (yr(m, u.center, u.radius, l), de.hasExtrema(u))) for (var p = 0, v = u.extrema; p < v.length; p++)
        yr(m, v[p], 1, 0);
      return nt.getMesh(m);
    }(t, n && n.mesh), s = n ? n.renderObject : function(u, c, l, d) {
      var m = ht.Utils.createValuesSimple(u, { alpha: 0.1, doubleSided: !1 }, c, 1, d);
      return ad("mesh", m, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, l);
    }(o, r, i, a);
    return n ? k.updateIfChanged(s.values.drawCount, Ur.getDrawCount(o)) : e.add(s), { boundingSphere: de.clone(t), renderObject: s, mesh: o };
  }
}
var Wk = Ms(), Zk = Ms(), Qk = Ms(), Jk = Ms(), dh = S(), fh = S(), P6 = S(), Lx = { maxFps: N.Numeric(30, { min: 10, max: 60, step: 10 }), preferAtomPixelPadding: N.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." }) }, $k = function() {
  function e(t, n, r, i, a) {
    var o = this;
    a === void 0 && (a = {}), this.canvasIdentify = t, this.lociGetter = n, this.input = r, this.camera = i, this.ev = wi.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 = Mt.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = _c.create(0), this.button = _c.create(0), this.modifiers = El.None, this.props = B(B({}, N.getDefaultValues(Lx)), a), r.drag.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, m = s.modifiers;
      o.isInteracting = !0, o.drag(u, c, l, d, m);
    }), r.move.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.inside, d = s.buttons, m = s.button, p = s.modifiers;
      l && !o.isInteracting && o.move(u, c, d, m, p);
    }), r.leave.subscribe(function() {
      o.leave();
    }), r.click.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, m = s.modifiers;
      o.outsideViewport(u, c) || o.click(u, c, l, d, m);
    }), r.interactionEnd.subscribe(function() {
      o.isInteracting = !1;
    }), r.modifiers.subscribe(function(s) {
      o.modify(s);
    });
  }
  return e.prototype.setProps = function(t) {
    Object.assign(this.props, t);
  }, e.prototype.identify = function(t, n) {
    var r = this.startX !== this.endX || this.startY !== this.endY;
    if (t !== 2) {
      if (r) {
        var i = this.canvasIdentify(this.endX, this.endY);
        this.id = i == null ? void 0 : i.id, this.position = i == null ? void 0 : i.position, this.startX = this.endX, this.startY = this.endY;
      }
      if (t === 1) {
        var a = this.getLoci(this.id, this.position);
        return this.events.click.next({ current: a, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ge.create(this.endX, this.endY), position: this.position }), void (this.prevLoci = a);
      }
      if (this.inside && this.currentIdentifyT === n && r && !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: ge.create(this.endX, this.endY), position: this.position }), this.prevLoci = o;
      }
    } else r && !this.outsideViewport(this.startX, this.startY) && (this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: ge.create(this.startX, this.startY), pageEnd: ge.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, Mt.Loci.isEmpty(this.prevLoci) || (this.prevLoci = Mt.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers }));
  }, e.prototype.move = function(t, n, r, i, a) {
    this.inside = !0, this.buttons = r, this.button = i, this.modifiers = a, this.endX = t, this.endY = n;
  }, e.prototype.click = function(t, n, r, i, a) {
    this.endX = t, this.endY = n, this.buttons = r, this.button = i, this.modifiers = a, this.identify(1, 0);
  }, e.prototype.drag = function(t, n, r, i, a) {
    this.endX = t, this.endY = n, this.buttons = r, this.button = i, this.modifiers = a, this.identify(2, 0);
  }, e.prototype.modify = function(t) {
    El.areEqual(t, this.modifiers) || (this.modifiers = t, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ge.create(this.endX, this.endY), position: this.position }));
  }, e.prototype.outsideViewport = function(t, n) {
    var r = this.input, i = this.camera.viewport;
    return t *= r.pixelRatio, n *= r.pixelRatio, t > i.x + i.width || r.height - n > i.y + i.height || t < i.x || r.height - n < i.y;
  }, e.prototype.getLoci = function(t, n) {
    var r, i = this.lociGetter(t), a = i.repr, o = i.loci;
    if (n && a && rt.isLoci(o) && o.bonds.length === 2) {
      var s = o.bonds[0], u = s.aUnit, c = s.aIndex;
      u.conformation.position(u.elements[c], dh), S.sub(P6, this.camera.state.position, this.camera.state.target), S.projectPointOnPlane(fh, n, P6, dh);
      var l = this.camera.getPixelSize(fh), d = a.theme.size.size(o.bonds[0]) * ((r = a.props.sizeFactor) !== null && r !== void 0 ? r : 1);
      if (a.props.lineSizeAttenuation === !1 && (d *= l / 2), d += this.props.preferAtomPixelPadding * l, S.distance(fh, dh) < d) return { repr: a, loci: rt.toFirstStructureElementLoci(o) };
    }
    return { repr: a, loci: o };
  }, e.prototype.dispose = function() {
    this.ev.dispose();
  }, e;
}(), eO = { edgeThresholdMin: N.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 1e-4 }, { description: "Trims the algorithm from processing darks." }), edgeThresholdMax: N.Numeric(0.063, { min: 0.063, max: 0.333, step: 1e-3 }, { description: "The minimum amount of local contrast required to apply algorithm." }), iterations: N.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }), subpixelQuality: N.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." }) }, tO = function() {
  function e(t, n) {
    var r, i, a, o, s, u;
    this.webgl = t, this.renderable = (r = t, a = (i = n).getWidth(), o = i.getHeight(), s = B(B({}, Er), { tColor: k.create(i), uTexSizeInv: k.create(ge.create(1 / a, 1 / o)), dEdgeThresholdMin: k.create(0.0312), dEdgeThresholdMax: k.create(0.125), dIterations: k.create(12), dSubpixelQuality: k.create(0.3) }), u = B({}, nO), Sr(xr(r, "triangles", rO, u, s), s));
  }
  return e.prototype.updateState = function(t) {
    var n = this.webgl, r = n.gl, i = n.state;
    i.enable(r.SCISSOR_TEST), i.disable(r.BLEND), i.disable(r.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, s = t.width, u = t.height;
    r.viewport(a, o, s, u), r.scissor(a, o, s, u), i.clearColor(0, 0, 0, 1), r.clear(r.COLOR_BUFFER_BIT);
  }, e.prototype.setSize = function(t, n) {
    k.update(this.renderable.values.uTexSizeInv, ge.set(this.renderable.values.uTexSizeInv.ref.value, 1 / t, 1 / n));
  }, e.prototype.update = function(t, n) {
    var r = this.renderable.values, i = n.edgeThresholdMin, a = n.edgeThresholdMax, o = n.iterations, s = n.subpixelQuality, u = !1;
    r.tColor.ref.value !== t && (k.update(this.renderable.values.tColor, t), u = !0), r.dEdgeThresholdMin.ref.value !== i && (u = !0), k.updateIfChanged(r.dEdgeThresholdMin, i), r.dEdgeThresholdMax.ref.value !== a && (u = !0), k.updateIfChanged(r.dEdgeThresholdMax, a), r.dIterations.ref.value !== o && (u = !0), k.updateIfChanged(r.dIterations, o), r.dSubpixelQuality.ref.value !== s && (u = !0), k.updateIfChanged(r.dSubpixelQuality, s), u && this.renderable.update();
  }, e.prototype.render = function(t, n) {
    n ? n.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.renderable.render();
  }, e;
}(), nO = B(B({}, Mr), { tColor: pt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ce("v2"), dEdgeThresholdMin: mt("number"), dEdgeThresholdMax: mt("number"), dIterations: mt("number"), dSubpixelQuality: mt("number") }), rO = Pn("fxaa", ci, `
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);
}
`), iO = { edgeThreshold: N.Numeric(0.1, { min: 0.05, max: 0.15, step: 0.01 }), maxSearchSteps: N.Numeric(16, { min: 0, max: 32, step: 1 }) }, aO = function() {
  function e(t, n) {
    if (this.webgl = t, this._supported = !1, typeof HTMLImageElement < "u") {
      var r = n.getWidth(), i = n.getHeight();
      this.edgesTarget = t.createRenderTarget(r, i, !1, "uint8", "linear"), this.weightsTarget = t.createRenderTarget(r, i, !1, "uint8", "linear"), this.edgesRenderable = function(a, o) {
        var s = o.getWidth(), u = o.getHeight(), c = B(B({}, Er), { tColor: k.create(o), uTexSizeInv: k.create(ge.create(1 / s, 1 / u)), uViewport: k.create(vt()), dEdgeThreshold: k.create(0.1) }), l = B({}, oO);
        return Sr(xr(a, "triangles", sO, l, c), c);
      }(t, n), this.weightsRenderable = function(a, o) {
        var s = o.getWidth(), u = o.getHeight(), c = Y2(a.gl, a.extensions, "image-uint8", "rgb", "ubyte", "linear"), l = Y2(a.gl, a.extensions, "image-uint8", "rgba", "ubyte", "nearest"), d = B(B({}, Er), { tEdges: k.create(o), tArea: k.create(c), tSearch: k.create(l), uTexSizeInv: k.create(ge.create(1 / s, 1 / u)), uViewport: k.create(vt()), dMaxSearchSteps: k.create(16) });
        c4("data:image/png;base64, ", d.tArea, c), c4("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=", d.tSearch, l);
        var m = B({}, uO);
        return Sr(xr(a, "triangles", cO, m, d), d);
      }(t, this.edgesTarget.texture), this.blendRenderable = function(a, o, s) {
        var u = o.getWidth(), c = o.getHeight(), l = B(B({}, Er), { tColor: k.create(o), tWeights: k.create(s), uTexSizeInv: k.create(ge.create(1 / u, 1 / c)), uViewport: k.create(vt()) }), d = B({}, lO);
        return Sr(xr(a, "triangles", dO, d, l), l);
      }(t, n, this.weightsTarget.texture), this._supported = !0;
    } else Xt && 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 n = this.webgl, r = n.gl, i = n.state;
    i.enable(r.SCISSOR_TEST), i.disable(r.BLEND), i.disable(r.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, s = t.width, u = t.height;
    r.viewport(a, o, s, u), r.scissor(a, o, s, u), i.clearColor(0, 0, 0, 1), r.clear(r.COLOR_BUFFER_BIT), k.update(this.edgesRenderable.values.uViewport, Pr.toVec4(this.edgesRenderable.values.uViewport.ref.value, t)), k.update(this.weightsRenderable.values.uViewport, Pr.toVec4(this.weightsRenderable.values.uViewport.ref.value, t)), k.update(this.blendRenderable.values.uViewport, Pr.toVec4(this.blendRenderable.values.uViewport.ref.value, t));
  }, e.prototype.setSize = function(t, n) {
    var r = this.edgesTarget.getWidth(), i = this.edgesTarget.getHeight();
    t === r && n === i || (this.edgesTarget.setSize(t, n), this.weightsTarget.setSize(t, n), k.update(this.edgesRenderable.values.uTexSizeInv, ge.set(this.edgesRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / n)), k.update(this.weightsRenderable.values.uTexSizeInv, ge.set(this.weightsRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / n)), k.update(this.blendRenderable.values.uTexSizeInv, ge.set(this.blendRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / n)));
  }, e.prototype.update = function(t, n) {
    var r = !1;
    this.edgesRenderable.values.tColor.ref.value !== t && (k.update(this.edgesRenderable.values.tColor, t), r = !0), this.edgesRenderable.values.dEdgeThreshold.ref.value !== n.edgeThreshold && (k.update(this.edgesRenderable.values.dEdgeThreshold, n.edgeThreshold), r = !0), r && this.edgesRenderable.update(), this.weightsRenderable.values.dMaxSearchSteps.ref.value !== n.maxSearchSteps && (k.update(this.weightsRenderable.values.dMaxSearchSteps, n.maxSearchSteps), this.weightsRenderable.update()), this.blendRenderable.values.tColor.ref.value !== t && (k.update(this.blendRenderable.values.tColor, t), this.blendRenderable.update());
  }, e.prototype.render = function(t, n) {
    this.edgesTarget.bind(), this.updateState(t), this.edgesRenderable.render(), this.weightsTarget.bind(), this.updateState(t), this.weightsRenderable.render(), n ? n.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.blendRenderable.render();
  }, e;
}(), oO = B(B({}, Mr), { tColor: pt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ce("v2"), uViewport: ce("v4"), dEdgeThreshold: mt("number") }), sO = Pn("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);
}
`), uO = B(B({}, Mr), { tEdges: pt("texture", "rgba", "ubyte", "linear"), tArea: pt("texture", "rgb", "ubyte", "linear"), tSearch: pt("texture", "rgba", "ubyte", "nearest"), uTexSizeInv: ce("v2"), uViewport: ce("v4"), dMaxSearchSteps: mt("number") }), cO = Pn("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));
}
`), lO = B(B({}, Mr), { tColor: pt("texture", "rgba", "ubyte", "linear"), tWeights: pt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ce("v2"), uViewport: ce("v4") }), dO = Pn("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);
}
`), fO = B(B({}, Mr), { tDepth: pt("texture", "rgba", "ubyte", "nearest"), uTexSize: ce("v2"), dOrthographic: mt("number"), uNear: ce("f"), uFar: ce("f"), uMaxPossibleViewZDiff: ce("f") }), mO = B(B({}, Mr), { tDepth: pt("texture", "rgba", "ubyte", "nearest"), uSamples: ce("v3[]"), dNSamples: mt("number"), uProjection: ce("m4"), uInvProjection: ce("m4"), uBounds: ce("v4"), uTexSize: ce("v2"), uRadius: ce("f"), uBias: ce("f") }), pO = B(B({}, Mr), { tSsaoDepth: pt("texture", "rgba", "ubyte", "nearest"), uTexSize: ce("v2"), uKernel: ce("f[]"), dOcclusionKernelSize: mt("number"), uBlurDirectionX: ce("f"), uBlurDirectionY: ce("f"), uMaxPossibleViewZDiff: ce("f"), uNear: ce("f"), uFar: ce("f"), uBounds: ce("v4"), dOrthographic: mt("number") });
function E6(e, t, n) {
  var r = B(B({}, Er), { tSsaoDepth: k.create(t), uTexSize: k.create(ge.create(t.getWidth(), t.getHeight())), uKernel: k.create([0]), dOcclusionKernelSize: k.create(15), uBlurDirectionX: k.create(n === "horizontal" ? 1 : 0), uBlurDirectionY: k.create(n === "vertical" ? 1 : 0), uMaxPossibleViewZDiff: k.create(0.5), uNear: k.create(0), uFar: k.create(1e4), uBounds: k.create(vt()), dOrthographic: k.create(0) }), i = B({}, pO);
  return Sr(xr(e, "triangles", Pn("ssao_blur", ci, `
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);
}
`), i, r), r);
}
var hO = B(B({}, Mr), { tSsaoDepth: pt("texture", "rgba", "ubyte", "nearest"), tColor: pt("texture", "rgba", "ubyte", "nearest"), tDepth: pt("texture", "rgba", "ubyte", "nearest"), tOutlines: pt("texture", "rgba", "ubyte", "nearest"), uTexSize: ce("v2"), dOrthographic: mt("number"), uNear: ce("f"), uFar: ce("f"), uFogNear: ce("f"), uFogFar: ce("f"), uFogColor: ce("v3"), uOutlineColor: ce("v3"), uTransparentBackground: ce("b"), uMaxPossibleViewZDiff: ce("f"), dOcclusionEnable: mt("boolean"), uOcclusionOffset: ce("v2"), dOutlineEnable: mt("boolean"), dOutlineScale: mt("number"), uOutlineThreshold: ce("f") }), Fx = { occlusion: N.MappedStatic("on", { on: N.Group({ samples: N.Numeric(32, { min: 1, max: 256, step: 1 }), radius: N.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: "Final occlusion radius is 2^x" }), bias: N.Numeric(0.8, { min: 0, max: 3, step: 0.1 }), blurKernelSize: N.Numeric(15, { min: 1, max: 25, step: 2 }), resolutionScale: N.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" }) }), off: N.Group({}) }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect" }), outline: N.MappedStatic("off", { on: N.Group({ scale: N.Numeric(1, { min: 1, max: 5, step: 1 }), threshold: N.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }), color: N.Color(ye(0)) }), off: N.Group({}) }, { cycle: !0, description: "Draw outline around 3D objects" }), antialiasing: N.MappedStatic("smaa", { fxaa: N.Group(eO), smaa: N.Group(iO), off: N.Group({}) }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges" }) }, os = function() {
  function e(t, n) {
    this.webgl = t, this.drawPass = n, this.occlusionOffset = [0, 0];
    var r = n.colorTarget, i = n.depthTexture, a = r.getWidth(), o = r.getHeight();
    this.nSamples = 1, this.blurKernelSize = 1, this.downsampleFactor = 1, this.ssaoScale = this.calcSsaoScale(), this.target = t.createRenderTarget(a, o, !1, "uint8", "linear"), this.outlinesTarget = t.createRenderTarget(a, o, !1), this.outlinesRenderable = function(d, m) {
      var p = B(B({}, Er), { tDepth: k.create(m), uTexSize: k.create(ge.create(m.getWidth(), m.getHeight())), dOrthographic: k.create(0), uNear: k.create(1), uFar: k.create(1e4), uMaxPossibleViewZDiff: k.create(0.5) }), v = B({}, fO);
      return Sr(xr(d, "triangles", Pn("outlines", ci, `
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);
}
`), v, p), p);
    }(t, i), this.randomHemisphereVector = [];
    for (var s = 0; s < 256; s++) {
      var u = S();
      u[0] = 2 * Math.random() - 1, u[1] = 2 * Math.random() - 1, u[2] = Math.random(), S.normalize(u, u), S.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(a * this.ssaoScale), l = Math.floor(o * this.ssaoScale);
    this.downsampledDepthTarget = t.createRenderTarget(c, l, !1, "uint8", "linear"), this.downsampleDepthRenderable = pv(t, i), 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, m) {
      var p = B(B({}, Er), { tDepth: k.create(m), uSamples: k.create([0, 0, 1]), dNSamples: k.create(32), uProjection: k.create(J.identity()), uInvProjection: k.create(J.identity()), uBounds: k.create(vt()), uTexSize: k.create(ge.create(d.gl.drawingBufferWidth, d.gl.drawingBufferHeight)), uRadius: k.create(8), uBias: k.create(0.025) }), v = B({}, mO);
      return Sr(xr(d, "triangles", Pn("ssao", ci, `
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);
}
`), v, p), p);
    }(t, this.downsampleFactor === 1 ? i : this.downsampledDepthTarget.texture), this.ssaoBlurFirstPassRenderable = E6(t, this.ssaoDepthTexture, "horizontal"), this.ssaoBlurSecondPassRenderable = E6(t, this.ssaoDepthBlurProxyTexture, "vertical"), this.renderable = function(d, m, p, v, f) {
      var y = B(B({}, Er), { tSsaoDepth: k.create(f), tColor: k.create(m), tDepth: k.create(p), tOutlines: k.create(v), uTexSize: k.create(ge.create(m.getWidth(), m.getHeight())), dOrthographic: k.create(0), uNear: k.create(1), uFar: k.create(1e4), uFogNear: k.create(1e4), uFogFar: k.create(1e4), uFogColor: k.create(S.create(1, 1, 1)), uOutlineColor: k.create(S.create(0, 0, 0)), uTransparentBackground: k.create(!1), uMaxPossibleViewZDiff: k.create(0.5), dOcclusionEnable: k.create(!0), uOcclusionOffset: k.create(ge.create(0, 0)), dOutlineEnable: k.create(!1), dOutlineScale: k.create(1), uOutlineThreshold: k.create(0.33) }), h = B({}, hO);
      return Sr(xr(d, "triangles", Pn("postprocessing", ci, `
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;
}
`), h, y), y);
    }(t, r.texture, i, 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, n) {
    var r = this.renderable.values.uTexSize.ref.value, i = r[0], a = r[1], o = this.calcSsaoScale();
    if (t !== i || n !== a || this.ssaoScale !== o) {
      this.ssaoScale = o;
      var s = Math.floor(t * this.ssaoScale), u = Math.floor(n * this.ssaoScale);
      this.target.setSize(t, n), this.outlinesTarget.setSize(t, n), this.downsampledDepthTarget.setSize(s, u), this.ssaoDepthTexture.define(s, u), this.ssaoDepthBlurProxyTexture.define(s, u), k.update(this.renderable.values.uTexSize, ge.set(this.renderable.values.uTexSize.ref.value, t, n)), k.update(this.outlinesRenderable.values.uTexSize, ge.set(this.outlinesRenderable.values.uTexSize.ref.value, t, n)), k.update(this.downsampleDepthRenderable.values.uTexSize, ge.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, s, u)), k.update(this.ssaoRenderable.values.uTexSize, ge.set(this.ssaoRenderable.values.uTexSize.ref.value, s, u)), k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ge.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, s, u)), k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ge.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, s, u));
    }
  }, e.prototype.updateState = function(t, n, r, i) {
    var a = !1, o = !1, s = !1, u = t.state.mode === "orthographic" ? 1 : 0, c = i.outline.name === "on", l = i.occlusion.name === "on", d = J.identity();
    if (J.invert(d, t.projection), i.occlusion.name === "on") {
      k.update(this.ssaoRenderable.values.uProjection, t.projection), k.update(this.ssaoRenderable.values.uInvProjection, d);
      var m = this.renderable.values.uTexSize.ref.value, p = m[0], v = m[1], f = this.ssaoRenderable.values.uBounds, y = t.viewport, h = this.ssaoScale;
      if (vt.set(f.ref.value, Math.floor(y.x * h) / (p * h), Math.floor(y.y * h) / (v * h), Math.ceil((y.x + y.width) * h) / (p * h), Math.ceil((y.y + y.height) * h) / (v * h)), k.update(f, f.ref.value), k.update(this.ssaoBlurFirstPassRenderable.values.uBounds, f.ref.value), k.update(this.ssaoBlurSecondPassRenderable.values.uBounds, f.ref.value), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear, t.near), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear, t.near), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar, t.far), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar, t.far), this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value !== u && (s = !0), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOrthographic, u), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOrthographic, u), this.nSamples !== i.occlusion.params.samples && (o = !0, this.nSamples = i.occlusion.params.samples, k.update(this.ssaoRenderable.values.uSamples, function(O, L) {
        for (var F = [], G = 0; G < L; G++) {
          var V = (G * G + 2 * G + 1) / (L * L);
          V = 0.1 + 0.9 * V, F.push(O[G][0] * V), F.push(O[G][1] * V), F.push(O[G][2] * V);
        }
        return F;
      }(this.randomHemisphereVector, this.nSamples)), k.updateIfChanged(this.ssaoRenderable.values.dNSamples, this.nSamples)), k.updateIfChanged(this.ssaoRenderable.values.uRadius, Math.pow(2, i.occlusion.params.radius)), k.updateIfChanged(this.ssaoRenderable.values.uBias, i.occlusion.params.bias), this.blurKernelSize !== i.occlusion.params.blurKernelSize) {
        s = !0, this.blurKernelSize = i.occlusion.params.blurKernelSize;
        var g = function(O) {
          for (var L = O / 3, F = Math.floor((O + 1) / 2), G = [], V = 0; V < F; V++) G.push(1 / (Math.sqrt(2 * Math.PI) * L) * Math.exp(-V * V / (2 * L * L)));
          return G;
        }(this.blurKernelSize);
        k.update(this.ssaoBlurFirstPassRenderable.values.uKernel, g), k.update(this.ssaoBlurSecondPassRenderable.values.uKernel, g), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
      }
      if (this.downsampleFactor !== i.occlusion.params.resolutionScale) {
        o = !0, this.downsampleFactor = i.occlusion.params.resolutionScale, this.ssaoScale = this.calcSsaoScale();
        var x = Math.floor(p * this.ssaoScale), C = Math.floor(v * this.ssaoScale);
        this.downsampledDepthTarget.setSize(x, C), this.ssaoDepthTexture.define(x, C), this.ssaoDepthBlurProxyTexture.define(x, C), this.ssaoScale === 1 ? k.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture) : k.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture), k.update(this.downsampleDepthRenderable.values.uTexSize, ge.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, x, C)), k.update(this.ssaoRenderable.values.uTexSize, ge.set(this.ssaoRenderable.values.uTexSize.ref.value, x, C)), k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ge.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, x, C)), k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ge.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, x, C));
      }
    }
    if (i.outline.name === "on") {
      var b = i.outline.params.threshold;
      t.state.mode === "orthographic" && (b /= 5);
      var _ = Math.pow(1e3, b) / 1e3 * t.state.radiusMax, A = i.outline.params.scale - 1;
      k.updateIfChanged(this.outlinesRenderable.values.uNear, t.near), k.updateIfChanged(this.outlinesRenderable.values.uFar, t.far), k.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, _), k.update(this.renderable.values.uOutlineColor, ye.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, i.outline.params.color)), k.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, _), this.renderable.values.dOutlineScale.ref.value !== A && (a = !0), k.updateIfChanged(this.renderable.values.dOutlineScale, A);
    }
    k.updateIfChanged(this.renderable.values.uFar, t.far), k.updateIfChanged(this.renderable.values.uNear, t.near), k.updateIfChanged(this.renderable.values.uFogFar, t.fogFar), k.updateIfChanged(this.renderable.values.uFogNear, t.fogNear), k.update(this.renderable.values.uFogColor, ye.toVec3Normalized(this.renderable.values.uFogColor.ref.value, r)), k.updateIfChanged(this.renderable.values.uTransparentBackground, n), this.renderable.values.dOrthographic.ref.value !== u && (a = !0), k.updateIfChanged(this.renderable.values.dOrthographic, u), this.renderable.values.dOutlineEnable.ref.value !== c && (a = !0), k.updateIfChanged(this.renderable.values.dOutlineEnable, c), this.renderable.values.dOcclusionEnable.ref.value !== l && (a = !0), k.updateIfChanged(this.renderable.values.dOcclusionEnable, l), o && this.ssaoRenderable.update(), s && (this.ssaoBlurFirstPassRenderable.update(), this.ssaoBlurSecondPassRenderable.update()), a && this.renderable.update();
    var I = this.webgl, w = I.gl, E = I.state;
    E.enable(w.SCISSOR_TEST), E.disable(w.BLEND), E.disable(w.DEPTH_TEST), E.depthMask(!1);
    var D = t.viewport, T = D.x, P = D.y, M = D.width, R = D.height;
    w.viewport(T, P, M, R), w.scissor(T, P, M, R);
  }, e.prototype.setOcclusionOffset = function(t, n) {
    this.occlusionOffset[0] = t, this.occlusionOffset[1] = n, k.update(this.renderable.values.uOcclusionOffset, ge.set(this.renderable.values.uOcclusionOffset.ref.value, t, n));
  }, e.prototype.render = function(t, n, r, i, a) {
    this.updateState(t, r, i, a), a.outline.name === "on" && (this.outlinesTarget.bind(), this.outlinesRenderable.render()), a.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()), n ? 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;
}(), mh = function() {
  function e(t, n) {
    this.drawPass = n;
    var r = n.colorTarget, i = r.getWidth(), a = r.getHeight();
    this.target = t.createRenderTarget(i, a, !1), this.fxaa = new tO(t, this.target.texture), this.smaa = new aO(t, this.target.texture);
  }
  return e.isEnabled = function(t) {
    return t.antialiasing.name !== "off";
  }, e.prototype.setSize = function(t, n) {
    var r = this.target.texture.getWidth(), i = this.target.texture.getHeight();
    t === r && n === i || (this.target.setSize(t, n), this.fxaa.setSize(t, n), this.smaa.supported && this.smaa.setSize(t, n));
  }, e.prototype._renderFxaa = function(t, n, r) {
    if (r.antialiasing.name === "fxaa") {
      var i = os.isEnabled(r) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.fxaa.update(i, r.antialiasing.params), this.fxaa.render(t.viewport, n ? void 0 : this.target);
    }
  }, e.prototype._renderSmaa = function(t, n, r) {
    if (r.antialiasing.name === "smaa") {
      var i = os.isEnabled(r) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.smaa.update(i, r.antialiasing.params), this.smaa.render(t.viewport, n ? void 0 : this.target);
    }
  }, e.prototype.render = function(t, n, r) {
    if (r.antialiasing.name !== "off") {
      if (r.antialiasing.name === "fxaa") this._renderFxaa(t, n, r);
      else if (r.antialiasing.name === "smaa") {
        if (!this.smaa.supported) throw new Error('SMAA not supported, missing "HTMLImageElement"');
        this._renderSmaa(t, n, r);
      }
    }
  }, e;
}(), vO = B(B({}, Mr), { tColor: pt("texture", "rgba", "ubyte", "nearest"), uTexSize: ce("v2"), uWeight: ce("f") }), gO = Pn("compose", ci, `
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;
}
`), Gx = { mode: N.Select("temporal", [["off", "Off"], ["on", "On"], ["temporal", "Temporal"]]), sampleLevel: N.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." }) }, o0 = function() {
  function e(t, n) {
    this.webgl = t, this.drawPass = n;
    var r = t.extensions, i = r.colorBufferFloat, a = r.textureFloat, o = r.colorBufferHalfFloat, s = r.textureHalfFloat, u = n.colorTarget.getWidth(), c = n.colorTarget.getHeight();
    this.colorTarget = t.createRenderTarget(u, c, !1);
    var l, d, m, p, v = o && s ? "fp16" : i && a ? "float32" : "uint8";
    this.composeTarget = t.createRenderTarget(u, c, !1, v), this.holdTarget = t.createRenderTarget(u, c, !1), this.compose = (l = t, d = n.colorTarget.texture, m = B(B({}, Er), { tColor: k.create(d), uTexSize: k.create(ge.create(d.getWidth(), d.getHeight())), uWeight: k.create(1) }), p = B({}, vO), Sr(xr(l, "triangles", gO, p, m), m));
  }
  return e.isEnabled = function(t) {
    return t.mode !== "off";
  }, e.prototype.syncSize = function() {
    var t = this.drawPass.colorTarget.getWidth(), n = this.drawPass.colorTarget.getHeight(), r = this.compose.values.uTexSize.ref.value, i = r[0], a = r[1];
    t === i && n === a || (this.colorTarget.setSize(t, n), this.composeTarget.setSize(t, n), this.holdTarget.setSize(t, n), k.update(this.compose.values.uTexSize, ge.set(this.compose.values.uTexSize.ref.value, t, n)));
  }, e.prototype.render = function(t, n, r, i, a) {
    return r.multiSample.mode !== "temporal" || a ? (this.renderMultiSample(n, i, r), -2) : this.renderTemporalMultiSample(t, n, r, i);
  }, e.prototype.bindOutputTarget = function(t) {
    t ? this.webgl.unbindFramebuffer() : this.colorTarget.bind();
  }, e.prototype.renderMultiSample = function(t, n, r) {
    var i = t.camera, a = this, o = a.compose, s = a.composeTarget, u = a.drawPass, c = a.webgl, l = c.gl, d = c.state, m = Dv[Math.max(0, Math.min(r.multiSample.sampleLevel, 5))], p = i.viewport, v = p.x, f = p.y, y = p.width, h = p.height, g = 1 / m.length;
    i.viewOffset.enabled = !0, k.update(o.values.tColor, u.getColorTarget(r.postprocessing).texture), o.update();
    for (var x = 0; x < m.length; ++x) {
      var C = m[x];
      Kn.setViewOffset(i.viewOffset, y, h, C[0], C[1], y, h), i.update();
      var b = g + 0.03125 * ((x + 0.5) / m.length - 0.5);
      k.update(o.values.uWeight, b), x === 0 ? u.postprocessing.setOcclusionOffset(0, 0) : u.postprocessing.setOcclusionOffset(C[0] / y, C[1] / h), u.render(t, r, !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(v, f, y, h), l.scissor(v, f, y, h), x === 0 && (d.clearColor(0, 0, 0, 0), l.clear(l.COLOR_BUFFER_BIT)), o.render();
    }
    u.postprocessing.setOcclusionOffset(0, 0), k.update(o.values.uWeight, 1), k.update(o.values.tColor, s.texture), o.update(), this.bindOutputTarget(n), l.viewport(v, f, y, h), l.scissor(v, f, y, h), d.disable(l.BLEND), o.render(), i.viewOffset.enabled = !1, i.update();
  }, e.prototype.renderTemporalMultiSample = function(t, n, r, i) {
    var a = n.camera, o = this, s = o.compose, u = o.composeTarget, c = o.holdTarget, l = o.drawPass, d = o.webgl, m = d.gl, p = d.state, v = Dv[Math.max(0, Math.min(r.multiSample.sampleLevel, 5))];
    if (t === -2 || t >= v.length) return -2;
    var f = a.viewport, y = f.x, h = f.y, g = f.width, x = f.height, C = 1 / v.length;
    if (t === -1) l.render(n, r, !1), k.update(s.values.uWeight, 1), k.update(s.values.tColor, l.getColorTarget(r.postprocessing).texture), s.update(), c.bind(), p.disable(m.BLEND), p.disable(m.DEPTH_TEST), p.depthMask(!1), m.viewport(y, h, g, x), m.scissor(y, h, g, x), s.render(), t += 1;
    else {
      a.viewOffset.enabled = !0, k.update(s.values.tColor, l.getColorTarget(r.postprocessing).texture), k.update(s.values.uWeight, C), s.update();
      for (var b = Math.pow(2, Math.max(0, r.multiSample.sampleLevel - 2)), _ = 0; _ < b; ++_) {
        var A = v[t];
        if (Kn.setViewOffset(a.viewOffset, g, x, A[0], A[1], g, x), a.update(), t === 0 ? l.postprocessing.setOcclusionOffset(0, 0) : l.postprocessing.setOcclusionOffset(A[0] / g, A[1] / x), l.render(n, r, !1), u.bind(), p.enable(m.BLEND), p.blendEquationSeparate(m.FUNC_ADD, m.FUNC_ADD), p.blendFuncSeparate(m.ONE, m.ONE, m.ONE, m.ONE), p.disable(m.DEPTH_TEST), p.depthMask(!1), m.viewport(y, h, g, x), m.scissor(y, h, g, x), t === 0 && (p.clearColor(0, 0, 0, 0), m.clear(m.COLOR_BUFFER_BIT)), s.render(), (t += 1) >= v.length) break;
      }
    }
    l.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(i), m.viewport(y, h, g, x), m.scissor(y, h, g, x);
    var I = t * C;
    return I > 0 && (k.update(s.values.uWeight, 1), k.update(s.values.tColor, u.texture), s.update(), p.disable(m.BLEND), s.render()), I < 1 && (k.update(s.values.uWeight, 1 - I), k.update(s.values.tColor, c.texture), s.update(), I === 0 ? p.disable(m.BLEND) : p.enable(m.BLEND), s.render()), a.viewOffset.enabled = !1, a.update(), t >= v.length ? -2 : t;
  }, e;
}(), Dv = [[[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]]];
Dv.forEach(function(e) {
  e.forEach(function(t) {
    t[0] *= 0.0625, t[1] *= 0.0625;
  });
});
var Vx = function() {
  function e(t) {
    this.multiSamplePass = t, this.sampleIndex = -2;
  }
  return e.prototype.update = function(t, n) {
    return t && (this.sampleIndex = -1), n.mode === "temporal" && this.sampleIndex !== -2;
  }, e.prototype.render = function(t, n, r, i) {
    return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, t, n, r, !!i), this.sampleIndex < 0;
  }, e;
}(), zx = { eyeSeparation: N.Numeric(0.064, { min: 0.01, max: 0.5, step: 1e-3 }), focus: N.Numeric(10, { min: 1, max: 100, step: 0.01 }) }, yO = N.getDefaultValues(zx), Ul = function() {
  function e(t, n) {
    n === void 0 && (n = {}), this.parent = t, this.left = new T6(), this.right = new T6(), this.props = B(B({}, yO), n);
  }
  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, n, r, i) {
      Pr.copy(r.viewport, t.viewport), J.copy(r.view, t.view), J.copy(r.projection, t.projection), Kn.copySnapshot(r.state, t.state), Kn.copyViewOffset(r.viewOffset, t.viewOffset), r.far = t.far, r.near = t.near, r.fogFar = t.fogFar, r.fogNear = t.fogNear, Pr.copy(i.viewport, t.viewport), J.copy(i.view, t.view), J.copy(i.projection, t.projection), Kn.copySnapshot(i.state, t.state), Kn.copyViewOffset(i.viewOffset, t.viewOffset), i.far = t.far, i.near = t.near, i.fogFar = t.fogFar, i.fogNear = t.fogNear;
      var a = Math.floor(t.viewport.width / 2), o = a / t.viewport.height;
      r.viewport.width = a, i.viewport.x += a, i.viewport.width -= a;
      var s, u, c = n.eyeSeparation / 2, l = c * t.near / n.focus, d = t.near * Math.tan(0.5 * t.state.fov);
      M6[12] = -c, D6[12] = c, s = -d * o + l, u = d * o + l, r.projection[0] = 2 * t.near / (u - s), r.projection[8] = (u + s) / (u - s), J.mul(r.view, r.view, M6), J.mul(r.projectionView, r.projection, r.view), J.invert(r.inverseProjectionView, r.projectionView), s = -d * o - l, u = d * o - l, i.projection[0] = 2 * t.near / (u - s), i.projection[8] = (u + s) / (u - s), J.mul(i.view, i.view, D6), J.mul(i.projectionView, i.projection, i.view), J.invert(i.inverseProjectionView, i.projectionView);
    }(this.parent, this.props, this.left, this.right);
  }, e;
}();
(function(e) {
  e.is = function(t) {
    return "left" in t && "right" in t;
  };
})(Ul || (Ul = {}));
var T6 = function() {
  this.viewport = Pr.create(0, 0, 0, 0), this.view = J(), this.projection = J(), this.projectionView = J(), this.inverseProjectionView = J(), this.state = Kn.createDefaultSnapshot(), this.viewOffset = Kn.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0;
}, M6 = J.identity(), D6 = J.identity(), ph = Math.pow(2, 24) - 2, bO = function() {
  function e(t, n, r) {
    this.webgl = t, this.drawPass = n, this.pickBaseScale = r;
    var i = r / t.pixelRatio;
    this.pickWidth = Math.ceil(n.colorTarget.getWidth() * i), this.pickHeight = Math.ceil(n.colorTarget.getHeight() * i), 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, n = Math.ceil(this.drawPass.colorTarget.getWidth() * t), r = Math.ceil(this.drawPass.colorTarget.getHeight() * t);
    n === this.pickWidth && r === this.pickHeight || (this.pickWidth = n, this.pickHeight = r, 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, n, r, i, a, o) {
    var s = this.drawPass.depthTexturePrimitives;
    t.clear(!1), t.update(n), t.renderPick(r.primitives, n, a, null, o), t.renderPick(r.volumes, n, a, s, o), t.renderPick(i.handle.scene, n, a, null, o), i.camera.isEnabled && (i.camera.update(n), t.update(i.camera.camera), t.renderPick(i.camera.scene, i.camera.camera, a, null, o));
  }, e.prototype.render = function(t, n, r, i) {
    this.objectPickTarget.bind(), this.renderVariant(t, n, r, i, "pick", 1), this.instancePickTarget.bind(), this.renderVariant(t, n, r, i, "pick", 2), this.groupPickTarget.bind(), this.renderVariant(t, n, r, i, "pick", 3), this.depthPickTarget.bind(), this.renderVariant(t, n, r, i, "depth", 0);
  }, e;
}(), _O = function() {
  function e(t, n, r, i, a, o, s) {
    s === void 0 && (s = 1), this.webgl = t, this.renderer = n, this.scene = r, this.helper = i, this.pickPass = a, this.pickPadding = s, this.dirty = !0, this.viewport = Pr(), 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, n, r, i) {
    Pr.set(this.viewport, t, n, r, i), this.pickScale = this.pickPass.pickBaseScale / this.webgl.pixelRatio, this.pickX = Math.ceil(t * this.pickScale), this.pickY = Math.ceil(n * this.pickScale);
    var a = Math.floor(r * this.pickScale), o = Math.floor(i * this.pickScale);
    a === this.pickWidth && o === this.pickHeight || (this.pickWidth = a, 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], m = 2 * s + 1, p = m / 2, v = [], f = Math.pow(m, 2); f > 0; --f) -p < c && c <= p && -p < l && l <= p && v.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 v;
    }(Math.round(this.pickScale * this.pickPadding));
  }, e.prototype.syncBuffers = function() {
    var t = this, n = t.pickX, r = t.pickY, i = t.pickWidth, a = t.pickHeight;
    this.pickPass.objectPickTarget.bind(), this.webgl.readPixels(n, r, i, a, this.objectBuffer), this.pickPass.instancePickTarget.bind(), this.webgl.readPixels(n, r, i, a, this.instanceBuffer), this.pickPass.groupPickTarget.bind(), this.webgl.readPixels(n, r, i, a, this.groupBuffer), this.pickPass.depthPickTarget.bind(), this.webgl.readPixels(n, r, i, a, this.depthBuffer);
  }, e.prototype.getBufferIdx = function(t, n) {
    return 4 * (n * this.pickWidth + t);
  }, e.prototype.getDepth = function(t, n) {
    var r = this.getBufferIdx(t, n), i = this.depthBuffer;
    return function(a, o, s, u) {
      return vt.set(q5, a / 255, o / 255, s / 255, u / 255), vt.dot(q5, qB);
    }(i[r], i[r + 1], i[r + 2], i[r + 3]);
  }, e.prototype.getId = function(t, n, r) {
    var i = this.getBufferIdx(t, n);
    return Zg(r[i], r[i + 1], r[i + 2]);
  }, e.prototype.render = function(t) {
    var n = this, r = n.pickX, i = n.pickY, a = n.pickWidth, o = n.pickHeight, s = n.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), Ul.is(t) ? (c.setViewport(r, i, s, o), this.pickPass.render(c, t.left, l, d), c.setViewport(r + s, i, a - s, o), this.pickPass.render(c, t.right, l, d)) : (c.setViewport(r, i, a, o), this.pickPass.render(c, t, l, d)), this.dirty = !1;
  }, e.prototype.identifyInternal = function(t, n, r) {
    var i = this.webgl, a = this.pickScale;
    if (!i.isContextLost) {
      t *= i.pixelRatio, n *= i.pixelRatio, n = this.pickPass.drawingBufferHeight - n;
      var o = this.viewport;
      if (!(t < o.x || n < o.y || t > o.x + o.width || n > o.y + o.height)) {
        this.dirty && (this.render(r), this.syncBuffers());
        var s = t - o.x, u = n - o.y, c = Math.floor(s * a), l = Math.floor(u * a), d = this.getId(c, l, this.objectBuffer);
        if (d !== -1 && d !== ph) {
          var m = this.getId(c, l, this.instanceBuffer);
          if (m !== -1 && m !== ph) {
            var p = this.getId(c, l, this.groupBuffer);
            if (p !== -1 && p !== ph) {
              var v = this.getDepth(c, l), f = S.create(t, o.height - n, v);
              if (Ul.is(r)) {
                var y = Math.floor(o.width / 2);
                t > o.x + y ? (f[0] = o.x + 2 * (s - y), Od(f, f, o, r.right.inverseProjectionView)) : (f[0] = o.x + 2 * s, Od(f, f, o, r.left.inverseProjectionView));
              } else Od(f, f, o, r.inverseProjectionView);
              return { id: { objectId: d, instanceId: m, groupId: p }, position: f };
            }
          }
        }
      }
    }
  }, e.prototype.identify = function(t, n, r) {
    for (var i = 0, a = this.spiral; i < a.length; i++) {
      var o = a[i], s = this.identifyInternal(t + o[0], n + o[1], r);
      if (s) return s;
    }
  }, e.prototype.getPosition = function(t, n, r) {
    var i = this.webgl;
    if (!i.isContextLost) {
      t *= i.pixelRatio, n *= i.pixelRatio, n = this.pickPass.drawingBufferHeight - n;
      var a = this.viewport;
      if (!(t < a.x || n < a.y || t > a.x + a.width || n > a.y + a.height)) {
        this.dirty && (this.render(r), this.syncBuffers());
        var o = 255 / 256, s = S.create(16777216, 65536, 256), u = vt.create(o / s[0], o / s[1], o / s[2], 0.99609375), c = vt();
        vt.set(c, 128 / 255, 128 / 255, 30 / 255, 60 / 255);
        var l = vt.dot(c, u) / (r.zoom / 40);
        l > 0.2 && (l = 0.1);
        var d = S.create(t, a.height - n, l);
        return Od(d, d, a, r.inverseProjectionView), { position: d };
      }
    }
  }, e;
}(), xO = B(B({}, Mr), { tWboitA: pt("texture", "rgba", "float", "nearest"), tWboitB: pt("texture", "rgba", "float", "nearest"), uTexSize: ce("v2") }), SO = Pn("evaluate-wboit", ci, `
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);
}
`), CO = function() {
  function e(t, n, r) {
    if (this.webgl = t, this._supported = !1, e.isSupported(t)) {
      var i, a, o, s, u, c = t.resources;
      this.textureA = c.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(n, r), this.textureB = c.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(n, r), this.renderable = (i = t, a = this.textureA, o = this.textureB, s = B(B({}, Er), { tWboitA: k.create(a), tWboitB: k.create(o), uTexSize: k.create(ge.create(a.getWidth(), a.getHeight())) }), u = B({}, xO), Sr(xr(i, "triangles", SO, 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, n = t.state, r = t.gl;
    this.framebuffer.bind(), n.clearColor(0, 0, 0, 1), r.clear(r.COLOR_BUFFER_BIT), n.disable(r.DEPTH_TEST), n.blendFuncSeparate(r.ONE, r.ONE, r.ZERO, r.ONE_MINUS_SRC_ALPHA), n.enable(r.BLEND);
  }, e.prototype.render = function() {
    var t = this.webgl, n = t.state, r = t.gl;
    n.blendFuncSeparate(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA), n.enable(r.BLEND), this.renderable.update(), this.renderable.render();
  }, e.prototype.setSize = function(t, n) {
    var r = this.renderable.values.uTexSize.ref.value, i = r[0], a = r[1];
    t === i && n === a || (this.textureA.define(t, n), this.textureB.define(t, n), k.update(this.renderable.values.uTexSize, ge.set(this.renderable.values.uTexSize.ref.value, t, n)));
  }, 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 n = t.extensions, r = n.drawBuffers, i = n.textureFloat, a = n.colorBufferFloat, o = n.depthTexture;
    if (i && a && o && r) return !0;
    if (Xt) {
      var s = [];
      i || s.push("textureFloat"), a || s.push("colorBufferFloat"), o || s.push("depthTexture"), r || s.push("drawBuffers"), console.log('Missing "'.concat(s.join('", "'), '" extensions required for "wboit"'));
    }
    return !1;
  }, e;
}(), Ux = { enabled: N.Boolean(!0), highlightEdgeColor: N.Color(ye.darken(ye.fromNormalizedRgb(1, 0.4, 0.6), 1)), selectEdgeColor: N.Color(ye.darken(ye.fromNormalizedRgb(0.2, 1, 0.1), 1)), edgeScale: N.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }), ghostEdgeStrength: N.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: N.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." }) }, B6 = function() {
  function e(t, n, r) {
    this.webgl = t, this.depthTarget = t.createRenderTarget(n, r), this.maskTarget = t.createRenderTarget(n, r), this.edgesTarget = t.createRenderTarget(n, r), this.edge = function(i, a) {
      var o = a.getWidth(), s = a.getHeight(), u = B(B({}, Er), { tMaskTexture: k.create(a), uTexSizeInv: k.create(ge.create(1 / o, 1 / s)), dEdgeScale: k.create(1) }), c = B({}, AO);
      return Sr(xr(i, "triangles", IO, c, u), u);
    }(t, this.maskTarget.texture), this.overlay = function(i, a) {
      var o = a.getWidth(), s = a.getHeight(), u = B(B({}, Er), { tEdgeTexture: k.create(a), uTexSizeInv: k.create(ge.create(1 / o, 1 / s)), uHighlightEdgeColor: k.create(S()), uSelectEdgeColor: k.create(S()), uGhostEdgeStrength: k.create(0), uInnerEdgeFactor: k.create(0) }), c = B({}, wO);
      return Sr(xr(i, "triangles", PO, c, u), u);
    }(t, this.edgesTarget.texture);
  }
  return e.isEnabled = function(t) {
    return t.enabled;
  }, e.prototype.setEdgeState = function(t) {
    var n = this.webgl, r = n.gl, i = n.state;
    i.enable(r.SCISSOR_TEST), i.enable(r.BLEND), i.blendFunc(r.ONE, r.ONE), i.blendEquation(r.FUNC_ADD), i.disable(r.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, s = t.width, u = t.height;
    r.viewport(a, o, s, u), r.scissor(a, o, s, u), i.clearColor(0, 0, 0, 0), r.clear(r.COLOR_BUFFER_BIT);
  }, e.prototype.setOverlayState = function(t) {
    var n = this.webgl, r = n.gl, i = n.state;
    i.enable(r.SCISSOR_TEST), i.enable(r.BLEND), i.blendFunc(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA), i.blendEquation(r.FUNC_ADD), i.disable(r.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, s = t.width, u = t.height;
    r.viewport(a, o, s, u), r.scissor(a, o, s, u);
  }, e.prototype.setSize = function(t, n) {
    var r = this.depthTarget.getWidth(), i = this.depthTarget.getHeight();
    t === r && n === i || (this.depthTarget.setSize(t, n), this.maskTarget.setSize(t, n), this.edgesTarget.setSize(t, n), k.update(this.edge.values.uTexSizeInv, ge.set(this.edge.values.uTexSizeInv.ref.value, 1 / t, 1 / n)), k.update(this.overlay.values.uTexSizeInv, ge.set(this.overlay.values.uTexSizeInv.ref.value, 1 / t, 1 / n)));
  }, e.prototype.update = function(t) {
    var n = t.highlightEdgeColor, r = t.selectEdgeColor, i = t.edgeScale, a = t.innerEdgeFactor, o = t.ghostEdgeStrength, s = this.edge.values, u = Math.round(i * this.webgl.pixelRatio);
    s.dEdgeScale.ref.value !== u && (k.update(s.dEdgeScale, u), this.edge.update());
    var c = this.overlay.values;
    k.update(c.uHighlightEdgeColor, ye.toVec3Normalized(c.uHighlightEdgeColor.ref.value, n)), k.update(c.uSelectEdgeColor, ye.toVec3Normalized(c.uSelectEdgeColor.ref.value, r)), k.update(c.uInnerEdgeFactor, a), k.update(c.uGhostEdgeStrength, o);
  }, e.prototype.render = function(t, n) {
    this.edgesTarget.bind(), this.setEdgeState(t), this.edge.render(), n ? n.bind() : this.webgl.unbindFramebuffer(), this.setOverlayState(t), this.overlay.render();
  }, e;
}(), AO = B(B({}, Mr), { tMaskTexture: pt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ce("v2"), dEdgeScale: mt("number") }), IO = Pn("edge", ci, `
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);
}
`), wO = B(B({}, Mr), { tEdgeTexture: pt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: ce("v2"), uHighlightEdgeColor: ce("v3"), uSelectEdgeColor: ce("v3"), uGhostEdgeStrength: ce("f"), uInnerEdgeFactor: ce("f") }), PO = Pn("overlay", ci, `
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);
    }
}
`), EO = B(B({}, Mr), { tDepthPrimitives: pt("texture", "depth", "ushort", "nearest"), tDepthVolumes: pt("texture", "depth", "ushort", "nearest"), uTexSize: ce("v2"), dPackedDepth: mt("boolean") }), TO = Pn("depth-merge", ci, `
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);
}
`), Hx = function() {
  function e(t, n, r, i) {
    this.webgl = t;
    var a, o, s, u, c, l, d, m = t.extensions, p = t.resources, v = t.isWebGL2;
    this.drawTarget = (a = t.gl, { id: q7(), texture: Ni(a), framebuffer: { id: U7(), bind: function() {
    }, reset: function() {
    }, destroy: function() {
    } }, getWidth: function() {
      return 0;
    }, getHeight: function() {
      return 0;
    }, bind: function() {
      a.bindFramebuffer(a.FRAMEBUFFER, null);
    }, setSize: function() {
    }, reset: function() {
    }, destroy: function() {
    } }), this.colorTarget = t.createRenderTarget(n, r, !0, "uint8", "linear"), this.packedDepth = !m.depthTexture, this.depthTarget = t.createRenderTarget(n, r), this.depthTexture = this.depthTarget.texture, this.depthTargetPrimitives = this.packedDepth ? t.createRenderTarget(n, r) : null, this.depthTargetVolumes = this.packedDepth ? t.createRenderTarget(n, r) : null, this.depthTexturePrimitives = this.depthTargetPrimitives ? this.depthTargetPrimitives.texture : p.texture("image-depth", "depth", v ? "float" : "ushort", "nearest"), this.depthTextureVolumes = this.depthTargetVolumes ? this.depthTargetVolumes.texture : p.texture("image-depth", "depth", v ? "float" : "ushort", "nearest"), this.packedDepth || (this.depthTexturePrimitives.define(n, r), this.depthTextureVolumes.define(n, r)), this.depthMerge = (o = t, s = this.depthTexturePrimitives, u = this.depthTextureVolumes, c = this.packedDepth, l = B(B({}, Er), { tDepthPrimitives: k.create(s), tDepthVolumes: k.create(u), uTexSize: k.create(ge.create(s.getWidth(), s.getHeight())), dPackedDepth: k.create(c) }), d = B({}, EO), Sr(xr(o, "triangles", TO, d, l), l)), this.wboit = i ? new CO(t, n, r) : void 0, this.marking = new B6(t, n, r), this.postprocessing = new os(t, this), this.antialiasing = new mh(t, this), this.copyFboTarget = pv(t, this.colorTarget.texture), this.copyFboPostprocessing = pv(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, n) {
    var r, i = this.colorTarget.getWidth(), a = this.colorTarget.getHeight();
    t === i && n === a || (this.colorTarget.setSize(t, n), this.depthTarget.setSize(t, n), this.depthTargetPrimitives ? this.depthTargetPrimitives.setSize(t, n) : this.depthTexturePrimitives.define(t, n), this.depthTargetVolumes ? this.depthTargetVolumes.setSize(t, n) : this.depthTextureVolumes.define(t, n), k.update(this.depthMerge.values.uTexSize, ge.set(this.depthMerge.values.uTexSize.ref.value, t, n)), k.update(this.copyFboTarget.values.uTexSize, ge.set(this.copyFboTarget.values.uTexSize.ref.value, t, n)), k.update(this.copyFboPostprocessing.values.uTexSize, ge.set(this.copyFboPostprocessing.values.uTexSize.ref.value, t, n)), !((r = this.wboit) === null || r === void 0) && r.supported && this.wboit.setSize(t, n), this.marking.setSize(t, n), this.postprocessing.setSize(t, n), this.antialiasing.setSize(t, n));
  }, e.prototype._depthMerge = function() {
    var t = this.webgl, n = t.state, r = t.gl;
    this.depthMerge.update(), this.depthTarget.bind(), n.disable(r.BLEND), n.disable(r.DEPTH_TEST), n.disable(r.CULL_FACE), n.depthMask(!1), n.clearColor(1, 1, 1, 1), r.clear(r.COLOR_BUFFER_BIT), this.depthMerge.render();
  }, e.prototype._renderWboit = function(t, n, r, i, a) {
    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(r.primitives, n, null), this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), t.clearDepth(), t.renderWboitOpaque(r.volumes, n, this.depthTexturePrimitives), this._depthMerge(), os.isEnabled(a) && this.postprocessing.render(n, !1, i, t.props.backgroundColor, a), this.wboit.bind(), t.renderWboitTransparent(r.primitives, n, this.depthTexture), t.renderWboitTransparent(r.volumes, n, this.depthTexture), os.isEnabled(a) ? (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, n, r, i, a, o) {
    if (i ? this.drawTarget.bind() : (this.colorTarget.bind(), this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth")), t.clear(!0), t.renderBlendedOpaque(r.primitives, n, null), !i) {
      this.depthTargetPrimitives && (this.depthTargetPrimitives.bind(), t.clear(!1), t.renderDepth(r.primitives, n, null), this.colorTarget.bind()), this.packedDepth || (this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), t.clearDepth()), t.renderBlendedVolumeOpaque(r.volumes, n, this.depthTexturePrimitives), this.depthTargetVolumes && (this.depthTargetVolumes.bind(), t.clear(!1), t.renderDepth(r.volumes, n, this.depthTexturePrimitives), this.colorTarget.bind()), this._depthMerge(), this.colorTarget.bind(), os.isEnabled(o) && this.postprocessing.render(n, !1, a, t.props.backgroundColor, o), t.renderBlendedVolumeTransparent(r.volumes, n, this.depthTexturePrimitives);
      var s = os.isEnabled(o) ? this.postprocessing.target : this.colorTarget;
      this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(s.framebuffer, "depth"), s.bind();
    }
    t.renderBlendedTransparent(r.primitives, n, null);
  }, e.prototype._render = function(t, n, r, i, a, o) {
    var s = r.volumes.renderables.length > 0, u = os.isEnabled(o.postprocessing), c = mh.isEnabled(o.postprocessing), l = B6.isEnabled(o.marking), d = n.viewport, m = d.x, p = d.y, v = d.width, f = d.height;
    if (t.setViewport(m, p, v, f), t.update(n), o.transparentBackground && !c && a && (this.drawTarget.bind(), t.clear(!1)), this.wboitEnabled ? this._renderWboit(t, n, r, o.transparentBackground, o.postprocessing) : this._renderBlended(t, n, r, !s && !u && !c && a, o.transparentBackground, o.postprocessing), u ? this.postprocessing.target.bind() : !a || s || this.wboitEnabled ? this.colorTarget.bind() : this.drawTarget.bind(), l) {
      var y = r.getMarkerAverage();
      if (y > 0) {
        var h = o.marking.ghostEdgeStrength < 1;
        h && y !== 1 && (this.marking.depthTarget.bind(), t.clear(!1, !0), t.renderMarkingDepth(r.primitives, n, null)), this.marking.maskTarget.bind(), t.clear(!1, !0), t.renderMarkingMask(r.primitives, n, h ? this.marking.depthTarget.texture : null), this.marking.update(o.marking), this.marking.render(n.viewport, u ? this.postprocessing.target : this.colorTarget);
      }
    }
    i.debug.isEnabled && (i.debug.syncVisibility(), t.renderBlended(i.debug.scene, n, null)), i.handle.isEnabled && t.renderBlended(i.handle.scene, n, null), i.camera.isEnabled && (i.camera.update(n), t.update(i.camera.camera), t.renderBlended(i.camera.scene, i.camera.camera, null)), c ? this.antialiasing.render(n, a, o.postprocessing) : a && (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, n, r) {
    var i = t.renderer, a = t.camera, o = t.scene, s = t.helper;
    i.setTransparentBackground(n.transparentBackground), i.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), i.setPixelRatio(this.webgl.pixelRatio), Ul.is(a) ? (this._render(i, a.left, o, s, r, n), this._render(i, a.right, o, s, r, n)) : this._render(i, a, o, s, r, n);
  }, e.prototype.getColorTarget = function(t) {
    return mh.isEnabled(t) ? this.antialiasing.target : os.isEnabled(t) ? this.postprocessing.target : this.colorTarget;
  }, e;
}();
function Qa(e) {
  for (var t = arguments.length, n = Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++) n[r - 1] = arguments[r];
  throw Error("[Immer] minified error nr: " + e + (n.length ? " " + n.map(function(i) {
    return "'" + i + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function Hl(e) {
  return !!e && !!e[ra];
}
function Tc(e) {
  return !!e && (function(t) {
    if (!t || typeof t != "object") return !1;
    var n = Object.getPrototypeOf(t);
    if (n === null) return !0;
    var r = Object.hasOwnProperty.call(n, "constructor") && n.constructor;
    return r === Object || typeof r == "function" && Function.toString.call(r) === OO;
  }(e) || Array.isArray(e) || !!e[V6] || !!e.constructor[V6] || o3(e) || s3(e));
}
function If(e, t, n) {
  n === void 0 && (n = !1), ql(e) === 0 ? (n ? Object.keys : f3)(e).forEach(function(r) {
    n && typeof r == "symbol" || t(r, e[r], e);
  }) : e.forEach(function(r, i) {
    return t(i, r, e);
  });
}
function ql(e) {
  var t = e[ra];
  return t ? t.i > 3 ? t.i - 4 : t.i : Array.isArray(e) ? 1 : o3(e) ? 2 : s3(e) ? 3 : 0;
}
function Bv(e, t) {
  return ql(e) === 2 ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
}
function qx(e, t, n) {
  var r = ql(e);
  r === 2 ? e.set(t, n) : r === 3 ? (e.delete(t), e.add(n)) : e[t] = n;
}
function o3(e) {
  return RO && e instanceof Map;
}
function s3(e) {
  return kO && e instanceof Set;
}
function rc(e) {
  return e.o || e.t;
}
function u3(e) {
  if (Array.isArray(e)) return Array.prototype.slice.call(e);
  var t = NO(e);
  delete t[ra];
  for (var n = f3(t), r = 0; r < n.length; r++) {
    var i = n[r], a = t[i];
    a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (t[i] = { configurable: !0, writable: !0, enumerable: a.enumerable, value: e[i] });
  }
  return Object.create(Object.getPrototypeOf(e), t);
}
function c3(e, t) {
  return t === void 0 && (t = !1), l3(e) || Hl(e) || !Tc(e) || (ql(e) > 1 && (e.set = e.add = e.clear = e.delete = MO), Object.freeze(e), t && If(e, function(n, r) {
    return c3(r, !0);
  }, !0)), e;
}
function MO() {
  Qa(2);
}
function l3(e) {
  return e == null || typeof e != "object" || Object.isFrozen(e);
}
function Bo(e) {
  var t = LO[e];
  return t || Qa(18, e), t;
}
function R6() {
  return wf;
}
function hh(e, t) {
  t && (Bo("Patches"), e.u = [], e.s = [], e.v = t);
}
function s0(e) {
  Rv(e), e.p.forEach(DO), e.p = null;
}
function Rv(e) {
  e === wf && (wf = e.l);
}
function k6(e) {
  return wf = { p: [], l: wf, h: e, m: !0, _: 0 };
}
function DO(e) {
  var t = e[ra];
  t.i === 0 || t.i === 1 ? t.j() : t.O = !0;
}
function vh(e, t) {
  t._ = t.p.length;
  var n = t.p[0], r = e !== void 0 && e !== n;
  return t.h.g || Bo("ES5").S(t, e, r), r ? (n[ra].P && (s0(t), Qa(4)), Tc(e) && (e = u0(t, e), t.l || c0(t, e)), t.u && Bo("Patches").M(n[ra].t, e, t.u, t.s)) : e = u0(t, n, []), s0(t), t.u && t.v(t.u, t.s), e !== jx ? e : void 0;
}
function u0(e, t, n) {
  if (l3(t)) return t;
  var r = t[ra];
  if (!r) return If(t, function(a, o) {
    return O6(e, r, t, a, o, n);
  }, !0), t;
  if (r.A !== e) return t;
  if (!r.P) return c0(e, r.t, !0), r.t;
  if (!r.I) {
    r.I = !0, r.A._--;
    var i = r.i === 4 || r.i === 5 ? r.o = u3(r.k) : r.o;
    If(r.i === 3 ? new Set(i) : i, function(a, o) {
      return O6(e, r, i, a, o, n);
    }), c0(e, i, !1), n && e.u && Bo("Patches").R(r, n, e.u, e.s);
  }
  return r.o;
}
function O6(e, t, n, r, i, a) {
  if (Hl(i)) {
    var o = u0(e, i, a && t && t.i !== 3 && !Bv(t.D, r) ? a.concat(r) : void 0);
    if (qx(n, r, o), !Hl(o)) return;
    e.m = !1;
  }
  if (Tc(i) && !l3(i)) {
    if (!e.h.F && e._ < 1) return;
    u0(e, i), t && t.A.l || c0(e, i);
  }
}
function c0(e, t, n) {
  n === void 0 && (n = !1), e.h.F && e.m && c3(t, n);
}
function gh(e, t) {
  var n = e[ra];
  return (n ? rc(n) : e)[t];
}
function N6(e, t) {
  if (t in e) for (var n = Object.getPrototypeOf(e); n; ) {
    var r = Object.getOwnPropertyDescriptor(n, t);
    if (r) return r;
    n = Object.getPrototypeOf(n);
  }
}
function kv(e) {
  e.P || (e.P = !0, e.l && kv(e.l));
}
function yh(e) {
  e.o || (e.o = u3(e.t));
}
function Ov(e, t, n) {
  var r = o3(t) ? Bo("MapSet").N(t, n) : s3(t) ? Bo("MapSet").T(t, n) : e.g ? function(i, a) {
    var o = Array.isArray(i), s = { i: o ? 1 : 0, A: a ? a.A : R6(), P: !1, I: !1, D: {}, l: a, t: i, k: null, o: null, j: null, C: !1 }, u = s, c = Nv;
    o && (u = [s], c = jd);
    var l = Proxy.revocable(u, c), d = l.revoke, m = l.proxy;
    return s.k = m, s.j = d, m;
  }(t, n) : Bo("ES5").J(t, n);
  return (n ? n.A : R6()).p.push(r), r;
}
function BO(e) {
  return Hl(e) || Qa(22, e), function t(n) {
    if (!Tc(n)) return n;
    var r, i = n[ra], a = ql(n);
    if (i) {
      if (!i.P && (i.i < 4 || !Bo("ES5").K(i))) return i.t;
      i.I = !0, r = L6(n, a), i.I = !1;
    } else r = L6(n, a);
    return If(r, function(o, s) {
      i && function(u, c) {
        return ql(u) === 2 ? u.get(c) : u[c];
      }(i.t, o) === s || qx(r, o, t(s));
    }), a === 3 ? new Set(r) : r;
  }(e);
}
function L6(e, t) {
  switch (t) {
    case 2:
      return new Map(e);
    case 3:
      return Array.from(e);
  }
  return u3(e);
}
var F6, wf, d3 = typeof Symbol < "u" && typeof Symbol("x") == "symbol", RO = typeof Map < "u", kO = typeof Set < "u", G6 = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", jx = d3 ? Symbol.for("immer-nothing") : ((F6 = {})["immer-nothing"] = !0, F6), V6 = d3 ? Symbol.for("immer-draftable") : "__$immer_draftable", ra = d3 ? Symbol.for("immer-state") : "__$immer_state", OO = "" + Object.prototype.constructor, f3 = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(e) {
  return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : Object.getOwnPropertyNames, NO = Object.getOwnPropertyDescriptors || function(e) {
  var t = {};
  return f3(e).forEach(function(n) {
    t[n] = Object.getOwnPropertyDescriptor(e, n);
  }), t;
}, LO = {}, Nv = { get: function(e, t) {
  if (t === ra) return e;
  var n = rc(e);
  if (!Bv(n, t)) return function(i, a, o) {
    var s, u = N6(a, o);
    return u ? "value" in u ? u.value : (s = u.get) === null || s === void 0 ? void 0 : s.call(i.k) : void 0;
  }(e, n, t);
  var r = n[t];
  return e.I || !Tc(r) ? r : r === gh(e.t, t) ? (yh(e), e.o[t] = Ov(e.A.h, r, e)) : r;
}, has: function(e, t) {
  return t in rc(e);
}, ownKeys: function(e) {
  return Reflect.ownKeys(rc(e));
}, set: function(e, t, n) {
  var r = N6(rc(e), t);
  if (r != null && r.set) return r.set.call(e.k, n), !0;
  if (!e.P) {
    var i = gh(rc(e), t), a = i == null ? void 0 : i[ra];
    if (a && a.t === n) return e.o[t] = n, e.D[t] = !1, !0;
    if (function(o, s) {
      return o === s ? o !== 0 || 1 / o == 1 / s : o != o && s != s;
    }(n, i) && (n !== void 0 || Bv(e.t, t))) return !0;
    yh(e), kv(e);
  }
  return e.o[t] === n && typeof n != "number" && (n !== void 0 || t in e.o) || (e.o[t] = n, e.D[t] = !0, !0);
}, deleteProperty: function(e, t) {
  return gh(e.t, t) !== void 0 || t in e.t ? (e.D[t] = !1, yh(e), kv(e)) : delete e.D[t], e.o && delete e.o[t], !0;
}, getOwnPropertyDescriptor: function(e, t) {
  var n = rc(e), r = Reflect.getOwnPropertyDescriptor(n, t);
  return r && { writable: !0, configurable: e.i !== 1 || t !== "length", enumerable: r.enumerable, value: n[t] };
}, defineProperty: function() {
  Qa(11);
}, getPrototypeOf: function(e) {
  return Object.getPrototypeOf(e.t);
}, setPrototypeOf: function() {
  Qa(12);
} }, jd = {};
If(Nv, function(e, t) {
  jd[e] = function() {
    return arguments[0] = arguments[0][0], t.apply(this, arguments);
  };
}), jd.deleteProperty = function(e, t) {
  return jd.set.call(this, e, t, void 0);
}, jd.set = function(e, t, n) {
  return Nv.set.call(this, e[0], t, n, e[0]);
};
var FO = function() {
  function e(n) {
    var r = this;
    this.g = G6, this.F = !0, this.produce = function(i, a, o) {
      if (typeof i == "function" && typeof a != "function") {
        var s = a;
        a = i;
        var u = r;
        return function(f) {
          var y = this;
          f === void 0 && (f = s);
          for (var h = arguments.length, g = Array(h > 1 ? h - 1 : 0), x = 1; x < h; x++) g[x - 1] = arguments[x];
          return u.produce(f, function(C) {
            var b;
            return (b = a).call.apply(b, [y, C].concat(g));
          });
        };
      }
      var c;
      if (typeof a != "function" && Qa(6), o !== void 0 && typeof o != "function" && Qa(7), Tc(i)) {
        var l = k6(r), d = Ov(r, i, void 0), m = !0;
        try {
          c = a(d), m = !1;
        } finally {
          m ? s0(l) : Rv(l);
        }
        return typeof Promise < "u" && c instanceof Promise ? c.then(function(f) {
          return hh(l, o), vh(f, l);
        }, function(f) {
          throw s0(l), f;
        }) : (hh(l, o), vh(c, l));
      }
      if (!i || typeof i != "object") {
        if ((c = a(i)) === void 0 && (c = i), c === jx && (c = void 0), r.F && c3(c, !0), o) {
          var p = [], v = [];
          Bo("Patches").M(i, c, p, v), o(p, v);
        }
        return c;
      }
      Qa(21, i);
    }, this.produceWithPatches = function(i, a) {
      if (typeof i == "function") return function(c) {
        for (var l = arguments.length, d = Array(l > 1 ? l - 1 : 0), m = 1; m < l; m++) d[m - 1] = arguments[m];
        return r.produceWithPatches(c, function(p) {
          return i.apply(void 0, [p].concat(d));
        });
      };
      var o, s, u = r.produce(i, a, 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 (n == null ? void 0 : n.useProxies) == "boolean" && this.setUseProxies(n.useProxies), typeof (n == null ? void 0 : n.autoFreeze) == "boolean" && this.setAutoFreeze(n.autoFreeze);
  }
  var t = e.prototype;
  return t.createDraft = function(n) {
    Tc(n) || Qa(8), Hl(n) && (n = BO(n));
    var r = k6(this), i = Ov(this, n, void 0);
    return i[ra].C = !0, Rv(r), i;
  }, t.finishDraft = function(n, r) {
    var i = (n && n[ra]).A;
    return hh(i, r), vh(void 0, i);
  }, t.setAutoFreeze = function(n) {
    this.F = n;
  }, t.setUseProxies = function(n) {
    n && !G6 && Qa(20), this.g = n;
  }, t.applyPatches = function(n, r) {
    var i;
    for (i = r.length - 1; i >= 0; i--) {
      var a = r[i];
      if (a.path.length === 0 && a.op === "replace") {
        n = a.value;
        break;
      }
    }
    i > -1 && (r = r.slice(i + 1));
    var o = Bo("Patches").$;
    return Hl(n) ? o(n, r) : this.produce(n, function(s) {
      return o(s, r);
    });
  }, e;
}(), Xi = new FO(), m3 = Xi.produce;
Xi.produceWithPatches.bind(Xi), Xi.setAutoFreeze.bind(Xi), Xi.setUseProxies.bind(Xi), Xi.applyPatches.bind(Xi), Xi.createDraft.bind(Xi), Xi.finishDraft.bind(Xi);
var Tu, fa = new Uint16Array([0, 1, 2, 1, 3, 2]), zu = he.add3, Br = he.add2, z6 = he.add;
(function(e) {
  e.create = function(t, n, r, i) {
    t === void 0 && (t = {}), n === void 0 && (n = 2048), r === void 0 && (r = 1024), n *= 2, r *= 2;
    var a = he.create(Float32Array, 3, r, i ? i.centerBuffer.ref.value : n), o = he.create(Float32Array, 2, r, i ? i.mappingBuffer.ref.value : n), s = he.create(Float32Array, 1, r, i ? i.depthBuffer.ref.value : n), u = he.create(Uint32Array, 3, r, i ? i.indexBuffer.ref.value : n), c = he.create(Float32Array, 1, r, i ? i.groupBuffer.ref.value : n), l = he.create(Float32Array, 2, r, i ? i.tcoordBuffer.ref.value : n), d = B(B({}, N.getDefaultValues(na.Params)), t), m = d.attachment, p = d.background, v = d.backgroundMargin, f = d.tether, y = d.tetherLength, h = d.tetherBaseWidth, g = function(_) {
      var A = JSON.stringify(_);
      return jp[A] === void 0 && (jp[A] = new KB(_)), jp[A];
    }(d), x = 0.4 * v, C = g.buffer / g.lineHeight, b = function(_, A, I, w, E) {
      zu(a, _, A, I), z6(s, w), z6(c, E);
    };
    return { add: function(_, A, I, w, E, D, T) {
      for (var P = 0, M = _.length, R = 0; R < M; ++R)
        P += (ke = g.get(_[R])).nw - 2 * C;
      var O, L;
      if (O = m.startsWith("top") ? 0.8 : m.startsWith("middle") ? 0.4 : 0, L = m.endsWith("right") ? P : m.endsWith("center") ? P / 2 : 0, f) switch (m) {
        case "bottom-left":
          L -= y / 2 + x + 0.1, O -= y / 2 + x;
          break;
        case "bottom-center":
          O -= y + x;
          break;
        case "bottom-right":
          L += y / 2 + x + 0.1, O -= y / 2 + x;
          break;
        case "middle-left":
          L -= y + x + 0.1;
          break;
        case "middle-center":
          break;
        case "middle-right":
          L += y + x + 0.1;
          break;
        case "top-left":
          L -= y / 2 + x + 0.1, O += y / 2 + x;
          break;
        case "top-center":
          O += y + x;
          break;
        case "top-right":
          L += y / 2 + x + 0.1, O += y / 2 + x;
      }
      var F = (-L - x - 0.1) * D, G = (P - L + x + 0.1) * D, V = (0.8 - O + x) * D, U = (-O - x) * D;
      if (p) {
        Br(o, F, V), Br(o, F, U), Br(o, G, V), Br(o, G, U);
        for (var q = a.elementCount, H = 0; H < 4; ++H) Br(l, 10, 10), b(A, I, w, E, T);
        zu(u, q + fa[0], q + fa[1], q + fa[2]), zu(u, q + fa[3], q + fa[4], q + fa[5]);
      }
      if (f) {
        var K = void 0, j = void 0, W = void 0, Z = void 0, Y = void 0, te = void 0, ee = void 0, $ = void 0, ue = y * D, se = h * D;
        switch (m) {
          case "bottom-left":
            K = F - ue / 2, W = F + se / 2, Y = F, ee = F, j = U - ue / 2, Z = U, te = U + se / 2, $ = U;
            break;
          case "bottom-center":
            K = 0, W = se / 2, Y = -se / 2, ee = 0, j = U - ue, Z = U, te = U, $ = U;
            break;
          case "bottom-right":
            K = G + ue / 2, W = G, Y = G - se / 2, ee = G, j = U - ue / 2, Z = U + se / 2, te = U, $ = U;
            break;
          case "middle-left":
            K = F - ue, W = F, Y = F, ee = F, j = 0, Z = -se / 2, te = se / 2, $ = 0;
            break;
          case "middle-center":
            K = 0, W = 0, Y = 0, ee = 0, j = 0, Z = 0, te = 0, $ = 0;
            break;
          case "middle-right":
            K = G + ue, W = G, Y = G, ee = G, j = 0, Z = se / 2, te = -se / 2, $ = 0;
            break;
          case "top-left":
            K = F - ue / 2, W = F + se / 2, Y = F, ee = F, j = V + ue / 2, Z = V, te = V - se / 2, $ = V;
            break;
          case "top-center":
            K = 0, W = se / 2, Y = -se / 2, ee = 0, j = V + ue, Z = V, te = V, $ = V;
            break;
          case "top-right":
            K = G + ue / 2, W = G, Y = G - se / 2, ee = G, j = V + ue / 2, Z = V - se / 2, te = V, $ = V;
            break;
          default:
            Tr();
        }
        for (Br(o, K, j), Br(o, W, Z), Br(o, Y, te), Br(o, ee, $), q = a.elementCount, H = 0; H < 4; ++H) Br(l, 10, 10), b(A, I, w, E, T);
        zu(u, q, q + 1, q + 3), zu(u, q, q + 3, q + 2);
      }
      L += C, O += C;
      var be = 0;
      for (R = 0; R < M; ++R) {
        var ke, Oe = (be - L) * D, ze = (be + (ke = g.get(_[R])).nw - L) * D, je = (ke.nh - O) * D, xe = -O * D;
        Br(o, Oe, je), Br(o, Oe, xe), Br(o, ze, je), Br(o, ze, xe);
        var Xe = g.texture.width, Ee = g.texture.height;
        for (Br(l, ke.x / Xe, ke.y / Ee), Br(l, ke.x / Xe, (ke.y + ke.h) / Ee), Br(l, (ke.x + ke.w) / Xe, ke.y / Ee), Br(l, (ke.x + ke.w) / Xe, (ke.y + ke.h) / Ee), be += ke.nw - 2 * C, q = a.elementCount, H = 0; H < 4; ++H) b(A, I, w, E, T);
        zu(u, q + fa[0], q + fa[1], q + fa[2]), zu(u, q + fa[3], q + fa[4], q + fa[5]);
      }
    }, getText: function() {
      var _ = g.texture, A = he.compact(a, !0), I = he.compact(o, !0), w = he.compact(s, !0), E = he.compact(u, !0), D = he.compact(c, !0), T = he.compact(l, !0);
      return na.create(_, A, I, w, E, D, T, u.elementCount / 2, i);
    } };
  };
})(Tu || (Tu = {}));
var vn, Kx = { alpha: N.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }), hideX: N.Boolean(!1), hideY: N.Boolean(!1), hideZ: N.Boolean(!1), colorX: N.Color(_t.red, { isEssential: !0 }), colorY: N.Color(_t.green, { isEssential: !0 }), colorZ: N.Color(_t.blue, { isEssential: !0 }), scale: N.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }), vecA: N.Vec3(S.unitX), vecB: N.Vec3(S.unitY), vecC: N.Vec3(S.unitZ), location: N.Select("bottom-left", N.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])), locationOffsetX: N.Numeric(0), locationOffsetY: N.Numeric(0), originColor: N.Color(_t.grey), radiusScale: N.Numeric(0.075, { min: 0.01, max: 0.3, step: 1e-3 }), showPlanes: N.Boolean(!1), planeColorXY: N.Color(_t.grey, { label: "Plane Color XY" }), planeColorXZ: N.Color(_t.grey, { label: "Plane Color XZ" }), planeColorYZ: N.Color(_t.grey, { label: "Plane Color YZ" }), showLabels: N.Boolean(!0), labelX: N.Text("X"), labelY: N.Text("Y"), labelZ: N.Text("Z"), labelColorX: N.Color(_t.grey), labelColorY: N.Color(_t.grey), labelColorZ: N.Color(_t.grey), labelOpacity: N.Numeric(1, { min: 0, max: 1, step: 0.01 }), labelScale: N.Numeric(0.15, { min: 0.1, max: 1, step: 0.01 }) }, G0 = { axes: N.MappedStatic("on", { on: N.Group(Kx), off: N.Group({}) }, { cycle: !0, description: "Show camera orientation axes" }) }, Xx = function() {
  function e(t, n) {
    var r = this;
    n === void 0 && (n = {}), this.webgl = t, this.props = { axes: { name: "off", params: {} } }, this.pixelRatio = 1, this.eachGroup = function(i, a) {
      if (!U6(i)) return !1;
      var o = !1;
      if (r.meshRenderObject) for (var s = r.meshRenderObject.values.uGroupCount.ref.value, u = 0, c = i.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, m = l.instanceId * s + d;
        a(oe.ofSingleton(m)) && (o = !0);
      }
      if (r.textRenderObject) {
        s = r.textRenderObject.values.uGroupCount.ref.value;
        for (var p = 0, v = i.elements; p < v.length; p++) {
          var f = v[p];
          d = f.groupId, m = f.instanceId * s + d, a(oe.ofSingleton(m)) && (o = !0);
        }
      }
      return o;
    }, this.scene = zl.create(t, O0), this.camera = new Kn(), S.set(this.camera.up, 0, 1, 0), S.set(this.camera.target, 0, 0, 0), this.setProps(n);
  }
  return e.prototype.setProps = function(t) {
    var n = this;
    this.props = m3(this.props, function(r) {
      if (t.axes !== void 0 && (r.axes.name = t.axes.name, t.axes.name === "on")) {
        n.scene.clear();
        var i = B(B({}, N.getDefaultValues(Kx)), t.axes.params);
        n.pixelRatio = n.webgl.pixelRatio;
        var a = B(B({}, i), { scale: i.scale * n.pixelRatio, labelScale: i.labelScale * n.pixelRatio });
        n.meshRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(p, v) {
              var f = p.vecA, y = p.vecB, h = p.vecC, g = nt.createState(512, 256, v), x = 100 * p.scale, C = p.radiusScale * x, b = p.showLabels ? 100 * p.labelScale / 3 : 0, _ = S.sub(S(), S.scale(S(), f, x - b), S.scale(S(), S.create(0, 0, 1), 0.5 * x)), A = S.sub(S(), S.scale(S(), y, x - b), S.scale(S(), S.create(0, 0, 1), 0.5 * x)), I = S.sub(S(), S.scale(S(), h, x - b), S.scale(S(), S.create(0, 0, 1), 0.5 * x)), w = S.sub(S(), S.origin, S.scale(S(), S.create(0, 0, 1), 0.5 * x)), E = { radiusTop: C, radiusBottom: C, radialSegments: 32 };
              if (g.currentGroup = vn.Origin, yr(g, w, C, 2), p.hideX || (g.currentGroup = vn.X, yr(g, _, C, 2), pr(g, w, _, 1, E)), p.hideY || (g.currentGroup = vn.Y, yr(g, A, C, 2), pr(g, w, A, 1, E)), p.hideZ || (g.currentGroup = vn.Z, yr(g, I, C, 2), pr(g, w, I, 1, E)), p.showPlanes) {
                if (S.scale(_, _, 0.5), S.scale(A, A, 0.5), S.scale(I, I, 0.5), !p.hideX && !p.hideY) {
                  g.currentGroup = vn.XY, nt.addTriangle(g, w, _, A), nt.addTriangle(g, w, A, _);
                  var D = S.add(S(), _, A);
                  nt.addTriangle(g, D, _, A), nt.addTriangle(g, D, A, _);
                }
                if (!p.hideX && !p.hideZ) {
                  g.currentGroup = vn.XZ, nt.addTriangle(g, w, _, I), nt.addTriangle(g, w, I, _);
                  var T = S.add(S(), _, I);
                  nt.addTriangle(g, T, _, I), nt.addTriangle(g, T, I, _);
                }
                if (!p.hideY && !p.hideZ) {
                  g.currentGroup = vn.YZ, nt.addTriangle(g, w, A, I), nt.addTriangle(g, w, I, A);
                  var P = S.add(S(), A, I);
                  nt.addTriangle(g, P, A, I), nt.addTriangle(g, P, I, A);
                }
              }
              return nt.getMesh(g);
            }(u, void 0);
            d.setBoundingSphere(de.create(S.create(l / 2, l / 2, l / 2), l + l / 4));
            var m = function(p) {
              switch (p) {
                case vn.X:
                  return u.colorX;
                case vn.Y:
                  return u.colorY;
                case vn.Z:
                  return u.colorZ;
                case vn.XY:
                  return u.planeColorXY;
                case vn.XZ:
                  return u.planeColorXZ;
                case vn.YZ:
                  return u.planeColorYZ;
                case vn.Origin:
                  return u.originColor;
                default:
                  return _t.grey;
              }
            };
            return Ct.create("axes-mesh", {}, d, m, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return Ct.createRenderObject(s, B(B(B({}, N.getDefaultValues(ht.Params)), o), { ignoreLight: !0 }));
        }(a), n.scene.add(n.meshRenderObject), a.showLabels ? (n.textRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(p, v) {
              var f = p.vecA, y = p.vecB, h = p.vecC, g = Tu.create(p, 8, 8, v), x = 100 * p.scale, C = S.add(S(), S.scale(S(), f, x), S.scale(S(), S.create(0, 0, 1), 1.5 * x)), b = S.add(S(), S.scale(S(), y, x), S.scale(S(), S.create(0, 0, 1), 1.5 * x)), _ = S.add(S(), S.scale(S(), h, x), S.scale(S(), S.create(0, 0, 1), 1.5 * x)), A = 100 * p.labelScale;
              return p.hideX || g.add(p.labelX, C[0], C[1], C[2], 0, A, vn.X), p.hideY || g.add(p.labelY, b[0], b[1], b[2], 0, A, vn.Y), p.hideZ || g.add(p.labelZ, _[0], _[1], _[2], 0, A, vn.Z), g.getText();
            }(u, void 0);
            d.setBoundingSphere(de.create(S.create(l / 2, l / 2, l / 2), l));
            var m = function(p) {
              switch (p) {
                case vn.X:
                  return u.labelColorX;
                case vn.Y:
                  return u.labelColorY;
                case vn.Z:
                  return u.labelColorZ;
                default:
                  return _t.grey;
              }
            };
            return Ct.create("axes-text", {}, d, m, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return Ct.createRenderObject(s, B(B(B({}, N.getDefaultValues(na.Params)), o), { alpha: o.labelOpacity }));
        }(a), n.scene.add(n.textRenderObject)) : n.textRenderObject = void 0, n.scene.commit(), S.set(n.camera.position, 0, 0, 200 * a.scale), J.lookAt(n.camera.view, n.camera.position, n.camera.target, n.camera.up), r.axes.params = B({}, i);
      }
    });
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this.props.axes.name === "on";
  }, enumerable: !1, configurable: !0 }), e.prototype.getLoci = function(t) {
    var n = t.objectId, r = t.groupId, i = t.instanceId;
    return (this.meshRenderObject && n === this.meshRenderObject.id || this.textRenderObject && n === this.textRenderObject.id) && r !== vn.None ? function(a, o, s) {
      return r3("camera-axes", a, [{ groupId: o, instanceId: s }], void 0, function() {
        return function(u, c) {
          var l = c.props.axes, d = l.name === "on" ? l.params.labelX : "X", m = l.name === "on" ? l.params.labelY : "Y", p = l.name === "on" ? l.params.labelZ : "Z";
          switch (u) {
            case vn.X:
              return "".concat(d, " Axis");
            case vn.Y:
              return "".concat(m, " Axis");
            case vn.Z:
              return "".concat(p, " Axis");
            case vn.XY:
              return "".concat(d).concat(m, " Plane");
            case vn.XZ:
              return "".concat(d).concat(p, " Plane");
            case vn.YZ:
              return "".concat(m).concat(p, " Plane");
            case vn.Origin:
              return "Origin";
            default:
              return "Axes";
          }
        }(o, a);
      });
    }(this, r, i) : Sn;
  }, e.prototype.mark = function(t, n) {
    return !Wt.is(Wt.Highlighting, n) || !Vi(t) && (!U6(t) || t.data !== this) ? !1 : Pt.mark(this.meshRenderObject, t, n, this.eachGroup) || Pt.mark(this.textRenderObject, t, n, 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, m = s.width / 2, p = s.height / 2, v = -s.height / 2, f = (m - d) / 2, y = (p - v) / 2, h = (m + d) / 2, g = (p + v) / 2, x = h - f, C = h + f, b = g + y, _ = g - y;
        if (u.enabled) {
          var A = (m - d) / u.width, I = (p - v) / u.height;
          C = (x += A * u.offsetX) + A * u.width, _ = (b -= I * u.offsetY) - I * u.height;
        }
        J.ortho(o.projection, x, C, b, _, c, l);
      }(this.camera, t.viewport, t.viewOffset), J.extractRotation(this.scene.view, t.view);
      var n = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, r = this.props.axes.params.location, i = this.props.axes.params.locationOffsetX * this.pixelRatio, a = this.props.axes.params.locationOffsetY * this.pixelRatio;
      r === "bottom-left" ? J.setTranslation(this.scene.view, S.create(-t.viewport.width / 2 + n + i, -t.viewport.height / 2 + n + a, 0)) : r === "bottom-right" ? J.setTranslation(this.scene.view, S.create(t.viewport.width / 2 - n - i, -t.viewport.height / 2 + n + a, 0)) : r === "top-left" ? J.setTranslation(this.scene.view, S.create(-t.viewport.width / 2 + n + i, t.viewport.height / 2 - n - a, 0)) : r === "top-right" ? J.setTranslation(this.scene.view, S.create(t.viewport.width / 2 - n - i, t.viewport.height / 2 - n - a, 0)) : Tr();
    }
  }, e;
}();
function U6(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";
})(vn || (vn = {}));
var GO = { transparentBackground: N.Boolean(!1), multiSample: N.Group(Gx), postprocessing: N.Group(Fx), marking: N.Group(Ux), cameraHelper: N.Group(G0) }, VO = function() {
  function e(t, n, r, i, a, o, s) {
    this.webgl = t, this.renderer = n, this.scene = r, this.camera = i, this._width = 0, this._height = 0, this._camera = new Kn(), this.props = B(B({}, N.getDefaultValues(GO)), s), this.drawPass = new Hx(t, 128, 128, o), this.multiSamplePass = new o0(t, this.drawPass), this.multiSampleHelper = new Vx(this.multiSamplePass), this.helper = { camera: new Xx(t, this.props.cameraHelper), debug: a.debug, handle: a.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, n) {
    t === this._width && n === this._height || (this._width = t, this._height = n, this.drawPass.setSize(t, n), 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() {
    Kn.copySnapshot(this._camera.state, this.camera.state), Pr.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 };
    o0.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, n, r) {
    var i, a;
    this.setSize(t, n), this.render(), this.colorTarget.bind();
    var o = (i = r == null ? void 0 : r.width) !== null && i !== void 0 ? i : t, s = (a = r == null ? void 0 : r.height) !== null && a !== void 0 ? a : n, u = new Uint8Array(o * s * 4);
    r ? this.webgl.readPixels(r.x, n - r.y - r.height, o, s, u) : this.webgl.readPixels(0, 0, o, s, u);
    var c = hc.create(u, o, s);
    return hc.flipY(c), hc.divideByAlpha(c), new ImageData(new Uint8ClampedArray(u), o, s);
  }, e;
}(), zO = B(B({}, ht.Params), { alpha: B(B({}, ht.Params.alpha), { defaultValue: 1 }), ignoreLight: B(B({}, ht.Params.ignoreLight), { defaultValue: !0 }), colorX: N.Color(_t.red, { isEssential: !0 }), colorY: N.Color(_t.green, { isEssential: !0 }), colorZ: N.Color(_t.blue, { isEssential: !0 }), scale: N.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }) }), Yx = { handle: N.MappedStatic("off", { on: N.Group(zO), off: N.Group({}) }, { cycle: !0, description: "Show handle tool" }) }, UO = function() {
  function e(t, n) {
    var r = this;
    n === void 0 && (n = {}), this.webgl = t, this.props = { handle: { name: "off", params: {} } }, this.pixelRatio = 1, this._transform = J(), this.eachGroup = function(i, a) {
      if (!r.renderObject || !H6(i)) return !1;
      for (var o = !1, s = r.renderObject.values.uGroupCount.ref.value, u = 0, c = i.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, m = l.instanceId * s + d;
        a(oe.ofSingleton(m)) && (o = !0);
      }
      return o;
    }, this.scene = zl.create(t, O0), this.setProps(n);
  }
  return e.prototype.getBoundingSphere = function(t, n) {
    return this.renderObject && (de.copy(t, this.renderObject.values.invariantBoundingSphere.ref.value), J.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, 16 * n), de.transform(t, t, this._transform)), t;
  }, e.prototype.setProps = function(t) {
    var n = this;
    this.props = m3(this.props, function(r) {
      if (t.handle !== void 0 && (r.handle.name = t.handle.name, t.handle.name === "on")) {
        n.scene.clear(), n.pixelRatio = n.webgl.pixelRatio;
        var i = B(B({}, t.handle.params), { scale: t.handle.params.scale * n.webgl.pixelRatio });
        n.renderObject = function(a) {
          var o = function(s, u) {
            var c = 10 * s.scale, l = function(m, p) {
              var v = nt.createState(512, 256, p), f = 0.05 * m, y = S.scale(S(), S.unitX, m), h = S.scale(S(), S.unitY, m), g = S.scale(S(), S.unitZ, m), x = { radiusTop: f, radiusBottom: f, radialSegments: 32 };
              return v.currentGroup = Uu.TranslateScreenXY, yr(v, S.origin, 3 * f, 2), v.currentGroup = Uu.TranslateObjectX, yr(v, y, f, 2), pr(v, S.origin, y, 1, x), v.currentGroup = Uu.TranslateObjectY, yr(v, h, f, 2), pr(v, S.origin, h, 1, x), v.currentGroup = Uu.TranslateObjectZ, yr(v, g, f, 2), pr(v, S.origin, g, 1, x), nt.getMesh(v);
            }(c, void 0);
            l.setBoundingSphere(de.create(S.create(c / 2, c / 2, c / 2), c + c / 4));
            var d = function(m) {
              switch (m) {
                case Uu.TranslateObjectX:
                  return s.colorX;
                case Uu.TranslateObjectY:
                  return s.colorY;
                case Uu.TranslateObjectZ:
                  return s.colorZ;
                default:
                  return _t.grey;
              }
            };
            return Ct.create("handle", {}, l, d, function() {
              return 1;
            }, function() {
              return "";
            });
          }(a);
          return Ct.createRenderObject(o, a);
        }(i), n.scene.add(n.renderObject), n.scene.commit(), r.handle.params = B({}, 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, n, r) {
    this.renderObject && (this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), J.setTranslation(this.renderObject.values.aTransform.ref.value, n), J.fromMat3(this.renderObject.values.aTransform.ref.value, r), k.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0));
  }, e.prototype.getLoci = function(t) {
    var n = t.objectId, r = t.groupId, i = t.instanceId;
    return this.renderObject && n === this.renderObject.id ? function(a, o, s) {
      return r3("handle", a, [{ groupId: o, instanceId: s }], function(u) {
        return a.getBoundingSphere(u, s);
      }, function() {
        return "Handle Helper | Group Id ".concat(o, " | Instance Id ").concat(s);
      });
    }(this, r, i) : Sn;
  }, e.prototype.mark = function(t, n) {
    return !Wt.is(Wt.Highlighting, n) || !Vi(t) && (!H6(t) || t.data !== this) ? !1 : Pt.mark(this.renderObject, t, n, this.eachGroup);
  }, e;
}(), Uu = { None: 0, TranslateScreenXY: 1, TranslateObjectX: 3, TranslateObjectY: 4, TranslateObjectZ: 5 };
function H6(e) {
  return e.kind === "data-loci" && e.tag === "handle";
}
var Lv, HO = { debug: N.Group(a3), camera: N.Group({ helper: N.Group(G0) }), handle: N.Group(Yx) }, qO = N.getDefaultValues(HO), jO = function(e, t, n) {
  n === void 0 && (n = {});
  var r = B(B({}, qO), n);
  this.debug = new Yk(e, t, r.debug), this.camera = new Xx(e, r.camera.helper), this.handle = new UO(e, r.handle);
}, KO = function() {
  function e(t, n) {
    n === void 0 && (n = {}), this.webgl = t;
    var r = t.gl;
    this.draw = new Hx(t, r.drawingBufferWidth, r.drawingBufferHeight, n.enableWboit || !1), this.pick = new bO(t, this.draw, n.pickScale || 0.25), this.multiSample = new o0(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;
}(), l0 = { camera: N.Group({ mode: N.Select("orthographic", N.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }), helper: N.Group(G0, { isFlat: !0 }), stereo: N.MappedStatic("off", { on: N.Group(zx), off: N.Group({}) }, { cycle: !0, hideIf: function(e) {
  return (e == null ? void 0 : e.mode) !== "perspective";
} }), manualReset: N.Boolean(!1, { isHidden: !0 }) }, { pivot: "mode" }), cameraFog: N.MappedStatic("on", { on: N.Group({ intensity: N.Numeric(50, { min: 1, max: 100, step: 1 }) }), off: N.Group({}) }, { cycle: !0, description: "Show fog in the distance" }), cameraClipping: N.Group({ radius: N.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }), far: N.Boolean(!0, { description: "Hide scene in the distance" }) }, { pivot: "radius" }), viewport: N.MappedStatic("canvas", { canvas: N.Group({}), "static-frame": N.Group({ x: N.Numeric(0), y: N.Numeric(0), width: N.Numeric(128), height: N.Numeric(128) }), "relative-frame": N.Group({ x: N.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), y: N.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), width: N.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }), height: N.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }) }) }), cameraResetDurationMs: N.Numeric(250, { min: 0, max: 1e3, step: 1 }, { description: "The time it takes to reset the camera." }), transparentBackground: N.Boolean(!1), multiSample: N.Group(Gx), postprocessing: N.Group(Fx), marking: N.Group(Ux), renderer: N.Group(j2), trackball: N.Group(V7), interaction: N.Group(Lx), debug: N.Group(a3), handle: N.Group(Yx) }, XO = N.getDefaultValues(l0);
(function(e) {
  e.DefaultAttribs = { antialias: !0, preserveDrawingBuffer: !0, pixelScale: 1, pickScale: 0.25, pickPadding: 1, enableWboit: !0, preferWebGl1: !1 }, e.fromCanvas = function(t, n) {
    n === void 0 && (n = {});
    var r = B(B({}, e.DefaultAttribs), n), i = r.antialias, a = r.preserveDrawingBuffer, o = r.pixelScale, s = r.preferWebGl1, u = function(y, h) {
      function g(C) {
        try {
          return y.getContext(C, h);
        } catch {
          return null;
        }
      }
      var x = (h != null && h.preferWebGl1 ? null : g("webgl2")) || g("webgl") || g("experimental-webgl");
      return Xt && console.log("isWebgl2: ".concat(Et(x))), x;
    }(t, { antialias: i, preserveDrawingBuffer: a, alpha: !0, depth: !0, premultipliedAlpha: !0, preferWebGl1: s });
    if (u === null) throw new Error("Could not create a WebGL rendering context");
    var c = z2.fromElement(t, { pixelScale: o, preventGestures: !0 }), l = sT(u, { pixelScale: o }), d = new KO(l, n);
    if (Xt) {
      var m = u.getExtension("WEBGL_lose_context");
      m && t.addEventListener("mousedown", function(y) {
        l.isContextLost || y.shiftKey && y.ctrlKey && y.altKey && (Xt && console.log("lose context"), m.loseContext(), setTimeout(function() {
          l.isContextLost && (Xt && console.log("restore context"), m.restoreContext());
        }, 1e3));
      }, !1);
    }
    var p = new cu(0), v = function(y) {
      l.setContextLost(), y && y.preventDefault(), Xt && console.log("context lost"), p.next(nr());
    }, f = function() {
      l.isContextLost && (l.handleContextRestored(function() {
        d.draw.reset();
      }), Xt && console.log("context restored"));
    };
    return t.addEventListener("webglcontextlost", v, !1), t.addEventListener("webglcontextrestored", f, !1), { canvas: t, webgl: l, input: c, passes: d, attribs: r, contextLost: p, contextRestored: l.contextRestored, dispose: function(y) {
      c.dispose(), t.removeEventListener("webglcontextlost", v, !1), t.removeEventListener("webglcontextrestored", f, !1), l.destroy(y);
    }, handleWebglContextLost: v, handlewWebglContextRestored: f };
  };
})(Lv || (Lv = {}));
var Fv, YO = typeof window < "u" ? window.requestAnimationFrame : function(e) {
  return setImmediate(function() {
    return e(Date.now());
  });
}, WO = typeof window < "u" ? window.cancelAnimationFrame : function(e) {
  return clearImmediate(e);
};
function q6(e, t, n) {
  n === void 0 && (n = 1);
  var r = window.innerWidth, i = window.innerHeight;
  t !== document.body && (r = t.offsetWidth, i = t.offsetHeight), function(a, o, s, u) {
    u === void 0 && (u = 1), a.width = Math.round(window.devicePixelRatio * u * o), a.height = Math.round(window.devicePixelRatio * u * s), Object.assign(a.style, { width: "".concat(o, "px"), height: "".concat(s, "px") });
  }(e, r, i, n);
}
function j6(e, t, n) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(r) {
      return [2, new Promise(function(i, a) {
        var o = function(s) {
          s ? i(s) : a("no blob returned");
        };
        HTMLCanvasElement.prototype.toBlob ? e.toBlob(o, t, n) : function(s, u, c, l) {
          for (var d = atob(s.toDataURL(c, l).split(",")[1]), m = d.length, p = m >> 2, v = new Uint8Array(m), f = new Uint32Array(v.buffer, 0, p), y = 0, h = 0; h < p; ++h) f[h] = d.charCodeAt(y++) | d.charCodeAt(y++) << 8 | d.charCodeAt(y++) << 16 | d.charCodeAt(y++) << 24;
          for (var g = 3 & m; g--; ) v[y] = d.charCodeAt(y++);
          u(new Blob([v], { type: c }));
        }(e, o, t, n);
      })];
    });
  });
}
function Zt(e, t) {
  return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t]);
}
function p3(e, t) {
  return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t]);
}
function Wx(e, t) {
  return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t]);
}
function d0(e, t) {
  return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t]);
}
function ZO(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t]);
}
function Pf(e, t, n) {
  return function(r, i, a) {
    for (var o = 0, s = r.interUnitBonds.getEdgeIndices(a, i.id), u = 0, c = s.length; u < c; ++u) {
      var l = r.interUnitBonds.edges[s[u]];
      Bt.isCovalent(l.props.flag) && (o += 1);
    }
    return o;
  }(e, t, n) + function(r, i) {
    for (var a = 0, o = r.bonds, s = o.offset, u = o.edgeProps.flags, c = s[i], l = s[i + 1]; c < l; ++c) Bt.isCovalent(u[c]) && (a += 1);
    return a;
  }(t, n);
}
function K6(e, t, n, r) {
  var i = 0;
  return gs(e, t, n, function(a, o) {
    Zt(a, o) === r && (i += 1);
  }), i;
}
function QO(e, t, n, r, i) {
  return t === r ? function(a, o, s) {
    var u = a.bonds, c = u.offset, l = u.b, d = u.edgeProps.flags;
    Bt.is;
    for (var m = c[o], p = c[o + 1]; m < p; ++m) if (l[m] === s && Bt.isCovalent(d[m])) return !0;
    return !1;
  }(t, n, i) : function(a, o, s, u, c) {
    var l = a.interUnitBonds.getEdge(s, o.id, c, u.id);
    return l && Bt.isCovalent(l.props.flag);
  }(e, t, n, r, i);
}
function Eo(e, t, n) {
  for (var r = e.bonds, i = r.offset, a = r.b, o = r.edgeProps.flags, s = i[t], u = i[t + 1]; s < u; ++s) Bt.isCovalent(o[s]) && n(e, a[s]);
}
function gs(e, t, n, r) {
  (function(i, a, o, s) {
    for (var u = i.interUnitBonds.getEdgeIndices(o, a.id), c = 0, l = u.length; c < l; ++c) {
      var d = i.interUnitBonds.edges[u[c]], m = i.unitMap.get(d.unitB);
      Bt.isCovalent(d.props.flag) && s(m, d.indexB);
    }
  })(e, t, n, r), Eo(t, n, r);
}
function R1(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, n) {
    var r = t.webgl, i = t.input, a = t.passes, o = t.attribs;
    n === void 0 && (n = {});
    var s = B(B({}, XO), n), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = new cu(0), d = nr(), m = new cu(0), p = new cu(0), v = r.gl, f = r.contextRestored, y = 0, h = 0, g = 128, x = 128;
    Ye();
    var C = zl.create(r, a.draw.wboitEnabled ? tR : O0), b = new Kn({ position: S.create(0, 0, 100), mode: s.camera.mode, fog: s.cameraFog.name === "on" ? s.cameraFog.params.intensity : 0, clipFar: s.cameraClipping.far }, { x: y, y: h, width: g, height: x }, { pixelScale: o.pixelScale }), _ = new Ul(b, s.camera.stereo.params), A = K2.create(i, b, s.trackball), I = q2.create(r, s.renderer), w = new jO(r, C, s), E = new _O(r, I, C, w, a.pick, { x: y, y: h, width: g, height: x }, o.pickPadding), D = new $k($, F, i, b, s.interaction), T = new Vx(a.multiSample), P = !1, M = void 0, R = void 0, O = !1, L = !0;
    function F(le) {
      var Ce = Sn, Ae = Mt.Empty;
      if (le) {
        var Te = w.camera.getLoci(le);
        if (Te !== Sn) return { loci: Te, repr: Ae };
        Ce = w.handle.getLoci(le), u.forEach(function(Re, we) {
          var Qe = we.getLoci(le);
          Cu(Qe) || (Cu(Ce) || console.warn("found another loci, this should not happen"), Ce = Qe, Ae = we);
        });
      }
      return { loci: Ce, repr: Ae };
    }
    var G = [];
    function V(le, Ce) {
      var Ae = le.repr, Te = le.loci, Re = !1;
      return Ae ? Re = Ae.mark(Te, Ce) : (Re = w.handle.mark(Te, Ce), Re = w.camera.mark(Te, Ce) || Re, u.forEach(function(we, Qe) {
        Re = Qe.mark(Te, Ce) || Re;
      })), Re;
    }
    function U(le) {
      if (r.isContextLost) return !1;
      var Ce = !1;
      if (O && (Ee(!1), O = !1, Ce = !0), y > v.drawingBufferWidth || y + g < 0 || h > v.drawingBufferHeight || h + x < 0) return !1;
      var Ae = function() {
        for (var ft = !1, It = 0, pe = G; It < pe.length; It++) {
          var We = pe[It];
          ft = V(We[0], We[1]) || ft;
        }
        return G = [], ft && (C.update(void 0, !0), w.handle.scene.update(void 0, !0), w.camera.scene.update(void 0, !0)), ft;
      }(), Te = !1;
      A.update(K);
      var Re = b.update(), we = le || Re || Ce || q;
      q = !1;
      var Qe = T.update(Ae || we, s.multiSample);
      if (we || Qe || Ae) {
        var Je = b;
        s.camera.stereo.name === "on" && (_.update(), Je = _);
        var lt = { renderer: I, camera: Je, scene: C, helper: w };
        if (o0.isEnabled(s.multiSample)) {
          var st = !Re && Ae && !A.isAnimating;
          T.render(lt, s, !0, st);
        } else a.draw.render(lt, s, !0);
        E.dirty = E.dirty || we, Te = !0;
      }
      return Te;
    }
    var q = !1, H = !1, K = 0, j = !1;
    function W(le) {
      j || U(!!(le != null && le.force)) && L && m.next(nr() - d);
    }
    function Z() {
      q = !0;
    }
    var Y = 0;
    function te(le, Ce) {
      K = le, ue(Ce == null ? void 0 : Ce.isSynchronous), b.transition.tick(K), Ce != null && Ce.manualDraw || (W(), b.transition.inTransition || r.isContextLost || D.tick(K));
    }
    function ee() {
      te(nr()), Y = YO(ee);
    }
    function $(le, Ce) {
      var Ae = s.camera.stereo.name === "on" ? _ : b;
      return r.isContextLost ? void 0 : E.identify(le, Ce, Ae);
    }
    function ue(le) {
      le === void 0 && (le = !1);
      var Ce = function(Ae) {
        if (!C.needsCommit) return !0;
        if (de.copy(se, C.boundingSphereVisible), !C.commit(Ae ? void 0 : ke)) return !1;
        w.debug.isEnabled && w.debug.update();
        var Te = function() {
          if (b.state.radiusMax === 0) return !0;
          if (b.transition.inTransition || R) return !1;
          var Re = !0, we = !0;
          de.set(be, b.state.target, b.state.radius);
          for (var Qe = 0, Je = C.renderables; Qe < Je.length; Qe++) {
            var lt = Je[Qe];
            if (lt.state.visible) {
              var st = lt.values.boundingSphere.ref.value;
              if (st.radius) {
                we = !1;
                var ft = S.distance(be.center, st.center);
                if ((ft > be.radius || ft > st.radius || st.radius > b.state.radiusMax) && !de.includes(se, st)) return !0;
                de.overlaps(be, st) && (Re = !1);
              }
            }
          }
          return Re || !we && be.radius <= 0.1;
        }();
        return s.camera.manualReset || l.value !== 0 && !Te || (P = !0), se.radius === 0 && (M = 0), Te && b.setState({ radiusMax: C.boundingSphere.radius }, 0), l.next(u.size), Xt && Oe(), !0;
      }(le);
      Ce && (A.isLockCamera ? (M = void 0, R = void 0, P = !1) : function() {
        if (!(!P || A.isLockCamera)) {
          var Ae = C.boundingSphereVisible, Te = Ae.center, Re = Ae.radius, we = A.props.autoAdjustMinMaxDistance;
          if (we.name === "on") {
            var Qe = we.params.minDistanceFactor * Re + we.params.minDistancePadding, Je = Math.max(we.params.maxDistanceFactor * Re, we.params.maxDistanceMin);
            A.setProps({ minDistance: Qe, maxDistance: Je });
          }
          if (Re > 0) {
            var lt = M === void 0 ? s.cameraResetDurationMs : M, st = b.getFocus(Te, Re), ft = typeof R == "function" ? R(C, b) : R, It = ft ? B(B({}, st), ft) : st;
            b.setState(B(B({}, It), { radiusMax: C.boundingSphere.radius }), lt);
          }
          M = void 0, R = void 0, P = !1;
        }
      }(), H && (w.debug.isEnabled && w.debug.update(), W({ force: !0 }), H = !1), p.next(nr()));
    }
    var se = de(), be = de(), ke = 250;
    function Oe() {
      console.table(C.renderables.map(function(Re) {
        return { drawCount: Re.values.drawCount.ref.value, instanceCount: Re.values.instanceCount.ref.value, materialId: Re.materialId, renderItemId: Re.id };
      })), console.log(r.stats);
      var le = r.resources.getByteCounts(), Ce = le.texture, Ae = le.attribute, Te = le.elements;
      console.log({ texture: "".concat((Ce / 1024 / 1024).toFixed(3), " MiB"), attribute: "".concat((Ae / 1024 / 1024).toFixed(3), " MiB"), elements: "".concat((Te / 1024 / 1024).toFixed(3), " MiB") });
    }
    function ze(le) {
      (function(Te) {
        c.has(Te) || c.set(Te, Te.updated.subscribe(function(Re) {
          Te.state.syncManually || ze(Te);
        }));
      })(le);
      var Ce = u.get(le), Ae = /* @__PURE__ */ new Set();
      le.renderObjects.forEach(function(Te) {
        return Ae.add(Te);
      }), Ce ? Ii.areEqual(Ae, Ce) || (Ae.forEach(function(Te) {
        Ce.has(Te) || C.add(Te);
      }), Ce.forEach(function(Te) {
        Ae.has(Te) || C.remove(Te);
      })) : le.renderObjects.forEach(function(Te) {
        return C.add(Te);
      }), u.set(le, Ae), C.update(le.renderObjects, !1), H = !0, Xt && Oe();
    }
    function je() {
      var le = C.boundingSphere.radius > 0 ? 100 - Math.round(b.transition.target.radius / C.boundingSphere.radius * 100) : 0;
      return { camera: { mode: b.state.mode, helper: B({}, w.camera.props), stereo: B({}, 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: le }, cameraResetDurationMs: s.cameraResetDurationMs, transparentBackground: s.transparentBackground, viewport: s.viewport, postprocessing: B({}, s.postprocessing), marking: B({}, s.marking), multiSample: B({}, s.multiSample), renderer: B({}, I.props), trackball: B({}, A.props), interaction: B({}, D.props), debug: B({}, w.debug.props), handle: B({}, w.handle.props) };
    }
    var xe = f.subscribe(function() {
      E.dirty = !0, W({ force: !0 }), W({ force: !0 });
    }), Xe = new cu(0);
    function Ee(le) {
      le === void 0 && (le = !0), a.updateSize(), Ye(), He(), le && Z(), Xe.next(+/* @__PURE__ */ new Date());
    }
    return { webgl: r, scene: C, helper: w, add: ze, remove: function(le) {
      (function(Ae) {
        var Te = c.get(Ae);
        Te && (Te.unsubscribe(), c.delete(Ae));
      })(le);
      var Ce = u.get(le);
      Ce && (Ce.forEach(function(Ae) {
        return C.remove(Ae);
      }), u.delete(le), H = !0, Xt && Oe());
    }, commit: ue, controls: A, update: function(le, Ce) {
      if (le) {
        if (!u.has(le)) return;
        C.update(le.renderObjects, !!Ce);
      } else C.update(void 0, !!Ce);
      H = !0;
    }, clear: function() {
      c.forEach(function(le) {
        return le.unsubscribe();
      }), c.clear(), u.clear(), C.clear(), w.debug.clear(), Z(), l.next(u.size);
    }, syncVisibility: function() {
      b.state.radiusMax === 0 && (P = !0, M = 0), C.syncVisibility() && w.debug.isEnabled && w.debug.update(), Z();
    }, requestDraw: Z, tick: te, animate: function() {
      j = !1, A.start(nr()), Y === 0 && ee();
    }, resetTime: function(le) {
      d = le, A.start(le);
    }, pause: function(le) {
      le === void 0 && (le = !1), j = le, WO(Y), Y = 0;
    }, resume: function() {
      j = !1;
    }, identify: $, getPosition: function(le, Ce) {
      var Ae = b;
      return r.isContextLost ? void 0 : E.getPosition(le, Ce, Ae);
    }, mark: function(le, Ce) {
      G.push([le, Ce]);
    }, getLoci: F, handleResize: Ee, requestResize: function() {
      O = !0;
    }, requestCameraReset: function(le) {
      M = le == null ? void 0 : le.durationMs, R = le == null ? void 0 : le.snapshot, P = !0;
    }, camera: b, boundingSphere: C.boundingSphere, boundingSphereVisible: C.boundingSphereVisible, get notifyDidDraw() {
      return L;
    }, set notifyDidDraw(le) {
      L = le;
    }, didDraw: m, commited: p, reprCount: l, resized: Xe, setProps: function(le, Ce) {
      var Ae, Te, Re;
      Ce === void 0 && (Ce = !1);
      var we = typeof le == "function" ? m3(je(), le) : le, Qe = /* @__PURE__ */ Object.create(null);
      if (we.camera && we.camera.mode !== void 0 && we.camera.mode !== b.state.mode && (Qe.mode = we.camera.mode), we.cameraFog !== void 0 && we.cameraFog.params) {
        var Je = we.cameraFog.name === "on" ? we.cameraFog.params.intensity : 0;
        Je !== b.state.fog && (Qe.fog = Je);
      }
      if (we.cameraClipping !== void 0 && (we.cameraClipping.far !== void 0 && we.cameraClipping.far !== b.state.clipFar && (Qe.clipFar = we.cameraClipping.far), we.cameraClipping.radius !== void 0)) {
        var lt = C.boundingSphere.radius / 100 * (100 - we.cameraClipping.radius);
        lt > 0 && lt !== Qe.radius && (Qe.radius = Math.max(lt, 0.01));
      }
      Object.keys(Qe).length > 0 && b.setState(Qe), !((Ae = we.camera) === null || Ae === void 0) && Ae.helper && w.camera.setProps(we.camera.helper), ((Te = we.camera) === null || Te === void 0 ? void 0 : Te.manualReset) !== void 0 && (s.camera.manualReset = we.camera.manualReset), ((Re = we.camera) === null || Re === void 0 ? void 0 : Re.stereo) !== void 0 && Object.assign(s.camera.stereo, we.camera.stereo), we.cameraResetDurationMs !== void 0 && (s.cameraResetDurationMs = we.cameraResetDurationMs), we.transparentBackground !== void 0 && (s.transparentBackground = we.transparentBackground), we.viewport !== void 0 && (s.viewport === we.viewport || s.viewport.name === we.viewport.name && V2(s.viewport.params, we.viewport.params) || (s.viewport = we.viewport, Ye(), He())), we.postprocessing && Object.assign(s.postprocessing, we.postprocessing), we.marking && Object.assign(s.marking, we.marking), we.multiSample && Object.assign(s.multiSample, we.multiSample), we.renderer && I.setProps(we.renderer), we.trackball && A.setProps(we.trackball), we.interaction && D.setProps(we.interaction), we.debug && w.debug.setProps(we.debug), we.handle && w.handle.setProps(we.handle), Qe.mode === "orthographic" && (s.camera.stereo.name = "off"), Ce || Z();
    }, getImagePass: function(le) {
      return le === void 0 && (le = {}), new VO(r, I, C, b, w, a.draw.wboitEnabled, le);
    }, getRenderObjects: function() {
      var le = [];
      return C.forEach(function(Ce, Ae) {
        return le.push(Ae);
      }), le;
    }, get props() {
      return je();
    }, get input() {
      return i;
    }, get stats() {
      return I.stats;
    }, get interaction() {
      return D.events;
    }, dispose: function() {
      xe.unsubscribe(), G = [], C.clear(), w.debug.clear(), A.dispose(), I.dispose(), D.dispose();
    } };
    function Ye() {
      var le = y, Ce = h, Ae = g, Te = x;
      s.viewport.name === "canvas" ? (y = 0, h = 0, g = v.drawingBufferWidth, x = v.drawingBufferHeight) : s.viewport.name === "static-frame" ? (y = s.viewport.params.x * r.pixelRatio, x = s.viewport.params.height * r.pixelRatio, h = v.drawingBufferHeight - x - s.viewport.params.y * r.pixelRatio, g = s.viewport.params.width * r.pixelRatio) : s.viewport.name === "relative-frame" && (y = Math.round(s.viewport.params.x * v.drawingBufferWidth), x = Math.round(s.viewport.params.height * v.drawingBufferHeight), h = Math.round(v.drawingBufferHeight - x - s.viewport.params.y * v.drawingBufferHeight), g = Math.round(s.viewport.params.width * v.drawingBufferWidth)), le === y && Ce === h && Ae === g && Te === x || (q = !0);
    }
    function He() {
      E.setViewport(y, h, g, x), I.setViewport(y, h, g, x), Pr.set(b.viewport, y, h, g, x), Pr.set(A.viewport, y, h, g, x);
    }
  };
})(Fv || (Fv = {}));
var X6 = S(), Y6 = S(), bh = S(), W6 = S(), Z6 = S();
function Gv(e, t, n, r, i) {
  var a = [];
  return t.conformation.position(t.elements[n], bh), r.conformation.position(r.elements[i], W6), S.sub(X6, W6, bh), gs(e, t, n, function(o, s) {
    Zt(o, s) !== "H" && (o.conformation.position(o.elements[s], Z6), S.sub(Y6, Z6, bh), a.push(S.angle(X6, Y6)));
  }), a;
}
var JO = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR"]), $O = /* @__PURE__ */ new Set(["BE", "MG", "CA", "SR", "BA", "RA"]), eN = /* @__PURE__ */ new Set(["ZN", "GA", "CD", "IN", "SN", "HG", "TI", "PB", "BI", "PO", "CN"]), tN = /* @__PURE__ */ new Set(["F", "CL", "BR", "I", "AT"]);
function nN(e) {
  return tN.has(e);
}
function Zx(e) {
  var t = yf(e);
  return t >= 21 && t <= 29 || t >= 39 && t <= 47 || t >= 72 && t <= 79 || t >= 104 && t <= 108;
}
function rN(e) {
  return function(t) {
    return JO.has(t);
  }(e) || function(t) {
    return $O.has(t);
  }(e) || function(t) {
    var n = yf(t);
    return n >= 57 && n <= 71;
  }(e) || function(t) {
    var n = yf(t);
    return n >= 89 && n <= 103;
  }(e) || Zx(e) || function(t) {
    return eN.has(t);
  }(e);
}
var _h = new rt.ElementBondIterator(), xh = new rt.ElementBondIterator(), el = new rt.ElementBondIterator(), Sh = new rt.ElementBondIterator();
function iN(e, t, n, r) {
  var i = K6(e, t, n, "H"), a = Zt(t, n), o = p3(t, n), s = r.assignCharge === "always" || r.assignCharge === "auto" && o === 0, u = !["sdf", "mol"].includes(t.model.sourceData.kind) && (r.assignH === "always" || r.assignH === "auto" && i === 0), c = Pf(e, t, n), l = function(x, C, b) {
    for (var _ = 0, A = C.bonds, I = A.offset, w = A.edgeProps, E = w.flags, D = w.order, T = I[b], P = I[b + 1]; T < P; ++T) Bt.isCovalent(E[T]) && (_ += D[T]);
    return x.interUnitBonds.getEdgeIndices(b, C.id).forEach(function(M) {
      var R = x.interUnitBonds.edges[M];
      Bt.isCovalent(R.props.flag) && (_ += R.props.order);
    }), _;
  }(e, t, n), d = function(x, C, b) {
    var _ = Zt(C, b), A = _ === "O" || _ === "N";
    if (A && Pf(x, C, b) === 4) return !1;
    for (_h.setElement(x, C, b); _h.hasNext; ) {
      var I = _h.move();
      if (I.order > 1) return !0;
      if (A) {
        var w = Zt(I.otherUnit, I.otherIndex);
        for (xh.setElement(x, I.otherUnit, I.otherIndex); xh.hasNext; ) {
          var E = xh.move();
          if (E.order > 1) {
            if ((w === "P" || w === "S") && Zt(E.otherUnit, E.otherIndex) === "O") continue;
            return !0;
          }
        }
      }
    }
    return !1;
  }(e, t, n), m = l - c > 0, p = 0, v = 8;
  switch (a) {
    case "H":
      s && (c === 0 ? (o = 1, v = 0) : c === 1 && (o = 0, v = 1));
      break;
    case "C":
      s && (o = 0), u && (p = Math.max(0, 4 - l - Math.abs(o))), v = R1(c + p + Math.max(0, -o));
      break;
    case "N":
      if (s) if (u) if (d && l < 4) o = c - i == 1 && l - i == 2 ? 1 : 0;
      else for (el.setElement(e, t, n); el.hasNext; ) {
        var f = el.move(), y = Zt(f.otherUnit, f.otherIndex);
        if (y === "S" || rN(y) || Bt.is(f.type, 32)) {
          o = 0;
          break;
        }
        o = 1;
      }
      else o = l - 3;
      u && (p = Math.max(0, 3 - l + o)), v = R1(d && !m ? c + p - o : c + p + 1 - o);
      break;
    case "O":
      if (s && (u || (o = l - 2), l === 1)) {
        el.setElement(e, t, n);
        e: for (; el.hasNext; ) {
          var h = el.move();
          for (Sh.setElement(e, h.otherUnit, h.otherIndex); Sh.hasNext; ) {
            var g = Sh.move();
            if ((g.otherUnit !== t || g.otherIndex !== n) && Zt(g.otherUnit, g.otherIndex) === "O" && g.order === 2) {
              o = -1;
              break e;
            }
          }
        }
      }
      u && (p = Math.max(0, 2 - l + o)), v = R1(d && !m ? c + p - o + 1 : c + p - o + 2);
      break;
    case "S":
      s && (u || (o = l <= 3 && K6(e, t, n, "O") === 0 ? l - 2 : 0)), u && l < 2 && (p = Math.max(0, 2 - l + o)), l <= 3 && (v = R1(c + p - 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:
      Xt && console.warn("Requested charge, protonation for an unhandled element", a);
  }
  return [o, p, p + i, v];
}
function aN(e, t, n) {
  for (var r = t.elements.length, i = new Int8Array(r), a = new Int8Array(r), o = new Int8Array(r), s = new Int8Array(r), u = 0; u < r; ++u) {
    var c = iN(e, t, u, n), l = c[0], d = c[1], m = c[2], p = c[3];
    i[u] = l, a[u] = d, o[u] = m, s[u] = p;
  }
  return { charge: i, implicitH: a, totalH: o, idealGeometry: s };
}
var Qx = { assignCharge: N.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]), assignH: N.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]) };
function oN(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u;
    return ne(this, function(c) {
      for (r = B(B({}, N.getDefaultValues(Qx)), n), i = /* @__PURE__ */ new Map(), a = 0, o = t.units.length; a < o; ++a) s = t.units[a], me.isAtomic(s) && (u = aN(t, s, r), i.set(s.id, u));
      return [2, i];
    });
  });
}
var nn, Vv, zv, Ch = B({}, Qx), Hf = Rl.createProvider({ label: "Valence Model", descriptor: no({ name: "molstar_computed_valence_model" }), type: "local", defaultParams: Ch, getParams: function(e) {
  return Ch;
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, n) {
  return ie(void 0, 0, void 0, function() {
    var r, i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return r = B(B({}, N.getDefaultValues(Ch)), n), i = {}, [4, oN(e.runtime, t, r)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} });
(function(e) {
  function t(a, o) {
    for (var s = new Int32Array(o + 1), u = new Int32Array(o), c = new Int32Array(o), l = a.members, d = a.count, m = a.offsets, p = 0, v = m[d]; p < v; ++p) ++c[l[p]];
    var f = 0;
    for (p = 0; p < o; p++) s[p] = f, f += c[p];
    s[o] = f;
    var y = new Int32Array(f);
    for (p = 0; p < d; ++p) for (var h = m[p], g = m[p + 1]; h < g; ++h) {
      var x = l[h];
      y[s[x] + u[x]] = p, ++u[x];
    }
    return { indices: y, offsets: s };
  }
  function n(a, o) {
    for (var s, u = a.count, c = a.types, l = [], d = 0; d < u; ++d) o.has(c[d]) && l.push(d);
    var m = _e.ofSortedArray(l);
    return { indices: m, get lookup3d() {
      if (!s) {
        var p = { x: a.x, y: a.y, z: a.z, indices: m };
        s = xc(p, Dl(p));
      }
      return s;
    } };
  }
  e.setPosition = function(a, o, s, u) {
    return S.set(a, u.x[s], u.y[s], u.z[s]), S.transformMat4(a, a, o.conformation.operator.matrix), a;
  }, e.createElementsIndex = t, e.create = function(a, o) {
    var s, u;
    return B(B({}, o), { get lookup3d() {
      if (!s) {
        var c = { x: o.x, y: o.y, z: o.z, indices: ve.ofBounds(0, o.count) };
        s = xc(c, Dl(c));
      }
      return s;
    }, get elementsIndex() {
      return u || (u = t(o, a));
    }, subset: function(c) {
      return n(o, c);
    } });
  }, e.createSubset = n, e.Info = function(a, o, s) {
    var u = Hf.get(a).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(a, o) {
    return S.set(a, o.x[o.feature], o.y[o.feature], o.z[o.feature]), S.transformMat4(a, a, o.unit.conformation.operator.matrix), a;
  };
  var r = S(), i = S();
  e.distance = function(a, o) {
    var s = a.members[a.offsets[a.feature]], u = o.members[o.offsets[o.feature]];
    return a.unit.conformation.position(a.unit.elements[s], r), o.unit.conformation.position(o.unit.elements[u], i), S.distance(r, i);
  }, e.Provider = function(a, o) {
    return { types: new Set(a), add: o };
  };
})(nn || (nn = {})), function(e) {
  e.create = function(t, n, r) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024);
    var i = he.create(Float32Array, 1, n, r ? r.x : t), a = he.create(Float32Array, 1, n, r ? r.y : t), o = he.create(Float32Array, 1, n, r ? r.z : t), s = he.create(Uint8Array, 1, n, r ? r.types : t), u = he.create(Uint8Array, 1, n, r ? r.groups : t), c = he.create(Uint32Array, 1, n, r ? r.offsets : t), l = he.create(Uint32Array, 1, n, r ? r.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(m, p, v, f) {
      he.add(l, f), d.x += m, d.y += p, d.z += v, d.count += 1;
    }, finishState: function(m, p) {
      var v = d.count;
      v !== 0 && (he.add(s, m), he.add(u, p), he.add(i, d.x / v), he.add(a, d.y / v), he.add(o, d.z / v), he.add(c, d.offset));
    }, add: function(m, p, v, f, y, h) {
      he.add(s, m), he.add(u, p), he.add(i, v), he.add(a, f), he.add(o, y), he.add(c, l.elementCount), he.add(l, h);
    }, getFeatures: function(m) {
      he.add(c, l.elementCount);
      var p = he.compact(i, !0), v = he.compact(a, !0), f = he.compact(o, !0), y = i.elementCount;
      return nn.create(m, { x: p, y: v, z: f, count: y, types: he.compact(s, !0), groups: he.compact(u, !0), offsets: he.compact(c, !0), members: he.compact(l, !0) });
    } };
  };
}(Vv || (Vv = {})), function(e) {
  e.createElementsIndex = function(t, n, r) {
    for (var i = new Int32Array(r + 1), a = new Int32Array(r), o = new Int32Array(r), s = n.members, u = n.offsets, c = 0, l = 2 * t.edgeCount; c < l; ++c)
      if (!((f = t.a[c]) > (y = t.b[c]))) {
        for (var d = u[f], m = u[f + 1]; d < m; ++d) ++o[s[d]];
        for (d = u[y], m = u[y + 1]; d < m; ++d) ++o[s[d]];
      }
    var p = 0;
    for (c = 0; c < r; c++) i[c] = p, p += o[c];
    i[r] = p;
    var v = new Int32Array(p);
    for (c = 0, l = 2 * t.edgeCount; c < l; ++c) {
      var f, y;
      if (!((f = t.a[c]) > (y = t.b[c]))) {
        for (d = u[f], m = u[f + 1]; d < m; ++d)
          v[i[h = s[d]] + a[h]] = c, ++a[h];
        for (d = u[y], m = u[y + 1]; d < m; ++d) {
          var h;
          v[i[h = s[d]] + a[h]] = c, ++a[h];
        }
      }
    }
    return { indices: v, offsets: i };
  };
}(zv || (zv = {}));
var Pi, Lt, sN = function(e) {
  function t(n, r) {
    var i = e.call(this, n) || this;
    i.elementKeyIndex = /* @__PURE__ */ new Map();
    for (var a = 0, o = i.edges.length; a < o; ++a) for (var s = i.edges[a], u = s.unitA, c = s.indexA, l = r.get(u), d = l.offsets, m = l.members, p = d[c], v = d[c + 1]; p < v; ++p) {
      var f = i.getElementKey(m[p], u), y = i.elementKeyIndex.get(f);
      y === void 0 ? i.elementKeyIndex.set(f, [a]) : y.push(a);
    }
    return i;
  }
  return Zr(t, e), t.prototype.getContactIndicesForElement = function(n, r) {
    return this.elementKeyIndex.get(this.getElementKey(n, r.id)) || [];
  }, t.prototype.getElementKey = function(n, r) {
    return "".concat(n, "|").concat(r);
  }, t;
}(Sc);
function Uv(e) {
  switch (e) {
    case Lt.HydrogenBond:
      return "Hydrogen Bond";
    case Lt.Hydrophobic:
      return "Hydrophobic Contact";
    case Lt.HalogenBond:
      return "Halogen Bond";
    case Lt.Ionic:
      return "Salt Bridge";
    case Lt.MetalCoordination:
      return "Metal Bond";
    case Lt.CationPi:
      return "Cation-Pi Interaction";
    case Lt.PiStacking:
      return "Pi Stacking";
    case Lt.WeakHydrogenBond:
      return "Weak Hydrogen Bond";
    case Lt.Unknown:
      return "Unknown Interaction";
  }
}
(function(e) {
  e[e.None = 0] = "None", e[e.Filtered = 1] = "Filtered";
})(Pi || (Pi = {})), 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";
}(Lt || (Lt = {}));
var Jx = { distanceMax: N.Numeric(2.8, { min: 1, max: 5, step: 0.1 }), backbone: N.Boolean(!0, { description: "Include backbone-to-backbone hydrogen bonds" }), accAngleDevMax: N.Numeric(90, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }), donAngleDevMax: N.Numeric(120, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }), accOutOfPlaneAngleMax: N.Numeric(90, { min: 0, max: 180, step: 1 }), donOutOfPlaneAngleMax: N.Numeric(45, { min: 0, max: 180, step: 1 }) }, $x = B(B({}, Jx), { water: N.Boolean(!1, { description: "Include water-to-water hydrogen bonds" }), sulfurDistanceMax: N.Numeric(3.4, { min: 1, max: 5, step: 0.1 }) }), uN = N.getDefaultValues($x), eS = B({}, Jx), cN = N.getDefaultValues(eS);
function Q6(e, t) {
  return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[t]]] === 2;
}
function J6(e, t) {
  return Gg.has(Wx(e, t));
}
function tS(e) {
  return { includeBackbone: e.backbone, maxAccAngleDev: Bn(e.accAngleDevMax), maxDonAngleDev: Bn(e.donAngleDevMax), maxAccOutOfPlaneAngle: Bn(e.accOutOfPlaneAngleMax), maxDonOutOfPlaneAngle: Bn(e.donOutOfPlaneAngleMax) };
}
function nS(e, t, n, r) {
  var i = t.members[t.offsets[t.feature]], a = n.members[n.offsets[n.feature]];
  if (r.includeBackbone || (o = t.unit, s = i, u = n.unit, c = a, !J6(o, s) || !J6(u, c))) {
    var o, s, u, c, l = Gv(e, t.unit, i, n.unit, a);
    if ($r(l[0]) >= 120 && $r(l[0]) <= 180) return !0;
  }
}
function lN(e, t, n, r, i) {
  var a = t.types[t.feature], o = n.types[n.feature];
  if (u = o, (s = a) === 5 && u === 4 || s === 4 && u === 5) {
    var s, u, c, l, d, m, p = o === 5 ? [t, n] : [n, t], v = p[0], f = p[1], y = v.members[v.offsets[v.feature]], h = f.members[f.offsets[f.feature]];
    if (!(r > (Zt(v.unit, y) === "S" || Zt(f.unit, h) === "S" ? i.maxSulfurDistSq : i.maxDistSq)) && (i.includeWater || (c = v.unit, l = y, d = f.unit, m = h, !Q6(c, l) || !Q6(d, m))) && nS(e, v, f, i)) return Lt.HydrogenBond;
  }
}
var dN = nn.Provider([4], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, m) {
    var p = Zt(t, d), v = !1;
    p === "H" && (Eo(t, d, function(f, y) {
      var h = Zt(f, y);
      h !== "N" && h !== "O" && h !== "S" || (v = !0);
    }), v && n.add(4, 0, a[r[d]], o[r[d]], s[r[d]], d));
  }, c = 0, l = r.length; c < l; ++c) u(c);
}), fN = nn.Provider([9], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, m) {
    var p = Zt(t, d), v = !1;
    if (p === "H") {
      var f = [];
      if (Eo(t, d, function(h, g) {
        Zt(h, g) === "C" && (function(x, C) {
          var b = x.rings.elementAromaticRingIndices, _ = b.get(C);
          return _ !== void 0;
        }(h, g) ? v = !0 : f.push(g));
      }), !v && f.length === 1) {
        var y = 0;
        Eo(t, f[0], function(h, g) {
          Zt(h, g) === "F" && y++;
        }), y === 2 && (v = !0);
      }
      v && n.add(9, 0, a[r[d]], o[r[d]], s[r[d]], d);
    }
  }, c = 0, l = r.length; c < l; ++c) u(c);
}), mN = nn.Provider([5], function(e, t, n) {
  for (var r = function(g, x) {
    var C = Hf.get(g).value;
    if (!C) throw Error("expected valence model to be available");
    var b = C.get(x.id);
    if (!b) throw Error("expected valence model for unit to be available");
    return b;
  }(e, t), i = r.charge, a = r.implicitH, o = r.idealGeometry, s = t.elements, u = t.model.atomicConformation, c = u.x, l = u.y, d = u.z, m = function(g) {
    n.add(5, 0, c[s[g]], l[s[g]], d[s[g]], g);
  }, p = 0, v = s.length; p < v; ++p) {
    var f = Zt(t, p);
    if (f === "O") m(p);
    else if (f === "N") {
      if (i[p] < 1) {
        var y = Pf(e, t, p) + a[p], h = o[p];
        (h === 4 && y < 4 || h === 3 && y < 3 || h === 2 && y < 2) && m(p);
      }
    } else f === "S" ? p3(t, p) === -1 && m(p) : f === "F" && m(p);
  }
}), pN = { name: "hydrogen-bonds", params: $x, createTester: function(e) {
  var t = Math.max(e.distanceMax, e.sulfurDistanceMax), n = function(r) {
    return B(B({}, tS(r)), { includeWater: r.water, maxSulfurDistSq: r.sulfurDistanceMax * r.sulfurDistanceMax, maxDistSq: r.distanceMax * r.distanceMax });
  }(e);
  return { maxDistance: t, requiredFeatures: /* @__PURE__ */ new Set([4, 5]), getType: function(r, i, a, o) {
    return lN(r, i, a, o, n);
  } };
} }, hN = { name: "weak-hydrogen-bonds", params: eS, createTester: function(e) {
  var t = tS(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([9, 5]), getType: function(n, r, i, a) {
    return function(o, s, u, c, l) {
      var d = s.types[s.feature], m = u.types[u.feature];
      if (v = m, (p = d) === 9 && v === 5 || p === 5 && v === 9) {
        var p, v, f = m === 5 ? [s, u] : [u, s];
        if (nS(o, f[0], f[1], l)) return Lt.WeakHydrogenBond;
      }
    }(n, r, i, 0, t);
  } };
} }, rS = { distanceMax: N.Numeric(3.5, { min: 1, max: 5, step: 0.1 }), angleMax: N.Numeric(60, { min: 0, max: 60, step: 1 }) }, vN = N.getDefaultValues(rS), gN = ["CL", "BR", "I", "AT"], yN = Bn(180), bN = Bn(120), _N = nn.Provider([6], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = r.length; u < c; ++u) {
    var l = Zt(t, u);
    gN.includes(l) && n.add(6, 0, a[r[u]], o[r[u]], s[r[u]], u);
  }
}), xN = nn.Provider([7], function(e, t, n) {
  for (var r = function(A, I) {
    var w = Hf.get(A).value;
    if (!w) throw Error("expected valence model to be available");
    var E = w.get(I.id);
    if (!E) throw Error("expected valence model for unit to be available");
    return E;
  }(e, t), i = r.charge, a = r.implicitH, o = r.idealGeometry, s = t.elements, u = t.model.atomicConformation, c = u.x, l = u.y, d = u.z, m = function(A) {
    n.add(7, 0, c[s[A]], l[s[A]], d[s[A]], A);
  }, p = 0, v = s.length; p < v; ++p) {
    var f = Zt(t, p);
    if (f === "O") m(p);
    else if (f === "N") {
      if (i[p] < 1) {
        var y = Pf(e, t, p) + a[p], h = o[p];
        (h === 4 && y < 4 || h === 3 && y < 3 || h === 2 && y < 2) && m(p);
      }
    } else f === "S" ? p3(t, p) === -1 && m(p) : f === "F" && m(p);
  }
  for (var g = 0, x = t.rings.aromaticRings; g < x.length; g++) {
    var C = x[g], b = t.rings.all[C];
    for (n.startState(), p = 0, v = b.length; p < v; ++p) {
      var _ = b[p];
      n.pushMember(c[s[_]], l[s[_]], d[s[_]], _);
    }
    n.finishState(7, 0);
  }
}), SN = { name: "halogen-bonds", params: rS, createTester: function(e) {
  var t = function(n) {
    return { angleMax: Bn(n.angleMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([6, 7]), getType: function(n, r, i) {
    return function(a, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (m = l, (d = c) === 7 && m === 6 || d === 6 && m === 7) {
        var d, m, p = c === 6 ? [o, s] : [s, o], v = p[0], f = p[1], y = v.members[v.offsets[v.feature]], h = f.members[f.offsets[f.feature]], g = Gv(a, v.unit, y, f.unit, h);
        if (g.length === 1 && !(yN - g[0] > u.angleMax)) {
          var x = Gv(a, f.unit, h, v.unit, y);
          if (x.length !== 0 && !x.some(function(C) {
            return bN - C > u.angleMax;
          })) return Lt.HalogenBond;
        }
      }
    }(n, r, i, t);
  } };
} }, iS = { distanceMax: N.Numeric(5, { min: 0, max: 8, step: 0.1 }) }, CN = N.getDefaultValues(iS), aS = { distanceMax: N.Numeric(5.5, { min: 1, max: 8, step: 0.1 }), offsetMax: N.Numeric(2, { min: 0, max: 4, step: 0.1 }), angleDevMax: N.Numeric(30, { min: 0, max: 180, step: 1 }) }, AN = N.getDefaultValues(aS), oS = { distanceMax: N.Numeric(6.6, { min: 1, max: 8, step: 0.1 }), offsetMax: N.Numeric(2, { min: 0, max: 4, step: 0.1 }) }, IN = N.getDefaultValues(oS);
function sS(e, t) {
  var n = Hf.get(e).value;
  if (!n) throw Error("expected valence model to be available");
  var r = n.get(t.id);
  if (!r) throw Error("expected valence model for unit to be available");
  return r;
}
var $6 = S(), e_ = S(), jl = S(), yu = S(), vc = S(), k1 = S();
function Hv(e, t) {
  var n = t.unit, r = t.feature, i = t.offsets, a = t.members, o = n.elements, s = i[r];
  return t.unit.conformation.position(o[a[s]], jl), t.unit.conformation.position(o[a[s + 1]], yu), t.unit.conformation.position(o[a[s + 2]], vc), S.triangleNormal(e, jl, yu, vc);
}
var Ah = Bn(180), O1 = Bn(90), uf = S(), Ih = S();
function wN(e, t, n, r, i) {
  var a, o, s = t.types[t.feature], u = n.types[n.feature];
  if (o = u, ((a = s) === 2 && o === 1 || a === 1 && o === 2) && function(c, l, d) {
    for (var m = c.feature, p = c.offsets, v = c.members, f = l.feature, y = l.offsets, h = l.members, g = p[m], x = p[m + 1]; g < x; ++g) {
      var C = v[g];
      c.unit.conformation.position(c.unit.elements[C], $6);
      for (var b = y[f], _ = y[f + 1]; b < _; ++b) {
        var A = h[b];
        if (l.unit.conformation.position(l.unit.elements[A], e_), S.squaredDistance($6, e_) < d) return !0;
      }
    }
    return !1;
  }(t, n, i.distanceMaxSq)) return Lt.Ionic;
}
function PN(e, t, n, r, i) {
  var a, o, s = t.types[t.feature], u = n.types[n.feature];
  if (o = u, (a = s) === 3 && o === 1 || a === 1 && o === 3) {
    var c = s === 3 ? [t, n] : [n, t], l = c[0], d = c[1];
    Hv(uf, l);
    var m = function(p, v, f) {
      return nn.position(jl, p), nn.position(yu, v), S.sub(vc, jl, yu), S.projectOnPlane(k1, vc, f), S.add(k1, k1, yu), S.distance(k1, yu);
    }(d, l, uf);
    if (m <= i.offsetMax) return Lt.CationPi;
  }
}
var EN = nn.Provider([2], function(e, t, n) {
  for (var r = sS(e, t).charge, i = t.elements, a = t.model.atomicConformation, o = a.x, s = a.y, u = a.z, c = St.transientSegments(t.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, m = l.end, p = function(f) {
    if (r[f] < 0) n.add(2, 0, o[i[f]], s[i[f]], u[i[f]], f);
    else if (Zt(t, f) === "O") {
      var y = -1, h = 0;
      if (Eo(t, f, function(E, D) {
        Zt(t, D) === "C" && (y = D, h++);
      }), h === 1 && y !== -1) {
        var g = /* @__PURE__ */ new Set(), x = 0;
        if (Eo(t, y, function(E, D) {
          Zt(t, D) === "O" && g.add(D);
        }), g.size === 2) {
          for (var C = t.bonds, b = !0, _ = 0, A = C.a.length; _ < A; _++) {
            var I = C.a[_], w = C.b[_];
            g.has(w) && I !== y && Zt(t, I) !== "H" && (x = -100), C.edgeProps.order[_] === 2 && w === f && (b = !1), I === y && g.has(w) && C.edgeProps.order[_] === 2 && x++;
          }
          x === 1 && b && n.add(2, 0, o[i[f]], s[i[f]], u[i[f]], f);
        }
      }
    }
  }, v = d; v < m; ++v) p(v);
}), TN = nn.Provider([1], function(e, t, n) {
  for (var r = sS(e, t).charge, i = t.elements, a = t.model.atomicConformation, o = a.x, s = a.y, u = a.z, c = St.transientSegments(t.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, m = l.end, p = function(f) {
    if (r[f] > 0) n.add(1, 0, o[i[f]], s[i[f]], u[i[f]], f);
    else if (Zt(t, f) === "N") {
      var y = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
      if (Eo(t, f, function(x, C) {
        Zt(t, C) === "C" && y.add(C);
      }), !y.size) return "continue";
      y.forEach(function(x) {
        var C = /* @__PURE__ */ new Set();
        Eo(t, x, function(b, _) {
          Zt(t, _) === "N" ? C.add(_) : y.delete(x);
        }), C.size !== 3 ? y.delete(x) : h.set(x, C);
      });
      var g = !1;
      if (!y.size) return "continue";
      y.forEach(function(x) {
        var C = t.bonds, b = h.get(x), _ = 0;
        if (b) {
          for (var A = function(E, D) {
            var T = C.a[E], P = C.b[E];
            if (T === x && b.has(P) && C.edgeProps.order[E] === 2) {
              P === f && (g = !0);
              var M = !0;
              Eo(t, P, function(R, O) {
                O !== x && Zt(t, O) !== "H" && (M = !1);
              }), M && b.delete(P), _++;
            }
          }, I = 0, w = C.a.length; I < w; I++) A(I);
          _ !== 1 ? y.delete(x) : b.forEach(function(E) {
            var D = !0;
            Eo(t, E, function(T, P) {
              P !== x && Zt(t, P) !== "H" && (D = !1);
            }), D && b.delete(E);
          }), b.size > 1 && y.delete(x);
        }
      }), y.size && g && n.add(1, 0, o[i[f]], s[i[f]], u[i[f]], f);
    }
  }, v = d; v < m; ++v) p(v);
}), MN = nn.Provider([3], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = t.rings.aromaticRings; u < c.length; u++) {
    var l = c[u], d = t.rings.all[l];
    n.startState();
    for (var m = 0, p = d.length; m < p; ++m) {
      var v = d[m];
      n.pushMember(a[r[v]], o[r[v]], s[r[v]], v);
    }
    n.finishState(3, 0);
  }
}), DN = { name: "ionic", params: iS, createTester: function(e) {
  var t = function(n) {
    return { distanceMaxSq: n.distanceMax * n.distanceMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([2, 1]), getType: function(n, r, i, a) {
    return wN(0, r, i, 0, t);
  } };
} }, BN = { name: "pi-stacking", params: aS, createTester: function(e) {
  var t = function(n) {
    return { offsetMax: n.offsetMax, angleDevMax: Bn(n.angleDevMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3]), getType: function(n, r, i, a) {
    return function(o, s, u, c, l) {
      var d, m = s.types[s.feature], p = u.types[u.feature];
      if (d = p, m === 3 && d === 3) {
        Hv(uf, s), Hv(Ih, u);
        var v = S.angle(uf, Ih);
        nn.position(jl, s), nn.position(yu, u), S.sub(vc, jl, yu);
        var f = S.angle(uf, vc), y = S.angle(Ih, vc), h = $r(f > O1 ? Ah - f : f), g = $r(y > O1 ? Ah - y : y), x = v <= l.angleDevMax || v >= Ah - l.angleDevMax ? "parallel" : v <= l.angleDevMax + O1 && v >= O1 - l.angleDevMax ? "t-shaped" : void 0, C = x === "parallel" ? [0, 33] : [0, 30];
        if (x && (h >= C[0] && h <= C[1] || g >= C[0] && g <= C[1])) return Lt.PiStacking;
      }
    }(0, r, i, 0, t);
  } };
} }, RN = { name: "cation-pi", params: oS, createTester: function(e) {
  var t = function(n) {
    return { offsetMax: n.offsetMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3, 1]), getType: function(n, r, i, a) {
    return PN(0, r, i, 0, t);
  } };
} }, uS = { distanceMax: N.Numeric(3, { min: 1, max: 5, step: 0.1 }) }, kN = N.getDefaultValues(uS), N1 = { 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 }, ON = ["LI", "NA", "K", "RB", "CS", "MG", "CA", "SR", "BA", "AL", "GA", "IN", "TL", "SC", "SN", "PB", "BI", "SB", "HG"];
function t_(e) {
  return !Gg.has(e);
}
function NN(e) {
  return Gg.has(e);
}
function LN(e) {
  return FT.has(e);
}
function n_(e, t) {
  return e === 12 ? t === 11 || t === 12 : e === 13 ? t === 10 : void 0;
}
var L1, vd, tl, Nt, ai, fe, tt, FN = nn.Provider([13, 12], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = r.length; u < c; ++u) {
    var l = Zt(t, u), d = 0;
    ON.includes(l) ? d = 13 : (Zx(l) || l === "ZN" || l === "CD") && (d = 12), d && n.add(d, 0, a[r[u]], o[r[u]], s[r[u]], u);
  }
}), GN = nn.Provider([10, 11], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = r.length; u < c; ++u) {
    var l = Zt(t, u), d = ZO(t, u), m = Wx(t, u), p = !1, v = !1, f = Lf.has(d), y = zg.has(d);
    f || y ? f ? l === "O" ? (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(d) && t_(m) || NN(m)) && (p = !0, v = !0) : l !== "S" || d !== "CYS" && d !== "MET" ? l === "N" && d === "HIS" && t_(m) && (p = !0) : (p = !0, v = !0) : y && (l === "O" && LN(m) ? (p = !0, v = !0) : ["N3", "N4", "N7"].includes(m) ? p = !0 : ["O2", "O4", "O6"].includes(m) && (p = !0, v = !0)) : nN(l) || l === "O" || l === "S" ? (p = !0, v = !0) : l === "N" && (p = !0), p && n.add(11, 0, a[r[u]], o[r[u]], s[r[u]], u), v && n.add(10, 0, a[r[u]], o[r[u]], s[r[u]], u);
  }
}), VN = { name: "metal-coordination", params: uS, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([13, 12, 10, 11]), getType: function(t, n, r, i) {
    return function(a, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (n_(c, l) || n_(l, c)) {
        var d = Bl[Zt(o.unit, o.members[o.offsets[o.feature]])], m = Bl[Zt(s.unit, s.members[s.offsets[s.feature]])];
        if (d && m && N1[d] && N1[m]) {
          var p = N1[d] + N1[m] + 0.5, v = S.create(0, 0, 0), f = S.create(0, 0, 0);
          if (nn.position(v, o), nn.position(f, s), S.distance(v, f) > p) return;
        }
        return Lt.MetalCoordination;
      }
    }(0, n, r);
  } };
} };
(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";
})(Nt || (Nt = {})), 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";
}(ai || (ai = {})), 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";
}(fe || (fe = {})), function(e) {
  e.RIBBON = "Ribbon", e.ATOM = "Atom", e.SURFACE = "Surface";
}(tt || (tt = {}));
var iu, In = ((L1 = {})[tt.RIBBON] = [fe.Ribbon], L1[tt.ATOM] = [fe.CPK, fe.Line, fe.Stick, fe.BallAndStick], L1[tt.SURFACE] = [fe.Surface], L1);
(function(e) {
  e[e.Not = 0] = "Not", e[e.Include = 1] = "Include", e[e.BeIncluded = 2] = "BeIncluded", e[e.Cross = 3] = "Cross";
})(iu || (iu = {}));
var on, zN = /* @__PURE__ */ new Set([fe.Ribbon, fe.CPK, fe.Line, fe.Stick, fe.BallAndStick, fe.Surface]), ac = /* @__PURE__ */ new Set([fe.BallAndStick, fe.Line, fe.Stick, fe.CPK]), UN = /* @__PURE__ */ new Set([fe.BallAndStick, fe.Line, fe.Stick]), Kl = /* @__PURE__ */ new Set([fe.Label, fe.Distance, fe.Angle, fe.Dihedral]), HN = /* @__PURE__ */ new Set([fe.Surface, fe.Pharmacophore, fe.Pocket]);
(function(e) {
  e.Atom = "Atom", e.Residue = "Residue", e.Chain = "Chain", e.Molecular = "Molecular";
})(on || (on = {}));
var xo, qN = ((vd = {})[on.Atom] = "element", vd[on.Residue] = "residue", vd[on.Chain] = "chain", vd[on.Molecular] = "entity", vd), jN = { element: on.Atom, residue: on.Residue, chain: on.Chain, entity: on.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";
})(xo || (xo = {}));
var oc, qv = function(e) {
  var t, n = ((t = {})[xo.HydrogenBonds] = { name: "on", params: uN }, t[xo.WeakHydrogenBonds] = { name: "off", params: cN }, t[xo.HalogenBonds] = { name: "on", params: vN }, t[xo.SaltBridge] = { name: "on", params: CN }, t[xo.PiPiStacking] = { name: "on", params: AN }, t[xo.PiCations] = { name: "on", params: IN }, t[xo.MetalBonds] = { name: "on", params: kN }, t[xo.Hydrophobic] = { name: "off", params: {} }, t);
  return e && Object.keys(n).forEach(function(r) {
    n[r].name = e.includes(r) ? "on" : "off";
  }), n;
};
(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";
})(oc || (oc = {}));
var cf, sr, lc, KN = ((tl = {})[oc.All] = [ai.Protein, ai.Water, ai.Ligand, ai.Solvent], tl[oc.Residues] = [ai.Protein], tl[oc.Water] = [ai.Water], tl[oc.SolventWithoutWater] = [ai.Solvent], tl[oc.Solvent] = [ai.Water, ai.Solvent], tl);
(function(e) {
  e.Structure = "Structure", e.Measurement = "Measurement", e.Interaction = "Interaction", e.Bond = "Bond";
})(cf || (cf = {})), 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";
}(sr || (sr = {})), function(e) {
  e.Drug = "drug", e.Material = "material";
}(lc || (lc = {}));
var Yr = function(e) {
  if (e.kind === "element-loci") return e;
  if (e.kind === "structure-loci") return Be.toStructureElementLoci(e.structure);
  if (e.kind === "shape-loci") {
    var t, n = e.shape.sourceData, r = [];
    return n.infos ? r.push.apply(r, Pe([], n.infos, !0).map(function(i) {
      return i.loci;
    })) : n.pairs ? r.push.apply(r, n.pairs[0].loci) : n.triples ? r.push.apply(r, n.triples[0].loci) : n.quads && r.push.apply(r, n.quads[0].loci), r.forEach(function(i) {
      t = t ? Se.union(t, Yr(i)) : Yr(i);
    }), t;
  }
}, Yn = function(e, t) {
  var n = [], r = new Set(t), i = /* @__PURE__ */ new Set();
  return e.units.forEach(function(a) {
    if (!i.has(a.invariantId)) {
      i.add(a.invariantId);
      var o = [];
      a.elements.forEach(function(s, u) {
        t && !r.has(s) || o.push(u);
      }), o.length > 0 && n.push({ unit: a, indices: o });
    }
  }), Se(e, n);
}, wr = function(e) {
  var t = [];
  return e.elements.forEach(function(n) {
    t.push.apply(t, ve.toArray(n.indices).map(function(r) {
      return n.unit.elements[r];
    }).filter(function(r) {
      return r !== void 0;
    }));
  }), t;
}, XN = function(e, t) {
  var n, r = Ic.ofLoci(e);
  n = r.elementCount > 0 ? r.firstElementLoc : r.residueCount > 0 ? r.firstResidueLoc : r.chainCount > 0 ? r.firstChainLoc : r.unitCount > 0 ? r.firstUnitLoc : r.conformationCount > 0 ? r.firstConformationLoc : r.firstStructureLoc;
  var i = Me.atom.em_confidence(n), a = Me.atom.B_iso_or_equiv(n);
  switch (t) {
    case on.Atom:
      return r.elementCount === 1 ? { x: Me.atom.x(n), y: Me.atom.y(n), z: Me.atom.z(n), granularity: on.Atom, atomName: Me.atom.label_atom_id(n), atomId: Me.atom.id(n), altId: Me.atom.label_alt_id(n), residueName: Me.atom.label_comp_id(n), residueId: Me.residue.auth_seq_id(n), insertCode: Me.residue.pdbx_PDB_ins_code(n), chainId: Me.chain.label_asym_id(n), emConfidence: i, bfactor: a } : { granularity: on.Residue, altId: Me.atom.label_alt_id(n), residueName: Me.atom.label_comp_id(n), residueId: Me.residue.auth_seq_id(n), chainId: Me.chain.label_asym_id(n), insertCode: Me.residue.pdbx_PDB_ins_code(n), emConfidence: i, bfactor: a };
    case on.Residue:
      return { granularity: on.Residue, altId: Me.atom.label_alt_id(n), residueName: Me.atom.label_comp_id(n), residueId: Me.residue.auth_seq_id(n), chainId: Me.chain.label_asym_id(n), insertCode: Me.residue.pdbx_PDB_ins_code(n), bfactor: a };
    case on.Chain:
      return { granularity: on.Chain, chainId: Me.chain.label_asym_id(n) };
    case on.Molecular:
      return { granularity: on.Molecular };
    default:
      return {};
  }
}, YN = function(e) {
  var t = e.elements[0], n = t.unitA, r = t.indexA, i = t.unitB, a = t.indexB, o = e.data.interactions, s = o.contacts, u = o.unitsContacts, c = o.unitsFeatures, l = c.get(n.id), d = l.members, m = l.offsets, p = c.get(i.id), v = p.members, f = p.offsets, y = -1;
  if (n === i) {
    var h = u.get(n.id), g = h.getDirectedEdgeIndex(r, a);
    y = h.edgeProps.type[g];
  } else
    g = s.getEdgeIndex(r, n.id, a, i.id), y = s.edges[g].props.type;
  var x = rt.Location(e.data.structure, n, d[m[r]], e.data.structure, i, v[f[a]]), C = Se(x.aStructure, [{ unit: x.aUnit, indices: ve.ofSingleton(x.aIndex) }]), b = Se(x.bStructure, [{ unit: x.bUnit, indices: ve.ofSingleton(x.bIndex) }]), _ = Ic.ofLoci(C), A = Ic.ofLoci(b), I = _.firstElementLoc, w = A.firstElementLoc;
  return { infoA: { chainId: Me.chain.label_asym_id(I), residueName: Me.atom.label_comp_id(I), residueId: Me.residue.auth_seq_id(I), atomName: Me.atom.label_atom_id(I) }, infoB: { chainId: Me.chain.label_asym_id(w), residueName: Me.atom.label_comp_id(w), residueId: Me.residue.auth_seq_id(w), atomName: Me.atom.label_atom_id(w) }, interactionType: Uv(y) };
}, WN = function(e) {
  return fetch(e).then(function(t) {
    return t.text();
  });
}, ZN = function(e) {
  return fetch(e).then(function(t) {
    return t.blob();
  });
}, QN = function(e) {
  return new Promise(function(t) {
    var n = new FileReader();
    n.onload = function(r) {
      return ie(this, 0, void 0, function() {
        return ne(this, function(i) {
          return t(n.result), [2];
        });
      });
    }, n.readAsText(e);
  });
}, gc = function(e) {
  return ie(void 0, 0, void 0, function() {
    var t, n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return typeof e != "string" ? [3, 4] : e.startsWith("http") || e.startsWith("https") ? [4, WN(e)] : [3, 2];
        case 1:
          return n = r.sent(), [3, 3];
        case 2:
          n = e, r.label = 3;
        case 3:
          return t = n, [3, 6];
        case 4:
          return [4, QN(e)];
        case 5:
          t = r.sent(), r.label = 6;
        case 6:
          return [2, t];
      }
    });
  });
}, JN = function(e) {
  return ie(void 0, 0, void 0, function() {
    var t, n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return typeof e != "string" ? [3, 2] : [4, ZN(e)];
        case 1:
          return t = r.sent(), [3, 4];
        case 2:
          return n = Blob.bind, [4, e.arrayBuffer()];
        case 3:
          t = new (n.apply(Blob, [void 0, [r.sent()]]))(), r.label = 4;
        case 4:
          return [2, t];
      }
    });
  });
};
function $N(e, t, n) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(r) {
      return [2, new Promise(function(i, a) {
        var o = function(f) {
          f ? i(f) : a("no blob returned");
        };
        if (HTMLCanvasElement.prototype.toBlob) e.toBlob(o, t, n);
        else {
          for (var s = atob(e.toDataURL(t, n).split(",")[1]), u = s.length, c = u >> 2, l = new Uint8Array(u), d = new Uint32Array(l.buffer, 0, c), m = 0, p = 0; p < c; ++p) d[p] = s.charCodeAt(m++) | s.charCodeAt(m++) << 8 | s.charCodeAt(m++) << 16 | s.charCodeAt(m++) << 24;
          for (var v = 3 & u; v--; ) l[m] = s.charCodeAt(m++);
          o(new Blob([l], { type: t }));
        }
      })];
    });
  });
}
var eL = 1 / 0;
function cS(e, t, n, r, i) {
  var a = -1, o = e.length;
  for (n || (n = Array.isArray), i || (i = []); ++a < o; ) {
    var s = e[a];
    n(s) ? cS(s, t - 1, n, r, i) : i[i.length] = s;
  }
  return i;
}
function lS(e) {
  return e != null && e.length ? cS(e, eL) : [];
}
var wh = function(e, t) {
  for (var n = [], r = 0, i = t.length; r < i; r++) {
    var a = t[r], o = a.start, s = a.end;
    a.regular.test(e.slice(o, s)) || n.push({ start: o, end: s });
  }
  return n;
}, Ef = function(e) {
  return e.length > 2 || e.length === 0 ? e : "".concat(e[0].toLocaleUpperCase()).concat(e.length === 2 ? e[1].toLocaleLowerCase() : "");
}, Ph = { 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" }, tL = { 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" }, nL = [{ 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]+/ }], rL = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }, { start: 6, end: 9, regular: /\s*[\d]+/ }], iL = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }], dS = { Dihedral: fe.Dihedral, Distance: fe.Distance, Angle: fe.Angle, Label: fe.Label, "Molecular Surface": fe.Surface, "Ball & Stick": fe.BallAndStick, Line: fe.Line, Stick: fe.Stick, Spacefill: fe.CPK, Cartoon: fe.Ribbon }, fS = function(e, t, n) {
  var r, i = t[0], a = i.residueName, o = i.residueId, s = i.isEutectic, u = t.map(function(p) {
    return p.elementId;
  }), c = Yn(e, u), l = Ic.ofLoci(c);
  r = 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, m = (d = Me.residue.secondary_structure_type(r), Ft.is(d, 2) ? "helix" : Ft.is(d, 4) ? "sheet" : Ft.is(d, 16) ? "turn" : Ft.is(d, 8) ? "bend" : "none");
  return { residueNum: o, residueName: a.toUpperCase(), standardResidueName: Ph[a.toUpperCase()], oneLetter: s ? "X" : tL[Ph[a.toUpperCase()]] || Ph[a.toUpperCase()] || "X", elementIds: t.map(function(p) {
    return p.elementId;
  }), secondaryStructureType: m, secondaryStructureTypeInfo: Me.residue.secondary_structure_type(r), secondaryStructureTypeKey: Me.residue.secondary_structure_key(r), insCode: Me.residue.pdbx_PDB_ins_code(r), index: n };
}, yc = /* @__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"]), h3 = /* @__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"]), v3 = /* @__PURE__ */ new Set(["EOH", "GOL", "DMS", "PEG", "POL", "IOH", "DIO", "ACN", "SBT", "1BO", "CCN", "DMS", "GBL", "P2K", "MPD", "PGQ", "SEO"]), bi = function(e, t, n) {
  n === void 0 && (n = !1);
  var r = n ? "".concat(t.residueId, "_").concat(t.insertCode) : t.residueId;
  e[t.chainId] ? e[t.chainId][r] = (e[t.chainId][r] ? e[t.chainId][r] : []).concat(t) : (e[t.chainId] = {}, e[t.chainId][r] = [t]);
}, mS = function(e) {
  var t = {}, n = {}, r = {}, i = {}, a = {}, o = {}, s = {}, u = {}, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
  e.units.forEach(function(y) {
    var h;
    y.elements.forEach(function(_) {
      var A = Fo(y, _);
      if (td.has(A.residueName.toUpperCase())) bi(n, A);
      else if (h3.has(A.typeSymbol.toUpperCase())) bi(i, A);
      else if (v3.has(A.residueName.toUpperCase())) bi(r, A);
      else if (Nf.has(A.residueName.toUpperCase())) bi(a, A);
      else {
        if (A.groupPDB === "ATOM" && !["UNK", "MOL"].includes(A.residueName) && !yc.has(A.residueName)) return bi(t, A, !0), void c.add(A.elementId);
        if (A.groupPDB !== "HETATM" && !["UNK", "MOL"].includes(A.residueName) && yc.has(A.residueName)) bi(s, A);
        else {
          var I = "".concat(A.chainId, "_").concat(A.residueId);
          l.set(I, l.has(I) ? Pe(Pe([], l.get(I), !0), [A], !1) : [A]);
        }
      }
    });
    for (var g = 0, x = y.bonds.a.length; g < x; g++) {
      var C = y.elements[y.bonds.a[g]], b = y.elements[y.bonds.b[g]];
      d.has(C) ? (h = d.get(C)) === null || h === void 0 || h.add(b) : d.set(C, /* @__PURE__ */ new Set([b]));
    }
  }), l.forEach(function(y) {
    var h = !1;
    new Set(y.map(function(g) {
      return g.elementId;
    })).forEach(function(g) {
      if (d.has(g)) {
        var x = d.get(g);
        x == null || x.forEach(function(C) {
          c.has(C) && (h = !0);
        });
      }
    }), y.forEach(function(g) {
      h ? (Object.assign(g, { isEutectic: !0 }), bi(o, g)) : bi(s, g);
    });
  });
  var m = {};
  Object.keys(s).forEach(function(y) {
    var h = s[y];
    Object.keys(h).forEach(function(g) {
      var x = h[g], C = x.filter(function(b) {
        return b.typeSymbol !== "H";
      });
      !yc.has(x[0].residueName.toUpperCase()) && C.length > 10 && C.length < 150 ? (u[y] || (u[y] = {}), u[y][g] = x) : (m[y] || (m[y] = {}), m[y][g] = x);
    });
  });
  var p = {};
  Object.keys(t).forEach(function(y) {
    var h;
    p[y] || (p[y] = []), (h = p[y]).push.apply(h, Object.values(t[y]));
  }), Object.keys(o).forEach(function(y) {
    var h = o[y];
    Object.keys(h).forEach(function(g) {
      var x = h[g];
      m[y] || (m[y] = {}), p[y] || (p[y] = []), p[y].push(x), m[y][g] = x;
    });
  });
  var v = 0, f = {};
  return Object.keys(p).forEach(function(y) {
    f[y] = {}, p[y].sort(function(h, g) {
      return h[0].residueId !== g[0].residueId ? h[0].residueId - g[0].residueId : h[0].insertCode.localeCompare(g[0].insertCode);
    }).forEach(function(h) {
      f[h[0].chainId]["".concat(h[0].residueId, "_").concat(h[0].insertCode)] = fS(e, h, v++);
    });
  }), { data: { polymer: t, water: n, otherSolvent: r, metal: i, ion: a, ligand: u, other: m }, extraData: { sequenceData: f } };
}, aL = function(e) {
  var t = {}, n = {}, r = {}, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(d) {
    var m;
    d.elements.forEach(function(h) {
      var g = Fo(d, h);
      if (!td.has(g.residueName.toUpperCase()) && !(h3.has(g.typeSymbol.toUpperCase()) || v3.has(g.residueName.toUpperCase()) || Nf.has(g.residueName.toUpperCase()) || yc.has(g.residueName.toUpperCase()))) {
        if (g.groupPDB === "ATOM" && !["UNK", "MOL"].includes(g.residueName)) return bi(t, g, !0), void i.add(g.elementId);
        if (g.groupPDB === "HETATM" || ["UNK", "MOL"].includes(g.residueName)) {
          var x = "".concat(g.chainId, "_").concat(g.residueId);
          a.set(x, a.has(x) ? Pe(Pe([], a.get(x), !0), [g], !1) : [g]);
        } else bi(r, g);
      }
    });
    for (var p = 0, v = d.bonds.a.length; p < v; p++) {
      var f = d.elements[d.bonds.a[p]], y = d.elements[d.bonds.b[p]];
      o.has(f) ? (m = o.get(f)) === null || m === void 0 || m.add(y) : o.set(f, /* @__PURE__ */ new Set([y]));
    }
  }), a.forEach(function(d) {
    var m = !1;
    new Set(d.map(function(p) {
      return p.elementId;
    })).forEach(function(p) {
      if (o.has(p)) {
        var v = o.get(p);
        v == null || v.forEach(function(f) {
          i.has(f) && (m = !0);
        });
      }
    }), d.forEach(function(p) {
      m ? (Object.assign(p, { isEutectic: !0 }), bi(n, p)) : bi(r, p);
    });
  });
  var s = {};
  Object.keys(r).forEach(function(d) {
    var m = r[d];
    Object.keys(m).forEach(function(p) {
      var v = m[p], f = v.filter(function(y) {
        return y.typeSymbol !== "H";
      });
      f.length <= 10 && f.length < 150 && (s[d] || (s[d] = {}), s[d][p] = v);
    });
  });
  var u = {};
  Object.keys(t).forEach(function(d) {
    var m;
    u[d] || (u[d] = []), (m = u[d]).push.apply(m, Object.values(t[d]));
  }), Object.keys(n).forEach(function(d) {
    var m = n[d];
    Object.keys(m).forEach(function(p) {
      var v = m[p];
      s[d] || (s[d] = {}), u[d] || (u[d] = []), u[d].push(v), s[d][p] = v;
    });
  });
  var c = 0, l = {};
  return Object.keys(u).forEach(function(d) {
    l[d] = {}, u[d].sort(function(m, p) {
      return m[0].residueId !== p[0].residueId ? m[0].residueId - p[0].residueId : m[0].insertCode.localeCompare(p[0].insertCode);
    }).forEach(function(m) {
      l[m[0].chainId]["".concat(m[0].residueId, "_").concat(m[0].insertCode)] = fS(e, m, c++);
    });
  }), l;
}, f0 = function(e, t) {
  switch (t) {
    case on.Atom:
      return "".concat(e.elementId);
    case on.Residue:
      return "".concat(e.chainId, "_").concat(e.residueName, "_").concat(e.residueId);
    case on.Chain:
      return "".concat(e.chainId);
    case on.Molecular:
      return "".concat(e.unitId);
  }
  return "";
}, oL = function(e, t) {
  switch (t) {
    case on.Atom:
      return e;
    case on.Residue:
      return { unitId: e.unitId, chainId: e.chainId, groupPDB: e.groupPDB, residueId: e.residueId, residueName: e.residueName };
    case on.Chain:
      return { unitId: e.unitId, chainId: e.chainId };
    case on.Molecular:
      return { unitId: e.unitId };
  }
  return {};
};
function pS(e, t, n) {
  var r = this;
  return n === void 0 && (n = !1), At.create("Parse PDB", function(i) {
    return ie(r, 0, void 0, function() {
      var a, o, s;
      return ne(this, function(u) {
        switch (u.label) {
          case 0:
            return o = (a = _r).success, s = {}, [4, Le.readAllLinesAsync(e, i)];
          case 1:
            return [2, o.apply(a, [(s.lines = u.sent(), s.id = t, s.isPdbqt = n, s)])];
        }
      });
    });
  });
}
function sL(e, t) {
  var n = function(a, o) {
    return (t.substr(a, o) || "").trim();
  }, r = { entry_id: Fe.ofString(e), length_a: Fe.ofString(n(6, 9)), length_b: Fe.ofString(n(15, 9)), length_c: Fe.ofString(n(24, 9)), angle_alpha: Fe.ofString(n(33, 7)), angle_beta: Fe.ofString(n(40, 7)), angle_gamma: Fe.ofString(n(47, 7)), Z_PDB: Fe.ofString(n(66, 4)), pdbx_unique_axis: Fe.ofString("?") }, i = { entry_id: Fe.ofString(e), "space_group_name_H-M": Fe.ofString(n(55, 11)), Int_Tables_number: Fe.ofString("?"), cell_setting: Fe.ofString("?"), space_group_name_Hall: Fe.ofString("?") };
  return [Wr.ofFields("cell", r), Wr.ofFields("symmetry", i)];
}
function r_(e, t) {
  return { id: e, details: t, groups: [] };
}
function uL(e, t, n) {
  for (var r, i, a, o = [], s = 1, u = 1, c = function(H) {
    return e.data.substring(e.indices[2 * H], e.indices[2 * H + 1]);
  }, l = t; l < n; l++) {
    var d = c(l);
    if (d.substr(11, 12) === "BIOMOLECULE:") {
      var m = d.substr(23).trim(), p = "Biomolecule ".concat(m);
      (d = c(l + 1)).substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:" && (l++, p = d.substr(11).trim()), r = r_(m, p), o.push(r);
    } else if (d.substr(13, 5) === "BIOMT") {
      var v = d.split(/\s+/);
      (V = parseInt(d[18]) - 1) === 0 && (a = J.identity(), i.operators.push({ id: s++, matrix: a })), J.setValue(a, V, 0, parseFloat(v[4])), J.setValue(a, V, 1, parseFloat(v[5])), J.setValue(a, V, 2, parseFloat(v[6])), J.setValue(a, V, 3, parseFloat(v[7]));
    } else if (d.substr(11, 30) === "APPLY THE FOLLOWING TO CHAINS:" || d.substr(11, 30) === "                   AND CHAINS:") {
      d.substr(11, 5) === "APPLY" && (i = { chains: [], operators: [] }, r.groups.push(i));
      for (var f = 0, y = (h = d.substr(41, 30).split(",")).length; f < y; ++f)
        (g = h[f].trim()) && i.chains.push(g);
    } else if (d.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      r = r_("".concat(u), "Biomolecule ".concat(u)), o.push(r), u += 1, i = { chains: [], operators: [] }, r.groups.push(i);
      var h;
      for (f = 0, y = (h = (d = c(++l)).substr(11, 69).split(",")).length; f < y; ++f) {
        var g;
        (g = h[f].trim()) && i.chains.push(g);
      }
    }
  }
  if (o.length === 0) return [];
  for (var x = { id: Fe.ofStrings(o.map(function(H) {
    return H.id;
  })), details: Fe.ofStrings(o.map(function(H) {
    return H.details;
  })) }, C = [], b = 0, _ = o; b < _.length; b++) for (var A = 0, I = (M = _[b]).groups; A < I.length; A++) {
    var w = I[A];
    C.push({ assembly_id: M.id, oper_expression: w.operators.map(function(H) {
      return H.id;
    }).join(","), asym_id_list: w.chains.join(",") });
  }
  for (var E = { assembly_id: Fe.ofStrings(C.map(function(H) {
    return H.assembly_id;
  })), oper_expression: Fe.ofStrings(C.map(function(H) {
    return H.oper_expression;
  })), asym_id_list: Fe.ofStrings(C.map(function(H) {
    return H.asym_id_list;
  })) }, D = [], T = 0, P = o; T < P.length; T++) for (var M, R = 0, O = (M = P[T]).groups; R < O.length; R++) for (var L = 0, F = O[R].operators; L < F.length; L++) {
    var G = F[L], V = { id: "" + G.id, type: "?", name: "?", symmetry_operation: "?" };
    for (l = 0; l < 3; l++) {
      for (f = 0; f < 3; f++) V["matrix[".concat(l + 1, "][").concat(f + 1, "]")] = "" + J.getValue(G.matrix, l, f);
      V["vector[".concat(l + 1, "]")] = "" + J.getValue(G.matrix, l, 3);
    }
    D.push(V);
  }
  var U = { id: Fe.ofStrings(D.map(function(H) {
    return H.id;
  })), type: Fe.ofStrings(D.map(function(H) {
    return H.type;
  })), name: Fe.ofStrings(D.map(function(H) {
    return H.name;
  })), symmetry_operation: Fe.ofStrings(D.map(function(H) {
    return H.symmetry_operation;
  })) }, q = function(H) {
    for (var K = function(Z) {
      var Y = "matrix[".concat(H + 1, "][").concat(Z + 1, "]");
      U[Y] = Fe.ofStrings(D.map(function(te) {
        return te[Y];
      }));
    }, j = 0; j < 3; j++) K(j);
    var W = "vector[".concat(H + 1, "]");
    U[W] = Fe.ofStrings(D.map(function(Z) {
      return Z[W];
    }));
  };
  for (l = 0; l < 3; l++) q(l);
  return [Wr.ofFields("pdbx_struct_assembly", x), Wr.ofFields("pdbx_struct_assembly_gen", E), Wr.ofFields("pdbx_struct_oper_list", U)];
}
function cL(e, t, n) {
  for (var r, i = [], a = function(g) {
    return e.data.substring(e.indices[2 * g], e.indices[2 * g + 1]);
  }, o = t; o < n; o++) {
    var s = a(o), u = s.split(/\s+/);
    (v = parseInt(s[5]) - 1) === 0 && (r = J.identity(), i.push(r)), J.setValue(r, v, 0, parseFloat(u[2])), J.setValue(r, v, 1, parseFloat(u[3])), J.setValue(r, v, 2, parseFloat(u[4])), J.setValue(r, v, 3, parseFloat(u[5]));
  }
  if (i.length === 0) return [];
  for (var c = [], l = 1, d = 0, m = i; d < m.length; d++) {
    var p = m[d], v = { id: "ncsop" + l++, code: ".", details: "." };
    for (o = 0; o < 3; o++) {
      for (var f = 0; f < 3; f++) v["matrix[".concat(o + 1, "][").concat(f + 1, "]")] = "" + J.getValue(p, o, f);
      v["vector[".concat(o + 1, "]")] = "" + J.getValue(p, o, 3);
    }
    c.push(v);
  }
  var y = { id: Fe.ofStrings(c.map(function(g) {
    return g.id;
  })), code: Fe.ofStrings(c.map(function(g) {
    return g.code;
  })), details: Fe.ofStrings(c.map(function(g) {
    return g.details;
  })) }, h = function(g) {
    for (var x = function(_) {
      var A = "matrix[".concat(g + 1, "][").concat(_ + 1, "]");
      y[A] = Fe.ofStrings(c.map(function(I) {
        return I[A];
      }));
    }, C = 0; C < 3; C++) x(C);
    var b = "vector[".concat(g + 1, "]");
    y[b] = Fe.ofStrings(c.map(function(_) {
      return _[b];
    }));
  };
  for (o = 0; o < 3; o++) h(o);
  return [Wr.ofFields("struct_ncs_oper", y)];
}
var lL = { 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 dL(e, t, n) {
  for (var r = [], i = function(m) {
    return e.data.substring(e.indices[2 * m], e.indices[2 * m + 1]);
  }, a = t; a < n; a++) {
    var o = i(a);
    r.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 = Fe.ofStrings(r.map(function(m) {
    return m.initChainID;
  })), u = Fe.ofStrings(r.map(function(m) {
    return m.initResName;
  })), c = Fe.ofStrings(r.map(function(m) {
    return m.endChainID;
  })), l = Fe.ofStrings(r.map(function(m) {
    return m.endResName;
  })), d = { beg_label_asym_id: s, beg_label_comp_id: u, beg_label_seq_id: Fe.ofUndefined(r.length, X.Schema.int), beg_auth_asym_id: s, beg_auth_comp_id: u, beg_auth_seq_id: Fe.ofStrings(r.map(function(m) {
    return m.initSeqNum;
  })), conf_type_id: Fe.ofStrings(r.map(function(m) {
    return function(p) {
      return lL[p] || "HELX_P";
    }(m.helixClass);
  })), details: Fe.ofStrings(r.map(function(m) {
    return m.comment;
  })), end_label_asym_id: c, end_label_comp_id: l, end_label_seq_id: Fe.ofUndefined(r.length, X.Schema.int), end_auth_asym_id: c, end_auth_comp_id: l, end_auth_seq_id: Fe.ofStrings(r.map(function(m) {
    return m.endSeqNum;
  })), id: Fe.ofStrings(r.map(function(m) {
    return m.serNum;
  })), pdbx_beg_PDB_ins_code: Fe.ofStrings(r.map(function(m) {
    return m.initICode;
  })), pdbx_end_PDB_ins_code: Fe.ofStrings(r.map(function(m) {
    return m.endICode;
  })), pdbx_PDB_helix_class: Fe.ofStrings(r.map(function(m) {
    return m.helixClass;
  })), pdbx_PDB_helix_length: Fe.ofStrings(r.map(function(m) {
    return m.length;
  })), pdbx_PDB_helix_id: Fe.ofStrings(r.map(function(m) {
    return m.helixID;
  })) };
  return Wr.ofFields("struct_conf", d);
}
function fL(e, t, n) {
  for (var r = [], i = function(v) {
    return e.data.substring(e.indices[2 * v], e.indices[2 * v + 1]);
  }, a = t; a < n; a++) {
    var o = i(a);
    r.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 = Fe.ofStrings(r.map(function(v) {
    return v.initChainID;
  })), u = Fe.ofStrings(r.map(function(v) {
    return v.initResName;
  })), c = Fe.ofStrings(r.map(function(v) {
    return v.initSeqNum;
  })), l = Fe.ofStrings(r.map(function(v) {
    return v.endChainID;
  })), d = Fe.ofStrings(r.map(function(v) {
    return v.endResName;
  })), m = Fe.ofStrings(r.map(function(v) {
    return v.endSeqNum;
  })), p = { 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: m, end_auth_asym_id: l, end_auth_comp_id: d, end_auth_seq_id: m, id: Fe.ofStrings(r.map(function(v) {
    return v.strand;
  })), sheet_id: Fe.ofStrings(r.map(function(v) {
    return v.sheetID;
  })), pdbx_beg_PDB_ins_code: Fe.ofStrings(r.map(function(v) {
    return v.initICode;
  })), pdbx_end_PDB_ins_code: Fe.ofStrings(r.map(function(v) {
    return v.endICode;
  })) };
  return Wr.ofFields("struct_sheet_range", p);
}
var mL = { MOL_ID: "", MOLECULE: "", CHAIN: "", FRAGMENT: "", SYNONYM: "", EC: "", ENGINEERED: "", MUTATION: "", OTHER_DETAILS: "" };
function pL(e, t, n) {
  for (var r, i = function(x) {
    return e.data.substring(e.indices[2 * x], e.indices[2 * x + 1]);
  }, a = { chains: [], description: "" }, o = [], s = t; s < n; s++) {
    var u = i(s).substr(10, 70).trim(), c = u.indexOf(":"), l = u.substring(0, c), d = void 0;
    l in mL ? (r = l, d = u.substring(c + 2)) : d = u, d = d.replace(/;$/, ""), r === "MOL_ID" ? (a = { chains: [], description: "" }, o.push(a)) : r === "MOLECULE" ? (a.description && (a.description += " "), a.description += d) : r === "CHAIN" && Array.prototype.push.apply(a.chains, d.split(/\s*,\s*/));
  }
  for (var m = [], p = 0, v = o; p < v.length; p++) for (var f = v[p], y = 0, h = f.chains; y < h.length; y++) {
    var g = h[y];
    m.push({ description: f.description, chains: [g] });
  }
  return m;
}
function hL(e, t, n) {
  for (var r = function(c) {
    return e.data.substring(e.indices[2 * c], e.indices[2 * c + 1]);
  }, i = /* @__PURE__ */ new Map(), a = t; a < n; a++) {
    var o = r(a), s = o.substr(11, 3).trim(), u = o.substr(15).trim();
    i.has(s) ? i.set(s, "".concat(i.get(s), " ").concat(u)) : i.set(s, u);
  }
  return i;
}
var vL = [/* @__PURE__ */ new Set(["CA"]), /* @__PURE__ */ new Set(["C"]), /* @__PURE__ */ new Set(["N"])], gL = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C4'", "C4*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], yL = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C3'", "C3*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], bL = /* @__PURE__ */ new Set(["FMN", "NCN", "FNS", "FMA", "ATP", "ADP", "AMP", "GTP", "GDP", "GMP"]), i_ = 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;
}(), a_ = 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;
}(), kc = function() {
  function e(t, n) {
    this.seqId = t, this.atomId = n, 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(Ug.has(t.id) ? "y" : "n");
  }, e.prototype.getAtomIds = function(t) {
    for (var n = /* @__PURE__ */ new Set(), r = this.seqId.value(t); t < this.seqId.rowCount && this.seqId.value(t) === r; )
      n.add(this.atomId.value(t)), t += 1;
    return n;
  }, e.prototype.hasAtomIds = function(t, n) {
    for (var r = 0, i = n.length; r < i; ++r) if (!Ii.areIntersecting(t, n[r])) return !1;
    return !0;
  }, e.prototype.getType = function(t) {
    return this.hasAtomIds(t, vL) ? "peptide linking" : this.hasAtomIds(t, gL) ? "RNA linking" : this.hasAtomIds(t, yL) ? "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, n) {
    if (!this.has(t)) if (i_.has(t)) this.set(i_.get(t));
    else if (td.has(t)) this.set({ id: t, name: "WATER", type: "non-polymer" });
    else if (bL.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "non-polymer" });
    else if (xu.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "saccharide" });
    else {
      var r = this.getAtomIds(n);
      if (r.size === 1 && a_.has(t)) this.set(a_.get(t));
      else {
        var i = this.getType(r);
        this.set({ id: t, name: this.namesMap.get(t) || t, type: i });
      }
    }
    return this.get(t);
  }, e.prototype.getChemCompTable = function() {
    return Jt.ofPartialColumns(Gi.chem_comp, { id: X.ofStringArray(this.ids), name: X.ofStringArray(this.names), type: X.ofStringAliasArray(this.types), mon_nstd_flag: X.ofStringAliasArray(this.mon_nstd_flags) }, this.ids.length);
  }, e.prototype.setNames = function(t) {
    var n = this;
    t.forEach(function(r) {
      return n.namesMap.set(r[0], r[1]);
    });
  }, e;
}(), Oc = 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, n) {
    this.count += 1, this.ids.push("".concat(this.count)), this.types.push(t), this.descriptions.push([n]);
  }, e.prototype.getEntityId = function(t, n, r, i) {
    return n === 2 ? (this.waterId === void 0 && (this.set("water", (i == null ? void 0 : i.customName) || "Water"), this.waterId = "".concat(this.count)), this.waterId) : Hg(n) ? this.compoundsMap.has(r) ? this.compoundsMap.get(r) : (this.chainMap.has(r) || (this.set("polymer", (i == null ? void 0 : i.customName) || "Polymer ".concat(this.chainMap.size + 1)), this.chainMap.set(r, "".concat(this.count))), this.chainMap.get(r)) : (this.heteroMap.has(t) || (this.set("non-polymer", (i == null ? void 0 : i.customName) || this.namesMap.get(t) || t), this.heteroMap.set(t, "".concat(this.count))), this.heteroMap.get(t));
  }, e.prototype.getEntityTable = function() {
    return Jt.ofPartialColumns(Gi.entity, { id: X.ofStringArray(this.ids), type: X.ofStringAliasArray(this.types), pdbx_description: X.ofStringListArray(this.descriptions) }, this.count);
  }, e.prototype.setCompounds = function(t) {
    for (var n = 0, r = t.length; n < r; ++n) {
      var i = t[n], a = i.chains, o = i.description;
      this.set("polymer", o);
      for (var s = 0, u = a.length; s < u; ++s) this.compoundsMap.set(a[s], "".concat(this.count));
    }
  }, e.prototype.setNames = function(t) {
    var n = this;
    t.forEach(function(r) {
      return n.namesMap.set(r[0], r[1]);
    });
  }, e;
}();
function m0(e, t, n, r) {
  for (var i = n, a = r - 1, o = t.charCodeAt(i); (o === 32 || o >= 48 && o <= 57) && i <= a; ) o = t.charCodeAt(++i);
  for (o = t.charCodeAt(a); (o === 32 || o >= 48 && o <= 57) && a >= i; ) o = t.charCodeAt(--a);
  if (i === ++a || i + 1 === a) return Ge.add(e, i, a);
  if (o = t.charCodeAt(i), i + 2 === a) {
    var s = t.charCodeAt(i + 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 Ge.add(e, i, i + 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 Ge.add(e, i, i + 1);
  Ge.add(e, i, i);
}
var jv, _L = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), xL = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), SL = /^[\s\d]+|[\s\d]+$/g;
function g3(e, t) {
  var n = (e = e.replace(SL, "").toUpperCase()).length;
  if (n === 0 || n === 1 || _L.has(e)) return e;
  if (n === 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 xL.has(e[0]) ? e[0] : e;
}
function o_(e, t, n, r, i, a) {
  var o = n.data, s = i - r;
  Ge.addToken(e.group_PDB, Le.trim(n, r, r + 6)), Le.trim(n, r + 6, r + 11), e.id[e.index] = n.data.substring(n.tokenStart, n.tokenEnd), Ge.addToken(e.auth_atom_id, Le.trim(n, r + 12, r + 16)), o.charCodeAt(r + 16) === 32 ? Ge.add(e.label_alt_id, 0, 0) : Ge.add(e.label_alt_id, r + 16, r + 17), Ge.addToken(e.auth_comp_id, Le.trim(n, r + 17, r + 20)), Ge.add(e.auth_asym_id, r + 21, r + 22), Ge.addToken(e.auth_seq_id, Le.trim(n, r + 22, r + 26)), o.charCodeAt(r + 26) === 32 ? Ge.add(e.pdbx_PDB_ins_code, 0, 0) : Ge.add(e.pdbx_PDB_ins_code, r + 26, r + 27), Ge.addToken(e.Cartn_x, Le.trim(n, r + 30, r + 38)), Ge.addToken(e.Cartn_y, Le.trim(n, r + 38, r + 46)), Ge.addToken(e.Cartn_z, Le.trim(n, r + 46, r + 54)), Ge.addToken(e.occupancy, Le.trim(n, r + 54, r + 60)), s >= 66 ? Ge.addToken(e.B_iso_or_equiv, Le.trim(n, r + 60, r + 66)) : Ge.add(e.B_iso_or_equiv, 0, 0), a && Ge.addToken(e.partial_charge, Le.trim(n, r + 70, r + 76)), s >= 78 && !a ? (Le.trim(n, r + 76, r + 78), n.tokenStart < n.tokenEnd ? Ge.addToken(e.type_symbol, n) : m0(e.type_symbol, o, r + 12, r + 16)) : m0(e.type_symbol, o, r + 12, r + 16), s >= 82 && Ge.addToken(e.pdbx_formal_charge, Le.trim(n, r + 78, r + 82)), s >= 84 && Ge.addToken(e.cdr, Le.trim(n, r + 82, r + 84)), s >= 90 && Ge.addToken(e.em_confidence, Le.trim(n, r + 84, r + 90)), e.pdbx_PDB_model_num[e.index] = t, e.index++;
}
function CL(e) {
  var t = Fe.ofTokens(e.pdbx_auth_seq_id), n = Fe.ofTokens(e.pdbx_auth_comp_id), r = Fe.ofTokens(e.pdbx_auth_asym_id), i = Fe.ofTokens(e.pdbx_auth_atom_id), a = { id: Fe.ofStrings(e.id), type_symbol: Fe.ofTokens(e.type_symbol), pdbx_label_atom_id: i, pdbx_label_alt_id: Fe.ofTokens(e.pdbx_label_alt_id), pdbx_label_comp_id: n, pdbx_label_asym_id: r, pdbx_label_seq_id: t, pdbx_PDB_ins_code: Fe.ofTokens(e.pdbx_PDB_ins_code), pdbx_auth_seq_id: t, pdbx_auth_comp_id: n, pdbx_auth_asym_id: r, pdbx_auth_atom_id: i };
  return a["U[1][1]"] = Fe.ofNumbers(e["U[1][1]"]), a["U[2][2]"] = Fe.ofNumbers(e["U[2][2]"]), a["U[3][3]"] = Fe.ofNumbers(e["U[3][3]"]), a["U[1][2]"] = Fe.ofNumbers(e["U[1][2]"]), a["U[1][3]"] = Fe.ofNumbers(e["U[1][3]"]), a["U[2][3]"] = Fe.ofNumbers(e["U[2][3]"]), a;
}
function AL(e, t, n, r, i) {
  var a = n.data, o = i - r;
  Le.trim(n, r + 6, r + 11), e.id[e.index] = a.substring(n.tokenStart, n.tokenEnd), Ge.addToken(e.pdbx_auth_atom_id, Le.trim(n, r + 12, r + 16)), a.charCodeAt(r + 16) === 32 ? Ge.add(e.pdbx_label_alt_id, 0, 0) : Ge.add(e.pdbx_label_alt_id, r + 16, r + 17), Ge.addToken(e.pdbx_auth_comp_id, Le.trim(n, r + 17, r + 20)), Ge.add(e.pdbx_auth_asym_id, r + 21, r + 22), Ge.addToken(e.pdbx_auth_seq_id, Le.trim(n, r + 22, r + 26)), a.charCodeAt(r + 26) === 32 ? Ge.add(e.pdbx_PDB_ins_code, 0, 0) : Ge.add(e.pdbx_PDB_ins_code, r + 26, r + 27), e["U[1][1]"][e.index] = ec(a, r + 28, r + 35) / 1e4, e["U[2][2]"][e.index] = ec(a, r + 35, r + 42) / 1e4, e["U[3][3]"][e.index] = ec(a, r + 42, r + 49) / 1e4, e["U[1][2]"][e.index] = ec(a, r + 49, r + 56) / 1e4, e["U[1][3]"][e.index] = ec(a, r + 56, r + 63) / 1e4, e["U[2][3]"][e.index] = ec(a, r + 63, r + 70) / 1e4, o >= 78 ? (Le.trim(n, r + 76, r + 78), n.tokenStart < n.tokenEnd ? Ge.addToken(e.type_symbol, n) : m0(e.type_symbol, a, r + 12, r + 16)) : m0(e.type_symbol, a, r + 12, r + 16), e.index++;
}
function IL(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L;
    return ne(this, function(F) {
      for (t = e.lines, n = t.data, r = t.indices, i = Le(n), a = !!e.isPdbqt, o = 0, s = 0, w = 0, y = t.count; w < y; w++) switch (h = r[2 * w], g = r[2 * w + 1], n[h]) {
        case "A":
          Qn(n, h, g, "ATOM  ") ? o++ : Qn(n, h, g, "ANISOU") && s++;
          break;
        case "H":
          Qn(n, h, g, "HETATM") && o++;
      }
      for (u = function(H, K) {
        var j = function() {
          return Ge.create(H, 2 * K);
        };
        return { index: 0, group_PDB: j(), id: [], auth_atom_id: j(), label_alt_id: j(), auth_comp_id: j(), auth_asym_id: j(), auth_seq_id: j(), pdbx_PDB_ins_code: j(), Cartn_x: j(), Cartn_y: j(), Cartn_z: j(), occupancy: j(), B_iso_or_equiv: j(), type_symbol: j(), pdbx_PDB_model_num: [], label_entity_id: [], partial_charge: j(), pdbx_formal_charge: j(), cdr: j(), em_confidence: j() };
      }(n, o), c = function(H, K) {
        var j = function() {
          return new Float32Array(K);
        }, W = function() {
          return Ge.create(H, 2 * K);
        };
        return { index: 0, count: K, id: [], type_symbol: W(), pdbx_label_atom_id: W(), pdbx_label_alt_id: W(), pdbx_label_comp_id: W(), pdbx_label_asym_id: W(), pdbx_label_seq_id: W(), pdbx_PDB_ins_code: W(), "U[1][1]": j(), "U[2][2]": j(), "U[3][3]": j(), "U[1][2]": j(), "U[1][3]": j(), "U[2][3]": j(), pdbx_auth_seq_id: W(), pdbx_auth_comp_id: W(), pdbx_auth_asym_id: W(), pdbx_auth_atom_id: W() };
      }(n, s), l = new Oc(), d = [], m = [], p = 0, v = "", f = void 0, w = 0, y = t.count; w < y; w++) switch (h = r[2 * w], g = r[2 * w + 1], n[h]) {
        case "A":
          Qn(n, h, g, "ATOM  ") ? (p || (p++, v = "" + p), o_(u, v, i, h, g, a)) : Qn(n, h, g, "ANISOU") && AL(c, 0, i, h, g);
          break;
        case "C":
          if (Qn(n, h, g, "CRYST1")) d.push.apply(d, sL(e.id || "?", n.substring(h, g)));
          else if (Qn(n, h, g, "CONECT")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "CONECT"); ) x++;
            f ? Xt && console.log("only single CONECT block allowed, ignoring others") : f = [w, x], w = x - 1;
          } else if (Qn(n, h, g, "COMPND")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "COMPND"); ) x++;
            l.setCompounds(pL(t, w, x)), w = x - 1;
          }
          break;
        case "H":
          if (Qn(n, h, g, "HETATM")) p || (p++, v = "" + p), o_(u, v, i, h, g, a);
          else if (Qn(n, h, g, "HELIX")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "HELIX"); ) x++;
            d.push(dL(t, w, x)), w = x - 1;
          } else if (Qn(n, h, g, "HETNAM")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "HETNAM"); ) x++;
            m.push.apply(m, Array.from(hL(t, w, x).entries())), w = x - 1;
          }
          break;
        case "M":
          if (Qn(n, h, g, "MODEL ") && (p++, v = "" + p), Qn(n, h, g, "MTRIX")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "MTRIX"); ) x++;
            d.push.apply(d, cL(t, w, x)), w = x - 1;
          }
          break;
        case "O":
          break;
        case "R":
          if (Qn(n, h, g, "REMARK 350")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "REMARK 350"); ) x++;
            d.push.apply(d, uL(t, w, x)), w = x - 1;
          }
          break;
        case "S":
          if (Qn(n, h, g, "SHEET")) {
            for (x = w + 1; h = r[2 * x], g = r[2 * x + 1], Qn(n, h, g, "SHEET"); ) x++;
            d.push(fL(t, w, x)), w = x - 1;
          }
      }
      for (C = X.ofIntTokens(u.auth_seq_id), b = X.ofStringTokens(u.auth_atom_id), _ = X.ofStringTokens(u.auth_comp_id), A = X.ofStringTokens(u.auth_asym_id), (I = new kc(C, b)).setNames(m), l.setNames(m), w = 0, E = _.rowCount; w < E; ++w) D = _.value(w), T = Ff(I.add(D, w).type, D), u.label_entity_id[w] = l.getEntityId(D, T, A.value(w));
      var G, V, U, q;
      for (G = u, V = Fe.ofTokens(G.auth_asym_id), U = Fe.ofTokens(G.auth_atom_id), q = Fe.ofTokens(G.auth_comp_id), P = { auth_asym_id: V, auth_atom_id: U, auth_comp_id: q, auth_seq_id: Fe.ofTokens(G.auth_seq_id), B_iso_or_equiv: Fe.ofTokens(G.B_iso_or_equiv), Cartn_x: Fe.ofTokens(G.Cartn_x), Cartn_y: Fe.ofTokens(G.Cartn_y), Cartn_z: Fe.ofTokens(G.Cartn_z), group_PDB: Fe.ofTokens(G.group_PDB), id: Fe.ofStrings(G.id), label_alt_id: Fe.ofTokens(G.label_alt_id), label_asym_id: V, label_atom_id: U, label_comp_id: q, label_seq_id: Fe.ofUndefined(G.index, X.Schema.int), label_entity_id: Fe.ofStrings(G.label_entity_id), occupancy: lT(G.occupancy) ? Fe.ofUndefined(G.index, X.Schema.float) : Fe.ofTokens(G.occupancy), type_symbol: Fe.ofTokens(G.type_symbol), pdbx_PDB_ins_code: Fe.ofTokens(G.pdbx_PDB_ins_code), pdbx_PDB_model_num: Fe.ofStrings(G.pdbx_PDB_model_num), partial_charge: Fe.ofTokens(G.partial_charge), pdbx_formal_charge: Fe.ofTokens(G.pdbx_formal_charge), cdr: Fe.ofTokens(G.cdr), em_confidence: Fe.ofTokens(G.em_confidence) }, f && d.push(function(H, K, j, W) {
        for (var Z = {}, Y = 0, te = W.id.rowCount; Y < te; ++Y) Z[W.id.str(Y)] = Y;
        var ee = function(Qe) {
          return H.data.substring(H.indices[2 * Qe], H.indices[2 * Qe + 1]);
        }, $ = [], ue = [], se = [], be = [], ke = [], Oe = [], ze = [], je = [], xe = [], Xe = [], Ee = [11, 16, 21, 26], Ye = 1;
        for (Y = K; Y < j; Y++) {
          var He = ee(Y), le = Z[parseInt(He.substr(6, 5))], Ce = {};
          if (le !== void 0) for (var Ae = 0; Ae < 4; ++Ae) {
            var Te = parseInt(He.substr(Ee[Ae], 5));
            if (!Number.isNaN(Te)) {
              var Re = Z[Te];
              Re !== void 0 && (le > Re || Ce[Re] === void 0 && ($.push("covale".concat(Ye)), ue.push("covale"), se.push(W.label_asym_id.str(le)), ke.push(W.auth_seq_id.int(le)), be.push(W.label_seq_id.int(le)), Oe.push(W.label_atom_id.str(le)), ze.push(W.label_asym_id.str(Re)), xe.push(W.auth_seq_id.int(Re)), je.push(W.label_seq_id.int(Re)), Xe.push(W.label_atom_id.str(Re)), Ye += 1));
            }
          }
        }
        var we = { id: Fe.ofStrings($), conn_type_id: Fe.ofStrings(ue), ptnr1_label_asym_id: Fe.ofStrings(se), ptnr1_auth_seq_id: Fe.ofNumbers(ke), ptnr1_label_seq_id: Fe.ofNumbers(be), ptnr1_label_atom_id: Fe.ofStrings(Oe), ptnr2_label_asym_id: Fe.ofStrings(ze), ptnr2_label_seq_id: Fe.ofNumbers(je), ptnr2_auth_seq_id: Fe.ofNumbers(xe), ptnr2_label_atom_id: Fe.ofStrings(Xe) };
        return Wr.ofFields("struct_conn", we);
      }(t, f[0], f[1], P)), M = { entity: Wr.ofTable("entity", l.getEntityTable()), chem_comp: Wr.ofTable("chem_comp", I.getChemCompTable()), atom_site: Wr.ofFields("atom_site", P), atom_site_anisotrop: Wr.ofFields("atom_site_anisotrop", CL(c)) }, R = 0, O = d; R < O.length; R++) L = O[R], M[L.name] = L;
      return [2, { header: e.id || "PDB", categoryNames: Object.keys(M), categories: M }];
    });
  });
}
function hS(e) {
  var t = this;
  return At.create("Parse PDB", function(n) {
    return ie(t, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m, p;
      return ne(this, function(v) {
        switch (v.label) {
          case 0:
            return [4, n.update("Converting to mmCIF")];
          case 1:
            return v.sent(), [4, IL(e)];
          case 2:
            return r = v.sent(), i = _n.fromFrame(r, void 0, jv.create(e)), [4, Ps(Bu(i.data.db, !0), i, n)];
          case 3:
            return a = v.sent(), (o = (p = r.categories.atom_site) === null || p === void 0 ? void 0 : p.getField("partial_charge")) && a.frameCount === 1 && (s = a.representative, u = s.atomicHierarchy.atomSourceIndex, c = X.isIdentity(u), l = c ? void 0 : u.toArray({ array: Int32Array }), d = o.toFloatArray(), m = l ? X.ofFloatArray(X.mapToArray(u, function(f) {
              return d[f];
            }, Float32Array)) : X.ofFloatArray(d), Ss.Provider.set(s, { data: m, type: "GASTEIGER" })), [2, a];
        }
      });
    });
  });
}
(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 };
  };
})(jv || (jv = {}));
var Kv, wL = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, pS(e).run()] : [2, [Go()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, hS(t.result).run()];
        case 2:
          return [2, n.sent().frames.map(function(r) {
            return Be.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function PL(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 y3(e, t) {
  for (var n = Ge.create(e.data, 2 * t), r = Ge.create(e.data, 2 * t), i = Ge.create(e.data, 2 * t), a = Ge.create(e.data, 2 * t), o = Ge.create(e.data, 2 * t), s = 0; s < t; ++s) {
    Le.markLine(e);
    var u = e.tokenStart, c = e.position;
    Le.trim(e, u, u + 10), Ge.addUnchecked(n, e.tokenStart, e.tokenEnd), Le.trim(e, u + 10, u + 20), Ge.addUnchecked(r, e.tokenStart, e.tokenEnd), Le.trim(e, u + 20, u + 30), Ge.addUnchecked(i, e.tokenStart, e.tokenEnd), Le.trim(e, u + 31, u + 34), Ge.addUnchecked(a, e.tokenStart, e.tokenEnd), Le.trim(e, u + 36, u + 39), Ge.addUnchecked(o, e.tokenStart, e.tokenEnd), e.position = c;
  }
  return { count: t, x: en(n)(X.Schema.float), y: en(r)(X.Schema.float), z: en(i)(X.Schema.float), type_symbol: en(a)(X.Schema.str), formal_charge: en(o)(X.Schema.int) };
}
function b3(e, t) {
  for (var n = Ge.create(e.data, 2 * t), r = Ge.create(e.data, 2 * t), i = Ge.create(e.data, 2 * t), a = 0; a < t; ++a) {
    Le.markLine(e);
    var o = e.tokenStart, s = e.position;
    Le.trim(e, o, o + 3), Ge.addUnchecked(n, e.tokenStart, e.tokenEnd), Le.trim(e, o + 3, o + 6), Ge.addUnchecked(r, e.tokenStart, e.tokenEnd), Le.trim(e, o + 6, o + 9), Ge.addUnchecked(i, e.tokenStart, e.tokenEnd), e.position = s;
  }
  return { count: t, atomIdxA: en(n)(X.Schema.int), atomIdxB: en(r)(X.Schema.int), order: en(i)(X.Schema.int) };
}
function EL(e, t, n) {
  Le.trim(e, t + 6, t + 9);
  for (var r = parseInt(Le.getTokenString(e)), i = 0; i < r; ++i) {
    var a = 9 + 8 * i;
    Le.trim(e, t + a, t + a + 4);
    var o = Le.getTokenString(e);
    n.atomIdx.push(+o), Le.trim(e, t + a + 4, t + a + 8);
    var s = Le.getTokenString(e);
    n.charge.push(+s);
  }
  Le.eatLine(e);
}
function _3(e) {
  for (var t = { atomIdx: [], charge: [] }; e.position < e.length; ) {
    var n = e.position;
    Le.trim(e, n + 3, n + 6);
    var r = Le.getTokenString(e);
    if (r === "END") break;
    Le.eatLine(e), r === "CHG" && EL(e, n, t);
  }
  return { atomIdx: X.ofIntArray(t.atomIdx), charge: X.ofIntArray(t.charge) };
}
function TL(e) {
  var t = Le(e), n = Le.readLine(t).trim(), r = Le.readLine(t).trim(), i = Le.readLine(t).trim(), a = Le.readLine(t), o = +a.substr(0, 3), s = +a.substr(3, 3), u = { title: n, program: r, comment: i, atoms: y3(t, o), bonds: b3(t, s), formalCharges: _3(t) };
  return _r.success(u);
}
function ML(e) {
  var t = this;
  return At.create("Parse Mol", function() {
    return ie(t, 0, void 0, function() {
      return ne(this, function(n) {
        return [2, TL(e)];
      });
    });
  });
}
function vS(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x;
    return ne(this, function(C) {
      switch (C.label) {
        case 0:
          if (r = e.atoms, i = e.bonds, a = e.formalCharges, o = X.ofConst("MOL", e.atoms.count, X.Schema.str), s = X.ofConst("A", e.atoms.count, X.Schema.str), u = X.asArrayColumn(r.type_symbol), c = X.ofConst(1, r.count, X.Schema.int), l = new Int32Array(e.atoms.count), a.atomIdx.rowCount > 0) for (d = 0; d < a.atomIdx.rowCount; d++) l[a.atomIdx.value(d) - 1] = a.charge.value(d);
          else for (d = 0; d < e.atoms.count; d++) l[d] = PL(r.formal_charge.value(d));
          return m = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: s, auth_atom_id: u, auth_comp_id: o, auth_seq_id: c, Cartn_x: X.asArrayColumn(r.x, Float32Array), Cartn_y: X.asArrayColumn(r.y, Float32Array), Cartn_z: X.asArrayColumn(r.z, Float32Array), id: X.range(0, r.count - 1), label_asym_id: s, label_atom_id: u, label_comp_id: o, label_seq_id: c, label_entity_id: X.ofConst("1", r.count, X.Schema.str), occupancy: X.ofConst(1, r.count, X.Schema.float), type_symbol: u, pdbx_PDB_model_num: X.ofConst(1, r.count, X.Schema.int), pdbx_formal_charge: X.ofIntArray(l) }, r.count), (p = new Oc()).setNames([["MOL", "Ligand"]]), p.getEntityId("MOL", 0, "A"), (v = new kc(c, u)).setNames([["MOL", "Unknown Molecule"]]), v.add("MOL", 0), [4, Ps(Bu({ entity: p.getEntityTable(), chem_comp: v.getChemCompTable(), atom_site: m }), t ?? Kv.create(e), n)];
        case 1:
          return (f = C.sent()).frameCount > 0 && (y = X.ofIntArray(X.mapToArray(i.atomIdxA, function(b) {
            return b - 1;
          }, Int32Array)), h = X.ofIntArray(X.mapToArray(i.atomIdxB, function(b) {
            return b - 1;
          }, Int32Array)), g = X.asArrayColumn(i.order, Int32Array), x = gr.fromData({ pairs: { indexA: y, indexB: h, order: g }, count: r.count }), gr.Provider.set(f.representative, x)), [2, f];
      }
    });
  });
}
(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 };
  };
})(Kv || (Kv = {}));
var DL = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, ML(e).run()] : [2, [Go()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, (i = t.result, At.create("Parse MOL", function(a) {
            return vS(i, void 0, a);
          })).run()];
        case 2:
          return n = r.sent(), [2, [Be.ofModel(n.representative)]];
      }
      var i;
    });
  });
} };
function $o(e) {
  Le.skipWhitespace(e), Le.eatValue(e);
}
function es(e, t) {
  var n = e.position;
  Le.skipWhitespace(e), Le.eatValue(e), Le.trim(e, n, e.position), Ge.addUnchecked(t, e.tokenStart, e.tokenEnd);
}
var Xv, Eh = "$$$$";
function BL(e) {
  var t = Le.readLine(e).trim(), n = Le.readLine(e).trim(), r = Le.readLine(e).trim(), i = Le.readLine(e), a = i.trim().endsWith("V3000"), o = a ? function(v) {
    var f = Ge.create(v.data, 1), y = Ge.create(v.data, 1);
    return Le.eatLine(v), $o(v), $o(v), $o(v), es(v, f), es(v, y), Le.eatLine(v), { atomCount: en(f)(X.Schema.int).value(0), bondCount: en(y)(X.Schema.int).value(0) };
  }(e) : function(v) {
    return { atomCount: +v.substr(0, 3), bondCount: +v.substr(3, 3) };
  }(i), s = o.atomCount, u = o.bondCount;
  if (!Number.isNaN(s) && !Number.isNaN(u)) {
    var c = { atomIdx: X.ofConst(0, s, X.Schema.int), charge: X.ofConst(0, s, X.Schema.int) }, l = a ? function(v, f) {
      for (var y = Ge.create(v.data, 2 * f), h = Ge.create(v.data, 2 * f), g = Ge.create(v.data, 2 * f), x = Ge.create(v.data, 2 * f), C = 0; C < f; ++C) {
        Le.markLine(v), $o(v), $o(v), $o(v);
        var b = v.position;
        es(v, x), es(v, y), es(v, h), es(v, g), v.position = b;
      }
      return Le.eatLine(v), Le.eatLine(v), { count: f, x: en(y)(X.Schema.float), y: en(h)(X.Schema.float), z: en(g)(X.Schema.float), type_symbol: en(x)(X.Schema.str), formal_charge: X.ofConst(0, f, X.Schema.int) };
    }(e, s) : y3(e, s), d = a ? function(v, f) {
      for (var y = Ge.create(v.data, 2 * f), h = Ge.create(v.data, 2 * f), g = Ge.create(v.data, 2 * f), x = 0; x < f; ++x) {
        Le.markLine(v), $o(v), $o(v), $o(v);
        var C = v.position;
        es(v, g), es(v, y), es(v, h), v.position = C;
      }
      return Le.eatLine(v), Le.eatLine(v), { count: f, atomIdxA: en(y)(X.Schema.float), atomIdxB: en(h)(X.Schema.float), order: en(g)(X.Schema.float) };
    }(e, u) : b3(e, u), m = a ? c : _3(e), p = function(v) {
      for (var f = Ge.create(v.data, 32), y = Ge.create(v.data, 32); v.position < v.length; ) {
        var h = Le.readLine(v);
        if (h.startsWith(Eh)) break;
        if (h && h.startsWith("> ")) {
          Ge.add(f, v.tokenStart + 2, v.tokenEnd), Le.markLine(v);
          for (var g = v.tokenStart, x = v.tokenEnd, C = !1; v.position < v.length; ) {
            var b = Le.readLine(v);
            if (!b || b.startsWith(Eh) || b.startsWith("> ")) {
              Ge.add(y, g, x), C = !0;
              break;
            }
            x = v.tokenEnd;
          }
          C || Ge.add(y, g, x);
        }
      }
      return { dataHeader: en(f)(X.Schema.str), data: en(y)(X.Schema.str) };
    }(e);
    return { molFile: { title: t, program: n, comment: r, atoms: l, bonds: d, formalCharges: m }, dataItems: p };
  }
  for (; e.position < e.length && !Le.readLine(e).startsWith(Eh); )
    ;
}
function RL(e) {
  for (var t = Le(e), n = []; t.position < t.length; ) {
    var r = BL(t);
    r && n.push(r);
  }
  return _r.success({ compounds: n });
}
function kL(e) {
  var t = this;
  return At.create("Parse Sdf", function() {
    return ie(t, 0, void 0, function() {
      return ne(this, function(n) {
        return [2, RL(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 };
  };
})(Xv || (Xv = {}));
var Th, lf, bc = {};
Th = bc, 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(i) {
    return function(a, o) {
      var s, u, c, l, d, m, p, v, f, y = 1, h = a.length, g = "";
      for (u = 0; u < h; u++) if (typeof a[u] == "string") g += a[u];
      else if (typeof a[u] == "object") {
        if ((l = a[u]).keys) for (s = o[y], 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[y++];
        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) && (v = 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) ? g += s : (!e.number.test(l.type) || v && !l.sign ? f = "" : (f = v ? "+" : "-", s = s.toString().replace(e.sign, "")), m = l.pad_char ? l.pad_char === "0" ? "0" : l.pad_char.charAt(1) : " ", p = l.width - (f + s).length, d = l.width && p > 0 ? m.repeat(p) : "", g += l.align ? f + s + d : m === "0" ? f + d + s : d + f + s);
      }
      return g;
    }(function(a) {
      if (r[a]) return r[a];
      for (var o, s = a, 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], m = [];
            if ((m = e.key.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
            for (l.push(m[1]); (d = d.substring(m[0].length)) !== ""; ) if ((m = e.key_access.exec(d)) !== null) l.push(m[1]);
            else {
              if ((m = e.index_access.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
              l.push(m[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 r[a] = u;
    }(i), arguments);
  }
  function n(i, a) {
    return t.apply(null, [i].concat(a || []));
  }
  var r = /* @__PURE__ */ Object.create(null);
  Th.sprintf = t, Th.vsprintf = n, typeof window < "u" && (window.sprintf = t, window.vsprintf = n);
}(), function(e) {
  e.PDB = "chemical/pdb", e.SDF = "chemical/x-mdl-sdf", e.MOL = "chemical/x-mdl-molfile", e.MOL2 = "chemical/x-mol2";
}(lf || (lf = {}));
var OL = ["HEADER", "SOURCE", "AUTHOR", "OBSLTE", "KEYWDS", "REVDAT", "TITLE", "EXPDTA", "SPRSDE", "SPLT", "NUMMDL", "JRNL", "CAVEAT", "MDLTYP", "REMARKS", "COMPND"], NL = ["DBREF", "DBREF1", "DBREF2", "SEQADV", "SEQRES", "MODRES"], LL = ["HET   ", "HETNAM", "HETSYN", "FORMUL"], x3 = function(e, t) {
  var n = ea(e);
  return (n == null ? void 0 : n.sourceData.kind) === "mmCIF" ? n.sourceData.data.source.data.lines.data.split(`
`).filter(function(r) {
    for (var i = 0, a = t.length; i < a; i++) if (r.startsWith(t[i])) return !0;
    return !1;
  }) : [];
};
function S3(e, t, n, r) {
  var i, a = [];
  if (((i = e.models[0]) === null || i === void 0 ? void 0 : i.sourceData.kind) === "mmCIF") {
    var o = Pe(Pe(Pe([], OL, !0), NL, !0), LL, !0);
    a.push.apply(a, x3(e, o));
  }
  var s = [];
  t ? s.push.apply(s, Pe([], t, !0).sort(function(f, y) {
    return f - y;
  })) : e.units.forEach(function(f) {
    return s.push.apply(s, Pe([], f.elements, !0));
  });
  var u = e.units[0], c = [], l = !1, d = !1;
  if (s.forEach(function(f) {
    var y = { elementId: f, group_PDB: u.model.atomicHierarchy.residues.group_PDB.value(u.residueIndex[f]), atom_id: u.model.atomicConformation.atomId.value(f), auth_atom_id: u.model.atomicHierarchy.atoms.auth_atom_id.value(f), label_alt_id: u.model.atomicHierarchy.atoms.label_alt_id.value(f), auth_comp_id: u.model.atomicHierarchy.atoms.label_comp_id.value(f), auth_asym_id: u.model.atomicHierarchy.chains.auth_asym_id.value(u.chainIndex[f]), auth_seq_id: u.model.atomicHierarchy.residues.auth_seq_id.value(u.residueIndex[f]), pdbx_PDB_ins_code: u.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(u.residueIndex[f]), x: u.model.atomicConformation.x[f], y: u.model.atomicConformation.y[f], z: u.model.atomicConformation.z[f], occupancy: u.model.atomicConformation.occupancy.value(f), B_iso_or_equiv: u.model.atomicConformation.B_iso_or_equiv.value(f), type_symbol: Ef(u.model.atomicHierarchy.atoms.type_symbol.value(f)), charge: u.model.atomicHierarchy.atoms.pdbx_formal_charge.value(f), em_confidence: u.model.atomicHierarchy.atoms.em_confidence.value(f) };
    c.push(y), y.em_confidence && (l = !0), y.charge && (d = !0);
  }), r) {
    var m = r(c, []), p = m.editedAtomList, v = m.editedBondList;
    return a.push(Yv(p, v, n && d, n && l)), a.join(`
`);
  }
  return a.push(Yv(c, [], n && d, n && l)), a.join(`
`);
}
function Yv(e, t, n, r) {
  var i = "ATOM  %5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(n ? "%4.1f" : "%2s  ").concat(r ? "   %5.2f" : ""), a = "HETATM%5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(n ? "%4.1f" : "%2s  ").concat(r ? "   %5.2f" : ""), o = "CONECT%5s%5s%5s%5s%5s", s = [], u = [];
  return e.forEach(function(c) {
    var l = c.elementId, d = c.atom_id, m = c.auth_atom_id, p = c.label_alt_id, v = c.auth_comp_id, f = c.auth_asym_id, y = c.auth_seq_id, h = c.pdbx_PDB_ins_code, g = h === void 0 ? " " : h, x = c.x, C = c.y, b = c.z, _ = c.occupancy, A = c.B_iso_or_equiv, I = c.type_symbol, w = c.group_PDB, E = c.charge, D = c.em_confidence, T = w === "HETATM" ? a : i;
    s.push(bc.sprintf(T, d, m, p, v, f, y, g, x, C, b, _, A, " ", I, n ? E : "  ", r ? D : ""));
    var P = [];
    if (t && (t.forEach(function(O) {
      if (O.a !== l || P.includes(O.atom_idB)) {
        if (O.b === l && !P.includes(O.atom_idA)) for (L = 0, F = O.order; L < F; L++) P.push(O.atom_idA);
      } else for (var L = 0, F = O.order; L < F; L++) P.push(O.atom_idB);
    }), P.length > 0)) {
      for (var M = []; P.length > 0; ) {
        var R = P.shift();
        R && M.push(R), M.length === 4 && (u.push(bc.sprintf(o, d, M[0], M[1], M[2], M[3])), M = []);
      }
      M.length > 0 && (u.push(bc.sprintf(o, d, M[0] || "", M[1] || "", M[2] || "", M[3] || "")), M = []);
    }
  }), Pe(Pe([], s, !0), u, !0).join(`
`);
}
function Wv(e, t, n, r, i) {
  var a, o, s, u, c, l;
  i === void 0 && (i = !1);
  var d = [];
  if (e.units.forEach(function(O) {
    return d.push.apply(d, Pe([], O.elements, !0));
  }), d.length > 999) return "";
  if (d.length <= 0) {
    if (r) {
      var m = r([], []), p = m.editedAtomList, v = m.editedBondList, f = (a = e == null ? void 0 : e.state.model) !== null && a !== void 0 ? a : e == null ? void 0 : e.state.models[0], y = (o = f == null ? void 0 : f.sourceData) === null || o === void 0 ? void 0 : o.kind, h = Sm(p, v);
      return y === "sdf" || y === "mol" ? Pe(Pe([f.entryId], h.split(`
`).slice(1), !0), ["$$$$"], !1).join(`
`) : "".concat(h, `
$$$$`);
    }
    return "";
  }
  var g = e.units[0], x = [], C = /* @__PURE__ */ new Map();
  d.forEach(function(O) {
    var L;
    x.push({ elementId: O, group_PDB: g.model.atomicHierarchy.residues.group_PDB.value(g.residueIndex[O]), atom_id: g.model.atomicConformation.atomId.value(O), auth_atom_id: g.model.atomicHierarchy.atoms.label_atom_id.value(O), label_alt_id: g.model.atomicHierarchy.atoms.label_alt_id.value(O), auth_comp_id: g.model.atomicHierarchy.atoms.label_comp_id.value(O), auth_asym_id: g.model.atomicHierarchy.chains.auth_asym_id.value(g.chainIndex[O]), auth_seq_id: g.model.atomicHierarchy.residues.auth_seq_id.value(g.residueIndex[O]), pdbx_PDB_ins_code: g.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(g.residueIndex[O]), x: g.model.atomicConformation.x[O], y: g.model.atomicConformation.y[O], z: g.model.atomicConformation.z[O], occupancy: g.model.atomicConformation.occupancy.value(O), B_iso_or_equiv: g.model.atomicConformation.B_iso_or_equiv.value(O), type_symbol: Ef(g.model.atomicHierarchy.atoms.type_symbol.value(O)), charge: g.model.atomicHierarchy.atoms.pdbx_formal_charge.value(O) || ((L = Ss.Provider.get(g.model)) === null || L === void 0 ? void 0 : L.data.value(O)) || 0 });
  });
  var b = new Set(t), _ = /* @__PURE__ */ new Map();
  if (i && ((s = e.model) === null || s === void 0 ? void 0 : s.sourceData.kind) === "mmCIF") for (var A = function(O, L) {
    for (var F = e.units[O], G = function(q, H) {
      var K = F.rings.all[F.rings.aromaticRings[q]].map(function(j) {
        return F.elements[j];
      });
      K.forEach(function(j, W) {
        b.has(j) && _.set(j, new Set(Pe(Pe([], K.slice(0, W), !0), K.slice(W + 1), !0)));
      });
    }, V = 0, U = F.rings.aromaticRings.length; V < U; V++) G(V);
  }, I = 0, w = e.units.length; I < w; I++) A(I);
  e.units.forEach(function(O) {
    for (var L, F = 0, G = O.bonds.a.length; F < G; F++) {
      var V = O.elements[O.bonds.a[F]], U = O.elements[O.bonds.b[F]];
      if (d.includes(V) && d.includes(U) && !C.has("".concat(V, "_").concat(U)) && !C.has("".concat(U, "_").concat(V))) {
        var q = i && _.has(V) && (!((L = _.get(V)) === null || L === void 0) && L.has(U)) ? 4 : O.bonds.edgeProps.order[F];
        C.set("".concat(V, "_").concat(U), { a: d.indexOf(V) + 1, b: d.indexOf(U) + 1, order: q });
      }
    }
  });
  var E = [];
  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 D = (l = e.state.models[0]) === null || l === void 0 ? void 0 : l.sourceData.data.dataItems, T = (I = 0, D.data.rowCount); I < T; I++) E.push("> ".concat(D.dataHeader.value(I), `
`).concat(D.data.value(I)));
  if (r) {
    var P = r(x, Array.from(C).map(function(O) {
      return O[1];
    })), M = (p = P.editedAtomList, v = P.editedBondList, Sm(p, v));
    return "".concat(M, `
`).concat(E.join(`

`)).concat(E.length ? `

` : "", "$$$$");
  }
  var R = Sm(x, Array.from(C).map(function(O) {
    return O[1];
  }));
  return "".concat(R, `
`).concat(E.join(`

`)).concat(E.length ? `

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

`)), r.push(bc.sprintf("%3d%3d  0  0  0  0  0  0  0  0999 V2000", e.length, t.length)), e.forEach(function(i) {
    var a = i.x, o = i.y, s = i.z, u = i.type_symbol, c = i.charge;
    r.push(bc.sprintf("%10.4f%10.4f%10.4f %-2s  0%3d  0  0  0  0  0  0  0  0  0  0", a, 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(i) {
    var a = i.a, o = i.b, s = i.order;
    r.push(bc.sprintf("%3s%3s%3s  0  0  0  0", a, o, s));
  }), r.push("M  END"), r.join(`
`);
}, gd = function(e, t, n, r) {
  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(n[0].toFixed(3)), y: parseFloat(n[1].toFixed(3)), z: parseFloat(n[2].toFixed(3)), occupancy: "1", B_iso_or_equiv: "0.00", type_symbol: t, charge: r ?? 0 };
}, FL = function(e, t) {
  var n = [], r = [], i = 1, a = "sdf", o = [], s = [], u = !1, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = e.sort(function(y) {
    var h;
    return ((h = ea(y)) === null || h === void 0 ? void 0 : h.sourceData.kind) === "mmCIF" ? -1 : 1;
  });
  d.forEach(function(y, h) {
    var g;
    y && ((g = ea(y)) === null || g === void 0 ? void 0 : g.sourceData.kind) === "mmCIF" && Array.from(ea(y).properties.structAsymMap.keys()).forEach(function(x) {
      l.set("".concat(h, `
`).concat(x), x), c.has(x) && (u = !0), c.add(x);
    });
  });
  var m = "", p = 1;
  if (l.size > 35) return { format: "pdb", type: lf.PDB, content: "" };
  if (u) c.clear(), Array.from(l.keys()).forEach(function(y, h) {
    var g = 65 + h > 90 ? String.fromCharCode(65 + h) : "".concat(h);
    l.set(y, g), h === l.size - 1 && (m = 65 + h + 1 > 90 ? String.fromCharCode(65 + h + 1) : "".concat(h));
  });
  else {
    for (var v = 65; v < 91 && m === ""; v++) {
      var f = String.fromCharCode(v);
      c.has(f) || (m = f);
    }
    for (v = 48; v < 58 && m === ""; v++)
      f = String.fromCharCode(v), c.has(f) || (m = f);
  }
  return d.forEach(function(y, h) {
    var g;
    if (y) if (((g = ea(y)) === null || g === void 0 ? void 0 : g.sourceData.kind) === "mmCIF") {
      var x = [], C = x3(y, ["HEADER"]);
      x.push.apply(x, C);
      var b = $i(y), _ = y.units[0], A = [];
      b.forEach(function(P) {
        var M, R = _.model.atomicHierarchy.chains.auth_asym_id.value(_.chainIndex[P]), O = { elementId: i, atom_id: "".concat(i), group_PDB: _.model.atomicHierarchy.residues.group_PDB.value(_.residueIndex[P]), auth_atom_id: _.model.atomicHierarchy.atoms.auth_atom_id.value(P), label_alt_id: _.model.atomicHierarchy.atoms.label_alt_id.value(P), auth_comp_id: _.model.atomicHierarchy.atoms.label_comp_id.value(P), auth_asym_id: (M = l.get("".concat(h, `
`).concat(R))) !== null && M !== void 0 ? M : R, auth_seq_id: _.model.atomicHierarchy.residues.auth_seq_id.value(_.residueIndex[P]), pdbx_PDB_ins_code: _.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(_.residueIndex[P]), x: _.model.atomicConformation.x[P], y: _.model.atomicConformation.y[P], z: _.model.atomicConformation.z[P], occupancy: _.model.atomicConformation.occupancy.value(P), B_iso_or_equiv: _.model.atomicConformation.B_iso_or_equiv.value(P), type_symbol: Ef(_.model.atomicHierarchy.atoms.type_symbol.value(P)), charge: _.model.atomicHierarchy.atoms.pdbx_formal_charge.value(P) };
        A.push(O), i++;
      });
      var I = /* @__PURE__ */ new Map();
      y.units.forEach(function(P) {
        for (var M = 0, R = P.bonds.a.length; M < R; M++) {
          var O = P.elements[P.bonds.a[M]], L = P.elements[P.bonds.b[M]];
          if (b.includes(O) && b.includes(L) && !I.has("".concat(O, "_").concat(L)) && !I.has("".concat(L, "_").concat(O))) {
            var F = P.bonds.edgeProps.order[M];
            I.set("".concat(O, "_").concat(L), { a: A[b.indexOf(O)].elementId, b: A[b.indexOf(L)].elementId, order: F, atom_idA: A[b.indexOf(O)].atom_id, atom_idB: A[b.indexOf(O)].atom_id });
          }
        }
      }), n.push.apply(n, A), r.push.apply(r, Array.from(I).map(function(P) {
        return P[1];
      })), a = "pdb";
    } else {
      var w = $i(y), E = y.units[0], D = [], T = /* @__PURE__ */ new Map();
      w.forEach(function(P) {
        var M;
        D.push({ elementId: i, group_PDB: "HETATM", atom_id: "".concat(i), auth_atom_id: E.model.atomicHierarchy.atoms.label_atom_id.value(P), label_alt_id: E.model.atomicHierarchy.atoms.label_alt_id.value(P), auth_comp_id: E.model.atomicHierarchy.atoms.label_comp_id.value(P), auth_asym_id: m, auth_seq_id: "".concat(p), pdbx_PDB_ins_code: E.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(E.residueIndex[P]), x: E.model.atomicConformation.x[P], y: E.model.atomicConformation.y[P], z: E.model.atomicConformation.z[P], occupancy: E.model.atomicConformation.occupancy.value(P), B_iso_or_equiv: E.model.atomicConformation.B_iso_or_equiv.value(P), type_symbol: Ef(E.model.atomicHierarchy.atoms.type_symbol.value(P)), charge: E.model.atomicHierarchy.atoms.pdbx_formal_charge.value(P) || ((M = Ss.Provider.get(E.model)) === null || M === void 0 ? void 0 : M.data.value(P)) || 0 }), i++;
      }), y.units.forEach(function(P) {
        for (var M = 0, R = P.bonds.a.length; M < R; M++) {
          var O = P.elements[P.bonds.a[M]], L = P.elements[P.bonds.b[M]];
          if (w.includes(O) && w.includes(L) && !T.has("".concat(O, "_").concat(L)) && !T.has("".concat(L, "_").concat(O))) {
            var F = P.bonds.edgeProps.order[M];
            T.set("".concat(O, "_").concat(L), { a: D[w.indexOf(O)].elementId, b: D[w.indexOf(L)].elementId, order: F, atom_idA: D[w.indexOf(O)].atom_id, atom_idB: D[w.indexOf(O)].atom_id });
          }
        }
      }), p++, s.push.apply(s, D), r.push.apply(r, Array.from(T).map(function(P) {
        return P[1];
      }));
    }
  }), o.length === 2 && r.push({ a: o[0], b: o[1], order: 1, atom_idA: "".concat(o[0]), atom_idB: "".concat(o[1]) }), n.push.apply(n, s), a === "pdb" ? { format: "pdb", type: lf.PDB, content: n.length > 99999 ? "" : Yv(n, r, !1, !1) } : { format: "sdf", type: lf.SDF, content: n.length > 999 || r.length > 999 ? "" : "".concat(Sm(n, r), `
$$$$`) };
}, GL = function(e, t) {
  switch (t) {
    case Nt.Pdb:
      return VL(e);
    case Nt.Sdf:
    case Nt.Mol:
      return gS(e);
    default:
      return [e];
  }
}, VL = function(e) {
  var t = e.split(`
`), n = [], r = [[]], i = 0;
  t.forEach(function(s) {
    switch (s[0]) {
      case "A":
        if (s.startsWith("ATOM")) return void r[i].push(s);
        if (s.startsWith("AUTHER")) return;
        n.push(s);
        break;
      case "C":
        if (s.startsWith("CONECT")) return void r[i].push(s);
        n.push(s);
        break;
      case "E":
        if (s.startsWith("ENDMDL")) return void (r[i].length > 0 && (i++, r.push([])));
        if (s.startsWith("END")) return;
        n.push(s);
        break;
      case "H":
        if (s.startsWith("HETATM")) return void r[i].push(s);
        n.push(s);
        break;
      case "M":
        if (s.startsWith("MODEL")) return void (r[i].length > 0 && (i++, r.push([])));
        if (s.startsWith("MASTER")) return;
        n.push(s);
        break;
      case "R":
        if (s.startsWith("REVDAT")) return;
        n.push(s);
        break;
      case "S":
        if (s.startsWith("SOURCE")) return;
        n.push(s);
        break;
      case "T":
        if (s.startsWith("TER")) return void r[i].push(s);
        n.push(s);
        break;
      default:
        n.push(s);
    }
  });
  var a = n.join(`
`), o = [];
  return r.forEach(function(s) {
    s.length > 0 && o.push("".concat(a).concat(a ? `
` : "").concat(s.join(`
`)));
  }), o;
}, gS = function(e) {
  return e.replace(/\u001a/g, " ").split(/\$\$\$\$\r?\n?/).filter(function(t) {
    return !!t.trim();
  });
}, zL = function(e) {
  for (var t = e.split(`
`), n = !0, r = !1, i = [], a = [], o = 0, s = t.length; o < s; o++) {
    var u = t[o];
    if (n) {
      if (i.length < 4)
        i.push(u), i.length === 4 && (c = wh(u, iL)).length > 0 && a.push({ index: o, info: c });
      else if (u.startsWith("M  END")) r = !0, n = !1, i = [];
      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 = wh(u, rL)).length > 0 && a.push({ index: o, info: c }) : (c = wh(u, nL)).length > 0 && a.push({ index: o, info: c });
        }
      }
    } else u.startsWith("$$$$") && (n = !0, i = []);
  }
  return r || a.push({ index: 0, info: [{ start: 0, end: 0 }] }), a;
}, UL = function(e, t) {
  switch (t) {
    case Nt.Sdf:
    case Nt.Mol:
      return zL(e);
    default:
      return [];
  }
}, HL = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s, u, c, l;
    return ne(this, function(d) {
      switch (d.label) {
        case 0:
          if (!e.trim()) return [2, [Go()]];
          t = [], n = gS(e), r = 0, i = n, d.label = 1;
        case 1:
          return r < i.length ? [4, kL(i[r]).run()] : [3, 7];
        case 2:
          if ((a = d.sent()).isError) throw a;
          o = 0, s = a.result.compounds, d.label = 3;
        case 3:
          return o < s.length ? (u = s[o], [4, (m = u, At.create("Parse SDF", function(p) {
            return vS(m.molFile, Xv.create(m), p);
          })).run()]) : [3, 6];
        case 4:
          c = d.sent(), l = Be.ofModel(c.representative), t.push(l), d.label = 5;
        case 5:
          return o++, [3, 3];
        case 6:
          return r++, [3, 1];
        case 7:
          return [2, t];
      }
      var m;
    });
  });
} };
function qL(e) {
  return function(t, n, r) {
    return function(i, a, o, s) {
      var u = i.data, c = i.indices, l = i.count, d = s.valueType, m = d === "str" ? function(p) {
        var v = c[2 * p] + a, f = c[2 * p + 1];
        if (v >= f) return "";
        var y = v + o;
        return y > f && (y = f), function(h, g, x) {
          for (var C = g, b = x - 1, _ = h.charCodeAt(C); (_ === 9 || _ === 32) && C <= b; ) _ = h.charCodeAt(++C);
          for (_ = h.charCodeAt(b); (_ === 9 || _ === 32) && b >= C; ) _ = h.charCodeAt(--b);
          return h.substring(C, b + 1);
        }(u, v, y);
      } : d === "int" ? function(p) {
        var v = c[2 * p] + a;
        return v > c[2 * p + 1] ? 0 : ec(u, v, v + o);
      } : function(p) {
        var v = c[2 * p] + a;
        return v > c[2 * p + 1] ? 0 : function(f, y, h) {
          for (; y < h && f.charCodeAt(y) === 32; ) y++;
          return fc(f, y, h);
        }(u, v, v + o);
      };
      return { schema: s, __array: void 0, isDefined: !0, rowCount: l, value: m, valueKind: function(p) {
        return 0;
      }, toArray: function(p) {
        return Nr(l, m, p);
      }, areValuesEqual: function(p, v) {
        return m(p) === m(v);
      } };
    }(e, t, n, r);
  };
}
function jL(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s, u, c, l, d;
    return ne(this, function(m) {
      switch (m.label) {
        case 0:
          return t = e.tokenizer, n = e.numberOfAtoms, [4, Le.readLinesAsync(t, n, e.runtimeCtx, 1e5)];
        case 1:
          return r = m.sent(), i = t.data.substring(r.indices[0], r.indices[1]).substring(20), a = i.match(/\.\d+/g), o = a.length === 6, e.header.hasVelocities = o, e.header.precision.position = a[0].length - 1, e.header.precision.velocity = o ? a[3].length - 1 : 0, s = e.header.precision.position + 5, u = 20 + 3 * s, c = e.header.precision.velocity + 4, l = qL(r), d = X.Undefined(e.numberOfAtoms, X.Schema.float), [2, { count: e.numberOfAtoms, residueNumber: l(0, 5, X.Schema.int), residueName: l(5, 5, X.Schema.str), atomName: l(10, 5, X.Schema.str), atomNumber: l(15, 5, X.Schema.int), x: l(20, s, X.Schema.float), y: l(20 + s, s, X.Schema.float), z: l(20 + 2 * s, s, X.Schema.float), vx: o ? l(u, c, X.Schema.float) : d, vy: o ? l(u + c, c, X.Schema.float) : d, vz: o ? l(u + 2 * c, c, X.Schema.float) : d }];
      }
    });
  });
}
function KL(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          return n = Le(e), [4, t.update({ message: "Parsing...", current: 0, max: e.length })];
        case 1:
          s.sent(), r = [], s.label = 2;
        case 2:
          return n.position < e.length ? (i = /* @__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 };
          }(n, t), function(u) {
            var c = u.tokenizer, l = u.header, d = Le.readLine(c);
            d.trim().length === 0 && (d = Le.readLine(c));
            var m = d.lastIndexOf("t=");
            m >= 0 ? (l.timeInPs = parseFloat(d.substring(m + 2)), l.title = d.substring(0, m).trim(), l.title && l.title[l.title.length - 1] === "," && (l.title = l.title.substring(0, l.title.length - 1))) : l.title = d;
          }(i), function(u) {
            var c = u.tokenizer;
            Le.markLine(c);
            var l = Le.getTokenString(c);
            u.numberOfAtoms = parseInt(l);
          }(i), [4, jL(i)]) : [3, 4];
        case 3:
          return a = s.sent(), function(u) {
            var c = u.tokenizer, l = Le.readLine(c).trim().split(/\s+/g);
            u.header.box = [+l[0], +l[1], +l[2]];
          }(i), r.push({ header: i.header, atoms: a }), [3, 2];
        case 4:
          return o = { structures: r }, [2, _r.success(o)];
      }
    });
  });
}
function yS(e) {
  var t = this;
  return At.create("Parse GRO", function(n) {
    return ie(t, 0, void 0, function() {
      return ne(this, function(r) {
        switch (r.label) {
          case 0:
            return [4, KL(e, n)];
          case 1:
            return [2, r.sent()];
        }
      });
    });
  });
}
var s_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", Zv, XL = W9(function(e) {
  for (var t = e, n = 0, r = s_[t % 26]; t >= 26; ) t = Math.floor(t / 26), r += s_[t % 26], n += 1;
  return n >= 5 && console.warn("getChainId overflow"), r;
});
function bS(e) {
  var t = this;
  return At.create("Parse GRO", function(n) {
    return ie(t, 0, void 0, function() {
      var r, i, a, o, s, u;
      return ne(this, function(c) {
        switch (c.label) {
          case 0:
            r = Zv.fromGro(e), i = [], a = 0, o = e.structures.length, c.label = 1;
          case 1:
            return a < o ? (s = function(l, d) {
              for (var m = l.atomName, p = l.residueName, v = new Array(l.count), f = new Array(l.count), y = new Uint32Array(l.count), h = new Uint32Array(l.count), g = new Array(l.count), x = new Oc(), C = new kc(l.residueNumber, l.atomName), b = "", _ = 0, A = "", I = 0, w = 0, E = -1, D = 0, T = l.count; D < T; ++D) {
                var P = l.residueNumber.value(D);
                if (P !== E) {
                  var M = l.residueName.value(D), R = Ff(C.add(M, D).type, M);
                  R === w && (P === E + 1 || E === 99999 && P === 0) || (A = XL(_), _ += 1, I = 0), b = x.getEntityId(M, R, A), I += 1, E = P, w = R;
                }
                v[D] = b, f[D] = A, y[D] = I, h[D] = D, g[D] = g3(l.atomName.value(D), l.residueName.value(D));
              }
              var O = X.ofStringArray(f), L = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: O, auth_atom_id: m, auth_comp_id: p, auth_seq_id: l.residueNumber, Cartn_x: X.ofFloatArray(X.mapToArray(l.x, function(F) {
                return 10 * F;
              }, Float32Array)), Cartn_y: X.ofFloatArray(X.mapToArray(l.y, function(F) {
                return 10 * F;
              }, Float32Array)), Cartn_z: X.ofFloatArray(X.mapToArray(l.z, function(F) {
                return 10 * F;
              }, Float32Array)), id: X.ofIntArray(h), label_asym_id: O, label_atom_id: m, label_comp_id: p, label_seq_id: X.ofIntArray(y), label_entity_id: X.ofStringArray(v), occupancy: X.ofConst(1, l.count, X.Schema.float), type_symbol: X.ofStringArray(g), pdbx_PDB_model_num: X.ofConst(d, l.count, X.Schema.int) }, l.count);
              return Bu({ entity: x.getEntityTable(), chem_comp: C.getChemCompTable(), atom_site: L });
            }(e.structures[a].atoms, a + 1), [4, Ps(s, r, n)]) : [3, 4];
          case 2:
            (u = c.sent()).frameCount === 1 && i.push(u.representative), c.label = 3;
          case 3:
            return ++a, [3, 1];
          case 4:
            return [2, new bf(i)];
        }
      });
    });
  });
}
(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 };
  };
})(Zv || (Zv = {}));
var Bi, YL = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, yS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, bS(t.result).run()];
        case 2:
          return [2, n.sent().representative];
      }
    });
  });
} }, nl = 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]), Mh = 9;
function WL() {
  throw new Error("(xdrfile error) Undefined error.");
}
function ZL(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L, F;
    return ne(this, function(G) {
      switch (G.label) {
        case 0:
          n = new DataView(t.buffer, t.byteOffset), i = (r = { frames: [], boxes: [], times: [], timeOffset: 0, deltaTime: 0 }).frames, a = r.boxes, o = r.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], m = [0.1, 0.1, 0.1], p = 0, v = Bi.buf, G.label = 1;
        case 1:
          for (f = void 0, y = n.getInt32(p + 4), p += 12, o.push(n.getFloat32(p)), p += 4, h = new Float32Array(9), P = 0; P < 9; ++P) h[P] = 10 * n.getFloat32(p), p += 4;
          if (a.push(h), y <= 9) for (f = { count: y / 3, x: new Float32Array(y / 3), y: new Float32Array(y / 3), z: new Float32Array(y / 3) }, P = 0; P < y / 3; ++P) f.x[P] = n.getFloat32(p), f.y[P] = n.getFloat32(p), f.z[P] = n.getFloat32(p), p += 4;
          else {
            for (v[0] = v[1] = v[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, m[0] = m[1] = m[2] = 0, f = { count: y, x: new Float32Array(y), y: new Float32Array(y), z: new Float32Array(y) }, g = 0, x = n.getInt32(p), p += 4, C = n.getFloat32(p), p += 4, s[0] = n.getInt32(p), s[1] = n.getInt32(p + 4), s[2] = n.getInt32(p + 8), s[3] = n.getInt32(p + 12), s[4] = n.getInt32(p + 16), s[5] = n.getInt32(p + 20), u[0] = s[3] - s[0] + 1, u[1] = s[4] - s[1] + 1, u[2] = s[5] - s[2] + 1, p += 24, b = void 0, (u[0] | u[1] | u[2]) > 16777215 ? (c[0] = Bi.sizeOfInt(u[0]), c[1] = Bi.sizeOfInt(u[1]), c[2] = Bi.sizeOfInt(u[2]), b = 0) : b = Bi.sizeOfInts(3, u), _ = n.getInt32(p), p += 4, I = nl[A = Mh > (A = _ - 1) ? Mh : A] / 2 | 0, w = nl[_] / 2 | 0, l[0] = l[1] = l[2] = nl[_], E = 4 * Math.ceil(n.getInt32(p) / 4), p += 4, D = 1 / C, T = 0, P = 0, d[0] = d[1] = d[2] = 0; P < x; ) {
              if (b === 0 ? (d[0] = Bi.decodeBits(t, p, c[0]), d[1] = Bi.decodeBits(t, p, c[1]), d[2] = Bi.decodeBits(t, p, c[2])) : Bi.decodeInts(t, p, b, u, d), P++, d[0] += s[0], d[1] += s[1], d[2] += s[2], m[0] = d[0], m[1] = d[1], m[2] = d[2], M = Bi.decodeBits(t, p, 1), R = 0, M === 1 && (T = Bi.decodeBits(t, p, 5), T -= R = T % 3, R--), T > 0) for (d[0] = d[1] = d[2] = 0, O = 0; O < T; O += 3) Bi.decodeInts(t, p, _, l, d), P++, d[0] += m[0] - w, d[1] += m[1] - w, d[2] += m[2] - w, O === 0 ? (L = d[0], d[0] = m[0], m[0] = L, L = d[1], d[1] = m[1], m[1] = L, L = d[2], d[2] = m[2], m[2] = L, f.x[g] = m[0] * D, f.y[g] = m[1] * D, f.z[g] = m[2] * D, g++) : (m[0] = d[0], m[1] = d[1], m[2] = d[2]), f.x[g] = d[0] * D, f.y[g] = d[1] * D, f.z[g] = d[2] * D, g++;
              else f.x[g] = d[0] * D, f.y[g] = d[1] * D, f.z[g] = d[2] * D, g++;
              _ += R, R < 0 ? (w = I, I = _ > Mh ? nl[_ - 1] / 2 | 0 : 0) : R > 0 && (I = w, w = nl[_] / 2 | 0), l[0] = l[1] = l[2] = nl[_], l[0] !== 0 && l[1] !== 0 && l[2] !== 0 || WL();
            }
            p += E;
          }
          for (F = 0; F < y; F++) f.x[F] *= 10, f.y[F] *= 10, f.z[F] *= 10;
          return i.push(f), e.shouldUpdate ? [4, e.update({ current: p, max: t.length })] : [3, 3];
        case 2:
          G.sent(), G.label = 3;
        case 3:
          return p >= t.length ? [3, 4] : [3, 1];
        case 4:
          return o.length >= 1 && (r.timeOffset = o[0]), o.length >= 2 && (r.deltaTime = o[1] - o[0]), [2, r];
      }
    });
  });
}
function QL(e) {
  var t = this;
  return At.create("Parse XTC", function(n) {
    return ie(t, 0, void 0, function() {
      var r, i;
      return ne(this, function(a) {
        switch (a.label) {
          case 0:
            return a.trys.push([0, 2, , 3]), n.update({ canAbort: !0, message: "Parsing trajectory..." }), [4, ZL(n, e)];
          case 1:
            return r = a.sent(), [2, _r.success(r)];
          case 2:
            return i = a.sent(), [2, _r.error("" + i)];
          case 3:
            return [2];
        }
      });
    });
  });
}
function p0() {
  return p0.empty();
}
function JL(e) {
  var t = this;
  return At.create("Parse XTC", function(n) {
    return ie(t, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d;
      return ne(this, function(m) {
        switch (m.label) {
          case 0:
            return [4, n.update("Converting to coordinates")];
          case 1:
            for (m.sent(), r = fp(e.deltaTime, "step"), i = fp(e.timeOffset, r.unit), a = [], o = 0, s = e.frames.length; o < s; ++o) u = e.boxes[o], c = S.fromArray(S(), u, 0), l = S.fromArray(S(), u, 3), d = S.fromArray(S(), u, 6), a.push({ elementCount: e.frames[o].count, cell: p0.fromBasis(c, l, d), x: e.frames[o].x, y: e.frames[o].y, z: e.frames[o].z, xyzOrdering: { isIdentity: !0 }, time: fp(i.value + r.value * o, r.unit) });
            return [2, Gm.create(a, r, i)];
        }
      });
    });
  });
}
(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 m = void 0, p = 0;
      for (m = 0; m < c; m++) p += t[m] * u[d], t[m] = 255 & p, p >>= 8;
      for (; p !== 0; ) t[m++] = 255 & p, p >>= 8;
      c = m;
    }
    var v = 1;
    for (c--; t[c] >= v; ) l++, v *= 2;
    return l + 8 * c;
  };
  var n = new ArrayBuffer(24);
  e.buf = new Int32Array(n);
  var r = new Uint32Array(n);
  function i(s, u, c) {
    for (var l = c, d = (1 << l) - 1, m = r[1], p = r[2], v = e.buf[0], f = 0; l >= 8; ) f |= (p = p << 8 | s[u + v++]) >> m << l - 8, l -= 8;
    return l > 0 && (m < l && (m += 8, p = p << 8 | s[u + v++]), f |= p >> (m -= l) & (1 << l) - 1), f &= d, e.buf[0] = v, e.buf[1] = m, e.buf[2] = p, f;
  }
  function a(s, u) {
    var c = r[2], l = e.buf[0];
    return c = c << 8 | s[u + l], e.buf[0] = l + 1, e.buf[2] = c, c >> r[1] & 255;
  }
  e.decodeBits = i;
  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 m = c, p = 0;
    for (o[0] = 0, o[1] = 0, o[2] = 0, o[3] = 0; m > 8; ) o[p++] = a(s, u), m -= 8;
    m > 0 && (o[p++] = i(s, u, m));
    for (var v = 2; v > 0; v--) {
      for (var f = 0, y = l[v], h = p - 1; h >= 0; h--) {
        var g = (f = f << 8 | o[h]) / y | 0;
        o[h] = g, f -= g * y;
      }
      d[v] = f;
    }
    d[0] = o[0] | o[1] << 8 | o[2] << 16 | o[3] << 24;
  };
})(Bi || (Bi = {})), function(e) {
  function t(r, i) {
    return { size: r, anglesInRadians: i };
  }
  function n() {
    return t(S(), S());
  }
  e.create = t, e.empty = n, e.fromBasis = function(r, i, a) {
    var o = S.magnitude(r), s = S.magnitude(i), u = S.magnitude(a), c = Math.acos(S.dot(i, a) / (s * u)), l = Math.acos(S.dot(r, a) / (o * u)), d = Math.acos(S.dot(r, i) / (o * s));
    return o <= 0 || s <= 0 || u <= 0 || c >= Math.PI || l >= Math.PI || d >= Math.PI ? n() : t(S.create(o, s, u), S.create(c, l, d));
  };
}(p0 || (p0 = {}));
var $L = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(t) {
      return [2, new Promise(function(n) {
        var r = new FileReader();
        r.onload = function(i) {
          return ie(this, 0, void 0, function() {
            var a, o;
            return ne(this, function(s) {
              switch (s.label) {
                case 0:
                  return [4, QL(new Uint8Array(r.result)).run()];
                case 1:
                  if ((a = s.sent()).isError) throw new Error(a.message);
                  return [4, JL(a.result).run()];
                case 2:
                  return o = s.sent(), n(o), [2];
              }
            });
          });
        }, r.readAsArrayBuffer(e);
      })];
    });
  });
} };
function _S(e, t, n, r, i, a) {
  var o = e, s = t, u = n, c = Math.cos(r * Math.PI / 180), l = Math.cos(i * Math.PI / 180), d = Math.cos(a * Math.PI / 180), m = Math.sin(r * Math.PI / 180), p = Math.sin(i * Math.PI / 180), v = function() {
    var b = (c * l - d) / (m * p);
    return Math.max(Math.min(b, 1), -1);
  }(), f = Math.acos(v), y = J.ofRows([[o * p, -s * m * Math.cos(f), 0, 0], [0, s * m * Math.sin(f), 0, 0], [o * l, s * c, u, 0], [0, 0, 0, 1]]), h = J.invert(J.zero(), y), g = S.create(y[0], y[4], y[8]), x = S.create(y[1], y[5], y[9]), C = S.create(y[2], y[6], y[10]);
  return { a: e, b: t, c: n, volume: Math.abs(S.dot(g, g)) * n, alpha: r, beta: i, gamma: a, vecA: g, vecB: x, vecC: C, matrix: y, invertMatrix: h };
}
function xS(e, t, n) {
  var r = S.create.apply(null, e), i = S.create.apply(null, t), a = S.create.apply(null, n), o = r[0], s = r[1], u = r[2], c = i[0], l = i[1], d = i[2], m = a[0], p = a[1], v = a[2], f = J.ofRows([[o, c, m, 0], [s, l, p, 0], [u, d, v, 0], [0, 0, 0, 1]]), y = J.invert(J.zero(), f), h = Math.sqrt(Math.abs(S.dot(r, r))), g = Math.sqrt(Math.abs(S.dot(i, i))), x = Math.sqrt(Math.abs(S.dot(a, a))), C = S.angle(i, a) * (180 / Math.PI), b = S.angle(r, a) * (180 / Math.PI), _ = S.angle(r, i) * (180 / Math.PI);
  return { a: h, b: g, c: x, volume: Math.abs(S.dot(r, r)) * x, alpha: C, beta: b, gamma: _, vecA: r, vecB: i, vecC: a, matrix: f, invertMatrix: y };
}
var h0, SS = [];
function eF(e) {
  Le.readLine(e);
  var t = +Le.readLine(e);
  Le.readLine(e);
  var n = +Le.readLine(e);
  isNaN(n) && (n = 0);
  var r = Le.readLine(e), i = new Float64Array(3), a = new Float64Array(3), o = new Float64Array(3);
  r.includes("xy xz yz") && function(b, _) {
    var A = _[0], I = _[1], w = _[2], E = _.map(function() {
      return Le.readLine(b).trim().split(/\s+/g).map(function(ee) {
        return Number(ee);
      });
    }), D = E[0], T = D[0], P = D[1], M = D[2], R = E[1], O = R[0], L = R[1], F = R[2], G = E[2], V = G[0], U = G[1], q = G[2], H = [[T, P], [O, L], [V, U]], K = [M, F, q], j = [0, K[0], K[1], K[0] + K[1]], W = [0, K[2]], Z = [[Math.min.apply(null, j), Math.max.apply(null, j)], [Math.min.apply(null, W), Math.max.apply(null, W)], [0, 0]];
    H.forEach(function(ee, $) {
      ee.forEach(function(ue, se) {
        H[$][se] = ue - Z[$][se];
      });
    });
    var Y = H.map(function(ee) {
      return ee[1] - ee[0];
    }), te = [[Y[0], 0, 0], [K[0], Y[1], 0], [K[1], K[2], Y[2]]];
    A[0] = te[0][0], A[1] = te[0][1], A[2] = te[0][2], I[0] = te[1][0], I[1] = te[1][1], I[2] = te[1][2], w[0] = te[2][0], w[1] = te[2][1], w[2] = te[2][2];
  }(e, [i, a, o]);
  var s = function(b, _, A) {
    var I = new Float64Array(_), w = new Float64Array(_), E = new Float64Array(_), D = new Float64Array(_), T = new Float64Array(_), P = [["id", I], ["type", w], ["x", E], ["y", D], ["z", T]];
    P.sort(function(L, F) {
      return A.indexOf(L[0]) - A.indexOf(F[0]);
    });
    for (var M = P.map(function(L) {
      return L[1];
    }), R = function(L) {
      Le.readLine(b).trim().split(/\s+/g).forEach(function(F, G) {
        M[G][L] = Number(F);
      });
    }, O = 0; O < _; O++) R(O);
    return [I, w, E, D, T];
  }(e, n, Le.readLine(e).replace("ITEM: ATOMS", "").split(/\s+/g)), u = s[0], c = s[1], l = s[2], d = s[3], m = s[4], p = [], v = [];
  c.forEach(function(b) {
    p[b] || (p[b] = SS[b].symbol), v.push(p[b]);
  });
  for (var f = xS(i, a, o), y = new Float64Array(n), h = new Float64Array(n), g = new Float64Array(n), x = 0; x < n; x++) {
    var C = S.create(l[x], d[x], m[x]);
    S.transformMat4(C, C, f.invertMatrix), y[x] = C[0], h[x] = C[1], g[x] = C[2];
  }
  return { count: n, comment: "", x: X.ofFloatArray(l), y: X.ofFloatArray(d), z: X.ofFloatArray(m), type_symbol: X.ofStringArray(v), cell: f, timestep: t, fractX: X.ofFloatArray(y), fractY: X.ofFloatArray(h), fractZ: X.ofFloatArray(g), id: X.ofFloatArray(u) };
}
function tF(e) {
  for (var t = Le(e), n = []; ; ) {
    var r = eF(t);
    if (r.count === 0) break;
    n.push(r);
  }
  var i = { molecules: n, isMaterial: !0 };
  return _r.success(i);
}
function C3(e) {
  var t = this;
  return At.create("Parse Mol", function() {
    return ie(t, 0, void 0, function() {
      var n;
      return ne(this, function(r) {
        return n = function(i) {
          var a = i.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(L) {
              return L.includes("ITEM: BOX BOUNDS");
            });
            o.splice(s, 1, "ITEM: BOX BOUNDS xy xz yz pp pp pp");
            var u = o.findIndex(function(L) {
              return L.includes("ITEM: ATOMS");
            }), c = o[u].includes("xs") || o[u].includes("xsu"), l = o[s + 1], d = o[s + 2], m = o[s + 3], p = l.split(" ").map(function(L) {
              return +L;
            }), v = p[0], f = p[1], y = p[2], h = y === void 0 ? 0 : y, g = d.split(" ").map(function(L) {
              return +L;
            }), x = g[0], C = g[1], b = g[2], _ = b === void 0 ? 0 : b, A = m.split(" ").map(function(L) {
              return +L;
            }), I = A[0], w = A[1], E = A[2], D = E === void 0 ? 0 : E;
            if (c) {
              var T = [[f - v - Math.abs(h) - Math.abs(_), 0, 0], [h, C - x - Math.abs(D), 0], [_, D, w - I]], P = o.slice(u + 1).map(function(L) {
                return L.split(" ");
              }).map(function(L) {
                var F = L[0], G = L[1], V = function(U, q) {
                  for (var H = [], K = 0; K < U.length; K++) {
                    H[K] = [];
                    for (var j = 0; j < q[0].length; j++) {
                      for (var W = 0, Z = 0; Z < U[0].length; Z++) W += +U[K][Z] * +q[Z][j];
                      H[K][j] = W;
                    }
                  }
                  return H;
                }([[L[2], L[3], L[4]]], T)[0];
                return [F, G, V[0], V[1], V[2]];
              }), M = P.map(function(L) {
                return L.join(" ");
              }).join(`
`);
              return [o.slice(0, s + 4).join(`
`), O = "ITEM: ATOMS id type x y z", M].join(`
`);
            }
            var R = [[v, f, h], [x, C, _], [I, w, D]].map(function(L) {
              return L.join(" ");
            });
            o.splice.apply(o, Pe([s + 1, 3], R, !1)), M = (P = o.slice(u + 1).map(function(L) {
              return L.split(" ");
            }).map(function(L) {
              return [L[0], L[1], L[2], L[3], L[4]];
            })).map(function(L) {
              return L.join(" ");
            }).join(`
`);
            var O = "ITEM: ATOMS id type x y z";
            return [o.slice(0, s + 4).join(`
`), O, M].join(`
`);
          });
          return a.join(`
`);
        }(e), [2, tF(n)];
      });
    });
  });
}
function nF(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O;
    return ne(this, function(L) {
      switch (L.label) {
        case 0:
          for (n = h0.formatMol(e), r = n.molecules, i = 0, a = 0, o = r; a < o.length; a++) f = o[a], i += f.count;
          for (s = new Array(i), u = new Int32Array(i), c = new Float32Array(i), l = new Float32Array(i), d = new Float32Array(i), m = new Int32Array(i), p = function(F) {
            if (F.length) {
              var G = F[0], V = G.cell, U = G.spaceGroup;
              if (V) {
                var q = V.a, H = V.b, K = V.c, j = V.alpha, W = V.beta, Z = V.gamma, Y = V.matrix, te = V.invertMatrix, ee = function(ue) {
                  if (!ue) return "P 1";
                  var se = ue.it_number.value(0), be = ue["name_h-m_full"].value(0).replace("-", " ");
                  return ue.it_number.isDefined ? (ue["name_h-m_full"].isDefined, se) : be;
                }(U), $ = Ma.createMaterial(ee, S.create(q, H, K), S.scale(S(), S.create(j, W, Z), Math.PI / 180), q * H * K, te, Y);
                return { spacegroup: ki.create($), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
              }
            }
          }(r), v = 0, O = 0; O < r.length; O++) for (f = r[O], y = 0; y < f.count; y++) s[v] = f.type_symbol.value(y), c[v] = f.x.value(y), l[v] = f.y.value(y), d[v] = f.z.value(y), u[v] = y, m[v] = O, v++;
          return h = X.ofConst("MOL", i, X.Schema.str), g = X.ofConst("A", i, X.Schema.str), x = X.ofConst(1, i, X.Schema.int), C = X.ofStringArray(s), b = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: g, auth_atom_id: C, auth_comp_id: h, auth_seq_id: x, Cartn_x: X.ofFloatArray(c), Cartn_y: X.ofFloatArray(l), Cartn_z: X.ofFloatArray(d), id: X.ofIntArray(u), label_asym_id: g, label_atom_id: C, label_comp_id: h, label_seq_id: x, label_entity_id: X.ofConst("1", i, X.Schema.str), occupancy: X.ofConst(1, i, X.Schema.float), type_symbol: C, pdbx_PDB_model_num: X.ofIntArray(m) }, i), (_ = new Oc()).setNames([["MOL", "Ligand"]]), _.getEntityId("MOL", 0, "A"), (A = new kc(x, C)).setNames([["MOL", "Unknown Molecule"]]), A.add("MOL", 0), [4, Ps(Bu({ entity: _.getEntityTable(), chem_comp: A.getChemCompTable(), atom_site: b }), h0.create(n), t)];
        case 1:
          if ((I = L.sent()).frameCount > 0 && (w = I.representative, Vr.Provider.set(w, p)), E = r[0], D = E.bonds) for (T = X.ofIntArray(D.atomA), P = X.ofIntArray(D.atomB), M = X.ofIntArray(new Array(D.count).fill(1)), R = gr.fromData({ pairs: { indexA: T, indexB: P, order: M }, count: E.count }), O = 0; O < I.frameCount; O++) gr.Provider.set(I.getFrameAtIndex(O), R);
          return [2, I];
      }
    });
  });
}
function Ru(e) {
  return At.create("Parse Material", function(t) {
    return nF(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], n = e[1];
  SS[n["Atomic no"]] = B(B({}, n), { 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 n = t.isMaterial, r = t.molecules;
    if (!n || r.length > 1 || !r[0].cell) return t;
    for (var i = r[0], a = i.cell, o = i.x, s = i.y, u = i.z, c = o.rowCount, l = new Float32Array(c), d = new Float32Array(c), m = new Float32Array(c), p = 0; p < c; p++) {
      var v = S.create(o.value(p), s.value(p), u.value(p)), f = S.transformMat4(S.zero(), v, a.invertMatrix);
      l[p] = f[0], d[p] = f[1], m[p] = f[2];
    }
    return { isMaterial: !0, molecules: [B(B({}, r[0]), { fractX: X.ofFloatArray(l), fractY: X.ofFloatArray(d), fractZ: X.ofFloatArray(m) })] };
  };
}(h0 || (h0 = {}));
var Qv, rF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, C3(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, Ru(t.result).run()];
        case 2:
          return [2, n.sent().frames.map(function(r) {
            return Be.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function iF(e) {
  var t = e.position >= e.data.length - 1 ? 0 : +Le.readLine(e);
  isNaN(t) && (t = 0);
  for (var n = Le.readLine(e), r = new Float64Array(t), i = new Float64Array(t), a = new Float64Array(t), o = new Array(t), s = 0; s < t; ++s) {
    var u = Le.readLineTrim(e).split(/\s+/g);
    o[s] = u[0], r[s] = +u[1], i[s] = +u[2], a[s] = +u[3];
  }
  return { count: t, comment: n, x: X.ofFloatArray(r), y: X.ofFloatArray(i), z: X.ofFloatArray(a), type_symbol: X.ofStringArray(o) };
}
function aF(e) {
  for (var t = Le(e), n = []; ; ) {
    var r = iF(t);
    if (r.count === 0) break;
    n.push(r);
  }
  var i = { molecules: n, isMaterial: !1 };
  return _r.success(i);
}
function CS(e) {
  var t = this;
  return At.create("Parse Mol", function() {
    return ie(t, 0, void 0, function() {
      return ne(this, function(n) {
        return [2, aF(e)];
      });
    });
  });
}
function AS(e) {
  return At.create("Parse XYZ", function(t) {
    return function(n, r) {
      for (var i = n.molecules, a = 0, o = 0, s = i; o < s.length; o++) a += (y = s[o]).count;
      for (var u = new Array(a), c = new Int32Array(a), l = new Float32Array(a), d = new Float32Array(a), m = new Float32Array(a), p = new Int32Array(a), v = 0, f = 0; f < i.length; f++) for (var y = i[f], h = 0; h < y.count; h++) u[v] = y.type_symbol.value(h), l[v] = y.x.value(h), d[v] = y.y.value(h), m[v] = y.z.value(h), c[v] = h, p[v] = f, v++;
      var g = X.ofConst("MOL", a, X.Schema.str), x = X.ofConst("A", a, X.Schema.str), C = X.ofConst(1, a, X.Schema.int), b = X.ofStringArray(u), _ = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: x, auth_atom_id: b, auth_comp_id: g, auth_seq_id: C, Cartn_x: X.ofFloatArray(l), Cartn_y: X.ofFloatArray(d), Cartn_z: X.ofFloatArray(m), id: X.ofIntArray(c), label_asym_id: x, label_atom_id: b, label_comp_id: g, label_seq_id: C, label_entity_id: X.ofConst("1", a, X.Schema.str), occupancy: X.ofConst(1, a, X.Schema.float), type_symbol: b, pdbx_PDB_model_num: X.ofIntArray(p) }, a), A = new Oc();
      A.setNames([["MOL", "Unknown Entity"]]), A.getEntityId("MOL", 0, "A");
      var I = new kc(C, b);
      return I.setNames([["MOL", "Unknown Molecule"]]), I.add("MOL", 0), Ps(Bu({ entity: A.getEntityTable(), chem_comp: I.getChemCompTable(), atom_site: _ }), Qv.create(n), r);
    }(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 };
  };
})(Qv || (Qv = {}));
var Kd, oF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, CS(e).run()] : [2, [Go()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, AS(t.result).run()];
        case 2:
          return n = r.sent(), [2, [Be.ofModel(n.representative, { dynamicBonds: !0 })]];
      }
    });
  });
} };
function sF(e, t, n) {
  var r;
  return ie(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L, F, G, V, U, q, H, K, j, W, Z, Y, te, ee, $, ue, se, be, ke, Oe, ze, je;
    return ne(this, function(xe) {
      switch (xe.label) {
        case 0:
          for (i = e.atom_site._rowCount, a = X.ofConst("MOL", i, X.Schema.str), o = X.ofConst("A", i, X.Schema.str), s = X.ofConst(1, i, X.Schema.int), u = function(Xe) {
            var Ee = Xe.cell, Ye = (le = Xe.space_group, Ce = le.it_number.value(0), Ae = le["name_h-m_full"].value(0).replace("-", " "), le.it_number.isDefined ? (le["name_h-m_full"].isDefined, Ce) : Ae), He = Ma.create(Ye, S.create(Ee.length_a.value(0), Ee.length_b.value(0), Ee.length_c.value(0)), S.scale(S(), S.create(Ee.angle_alpha.value(0), Ee.angle_beta.value(0), Ee.angle_gamma.value(0)), Math.PI / 180)), le, Ce, Ae;
            return { spacegroup: ki.create(He), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
          }(e), c = u.spacegroup.cell.fromFractional, l = e.atom_site, d = l.fract_x, m = l.fract_y, p = l.fract_z, v = new Float32Array(i), f = new Float32Array(i), y = new Float32Array(i), h = S(), be = 0; be < i; ++be) S.set(h, d.value(be), m.value(be), p.value(be)), S.transformMat4(h, h, c), v[be] = h[0], f[be] = h[1], y[be] = h[2];
          if (g = e.atom_site, x = g.type_symbol, C = g.label, x.isDefined) {
            for (E = new Array(i), A = new Int8Array(i), be = 0; be < i; ++be) I = x.value(be), w = I.length, I[w - 1] === "+" ? A[be] = parseInt(I[w - 2]) : I[w - 2] === "+" ? A[be] = parseInt(I[w - 1]) : I[w - 1] === "-" ? A[be] = -parseInt(I[w - 2]) : I[w - 2] === "-" ? A[be] = -parseInt(I[w - 1]) : (E[be] = I, A[be] = 0), I = (I = (I = I.replace(/\-/g, "")).replace(/\+/g, "")).replace(/[0-9]/g, ""), E[be] = I;
            b = X.ofStringArray(E), _ = X.ofIntArray(A);
          } else {
            for (E = new Array(i), be = 0; be < i; ++be) E[be] = g3(C.value(be), "");
            b = X.ofStringArray(E), _ = X.Undefined(i, X.Schema.int);
          }
          return D = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: o, auth_atom_id: C, auth_comp_id: a, auth_seq_id: s, Cartn_x: X.ofFloatArray(v), Cartn_y: X.ofFloatArray(f), Cartn_z: X.ofFloatArray(y), id: X.range(0, i - 1), label_asym_id: o, label_atom_id: C, label_comp_id: a, label_seq_id: s, label_entity_id: X.ofConst("1", i, X.Schema.str), occupancy: e.atom_site.occupancy.isDefined ? e.atom_site.occupancy : X.ofConst(1, i, X.Schema.float), type_symbol: b, pdbx_formal_charge: _, pdbx_PDB_model_num: X.ofConst(1, i, X.Schema.int), B_iso_or_equiv: e.atom_site.u_iso_or_equiv }, i), T = e.chemical.name_common.value(0) || e.chemical.name_systematic.value(0) || e.chemical_formula.sum.value(0), (P = new Oc()).setNames([["MOL", T || "Ligand"]]), P.getEntityId("MOL", 0, "A"), (M = new kc(s, e.atom_site.type_symbol)).setNames([["MOL", T || "Unknown Molecule"]]), M.add("MOL", 0), [4, Ps(Bu({ entity: P.getEntityTable(), chem_comp: M.getChemCompTable(), atom_site: D }), t, n)];
        case 1:
          if ((R = xe.sent()).frameCount > 0 && (O = R.representative, Vr.Provider.set(O, u), (L = e.geom_bond._rowCount) > 0)) {
            for (F = {}, G = e.atom_site.label, be = 0, V = G.rowCount; be < V; ++be) F[G.value(be)] = be;
            for (U = (r = t.data.frame.categories.ccdc_geom_bond_type) === null || r === void 0 ? void 0 : r.getField(""), q = [], H = [], K = [], j = [], W = [], Z = /* @__PURE__ */ new Set(), Y = 0, te = e.geom_bond, ee = te.atom_site_label_1, $ = te.atom_site_label_2, ue = te.valence, se = te.distance, be = 0; be < L; ++be) ke = F[ee.value(be)], Oe = F[$.value(be)], ze = ke < Oe ? Ta(ke, Oe) : Ta(Oe, ke), Z.has(ze) || (Z.add(ze), q[Y] = ke, H[Y] = Oe, j[Y] = se.value(be) || -1, U ? (je = U.str(be)) === "D" ? (K[Y] = 2, W[Y] = 1) : je === "A" ? (K[Y] = 1, W[Y] = 17) : (K[Y] = 1, W[Y] = 1) : (W[Y] = 1, K[Y] = ue.isDefined ? ue.value(be) : 1), Y += 1);
            gr.Provider.set(O, gr.fromData({ pairs: { indexA: X.ofIntArray(q), indexB: X.ofIntArray(H), order: X.ofIntArray(K), distance: X.ofFloatArray(j), flag: X.ofIntArray(W) }, count: i }));
          }
          return [2, R];
      }
    });
  });
}
function uF(e) {
  var t = Kd.fromFrame(e);
  return At.create("Parse CIF Core", function(n) {
    return sF(t.data.db, t, n);
  });
}
Su.Provider.formatRegistry.add("cifCore", function(e) {
  if (Kd.is(e.sourceData)) {
    var t = e.sourceData.data.db, n = t.atom_site, r = t.atom_site_aniso;
    return { data: Jt.ofPartialColumns(Su.Schema, { U: r.u }, r._rowCount), elementToAnsiotrop: Su.getElementToAnsiotropFromLabel(n.label, r.label) };
  }
}, function(e) {
  return !!Kd.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, n) {
    return n || (n = L9.cifCore(t)), { kind: "cifCore", name: n.database_code.depnum_ccdc_archive.value(0) || n.database_code.depnum_ccdc_fiz.value(0) || n.database_code.icsd.value(0) || n.database_code.mdf.value(0) || n.database_code.nbs.value(0) || n.database_code.csd.value(0) || n.database_code.cod.value(0) || n._name, data: { db: n, frame: t } };
  };
}(Kd || (Kd = {}));
var cF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s;
    return ne(this, function(u) {
      switch (u.label) {
        case 0:
          return e.trim() ? [4, N9(e).run()] : [2, [Go()]];
        case 1:
          if ((t = u.sent()).isError) throw t;
          n = 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 ? G9 : uF, r = [], i = 0, a = t.result.blocks.length, u.label = 2;
        case 2:
          return i < a ? (o = t.result.blocks[i], [4, n(o).run()]) : [3, 5];
        case 3:
          s = u.sent(), r.push(Be.ofModel(s.frames[0], { dynamicBonds: !0 })), u.label = 4;
        case 4:
          return i++, [3, 2];
        case 5:
          return [2, r];
      }
    });
  });
} }, u_ = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a;
    return ne(this, function(o) {
      switch (o.label) {
        case 0:
          return e.trim() ? [4, N9(e).run()] : [2, [Go()]];
        case 1:
          if ((t = o.sent()).isError) throw t;
          n = [], r = 0, i = t.result.blocks.length, o.label = 2;
        case 2:
          return r < i ? [4, G9(t.result.blocks[r]).run()] : [3, 5];
        case 3:
          a = o.sent(), n.push(Be.ofModel(a.frames[0], { dynamicBonds: !0 })), o.label = 4;
        case 4:
          return r++, [3, 2];
        case 5:
          return [2, n];
      }
    });
  });
} };
function lF(e) {
  var t = [], n = function(i) {
    var a = Le.readLine(i), o = +Le.readLine(i), s = new Float64Array(3), u = new Float64Array(3), c = new Float64Array(3);
    [s, u, c].forEach(function(R) {
      var O = Le.readLineTrim(i).trim().split(/\s+/g);
      R[0] = +O[0], R[1] = +O[1], R[2] = +O[2];
    });
    for (var l = xS(s, u, c), d = Le.readLineTrim(i).trim().split(/\s+/g), m = Le.readLineTrim(i).trim().split(/\s+/g), p = Le.readLineTrim(i), v = ["cartesian", "direct"].includes(p.toLowerCase()) ? "cartesian" : p, f = m.reduce(function(R, O) {
      return +R + +O;
    }, 0), y = new Float64Array(f), h = new Float64Array(f), g = new Float64Array(f), x = new Float64Array(f), C = new Float64Array(f), b = new Float64Array(f), _ = new Float64Array(f), A = new Float64Array(f), I = new Float64Array(f), w = new Array(f), E = function(R) {
      for (var O = R === 0 ? 0 : m.slice(0, R).reduce(function(V, U) {
        return +V + +U;
      }, 0), L = 0; L < Number(m[R]); L++) {
        var F = O + L, G = Le.readLineTrim(i).trim().split(/\s+/g);
        w[F] = d[R], _[F] = +G[0], A[F] = +G[1], I[F] = +G[2];
      }
    }, D = 0; D < m.length; D++) E(D);
    if (v === "cartesian") for (D = 0; D < f; D++) {
      y[D] = _[D], h[D] = A[D], g[D] = I[D];
      var T = S.create(y[D], h[D], g[D]), P = S.transformMat4(S.zero(), T, l.invertMatrix);
      x[D] = P[0], C[D] = P[1], b[D] = P[2];
    }
    else for (D = 0; D < f; D++) {
      x[D] = _[D], C[D] = A[D], b[D] = I[D];
      var M = S.create(y[D], h[D], g[D]);
      P = S.transformMat4(S.zero(), M, l.matrix), y[D] = P[0], h[D] = P[1], g[D] = P[2];
    }
    return { count: f, comment: a, scalingFactor: o, dynamics: v, type_symbol: X.ofStringArray(w), x: X.ofFloatArray(y), y: X.ofFloatArray(h), z: X.ofFloatArray(g), fractX: X.ofFloatArray(y), fractY: X.ofFloatArray(h), fractZ: X.ofFloatArray(g), cell: l };
  }(Le(e));
  t.push(n);
  var r = { isMaterial: !0, molecules: t };
  return _r.success(r);
}
function dF(e) {
  var t = this;
  return At.create("Parse Mol", function() {
    return ie(t, 0, void 0, function() {
      return ne(this, function(n) {
        return [2, lF(e)];
      });
    });
  });
}
var fF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, dF(e).run()] : [2, [Go()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, Ru(t.result).run()];
        case 2:
          return [2, n.sent().frames.map(function(r) {
            return Be.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function mF(e) {
  var t = [], n = function(r, i, a) {
    for (var o = function() {
      if (a) return _S(a.a, a.b, a.c, a.alpha, a.beta, a.gamma);
    }(), s = r.length, u = new Float64Array(s), c = new Float64Array(s), l = new Float64Array(s), d = new Array(s), m = 0; m < s; m++) d[m] = r[m], u[m] = i[m][0], c[m] = i[m][1], l[m] = i[m][2];
    return { count: s, comment: "", type_symbol: X.ofStringArray(d), x: X.ofFloatArray(u), y: X.ofFloatArray(c), z: X.ofFloatArray(l), cell: o };
  }(e.elements, e.xyzs, e.lattice);
  return t.push(n), { isMaterial: !0, molecules: t };
}
function IS(e) {
  return mF(e);
}
var pF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, Ru(IS(e)).run()];
        case 1:
          return [2, t.sent().frames.map(function(n) {
            return Be.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, Xd = function(e, t, n, r) {
  this.name = e, this.visible = t, this.origin = n, this.contents = r;
};
(function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Zr(t, e);
})(Xd), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Zr(t, e);
}(Xd), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Zr(t, e);
}(Xd), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  Zr(t, e);
}(Xd);
var hF = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return Zr(t, e), t.create = function(n) {
    var r = n.name, i = n.visible, a = n.origin, o = n.contents, s = {};
    return o.forEach(function(u) {
      Reflect.defineProperty(s, u.name, { value: u });
    }), new t(r, i, a, s);
  }, t;
}(Xd);
function vF(e) {
  var t = e.scene, n = e.structure, r = hF.create(t).contents, i = r.atoms, a = r.bonds, o = i.contents.length, s = new Float64Array(o), u = new Float64Array(o), c = new Float64Array(o), l = new Array(o), d = function() {
    if (n.lattice) {
      var h = n.lattice;
      return _S(h.a, h.b, h.c, h.alpha, h.beta, h.gamma);
    }
  }(), m = {};
  a.contents.forEach(function(h) {
    h.positionPairs.forEach(function(g) {
      var x = g[1].join(",");
      m[x] = m[x] || [], m[x].push(g[0]);
    });
  });
  var p = {};
  i.contents.forEach(function(h, g) {
    var x, C = h.positions, b = h.tooltip, _ = C[0];
    for (var A in s[g] = _[0], u[g] = _[1], c[g] = _[2], l[g] = ((x = b.split(/\s/)[0].match(/[A-Za-z]/g)) === null || x === void 0 ? void 0 : x.join("")) || "", m) {
      var I = m[A];
      p[A] = p[A] || [], I[0].every(function(w, E) {
        return w === _[E];
      }) && (p[A][0] = g), I[1].every(function(w, E) {
        return w === _[E];
      }) && (p[A][1] = g);
    }
  });
  var v = [], f = [];
  Object.values(p).forEach(function(h) {
    v.push(h[0]), f.push(h[1]);
  });
  var y = { count: 2 * v.length, atomA: Pe(Pe([], v, !0), f, !0), atomB: Pe(Pe([], f, !0), v, !0) };
  return { comment: "", count: o, x: X.ofFloatArray(s), y: X.ofFloatArray(u), z: X.ofFloatArray(c), type_symbol: X.ofStringArray(l), cell: d, bonds: y };
}
function gF(e) {
  var t = { molecules: e.map(vF), isMaterial: !0 };
  return _r.success(t);
}
function wS(e) {
  var t = this;
  return At.create("Parse Mol", function() {
    return ie(t, 0, void 0, function() {
      return ne(this, function(n) {
        return [2, gF(e)];
      });
    });
  });
}
var yF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, wS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw new Error(t.message);
          return [4, Ru(t.result).run()];
        case 2:
          return [2, n.sent().frames.map(function(r) {
            return Be.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, A3 = Le.skipWhitespace, PS = Le.eatValue, va = Le.markLine, ga = Le.getTokenString, ES = Le.readLine, Jv, c_ = /\s+/g;
function bF(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _;
    return ne(this, function(A) {
      switch (A.label) {
        case 0:
          for (t = e.tokenizer, n = e.molecule; ga(t) !== "@<TRIPOS>ATOM" && t.position < t.data.length; ) va(t);
          return r = t.position, i = t.lineNumber, a = ES(t), o = a.trim().split(/\s+/g), s = o.length, u = Ge.create(t.data, 2 * n.num_atoms), c = Ge.create(t.data, 2 * n.num_atoms), l = Ge.create(t.data, 2 * n.num_atoms), d = Ge.create(t.data, 2 * n.num_atoms), m = Ge.create(t.data, 2 * n.num_atoms), p = Ge.create(t.data, 2 * n.num_atoms), v = Ge.create(t.data, 2 * n.num_atoms), f = Ge.create(t.data, 2 * n.num_atoms), y = Ge.create(t.data, 2 * n.num_atoms), h = Ge.create(t.data, 2 * n.num_atoms), g = X.Undefined(n.num_atoms, X.Schema.float), x = X.Undefined(n.num_atoms, X.Schema.int), C = X.Undefined(n.num_atoms, X.Schema.str), t.position = r, t.lineNumber = i, b = t.length, _ = 0, [4, mf(e.runtimeCtx, 1e5, void 0, function(I) {
            for (var w = Math.min(n.num_atoms - _, I), E = 0; E < w; E++) for (var D = 0; D < s; D++) switch (A3(t), t.tokenStart = t.position, PS(t), D) {
              case 0:
                Ge.addUnchecked(u, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                Ge.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                Ge.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                Ge.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              case 4:
                Ge.addUnchecked(m, t.tokenStart, t.tokenEnd);
                break;
              case 5:
                Ge.addUnchecked(p, t.tokenStart, t.tokenEnd);
                break;
              case 6:
                Ge.addUnchecked(v, t.tokenStart, t.tokenEnd);
                break;
              case 7:
                Ge.addUnchecked(f, t.tokenStart, t.tokenEnd);
                break;
              case 8:
                Ge.addUnchecked(y, t.tokenStart, t.tokenEnd);
                break;
              case 9:
                Ge.addUnchecked(h, t.tokenStart, t.tokenEnd);
            }
            return _ += w, w;
          }, function(I) {
            return I.update({ message: "Parsing...", current: t.position, max: b });
          })];
        case 1:
          return A.sent(), [2, { count: n.num_atoms, atom_id: en(u)(X.Schema.int), atom_name: en(c)(X.Schema.str), x: en(l)(X.Schema.float), y: en(d)(X.Schema.float), z: en(m)(X.Schema.float), atom_type: s > 5 ? en(p)(X.Schema.str) : C, subst_id: s > 6 ? en(v)(X.Schema.int) : x, subst_name: s > 7 ? en(f)(X.Schema.str) : C, charge: s > 8 ? en(y)(X.Schema.float) : g, status_bit: s > 9 ? en(h)(X.Schema.str) : C }];
      }
    });
  });
}
function _F(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o, s, u, c, l, d, m, p, v;
    return ne(this, function(f) {
      switch (f.label) {
        case 0:
          for (t = e.tokenizer, n = e.molecule; ga(t) !== "@<TRIPOS>BOND" && t.position < t.data.length; ) va(t);
          return r = t.position, i = t.lineNumber, a = ES(t), o = a.trim().split(/\s+/g), s = o.length, u = Ge.create(t.data, 2 * n.num_bonds), c = Ge.create(t.data, 2 * n.num_bonds), l = Ge.create(t.data, 2 * n.num_bonds), d = Ge.create(t.data, 2 * n.num_bonds), m = Ge.create(t.data, 2 * n.num_bonds), t.position = r, t.lineNumber = i, p = t.length, v = 0, [4, mf(e.runtimeCtx, 1e5, void 0, function(y) {
            for (var h = Math.min(n.num_bonds - v, y), g = 0; g < h; g++) for (var x = 0; x < s; x++) switch (A3(t), t.tokenStart = t.position, PS(t), x) {
              case 0:
                Ge.addUnchecked(u, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                Ge.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                Ge.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                Ge.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              default:
                Ge.addUnchecked(m, t.tokenStart, t.tokenEnd);
            }
            return v += h, h;
          }, function(y) {
            return y.update({ message: "Parsing...", current: t.position, max: p });
          })];
        case 1:
          return f.sent(), [2, { count: n.num_bonds, bond_id: en(u)(X.Schema.int), origin_atom_id: en(c)(X.Schema.int), target_atom_id: en(l)(X.Schema.int), bond_type: en(d)(X.Schema.str), status_bits: s > 4 ? en(m)(X.Schema.str) : X.Undefined(n.num_bonds, X.Schema.str) }];
      }
    });
  });
}
function xF(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c;
    return ne(this, function(l) {
      switch (l.label) {
        case 0:
          r = Le(t), e.update({ message: "Parsing...", current: 0, max: t.length }), i = [], l.label = 1;
        case 1:
          return r.position < t.length ? (a = /* @__PURE__ */ function(d, m) {
            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: m };
          }(r, e), function(d) {
            for (var m = d.tokenizer, p = d.molecule; ga(m) !== "@<TRIPOS>MOLECULE" && m.position < m.data.length; ) va(m);
            va(m), p.mol_name = ga(m), va(m);
            var v = ga(m).trim().split(c_);
            p.num_atoms = parseInt(v[0]), p.num_bonds = parseInt(v[1]), p.num_subst = parseInt(v[2]), p.num_feat = parseInt(v[3]), p.num_sets = parseInt(v[4]), va(m);
            var f = ga(m);
            if (!f.startsWith("@<TRIPOS>")) {
              p.mol_type = f, va(m);
              var y = ga(m);
              if (!y.startsWith("@<TRIPOS>")) {
                p.charge_type = y, va(m);
                var h = ga(m);
                if (!h.startsWith("@<TRIPOS>")) {
                  p.status_bits = h, va(m);
                  var g = ga(m);
                  g.startsWith("@<TRIPOS>") || (p.mol_comment = g);
                }
              }
            }
          }(a), [4, bF(a)]) : [3, 4];
        case 2:
          return o = l.sent(), [4, _F(a)];
        case 3:
          for (s = l.sent(), u = function(d) {
            for (var m = d.tokenizer; m.position < m.data.length; ) {
              var p = ga(m);
              if (p === "@<TRIPOS>MOLECULE") return;
              if (p === "@<TRIPOS>CRYSIN") break;
              va(m);
            }
            if (!(m.position >= m.data.length)) {
              va(m);
              var v = ga(m).trim().split(c_);
              return { a: parseFloat(v[0]), b: parseFloat(v[1]), c: parseFloat(v[2]), alpha: parseFloat(v[3]), beta: parseFloat(v[4]), gamma: parseFloat(v[5]), spaceGroup: parseInt(v[6], 10), setting: parseInt(v[7], 10) };
            }
          }(a), i.push({ molecule: a.molecule, atoms: o, bonds: s, crysin: u }), A3(r); ga(r) !== "@<TRIPOS>MOLECULE" && r.position < r.data.length; ) va(r);
          return [3, 1];
        case 4:
          return c = { name: n, structures: i }, [2, _r.success(c)];
      }
    });
  });
}
function SF(e, t) {
  var n = this;
  return At.create("Parse MOL2", function(r) {
    return ie(n, 0, void 0, function() {
      return ne(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, xF(r, e, t)];
          case 1:
            return [2, i.sent()];
        }
      });
    });
  });
}
function CF(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T;
    return ne(this, function(P) {
      switch (P.label) {
        case 0:
          n = [], r = 0, i = e.structures.length, P.label = 1;
        case 1:
          if (!(r < i)) return [3, 4];
          for (a = e.structures[r], o = a.molecule, s = a.atoms, u = a.bonds, c = a.crysin, l = X.ofConst("A", s.count, X.Schema.str), d = new Array(s.count), m = !1, p = 0; p < s.count; ++p) if (s.atom_type.value(p).includes(".")) {
            m = !0;
            break;
          }
          for (v = 0; v < s.count; ++v) d[v] = m ? s.atom_type.value(v).split(".")[0].toUpperCase() : g3(s.atom_name.value(v), s.subst_name.value(v));
          for (f = Jt.ofPartialColumns(Gi.atom_site, { auth_asym_id: l, auth_atom_id: X.asArrayColumn(s.atom_name), auth_comp_id: s.subst_name, auth_seq_id: s.subst_id, Cartn_x: X.asArrayColumn(s.x, Float32Array), Cartn_y: X.asArrayColumn(s.y, Float32Array), Cartn_z: X.asArrayColumn(s.z, Float32Array), id: X.asArrayColumn(s.atom_id), label_asym_id: l, label_atom_id: X.asArrayColumn(s.atom_name), label_comp_id: s.subst_name, label_seq_id: s.subst_id, label_entity_id: X.ofConst("1", s.count, X.Schema.str), occupancy: X.ofConst(1, s.count, X.Schema.float), type_symbol: X.ofStringArray(d), pdbx_PDB_model_num: X.ofConst(r, s.count, X.Schema.int) }, s.count), (y = new Oc()).setNames([["MOL", o.mol_name || "Ligand"]]), y.getEntityId("MOL", 0, "A"), h = new kc(s.subst_id, s.atom_name), g = 0, x = s.subst_name.rowCount; g < x; ++g) h.add(s.subst_name.value(g), g);
          return [4, Ps(Bu({ entity: y.getEntityTable(), chem_comp: h.getChemCompTable(), atom_site: f }), Jv.create(e), t)];
        case 2:
          (C = P.sent()).frameCount > 0 && (b = X.ofIntArray(X.mapToArray(u.origin_atom_id, function(M) {
            return M - 1;
          }, Int32Array)), _ = X.ofIntArray(X.mapToArray(u.target_atom_id, function(M) {
            return M - 1;
          }, Int32Array)), A = u.bond_id, I = X.ofIntArray(X.mapToArray(u.bond_type, function(M) {
            switch (M) {
              case "ar":
              case "am":
              case "un":
                return 1;
              case "du":
              case "nc":
                return 0;
              default:
                return parseInt(M);
            }
          }, Int8Array)), w = X.ofIntArray(X.mapToArray(u.bond_type, function(M) {
            switch (M) {
              case "ar":
              case "am":
                return 17;
              case "du":
              case "nc":
                return 0;
              default:
                return 1;
            }
          }, Int8Array)), E = gr.fromData({ pairs: { key: A, indexA: b, indexB: _, order: I, flag: w }, count: s.count }), D = C.representative, gr.Provider.set(D, E), Ss.Provider.set(D, { data: s.charge, type: o.charge_type }), c && (T = function(M) {
            if (M.setting === 1) {
              var R = Ma.create(M.spaceGroup, S.create(M.a, M.b, M.c), S.scale(S(), S.create(M.alpha, M.beta, M.gamma), Math.PI / 180));
              return { spacegroup: ki.create(R), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
            }
          }(c), T && Vr.Provider.set(D, T)), n.push(D)), P.label = 3;
        case 3:
          return ++r, [3, 1];
        case 4:
          return [2, new bf(n)];
      }
    });
  });
}
(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 };
  };
})(Jv || (Jv = {}));
var hi, AF = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t, n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, SF(e, "").run()] : [2, [Go()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, (i = t.result, At.create("Parse MOL2", function(a) {
            return CF(i, a);
          })).run()];
        case 2:
          return n = r.sent(), [2, [Be.ofModel(n.representative, { dynamicBonds: !0 })]];
      }
      var i;
    });
  });
} }, As = ((hi = {})[Nt.Pdb] = wL, hi[Nt.Mol] = DL, hi[Nt.Sdf] = HL, hi[Nt.Gro] = YL, hi[Nt.Xtc] = $L, hi[Nt.Dump] = rF, hi[Nt.Xyz] = oF, hi[Nt.Cif] = cF, hi[Nt.MMCif] = u_, hi[Nt.MCif] = u_, hi[Nt.POSCAR] = fF, hi[Nt.Material] = pF, hi[Nt.Pymatgen] = yF, hi[Nt.Mol2] = AF, hi), dt = t0.Const, at = t0.Dynamic, IF = [dt(Q.core.type.bool, function(e, t) {
  return !!t[0](e);
}), dt(Q.core.type.num, function(e, t) {
  return +t[0](e);
}), dt(Q.core.type.str, function(e, t) {
  return "" + t[0](e);
}), dt(Q.core.type.list, function(e, t) {
  return of.forEachEval(t, e, function(n, r, i) {
    return i[r] = n;
  }, []);
}), dt(Q.core.type.set, function(e, t) {
  return of.forEachEval(t, e, function(n, r, i) {
    return i.add(n);
  }, /* @__PURE__ */ new Set());
}), dt(Q.core.type.regex, function(e, t) {
  return new RegExp(t[0](e), t[1] && t[1](e) || "");
}), dt(Q.core.type.bitflags, function(e, t) {
  return +t[0](e);
}), dt(Q.core.type.compositeKey, function(e, t) {
  return of.forEachEval(t, e, function(n, r, i) {
    return i[r] = "" + n;
  }, []).join("-");
}), dt(Q.core.logic.not, function(e, t) {
  return !t[0](e);
}), dt(Q.core.logic.and, function(e, t) {
  if (typeof t.length == "number") {
    for (var n = 0, r = t.length; n < r; n++) if (!t[n](e)) return !1;
  } else for (var i = 0, a = Object.keys(t); i < a.length; i++)
    if (!t[a[i]](e)) return !1;
  return !0;
}), dt(Q.core.logic.or, function(e, t) {
  if (typeof t.length == "number") {
    for (var n = 0, r = t.length; n < r; n++) if (t[n](e)) return !0;
  } else for (var i = 0, a = Object.keys(t); i < a.length; i++)
    if (t[a[i]](e)) return !0;
  return !1;
}), dt(Q.core.rel.eq, function(e, t) {
  return t[0](e) === t[1](e);
}), dt(Q.core.rel.neq, function(e, t) {
  return t[0](e) !== t[1](e);
}), dt(Q.core.rel.lt, function(e, t) {
  return t[0](e) < t[1](e);
}), dt(Q.core.rel.lte, function(e, t) {
  return t[0](e) <= t[1](e);
}), dt(Q.core.rel.gr, function(e, t) {
  return t[0](e) > t[1](e);
}), dt(Q.core.rel.gre, function(e, t) {
  return t[0](e) >= t[1](e);
}), dt(Q.core.rel.inRange, function(e, t) {
  var n = t[0](e);
  return n >= t[1](e) && n <= t[2](e);
}), dt(Q.core.math.add, function(e, t) {
  var n = 0;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n += t[r](e);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    n += t[o[a]](e);
  return n;
}), dt(Q.core.math.sub, function(e, t) {
  var n = 0;
  if (typeof t.length == "number") {
    if (t.length === 1) return -t[0](e);
    n = t[0](e) || 0;
    for (var r = 1, i = t.length; r < i; r++) n -= t[r](e);
  } else {
    var a = Object.keys(t);
    if (a.length === 1) return -t[a[0]](e);
    for (n = t[a[0]](e) || 0, r = 1, i = a.length; r < i; r++) n -= t[a[r]](e);
  }
  return n;
}), dt(Q.core.math.mult, function(e, t) {
  var n = 1;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n *= t[r](e);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    n *= t[o[a]](e);
  return n;
}), dt(Q.core.math.div, function(e, t) {
  return t[0](e) / t[1](e);
}), dt(Q.core.math.pow, function(e, t) {
  return Math.pow(t[0](e), t[1](e));
}), dt(Q.core.math.mod, function(e, t) {
  return t[0](e) % t[1](e);
}), dt(Q.core.math.min, function(e, t) {
  var n = Number.POSITIVE_INFINITY;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n = Math.min(t[r](e), n);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var s = o[a];
    n = Math.min(t[s](e), n);
  }
  return n;
}), dt(Q.core.math.max, function(e, t) {
  var n = Number.NEGATIVE_INFINITY;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n = Math.max(t[r](e), n);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var s = o[a];
    n = Math.max(t[s](e), n);
  }
  return n;
}), dt(Q.core.math.floor, function(e, t) {
  return Math.floor(t[0](e));
}), dt(Q.core.math.ceil, function(e, t) {
  return Math.ceil(t[0](e));
}), dt(Q.core.math.roundInt, function(e, t) {
  return Math.round(t[0](e));
}), dt(Q.core.math.abs, function(e, t) {
  return Math.abs(t[0](e));
}), dt(Q.core.math.sqrt, function(e, t) {
  return Math.sqrt(t[0](e));
}), dt(Q.core.math.cbrt, function(e, t) {
  return Math.cbrt(t[0](e));
}), dt(Q.core.math.sin, function(e, t) {
  return Math.sin(t[0](e));
}), dt(Q.core.math.cos, function(e, t) {
  return Math.cos(t[0](e));
}), dt(Q.core.math.tan, function(e, t) {
  return Math.tan(t[0](e));
}), dt(Q.core.math.asin, function(e, t) {
  return Math.asin(t[0](e));
}), dt(Q.core.math.acos, function(e, t) {
  return Math.acos(t[0](e));
}), dt(Q.core.math.atan, function(e, t) {
  return Math.atan(t[0](e));
}), dt(Q.core.math.sinh, function(e, t) {
  return Math.sinh(t[0](e));
}), dt(Q.core.math.cosh, function(e, t) {
  return Math.cosh(t[0](e));
}), dt(Q.core.math.tanh, function(e, t) {
  return Math.tanh(t[0](e));
}), dt(Q.core.math.exp, function(e, t) {
  return Math.exp(t[0](e));
}), dt(Q.core.math.log, function(e, t) {
  return Math.log(t[0](e));
}), dt(Q.core.math.log10, function(e, t) {
  return Math.log10(t[0](e));
}), dt(Q.core.math.atan2, function(e, t) {
  return Math.atan2(t[0](e), t[1](e));
}), dt(Q.core.str.match, function(e, t) {
  return t[0](e).test(t[1](e));
}), dt(Q.core.str.concat, function(e, t) {
  var n = [];
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n.push(t[r](e).toString());
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var s = o[a];
    n.push(t[s](e).toString());
  }
  return n.join("");
}), dt(Q.core.list.getAt, function(e, t) {
  return t[0](e)[t[1](e)];
}), dt(Q.core.list.equal, function(e, t) {
  return function(n, r) {
    if (!n || n.length === 0) return !r || r.length === 0;
    if (!r) return !1;
    var i = n.length;
    if (i !== r.length) return !1;
    for (var a = 0; a < i; a++) if (n[a] !== r[a]) return !1;
    return !0;
  }(t[0](e), t[1](e));
}), dt(Q.core.set.has, function(e, t) {
  return t[0](e).has(t[1](e));
}), dt(Q.core.set.isSubset, function(e, t) {
  return Ii.isSuperset(t[1](e), t[0](e));
}), dt(Q.core.flags.hasAny, function(e, t) {
  var n = t[1](e), r = t[0](e);
  return n ? !!(r & n) : !!r;
}), dt(Q.core.flags.hasAll, function(e, t) {
  var n = t[1](e), r = t[0](e);
  return n ? (r & n) === n : !r;
}), dt(Q.structureQuery.type.elementSymbol, function(e, t) {
  return Tl(t[0](e));
}), dt(Q.structureQuery.type.atomName, function(e, t) {
  return (n = t[0](e)) ? typeof n == "string" ? n.toUpperCase() : "".concat(n).toUpperCase() : "";
  var n;
}), dt(Q.structureQuery.type.bondFlags, function(e, t) {
  var n = 0;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n = l_(n, t[r](e));
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    n = l_(n, t[o[a]](e));
  return n;
}), dt(Q.structureQuery.type.ringFingerprint, function(e, t) {
  return Ea.elementFingerprint(function(n, r) {
    var i = [];
    if (!r) return i;
    if (typeof r.length == "number") for (var a = 0, o = r.length; a < o; a++) i.push(r[a](n));
    else {
      var s = Object.keys(r);
      for (a = 1, o = s.length; a < o; a++) i.push(r[s[a]](n));
    }
    return i;
  }(e, t));
}), dt(Q.structureQuery.type.secondaryStructureFlags, function(e, t) {
  var n = 0;
  if (typeof t.length == "number") for (var r = 0, i = t.length; r < i; r++) n = d_(n, t[r](e));
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    n = d_(n, t[o[a]](e));
  return n;
}), at(Q.structureQuery.filter.pick, function(e, t) {
  return Cn.filters.pick(t[0], t.test)(e);
}), at(Q.structureQuery.filter.first, function(e, t) {
  return Cn.filters.first(t[0])(e);
}), at(Q.structureQuery.filter.withSameAtomProperties, function(e, t) {
  return Cn.filters.withSameAtomProperties(t[0], t.source, t.property)(e);
}), at(Q.structureQuery.filter.intersectedBy, function(e, t) {
  return Cn.filters.areIntersectedBy(t[0], t.by)(e);
}), at(Q.structureQuery.filter.within, function(e, t) {
  return Cn.filters.within({ query: t[0], target: t.target, minRadius: t["min-radius"], maxRadius: t["max-radius"], elementRadius: t["atom-radius"], invert: t.invert })(e);
}), at(Q.structureQuery.filter.isConnectedTo, function(e, t) {
  return Cn.filters.isConnectedTo({ query: t[0], target: t.target, disjunct: t.disjunct, invert: t.invert, bondTest: t["bond-test"] })(e);
}), at(Q.structureQuery.generator.atomGroups, function(e, t) {
  return Cn.generators.atoms({ entityTest: t["entity-test"], chainTest: t["chain-test"], residueTest: t["residue-test"], atomTest: t["atom-test"], groupBy: t["group-by"] })(e);
}), at(Q.structureQuery.generator.all, function(e) {
  return Cn.generators.all(e);
}), at(Q.structureQuery.generator.empty, function(e) {
  return Cn.generators.none(e);
}), at(Q.structureQuery.generator.bondedAtomicPairs, function(e, t) {
  return Cn.generators.bondedAtomicPairs(t && t[0])(e);
}), at(Q.structureQuery.generator.rings, function(e, t) {
  var n, r;
  return Cn.generators.rings((n = t == null ? void 0 : t.fingerprint) === null || n === void 0 ? void 0 : n.call(t, e), (r = t == null ? void 0 : t["only-aromatic"]) === null || r === void 0 ? void 0 : r.call(t, e))(e);
}), at(Q.structureQuery.modifier.includeSurroundings, function(e, t) {
  return Cn.modifiers.includeSurroundings(t[0], { radius: t.radius(e), wholeResidues: !(!t["as-whole-residues"] || !t["as-whole-residues"](e)), elementRadius: t["atom-radius"] })(e);
}), at(Q.structureQuery.modifier.surroundingLigands, function(e, t) {
  return Cn.modifiers.surroundingLigands({ query: t[0], radius: t.radius(e), includeWater: !(!t["include-water"] || !t["include-water"](e)) })(e);
}), at(Q.structureQuery.modifier.wholeResidues, function(e, t) {
  return Cn.modifiers.wholeResidues(t[0])(e);
}), at(Q.structureQuery.modifier.union, function(e, t) {
  return Cn.modifiers.union(t[0])(e);
}), at(Q.structureQuery.modifier.expandProperty, function(e, t) {
  return Cn.modifiers.expandProperty(t[0], t.property)(e);
}), at(Q.structureQuery.modifier.exceptBy, function(e, t) {
  return Cn.modifiers.exceptBy(t[0], t.by)(e);
}), at(Q.structureQuery.modifier.intersectBy, function(e, t) {
  return Cn.modifiers.intersectBy(t[0], t.by)(e);
}), at(Q.structureQuery.modifier.includeConnected, function(e, t) {
  var n, r;
  return Cn.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: (r = (n = t["fixed-point"]) === null || n === void 0 ? void 0 : n.call(t, e)) !== null && r !== void 0 && r })(e);
}), at(Q.structureQuery.combinator.merge, function(e, t) {
  return Cn.combinators.merge(t)(e);
}), at(Q.structureQuery.atomProperty.core.elementSymbol, ln(Me.atom.type_symbol)), at(Q.structureQuery.atomProperty.core.vdw, function(e, t) {
  return M0(Me.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), at(Q.structureQuery.atomProperty.core.mass, function(e, t) {
  return function(n) {
    var r = Bl[n];
    return r === void 0 ? 10.81 : mD[r];
  }(Me.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), at(Q.structureQuery.atomProperty.core.atomicNumber, function(e, t) {
  return yf(Me.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), at(Q.structureQuery.atomProperty.core.x, ln(Me.atom.x)), at(Q.structureQuery.atomProperty.core.y, ln(Me.atom.y)), at(Q.structureQuery.atomProperty.core.z, ln(Me.atom.z)), at(Q.structureQuery.atomProperty.core.sourceIndex, ln(Me.atom.sourceIndex)), at(Q.structureQuery.atomProperty.core.operatorName, ln(Me.unit.operator_name)), at(Q.structureQuery.atomProperty.core.modelIndex, ln(Me.unit.model_index)), at(Q.structureQuery.atomProperty.core.modelLabel, ln(Me.unit.model_label)), at(Q.structureQuery.atomProperty.core.atomKey, function(e, t) {
  var n = t && t[0] && t[0](e) || e.element;
  return Ta(n.unit.id, n.element);
}), at(Q.structureQuery.atomProperty.macromolecular.residueKey, function(e, t) {
  return n = t && t[0] && t[0](e) || e.element, me.isAtomic(n.unit) ? n.unit.residueIndex[n.element] : -1;
  var n;
}), at(Q.structureQuery.atomProperty.macromolecular.chainKey, function(e, t) {
  return n = t && t[0] && t[0](e) || e.element, me.isAtomic(n.unit) ? n.unit.chainIndex[n.element] : -1;
  var n;
}), at(Q.structureQuery.atomProperty.macromolecular.entityKey, function(e, t) {
  return function(n) {
    return Me.entity.key(n);
  }(t && t[0] && t[0](e) || e.element);
}), at(Q.structureQuery.atomProperty.macromolecular.id, ln(Me.atom.id)), at(Q.structureQuery.atomProperty.macromolecular.isHet, function(e, t) {
  return Me.residue.group_PDB(t && t[0] && t[0](e) || e.element) !== "ATOM";
}), at(Q.structureQuery.atomProperty.macromolecular.label_atom_id, ln(Me.atom.label_atom_id)), at(Q.structureQuery.atomProperty.macromolecular.label_alt_id, ln(Me.atom.label_alt_id)), at(Q.structureQuery.atomProperty.macromolecular.label_comp_id, ln(Me.atom.label_comp_id)), at(Q.structureQuery.atomProperty.macromolecular.label_seq_id, ln(Me.residue.label_seq_id)), at(Q.structureQuery.atomProperty.macromolecular.label_asym_id, ln(Me.chain.label_asym_id)), at(Q.structureQuery.atomProperty.macromolecular.label_entity_id, ln(Me.entity.id)), at(Q.structureQuery.atomProperty.macromolecular.auth_atom_id, ln(Me.atom.auth_atom_id)), at(Q.structureQuery.atomProperty.macromolecular.auth_comp_id, ln(Me.atom.auth_comp_id)), at(Q.structureQuery.atomProperty.macromolecular.auth_seq_id, ln(Me.residue.auth_seq_id)), at(Q.structureQuery.atomProperty.macromolecular.auth_asym_id, ln(Me.chain.auth_asym_id)), at(Q.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, ln(Me.residue.pdbx_PDB_ins_code)), at(Q.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, ln(Me.atom.pdbx_formal_charge)), at(Q.structureQuery.atomProperty.macromolecular.occupancy, ln(Me.atom.occupancy)), at(Q.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, ln(Me.atom.B_iso_or_equiv)), at(Q.structureQuery.atomProperty.macromolecular.entityType, ln(Me.entity.type)), at(Q.structureQuery.atomProperty.macromolecular.entitySubtype, ln(Me.entity.subtype)), at(Q.structureQuery.atomProperty.macromolecular.entityPrdId, ln(Me.entity.prd_id)), at(Q.structureQuery.atomProperty.macromolecular.entityDescription, ln(Me.entity.pdbx_description)), at(Q.structureQuery.atomProperty.macromolecular.objectPrimitive, ln(Me.unit.object_primitive)), at(Q.structureQuery.atomProperty.macromolecular.isNonStandard, ln(Me.residue.isNonStandard)), at(Q.structureQuery.atomProperty.macromolecular.secondaryStructureKey, ln(Me.residue.secondary_structure_key)), at(Q.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, ln(Me.residue.secondary_structure_type)), at(Q.structureQuery.atomProperty.macromolecular.chemCompType, ln(Me.residue.chem_comp_type)), at(Q.structureQuery.bondProperty.order, function(e, t) {
  return e.atomicBond.order;
}), at(Q.structureQuery.bondProperty.flags, function(e, t) {
  return e.atomicBond.type;
}), at(Q.structureQuery.bondProperty.atomA, function(e, t) {
  return e.atomicBond.a;
}), at(Q.structureQuery.bondProperty.atomB, function(e, t) {
  return e.atomicBond.b;
}), at(Q.structureQuery.bondProperty.length, function(e, t) {
  return e.atomicBond.length;
}), at(Q.internal.generator.bundleElement, function(e, t) {
  return M9(t.groupedUnits(e), t.ranges(e), t.set(e));
}), at(Q.internal.generator.bundle, function(e, t) {
  return D9(t.elements(e))(e);
}), at(Q.internal.generator.current, function(e, t) {
  return e.tryGetCurrentSelection();
})];
function ln(e) {
  return function(t, n) {
    return e(n && n[0] && n[0](t) || t.element);
  };
}
function l_(e, t) {
  return e | (Bt.isName(t) ? Bt.fromName(t) : 0);
}
function d_(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 = IF; e < t.length; e++) {
    var n = t[e];
    kx.addSymbol(n);
  }
})();
var Tf, wF = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function PF(e, t, n) {
  var r = !1;
  return gs(e, t, n, function(i, a) {
    var o;
    o = Zt(i, a), wF.has(o) && (r = !0);
  }), r;
}
function f_(e, t, n) {
  var r, i;
  return n === void 0 && (n = {}), { label: e, expression: t, description: n.description || "", category: (r = n.category) !== null && r !== void 0 ? r : Tf.Misc, isHidden: !!n.isHidden, priority: n.priority || 0, referencesCurrent: !!n.referencesCurrent, get query() {
    return i || (i = n0(t)), i;
  }, ensureCustomProperties: n.ensureCustomProperties };
}
(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";
})(Tf || (Tf = {}));
var F1 = { polymer: f_("Polymer", ot.struct.modifier.union([ot.struct.generator.atomGroups({ "entity-test": ot.core.logic.and([ot.core.rel.eq([ot.ammp("entityType"), "polymer"]), ot.core.str.match([ot.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"), ot.ammp("entitySubtype")])]) })]), { category: Tf.Type }), lipid: f_("Lipid", ot.struct.modifier.union([ot.struct.generator.atomGroups({ "entity-test": ot.core.rel.eq([ot.ammp("entitySubtype"), "lipid"]) })]), { category: Tf.Type }) }, Go = function() {
  return Be.Builder().getStructure();
}, TS = function(e, t) {
  for (var n = Be.Builder(), r = new Set(t), i = 0, a = e.units; i < a.length; i++) {
    var o = a[i], s = Pe([], o.elements, !0).filter(function(u) {
      return !r.has(u);
    });
    s.length && n.addUnit(o.kind, o.model, o.conformation.operator, s, o.traits);
  }
  return n.getStructure();
}, Li = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? t.structure : t.kind === "element-loci" ? Se.toStructure(t) : Be.Empty;
}, qf = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? wr(Be.toStructureElementLoci(t.structure)) : t.kind === "element-loci" ? wr(t) : [];
}, Xn = function(e, t, n, r) {
  if ((t == null ? void 0 : t.length) === 0 && !n) return Be.Empty;
  for (var i = Be.Builder(), a = new Set(t), o = typeof r == "string" ? r : vr.create22(), s = 0, u = e.units; s < u.length; s++) {
    var c = u[s], l = t != null && t.length ? Pe([], c.elements, !0).filter(function(d) {
      return a.has(d);
    }) : c.elements;
    l.length && i.addUnit(c.kind, r ? B(B({}, c.model), { id: o }) : c.model, c.conformation.operator, l, c.traits);
  }
  return i.getStructure();
}, Cm = function(e, t) {
  for (var n = Be.Builder(), r = /* @__PURE__ */ new Map(), i = 0, a = function(u, c) {
    var l = e[u], d = l.ref, m = l.elementIds, p = un(t.cells.get(d)), v = new Set(m);
    r.set(u, []);
    for (var f = 0, y = p.units; f < y.length; f++) {
      var h = y[f], g = m ? Pe([], h.elements, !0).filter(function(x) {
        return v.has(x);
      }) : h.elements;
      g.length && (r.get(u).push(i), n.addUnit(h.kind, h.model, h.conformation.operator, g, h.traits, i), i++);
    }
  }, o = 0, s = e.length; o < s; o++) a(o);
  return { unitsMap: r, structure: n.getStructure() };
}, $v = function(e) {
  if (e.model.sourceData.kind === "gro") return { polymer: $i(Yl(Xl(e, ot.struct.modifier.exceptBy({ 0: F1.polymer.expression, by: F1.lipid.expression })))), other: $i(Yl(Xl(e, ot.struct.modifier.exceptBy({ 0: vu.toExpression(vu("(sel.atom.all)", "mol-script")), by: ot.struct.modifier.exceptBy({ 0: F1.polymer.expression, by: F1.lipid.expression }) })))) };
  var t = {}, n = {}, r = /* @__PURE__ */ new Set(), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(u) {
    var c;
    u.elements.forEach(function(v) {
      var f = Fo(u, v);
      if (f.groupPDB === "ATOM" && !["UNK", "MOL"].includes(f.residueName) && !yc.has(f.residueName)) return bi(t, f), r.add(f.elementId), void i.push(f.elementId);
      if (f.groupPDB !== "HETATM" && !["UNK", "MOL"].includes(f.residueName) && yc.has(f.residueName)) bi(n, f);
      else {
        var y = "".concat(f.chainId, "_").concat(f.residueId);
        a.set(y, a.has(y) ? Pe(Pe([], a.get(y), !0), [f], !1) : [f]);
      }
    });
    for (var l = 0, d = u.bonds.a.length; l < d; l++) {
      var m = u.elements[u.bonds.a[l]], p = u.elements[u.bonds.b[l]];
      o.has(m) ? (c = o.get(m)) === null || c === void 0 || c.add(p) : o.set(m, /* @__PURE__ */ new Set([p]));
    }
  }), a.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(m) {
          r.has(m) && (c = !0);
        });
      }
    }), u.forEach(function(l) {
      c ? (Object.assign(l, { isEutectic: !0 }), i.push(l.elementId), r.add(l.elementId)) : bi(n, l);
    });
  });
  var s = [];
  return Object.keys(n).forEach(function(u) {
    Object.keys(n[u]).forEach(function(c) {
      s.push.apply(s, n[u][c].map(function(l) {
        return l.elementId;
      }));
    });
  }), { polymer: i, other: s };
}, V0 = function(e, t) {
  var n;
  if (!e.elementCount) return "";
  if (t === Nt.Pdb) return S3(e, void 0, !0);
  var r = ea(e), i = (n = r == null ? void 0 : r.entryId) !== null && n !== void 0 ? n : "";
  return t === Nt.Sdf || t === Nt.Mol ? i ? Pe([i], Wv(e).split(`
`).slice(1), !0).join(`
`) : Wv(e) : void 0;
}, EF = function(e, t) {
  var n = ea(e);
  return t !== Nt.Material ? n.sourceData.data : n.sourceData.data.molecules[0];
}, TF = function(e, t, n, r) {
  return ie(void 0, 0, void 0, function() {
    var i, a, o, s, u, c, l;
    return ne(this, function(d) {
      switch (d.label) {
        case 0:
          return i = !((u = e == null ? void 0 : e.models) === null || u === void 0) && u.length ? e.models[0] : e == null ? void 0 : e.model, ((l = r ?? (i ? i.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 = (a = As[Nt.Pdb]).parse, [4, S3(e, void 0, !0, n)]);
        case 1:
          return [4, o.apply(a, [d.sent()])];
        case 2:
        case 5:
          return [2, d.sent()];
        case 3:
          return [4, Wv(e, void 0, 0, t)];
        case 4:
          return s = d.sent(), [4, As[Nt.Sdf].parse(s)];
      }
    });
  });
}, Xl = function(e, t) {
  return n0(t)(new Cc(e));
}, Yl = function(e) {
  var t;
  if (e.structure) t = e.structure;
  else if (e.structures) {
    var n = e.structures.map(function(a) {
      return (a == null ? void 0 : a.units.length) > 0 ? Be.toStructureElementLoci(a) : void 0;
    }).filter(function(a) {
      return a;
    });
    if (n.length === 0) return Go();
    for (var r = n[0], i = 1; i < n.length; i++) r = Se.union(r, n[i]);
    t = Se.toStructure(r);
  }
  return t;
}, $i = function(e) {
  var t = [];
  return e.units.forEach(function(n) {
    t.push.apply(t, n.elements);
  }), t;
}, Fo = function(e, t) {
  var n;
  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: Ef(e.model.atomicHierarchy.atoms.type_symbol.value(t)), charge: ((n = Ss.Provider.get(e.model)) === null || n === void 0 ? void 0 : n.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) };
}, MS = function(e, t, n) {
  var r = n;
  if (e.units.some(function(a) {
    return !!a.elements.includes(t) && (r = a.invariantId, !0);
  }), r === void 0 || !e.unitMap.has(r)) return {};
  var i = e.unitMap.get(r);
  return Fo(i, t);
}, MF = function(e, t) {
  e.units.forEach(function(n) {
    n.elements.forEach(function(r) {
      var i = Fo(n, r);
      t(i);
    });
  });
}, DF = function(e, t, n) {
  var r = [];
  return t.forEach(function(i) {
    var a = e.managers.cell.get(i.ref), o = un(a), s = /* @__PURE__ */ new Map(), u = new Set(i.elementIds);
    o && (o.units.forEach(function(c) {
      c.elements.forEach(function(l) {
        var d;
        if (!i.elementIds || u.has(l)) {
          var m = Fo(c, l), p = f0(m, n);
          s.has(p) ? (d = s.get(p)) === null || d === void 0 || d.push(m) : s.set(p, [m]);
        }
      });
    }), s.forEach(function(c) {
      r.push({ ref: i.ref, elementIds: c.map(function(l) {
        return l.elementId;
      }), props: oL(c[0], n) });
    }));
  }), r;
}, DS = function(e, t) {
  var n = {}, r = /* @__PURE__ */ new Set(), i = t ?? [];
  return t || e.managers.cell.traverse(function(a, o) {
    un(a) && !o.isHidden && r.add(a.ref);
  }), r.forEach(function(a) {
    i.push({ ref: a });
  }), i.forEach(function(a) {
    var o, s = a.ref, u = a.elementIds, c = new Set(u), l = e.cells.get(s);
    if (l) {
      var d = un(l);
      if (d) {
        var m = [], p = [], v = [], f = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
        d.units.forEach(function(C) {
          var b;
          C.elements.forEach(function(E) {
            var D, T;
            if (!u || c.has(E)) {
              var P = Fo(C, E), M = f0(P, on.Residue);
              v3.has(P.residueName.toUpperCase()) ? m.push(P.elementId) : td.has(P.residueName.toUpperCase()) ? p.push(P.elementId) : h3.has(P.typeSymbol.toUpperCase()) || Nf.has(P.residueName.toUpperCase()) || yc.has(P.residueName.toUpperCase()) ? v.push(P.elementId) : P.groupPDB !== "ATOM" || ["UNK", "MOL"].includes(P.residueName) ? P.groupPDB === "HETATM" || ["UNK", "MOL"].includes(P.residueName) ? g.has(M) ? (D = g.get(M)) === null || D === void 0 || D.push(P) : g.set(M, [P]) : h.has(M) ? (T = h.get(M)) === null || T === void 0 || T.push(P) : h.set(M, [P]) : f.add(P.elementId);
            }
          });
          for (var _ = 0, A = C.bonds.a.length; _ < A; _++) {
            var I = C.elements[C.bonds.a[_]], w = C.elements[C.bonds.b[_]];
            x.has(I) ? (b = x.get(I)) === null || b === void 0 || b.add(w) : x.set(I, /* @__PURE__ */ new Set([w]));
          }
        }), g.forEach(function(C, b) {
          var _ = !1, A = new Set(C.map(function(I) {
            return I.elementId;
          }));
          A.forEach(function(I) {
            if (x.has(I)) {
              var w = x.get(I);
              w == null || w.forEach(function(E) {
                f.has(E) && (_ = !0);
              });
            }
          }), C.forEach(function(I) {
            var w;
            _ ? f.add(I.elementId) : h.has(b) ? (w = h.get(b)) === null || w === void 0 || w.push(I) : h.set(b, [I]);
          });
        }), h.forEach(function(C, b) {
          var _ = C.filter(function(A) {
            return A.typeSymbol !== "H";
          });
          _.length > 10 && _.length < 150 ? y.set(b, C) : v.push.apply(v, C.map(function(A) {
            return A.elementId;
          }));
        }), n[s] = ((o = {})[ai.Protein] = f.size ? [{ ref: s, elementIds: Array.from(f.values()) }] : [], o[ai.Ligand] = Array.from(y.entries()).map(function(C) {
          var b = C[0], _ = C[1];
          return { ref: s, elementIds: _.map(function(A) {
            return A.elementId;
          }), name: b };
        }), o[ai.Solvent] = m.length ? [{ ref: s, elementIds: m }] : [], o[ai.Water] = p.length ? [{ ref: s, elementIds: p }] : [], o[ai.Other] = v.length ? [{ ref: s, elementIds: v }] : [], o);
      }
    }
  }), n;
}, ea = function(e) {
  var t;
  return (t = e.model) !== null && t !== void 0 ? t : e.models[0];
}, Ja = function(e) {
  var t, n;
  return (n = (t = e.model) !== null && t !== void 0 ? t : e.models[0]) === null || n === void 0 ? void 0 : n.id;
}, un = function(e) {
  var t, n, r, i;
  return (t = e == null ? void 0 : e.model.structure) !== null && t !== void 0 ? t : !((n = e == null ? void 0 : e.model) === null || n === void 0) && n.trajectory ? Be.ofModel((r = e == null ? void 0 : e.model.trajectory) === null || r === void 0 ? void 0 : r.state.getFrameAtIndex((i = e == null ? void 0 : e.model.trajectory) === null || i === void 0 ? void 0 : i.frameIndex)) : void 0;
}, z0 = function(e, t) {
  var n = e.units.filter(function(a) {
    return _e.has(a.elements, t);
  })[0];
  if (!n || me.isCoarse(n)) return sr.NotHydrogen;
  if (n.model.atomicHierarchy.derived.atom.atomicNumber[t] !== 1) {
    var r = sr.NotHydrogen;
    return gs(e, n, n.elements.indexOf(t), function(a, o) {
      if (a.model.atomicHierarchy.derived.atom.atomicNumber[a.elements[o]] === 1) switch (z0(e, a.elements[o])) {
        case sr.Polar:
          r = sr.ConnectPolar;
          break;
        case sr.NonPolar:
          r = sr.ConnectNonPolar;
      }
    }), r;
  }
  var i = PF(e, n, _e.indexOf(n.elements, t));
  return i ? sr.Polar : i ? sr.NotHydrogen : sr.NonPolar;
}, BF = function(e, t) {
  return ie(void 0, 0, void 0, function() {
    var n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, Promise.all(t.filter(function(i) {
            return e.cells.has(i.ref);
          }).map(function(i) {
            return e.managers.cell.getStructure(i.ref);
          }))];
        case 1:
          return n = r.sent(), [2, FL(n)];
      }
    });
  });
}, BS = function(e) {
  return Array.from(e.cells.entries()).map(function(t) {
    var n = t[0], r = t[1];
    return un(r) ? r.representations.size === 0 || Array.from(r.representations.values()).filter(function(i) {
      return !i.isHidden;
    }).length === 0 ? { ref: "" } : { ref: n } : { ref: "" };
  }).filter(function(t) {
    return t.ref;
  });
}, yd = function(e, t) {
  return MS(e, t).typeSymbol === "H" && z0(e, t) === sr.NonPolar;
}, Dh = function(e) {
  if (!e) return e;
  var t = [], n = e.sort(function(i, a) {
    return +i - +a;
  }), r = [];
  return n.forEach(function(i, a) {
    r.length !== 0 ? r.length !== 1 ? r.length === 2 && (r[1] === i - 1 ? r[1] = i : (t.push.apply(t, r), r = [i])) : r[0] === i - 1 ? r.push(i) : (t.push(r[0], r[0]), r = [i]) : r.push(i);
  }), r.length && t.push.apply(t, r.length === 2 ? r : [r[0], r[0]]), t;
}, G1 = function(e) {
  for (var t = [], n = 0, r = e.length; n < r; n += 2) for (var i = e[n]; i <= e[n + 1]; i++) t.push(i);
  return t;
};
function Mc(e, t, n, r) {
  var i, a, o, s, u = 0, c = t.webgl, l = new $n(), d = new Mt.GeometryState(), m = Ms(), p = [], v = ia.create(), f = Ba.createEmpty();
  function y(h) {
    if (ia.update(v, h), h.visible !== void 0 && i && i.setVisibility(h.visible && (v.unitTransforms === null || v.unitTransforms.isIdentity)), h.alphaFactor !== void 0 && i && i.setAlphaFactor(h.alphaFactor), h.pickable !== void 0 && i && i.setPickable(h.pickable), h.overpaint !== void 0 && i) {
      var g = xf.remap(h.overpaint, a);
      i.setOverpaint(g, c);
    }
    if (h.transparency !== void 0 && i) {
      var x = Sf.remap(h.transparency, a);
      i.setTransparency(x, c);
    }
    if (h.substance !== void 0 && i) {
      var C = Af.remap(h.substance, a);
      i.setSubstance(C, c);
    }
    if (h.clipping !== void 0 && i) {
      var b = Cf.remap(h.clipping, a);
      i.setClipping(b);
    }
    h.transform !== void 0 && i && i.setTransform(h.transform), h.unitTransforms !== void 0 && i && i.setVisibility(v.visible && (h.unitTransforms === null || h.unitTransforms.isIdentity));
  }
  return { label: e, get groupCount() {
    return i ? i.groupCount : 0;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return v;
  }, get theme() {
    return f;
  }, get geometryVersion() {
    return d.version;
  }, renderObjects: p, updated: l, createOrUpdate: function(h, g) {
    var x = this;
    return h === void 0 && (h = {}), g && g !== a && (o = n(t, g), a = g, s || (s = N.getDefaultValues(o))), s = Object.assign({}, s, h), At.create("Creating or updating ComplexRepresentation", function(C) {
      return ie(x, 0, void 0, function() {
        var b, _, A;
        return ne(this, function(I) {
          switch (I.label) {
            case 0:
              return b = !1, i ? !((A = i.mustRecreate) === null || A === void 0) && A.call(i, a, s, c) && (i.destroy(), i = r(m, a, s, c), b = !0) : (i = r(m, a, s, c), b = !0), (_ = i.createOrUpdate({ webgl: c, runtime: C }, f, s, g)) ? [4, _] : [3, 2];
            case 1:
              I.sent(), I.label = 2;
            case 2:
              return b && y(v), p.length = 0, i && i.renderObject && (p.push(i.renderObject), d.add(i.renderObject.id, i.geometryVersion)), d.snapshot(), u += 1, l.next(u), [2];
          }
        });
      });
    });
  }, setState: y, setTheme: function(h) {
    f = h;
  }, getLoci: function(h) {
    return h === void 0 ? Be.Loci(a.target) : i ? i.getLoci(h) : Sn;
  }, mark: function(h, g) {
    if (!a || !Wt.is(v.markerActions, g)) return !1;
    if (Be.isLoci(h) || Se.is(h) || rt.isLoci(h)) {
      if (!Be.areRootsEquivalent(h.structure, a)) return !1;
      h = rn.remap(h, a), (Be.isLoci(h) || Se.is(h) && Se.isWholeStructure(h)) && (h = n3);
    } else if (!Vi(h) && !af(h)) return !1;
    return !rn.isEmpty(h) && !!i && i.mark(h, g);
  }, destroy: function() {
    i && i.destroy();
  } };
}
function RS(e, t, n) {
  var r = t.elements, i = t.model;
  if (ve.indexOf(r, n) !== -1) {
    for (var a = i.atomicHierarchy.residueAtomSegments, o = a.index, s = a.offsets, u = o[n], c = [], l = s[u], d = s[u + 1]; l < d; ++l) {
      var m = ve.indexOf(r, l);
      m !== -1 && c.push(m);
    }
    return Se(e, [{ unit: t, indices: ve.ofSortedArray(_e.ofSortedArray(c)) }]);
  }
  return Sn;
}
function m_(e, t, n) {
  for (var r = e.structure.child, i = t && r ? e.group.units.filter(function(c) {
    return r.unitMap.has(c.id);
  }) : e.group.units, a = i.length, o = 16 * a, s = n && n.aTransform.ref.value.length >= o ? n.aTransform.ref.value : new Float32Array(o), u = 0; u < a; u++) J.toArray(i[u].conformation.operator.matrix, s, 16 * u);
  return Xg(s, a, n);
}
var RF = N.objectToOptions({ atomic: {}, spheres: {}, gaussians: {} }), p_ = 5e8;
function kF(e, t, n) {
  n === void 0 && (n = p_);
  var r = function(u, c, l) {
    l === void 0 && (l = p_);
    var d = sn.size(S(), u);
    S.ceil(d, d), d.sort(function(v, f) {
      return f - v;
    });
    var m = Math.floor(Math.cbrt(l) * Math.cbrt(l)), p = d[0] * d[1];
    return { area: p, areaCells: Math.ceil(p / (c * c)), maxAreaCells: m };
  }(e, t.resolution, n), i = r.area, a = r.areaCells, o = r.maxAreaCells, s = a > o ? Math.sqrt(i / o) : t.resolution;
  return B(B({}, t), { resolution: s });
}
var I3 = { ignoreHydrogens: N.Boolean(!1, { description: "Whether or not to include hydrogen atoms in the surface calculation." }), traceOnly: N.Boolean(!1, { description: "Whether or not to only use trace atoms in the surface calculation." }), includeParent: N.Boolean(!1, { description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure." }) };
N.getDefaultValues(I3);
var OF = S();
function NF(e, t, n, r) {
  return S.squaredDistance(S.set(OF, e, t, n), r);
}
function LF(e, t, n, r) {
  var i, a, o = r.ignoreHydrogens, s = r.traceOnly, u = r.includeParent, c = u ? e.root.unitMap.get(t.id) : t, l = function(D) {
    switch (D.kind) {
      case 0:
        return D.model.atomicConformation;
      case 1:
        return D.model.coarseConformation.spheres;
      case 2:
        return D.model.coarseConformation.gaussians;
    }
  }(c), d = l.x, m = l.y, p = l.z, v = c.elements, f = t.boundary.sphere, y = f.center, h = f.radius, g = (h + 7) * (h + 7);
  if (o || s || u && c !== t) {
    for (var x = [], C = [], b = 0, _ = v.length; b < _; ++b) {
      var A = v[b];
      o && eg(c, A) || s && !OS(c, A) || u && NF(d[A], m[A], p[A], y) > g || (x.push(A), C.push(b));
    }
    i = _e.ofSortedArray(x), a = C;
  } else i = v, a = Oo(new Int32Array(i.length));
  u && c !== t && function(D, T, P) {
    for (var M = 0, R = T.length, O = 0, L = P.length; O < L; ++O) {
      var F = _e.indexOfInRange(T, P[O], M, R);
      F === -1 ? D[O] = -2 : (D[O] = F, M = F);
    }
  }(a, t.elements, i);
  var I = { indices: i, x: d, y: m, z: p, id: a }, w = t === c ? t.boundary : Dl(I), E = Ne.create(e, c);
  return { position: I, boundary: w, radius: function(D) {
    return E.element = D, n.size(E);
  } };
}
var kS = Bl.H;
function eg(e, t) {
  return !me.isCoarse(e) && e.model.atomicHierarchy.derived.atom.atomicNumber[t] === kS;
}
function tg(e, t) {
  return e[t] === kS;
}
function OS(e, t) {
  if (me.isCoarse(e)) return !0;
  var n = e.model.atomicHierarchy.atoms.label_atom_id.value(t);
  return n === "CA" || n === "BB" || n === "P";
}
function jf(e) {
  return N.MultiSelect(e, RF, { description: "For which kinds of units/chains to show the representation visuals." });
}
var zi = { unitKinds: jf(["atomic", "spheres"]), includeParent: N.Boolean(!1, { isHidden: !0 }) }, NS = B({}, ht.Params), FF = B({}, ro.Params), LS = B({}, li.Params), GF = B({}, Pc.Params), FS = B({}, Yt.Params), GS = B({}, na.Params), VS = B({}, $m.Params), zS = B({}, Eu.Params);
function U0(e, t) {
  var n, r, i, a, o, s, u, c, l = e.defaultProps, d = e.createGeometry, m = e.createLocationIterator, p = e.getLoci, v = e.eachLocation, f = e.setUpdateState, y = e.mustRecreate, h = e.processValues, g = e.dispose, x = e.geometryUtils, C = x.updateValues, b = x.updateBoundingSphere, _ = x.updateRenderableState, A = x.createPositionIterator, I = Lo.create(), w = { loci: Sn, action: $e.None, status: -1 }, E = Object.assign({}, l), D = Ba.createEmpty(), T = -1;
  function P(O) {
    if (I.createNew) {
      if (u = m(a), !O) throw new Error("expected geometry to be given");
      n = function(L, F, G, V, U, q) {
        var H = Ur.getUtils(F), K = H.createValues, j = H.createRenderableState, W = K(F, Wg(), G, V, U), Z = j(U);
        return ad(F.kind, W, Z, q);
      }(0, O, u, i, r, t), c = A(O, n.values);
    } else {
      if (!n) throw new Error("expected renderObject to be available");
      if (I.updateTransform && Da((u = m(a)).instanceCount * u.groupCount, n.values), I.createGeometry) {
        if (!O) throw new Error("expected geometry to be given");
        k.updateIfChanged(n.values.drawCount, Ur.getDrawCount(O)), k.updateIfChanged(n.values.uVertexCount, Ur.getVertexCount(O));
      }
      (I.updateTransform || I.createGeometry) && (b(n.values, O || s), c = A(s, n.values)), I.updateSize && "uSize" in n.values && Es(u, i.size, n.values), I.updateColor && ta(u, c, i.color, n.values), C(n.values, r), _(n.state, r);
    }
    E = r, D = i, o = a, O && (s = O, T += 1);
  }
  function M(O, L, F) {
    return function(G) {
      return !!Vi(G) || !(!Be.isLoci(G) || !Be.areRootsEquivalent(G.structure, o)) || !!(Se.is(G) && Be.areRootsEquivalent(G.structure, o) && Se.isWholeStructure(G));
    }(O) ? L(oe.ofBounds(0, u.groupCount * u.instanceCount)) : v(O, o, L, F);
  }
  function R(O) {
    n && (h == null || h(n.values, s, E, D, O.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? n : void 0;
  }, get geometryVersion() {
    return T;
  }, createOrUpdate: function(O, L, F, G) {
    if (F === void 0 && (F = {}), function(U, q, H) {
      if (!H && !o) throw new Error("missing structure");
      if (r = Object.assign({}, E, q), i = U, a = H, Lo.reset(I), !n || !o) return I.createNew = !0, void (I.createGeometry = !0);
      f(I, r, E, i, D, a, o), Be.areEquivalent(a, o) || (I.createGeometry = !0), Be.areHierarchiesEqual(a, o) || (I.updateTransform = !0, I.createGeometry = !0), Cs.areEqual(U.color, D.color) || (I.updateColor = !0), Iu(r.unitKinds, E.unitKinds) || (I.createGeometry = !0), o.child !== a.child && (I.createGeometry = !0), I.updateSize && !("uSize" in n.values) && (I.createGeometry = !0), I.createGeometry && (I.updateColor = !0, I.updateSize = !0);
    }(L, F, G || o), I.createGeometry) {
      var V = d(O, a, i, r, s);
      if (Dg(V)) return V.then(function(U) {
        P(U), R(O);
      });
      P(V);
    } else P();
    R(O);
  }, getLoci: function(O) {
    return n ? p(O, o, n.id) : Sn;
  }, mark: function(O, L) {
    return Pt.mark(n, O, L, M, w);
  }, setVisibility: function(O) {
    Pt.setVisibility(n, O);
  }, setAlphaFactor: function(O) {
    Pt.setAlphaFactor(n, O);
  }, setPickable: function(O) {
    Pt.setPickable(n, O);
  }, setColorOnly: function(O) {
    Pt.setColorOnly(n, O);
  }, setTransform: function(O, L) {
    Pt.setTransform(n, O, L);
  }, setOverpaint: function(O, L) {
    var F = { geometry: s, props: E, webgl: L };
    Pt.setOverpaint(n, O, M, !0, F);
  }, setTransparency: function(O, L) {
    var F = { geometry: s, props: E, webgl: L };
    Pt.setTransparency(n, O, M, !0, F);
  }, setSubstance: function(O, L) {
    var F = { geometry: s, props: E, webgl: L };
    Pt.setSubstance(n, O, M, !0, F);
  }, setClipping: function(O) {
    Pt.setClipping(n, O, M, !0);
  }, destroy: function() {
    g == null || g(s), n && (n.state.disposed = !0, n = void 0);
  }, mustRecreate: y };
}
var US = B(B({}, NS), zi);
function HS(e, t) {
  return U0(B(B({}, e), { setUpdateState: function(n, r, i, a, o, s, u) {
    e.setUpdateState(n, r, i, a, o, s, u), Ai.areEqual(a.size, o.size) || (n.createGeometry = !0);
  }, geometryUtils: ht.Utils }), t);
}
var VF = B(B({}, LS), zi), zF = B(B({}, FS), zi), UF = B(B({}, GS), zi);
function ui(e, t, n, r) {
  var i, a, o, s, u = 0, c = t.webgl, l = new $n(), d = Ms(), m = [], p = new Mt.GeometryState(), v = ia.create(), f = /* @__PURE__ */ new Map(), y = Ba.createEmpty();
  function h(g, x, C) {
    var b = C.visible, _ = C.alphaFactor, A = C.pickable, I = C.overpaint, w = C.transparency, E = C.substance, D = C.clipping, T = C.transform, P = C.unitTransforms;
    b !== void 0 && g.setVisibility(b), _ !== void 0 && g.setAlphaFactor(_), A !== void 0 && g.setPickable(A), I !== void 0 && g.setOverpaint(I, c), w !== void 0 && g.setTransparency(w, c), E !== void 0 && g.setSubstance(E, c), D !== void 0 && g.setClipping(D), T !== void 0 && g.setTransform(T), P !== void 0 && (P ? g.setTransform(void 0, P.getSymmetryGroupTransforms(x)) : g.setTransform(void 0, null));
  }
  return { label: e, get groupCount() {
    var g = 0;
    return f.forEach(function(x) {
      var C = x.visual;
      C.renderObject && (g += C.groupCount);
    }), g;
  }, get geometryVersion() {
    return p.version;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return v;
  }, get theme() {
    return y;
  }, renderObjects: m, updated: l, createOrUpdate: function(g, x) {
    var C = this;
    return g === void 0 && (g = {}), x && x !== i && (o = n(t, x), s || (s = N.getDefaultValues(o))), s = Object.assign({}, s, g), At.create("Creating or updating UnitsRepresentation", function(b) {
      return ie(C, 0, void 0, function() {
        var _, A, I, w, E, D, T, P, M, R, O, L, F;
        return ne(this, function(G) {
          switch (G.label) {
            case 0:
              if (i || x) return [3, 1];
              throw new Error("missing structure");
            case 1:
              if (!x || i) return [3, 8];
              a = x.unitSymmetryGroups, E = 0, G.label = 2;
            case 2:
              return E < a.length ? (M = a[E], P = r(d, x, s, c), (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 4]) : [3, 7];
            case 3:
              G.sent(), G.label = 4;
            case 4:
              return h(P, M, v), f.set(M.hashCode, { visual: P, group: M }), b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: E, max: a.length })] : [3, 6];
            case 5:
              G.sent(), G.label = 6;
            case 6:
              return E++, [3, 2];
            case 7:
              return [3, 43];
            case 8:
              if (!x || Be.areUnitIdsAndIndicesEqual(x, i) && x.child === i.child) return [3, 22];
              a = x.unitSymmetryGroups, _ = f, f = /* @__PURE__ */ new Map(), E = 0, G.label = 9;
            case 9:
              return E < a.length ? (M = a[E], (I = _.get(M.hashCode)) ? (P = I.visual, !((O = P.mustRecreate) === null || O === void 0) && O.call(P, { group: M, structure: x }, s, c) ? (P.destroy(), P = r(d, x, s, c), (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 11]) : [3, 12]) : [3, 15]) : [3, 21];
            case 10:
              G.sent(), G.label = 11;
            case 11:
              return h(P, M, v), [3, 14];
            case 12:
              return (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 14];
            case 13:
              G.sent(), G.label = 14;
            case 14:
              return f.set(M.hashCode, { visual: P, group: M }), _.delete(M.hashCode), P.renderObject && wv(A = P.renderObject.values.tMarker.ref.value.array, oe.ofBounds(0, A.length), $e.RemoveHighlight), [3, 18];
            case 15:
              return P = r(d, x, s, c), (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 17];
            case 16:
              G.sent(), G.label = 17;
            case 17:
              h(P, M, v), f.set(M.hashCode, { visual: P, group: M }), G.label = 18;
            case 18:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: E, max: a.length })] : [3, 20];
            case 19:
              G.sent(), G.label = 20;
            case 20:
              return E++, [3, 9];
            case 21:
              return _.forEach(function(V) {
                V.visual.destroy();
              }), [3, 43];
            case 22:
              if (!x || x === i || !Be.areUnitIdsAndIndicesEqual(x, i)) return [3, 34];
              a = x.unitSymmetryGroups, E = 0, G.label = 23;
            case 23:
              return E < a.length ? (M = a[E], (I = f.get(M.hashCode)) ? (P = I.visual, !((L = P.mustRecreate) === null || L === void 0) && L.call(P, { group: M, structure: x }, s, t.webgl) ? (P.destroy(), P = r(d, x, s, t.webgl), I.visual = P, (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 25]) : [3, 26]) : [3, 29]) : [3, 33];
            case 24:
              G.sent(), G.label = 25;
            case 25:
              return h(P, M, v), [3, 28];
            case 26:
              return (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: x })) ? [4, R] : [3, 28];
            case 27:
              G.sent(), G.label = 28;
            case 28:
              return I.group = M, [3, 30];
            case 29:
              throw new Error("expected to find visual for hashCode ".concat(M.hashCode));
            case 30:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: E, max: a.length })] : [3, 32];
            case 31:
              G.sent(), G.label = 32;
            case 32:
              return E++, [3, 23];
            case 33:
              return [3, 43];
            case 34:
              w = [], f.forEach(function(V) {
                return w.push(V);
              }), E = 0, D = w.length, G.label = 35;
            case 35:
              return E < D ? (T = w[E], P = T.visual, M = T.group, !((F = P.mustRecreate) === null || F === void 0) && F.call(P, { group: M, structure: i }, s, t.webgl) ? (P.destroy(), P = r(d, i, s, c), w[E].visual = P, (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s, { group: M, structure: i })) ? [4, R] : [3, 37]) : [3, 38]) : [3, 43];
            case 36:
              G.sent(), G.label = 37;
            case 37:
              return h(P, M, v), [3, 40];
            case 38:
              return (R = P.createOrUpdate({ webgl: c, runtime: b }, y, s)) ? [4, R] : [3, 40];
            case 39:
              G.sent(), G.label = 40;
            case 40:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: E, max: D })] : [3, 42];
            case 41:
              G.sent(), G.label = 42;
            case 42:
              return ++E, [3, 35];
            case 43:
              return m.length = 0, f.forEach(function(V) {
                var U = V.visual;
                U.renderObject && (m.push(U.renderObject), p.add(U.renderObject.id, U.geometryVersion));
              }), p.snapshot(), x && (i = x), l.next(u++), [2];
          }
        });
      });
    });
  }, setState: function(g) {
    var x = g.visible, C = g.alphaFactor, b = g.pickable, _ = g.overpaint, A = g.transparency, I = g.substance, w = g.clipping, E = g.transform, D = g.unitTransforms, T = g.syncManually, P = g.markerActions, M = {};
    x !== v.visible && (M.visible = x), C !== v.alphaFactor && (M.alphaFactor = C), b !== v.pickable && (M.pickable = b), _ !== void 0 && i && (M.overpaint = xf.remap(_, i)), A !== void 0 && i && (M.transparency = Sf.remap(A, i)), I !== void 0 && i && (M.substance = Af.remap(I, i)), w !== void 0 && i && (M.clipping = Cf.remap(w, i)), E === void 0 || J.areEqual(E, v.transform, bn) || (M.transform = E), D === v.unitTransforms && (D == null ? void 0 : D.version) === g.unitTransformsVersion || (M.unitTransforms = D, v.unitTransformsVersion = D ? D == null ? void 0 : D.version : -1), T !== v.syncManually && (M.syncManually = T), P !== v.markerActions && (M.markerActions = P), f.forEach(function(R) {
      return h(R.visual, R.group, M);
    }), ia.update(v, M);
  }, setTheme: function(g) {
    y = g;
  }, getLoci: function(g) {
    if (g === void 0) return Be.Loci(i.target);
    var x = Sn;
    return f.forEach(function(C) {
      var b = C.visual.getLoci(g);
      Cu(b) || (x = b);
    }), x;
  }, mark: function(g, x) {
    if (!i || !Wt.is(v.markerActions, x)) return !1;
    if (Be.isLoci(g) || Se.is(g) || rt.isLoci(g)) {
      if (!Be.areRootsEquivalent(g.structure, i)) return !1;
      g = rn.remap(g, i), (Be.isLoci(g) || Se.is(g) && Se.isWholeStructure(g)) && (g = n3);
    } else if (!Vi(g) && !af(g)) return !1;
    if (rn.isEmpty(g)) return !1;
    var C = !1;
    return f.forEach(function(b) {
      var _ = b.visual;
      C = _.mark(g, x) || C;
    }), C;
  }, destroy: function() {
    f.forEach(function(g) {
      return g.visual.destroy();
    }), f.clear();
  } };
}
function Kf(e, t) {
  var n, r, i, a, o, s, u, c, l = e.defaultProps, d = e.createGeometry, m = e.createLocationIterator, p = e.getLoci, v = e.eachLocation, f = e.setUpdateState, y = e.mustRecreate, h = e.processValues, g = e.dispose, x = e.geometryUtils, C = x.createEmpty, b = x.updateValues, _ = x.updateBoundingSphere, A = x.updateRenderableState, I = x.createPositionIterator, w = Lo.create(), E = { loci: Sn, action: $e.None, status: -1 }, D = Object.assign({}, l), T = Ba.createEmpty(), P = -1;
  function M(F) {
    if (w.createNew) {
      if (u = m(r), !F) throw new Error("expected geometry to be given");
      n = function(G, V, U, q, H, K) {
        var j = Ur.getUtils(V), W = j.createValues, Z = j.createRenderableState, Y = W(V, m_(G, H.includeParent), U, q, H), te = Z(H);
        return ad(V.kind, Y, te, K);
      }(r, F, u, T, D, t), c = I(F, n.values);
    } else {
      if (!n) throw new Error("expected renderObject to be available");
      if (w.updateTransform && Da((u = m(r)).instanceCount * u.groupCount, n.values), w.updateMatrix && m_(r, D.includeParent, n.values), w.createGeometry) {
        if (!F) throw new Error("expected geometry to be given");
        k.updateIfChanged(n.values.drawCount, Ur.getDrawCount(F)), k.updateIfChanged(n.values.uVertexCount, Ur.getVertexCount(F));
      }
      (w.updateTransform || w.createGeometry) && (_(n.values, F || s), c = I(F || s, n.values)), w.updateSize && "uSize" in n.values && Es(u, T.size, n.values), w.updateColor && ta(u, c, T.color, n.values), b(n.values, D), A(n.state, D);
    }
    i = D, a = T, o = r, F && (s = F, P += 1);
  }
  function R(F, G, V, U, q, H) {
    return function(K, j) {
      for (var W = 0, Z = K.length; W < Z; ++W)
        if (me.isAtomic(j) && K[W] === "atomic" || me.isSpheres(j) && K[W] === "spheres" || me.isGaussians(j) && K[W] === "gaussians") return !0;
      return !1;
    }(q.unitKinds, G) ? d(F, G, V, U, q, H) : C(H);
  }
  function O(F, G, V) {
    return function(U) {
      return !!Vi(U) || !(!Be.isLoci(U) || !Be.areRootsEquivalent(U.structure, o.structure)) || !!(Se.is(U) && Be.areRootsEquivalent(U.structure, o.structure) && Se.isWholeStructure(U));
    }(F) ? G(oe.ofBounds(0, u.groupCount * u.instanceCount)) : v(F, o, G, V);
  }
  function L(F) {
    n && (h == null || h(n.values, s, i, a, F.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? n : void 0;
  }, get geometryVersion() {
    return P;
  }, createOrUpdate: function(F, G, V, U) {
    if (function(H, K, j) {
      if (!j && !o) throw new Error("missing structureGroup");
      if (D = K, T = H, r = j, Lo.reset(w), !n || !o) return w.createNew = !0, void (w.createGeometry = !0);
      f(w, D, i, T, a, r, o), Be.areHierarchiesEqual(o.structure, r.structure) || (w.updateTransform = !0, w.updateColor = !0, w.updateSize = !0), Cs.areEqual(T.color, a.color) || (w.updateColor = !0), o.structure.child !== r.structure.child && (w.createGeometry = !0), Iu(D.unitKinds, i.unitKinds) || (w.createGeometry = !0), r.group.transformHash !== o.group.transformHash && (r.group.units.length !== o.group.units.length || w.updateColor ? w.updateTransform = !0 : w.updateMatrix = !0);
      var W = r.group.units[0], Z = o.group.units[0];
      me.areOperatorsEqual(W, Z) || (w.updateTransform = !0), me.areConformationsEqual(W, Z) || (w.createGeometry = !0), w.updateTransform && (w.updateMatrix = !0), w.updateSize && !("uSize" in n.values) && (w.createGeometry = !0), (w.createGeometry || w.updateTransform) && (o.structure.hashCode !== r.structure.hashCode && (w.updateColor = !0, w.updateSize = !0), (T.color.granularity.startsWith("vertex") || n.values.dColorType.ref.value.startsWith("vertex") || T.color.granularity.startsWith("volume") || n.values.dColorType.ref.value.startsWith("volume")) && (w.updateColor = !0));
    }(G, V, U || o), w.createGeometry) {
      var q = R(F, r.group.units[0], r.structure, T, D, s);
      if (Dg(q)) return q.then(function(H) {
        M(H), L(F);
      });
      M(q);
    } else M();
    L(F);
  }, getLoci: function(F) {
    return n ? p(F, o, n.id) : Sn;
  }, mark: function(F, G) {
    var V = !0;
    if (Se.is(F)) {
      V = !1;
      for (var U = o.group.units[0].invariantId, q = 0, H = F.elements; q < H.length; q++)
        if (H[q].unit.invariantId === U) {
          V = !0;
          break;
        }
    }
    return !!V && Pt.mark(n, F, G, O, E);
  }, setVisibility: function(F) {
    Pt.setVisibility(n, F);
  }, setAlphaFactor: function(F) {
    Pt.setAlphaFactor(n, F);
  }, setPickable: function(F) {
    Pt.setPickable(n, F);
  }, setColorOnly: function(F) {
    Pt.setColorOnly(n, F);
  }, setTransform: function(F, G) {
    Pt.setTransform(n, F, G);
  }, setOverpaint: function(F, G) {
    var V = { geometry: s, props: i, webgl: G };
    Pt.setOverpaint(n, F, O, !0, V);
  }, setTransparency: function(F, G) {
    var V = { geometry: s, props: i, webgl: G };
    Pt.setTransparency(n, F, O, !0, V);
  }, setSubstance: function(F, G) {
    var V = { geometry: s, props: i, webgl: G };
    Pt.setSubstance(n, F, O, !0, V);
  }, setClipping: function(F) {
    Pt.setClipping(n, F, O, !0);
  }, destroy: function() {
    g == null || g(s), n && (n.state.disposed = !0, n = void 0);
  }, mustRecreate: y };
}
B(B({}, VS), zi), B(B({}, zS), zi);
var Ds = B(B({}, NS), zi);
function Bs(e, t) {
  return Kf(B(B({}, e), { setUpdateState: function(n, r, i, a, o, s, u) {
    e.setUpdateState(n, r, i, a, o, s, u), Ai.areEqual(a.size, o.size) || (n.createGeometry = !0);
  }, geometryUtils: ht.Utils }), t);
}
var HF = B(B({}, FF), zi), qF = B(B({}, LS), zi), jF = B(B({}, GF), zi), w3 = B(B({}, FS), zi);
function P3(e, t) {
  return Kf(B(B({}, e), { setUpdateState: function(n, r, i, a, o, s, u) {
    e.setUpdateState(n, r, i, a, o, s, u), Ai.areEqual(a.size, o.size) || (n.updateSize = !0);
  }, geometryUtils: Yt.Utils }), t);
}
B(B({}, GS), zi), B(B({}, VS), zi), B(B({}, zS), zi);
var ia = { create: function() {
  return B(B({}, Mt.createState()), { unitTransforms: null, unitTransformsVersion: -1 });
}, update: function(e, t) {
  Mt.updateState(e, t), t.unitTransforms !== void 0 && (e.unitTransforms = t.unitTransforms);
} };
function qS(e, t) {
  return { centerA: Ne.create(e, t), centerB: Ne.create(e, t) };
}
var KF = function() {
  function e(t, n) {
    this.unit = n, this.hasNext = !1, this.traceElementIndex = n.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = dn.transientSegments(WS(n), n.elements), this.value = qS(t, n), this.hasNext = this.gapIt.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.unit, n = t.elements, r = t.residueIndex, i = this.gapIt.move();
    return this.value.centerA.element = this.traceElementIndex[r[n[i.start]]], this.value.centerB.element = this.traceElementIndex[r[n[i.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
  }, e;
}(), XF = function() {
  function e(t, n) {
    this.unit = n, this.hasNext = !1, this.gapIt = dn.transientSegments(WS(n), n.elements), this.value = qS(t, n), 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 YF(e) {
  for (var t = e.atomicConformation, n = t.x, r = t.y, i = t.z, a = e.atomicHierarchy.derived.residue, o = a.polymerType, s = a.traceElementIndex, u = o.length, c = ve.ofBounds(0, e.atomicConformation.atomId.rowCount), l = dn.transientSegments(e.atomicRanges.polymerRanges, c), d = St.transientSegments(e.atomicHierarchy.residueAtomSegments, c), m = new Float32Array(3 * u), p = new Float32Array(3 * u), v = 0, f = -1, y = -1, h = S(), g = S(), x = S(), C = S(), b = S(), _ = S(), A = S(), I = S(), w = S(), E = S(), D = S(), T = S(), P = S(), M = S(); l.hasNext; ) {
    var R = l.move();
    for (d.setSegment(R), v = -1, y = -1; d.hasNext; ) {
      v += 1;
      var O = d.move().index;
      v === 0 && (y = O);
      var L = 3 * (f = O - 2);
      S.copy(h, g), S.copy(g, x), S.copy(x, C);
      var F = s[O];
      if (S.set(C, n[F], r[F], i[F]), !(v < 3)) {
        S.sub(b, g, h), S.sub(_, x, g), S.sub(A, C, x), S.sub(D, b, _), S.sub(T, _, A), S.cross(P, D, T), S.normalize(P, P), S.toArray(P, p, L);
        var G = Math.cos(S.angle(D, T)), V = S.magnitude(D), U = S.magnitude(T), q = Math.sqrt(U * V) / Math.max(2, 2 * (1 - G));
        S.scale(I, D, q / V), S.sub(I, g, I), S.toArray(I, m, L), S.scale(w, T, q / U), S.sub(w, x, w), S.toArray(w, m, L + 3), S.copy(M, P);
      }
    }
    var H = 3 * y;
    S.fromArray(I, m, H + 3), S.fromArray(w, m, H + 6), S.normalize(P, S.sub(P, I, w));
    var K = s[y];
    S.set(h, n[K], r[K], i[K]), S.copy(E, h), S.projectPointOnVector(E, E, P, I), S.toArray(E, m, H);
    var j = f + 2, W = 3 * j;
    S.fromArray(I, m, W - 3), S.fromArray(w, m, W - 6), S.normalize(P, S.sub(P, I, w));
    var Z = s[j];
    S.set(h, n[Z], r[Z], i[Z]), S.copy(E, h), S.projectPointOnVector(E, E, P, I), S.toArray(E, m, W);
  }
  return { centers: m };
}
var ng = Cl.createProvider({ label: "Helix Orientation", descriptor: no({ name: "molstar_helix_orientation" }), type: "dynamic", defaultParams: {}, getParams: function() {
  return {};
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t) {
  return ie(void 0, 0, void 0, function() {
    return ne(this, function(n) {
      return [2, { value: YF(t) }];
    });
  });
} });
function za(e) {
  return Ft.is(e, 2);
}
function jS(e, t, n) {
  switch (n === void 0 && (n = {}), e.kind) {
    case 0:
      return new WF(e, t, n);
    case 1:
    case 2:
      return new ZF(e, t);
  }
}
var Am = Ft.create(536870912);
function KS(e, t) {
  return { center: Ne.create(e, t), centerPrev: Ne.create(e, t), centerNext: Ne.create(e, t), first: !1, last: !1, initial: !1, final: !1, secStrucFirst: !1, secStrucLast: !1, secStrucType: Am, moleculeType: 0, coarseBackboneFirst: !1, coarseBackboneLast: !1, isCoarseBackbone: !1, p0: S(), p1: S(), p2: S(), p3: S(), p4: S(), d12: S(), d23: S() };
}
var ct = S(), V1 = S(), z1 = S(), WF = function() {
  function e(t, n, r) {
    var i;
    if (r === void 0 && (r = {}), this.unit = t, this.state = 0, this.p0 = S(), this.p1 = S(), this.p2 = S(), this.p3 = S(), this.p4 = S(), this.p5 = S(), this.p6 = S(), this.d01 = S(), this.d12 = S(), this.d23 = S(), this.d34 = S(), 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 = dn.transientSegments(this.polymerRanges, t.elements), this.residueIt = St.transientSegments(this.residueAtomSegments, t.elements), this.value = KS(n, t), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, r.ignoreSecondaryStructure || (this.secondaryStructure = (i = ei.get(n).value) === null || i === void 0 ? void 0 : i.get(t.invariantId)), r.useHelixOrientation) {
      var a = ng.get(t.model).value;
      if (!a) throw new Error("missing helix-orientation");
      this.helixOrientationCenters = a.centers;
    }
  }
  return e.prototype.atomicPos = function(t, n) {
    n !== -1 && (t[0] = this.atomicConformation.x[n], t[1] = this.atomicConformation.y[n], t[2] = this.atomicConformation.z[n]);
  }, e.prototype.pos = function(t, n, r) {
    var i = this.traceElementIndex[n];
    this.helixOrientationCenters && za(r) ? S.fromArray(t, this.helixOrientationCenters, 3 * n) : this.atomicPos(t, i);
  }, e.prototype.updateResidueSegmentRange = function(t) {
    var n = this.residueAtomSegments.index;
    this.residueSegmentMin = n[this.polymerRanges[2 * t.index]], this.residueSegmentMax = n[this.polymerRanges[2 * t.index + 1]];
  }, e.prototype.getResidueIndex = function(t) {
    if (t < this.residueSegmentMin) t = (n = this.cyclicPolymerMap.get(this.residueSegmentMin)) !== void 0 ? n - (this.residueSegmentMin - t - 1) : this.residueSegmentMin;
    else if (t > this.residueSegmentMax) {
      var n;
      t = (n = this.cyclicPolymerMap.get(this.residueSegmentMax)) !== void 0 ? n + (t - this.residueSegmentMax - 1) : this.residueSegmentMax;
    }
    return t;
  }, e.prototype.getSecStruc = function(t) {
    if (this.secondaryStructure) {
      var n = this.secondaryStructure, r = n.type[(0, n.getIndex)(t)];
      return za(r) ? 2 : r;
    }
    return Am;
  }, e.prototype.setControlPoint = function(t, n, r, i, a) {
    (function(o) {
      return Ft.is(o, 4);
    })(a) || this.helixOrientationCenters && za(a) ? S.scale(t, S.add(t, n, S.add(t, i, S.add(t, r, r))), 1 / 4) : S.copy(t, r);
  }, e.prototype.setFromToVector = function(t, n, r) {
    this.value.isCoarseBackbone || this.helixOrientationCenters && za(r) ? S.set(t, 1, 0, 0) : (this.atomicPos(V1, this.directionFromElementIndex[n]), this.atomicPos(z1, this.directionToElementIndex[n]), S.sub(t, z1, V1));
  }, e.prototype.setDirection = function(t, n, r, i) {
    S.matchDirection(V1, n, r), S.matchDirection(z1, i, r), S.scale(t, S.add(t, V1, S.add(t, z1, S.add(t, r, r))), 1 / 4);
  }, e.prototype.move = function() {
    var t = this, n = t.residueIt, r = t.polymerIt, i = t.value;
    if (this.state === 0) {
      for (; r.hasNext; ) if (this.polymerSegment = r.move(), n.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), n.hasNext) {
        this.state = 1;
        var a = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], o = this.getResidueIndex(a - 1);
        this.currSecStrucType = a === o ? Am : this.getSecStruc(o), this.nextSecStrucType = this.getSecStruc(a), this.currCoarseBackbone = this.directionFromElementIndex[o] === -1 || this.directionToElementIndex[o] === -1, this.nextCoarseBackbone = this.directionFromElementIndex[a] === -1 || this.directionToElementIndex[a] === -1;
        break;
      }
    }
    if (this.state === 1) {
      var s = n.move().index, u = this.getResidueIndex(s - 3), c = this.getResidueIndex(s - 2), l = this.getResidueIndex(s - 1), d = this.getResidueIndex(s + 1), m = this.getResidueIndex(s + 2), p = this.getResidueIndex(s + 3);
      this.prevSecStrucType = this.currSecStrucType, this.currSecStrucType = this.nextSecStrucType, this.nextSecStrucType = s === d ? Am : this.getSecStruc(d), this.prevCoarseBackbone = this.currCoarseBackbone, this.currCoarseBackbone = this.nextCoarseBackbone, this.nextCoarseBackbone = this.directionFromElementIndex[d] === -1 || this.directionToElementIndex[d] === -1, i.secStrucType = this.currSecStrucType, i.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType, i.secStrucLast = this.currSecStrucType !== this.nextSecStrucType, i.isCoarseBackbone = this.currCoarseBackbone, i.coarseBackboneFirst = this.prevCoarseBackbone !== this.currCoarseBackbone, i.coarseBackboneLast = this.currCoarseBackbone !== this.nextCoarseBackbone, i.first = s === this.residueSegmentMin, i.last = s === this.residueSegmentMax, i.moleculeType = this.moleculeType[s], i.initial = s === l, i.final = s === d, i.centerPrev.element = this.traceElementIndex[l], i.center.element = this.traceElementIndex[s], i.centerNext.element = this.traceElementIndex[d];
      var v = this.getSecStruc(u), f = this.getSecStruc(c), y = this.getSecStruc(l), h = this.getSecStruc(s), g = this.getSecStruc(d), x = this.getSecStruc(m), C = this.getSecStruc(p);
      this.pos(this.p0, u, v), this.pos(this.p1, c, f), this.pos(this.p2, l, y), this.pos(this.p3, s, h), this.pos(this.p4, d, g), this.pos(this.p5, m, x), this.pos(this.p6, p, C);
      var b = za(v), _ = za(f), A = za(y), I = za(h), w = za(g), E = za(x), D = za(C);
      this.helixOrientationCenters && (I !== A ? I ? (S.copy(this.p0, this.p3), S.copy(this.p1, this.p3), S.copy(this.p2, this.p3)) : A && (S.scale(ct, S.sub(ct, this.p2, this.p3), 2), S.add(this.p2, this.p3, ct), S.add(this.p1, this.p2, ct), S.add(this.p0, this.p1, ct)) : I !== _ ? I ? (S.copy(this.p0, this.p2), S.copy(this.p1, this.p2)) : _ && (S.scale(ct, S.sub(ct, this.p1, this.p2), 2), S.add(this.p1, this.p2, ct), S.add(this.p0, this.p1, ct)) : I !== b && (I ? S.copy(this.p0, this.p1) : b && (S.scale(ct, S.sub(ct, this.p0, this.p1), 2), S.add(this.p0, this.p1, ct))), I !== w ? I ? (S.copy(this.p4, this.p3), S.copy(this.p5, this.p3), S.copy(this.p6, this.p3)) : w && (S.scale(ct, S.sub(ct, this.p4, this.p3), 2), S.add(this.p4, this.p3, ct), S.add(this.p5, this.p4, ct), S.add(this.p6, this.p5, ct)) : I !== E ? I ? (S.copy(this.p5, this.p4), S.copy(this.p6, this.p4)) : E && (S.scale(ct, S.sub(ct, this.p5, this.p4), 2), S.add(this.p5, this.p4, ct), S.add(this.p6, this.p5, ct)) : I !== D && (I ? S.copy(this.p6, this.p5) : D && (S.scale(ct, S.sub(ct, this.p6, this.p5), 2), S.add(this.p6, this.p5, ct)))), this.setFromToVector(this.d01, l, y), this.setFromToVector(this.d12, s, h), this.setFromToVector(this.d23, d, g), this.setFromToVector(this.d34, m, x);
      var T = I && this.helixOrientationCenters, P = 1.5;
      s === l || h !== y && T ? (S.setMagnitude(ct, S.sub(ct, this.p3, this.p4), P), S.add(this.p2, this.p3, ct), S.add(this.p1, this.p2, ct), S.add(this.p0, this.p1, ct)) : l === c || h !== f && T ? (S.setMagnitude(ct, S.sub(ct, this.p2, this.p3), P), S.add(this.p1, this.p2, ct), S.add(this.p0, this.p1, ct)) : (c === u || h !== v && T) && (S.setMagnitude(ct, S.sub(ct, this.p1, this.p2), P), S.add(this.p0, this.p1, ct)), s === d || h !== g && T ? (S.setMagnitude(ct, S.sub(ct, this.p3, this.p2), P), S.add(this.p4, this.p3, ct), S.add(this.p5, this.p4, ct), S.add(this.p6, this.p5, ct)) : d === m || h !== x && T ? (S.setMagnitude(ct, S.sub(ct, this.p4, this.p3), P), S.add(this.p5, this.p4, ct), S.add(this.p6, this.p5, ct)) : (m === p || h !== C && T) && (S.setMagnitude(ct, S.sub(ct, this.p5, this.p4), P), S.add(this.p6, this.p5, ct)), this.setControlPoint(i.p0, this.p0, this.p1, this.p2, f), this.setControlPoint(i.p1, this.p1, this.p2, this.p3, y), this.setControlPoint(i.p2, this.p2, this.p3, this.p4, h), this.setControlPoint(i.p3, this.p3, this.p4, this.p5, g), this.setControlPoint(i.p4, this.p4, this.p5, this.p6, x), this.setDirection(i.d12, this.d01, this.d12, this.d23), this.setDirection(i.d23, this.d12, this.d23, this.d34), n.hasNext || (this.state = 0);
    }
    return this.hasNext = n.hasNext || r.hasNext, this.value;
  }, e;
}(), ZF = function() {
  function e(t, n) {
    switch (this.unit = t, this.state = 0, this.hasNext = !1, this.polymerIt = dn.transientSegments(function(r) {
      switch (r.kind) {
        case 0:
          return r.model.atomicRanges.polymerRanges;
        case 1:
          return r.model.coarseHierarchy.spheres.polymerRanges;
        case 2:
          return r.model.coarseHierarchy.gaussians.polymerRanges;
      }
    }(t), t.elements), this.value = KS(n, t), S.set(this.value.d12, 1, 0, 0), S.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, n) {
    var r = this.unit.elements[n];
    t[0] = this.conformation.x[r], t[1] = this.conformation.y[r], t[2] = this.conformation.z[r];
  }, 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), n = this.getElementIndex(this.elementIndex - 1), r = this.getElementIndex(this.elementIndex + 1), i = this.getElementIndex(this.elementIndex + 2);
      this.value.centerPrev.element = this.value.center.unit.elements[n], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[r], this.pos(this.value.p0, t), this.pos(this.value.p1, n), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, r), this.pos(this.value.p4, i);
      var a = 0.5;
      this.elementIndex === n ? (S.scale(ct, S.sub(ct, this.value.p2, this.value.p3), a), S.add(this.value.p1, this.value.p2, ct), S.add(this.value.p0, this.value.p1, ct)) : n === t && (S.scale(ct, S.sub(ct, this.value.p1, this.value.p2), a), S.add(this.value.p0, this.value.p1, ct)), this.elementIndex === r ? (S.scale(ct, S.sub(ct, this.value.p2, this.value.p1), a), S.add(this.value.p3, this.value.p2, ct), S.add(this.value.p4, this.value.p3, ct)) : r === i && (S.scale(ct, S.sub(ct, this.value.p3, this.value.p2), a), S.add(this.value.p4, this.value.p3, ct)), 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;
}(), Hu = S.fromArray, rl = S.toArray, Bh = S.normalize, QF = S.sub, il = S.spline, JF = S.slerp, h_ = S.copy, v_ = S.cross, Rh = S.orthogonalize, $F = S.matchDirection, eG = S.scale, g_ = S.add;
function XS(e) {
  var t = e + 1, n = 3 * t;
  return { curvePoints: new Float32Array(n), tangentVectors: new Float32Array(n), normalVectors: new Float32Array(n), binormalVectors: new Float32Array(n), widthValues: new Float32Array(t), heightValues: new Float32Array(t), linearSegments: e };
}
function YS(e, t, n, r) {
  (function(i, a, o, s) {
    for (var u = i.curvePoints, c = i.tangentVectors, l = i.linearSegments, d = a.p0, m = a.p1, p = a.p2, v = a.p3, f = a.p4, y = a.secStrucFirst, h = a.secStrucLast, g = 1 - s, x = y ? 0.5 : o, C = h ? 0.5 : o, b = 0; b <= l; ++b) {
      var _ = 1 * b / l;
      if (_ < g) {
        var A = fr(x, o, _);
        il(Nh, d, m, p, v, _ + s, A), il(kh, d, m, p, v, _ + s + 0.01, x), il(Oh, d, m, p, v, _ + s - 0.01, x);
      } else
        A = fr(o, C, _), il(Nh, m, p, v, f, _ - g, A), il(kh, m, p, v, f, _ - g + 0.01, A), il(Oh, m, p, v, f, _ - g - 0.01, A);
      rl(Nh, u, 3 * b), Bh(Gs, QF(Gs, kh, Oh)), rl(Gs, c, 3 * b);
    }
  })(e, t, n, r), function(i, a) {
    var o = i.curvePoints, s = i.tangentVectors, u = i.normalVectors, c = i.binormalVectors, l = a.d12, d = a.d23, m = o.length / 3;
    Hu(b_, s, 0), Hu(__, s, 3 * (m - 1)), Rh(Lh, b_, l), Rh(U1, __, d), $F(U1, U1, Lh), h_(bd, Lh);
    for (var p = m - 1, v = 0; v < m; ++v) {
      var f = s7(0, p, v) * p, y = v === 0 ? 0 : 1 / (m - f);
      Hu(Gs, s, 3 * v), Rh(Ua, Gs, JF(tG, bd, U1, y)), rl(Ua, u, 3 * v), h_(bd, Ua), Bh(al, v_(al, Gs, Ua)), rl(al, c, 3 * v);
    }
    for (v = 1; v < p; ++v) Hu(bd, u, 3 * (v - 1)), Hu(Ua, u, 3 * v), Hu(y_, u, 3 * (v + 1)), eG(Ua, g_(Ua, bd, g_(Ua, y_, Ua)), 1 / 3), rl(Ua, u, 3 * v), Hu(Gs, s, 3 * v), Bh(al, v_(al, Gs, Ua)), rl(al, c, 3 * v);
  }(e, t);
}
var kh = S(), Oh = S(), Nh = S(), tG = S(), Gs = S(), Ua = S(), al = S(), bd = S(), y_ = S(), b_ = S(), __ = S(), Lh = S(), U1 = S();
function x_(e, t, n, r, i, a, o, s) {
  for (var u = e.widthValues, c = e.heightValues, l = e.linearSegments, d = 1 - s, m = 0; m <= l; ++m) {
    var p = 1 * m / l;
    p < d ? (u[m] = fr(t, n, p + s), c[m] = fr(i, a, p + s)) : (u[m] = fr(n, r, p - d), c[m] = fr(a, o, p - d));
  }
}
var v0, rg, g0, nG = 0.5, rG = 0.9, iG = 0.5, aG = 0.3, S_ = 2;
function WS(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 ZS(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group.units[i];
    if (me.isAtomic(s)) return RS(o, s, s.polymerElements[a]);
    var u = s.elements, c = s.polymerElements[a], l = ve.indexOf(u, c);
    if (l !== -1) return Se(o, [{ unit: s, indices: ve.ofSingleton(l) }]);
  }
  return Sn;
}
function C_(e, t, n, r, i, a) {
  for (var o = -1, s = -1, u = i; u <= a; u++)
    if (!((l = n[u]) < 0) && (o = ve.indexOf(t, l)) >= 0) {
      s = u;
      break;
    }
  if (o < 0) return !1;
  var c = o;
  for (u = a; u > s; u--) {
    var l;
    if (!((l = n[u]) < 0)) {
      var d = ve.indexOf(t, l);
      if (d >= 0) {
        c = d;
        break;
      }
    }
  }
  return r(oe.ofRange(e + o, e + c));
}
function QS(e, t, n, r, i) {
  var a = !1, o = i.unit.elements, s = i.unit.model.atomicHierarchy.derived.residue.traceElementIndex, u = i.unit.model.atomicHierarchy.residueAtomSegments.index, c = n(i.unit);
  if (oe.is(i.indices)) a = oe.start(i.indices) === 0 && oe.end(i.indices) === i.unit.elements.length ? r(oe.ofBounds(e, e + t)) || a : C_(e, c, s, r, p = u[o[oe.min(i.indices)]], v = u[o[oe.max(i.indices)]]) || a;
  else for (var l = i.indices, d = 0, m = l.length; d < m; d++) {
    for (var p, v = p = u[o[l[d]]], f = d + 1; f < m; ) {
      var y = u[o[l[f]]];
      if (y - v > 1) break;
      v = y, f++;
    }
    d = f - 1, a = C_(e, c, s, r, p, v) || a;
  }
  return a;
}
function oG(e) {
  return e.polymerElements;
}
function JS(e, t, n) {
  var r = !1;
  if (!Se.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!Be.areEquivalent(e.structure, i)) return !1;
  for (var o = a.units[0].polymerElements.length, s = 0, u = e.elements; s < u.length; s++) {
    var c = u[s];
    if (a.unitIndexMap.has(c.unit.id)) {
      var l = a.unitIndexMap.get(c.unit.id) * o;
      if (me.isAtomic(c.unit)) r = QS(l, o, oG, n, c) || r;
      else if (oe.is(c.indices)) {
        var d = l + oe.start(c.indices), m = l + oe.end(c.indices);
        r = n(oe.ofBounds(d, m)) || r;
      } else for (var p = 0, v = c.indices.length; p < v; p++) {
        d = c.indices[p];
        for (var f = p + 1; f < v && c.indices[f] === d; ) f++;
        p = f - 1, m = c.indices[p], r = n(oe.ofRange(l + d, l + m)) || r;
      }
    }
  }
  return r;
}
function sG(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group.units[i], u = ve.indexOf(s.elements, s.gapElements[a]), c = ve.indexOf(s.elements, s.gapElements[a % 2 ? a - 1 : a + 1]);
    if (u !== -1 && c !== -1) return rt.Loci(o, [rt.Location(o, s, u, o, s, c), rt.Location(o, s, c, o, s, u)]);
  }
  return Sn;
}
function uG(e, t, n) {
  var r = !1;
  if (rt.isLoci(e)) {
    var i = t.structure, a = t.group;
    if (!Be.areRootsEquivalent(e.structure, i)) return !1;
    e = rt.remapLoci(e, i);
    for (var o = a.units[0].gapElements.length, s = 0, u = e.bonds; s < u.length; s++) {
      var c = u[s], l = a.unitIndexMap.get(c.aUnit.id);
      if (l !== void 0) {
        var d = ve.indexOf(c.aUnit.gapElements, c.aUnit.elements[c.aIndex]), m = ve.indexOf(c.bUnit.gapElements, c.bUnit.elements[c.bIndex]);
        d !== -1 && m !== -1 && n(oe.ofSingleton(l * o + d)) && (r = !0);
      }
    }
  } else if (Se.is(e)) {
    if (i = t.structure, a = t.group, !Be.areRootsEquivalent(e.structure, i)) return !1;
    e = Se.remap(e, i);
    for (var p = a.units[0].gapElements.length, v = function(h) {
      var g = a.unitIndexMap.get(h.unit.id);
      g !== void 0 && ve.forEach(h.indices, function(x) {
        var C = ve.indexOf(h.unit.gapElements, h.unit.elements[x]);
        C !== -1 && n(oe.ofSingleton(g * p + C)) && (r = !0);
      });
    }, f = 0, y = e.elements; f < y.length; f++)
      v(y[f]);
  }
  return r;
}
function $S(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group.units[i];
    if (me.isAtomic(s)) return RS(o, s, s.nucleotideElements[a]);
  }
  return Sn;
}
function cG(e) {
  return e.nucleotideElements;
}
function eC(e, t, n) {
  var r = !1;
  if (!Se.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!Be.areEquivalent(e.structure, i)) return !1;
  var o = a.units[0];
  if (!me.isAtomic(o)) return !1;
  for (var s = o.nucleotideElements.length, u = 0, c = e.elements; u < c.length; u++) {
    var l = c[u];
    if (me.isAtomic(l.unit) && a.unitIndexMap.has(l.unit.id)) {
      var d = a.unitIndexMap.get(l.unit.id) * s;
      me.isAtomic(l.unit) && (r = QS(d, s, cG, n, l) || r);
    }
  }
  return r;
}
(function(e) {
  e.fromGroup = function(t) {
    var n = t.group, r = t.structure, i = n.units[0].polymerElements, a = i.length, o = n.units.length, s = Ne.create(r);
    return Zn(a, o, 1, function(u, c) {
      var l = n.units[c];
      return s.unit = l, s.element = i[u], s;
    });
  };
})(v0 || (v0 = {})), function(e) {
  e.fromGroup = function(t) {
    var n = t.group, r = t.structure, i = n.units[0].gapElements, a = i.length, o = n.units.length, s = Ne.create(r);
    return Zn(a, o, 1, function(u, c) {
      var l = n.units[c];
      return s.unit = l, s.element = i[u], s;
    });
  };
}(rg || (rg = {})), function(e) {
  e.fromGroup = function(t) {
    var n = t.group, r = t.structure, i = n.units[0], a = me.isAtomic(i) ? i.nucleotideElements : [], o = a.length, s = n.units.length, u = Ne.create(r);
    return Zn(o, s, 1, function(c, l) {
      var d = n.units[l];
      return u.unit = d, u.element = a[c], u;
    });
  };
}(g0 || (g0 = {}));
var _d = S(), H1 = S(), A_ = S(), I_ = S(), w_ = S(), P_ = S(), q1 = S(), Fh = S(), Gh = S(), E_ = S(), xd = J.identity(), lG = S(), T_ = ux(), tC = { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: N.Numeric(16, { min: 2, max: 56, step: 2 }, Ve.CustomQualityParamInfo) };
function dG(e, t, n, r, i, a) {
  if (!me.isAtomic(t)) return ht.createEmpty(a);
  var o = t.nucleotideElements.length;
  if (!o) return ht.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = o * (T_.vertices.length / 3 + 2 * u), l = nt.createState(c, c / 4, a), d = t.elements, m = t.model, p = m.atomicHierarchy, v = p.chainAtomSegments, f = p.residueAtomSegments, y = p.atoms, h = p.index, g = m.atomicHierarchy.derived.residue, x = g.moleculeType, C = g.traceElementIndex, b = y.label_comp_id, _ = t.conformation.invariantPosition, A = St.transientSegments(v, d), I = St.transientSegments(f, d), w = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u, bottomCap: !0 }, E = 0; A.hasNext; ) for (I.setSegment(A.move()); I.hasNext; ) {
    var D = I.move().index;
    if (nd(x[D])) {
      var T = b.value(f.offsets[D]), P = -1, M = -1, R = -1, O = -1, L = -1, F = -1, G = 2.5 * s, V = 4.5, U = p9(T), q = h9(T);
      if (!U && !q) {
        var H = h.findAtomOnResidue(D, "C4"), K = h.findAtomOnResidue(D, "N9");
        H !== -1 && K !== -1 && S.distance(_(H, _d), _(K, H1)) < 1.6 ? U = !0 : q = !0;
      }
      U ? (V = 4.5, P = h.findAtomOnResidue(D, "N1"), M = h.findAtomOnResidue(D, "C4"), R = h.findAtomOnResidue(D, "C6"), O = h.findAtomOnResidue(D, "C2"), L = h.findAtomOnResidue(D, "N9"), F = C[D]) : q && (V = 3, P = h.findAtomOnResidue(D, "N3"), M = h.findAtomOnResidue(D, "C6"), R = h.findAtomOnResidue(D, "C4"), O = h.findAtomOnResidue(D, "C2"), (L = h.findAtomOnResidue(D, "N1")) === -1 && (L = h.findAtomOnResidue(D, "C1")), F = C[D]), L !== -1 && F !== -1 && (_(L, w_), _(F, P_), l.currentGroup = E, pr(l, w_, P_, 1, w), P !== -1 && M !== -1 && R !== -1 && O !== -1 && (_(P, _d), _(M, H1), _(R, A_), _(O, I_), S.normalize(q1, S.sub(q1, H1, _d)), S.normalize(Fh, S.sub(Fh, I_, A_)), S.normalize(Gh, S.cross(Gh, q1, Fh)), J.targetTo(xd, _d, H1, Gh), S.scaleAndAdd(E_, _d, q1, V / 2 - 0.2), J.scale(xd, xd, S.set(lG, 4.5, G, V)), J.setTranslation(xd, E_), nt.addPrimitive(l, xd, T_))), ++E;
    }
  }
  var j = nt.getMesh(l), W = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return j.setBoundingSphere(W), j;
}
N.getDefaultValues(tC);
var nC = B(B({}, Ds), tC);
function fG(e) {
  return Bs({ defaultProps: N.getDefaultValues(nC), createGeometry: dG, createLocationIterator: g0.fromGroup, getLoci: $S, eachLocation: eC, setUpdateState: function(t, n, r) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.radialSegments !== r.radialSegments;
  } }, e);
}
var j1 = S.zero(), Vs = S.zero(), K1 = S.zero(), X1 = S.zero(), qu = S.zero(), ol = S.zero(), Y1 = S.zero(), M_ = S.zero(), D_ = S.zero(), Sd = S.zero(), zs = S.zero(), rC = { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: N.Numeric(16, { min: 2, max: 56, step: 2 }, Ve.CustomQualityParamInfo), detail: N.Numeric(0, { min: 0, max: 3, step: 1 }, Ve.CustomQualityParamInfo) };
N.getDefaultValues(rC);
var W1 = new Float32Array(54), mG = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), pG = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), hG = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), Z1 = new Float32Array(36), vG = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), gG = new Uint32Array([0, 10, 8, 6, 4, 2]), yG = new Uint32Array([1, 3, 5, 7, 9, 11]), B_ = S.zero();
function R_(e, t) {
  for (var n = [], r = 2; r < arguments.length; r++) n[r - 2] = arguments[r];
  for (var i = 0, a = n.length; i < a; ++i) {
    var o = n[i];
    S.toArray(S.add(B_, o, t), e, 2 * i * 3), S.toArray(S.sub(B_, o, t), e, 3 * (2 * i + 1));
  }
}
function bG(e, t, n, r, i, a) {
  if (!me.isAtomic(t)) return ht.createEmpty(a);
  var o = t.nucleotideElements.length;
  if (!o) return ht.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = i.detail, l = o * (26 + 2 * u), d = nt.createState(l, l / 4, a), m = t.elements, p = t.model, v = p.atomicHierarchy, f = v.chainAtomSegments, y = v.residueAtomSegments, h = v.atoms, g = v.index, x = p.atomicHierarchy.derived.residue, C = x.moleculeType, b = x.traceElementIndex, _ = h.label_comp_id, A = t.conformation.invariantPosition, I = St.transientSegments(f, m), w = St.transientSegments(y, m), E = 1 * s, D = 1.25 * s, T = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u }, P = 0; I.hasNext; ) for (w.setSegment(I.move()); w.hasNext; ) {
    var M = w.move().index;
    if (nd(C[M])) {
      var R = _.value(y.offsets[M]), O = -1, L = -1, F = -1, G = -1, V = -1, U = -1, q = -1, H = -1, K = -1, j = -1;
      d.currentGroup = P;
      var W = p9(R), Z = h9(R);
      if (!W && !Z) {
        var Y = g.findAtomOnResidue(M, "C4"), te = g.findAtomOnResidue(M, "N9");
        Y !== -1 && te !== -1 && S.distance(A(Y, qu), A(te, Sd)) < 1.6 ? W = !0 : Z = !0;
      }
      W ? (O = b[M], L = g.findAtomOnResidue(M, "N1"), F = g.findAtomOnResidue(M, "C2"), G = g.findAtomOnResidue(M, "N3"), V = g.findAtomOnResidue(M, "C4"), (U = g.findAtomOnResidue(M, "C5")) === -1 && (U = g.findAtomOnResidue(M, "N5")), q = g.findAtomOnResidue(M, "C6"), (H = g.findAtomOnResidue(M, "N7")) === -1 && (H = g.findAtomOnResidue(M, "C7")), K = g.findAtomOnResidue(M, "C8"), (j = g.findAtomOnResidue(M, "N9")) !== -1 && O !== -1 && (A(j, Sd), A(O, j1), d.currentGroup = P, pr(d, Sd, j1, 1, T), yr(d, Sd, E, c)), L !== -1 && F !== -1 && G !== -1 && V !== -1 && U !== -1 && q !== -1 && H !== -1 && K !== -1 && j !== -1 && (A(L, Vs), A(F, K1), A(G, X1), A(V, qu), A(U, ol), A(q, Y1), A(H, M_), A(K, D_), S.triangleNormal(zs, Vs, qu, ol), S.scale(zs, zs, D), R_(W1, zs, Vs, K1, X1, qu, ol, Y1, M_, D_, Sd), nt.addTriangleStrip(d, W1, mG), nt.addTriangleFan(d, W1, pG), nt.addTriangleFan(d, W1, hG))) : Z && (O = b[M], (L = g.findAtomOnResidue(M, "N1")) === -1 && (L = g.findAtomOnResidue(M, "C1")), F = g.findAtomOnResidue(M, "C2"), G = g.findAtomOnResidue(M, "N3"), V = g.findAtomOnResidue(M, "C4"), U = g.findAtomOnResidue(M, "C5"), q = g.findAtomOnResidue(M, "C6"), L !== -1 && O !== -1 && (A(L, Vs), A(O, j1), d.currentGroup = P, pr(d, Vs, j1, 1, T), yr(d, Vs, E, c)), L !== -1 && F !== -1 && G !== -1 && V !== -1 && U !== -1 && q !== -1 && (A(F, K1), A(G, X1), A(V, qu), A(U, ol), A(q, Y1), S.triangleNormal(zs, Vs, qu, ol), S.scale(zs, zs, D), R_(Z1, zs, Vs, K1, X1, qu, ol, Y1), nt.addTriangleStrip(d, Z1, vG), nt.addTriangleFan(d, Z1, gG), nt.addTriangleFan(d, Z1, yG))), ++P;
    }
  }
  var ee = nt.getMesh(d), $ = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return ee.setBoundingSphere($), ee;
}
var iC = B(B({}, Ds), rC);
function _G(e) {
  return Bs({ defaultProps: N.getDefaultValues(iC), createGeometry: bG, createLocationIterator: g0.fromGroup, getLoci: $S, eachLocation: eC, setUpdateState: function(t, n, r) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.radialSegments !== r.radialSegments;
  } }, e);
}
var Vh, ju = S.zero(), sl = S.zero(), Ku = S.zero(), k_ = S.zero(), cr = B0(3, !1), Xu = J.identity(), xG = S.zero(), O_ = S.zero(), N_ = S.zero(), zh = S.zero(), SG = 4, CG = 4, AG = 6, IG = (Vh || (Vh = function() {
  for (var e = zf(8), t = 0; t < 3; ++t) {
    var n = (t + 1) % 3;
    S.set(ju, cr[3 * t], cr[3 * t + 1], -0.5), S.set(sl, cr[3 * n], cr[3 * n + 1], -0.5), S.set(Ku, cr[3 * n], cr[3 * n + 1], 0.5), S.set(k_, cr[3 * t], cr[3 * t + 1], 0.5), e.add(ju, sl, Ku), e.add(Ku, k_, ju);
  }
  return S.set(ju, cr[0], cr[1], -0.5), S.set(sl, cr[3], cr[4], -0.5), S.set(Ku, cr[6], cr[7], -0.5), e.add(Ku, sl, ju), S.set(ju, cr[0], cr[1], 0.5), S.set(sl, cr[3], cr[4], 0.5), S.set(Ku, cr[6], cr[7], 0.5), e.add(ju, sl, Ku), e.getPrimitive();
}()), Vh), aC = { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }) };
function wG(e, t, n, r, i, a) {
  var o = t.polymerElements.length;
  if (!o) return ht.createEmpty(a);
  for (var s = i.sizeFactor, u = 24 * o, c = nt.createState(u, u / 10, a), l = XS(1), d = l.normalVectors, m = l.binormalVectors, p = 0, v = jS(t, n); v.hasNext; ) {
    var f = v.move();
    c.currentGroup = p;
    var y = nd(f.moleculeType), h = Ft.is(f.secStrucType, 4);
    if (YS(l, f, y || h ? 0.5 : 0.9, y ? 0.3 : 0.5), h && !f.secStrucLast || !h) {
      var g = r.size.size(f.center) * s, x = SG * g, C = CG * g, b = AG * g, _ = y ? m : d;
      S.fromArray(O_, _, 0), S.fromArray(N_, _, 3), S.normalize(zh, S.add(zh, O_, N_)), J.targetTo(Xu, f.p3, f.p1, zh), J.mul(Xu, Xu, J.rotY90Z180), J.scale(Xu, Xu, S.set(xG, b, C, x)), J.setTranslation(Xu, f.p2), nt.addPrimitive(c, Xu, IG);
    }
    ++p;
  }
  var A = nt.getMesh(c), I = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return A.setBoundingSphere(I), A;
}
N.getDefaultValues(aC);
var oC = B(B({}, Ds), aC);
function PG(e) {
  return Bs({ defaultProps: N.getDefaultValues(oC), createGeometry: wG, createLocationIterator: v0.fromGroup, getLoci: ZS, eachLocation: JS, setUpdateState: function(t, n, r) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor;
  } }, e);
}
var Uh = 10, sC = { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: N.Numeric(16, { min: 2, max: 56, step: 2 }, Ve.CustomQualityParamInfo) };
function EG(e, t, n, r, i, a) {
  var o = t.gapElements.length;
  if (!o) return ht.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = Uh * u * 2 * o * 2, l = nt.createState(c, c / 10, a), d = t.conformation.invariantPosition, m = S.zero(), p = S.zero(), v = { radiusTop: 1, radiusBottom: 1, topCap: !0, bottomCap: !0, radialSegments: u }, f = 0, y = function(_, A) {
    switch (A.kind) {
      case 0:
        return new KF(_, A);
      case 1:
      case 2:
        return new XF(_, A);
    }
  }(n, t); y.hasNext; ) {
    var h = y.move(), g = h.centerA, x = h.centerB;
    g.element === x.element || (d(g.element, m), d(x.element, p), v.radiusTop = v.radiusBottom = r.size.size(g) * s, l.currentGroup = f, sf(l, m, p, 0.5, Uh, v), v.radiusTop = v.radiusBottom = r.size.size(x) * s, l.currentGroup = f + 1, sf(l, p, m, 0.5, Uh, v)), f += 2;
  }
  var C = nt.getMesh(l), b = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return C.setBoundingSphere(b), C;
}
N.getDefaultValues(sC);
var uC = B(B({}, Ds), sC);
function TG(e) {
  return Bs({ defaultProps: N.getDefaultValues(uC), createGeometry: EG, createLocationIterator: rg.fromGroup, getLoci: sG, eachLocation: uG, setUpdateState: function(t, n, r) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.radialSegments !== r.radialSegments;
  } }, e);
}
var Ht = S(), Qt = S(), MG = S(), Wi = S(), So = S(), Q1 = S(), J1 = S(), Cd = S(), Xa = S(), Co = S(), Hh = S(), Us = S(), Hs = S(), qs = S(), js = S(), ya = S.fromArray, Al = S.scale, Sa = S.add, ls = S.sub, DG = S.magnitude, L_ = S.negate, ig = S.copy, cC = S.cross, BG = S.set, $t = he.add3, RG = he.add;
function $1(e, t, n, r, i, a, o, s, u) {
  var c = t.vertices, l = t.normals, d = t.indices, m = c.elementCount;
  if (ya(Ht, r, e), Al(J1, Ht, o), Al(Q1, Ht, s), ya(Qt, i, e), Al(Wi, Qt, a), cC(Co, Qt, Ht), ya(Xa, n, e), Sa(Us, Sa(Us, Xa, Wi), Q1), ls(Hs, Sa(Hs, Xa, Wi), J1), ls(qs, ls(qs, Xa, Wi), J1), Sa(js, ls(js, Xa, Wi), Q1), o < s ? ($t(c, js[0], js[1], js[2]), $t(c, qs[0], qs[1], qs[2]), $t(c, Hs[0], Hs[1], Hs[2]), $t(c, Us[0], Us[1], Us[2]), ig(So, Q1)) : ($t(c, Us[0], Us[1], Us[2]), $t(c, Hs[0], Hs[1], Hs[2]), $t(c, qs[0], qs[1], qs[2]), $t(c, js[0], js[1], js[2]), ig(So, J1)), u) {
    for (var p = 0; p < 4; ++p) $t(l, -Co[0], -Co[1], -Co[2]);
    $t(d, m, m + 1, m + 2), $t(d, m + 2, m + 3, m);
  } else {
    for (p = 0; p < 4; ++p) $t(l, Co[0], Co[1], Co[2]);
    $t(d, m + 2, m + 1, m), $t(d, m, m + 3, m + 2);
  }
}
function qh(e, t, n, r, i, a, o, s, u, c) {
  var l = e.currentGroup, d = e.vertices, m = e.normals, p = e.indices, v = e.groups, f = d.elementCount, y = 0;
  s > 0 ? (ya(Ht, t, 0), ya(Qt, t, 3 * i), y = s / DG(ls(MG, Qt, Ht))) : BG(Cd, 0, 0, 0);
  for (var h = 0; h <= i; ++h) {
    var g = a[h], x = o[h], C = s === 0 ? x : s * (1 - h / i), b = 3 * h;
    ya(So, n, b), Al(So, So, C), ya(Wi, r, b), Al(Wi, Wi, g), s > 0 && (ya(Ht, n, b), ya(Qt, r, b), Al(Cd, cC(Cd, Ht, Qt), y)), ya(Xa, t, b), ya(Co, n, b), ya(Hh, r, b), Sa(Ht, Sa(Ht, Xa, Wi), So), Sa(Qt, Co, Cd), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), Sa(Ht, ls(Ht, Xa, Wi), So), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), L_(Qt, Hh), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), ls(Ht, ls(Ht, Xa, Wi), So), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), Sa(Qt, L_(Qt, Co), Cd), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), ls(Ht, Sa(Ht, Xa, Wi), So), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), ig(Qt, Hh), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]), Sa(Ht, Sa(Ht, Xa, Wi), So), $t(d, Ht[0], Ht[1], Ht[2]), $t(m, Qt[0], Qt[1], Qt[2]);
  }
  for (h = 0; h < i; ++h) {
    for (var _ = 0; _ < 2; _++) $t(p, f + 8 * h + 2 * _, f + 8 * (h + 1) + 2 * _ + 1, f + 8 * h + 2 * _ + 1), $t(p, f + 8 * h + 2 * _, f + 8 * (h + 1) + 2 * _, f + 8 * (h + 1) + 2 * _ + 1);
    for (_ = 2; _ < 4; _++) $t(p, f + 8 * h + 2 * _, f + 8 * (h + 1) + 2 * _, f + 8 * h + 2 * _ + 1), $t(p, f + 8 * (h + 1) + 2 * _, f + 8 * (h + 1) + 2 * _ + 1, f + 8 * h + 2 * _ + 1);
  }
  if (u) {
    var g = a[0], x = o[0], A = s === 0 ? x : s;
    $1(0, e, t, n, r, g, A, A, !1);
  } else s > 0 && ($1(0, e, t, n, r, g = a[0], s, -(x = o[0]), !1), $1(0, e, t, n, r, g, -s, x, !1));
  c && s === 0 && $1(3 * i, e, t, n, r, g = a[i], x = o[i], x, !0), h = 0;
  for (var I = 8 * (i + 1) + (u ? 4 : s > 0 ? 8 : 0) + (c && s === 0 ? 4 : 0); h < I; ++h) RG(v, l);
}
var jn = S(), ar = S(), vi = S(), Rr = S(), ti = S();
function em(e, t, n, r, i) {
  e[0] = t[0] * r + n[0] * i, e[1] = t[1] * r + n[1] * i, e[2] = t[2] * r + n[2] * i;
}
function ul(e, t, n, r, i, a) {
  e[0] = t[0] * i + n[0] * a + r[0], e[1] = t[1] * i + n[1] * a + r[1], e[2] = t[2] * i + n[2] * a + r[2];
}
var ts = S.fromArray, kG = S.normalize, jh = S.scaleAndAdd, F_ = S.cross, OG = S.dot, NG = S.unitX, ni = he.add3, Kh = /* @__PURE__ */ new Map();
function G_(e, t, n, r, i, a, o, s, u, c, l) {
  for (var d = e.currentGroup, m = e.vertices, p = e.normals, v = e.indices, f = e.groups, y = m.elementCount, h = function(L, F) {
    var G = F ? 1 : 0, V = Ta(L, G);
    if (!Kh.has(V)) {
      for (var U = [], q = [], H = 0; H < L; ++H) {
        var K = (2 * H + G) / L * Math.PI;
        U[H] = Math.cos(K), q[H] = Math.sin(K);
      }
      Kh.set(V, { cos: U, sin: q });
    }
    return Kh.get(V);
  }(a, l === "rounded"), g = h.cos, x = h.sin, C = Math.round(a / 4), b = 3 * C, _ = 0; _ <= i; ++_) {
    var A = 3 * _;
    ts(Rr, n, A), ts(ti, r, A), ts(vi, t, A);
    for (var I = o[_], w = s[_], E = l === "rounded" && w > I, D = 0; D < a; ++D) {
      if (E) {
        ul(ar, Rr, ti, vi, I * g[D], I * x[D]);
        var T = OG(ti, NG) < 0 ? D < C || D >= b ? w - I : -w + I : D >= C && D < b ? -w + I : w - I;
        jh(ar, ar, Rr, T), D === C || D === C - 1 ? em(jn, Rr, ti, 0, 1) : D === b || D === b - 1 ? em(jn, Rr, ti, 0, -1) : em(jn, Rr, ti, g[D], x[D]);
      } else ul(ar, Rr, ti, vi, w * g[D], I * x[D]), em(jn, Rr, ti, I * g[D], w * x[D]);
      kG(jn, jn), ni(m, ar[0], ar[1], ar[2]), ni(p, jn[0], jn[1], jn[2]);
    }
  }
  var P = Math.round(a / 2);
  for (_ = 0; _ < i; ++_) {
    for (D = 0; D < P; ++D) ni(v, y + _ * a + (D + 1) % a, y + (_ + 1) * a + (D + 1) % a, y + _ * a + D), ni(v, y + (_ + 1) * a + (D + 1) % a, y + (_ + 1) * a + D, y + _ * a + D);
    for (D = P; D < a; ++D) ni(v, y + _ * a + (D + 1) % a, y + (_ + 1) * a + D, y + _ * a + D), ni(v, y + (_ + 1) * a + (D + 1) % a, y + (_ + 1) * a + D, y + _ * a + (D + 1) % a);
  }
  if (u) {
    var M = 0, R = m.elementCount;
    for (ts(Rr, n, M), ts(ti, r, M), ts(vi, t, M), F_(jn, ti, Rr), ni(m, vi[0], vi[1], vi[2]), ni(p, jn[0], jn[1], jn[2]), I = o[0], w = s[0], (E = l === "rounded" && w > I) && (w -= I), y = m.elementCount, _ = 0; _ < a; ++_) E ? (ul(ar, Rr, ti, vi, I * g[_], I * x[_]), jh(ar, ar, Rr, _ < C || _ >= b ? w : -w)) : ul(ar, Rr, ti, vi, w * g[_], I * x[_]), ni(m, ar[0], ar[1], ar[2]), ni(p, jn[0], jn[1], jn[2]), ni(v, y + (_ + 1) % a, y + _, R);
  }
  if (c)
    for (M = 3 * i, R = m.elementCount, ts(Rr, n, M), ts(ti, r, M), ts(vi, t, M), F_(jn, Rr, ti), ni(m, vi[0], vi[1], vi[2]), ni(p, jn[0], jn[1], jn[2]), I = o[i], w = s[i], (E = l === "rounded" && w > I) && (w -= I), y = m.elementCount, _ = 0; _ < a; ++_) E ? (ul(ar, Rr, ti, vi, I * g[_], I * x[_]), jh(ar, ar, Rr, _ < C || _ >= b ? w : -w)) : ul(ar, Rr, ti, vi, w * g[_], I * x[_]), ni(m, ar[0], ar[1], ar[2]), ni(p, jn[0], jn[1], jn[2]), ni(v, y + _, y + (_ + 1) % a, R);
  var O = (i + 1) * a + (u ? a + 1 : 0) + (c ? a + 1 : 0);
  he.addRepeat(f, O, d);
}
var ns = S.fromArray, LG = S.magnitude, Xh = S.sub, V_ = S.add, Yh = S.scale, FG = S.negate, GG = S.copy, VG = S.cross, ma = he.add3, zG = he.add, lr = S(), kr = S(), UG = S(), Wh = S(), Yu = S(), z_ = S(), Ad = S(), HG = S(), Zh = S();
function Qh(e, t, n, r, i, a, o, s) {
  var u = e.currentGroup, c = e.vertices, l = e.normals, d = e.indices, m = e.groups, p = c.elementCount, v = 0;
  s > 0 && (ns(lr, t, 0), ns(kr, t, 3 * i), v = s / LG(Xh(UG, kr, lr)));
  for (var f = 0; f <= i; ++f) {
    var y = a[f], h = o[f], g = s === 0 ? h : s * (1 - f / i), x = 3 * f;
    ns(Yu, n, x), Yh(Yu, Yu, g), ns(Wh, r, x), Yh(Wh, Wh, y), s > 0 && (ns(lr, n, x), ns(kr, r, x), Yh(z_, VG(z_, lr, kr), v)), ns(Ad, t, x), ns(HG, n, x), ns(Zh, r, x), V_(lr, Ad, Yu), FG(kr, Zh), ma(c, lr[0], lr[1], lr[2]), ma(l, kr[0], kr[1], kr[2]), Xh(lr, Ad, Yu), ma(c, lr[0], lr[1], lr[2]), ma(l, kr[0], kr[1], kr[2]), V_(lr, Ad, Yu), GG(kr, Zh), ma(c, lr[0], lr[1], lr[2]), ma(l, kr[0], kr[1], kr[2]), Xh(lr, Ad, Yu), ma(c, lr[0], lr[1], lr[2]), ma(l, kr[0], kr[1], kr[2]);
  }
  for (f = 0; f < i; ++f) ma(d, p + 4 * f, p + 4 * (f + 1) + 1, p + 4 * f + 1), ma(d, p + 4 * f, p + 4 * (f + 1), p + 4 * (f + 1) + 1), ma(d, p + 4 * f + 2 + 1, p + 4 * (f + 1) + 2 + 1, p + 4 * f + 2), ma(d, p + 4 * f + 2, p + 4 * (f + 1) + 2 + 1, p + 4 * (f + 1) + 2);
  f = 0;
  for (var C = 4 * (i + 1); f < C; ++f) zG(m, u);
}
var lC = { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), aspectRatio: N.Numeric(5, { min: 0.1, max: 10, step: 0.1 }), arrowFactor: N.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }), tubularHelices: N.Boolean(!1, { description: "Draw alpha helices as tubes" }), helixProfile: N.Select("elliptical", N.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein and nucleic helix trace profile" }), detail: N.Numeric(0, { min: 0, max: 3, step: 1 }, Ve.CustomQualityParamInfo), linearSegments: N.Numeric(8, { min: 1, max: 48, step: 1 }, Ve.CustomQualityParamInfo), radialSegments: N.Numeric(16, { min: 2, max: 56, step: 2 }, Ve.CustomQualityParamInfo) };
N.getDefaultValues(lC);
var Di = S();
function qG(e, t, n, r, i, a) {
  var o = t.polymerElements.length;
  if (!o) return ht.createEmpty(a);
  for (var s = i.sizeFactor, u = i.detail, c = i.linearSegments, l = i.radialSegments, d = i.aspectRatio, m = i.arrowFactor, p = i.tubularHelices, v = i.helixProfile, f = c * l * o + (l + 1) * o * 2, y = nt.createState(f, f / 10, a), h = me.isCoarse(t), g = XS(c), x = g.curvePoints, C = g.normalVectors, b = g.binormalVectors, _ = g.widthValues, A = g.heightValues, I = 0, w = jS(t, n, { ignoreSecondaryStructure: !1, useHelixOrientation: p }); w.hasNext; ) {
    var E = w.move();
    y.currentGroup = I;
    var D = nd(E.moleculeType), T = Ft.is(E.secStrucType, 4), P = Ft.is(E.secStrucType, 2), M = D ? aG : iG;
    YS(g, E, P && !p ? rG : nG, M);
    var R = r.size.size(E.centerPrev) * s, O = r.size.size(E.center) * s, L = r.size.size(E.centerNext) * s;
    h && (R *= d / 2, O *= d / 2, L *= d / 2);
    var F = E.secStrucFirst || E.coarseBackboneFirst || E.first, G = E.secStrucLast || E.coarseBackboneLast || E.last, V = c;
    if (E.initial) {
      var U = c - (V = Math.max(Math.round(c * M), 1));
      x.copyWithin(0, 3 * U), b.copyWithin(0, 3 * U), C.copyWithin(0, 3 * U), S.fromArray(Di, x, 3), S.normalize(Di, S.sub(Di, E.p2, Di)), S.scaleAndAdd(Di, E.p2, Di, O * S_), S.toArray(Di, x, 0);
    } else E.final && (V = Math.max(Math.round(c * (1 - M)), 1), S.fromArray(Di, x, 3 * V - 3), S.normalize(Di, S.sub(Di, E.p2, Di)), S.scaleAndAdd(Di, E.p2, Di, O * S_), S.toArray(Di, x, 3 * V));
    if (E.initial === !0 && E.final === !0) yr(y, E.p2, 2 * O, u);
    else if (T) {
      var q = R * d, H = O * d, K = L * d, j = E.secStrucLast ? H * m : 0;
      x_(g, R, O, L, q, H, K, M), l === 2 ? Qh(y, x, C, b, V, _, A, j) : qh(y, x, C, b, V, _, A, j, F, G);
    } else {
      q = void 0, H = void 0, K = void 0, P && !E.isCoarseBackbone ? p ? (q = R *= 1.5 * d, H = O *= 1.5 * d, K = L *= 1.5 * d) : (q = R * d, H = O * d, K = L * d) : D && !E.isCoarseBackbone ? (q = R * d, H = O * d, K = L * d) : (q = R, H = O, K = L), x_(g, R, O, L, q, H, K, M);
      var W = D && !E.isCoarseBackbone ? [b, C] : [C, b], Z = W[0], Y = W[1];
      if (D && !E.isCoarseBackbone) for (var te = 0, ee = Z.length; te < ee; te++) Z[te] *= -1;
      l === 2 ? D && !E.isCoarseBackbone ? Qh(y, x, Z, Y, V, A, _, 0) : Qh(y, x, Z, Y, V, _, A, 0) : l === 4 ? qh(y, x, Z, Y, V, _, A, 0, F, G) : H === O ? G_(y, x, Z, Y, V, l, _, A, F, G, "elliptical") : v === "square" ? qh(y, x, Z, Y, V, _, A, 0, F, G) : G_(y, x, Z, Y, V, l, _, A, F, G, v);
    }
    ++I;
  }
  var $ = nt.getMesh(y), ue = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return $.setBoundingSphere(ue), $;
}
var dC = B(B({}, Ds), lC);
function jG(e) {
  return Bs({ defaultProps: N.getDefaultValues(dC), createGeometry: qG, createLocationIterator: v0.fromGroup, getLoci: ZS, eachLocation: JS, setUpdateState: function(t, n, r, i, a, o, s) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.tubularHelices !== r.tubularHelices || n.detail !== r.detail || n.linearSegments !== r.linearSegments || n.radialSegments !== r.radialSegments || n.aspectRatio !== r.aspectRatio || n.arrowFactor !== r.arrowFactor || n.helixProfile !== r.helixProfile;
    var u = ei.get(o.structure).version;
    t.info.secondaryStructureHash !== u && (t.createGeometry = t.info.secondaryStructureHash !== void 0, t.info.secondaryStructureHash = u);
  } }, e);
}
var fC = { "polymer-trace": function(e, t) {
  return ui("Polymer trace mesh", e, t, jG);
}, "polymer-gap": function(e, t) {
  return ui("Polymer gap cylinder", e, t, TG);
}, "nucleotide-block": function(e, t) {
  return ui("Nucleotide block mesh", e, t, fG);
}, "nucleotide-ring": function(e, t) {
  return ui("Nucleotide ring mesh", e, t, _G);
}, "direction-wedge": function(e, t) {
  return ui("Polymer direction wedge", e, t, PG);
} }, U_ = B(B(B(B(B(B({}, dC), uC), nC), iC), oC), { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: N.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring"], N.objectToOptions(fC)), bumpFrequency: N.Numeric(2, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory) }), Mf, us = { name: "cartoon", label: "Cartoon", description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.", factory: function(e, t) {
  return Mt.createMulti("Cartoon", e, t, ia, fC);
}, getParams: function(e, t) {
  var n = N.clone(U_), r = !1, i = !1;
  return t.units.forEach(function(a) {
    !r && me.isAtomic(a) && a.nucleotideElements.length && (r = !0), !i && a.gapElements.length && (i = !0);
  }), n.visuals.defaultValue = ["polymer-trace"], r && n.visuals.defaultValue.push("nucleotide-ring"), i && n.visuals.defaultValue.push("polymer-gap"), n;
}, defaultValues: N.getDefaultValues(U_), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.polymerResidueCount > 0;
}, ensureCustomProperties: { attach: function(e, t) {
  return ie(void 0, 0, void 0, function() {
    var n, r, i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, ei.attach(e, t, void 0, !0)];
        case 1:
          a.sent(), n = 0, r = t.models, a.label = 2;
        case 2:
          return n < r.length ? (i = r[n], [4, ng.attach(e, i, void 0, !0)]) : [3, 5];
        case 3:
          a.sent(), a.label = 4;
        case 4:
          return n++, [3, 2];
        case 5:
          return [2];
      }
    });
  });
}, detach: function(e) {
  ei.ref(e, !1);
  for (var t = 0, n = e.models; t < n.length; t++) {
    var r = n[t];
    ng.ref(r, !1);
  }
} } }, KG = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.elementCount ? [4, ei.attach({ runtime: Ji, assetManager: new ds() }, e)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return (r = us.factory(t, us.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, r.createOrUpdate(B(B({}, us.defaultValues), { quality: "auto" }), e).run()];
        case 3:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("uniform", { structure: t }) }), t.elementCount ? [4, ei.attach({ runtime: Ji, assetManager: new ds() }, t)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return [4, e.createOrUpdate({}, t).run()];
        case 3:
          return i.sent(), [2];
      }
    });
  });
} }, tm = S(), nm = S(), Wu = S(), Jh = he.add, H_ = he.add3;
(function(e) {
  e.create = function(t, n, r) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024);
    var i = he.create(Float32Array, 1, n, r ? r.groupBuffer.ref.value : t), a = he.create(Float32Array, 3, n, r ? r.startBuffer.ref.value : t), o = he.create(Float32Array, 3, n, r ? r.endBuffer.ref.value : t), s = he.create(Float32Array, 1, n, r ? r.scaleBuffer.ref.value : t), u = he.create(Float32Array, 1, n, r ? r.capBuffer.ref.value : t), c = function(d, m, p, v, f, y, h, g, x, C) {
      for (var b = 0; b < 6; ++b) H_(a, d, m, p), H_(o, v, f, y), Jh(i, C), Jh(s, h), Jh(u, (g ? 1 : 0) + (x ? 2 : 0));
    }, l = function(d, m, p, v, f, y, h) {
      var g = S.distance(d, m), x = Math.floor(p / 2), C = 1 / p;
      S.sub(Wu, m, d);
      for (var b = 0; b < x; ++b) {
        var _ = C * (2 * b + 1);
        S.setMagnitude(Wu, Wu, g * _), S.add(tm, d, Wu), S.setMagnitude(Wu, Wu, g * C * (2 * (b + 1))), S.add(nm, d, Wu), c(tm[0], tm[1], tm[2], nm[0], nm[1], nm[2], v, f, y, h);
      }
    };
    return { add: c, addFixedCountDashes: l, addFixedLengthDashes: function(d, m, p, v, f, y, h) {
      var g = S.distance(d, m);
      l(d, m, g / p, v, f, y, h);
    }, getCylinders: function() {
      var d = i.elementCount / 6, m = he.compact(i, !0), p = he.compact(a, !0), v = he.compact(o, !0), f = he.compact(s, !0), y = he.compact(u, !0), h = r && d <= r.cylinderCount ? r.mappingBuffer.ref.value : new Float32Array(18 * d), g = r && d <= r.cylinderCount ? r.indexBuffer.ref.value : new Uint32Array(12 * d);
      return (!r || d > r.cylinderCount) && function(x, C, b) {
        for (var _ = 0; _ < x; ++_) {
          var A = 18 * _;
          C[A] = -1, C[A + 1] = 1, C[A + 2] = -1, C[A + 3] = -1, C[A + 4] = -1, C[A + 5] = -1, C[A + 6] = 1, C[A + 7] = 1, C[A + 8] = -1, C[A + 9] = 1, C[A + 10] = 1, C[A + 11] = 1, C[A + 12] = 1, C[A + 13] = -1, C[A + 14] = -1, C[A + 15] = 1, C[A + 16] = -1, C[A + 17] = 1;
        }
        for (_ = 0; _ < x; ++_) {
          var I = 6 * _, w = 12 * _;
          b[w] = I, b[w + 1] = I + 1, b[w + 2] = I + 2, b[w + 3] = I + 1, b[w + 4] = I + 4, b[w + 5] = I + 2, b[w + 6] = I + 2, b[w + 7] = I + 4, b[w + 8] = I + 3, b[w + 9] = I + 4, b[w + 10] = I + 5, b[w + 11] = I + 3;
        }
      }(d, h, g), li.create(h, g, m, p, v, f, y, d, r);
    } };
  };
})(Mf || (Mf = {}));
var H0 = { linkScale: N.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), linkSpacing: N.Numeric(1, { min: 0, max: 2, step: 0.01 }), linkCap: N.Boolean(!1), aromaticScale: N.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), aromaticSpacing: N.Numeric(1.5, { min: 0, max: 3, step: 0.01 }), aromaticDashCount: N.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: N.Numeric(4, { min: 2, max: 10, step: 2 }), dashScale: N.Numeric(0.8, { min: 0, max: 2, step: 0.1 }), dashCap: N.Boolean(!0), stubCap: N.Boolean(!0), radialSegments: N.Numeric(16, { min: 2, max: 56, step: 2 }, Ve.CustomQualityParamInfo) };
N.getDefaultValues(H0);
var mC = { linkScale: N.Numeric(0.5, { min: 0, max: 1, step: 0.1 }), linkSpacing: N.Numeric(0.1, { min: 0, max: 2, step: 0.01 }), aromaticDashCount: N.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: N.Numeric(4, { min: 2, max: 10, step: 2 }) };
N.getDefaultValues(mC);
var zt = S(), Ks = S(), pa = S(), XG = S.create(0, 1, 0);
function E3(e, t, n, r) {
  S.normalize(Ks, S.sub(Ks, t, n)), r !== null ? S.sub(pa, t, r) : S.copy(pa, t), S.normalize(pa, pa);
  var i = S.dot(Ks, pa);
  return 1 - Math.abs(i) < 1e-5 && (S.set(pa, 1, 0, 0), i = S.dot(Ks, pa), 1 - Math.abs(i) < 1e-5 && (S.set(pa, 0, 1, 0), i = S.dot(Ks, pa))), S.setMagnitude(Ks, Ks, i), S.sub(pa, pa, Ks), S.normalize(e, pa);
}
var Zi = S.scale, zn = S.add, gn = S.sub, Xr = S.setMagnitude, YG = S.dot;
function q0(e, t, n, r) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, s = t.style, u = t.radius, c = t.ignore, l = t.stub;
  if (!i) return { mesh: ht.createEmpty(r) };
  for (var d = n.linkScale, m = n.linkSpacing, p = n.radialSegments, v = n.linkCap, f = n.aromaticScale, y = n.aromaticSpacing, h = n.aromaticDashCount, g = n.dashCount, x = n.dashScale, C = n.dashCap, b = n.stubCap, _ = 2 * p * i * 2, A = nt.createState(_, _ / 4, r), I = S(), w = S(), E = S(), D = S(), T = 0, P = { radiusTop: 1, radiusBottom: 1, radialSegments: p, topCap: v, bottomCap: v }, M = g + 1, R = 0, O = i; R < O; ++R) if (!c || !c(R)) {
    o(I, w, R), zn(D, D, I), zn(D, D, w), T += 2, gn(zt, w, I);
    var L = YG(zt, XG) > 0, F = u(R), G = s ? s(R) : 0, V = b && !!l && l(R), U = L ? [V, v] : [v, V], q = U[0], H = U[1];
    A.currentGroup = R;
    var K = h + 1;
    if (G === 0) P.radiusTop = P.radiusBottom = F, P.topCap = q, P.bottomCap = H, pr(A, I, w, 0.5, P);
    else if (G === 1) P.radiusTop = P.radiusBottom = F * x, P.topCap = P.bottomCap = C, sf(A, I, w, 0.5, M, P);
    else if (G === 2 || G === 3 || G === 4 || G === 5 || G === 7 || G === 8) {
      var j = G === 2 || G === 3 ? 2 : G === 4 || G === 5 ? 3 : 1.5, W = F * (d / (0.5 * j)), Z = (F - W) * m;
      if (E3(E, I, w, a ? a(R) : null), P.topCap = q, P.bottomCap = H, G === 7 || G === 8) {
        P.radiusTop = P.radiusBottom = F, pr(A, I, w, 0.5, P);
        var Y = F + f * F + f * F * y;
        Xr(zt, gn(zt, w, I), 0.5 * F), zn(I, I, zt), gn(w, w, zt), P.radiusTop = P.radiusBottom = F * f, P.topCap = P.bottomCap = C, Xr(E, E, Y), gn(I, I, E), gn(w, w, E), sf(A, I, w, 0.5, K, P), G === 8 && (Xr(E, E, 2 * Y), zn(I, I, E), zn(w, w, E), sf(A, I, w, 0.5, K, P));
      } else if (G === 3 || G === 5) {
        var te = F + W + d * F * m;
        Xr(E, E, te), P.radiusTop = P.radiusBottom = F, pr(A, I, w, 0.5, P), Zi(zt, zt, m * d * 0.2), zn(I, I, zt), gn(w, w, zt), P.radiusTop = P.radiusBottom = W, P.topCap = L ? V : C, P.bottomCap = L ? C : V, Xr(E, E, te), gn(I, I, E), gn(w, w, E), pr(A, I, w, 0.5, P), j === 3 && (Xr(E, E, 2 * te), zn(I, I, E), zn(w, w, E), pr(A, I, w, 0.5, P));
      } else Xr(E, E, Z), P.radiusTop = P.radiusBottom = W, j === 3 && pr(A, I, w, 0.5, P), Kk(A, I, w, 0.5, E, P);
    } else G === 6 && (Zi(zt, zt, 0.475), zn(I, I, zt), gn(w, w, zt), P.radiusTop = P.radiusBottom = F, P.topCap = q, P.bottomCap = H, pr(A, I, w, 0.5, P));
  }
  var ee = r ? de.clone(r.boundingSphere) : void 0, $ = nt.getMesh(A);
  return T === 0 ? { mesh: $ } : (S.scale(D, D, 1 / T), ee && S.distance(D, ee.center) / ee.radius < 1 ? { mesh: $, boundingSphere: ee } : { mesh: $ });
}
function pC(e, t, n, r) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, s = t.style, u = t.radius, c = t.ignore, l = t.stub;
  if (!i) return { cylinders: li.createEmpty(r) };
  for (var d = n.linkScale, m = n.linkSpacing, p = n.linkCap, v = n.aromaticScale, f = n.aromaticSpacing, y = n.aromaticDashCount, h = n.dashCount, g = n.dashScale, x = n.dashCap, C = n.stubCap, b = 2 * i, _ = Mf.create(b, b / 4, r), A = S(), I = S(), w = S(), E = S(), D = S(), T = 0, P = h % 2 == 1 ? h : h + 1, M = 0.5 - 0.25 / P, R = y + 1, O = 0.5 - 0.25 / R, L = 0, F = i; L < F; ++L) if (!c || !c(L)) {
    o(A, I, L), zn(D, D, A), zn(D, D, I), T += 2;
    var G = u(L), V = s ? s(L) : 0, U = C && !!l && l(L);
    if (V === 0) Zi(w, zn(w, A, I), 0.5), _.add(A[0], A[1], A[2], w[0], w[1], w[2], 1, p, U, L);
    else if (V === 1) Zi(zt, gn(zt, I, A), M), gn(I, I, zt), _.addFixedCountDashes(A, I, P, g, x, x, L);
    else if (V === 2 || V === 3 || V === 4 || V === 5 || V === 7 || V === 8) {
      var q = V === 2 || V === 3 ? 2 : V === 4 || V === 5 ? 3 : 1.5, H = d / (0.5 * q), K = (G - H * G) * m;
      if (Zi(w, zn(w, A, I), 0.5), E3(E, A, I, a ? a(L) : null), V === 7 || V === 8) {
        _.add(A[0], A[1], A[2], w[0], w[1], w[2], 1, p, U, L);
        var j = G + v * G + v * G * f;
        Zi(zt, gn(zt, I, A), O), gn(I, I, zt), Xr(zt, gn(zt, I, A), 0.5 * G), zn(A, A, zt), Xr(E, E, j), gn(A, A, E), gn(I, I, E), _.addFixedCountDashes(A, I, R, v, x, x, L), V === 8 && (Xr(E, E, 2 * j), zn(A, A, E), zn(I, I, E), _.addFixedCountDashes(A, I, R, v, x, x, L));
      } else V === 3 || V === 5 ? (Xr(E, E, G + H * G + d * G * m), _.add(A[0], A[1], A[2], w[0], w[1], w[2], 1, p, U, L), Xr(zt, gn(zt, A, I), G / 1.5), gn(A, A, zt), q === 3 && _.add(A[0] + E[0], A[1] + E[1], A[2] + E[2], w[0] + E[0], w[1] + E[1], w[2] + E[2], H, p, U, L), _.add(A[0] - E[0], A[1] - E[1], A[2] - E[2], w[0] - E[0], w[1] - E[1], w[2] - E[2], H, x, U, L)) : (Xr(E, E, K), q === 3 && _.add(A[0], A[1], A[2], w[0], w[1], w[2], H, p, U, L), _.add(A[0] + E[0], A[1] + E[1], A[2] + E[2], w[0] + E[0], w[1] + E[1], w[2] + E[2], H, p, U, L), _.add(A[0] - E[0], A[1] - E[1], A[2] - E[2], w[0] - E[0], w[1] - E[1], w[2] - E[2], H, p, U, L));
    } else V === 6 && (Zi(zt, gn(zt, I, A), 0.475), zn(A, A, zt), gn(I, I, zt), _.add(A[0], A[1], A[2], I[0], I[1], I[2], 1, p, U, L));
  }
  var W = r ? de.clone(r.boundingSphere) : void 0, Z = _.getCylinders();
  return T === 0 ? { cylinders: Z } : (S.scale(D, D, 1 / T), W && S.distance(D, W.center) / W.radius < 1 ? { cylinders: Z, boundingSphere: W } : { cylinders: Z });
}
function hC(e, t, n, r) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, s = t.style, u = t.ignore;
  if (!i) return { lines: Yt.createEmpty(r) };
  for (var c = n.linkScale, l = n.linkSpacing, d = n.aromaticDashCount, m = n.dashCount, p = 2 * i, v = zr.create(p, p / 4, r), f = S(), y = S(), h = S(), g = S(), x = S(), C = 0, b = m % 2 == 1 ? m : m + 1, _ = 0.5 - 0.25 / b, A = d + 1, I = 0.5 - 0.25 / A, w = 0, E = i; w < E; ++w) if (!u || !u(w)) {
    o(f, y, w), zn(x, x, f), zn(x, x, y), C += 2;
    var D = s ? s(w) : 0;
    if (D === 0) Zi(h, zn(h, f, y), 0.5), v.add(f[0], f[1], f[2], h[0], h[1], h[2], w);
    else if (D === 1) Zi(zt, gn(zt, y, f), _), gn(y, y, zt), v.addFixedCountDashes(f, y, b, w);
    else if (D === 2 || D === 3 || D === 4 || D === 5 || D === 7 || D === 8) {
      var T = D === 2 || D === 3 ? 2 : D === 4 || D === 5 ? 3 : 1.5, P = (1 - c / (0.5 * T) * 1) * l;
      Zi(h, zn(h, f, y), 0.5), E3(g, f, y, a ? a(w) : null), D === 7 || D === 8 ? (v.add(f[0], f[1], f[2], h[0], h[1], h[2], w), Zi(zt, gn(zt, y, f), I), gn(y, y, zt), Xr(g, g, 4.5 * P), gn(f, f, g), gn(y, y, g), v.addFixedCountDashes(f, y, A, w), D === 8 && (Xr(g, g, 4.5 * P * 2), zn(f, f, g), zn(y, y, g), v.addFixedCountDashes(f, y, A, w))) : D === 3 || D === 5 ? (Xr(g, g, 3 * P), v.add(f[0], f[1], f[2], h[0], h[1], h[2], w), Zi(zt, gn(zt, f, y), l * c), gn(f, f, zt), T === 3 && v.add(f[0] + g[0], f[1] + g[1], f[2] + g[2], h[0] + g[0], h[1] + g[1], h[2] + g[2], w), v.add(f[0] - g[0], f[1] - g[1], f[2] - g[2], h[0] - g[0], h[1] - g[1], h[2] - g[2], w)) : (Xr(g, g, 1.5 * P), T === 3 && v.add(f[0], f[1], f[2], h[0], h[1], h[2], w), v.add(f[0] + g[0], f[1] + g[1], f[2] + g[2], h[0] + g[0], h[1] + g[1], h[2] + g[2], w), v.add(f[0] - g[0], f[1] - g[1], f[2] - g[2], h[0] - g[0], h[1] - g[1], h[2] - g[2], w));
    } else D === 6 && (Zi(zt, gn(zt, y, f), 0.475), zn(f, f, zt), gn(y, y, zt), v.add(f[0], f[1], f[2], y[0], y[1], y[2], w));
  }
  var M = r ? de.clone(r.boundingSphere) : void 0, R = v.getLines();
  return C === 0 ? { lines: R } : (S.scale(x, x, 1 / C), M && S.distance(x, M.center) / M.radius < 1 ? { lines: R, boundingSphere: M } : { lines: R });
}
var T3 = { includeTypes: N.MultiSelect(Mg(Bt.Names), N.objectToOptions(Bt.Names)), excludeTypes: N.MultiSelect([], N.objectToOptions(Bt.Names)), ignoreHydrogens: N.Boolean(!1), aromaticBonds: N.Boolean(!0, { description: "Display aromatic bonds with dashes" }), multipleBonds: N.Select("symmetric", N.arrayToOptions(["off", "symmetric", "offset"])) };
N.getDefaultValues(T3);
var M3 = B(B(B({}, H0), T3), { adjustCylinderLength: N.Boolean(!1, { description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds." }) });
N.getDefaultValues(M3);
var Mu, D3 = B(B({}, mC), T3);
function j0(e, t, n) {
  return !Bt.is(e, n) || Bt.is(t, n);
}
function vC(e, t, n) {
  var r = t.elements, i = t.model.atomicHierarchy.derived.atom.atomicNumber, a = t.bonds, o = a.a, s = a.b, u = a.edgeProps.flags, c = n.ignoreHydrogens, l = n.includeTypes, d = n.excludeTypes, m = Bt.fromNames(l), p = Bt.fromNames(d), v = Bt.isAll(m) && p === 0, f = e.child, y = f == null ? void 0 : f.unitMap.get(t.id);
  if (f && !y) throw new Error("expected childUnit to exist if child exists");
  if (!v || c || f) return function(h) {
    return !!y && !_e.has(y.elements, r[o[h]]) || c && (tg(i, r[o[h]]) || tg(i, r[s[h]])) || !v && j0(m, p, u[h]);
  };
}
function gC(e, t) {
  var n = e.interUnitBonds.edges, r = t.ignoreHydrogens, i = t.includeTypes, a = t.excludeTypes, o = Bt.fromNames(i), s = Bt.fromNames(a), u = Bt.isAll(o) && s === 0, c = e.child;
  if (!u || r || c) return function(l) {
    if (c) {
      var d = n[l], m = c.unitMap.get(d.unitA);
      if (!m) return !0;
      var p = e.unitMap.get(d.unitA).elements[d.indexA];
      if (!_e.has(m.elements, p)) return !0;
    }
    if (r) {
      d = n[l];
      var v = e.unitMap.get(d.unitA), f = e.unitMap.get(d.unitB);
      if (eg(v, v.elements[d.indexA]) || eg(f, f.elements[d.indexB])) return !0;
    }
    return !(u || !j0(o, s, n[l].props.flag));
  };
}
function ag(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group.units[i];
    if (me.isAtomic(s)) {
      var u = o.target, c = s.bonds.a[a], l = s.bonds.b[a];
      return rt.Loci(u, [rt.Location(u, s, c, u, s, l), rt.Location(u, s, l, u, s, c)]);
    }
  }
  return Sn;
}
function og(e, t, n, r) {
  var i = !1;
  if (rt.isLoci(e)) {
    var a = t.structure, o = t.group;
    if (!Be.areEquivalent(e.structure, a)) return !1;
    var s = o.units[0];
    if (!me.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 m = o.unitIndexMap.get(d.aUnit.id);
        if (m !== void 0) {
          var p = s.bonds.getDirectedEdgeIndex(d.aIndex, d.bIndex);
          p !== -1 && n(oe.ofSingleton(m * u + p)) && (i = !0);
        }
      }
    }
  } else if (Se.is(e)) {
    if (a = t.structure, o = t.group, !Be.areEquivalent(e.structure, a) || (s = o.units[0], !me.isAtomic(s))) return !1;
    for (var v = 2 * s.bonds.edgeCount, f = function(g) {
      var x = o.unitIndexMap.get(g.unit.id);
      if (x !== void 0) {
        var C = s.bonds, b = C.offset, _ = C.b;
        ve.forEach(g.indices, function(A) {
          for (var I = b[A], w = b[A + 1]; I < w; I++) r && !ve.has(g.indices, _[I]) || n(oe.ofSingleton(x * v + I)) && (i = !0);
        });
      }
    }, y = 0, h = e.elements; y < h.length; y++)
      f(h[y]);
  }
  return i;
}
function sg(e, t, n) {
  var r = e.objectId, i = e.groupId;
  if (n === r) {
    var a = t.target, o = t.interUnitBonds.edges[i], s = t.unitMap.get(o.unitA), u = t.unitMap.get(o.unitB);
    return rt.Loci(a, [rt.Location(a, s, o.indexA, a, u, o.indexB), rt.Location(a, u, o.indexB, a, s, o.indexA)]);
  }
  return Sn;
}
N.getDefaultValues(D3), function(e) {
  e.fromGroup = function(t) {
    var n = t.group, r = t.structure, i = n.units[0], a = me.isAtomic(i) ? 2 * i.bonds.edgeCount : 0, o = n.units.length, s = rt.Location(r, void 0, void 0, r, void 0, void 0);
    return Zn(a, o, 1, function(u, c) {
      var l = n.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 n = t.interUnitBonds.edgeCount, r = rt.Location(t, void 0, void 0, t, void 0, void 0);
    return Zn(n, 1, 1, function(i) {
      var a = t.interUnitBonds.edges[i];
      return r.aUnit = t.unitMap.get(a.unitA), r.aIndex = a.indexA, r.bUnit = t.unitMap.get(a.unitB), r.bIndex = a.indexB, r;
    }, !0);
  };
}(Mu || (Mu = {}));
var $h = /* @__PURE__ */ new Map();
function ug(e, t, n, r) {
  var i = !1;
  if (rt.isLoci(e)) {
    if (!Be.areEquivalent(e.structure, t)) return !1;
    for (var a = 0, o = e.bonds; a < o.length; a++) {
      var s = o[a], u = t.interUnitBonds.getBondIndexFromLocation(s);
      u !== -1 && n(oe.ofSingleton(u)) && (i = !0);
    }
  } else if (Se.is(e)) {
    if (!Be.areEquivalent(e.structure, t) || r && e.elements.length === 1) return !1;
    for (var c = 0, l = e.elements; c < l.length; c++) {
      var d = l[c];
      $h.set(d.unit.id, d.indices);
    }
    for (var m = function(f) {
      var y = f.unit;
      if (!me.isAtomic(y)) return "continue";
      t.interUnitBonds.getConnectedUnits(y.id).forEach(function(h) {
        var g = $h.get(h.unitB);
        r && !g || ve.forEach(f.indices, function(x) {
          h.connectedIndices.includes(x) && h.getEdges(x).forEach(function(C) {
            if (!r || g && ve.has(g, C.indexB)) {
              var b = t.interUnitBonds.getEdgeIndex(x, y.id, C.indexB, h.unitB);
              n(oe.ofSingleton(b)) && (i = !0);
            }
          });
        });
      });
    }, p = 0, v = e.elements; p < v.length; p++)
      m(d = v[p]);
    $h.clear();
  }
  return i;
}
var e2 = Bt.is;
function yC(e, t, n, r) {
  var i, a = e.elements, o = e.bonds, s = o.edgeCount, u = o.a, c = o.b, l = o.edgeProps, d = o.offset, m = l.order, p = l.flags, v = r.sizeFactor, f = r.sizeAspectRatio, y = r.adjustCylinderLength, h = r.aromaticBonds, g = r.includeTypes, x = r.excludeTypes, C = r.multipleBonds, b = C === "off", _ = C === "symmetric", A = j0(Bt.fromNames(g), Bt.fromNames(x), 32), I = S(), w = S(), E = e.conformation.invariantPosition, D = Ne.create(t, e), T = rt.Location(t, e, void 0, t, e, void 0), P = t.child;
  if (r.includeParent && P) {
    var M = P.unitMap.get(e.id);
    if (!M) throw new Error("expected childUnit to exist");
    i = function(G) {
      var V = a[u[G]], U = a[c[G]];
      return _e.has(M.elements, V) && !_e.has(M.elements, U);
    };
  }
  var R = e.rings, O = R.elementRingIndices, L = R.elementAromaticRingIndices, F = h ? e.resonance.delocalizedTriplets : void 0;
  return { linkCount: 2 * s, referencePosition: function(G) {
    var V, U, q = u[G], H = c[G], K = F == null ? void 0 : F.getThirdElement(q, H);
    if (K !== void 0) return E(a[K], I);
    q > H && (q = (V = [H, q])[0], H = V[1]), d[q + 1] - d[q] == 1 && (q = (U = [H, q])[0], H = U[1]);
    for (var j = L.get(q) || O.get(q), W = 0, Z = d[q], Y = d[q + 1]; Z < Y; ++Z) {
      var te = c[Z];
      if (te !== H && te !== q) {
        if (!j) return E(a[te], I);
        var ee = L.get(te) || O.get(te);
        if (!ee) continue;
        var $ = Lm(j, ee);
        $ > W && (W = $, E(a[te], I));
      }
    }
    return W > 0 ? I : null;
  }, position: function(G, V, U) {
    if (E(a[u[U]], G), E(a[c[U]], V), y) {
      var q = function(Z) {
        return D.element = a[u[Z]], n.size.size(D) * v;
      }(U), H = function(Z) {
        return D.element = a[c[Z]], n.size.size(D) * v;
      }(U), K = Math.min(q, H) * f, j = Math.sqrt(Math.max(0, q * q - K * K)) - 0.05, W = Math.sqrt(Math.max(0, H * H - K * K)) - 0.05;
      if (j <= 0.01 && W <= 0.01) return;
      S.normalize(w, S.sub(w, V, G)), S.scaleAndAdd(G, G, w, j), S.scaleAndAdd(V, V, w, -W);
    }
  }, style: function(G) {
    var V = m[G], U = p[G];
    if (e2(U, 2) || e2(U, 4)) return 1;
    if (V === 3) return b ? 0 : _ ? 4 : 5;
    if (h) {
      var q = u[G], H = c[G], K = L.get(q), j = L.get(H), W = K && j ? Lm(K, j) : 0;
      if (e2(U, 16) || W && !A) {
        if (W === 2) return 8;
        if (W === 1 || F != null && F.getThirdElement(q, H)) return 7;
      }
    }
    return V !== 2 || b ? 0 : _ ? 2 : 3;
  }, radius: function(G) {
    return function(V) {
      return T.aIndex = u[V], T.bIndex = c[V], n.size.size(T) * v;
    }(G) * f;
  }, ignore: vC(t, e, r), stub: i };
}
function WG(e, t, n, r, i, a) {
  if (!me.isAtomic(t) || !t.bonds.edgeCount) return li.createEmpty(a);
  var o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return li.createEmpty(a);
  var u = pC(0, yC(t, n, r, i), i, a), c = u.cylinders, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.cylinderCount > 0) {
    var d = de.expand(de(), (s ?? t).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
function ZG(e, t, n, r, i, a) {
  if (!me.isAtomic(t) || !t.bonds.edgeCount) return ht.createEmpty(a);
  var o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return ht.createEmpty(a);
  var u = q0(0, yC(t, n, r, i), i, a), c = u.mesh, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.triangleCount > 0) {
    var d = de.expand(de(), (s ?? t).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
var y0 = B(B(B(B({}, Ds), qF), M3), { sizeFactor: N.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: N.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: N.Boolean(!0), includeParent: N.Boolean(!1) });
function bC(e, t, n, r) {
  return n.tryUseImpostor && r && r.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Kf(B(B({}, a), { setUpdateState: function(s, u, c, l, d, m, p) {
        a.setUpdateState(s, u, c, l, d, m, p), Ai.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: li.Utils }), o);
    }({ defaultProps: N.getDefaultValues(y0), createGeometry: WG, createLocationIterator: Mu.fromGroup, getLoci: ag, eachLocation: og, setUpdateState: function(a, o, s, u, c, l, d) {
      a.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 || !Si(o.includeTypes, s.includeTypes) || !Si(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var m = l.group.units[0], p = d.group.units[0];
      me.isAtomic(m) && me.isAtomic(p) && (Ui.areEqual(m.bonds, p.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, s) {
      return !o.tryUseImpostor || !s;
    } }, i);
  }(e) : function(i) {
    return Bs({ defaultProps: N.getDefaultValues(y0), createGeometry: ZG, createLocationIterator: Mu.fromGroup, getLoci: ag, eachLocation: og, setUpdateState: function(a, o, s, u, c, l, d) {
      a.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 || !Si(o.includeTypes, s.includeTypes) || !Si(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var m = l.group.units[0], p = d.group.units[0];
      me.isAtomic(m) && me.isAtomic(p) && (Ui.areEqual(m.bonds, p.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, s) {
      return o.tryUseImpostor && !!s;
    } }, i);
  }(e);
}
var t2 = new rt.ElementBondIterator();
function q_(e, t, n, r) {
  for (t2.setElement(t, n, r); t2.hasNext; ) {
    var i = t2.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], e), e;
  }
  return null;
}
var j_ = S();
function _C(e, t, n) {
  var r, i = Ne.create(e), a = rt.Location(e, void 0, void 0, e, void 0, void 0), o = e.interUnitBonds, s = o.edgeCount, u = o.edges, c = n.sizeFactor, l = n.sizeAspectRatio, d = n.adjustCylinderLength, m = n.aromaticBonds, p = n.multipleBonds, v = p === "off", f = p === "symmetric", y = S(), h = e.child;
  return n.includeParent && h && (r = function(g) {
    var x = u[g], C = h.unitMap.get(x.unitA), b = h.unitMap.get(x.unitB), _ = e.unitMap.get(x.unitA).elements[x.indexA], A = e.unitMap.get(x.unitB).elements[x.indexB];
    return C && _e.has(C.elements, _) && (!b || !_e.has(b.elements, A));
  }), { linkCount: s, referencePosition: function(g) {
    var x, C, b, _, A = u[g];
    if (A.unitA < A.unitB) x = e.unitMap.get(A.unitA), C = e.unitMap.get(A.unitB), b = A.indexA, _ = A.indexB;
    else {
      if (!(A.unitA > A.unitB)) throw new Error("same units in createInterUnitBondCylinderMesh");
      x = e.unitMap.get(A.unitB), C = e.unitMap.get(A.unitA), b = A.indexB, _ = A.indexA;
    }
    return q_(j_, e, x, b) || q_(j_, e, C, _);
  }, position: function(g, x, C) {
    var b = u[C], _ = e.unitMap.get(b.unitA), A = e.unitMap.get(b.unitB);
    if (_.conformation.position(_.elements[b.indexA], g), A.conformation.position(A.elements[b.indexB], x), d) {
      var I = function(P) {
        var M = u[P];
        return i.unit = e.unitMap.get(M.unitA), i.element = i.unit.elements[M.indexA], t.size.size(i) * c;
      }(C), w = function(P) {
        var M = u[P];
        return i.unit = e.unitMap.get(M.unitB), i.element = i.unit.elements[M.indexB], t.size.size(i) * c;
      }(C), E = Math.min(I, w) * l, D = Math.sqrt(Math.max(0, I * I - E * E)) - 0.05, T = Math.sqrt(Math.max(0, w * w - E * E)) - 0.05;
      if (D <= 0.01 && T <= 0.01) return;
      S.normalize(y, S.sub(y, x, g)), S.scaleAndAdd(g, g, y, D), S.scaleAndAdd(x, x, y, -T);
    }
  }, style: function(g) {
    var x = u[g].props.order, C = Qr.create(u[g].props.flag);
    return Bt.is(C, 2) || Bt.is(C, 4) ? 1 : x === 3 ? v ? 0 : f ? 4 : 5 : m && Bt.is(C, 16) ? 7 : x !== 2 || v ? 0 : f ? 2 : 3;
  }, radius: function(g) {
    return function(x) {
      var C = u[x];
      return a.aUnit = e.unitMap.get(C.unitA), a.aIndex = C.indexA, a.bUnit = e.unitMap.get(C.unitB), a.bIndex = C.indexB, t.size.size(a) * c;
    }(g) * l;
  }, ignore: gC(e, n), stub: r };
}
function QG(e, t, n, r, i) {
  if (!t.interUnitBonds.edgeCount) return li.createEmpty(i);
  var a = pC(0, _C(t, n, r), r, i), o = a.cylinders, s = a.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.cylinderCount > 0) {
    var u = t.child, c = de.expand(de(), (u ?? t).boundary.sphere, 1 * r.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
function JG(e, t, n, r, i) {
  if (!t.interUnitBonds.edgeCount) return ht.createEmpty(i);
  var a = q0(0, _C(t, n, r), r, i), o = a.mesh, s = a.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.triangleCount > 0) {
    var u = t.child, c = de.expand(de(), (u ?? t).boundary.sphere, 1 * r.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
var b0 = B(B(B(B({}, US), VF), M3), { sizeFactor: N.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: N.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: N.Boolean(!0), includeParent: N.Boolean(!1) });
function xC(e, t, n, r) {
  return n.tryUseImpostor && r && r.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return U0(B(B({}, a), { setUpdateState: function(s, u, c, l, d, m, p) {
        a.setUpdateState(s, u, c, l, d, m, p), Ai.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: li.Utils }), o);
    }({ defaultProps: N.getDefaultValues(b0), createGeometry: QG, createLocationIterator: Mu.fromStructure, getLoci: sg, eachLocation: ug, setUpdateState: function(a, o, s, u, c, l, d) {
      a.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 || !Si(o.includeTypes, s.includeTypes) || !Si(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.multipleBonds !== s.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0);
    }, mustRecreate: function(a, o, s) {
      return !o.tryUseImpostor || !s;
    } }, i);
  }(e) : function(i) {
    return HS({ defaultProps: N.getDefaultValues(b0), createGeometry: JG, createLocationIterator: Mu.fromStructure, getLoci: sg, eachLocation: ug, setUpdateState: function(a, o, s, u, c, l, d) {
      a.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 || !Si(o.includeTypes, s.includeTypes) || !Si(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.multipleBonds !== s.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0);
    }, mustRecreate: function(a, o, s) {
      return o.tryUseImpostor && !!s;
    } }, i);
  }(e);
}
var Df, K_ = new Float32Array([-1, 1, -1, -1, 1, 1, 1, -1]), cl = new Uint16Array([0, 1, 2, 1, 3, 2]), n2 = he.add3, $G = he.add2, eV = he.add;
(function(e) {
  e.create = function(t, n, r) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024), t *= 4, n *= 4;
    var i = he.create(Float32Array, 3, n, r ? r.centerBuffer.ref.value : t), a = he.create(Float32Array, 2, n, r ? r.mappingBuffer.ref.value : t), o = he.create(Uint32Array, 3, n / 2, r ? r.indexBuffer.ref.value : t / 2), s = he.create(Float32Array, 1, n, r ? r.groupBuffer.ref.value : t);
    return { add: function(u, c, l, d) {
      for (var m = i.elementCount, p = 0; p < 4; ++p) n2(i, u, c, l), $G(a, K_[2 * p], K_[2 * p + 1]), eV(s, d);
      n2(o, m + cl[0], m + cl[1], m + cl[2]), n2(o, m + cl[3], m + cl[4], m + cl[5]);
    }, getSpheres: function() {
      var u = he.compact(i, !0), c = he.compact(a, !0), l = he.compact(o, !0), d = he.compact(s, !0);
      return ro.create(u, c, l, d, i.elementCount / 4, r);
    } };
  };
})(Df || (Df = {}));
var Is, SC = S.add;
function K0(e, t, n) {
  var r = n.ignoreHydrogens, i = n.traceOnly, a = t.model.atomicHierarchy.derived.atom.atomicNumber, o = me.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 || r || i) return function(c) {
    return !!u && !_e.has(u.elements, c) || !o && r && tg(a, c) || i && !OS(t, c);
  };
}
function tV(e, t, n, r, i, a) {
  var o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return ht.createEmpty(a);
  for (var u = i.detail, c = i.sizeFactor, l = t.elements, d = l.length, m = d * Nx(u), p = nt.createState(m, m / 2, a), v = S(), f = t.conformation.invariantPosition, y = K0(n, t, i), h = Ne.create(n, t), g = r.size.size, x = S(), C = 0, b = 0, _ = 0; _ < d; _++) if (!y || !y(l[_])) {
    h.element = l[_], f(l[_], v), SC(x, x, v), b += 1, p.currentGroup = _;
    var A = g(h);
    A > C && (C = A), yr(p, v, A * c, u);
  }
  var I, w = a ? de.clone(a.boundingSphere) : void 0, E = nt.getMesh(p);
  return b === 0 || (S.scale(x, x, 1 / b), I = w && S.distance(x, w.center) / w.radius < 1 ? w : de.expand(de(), (s ?? t).boundary.sphere, C * c + 0.05), E.setBoundingSphere(I)), E;
}
function nV(e, t, n, r, i, a) {
  var o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return ro.createEmpty(a);
  for (var u = t.elements, c = u.length, l = Df.create(c, c / 2, a), d = S(), m = t.conformation.invariantPosition, p = K0(n, t, i), v = Ne.create(n, t), f = r.size.size, y = S(), h = 0, g = 0, x = 0; x < c; x++) if (!(p != null && p(u[x]))) {
    m(u[x], d), l.add(d[0], d[1], d[2], x), SC(y, y, d), g += 1, v.element = u[x];
    var C = f(v);
    C > h && (h = C);
  }
  var b, _ = a ? de.clone(a.boundingSphere) : void 0, A = l.getSpheres();
  return g === 0 || (S.scale(y, y, 1 / g), b = _ && S.distance(y, _.center) / _.radius < 1 ? _ : de.expand(de(), (s ?? t).boundary.sphere, h * i.sizeFactor + 0.05), A.setBoundingSphere(b)), A;
}
function Wl(e, t, n) {
  var r = !1;
  if (!Se.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!Be.areEquivalent(e.structure, i)) return !1;
  for (var o = a.elements.length, s = a.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 m = d * o;
      if (oe.is(l.indices)) {
        var p = m + oe.start(l.indices), v = m + oe.end(l.indices);
        n(oe.ofBounds(p, v)) && (r = !0);
      } else for (var f = 0, y = l.indices.length; f < y; f++) {
        p = l.indices[f];
        for (var h = f + 1; h < y && l.indices[h] === p; ) h++;
        f = h - 1, v = l.indices[f], r = n(oe.ofRange(m + p, m + v)) || r;
      }
    }
  }
  return r;
}
function Zl(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group.units[i], u = ve.ofSingleton(a);
    return Se(o.target, [{ unit: s, indices: u }]);
  }
  return Sn;
}
function rV(e, t, n) {
  var r = !1;
  if (!Se.is(e) || !Be.areEquivalent(e.structure, t)) return !1;
  for (var i = t.serialMapping.cumulativeUnitElementCount, a = 0, o = e.elements; a < o.length; a++) {
    var s = o[a], u = t.unitIndexMap.get(s.unit.id);
    if (u !== void 0) if (oe.is(s.indices)) {
      var c = i[u] + oe.start(s.indices), l = i[u] + oe.end(s.indices);
      n(oe.ofBounds(c, l)) && (r = !0);
    } else for (var d = 0, m = s.indices.length; d < m; d++) {
      var p = i[u] + s.indices[d];
      n(oe.ofSingleton(p)) && (r = !0);
    }
  }
  return r;
}
function iV(e, t, n) {
  var r = e.objectId, i = e.groupId;
  if (n === r) {
    var a = t.serialMapping, o = a.unitIndices, s = a.cumulativeUnitElementCount, u = o[i], c = t.units[u], l = i - s[u];
    return Se(t, [{ unit: c, indices: ve.ofSingleton(l) }]);
  }
  return Sn;
}
(function(e) {
  e.fromGroup = function(t) {
    var n = t.group, r = t.structure, i = n.elements.length, a = n.units.length, o = Ne.create(r);
    return Zn(i, a, 1, function(s, u) {
      var c = n.units[u];
      return o.unit = c, o.element = c.elements[s], o;
    });
  }, e.fromStructure = function(t) {
    var n = t.units, r = t.elementCount, i = t.serialMapping, a = i.unitIndices, o = i.elementIndices, s = Ne.create(t);
    return Zn(r, 1, 1, function(u) {
      return s.unit = n[a[u]], s.element = o[u], s;
    }, !0);
  };
})(Is || (Is = {}));
var Bf = B(B(B({}, Ds), HF), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), detail: N.Numeric(0, { min: 0, max: 3, step: 1 }, Ve.CustomQualityParamInfo), ignoreHydrogens: N.Boolean(!1), traceOnly: N.Boolean(!1), tryUseImpostor: N.Boolean(!0) });
function B3(e, t, n, r) {
  return n.tryUseImpostor && r && r.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Kf(B(B({}, a), { setUpdateState: function(s, u, c, l, d, m, p) {
        a.setUpdateState(s, u, c, l, d, m, p), Ai.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: ro.Utils }), o);
    }({ defaultProps: N.getDefaultValues(Bf), createGeometry: nV, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(a, o, s) {
      a.createGeometry = o.ignoreHydrogens !== s.ignoreHydrogens || o.traceOnly !== s.traceOnly;
    }, mustRecreate: function(a, o, s) {
      return !o.tryUseImpostor || !s;
    } }, i);
  }(e) : function(i) {
    return Bs({ defaultProps: N.getDefaultValues(Bf), createGeometry: tV, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(a, o, s) {
      a.createGeometry = o.sizeFactor !== s.sizeFactor || o.detail !== s.detail || o.ignoreHydrogens !== s.ignoreHydrogens || o.traceOnly !== s.traceOnly;
    }, mustRecreate: function(a, o, s) {
      return o.tryUseImpostor && !!s;
    } }, i);
  }(e);
}
var aV = B(B({}, UF), { sizeFactor: N.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), background: N.Boolean(!1), backgroundMargin: N.Numeric(0, { min: 0, max: 1, step: 0.01 }), backgroundColor: N.Color(_t.black), backgroundOpacity: N.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), borderWidth: N.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }), level: N.Select("element", [["element", "Element"]], { isEssential: !0 }), chainScale: N.Numeric(10, { min: 0, max: 20, step: 0.1 }), residueScale: N.Numeric(1, { min: 0, max: 20, step: 0.1 }), elementScale: N.Numeric(2, { min: 0, max: 20, step: 0.1 }), attachment: N.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: N.Boolean(!0), tetherLength: N.Numeric(0.2, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: N.Numeric(0, { min: 0, max: 1, step: 0.01 }) });
function R3(e) {
  return function(t, n) {
    return U0(B(B({}, t), { setUpdateState: function(r, i, a, o, s, u, c) {
      t.setUpdateState(r, i, a, o, s, u, c), Ai.areEqual(o.size, s.size) || (r.updateSize = !0), i.background !== a.background && (r.createGeometry = !0), i.backgroundMargin !== a.backgroundMargin && (r.createGeometry = !0), i.tether !== a.tether && (r.createGeometry = !0), i.tetherLength !== a.tetherLength && (r.createGeometry = !0), i.tetherBaseWidth !== a.tetherBaseWidth && (r.createGeometry = !0), i.attachment !== a.attachment && (r.createGeometry = !0), i.fontFamily !== a.fontFamily && (r.createGeometry = !0), i.fontQuality !== a.fontQuality && (r.createGeometry = !0), i.fontStyle !== a.fontStyle && (r.createGeometry = !0), i.fontVariant !== a.fontVariant && (r.createGeometry = !0), i.fontWeight !== a.fontWeight && (r.createGeometry = !0);
    }, geometryUtils: na.Utils }), n);
  }({ defaultProps: N.getDefaultValues(aV), createGeometry: oV, createLocationIterator: Is.fromStructure, getLoci: iV, eachLocation: rV, setUpdateState: function(t, n, r) {
    t.createGeometry = n.level !== r.level || n.level === "element" && n.elementScale !== r.elementScale;
  } }, e);
}
function oV(e, t, n, r, i) {
  return n.size.size = function() {
    return 1;
  }, n.color.color = function(a) {
    if (Ne.is(a) && me.isAtomic(a.unit)) {
      var o = (0, Me.atom.pdbx_formal_charge)(a);
      if (o > 0) return _t.red;
      if (o < 0) return _t.blue;
    }
    return _t.white;
  }, r.sizeFactor = 0.2, function(a, o, s, u, c) {
    for (var l = Ne.create(o), d = o.units, m = o.serialMapping, p = Me.atom.pdbx_formal_charge, v = m.cumulativeUnitElementCount, f = o.elementCount, y = Tu.create(u, f, f / 2, c), h = !1, g = 0, x = d.length; g < x; ++g) {
      var C = d[g], b = C.conformation.position, _ = C.elements;
      l.unit = C;
      for (var A = v[g], I = 0, w = _.length; I < w; I++) {
        l.element = _[I];
        var E = p(l);
        if (E !== 0) {
          b(l.element, rm);
          var D = "".concat(E > 0 ? "+" : "").concat(E);
          y.add(D, rm[0], rm[1], rm[2], 0, 5, A + I), h = !0;
        }
      }
      if (!h) {
        var T = o.boundary.sphere.center;
        y.add("", T[0], T[1], T[2], 0, 0, A + 1);
      }
    }
    return y.getText();
  }(0, t, 0, r, i);
}
var rm = S(), CC = { "element-sphere": function(e, t) {
  return ui("Element sphere", e, t, B3);
}, "intra-bond": function(e, t) {
  return ui("Intra-unit bond cylinder", e, t, bC);
}, "inter-bond": function(e, t) {
  return Mc("Inter-unit bond cylinder", e, t, xC);
}, "charge-text": function(e, t) {
  return Mc("Charge Text", e, t, R3);
} }, X_ = B(B(B(B(B({}, Bf), { traceOnly: N.Boolean(!1, { isHidden: !0 }) }), y0), b0), { includeParent: N.Boolean(!1), unitKinds: jf(["atomic"]), sizeFactor: N.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: N.Numeric(0.5, { min: 0.01, max: 3, step: 0.01 }), visuals: N.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], N.objectToOptions(CC)), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory) }), yi = { name: "ball-and-stick", label: "Ball & Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return Mt.createMulti("Ball & Stick", e, t, ia, CC);
}, getParams: function(e, t) {
  return N.clone(X_);
}, defaultValues: N.getDefaultValues(X_), 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;
} }, AC = { create: function(e, t, n) {
  var r;
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = yi.factory(t, yi.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(B(B({}, yi.defaultValues), { aromaticBonds: ((r = e.model) === null || r === void 0 ? void 0 : r.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 a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: n.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function wn(e, t, n) {
  n === void 0 && (n = {});
  var r, i, a, o, s = 0, u = new $n(), c = Mt.createState(), l = Ms(), d = [], m = -1, p = Ba.createEmpty(), v = N.getDefaultValues(t.Params);
  n.modifyState && Mt.updateState(c, n.modifyState(c));
  var f = Lo.create();
  function y(h, g) {
    return Vi(h) || Ct.isLoci(h) && h.shape === i ? g(oe.ofBounds(0, i.groupCount * i.transforms.length)) : function(x, C, b) {
      if (!_i.isLoci(x) || x.shape !== C) return !1;
      for (var _ = !1, A = C.groupCount, I = x.groups, w = 0, E = I; w < E.length; w++) {
        var D = E[w], T = D.ids, P = D.instance;
        if (oe.is(T)) {
          var M = P * A + oe.start(T), R = P * A + oe.end(T);
          b(oe.ofBounds(M, R)) && (_ = !0);
        } else for (var O = 0, L = T.length; O < L; O++) {
          var F = P * A + T[O];
          b(oe.ofSingleton(F)) && (_ = !0);
        }
      }
      return _;
    }(h, i, g);
  }
  return { label: "Shape geometry", get groupCount() {
    return a ? a.count : 0;
  }, get props() {
    return v;
  }, get params() {
  }, get state() {
    return c;
  }, get theme() {
    return p;
  }, renderObjects: d, get geometryVersion() {
    return m;
  }, updated: u, createOrUpdate: function(h, g) {
    var x = this;
    return h === void 0 && (h = {}), n.modifyProps && (h = n.modifyProps(h)), At.create("ShapeRepresentation.create", function(C) {
      return ie(x, 0, void 0, function() {
        var b, _, A, I, w, E, D, T;
        return ne(this, function(P) {
          switch (P.label) {
            case 0:
              return b = Object.assign(v, h), g ? [4, e(C, g, b, i)] : [3, 2];
            case 1:
              return A = P.sent(), [3, 3];
            case 2:
              A = void 0, P.label = 3;
            case 3:
              if (function(M, R) {
                Lo.reset(f), (R || i) && (R && !i ? f.createNew = !0 : R && i && R.id === i.id || (R && i && R.id !== i.id ? (f.updateTransform = !0, f.createGeometry = !0) : R && console.warn("unexpected state")), f.updateTransform && (f.updateColor = !0, f.updateSize = !0), f.createGeometry && (f.updateColor = !0, f.updateSize = !0));
              }(0, _ = A), _ && (i = _, Object.assign(p, Ct.getTheme(i))), f.createNew) d.length = 0, a = Ct.groupIterator(i), I = Ct.createTransform(i.transforms), w = t.createValues(i.geometry, I, a, p, b), E = t.createRenderableState(b), n.modifyState && Object.assign(E, n.modifyState(E)), Mt.updateState(c, E), (r = ad(i.geometry.kind, w, E, l)) && d.push(r), o = t.createPositionIterator(i.geometry, r.values);
              else {
                if (!r) throw new Error("expected renderObject to be available");
                f.updateTransform && (Ct.createTransform(i.transforms, r.values), a = Ct.groupIterator(i), D = a.instanceCount, T = a.groupCount, Da(D * T, r.values)), f.createGeometry && (k.updateIfChanged(r.values.drawCount, Ur.getDrawCount(i.geometry)), k.updateIfChanged(r.values.uVertexCount, Ur.getVertexCount(i.geometry))), (f.updateTransform || f.createGeometry) && (t.updateBoundingSphere(r.values, i.geometry), o = t.createPositionIterator(i.geometry, r.values)), f.updateColor && ta(a, o, p.color, r.values), f.updateSize && "uSize" in r.values && Es(a, p.size, r.values), t.updateValues(r.values, b), t.updateRenderableState(r.state, b);
              }
              return v = b, (f.createGeometry || f.createNew) && (m += 1), u.next(s++), [2];
          }
        });
      });
    });
  }, getLoci: function(h) {
    if (h === void 0) return Ct.Loci(i);
    var g = h.objectId, x = h.groupId, C = h.instanceId;
    return r && r.id === g ? _i.Loci(i, [{ ids: ve.ofSingleton(x), instance: C }]) : Sn;
  }, mark: function(h, g) {
    if (!Wt.is(c.markerActions, g)) return !1;
    if (_i.isLoci(h) || Ct.isLoci(h)) {
      if (h.shape !== i) return !1;
    } else if (!Vi(h)) return !1;
    return Pt.mark(r, h, g, y);
  }, setState: function(h) {
    n.modifyState && (h = n.modifyState(h)), r && (h.visible !== void 0 && Pt.setVisibility(r, h.visible), h.alphaFactor !== void 0 && Pt.setAlphaFactor(r, h.alphaFactor), h.pickable !== void 0 && Pt.setPickable(r, h.pickable), h.colorOnly !== void 0 && Pt.setColorOnly(r, h.colorOnly), h.overpaint !== void 0 && Pt.setOverpaint(r, h.overpaint, y, !0), h.transparency !== void 0 && Pt.setTransparency(r, h.transparency, y, !0), h.substance !== void 0 && Pt.setSubstance(r, h.substance, y, !0), h.transform !== void 0 && Pt.setTransform(r, h.transform)), Mt.updateState(c, h);
  }, setTheme: function(h) {
    Xt && 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, r && (r.state.disposed = !0, r = void 0);
  } };
}
var sd = { granularity: "element", condensed: !1, reverse: !1, countsOnly: !1, hidePrefix: !1, htmlStyling: !0 };
function IC(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 = B(B({}, sd), l), m = function(p, v, f, y, h) {
          v === void 0 && (v = !1), f === void 0 && (f = !1), y === void 0 && (y = !1), h === void 0 && (h = !1);
          var g = p.structureCount, x = p.chainCount, C = p.residueCount, b = p.conformationCount, _ = p.elementCount;
          if (v || _ !== 1 || C !== 0 || x !== 0) {
            if (v || _ !== 0 || C !== 1 || x !== 0) {
              if (v || _ !== 0 || C !== 0 || x !== 1) {
                if (v)
                  return A = [], g > 0 && A.push(hl(g, "Structure")), x > 0 && A.push(hl(x, "Chain")), C > 0 && A.push(hl(C, "Residue")), b > 0 && A.push(hl(b, "Conformation")), _ > 0 && A.push(hl(_, "Element")), A.join("<small> + </small>");
                var A = [];
                return g > 0 && A.push(g === 1 ? is(p.firstStructureLoc, { hidePrefix: f, condensed: y, granularity: "structure", reverse: h }, !0) : Id(g, p.firstStructureLoc, "structure", f, h, y)), x > 0 && (A.push(x === 1 ? is(p.firstChainLoc, { condensed: y, granularity: "chain", hidePrefix: f, reverse: h }, !0) : Id(x, p.firstChainLoc, "chain", f, h, y)), f = !0), C > 0 && (A.push(C === 1 ? is(p.firstResidueLoc, { condensed: y, granularity: "residue", hidePrefix: f, reverse: h }, !0) : Id(C, p.firstResidueLoc, "residue", f, h, y)), f = !0), b > 0 && (A.push(b === 1 ? is(p.firstConformationLoc, { condensed: y, granularity: "conformation", hidePrefix: f, reverse: h }, !0) : Id(b, p.firstConformationLoc, "conformation", f, h, y)), f = !0), _ > 0 && A.push(_ === 1 ? is(p.firstElementLoc, { condensed: y, granularity: "element", hidePrefix: f, reverse: h }, !0) : Id(_, p.firstElementLoc, "element", f, h, y)), A.join("<small> + </small>");
              }
              var I = p.firstChainLoc.unit, w = me.isAtomic(I) && function(E) {
                var D = E.elements, T = E.model, P = T.atomicHierarchy, M = P.chainAtomSegments, R = P.residueAtomSegments, O = M.offsets[M.index[D[0]]], L = M.offsets[M.index[D[D.length - 1]] + 1] - 1;
                return R.index[L] - R.index[O] + 1;
              }(I) === 1 || me.Traits.is(I.traits, 1) ? "residue" : "chain";
              return is(p.firstChainLoc, { hidePrefix: f, condensed: y, granularity: w, reverse: h }, !0);
            }
            return is(p.firstResidueLoc, { hidePrefix: f, condensed: y, granularity: "residue", reverse: h }, !0);
          }
          return is(p.firstElementLoc, { hidePrefix: f, condensed: y, granularity: "element", reverse: h }, !0);
        }(c, d.countsOnly, d.hidePrefix, d.condensed, d.reverse);
        return d.htmlStyling ? m : Ig(m);
      }(Ic.ofLoci(e), t);
    case "bond-loci":
      var n = e.bonds[0];
      return n ? wC(n) : "";
    case "shape-loci":
      return e.shape.name;
    case "group-loci":
      var r = e.groups[0];
      return r ? e.shape.getLabel(ve.start(r.ids), r.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(Tt.IsoValue.toString(e.isoValue))].join(" | ");
    case "cell-loci":
      var i = ve.size(e.indices), a = ve.start(e.indices), o = Tt.IsoValue.absolute(e.volume.grid.cells.data[a]), s = Tt.IsoValue.toRelative(o, e.volume.grid.stats), u = ["".concat(e.volume.label || "Volume"), "".concat(i === 1 ? "Cell #".concat(a) : "".concat(i, " Cells"))];
      return i === 1 && u.push("".concat(Tt.IsoValue.toString(o), " (").concat(Tt.IsoValue.toString(s), ")")), u.join(" | ");
  }
}
function hl(e, t) {
  return e === 1 ? "1 ".concat(t) : "".concat(e, " ").concat(t, "s");
}
function Id(e, t, n, r, i, a) {
  return "".concat(is(t, { granularity: n, hidePrefix: r, reverse: i, condensed: a }), " <small>[+ ").concat(hl(e - 1, "other ".concat(Ag(n))), "]</small>");
}
function wC(e, t) {
  return t === void 0 && (t = {}), X0({ loci: [Se(e.aStructure, [{ unit: e.aUnit, indices: ve.ofSingleton(e.aIndex) }]), Se(e.bStructure, [{ unit: e.bUnit, indices: ve.ofSingleton(e.bIndex) }])] }, t);
}
function X0(e, t) {
  t === void 0 && (t = {});
  var n = B(B({}, sd), t), r = function(i, a) {
    for (var o = a.granularity, s = a.hidePrefix, u = a.reverse, c = a.condensed, l = !0, d = 0, m = i.loci; d < m.length; d++) {
      var p = m[d];
      if (!Se.is(p) || Se.size(p) !== 1) {
        l = !1;
        break;
      }
    }
    if (l) {
      var v = i.loci.map(function(A) {
        var I = A.elements[0], w = I.unit, E = I.indices;
        return Ne.create(A.structure, w, w.elements[ve.start(E)]);
      }), f = v.map(function(A) {
        return PC(A, o, s, u || c);
      });
      if (c) return f.map(function(A) {
        return A[0].replace(/\[.*\]/g, "").trim();
      }).filter(function(A) {
        return !!A;
      }).join(" — ");
      for (var y = 0, h = 0, g = Math.min.apply(Math, f.map(function(A) {
        return A.length;
      })) - 1; h < g; ++h) {
        for (var x = !0, C = 1, b = f.length; C < b; ++C) if (f[0][h] !== f[C][h]) {
          x = !1;
          break;
        }
        if (!x) break;
        y += 1;
      }
      if (y > 0) {
        var _ = [f[0].join(" | ")];
        for (C = 1, b = f.length; C < b; ++C) _.push(f[C].slice(y).filter(function(A) {
          return !!A;
        }).join(" | "));
        return _.join(" — ");
      }
      return f.map(function(A) {
        return A.filter(function(I) {
          return !!I;
        }).join(" | ");
      }).filter(function(A) {
        return !!A;
      }).join("</br>");
    }
    return f = i.loci.map(function(A) {
      return IC(A, a);
    }), f.filter(function(A) {
      return !!A;
    }).join(c ? " — " : "</br>");
  }(e, n);
  return n.htmlStyling ? r : Ig(r);
}
function is(e, t, n) {
  var r, i;
  t === void 0 && (t = {});
  var a = B(B({}, sd), t), o = PC(e, a.granularity, a.hidePrefix, a.reverse || a.condensed), s = (a.condensed ? (i = (r = o[0]) === null || r === void 0 ? void 0 : r.replace(/\[.*\]/g, "").trim()) !== null && i !== void 0 ? i : "" : o.filter(function(u) {
    return !!u;
  }).join(" | ")) + (n ? 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>");
  }(Me.atom.B_iso_or_equiv(e)) : "");
  return a.htmlStyling ? s : Ig(s);
}
function PC(e, t, n, r) {
  t === void 0 && (t = "element"), n === void 0 && (n = !1), r === void 0 && (r = !1);
  var i = [];
  if (!n) {
    var a = e.unit.model.entry;
    a.length > 30 && (a = a.substr(0, 27) + "…"), i.push("<small>".concat(a, "</small>")), t !== "structure" && (i.push("<small>Model ".concat(e.unit.model.modelNum, "</small>")), i.push("<small>Instance ".concat(e.unit.conformation.operator.name, "</small>")));
  }
  return me.isAtomic(e.unit) ? i.push.apply(i, function(o, s, u) {
    u === void 0 && (u = !1);
    var c = Ne.residueIndex(o), l = Me.chain.label_asym_id(o), d = Me.chain.auth_asym_id(o), m = o.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(c) === 0, p = Me.residue.label_seq_id(o), v = Me.residue.auth_seq_id(o), f = Me.residue.pdbx_PDB_ins_code(o), y = Me.atom.label_comp_id(o), h = Me.atom.label_atom_id(o), g = Me.atom.label_alt_id(o), x = Me.atom.occupancy(o), C = Me.atom.id(o), b = Me.residue.microheterogeneityCompIds(o), _ = s === "residue" && b.length > 1 ? "(".concat(b.join("|"), ")") : y, A = [];
    switch (s) {
      case "element":
        A.push("<b>".concat(h, " ").concat(C, "</b>").concat(g ? "%".concat(g) : ""));
      case "conformation":
        s === "conformation" && g && A.push("<small>Conformation</small> <b>".concat(g, "</b>"));
      case "residue":
        var I = p === v && m ? p : v;
        A.push("<b>".concat(_, " ").concat(I, "</b>").concat(I !== p ? " <small>[auth</small> <b>".concat(p, "</b><small>]</small>") : "", "<b>").concat(f || "", "</b>"));
      case "chain":
        l === d ? A.push("<b>".concat(l, "</b>")) : s === "chain" && me.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 && x !== 1 && !u && (A[0] = "".concat(A[0], " <small>[occupancy</small> <b>").concat(Math.round(100 * x) / 100, "</b><small>]</small>")), A.reverse();
  }(e, t, r)) : me.isCoarse(e.unit) ? i.push.apply(i, function(o, s) {
    var u = Me.coarse.asym_id(o), c = Me.coarse.seq_id_begin(o), l = Me.coarse.seq_id_end(o), d = [];
    switch (s) {
      case "element":
      case "conformation":
      case "residue":
        if (c === l) {
          var m = Me.coarse.entityKey(o), p = o.unit.model.sequence.byEntityKey[m].sequence.compId.value(c - 1);
          d.push("<b>".concat(p, " ").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)) : i.push("Unknown"), r ? i.reverse() : i;
}
function Rf(e, t) {
  t === void 0 && (t = {});
  var n = B(B(B({}, sd), { measureOnly: !1, unitLabel: "Å" }), t), r = e.loci.map(function(u) {
    return rn.getCenter(u);
  }), i = r[0], a = r[1], o = "".concat(S.distance(i, a).toFixed(2), " ").concat(n.unitLabel);
  if (n.measureOnly) return o;
  var s = X0(e, n);
  return n.condensed ? "".concat(o, " | ").concat(s) : "Distance ".concat(o, "</br>").concat(s);
}
function k3(e, t) {
  t === void 0 && (t = {});
  var n = B(B(B({}, sd), { measureOnly: !1 }), t), r = e.loci.map(function(d) {
    return rn.getCenter(d);
  }), i = r[0], a = r[1], o = r[2], s = S.sub(S(), i, a), u = S.sub(S(), o, a), c = "".concat($r(S.angle(s, u)).toFixed(2), "°");
  if (n.measureOnly) return c;
  var l = X0(e, n);
  return n.condensed ? "".concat(c, " | ").concat(l) : "Angle ".concat(c, "</br>").concat(l);
}
function O3(e, t) {
  t === void 0 && (t = {});
  var n = B(B(B({}, sd), { measureOnly: !1 }), t), r = e.loci.map(function(l) {
    return rn.getCenter(l);
  }), i = r[0], a = r[1], o = r[2], s = r[3], u = "".concat($r(S.dihedralAngle(i, a, o, s)).toFixed(2), "°");
  if (n.measureOnly) return u;
  var c = X0(e, n);
  return n.condensed ? "".concat(u, " | ").concat(c) : "Dihedral ".concat(u, "</br>").concat(c);
}
var sV = { customText: N.Text("", { label: "Text", description: "Override the label with custom value.", isEssential: !0 }), textColor: N.Color(_t.black, { isEssential: !0 }), textSize: N.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }, Y0 = B(B(B({}, na.Params), sV), { borderWidth: N.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 }) }), uV = B(B({}, Y0), { offsetZ: N.Numeric(2, { min: 0, max: 10, step: 0.1 }), textSize: N.Numeric(0.7, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }), EC = { text: function(e, t) {
  return wn(dV, na.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !0 });
  } });
} }, cV = B(B({}, uV), { scaleByRadius: N.Boolean(!1), visuals: N.MultiSelect(["text"], N.objectToOptions(EC)), textColor: N.Color(ye.fromRgb(241, 160, 119), { isEssential: !0 }) }), lV = de();
function r2(e, t) {
  return t === void 0 && (t = !1), e.label || IC(e.loci, { hidePrefix: !0, htmlStyling: !1, condensed: t }).split("Plddt")[0];
}
function dV(e, t, n, r) {
  var i = function(u, c, l) {
    for (var d = Tu.create(c, 128, 64, l), m = c.customText.trim(), p = 0, v = u.infos.length; p < v; ++p) {
      var f = u.infos[p], y = rn.getBoundingSphere(f.loci, lV);
      if (y) {
        var h = y.center, g = y.radius, x = m || r2(f, !0);
        d.add(x, h[0], h[1], h[2], c.scaleByRadius ? g / 0.9 : 0, c.scaleByRadius ? Math.max(1, g) : 1, p);
      }
    }
    return d.getText();
  }(t, n, r && r.geometry), a = function(u) {
    return u.infos.length === 1 ? r2(u.infos[0]) : "".concat(u.infos.length, " Labels");
  }(t), o = n.customText.trim(), s = o ? function(u) {
    return o;
  } : function(u) {
    return r2(t.infos[u]);
  };
  return Ct.create(a, t, i, function() {
    return n.textColor;
  }, function() {
    return n.textSize;
  }, s);
}
var fV = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = Mt.createMulti("Label", o, s, Mt.StateBuilder, EC);
            return u.setState({ pickable: !0, markerActions: Wt.All }), u;
          }(t, function() {
            return cV;
          }), [4, i.createOrUpdate(n ?? {}, { infos: e[0].loci ? e : e.map(function(o) {
            return { loci: o };
          }) }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r && e.setTheme(r), [4, e.createOrUpdate(n ?? {}, { infos: t.map(function(a) {
            return { loci: a };
          }) }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, TC = { unitLabel: N.Text("Å", { isEssential: !0 }) }, mV = B(B(B({}, Yt.Params), TC), { lineSizeAttenuation: N.Boolean(!0), linesColor: N.Color(_t.lightgreen, { isEssential: !0 }), linesSize: N.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }), dashLength: N.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 }) }), pV = B(B({}, Y0), TC), MC = { lines: function(e, t) {
  return wn(vV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !0, markerActions: Wt.All });
  } });
}, text: function(e, t) {
  return wn(gV, na.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
} }, hV = B(B(B({}, mV), pV), { visuals: N.MultiSelect(["lines", "text"], N.objectToOptions(MC)) });
function DC(e, t) {
  var n = t.sphereA, r = t.sphereB, i = t.center, a = e.loci, o = a[0], s = a[1];
  return rn.getBoundingSphere(o, n), rn.getBoundingSphere(s, r), S.add(i, n.center, r.center), S.scale(i, i, 0.5), t.distance = S.distance(n.center, r.center), t;
}
var au = { sphereA: de(), sphereB: de(), center: S(), distance: 0 };
function BC(e, t) {
  return e.pairs.length === 1 ? "Distance ".concat(Rf(e.pairs[0], { unitLabel: t, measureOnly: !0 })) : "".concat(e.pairs.length, " Distances");
}
function vV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) DC(o.pairs[l], au), c.addFixedLengthDashes(au.sphereA.center, au.sphereB.center, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = BC(t, n.unitLabel);
  return Ct.create(a, t, i, function() {
    return n.linesColor;
  }, function() {
    return n.linesSize;
  }, function(o) {
    return Rf(t.pairs[o], n);
  });
}
function gV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = Tu.create(s, 128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) {
      DC(o.pairs[l], au);
      var m = au.center, p = au.distance, v = au.sphereA, f = au.sphereB, y = s.customText || "".concat(p.toFixed(2), " ").concat(s.unitLabel), h = Math.max(2, v.radius, f.radius) / 2;
      c.add(y, m[0], m[1], m[2], 1, h, l);
    }
    return c.getText();
  }(t, n, r && r.geometry), a = BC(t, n.unitLabel);
  return Ct.create(a, t, i, function() {
    return n.textColor;
  }, function() {
    return n.textSize;
  }, function(o) {
    return Rf(t.pairs[o], n);
  });
}
var yV = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = Mt.createMulti("Distance", o, s, Mt.StateBuilder, MC);
            return u.setState({ pickable: !0, markerActions: Wt.All }), u;
          }(t, function() {
            return hV;
          }), [4, i.createOrUpdate(n ?? {}, { pairs: [{ loci: e.slice(-2) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r && e.setTheme(r), [4, e.createOrUpdate(n ?? {}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, bV = { radius: 1, segments: 36, thetaStart: 0, thetaLength: 2 * Math.PI };
function N3(e) {
  var t = B(B({}, bV), e), n = t.radius, r = t.segments, i = t.thetaStart, a = t.thetaLength, o = a === 2 * Math.PI, s = o ? r + 1 : r + 2, u = new Float32Array(3 * s), c = new Float32Array(3 * s), l = new Uint32Array(3 * r);
  u[0] = 0, u[1] = 0, u[2] = 0, c[0] = 0, c[1] = 1, c[2] = 0;
  for (var d = 0, m = 3; d < r; ++d, m += 3) {
    var p = i + d / r * a;
    u[m] = n * Math.sin(p), u[m + 1] = 0, u[m + 2] = n * Math.cos(p), c[m] = 0, c[m + 1] = 1, c[m + 2] = 0;
  }
  for (d = 1, m = 0; d < r; ++d, m += 3) l[m] = d, l[m + 1] = d + 1, l[m + 2] = 0;
  if (o)
    l[v = 3 * (r - 1)] = r, l[v + 1] = 1, l[v + 2] = 0;
  else {
    var v;
    p = i + a, u[m = 3 * (r + 1)] = n * Math.sin(p), u[m + 1] = 0, u[m + 2] = n * Math.cos(p), c[m] = 0, c[m + 1] = 1, c[m + 2] = 0, l[v = 3 * (r - 1)] = r, l[v + 1] = r + 1, l[v + 2] = 0;
  }
  return { vertices: u, normals: c, indices: l };
}
var RC = { color: N.Color(_t.lightgreen), arcScale: N.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, kC = B(B(B({}, Yt.Params), RC), { lineSizeAttenuation: N.Boolean(!0), linesSize: N.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: N.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), _V = B({}, kC), xV = B({}, kC), SV = B(B(B({}, ht.Params), RC), { ignoreLight: N.Boolean(!0), sectorOpacity: N.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), OC = { vectors: function(e, t) {
  return wn(AV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1 });
  } });
}, arc: function(e, t) {
  return wn(IV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1 });
  } });
}, sector: function(e, t) {
  return wn(wV, ht.Utils, { modifyProps: function(n) {
    return B(B({}, n), { alpha: n.sectorOpacity });
  }, modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.Highlighting });
  } });
}, text: function(e, t) {
  return wn(PV, na.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: $e.None });
  } });
} }, CV = B(B(B(B(B({}, _V), xV), SV), Y0), { visuals: N.MultiSelect(["vectors", "sector", "text"], N.objectToOptions(OC)) }), Xs = S(), wd = J();
function W0(e, t, n) {
  var r = t.sphereA, i = t.sphereB, a = t.sphereC, o = t.arcDirA, s = t.arcDirC, u = t.arcNormal, c = e.loci, l = c[0], d = c[1], m = c[2];
  rn.getBoundingSphere(l, r), rn.getBoundingSphere(d, i), rn.getBoundingSphere(m, a), S.sub(o, r.center, i.center), S.sub(s, a.center, i.center), S.cross(u, o, s);
  var p = Math.min(S.magnitude(o), S.magnitude(s)) * n;
  return t.radius = p, t.angle = S.angle(o, s), t;
}
function NC(e, t) {
  var n = e.radius, r = e.angle, i = t ? o7(r, n) / t : 32;
  return J.targetTo(wd, e.sphereB.center, e.sphereA.center, e.arcNormal), J.setTranslation(wd, e.sphereB.center), J.mul(wd, wd, J.rotY180), D0(N3({ radius: n, thetaLength: r, segments: i }), wd);
}
var Lr = { sphereA: de(), sphereB: de(), sphereC: de(), arcDirA: S(), arcDirC: S(), arcNormal: S(), radius: 0, angle: 0 };
function Z0(e) {
  return e.triples.length === 1 ? "Angle ".concat(k3(e.triples[0], { measureOnly: !0 })) : "".concat(e.triples.length, " Angles");
}
function AV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) W0(o.triples[l], Lr, s.arcScale), c.addFixedLengthDashes(Lr.sphereB.center, Lr.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(Lr.sphereB.center, Lr.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = Z0(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function IV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      W0(o.triples[l], Lr, s.arcScale);
      for (var m = NC(Lr, s.dashLength), p = m.indices, v = m.vertices, f = 0, y = p.length; f < y; f += 3) if (f % 2 != 1) {
        var h = 3 * p[f], g = 3 * p[f + 1], x = v[h], C = v[h + 1], b = v[h + 2], _ = v[g], A = v[g + 1], I = v[g + 2];
        c.add(x, C, b, _, A, I, l);
      }
    }
    return c.getLines();
  }(t, n, r && r.geometry), a = Z0(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function wV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = nt.createState(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      W0(o.triples[l], Lr, s.arcScale);
      var m = NC(Lr);
      c.currentGroup = l, nt.addPrimitive(c, J.id, m), nt.addPrimitiveFlipped(c, J.id, m);
    }
    return nt.getMesh(c);
  }(t, n, r && r.geometry), a = Z0(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return 1;
  }, function(o) {
    return k3(t.triples[o]);
  });
}
function PV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = Tu.create(s, 128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      W0(o.triples[l], Lr, s.arcScale), S.add(Xs, Lr.arcDirA, Lr.arcDirC), S.setMagnitude(Xs, Xs, Lr.radius), S.add(Xs, Lr.sphereB.center, Xs);
      var m = $r(Lr.angle).toFixed(2), p = s.customText || "".concat(m, "°"), v = Math.max(2, Lr.sphereA.radius, Lr.sphereB.radius, Lr.sphereC.radius) / 2;
      c.add(p, Xs[0], Xs[1], Xs[2], 0.1, v, l);
    }
    return c.getText();
  }(t, n, r && r.geometry), a = Z0(t);
  return Ct.create(a, t, i, function() {
    return n.textColor;
  }, function() {
    return n.textSize;
  }, function(o) {
    return k3(t.triples[o]);
  });
}
var EV = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            return Mt.createMulti("Angle", o, s, Mt.StateBuilder, OC);
          }(t, function() {
            return CV;
          }), [4, i.createOrUpdate(n ?? {}, { triples: [{ loci: e.slice(-3) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r && e.setTheme(r), [4, e.createOrUpdate(n ?? {}, { triples: [{ loci: t.slice(-3) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, LC = { color: N.Color(_t.lightgreen), arcScale: N.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, Q0 = B(B(B({}, Yt.Params), LC), { lineSizeAttenuation: N.Boolean(!0), linesSize: N.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: N.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), TV = B({}, Q0), MV = B({}, Q0), DV = B({}, Q0), BV = B({}, Q0), RV = B(B(B({}, ht.Params), LC), { ignoreLight: N.Boolean(!0), sectorOpacity: N.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), FC = { vectors: function(e, t) {
  return wn(OV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
}, extenders: function(e, t) {
  return wn(FV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
}, connector: function(e, t) {
  return wn(NV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
}, arms: function(e, t) {
  return wn(LV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
}, arc: function(e, t) {
  return wn(GV, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { pickable: !1, markerActions: Wt.All });
  } });
}, sector: function(e, t) {
  return wn(VV, ht.Utils, { modifyProps: function(n) {
    return B(B({}, n), { alpha: n.sectorOpacity });
  }, modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, text: function(e, t) {
  return wn(zV, na.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
} }, kV = B(B(B(B(B(B(B({}, TV), MV), DV), BV), RV), Y0), { visuals: N.MultiSelect(["extenders", "arms", "sector", "text"], N.objectToOptions(FC)) }), oi = S(), Pd = J();
function Nc(e, t, n) {
  var r = t.sphereA, i = t.sphereB, a = t.sphereC, o = t.sphereD, s = t.dirBA, u = t.dirCD, c = t.projA, l = t.projD, d = t.arcPointA, m = t.arcPointD, p = t.arcDirA, v = t.arcDirD, f = t.arcCenter, y = t.arcNormal, h = e.loci, g = h[0], x = h[1], C = h[2], b = h[3];
  rn.getBoundingSphere(g, r), rn.getBoundingSphere(x, i), rn.getBoundingSphere(C, a), rn.getBoundingSphere(b, o), S.add(f, i.center, a.center), S.scale(f, f, 0.5), S.sub(s, r.center, i.center), S.sub(u, o.center, a.center), S.add(d, f, s), S.add(m, f, u), S.sub(y, a.center, i.center), S.orthogonalize(p, y, s), S.orthogonalize(v, y, u), S.projectPointOnVector(c, d, p, f), S.projectPointOnVector(l, m, v, f);
  var _ = Math.min(S.distance(c, f), S.distance(l, f)) * n;
  S.setMagnitude(p, p, _), S.setMagnitude(v, v, _), S.add(d, f, p), S.add(m, f, v), t.radius = _, t.angle = S.dihedralAngle(r.center, i.center, a.center, o.center), S.matchDirection(oi, y, S.sub(oi, d, r.center));
  var A = S.angle(s, oi), I = _ / Math.cos(A - xy);
  S.add(c, i.center, S.setMagnitude(oi, s, I)), S.matchDirection(oi, y, S.sub(oi, m, o.center));
  var w = S.angle(u, oi), E = _ / Math.cos(w - xy);
  return S.add(l, a.center, S.setMagnitude(oi, u, E)), t;
}
function GC(e, t) {
  var n = e.radius, r = e.angle, i = t ? o7(r, n) / t : 32;
  return J.targetTo(Pd, e.arcCenter, r < 0 ? e.arcPointD : e.arcPointA, e.arcNormal), J.setTranslation(Pd, e.arcCenter), J.mul(Pd, Pd, J.rotY180), D0(N3({ radius: n, thetaLength: Math.abs(r), segments: i }), Pd);
}
var fn = { sphereA: de(), sphereB: de(), sphereC: de(), sphereD: de(), dirBA: S(), dirCD: S(), projA: S(), projD: S(), arcPointA: S(), arcPointD: S(), arcDirA: S(), arcDirD: S(), arcCenter: S(), arcNormal: S(), radius: 0, angle: 0 };
function Lc(e) {
  return e.quads.length === 1 ? "Dihedral ".concat(O3(e.quads[0], { measureOnly: !0 })) : "".concat(e.quads.length, " Dihedrals");
}
function OV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) Nc(o.quads[l], fn, s.arcScale), c.addFixedLengthDashes(fn.arcCenter, fn.arcPointA, s.dashLength, l), c.addFixedLengthDashes(fn.arcCenter, fn.arcPointD, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function NV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) Nc(o.quads[l], fn, s.arcScale), c.addFixedLengthDashes(fn.sphereB.center, fn.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function LV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) Nc(o.quads[l], fn, s.arcScale), c.addFixedLengthDashes(fn.sphereB.center, fn.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(fn.sphereC.center, fn.sphereD.center, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function FV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) Nc(o.quads[l], fn, s.arcScale), c.addFixedLengthDashes(fn.arcPointA, fn.projA, s.dashLength, l), c.addFixedLengthDashes(fn.arcPointD, fn.projD, s.dashLength, l);
    return c.getLines();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function GV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      Nc(o.quads[l], fn, s.arcScale);
      for (var m = GC(fn, s.dashLength), p = m.indices, v = m.vertices, f = 0, y = p.length; f < y; f += 3) if (f % 2 != 1) {
        var h = 3 * p[f], g = 3 * p[f + 1], x = v[h], C = v[h + 1], b = v[h + 2], _ = v[g], A = v[g + 1], I = v[g + 2];
        c.add(x, C, b, _, A, I, l);
      }
    }
    return c.getLines();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "";
  });
}
function VV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = nt.createState(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      Nc(o.quads[l], fn, s.arcScale);
      var m = GC(fn);
      c.currentGroup = l, nt.addPrimitive(c, J.id, m), nt.addPrimitiveFlipped(c, J.id, m);
    }
    return nt.getMesh(c);
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.color;
  }, function() {
    return 1;
  }, function(o) {
    return O3(t.quads[o]);
  });
}
function zV(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = Tu.create(s, 128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      Nc(o.quads[l], fn, s.arcScale), S.add(oi, fn.arcDirA, fn.arcDirD), S.setMagnitude(oi, oi, fn.radius), S.add(oi, fn.arcCenter, oi);
      var m = $r(fn.angle).toFixed(2);
      m === "-0.00" && (m = "0.00");
      var p = s.customText || "".concat(m, "°"), v = Math.max(2, fn.sphereA.radius, fn.sphereB.radius, fn.sphereC.radius, fn.sphereD.radius) / 2;
      c.add(p, oi[0], oi[1], oi[2], 0.1, v, l);
    }
    return c.getText();
  }(t, n, r && r.geometry), a = Lc(t);
  return Ct.create(a, t, i, function() {
    return n.textColor;
  }, function() {
    return n.textSize;
  }, function(o) {
    return O3(t.quads[o]);
  });
}
var UV = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = Mt.createMulti("Dihedral", o, s, Mt.StateBuilder, FC);
            return u.setState({ pickable: !0, markerActions: Wt.All }), u;
          }(t, function() {
            return kV;
          }), [4, i.createOrUpdate(n ?? {}, { quads: [{ loci: e.slice(-4) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r && e.setTheme(r), [4, e.createOrUpdate(n ?? {}, { quads: [{ loci: t.slice(-4) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, i2 = Bt.is;
function HV(e, t, n, r, i, a) {
  if (!me.isAtomic(t)) return Yt.createEmpty(a);
  var o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !s) return Yt.createEmpty(a);
  var u = Ne.create(n, t), c = t.elements, l = t.bonds, d = l.edgeCount, m = l.a, p = l.b, v = l.edgeProps, f = l.offset;
  if (!d) return Yt.createEmpty(a);
  var y = v.order, h = v.flags, g = i.sizeFactor, x = i.aromaticBonds, C = i.includeTypes, b = i.excludeTypes, _ = i.multipleBonds, A = _ === "off", I = _ === "symmetric", w = j0(Bt.fromNames(C), Bt.fromNames(b), 32), E = S(), D = t.conformation.invariantPosition, T = t.rings, P = T.elementRingIndices, M = T.elementAromaticRingIndices, R = x ? t.resonance.delocalizedTriplets : void 0, O = { linkCount: 2 * d, referencePosition: function(U) {
    var q, H, K = m[U], j = p[U], W = R == null ? void 0 : R.getThirdElement(K, j);
    if (W !== void 0) return D(c[W], E);
    K > j && (K = (q = [j, K])[0], j = q[1]), f[K + 1] - f[K] == 1 && (K = (H = [j, K])[0], j = H[1]);
    for (var Z = M.get(K) || P.get(K), Y = 0, te = f[K], ee = f[K + 1]; te < ee; ++te) {
      var $ = p[te];
      if ($ !== j && $ !== K) {
        if (!Z) return D(c[$], E);
        var ue = M.get($) || P.get($);
        if (!ue) continue;
        var se = Lm(Z, ue);
        se > Y && (Y = se, D(c[$], E));
      }
    }
    return Y > 0 ? E : null;
  }, position: function(U, q, H) {
    D(c[m[H]], U), D(c[p[H]], q);
  }, style: function(U) {
    var q = y[U], H = h[U];
    if (i2(H, 2) || i2(H, 4)) return 1;
    if (q === 3) return A ? 0 : I ? 4 : 5;
    if (x) {
      var K = m[U], j = p[U], W = M.get(K), Z = M.get(j), Y = W && Z ? Lm(W, Z) : 0;
      if (i2(H, 16) || Y && !w) {
        if (Y === 2) return 8;
        if (Y === 1 || R != null && R.getThirdElement(K, j)) return 7;
      }
    }
    return q !== 2 || A ? 0 : I ? 2 : 3;
  }, radius: function(U) {
    u.element = c[m[U]];
    var q = r.size.size(u);
    u.element = c[p[U]];
    var H = r.size.size(u);
    return Math.min(q, H) * g;
  }, ignore: vC(n, t, i) }, L = hC(0, O, i, a), F = L.lines, G = L.boundingSphere;
  if (G) F.setBoundingSphere(G);
  else if (F.lineCount > 0) {
    var V = de.expand(de(), (s ?? t).boundary.sphere, 1 * g);
    F.setBoundingSphere(V);
  }
  return F;
}
var VC = B(B(B({}, w3), D3), { includeParent: N.Boolean(!1) });
function qV(e) {
  return P3({ defaultProps: N.getDefaultValues(VC), createGeometry: HV, createLocationIterator: Mu.fromGroup, getLoci: ag, eachLocation: og, setUpdateState: function(t, n, r, i, a, o, s) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.linkScale !== r.linkScale || n.linkSpacing !== r.linkSpacing || n.aromaticDashCount !== r.aromaticDashCount || n.dashCount !== r.dashCount || n.ignoreHydrogens !== r.ignoreHydrogens || !Si(n.includeTypes, r.includeTypes) || !Si(n.excludeTypes, r.excludeTypes) || n.aromaticBonds !== r.aromaticBonds || n.multipleBonds !== r.multipleBonds;
    var u = o.group.units[0], c = s.group.units[0];
    me.isAtomic(u) && me.isAtomic(c) && (Ui.areEqual(u.bonds, c.bonds) || (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0));
  } }, e);
}
var a2 = new rt.ElementBondIterator();
function Y_(e, t, n, r) {
  for (a2.setElement(t, n, r); a2.hasNext; ) {
    var i = a2.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], e), e;
  }
  return null;
}
function jV(e, t, n, r, i) {
  var a = t.interUnitBonds, o = a.edgeCount, s = a.edges;
  if (!o) return Yt.createEmpty(i);
  var u = r.sizeFactor, c = r.aromaticBonds, l = r.multipleBonds, d = l === "off", m = l === "symmetric", p = S(), v = Ne.create(), f = { linkCount: o, referencePosition: function(b) {
    var _, A, I, w, E = s[b];
    if (E.unitA < E.unitB) _ = t.unitMap.get(E.unitA), A = t.unitMap.get(E.unitB), I = E.indexA, w = E.indexB;
    else {
      if (!(E.unitA > E.unitB)) throw new Error("same units in createInterUnitBondLines");
      _ = t.unitMap.get(E.unitB), A = t.unitMap.get(E.unitA), I = E.indexB, w = E.indexA;
    }
    return Y_(p, t, _, I) || Y_(p, t, A, w);
  }, position: function(b, _, A) {
    var I = s[A], w = t.unitMap.get(I.unitA), E = t.unitMap.get(I.unitB);
    w.conformation.position(w.elements[I.indexA], b), E.conformation.position(E.elements[I.indexB], _);
  }, style: function(b) {
    var _ = s[b].props.order, A = Qr.create(s[b].props.flag);
    return Bt.is(A, 2) || Bt.is(A, 4) ? 1 : _ === 3 ? d ? 0 : m ? 4 : 5 : c && Bt.is(A, 16) ? 7 : _ !== 2 || d ? 0 : m ? 2 : 3;
  }, radius: function(b) {
    var _ = s[b];
    v.structure = t, v.unit = t.unitMap.get(_.unitA), v.element = v.unit.elements[_.indexA];
    var A = n.size.size(v);
    v.unit = t.unitMap.get(_.unitB), v.element = v.unit.elements[_.indexB];
    var I = n.size.size(v);
    return Math.min(A, I) * u;
  }, ignore: gC(t, r) }, y = hC(0, f, r, i), h = y.lines, g = y.boundingSphere;
  if (g) h.setBoundingSphere(g);
  else if (h.lineCount > 0) {
    var x = t.child, C = de.expand(de(), (x ?? t).boundary.sphere, 1 * u);
    h.setBoundingSphere(C);
  }
  return h;
}
var zC = B(B(B({}, zF), D3), { includeParent: N.Boolean(!1) });
function KV(e) {
  return function(t, n) {
    return U0(B(B({}, t), { setUpdateState: function(r, i, a, o, s, u, c) {
      t.setUpdateState(r, i, a, o, s, u, c), Ai.areEqual(o.size, s.size) || (r.updateSize = !0);
    }, geometryUtils: Yt.Utils }), n);
  }({ defaultProps: N.getDefaultValues(zC), createGeometry: jV, createLocationIterator: Mu.fromStructure, getLoci: sg, eachLocation: ug, setUpdateState: function(t, n, r, i, a, o, s) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.linkScale !== r.linkScale || n.linkSpacing !== r.linkSpacing || n.aromaticDashCount !== r.aromaticDashCount || n.dashCount !== r.dashCount || n.ignoreHydrogens !== r.ignoreHydrogens || !Si(n.includeTypes, r.includeTypes) || !Si(n.excludeTypes, r.excludeTypes) || n.multipleBonds !== r.multipleBonds, o.interUnitBonds !== s.interUnitBonds && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0);
  } }, e);
}
var cg, XV = he.add3, YV = he.add;
(function(e) {
  e.create = function(t, n, r) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024);
    var i = he.create(Float32Array, 3, n, r ? r.centerBuffer.ref.value : t), a = he.create(Float32Array, 1, n, r ? r.groupBuffer.ref.value : t);
    return { add: function(o, s, u, c) {
      XV(i, o, s, u), YV(a, c);
    }, getPoints: function() {
      var o = he.compact(i, !0), s = he.compact(a, !0);
      return Pc.create(o, s, i.elementCount, r);
    } };
  };
})(cg || (cg = {}));
var W_ = S.add, UC = B(B({}, jF), { pointSizeAttenuation: N.Boolean(!1), ignoreHydrogens: N.Boolean(!1), traceOnly: N.Boolean(!1) });
function WV(e, t, n, r, i, a) {
  var o = n.child;
  if (o && !o.unitMap.get(t.id)) return Pc.createEmpty(a);
  var s = t.elements, u = s.length, c = cg.create(u, u / 10, a), l = S(), d = t.conformation.invariantPosition, m = K0(n, t, i), p = S(), v = 0;
  if (m) for (var f = 0; f < u; ++f) m(s[f]) || (d(s[f], l), W_(p, p, l), v += 1, c.add(l[0], l[1], l[2], f));
  else for (f = 0; f < u; ++f) d(s[f], l), W_(p, p, l), v += 1, c.add(l[0], l[1], l[2], f);
  var y, h = a ? de.clone(a.boundingSphere) : void 0, g = c.getPoints();
  return v === 0 || (S.scale(p, p, 1 / v), y = h && S.distance(p, h.center) / h.radius < 1 ? h : de.expand(de(), t.boundary.sphere, 1), g.setBoundingSphere(y)), g;
}
function ZV(e) {
  return function(t, n) {
    return Kf(B(B({}, t), { setUpdateState: function(r, i, a, o, s, u, c) {
      t.setUpdateState(r, i, a, o, s, u, c), Ai.areEqual(o.size, s.size) || (r.updateSize = !0);
    }, geometryUtils: Pc.Utils }), n);
  }({ defaultProps: N.getDefaultValues(UC), createGeometry: WV, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(t, n, r) {
    t.createGeometry = n.ignoreHydrogens !== r.ignoreHydrogens || n.traceOnly !== r.traceOnly;
  } }, e);
}
var ll = S.scaleAndAdd, Z_ = S.unitX, Q_ = S.unitY, J_ = S.unitZ, HC = B(B({}, w3), { lineSizeAttenuation: N.Boolean(!1), ignoreHydrogens: N.Boolean(!1), traceOnly: N.Boolean(!1), crosses: N.Select("lone", N.arrayToOptions(["lone", "all"])), crossSize: N.Numeric(0.35, { min: 0, max: 2, step: 0.01 }) });
function QV(e, t, n, r, i, a) {
  var o = n.child;
  if (o && !o.unitMap.get(t.id)) return Yt.createEmpty(a);
  for (var s = t.elements, u = s.length, c = zr.create(u, u / 10, a), l = S(), d = S(), m = S(), p = t.conformation.invariantPosition, v = K0(n, t, i), f = i.crossSize / 2, y = i.crosses === "lone", h = 0; h < u; ++h) v && v(s[h]) || y && me.isAtomic(t) && Pf(n, t, h) !== 0 || (p(s[h], l), ll(d, l, Z_, f), ll(m, l, Z_, -f), c.add(d[0], d[1], d[2], m[0], m[1], m[2], h), ll(d, l, Q_, f), ll(m, l, Q_, -f), c.add(d[0], d[1], d[2], m[0], m[1], m[2], h), ll(d, l, J_, f), ll(m, l, J_, -f), c.add(d[0], d[1], d[2], m[0], m[1], m[2], h));
  var g = c.getLines(), x = de.expand(de(), t.boundary.sphere, 1 * i.sizeFactor);
  return g.setBoundingSphere(x), g;
}
function JV(e) {
  return P3({ defaultProps: N.getDefaultValues(HC), createGeometry: QV, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(t, n, r) {
    t.createGeometry = n.ignoreHydrogens !== r.ignoreHydrogens || n.traceOnly !== r.traceOnly || n.crosses !== r.crosses || n.crossSize !== r.crossSize;
  } }, e);
}
var qC = { "intra-bond": function(e, t) {
  return ui("Intra-unit bond line", e, t, qV);
}, "inter-bond": function(e, t) {
  return Mc("Inter-unit bond line", e, t, KV);
}, "element-point": function(e, t) {
  return ui("Points", e, t, ZV);
}, "element-cross": function(e, t) {
  return ui("Crosses", e, t, JV);
}, "charge-text": function(e, t) {
  return Mc("Charge Text", e, t, R3);
} }, $_ = B(B(B(B(B({}, VC), zC), UC), HC), { multipleBonds: N.Select("offset", N.arrayToOptions(["off", "symmetric", "offset"])), includeParent: N.Boolean(!1), sizeFactor: N.Numeric(0.01, { min: 0.01, max: 10, step: 0.01 }), unitKinds: jf(["atomic"]), visuals: N.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross", "charge-text"], N.objectToOptions(qC)), lineSizeAttenuation: N.Boolean(!0), traceOnly: N.Boolean(!1, { isHidden: !0 }), pointSizeAttenuation: N.Boolean(!0), pointStyle: N.Select("circle", N.objectToOptions({ square: "Square", circle: "Circle", fuzzy: "Fuzzy" })) }), o2 = { name: "line", label: "Line", description: "Displays bonds as lines and atoms as points or croses.", factory: function(e, t) {
  return Mt.createMulti("Line", e, t, ia, qC);
}, getParams: function(e, t) {
  var n = N.clone($_);
  return n.pointStyle.defaultValue = "circle", n;
}, defaultValues: N.getDefaultValues($_), 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;
} }, $V = { create: function(e, t, n) {
  var r;
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = o2.factory(t, o2.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(B(B({}, o2.defaultValues), { aromaticBonds: ((r = e.model) === null || r === void 0 ? void 0 : r.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 a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: n.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, jC = { "element-sphere": function(e, t) {
  return ui("Element sphere", e, t, B3);
}, "intra-bond": function(e, t) {
  return ui("Intra-unit bond cylinder", e, t, bC);
}, "inter-bond": function(e, t) {
  return Mc("Inter-unit bond cylinder", e, t, xC);
}, "charge-text": function(e, t) {
  return Mc("Charge Text", e, t, R3);
} }, e8 = B(B(B(B(B({}, Bf), { traceOnly: N.Boolean(!1, { isHidden: !0 }) }), y0), b0), { includeParent: N.Boolean(!1), unitKinds: jf(["atomic"]), visuals: N.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], N.objectToOptions(jC)), bumpFrequency: N.Numeric(0, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), sizeFactor: N.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: N.Numeric(1, { min: 0.01, max: 3, step: 0.01 }), multipleBonds: N.Select("offset", N.arrayToOptions(["off", "symmetric", "offset"])), tryUseImpostor: N.Boolean(!0), linkScale: N.Numeric(0.55, { min: 0, max: 1, step: 0.01 }) }), s2 = { name: "stick", label: "Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return Mt.createMulti("Ball & Stick", e, t, ia, jC);
}, getParams: function(e, t) {
  return N.clone(e8);
}, defaultValues: N.getDefaultValues(e8), 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;
} }, ez = { create: function(e, t, n) {
  var r;
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = s2.factory(t, s2.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(B(B({}, s2.defaultValues), { aromaticBonds: ((r = e.model) === null || r === void 0 ? void 0 : r.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 a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: n.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, L3 = { probeRadius: N.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }), resolution: N.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, B({ description: "Grid resolution/cell spacing." }, Ve.CustomQualityParamInfo)), probePositions: N.Numeric(36, { min: 12, max: 90, step: 1 }, B({ description: "Number of positions tested for probe target intersection." }, Ve.CustomQualityParamInfo)) };
function tz(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    function o(Ee, Ye, He, le, Ce) {
      if (d !== -1) {
        if ((Re = d) !== le && Re !== Ce && s(Re, Ee, Ye, He)) return Re;
        d = -1;
      }
      for (var Ae = 0, Te = A.count; Ae < Te; ++Ae) {
        var Re;
        if ((Re = ve.getAt(I, A.indices[Ae])) !== le && Re !== Ce && s(Re, Ee, Ye, He)) return d = Re, Re;
      }
      return -1;
    }
    function s(Ee, Ye, He, le) {
      var Ce = P[Ee], Ae = w[Ee] - Ye, Te = E[Ee] - He, Re = D[Ee] - le;
      return Ae * Ae + Te * Te + Re * Re < Ce * Ce;
    }
    function u() {
      return ie(this, 0, void 0, function() {
        var Ee;
        return ne(this, function(Ye) {
          switch (Ye.label) {
            case 0:
              Ee = 0, Ye.label = 1;
            case 1:
              return Ee < M ? (function(He, le) {
                for (var Ce = He; Ce < le; ++Ce) {
                  var Ae = ve.getAt(I, Ce), Te = w[Ae], Re = E[Ae], we = D[Ae], Qe = P[Ae], Je = Qe * Qe;
                  _.find(Te, Re, we, Qe);
                  for (var lt = Math.ceil(Qe * x), st = Math.floor(x * (Te - F)), ft = Math.floor(x * (Re - G)), It = Math.floor(x * (we - V)), pe = Math.max(0, st - lt), We = Math.max(0, ft - lt), gt = Math.max(0, It - lt), cn = Math.min(H, st + lt + 2), Kt = Math.min(K, ft + lt + 2), hn = Math.min(j, It + lt + 2), jt = pe; jt < cn; ++jt) for (var Rn = be[jt] - Te, ur = jt * Z, ir = We; ir < Kt; ++ir) for (var Hn = ke[ir] - Re, Dn = Rn * Rn + Hn * Hn, Dr = ir * W + ur, En = gt; En < hn; ++En) {
                    var Tn = Oe[En] - we, mi = Dn + Tn * Tn;
                    if (mi < Je) {
                      var Hr = En + Dr;
                      ue[Hr] < 0 && (ue[Hr] *= -1);
                      var Vo = Math.sqrt(mi), qn = Qe / Vo;
                      if (o(Rn * qn + Te, Hn * qn + Re, Tn * qn + we, Ae, -1) === -1) {
                        var kn = Qe - Vo;
                        kn < ue[Hr] && (ue[Hr] = kn, se[Hr] = T[Ce]);
                      }
                    }
                  }
                }
              }(Ee, Math.min(Ee + ze, M)), e.shouldUpdate ? [4, e.update({ message: "projecting points", current: Ee, max: M })] : [3, 3]) : [3, 4];
            case 2:
              Ye.sent(), Ye.label = 3;
            case 3:
              return Ee += ze, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    function c(Ee, Ye) {
      var He = P[Ee], le = P[Ye], Ce = m[0] = w[Ye] - w[Ee], Ae = m[1] = E[Ye] - E[Ee], Te = m[2] = D[Ye] - D[Ee], Re = Ce * Ce + Ae * Ae + Te * Te, we = Math.sqrt(Re), Qe = He * ((He * He + we * we - le * le) / (2 * He * we));
      S.normalize(m, m), function(Oa, qr) {
        Oa[0] = Oa[1] = Oa[2] = 1, qr[0] !== 0 ? Oa[0] = (qr[1] + qr[2]) / -qr[0] : qr[1] !== 0 ? Oa[1] = (qr[0] + qr[2]) / -qr[1] : qr[2] !== 0 && (Oa[2] = (qr[0] + qr[1]) / -qr[2]);
      }(v, m), S.normalize(v, v), S.cross(f, m, v), S.normalize(f, f);
      var Je = Math.sqrt(He * He - Qe * Qe);
      S.scale(v, v, Je), S.scale(f, f, Je), S.scale(m, m, Qe), p[0] = m[0] + w[Ee], p[1] = m[1] + E[Ee], p[2] = m[2] + D[Ee], d = -1;
      for (var lt = 0; lt < g; ++lt) {
        var st = te[lt], ft = ee[lt], It = p[0] + st * v[0] + ft * f[0], pe = p[1] + st * v[1] + ft * f[1], We = p[2] + st * v[2] + ft * f[2];
        if (o(It, pe, We, Ee, Ye) === -1) for (var gt = Math.floor(x * (It - F)), cn = Math.floor(x * (pe - G)), Kt = Math.floor(x * (We - V)), hn = Math.max(0, gt - C), jt = Math.max(0, cn - C), Rn = Math.max(0, Kt - C), ur = Math.min(H, gt + C + 2), ir = Math.min(K, cn + C + 2), Hn = Math.min(j, Kt + C + 2), Dn = hn; Dn < ur; ++Dn) for (var Dr = It - be[Dn], En = Dn * Z, Tn = jt; Tn < ir; ++Tn) for (var mi = pe - ke[Tn], Hr = Dr * Dr + mi * mi, Vo = Tn * W + En, qn = Rn; qn < Hn; ++qn) {
          var kn = We - Oe[qn], zo = Hr + kn * kn, Uo = qn + Vo, oo = ue[Uo];
          if (oo > 0 && zo < oo * oo) {
            ue[Uo] = Math.sqrt(zo);
            var Fc = Dr * m[0] + mi * m[1] + kn * m[2];
            se[Uo] = T[ve.indexOf(I, Fc < 0 ? Ye : Ee)];
          }
        }
      }
    }
    function l() {
      return ie(this, 0, void 0, function() {
        var Ee;
        return ne(this, function(Ye) {
          switch (Ye.label) {
            case 0:
              Ee = 0, Ye.label = 1;
            case 1:
              return Ee < M ? (function(He, le) {
                for (var Ce = He; Ce < le; ++Ce) {
                  var Ae = ve.getAt(I, Ce);
                  _.find(w[Ae], E[Ae], D[Ae], P[Ae]);
                  for (var Te = 0, Re = A.count; Te < Re; ++Te) {
                    var we = ve.getAt(I, A.indices[Te]);
                    Ae < we && c(Ae, we);
                  }
                }
              }(Ee, Math.min(Ee + ze, M)), e.shouldUpdate ? [4, e.update({ message: "projecting torii", current: Ee, max: M })] : [3, 3]) : [3, 4];
            case 2:
              Ye.sent(), Ye.label = 3;
            case 3:
              return Ee += ze, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    var d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L, F, G, V, U, q, H, K, j, W, Z, Y, te, ee, $, ue, se, be, ke, Oe, ze, je, xe, Xe;
    return ne(this, function(Ee) {
      switch (Ee.label) {
        case 0:
          return d = -1, m = S(), p = S(), v = S(), f = S(), y = a.resolution, h = a.probeRadius, g = a.probePositions, x = 1 / y, C = Math.max(5, 2 + Math.floor(h * x)), b = S.create(r, r, r), S.scale(b, b, 2), _ = xc(t, n, b), A = _.result, i === null && (i = _.boundary.box), I = t.indices, w = t.x, E = t.y, D = t.z, T = t.id, P = t.radius, M = ve.size(I), R = r + y, O = sn.expand(sn(), i, S.create(R, R, R)), L = O.min, F = L[0], G = L[1], V = L[2], U = sn.scale(sn(), O, x), q = sn.size(S(), U), S.ceil(q, q), H = q[0], K = q[1], j = q[2], Z = (W = j) * K, Y = function(Ye) {
            for (var He = 0, le = 2 * Math.PI / Ye, Ce = new Float32Array(Ye), Ae = new Float32Array(Ye), Te = 0; Te < Ye; Te++) Ce[Te] = Math.cos(He), Ae[Te] = Math.sin(He), He += le;
            return { cosTable: Ce, sinTable: Ae };
          }(g), te = Y.cosTable, ee = Y.sinTable, $ = Nn.Space(q, [0, 1, 2], Float32Array), ue = $.create(), se = $.create(), ue.fill(-1001), se.fill(-1), be = pp(H, F, y), ke = pp(K, G, y), Oe = pp(j, V, y), ze = Math.ceil(1e5 / (Math.pow(Math.pow(r, 3), 3) * x)), [4, u()];
        case 1:
          return Ee.sent(), [4, l()];
        case 2:
          return Ee.sent(), je = Nn.create($, ue), xe = Nn.create($, se), Xe = J.identity(), J.fromScaling(Xe, S.create(y, y, y)), J.setTranslation(Xe, O.min), [2, { field: je, idField: xe, transform: Xe, resolution: y, maxRadius: r }];
      }
    });
  });
}
function KC(e, t, n, r) {
  var i = this, a = t.lookup3d.boundary.box, o = kF(a, r), s = function(d, m, p, v) {
    for (var f = v.probeRadius, y = LF(d, m, p, v), h = y.position, g = y.boundary, x = y.radius, C = h.indices, b = ve.size(C), _ = new Float32Array(ve.end(C)), A = 0, I = 0; I < b; ++I) {
      var w = ve.getAt(C, I), E = x(w);
      A < E && (A = E), _[w] = E + f;
    }
    return { position: B(B({}, h), { radius: _ }), boundary: g, maxRadius: A };
  }(e, t, n, o), u = s.position, c = s.boundary, l = s.maxRadius;
  return At.create("Molecular Surface", function(d) {
    return ie(i, 0, void 0, function() {
      return ne(this, function(m) {
        switch (m.label) {
          case 0:
            return [4, nz(d, u, c, l, a, o)];
          case 1:
            return [2, m.sent()];
        }
      });
    });
  });
}
function nz(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(o) {
      return [2, tz(e, t, n, r, i, a)];
    });
  });
}
function Ys(e, t, n) {
  return { i: e, j: t, k: n };
}
function ha(e, t) {
  return { a: e, b: t };
}
N.getDefaultValues(L3);
var Vn = [Ys(0, 0, 0), Ys(1, 0, 0), Ys(1, 1, 0), Ys(0, 1, 0), Ys(0, 0, 1), Ys(1, 0, 1), Ys(1, 1, 1), Ys(0, 1, 1)], rz = [ha(Vn[0], Vn[1]), ha(Vn[1], Vn[2]), ha(Vn[2], Vn[3]), ha(Vn[3], Vn[0]), ha(Vn[4], Vn[5]), ha(Vn[5], Vn[6]), ha(Vn[6], Vn[7]), ha(Vn[7], Vn[4]), ha(Vn[0], Vn[4]), ha(Vn[1], Vn[5]), ha(Vn[2], Vn[6]), ha(Vn[3], Vn[7])], iz = [{ 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 }], az = [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], Il = [[], [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], []], u2 = [[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 XC(e) {
  return B(B({}, e), { bottomLeft: mr(e.bottomLeft, [0, 0, 0]), topRight: mr(e.topRight, e.scalarField.space.dimensions) });
}
function YC(e) {
  return { dX: e.topRight[0] - e.bottomLeft[0], dY: e.topRight[1] - e.bottomLeft[1], dZ: e.topRight[2] - e.bottomLeft[2] };
}
function WC(e, t) {
  var n = this;
  return At.create("Marching Cubes Mesh", function(r) {
    return ie(n, 0, void 0, function() {
      var i, a, o, s, u, c, l;
      return ne(this, function(d) {
        switch (d.label) {
          case 0:
            return i = XC(e), a = YC(i), o = a.dX, s = a.dY, u = a.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(m, p) {
              var v = Math.min(65536, 4 * m), f = he.create(Float32Array, 3, m, p && p.vertexBuffer.ref.value), y = he.create(Float32Array, 3, m, p && p.normalBuffer.ref.value), h = he.create(Float32Array, 1, m, p && p.groupBuffer.ref.value), g = he.create(Uint32Array, 3, v, p && p.indexBuffer.ref.value), x = 0, C = 0;
              return { addVertex: function(b, _, A) {
                return ++x, he.add3(f, b, _, A);
              }, addNormal: function(b, _, A) {
                he.add3(y, b, _, A);
              }, addGroup: function(b) {
                he.add(h, b);
              }, addTriangle: function(b, _, A, I) {
                var w = b[_], E = b[A], D = b[I];
                w >= 0 && E >= 0 && D >= 0 && (++C, he.add3(g, w, E, D));
              }, get: function() {
                var b = he.compact(f, !0), _ = he.compact(y, !0), A = he.compact(g, !0), I = he.compact(h, !0);
                return ht.create(b, A, _, I, x, C, p);
              } };
            }(c, t), [4, new QC(r, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
function ZC(e, t) {
  var n = this;
  return At.create("Marching Cubes Lines", function(r) {
    return ie(n, 0, void 0, function() {
      var i, a, o, s, u, c, l;
      return ne(this, function(d) {
        switch (d.label) {
          case 0:
            return i = XC(e), a = YC(i), o = a.dX, s = a.dY, u = a.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(m, p) {
              var v = he.create(Float32Array, 3, m), f = he.create(Float32Array, 1, m), y = he.create(Float32Array, 2, m), h = 0;
              return { addVertex: function(g, x, C) {
                return he.add3(v, g, x, C);
              }, addNormal: function() {
                return Bg;
              }, addGroup: function(g) {
                he.add(f, g);
              }, addTriangle: function(g, x, C, b, _) {
                var A = g[x], I = g[C], w = g[b];
                A >= 0 && I >= 0 && w >= 0 && (u2[x][C] & _ && (++h, he.add2(y, g[x], g[C])), u2[C][b] & _ && (++h, he.add2(y, g[C], g[b])), u2[x][b] & _ && (++h, he.add2(y, g[x], g[b])));
              }, get: function() {
                for (var g = he.compact(v, !0), x = he.compact(y, !0), C = he.compact(f, !0), b = zr.create(h, h / 10, p), _ = 0; _ < h; ++_) {
                  var A = x[2 * _], I = x[2 * _ + 1];
                  b.add(g[3 * A], g[3 * A + 1], g[3 * A + 2], g[3 * I], g[3 * I + 1], g[3 * I + 2], C[A]);
                }
                return b.getLines();
              } };
            }(c, t), [4, new QC(r, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
var QC = function() {
  function e(t, n, r) {
    this.ctx = t, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new oz(n, r), this.minX = r.bottomLeft[0], this.minY = r.bottomLeft[1], this.minZ = r.bottomLeft[2], this.maxX = r.topRight[0] - 1, this.maxY = r.topRight[1] - 1, this.maxZ = r.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 ie(this, 0, void 0, function() {
      var t, n;
      return ne(this, function(r) {
        switch (r.label) {
          case 0:
            t = 0, this.edgeFilter = 15, n = this.minZ, r.label = 1;
          case 1:
            return n < this.maxZ ? (this.slice(n), t += this.sliceSize, this.ctx.shouldUpdate ? [4, this.ctx.update({ message: "Computing surface...", current: t, max: this.size })] : [3, 3]) : [3, 4];
          case 2:
            r.sent(), r.label = 3;
          case 3:
            return n++, this.edgeFilter &= -5, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.slice = function(t) {
    this.edgeFilter |= 2;
    for (var n = this.minY; n < this.maxY; n++, this.edgeFilter &= -3) {
      this.edgeFilter |= 1;
      for (var r = this.minX; r < this.maxX; r++, this.edgeFilter &= -2) this.state.processCell(r, n, t, this.edgeFilter);
    }
    this.state.clearEdgeVertexIndexSlice(t);
  }, e.prototype.run = function() {
    return ie(this, 0, void 0, function() {
      return ne(this, function(t) {
        switch (t.label) {
          case 0:
            return [4, this.doSlices()];
          case 1:
            return t.sent(), [2];
        }
      });
    });
  }, e;
}(), oz = function() {
  function e(t, n) {
    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 r = n.scalarField.space.dimensions;
    this.nX = r[0], this.nY = r[1], this.nZ = r[2], this.isoLevel = n.isoLevel, this.scalarFieldGet = n.scalarField.space.get, this.scalarField = n.scalarField.data, n.idField && (this.idField = n.idField.data, this.idFieldGet = n.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 n = t % 2 == 0 ? 0 : 3 * this.nX * this.nY, r = t % 2 == 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
    this.verticesOnEdges.fill(0, n, r);
  }, e.prototype.interpolate = function(t) {
    var n = iz[t], r = 3 * this.get3dOffsetFromEdgeInfo(n) + n.e, i = this.verticesOnEdges[r];
    if (i > 0) return i - 1;
    var a = this.scalarField, o = this.scalarFieldGet, s = rz[t], u = s.a, c = s.b, l = u.i + this.i, d = u.j + this.j, m = u.k + this.k, p = c.i + this.i, v = c.j + this.j, f = c.k + this.k, y = o(a, l, d, m), h = o(a, p, v, f), g = (this.isoLevel - y) / (y - h);
    if (this.idField) {
      var x = this.idFieldGet(this.idField, l, d, m), C = this.idFieldGet(this.idField, p, v, f), b = g < 0.5 ? x : C;
      if (b === -1 && (b = g < 0.5 ? C : x), b === -2) return -1;
      this.builder.addGroup(b);
    } else this.builder.addGroup(0);
    var _ = this.builder.addVertex(l + g * (l - p), d + g * (d - v), m + g * (m - f));
    this.verticesOnEdges[r] = _ + 1;
    var A = o(a, Math.max(0, l - 1), d, m) - o(a, Math.min(this.nX - 1, l + 1), d, m), I = o(a, l, Math.max(0, d - 1), m) - o(a, l, Math.min(this.nY - 1, d + 1), m), w = o(a, l, d, Math.max(0, m - 1)) - o(a, l, d, Math.min(this.nZ, m + 1)), E = A + g * (A - (o(a, Math.max(0, p - 1), v, f) - o(a, Math.min(this.nX - 1, p + 1), v, f))), D = I + g * (I - (o(a, p, Math.max(0, v - 1), f) - o(a, p, Math.min(this.nY - 1, v + 1), f))), T = w + g * (w - (o(a, p, v, Math.max(0, f - 1)) - o(a, p, v, Math.min(this.nZ - 1, f + 1))));
    return this.isoLevel >= 0 ? this.builder.addNormal(E, D, T) : this.builder.addNormal(-E, -D, -T), _;
  }, e.prototype.get = function(t, n, r) {
    return this.scalarFieldGet(this.scalarField, t, n, r);
  }, e.prototype.processCell = function(t, n, r, i) {
    var a = 0;
    if (this.get(t, n, r) < this.isoLevel && (a |= 1), this.get(t + 1, n, r) < this.isoLevel && (a |= 2), this.get(t + 1, n + 1, r) < this.isoLevel && (a |= 4), this.get(t, n + 1, r) < this.isoLevel && (a |= 8), this.get(t, n, r + 1) < this.isoLevel && (a |= 16), this.get(t + 1, n, r + 1) < this.isoLevel && (a |= 32), this.get(t + 1, n + 1, r + 1) < this.isoLevel && (a |= 64), this.get(t, n + 1, r + 1) < this.isoLevel && (a |= 128), a !== 0 && a !== 255) {
      this.i = t, this.j = n, this.k = r;
      var o = az[a];
      (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 = Il[a], 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, i) : this.builder.addTriangle(this.vertList, d, l, c, i);
      }
    }
  }, e;
}(), JC = B(B(B(B({}, Ds), L3), I3), GB);
function sz(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    var o, s, u, c, l, d, m, p, v;
    return ne(this, function(f) {
      switch (f.label) {
        case 0:
          return [4, KC(n, t, r.size, i).runInContext(e.runtime)];
        case 1:
          return o = f.sent(), s = o.transform, u = o.field, c = o.idField, l = o.resolution, d = o.maxRadius, [4, WC({ isoLevel: i.probeRadius, scalarField: u, idField: c }, a).runAsChild(e.runtime)];
        case 2:
          return m = f.sent(), i.includeParent && (p = Math.ceil(2 / i.resolution), ht.smoothEdges(m, { iterations: p, maxNewEdgeLength: Math.sqrt(2) })), ht.transform(m, s), e.webgl && !e.webgl.isWebGL2 && ht.uniformTriangleGroup(m), v = de.expand(de(), t.boundary.sphere, d), m.setBoundingSphere(v), m.meta.resolution = l, [2, m];
      }
    });
  });
}
function uz(e) {
  return Bs({ defaultProps: N.getDefaultValues(JC), createGeometry: sz, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(t, n, r) {
    n.resolution !== r.resolution && (t.createGeometry = !0), n.probeRadius !== r.probeRadius && (t.createGeometry = !0), n.probePositions !== r.probePositions && (t.createGeometry = !0), n.ignoreHydrogens !== r.ignoreHydrogens && (t.createGeometry = !0), n.traceOnly !== r.traceOnly && (t.createGeometry = !0), n.includeParent !== r.includeParent && (t.createGeometry = !0), n.smoothColors.name !== r.smoothColors.name ? t.updateColor = !0 : n.smoothColors.name === "on" && r.smoothColors.name === "on" && (n.smoothColors.params.resolutionFactor !== r.smoothColors.params.resolutionFactor && (t.updateColor = !0), n.smoothColors.params.sampleStride !== r.smoothColors.params.sampleStride && (t.updateColor = !0));
  }, processValues: function(t, n, r, i, a) {
    var o = n.meta, s = o.resolution, u = o.colorTexture, c = nc(r.smoothColors, i.color.preferSmoothing, s);
    c && (function(l, d, m, p, v) {
      if (/* @__PURE__ */ function(y) {
        return y === "group" || y === "groupInstance";
      }(l.dColorType.ref.value)) {
        var f = xm({ 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, m, p, v);
        f.kind === "volume" ? (k.updateIfChanged(l.dColorType, f.type), k.update(l.tColorGrid, f.texture), k.update(l.uColorTexDim, f.gridTexDim), k.update(l.uColorGridDim, f.gridDim), k.update(l.uColorGridTransform, f.gridTransform)) : f.kind === "vertex" && (k.updateIfChanged(l.dColorType, f.type), k.update(l.tColor, f.texture), k.update(l.uColorTexDim, f.texDim));
      }
    }(t, c.resolution, c.stride, a, u), n.meta.colorTexture = t.tColorGrid.ref.value);
  }, dispose: function(t) {
    var n;
    (n = t.meta.colorTexture) === null || n === void 0 || n.destroy();
  } }, e);
}
var $C = B(B(B(B({}, w3), L3), I3), { sizeFactor: N.Numeric(1.5, { min: 0, max: 10, step: 0.1 }) });
function cz(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    var o, s, u, c, l, d, m;
    return ne(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, KC(n, t, r.size, i).runInContext(e.runtime)];
        case 1:
          return o = p.sent(), s = o.transform, u = o.field, c = o.idField, l = o.maxRadius, [4, ZC({ isoLevel: i.probeRadius, scalarField: u, idField: c }, a).runAsChild(e.runtime)];
        case 2:
          return d = p.sent(), Yt.transform(d, s), m = de.expand(de(), t.boundary.sphere, l), d.setBoundingSphere(m), [2, d];
      }
    });
  });
}
function lz(e) {
  return P3({ defaultProps: N.getDefaultValues($C), createGeometry: cz, createLocationIterator: Is.fromGroup, getLoci: Zl, eachLocation: Wl, setUpdateState: function(t, n, r) {
    n.resolution !== r.resolution && (t.createGeometry = !0), n.probeRadius !== r.probeRadius && (t.createGeometry = !0), n.probePositions !== r.probePositions && (t.createGeometry = !0), n.ignoreHydrogens !== r.ignoreHydrogens && (t.createGeometry = !0), n.includeParent !== r.includeParent && (t.createGeometry = !0);
  } }, e);
}
var eA = { "molecular-surface-mesh": function(e, t) {
  return ui("Molecular surface mesh", e, t, uz);
}, "molecular-surface-wireframe": function(e, t) {
  return ui("Molecular surface wireframe", e, t, lz);
} }, t8 = B(B(B({}, JC), $C), { visuals: N.MultiSelect(["molecular-surface-mesh"], N.objectToOptions(eA)), bumpFrequency: N.Numeric(1, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory) }), c2, l2 = { name: "molecular-surface", label: "Molecular Surface", description: "Displays a molecular surface.", factory: function(e, t) {
  return Mt.createMulti("Molecular Surface", e, t, ia, eA);
}, getParams: function(e, t) {
  return N.clone(t8);
}, defaultValues: N.getDefaultValues(t8), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, dz = { parse: function(e, t) {
  var n, r = t.managers.cell.get(e.ref), i = un(r);
  return i ? Xn(i, (n = e.elementIds) !== null && n !== void 0 ? n : [], !0) : Be.Empty;
}, createTheme: function(e, t, n) {
  return t.managers.representation.createTheme(fe.Surface, this.parse(e, t), n);
}, create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return (r = l2.factory(t, l2.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, r.createOrUpdate(B(B({}, l2.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, fz = S.create(0, 0, -0.5), mz = S.create(0, 0, 0.5), Ws = S(), Zs = S(), im = S(), n8 = S();
function pz() {
  return c2 || (c2 = function(e) {
    for (var t = e.length / 3, n = (t === 3 ? 1 : t === 4 ? 2 : t) + t, r = zf(n, t === 4 ? 3 * t + 4 : 3 * n), i = 0; i < t; ++i) {
      var a = (i + 1) % t;
      S.set(Ws, e[3 * i], e[3 * i + 1], -0.5), S.set(Zs, e[3 * a], e[3 * a + 1], -0.5), r.add(Ws, Zs, mz);
    }
    if (t === 3) S.set(Ws, e[0], e[1], -0.5), S.set(Zs, e[3], e[4], -0.5), S.set(im, e[6], e[7], -0.5), r.add(im, Zs, Ws);
    else if (t === 4) S.set(Ws, e[0], e[1], -0.5), S.set(Zs, e[3], e[4], -0.5), S.set(im, e[6], e[7], -0.5), S.set(n8, e[9], e[10], -0.5), r.addQuad(n8, im, Zs, Ws);
    else for (i = 0; i < t; ++i) a = (i + 1) % t, S.set(Ws, e[3 * i], e[3 * i + 1], -0.5), S.set(Zs, e[3 * a], e[3 * a + 1], -0.5), r.add(fz, Zs, Ws);
    return r.getPrimitive();
  }(B0(8, !0))), c2;
}
var lg = { center: N.Vec3(S()), vec: N.Vec3(S()), color: N.Color(ye.fromRgb(255, 196, 36)), alpha: N.Numeric(0.9, { min: 0, max: 1, step: 0.1 }) }, tA = { "rotate-arrow-cylinder": function(e, t) {
  return wn(vz, li.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "rotate-arrow-arrowhead": function(e, t) {
  return wn(gz, ht.Utils);
} }, hz = B(B(B({}, Yt.Params), lg), { visuals: N.MultiSelect(["rotate-arrow-cylinder", "rotate-arrow-arrowhead"], N.objectToOptions(tA)) });
function vz(e, t, n, r) {
  var i = n.center, a = n.vec, o = S.create(0, 0, 0);
  S.normalize(o, a);
  var s = S.create(0, 0, 0);
  S.scale(s, o, 0.25);
  var u = S.create(0, 0, 0);
  S.sub(u, a, s);
  var c = S.create(0, 0, 0);
  S.add(c, i, u);
  var l = S.create(0, 0, 0);
  S.scale(l, o, 0.45), S.sub(c, c, l);
  var d = Mf.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.05, !0, !0, 2), Ct.create("RotateArrow-cylinder", n, d.getCylinders(), function() {
    return n.color;
  }, function() {
    return n.sizeFactor;
  }, function() {
    return "RotateArrow";
  });
}
function gz(e, t, n, r) {
  var i = nt.createState(256, 128), a = pz(), o = n.center, s = n.vec, u = S.create(0, 0, 0);
  S.normalize(u, s);
  var c = S.create(0, 0, 0);
  S.scale(c, u, 0.1);
  var l = S.create(0, 0, 0);
  S.sub(l, s, c);
  var d = S.create(0, 0, 0);
  S.add(d, o, l);
  var m = S.create(0, 0, 0), p = S.create(0, 0, 0);
  S.scale(p, u, 0.35), S.sub(m, d, p);
  var v = J.identity(), f = S();
  return S.add(f, m, s), J.targetTo(v, f, m, S.create(1, 0, 0)), J.setTranslation(v, m), i.currentGroup = 0, J.scaleUniformly(v, v, 0.4 * 1.5), nt.addPrimitive(i, v, a), Ct.create("axes", n, nt.getMesh(i), function() {
    return n.color;
  }, function() {
    return 0.05;
  }, function() {
    return "";
  });
}
B(B(B({}, li.Params), lg), { color: N.Color(ye.fromRgb(255, 196, 36)), sizeFactor: N.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), B(B(B({}, ht.Params), lg), { color: N.Color(_t.brown) });
var yz = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r = function(a, o) {
            var s = Mt.createMulti("RotateArrow", a, o, ia, tA);
            return s.setState({ markerActions: Wt.All }), s;
          }(t, function() {
            return hz;
          }), [4, r.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, bz = { "element-sphere": function(e, t) {
  return ui("Sphere mesh", e, t, B3);
} }, r8 = B(B({}, Bf), { bumpFrequency: N.Numeric(1, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory) }), d2 = { name: "spacefill", label: "Spacefill", description: "Displays atomic/coarse elements as spheres.", factory: function(e, t) {
  return Mt.createMulti("Spacefill", e, t, ia, bz);
}, getParams: function(e, t) {
  var n = N.clone(r8);
  return t.isCoarseGrained && (n.sizeFactor.defaultValue = 2), n;
}, defaultValues: N.getDefaultValues(r8), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, _z = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return (r = d2.factory(t, d2.getParams)).setTheme(n ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, r.createOrUpdate(B(B({}, d2.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(r ?? { color: n.colorThemeRegistry.create("element-symbol", { structure: t }), size: n.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, xz = J.fromTranslation(J(), S.create(0.5, 0.5, 0.5)), Sz = k0(R0(cx()), xz), Zu = S(), i8 = J(), nA = B(B({}, ht.Params), { alpha: B(B({}, ht.Params.alpha), { defaultValue: 0.51 }), ignoreLight: B(B({}, ht.Params.ignoreLight), { defaultValue: !0 }), colorX: N.Color(_t.red, { isEssential: !0 }), colorY: N.Color(_t.green, { isEssential: !0 }), colorZ: N.Color(_t.blue, { isEssential: !0 }), scale: N.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }), Cz = B(B(B({}, ht.Params), nA), { pocketColor: N.Color(_t.red), pocketScale: N.Numeric(4, { min: 0.1, max: 5, step: 0.1 }), x: N.Numeric(10), y: N.Numeric(10), z: N.Numeric(10), center: N.Vec3(S()) }), Az = B(B({}, Cz), nA), Iz = { axes: function(e, t) {
  return wn(Pz, ht.Utils);
}, mesh: function(e, t) {
  return wn(wz, ht.Utils);
} };
function wz(e, t, n, r) {
  var i = function(o, s, u) {
    var c = nt.createState(256, 128, u), l = o.gridPocket.fromFractional;
    S.copy(Zu, o.ref), S.subScalar(Zu, Zu, 0.5), J.fromTranslation(i8, Zu);
    var d = k0(R0(Sz), i8), m = Math.cbrt(o.gridPocket.volume) / 300 * s.pocketScale;
    c.currentGroup = 1, nt.addCage(c, l, d, m, 2, 20);
    var p = de.fromDimensionsAndTransform(de(), S.unit, l);
    S.transformMat4(Zu, Zu, l), de.translate(p, p, Zu), de.expand(p, p, m);
    var v = nt.getMesh(c);
    return v.setBoundingSphere(p), v;
  }(t, n, r && r.geometry), a = "Grid Pocket Box";
  return Ct.create(a, t, i, function() {
    return n.pocketColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
function a8(e, t, n, r) {
  var i = S(), a = J.ofRows([[e, 0, 0, 0], [0, t, 0, 0], [0, 0, n, 0], [0, 0, 0, 1]]), o = J.invert(J.zero(), a);
  return { ref: S.transformMat4(i, r, o), gridPocket: { fromFractional: a, toFractional: o, x: e, y: t, z: n, center: r, volume: e * t * n } };
}
function Pz(e, t, n, r) {
  var i = n.scale, a = function(o, s, u) {
    var c = s.gridPocket, l = c.x, d = c.y, m = c.z, p = c.center, v = c.volume, f = nt.createState(512, 256, u), y = Math.cbrt(v) / 300 * o, h = p[0], g = p[1], x = p[2], C = Math.min(l, d, m), b = S.create(h + C / 3, g, x), _ = S.create(h, g + C / 3, x), A = S.create(h, g, x + C / 3), I = { radiusTop: y, radiusBottom: y, radialSegments: 32 };
    return f.currentGroup = 0, yr(f, p, y, 2), f.currentGroup = 1, yr(f, b, y, 2), pr(f, p, b, 1, I), f.currentGroup = 2, yr(f, _, y, 2), pr(f, p, _, 1, I), f.currentGroup = 3, yr(f, A, y, 2), pr(f, p, A, 1, I), S.scale(b, b, 0.5), S.scale(_, _, 0.5), S.scale(A, A, 0.5), nt.getMesh(f);
  }(i, t, r == null ? void 0 : r.geometry);
  return a.setBoundingSphere(de.create(S.create(i / 2, i / 2, i / 2), i + i / 4)), Ct.create("axes", {}, a, function(o) {
    switch (o) {
      case 1:
        return n.colorX;
      case 2:
        return n.colorY;
      case 3:
        return n.colorZ;
      default:
        return _t.grey;
    }
  }, function() {
    return 1;
  }, function() {
    return "";
  });
}
var Ez = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s;
    return ne(this, function(u) {
      switch (u.label) {
        case 0:
          return r = function(c, l) {
            return Mt.createMulti("Grid Pocket", c, l, Mt.StateBuilder, Iz);
          }(t, function() {
            return Az;
          }), i = e.x, a = e.y, o = e.z, s = e.center, [4, r.createOrUpdate(e, a8(i, a, o, s)).run()];
        case 1:
          return u.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i, a, o, s;
    return ne(this, function(u) {
      switch (u.label) {
        case 0:
          return i = t.x, a = t.y, o = t.z, s = t.center, [4, e.createOrUpdate(t, a8(i, a, o, s)).run()];
        case 1:
          return u.sent(), [2];
      }
    });
  });
} }, Tz = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1], bl = { radiusFactor: N.Numeric(1, { min: 0.1, max: 3, step: 0.01 }, { description: "Scale the radius of the membrane layer" }), center: N.Vec3(S()), radius: N.Numeric(1), vec: N.Vec3(S()) }, rA = { "pharmacophore-ball-1": function(e, t) {
  return wn(Rz, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "pharmacophore-ball-2": function(e, t) {
  return wn(kz, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "pharmacophore-sphere-1": function(e, t) {
  return wn(Nz, ro.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "pharmacophore-sphere-2": function(e, t) {
  return wn(Lz, ro.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "pharmacophore-cylinder": function(e, t) {
  return wn(Fz, li.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.All });
  } });
}, "pharmacophore-arrowhead": function(e, t) {
  return wn(Gz, ht.Utils);
} }, Mz = B(B(B({}, Yt.Params), bl), { color: N.Color(_t.blue), lineSizeAttenuation: N.Boolean(!1), linesSize: N.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: N.Boolean(!1), alpha: N.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), Dz = B(B(B({}, Yt.Params), bl), { color: N.Color(_t.blue), lineSizeAttenuation: N.Boolean(!1), linesSize: N.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: N.Boolean(!1), alpha: N.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), Bz = B(B(B({}, Mz), Dz), { visuals: N.MultiSelect(["pharmacophore-ball-1", "pharmacophore-ball-2", "pharmacophore-sphere-1", "pharmacophore-sphere-2", "pharmacophore-cylinder", "pharmacophore-arrowhead"], N.objectToOptions(rA)), alpha: N.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) });
function Rz(e, t, n, r) {
  var i = n.radiusFactor, a = n.center, o = i * n.radius, s = zr.create(128, 64, r == null ? void 0 : r.geometry), u = S.create(0, 0, 0);
  S.add(u, a, S.create(0, 1, 0));
  var c = S.create(0, 0, 0);
  S.add(c, a, S.create(0, 0, 1));
  var l = S.create(0, 0, 0);
  S.add(l, a, S.create(1, 0, 0)), Fr(s, a, u, o, n), Fr(s, a, c, o, n), Fr(s, a, l, o, n);
  var d = S.create(0, 0, 0);
  S.add(d, a, S.create(0, 0.5 * o, 0));
  var m = S.create(0, 0, 0);
  S.add(m, d, S.create(0, Math.sqrt(0.75), 0)), Fr(s, d, m, Math.sqrt(0.75) * o, n);
  var p = S.create(0, 0, 0);
  S.add(p, a, S.create(0, -0.5 * o, 0));
  var v = S.create(0, 0, 0);
  return S.add(v, p, S.create(0, -Math.sqrt(0.75), 0)), Fr(s, p, v, Math.sqrt(0.75) * o, n), d = S.create(0, 0, 0), S.add(d, a, S.create(0.5 * o, 0, 0)), m = S.create(0, 0, 0), S.add(m, d, S.create(Math.sqrt(0.75), 0, 0)), Fr(s, d, m, Math.sqrt(0.75) * o, n), p = S.create(0, 0, 0), S.add(p, a, S.create(-0.5 * o, 0, 0)), v = S.create(0, 0, 0), S.add(v, p, S.create(-Math.sqrt(0.75), 0, 0)), Fr(s, p, v, Math.sqrt(0.75) * o, n), d = S.create(0, 0, 0), S.add(d, a, S.create(0, 0, 0.5 * o)), m = S.create(0, 0, 0), S.add(m, d, S.create(0, 0, Math.sqrt(0.75))), Fr(s, d, m, Math.sqrt(0.75) * o, n), p = S.create(0, 0, 0), S.add(p, a, S.create(0, 0, -0.5 * o)), v = S.create(0, 0, 0), S.add(v, p, S.create(0, 0, -Math.sqrt(0.75))), Fr(s, p, v, Math.sqrt(0.75) * o, n), Ct.create("pharmacophore-ball-1", n, s.getLines(), function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function kz(e, t, n, r) {
  var i = n.radiusFactor, a = n.center, o = n.radius, s = n.vec, u = i * o, c = S.create(0, 0, 0);
  S.add(c, a, s);
  var l = zr.create(128, 64, r == null ? void 0 : r.geometry), d = S.create(0, 0, 0);
  S.add(d, c, S.create(0, 1, 0));
  var m = S.create(0, 0, 0);
  S.add(m, c, S.create(0, 0, 1));
  var p = S.create(0, 0, 0);
  S.add(p, c, S.create(1, 0, 0)), Fr(l, c, d, u, n), Fr(l, c, m, u, n), Fr(l, c, p, u, n);
  var v = S.create(0, 0, 0);
  S.add(v, c, S.create(0, 0.5 * u, 0));
  var f = S.create(0, 0, 0);
  S.add(f, v, S.create(0, Math.sqrt(0.75), 0)), Fr(l, v, f, Math.sqrt(0.75) * u, n);
  var y = S.create(0, 0, 0);
  S.add(y, c, S.create(0, -0.5 * u, 0));
  var h = S.create(0, 0, 0);
  return S.add(h, y, S.create(0, -Math.sqrt(0.75), 0)), Fr(l, y, h, Math.sqrt(0.75) * u, n), v = S.create(0, 0, 0), S.add(v, c, S.create(0.5 * u, 0, 0)), f = S.create(0, 0, 0), S.add(f, v, S.create(Math.sqrt(0.75), 0, 0)), Fr(l, v, f, Math.sqrt(0.75) * u, n), y = S.create(0, 0, 0), S.add(y, c, S.create(-0.5 * u, 0, 0)), h = S.create(0, 0, 0), S.add(h, y, S.create(-Math.sqrt(0.75), 0, 0)), Fr(l, y, h, Math.sqrt(0.75) * u, n), v = S.create(0, 0, 0), S.add(v, c, S.create(0, 0, 0.5 * u)), f = S.create(0, 0, 0), S.add(f, v, S.create(0, 0, Math.sqrt(0.75))), Fr(l, v, f, Math.sqrt(0.75) * u, n), y = S.create(0, 0, 0), S.add(y, c, S.create(0, 0, -0.5 * u)), h = S.create(0, 0, 0), S.add(h, y, S.create(0, 0, -Math.sqrt(0.75))), Fr(l, y, h, Math.sqrt(0.75) * u, n), Ct.create("pharmacophore-ball-2", n, l.getLines(), function() {
    return n.color;
  }, function() {
    return n.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function Fr(e, t, n, r, i, a) {
  for (var o = function(x, C, b) {
    S.dot(S.unitY, S.sub(Oz, x, C)) === 0 ? J.targetTo(dl, x, C, S.unitY) : J.targetTo(dl, x, C, S.unitX), J.setTranslation(dl, x), J.mul(dl, dl, J.rotX90);
    var _ = N3({ radius: b, segments: 64 });
    return D0(_, dl);
  }(t, n, r), s = o.indices, u = o.vertices, c = 0, l = s.length; c < l; c += 3) if (!i.dashedLines || c % 2 != 1) {
    var d = 3 * s[c], m = 3 * s[c + 1], p = u[d], v = u[d + 1], f = u[d + 2], y = u[m], h = u[m + 1], g = u[m + 2];
    e.add(p, v, f, y, h, g, 0);
  }
}
B(B(B({}, ro.Params), bl), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: N.Color(_t.green), alpha: N.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), B(B(B({}, ro.Params), bl), { sizeFactor: N.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: N.Color(_t.brown), alpha: N.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), B(B(B({}, li.Params), bl), { color: N.Color(_t.brown), sizeFactor: N.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), B(B(B({}, ht.Params), bl), { color: N.Color(_t.brown) });
var dl = J(), Oz = S();
function iA(e, t, n, r) {
  e.add(t[0], t[1], t[2], r);
}
function Nz(e, t, n, r) {
  var i = n.center, a = n.radius, o = n.radiusFactor, s = Df.create(128, 64);
  return iA(s, i, 0, 0), Ct.create("pharmacophore-sphere-1", B(B({}, n), { sizeFactor: 0.1 * n.radius }), s.getSpheres(), function() {
    return n.color;
  }, function() {
    return a * o / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Lz(e, t, n, r) {
  var i = n.center, a = n.radius, o = n.vec, s = n.radiusFactor, u = S.create(0, 0, 0);
  S.add(u, i, o);
  var c = Df.create(128, 64);
  return iA(c, u, 0, 1), Ct.create("pharmacophore-sphere-2", B(B({}, n), { sizeFactor: 0.1 * n.radius }), c.getSpheres(), function() {
    return n.color;
  }, function() {
    return a * s / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Fz(e, t, n, r) {
  var i = n.center, a = n.vec, o = S.create(0, 0, 0);
  S.normalize(o, a);
  var s = S.create(0, 0, 0);
  S.scale(s, o, 0.25);
  var u = S.create(0, 0, 0);
  S.sub(u, a, s);
  var c = S.create(0, 0, 0);
  S.add(c, i, u);
  var l = S.create(0, 0, 0);
  S.scale(l, o, 0.3), S.sub(c, c, l);
  var d = Mf.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.025, !0, !0, 2), Ct.create("pharmacophore-cylinder", n, d.getCylinders(), function() {
    return n.color;
  }, function() {
    return n.sizeFactor;
  }, function() {
    return "pharmacophore";
  });
}
function Gz(e, t, n, r) {
  var i = n.center, a = n.vec, o = S.create(0, 0, 0);
  S.normalize(o, a);
  var s = S.create(0, 0, 0);
  S.scale(s, o, 0.25);
  var u = S.create(0, 0, 0);
  S.sub(u, a, s);
  var c = S.create(0, 0, 0);
  S.add(c, i, u);
  var l = S.create(0, 0, 0), d = S.create(0, 0, 0);
  S.scale(d, o, 0.3), S.sub(l, c, d);
  var m = S.create(0, 0, 0), p = S.create(1, 2, l[2] - (o[0] * (1 - l[0]) + o[1] * (2 - l[1])) / o[2]);
  S.sub(m, p, l), S.normalize(m, m);
  var v = S.create(0, 0, 0);
  S.scale(v, m, 0.3);
  var f = S.create(0, 0, 0);
  S.add(f, l, v);
  var y = S.create(0, 0, 0);
  S.sub(y, f, l);
  var h = S.create(0, 0, 0), g = S.create(0, 0, 0);
  S.scale(g, y, Math.cos(120 * Math.PI / 180));
  var x = S.create(0, 0, 0);
  S.cross(x, o, y), S.scale(x, x, Math.sin(120 * Math.PI / 180));
  var C = S.create(0, 0, 0);
  S.scale(C, o, S.dot(o, y) * (1 - Math.cos(120 * Math.PI / 180))), S.add(h, g, x), S.add(h, h, C), S.add(h, h, l);
  var b = S.create(0, 0, 0);
  g = S.create(0, 0, 0), S.scale(g, y, Math.cos(240 * Math.PI / 180)), x = S.create(0, 0, 0), S.cross(x, o, y), S.scale(x, x, Math.sin(240 * Math.PI / 180)), C = S.create(0, 0, 0), S.scale(C, o, S.dot(o, y) * (1 - Math.cos(240 * Math.PI / 180))), S.add(b, g, x), S.add(b, b, C), S.add(b, b, l);
  var _ = nt.createState(128, 64), A = function(E) {
    return sx(E, Tz);
  }([c[0], c[1], c[2], f[0], f[1], f[2], h[0], h[1], h[2], b[0], b[1], b[2]]), I = J.ofRows([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), w = J.invert(J.zero(), I);
  return nt.addPrimitive(_, w, A), Ct.create("axes", {}, nt.getMesh(_), function() {
    return n.color;
  }, function() {
    return 0.15;
  }, function() {
    return "";
  });
}
var Vz = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r = function(a, o) {
            var s = Mt.createMulti("Pharmacophore", a, o, ia, rA);
            return s.setState({ markerActions: Wt.All }), s;
          }(t, function() {
            return Bz;
          }), [4, r.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function dg(e, t) {
  var n, r, i, a, o, s, u, c, l = e.defaultProps, d = e.createGeometry, m = e.createLocationIterator, p = e.getLoci, v = e.eachLocation, f = e.setUpdateState, y = e.mustRecreate, h = e.dispose, g = e.geometryUtils, x = g.updateValues, C = g.updateBoundingSphere, b = g.updateRenderableState, _ = g.createPositionIterator, A = Lo.create(), I = Object.assign({}, l), w = Ba.createEmpty(), E = -1;
  function D(P) {
    if (A.createNew) {
      if (u = m(a), !P) throw new Error("expected geometry to be given");
      n = function(M, R, O, L, F, G) {
        var V = Ur.getUtils(R), U = V.createValues, q = V.createRenderableState, H = U(R, Wg(), O, L, F), K = q(F);
        return ad(R.kind, H, K, G);
      }(0, P, u, i, r, t), c = _(P, n.values);
    } else {
      if (!n) throw new Error("expected renderObject to be available");
      if (u.reset(), A.createGeometry) {
        if (!P) throw new Error("expected geometry to be given");
        k.updateIfChanged(n.values.drawCount, Ur.getDrawCount(P)), k.updateIfChanged(n.values.uVertexCount, Ur.getVertexCount(P));
      }
      (A.updateTransform || A.createGeometry) && (C(n.values, P || s), c = _(P || s, n.values)), A.updateSize && "uSize" in n.values && Es(u, i.size, n.values), A.updateColor && ta(u, c, i.color, n.values), x(n.values, r), b(n.state, r);
    }
    I = r, w = i, o = a, P && (s = P, E += 1);
  }
  function T(P, M) {
    return Vi(P) ? M(oe.ofBounds(0, u.groupCount * u.instanceCount)) : v(P, o, I, M);
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return n;
  }, get geometryVersion() {
    return E;
  }, createOrUpdate: function(P, M, R, O) {
    return R === void 0 && (R = {}), ie(this, 0, void 0, function() {
      var L;
      return ne(this, function(F) {
        return function(G, V, U) {
          if (!U && !o) throw new Error("missing volume");
          r = Object.assign({}, I, V), i = G, a = U, Lo.reset(A), n && o && Tt.areEquivalent(a, o) || (A.createNew = !0), A.createNew ? A.createGeometry = !0 : (f(A, U, r, I, i, w), Cs.areEqual(G.color, w.color) || (A.updateColor = !0), A.createGeometry && (A.updateColor = !0));
        }(M, R, O || o), A.createGeometry ? [2, Dg(L = d(P, a, i, r, s)) ? L.then(D) : D(L)] : (D(), [2]);
      });
    });
  }, getLoci: function(P) {
    return n ? p(P, o, I, n.id) : Sn;
  }, mark: function(P, M) {
    return Pt.mark(n, P, M, T);
  }, setVisibility: function(P) {
    Pt.setVisibility(n, P);
  }, setAlphaFactor: function(P) {
    Pt.setAlphaFactor(n, P);
  }, setPickable: function(P) {
    Pt.setPickable(n, P);
  }, setColorOnly: function(P) {
    Pt.setColorOnly(n, P);
  }, setTransform: function(P, M) {
    Pt.setTransform(n, P, M);
  }, setOverpaint: function(P) {
    return Pt.setOverpaint(n, P, T, !0);
  }, setTransparency: function(P) {
    return Pt.setTransparency(n, P, T, !0);
  }, setSubstance: function(P) {
    return Pt.setSubstance(n, P, T, !0);
  }, setClipping: function(P) {
    return Pt.setClipping(n, P, T, !0);
  }, destroy: function() {
    h == null || h(s), n && (n.state.disposed = !0, n = void 0);
  }, mustRecreate: y };
}
function o8(e, t, n, r, i) {
  var a, o, s, u, c = 0, l = t.webgl, d = new $n(), m = new Mt.GeometryState(), p = Ms(), v = [], f = Mt.createState(), y = Ba.createEmpty();
  return { label: e, get groupCount() {
    return a ? a.groupCount : 0;
  }, get props() {
    return u;
  }, get params() {
    return s;
  }, get state() {
    return f;
  }, get theme() {
    return y;
  }, get geometryVersion() {
    return m.version;
  }, renderObjects: v, updated: d, createOrUpdate: function(h, g) {
    var x = this;
    h === void 0 && (h = {}), g && g !== o && (s = n(t, g), o = g, u || (u = N.getDefaultValues(s)));
    var C = Tv(Object.assign({}, u, h), o);
    return Object.assign(u, h, C), At.create("Creating or updating VolumeRepresentation", function(b) {
      return ie(x, 0, void 0, function() {
        var _, A;
        return ne(this, function(I) {
          switch (I.label) {
            case 0:
              return a ? !((A = a.mustRecreate) === null || A === void 0) && A.call(a, o, u, l) && (a.destroy(), a = r(p, o, u, l)) : a = r(p, o, u, l), (_ = a.createOrUpdate({ webgl: l, runtime: b }, y, u, g)) ? [4, _] : [3, 2];
            case 1:
              I.sent(), I.label = 2;
            case 2:
              return v.length = 0, a && a.renderObject && (v.push(a.renderObject), m.add(a.renderObject.id, a.geometryVersion)), m.snapshot(), d.next(c++), [2];
          }
        });
      });
    });
  }, setState: function(h) {
    h.visible !== void 0 && a && a.setVisibility(h.visible), h.alphaFactor !== void 0 && a && a.setAlphaFactor(h.alphaFactor), h.pickable !== void 0 && a && a.setPickable(h.pickable), h.overpaint !== void 0 && a && a.setOverpaint(h.overpaint), h.transparency !== void 0 && a && a.setTransparency(h.transparency), h.transform !== void 0 && a && a.setTransform(h.transform), Mt.updateState(f, h);
  }, setTheme: function(h) {
    y = h;
  }, getLoci: function(h) {
    return h === void 0 ? i(o, u) : a ? a.getLoci(h) : Sn;
  }, mark: function(h, g) {
    return !!a && a.mark(h, g);
  }, destroy: function() {
    a && a.destroy();
  } };
}
B({}, Ve.Params);
var zz = `
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
}
`, Uz = B(B({}, Mr), { tTexture: pt("texture", "rgba", "float", "nearest") }), Ia = "histopyramid-sum";
function Hz(e, t) {
  if (e.namedComputeRenderables[Ia]) {
    var n = e.namedComputeRenderables[Ia].values;
    k.update(n.tTexture, t), e.namedComputeRenderables[Ia].update();
  } else e.namedComputeRenderables[Ia] = function(r, i) {
    var a = B(B({}, Er), { tTexture: k.create(i) }), o = B({}, Uz), s = Pn("sum", ci, zz, {}, { 0: "ivec4" }), u = xr(r, "triangles", s, o, a);
    return Sr(u, a);
  }(e, t);
  return e.namedComputeRenderables[Ia];
}
var am = new Uint8Array(4), s8 = new Int32Array(4), om, sm, qz = `
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
}
`, jz = B(B({}, Mr), { tInputLevel: pt("texture", "rgba", "float", "nearest"), tPreviousLevel: pt("texture", "rgba", "float", "nearest"), uSize: ce("f"), uTexSize: ce("f"), uFirst: ce("b") }), ou = "histogram-pyramid";
function Kz(e, t, n) {
  if (e.namedComputeRenderables[ou]) {
    var r = e.namedComputeRenderables[ou].values;
    k.update(r.tInputLevel, t), k.update(r.tPreviousLevel, n), e.namedComputeRenderables[ou].update();
  } else e.namedComputeRenderables[ou] = function(i, a, o) {
    var s = B(B({}, Er), { tInputLevel: k.create(a), tPreviousLevel: k.create(o), uSize: k.create(0), uTexSize: k.create(0), uFirst: k.create(!0) }), u = B({}, jz), c = Pn("reduction", ci, qz, {}, { 0: "ivec4" }), l = xr(i, "triangles", c, u, s);
    return Sr(l, s);
  }(e, t, n);
  return e.namedComputeRenderables[ou];
}
function Xz(e, t) {
  var n = Math.pow(2, t), r = "level".concat(t), i = e.isWebGL2 ? _0(r, e, "image-int32", "alpha", "int", "nearest") : _0(r, e, "image-uint8", "rgba", "ubyte", "nearest");
  i.define(n, n);
  var a = function(o, s) {
    var u = "".concat(ou, "-").concat(o);
    return s.namedFramebuffers[u];
  }(r, e);
  return a || (a = aA(r, e), i.attachFramebuffer(a, 0)), { texture: i, framebuffer: a };
}
function aA(e, t) {
  var n = "".concat(ou, "-").concat(e);
  return t.namedFramebuffers[n] || (t.namedFramebuffers[n] = t.resources.framebuffer()), t.namedFramebuffers[n];
}
function _0(e, t, n, r, i, a) {
  var o = "".concat(ou, "-").concat(e);
  return t.namedTextures[o] || (t.namedTextures[o] = t.resources.texture(n, r, i, a)), t.namedTextures[o];
}
function Yz(e, t, n, r) {
  var i = e.gl, a = t.getWidth();
  if (a !== t.getHeight() || !function(x) {
    return x !== 0 && !(x & x - 1);
  }(a)) throw new Error("inputTexture must be of square power-of-two size");
  var o = Math.ceil(Math.log(a) / Math.log(2)), s = Math.pow(2, o), u = Math.pow(2, o), c = Math.pow(2, o - 1), l = e.isWebGL2 ? _0("pyramid", e, "image-int32", "alpha", "int", "nearest") : _0("pyramid", e, "image-uint8", "rgba", "ubyte", "nearest");
  l.define(u, c);
  var d = aA("pyramid", e);
  l.attachFramebuffer(d, 0), i.viewport(0, 0, u, c), Et(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT);
  for (var m = [], p = 0; p < o; ++p) m.push(Xz(e, p));
  var v = Kz(e, t, m[0].texture);
  e.state.currentRenderItemId = -1, function(x) {
    var C = x.gl, b = x.state;
    b.disable(C.CULL_FACE), b.disable(C.BLEND), b.disable(C.DEPTH_TEST), b.enable(C.SCISSOR_TEST), b.depthMask(!1), b.colorMask(!0, !0, !0, !0), b.clearColor(0, 0, 0, 0);
  }(e);
  var f = 0;
  for (p = 0; p < o; p++) {
    var y = o - 1 - p;
    m[y].framebuffer.bind();
    var h = Math.pow(2, y);
    k.update(v.values.uSize, Math.pow(2, p + 1) / s), k.update(v.values.uTexSize, h), k.updateIfChanged(v.values.uFirst, p === 0), p > 0 && (k.update(v.values.tPreviousLevel, m[o - p].texture), v.update()), e.state.currentRenderItemId = -1, i.viewport(0, 0, h, h), i.scissor(0, 0, h, h), Et(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT), i.scissor(0, 0, r[0], r[1]), v.render(), l.bind(0), i.copyTexSubImage2D(i.TEXTURE_2D, 0, f, 0, 0, 0, h, h), l.unbind(0), f += h;
  }
  i.finish();
  var g = Math.max(1, function(x, C) {
    var b = x.gl, _ = x.resources, A = Hz(x, C);
    x.state.currentRenderItemId = -1, x.namedFramebuffers[Ia] || (x.namedFramebuffers[Ia] = _.framebuffer());
    var I = x.namedFramebuffers[Ia];
    return x.namedTextures[Ia] || (x.namedTextures[Ia] = Et(b) ? _.texture("image-int32", "rgba", "int", "nearest") : _.texture("image-uint8", "rgba", "ubyte", "nearest"), x.namedTextures[Ia].define(1, 1)), x.namedTextures[Ia].attachFramebuffer(I, 0), function(w) {
      var E = w.gl, D = w.state;
      D.disable(E.CULL_FACE), D.disable(E.BLEND), D.disable(E.DEPTH_TEST), D.disable(E.SCISSOR_TEST), D.depthMask(!1), D.colorMask(!0, !0, !0, !0), D.clearColor(0, 0, 0, 0);
    }(x), b.viewport(0, 0, 1, 1), A.render(), b.finish(), x.readPixels(0, 0, 1, 1, Et(b) ? s8 : am), x.unbindFramebuffer(), Et(b) ? s8[0] : Zg(am[0], am[1], am[2]);
  }(e, m[0].texture));
  return { pyramidTex: l, count: g, height: Math.ceil(g / Math.pow(2, o)), levels: o, scale: n };
}
function Wz() {
  if (om !== void 0) return om;
  for (var e = (om = hr(256, 1, Uint8Array)).array, t = 0, n = Il.length; t < n; ++t) e[t] = Il[t].length / 3;
  return om;
}
function Zz() {
  if (sm !== void 0) return sm;
  for (var e = (sm = hr(4096, 1, Uint8Array)).array, t = 0, n = Il.length; t < n; ++t) for (var r = 0; r < 16; ++r) r < Il[t].length ? e[16 * t + r] = Il[t][r] : e[16 * t + r] = 255;
  return sm;
}
var Qz = `
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)));
}
`, Jz = `
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);
}
`, $z = B(B({}, Mr), { tTriCount: pt("image-uint8", "alpha", "ubyte", "nearest"), tVolumeData: pt("texture", "rgba", "ubyte", "nearest"), uIsoValue: ce("f"), uGridDim: ce("v3"), uGridTexDim: ce("v3"), uScale: ce("v2") }), Ya = "active-voxels";
function eU(e, t, n, r, i, a) {
  if (e.namedComputeRenderables[Ya]) {
    var o = e.namedComputeRenderables[Ya].values;
    k.update(o.uQuadScale, a), k.update(o.tVolumeData, t), k.updateIfChanged(o.uIsoValue, i), k.update(o.uGridDim, n), k.update(o.uGridTexDim, r), k.update(o.uScale, a), e.namedComputeRenderables[Ya].update();
  } else e.namedComputeRenderables[Ya] = function(s, u, c, l, d, m) {
    var p = B(B({}, Er), { tTriCount: k.create(Wz()), uQuadScale: k.create(m), tVolumeData: k.create(u), uIsoValue: k.create(d), uGridDim: k.create(c), uGridTexDim: k.create(l), uScale: k.create(m) }), v = B({}, $z), f = Pn("active-voxels", ci, Jz), y = xr(s, "triangles", f, v, p);
    return Sr(y, p);
  }(e, t, n, r, i, a);
  return e.namedComputeRenderables[Ya];
}
var tU = B(B({}, Mr), { tTriIndices: pt("image-uint8", "alpha", "ubyte", "nearest"), tActiveVoxelsPyramid: pt("texture", "rgba", "float", "nearest"), tActiveVoxelsBase: pt("texture", "rgba", "float", "nearest"), tVolumeData: pt("texture", "rgba", "ubyte", "nearest"), uIsoValue: ce("f"), uSize: ce("f"), uLevels: ce("f"), uCount: ce("f"), uInvert: ce("b"), uGridDim: ce("v3"), uGridTexDim: ce("v3"), uGridTransform: ce("m4"), uScale: ce("v2"), dPackedGroup: mt("boolean"), dAxisOrder: mt("string", ["012", "021", "102", "120", "201", "210"]) }), su = "isosurface";
function nU(e, t, n, r, i, a, o, s, u, c, l, d, m, p) {
  if (e.namedComputeRenderables[su]) {
    var v = e.namedComputeRenderables[su].values;
    k.update(v.tActiveVoxelsPyramid, t), k.update(v.tActiveVoxelsBase, n), k.update(v.tVolumeData, r), k.updateIfChanged(v.uIsoValue, s), k.updateIfChanged(v.uSize, Math.pow(2, u)), k.updateIfChanged(v.uLevels, u), k.updateIfChanged(v.uCount, l), k.updateIfChanged(v.uInvert, d), k.update(v.uGridDim, i), k.update(v.uGridTexDim, a), k.update(v.uGridTransform, o), k.update(v.uScale, c), k.update(v.dPackedGroup, m), k.updateIfChanged(v.dAxisOrder, p.join("")), e.namedComputeRenderables[su].update();
  } else e.namedComputeRenderables[su] = function(f, y, h, g, x, C, b, _, A, I, w, E, D, T) {
    var P = B(B({}, Er), { tTriIndices: k.create(Zz()), tActiveVoxelsPyramid: k.create(y), tActiveVoxelsBase: k.create(h), tVolumeData: k.create(g), uIsoValue: k.create(_), uSize: k.create(Math.pow(2, A)), uLevels: k.create(A), uCount: k.create(w), uInvert: k.create(E), uGridDim: k.create(x), uGridTexDim: k.create(C), uGridTransform: k.create(b), uScale: k.create(I), dPackedGroup: k.create(D), dAxisOrder: k.create(T.join("")) }), M = B({}, tU), R = Pn("isosurface", ci, Qz, { drawBuffers: "required" }), O = xr(f, "triangles", R, M, P);
    return Sr(O, P);
  }(e, t, n, r, i, a, o, s, u, c, l, d, m, p);
  return e.namedComputeRenderables[su];
}
function rU(e, t, n, r, i, a, o, s, u, c, l, d, m) {
  var p = function(f, y, h, g, x, C) {
    var b = f.gl, _ = f.resources, A = y.getWidth(), I = y.getHeight();
    f.namedFramebuffers[Ya] || (f.namedFramebuffers[Ya] = _.framebuffer());
    var w = f.namedFramebuffers[Ya];
    w.bind(), f.namedTextures[Ya] || (f.namedTextures[Ya] = _.texture("image-uint8", "rgba", "ubyte", "nearest"));
    var E = f.namedTextures[Ya];
    E.define(A, I);
    var D = eU(f, y, h, g, x, C);
    return f.state.currentRenderItemId = -1, E.attachFramebuffer(w, 0), function(T) {
      var P = T.gl, M = T.state;
      M.disable(P.CULL_FACE), M.disable(P.BLEND), M.disable(P.DEPTH_TEST), M.enable(P.SCISSOR_TEST), M.depthMask(!1), M.colorMask(!0, !0, !0, !0), M.clearColor(0, 0, 0, 0);
    }(f), b.viewport(0, 0, A, I), b.scissor(0, 0, A, I), b.clear(b.COLOR_BUFFER_BIT), b.scissor(0, 0, g[0], g[1]), D.render(), b.finish(), E;
  }(e, t, n, r, o, i), v = function(f, y, h, g, x, C, b, _, A, I, w, E, D, T) {
    var P = f.extensions.drawBuffers;
    if (!P) throw new Error("need WebGL draw buffers");
    var M = f.gl, R = f.resources, O = f.extensions, L = g.pyramidTex, F = g.height, G = g.levels, V = g.scale, U = g.count, q = L.getWidth();
    f.namedFramebuffers[su] || (f.namedFramebuffers[su] = R.framebuffer());
    var H = f.namedFramebuffers[su];
    Et(M) ? (E || (E = O.colorBufferHalfFloat && O.textureHalfFloat ? R.texture("image-float16", "rgba", "fp16", "nearest") : R.texture("image-float32", "rgba", "float", "nearest")), D || (D = R.texture("image-uint8", "rgba", "ubyte", "nearest")), T || (T = O.colorBufferHalfFloat && O.textureHalfFloat ? R.texture("image-float16", "rgba", "fp16", "nearest") : R.texture("image-float32", "rgba", "float", "nearest"))) : (E || (E = R.texture("image-float32", "rgba", "float", "nearest")), D || (D = R.texture("image-float32", "rgba", "float", "nearest")), T || (T = R.texture("image-float32", "rgba", "float", "nearest"))), E.define(q, F), D.define(q, F), T.define(q, F), E.attachFramebuffer(H, 0), D.attachFramebuffer(H, 1), T.attachFramebuffer(H, 2);
    var K = nU(f, L, y, h, x, C, b, _, G, V, U, A, I, w);
    return f.state.currentRenderItemId = -1, H.bind(), P.drawBuffers([P.COLOR_ATTACHMENT0, P.COLOR_ATTACHMENT1, P.COLOR_ATTACHMENT2]), function(j) {
      var W = j.gl, Z = j.state;
      Z.disable(W.CULL_FACE), Z.disable(W.BLEND), Z.disable(W.DEPTH_TEST), Z.disable(W.SCISSOR_TEST), Z.depthMask(!1), Z.colorMask(!0, !0, !0, !0), Z.clearColor(0, 0, 0, 0);
    }(f), M.viewport(0, 0, q, F), M.clear(M.COLOR_BUFFER_BIT), K.render(), M.finish(), { vertexTexture: E, groupTexture: D, normalTexture: T, vertexCount: U };
  }(e, p, t, Yz(e, p, i, r), n, r, a, o, s, u, c, l, d, m);
  return v;
}
var oA = { isoValue: Tt.IsoValueParam }, Yd = 1;
function f2(e, t) {
  return !(e.grid.cells.data.length < Math.pow(10, 3)) && r0(e.grid.cells.space.dimensions, Yd).powerOfTwoSize <= t.maxTextureSize / 2;
}
function iU(e, t, n, r) {
  return n.tryUseGpu && r && function(i) {
    return i.extensions.colorBufferFloat && i.extensions.textureFloat && i.extensions.drawBuffers;
  }(r) && f2(t, r) ? function(i) {
    return dg({ defaultProps: N.getDefaultValues(hg), createGeometry: oU, createLocationIterator: function(a) {
      return Zn(a.grid.cells.data.length, 1, 1, function() {
        return No;
      });
    }, getLoci: fg, eachLocation: mg, setUpdateState: function(a, o, s, u) {
      Tt.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: Eu.Utils, mustRecreate: function(a, o, s) {
      return !o.tryUseGpu || !s || !f2(a, s);
    }, dispose: function(a) {
      a.vertexTexture.ref.value.destroy(), a.groupTexture.ref.value.destroy(), a.normalTexture.ref.value.destroy(), a.doubleBuffer.destroy();
    } }, i);
  }(e) : function(i) {
    return dg({ defaultProps: N.getDefaultValues(hg), createGeometry: aU, createLocationIterator: function(a) {
      return Zn(a.grid.cells.data.length, 1, 1, function() {
        return No;
      });
    }, getLoci: fg, eachLocation: mg, setUpdateState: function(a, o, s, u) {
      Tt.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: ht.Utils, mustRecreate: function(a, o, s) {
      return o.tryUseGpu && !!s && f2(a, s);
    } }, i);
  }(e);
}
function u8(e, t) {
  return Tt.Isosurface.Loci(e, t.isoValue);
}
function fg(e, t, n, r) {
  var i = e.objectId, a = e.groupId;
  return r === i ? Tt.Cell.Loci(t, oe.ofSingleton(a)) : Sn;
}
function mg(e, t, n, r) {
  return function(i, a, o, s) {
    var u = !1;
    if (Tt.isLoci(i)) {
      if (!Tt.areEquivalent(i.volume, a)) return !1;
      s(oe.ofLength(a.grid.cells.data.length)) && (u = !0);
    } else if (Tt.Isosurface.isLoci(i)) {
      if (!Tt.areEquivalent(i.volume, a)) return !1;
      if (o) {
        if (!Tt.IsoValue.areSame(i.isoValue, o, a.grid.stats)) return !1;
        s(oe.ofLength(a.grid.cells.data.length)) && (u = !0);
      } else for (var c = a.grid, l = c.stats, d = c.cells.data, m = l.sigma, p = Tt.IsoValue.toAbsolute(i.isoValue, l).absoluteValue, v = 0, f = d.length; v < f; ++v) On(p, d[v], m) && s(oe.ofSingleton(v)) && (u = !0);
    } else if (Tt.Cell.isLoci(i)) {
      if (!Tt.areEquivalent(i.volume, a)) return !1;
      oe.is(i.indices) ? s(i.indices) && (u = !0) : ve.forEach(i.indices, function(y) {
        s(oe.ofSingleton(y)) && (u = !0);
      });
    }
    return u;
  }(e, t, n.isoValue, r);
}
function aU(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s;
    return ne(this, function(u) {
      switch (u.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), a = Oo(new Int32Array(t.grid.cells.data.length)), [4, WC({ isoLevel: Tt.IsoValue.toAbsolute(r.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: Nn.create(t.grid.cells.space, Nn.Data1(a)) }, i).runAsChild(e.runtime)];
        case 1:
          return o = u.sent(), s = Ri.getGridToCartesianTransform(t.grid), ht.transform(o, s), e.webgl && !e.webgl.isWebGL2 && ht.uniformTriangleGroup(o, !1), o.setBoundingSphere(Tt.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
var pg, hg = B(B(B(B({}, ht.Params), Eu.Params), oA), { quality: B(B({}, ht.Params.quality), { isEssential: !1 }), tryUseGpu: N.Boolean(!0) });
function oU(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s, u, c, l, d, m, p, v, f, y, h, g, x;
    return ne(this, function(C) {
      if (!e.webgl) throw new Error("webgl context required to create volume isosurface texture-mesh");
      return t.grid.cells.data.length <= 1 ? [2, Eu.createEmpty(i)] : (a = t.grid.stats, o = a.max, s = a.min, u = o - s, c = Tt.IsoValue.toAbsolute(r.isoValue, t.grid.stats).absoluteValue, l = (c - s) / u, d = pg.get(t, e.webgl), m = d.texture, p = d.gridDimension, v = d.gridTexDim, f = d.gridTexScale, y = d.transform, h = t.grid.cells.space.axisOrderSlowToFast, g = i == null ? void 0 : i.doubleBuffer.get(), x = rU(e.webgl, m, p, v, f, y, l, c < 0, !1, h, g == null ? void 0 : g.vertex, g == null ? void 0 : g.group, g == null ? void 0 : g.normal), [2, Eu.create(x.vertexCount, 1, x.vertexTexture, x.groupTexture, x.normalTexture, Tt.getBoundingSphere(t), i)]);
    });
  });
}
function sU(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s;
    return ne(this, function(u) {
      switch (u.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), a = Oo(new Int32Array(t.grid.cells.data.length)), [4, ZC({ isoLevel: Tt.IsoValue.toAbsolute(r.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: Nn.create(t.grid.cells.space, Nn.Data1(a)) }, i).runAsChild(e.runtime)];
        case 1:
          return o = u.sent(), s = Ri.getGridToCartesianTransform(t.grid), Yt.transform(o, s), o.setBoundingSphere(Tt.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
(function(e) {
  var t = "volume-isosurface-texture";
  e.descriptor = no({ name: t }), e.get = function(n, r) {
    var i = r.resources, a = Ri.getGridToCartesianTransform(n.grid), o = S.clone(n.grid.cells.space.dimensions), s = r0(o, Yd), u = s.width, c = s.height, l = s.powerOfTwoSize, d = S.create(u, c, 0), m = ge.create(u / l, c / l);
    if (l > r.maxTextureSize / 2) throw new Error("volume too large for gpu isosurface extraction");
    if (!n._propertyData[t]) {
      n._propertyData[t] = i.texture("image-uint8", "alpha", "ubyte", "linear");
      var p = n._propertyData[t];
      p.define(l, l), p.load(function(v, f, y) {
        var h = v.grid, g = h.cells, x = g.space, C = g.data, b = h.stats, _ = b.max, A = b.min, I = x.dimensions, w = x.dataOffset, E = r0(I, y), D = E.width, T = E.height, P = new Uint8Array(D * T * 1), M = { array: P, width: D, height: T }, R = _ - A, O = I[0], L = I[1], F = I[2], G = O + y, V = L + y;
        S(), S();
        for (var U = 0; U < F; ++U) for (var q = 0; q < L; ++q) for (var H = 0; H < O; ++H) {
          var K = Math.floor(U * G % D / G), j = 1 * (Math.floor(U * G / D) * V * D + q * D + (K * G + H)), W = w(H, q, U);
          P[j] = Math.round((C[W] - A) / R * 255);
        }
        return M;
      }(n, 0, Yd), !0), n.customProperties.add(e.descriptor), n.customProperties.assets(e.descriptor, [{ dispose: function() {
        return p.destroy();
      } }]);
    }
    return o[0] += Yd, o[1] += Yd, { texture: n._propertyData[t], transform: a, gridDimension: o, gridTexDim: d, gridTexScale: m };
  };
})(pg || (pg = {}));
var sA = B(B(B({}, Yt.Params), oA), { quality: B(B({}, Yt.Params.quality), { isEssential: !1 }), sizeFactor: N.Numeric(3, { min: 0, max: 10, step: 0.1 }) });
function uU(e) {
  return dg({ defaultProps: N.getDefaultValues(sA), createGeometry: sU, createLocationIterator: function(t) {
    return Zn(t.grid.cells.data.length, 1, 1, function() {
      return No;
    });
  }, getLoci: fg, eachLocation: mg, setUpdateState: function(t, n, r, i) {
    Tt.IsoValue.areSame(r.isoValue, i.isoValue, n.grid.stats) || (t.createGeometry = !0);
  }, geometryUtils: Yt.Utils }, e);
}
var ys, vg, Jr, gg, uA = { solid: function(e, t) {
  return o8("Isosurface mesh", e, t, iU, u8);
}, wireframe: function(e, t) {
  return o8("Isosurface wireframe", e, t, uU, u8);
} }, cA = B(B(B({}, hg), sA), { visuals: N.MultiSelect(["solid"], N.objectToOptions(uA)), bumpFrequency: N.Numeric(1, { min: 0, max: 10, step: 0.1 }, Ve.ShadingCategory), alpha: N.Numeric(0.12, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) });
function cU(e, t) {
  return Mt.createMulti("Isosurface", e, t, Mt.StateBuilder, uA);
}
function c8(e) {
  return e === Jr.Float32 ? 4 : e === Jr.Int16 || e === Jr.Uint16 ? 2 : 1;
}
function lU(e, t, n, r) {
  return n === void 0 && (n = 0), e === Jr.Float32 ? new Float32Array(t, n, r) : e === Jr.Int16 ? new Int16Array(t, n, r) : e === Jr.Uint16 ? new Uint16Array(t, n, r) : new Int8Array(t, n, r);
}
function dU(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(o) {
      switch (o.label) {
        case 0:
          return [4, t.readBuffer(n, e.readBuffer, r, i)];
        case 1:
          return o.sent(), e.elementByteSize > 1 && (a !== void 0 && a !== ys.IsNativeEndianLittle || !ys.IsNativeEndianLittle) && ys.flipByteOrder(e.readBuffer, e.valuesBuffer, r, e.elementByteSize, i), [2, e.values];
      }
    });
  });
}
function fU(e) {
  return ie(this, 0, void 0, function() {
    var t, n, r, i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          return [4, e.readBuffer(0, 1024)];
        case 1:
          if (t = s.sent().buffer, (n = 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 r = [t.readUInt8(212), t.readUInt8(213)], i = !1, r[0] === 68 && r[1] === 65 ? i = !0 : r[0] === 17 && r[1] === 17 ? i = !1 : t.readInt32LE(12) <= 16 && (i = !0), a = i ? function(u) {
            return t.readInt32LE(4 * u);
          } : function(u) {
            return t.readInt32BE(4 * u);
          }, o = i ? function(u) {
            return t.readFloatLE(4 * u);
          } : function(u) {
            return t.readFloatBE(4 * u);
          }, [2, { header: { NC: a(0), NR: a(1), NS: a(2), MODE: a(3), NCSTART: a(4), NRSTART: a(5), NSSTART: a(6), NX: a(7), NY: a(8), NZ: a(9), xLength: o(10), yLength: o(11), zLength: o(12), alpha: o(13), beta: o(14), gamma: o(15), MAPC: a(16), MAPR: a(17), MAPS: a(18), AMIN: o(19), AMAX: o(20), AMEAN: o(21), ISPG: a(22), NSYMBT: a(23), LSKFLG: a(24), SKWMAT: [], SKWTRN: [], userFlag1: a(39), userFlag2: a(40), originX: o(49), originY: o(50), originZ: o(51), MAP: n, MACHST: r, ARMS: o(54) }, littleEndian: i }];
      }
    });
  });
}
function lA(e) {
  switch (e) {
    case 0:
      return Jr.Int8;
    case 1:
      return Jr.Int16;
    case 2:
      return Jr.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:
      Jr.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 dA(e) {
  return e.userFlag1 === -128 && e.userFlag2 === 127;
}
function fA(e) {
  return dA(e) ? Jr.Float32 : lA(e.MODE);
}
function mU(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c, l, d, m;
    return ne(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, n.update({ message: "Parsing CCP4/MRC/MAP file..." })];
        case 1:
          return p.sent(), [4, fU(e)];
        case 2:
          return r = p.sent(), i = r.header, a = r.littleEndian, o = function(v) {
            return 1024 + v.NSYMBT;
          }(i), s = lA(i.MODE), u = fA(i), c = i.NC * i.NR * i.NS, l = c8(s), d = c * l, m = function(v, f) {
            var y = c8(f), h = new ArrayBuffer(y * v), g = ys.fromArrayBuffer(h), x = ys.IsNativeEndianLittle ? h : new ArrayBuffer(y * v);
            return { type: f, elementByteSize: y, readBuffer: g, valuesBuffer: new Uint8Array(x), values: lU(f, x) };
          }(c, u), function(v, f, y, h, g, x) {
            ie(this, 0, void 0, function() {
              var C, b, _, A, I, w;
              return ne(this, function(E) {
                switch (E.label) {
                  case 0:
                    return dA(v) ? (C = 3 * g, [4, y.readBuffer(h, f.readBuffer, g, C)]) : [3, 2];
                  case 1:
                    for (E.sent(), b = new Int8Array(f.valuesBuffer.buffer, C), _ = (v.AMAX - v.AMIN) / 255, A = 0.5 * (v.AMIN + v.AMAX + _), I = 0, w = g; I < w; ++I) f.values[I] = _ * b[I] + A;
                    return [3, 4];
                  case 2:
                    return [4, dU(f, y, h, g, 0, x)];
                  case 3:
                    E.sent(), E.label = 4;
                  case 4:
                    return [2];
                }
              });
            });
          }(i, m, e, o, d, a), [2, { header: i, values: m.values, name: e.name }];
      }
    });
  });
}
function pU(e, t) {
  return function(n, r) {
    var i = this;
    return At.create("Parse CCP4/MRC/MAP", function(a) {
      return ie(i, 0, void 0, function() {
        var o, s, u;
        return ne(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, 2, , 3]), s = (o = _r).success, [4, mU(n, 0, a)];
            case 1:
              return [2, s.apply(o, [c.sent()])];
            case 2:
              return u = c.sent(), [2, _r.error(u)];
            case 3:
              return [2];
          }
        });
      });
    });
  }(vg.fromBuffer(ys.fromUint8Array(e), t), e.length);
}
function hU(e, t) {
  var n = this;
  return At.create("Create Volume", function(r) {
    return ie(n, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C;
      return ne(this, function(b) {
        return i = e.header, a = e.values, o = S.create(i.xLength, i.yLength, i.zLength), s = S.create(Bn(i.alpha), Bn(i.beta), Bn(i.gamma)), u = i.ISPG > 65536 ? 0 : i.ISPG, c = Ma.create(u || "P 1", o, s), l = S.create(i.MAPC - 1, i.MAPR - 1, i.MAPS - 1), d = Nn.convertToCanonicalAxisIndicesFastToSlow(l), m = [i.NX, i.NY, i.NZ], p = d([i.NC, i.NR, i.NS]), v = function(_) {
          return _.originX === 0 && _.originY === 0 && _.originZ === 0 ? S.create(_.NCSTART, _.NRSTART, _.NSSTART) : S.create(_.originX / (_.xLength / _.NX), _.originY / (_.yLength / _.NY), _.originZ / (_.zLength / _.NZ));
        }(i), f = d(v), y = S.create(f[0] / m[0], f[1] / m[1], f[2] / m[2]), h = S.create(p[0] / m[0], p[1] / m[1], p[2] / m[2]), g = Nn.Space(p, Nn.invertAxisOrder(l), function(_) {
          var A = fA(_);
          switch (A) {
            case Jr.Float32:
              return Float32Array;
            case Jr.Int8:
              return Int8Array;
            case Jr.Int16:
              return Int16Array;
            case Jr.Uint16:
              return Uint16Array;
          }
          throw Error("".concat(A, " is not a supported value format."));
        }(i)), x = Nn.create(g, Nn.Data1(a)), C = i.AMIN === 0 && i.AMAX === 0 && i.AMEAN === 0 && i.ARMS === 0, [2, { label: void 0, entryId: void 0, grid: { transform: { kind: "spacegroup", cell: c, fractionalBox: sn.create(y, S.add(S.zero(), y, h)) }, cells: x, stats: { min: isNaN(i.AMIN) || C ? vE(a) : i.AMIN, max: isNaN(i.AMAX) || C ? Nm(a) : i.AMAX, mean: isNaN(i.AMEAN) || C ? gE(a) : i.AMEAN, sigma: isNaN(i.ARMS) || i.ARMS === 0 ? yE(a) : i.ARMS } }, sourceData: gg.create(e), customProperties: new ed(), _propertyData: /* @__PURE__ */ Object.create(null) }];
      });
    });
  });
}
N.getDefaultValues(cA), function(e) {
  function t(r) {
    var i = new DataView(r.buffer);
    return Object.assign(r.subarray(0), { readInt8: function(a) {
      return i.getInt8(a);
    }, readUInt8: function(a) {
      return i.getUint8(a);
    }, writeInt8: function(a, o) {
      return i.setInt8(o, a);
    }, writeUInt8: function(a, o) {
      return i.setUint8(o, a);
    }, readInt16LE: function(a) {
      return i.getInt16(a, !0);
    }, readInt32LE: function(a) {
      return i.getInt32(a, !0);
    }, readUInt16LE: function(a) {
      return i.getUint16(a, !0);
    }, readUInt32LE: function(a) {
      return i.getUint32(a, !0);
    }, readFloatLE: function(a) {
      return i.getFloat32(a, !0);
    }, readDoubleLE: function(a) {
      return i.getFloat64(a, !0);
    }, writeInt16LE: function(a, o) {
      return i.setInt16(o, a, !0);
    }, writeInt32LE: function(a, o) {
      return i.setInt32(o, a, !0);
    }, writeUInt16LE: function(a, o) {
      return i.setUint16(o, a, !0);
    }, writeUInt32LE: function(a, o) {
      return i.setUint32(o, a, !0);
    }, writeFloatLE: function(a, o) {
      return i.setFloat32(o, a, !0);
    }, writeDoubleLE: function(a, o) {
      return i.setFloat64(o, a, !0);
    }, readInt16BE: function(a) {
      return i.getInt16(a, !1);
    }, readInt32BE: function(a) {
      return i.getInt32(a, !1);
    }, readUInt16BE: function(a) {
      return i.getUint16(a, !1);
    }, readUInt32BE: function(a) {
      return i.getUint32(a, !1);
    }, readFloatBE: function(a) {
      return i.getFloat32(a, !1);
    }, readDoubleBE: function(a) {
      return i.getFloat64(a, !1);
    }, writeInt16BE: function(a, o) {
      return i.setInt16(o, a, !1);
    }, writeInt32BE: function(a, o) {
      return i.setInt32(o, a, !1);
    }, writeUInt16BE: function(a, o) {
      return i.setUint16(o, a, !1);
    }, writeUInt32BE: function(a, o) {
      return i.setUint32(o, a, !1);
    }, writeFloatBE: function(a, o) {
      return i.setFloat32(o, a, !1);
    }, writeDoubleBE: function(a, o) {
      return i.setFloat64(o, a, !1);
    }, copy: function(a, o, s, u) {
      return o = mr(o, 0), s = mr(s, 0), u = mr(u, r.length), a.set(r.subarray(s, u), o), u - s;
    } });
  }
  function n(r, i, a, o, s) {
    for (var u = 0, c = a; u < c; u += o) for (var l = 0; l < o; l++) i[s + u + o - l - 1] = r[s + u + l];
  }
  e.fromUint8Array = t, e.fromArrayBuffer = function(r) {
    return t(new Uint8Array(r));
  }, e.fromBuffer = function(r) {
    return t(new Uint8Array(r));
  }, e.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330, e.flipByteOrder = n, e.flipByteOrderInPlace2 = function(r, i, a) {
    i === void 0 && (i = 0);
    for (var o = new Int16Array(r, i, a), s = 0, u = o.length; s < u; ++s) {
      var c = o[s];
      o[s] = (255 & c) << 8 | c >> 8 & 255;
    }
  }, e.ensureLittleEndian = function(r, i, a, o, s) {
    e.IsNativeEndianLittle || !a || o <= 1 || n(r, i, a, o, s);
  };
}(ys || (ys = {})), function(e) {
  e.fromBuffer = function(t, n) {
    return { name: n, readBuffer: function(r, i, a, o) {
      var s, u;
      if (typeof i == "number") {
        a = mr(a, i);
        var c = r;
        s = (l = Math.min(t.length, c + a)) - c, u = ys.fromUint8Array(new Uint8Array(t.buffer, c, l - c));
      } else {
        a = mr(a, i.length), c = r;
        var l = Math.min(t.length, c + a);
        i.set(t.subarray(c, l), o), s = l - c, u = i;
      }
      return a !== s && console.warn("byteCount ".concat(a, " and bytesRead ").concat(s, " differ")), Promise.resolve({ bytesRead: s, buffer: u });
    }, writeBuffer: function(r, i, a) {
      return a = mr(a, i.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
    }, writeBufferSync: function(r, i, a) {
      return a = mr(a, i.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
    }, close: Bg };
  };
}(vg || (vg = {})), function(e) {
  e.Float32 = "float32", e.Int8 = "int8", e.Int16 = "int16", e.Uint16 = "uint16";
}(Jr || (Jr = {})), 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 };
  };
}(gg || (gg = {}));
var vU = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, pU(e, "Hermite").run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, hU(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, gU = { createTheme: function(e, t, n) {
  var r, i;
  if (n != null && n.color) return { color: (r = t.managers.representation.ctx) === null || r === void 0 ? void 0 : r.colorThemeRegistry.create(n.color.name, { volume: e }, n.color.props), size: (i = t.managers.representation.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("uniform", {}, {}) };
}, parse: function(e, t) {
  return ie(this, 0, void 0, function() {
    var n;
    return ne(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, e.arrayBuffer()];
        case 1:
          return n = r.sent(), [4, vU.parse(new Uint8Array(n))];
        case 2:
          return [2, r.sent()];
      }
    });
  });
}, create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = cU(t, function() {
            return cA;
          }), n && i.setTheme(n), [4, i.createOrUpdate(r ?? {}, e).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, t).run()];
        case 1:
          return a.sent(), r && e.setTheme(r), [2];
      }
    });
  });
} }, yU = { unitLabel: N.Text("Å", { isEssential: !0 }) }, bU = B(B(B({}, Yt.Params), yU), { lineSizeAttenuation: N.Boolean(!1), linesColor: N.Color(ye(14080239), { isEssential: !0 }), linesSize: N.Numeric(0.8), alpha: N.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) }), mA = { lines: function(e, t) {
  return wn(SU, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.Highlighting });
  } });
} }, _U = B(B({}, bU), { visuals: N.MultiSelect(["lines"], N.objectToOptions(mA)) });
function xU(e, t) {
  var n = t.sphereA, r = t.sphereB, i = t.center, a = e.loci, o = a[0], s = a[1];
  return rn.getBoundingSphere(o, n), rn.getBoundingSphere(s, r), S.add(i, n.center, r.center), S.scale(i, i, 0.5), t.distance = S.distance(n.center, r.center), t;
}
var Qu = { sphereA: de(), sphereB: de(), center: S(), distance: 0 };
function SU(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) xU(o.pairs[l], Qu), c.add(Qu.sphereA.center[0], Qu.sphereA.center[1], Qu.sphereA.center[2], Qu.sphereB.center[0], Qu.sphereB.center[1], Qu.sphereB.center[2], l);
    return c.getLines();
  }(t, 0, r && r.geometry), a = function(o, s) {
    return o.pairs.length === 1 ? "interactionLine ".concat(Rf(o.pairs[0], { unitLabel: s, measureOnly: !0 })) : "".concat(o.pairs.length, " interactionLines");
  }(t, n.unitLabel);
  return Ct.create(a, t, i, function() {
    return n.linesColor;
  }, function() {
    return n.linesSize;
  }, function(o) {
    return Rf(t.pairs[o], n);
  });
}
var CU = { parse: function(e, t) {
  return e.map(function(n) {
    var r = t.managers.cell.get(n.ref), i = un(r);
    return Yn(i, n.elementIds);
  });
}, create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r = function(a, o) {
            var s = Mt.createMulti("interactionLine", a, o, Mt.StateBuilder, mA);
            return s.setState({ pickable: !0, markerActions: Wt.All }), s;
          }(t, function() {
            return _U;
          }), [4, r.createOrUpdate({}, { pairs: [{ loci: e }] }).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate({}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, AU = J.fromTranslation(J(), S.create(0.5, 0.5, 0.5)), IU = k0(R0(cx()), AU), Ha = S(), l8 = J(), wU = B(B({}, ht.Params), { cellColor: N.Color(_t.black), cellScale: N.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), ref: N.Select("model", N.objectToOptions({ origin: "Origin", model: "Model" }), { isEssential: !0 }), attachment: N.Select("corner", N.objectToOptions({ corner: "Corner", center: "Center" }), { isEssential: !0 }) }), PU = { mesh: function(e, t) {
  return wn(TU, ht.Utils);
} }, EU = B({}, wU);
function TU(e, t, n, r) {
  var i = function(o, s, u) {
    var c = nt.createState(256, 128, u), l = o.symmetry.spacegroup.cell.fromFractional;
    S.copy(Ha, o.ref), s.attachment === "center" ? (S.trunc(Ha, Ha), S.subScalar(Ha, Ha, 0.5)) : S.floor(Ha, Ha), J.fromTranslation(l8, Ha);
    var d = k0(R0(IU), l8), m = Math.cbrt(o.symmetry.spacegroup.cell.volume) / 300 * s.cellScale;
    c.currentGroup = 1, nt.addCage(c, l, d, m, 2, 20);
    var p = de.fromDimensionsAndTransform(de(), S.unit, l);
    S.transformMat4(Ha, Ha, l), de.translate(p, p, Ha), de.expand(p, p, m);
    var v = nt.getMesh(c);
    return v.setBoundingSphere(p), v;
  }(t, n, r && r.geometry), a = Km.getUnitcellLabel(t.symmetry);
  return Ct.create(a, t, i, function() {
    return n.cellColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
var MU = { create: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r;
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return r = function(a, o) {
            return Mt.createMulti("Unit Cell", a, o, Mt.StateBuilder, PU);
          }(t, function() {
            return EU;
          }), [4, r.createOrUpdate({}, e).run()];
        case 1:
          return i.sent(), [2, r];
      }
    });
  });
}, update: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, DU = { unitLabel: N.Text("Å", { isEssential: !0 }) }, BU = B(B(B({}, Yt.Params), DU), { lineSizeAttenuation: N.Boolean(!1), linesColor: N.Color(_t.black), linesSize: N.Numeric(2), alpha: N.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), isDash: N.Boolean(!1), dashLength: N.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), pA = { lines: function(e, t) {
  return wn(kU, Yt.Utils, { modifyState: function(n) {
    return B(B({}, n), { markerActions: Wt.Selecting });
  } });
} }, RU = B(B({}, BU), { visuals: N.MultiSelect(["lines"], N.objectToOptions(pA)) });
function kU(e, t, n, r) {
  var i = function(o, s, u) {
    for (var c = zr.create(128, 64, u), l = 0, d = o.lines.length; l < d; ++l) s.isDash ? c.addFixedLengthDashes(S.create(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2]), S.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, n, r && r.geometry), a = function(o, s) {
    return "".concat(o.lines.length, " interactionLines");
  }(t, n.unitLabel);
  return Ct.create(a, t, i, function() {
    return n.linesColor;
  }, function() {
    return n.linesSize;
  }, function() {
    return "CustomLines";
  });
}
var OU = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = Mt.createMulti("customLines", o, s, Mt.StateBuilder, pA);
            return u.setState({ pickable: !1, markerActions: Wt.Selecting }), u;
          }(t, function() {
            return RU;
          }), [4, i.createOrUpdate(r ?? {}, { lines: e }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, { lines: t }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, NU = B(B({}, ht.Params), { color: N.Color(_t.orange), scaleFactor: N.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) }), hA = { plane: function(e, t) {
  return wn(FU, ht.Utils);
} }, LU = B(B({}, NU), { visuals: N.MultiSelect(["plane"], N.objectToOptions(hA)) });
function FU(e, t, n, r) {
  var i = function(a, o, s) {
    var u = nt.createState(256, 128, s);
    return a.planes.forEach(function(c) {
      nt.addTriangle(u, S.create.apply(S, c[0]), S.create.apply(S, c[1]), S.create.apply(S, c[2]));
    }), nt.getMesh(u);
  }(t, 0, r && r.geometry);
  return Ct.create("CustomPlanes", t, i, function() {
    return n.color;
  }, function() {
    return 1;
  }, function() {
    return "CustomPlanes";
  });
}
var fl, Ed, yo, Kr, Td, GU = { create: function(e, t, n, r) {
  return ie(this, 0, void 0, function() {
    var i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = Mt.createMulti("CustomPlanes", o, s, Mt.StateBuilder, hA);
            return u.setState({ pickable: !1, markerActions: Wt.Selecting }), u;
          }(t, function() {
            return LU;
          }), [4, i.createOrUpdate(r ?? {}, { planes: e }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, { planes: t }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, wa = ((fl = {})[fe.Ribbon] = KG, fl[fe.BallAndStick] = AC, fl[fe.Line] = $V, fl[fe.Stick] = ez, fl[fe.CPK] = _z, fl), Wd = ((Ed = {})[fe.Label] = fV, Ed[fe.Distance] = yV, Ed[fe.Angle] = EV, Ed[fe.Dihedral] = UV, Ed), Im = ((yo = {})[fe.Surface] = dz, yo[fe.IsoSurface] = gU, yo[fe.RotateArrow] = yz, yo[fe.Pocket] = Ez, yo[fe.Pharmacophore] = Vz, yo[fe.MappingLine] = CU, yo[fe.UnitCell] = MU, yo[fe.CustomLines] = OU, yo[fe.CustomPlanes] = GU, yo);
(function(e) {
  e.LigandReceptor = "ligand-receptor", e.IntraLigand = "intra-ligand", e.IntraReceptor = "intra-receptor", e.All = "all";
})(Kr || (Kr = {}));
var VU = function(e, t) {
  var n, r, i, a = Yr(e.getLoci());
  if (!a || !(!((i = (r = (n = a == null ? void 0 : a.elements) === null || n === void 0 ? void 0 : n[0]) === null || r === void 0 ? void 0 : r.unit) === null || i === void 0) && i.elements)) return iu.Not;
  var o = new Set(wr(a)), s = 0;
  return t.forEach(function(u) {
    o.has(u) && s++;
  }), s ? s === t.length ? iu.Include : s === o.size ? iu.BeIncluded : iu.Cross : iu.Not;
}, zU = function(e, t) {
  var n, r;
  if (e.ref !== t.ref) return !1;
  if (!(!((n = e.elementIds) === null || n === void 0) && n.length) || !(!((r = t.elementIds) === null || r === void 0) && r.length)) return !0;
  var i = new Set(t.elementIds);
  return e.elementIds.some(function(a) {
    return i.has(a);
  });
}, x0 = function(e, t) {
  var n = Yr(e.getLoci());
  if (!n) return [];
  var r = Yn(n == null ? void 0 : n.structure, t), i = Se.intersect(n, r);
  return wr(i);
}, yg = function(e, t, n, r, i) {
  var a = Li(e);
  if (a) {
    var o = TS(a, t);
    return wa[n].update(e, o, $s.managers.representation.ctx, r ? r(o) : e.theme), i && e.setState({ transparency: i(o) }), e;
  }
  console.warn("removeElementIdsInRepresentation");
}, UU = ((Td = {})[fe.Label] = ["customText", "textColor", "textSize"], Td[fe.Distance] = ["linesColor", "textSize", "textColor"], Td[fe.Angle] = ["color", "textSize", "textColor"], Td[fe.Dihedral] = ["color", "textSize", "textColor"], Td), vA = function(e, t) {
  if (Kl.has(e)) {
    var n = {};
    return UU[e].forEach(function(r) {
      n[r] = t.props[r];
    }), n;
  }
}, d8 = function(e, t, n, r) {
  var i = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], a = e[0], o = e[1], s = e[2], u = function(P) {
    var M = S.create(P[0], P[1], P[2]);
    return S.normalize(M, M), [M[0], M[1], M[2]];
  }(function(P, M) {
    return [M[0] - P[0], M[1] - P[1], M[2] - P[2]];
  }(e, t)), c = u[0], l = u[1], d = u[2], m = c * c, p = c * l, v = c * d, f = l * l, y = l * d, h = d * d, g = a * c, x = a * l, C = a * d, b = o * c, _ = o * l, A = o * d, I = s * c, w = s * l, E = s * d, D = Math.cos(n * (Math.PI / 180)), T = Math.sin(n * (Math.PI / 180));
  return i[0][0] = m + (f + h) * D, i[0][1] = p * (1 - D) + d * T, i[0][2] = v * (1 - D) - l * T, i[0][3] = 0, i[1][0] = p * (1 - D) - d * T, i[1][1] = f + (m + h) * D, i[1][2] = y * (1 - D) + c * T, i[1][3] = 0, i[2][0] = v * (1 - D) + l * T, i[2][1] = y * (1 - D) - c * T, i[2][2] = h + (m + f) * D, i[2][3] = 0, i[3][0] = (a * (f + h) - c * (_ + E)) * (1 - D) + (A - w) * T, i[3][1] = (o * (m + h) - l * (g + E)) * (1 - D) + (I - C) * T, i[3][2] = (s * (m + f) - d * (g + _)) * (1 - D) + (x - b) * T, i[3][3] = 1, [r[0] * i[0][0] + r[1] * i[1][0] + r[2] * i[2][0] + i[3][0], r[0] * i[0][1] + r[1] * i[1][1] + r[2] * i[2][1] + i[3][1], r[0] * i[0][2] + r[1] * i[1][2] + r[2] * i[2][2] + i[3][2]];
}, gA = function(e, t, n) {
  var r, i, a, o, s, u;
  if (!e.canvas3d) return S.create(0, 0, 0);
  var c = ge.create(0, 0), l = S.create(0, 0, 0), d = S.create(0, 0, 0);
  if (ge.sub(c, ge.copy(c, n), t), ge.squaredMagnitude(c)) {
    var m = (i = (r = e.canvas3d) === null || r === void 0 ? void 0 : r.input.pixelRatio) !== null && i !== void 0 ? i : 1;
    return c[0] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.width * m, c[1] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.height * m * (((o = (a = e.layout) === null || a === void 0 ? void 0 : a.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)), S.cross(l, S.sub(l, e.canvas3d.camera.position, e.canvas3d.camera.target), e.canvas3d.camera.up), S.setMagnitude(l, l, c[0]), S.setMagnitude(d, e.canvas3d.camera.up, c[1]), S.add(l, l, d), S.scale(l, l, 1 / 2100), l;
  }
  return S.create(0, 0, 0);
}, HU = function(e, t) {
  var n = Se.getBoundary(Yn(e, t));
  return { center: S.create((n.box.max[0] + n.box.min[0]) / 2, (n.box.max[1] + n.box.min[1]) / 2, (n.box.max[2] + n.box.min[2]) / 2), size: S.create(n.box.max[0] - n.box.min[0], n.box.max[1] - n.box.min[1], n.box.max[2] - n.box.min[2]) };
}, qU = function(e) {
  var t = ea(e);
  if (t) {
    var n = Vr.Provider.get(t);
    if (n) {
      var r = function(i, a, o) {
        var s = S();
        return o.ref === "model" && S.transformMat4(s, pn.getCenter(i), a.spacegroup.cell.toFractional), { symmetry: a, ref: s };
      }(t, n, {});
      return r;
    }
  }
};
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 bg, _g, Md = new ka("98"), f8 = function() {
  function e(t) {
    this.boundaryHelper = new ka("98"), this.plugin = t;
  }
  return e.prototype.focus = function(t) {
    var n;
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x = this;
      return ne(this, function(C) {
        switch (C.label) {
          case 0:
            if (r = !1, i = [], a = [], t ? t.forEach(function(b) {
              var _ = x.plugin.cells.get(b.ref);
              _ && (Array.from(_.representations.keys()).some(function(A) {
                return Kl.has(A) || HN.has(A);
              }) ? a.push(b) : i.push(b));
            }) : (a.push.apply(a, Array.from(this.plugin.managers.selection.shape.selection.values()).map(function(b) {
              return { ref: b };
            })), i.push.apply(i, this.plugin.managers.selection.structure.getSelectionCellItems().length ? this.plugin.managers.selection.structure.getSelectionCellItems() : a.length ? [] : this.plugin.managers.cell.getAllDisplayedCellsRef().map(function(b) {
              return { ref: b };
            }))), !i.length && !a.length) return [2];
            o = S.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), s = S.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), Md.reset(), u = [], a.forEach(function(b) {
              var _ = x.plugin.cells.get(b.ref);
              if (_) if (_.representations.has(fe.Surface)) i.push(_.model.other);
              else {
                if (_.representations.has(fe.Pharmacophore)) {
                  var A = _.model.other, I = A.center, w = A.normal, E = A.radius;
                  if (!w) return S.min(o, o, S.create(I[0] - E, I[1] - E, I[2] - E)), S.max(s, s, S.create(I[0] + E, I[1] + E, I[2] + E)), void (r = !0);
                  var D = S.create((I[0] + w[0]) / 2, (I[1] + w[1]) / 2, (I[2] + w[2]) / 2), T = (S.distance(w, I) + E) / 2;
                  return S.min(o, o, S.create(D[0] - T, D[1] - T, D[2] - T)), S.max(s, s, S.create(D[0] + T, D[1] + T, D[2] + T)), void (r = !0);
                }
                if (_.representations.has(fe.Pocket)) {
                  var P = _.model.other, M = (I = P.center, P.size), R = [(2 * I[0] + M[0]) / 2, (2 * I[1] + M[1]) / 2, (2 * I[2] + M[2]) / 2], O = [(2 * I[0] - M[0]) / 2, (2 * I[1] - M[1]) / 2, (2 * I[2] - M[2]) / 2], L = { min: S.fromArray(S.zero(), O, 0), max: S.fromArray(S.zero(), R, 0) };
                  return S.min(o, o, L.min), S.max(s, s, L.max), void (r = !0);
                }
                i.push.apply(i, _.dependency.on);
              }
            }), c = 0, l = i, C.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 (!(m = C.sent())) return [2];
            p = Yn(m, d.elementIds), (!Se.isEmpty(p) || ((n = p == null ? void 0 : p.elements) === null || n === void 0 ? void 0 : n.length) > 0) && u.push(Se.getBoundary(p)), C.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            if (!u.length) return r && this.focusSphere({ center: S.create((s[0] + o[0]) / 2, (s[1] + o[1]) / 2, (s[2] + o[2]) / 2), radius: S.distance(s, o) / 2 }), [2];
            for (y = 0, h = u.length; y < h; ++y) v = u[y], f = v.box, g = v.sphere, S.min(o, o, f.min), S.max(s, s, f.max), Md.includePositionRadius(g.center, g.radius);
            for (Md.finishedIncludeStep(), y = 0, h = u.length; y < h; ++y) g = u[y].sphere, Md.radiusPositionRadius(g.center, g.radius);
            return this.focusSphere(Md.getSphere()), [2];
        }
      });
    });
  }, e.prototype.focusSphere = function(t, n) {
    var r, i, a = B({ minRadius: 5, extraRadius: 4, durationMs: 250 }, n), o = a.extraRadius, s = a.minRadius, u = a.durationMs, c = Math.max(t.radius + o, s), l = (r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.camera.getFocus(t.center, c);
    (i = this.plugin.canvas3d) === null || i === void 0 || i.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, n, r = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (r) {
      var i = m8(r, 1);
      S.distance(r.target, i) < 10 || (r.position = i, (n = this.plugin.canvas3d) === null || n === void 0 || n.camera.setState(r, 200));
    }
  }, e.prototype.zoomOut = function() {
    var t, n, r = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (r) {
      var i = m8(r, -1);
      r.position = i, (n = this.plugin.canvas3d) === null || n === void 0 || n.camera.setState(r, 200);
    }
  }, e.prototype.updateAxes = function(t) {
    var n, r, i, a, o, s, u, c, l = { vecA: S.unitX, vecB: S.unitY, vecC: S.unitZ }, d = this.plugin.cells.get(t);
    if (d) {
      var m = un(d);
      if (m && (!((a = (i = (r = (n = ea(m)) === null || n === void 0 ? void 0 : n.sourceData) === null || r === void 0 ? void 0 : r.data) === null || i === void 0 ? void 0 : i.molecules) === null || a === void 0) && a.length)) {
        var p = (u = (s = (o = ea(m)) === 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, v = p.vecA, f = p.vecB, y = p.vecC;
        l = { vecA: S.scale(S(), v, 1 / S.distance(S(), v)), vecB: S.scale(S(), f, 1 / S.distance(S(), f)), vecC: S.scale(S(), y, 1 / S.distance(S(), y)) };
      }
    }
    (c = this.plugin.canvas3d) === null || c === void 0 || c.setProps({ camera: { helper: { axes: { name: "on", params: l } } } });
  }, e;
}();
function m8(e, t) {
  var n = S();
  S.sub(n, e.target, e.position), S.normalize(n, n), S.scale(n, n, 5 * t);
  var r = e.position;
  return S.add(r, r, n), r;
}
(function(e) {
  e.create = function(t, n) {
    var r = [], i = [], a = [];
    return { add: function(o, s, u) {
      r[r.length] = o, i[i.length] = s, a[a.length] = u;
    }, getContacts: function() {
      for (var o = new Ui.EdgeBuilder(t.count, r, i), s = new Int8Array(o.slotCount), u = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(s, a[c]);
      var d, m = o.createGraph({ type: s, flag: u });
      return Object.defineProperty(m, "elementsIndex", { get: function() {
        return d || (d = zv.createElementsIndex(m, t, n));
      } });
    } };
  };
})(bg || (bg = {})), function(e) {
  e.create = function() {
    var t = new Sc.Builder();
    return { startUnitPair: function(n, r) {
      t.startUnitPair(n.id, r.id);
    }, finishUnitPair: function() {
      t.finishUnitPair();
    }, add: function(n, r, i) {
      t.add(n, r, { type: i, flag: Pi.None });
    }, getContacts: function(n) {
      return new sN(t.getMap(), n);
    } };
  };
}(_g || (_g = {}));
var jU = { lineOfSightDistFactor: N.Numeric(1, { min: 0, max: 3, step: 0.1 }) }, KU = 3;
function yA(e, t, n) {
  var r = t.members[t.offsets[t.feature]], i = n.members[n.offsets[n.feature]];
  if (r === i && t.unit === n.unit) return !1;
  var a = d0(t.unit, r), o = d0(n.unit, i);
  return (!a || !o || a === o) && (t.unit.residueIndex[t.unit.elements[r]] !== n.unit.residueIndex[n.unit.elements[i]] || t.unit !== n.unit) && !QO(e, t.unit, r, n.unit, i);
}
function p8(e, t, n, r) {
  var i = d0(e, t), a = d0(n, r);
  return i && a && i !== a;
}
function h8(e, t) {
  for (var n = t.feature, r = t.offsets, i = t.members, a = r[n], o = r[n + 1]; a < o; ++a) if (i[a] === e) return !0;
  return !1;
}
var Qs = S(), m2 = S(), p2 = S(), XU = E9();
function YU(e, t, n, r) {
  var i = t.feature, a = n.feature, o = t.members[t.offsets[i]], s = n.members[n.offsets[a]];
  nn.position(m2, t), nn.position(p2, n), S.scale(Qs, S.add(Qs, m2, p2), 0.5);
  var u = r * KU, c = e.lookup3d.find(Qs[0], Qs[1], Qs[2], u, XU), l = c.count, d = c.indices, m = c.units, p = c.squaredDistances;
  if (l === 0) return !0;
  for (var v = 0; v < l; ++v) {
    var f = d[v], y = m[v];
    if (me.isAtomic(y)) {
      var h = Zt(y, f);
      if (h !== "H") {
        var g = M0(h);
        if (!(g * g * r * r <= p[v] || p8(y, f, t.unit, o) || p8(y, f, n.unit, s) || t.unit === y && h8(f, t) || n.unit === y && h8(f, n) || (y.conformation.position(y.elements[f], Qs), S.squaredDistance(Qs, m2) < 1 || S.squaredDistance(Qs, p2) < 1))) return !1;
      }
    }
  }
  return !0;
}
function WU(e, t, n, r, i, a, o) {
  for (var s = n.x, u = n.y, c = n.z, l = n.subset(i.requiredFeatures), d = l.lookup3d, m = l.indices, p = nn.Info(e, t, n), v = B({}, p), f = 0, y = ve.size(m); f < y; ++f) {
    var h = ve.getAt(m, f), g = d.find(s[h], u[h], c[h], i.maxDistance), x = g.count, C = g.indices, b = g.squaredDistances;
    if (x !== 0) {
      p.feature = h;
      for (var _ = 0; _ < x; ++_) {
        var A = ve.getAt(m, C[_]);
        if (!(A <= h)) {
          v.feature = A;
          var I = p.unit.elements[p.members[p.offsets[p.feature]]], w = v.unit.elements[v.members[v.offsets[v.feature]]];
          if ((!o || o(p.unit, I, v.unit, w)) && yA(e, p, v)) {
            var E = i.getType(e, p, v, b[_]);
            E && r.add(h, A, E);
          }
        }
      }
    }
  }
}
var ZU = J(), QU = { distanceMax: N.Numeric(4, { min: 1, max: 5, step: 0.1 }) }, JU = nn.Provider([8], function(e, t, n) {
  for (var r = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, m) {
    var p = Zt(t, d), v = !1;
    p === "C" ? (v = !0, gs(e, t, d, function(f, y) {
      var h = Zt(f, y);
      h !== "C" && h !== "H" && (v = !1);
    })) : p === "F" && (v = !0), v && n.add(8, 0, a[r[d]], o[r[d]], s[r[d]], d);
  }, c = 0, l = r.length; c < l; ++c) u(c);
}), $U = { name: "hydrophobic", params: QU, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([8]), getType: function(t, n, r, i) {
    return function(a, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (d = l, c === 8 && d === 8) {
        var d, m = o.members[o.offsets[o.feature]], p = s.members[s.offsets[s.feature]];
        if (Zt(o.unit, m) !== "F" || Zt(s.unit, p) !== "F") return Lt.Hydrophobic;
      }
    }(0, n, r);
  } };
} };
function eH(e, t) {
  var n = t.contacts, r = function(c, l, d, m, p) {
    var v = m.get(d) || [1 / 0, -1], f = v[0], y = v[1];
    c < f ? (y !== -1 && p(y), m.set(d, [c, l])) : p(l);
  };
  function i(c, l, d, m, p) {
    var v = l.members[l.offsets[l.feature]], f = d.members[d.offsets[d.feature]], y = l.unit.getResidueIndex(v), h = d.unit.getResidueIndex(f), g = "".concat(v, "|").concat(l.unit.id, "|").concat(h, "|").concat(d.unit.id, "|A"), x = "".concat(f, "|").concat(d.unit.id, "|").concat(y, "|").concat(l.unit.id, "|B"), C = nn.distance(l, d);
    r(C, c, g, m, p), r(C, c, x, m, p);
  }
  var a, o, s = /* @__PURE__ */ new Map(), u = function(c) {
    return n.edges[c].props.flag = Pi.Filtered;
  };
  return { isApplicable: function(c) {
    return c === Lt.Hydrophobic;
  }, handleInterContact: function(c, l, d) {
    i(c, l, d, s, u);
  }, startUnit: function(c, l, d) {
    a = /* @__PURE__ */ new Map(), o = function(m) {
      return l.edgeProps.flag[m] = Pi.Filtered;
    };
  }, handleIntraContact: function(c, l, d) {
    i(c, l, d, a, o);
  } };
}
function tH(e, t) {
  var n = t.contacts, r = function(i, a) {
    for (var o = i.types[i.feature] === 9 ? a : i, s = o.members[o.offsets[o.feature]], u = t.unitsContacts.get(o.unit.id), c = u.edgeProps.type, l = u.elementsIndex, d = l.offsets, m = l.indices, p = d[s], v = d[s + 1]; p < v; ++p) if (c[m[p]] === Lt.HydrogenBond) return !0;
    var f = n.getEdgeIndices(o.feature, o.unit.id);
    for (p = 0, v = f.length; p < v; ++p) if (n.edges[f[p]].props.type === Lt.HydrogenBond) return !0;
    return !1;
  };
  return { isApplicable: function(i) {
    return i === Lt.WeakHydrogenBond;
  }, handleInterContact: function(i, a, o) {
    r(a, o) && (n.edges[i].props.flag = Pi.Filtered);
  }, startUnit: function() {
  }, handleIntraContact: function(i, a, o) {
    r(a, o) && (t.unitsContacts.get(a.unit.id).edgeProps.flag[i] = Pi.Filtered);
  } };
}
function F3(e, t, n, r, i) {
  for (var a = n.offsets, o = n.feature, s = r.offsets, u = r.feature, c = a[o], l = a[o + 1]; c < l; ++c) for (var d = n.members[c], m = i.getContactIndicesForElement(d, n.unit), p = 0, v = m.length; p < v; ++p) {
    var f = m[p];
    if (e.includes(i.edges[f].props.type)) for (var y = s[u], h = s[u + 1]; y < h; ++y) {
      var g = r.members[y];
      if (i.getContactIndicesForElement(g, r.unit).includes(f)) return void (i.edges[t].props.flag = Pi.Filtered);
    }
  }
}
function G3(e, t, n, r, i) {
  for (var a = i.edgeProps, o = a.type, s = a.flag, u = i.elementsIndex, c = u.offsets, l = u.indices, d = n.offsets, m = n.feature, p = r.offsets, v = r.feature, f = d[m], y = d[m + 1]; f < y; ++f) for (var h = n.members[f], g = c[h], x = c[h + 1]; g < x; ++g) {
    var C = l[g];
    if (e.includes(o[C])) {
      for (var b = p[v], _ = p[v + 1]; b < _; ++b) for (var A = r.members[b], I = c[A], w = c[A + 1]; I < w; ++I) if (C === l[I]) return void (s[t] = Pi.Filtered);
    }
  }
}
function nH(e, t) {
  var n = t.contacts;
  return { isApplicable: function(r) {
    return r === Lt.Ionic;
  }, handleInterContact: function(r, i, a) {
    F3([Lt.HydrogenBond, Lt.WeakHydrogenBond], r, i, a, n);
  }, startUnit: function() {
  }, handleIntraContact: function(r, i, a) {
    G3([Lt.HydrogenBond, Lt.WeakHydrogenBond], r, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function rH(e, t) {
  var n = t.contacts;
  return { isApplicable: function(r) {
    return r === Lt.Hydrophobic || r === Lt.CationPi;
  }, handleInterContact: function(r, i, a) {
    F3([Lt.PiStacking], r, i, a, n);
  }, startUnit: function() {
  }, handleIntraContact: function(r, i, a) {
    G3([Lt.PiStacking], r, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function iH(e, t) {
  var n = t.contacts;
  return { isApplicable: function(r) {
    return r === Lt.Ionic;
  }, handleInterContact: function(r, i, a) {
    F3([Lt.MetalCoordination], r, i, a, n);
  }, startUnit: function() {
  }, handleIntraContact: function(r, i, a) {
    G3([Lt.MetalCoordination], r, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function aH(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    var o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E;
    return ne(this, function(D) {
      return me.isAtomic(t) ? (o = n.child, s = o == null ? void 0 : o.unitMap.get(t.id), o && !s ? [2, ht.createEmpty(a)] : (u = Ne.create(n, t), c = Un.get(n).value, l = c.unitsFeatures.get(t.id), d = c.unitsContacts.get(t.id), m = l.x, p = l.y, v = l.z, f = l.members, y = l.offsets, h = d.edgeCount, g = d.a, x = d.b, C = d.edgeProps.flag, b = i.sizeFactor, h ? (_ = { linkCount: 2 * h, position: function(T, P, M) {
        S.set(T, m[g[M]], p[g[M]], v[g[M]]), S.set(P, m[x[M]], p[x[M]], v[x[M]]);
      }, style: function(T) {
        return 1;
      }, radius: function(T) {
        u.element = t.elements[f[y[g[T]]]];
        var P = r.size.size(u);
        u.element = t.elements[f[y[x[T]]]];
        var M = r.size.size(u);
        return Math.min(P, M) * b;
      }, ignore: function(T) {
        if (C[T] === Pi.Filtered) return !0;
        if (s) for (var P = g[T], M = y[P], R = y[P + 1]; M < R; ++M) {
          var O = t.elements[f[y[M]]];
          if (!_e.has(s.elements, O)) return !0;
        }
        return !1;
      } }, A = q0(0, _, i, a), I = A.mesh, (w = A.boundingSphere) ? I.setBoundingSphere(w) : I.triangleCount > 0 && (E = de.expand(de(), (s ?? t).boundary.sphere, 1 * b), I.setBoundingSphere(E)), [2, I]) : [2, ht.createEmpty(a)])) : [2, ht.createEmpty(a)];
    });
  });
}
var bA = B(B(B({}, Ds), H0), { sizeFactor: N.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: N.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: N.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: N.Boolean(!1) });
function oH(e) {
  return Bs({ defaultProps: N.getDefaultValues(bA), createGeometry: aH, createLocationIterator: cH, getLoci: sH, eachLocation: uH, setUpdateState: function(t, n, r, i, a, o, s) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.dashCount !== r.dashCount || n.dashScale !== r.dashScale || n.dashCap !== r.dashCap || n.radialSegments !== r.radialSegments;
    var u = Un.get(o.structure).version;
    t.info.interactionsHash !== u && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = u);
  } }, e);
}
function sH(e, t, n) {
  var r = e.objectId, i = e.instanceId, a = e.groupId;
  if (n === r) {
    var o = t.structure, s = t.group, u = o.unitMap.get(s.units[i].id), c = Un.get(o).value, l = c.unitsContacts.get(u.id), d = l.a, m = l.b;
    return ws.Loci(o, c, [{ unitA: u, indexA: d[a], unitB: u, indexB: m[a] }, { unitA: u, indexA: m[a], unitB: u, indexB: d[a] }]);
  }
  return Sn;
}
var h2 = /* @__PURE__ */ new Set();
function uH(e, t, n, r) {
  var i = !1;
  if (ws.isLoci(e)) {
    var a = t.structure, o = t.group;
    if (!Be.areEquivalent(e.data.structure, a)) return !1;
    var s = Un.get(a).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, m = e.elements; d < m.length; d++)
      if ((D = m[d]).unitA === D.unitB) {
        var p = o.unitIndexMap.get(D.unitA.id);
        if (p !== void 0) {
          var v = c.getDirectedEdgeIndex(D.indexA, D.indexB);
          v !== -1 && n(oe.ofSingleton(p * l + v)) && (i = !0);
        }
      }
  } else if (Se.is(e)) {
    if (a = t.structure, o = t.group, !Be.areEquivalent(e.structure, a) || !(s = Un.get(a).value)) return !1;
    u = o.units[0];
    for (var f = s.unitsContacts.get(u.id), y = s.unitsFeatures.get(u.id), h = 2 * f.edgeCount, g = f.offset, x = y.elementsIndex, C = x.offsets, b = x.indices, _ = y.members, A = y.offsets, I = function(T) {
      var P = o.unitIndexMap.get(T.unit.id);
      if (P === void 0) return "continue";
      ve.forEach(T.indices, function(M) {
        for (var R = C[M], O = C[M + 1]; R < O; ++R) for (var L = b[R], F = g[L], G = g[L + 1]; F < G; ++F) h2.add(F);
      }), h2.forEach(function(M) {
        if (r) {
          for (var R = f.a[M], O = A[R], L = A[R + 1]; O < L; ++O) if (!ve.has(T.indices, _[O])) return;
          var F = f.b[M];
          for (O = A[F], L = A[F + 1]; O < L; ++O) if (!ve.has(T.indices, _[O])) return;
        }
        n(oe.ofSingleton(P * h + M)) && (i = !0);
      }), h2.clear();
    }, w = 0, E = e.elements; w < E.length; w++) {
      var D;
      I(D = E[w]);
    }
  }
  return i;
}
function cH(e) {
  var t = e.structure, n = e.group, r = n.units[0], i = Un.get(t).value, a = i.unitsContacts.get(r.id), o = 2 * a.edgeCount, s = n.units.length, u = ws.Location(i, t), c = u.element;
  return Zn(o, s, 1, function(l, d) {
    var m = n.units[d];
    return c.unitA = m, c.indexA = a.a[l], c.unitB = m, c.indexB = a.b[l], u;
  });
}
function lH(e, t, n, r, i) {
  if (!t.hasAtomic) return ht.createEmpty(i);
  var a = Ne.create(t), o = Un.get(t).value, s = o.contacts, u = o.unitsFeatures, c = s.edgeCount, l = s.edges, d = r.sizeFactor;
  if (!c) return ht.createEmpty(i);
  var m = t.child, p = { linkCount: c, position: function(x, C, b) {
    var _ = l[b], A = _.unitA, I = _.indexA, w = _.unitB, E = _.indexB, D = u.get(A), T = u.get(w), P = t.unitMap.get(A), M = t.unitMap.get(w);
    S.set(x, D.x[I], D.y[I], D.z[I]), S.transformMat4(x, x, P.conformation.operator.matrix), S.set(C, T.x[E], T.y[E], T.z[E]), S.transformMat4(C, C, M.conformation.operator.matrix);
  }, style: function(x) {
    return 1;
  }, radius: function(x) {
    var C = l[x], b = u.get(C.unitA);
    a.unit = t.unitMap.get(C.unitA), a.element = a.unit.elements[b.members[b.offsets[C.indexA]]];
    var _ = n.size.size(a), A = u.get(C.unitB);
    a.unit = t.unitMap.get(C.unitB), a.element = a.unit.elements[A.members[A.offsets[C.indexB]]];
    var I = n.size.size(a);
    return Math.min(_, I) * d;
  }, ignore: function(x) {
    if (l[x].props.flag === Pi.Filtered) return !0;
    if (m) {
      var C = l[x], b = m.unitMap.get(C.unitA);
      if (!b) return !0;
      for (var _ = t.unitMap.get(C.unitA), A = u.get(C.unitA), I = A.offsets, w = A.members, E = I[C.indexA], D = I[C.indexA + 1]; E < D; ++E) {
        var T = _.elements[w[E]];
        if (!_e.has(b.elements, T)) return !0;
      }
    }
    return !1;
  } }, v = q0(0, p, r, i), f = v.mesh, y = v.boundingSphere;
  if (y) f.setBoundingSphere(y);
  else if (f.triangleCount > 0) {
    var h = t.child, g = de.expand(de(), (h ?? t).boundary.sphere, 1 * d);
    f.setBoundingSphere(g);
  }
  return f;
}
var _A = B(B(B({}, US), H0), { sizeFactor: N.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: N.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: N.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: N.Boolean(!1) });
function dH(e) {
  return HS({ defaultProps: N.getDefaultValues(_A), createGeometry: lH, createLocationIterator: pH, getLoci: fH, eachLocation: mH, setUpdateState: function(t, n, r, i, a, o, s) {
    t.createGeometry = n.sizeFactor !== r.sizeFactor || n.dashCount !== r.dashCount || n.dashScale !== r.dashScale || n.dashCap !== r.dashCap || n.radialSegments !== r.radialSegments;
    var u = Un.get(o).version;
    t.info.interactionsHash !== u && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = u);
  } }, e);
}
function fH(e, t, n) {
  var r = e.objectId, i = e.groupId;
  if (n === r) {
    var a = Un.get(t).value, o = a.contacts.edges[i], s = t.unitMap.get(o.unitA), u = t.unitMap.get(o.unitB);
    return ws.Loci(t, a, [{ unitA: s, indexA: o.indexA, unitB: u, indexB: o.indexB }, { unitA: u, indexA: o.indexB, unitB: s, indexB: o.indexA }]);
  }
  return Sn;
}
var um = /* @__PURE__ */ new Map(), v2 = /* @__PURE__ */ new Set();
function mH(e, t, n, r) {
  var i = !1;
  if (ws.isLoci(e)) {
    if (!Be.areEquivalent(e.data.structure, t)) return !1;
    var a = Un.get(t).value;
    if (e.data.interactions !== a) return !1;
    for (var o = a.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 && n(oe.ofSingleton(l)) && (i = !0);
    }
  } else if (Se.is(e)) {
    if (!Be.areEquivalent(e.structure, t) || r && e.elements.length === 1 || !(a = Un.get(t).value)) return !1;
    for (var d = a.contacts, m = a.unitsFeatures, p = 0, v = e.elements; p < v.length; p++) {
      var f = v[p];
      um.set(f.unit.id, f.indices);
    }
    for (var y = function(x) {
      var C = x.unit;
      if (!me.isAtomic(C)) return "continue";
      ve.forEach(x.indices, function(b) {
        for (var _ = 0, A = d.getContactIndicesForElement(b, C); _ < A.length; _++) {
          var I = A[_];
          v2.add(I);
        }
      });
    }, h = 0, g = e.elements; h < g.length; h++)
      y(f = g[h]);
    v2.forEach(function(x) {
      if (r) {
        var C = d.edges[x], b = C.indexA, _ = C.unitA, A = C.indexB, I = C.unitB, w = um.get(_), E = um.get(I);
        if (!w || !E) return;
        for (var D = m.get(_), T = D.offsets, P = D.members, M = T[b], R = T[b + 1]; M < R; ++M) if (!ve.has(w, P[M])) return;
        var O = m.get(I), L = O.offsets, F = O.members;
        for (M = L[A], R = L[A + 1]; M < R; ++M) if (!ve.has(E, F[M])) return;
      }
      n(oe.ofSingleton(x)) && (i = !0);
    }), um.clear(), v2.clear();
  }
  return i;
}
function pH(e) {
  var t = Un.get(e).value, n = t.contacts, r = n.edgeCount, i = ws.Location(t, e), a = i.element;
  return Zn(r, 1, 1, function(o) {
    var s = n.edges[o];
    return a.unitA = e.unitMap.get(s.unitA), a.indexA = s.indexA, a.unitB = e.unitMap.get(s.unitB), a.indexB = s.indexB, i;
  }, !0);
}
var xA = { "intra-unit": function(e, t) {
  return ui("Intra-unit interactions cylinder", e, t, oH);
}, "inter-unit": function(e, t) {
  return Mc("Inter-unit interactions cylinder", e, t, dH);
} }, v8 = B(B(B({}, bA), _A), { unitKinds: jf(["atomic"]), sizeFactor: N.Numeric(0.15, { min: 0.01, max: 1, step: 0.01 }), visuals: N.MultiSelect(["intra-unit", "inter-unit"], N.objectToOptions(xA)) }), Dd, ws, ml = { name: "interactions", label: "Non-covalent Interactions", description: "Displays non-covalent interactions as dashed cylinders.", factory: function(e, t) {
  return Mt.createMulti("Interactions", e, t, ia, xA);
}, getParams: function(e, t) {
  return N.clone(v8);
}, defaultValues: N.getDefaultValues(v8), defaultColorTheme: { name: "interaction-type" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0 && Un.isApplicable(e);
}, ensureCustomProperties: { attach: function(e, t) {
  return Un.attach(e, t, void 0, !0);
}, detach: function(e) {
  return Un.ref(e, !1);
} }, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, g2 = { createOrUpdateInCellItems: function(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s, u;
    return ne(this, function(c) {
      switch (c.label) {
        case 0:
          return a = Cm(e, t).structure, o = B(B({}, Un.defaultParams), { type: n }), r && (o.providers.defaultValue = r), [4, Un.attach({ runtime: Ji, assetManager: new ds() }, a, o)];
        case 1:
          return c.sent(), t.managers.cell.traverse(function(l, d) {
            var m;
            d.type === fe.IntraInteractions && (s = l.ref, d.state && ((m = t.canvas3d) === null || m === void 0 || m.remove(d.state), d.state.destroy())), d.type === fe.BetweenInteractions && t.managers.cell.remove([{ ref: l.ref }]);
          }), (u = ml.factory(t.managers.representation.ctx, ml.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: a }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: a }) }), [4, u.createOrUpdate({}, a).run()];
        case 2:
          return c.sent(), [2, { representation: u, structure: a, ref: s }];
      }
    });
  });
}, createOrUpdateBetweenCellItems: function(e, t, n, r, i) {
  return ie(this, 0, void 0, function() {
    var a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _;
    return ne(this, function(A) {
      switch (A.label) {
        case 0:
          for (a = Cm(Pe(Pe([], e, !0), t, !0), n), o = a.unitsMap, s = a.structure, u = B({}, Un.defaultParams), r && (u.providers.defaultValue = r), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), f = 0, d = e.length; f < d; f++) o.get(f).forEach(function(I) {
            return c.add(I);
          });
          for (f = 0, d = t.length; f < d; f++) o.get(f + e.length).forEach(function(I) {
            return l.add(I);
          });
          return [4, Un.attach({ runtime: Ji, assetManager: new ds() }, s, u)];
        case 1:
          if (A.sent(), !s.state.propertyData.molstar_computed_interactions) return [2, {}];
          for (m = s.state.propertyData.molstar_computed_interactions.data.value, p = m.contacts, v = m.unitsFeatures, f = 0, y = p.edgeCount; f < y; ++f) h = p.edges[f], g = s.unitMap.get(h.unitA), x = s.unitMap.get(h.unitB), nn.Info(s, g, v.get(h.unitA)).feature = h.indexA, nn.Info(s, x, v.get(h.unitB)).feature = h.indexB, c.has(h.unitA) && l.has(h.unitB) || l.has(h.unitA) && c.has(h.unitB) || (p.edges[f].props.flag = Pi.Filtered);
          return b = [], n.managers.cell.traverse(function(I, w) {
            var E;
            w.type === fe.BetweenInteractions && (C = I.ref, w.state && ((E = n.canvas3d) === null || E === void 0 || E.remove(w.state), w.state.destroy())), w.type === fe.IntraInteractions && b.push({ ref: I.ref });
          }), [4, n.managers.cell.remove(b)];
        case 2:
          return A.sent(), (_ = ml.factory(n.managers.representation.ctx, ml.getParams)).setTheme({ color: n.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: s }), size: n.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: s }) }), [4, _.createOrUpdate({ visuals: ["inter-unit"] }, s).run()];
        case 3:
          return A.sent(), [2, { representation: _, structure: s, ref: C }];
      }
    });
  });
}, createOrUpdateGlobal: function(e, t, n, r, i, a) {
  return ie(this, 0, void 0, function() {
    var o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L, F;
    return ne(this, function(G) {
      switch (G.label) {
        case 0:
          o = /* @__PURE__ */ new Map(), s = [], u = 0, c = [], Mg(Ql).forEach(function(V) {
            var U = (r ?? T.providers.defaultValue)[V], q = U.name, H = U.params;
            q === "on" && c.push(Ql[V].createTester(H));
          }), l = /* @__PURE__ */ new Set(), c.forEach(function(V) {
            return Ii.add(l, V.requiredFeatures);
          }), d = SA.filter(function(V) {
            return Ii.areIntersecting(l, V.types);
          }), w = 0, E = e.length, G.label = 1;
        case 1:
          return w < E ? (m = e[w], (p = t.cells.get(m.ref)) ? (v = m.elementIds ? Xn(un(p), m.elementIds) : un(p), [4, Hf.attach({ runtime: Ji, assetManager: new ds() }, v)]) : [3, 3]) : [3, 4];
        case 2:
          for (G.sent(), v.currentPropertyData.molstar_computed_valence_model.data.value.forEach(function(V) {
            o.set(u, V), u++;
          }), f = 0, y = v.units.length; f < y; f++) h = AA(v, v.units[f], d), s.push(h);
          G.label = 3;
        case 3:
          return w++, [3, 1];
        case 4:
          for (g = Cm(e, t), x = g.unitsMap, C = g.structure, b = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), I = function(V, U) {
            A.set(e[V].ref, /* @__PURE__ */ new Set());
            var q = x.get(V), H = t.cells.get(e[V].ref);
            if (H) {
              var K = un(H).units;
              q.forEach(function(j, W) {
                b.set(j, e[V].ref), K && K[W] && _.set("".concat(e[V].ref, "_").concat(K[W].invariantId), j);
              });
            }
          }, w = 0, E = e.length; w < E; w++) I(w);
          return Object.assign(C.currentPropertyData, { molstar_computed_valence_model: { props: { assignCharge: "auto", assignH: "auto" }, data: { id: 3224, version: 1, value: o } } }), D = /* @__PURE__ */ new Set(), a == null || a.map(function(V) {
            var U = V.ref, q = V.elementIds, H = t.cells.get(U);
            H && un(H).units.forEach(function(K) {
              K.elements.filter(function(j) {
                return q == null ? void 0 : q.includes(j);
              }).forEach(function(j) {
                return D.add("".concat(_.get("".concat(U, "_").concat(K.invariantId)), "_").concat(j));
              });
            });
          }), T = B(B({}, Un.defaultParams), { type: n, featuresList: s, filterKeys: a ? Array.from(D.values()) : void 0 }), r && (T.providers.defaultValue = r), [4, Un.attach({ runtime: Ji, assetManager: new ds() }, C, T)];
        case 5:
          return G.sent(), P = C.state.propertyData.molstar_computed_interactions.data.value, M = P.contacts, R = P.unitsContacts, O = P.unitsFeatures, M.edges.forEach(function(V) {
            var U = V.indexA, q = V.indexB, H = V.unitA, K = V.unitB, j = V.props.flag, W = O.get(H), Z = W.members, Y = W.offsets, te = O.get(K), ee = te.members, $ = te.offsets;
            if (j !== Pi.Filtered) {
              var ue = C.unitMap.get(H).elements[Z[Y[U]]], se = C.unitMap.get(K).elements[ee[$[q]]];
              A.get(b.get(H)).add(ue), A.get(b.get(K)).add(se);
            }
          }), Array.from(R.entries()).forEach(function(V) {
            for (var U = V[0], q = V[1], H = O.get(U), K = H.members, j = H.offsets, W = q.a, Z = q.b, Y = 0, te = W.length; Y < te; Y++) {
              var ee = C.unitMap.get(U).elements[K[j[W[Y]]]], $ = C.unitMap.get(U).elements[K[j[Z[Y]]]];
              A.get(b.get(U)).add(ee), A.get(b.get(U)).add($);
            }
          }), t.managers.cell.traverse(function(V, U) {
            var q;
            U.type === fe.IntraInteractions && (L = V.ref, U.state && ((q = t.canvas3d) === null || q === void 0 || q.remove(U.state), U.state.destroy()));
          }), (F = ml.factory(t.managers.representation.ctx, ml.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: C }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: C }) }), [4, F.createOrUpdate({}, C).run()];
        case 6:
          return G.sent(), [2, { representation: F, structure: C, ref: L, interactionElementIds: Array.from(A.keys()).map(function(V) {
            return { ref: V, elementIds: Array.from(A.get(V).values()) };
          }).filter(function(V) {
            return V.elementIds.length;
          }) }];
      }
    });
  });
} };
(function(e) {
  function t(i, a) {
    var o = a.unitA, s = a.indexA, u = a.unitB, c = a.indexB, l = i.contacts, d = i.unitsContacts;
    if (o === u) {
      var m = d.get(o.id), p = m.getDirectedEdgeIndex(s, c);
      return Uv(m.edgeProps.type[p]);
    }
    return p = l.getEdgeIndex(s, o.id, c, u.id), Uv(l.edges[p].props.type);
  }
  function n(i, a, o) {
    var s = i.unitsFeatures;
    return Ml.fromPairProvider(a.length, function(u, c, l) {
      var d = a[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 r(i, a, o) {
    var s = o[0];
    if (s === void 0) return "";
    var u = s.unitA, c = s.indexA, l = s.unitB, d = s.indexB, m = a.unitsFeatures, p = m.get(u.id), v = p.members, f = p.offsets, y = m.get(l.id), h = y.members, g = y.offsets, x = { granularity: "element" };
    return (f[c + 1] - f[c] > 1 || g[d + 1] - g[d] > 1) && (x.granularity = "residue"), [t(a, s), wC(rt.Location(i, u, v[f[c]], i, l, h[g[d]]), x)].join("</br>");
  }
  e.Location = function(i, a, o, s, u, c) {
    return { kind: "data-location", tag: "interactions", data: { structure: a, interactions: i }, element: { unitA: o, indexA: s, unitB: u, indexB: c } };
  }, e.isLocation = function(i) {
    return !!i && i.kind === "data-location" && i.tag === "interactions";
  }, e.areLocationsEqual = function(i, a) {
    return i.data.structure === a.data.structure && i.data.interactions === a.data.interactions && i.element.indexA === a.element.indexA && i.element.indexB === a.element.indexB && i.element.unitA === a.element.unitA && i.element.unitB === a.element.unitB;
  }, e.locationLabel = function(i) {
    return t(i.data.interactions, i.element);
  }, e.Loci = function(i, a, o) {
    return r3("interactions", { structure: i, interactions: a }, o, function(s) {
      return n(a, o, s);
    }, function() {
      return r(i, a, o);
    });
  }, e.isLoci = function(i) {
    return !!i && i.kind === "data-loci" && i.tag === "interactions";
  }, e.getBoundingSphere = n, e.getLabel = r;
})(ws || (ws = {}));
var SA = [dN, fN, mN, EN, TN, MN, _N, xN, JU, FN, GN], Ql = { ionic: DN, "pi-stacking": BN, "cation-pi": RN, "halogen-bonds": SN, "hydrogen-bonds": pN, "weak-hydrogen-bonds": hN, hydrophobic: $U, "metal-coordination": VN }, hH = function(e) {
  e === void 0 && (e = []);
  var t = /* @__PURE__ */ Object.create(null);
  return Object.keys(Ql).forEach(function(n) {
    t[n] = N.MappedStatic(e.includes(n) ? "on" : "off", { on: N.Group(Ql[n].params), off: N.Group({}) }, { cycle: !0 });
  }), t;
}(["ionic", "cation-pi", "pi-stacking", "hydrogen-bonds", "halogen-bonds", "metal-coordination", "weak-hydrogen-bonds"]), vH = ((Dd = {})[Kr.LigandReceptor] = {}, Dd[Kr.IntraLigand] = {}, Dd[Kr.IntraReceptor] = {}, Dd[Kr.All] = {}, Dd), gH = Object.keys(vH), yH = N.arrayToOptions(gH), CA = { providers: N.Group(hH, { isFlat: !0 }), contacts: N.Group(jU, { label: "Advanced Options" }), type: N.Select(Kr.LigandReceptor, yH, { isEssential: !0, description: "Visual/rendering quality of the representation." }), featuresList: N.Value([], { isHidden: !0 }), filterKeys: N.Value(void 0, { isHidden: !0 }) };
function bH(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D;
    return ne(this, function(T) {
      switch (T.label) {
        case 0:
          r = B(B({}, N.getDefaultValues(CA)), n), i = r.type, a = r.featuresList, o = r.filterKeys, s = new Set(o), u = mS(t).data, c = u.ligand, l = u.other, d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), Object.keys(c).forEach(function(P) {
            Object.keys(c[P]).forEach(function(M) {
              c[P][M].forEach(function(R) {
                d.add(R.unitId), m.add("".concat(R.unitId, "_").concat(R.elementId));
              });
            });
          }), Object.keys(l).forEach(function(P) {
            Object.keys(l[P]).forEach(function(M) {
              l[P][M].forEach(function(R) {
                d.add(R.unitId), m.add("".concat(R.unitId, "_").concat(R.elementId));
              });
            });
          }), p = [], Mg(Ql).forEach(function(P) {
            var M = r.providers[P], R = M.name, O = M.params;
            R === "on" && p.push(Ql[P].createTester(i === Kr.All && ["hydrogen-bonds", "weak-hydrogen-bonds"].includes(P) ? B(B({}, O), { water: !0 }) : O));
          }), v = /* @__PURE__ */ new Set(), p.forEach(function(P) {
            return Ii.add(v, P.requiredFeatures);
          }), f = SA.filter(function(P) {
            return Ii.areIntersecting(v, P.types);
          }), y = Ro.Mutable(), h = Ro.Mutable(), g = 0, x = t.unitSymmetryGroups.length, T.label = 1;
        case 1:
          return g < x ? (C = t.unitSymmetryGroups[g], e.runtime.shouldUpdate ? [4, e.runtime.update({ message: "computing interactions", current: g, max: x })] : [3, 3]) : [3, 5];
        case 2:
          T.sent(), T.label = 3;
        case 3:
          for (b = a && a[g] ? a[g] : AA(t, C.units[0], f), _ = function(P, M, R, O, L, F) {
            var G = bg.create(R, M.elements.length);
            return me.isAtomic(M) && function(V, U, q, H, K, j, W) {
              for (var Z = 0, Y = K; Z < Y.length; Z++) WU(V, U, q, H, Y[Z], 0, W);
            }(P, M, R, G, O, 0, F), G.getContacts();
          }(t, C.units[0], b, p, r.contacts, function(P, M, R, O) {
            return !!(!o || s.has("".concat(P.invariantId, "_").concat(M)) && s.has("".concat(R.invariantId, "_").concat(O))) && i !== Kr.IntraReceptor && (i === Kr.All || ["".concat(P.invariantId, "_").concat(M), "".concat(R.invariantId, "_").concat(O)].filter(function(L) {
              return m.has(L);
            }).length === (i === Kr.LigandReceptor ? 1 : 2));
          }), A = 0, I = C.units.length; A < I; ++A) w = C.units[A], y.set(w.id, b), h.set(w.id, _);
          T.label = 4;
        case 4:
          return ++g, [3, 1];
        case 5:
          return E = function(P, M, R, O, L) {
            var F = _g.create();
            return Be.eachUnitPair(P, function(G, V) {
              var U = M.get(G.id), q = M.get(V.id);
              (function(H, K, j, W, Z, Y, te, ee, $) {
                var ue = j.count, se = j.x, be = j.y, ke = j.z, Oe = Z.lookup3d, ze = J.mul(ZU, W.conformation.operator.inverse, K.conformation.operator.matrix), je = !J.isIdentity(ze), xe = S(), Xe = Math.max.apply(Math, te.map(function(Kt) {
                  return Kt.maxDistance;
                })), Ee = Oe.boundary.sphere, Ye = Ee.center, He = Ee.radius, le = (He + Xe) * (He + Xe), Ce = ee.lineOfSightDistFactor, Ae = nn.Info(H, K, j), Te = nn.Info(H, W, Z);
                Y.startUnitPair(K, W);
                for (var Re = 0; Re < ue; ++Re) if (S.set(xe, se[Re], be[Re], ke[Re]), je && S.transformMat4(xe, xe, ze), !(S.squaredDistance(xe, Ye) > le)) {
                  var we = Oe.find(xe[0], xe[1], xe[2], Xe), Qe = we.indices, Je = we.count, lt = we.squaredDistances;
                  if (Je !== 0) {
                    Ae.feature = Re;
                    for (var st = 0; st < Je; ++st) {
                      var ft = Qe[st];
                      if (Te.feature = ft, (!$ || $(Ae.unit, Ae.unit.elements[Ae.members[Ae.offsets[Re]]], Te.unit, Te.unit.elements[Te.members[Te.offsets[ft]]])) && yA(H, Ae, Te)) for (var It = lt[st], pe = 0, We = te; pe < We.length; pe++) {
                        var gt = We[pe];
                        if (It < gt.maxDistance * gt.maxDistance) {
                          var cn = gt.getType(H, Ae, Te, It);
                          if (cn && YU(H, Ae, Te, Ce)) {
                            Y.add(Re, ft, cn);
                            break;
                          }
                        }
                      }
                    }
                  }
                }
                Y.finishUnitPair();
              })(P, G, U, V, q, F, R, O, L == null ? void 0 : L.elementIdFilter);
            }, { maxRadius: Math.max.apply(Math, R.map(function(G) {
              return G.maxDistance;
            })), validUnit: function(G) {
              return me.isAtomic(G);
            }, validUnitPair: function(G, V) {
              return Be.validUnitPair(P, G, V) && (!(L != null && L.unitFilter) || L.unitFilter(G, V));
            } }), F.getContacts(M);
          }(t, y, p, r.contacts, { unitFilter: function(P, M) {
            return i === Kr.LigandReceptor ? [P.invariantId, M.invariantId].filter(function(R) {
              return d.has(R);
            }).length >= 1 : i !== Kr.IntraLigand || [P.invariantId, M.invariantId].filter(function(R) {
              return d.has(R);
            }).length === 2;
          }, elementIdFilter: function(P, M, R, O) {
            return !!(!o || s.has("".concat(P.invariantId, "_").concat(M)) && s.has("".concat(R.invariantId, "_").concat(O))) && (i === Kr.All || ["".concat(P.invariantId, "_").concat(M), "".concat(R.invariantId, "_").concat(O)].filter(function(L) {
              return m.has(L);
            }).length === (i === Kr.LigandReceptor ? 1 : i === Kr.IntraReceptor ? 0 : 2));
          } }), function(P, M) {
            for (var R = M.contacts, O = M.unitsContacts, L = M.unitsFeatures, F = [eH(0, M), tH(0, M), nH(0, M), rH(0, M), iH(0, M)], G = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), q = 0, H = R.edgeCount; q < H; ++q) {
              var K = R.edges[q], j = P.unitMap.get(K.unitA), W = P.unitMap.get(K.unitB);
              if ((xe = nn.Info(P, j, L.get(K.unitA))).feature = K.indexA, (Xe = nn.Info(P, W, L.get(K.unitB))).feature = K.indexB, K.props.type === 5) {
                for (var Z = [], Y = (He = xe.types[xe.feature] === 5 ? xe : Xe).offsets[He.feature], te = He.offsets[He.feature + 1]; Y < te; Y++) Z.push(He.members[Y]);
                Z.length > 1 && V.set(q, Z), Z.length === 1 && G.add(Z[0]);
              }
              if (O.size) for (var ee = 0, $ = F; ee < $.length; ee++) (Ae = $[ee]).isApplicable(K.props.type) && Ae.handleInterContact(q, xe, Xe);
            }
            for (var ue = O.keys(); ; ) {
              var se = ue.next(), be = se.done, ke = se.value;
              if (be) break;
              var Oe = O.get(ke), ze = L.get(ke), je = P.unitMap.get(ke);
              if (me.isAtomic(je)) {
                for (var xe = nn.Info(P, je, ze), Xe = nn.Info(P, je, ze), Ee = 0, Ye = F; Ee < Ye.length; Ee++) (Ae = Ye[Ee]).startUnit(je, Oe, ze);
                for (q = 0, H = 2 * Oe.edgeCount; q < H; ++q) {
                  if (xe.feature = Oe.a[q], Xe.feature = Oe.b[q], Oe.edgeProps.type[q] === 5) {
                    var He;
                    for (Z = [], Y = (He = xe.types[xe.feature] === 5 ? xe : Xe).offsets[He.feature], te = He.offsets[He.feature + 1]; Y < te; Y++) Z.push(He.members[Y]);
                    Z.length > 1 && U.set(q, { elements: Z, value: ke }), Z.length === 1 && G.add(Z[0]);
                  }
                  for (var le = 0, Ce = F; le < Ce.length; le++) {
                    var Ae;
                    (Ae = Ce[le]).isApplicable(Oe.edgeProps.type[q]) && Ae.handleIntraContact(q, xe, Xe);
                  }
                }
              }
            }
            V.forEach(function(Te, Re) {
              Te.filter(function(we) {
                return G.has(we);
              }).length > 0 && (R.edges[Re].props.flag = Pi.Filtered);
            }), U.forEach(function(Te, Re) {
              var we = Te.elements, Qe = Te.value;
              we.filter(function(Je) {
                return G.has(Je);
              }).length > 0 && (O.get(Qe).edgeProps.flag[Re] = Pi.Filtered);
            });
          }(t, D = { unitsFeatures: y, unitsContacts: h, contacts: E }), [2, D];
      }
    });
  });
}
function AA(e, t, n) {
  var r = t.elements.length, i = Vv.create(r, r / 2);
  if (me.isAtomic(t)) for (var a = 0, o = n; a < o.length; a++)
    o[a].add(e, t, i);
  return i.getFeatures(r);
}
var y2 = B({}, CA), Un = Rl.createProvider({ label: "Interactions", descriptor: no({ name: "molstar_computed_interactions" }), type: "local", defaultParams: y2, getParams: function(e) {
  return y2;
}, isApplicable: function(e) {
  return !e.isCoarseGrained;
}, obtain: function(e, t, n) {
  return ie(void 0, 0, void 0, function() {
    var r, i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return r = B(B({}, N.getDefaultValues(y2)), n), i = {}, [4, bH(e, t, r)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} }), xg = ye(13421772), si = { HydrogenBond: 16751667, Hydrophobic: 8421504, HalogenBond: 6154474, Ionic: 15820019, MetalCoordination: 11646163, CationPi: 3392621, PiStacking: 4436985, WeakHydrogenBond: 16771231 }, _H = [["Hydrogen Bond", si.HydrogenBond], ["Hydrophobic", si.Hydrophobic], ["Halogen Bond", si.HalogenBond], ["Ionic", si.Ionic], ["Metal Coordination", si.MetalCoordination], ["Cation Pi", si.CationPi], ["Pi Stacking", si.PiStacking], ["Weak HydrogenBond", si.WeakHydrogenBond]];
function g8(e) {
  switch (e) {
    case Lt.HydrogenBond:
      return si.HydrogenBond;
    case Lt.Hydrophobic:
      return si.Hydrophobic;
    case Lt.HalogenBond:
      return si.HalogenBond;
    case Lt.Ionic:
      return si.Ionic;
    case Lt.MetalCoordination:
      return si.MetalCoordination;
    case Lt.CationPi:
      return si.CationPi;
    case Lt.PiStacking:
      return si.PiStacking;
    case Lt.WeakHydrogenBond:
      return si.WeakHydrogenBond;
    case Lt.Unknown:
      return xg;
  }
}
var y8 = {}, Bd, Js, Rd, Ju, cm, xH = { name: "interaction-type", label: "Interaction Type", category: "Miscellaneous", factory: function e(t, n) {
  var r, i = t.structure ? Un.get(t.structure) : void 0, a = i ? $l(i.id, i.version) : -1;
  return r = i && i.value ? function(o) {
    if (ws.isLocation(o)) {
      var s = o.data.interactions, u = s.unitsContacts, c = s.contacts, l = o.element, d = l.unitA, m = l.unitB, p = l.indexA, v = l.indexB;
      if (d === m) {
        var f = u.get(d.id), y = f.getDirectedEdgeIndex(p, v);
        return g8(f.edgeProps.type[y]);
      }
      return y = c.getEdgeIndex(p, d.id, v, m.id), g8(c.edges[y].props.type);
    }
    return xg;
  } : function() {
    return xg;
  }, { factory: e, granularity: "group", color: r, props: n, contextHash: a, description: "Assigns colors according the interaction type of a link.", legend: io(_H) };
}, getParams: function(e) {
  return y8;
}, defaultValues: N.getDefaultValues(y8), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? Un.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && Un.ref(e.structure, !1);
} } }, Sg = { color: (Bd = {}, Bd[tt.ATOM] = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: ye(14474728) } } } }, Bd[tt.RIBBON] = { name: "uniform", props: { value: ye(14474728) } }, Bd[tt.SURFACE] = { name: "uniform" }, Bd), size: (Js = {}, Js[fe.BallAndStick] = { name: "physical" }, Js[fe.Stick] = { name: "uniform" }, Js[fe.Line] = { name: "physical" }, Js[fe.CPK] = { name: "physical" }, Js[fe.Ribbon] = { name: "uniform" }, Js[fe.Surface] = { name: "physical" }, Js), transparency: (Rd = {}, Rd[tt.ATOM] = 0, Rd[tt.RIBBON] = 0, Rd[tt.SURFACE] = 0, Rd) }, b2 = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: ye(4777267) } } } }, SH = function() {
  function e(t, n) {
    this.plugin = t, this.defaultTheme = B(B({}, Sg), n);
  }
  return e.prototype.createColorTheme = function(t, n, r) {
    var i, a, o, s, u, c = this;
    return t.name === "multi-theme" ? (i = this.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("multi-theme", { structure: n }, { themes: (s = !((o = (a = t.props) === null || a === void 0 ? void 0 : a.themes) === null || o === void 0) && o.length ? t.props.themes : [this.defaultTheme.color[r]]) === null || s === void 0 ? void 0 : s.map(function(l) {
      return { colorTheme: c.createColorTheme(l, l.elementIds ? Xn(n, l.elementIds) : n, r), bundle: Ci.fromLoci(Yn(n, l.elementIds)) };
    }) }) : (u = this.ctx) === null || u === void 0 ? void 0 : u.colorThemeRegistry.create(t.name, { structure: t.elementIds ? Xn(n, t.elementIds) : n }, t.props);
  }, e.prototype.createTheme = function(t, n, r) {
    var i = Object.keys(In).find(function(s) {
      return In[s].includes(t);
    }), a = r != null && r.color ? r == null ? void 0 : r.color : this.defaultTheme.color[i], o = r != null && r.size ? r == null ? void 0 : r.size : this.defaultTheme.size[t];
    return { color: this.createColorTheme(a, n, i), size: this.ctx.sizeThemeRegistry.create(o.name, { structure: n }, o.props) };
  }, e.prototype.createTransparencyLayers = function(t, n) {
    if (!(n != null && n.length)) return { kind: "empty-loci", layers: [] };
    var r = n.map(function(i) {
      var a = i.elementIds, o = i.value;
      return { loci: Yn(t, a), value: o !== void 0 ? 1 - o : 0 };
    });
    return { kind: "element-loci", layers: r };
  }, e.prototype.setColorTheme = function(t, n, r) {
    var i = this;
    t.forEach(function(a) {
      var o, s, u, c, l = a.ref, d = a.elementIds, m = i.plugin.cells.get(l);
      if (!(m != null && m.model.structure) && (m != null && m.representations.has(fe.Surface))) {
        if (r !== tt.SURFACE) return;
        var p = Se.toStructure(Yr(m.representations.get(fe.Surface).state.getLoci())), v = $i(p);
        return m.theme.color = ((o = { Atom: [], Ribbon: [] })[tt.SURFACE] = [B({ elementIds: v }, n)], o), void Im[fe.Surface].update((u = m == null ? void 0 : m.representations.get(fe.Surface)) === null || u === void 0 ? void 0 : u.state, p, i.ctx, i.createTheme(fe.Surface, p, { color: n }));
      }
      var f = Pe([], d ?? [], !0);
      d || f.push.apply(f, wr(Be.toStructureElementLoci(un(m))));
      var y = new Set(f);
      m && (m.theme.color ? (!((c = m.theme.color[r]) === null || c === void 0) && c.length && (m.theme.color[r].forEach(function(h, g) {
        m.theme.color[r][g].elementIds = m.theme.color[r][g].elementIds.filter(function(x) {
          return !y.has(x);
        });
      }), m.theme.color[r] = m.theme.color[r].filter(function(h) {
        var g = h.elementIds;
        return g == null ? void 0 : g.length;
      })), m.theme.color[r].push(B({ elementIds: Array.from(y.values()) }, n))) : m.theme.color = ((s = { Atom: [], Ribbon: [], Surface: [] })[r] = [B({ elementIds: Array.from(y.values()) }, n)], s), In[r].forEach(function(h) {
        var g, x = m.representations.get(h);
        if (x) {
          var C = Li(x.state);
          wa[h].update(x.state, C, i.ctx, { color: i.ctx.colorThemeRegistry.create("multi-theme", { structure: C }, { themes: (g = m.theme.color[r]) === null || g === void 0 ? void 0 : g.map(function(b) {
            return { colorTheme: i.createColorTheme(b, C, r), bundle: Ci.fromLoci(Yn(C, b.elementIds)) };
          }) }), size: x.state.theme.size });
        }
      }));
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setTransparency = function(t, n, r) {
    var i = this, a = /* @__PURE__ */ new Set();
    t.forEach(function(s) {
      var u, c, l, d, m = s.ref, p = s.elementIds, v = i.plugin.cells.get(m);
      if (!(v != null && v.model.structure) && (v != null && v.representations.has(fe.Surface))) {
        if (r !== tt.SURFACE) return;
        var f = Se.toStructure(Yr(v.representations.get(fe.Surface).state.getLoci())), y = $i(f);
        return v.theme.transparency = ((u = {})[tt.SURFACE] = [{ elementIds: y, value: n }], u), void ((l = v == null ? void 0 : v.representations.get(fe.Surface)) === null || l === void 0 || l.state.setState({ transparency: i.createTransparencyLayers(Li((d = v == null ? void 0 : v.representations.get(fe.Surface)) === null || d === void 0 ? void 0 : d.state), v == null ? void 0 : v.theme.transparency[r]) }));
      }
      var h = Pe([], p ?? [], !0);
      !p && v && (f = un(v)) && h.push.apply(h, wr(Be.toStructureElementLoci(f)));
      var g = new Set(h);
      if (v) if (a.add(m), v.theme.transparency) {
        var x = v.theme.transparency[r];
        x.length && (x.forEach(function(C, b) {
          C.elementIds, x[b].elementIds = h.filter(function(_) {
            return !g.has(_);
          });
        }), v.theme.transparency[r] = x.filter(function(C) {
          return C.elementIds, h.length;
        })), v.theme.transparency[r].push({ elementIds: Array.from(g.values()), value: n });
      } else v.theme.transparency = ((c = {})[tt.ATOM] = [], c[tt.RIBBON] = [], c[tt.SURFACE] = [], c[r] = { elementIds: Array.from(g.values()), value: n }, c);
    });
    var o = In[r];
    a.forEach(function(s) {
      var u = i.plugin.cells.get(s);
      o.forEach(function(c) {
        var l = u == null ? void 0 : u.representations.get(c);
        if (l) {
          var d = Li(l.state), m = i.createTransparencyLayers(d, u == null ? void 0 : u.theme.transparency[r]);
          l.state.setState({ transparency: m });
        }
      });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setDefaultTheme = function(t) {
    var n;
    this.defaultTheme = B(B(B({}, Sg), (n = this.defaultTheme) !== null && n !== void 0 ? n : {}), t);
  }, e;
}(), kd = [fe.BallAndStick, fe.Line, fe.Stick, fe.CPK], CH = function(e) {
  function t(n, r, i) {
    var a = e.call(this, n, r) || this;
    return a.ev = wi.create(), a.event = { interactionParamsUpdated: a.ev(), interactionUpdated: a.ev() }, a.plugin = n, a.type = Kr.LigandReceptor, a.interactionParams = B(B({}, i), qv()), a;
  }
  return Zr(t, e), t.prototype.showInteractionInCellItems = function(n, r, i, a) {
    var o;
    return ie(this, 0, void 0, function() {
      var s, u, c, l, d, m, p = this;
      return ne(this, function(v) {
        switch (v.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), a && Array.from(n.map(function(f) {
              return f.ref;
            })).forEach(function(f) {
              var y = p.plugin.cells.get(f);
              if (y) {
                var h = [];
                In[tt.ATOM].forEach(function(g) {
                  y.representations.has(g) && y.representations.get(g).state && h.push.apply(h, wr(Yr(y.representations.get(g).state.getLoci())));
                }), s.set(f, new Set(h));
              }
            }), u = a ? n.map(function(f) {
              var y, h, g = f.ref, x = f.elementIds, C = x ? x.filter(function(b) {
                var _;
                return (_ = s.get(g)) === null || _ === void 0 ? void 0 : _.has(b);
              }) : Array.from((h = (y = s.get(g)) === null || y === void 0 ? void 0 : y.values()) !== null && h !== void 0 ? h : []);
              return { ref: g, elementIds: C };
            }).filter(function(f) {
              return f.elementIds.length;
            }) : n, [4, g2.createOrUpdateInCellItems(u, this.plugin, r, this.interactionParams, i)];
          case 1:
            return c = v.sent(), l = c.representation, d = c.ref, m = { representations: [{ state: l, isHidden: !1, type: fe.IntraInteractions }], model: { other: null }, dependency: { on: n } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(l), d ? (this.plugin.managers.cell.update(d, m), [2, d]) : [2, this.plugin.managers.cell.create(m)];
        }
      });
    });
  }, t.prototype.showInteractionBetweenCellItems = function(n, r, i, a) {
    var o;
    return a === void 0 && (a = !1), ie(this, 0, void 0, function() {
      var s, u, c, l, d, m, p, v = this;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), a && Array.from(Pe(Pe([], n, !0), r, !0).map(function(y) {
              return y.ref;
            })).forEach(function(y) {
              var h = v.plugin.cells.get(y);
              if (h) {
                var g = [];
                In[tt.ATOM].forEach(function(x) {
                  h.representations.has(x) && h.representations.get(x).state && g.push.apply(g, wr(Yr(h.representations.get(x).state.getLoci())));
                }), s.set(y, new Set(g));
              }
            }), u = a ? n.map(function(y) {
              var h, g, x = y.ref, C = y.elementIds, b = C ? C.filter(function(_) {
                var A;
                return (A = s.get(x)) === null || A === void 0 ? void 0 : A.has(_);
              }) : Array.from((g = (h = s.get(x)) === null || h === void 0 ? void 0 : h.values()) !== null && g !== void 0 ? g : []);
              return { ref: x, elementIds: b };
            }).filter(function(y) {
              return y.elementIds.length;
            }) : n, c = a ? r.map(function(y) {
              var h, g, x = y.ref, C = y.elementIds, b = C ? C.filter(function(_) {
                var A;
                return (A = s.get(x)) === null || A === void 0 ? void 0 : A.has(_);
              }) : Array.from((g = (h = s.get(x)) === null || h === void 0 ? void 0 : h.values()) !== null && g !== void 0 ? g : []);
              return { ref: x, elementIds: b };
            }).filter(function(y) {
              return y.elementIds.length;
            }) : r, [4, g2.createOrUpdateBetweenCellItems(u, c, this.plugin, this.interactionParams, i)];
          case 1:
            return l = f.sent(), d = l.representation, m = l.ref, d ? (p = { representations: [{ state: d, isHidden: !1, type: fe.BetweenInteractions }], model: { other: { itemsA: u, itemsB: c } }, dependency: { on: u.concat(c) } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(d), m ? (this.plugin.managers.cell.update(m, p), [2]) : [2, this.plugin.managers.cell.create(p)]) : [2];
        }
      });
    });
  }, t.prototype.setInteractionParams = function(n, r) {
    var i = this, a = new Set(Object.keys(this.interactionParams).filter(function(s) {
      var u;
      return ((u = i.interactionParams[s]) === null || u === void 0 ? void 0 : u.name) === "on";
    }));
    if (this.type === r && n.length === a.size && n.every(function(s) {
      return a.has(s);
    })) return !1;
    this.type = r, this.interactionParams = qv(n);
    var o = !1;
    return this.plugin.managers.cell.traverse(function(s, u) {
      u.type === fe.IntraInteractions && (o = !0, i.showGlobalInteraction(void 0, "lightPlugin.managers.representation.interactions.setInteractionParams"));
    }), this.event.interactionParamsUpdated.next({ params: this.interactionParams, type: r }), o;
  }, t.prototype.showGlobalInteraction = function(n, r) {
    var i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C = this;
      return ne(this, function(b) {
        switch (b.label) {
          case 0:
            return a = /* @__PURE__ */ new Map(), o = BS(this.plugin), n && Array.from(o.map(function(_) {
              return _.ref;
            })).forEach(function(_) {
              var A = C.plugin.cells.get(_);
              if (A) {
                var I = [];
                In[tt.ATOM].forEach(function(w) {
                  A.representations.has(w) && A.representations.get(w).state && I.push.apply(I, wr(Yr(A.representations.get(w).state.getLoci())));
                }), a.set(_, new Set(I));
              }
            }), s = n ? o.map(function(_) {
              var A, I, w = _.ref, E = _.elementIds, D = E ? E.filter(function(T) {
                var P;
                return (P = a.get(w)) === null || P === void 0 ? void 0 : P.has(T);
              }) : Array.from((I = (A = a.get(w)) === null || A === void 0 ? void 0 : A.values()) !== null && I !== void 0 ? I : []);
              return { ref: w, elementIds: D };
            }).filter(function(_) {
              return _.elementIds.length;
            }) : void 0, [4, g2.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, m = { representations: [{ state: c, isHidden: !1, type: fe.IntraInteractions }], model: { other: { type: this.type } }, dependency: { on: o } }, (i = this.plugin.canvas3d) === null || i === void 0 || i.add(c), n) return [3, 5];
            p = [], v = {}, d.forEach(function(_) {
              var A, I = _.ref, w = _.elementIds, E = C.plugin.cells.get(I);
              if (E) {
                v[I] = ((A = {})[fe.BallAndStick] = /* @__PURE__ */ new Set(), A[fe.Line] = /* @__PURE__ */ new Set(), A[fe.Stick] = /* @__PURE__ */ new Set(), A[fe.CPK] = /* @__PURE__ */ new Set(), A);
                var D = new Set(w);
                kd.forEach(function(T) {
                  if (E.representations.has(T) && E.representations.get(T).state) {
                    var P = qf(E.representations.get(T).state);
                    v[I][T] = new Set(P), D.forEach(function(M) {
                      v[I][T].has(M) && D.delete(M);
                    });
                  }
                }), D.size && p.push({ ref: I, elementIds: Array.from(D.values()) });
              }
            }), (x = {})[fe.BallAndStick] = [], x[fe.Line] = [], x[fe.Stick] = [], x[fe.CPK] = [], f = x, p.forEach(function(_) {
              var A, I = _.ref, w = _.elementIds, E = ((A = {})[fe.BallAndStick] = [], A[fe.Line] = [], A[fe.Stick] = [], A[fe.CPK] = [], A), D = /* @__PURE__ */ new Map();
              if (w != null && w.length) {
                var T = C.plugin.managers.cell.get(I), P = un(T);
                if (P) {
                  var M = new Set(w), R = new Set(w.map(function(L) {
                    return f0(MS(P, L), on.Residue);
                  })), O = /* @__PURE__ */ new Map();
                  P.units.forEach(function(L) {
                    L.elements.forEach(function(F) {
                      var G = Fo(L, F), V = f0(G, on.Residue);
                      R.has(V) && (D.has(V) || D.set(V, /* @__PURE__ */ new Set()), (M.has(F) || G.typeSymbol !== "H" || z0(P, F) === sr.Polar) && O.set(V, Pe([F], O.has(V) ? O.get(V) : [], !0)), kd.some(function(U) {
                        var q, H;
                        !((q = v[I][U]) === null || q === void 0) && q.has(F) && ((H = D.get(V)) === null || H === void 0 || H.add(U));
                      }));
                    });
                  }), R.forEach(function(L) {
                    var F, G, V = D.get(L);
                    V && V.size !== 0 ? V.size > 0 && (G = E[Array.from(V.values())[0]]).push.apply(G, O.get(L)) : (F = E[fe.Stick]).push.apply(F, O.get(L));
                  }), kd.forEach(function(L) {
                    E[L].length && f[L].push({ ref: I, elementIds: E[L] });
                  });
                }
              }
            }), y = 0, h = kd.length, b.label = 2;
          case 2:
            return y < h ? (g = kd[y], f[g].length ? [4, this.plugin.managers.representation.setMolecularRepr(f[g], g, !0, !1)] : [3, 4]) : [3, 5];
          case 3:
            b.sent(), b.label = 4;
          case 4:
            return y++, [3, 2];
          case 5:
            return l ? (this.plugin.managers.cell.update(l, m), this.event.interactionUpdated.next({ from: r }), [2, d]) : (this.event.interactionUpdated.next({ from: r }), [4, this.plugin.managers.cell.create(m)]);
          case 6:
            return b.sent(), [2, d];
        }
      });
    });
  }, t;
}(SH), IA = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, yS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, bS(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, AH = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, C3(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, Ru(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, IH = function(e, t) {
  return ie(void 0, 0, void 0, function() {
    var n, r, i;
    return ne(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, C3(e).run()];
        case 1:
          if ((n = a.sent()).isError) throw n;
          return r = n.result, t && (o = t[0], r.molecules[0], s = o.graph.graphs, u = s.nodes, c = s.adjacency, l = [], d = [], u.forEach(function(m, p) {
            c[p].forEach(function(v) {
              v.to_jimage.some(function(f) {
                return f !== 0;
              }) || (l.push(m.id), d.push(v.id));
            });
          }), i = { count: l.length, atomA: l, atomB: d }, r.molecules[0] = B(B({}, r.molecules[0]), { bonds: i })), [4, Ru(r).run()];
        case 2:
          return [2, a.sent()];
      }
      var o, s, u, c, l, d;
    });
  });
}, wH = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, pS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, hS(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, PH = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, CS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, AS(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, EH = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    return ne(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, Ru(IS(e)).run()];
        case 1:
          return [2, t.sent()];
      }
    });
  });
} }, TH = { parse: function(e) {
  return ie(this, 0, void 0, function() {
    var t;
    return ne(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, wS(e).run()];
        case 1:
          if ((t = n.sent()).isError) throw new Error(t.message);
          return [4, Ru(t.result).run()];
        case 2:
          return [2, n.sent()];
      }
    });
  });
} }, Cg = ((Ju = {})[Nt.Dump] = AH, Ju[Nt.Gro] = IA, Ju[Nt.Pdb] = wH, Ju[Nt.Xyz] = PH, Ju[Nt.Material] = EH, Ju[Nt.Pymatgen] = TH, Ju), b8 = function(e) {
  function t(n, r, i) {
    var a = e.call(this, n, r) || this;
    return a.defaultTheme = B(B({}, Sg), r), a.plugin = n, a.interactionParams = B(B({}, i), qv()), a.showPolarHydrogenOnly = !0, a.ctx = { webgl: void 0, colorThemeRegistry: Cs.createRegistry(), sizeThemeRegistry: Ai.createRegistry(), props: { hideBond: !1 } }, a;
  }
  return Zr(t, e), Object.defineProperty(t.prototype, "hideBond", { get: function() {
    var n, r;
    return (r = (n = this.ctx) === null || n === void 0 ? void 0 : n.props.hideBond) !== null && r !== void 0 && r;
  }, set: function(n) {
    this.ctx.props.hideBond !== n && (this.ctx.props.hideBond = n, this.plugin.managers.cell.traverse(function(r, i) {
      var a, o, s, u, c;
      if (UN.has(i.type)) {
        var l = n ? (s = (o = (a = i.state) === null || a === void 0 ? void 0 : a.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(Pe(Pe([], (c = (u = i.state) === null || u === void 0 ? void 0 : u.props) === null || c === void 0 ? void 0 : c.visuals, !0), ["inter-bond", "intra-bond"], !1)));
        i.state.createOrUpdate({ visuals: l }, Li(i.state)).run();
      }
    }));
  }, enumerable: !1, configurable: !0 }), t.prototype.createContext = function() {
    this.ctx = { webgl: this.plugin.canvas3d.webgl, colorThemeRegistry: Cs.createRegistry(), sizeThemeRegistry: Ai.createRegistry(), props: { hideBond: !1 } }, this.ctx.colorThemeRegistry.add(xH);
  }, t.prototype.createMolecular = function(n) {
    var r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w;
    return ie(this, 0, void 0, function() {
      var E, D, T, P, M, R, O, L, F, G, V, U, q, H, K, j, W, Z, Y, te, ee, $, ue, se, be, ke, Oe, ze = this;
      return ne(this, function(je) {
        switch (je.label) {
          case 0:
            E = n.format, D = n.reprType, T = n.theme, P = T === void 0 ? {} : T, M = n.elementIds, R = n.ref, O = n.defaultShown, L = n.updateInteraction, F = L === void 0 || L, G = n.autoConvertToTrajectory, V = G !== void 0 && G, je.label = 1;
          case 1:
            return je.trys.push([1, 12, , 13]), (U = typeof n.data == "string" || n.data instanceof File) ? [4, gc(n.data)] : [3, 3];
          case 2:
            return H = je.sent(), [3, 4];
          case 3:
            H = n.data, je.label = 4;
          case 4:
            return q = H, [4, As[E].parse(q)];
          case 5:
            return (K = je.sent()).length > 1 && V && Cg[E] ? [4, this.plugin.managers.trajectory.importTrajectory({ data: q, format: E })] : [3, 7];
          case 6:
            return [2, (j = je.sent()) ? [j] : []];
          case 7:
            W = n.data instanceof File ? n.data.name : "", Z = O ?? K.length, Y = Object.keys(In).find(function(xe) {
              return In[xe].includes(D);
            }), te = [], ee = 0, $ = function(xe) {
              var Xe, Ee, Ye, He, le, Ce, Ae, Te, Re, we, Qe, Je, lt, st, ft, It, pe, We, gt, cn;
              return ne(this, function(Kt) {
                switch (Kt.label) {
                  case 0:
                    return Xe = Pe([], M ?? [], !0), Ee = xe, ue.showPolarHydrogenOnly && ac.has(D) && (Xe = (M ?? $i(xe)).filter(function(hn) {
                      return !yd(xe, hn);
                    }), Ee = Xn(xe, Xe)), Ye = !Z, He = E === Nt.Material || ((r = V0(xe, E)) !== null && r !== void 0 ? r : U) ? q : EF(xe, E), le = { representations: [{ isHidden: Ye, type: D }], model: {}, assets: [{ format: E, data: ["sdf", "mol"].includes(E) && W && !(He != null && He.split(`
`)[0].trim()) ? Pe(["".concat(W).concat(ee > 0 ? "_".concat(ee) : "")], He.split(`
`).slice(1), !0).join(`
`) : He }], theme: { color: (lt = {}, lt[Y] = [B({ elementIds: M ?? wr(Be.toStructureElementLoci(xe)) }, (a = (i = P[Y]) === null || i === void 0 ? void 0 : i.color) !== null && a !== void 0 ? a : Y === tt.ATOM ? b2 : ue.defaultTheme.color[Y])], lt), transparency: (st = {}, st[tt.ATOM] = [], st[tt.RIBBON] = [], st[tt.SURFACE] = [], st[Y] = !((o = P[Y]) === null || o === void 0) && o.transparency ? [(s = P[Y]) === null || s === void 0 ? void 0 : s.transparency] : [], st), size: (ft = {}, ft[tt.ATOM] = [], ft[tt.RIBBON] = [], ft[tt.SURFACE] = [], ft[Y] = !((u = P[Y]) === null || u === void 0) && u.size ? [(c = P[Y]) === null || c === void 0 ? void 0 : c.size] : [], ft) }, ref: R }, ee++, Ye ? [3, 2] : [4, wa[D].create(Ee, ue.ctx, ue.createTheme(D, xe, B(B({}, P[Y]), Y !== tt.ATOM || !((l = P[Y]) === null || l === void 0) && l.color ? {} : { color: b2 })))];
                  case 1:
                    return Ce = Kt.sent(), !((d = P[Y]) === null || d === void 0) && d.transparency && Ce.setState({ transparency: ue.createTransparencyLayers(xe, [(m = P[Y]) === null || m === void 0 ? void 0 : m.transparency]) }), Z--, (p = ue.plugin.canvas3d) === null || p === void 0 || p.add(Ce), Object.assign(le.representations[0], { state: Ce }), [3, 3];
                  case 2:
                    Object.assign(le.representations[0], { cache: { isHidden: Ye, type: D, elementIds: Xe } }), Kt.label = 3;
                  case 3:
                    return Ae = ue.plugin.managers.cell.create(le), te.push(Ae), E !== Nt.Pdb || M != null && M.length ? [3, 7] : (Te = $v(xe), Re = Te.polymer, (we = Te.other).length ? Ye ? [3, 6] : (Qe = Xn(xe, Re), [4, wa[fe.Ribbon].update(le.representations[0].state, Xn(xe, Re), ue.ctx, ue.createTheme(fe.Ribbon, Qe, P[tt.RIBBON]))]) : [3, 7]);
                  case 4:
                    return Kt.sent(), Je = Xn(xe, we), ue.plugin.managers.cell.update(Ae, { representations: [], model: { structure: xe }, theme: { color: (It = {}, It[tt.ATOM] = [B({ elementIds: we ?? wr(Be.toStructureElementLoci(xe)) }, (f = (v = P[tt.ATOM]) === null || v === void 0 ? void 0 : v.color) !== null && f !== void 0 ? f : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: ye(4777267) } } } })], It), transparency: (pe = {}, pe[tt.ATOM] = !((y = P[tt.ATOM]) === null || y === void 0) && y.transparency ? [(h = P[tt.ATOM]) === null || h === void 0 ? void 0 : h.transparency] : [], pe), size: (We = {}, We[tt.ATOM] = [], We[tt.RIBBON] = [], We[tt.SURFACE] = [], We[Y] = !((g = P[tt.ATOM]) === null || g === void 0) && g.size ? [(x = P[tt.ATOM]) === null || x === void 0 ? void 0 : x.size] : [], We) } }), [4, ue.addMolecularRepr(Ae, { elementIds: we, reprType: fe.BallAndStick, isHidden: Ye, theme: ue.createTheme(fe.BallAndStick, Je, B({ color: B({ elementIds: we }, b2) }, P[tt.ATOM])), transparency: !((C = P[tt.ATOM]) === null || C === void 0) && C.transparency ? [(b = P[tt.ATOM]) === null || b === void 0 ? void 0 : b.transparency] : void 0 })];
                  case 5:
                    return Kt.sent(), [3, 7];
                  case 6:
                    ue.plugin.managers.cell.update(Ae, { representations: [B(B({}, le.representations[0]), { cache: B(B({}, le.representations[0].cache), { elementIds: Re }) }), { isHidden: Ye, type: fe.BallAndStick, cache: { isHidden: Ye, type: fe.BallAndStick, elementIds: we } }], model: {}, theme: { color: (gt = {}, gt[tt.ATOM] = [B({ elementIds: we ?? wr(Be.toStructureElementLoci(xe)) }, (A = (_ = P[tt.ATOM]) === null || _ === void 0 ? void 0 : _.color) !== null && A !== void 0 ? A : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: ye(4777267) } } } })], gt), transparency: (cn = {}, cn[tt.ATOM] = !((I = P[tt.ATOM]) === null || I === void 0) && I.transparency ? [(w = P[tt.ATOM]) === null || w === void 0 ? void 0 : w.transparency] : [], cn) } }), Kt.label = 7;
                  case 7:
                    return Ye || ue.plugin.managers.cell.update(Ae, { model: { structure: xe } }), F && ue.plugin.managers.cell.traverse(function(hn, jt) {
                      jt.type === fe.IntraInteractions && ze.plugin.managers.representation.showGlobalInteraction(void 0, "lightPlugin.managers.representation.createMolecular");
                    }), ue.plugin.managers.snapshot.event.changed.next({ from: "repr: createMolecular" }), [2];
                }
              });
            }, ue = this, se = 0, be = K, je.label = 8;
          case 8:
            return se < be.length ? (ke = be[se], [5, $(ke)]) : [3, 11];
          case 9:
            je.sent(), je.label = 10;
          case 10:
            return se++, [3, 8];
          case 11:
            return [2, te];
          case 12:
            return Oe = je.sent(), console.log(Oe), [2, []];
          case 13:
            return [2];
        }
      });
    });
  }, t.prototype.updateMolecular = function(n) {
    var r;
    return ie(this, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E = this;
      return ne(this, function(D) {
        for (i = n.ref, a = n.structure, o = this.plugin.managers.cell.get(i), s = Se.toExpression(Be.toStructureElementLoci(o.model.structure)), u = Se.toExpression(Be.toStructureElementLoci(a)), c = ot.struct.modifier.exceptBy({ 0: u, by: s }), (l = $i(Yl(Xl(a, c)))).length && (((d = o.theme.color[tt.ATOM]) == null ? void 0 : d.length) === 1 ? d[0].elementIds ? (I = d[0].elementIds).push.apply(I, l) : d[0].elementIds = Pe([], l, !0) : d == null || d.push(B({ elementIds: l }, this.defaultTheme.color[tt.ATOM])), this.plugin.managers.cell.update(i, { representations: [], model: {}, theme: { color: (w = {}, w[tt.ATOM] = d, w) } })), (m = [fe.BallAndStick, fe.Stick, fe.Line, fe.CPK]).forEach(function(T) {
          !p && o.representations.has(T) && (p = T);
        }), v = function(T) {
          var P = T[0], M = T[1], R = Object.keys(In).find(function(V) {
            return In[V].includes(P);
          }), O = o.theme.color[R], L = M.state.getLoci(), F = Se.toExpression(Be.toStructureElementLoci(L.structure));
          m.includes(P) && P !== p || (F = ot.struct.modifier.union([ot.struct.combinator.merge([c, F])]));
          var G = Yl(Xl(a, F));
          wa[P].update(M.state, G, f.ctx, f.createTheme(P, a, { color: { name: "multi-theme", props: { themes: O } }, size: o.theme.size && (!((r = o.theme.size[R]) === null || r === void 0) && r.length) ? o.theme.size[R][0] : f.defaultTheme.size[P] })), M.state.setState({ transparency: f.createTransparencyLayers(G, o == null ? void 0 : o.theme.transparency[R]) });
        }, f = this, y = 0, h = Array.from(o.representations); y < h.length; y++) g = h[y], v(g);
        for (x = function(T) {
          var P = C.plugin.cells.get(T);
          P && P.representations.forEach(function(M, R) {
            R === fe.IntraInteractions && E.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.updateMolecular"), Object.keys(Wd).includes(R) && E.plugin.managers.representation.updateMeasurement({ items: P.dependency.on, ref: T });
          });
        }, C = this, b = 0, _ = o.dependency.by; b < _.length; b++) A = _[b], x(A);
        return this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateMolecular" }), [2, o];
      });
    });
  }, t.prototype.createMeasurement = function(n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m, p, v;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            if (r = n.type, i = n.theme, a = n.items, o = n.ref, s = n.isHidden, !Kl.has(r)) return console.warn("There is no ".concat(r, " type ")), [2, ""];
            u = [], c = 0, l = a, f.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [4, this.plugin.managers.cell.getStructure(d.ref)]) : [3, 4];
          case 2:
            if (!(m = f.sent())) return [2, ""];
            u.push(Yn(m, d.elementIds)), f.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return [4, Wd[r].create(u, this.ctx, n.props, i)];
          case 5:
            return p = f.sent(), v = this.plugin.managers.cell.create({ representations: [{ state: p, isHidden: s != null && s, type: r }], model: { loci: u }, dependency: { on: a }, ref: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, v];
        }
      });
    });
  }, t.prototype.updateMeasurement = function(n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m = this;
      return ne(this, function(p) {
        switch (p.label) {
          case 0:
            return r = n.items, i = n.ref, a = n.params, o = this.plugin.cells.get(i), s = r.filter(function(v) {
              return un(m.plugin.cells.get(v.ref));
            }), u = s.map(function(v) {
              return Yn(un(m.plugin.cells.get(v.ref)), v.elementIds);
            }), o ? (c = Array.from(o.representations)[0], l = c[0], d = c[1], l && d ? d.state ? [4, Wd[l].update(d.state, u, a)] : [3, 2] : (console.error("There is no ".concat(l)), [2, !1])) : (console.warn("There is no ".concat(i)), [2, !1]);
          case 1:
            p.sent(), p.label = 2;
          case 2:
            return this.plugin.managers.cell.update(i, { model: { loci: u } }), [2, !0];
        }
      });
    });
  }, t.prototype.createStaticLabel = function(n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m, p;
      return ne(this, function(v) {
        switch (v.label) {
          case 0:
            r = n.theme, i = n.items, a = n.ref, o = n.isHidden, s = [], u = 0, c = i, v.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 = v.sent())) return [2, ""];
            s.push({ loci: Yn(d, l.item.elementIds), label: l.label }), v.label = 3;
          case 3:
            return u++, [3, 1];
          case 4:
            return [4, Wd[fe.Label].create(s, this.ctx, n.props, r)];
          case 5:
            return m = v.sent(), p = this.plugin.managers.cell.create({ representations: [{ state: m, isHidden: o != null && o, type: fe.Label }], model: { loci: s.map(function(f) {
              return f.loci;
            }) }, dependency: { on: i.map(function(f) {
              return f.item;
            }) }, ref: a }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, p];
        }
      });
    });
  }, t.prototype.createOther = function(n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l, d, m, p, v, f, y, h, g;
      return ne(this, function(x) {
        switch (x.label) {
          case 0:
            return r = n.type, i = n.theme, a = n.data, o = n.ref, s = n.isHidden, u = s !== void 0 && s, c = n.serverData, l = n.params, Im[r] ? (d = Im[r]).parse ? [4, d.parse(a, this.plugin)] : [3, 2] : (console.warn("There is no ".concat(r, " type ")), [2]);
          case 1:
            return p = x.sent(), [3, 3];
          case 2:
            p = a, x.label = 3;
          case 3:
            return m = p, [4, d.create(m, this.ctx, d.createTheme ? d.createTheme(r === fe.IsoSurface ? m : a, this.plugin, i) : void 0, l)];
          case 4:
            return v = x.sent(), r === fe.Surface && (i != null && i.transparency) && v.setState({ transparency: this.createTransparencyLayers(m, [i == null ? void 0 : i.transparency]) }), f = this.plugin.managers.cell.create({ representations: [{ state: v, isHidden: u, type: r }], model: { other: c ? { serverData: c, data: a } : a }, theme: r === fe.Surface ? { color: (y = {}, y[tt.SURFACE] = i != null && i.color ? [i == null ? void 0 : i.color] : [], y), transparency: (h = {}, h[tt.SURFACE] = i != null && i.transparency ? [i == null ? void 0 : i.transparency] : [], h), size: (g = {}, g[tt.SURFACE] = i != null && i.size ? [i == null ? void 0 : i.size] : [], g) } : void 0, ref: o, dependency: r === fe.Surface ? { on: [a] } : r === fe.MappingLine ? { on: a } : void 0 }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createOther" }), [2, f];
        }
      });
    });
  }, t.prototype.updateOther = function(n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u;
      return ne(this, function(c) {
        switch (c.label) {
          case 0:
            return r = n.data, i = n.ref, (a = this.plugin.cells.get(i)) ? (o = Array.from(a.representations)[0], s = o[0], u = o[1], s && u ? [4, Im[s].update(u.state, r, this.ctx)] : (console.error("There is no ".concat(s)), [2, !1])) : (console.warn("There is no ".concat(i)), [2, !1]);
          case 1:
            return c.sent(), this.plugin.managers.cell.update(i, { model: { other: r } }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateOther" }), [2, !0];
        }
      });
    });
  }, t.prototype.addMolecularRepr = function(n, r) {
    var i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, m, p, v;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            return a = r.elementIds, o = r.reprType, s = r.isHidden, u = r.theme, c = r.transparency, l = this.plugin.managers.cell.get(n), d = un(l), l && d ? (m = Pe([], a ?? [], !0), ac.has(o) && this.showPolarHydrogenOnly && (m = (a || $i(d)).filter(function(y) {
              return !yd(d, y);
            })), p = Xn(d, m, !0), [4, wa[o].create(p, this.ctx, u)]) : [2];
          case 1:
            return v = f.sent(), c && v.setState({ transparency: this.createTransparencyLayers(p, c) }), s || (i = this.plugin.canvas3d) === null || i === void 0 || i.add(v), l.representations.set(o, { state: v, isHidden: s, type: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: addMolecularRepr" }), [2];
        }
      });
    });
  }, t.prototype.checkStructuresDisplayed = function(n, r) {
    var i, a = this.plugin.managers.cell.get(n.ref), o = un(a), s = new Set(r && !ac.has(r) || !this.showPolarHydrogenOnly ? n.elementIds : ((i = n.elementIds) !== null && i !== void 0 ? i : []).filter(function(u) {
      return !yd(o, u);
    }));
    return (r ? [a.representations.get(r)] : Array.from(a.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 m = Yr(u.state.getLoci());
        m && (!((d = (l = (c = m == null ? void 0 : m.elements) === null || c === void 0 ? void 0 : c[0]) === null || l === void 0 ? void 0 : l.unit) === null || d === void 0) && d.elements) && wr(m).forEach(function(p) {
          return s.delete(p);
        });
      }
    }), s.size === 0;
  }, t.prototype.setMolecularRepr = function(n, r, i, a, o) {
    var s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A;
    return a === void 0 && (a = !0), o === void 0 && (o = !0), ie(this, 0, void 0, function() {
      var I, w, E, D, T, P, M, R, O, L, F, G, V, U, q, H, K, j, W, Z, Y = this;
      return ne(this, function(te) {
        switch (te.label) {
          case 0:
            if (I = /* @__PURE__ */ new Map(), w = n.filter(function(ee) {
              return un(Y.plugin.managers.cell.get(ee.ref));
            }), E = !!a && w.every(function(ee) {
              return Y.checkStructuresDisplayed(ee, r);
            }), D = Object.keys(In).find(function(ee) {
              return In[ee].includes(r);
            }), T = [], !E) return [3, 5];
            P = function(ee) {
              var $, ue, se;
              return ne(this, function(be) {
                switch (be.label) {
                  case 0:
                    return I.set(ee.ref, /* @__PURE__ */ new Set()), $ = M.plugin.managers.cell.get(ee.ref), ue = $.representations.get(r), se = $.theme.color[D], [4, yg(ue == null ? void 0 : ue.state, (s = ee.elementIds) !== null && s !== void 0 ? s : [], r, function(ke) {
                      var Oe;
                      return Y.createTheme(r, ke, { color: { name: "multi-theme", props: { themes: se } }, size: $.theme.size && (!((Oe = $.theme.size[D]) === null || Oe === void 0) && Oe.length) ? $.theme.size[D][0] : Y.defaultTheme.size[r] });
                    }, function(ke) {
                      return Y.createTransparencyLayers(ke, $ == null ? void 0 : $.theme.transparency[D]);
                    })];
                  case 1:
                    return be.sent(), (u = I.get(ee.ref)) === null || u === void 0 || u.add(r), $.dependency.by.length && T.push.apply(T, $.dependency.by), [2];
                }
              });
            }, M = this, R = 0, O = w, te.label = 1;
          case 1:
            return R < O.length ? (U = O[R], [5, P(U)]) : [3, 4];
          case 2:
            te.sent(), te.label = 3;
          case 3:
            return R++, [3, 1];
          case 4:
            return [3, 9];
          case 5:
            L = function(ee) {
              var $, ue, se, be, ke, Oe, ze, je, xe, Xe, Ee, Ye, He, le, Ce, Ae, Te, Re, we;
              return ne(this, function(Qe) {
                switch (Qe.label) {
                  case 0:
                    if (I.set(ee.ref, /* @__PURE__ */ new Set()), $ = F.plugin.managers.cell.get(ee.ref), ue = $.representations.get(r), se = un($), be = $.theme.color[D], ke = [], be == null || be.forEach(function(Je) {
                      var lt;
                      ke.push.apply(ke, (lt = Je.elementIds) !== null && lt !== void 0 ? lt : []);
                    }), Oe = new Set(ke), (ze = ((c = ee.elementIds) !== null && c !== void 0 ? c : []).filter(function(Je) {
                      return !Oe.has(Je);
                    })).length && (be == null || be.push(B({ elementIds: ze }, F.defaultTheme.color[D])), $.theme.color = B(B({}, $.theme.color), ((we = {})[D] = be, we))), je = [], !i) return [3, 4];
                    xe = function(Je) {
                      var lt;
                      return ne(this, function(st) {
                        switch (st.label) {
                          case 0:
                            return !a && Je.type !== fe.Ribbon && r !== fe.Ribbon && (lt = x0(Je.state, (l = ee.elementIds) !== null && l !== void 0 ? l : [])).length ? (ee.elementIds = (d = ee.elementIds) === null || d === void 0 ? void 0 : d.filter(function(ft) {
                              return !lt.includes(ft);
                            }), [2, "continue"]) : Je.type === r || Je.type === fe.Ribbon || Je.isHidden || VU(Je.state, (m = ee.elementIds) !== null && m !== void 0 ? m : []) === iu.Not ? [2, "continue"] : (je.push.apply(je, x0(Je == null ? void 0 : Je.state, (p = ee.elementIds) !== null && p !== void 0 ? p : [])), [4, yg(Je == null ? void 0 : Je.state, (v = ee.elementIds) !== null && v !== void 0 ? v : [], Je == null ? void 0 : Je.type, function(ft) {
                              var It;
                              return Y.createTheme(Je == null ? void 0 : Je.type, ft, { color: { name: "multi-theme", props: { themes: be } }, size: $.theme.size && (!((It = $.theme.size[D]) === null || It === void 0) && It.length) ? $.theme.size[D][0] : Y.defaultTheme.size[Je == null ? void 0 : Je.type] });
                            }, function(ft) {
                              return Y.createTransparencyLayers(ft, $ == null ? void 0 : $.theme.transparency[D]);
                            })]);
                          case 1:
                            return st.sent(), (f = I.get(ee.ref)) === null || f === void 0 || f.add(Je.type), [2];
                        }
                      });
                    }, Xe = 0, Ee = Array.from($.representations), Qe.label = 1;
                  case 1:
                    return Xe < Ee.length ? (Ye = Ee[Xe], He = Ye[1], [5, xe(He)]) : [3, 4];
                  case 2:
                    Qe.sent(), Qe.label = 3;
                  case 3:
                    return Xe++, [3, 1];
                  case 4:
                    return le = new Set(je), ue ? (Ce = (y = qf(ue.state)) !== null && y !== void 0 ? y : [], Ae = Xn(se, Array.from(new Set(Ce.concat(ac.has(r) && F.showPolarHydrogenOnly ? ((h = ee.elementIds) !== null && h !== void 0 ? h : []).filter(function(Je) {
                      return le.has(Je) || !yd(se, Je);
                    }) : (g = ee.elementIds) !== null && g !== void 0 ? g : [])))), Te = F.createTransparencyLayers(Ae, $ == null ? void 0 : $.theme.transparency[D]), [4, wa[r].update(ue == null ? void 0 : ue.state, Ae, F.ctx, F.createTheme(r, Ae, { color: { name: "multi-theme", props: { themes: be } }, size: $.theme.size && (!((x = $.theme.size[D]) === null || x === void 0) && x.length) ? $.theme.size[D][0] : F.defaultTheme.size[r] }))]) : [3, 6];
                  case 5:
                    return Qe.sent(), (C = I.get(ee.ref)) === null || C === void 0 || C.add(r), ue.state.setState({ transparency: Te }), [3, 8];
                  case 6:
                    return Ae = Xn(se, ac.has(r) && F.showPolarHydrogenOnly ? ee.elementIds.filter(function(Je) {
                      return le.has(Je) || !yd(se, Je);
                    }) : ee.elementIds), Te = F.createTransparencyLayers($ == null ? void 0 : $.model.structure, $ == null ? void 0 : $.theme.transparency[D]), [4, wa[r].create(Ae, F.plugin.managers.representation.ctx, F.createTheme(r, Ae, { color: { name: "multi-theme", props: { themes: be } }, size: $.theme.size && (!((b = $.theme.size[D]) === null || b === void 0) && b.length) ? $.theme.size[D][0] : F.defaultTheme.size[r] }))];
                  case 7:
                    Re = Qe.sent(), (_ = I.get(ee.ref)) === null || _ === void 0 || _.add(r), (A = F.plugin.canvas3d) === null || A === void 0 || A.add(Re), Re.setState({ transparency: Te }), $.representations.set(r, { state: Re, isHidden: !1, type: r }), Qe.label = 8;
                  case 8:
                    return $.dependency.by.length && T.push.apply(T, $.dependency.by), [2];
                }
              });
            }, F = this, G = 0, V = w, te.label = 6;
          case 6:
            return G < V.length ? (U = V[G], [5, L(U)]) : [3, 9];
          case 7:
            te.sent(), te.label = 8;
          case 8:
            return G++, [3, 6];
          case 9:
            for (q = this.plugin.managers.selection.structure.getSelection(), I.forEach(function(ee, $) {
              var ue;
              if (ee.size) {
                var se = Y.plugin.cells.get($), be = (ue = q[$]) !== null && ue !== void 0 ? ue : [];
                ee.forEach(function(ke) {
                  var Oe, ze = se == null ? void 0 : se.representations.get(ke);
                  if (ze) {
                    var je = Yn(Li(ze.state), be);
                    (Oe = Y.plugin.canvas3d) === null || Oe === void 0 || Oe.mark({ loci: je, repr: ze.state }, $e.Select);
                  }
                });
              }
            }), H = Array.from(new Set(T).values()), K = 0, j = H; K < j.length; K++) W = j[K], (Z = this.plugin.cells.get(W)) && Z.representations.forEach(function(ee, $) {
              $ === fe.IntraInteractions && o && Y.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(n, r, i) {
    var a = this, o = i ?? this.plugin.managers.selection.structure.getSelectionCellItems(), s = [];
    o.forEach(function(m) {
      var p = a.plugin.cells.get(m.ref);
      if (p) {
        var v = un(p);
        if (v) {
          m.elementIds || Object.assign(m, { elementIds: $i(v) });
          var f = m.elementIds.map(function(C) {
            return z0(v, C);
          }), y = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
          p.representations.forEach(function(C, b) {
            if ([fe.BallAndStick, fe.CPK, fe.Stick, fe.Line].includes(b)) {
              var _ = Yr(C.state.getLoci());
              if (!_) return;
              var A = wr(_);
              h.set(b, Pe([], A, !0)), A.forEach(function(I) {
                y.set(I, b);
              });
            }
          });
          var g = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
          f.forEach(function(C, b) {
            var _;
            if (m.elementIds) {
              var A = m.elementIds[b], I = v.units.filter(function(w) {
                return _e.indexOf(w.elements, A) !== -1;
              })[0];
              (!r && C === sr.NonPolar || !n && C === sr.Polar) && y.has(A) ? g.has(y.get(A)) ? (_ = g.get(y.get(A))) === null || _ === void 0 || _.add(A) : g.set(y.get(A), /* @__PURE__ */ new Set([A])) : ((!r && C === sr.ConnectNonPolar || !n && C === sr.ConnectPolar) && gs(v, I, I.elements.indexOf(A), function(w, E) {
                var D;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[E]] === 1 && y.has(w.elements[E]) && (g.has(y.get(A)) ? (D = g.get(y.get(A))) === null || D === void 0 || D.add(w.elements[E]) : g.set(y.get(A), /* @__PURE__ */ new Set([w.elements[E]])));
              }), !(r && C === sr.NonPolar || n && C === sr.Polar) || y.has(A) ? (r && C === sr.ConnectNonPolar || n && C === sr.ConnectPolar) && y.has(A) && gs(v, I, I.elements.indexOf(A), function(w, E) {
                var D;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[E]] !== 1 || y.has(w.elements[E]) || (x.has(y.get(A)) ? (D = x.get(y.get(A))) === null || D === void 0 || D.add(w.elements[E]) : x.set(y.get(A), /* @__PURE__ */ new Set([w.elements[E]])));
              }) : gs(v, I, I.elements.indexOf(A), function(w, E) {
                var D;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[E]] !== 1 && y.has(w.elements[E]) && (x.has(y.get(w.elements[E])) ? (D = x.get(y.get(w.elements[E]))) === null || D === void 0 || D.add(A) : x.set(y.get(w.elements[E]), /* @__PURE__ */ new Set([A])));
              }));
            }
          }), p.representations.forEach(function(C, b) {
            var _;
            if ([fe.BallAndStick, fe.CPK, fe.Stick, fe.Line].includes(b)) {
              var A = !1, I = h.get(b);
              if (g.has(b) && g.get(b).size > 0) {
                var w = g.get(b);
                I = I == null ? void 0 : I.filter(function(P) {
                  return !w.has(P);
                }), A = !0;
              }
              if (x.has(b) && x.get(b).size > 0) {
                var E = x.get(b);
                I = Array.from(new Set(Pe(Pe([], Array.from(E.values()), !0), I, !0))), A = !0;
              }
              if (A) {
                var D = Xn(v, I), T = p.theme.color[tt.ATOM];
                wa[b].update(C.state, D, a.ctx, a.createTheme(b, D, { color: { name: "multi-theme", props: { themes: T } }, size: p.theme.size && (!((_ = p.theme.size[tt.ATOM]) === null || _ === void 0) && _.length) ? p.theme.size[tt.ATOM][0] : a.defaultTheme.size[b] }));
              }
            }
          }), p.dependency.by.length && s.push.apply(s, p.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(m, p) {
        p === fe.IntraInteractions && a.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.showOrHideHs");
      });
    }
  }, t.prototype.redraw = function() {
    var n = this;
    this.plugin.canvas3d && (this.plugin.canvas3d.clear(), Array.from(this.plugin.cells.values()).forEach(function(r) {
      r.representations.forEach(function(i) {
        var a;
        i.isHidden !== !0 && i.state && ((a = n.plugin.canvas3d) === null || a === void 0 || a.add(i.state));
      });
    }));
  }, t.prototype.updateBondThresholds = function(n) {
    var r = this, i = n.reduce(function(o, s) {
      var u;
      return B(B({}, o), ((u = {})[S9(hf[s.atomA], hf[s.atomB])] = s.distance, u));
    }, {});
    Object.assign(x9, i), Object.assign(_9, i);
    var a = /* @__PURE__ */ new Set();
    this.plugin.managers.cell.traverse(function(o, s) {
      return ie(r, 0, void 0, function() {
        var u, c, l, d;
        return ne(this, function(m) {
          switch (m.label) {
            case 0:
              return a.has(o.ref) || !o.model.structure ? [2] : (u = o.assets[0], c = u.format, l = u.data, [4, As[c].parse(l)]);
            case 1:
              return d = m.sent(), this.plugin.managers.editor.coverStructure(o.ref, d[0], o.assets[0]), a.add(o.ref), [2];
          }
        });
      });
    });
  }, t;
}(CH), _2 = ((cm = {})[tt.ATOM] = [], cm[tt.RIBBON] = [], cm[tt.SURFACE] = [], cm), _8 = function() {
  function e(t) {
    var n, r = this;
    this.plugin = t, (n = this.plugin.canvas3d) === null || n === void 0 || n.reprCount.subscribe(function(i) {
      if (i > 100 && r.idleCellSet.size) {
        var a = Array.from(r.idleCellSet.values())[0];
        r.idleCellSet.delete(a), r.clearReprState(a);
      }
    }), this.idleCellSet = /* @__PURE__ */ new Set();
  }
  return e.prototype.get = function(t) {
    var n = this.plugin.cells.get(t);
    if (n) return n;
    console.error("no ".concat(t, " cell"));
  }, e.prototype.getHierarchy = function(t) {
    var n = this, r = this.get(t);
    if (!(r != null && r.model.structure)) return console.error("".concat(t, " cell does not have structure")), { data: { polymer: {}, water: {}, otherSolvent: {}, metal: {}, ion: {}, ligand: {}, other: {} }, extraData: { sequenceData: {} } };
    var i = [], a = [];
    r.dependency.by.forEach(function(s) {
      var u, c, l;
      if (n.plugin.cells.has(s)) {
        var d = n.get(s);
        d && (d.representations.has(fe.Label) && a.push({ ref: s, dependencies: Pe([], d.dependency.on, !0), label: ((c = (u = d.representations.get(fe.Label)) === null || u === void 0 ? void 0 : u.state) !== null && c !== void 0 ? c : (l = d.representations.get(fe.Label)) === null || l === void 0 ? void 0 : l.cache).props.customText }), d.representations.has(fe.Surface) && i.push({ ref: s, dependencies: Pe([], d.dependency.on, !0) }));
      }
    });
    var o = mS(r.model.structure);
    return B(B({}, o), { extraData: B(B({}, o.extraData), { label: a, surface: i }) });
  }, e.prototype.getSequence = function(t) {
    return ie(this, 0, void 0, function() {
      var n;
      return ne(this, function(r) {
        switch (r.label) {
          case 0:
            return [4, this.getStructure(t)];
          case 1:
            return (n = r.sent()) ? [2, aL(n)] : [2];
        }
      });
    });
  }, e.prototype.getStructure = function(t) {
    var n;
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u, c, l;
      return ne(this, function(d) {
        switch (d.label) {
          case 0:
            return (r = this.get(t)) ? (i = un(r)) ? [2, i] : i || !(!((n = r.assets) === null || n === void 0) && n.length) ? [3, 5] : (a = r.assets[0], o = a.data, s = a.format, l = (c = As[s]).parse, [4, gc(o)]) : [2];
          case 1:
            return [4, l.apply(c, [d.sent()])];
          case 2:
            return u = d.sent()[0], s !== Nt.Pdb || !u.elementCount || pn.hasSecondaryStructure(u == null ? void 0 : u.model) ? [3, 4] : [4, ei.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 ie(this, 0, void 0, function() {
      var n;
      return ne(this, function(r) {
        switch (r.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (n = r.sent()) ? [2, Yn(n, t.elementIds)] : [2, Sn];
        }
      });
    });
  }, e.prototype.getMolecularName = function(t) {
    var n, r, i, a, o, s, u = this.get(t);
    if (!u.model.structure) return !((n = u.assets) === null || n === void 0) && n.length && ["sdf", "mol"].includes(u.assets[0].format) ? "".concat(u.assets[0].data).split(`
`)[0] : "";
    var c = ((i = (r = u.model.structure) === null || r === void 0 ? void 0 : r.state.model) !== null && i !== void 0 ? i : !((a = u.model.structure) === null || a === void 0) && a.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 n, r = this.plugin.cells.get(t);
    if (!r) return !1;
    var i = un(r);
    return !!i && ((n = ea(i)) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF";
  }, e.prototype.getCellPdbId = function(t) {
    if (!this.isFromPdb(t)) return "";
    var n = this.plugin.cells.get(t);
    if (!n) return "";
    var r = un(n);
    if (!r) return "";
    var i = "";
    if (this.plugin.managers.cell.isFromPdb(t)) {
      for (var a = x3(r, ["HEADER"]), o = 0, s = a.length; o < s && !i; o++) if (a[o].startsWith("HEADER") && a[o].length >= 66) {
        var u = a[o].slice(62, 66).replace(" ", "");
        u.length === 4 && /^[A-Za-z0-9]*$/.test(u) && (i = u);
      }
    }
    return i;
  }, e.prototype.getMeasurementName = function(t, n) {
    var r, i, a = this.get(t);
    if (!a.representations.get(n)) return console.warn("There is no ".concat(n, " in ").concat(t, " cell"));
    var o = ((i = (r = a.model) === null || r === void 0 ? void 0 : r.loci) !== null && i !== void 0 ? i : []).map(function(s) {
      return rn.getCenter(s);
    });
    return n === fe.Distance ? "".concat(S.distance(o[0], o[1]).toFixed(2), "Å") : n === fe.Angle ? "".concat($r(S.angle(S.sub(S(), o[0], o[1]), S.sub(S(), o[2], o[1]))).toFixed(2), "°") : n === fe.Dihedral ? "".concat($r(S.dihedralAngle(o[0], o[1], o[2], o[3])).toFixed(2), "°") : "";
  }, e.prototype.create = function(t) {
    var n, r, i = this, a = t.representations, o = t.model, s = t.assets, u = t.dependency, c = t.ref, l = t.theme, d = c ?? vr.create22(), m = /* @__PURE__ */ new Map();
    return a.forEach(function(p) {
      var v;
      !p.isHidden && p.state && ((v = i.plugin.canvas3d) === null || v === void 0 || v.add(p.state)), m.set(p.type, p);
    }), this.plugin.cells.set(d, { ref: d, representations: m, dependency: B({ on: [], by: [] }, u), theme: { color: B(B({}, _2), l == null ? void 0 : l.color), size: B(B({}, _2), l == null ? void 0 : l.size), transparency: B(B({}, _2), l == null ? void 0 : l.transparency) }, assets: s, model: o }), !((n = u == null ? void 0 : u.on) === null || n === void 0) && n.length && Array.from(new Set(u == null ? void 0 : u.on)).forEach(function(p) {
      i.addDependency(p.ref, { by: [d] });
    }), !((r = u == null ? void 0 : u.by) === null || r === void 0) && r.length && Array.from(new Set(u == null ? void 0 : u.by)).forEach(function(p) {
      i.addDependency(p, { on: [{ ref: d }] });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "cell:create" }), d;
  }, e.prototype.createEmptyMolecularCell = function(t) {
    var n, r, i, a;
    return ie(this, 0, void 0, function() {
      var o, s, u, c;
      return ne(this, function(l) {
        switch (l.label) {
          case 0:
            return o = Go(), [4, AC.create(o, this.plugin.managers.representation.ctx)];
          case 1:
            return s = l.sent(), [2, this.create({ representations: [{ state: s, isHidden: !1, type: fe.BallAndStick }], model: { structure: o }, assets: [{ format: Nt.Sdf, data: "" }], theme: { transparency: (u = {}, u[tt.ATOM] = t && (!((n = t[tt.ATOM]) === null || n === void 0) && n.transparency) ? [(r = t[tt.ATOM]) === null || r === void 0 ? void 0 : r.transparency] : [], u[tt.RIBBON] = [], u[tt.SURFACE] = [], u), size: (c = {}, c[tt.ATOM] = t && (!((i = t[tt.ATOM]) === null || i === void 0) && i.size) ? [(a = t[tt.ATOM]) === null || a === void 0 ? void 0 : a.size] : [], c[tt.RIBBON] = [], c[tt.SURFACE] = [], c) } })];
        }
      });
    });
  }, e.prototype.copyMolecular = function(t, n) {
    var r, i, a, o, s, u;
    return ie(this, 0, void 0, function() {
      var c, l, d, m, p, v;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            c = [], l = function(y) {
              var h, g, x, C, b, _, A, I, w, E, D, T, P;
              return ne(this, function(M) {
                switch (M.label) {
                  case 0:
                    return h = d.get(y.ref), [4, d.getStructure(y.ref)];
                  case 1:
                    return g = M.sent(), x = [], (C = Xn(g, (r = y.elementIds) !== null && r !== void 0 ? r : [], !0, !0)).elementCount ? [4, ei.attach({}, C, void 0, !0)] : [3, 3];
                  case 2:
                    M.sent(), M.label = 3;
                  case 3:
                    return b = Ja(C), y.representationType ? (_ = Object.keys(In).find(function(R) {
                      return In[R].includes(y.representationType);
                    }), [4, wa[y.representationType].create(C, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(y.representationType, C, { color: { name: "multi-theme", props: { themes: h.theme.color[_] } }, size: h.theme.size && (!((i = h.theme.size[_]) === null || i === void 0) && i.length) ? h.theme.size[_][0] : d.plugin.managers.representation.defaultTheme.size[y.representationType] }))]) : [3, 5];
                  case 4:
                    return A = M.sent(), x.push({ state: A, isHidden: (a = n == null ? void 0 : n.isHidden) === null || a === void 0 || a, type: y.representationType }), [3, 9];
                  case 5:
                    I = function(R, O) {
                      var L, F, G;
                      return ne(this, function(V) {
                        switch (V.label) {
                          case 0:
                            return L = Object.keys(In).find(function(U) {
                              return In[U].includes(R);
                            }), !(!((o = y.elementIds) === null || o === void 0) && o.length) || x0(O.state, y.elementIds).length ? (F = Xn(O.state ? Li(O.state) : Xn(C, O.cache.elementIds, !0), (s = y.elementIds) !== null && s !== void 0 ? s : [], !0, b), [4, wa[R].create(F, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(R, F, { color: { name: "multi-theme", props: { themes: h.theme.color[L] } }, size: d.plugin.managers.representation.defaultTheme.size[R] }))]) : [3, 2];
                          case 1:
                            G = V.sent(), x.push({ state: G, isHidden: (u = n == null ? void 0 : n.isHidden) === null || u === void 0 || u, type: R }), V.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, w = 0, E = Array.from(h.representations), M.label = 6;
                  case 6:
                    return w < E.length ? (D = E[w], T = D[0], P = D[1], [5, I(T, P)]) : [3, 9];
                  case 7:
                    M.sent(), M.label = 8;
                  case 8:
                    return w++, [3, 6];
                  case 9:
                    return c.push(d.create({ representations: x, model: { structure: C }, assets: h.assets, theme: B({}, h.theme) })), [2];
                }
              });
            }, d = this, m = 0, p = t, f.label = 1;
          case 1:
            return m < p.length ? (v = p[m], [5, l(v)]) : [3, 4];
          case 2:
            f.sent(), f.label = 3;
          case 3:
            return m++, [3, 1];
          case 4:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:copyMolecular" }), [2, c];
        }
      });
    });
  }, e.prototype.update = function(t, n) {
    var r, i, a, o, s, u, c, l = this, d = this.plugin.managers.cell.get(t);
    d.model = Object.assign(d.model, n.model), n.theme && (d.theme = { color: B(B({}, d.theme.color), n.theme.color), size: B(B({}, d.theme.size), n.theme.size), transparency: B(B({}, d.theme.transparency), n.theme.transparency) }), !((r = n.representations) === null || r === void 0) && r.length && n.representations.forEach(function(m) {
      var p;
      d.representations.set(m.type, Object.assign((p = d.representations.get(m.type)) !== null && p !== void 0 ? p : {}, m));
    }), !((a = (i = n.dependency) === null || i === void 0 ? void 0 : i.on) === null || a === void 0) && a.length && (this.removeDependency(t, { on: d.dependency.on }), Array.from(new Set((o = n.dependency) === null || o === void 0 ? void 0 : o.on)).forEach(function(m) {
      l.addDependency(m.ref, { by: [t] });
    })), !((u = (s = n.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 = n.dependency) === null || c === void 0 ? void 0 : c.by)).forEach(function(m) {
      l.addDependency(m, { on: [{ ref: t }] });
    })), d.dependency = B(B({}, d.dependency), n.dependency), n.assets && (d.assets = n.assets), this.plugin.managers.snapshot.event.changed.next({ from: "cell:update" });
  }, e.prototype.remove = function(t, n) {
    var r, i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, m = this;
      return ne(this, function(p) {
        switch (p.label) {
          case 0:
            a = "", o = /* @__PURE__ */ new Map(), s = function(v) {
              var f, y, h, g, x, C, b, _, A, I, w, E;
              return ne(this, function(D) {
                switch (D.label) {
                  case 0:
                    return u.plugin.cells.has(v.ref) ? (f = u.get(v.ref), [4, u.getStructure(v.ref)]) : [2, "continue"];
                  case 1:
                    if (y = D.sent(), v.ref && y && u.plugin.managers.selection.structure.remove({ item: { ref: v.ref, elementIds: (r = v.elementIds) !== null && r !== void 0 ? r : $i(y) } }), o.has(v.ref) && o.get(v.ref) !== void 0 ? o.set(v.ref, v.elementIds === void 0 ? void 0 : Pe(Pe([], v.elementIds, !0), o.get(v.ref), !0)) : o.set(v.ref, v.elementIds), n) f.representations.forEach(function(T) {
                      var P, M;
                      if (Kl.has(T.type) && f.dependency.on.length) {
                        var R = f.dependency.on.some(function(O) {
                          return zU(O, n);
                        });
                        R && (!T.isHidden && T.state && ((P = m.plugin.canvas3d) === null || P === void 0 || P.remove(T.state)), f.representations.delete(T.type));
                      }
                      T.type === fe.Surface && (n.elementIds || (T.state && ((M = m.plugin.canvas3d) === null || M === void 0 || M.remove(T.state)), f.representations.delete(T.type)));
                    });
                    else if (!((i = v == null ? void 0 : v.elementIds) === null || i === void 0) && i.length) {
                      for (h = function(T, P) {
                        var M = Object.keys(In).find(function(R) {
                          return In[R].includes(T);
                        });
                        yg(P.state, v.elementIds, T, function(R) {
                          var O;
                          return m.plugin.managers.representation.createTheme(T, R, { color: { name: "multi-theme", props: { themes: f.theme.color[M] } }, size: f.theme.size && (!((O = f.theme.size[M]) === null || O === void 0) && O.length) ? f.theme.size[M][0] : m.plugin.managers.representation.defaultTheme.size[P.type] });
                        }, function(R) {
                          var O;
                          return m.plugin.managers.representation.createTransparencyLayers(R, Pe([], (O = f == null ? void 0 : f.theme.transparency[M]) !== null && O !== void 0 ? O : [], !0));
                        });
                      }, g = 0, x = Array.from(f.representations); g < x.length; g++) C = x[g], b = C[0], _ = C[1], h(b, _);
                      y && (f.model.structure = TS(y, v.elementIds));
                    } else f.representations.forEach(function(T) {
                      var P;
                      !T.isHidden && T.state && ((P = m.plugin.canvas3d) === null || P === void 0 || P.remove(T.state)), f.representations.delete(T.type);
                    });
                    if (!f.dependency.by.length) return [3, 6];
                    A = 0, I = Array.from(new Set(f.dependency.by)), D.label = 2;
                  case 2:
                    return A < I.length ? (w = I[A], (E = u.plugin.cells.get(w)) != null && E.representations.has(fe.IntraInteractions) ? (a = w, [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return [4, u.remove([{ ref: w }], v)];
                  case 4:
                    D.sent(), D.label = 5;
                  case 5:
                    return A++, [3, 2];
                  case 6:
                    return f.representations.size || (f.dependency.on.length && Array.from(new Set(f.dependency.on)).forEach(function(T) {
                      var P = m.plugin.cells.get(T.ref);
                      if (P) {
                        var M = P.dependency.by.findIndex(function(R) {
                          return R === v.ref;
                        });
                        M !== -1 && P.dependency.by.splice(M, 1);
                      }
                    }), u.plugin.cells.delete(v.ref)), [2];
                }
              });
            }, u = this, c = 0, l = t, p.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [5, s(d)]) : [3, 4];
          case 2:
            p.sent(), p.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return a && 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, n) {
    var r, i, a, o, s;
    return ie(this, 0, void 0, function() {
      var u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A;
      return ne(this, function(I) {
        switch (I.label) {
          case 0:
            u = [], c = 0, l = t, I.label = 1;
          case 1:
            return c < l.length ? (d = l[c], m = this.get(d.ref), [4, this.getStructure(d.ref)]) : [3, 8];
          case 2:
            p = I.sent(), v = Xn(p, (r = d.elementIds) !== null && r !== void 0 ? r : [], !0, !0), f = !((i = m.assets) === null || i === void 0) && i.length && (!((a = m.assets[0]) === null || a === void 0) && a.format) ? m.assets[0].format : Nt.Pdb, y = [], h = function(w, E) {
              var D, T, P, M;
              return ne(this, function(R) {
                switch (R.label) {
                  case 0:
                    return D = Object.keys(In).find(function(O) {
                      return In[O].includes(w);
                    }), (T = x0(E.state, d.elementIds)).length ? (P = Xn(v, T), [4, wa[w].create(P, g.plugin.managers.representation.ctx, g.plugin.managers.representation.createTheme(w, P, { color: { name: "multi-theme", props: { themes: m.theme.color[D] } }, size: m.theme.size && (!((o = m.theme.size[D]) === null || o === void 0) && o.length) ? m.theme.size[D][0] : g.plugin.managers.representation.defaultTheme.size[E.type] }))]) : [3, 2];
                  case 1:
                    M = R.sent(), y.push({ state: M, isHidden: (s = n == null ? void 0 : n.isHidden) === null || s === void 0 || s, type: w }), R.label = 2;
                  case 2:
                    return [2];
                }
              });
            }, g = this, x = 0, C = Array.from(m.representations), I.label = 3;
          case 3:
            return x < C.length ? (b = C[x], _ = b[0], A = b[1], [5, h(_, A)]) : [3, 6];
          case 4:
            I.sent(), I.label = 5;
          case 5:
            return x++, [3, 3];
          case 6:
            u.push(this.create({ representations: y, model: { structure: v }, assets: [{ format: f, data: V0(v, f) }], theme: B({}, m.theme) })), this.remove([d]), I.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, n) {
    var r, i, a = this.get(t);
    !((r = n.on) === null || r === void 0) && r.length && (a.dependency.on = a.dependency.on.concat(n.on)), !((i = n.by) === null || i === void 0) && i.length && (a.dependency.by = Array.from(new Set(a.dependency.by.concat(n.by))));
  }, e.prototype.removeDependency = function(t, n) {
    var r, i, a = this;
    !((r = n.on) === null || r === void 0) && r.length && n.on.forEach(function(o) {
      a.plugin.cells.has(o.ref) && (a.get(o.ref).dependency.by = a.get(o.ref).dependency.by.filter(function(s) {
        return s !== t;
      }));
    }), !((i = n.by) === null || i === void 0) && i.length && n.by.forEach(function(o) {
      a.plugin.cells.has(o) && (a.get(o).dependency.on = a.get(o).dependency.on.filter(function(s) {
        return s.ref !== t;
      }));
    });
  }, e.prototype.query = function(t) {
    var n = [];
    return this.plugin.cells.forEach(function(r) {
      r.representations.forEach(function(i) {
        t(r, i) && n.push(r);
      });
    }), n;
  }, e.prototype.traverse = function(t) {
    this.plugin.cells.forEach(function(n) {
      n.representations.forEach(function(r) {
        t(n, r);
      });
    });
  }, e.prototype.getAllDisplayedCellsRef = function() {
    var t = /* @__PURE__ */ new Set();
    return this.plugin.managers.cell.traverse(function(n, r) {
      [fe.Ribbon, fe.BallAndStick, fe.Line, fe.Stick, fe.CPK].includes(r.type) && !r.isHidden && un(n) && t.add(n.ref);
    }), Array.from(t.values());
  }, e.prototype.clearReprState = function(t) {
    var n = this, r = this.get(t), i = /* @__PURE__ */ new Map(), a = r.model.structure;
    if (a) {
      if (a) {
        var o = 0;
        a.units.forEach(function(s) {
          s.elements.forEach(function(u) {
            i.set(u, o++);
          });
        });
      }
      Array.from(r.representations.entries()).forEach(function(s) {
        var u;
        s[0];
        var c = s[1];
        c.state && ((u = n.plugin.canvas3d) === null || u === void 0 || u.remove(c.state), r.representations.set(c.type, { isHidden: c.isHidden, type: c.type, cache: { type: c.type, elementIds: qf(c.state).map(function(l) {
          return i && (i != null && i.has(l)) ? i == null ? void 0 : i.get(l) : l;
        }), isHidden: c.isHidden, params: Kl.has(c.type) ? vA(c.type, c.state) : void 0 } }));
      });
    }
  }, e.prototype.recoveryCache = function(t, n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s;
      return ne(this, function(u) {
        switch (u.label) {
          case 0:
            return r = this.get(t), i = Array.from(r.representations.values()), n ? [4, this.recoveryReprCache(r, n)] : [3, 2];
          case 1:
            u.sent(), u.label = 2;
          case 2:
            a = 0, o = i, u.label = 3;
          case 3:
            return a < o.length ? (s = o[a]).cache ? [4, this.recoveryReprCache(r, s.cache)] : [3, 5] : [3, 6];
          case 4:
            u.sent(), u.label = 5;
          case 5:
            return a++, [3, 3];
          case 6:
            return [2];
        }
      });
    });
  }, e.prototype.recoveryReprCache = function(t, n) {
    var r, i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u;
      return ne(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (a = c.sent()) ? (o = Object.keys(In).find(function(l) {
              return In[l].includes(n.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: n.type, elementIds: n.elementIds, isHidden: n.isHidden, theme: this.plugin.managers.representation.createTheme(n.type, Xn(a, (r = n.elementIds) !== null && r !== void 0 ? r : [], !0), { color: { name: "multi-theme", props: { themes: s } }, size: t.theme.size && (!((i = t.theme.size[o]) === null || i === void 0) && i.length) ? t.theme.size[o][0] : this.plugin.managers.representation.defaultTheme.size[n.type] }), transparency: u })]) : [2];
          case 2:
            return c.sent(), [2];
        }
      });
    });
  }, e.prototype.overlapLigands = function(t, n, r) {
    return ie(this, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, m, p, v;
      return ne(this, function(f) {
        switch (f.label) {
          case 0:
            return i = function(y) {
              var h = Le(y), g = Le.readLine(h).trim(), x = Le.readLine(h).trim(), C = Le.readLine(h).trim(), b = Le.readLine(h), _ = +b.substr(0, 3), A = +b.substr(3, 3);
              return { title: g, program: x, comment: C, atoms: y3(h, _), bonds: b3(h, A), formalCharges: _3(h) };
            }(r), a = [Array.from(i.atoms.x.toArray()).reduce(function(y, h) {
              return y + h;
            }) / i.atoms.count, Array.from(i.atoms.y.toArray()).reduce(function(y, h) {
              return y + h;
            }) / i.atoms.count, Array.from(i.atoms.z.toArray()).reduce(function(y, h) {
              return y + h;
            }) / i.atoms.count], [4, this.getStructure(t)];
          case 1:
            for (o = f.sent(), s = Yn(o, n), u = Se.getBoundary(s).sphere.center, c = [u[0] - a[0], u[1] - a[1], u[2] - a[2]], l = [], d = /* @__PURE__ */ new Map(), p = 0, v = i.formalCharges.atomIdx.rowCount; p < v; p++) d.set(i.formalCharges.atomIdx.value(p) - 1, i.formalCharges.charge.value(p));
            for (p = 0, v = i.atoms.count; p < v; p++) l.push({ x: i.atoms.x.value(p) + c[0], y: i.atoms.y.value(p) + c[1], z: i.atoms.z.value(p) + c[2], type_symbol: i.atoms.type_symbol.value(p), charge: d.get(p) || 0 });
            for (m = [], p = 0, v = i.bonds.count; p < v; p++) m.push({ a: i.bonds.atomIdxA.value(p), b: i.bonds.atomIdxB.value(p), order: i.bonds.order.value(p) });
            return [2, { atoms: l, bonds: m }];
        }
      });
    });
  }, e.prototype.getUnitCellData = function(t) {
    var n = this.get(t);
    if (n) {
      var r = un(n);
      return qU(r);
    }
  }, e;
}(), pl = { createByTrajectory: function(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f;
    return ne(this, function(y) {
      switch (y.label) {
        case 0:
          return n = e.trajectory, r = e.frameIndex, i = e.mode, a = n, o = Be.ofModel(a.getFrameAtIndex(r)), s = [], i !== lc.Drug ? [3, 7] : (u = $v(o), c = u.polymer, l = u.other, c.length ? (d = Xn(o, c)).elementCount ? [4, ei.attach({ runtime: Ji, assetManager: new ds() }, d, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          y.sent(), y.label = 2;
        case 2:
          return (m = us.factory(t, us.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: d }, { value: ye(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: d }) }), [4, m.createOrUpdate(B(B({}, us.defaultValues), { quality: "auto" }), d).run()];
        case 3:
          y.sent(), s.push({ state: m, type: fe.Ribbon }), y.label = 4;
        case 4:
          return l.length ? (p = Xn(o, l), (v = yi.factory(t, yi.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: p }, { carbonColor: { name: "uniform", params: { value: ye(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: p }) }), [4, v.createOrUpdate(B(B({}, yi.defaultValues), { quality: "auto" }), p).run()]) : [3, 6];
        case 5:
          y.sent(), s.push({ state: v, type: fe.BallAndStick }), y.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (f = yi.factory(t, yi.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: o }), size: t.sizeThemeRegistry.create("physical", { structure: o }) }), [4, f.createOrUpdate(B(B({}, yi.defaultValues), { quality: "auto" }), o).run()];
        case 8:
          y.sent(), s.push({ state: f, type: fe.BallAndStick }), y.label = 9;
        case 9:
          return [2, { model: a, reprs: s }];
      }
    });
  });
}, create: function(e, t) {
  return ie(this, 0, void 0, function() {
    var n, r, i, a, o, s, u, c, l, d, m, p, v, f, y;
    return ne(this, function(h) {
      switch (h.label) {
        case 0:
          return n = e.model, r = e.coordinates, i = e.frameIndex, a = e.mode, o = pn.trajectoryFromModelAndCoordinates(n, r), s = Be.ofModel(o.getFrameAtIndex(i)), u = [], a !== lc.Drug ? [3, 7] : (c = $v(s), l = c.polymer, d = c.other, l.length ? (m = Xn(s, l)).elementCount ? [4, ei.attach({ runtime: Ji, assetManager: new ds() }, m, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          h.sent(), h.label = 2;
        case 2:
          return (p = us.factory(t, us.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: m }, { value: ye(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: m }) }), [4, p.createOrUpdate(B(B({}, us.defaultValues), { quality: "auto" }), m).run()];
        case 3:
          h.sent(), u.push({ state: p, type: fe.Ribbon }), h.label = 4;
        case 4:
          return d.length ? (v = Xn(s, d), (f = yi.factory(t, yi.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: v }, { carbonColor: { name: "uniform", params: { value: ye(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: v }) }), [4, f.createOrUpdate(B(B({}, yi.defaultValues), { quality: "auto" }), v).run()]) : [3, 6];
        case 5:
          h.sent(), u.push({ state: f, type: fe.BallAndStick }), h.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (y = yi.factory(t, yi.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: s }), size: t.sizeThemeRegistry.create("physical", { structure: s }) }), [4, y.createOrUpdate(B(B({}, yi.defaultValues), { quality: "auto" }), s).run()];
        case 8:
          h.sent(), u.push({ state: y, type: fe.BallAndStick }), h.label = 9;
        case 9:
          return [2, { model: o, reprs: u }];
      }
    });
  });
}, update: function(e, t, n) {
  return ie(this, 0, void 0, function() {
    var r, i, a, o;
    return ne(this, function(s) {
      switch (s.label) {
        case 0:
          return r = t.trajectory, i = t.frameIndex, a = t.mode, (o = Be.ofModel(r.getFrameAtIndex(i))).elementCount ? [4, ei.attach({ runtime: Ji, assetManager: new ds() }, 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(In).find(function(m) {
              return In[m].includes(u.type);
            }), l = Se.toExpression(Be.toStructureElementLoci(u.getLoci().structure)), d = Yl(Xl(o, l));
            u.setTheme({ color: n.colorThemeRegistry.create(a === lc.Drug ? c === tt.RIBBON ? "uniform" : "element-symbol" : "material-element-symbol", { structure: d }, a === lc.Drug ? c === tt.RIBBON ? { value: ye(14474728) } : { carbonColor: { name: "uniform", params: { value: ye(14474728) } } } : {}), size: n.sizeThemeRegistry.create(c === tt.RIBBON ? "uniform" : "physical", { structure: d }, u.theme.size.props) }), u.createOrUpdate({}, d).run();
          }))];
        case 3:
          return s.sent(), [2];
      }
    });
  });
} }, x8 = function() {
  function e(t) {
    this.ev = wi.create(), this.updated = this.ev(), this.plugin = t, this.paused = !1;
  }
  return e.prototype.import = function(t, n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o, s, u;
      return ne(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, gc(t.data)];
          case 1:
            return r = c.sent(), [4, As[t.format].parse(r)];
          case 2:
            return i = c.sent(), [4, JN(n.data)];
          case 3:
            return a = c.sent(), [4, As[n.format].parse(a)];
          case 4:
            return o = c.sent(), [4, pl.create({ model: t.format === Nt.Gro ? i : i[0].model, coordinates: o, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return s = c.sent(), u = wr(Be.toStructureElementLoci(t.format === Nt.Gro ? Be.ofModel(s.model.frames[0], { dynamicBonds: !0 }) : i[0])), [2, this.plugin.managers.cell.create({ representations: s.reprs.map(function(l) {
              return B({ isHidden: !1 }, l);
            }), model: { trajectory: { state: s.model, frameIndex: 0 } }, assets: [{ data: r, format: t.format }, { data: a, format: n.format }], theme: { color: { Atom: [B({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[tt.ATOM])], Ribbon: [B({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[tt.RIBBON])] } } })];
        }
      });
    });
  }, e.prototype.importWithGro = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i;
      return ne(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, gc(t.data)];
          case 1:
            return n = a.sent(), [4, IA.parse(n)];
          case 2:
            return r = a.sent(), [4, pl.createByTrajectory({ trajectory: r, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 3:
            return i = a.sent(), [2, this.plugin.managers.cell.create({ representations: i.reprs.map(function(o) {
              return B({ isHidden: !1 }, o);
            }), model: { trajectory: { state: i.model, frameIndex: 0 } }, assets: [{ data: n, format: t.format }] })];
        }
      });
    });
  }, e.prototype.importTrajectory = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i, a;
      return ne(this, function(o) {
        switch (o.label) {
          case 0:
            return Cg[t.format] ? typeof t.data == "string" || t.data instanceof File ? [4, gc(t.data)] : [3, 2] : [2];
          case 1:
            return r = o.sent(), [3, 3];
          case 2:
            r = t.data, o.label = 3;
          case 3:
            return n = r, [4, Cg[t.format].parse(n)];
          case 4:
            return i = o.sent(), [4, pl.createByTrajectory({ trajectory: i, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return a = o.sent(), [2, this.plugin.managers.cell.create({ representations: a.reprs.map(function(s) {
              return B({ isHidden: !1 }, s);
            }), model: { trajectory: { state: a.model, frameIndex: 0 } }, assets: [{ data: n, format: t.format }] })];
        }
      });
    });
  }, e.prototype.getTrajectoryCell = function(t) {
    var n = [];
    if (t) {
      var r = this.plugin.cells.get(t);
      if (!(r != null && r.model.trajectory)) return [];
      n.push(r);
    } else this.plugin.cells.forEach(function(i) {
      i.model.trajectory && n.push(i);
    });
    return n;
  }, e.prototype.play = function(t) {
    var n = this;
    this.paused = !1;
    var r = function() {
      n.next(t), n.paused || window.requestAnimationFrame(r);
    };
    window.requestAnimationFrame(r);
  }, e.prototype.next = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i, a, o, s, u, c;
      return ne(this, function(l) {
        switch (l.label) {
          case 0:
            n = this.getTrajectoryCell(t), r = 0, i = n, l.label = 1;
          case 1:
            return r < i.length ? (a = i[r], o = a.model.trajectory, s = o.state, u = o.frameIndex, c = u >= s.frameCount - 1 ? 0 : u + 1, [4, pl.update(Array.from(a.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(), a.model.trajectory.frameIndex = c, this.updateDependencyByCells(t), t && this.updated.next({ ref: t, frame: c }), l.label = 3;
          case 3:
            return r++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.setFrameIndex = function(t, n) {
    var r;
    return ie(this, 0, void 0, function() {
      var i, a, o, s;
      return ne(this, function(u) {
        switch (u.label) {
          case 0:
            i = this.getTrajectoryCell(n), a = 0, o = i, u.label = 1;
          case 1:
            return a < o.length ? (s = o[a], [4, pl.update(Array.from(s.representations).map(function(c) {
              return c[0], c[1].state;
            }), { trajectory: (r = s.model.trajectory) === null || r === void 0 ? void 0 : r.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 a++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.updateDependencyByCells = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i, a, o, s, u, c, l, d = this;
      return ne(this, function(m) {
        for (n = this.getTrajectoryCell(t), r = 0, i = n; r < i.length; r++) if ((a = i[r]).dependency.by.length) for (o = function(p) {
          var v = s.plugin.cells.get(p);
          v && v.representations.forEach(function(f, y) {
            y === fe.IntraInteractions && d.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.trajectory.updateDependencyByCells"), Object.keys(Wd).includes(y) && d.plugin.managers.representation.updateMeasurement({ items: v.dependency.on, ref: p });
          });
        }, s = this, u = 0, c = a.dependency.by; u < c.length; u++) l = c[u], o(l);
        return [2];
      });
    });
  }, e.prototype.mergeDumpAndPymatgen = function(t, n) {
    return ie(this, 0, void 0, function() {
      var r, i, a;
      return ne(this, function(o) {
        switch (o.label) {
          case 0:
            return (r = this.getTrajectoryCell(n)).length && r[0].assets[0].format === Nt.Dump ? (i = r[0], [4, IH(i.assets[0].data, t)]) : [2];
          case 1:
            return a = o.sent(), i.model.trajectory = { state: a, frameIndex: i.model.trajectory.frameIndex }, [4, pl.update(Array.from(i.representations).map(function(s) {
              return s[0], s[1].state;
            }), { trajectory: a, frameIndex: i.model.trajectory.frameIndex, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 2:
            return o.sent(), i.model.trajectory.frameIndex = i.model.trajectory.frameIndex, this.updateDependencyByCells(n), [2];
        }
      });
    });
  }, e.prototype.pause = function() {
    this.paused = !0;
  }, e;
}();
function S8(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 wA(e, t) {
  if (t === void 0 && (t = "download"), e) if ("download" in HTMLAnchorElement.prototype) {
    var n = document.createElement("a");
    n.download = t, n.rel = "noopener", typeof e == "string" ? (n.href = e, S8(n)) : (n.href = URL.createObjectURL(e), setTimeout(function() {
      return URL.revokeObjectURL(n.href);
    }, 4e4), setTimeout(function() {
      return S8(n);
    }));
  } else if (typeof navigator < "u" && navigator.msSaveOrOpenBlob) navigator.msSaveOrOpenBlob(e, t);
  else {
    var r = window.navigator.userAgent, i = /Safari/i.test(r), a = /CriOS\/[\d]+/.test(r), o = function(c) {
      var l;
      l = a ? c : c.replace(/^data:[^;]*;/, "data:attachment/file;"), window.open(l, "_blank") || (window.location.href = l);
    };
    if ((i || a) && 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 ba, df, C8 = function() {
  function e(t) {
    this.ev = wi.create(), this.event = { changed: this.ev() }, this.plugin = t;
  }
  return e.prototype.setSnapshot = function(t, n) {
    var r, i, a, o, s;
    return ie(this, 0, void 0, function() {
      var u, c, l, d, m, p, v, f;
      return ne(this, function(y) {
        switch (y.label) {
          case 0:
            for (u = /* @__PURE__ */ new Map(), ((r = t == null ? void 0 : t.params) === null || r === void 0 ? void 0 : r.showPolarHydrogenOnly) !== void 0 && (this.plugin.managers.representation.showPolarHydrogenOnly = t.params.showPolarHydrogenOnly), ((i = t == null ? void 0 : t.params) === null || i === void 0 ? void 0 : i.interactionParams) !== void 0 && (this.plugin.managers.representation.interactionParams = t.params.interactionParams), c = 0, l = t.cells; c < l.length; c++) f = l[c], u.set(f.ref, { ref: f.ref, assets: f.assets, dependency: f.dependency, model: {}, representations: /* @__PURE__ */ new Map(), theme: f.theme });
            this.plugin.cells = u, d = function(h) {
              var g, x, C, b, _, A, I, w, E, D, T, P, M, R, O, L, F, G, V, U, q;
              return ne(this, function(H) {
                switch (H.label) {
                  case 0:
                    return g = h.model, x = g.structure, g.trajectory, C = g.other, b = h.representations, _ = h.dependency, A = h.theme, I = void 0, x ? b != null && b.some(function(K) {
                      return K.isHidden !== !0;
                    }) ? (w = typeof x.data == "string" || x.data instanceof File, T = (D = As[x.format]).parse, w ? [4, gc(x.data)] : [3, 2]) : [3, 7] : [3, 8];
                  case 1:
                    return P = H.sent(), [3, 3];
                  case 2:
                    P = x.data, H.label = 3;
                  case 3:
                    return [4, T.apply(D, [P])];
                  case 4:
                    return E = H.sent(), x.format !== Nt.Pdb || !E[0].elementCount || pn.hasSecondaryStructure((a = E[0]) === null || a === void 0 ? void 0 : a.model) ? [3, 6] : [4, ei.attach({}, E[0], { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
                  case 5:
                    H.sent(), H.label = 6;
                  case 6:
                    return I = E[0], m.plugin.managers.cell.update(h.ref, { representations: [], model: { structure: E[0] }, assets: [{ format: x.format, data: x.data }] }), [3, 8];
                  case 7:
                    m.plugin.managers.cell.update(h.ref, { representations: [], model: { structure: void 0 }, assets: [{ format: x.format, data: x.data }] }), H.label = 8;
                  case 8:
                    return M = h.theme, A && (R = {}, Object.keys(A).forEach(function(K) {
                      var j = A[K];
                      if (j) {
                        var W = {};
                        Object.keys(j).forEach(function(Z) {
                          var Y = j[Z], te = [];
                          Y != null && Y.length && Y.forEach(function(ee) {
                            te.push(B(B({}, ee), { elementIds: ee.elementIds ? G1(ee.elementIds) : ee.elementIds }));
                          }), W[Z] = te;
                        }), R[K] = W;
                      }
                    }), M = R, m.plugin.managers.cell.update(h.ref, { representations: [], model: {}, theme: R })), b != null && b.length ? I ? [3, 9] : (m.plugin.managers.cell.update(h.ref, { representations: b == null ? void 0 : b.map(function(K) {
                      var j;
                      return K.cache ? K : B(B({}, K), { elementIds: [], cache: B(B({}, K), { elementIds: !((j = K.elementIds) === null || j === void 0) && j.length ? G1(K.elementIds) : K.elementIds }) });
                    }), model: {} }), [3, 13]) : [3, 13];
                  case 9:
                    O = function(K) {
                      var j, W, Z, Y;
                      return ne(this, function(te) {
                        switch (te.label) {
                          case 0:
                            return !((o = K.elementIds) === null || o === void 0) && o.length ? (j = Object.keys(In).find(function(ee) {
                              return In[ee].includes(K.type);
                            }), W = M.color[j], Z = M.transparency ? M.transparency[j] : void 0, Y = K.elementIds ? G1(K.elementIds) : [], [4, m.plugin.managers.representation.addMolecularRepr(h.ref, { reprType: K.type, elementIds: Y, isHidden: K.isHidden, theme: m.plugin.managers.representation.createTheme(K.type, Xn(I, Y, !0), { color: { name: "multi-theme", props: { themes: W } }, size: M.size && (!((s = M.size[j]) === null || s === void 0) && s.length) ? M.size[j][0] : m.plugin.managers.representation.defaultTheme.size[K.type] }), transparency: Z })]) : [3, 2];
                          case 1:
                            te.sent(), te.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, L = 0, F = b, H.label = 10;
                  case 10:
                    return L < F.length ? (G = F[L], [5, O(G)]) : [3, 13];
                  case 11:
                    H.sent(), H.label = 12;
                  case 12:
                    return L++, [3, 10];
                  case 13:
                    return C ? (G = b[0], C.serverData && !C.data && n ? [4, n(C.serverData)] : [3, 15]) : [3, 18];
                  case 14:
                    return U = H.sent(), [3, 16];
                  case 15:
                    U = C, H.label = 16;
                  case 16:
                    return V = U, [4, m.plugin.managers.representation.createOther({ data: G.type === fe.IsoSurface ? new File([V.data], V.name) : V, serverData: C.serverData, type: G.type, ref: h.ref, isHidden: G.isHidden })];
                  case 17:
                    H.sent(), H.label = 18;
                  case 18:
                    return _.on.length ? (q = _.on.map(function(K) {
                      return B(B({}, K), { elementIds: K.elementIds ? G1(K.elementIds) : K.elementIds });
                    }), [4, m.plugin.managers.representation.createMeasurement({ items: q, type: b[0].type, ref: h.ref, props: b[0].params, isHidden: b[0].isHidden })]) : [3, 20];
                  case 19:
                    H.sent(), m.plugin.managers.cell.update(h.ref, { representations: [], model: {}, dependency: B(B({}, h.dependency), { on: q }) }), H.label = 20;
                  case 20:
                    return [2];
                }
              });
            }, m = this, p = 0, v = t.cells, y.label = 1;
          case 1:
            return p < v.length ? (f = v[p], [5, d(f)]) : [3, 4];
          case 2:
            y.sent(), y.label = 3;
          case 3:
            return p++, [3, 1];
          case 4:
            return this.refresh(), [2];
        }
      });
    });
  }, e.prototype.getSnapshot = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i = this;
      return ne(this, function(a) {
        switch (a.label) {
          case 0:
            return this.timestamp = Date.now(), n = [], r = {}, 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(m) {
                    c.set(m, l++);
                  });
                }), r[u] = c;
              }
            }), [4, Promise.all(Array.from(this.plugin.cells.values()).map(function(o) {
              return ie(i, 0, void 0, function() {
                var s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D;
                return ne(this, function(T) {
                  switch (T.label) {
                    case 0:
                      return s = o.representations, u = o.assets, c = o.model, l = c.structure, d = c.trajectory, m = c.other, p = function(P, M) {
                        var R = {};
                        for (var O in P) Object.prototype.hasOwnProperty.call(P, O) && M.indexOf(O) < 0 && (R[O] = P[O]);
                        if (P != null && typeof Object.getOwnPropertySymbols == "function") {
                          var L = 0;
                          for (O = Object.getOwnPropertySymbols(P); L < O.length; L++) M.indexOf(O[L]) < 0 && Object.prototype.propertyIsEnumerable.call(P, O[L]) && (R[O[L]] = P[O[L]]);
                        }
                        return R;
                      }(o, ["representations", "assets", "model"]), (v = xs(p)).model = {}, s.get(fe.IntraInteractions) || s.get(fe.BetweenInteractions) ? [2] : (l ? v.model.structure = { data: (I = (A = V0(l, u == null ? void 0 : u[0].format)) !== null && A !== void 0 ? A : u == null ? void 0 : u[0].data) !== null && I !== void 0 ? I : ea(l).sourceData.data, format: u == null ? void 0 : u[0].format } : u && (v.assets = u), d && (v.model.trajectory = { data: "提取的结构信息", format: u == null ? void 0 : u[0].format }), m ? s.get(fe.IsoSurface) ? (f = !!o.model.other.serverData, y = f ? o.model.other.data : o.model.other, h = v.model, t ? (g = { serverData: f ? o.model.other.serverData : o.model.other }, [3, 3]) : [3, 1]) : [3, 4] : [3, 5]);
                    case 1:
                      return _ = {}, x = Uint8Array.bind, [4, y.arrayBuffer()];
                    case 2:
                      _.data = new (x.apply(Uint8Array, [void 0, T.sent()]))(), _.name = y.name, _.serverData = f ? o.model.other.serverData : o.model.other, g = _, T.label = 3;
                    case 3:
                      return h.other = g, [3, 5];
                    case 4:
                      v.model.other = o.model.other, T.label = 5;
                    case 5:
                      return s != null && s.size && (v.representations = [], C = r[p.ref], s.forEach(function(P) {
                        v.representations.push({ type: P.type, elementIds: P.state ? Dh(qf(P.state).map(function(M) {
                          return C && (C != null && C.has(M)) ? C == null ? void 0 : C.get(M) : M;
                        })) : [], isHidden: P.isHidden, params: Kl.has(P.type) && P.state ? vA(P.type, P.state) : void 0, cache: P.cache });
                      }), p.theme && Object.keys(p.theme).forEach(function(P) {
                        var M = p.theme[P];
                        if (M) {
                          var R = {};
                          Object.keys(M).forEach(function(O) {
                            var L = M[O], F = [];
                            L != null && L.length && L.forEach(function(G) {
                              F.push(B(B({}, G), { elementIds: Dh(G.elementIds && C ? G.elementIds.map(function(V) {
                                var U;
                                return (U = C.get(V)) !== null && U !== void 0 ? U : V;
                              }) : G.elementIds) }));
                            }), R[O] = F;
                          }), v.theme[P] = R;
                        }
                      })), !((E = (w = p.dependency) === null || w === void 0 ? void 0 : w.on) === null || E === void 0) && E.length && (b = [], (D = p.dependency) === null || D === void 0 || D.on.forEach(function(P) {
                        var M = r[p.ref];
                        b.push(B(B({}, P), { elementIds: Dh(P.elementIds && M ? P.elementIds.map(function(R) {
                          var O;
                          return (O = M.get(R)) !== null && O !== void 0 ? O : R;
                        }) : P.elementIds) }));
                      }), v.dependency.on = b), n.push(v), [2];
                  }
                });
              });
            }))];
          case 1:
            return a.sent(), [2, { cells: n, timestamp: this.timestamp, params: { interactionParams: xs(this.plugin.managers.representation.interactionParams), showPolarHydrogenOnly: this.plugin.managers.representation.showPolarHydrogenOnly } }];
        }
      });
    });
  }, e.prototype.refresh = function() {
    var t, n, r, i = this.plugin;
    (t = i.canvas3d) === null || t === void 0 || t.pause(!0), (n = i.canvas3d) === null || n === void 0 || n.clear(), i.cells.forEach(function(a) {
      a.representations.forEach(function(o) {
        var s;
        !o.isHidden && o.state && ((s = i.canvas3d) === null || s === void 0 || s.add(o.state));
      });
    }), (r = i.canvas3d) === null || r === void 0 || r.animate();
  }, e.prototype.downloadAsImage = function(t, n) {
    var r, i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, m, p, v, f, y, h, g;
      return ne(this, function(x) {
        switch (x.label) {
          case 0:
            if (a = n || { width: ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.webgl.gl.drawingBufferWidth) || 0, height: ((i = this.plugin.canvas3d) === null || i === void 0 ? void 0 : i.webgl.gl.drawingBufferHeight) || 0 }, o = a.width, s = a.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, m = d.colorBufferFloat, p = d.textureFloat, v = l.props.postprocessing.occlusion, f = l.getImagePass({ transparentBackground: !0, cameraHelper: { axes: { name: "off", params: {} } }, multiSample: B(B({}, l.props.multiSample), { mode: "on", sampleLevel: m && p ? 4 : 2 }), postprocessing: B(B({}, l.props.postprocessing), { occlusion: v.name === "on" ? { name: "on", params: B(B({}, v.params), { samples: 128, resolutionScale: l.webgl.pixelRatio }) } : v }), marking: B({}, l.props.marking) }), y = f.getImageData(o, s, c), (h = document.createElement("canvas")).width = y.width, h.height = y.height, !(g = h.getContext("2d"))) throw new Error("Could not create canvas 2d context");
            return g.putImageData(y, 0, 0), [4, $N(h, "png")];
          case 1:
            return wA(x.sent(), t), [2];
        }
      });
    });
  }, e;
}(), MH = { Dihedral: fe.Dihedral, Distance: fe.Distance, Angle: fe.Angle, Label: fe.Label, "Molecular Surface": fe.Surface }, DH = function() {
  function e(t) {
    var n = this;
    this.ev = wi.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(r) {
      var i = r.current, a = i.repr;
      if (i.loci.kind !== "empty-loci") {
        var o = MH[a.label];
        o === fe.Surface && (r.current.loci = r.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) === a && (n.selection.has(s.ref) ? r.button !== 2 && n.remove({ item: { ref: s.ref }, loci: r.current }) : n.add({ item: { ref: s.ref }, loci: r.current }));
        });
      } else n.clear();
    });
  }
  return e.prototype.add = function(t) {
    var n, r, i = t.item.ref;
    this.selection.add(i);
    var a = this.plugin.cells.get(i);
    if (a) {
      var o = Array.from(a.representations.values())[0];
      if (t != null && t.loci || o.state) {
        var s = (n = t.loci) !== null && n !== void 0 ? n : { repr: o.state, loci: o.state.getLoci() };
        (r = this.plugin.canvas3d) === null || r === void 0 || r.mark(s, $e.Select), this.event.add.next({ ref: i, loci: s }), this.prev.set(i, s), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.remove = function(t) {
    var n, r, i = t.item.ref;
    this.selection.delete(i);
    var a = this.plugin.cells.get(i);
    if (a) {
      var o = Array.from(a.representations.values())[0];
      if (o.state) {
        var s = (n = t.loci) !== null && n !== void 0 ? n : { repr: o.state, loci: o.state.getLoci() };
        (r = this.plugin.canvas3d) === null || r === void 0 || r.mark(s, $e.Deselect), this.event.remove.next({ ref: i, loci: s }), this.prev.delete(i), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.clear = function() {
    var t = this;
    this.selection.clear(), this.prev.forEach(function(n) {
      var r;
      (r = t.plugin.canvas3d) === null || r === void 0 || r.mark(n, $e.Deselect);
    }), this.prev.clear(), this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e;
}(), BH = function() {
  function e(t) {
    var n = this;
    this.ev = wi.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(r) {
      if (r.current.loci.kind === "element-loci" && n.plugin.cells.forEach(function(s, u) {
        var c;
        if (s != null && s.model.structure && Ja(s == null ? void 0 : s.model.structure) === Ja(r.current.loci.structure) || s.model.trajectory && (s == null ? void 0 : s.model.trajectory.state.getFrameAtIndex(s.model.trajectory.frameIndex).id) === Ja(r.current.loci.structure)) {
          var l = un(s);
          r.current.loci = rn.normalize(Yn(l, wr(r.current.loci)), n.lociGranularity, !0);
          var d = wr(r.current.loci), m = new Set((c = n.selection.get(u)) !== null && c !== void 0 ? c : []), p = m.size ? d.filter(function(v) {
            return !m.has(v);
          }) : d;
          r.button !== 2 && p.length === 0 ? n.remove({ item: { ref: u, elementIds: d }, reprLoci: r.current }) : n.add({ item: { ref: u, elementIds: p }, reprLoci: r.current });
        }
      }), r.current.loci.kind === "bond-loci") {
        var i = r.current.loci;
        r.current.loci = rn.normalize(r.current.loci, n.lociGranularity, !0);
        var a = /* @__PURE__ */ new Set();
        i.bonds.forEach(function(s) {
          a.add(s.aUnit.elements[s.aIndex]), a.add(s.bUnit.elements[s.bIndex]);
        });
        var o = wr(r.current.loci);
        n.plugin.cells.forEach(function(s, u) {
          var c;
          if (s != null && s.model.structure && Ja(s == null ? void 0 : s.model.structure) === Ja(i.bonds[0].aStructure)) {
            var l = new Set((c = n.selection.get(u)) !== null && c !== void 0 ? c : []), d = l.size ? o.filter(function(m) {
              return !l.has(m);
            }) : o;
            r.button !== 2 && d.length === 0 ? n.remove({ item: { ref: u, elementIds: o }, reprLoci: r.current }) : n.add({ item: { ref: u, elementIds: d }, reprLoci: r.current });
          }
        });
      }
      r.current.loci.kind === "empty-loci" && n.clear();
    });
  }
  return Object.defineProperty(e.prototype, "granularity", { get: function() {
    return jN[this.lociGranularity];
  }, enumerable: !1, configurable: !0 }), e.prototype.getSelectionCellItems = function(t, n) {
    var r = this;
    t === void 0 && (t = !1), n === void 0 && (n = !1);
    var i = /* @__PURE__ */ new Map();
    n && Array.from(this.selection.keys()).forEach(function(o) {
      var s = r.plugin.managers.cell.get(o);
      if (s) {
        var u = Array.from(s.representations.entries()).filter(function(c) {
          var l = c[0];
          return ac.has(l);
        }).reduce(function(c, l) {
          l[0];
          var d = l[1], m = d.state ? qf(d.state) : [];
          return Pe(Pe([], c, !0), m, !0);
        }, []);
        i.set(o, new Set(u));
      }
    });
    var a = Array.from(this.selection).map(function(o) {
      var s = o[0], u = o[1], c = [];
      if (n) {
        var l = r.plugin.managers.cell.get(s), d = un(l);
        u.forEach(function(m) {
          var p = d.units.filter(function(v) {
            return _e.has(v.elements, m);
          })[0];
          gs(d, p, p.elements.indexOf(m), function(v, f) {
            var y;
            v.model.atomicHierarchy.derived.atom.atomicNumber[v.elements[f]] !== 1 || !((y = i.get(s)) === null || y === void 0) && y.has(v.elements[f]) || c.push(v.elements[f]);
          });
        });
      }
      return { ref: s, elementIds: Array.from(new Set(Pe(Pe([], u, !0), c, !0)).values()) };
    }).filter(function(o) {
      var s;
      return (s = o.elementIds) === null || s === void 0 ? void 0 : s.length;
    });
    return t && !a.length ? BS(this.plugin) : a;
  }, e.prototype.getSelection = function() {
    return Array.from(this.selection).reduce(function(t, n) {
      var r;
      return B(B({}, t), ((r = {})[n[0]] = n[1], r));
    }, {});
  }, e.prototype.add = function(t, n, r) {
    var i, a, o = this;
    n === void 0 && (n = !0), r === void 0 && (r = !1);
    var s = t.item, u = s.ref, c = s.elementIds;
    if (!c || c.length) {
      this.selection.set(u, Array.from(new Set(Pe(Pe([], (i = this.selection.get(u)) !== null && i !== void 0 ? i : [], !0), c ?? [], !0))));
      var l = this.plugin.cells.get(u);
      if (l) {
        var d = un(l);
        if (d) {
          var m, p = this.selection.get(u);
          l == null || l.representations.forEach(function(v) {
            var f;
            if (!v.isHidden && v.state) {
              var y = n ? rn.normalize(Se.intersect(Yn(Li(v.state), p), Yr(v.state.getLoci())), o.lociGranularity, !0) : Se.intersect(Yn(Li(v.state), p), Yr(v.state.getLoci()));
              m = { loci: y, repr: v.state }, (f = o.plugin.canvas3d) === null || f === void 0 || f.mark(m, $e.Select);
            }
          }), this.prev.push({ ref: u, elementIds: c }), r || (this.event.add.next({ loci: (a = t.reprLoci) !== null && a !== void 0 ? a : { loci: Yn(d, p) }, item: t.item }), this.plugin.managers.selection.event.changed.next({}));
        }
      }
    } else console.warn("add selection, elementIds is empty");
  }, e.prototype.remove = function(t, n, r) {
    var i, a = this;
    n === void 0 && (n = !0), r === void 0 && (r = !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(y) {
          d.has(y) ? c.add(y) : l.push(y);
        }), l.length ? this.selection.set(s, l) : this.selection.delete(s);
        var m, p = this.plugin.cells.get(s), v = (i = this.selection.get(s)) !== null && i !== void 0 ? i : [];
        p == null || p.representations.forEach(function(y) {
          var h, g;
          if (!y.isHidden && y.state) {
            var x = n ? rn.normalize(Se.intersect(Yn(Li(y.state), v), Yr(y.state.getLoci())), a.lociGranularity, !0) : Se.intersect(Yn(Li(y.state), v), Yr(y.state.getLoci()));
            (h = a.plugin.canvas3d) === null || h === void 0 || h.mark({ loci: Yr(y.state.getLoci()), repr: y.state }, $e.Deselect), m = { loci: x, repr: y.state }, (g = a.plugin.canvas3d) === null || g === void 0 || g.mark(m, $e.Select);
          }
        });
        var f = [];
        this.prev.forEach(function(y) {
          var h = y.ref, g = y.elementIds;
          if (h === s) {
            var x = [];
            g == null || g.forEach(function(C) {
              c.has(C) || x.push(C);
            }), x.length && f.push({ ref: h, elementIds: x });
          }
        }), this.prev = f, r || (this.event.remove.next({ loci: m, 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(n) {
      var r = t.plugin.cells.get(n);
      r && (r == null || r.representations.forEach(function(i) {
        var a;
        !i.isHidden && i.state && ((a = t.plugin.canvas3d) === null || a === void 0 || a.mark({ loci: Yr(i.state.getLoci()), repr: i.state }, $e.Deselect));
      }));
    }), this.selection.clear(), this.prev = [], this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e.prototype.setGranularity = function(t) {
    this.lociGranularity = qN[t];
  }, e.prototype.expand = function(t, n) {
    var r = this, i = n ?? this.getSelectionCellItems(), a = this.plugin.managers.cell.getAllDisplayedCellsRef(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), u = Cm(a.map(function(C) {
      return { ref: C };
    }), this.plugin), c = u.unitsMap, l = u.structure;
    c.forEach(function(C, b) {
      o.set(a[b], C.map(function(_) {
        return l.unitMap.get(_);
      })), C.forEach(function(_) {
        return s.set(_, a[b]);
      });
    });
    var d = lS(i.map(function(C) {
      var b, _ = o.get(C.ref), A = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
      _.forEach(function(E, D) {
        A.set(D, new Set(E.elements)), I.set(D, []);
      }), (b = C.elementIds) === null || b === void 0 || b.forEach(function(E) {
        A.forEach(function(D, T) {
          var P;
          D.has(E) && ((P = I.get(T)) === null || P === void 0 || P.push(_[T].elements.indexOf(E)));
        });
      });
      var w = Array.from(I.entries()).filter(function(E) {
        return E[0], E[1].length;
      }).map(function(E) {
        var D = E[0], T = E[1];
        return { unit: _[D], indices: T };
      });
      return w;
    })), m = Se(l, d), p = Se.toExpression(m), v = ot.struct.modifier.union([ot.struct.modifier.exceptBy({ 0: ot.struct.modifier.includeSurroundings({ 0: p, radius: t.radius, "as-whole-residues": t.asWholeResidue }), by: p })]), f = Yl(Xl(l, v)), y = /* @__PURE__ */ new Map();
    f.units.forEach(function(C) {
      var b, _ = s.get(C.id);
      _ && (y.has(_) ? (b = y.get(_)) === null || b === void 0 || b.push.apply(b, C.elements) : y.set(_, Pe([], C.elements, !0)));
    });
    var h = Array.from(y.entries()).map(function(C) {
      return { ref: C[0], elementIds: C[1] };
    }), g = DS(this.plugin, h), x = KN[t.filter];
    t.excludeSelectedAtoms && this.clear(), Object.keys(g).forEach(function(C) {
      var b = [];
      x.forEach(function(_) {
        g[C][_].forEach(function(A) {
          return b.push.apply(b, A.elementIds);
        });
      }), r.add({ item: { ref: C, elementIds: b } }, !1);
    });
  }, e;
}(), A8 = function() {
  function e(t) {
    this.ev = wi.create(), this.event = { changed: this.ev() }, this.plugin = t, this.structure = new BH(t), this.shape = new DH(t);
  }
  return e.prototype.clear = function() {
    this.structure.clear(), this.shape.clear();
  }, e;
}(), I8 = function() {
  function e(t) {
    this.ev = wi.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, n, r = this;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.subscribe(function(i) {
      if (i.current.loci.kind === "empty-loci") {
        if (!r.allowEmptyClick || i.button === 2) return;
        r.plugin.managers.selection.shape.event.change.next(i), r.plugin.managers.selection.structure.event.change.next(i);
      } else if (r.allowSelect) i.current.repr.label === "Molecular Surface" || i.current.loci.kind === "group-loci" ? r.plugin.managers.selection.shape.event.change.next(i) : i.current.loci.kind !== "element-loci" && i.current.loci.kind !== "bond-loci" || r.plugin.managers.selection.structure.event.change.next(i);
      else if (i.button !== 2) return;
      i.button === 2 && r.rightClick.next({ loci: i.current, modifiers: i.modifiers, isEmpty: i.current.loci.kind === "empty-loci", isSelection: !1, reprType: dS[i.current.repr.label] });
    }), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.hover.subscribe(function(i) {
      i.current.loci.kind !== "empty-loci" ? r.plugin.managers.highlight.setHoverSelection(i.current) : r.plugin.managers.highlight.setHoverSelection();
    });
  }, e.prototype.setAllowEmptyClick = function(t) {
    this.allowEmptyClick = t;
  }, e.prototype.setAllowSelect = function(t) {
    this.allowSelect = t;
  }, e;
}(), RH = { interval: void 0, observers: void 0, cRef: "", elementId: -1, totalOffset: S.create(0, 0, 0) }, kH = function() {
  function e(t) {
    this.state = RH, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, n, r = this;
    this.plugin.managers.editor.disabledInteraction = ["click", "drag"], this.plugin.managers.selection.structure.setGranularity(on.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 (r.state.totalOffset.filter(function(a) {
        return a !== 0;
      }).length !== 0 && r.state.elementId !== -1) {
        var i = Pe([], r.state.totalOffset, !0);
        r.state.totalOffset = S.create(0, 0, 0), r.plugin.managers.editor.executeEdit(r.state.cRef, function(a, o) {
          var s = Pe([], a, !0), u = Pe([], o, !0);
          return s.forEach(function(c) {
            c.elementId === r.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: s, editedBondList: u };
        }, function(a, o) {
          var s = Pe([], a, !0), u = Pe([], o, !0);
          return s.forEach(function(c) {
            c.elementId === r.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: s, editedBondList: u };
        });
      }
    }, this.intervalTime), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(function(i) {
      var a = i.current.loci;
      if (a.kind === "element-loci") {
        var o = ve.toArray(a.elements[0].indices);
        if (o.length === 1) {
          r.plugin.cells.forEach(function(u, c) {
            u.model.structure && Se.isSubset(Be.toStructureElementLoci(u.model.structure), a) && (r.state.cRef = c);
          });
          var s = gA(r.plugin, i.pageStart, i.pageEnd);
          S.add(r.state.totalOffset, r.state.totalOffset, s), r.state.elementId = a.elements[0].unit.elements[o[0]];
        }
      }
    });
  }, e.prototype.end = function() {
    var t, n;
    this.state.interval && clearInterval(this.state.interval), (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.drag.observers.pop(), this.state.observers && ((n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(this.state.observers)), this.state.observers = void 0, this.state.cRef = "", this.state.elementId = -1, this.state.totalOffset = S.create(0, 0, 0);
  }, e;
}(), OH = { elementType: "C", drawClickObserver: void 0, position: void 0, isDelete: !1 }, NH = function() {
  function e(t) {
    this.ev = wi.create(), this.state = OH, 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, n, r = this;
    this.plugin.managers.editor.disabledInteraction = ["click"], this.plugin.managers.selection.structure.setGranularity(on.Atom), this.state.drawClickObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.click.observers.pop(), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.click.subscribe(function(i) {
      return ie(r, 0, void 0, function() {
        var a, o, s, u, c, l, d, m, p, v, f, y, h, g = this;
        return ne(this, function(x) {
          switch (x.label) {
            case 0:
              return i.current.loci && i.current.loci.kind === "element-loci" ? (a = i.current.loci, (o = ve.toArray(a.elements[0].indices)).length !== 1 ? [3, 5] : (this.plugin.cells.forEach(function(C, b) {
                C.model.structure && Se.isSubset(Be.toStructureElementLoci(C.model.structure), a) && (s = b);
              }), u = a.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 x.sent(), [3, 4];
            case 2:
              return [4, this.plugin.managers.cell.remove([{ ref: s, elementIds: [u] }])];
            case 3:
              x.sent(), x.label = 4;
            case 4:
              this.event.update.next({ isUpdateHierarchy: !0, cRef: s }), x.label = 5;
            case 5:
              return [3, 9];
            case 6:
              return !i.current.loci || i.current.loci.kind !== "empty-loci" || this.state.isDelete ? [3, 9] : (c = Array.from(this.plugin.cells.entries()).filter(function(C) {
                C[0];
                var b = C[1];
                return b.model.structure && (Array.from(b.representations.values()).findIndex(function(_) {
                  return _.isHidden === !1;
                }) !== -1 || !b.representations.size);
              }), c.length ? (l = ((v = c[0][1].model.structure) === null || v === void 0 ? void 0 : v.units.length) === 0, (d = (((f = this.plugin.canvas3d) === null || f === void 0 ? void 0 : f.getPosition(i.page[0], i.page[1])) || { position: void 0 }).position) ? c.length !== 1 ? [3, 8] : (m = c[0][1].model.structure) ? (p = "".concat(Math.max.apply(Math, Array.from((h = (y = m.model) === null || y === void 0 ? void 0 : y.atomicConformation.atomId.toArray()) !== null && h !== void 0 ? h : [0])) + 1), [4, this.plugin.managers.editor.executeEdit(c[0][0], function(C, b) {
                return { editedAtomList: Pe(Pe([], C, !0), [gd(p, g.state.elementType, d)], !1), editedBondList: Pe([], b, !0), affectedAtomIds: [+p] };
              }, function(C, b) {
                return { editedAtomList: Pe(Pe([], C, !0), [gd(p, g.state.elementType, d)], !1), editedBondList: Pe([], b, !0) };
              })]) : [2] : [3, 9]) : (this.event.update.next({ hasMultiRef: !0 }), [2]));
            case 7:
              return x.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: gd("", this.state.elementType, d) }), x.label = 9;
            case 9:
              return [2];
          }
        });
      });
    });
  }, e.prototype.end = function() {
    var t, n;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.observers.pop(), this.state.drawClickObserver && ((n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.click.subscribe(this.state.drawClickObserver)), this.state.drawClickObserver = void 0;
  }, e.prototype.addAtomByRef = function(t) {
    var n, r, i = this;
    if (this.state.position) {
      var a = this.plugin.cells.get(t);
      if (a) {
        var o = a.model.structure;
        if (o) {
          var s = "".concat(Math.max.apply(Math, Array.from((r = (n = o.model) === null || n === void 0 ? void 0 : n.atomicConformation.atomId.toArray()) !== null && r !== void 0 ? r : [0])) + 1);
          this.plugin.managers.editor.executeEdit(t, function(u, c) {
            return { editedAtomList: Pe(Pe([], u, !0), [gd(s, i.state.elementType, i.state.position)], !1), editedBondList: Pe([], c, !0), affectedAtomIds: [+s] };
          }, function(u, c) {
            return { editedAtomList: Pe(Pe([], u, !0), [gd(s, i.state.elementType, i.state.position)], !1), editedBondList: Pe([], c, !0) };
          }), this.setPosition();
        }
      }
    }
  }, e;
}(), LH = { interval: void 0, dragObserver: void 0, cRef: "", elementIds: [], unit: void 0, rotateOffset: S.create(0, 0, 0), rotateAtoms: [], arrowCRef: void 0, invert: !1, pointA: S.create(0, 0, 0), pointB: S.create(0, 0, 0) }, FH = function() {
  function e(t) {
    this.state = LH, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, n, r;
    return ie(this, 0, void 0, function() {
      var i, a = this;
      return ne(this, function(o) {
        switch (o.label) {
          case 0:
            return this.plugin.managers.editor.disabledInteraction = ["drag"], this.plugin.managers.selection.structure.setGranularity(on.Atom), this.state.dragObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.drag.observers.pop(), i = function() {
              return ie(a, 0, void 0, function() {
                var s, u, c, l, d, m, p, v, f, y, h, g, x, C, b, _, A, I, w, E, D, T, P, M;
                return ne(this, function(R) {
                  switch (R.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(O) {
                        return O[0], O[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 = Pe([], c, !0), !(l = (M = this.plugin.cells.get(u[0][0])) === null || M === void 0 ? void 0 : M.model.structure)) return [2];
                      for (d = l.units.find(function(O) {
                        return _e.has(O.elements, c[0]) && _e.has(O.elements, c[1]);
                      }), this.state.unit = d, p = (m = d).bonds, v = m.conformation, f = m.rings, y = m.elements, h = /* @__PURE__ */ new Map(), g = -1, x = 0, C = p.a.length; x < C; x++) {
                        if (g === -1 && (y[p.a[x]] === c[0] && y[p.b[x]] === c[1] && p.edgeProps.order[x] === 1 || y[p.a[x]] === c[1] && y[p.b[x]] === c[0] && p.edgeProps.order[x] === 1)) {
                          for (b = 0, _ = f.all.length; b < _; b++) if (f.all[b].includes(c[0]) && f.all[b].includes(c[1])) return [2];
                          g = x;
                        }
                        h.has(y[p.a[x]]) ? h.set(y[p.a[x]], Pe(Pe([], h.get(y[p.a[x]]), !0), [y[p.b[x]]], !1)) : h.set(y[p.a[x]], [y[p.b[x]]]);
                      }
                      return g !== -1 && h.get(c[0]).length > 1 && h.get(c[1]).length > 1 ? (A = this.state.invert ? 1 : 0, I = this.state.invert ? 0 : 1, this.state.pointA = S.create(v.x(c[I]), v.y(c[I]), v.z(c[I])), this.state.pointB = S.create(v.x(c[A]), v.y(c[A]), v.z(c[A])), w = this.state, [4, this.plugin.managers.representation.createOther({ data: { center: this.state.pointA, vec: S.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: ye.fromRgb(255, 196, 36), alpha: 0.9 }, type: fe.RotateArrow })]) : [3, 2];
                    case 1:
                      for (w.arrowCRef = R.sent(), E = Pe([], h.get(c[A]).filter(function(O) {
                        return O !== c[I] && O !== c[A];
                      }), !0), D = [c[A]], this.state.rotateAtoms = Pe([], E, !0); E.length; ) T = E.shift(), (P = this.state.rotateAtoms).push.apply(P, h.get(T)), D.push(T), E.push.apply(E, h.get(T).filter(function(O) {
                        return !D.includes(O);
                      }));
                      this.state.rotateAtoms = Array.from(new Set(this.state.rotateAtoms.filter(function(O) {
                        return O !== c[I] && O !== c[A];
                      }))), R.label = 2;
                    case 2:
                      return [2];
                  }
                });
              });
            }, [4, i()];
          case 1:
            return o.sent(), this.plugin.managers.selection.structure.event.add.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = S.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, i();
            }), this.plugin.managers.selection.structure.event.remove.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = S.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, i();
            }), this.plugin.managers.selection.structure.event.clear.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = S.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, a.state.arrowCRef && a.plugin.managers.cell.remove([{ ref: a.state.arrowCRef }]);
            }), (n = this.plugin.canvas3d) === null || n === void 0 || n.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") && (a.state.invert = !a.state.invert, i());
            }), this.state.interval = setInterval(function() {
              if (a.state.rotateOffset.filter(function(d) {
                return d !== 0;
              }).length !== 0 && a.state.cRef && a.state.elementIds.length === 2 && a.state.rotateAtoms.length !== 0) {
                var s = a.state.elementIds, u = a.state.unit.conformation, c = S.angle(S.sub(S.create(0, 0, 0), a.state.pointA, a.state.pointB), S.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]));
                S.cross(S.create(0, 0, 0), S.sub(S.create(0, 0, 0), a.state.pointA, a.state.pointB), S.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]))[2] < 0 && (c = 2 * Math.PI - c);
                var l = 5 * S.distance(S.create(0, 0, 0), S.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2])) * (c < Math.PI && c > 0 ? -1 : 1);
                a.state.rotateOffset = S.create(0, 0, 0), a.plugin.managers.editor.executeEdit(a.state.cRef, function(d, m) {
                  var p = Pe([], d, !0), v = Pe([], m, !0);
                  return p.forEach(function(f) {
                    if (a.state.rotateAtoms.includes(f.elementId)) {
                      var y = d8([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, [f.x, f.y, f.z]);
                      f.x = y[0], f.y = y[1], f.z = y[2];
                    }
                  }), { editedAtomList: p, editedBondList: v };
                }, function(d, m) {
                  var p = Pe([], d, !0), v = Pe([], m, !0);
                  return p.forEach(function(f) {
                    if (a.state.rotateAtoms.includes(f.elementId)) {
                      var y = d8([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, [f.x, f.y, f.z]);
                      f.x = y[0], f.y = y[1], f.z = y[2];
                    }
                  }), { editedAtomList: p, editedBondList: v };
                });
              }
            }, this.intervalTime), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(function(s) {
              if (a.state.rotateAtoms.length) {
                var u = gA(a.plugin, s.pageStart, s.pageEnd);
                a.state.rotateOffset[0] += u[0], a.state.rotateOffset[1] += u[1], a.state.rotateOffset[2] += u[2];
              }
            }), [2];
        }
      });
    });
  }, e.prototype.end = function() {
    var t, n, r;
    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 && ((n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(this.state.dragObserver)), this.state.invert = !1, this.state.dragObserver = void 0, this.state.rotateOffset = S.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(), (r = this.plugin.canvas3d) === null || r === void 0 || r.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";
})(ba || (ba = {})), 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";
}(df || (df = {}));
var w8 = [df.SINGLE, df.DOUBLE, df.TRIPLE], P8 = function() {
  function e(t) {
    var n;
    this.state = { mode: ba.None, editAtomDisabled: !1, addBondDisabled: !1, editBondDisabled: !1, selectedPdb: !1, isMergeNeeded: !1 }, this.ev = wi.create(), this.editStateUpdated = this.ev(), this.editStructureUpdated = this.ev(), this.plugin = t, this.instance = ((n = {})[ba.Drag] = new kH(t), n[ba.Rotate] = new FH(t), n[ba.Draw] = new NH(t), n[ba.None] = void 0, n);
  }
  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 n, r, i = ((n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.controls.isEditing) === !1 && t;
    if ((r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setEditState(t), i && this.setState(this.getEditState()), !t) {
      var a = [];
      this.plugin.cells.forEach(function(o, s) {
        o.representations.has(fe.RotateArrow) && a.push({ ref: s });
      }), this.plugin.managers.cell.remove(a);
    }
  }, 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 n;
    (n = this.plugin.canvas3d) === null || n === void 0 || n.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 n;
    (n = this.plugin.canvas3d) === null || n === void 0 || n.controls.setLockCameraState(t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "drawEditor", { get: function() {
    return this.instance[ba.Draw];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rotateEditor", { get: function() {
    return this.instance[ba.Rotate];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dragEditor", { get: function() {
    return this.instance[ba.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, n, r) {
    n === void 0 && (n = !1), r === void 0 && (r = ["click", "drag"]), this.isEditing = t, this.isLockCamera = n, this.disabledInteraction = r;
  }, e.prototype.getEditState = function() {
    var t, n, r, i, a = 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, m = [];
    if (d.forEach(function(g, x) {
      m.push(x), c = c || a.plugin.managers.cell.isFromPdb(x);
    }), m.length > 0) for (var p = 0, v = m.length; p < v; p++) {
      var f = m[p];
      d.has(f) && (o = !1);
    }
    if (m.length === 0 || m.length > 2) return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
    if (m.length === 2) (y = Pe(Pe([], (t = d.get(m[0])) !== null && t !== void 0 ? t : [], !0), (n = d.get(m[1])) !== null && n !== void 0 ? n : [], !0)).length === 2 && (s = !1, l = !0);
    else if (m.length === 1) {
      var y;
      if (((y = d.get(m[0])) == null ? void 0 : y.length) === 2) {
        s = !1;
        var h = this.plugin.cells.get(m[0]);
        !((r = h == null ? void 0 : h.model.structure) === null || r === void 0) && r.units.length && ((i = h == null ? void 0 : h.model.structure) === null || i === void 0 ? void 0 : i.units[0]).bonds.getEdgeIndex(y[0], y[1]) !== -1 && (u = !1);
      }
    }
    return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
  }, e.prototype.coverStructure = function(t, n, r) {
    return ie(this, 0, void 0, function() {
      var i, a, o, s = this;
      return ne(this, function(u) {
        switch (u.label) {
          case 0:
            return i = r.format, a = r.data, [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: n })];
          case 1:
            return (o = u.sent()).model.structure = n, this.plugin.managers.cell.update(t, { model: o.model, representations: Array.from(o.representations.values()), assets: [{ format: i, data: a }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(c, l) {
              l.type === fe.IntraInteractions && s.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.executeEdit = function(t, n, r, i) {
    var a, o, s;
    return ie(this, 0, void 0, function() {
      var u, c, l, d, m, p = this;
      return ne(this, function(v) {
        switch (v.label) {
          case 0:
            return u = this.plugin.cells.get(t), (c = (a = u == null ? void 0 : u.model) === null || a === void 0 ? void 0 : a.structure) ? [4, TF(c, n, r, i)] : [2];
          case 1:
            return (l = v.sent()).length <= 0 ? [2] : [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: l[0] })];
          case 2:
            return (d = v.sent()).model.structure = l[0], m = ((s = (o = ea(l[0])) === null || o === void 0 ? void 0 : o.sourceData) === null || s === void 0 ? void 0 : s.kind) !== "mmCIF" ? Nt.Sdf : Nt.Pdb, this.plugin.managers.cell.update(t, { model: d.model, representations: Array.from(d.representations.values()), assets: [{ format: m, data: V0(l[0], m) }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(f, y) {
              y.type === fe.IntraInteractions && p.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.coverSourceData = function(t, n, r, i) {
    var a, o, s, u, c, l, d;
    return ie(this, 0, void 0, function() {
      var m, p, v, f, y, h, g, x, C, b, _, A = this;
      return ne(this, function(I) {
        switch (I.label) {
          case 0:
            return this.plugin.cells.has(t) ? (v = (p = As[n]).parse, [4, gc(r)]) : [2];
          case 1:
            return [4, v.apply(p, [I.sent()])];
          case 2:
            return m = I.sent(), i ? ((f = this.plugin.cells.get(t)) == null || f.representations.forEach(function(w) {
              var E;
              w.state && ((E = A.plugin.canvas3d) === null || E === void 0 || E.remove(w.state));
            }), this.plugin.managers.cell.update(t, { model: { structure: m[0] }, representations: [], assets: [{ format: n, data: r }] }), f.representations = /* @__PURE__ */ new Map(), [4, this.plugin.managers.representation.setMolecularRepr([{ ref: t, elementIds: $i(m[0]) }], i, !1)]) : [3, 4];
          case 3:
            return I.sent(), y = this.plugin.managers.selection.structure.getSelection(), h = (a = y[t]) !== null && a !== void 0 ? a : [], (g = (o = this.plugin.cells.get(t)) === null || o === void 0 ? void 0 : o.representations.get(i)) && (x = Yn(Li(g.state), h), (s = this.plugin.canvas3d) === null || s === void 0 || s.mark({ loci: x, repr: g.state }, $e.Select)), [2];
          case 4:
            return [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: m[0] })];
          case 5:
            return (C = I.sent()).model.structure = m[0], this.plugin.managers.cell.update(t, { model: C.model, representations: Array.from(C.representations.values()), assets: [{ format: n, data: r }] }), b = this.plugin.managers.selection.structure.getSelection(), _ = (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(w) {
              var E, D = Yn(Li(w.state), _);
              (E = A.plugin.canvas3d) === null || E === void 0 || E.mark({ loci: D, repr: w.state }, $e.Select);
            }), this.plugin.managers.cell.traverse(function(w, E) {
              E.type === fe.IntraInteractions && A.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.coverSourceData");
            }), [2];
        }
      });
    });
  }, e.prototype.edit = function(t, n) {
    return ie(this, 0, void 0, function() {
      var r, i, a, o = this;
      return ne(this, function(s) {
        switch (s.label) {
          case 0:
            return r = this.isLockCamera, this.isLockCamera = !0, i = n ?? this.plugin.managers.selection.structure.getSelectionCellItems(), [4, Promise.all(i.map(function(u) {
              var c = u.ref, l = u.elementIds;
              return t(c, l ?? []);
            }))];
          case 1:
            return s.sent(), a = this.plugin.managers.selection.structure.getSelection(), i.forEach(function(u) {
              var c, l, d = u.ref, m = o.plugin.cells.get(d), p = (c = a[d]) !== null && c !== void 0 ? c : [];
              Array.from((l = m == null ? void 0 : m.representations.values()) !== null && l !== void 0 ? l : []).forEach(function(v) {
                var f, y = Yn(Li(v.state), p);
                (f = o.plugin.canvas3d) === null || f === void 0 || f.mark({ loci: y, repr: v.state }, $e.Select);
              });
            }), this.isLockCamera = r, [2];
        }
      });
    });
  }, e.prototype.deleteAtoms = function(t) {
    return ie(this, 0, void 0, function() {
      var n, r, i = this;
      return ne(this, function(a) {
        switch (a.label) {
          case 0:
            return n = {}, r = function(o, s) {
              return i.executeEdit(o, function(u, c) {
                var l = new Set(s), d = /* @__PURE__ */ new Map(), m = [];
                u.forEach(function(v) {
                  var f = l.has(v.elementId);
                  return f || (n[v.elementId] = m.length, m.push(B({}, v)), d.set(v.elementId + 1, m.length)), !f;
                });
                var p = c.filter(function(v) {
                  var f = l.has(v.a - 1) || l.has(v.b - 1);
                  return d.has(v.a) && (v.a = d.get(v.a)), d.has(v.b) && (v.b = d.get(v.b)), !f;
                });
                return { editedAtomList: m, editedBondList: p };
              }, function(u, c) {
                var l = new Set(s), d = [];
                u.forEach(function(p) {
                  l.has(p.elementId) || (n[p.elementId] = d.length, d.push(p));
                });
                var m = Pe([], c, !0);
                return { editedAtomList: d, editedBondList: m, affectedAtomIds: [] };
              });
            }, [4, this.edit(r, t)];
          case 1:
            return a.sent(), [2, n];
        }
      });
    });
  }, e.prototype.editAtomCharge = function(t, n) {
    var r = this;
    return this.edit(function(i, a) {
      return r.executeEdit(i, function(o, s) {
        var u = new Set(a), c = Pe([], o, !0), l = Pe([], s, !0), d = [];
        return c.forEach(function(m) {
          if (u.has(m.elementId)) {
            var p = m.charge !== void 0 ? m.charge + t : t;
            p <= 3 && p >= -3 && (m.charge = p, d.push(parseInt(m.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      }, function(o, s) {
        var u = new Set(a), c = Pe([], o, !0), l = Pe([], s, !0), d = [];
        return c.forEach(function(m) {
          if (u.has(m.elementId)) {
            var p = m.charge !== void 0 ? m.charge + t : t;
            p <= 3 && p >= -3 && (m.charge = p, d.push(parseInt(m.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      });
    }, n);
  }, e.prototype.editAtomType = function(t, n) {
    var r = this, i = t ?? this.instance[ba.Draw].state.elementType;
    return this.edit(function(a, o) {
      return r.executeEdit(a, function(s, u) {
        var c = new Set(o), l = Pe([], s, !0), d = Pe([], u, !0), m = [];
        return l.forEach(function(p) {
          c.has(p.elementId) && (p.auth_atom_id = i, p.type_symbol = i, m.push(parseInt(p.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: m };
      }, function(s, u) {
        var c = new Set(o), l = Pe([], s, !0), d = Pe([], u, !0), m = [];
        return l.forEach(function(p) {
          c.has(p.elementId) && (p.auth_atom_id = i, p.type_symbol = i, m.push(parseInt(p.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: m };
      });
    }, n);
  }, e.prototype.editBondOrder = function(t, n) {
    var r = this;
    return this.edit(function(i, a) {
      return r.executeEdit(i, function(o, s) {
        var u = Pe([], o, !0), c = Pe([], s, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a - 1 === a[0] && d.b - 1 === a[1] || d.a - 1 === a[1] && d.b - 1 === a[0]) {
            var m = d.order + t;
            w8.includes(m) && (d.order = m, l.add(d.a - 1), l.add(d.b - 1));
          }
        }), { editedAtomList: u, editedBondList: c, affectedAtomIds: Array.from(l) };
      }, function(o, s) {
        var u = Pe([], o, !0), c = Pe([], s, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a === a[0] && d.b === a[1] || d.a === a[1] && d.b === a[0]) {
            var m = d.order + t;
            w8.includes(m) && (d.order = m, 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) };
      });
    }, n);
  }, e.prototype.addOrDelBond = function(t, n) {
    var r, i = this;
    if (!n || n.length === 1 && ((r = n[0].elementIds) === null || r === void 0 ? void 0 : r.length) === 2) {
      if (!n) {
        var a = this.plugin.managers.selection.structure.selection;
        if (a.size !== 1 && Array.from(a.values())[0].length !== 2) return;
      }
      return this.edit(function(o, s) {
        return i.executeEdit(o, function(u, c) {
          var l = Pe([], u, !0), d = Pe([], c, !0), m = Pe([], s, !0);
          return t ? d.filter(function(p) {
            return p.a - 1 === s[0] && p.b - 1 === s[1] || p.a - 1 === s[1] && p.b - 1 === s[0];
          }).length === 0 && d.push({ a: s[0] + 1, b: s[1] + 1, order: 1 }) : d = d.filter(function(p) {
            return !(p.a - 1 === s[0] && p.b - 1 === s[1] || p.a - 1 === s[1] && p.b - 1 === s[0]);
          }), { editedAtomList: l, editedBondList: d, affectedAtomIds: m };
        }, function(u, c) {
          var l, d = Pe([], u, !0), m = Pe([], c, !0), p = [];
          if (t) {
            if (m.filter(function(g) {
              return g.a === s[0] && g.b === s[1] || g.a === s[1] && g.b === s[0];
            }).length === 0) {
              var v = (l = i.plugin.cells.get(o)) === null || l === void 0 ? void 0 : l.model.structure;
              if (v && v.units.length > 0) {
                var f = v.units[0], y = f.model.atomicConformation.atomId.value(s[0]), h = f.model.atomicConformation.atomId.value(s[1]);
                m.push({ a: s[0], b: s[1], order: 1, atom_idA: "".concat(y), atom_idB: "".concat(h) }), p.push(y, h);
              }
            }
          } else m = m.filter(function(g) {
            return !(g.a === s[0] && g.b === s[1] || g.a === s[1] && g.b === s[0]) || (p.push(g.atom_idA === void 0 ? g.a - 1 : parseInt(g.atom_idA, 10), g.atom_idB === void 0 ? g.b - 1 : parseInt(g.atom_idB, 10)), !1);
          });
          return { editedAtomList: d, editedBondList: m, affectedAtomIds: p };
        });
      }, n);
    }
  }, e.prototype.changeEditorMode = function(t) {
    var n = this.instance[this.state.mode];
    this.isLockCamera = !1, this.disabledInteraction = [], n && n.end();
    var r = this.instance[t];
    r && (this.isEditing = !0, this.isLockCamera = !0, r.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;
}(), E8 = function() {
  function e(t) {
    this.ev = wi.create(), this.info = this.ev(), this.handleHighlightLocis = [], this.plugin = t;
  }
  return e.prototype.setHoverSelection = function(t, n) {
    var r, i, a, o = this;
    if (n === void 0 && (n = !0), this.hoverLoci && ((r = this.plugin.canvas3d) === null || r === void 0 || r.mark(this.hoverLoci, $e.RemoveHighlight)), !((i = this.handleHighlightLocis) === null || i === void 0) && i.length && this.handleHighlightLocis.forEach(function(u) {
      var c;
      (c = o.plugin.canvas3d) === null || c === void 0 || c.mark(u, $e.RemoveHighlight);
    }), t) {
      var s = { loci: rn.normalize(t.loci, this.plugin.managers.selection.structure.lociGranularity), repr: t.repr };
      (a = this.plugin.canvas3d) === null || a === void 0 || a.mark(s, $e.Highlight), this.hoverLoci = s, n && this.info.next({ loci: s, info: this.createHighlightInfo(s) });
    } else this.info.next({});
  }, e.prototype.addHighlightLocis = function(t, n) {
    var r, i = this;
    n === void 0 && (n = !0), n && (this.handleHighlightLocis.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, $e.RemoveHighlight);
    }), this.handleHighlightLocis = []), t.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, $e.Highlight);
    }), (r = this.handleHighlightLocis).push.apply(r, t);
  }, e.prototype.createHighlightInfo = function(t) {
    if (t.loci.kind === "element-loci") {
      var n = "";
      if (Array.from(this.plugin.cells.entries()).some(function(f) {
        var y = f[0], h = f[1];
        return !(n || !un(h) || Ja(un(h)) !== Ja(t.loci.structure)) && (n = y, !0);
      }), !n) return;
      var r, i = this.plugin.cells.get(n), a = "";
      if (Object.entries(In).forEach(function(f) {
        var y = f[0];
        f[1].includes(dS[t.repr.label]) && (r = y);
      }), r && i.theme.color && i.theme.color[r]) {
        var o = i.theme.color[r], s = wr(t.loci);
        o.forEach(function(f) {
          var y = new Set(f.elementIds);
          s.filter(function(h) {
            return !y.has(h);
          }).length === 0 && (a = f.name);
        });
      }
      return p = B({ type: cf.Structure, ref: n, colorThemeName: a }, XN(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, m = l.unitB;
      Array.from(this.plugin.cells.entries()).some(function(f) {
        var y = f[0], h = f[1];
        if (u && c) return !0;
        if (h.model.structure) {
          var g = Ja(h.model.structure);
          g === d.model.id && (u = y), g === m.model.id && (c = y);
        }
        return !1;
      });
      var p = B({ type: cf.Interaction }, YN(t.loci));
      return Object.assign(p.infoA, { ref: u }), Object.assign(p.infoB, { ref: c }), p;
    }
    if (t.loci.kind === "group-loci") return {};
    if (t.loci.kind === "bond-loci") {
      var v = "";
      return Array.from(this.plugin.cells.entries()).some(function(f) {
        var y = f[0], h = f[1];
        return !(v || !h.model.structure || Ja(h.model.structure) !== Ja(t.loci.structure)) && (v = y, !0);
      }), p = { infoA: Fo(t.loci.bonds[0].aUnit, t.loci.bonds[0].aUnit.elements[t.loci.bonds[0].aIndex]), infoB: Fo(t.loci.bonds[0].bUnit, t.loci.bonds[0].bUnit.elements[t.loci.bonds[0].bIndex]), ref: v, type: cf.Bond };
    }
  }, e.prototype.clear = function() {
    this.hoverLoci = void 0;
  }, e;
}(), GH = [["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"]], T8 = function() {
  function e(t) {
    this.plugin = t, this.ev = wi.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: ye(0), transparent: !1 };
  }
  return e.prototype.createParams = function() {
    var t = Math.min(this.plugin.canvas3d ? this.plugin.canvas3d.webgl.maxRenderbufferSize : 4096, 4096);
    return { resolution: N.MappedStatic("ultra-hd", { viewport: N.Group({}), hd: N.Group({}), "full-hd": N.Group({}), "ultra-hd": N.Group({}), custom: N.Group({ width: N.Numeric(1920, { min: 128, max: t, step: 1 }), height: N.Numeric(1080, { min: 128, max: t, step: 1 }) }, { isFlat: !0 }) }, { options: GH }), transparent: N.Boolean(!1), axes: G0.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, n;
    return { width: ((t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.webgl.gl.drawingBufferWidth) || 0, height: ((n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.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 n = this.plugin.canvas3d, r = n.webgl.extensions, i = r.colorBufferFloat, a = r.textureFloat, o = n.props.postprocessing.occlusion;
    return n.getImagePass({ transparentBackground: this.values.transparent, cameraHelper: { axes: this.values.axes }, multiSample: { mode: t ? "on" : "off", sampleLevel: i && a ? 4 : 2 }, postprocessing: B(B({}, n.props.postprocessing), { occlusion: o.name === "on" ? { name: "on", params: B(B({}, o.params), { samples: 128, resolutionScale: 1 }) } : o }), marking: B({}, n.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, n = t.props.postprocessing.occlusion;
      return this._imagePass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: B(B({}, t.props.postprocessing), { occlusion: n.name === "on" ? { name: "on", params: B(B({}, n.params), { samples: 128, resolutionScale: 1 }) } : n }), marking: B({}, 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(B(B({}, this.cropParams), { auto: !1 })), this.resetCrop()) : this.behaviors.cropParams.next(B(B({}, this.cropParams), { auto: !0 }));
  }, Object.defineProperty(e.prototype, "isFullFrame", { get: function() {
    var t = this.relativeCrop;
    return On(t.x, 0, 1e-5) && On(t.y, 0, 1e-5) && On(t.width, 1, 1e-5) && On(t.height, 1, 1e-5);
  }, enumerable: !1, configurable: !0 }), e.prototype.autocrop = function(t) {
    t === void 0 && (t = this.cropParams.relativePadding);
    for (var n = this.previewData.image, r = n.data, i = n.width, a = n.height, o = this.previewData.transparent, s = o ? this.previewData.background : 4278190080 | this.previewData.background, u = i, c = 0, l = a, d = 0, m = 0; m < a; m++) for (var p = m * i, v = 0; v < i; v++) {
      var f = 4 * (p + v);
      if (o) {
        if (r[f + 3] === 0) continue;
      } else if ((r[f] << 16 | r[f + 1] << 8 | r[f + 2] | r[f + 3] << 24) === s) continue;
      v < u && (u = v), v > c && (c = v), m < l && (l = m), m > d && (d = m);
    }
    if (u > c) {
      var y = u;
      u = c, c = y;
    }
    l > d && (y = l, l = d, d = y);
    var h = c - u + 1, g = d - l + 1;
    u -= t * h, c += t * h, l -= t * g, d += t * g;
    var x = { x: Math.max(0, u / i), y: Math.max(0, l / a), width: Math.min(1, (c - u + 1) / i), height: Math.min(1, (d - l + 1) / a) };
    this.behaviors.relativeCrop.next(x);
  }, e.prototype.getPreview = function(t) {
    t === void 0 && (t = 320);
    var n = this.getSize(), r = n.width, i = n.height;
    if (!(r <= 0 || i <= 0)) {
      var a = r / i, o = 0, s = 0;
      a > 1 ? (o = t, s = Math.round(t / a)) : (s = t, o = Math.round(t * a));
      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(), n = t.width, r = t.height, i = this.relativeCrop, a = { x: Math.floor(i.x * n), y: Math.floor(i.y * r), width: Math.ceil(i.width * n), height: Math.ceil(i.height * r) };
    return a.width + a.x > n && (a.width = n - a.x), a.height + a.y > r && (a.height = r - a.y), { width: n, height: r, viewport: a };
  }, e.prototype.draw = function() {
    return ie(this, 0, void 0, function() {
      var t, n, r, i, a, o, s;
      return ne(this, function(u) {
        if (t = this.getSizeAndViewport(), n = t.width, r = t.height, i = t.viewport, n <= 0 || r <= 0) return [2];
        if (a = this.imagePass.getImageData(n, r, i), (o = this.canvas).width = a.width, o.height = a.height, !(s = o.getContext("2d"))) throw new Error("Could not create canvas 2d context");
        return s.putImageData(a, 0, 0), [2];
      });
    });
  }, e.prototype.getImageDataUri = function() {
    return ie(this, 0, void 0, function() {
      return ne(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 ie(this, 0, void 0, function() {
      var t, n, r;
      return ne(this, function(i) {
        switch (i.label) {
          case 0:
            return (t = navigator.clipboard) != null && t.write ? [4, this.draw()] : [2];
          case 1:
            return i.sent(), [4, j6(this.canvas, "png")];
          case 2:
            return n = i.sent(), r = new ClipboardItem({ "image/png": n }), [4, t.write([r])];
          case 3:
            return i.sent(), [2];
        }
      });
    });
  }, e.prototype.getAxesScale = function() {
    var t = this.getSize(), n = t.width * t.height;
    switch (!0) {
      case n <= 921600:
        return 0.22;
      case n <= 2073600:
        return 0.33;
      case n <= 8294400:
        return 0.5;
      default:
        return 0.65;
    }
  }, e.prototype.download = function(t) {
    return ie(this, 0, void 0, function() {
      return ne(this, function(n) {
        switch (n.label) {
          case 0:
            return this.behaviors.values.next({ transparent: this.values.transparent, axes: B(B({}, this.values.axes), { params: B(B(B({}, this.params.axes.defaultValue), this.values.axes.params), { scale: this.getAxesScale() }) }), resolution: this.values.resolution }), [4, this.draw()];
          case 1:
            return n.sent(), this.behaviors.cropParams.next(B(B({}, this.cropParams), { auto: !1 })), this.resetCrop(), [4, j6(this.canvas, "png")];
          case 2:
            return wA(n.sent(), t), this.behaviors.values.next({ transparent: this.values.transparent, axes: B(B({}, this.values.axes), { params: B(B(B({}, this.params.axes.defaultValue), this.values.axes.params), { scale: 0.11 }) }), resolution: this.values.resolution }), [2];
        }
      });
    });
  }, e;
}(), VH = N.getDefaultValues(l0), PA = function() {
  function e() {
    this.mode = lc.Drug, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new f8(this), representation: new b8(this), cell: new _8(this), trajectory: new x8(this), snapshot: new C8(this), selection: new A8(this), events: new I8(this), highlight: new E8(this), editor: new P8(this), screenshot: new T8(this) };
  }
  var t;
  return e.prototype.createCanvas = function(n, r) {
    var i = document.createElement("canvas");
    n.appendChild(i), q6(i, n), this.layout = { root: n, canvas: i }, this.canvas3d = Fv.create(Lv.fromCanvas(i), N.merge(l0, N.getDefaultValues(l0), B({ 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: B(B({}, VH.renderer), { backgroundColor: ye(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 }, r))), this.canvas3d.animate(), this.managers.representation.createContext(), this.managers.events.subscribe(), this.managers.editor.start();
  }, e.prototype.focus = function(n, r) {
    return ie(this, 0, void 0, function() {
      var i, a, o, s, u = this;
      return ne(this, function(c) {
        switch (c.label) {
          case 0:
            return i = [], a = new Set(n.map(function(l) {
              var d, m, p;
              return i.push.apply(i, (p = (m = (d = u.cells.get(l.ref)) === null || d === void 0 ? void 0 : d.dependency) === null || m === void 0 ? void 0 : m.by) !== null && p !== void 0 ? p : []), l.ref;
            })), o = new Set(i), s = Array.from(this.cells).map(function(l) {
              return { ref: l[0] };
            }).filter(function(l) {
              return !a.has(l.ref) && !o.has(l.ref);
            }), this.hide(s, !0), [4, this.show(n, r)];
          case 1:
            return c.sent(), [2, s];
        }
      });
    });
  }, e.prototype.show = function(n, r) {
    var i;
    return ie(this, 0, void 0, function() {
      var a, o, s, u, c, l = this;
      return ne(this, function(d) {
        switch (d.label) {
          case 0:
            a = function(m) {
              var p, v, f, y, h, g, x, C;
              return ne(this, function(b) {
                switch (b.label) {
                  case 0:
                    return o.managers.cell.idleCellSet.delete(m.ref), p = o.managers.cell.get(m.ref), [4, o.managers.cell.getStructure(m.ref)];
                  case 1:
                    if (b.sent(), !p || !m.representationType && Array.from(p.representations.values()).some(function(_) {
                      return !_.isHidden;
                    })) return [2, "continue"];
                    v = 0, f = Array.from(p.representations), b.label = 2;
                  case 2:
                    return v < f.length ? (y = f[v], h = y[0], (g = y[1]).state ? (!g.isHidden || m.representationType && m.representationType !== h || ((i = o.canvas3d) === null || i === void 0 || i.add(g.state), p.representations.set(h, B(B({}, g), { isHidden: !1 }))), [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return g.cache ? [4, $s.managers.cell.recoveryReprCache(p, B(B({}, g.cache), { isHidden: !1 }))] : [3, 5];
                  case 4:
                    b.sent(), b.label = 5;
                  case 5:
                    return v++, [3, 2];
                  case 6:
                    return p.dependency.by.length && (x = [], C = p.dependency.by.filter(function(_) {
                      var A = l.cells.has(_);
                      if (A) {
                        if (l.cells.get(_).dependency.on.some(function(I) {
                          var w, E;
                          return Array.from((E = (w = l.cells.get(I.ref)) === null || w === void 0 ? void 0 : w.representations.values()) !== null && E !== void 0 ? E : []).filter(function(D) {
                            return D.isHidden !== !0;
                          }).length === 0;
                        })) return !1;
                      } else x.push(_);
                      return A;
                    }), o.show(C.map(function(_) {
                      return { ref: _ };
                    }), !0), x.length && o.managers.cell.update(m.ref, { model: {}, dependency: { by: C } })), [2];
                }
              });
            }, o = this, s = 0, u = n, d.label = 1;
          case 1:
            return s < u.length ? (c = u[s], [5, a(c)]) : [3, 4];
          case 2:
            d.sent(), d.label = 3;
          case 3:
            return s++, [3, 1];
          case 4:
            return r || this.managers.cell.traverse(function(m, p) {
              p.type === fe.IntraInteractions && l.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
            }), this.managers.snapshot.event.changed.next({ from: "show" }), [2];
        }
      });
    });
  }, e.prototype.hide = function(n, r) {
    var i = this;
    n.forEach(function(a) {
      i.managers.cell.idleCellSet.add(a.ref);
      var o = i.cells.get(a.ref);
      if (o && (i.managers.selection.shape.selection.has(a.ref) && i.managers.selection.shape.remove({ item: a }), i.managers.selection.structure.selection.has(a.ref) && i.managers.selection.structure.remove({ item: { ref: a.ref, elementIds: $i(un(o)) } }), o.representations.forEach(function(c, l) {
        var d;
        c.isHidden || a.representationType && a.representationType !== l || (c.state && ((d = i.canvas3d) === null || d === void 0 || d.remove(c.state)), o.representations.set(l, B(B(B({}, c), { isHidden: !0 }), c.cache ? { cache: B(B({}, c.cache), { isHidden: !0 }) } : {})));
      }), o.dependency.by.length)) {
        var s = [], u = o.dependency.by.filter(function(c) {
          var l = i.cells.has(c);
          l || s.push(c);
          var d = i.cells.get(c);
          return !(d != null && d.representations.has(fe.IntraInteractions)) && l;
        });
        i.hide(u.map(function(c) {
          return { ref: c };
        }), !0), s.length && i.managers.cell.update(a.ref, { model: {}, dependency: { by: u } });
      }
    }), r || this.managers.cell.traverse(function(a, o) {
      o.type === fe.IntraInteractions && i.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
    }), this.managers.snapshot.event.changed.next({ from: "hide" });
  }, e.prototype.toggle = function(n) {
    var r = this, i = n.types, a = n.forceAction, o = n.refs, s = Array.from(this.cells).filter(function(l) {
      var d = l[0], m = l[1], p = (!o || o.includes(d)) && i.some(function(v) {
        return m.representations.get(v);
      });
      return !!p && !!m.dependency.on.every(function(v) {
        var f = r.cells.get(v.ref);
        return !!f && !Array.from(f.representations.values()).every(function(y) {
          return y.isHidden === !0;
        });
      });
    });
    if (s.length) {
      var u = a ?? s.some(function(l) {
        l[0];
        var d = l[1];
        return i.some(function(m) {
          var p;
          return (p = d.representations.get(m)) === null || p === void 0 ? void 0 : p.isHidden;
        });
      }) ? "show" : "hide", c = lS(s.map(function(l) {
        var d = l[0], m = l[1];
        return Array.from(m.representations).filter(function(p) {
          var v = p[0];
          return i.includes(v);
        }).map(function(p) {
          return { representationType: p[0], ref: d };
        });
      }));
      this[u](c);
    }
  }, e.prototype.refresh = function(n) {
    var r, i, a, o, s;
    this.canvas3d && (!((i = (r = this.layout) === null || r === void 0 ? void 0 : r.root.children[0]) === null || i === void 0) && i.clientWidth) && (n != null && n.fixCamera && (s = this.canvas3d.camera.getSnapshot()), q6(this.layout.canvas, this.layout.root), (a = this.canvas3d) === null || a === void 0 || a.handleResize(), n != null && n.fixCamera ? (o = this.canvas3d) === null || o === void 0 || o.camera.setState(s) : this.managers.camera.focus());
  }, e.prototype.clear = function() {
    var n;
    this.managers.selection.clear(), this.managers.highlight.clear(), this.managers.editor.changeEditorMode(ba.None), this.cells = /* @__PURE__ */ new Map(), (n = this.canvas3d) === null || n === void 0 || n.clear();
  }, e.prototype.dispose = function() {
    var n;
    (n = this.canvas3d) === null || n === void 0 || n.dispose(), this.layout = void 0, this.canvas3d = void 0, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new f8(this), representation: new b8(this), cell: new _8(this), trajectory: new x8(this), snapshot: new C8(this), selection: new A8(this), events: new I8(this), highlight: new E8(this), editor: new P8(this), screenshot: new T8(this) };
  }, t = e, e.Utils = { sliceCellItems: function(n, r) {
    return DF($s, n, r);
  }, queryCellItems: function(n) {
    return DS($s, n);
  }, exportToPdb: function(n) {
    return ie(void 0, 0, void 0, function() {
      return ne(t, function(r) {
        switch (r.label) {
          case 0:
            return [4, $s.managers.cell.getStructure(n.ref)];
          case 1:
            return [2, S3(r.sent(), n.elementIds, !1)];
        }
      });
    });
  }, getBox: function(n) {
    return ie(void 0, 0, void 0, function() {
      var r, i;
      return ne(t, function(a) {
        switch (a.label) {
          case 0:
            return [4, $s.managers.cell.getStructure(n.ref)];
          case 1:
            return r = a.sent(), [2, HU(r, (i = n.elementIds) !== null && i !== void 0 ? i : [])];
        }
      });
    });
  }, splitMolecularContent: function(n, r) {
    return GL(n, r);
  }, checkMolecularContentVerify: function(n, r) {
    return UL(n, r);
  }, getMergedContent: function(n) {
    return BF($s, n);
  }, traverseAtoms: function(n, r) {
    return ie(void 0, 0, void 0, function() {
      var i;
      return ne(t, function(a) {
        switch (a.label) {
          case 0:
            return [4, $s.managers.cell.getStructure(n)];
          case 1:
            return (i = a.sent()) ? (MF(i, r), [2]) : [2];
        }
      });
    });
  } }, e;
}(), $s = new PA();
const {
  SvelteComponent: zH,
  append: bo,
  attr: qa,
  detach: UH,
  element: $u,
  flush: lm,
  init: HH,
  insert: qH,
  listen: x2,
  noop: M8,
  run_all: jH,
  safe_not_equal: KH,
  set_style: XH,
  space: dm
} = window.__gradio__svelte__internal;
function YH(e) {
  let t, n, r, i, a, o, s, u, c, l, d, m, p, v;
  return {
    c() {
      t = $u("div"), n = $u("div"), r = dm(), i = $u("div"), a = $u("button"), a.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>', o = dm(), s = $u("button"), s.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>', u = dm(), c = $u("button"), c.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>', l = dm(), d = $u("div"), qa(n, "id", "uni-view-canvas-" + /*key*/
      e[2]), qa(n, "class", "uni-view-canvas svelte-o2v4ea"), qa(a, "class", "uni-view-toolbar-btn svelte-o2v4ea"), qa(s, "class", "uni-view-toolbar-btn svelte-o2v4ea"), qa(c, "class", "uni-view-toolbar-btn svelte-o2v4ea"), qa(i, "class", "uni-view-toolbar svelte-o2v4ea"), qa(d, "id", "uni-view-label-" + /*key*/
      e[2]), qa(d, "class", "uni-view-label svelte-o2v4ea"), XH(d, "display", "none"), qa(t, "class", "uni-view-container svelte-o2v4ea"), qa(t, "style", m = /*height*/
      e[0] !== void 0 ? `height: ${/*height*/
      e[0]}px;` : "");
    },
    m(f, y) {
      qH(f, t, y), bo(t, n), bo(t, r), bo(t, i), bo(i, a), bo(i, o), bo(i, s), bo(i, u), bo(i, c), bo(t, l), bo(t, d), p || (v = [
        x2(
          a,
          "click",
          /*click_handler*/
          e[9]
        ),
        x2(
          s,
          "click",
          /*click_handler_1*/
          e[10]
        ),
        x2(
          c,
          "click",
          /*click_handler_2*/
          e[11]
        )
      ], p = !0);
    },
    p(f, [y]) {
      y & /*height*/
      1 && m !== (m = /*height*/
      f[0] !== void 0 ? `height: ${/*height*/
      f[0]}px;` : "") && qa(t, "style", m);
    },
    i: M8,
    o: M8,
    d(f) {
      f && UH(t), p = !1, jH(v);
    }
  };
}
const D8 = 698;
function WH(e, t, n) {
  this && this.__awaiter;
  let { gradio: r } = t, { value: i = "" } = t, { height: a } = t, { structures: o = [] } = t;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  const s = /* @__PURE__ */ new Map([
    ["ligand-default", "#48e533"],
    ["residue-default", "#dcdde8"],
    ["reference", "#f7aa61"],
    ["green", "#01BE77"],
    ["purple", "#7570b3"],
    ["pink", "#e7298a"],
    ["yellow", "#e6ab02"],
    ["brown", "#a6761d"],
    ["gray", "#666666"],
    ["red", "#E41A1C"],
    ["blue", "#3daf4a"]
  ]);
  let u = new PA();
  const l = (() => {
    function I() {
      return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
    }
    return `${I() + I()}-${I()}-${I()}-${I()}-${I()}${I()}${I()}`;
  })();
  function d() {
    r.dispatch("change");
  }
  let m = "";
  const p = () => {
    const I = document.getElementById(`uni-view-label-${l}`);
    if (I) {
      if (!m) {
        I.style.display = "none";
        return;
      }
      I.innerHTML = m, I.style.display = "block";
    }
  }, v = () => {
    n(1, u.managers.representation.showPolarHydrogenOnly = !1, u), u.createCanvas(document.getElementById(`uni-view-canvas-${l}`), {
      renderer: {
        ambientIntensity: 0.4,
        backgroundColor: ye(15922682)
      }
    }), u.managers.selection.event.changed.subscribe(() => {
      const { prev: I } = u.managers.selection.structure;
      I.length;
    }), u.managers.highlight.info.subscribe((I) => {
      if (!I.info) {
        n(6, m = "");
        return;
      }
      if (I.info.type === "Structure") {
        const { granularity: w, atomName: E, atomId: D, altId: T, residueName: P, residueId: M, chainId: R, emConfidence: O, bfactor: L, insertCode: F, ref: G } = I.info, V = u.managers.cell.getMolecularName(G);
        switch (w) {
          case "Atom":
            n(6, m = `${V ? `${V} ` : ""}${E} ${D}${T} ${P} ${M}${F ?? ""} ${R}${L ? `<p />b-factor: ${L}` : ""}${O ? `<p />EM Confidence: ${O}` : ""}`);
            break;
          case "Residue":
            n(6, m = `${V ? `${V} ` : ""}${P} ${M}${F ?? ""} ${R}${L ? `<p />b-factor: ${L}` : ""}`);
            break;
          case "Chain":
            n(6, m = `${V ? `${V} ` : ""}Chain ${R}`);
            break;
          default:
            n(6, m = `${V ? `${V} ` : ""}`);
            break;
        }
        return;
      }
      if (I.info.type === "Interaction") {
        const { interactionType: w, infoA: E, infoB: D } = I.info;
        n(6, m = `${w} ${E.chainId}:${E.residueName}${E.residueId}:${E.atomName} - ${D.chainId}:${D.residueName}${D.residueId}:${D.atomName}`);
        return;
      }
      n(6, m = "");
    }), window.__simple_plugin = u, setTimeout(() => u.refresh(), 50), C();
  };
  let f = !1, y = 0;
  const h = setInterval(
    () => {
      document.getElementById(`uni-view-canvas-${l}`) && !u.canvas3d && (clearInterval(h), new ResizeObserver((w) => {
        n(7, f = w[0].contentRect.width < D8 + 18), n(8, y = Math.min(w[0].contentRect.width - 16, D8)), g();
      }).observe(document.getElementById(`uni-view-canvas-${l}`)), v());
    },
    1e3
  ), g = () => {
    setTimeout(
      () => {
        u.refresh({ fixCamera: !0 });
      },
      0
    );
  }, x = (I = "#F2F5FA") => (I.startsWith("#") && (I = I.substr(1)), parseInt(I, 16)), C = () => {
    u.clear(), u.canvas3d && o.forEach((I) => {
      var w;
      const { format: E, content: D, reprType: T, carbonColor: P } = I;
      !zN.has(T) || !D || u.managers.representation.createMolecular({
        format: E,
        data: D,
        reprType: T ?? (E === "pdb" ? fe.Ribbon : fe.BallAndStick),
        theme: P && ac.has(T) ? {
          Atom: {
            color: {
              name: "element-symbol",
              props: {
                carbonColor: {
                  name: "uniform",
                  params: {
                    value: ye(x((w = s.get(P)) !== null && w !== void 0 ? w : P))
                  }
                }
              }
            }
          }
        } : void 0
      });
    });
  }, b = () => u.managers.camera.zoomIn(), _ = () => u.managers.camera.zoomOut(), A = () => u.managers.camera.focus();
  return e.$$set = (I) => {
    "gradio" in I && n(4, r = I.gradio), "value" in I && n(3, i = I.value), "height" in I && n(0, a = I.height), "structures" in I && n(5, o = I.structures);
  }, e.$$.update = () => {
    e.$$.dirty & /*value*/
    8 && i === null && n(3, i = ""), e.$$.dirty & /*value*/
    8 && d(), e.$$.dirty & /*info*/
    64 && p(), e.$$.dirty & /*isFixedRight*/
    128, e.$$.dirty & /*rootWidth*/
    256, e.$$.dirty & /*height*/
    1 && g(), e.$$.dirty & /*structures*/
    32 && C();
  }, [
    a,
    u,
    l,
    i,
    r,
    o,
    m,
    f,
    y,
    b,
    _,
    A
  ];
}
class ZH extends zH {
  constructor(t) {
    super(), HH(this, t, WH, YH, KH, {
      gradio: 4,
      value: 3,
      height: 0,
      structures: 5
    });
  }
  get gradio() {
    return this.$$.ctx[4];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), lm();
  }
  get value() {
    return this.$$.ctx[3];
  }
  set value(t) {
    this.$$set({ value: t }), lm();
  }
  get height() {
    return this.$$.ctx[0];
  }
  set height(t) {
    this.$$set({ height: t }), lm();
  }
  get structures() {
    return this.$$.ctx[5];
  }
  set structures(t) {
    this.$$set({ structures: t }), lm();
  }
}
const {
  SvelteComponent: QH,
  add_flush_callback: JH,
  assign: $H,
  bind: eq,
  binding_callbacks: tq,
  check_outros: B8,
  create_component: V3,
  destroy_component: z3,
  detach: R8,
  empty: nq,
  flush: ri,
  get_spread_object: rq,
  get_spread_update: iq,
  group_outros: k8,
  init: aq,
  insert: O8,
  mount_component: U3,
  safe_not_equal: oq,
  space: sq,
  transition_in: cs,
  transition_out: dc
} = window.__gradio__svelte__internal;
function N8(e) {
  let t, n;
  const r = [
    { autoscroll: (
      /*gradio*/
      e[1].autoscroll
    ) },
    { i18n: (
      /*gradio*/
      e[1].i18n
    ) },
    /*loading_status*/
    e[7]
  ];
  let i = {};
  for (let a = 0; a < r.length; a += 1)
    i = $H(i, r[a]);
  return t = new Cw({ props: i }), t.$on(
    "clear_status",
    /*clear_status_handler*/
    e[16]
  ), {
    c() {
      V3(t.$$.fragment);
    },
    m(a, o) {
      U3(t, a, o), n = !0;
    },
    p(a, o) {
      const s = o & /*gradio, loading_status*/
      130 ? iq(r, [
        o & /*gradio*/
        2 && { autoscroll: (
          /*gradio*/
          a[1].autoscroll
        ) },
        o & /*gradio*/
        2 && { i18n: (
          /*gradio*/
          a[1].i18n
        ) },
        o & /*loading_status*/
        128 && rq(
          /*loading_status*/
          a[7]
        )
      ]) : {};
      t.$set(s);
    },
    i(a) {
      n || (cs(t.$$.fragment, a), n = !0);
    },
    o(a) {
      dc(t.$$.fragment, a), n = !1;
    },
    d(a) {
      z3(t, a);
    }
  };
}
function L8(e) {
  let t, n, r;
  function i(o) {
    e[17](o);
  }
  let a = {
    structures: (
      /*structures*/
      e[9]
    ),
    height: (
      /*height*/
      e[8]
    ),
    gradio: (
      /*gradio*/
      e[1]
    )
  };
  return (
    /*value*/
    e[0] !== void 0 && (a.value = /*value*/
    e[0]), t = new ZH({ props: a }), tq.push(() => eq(t, "value", i)), {
      c() {
        V3(t.$$.fragment);
      },
      m(o, s) {
        U3(t, o, s), r = !0;
      },
      p(o, s) {
        const u = {};
        s & /*structures*/
        512 && (u.structures = /*structures*/
        o[9]), s & /*height*/
        256 && (u.height = /*height*/
        o[8]), s & /*gradio*/
        2 && (u.gradio = /*gradio*/
        o[1]), !n && s & /*value*/
        1 && (n = !0, u.value = /*value*/
        o[0], JH(() => n = !1)), t.$set(u);
      },
      i(o) {
        r || (cs(t.$$.fragment, o), r = !0);
      },
      o(o) {
        dc(t.$$.fragment, o), r = !1;
      },
      d(o) {
        z3(t, o);
      }
    }
  );
}
function uq(e) {
  let t, n, r, i = (
    /*loading_status*/
    e[7] && N8(e)
  ), a = (
    /*visible*/
    e[4] && L8(e)
  );
  return {
    c() {
      i && i.c(), t = sq(), a && a.c(), n = nq();
    },
    m(o, s) {
      i && i.m(o, s), O8(o, t, s), a && a.m(o, s), O8(o, n, s), r = !0;
    },
    p(o, s) {
      /*loading_status*/
      o[7] ? i ? (i.p(o, s), s & /*loading_status*/
      128 && cs(i, 1)) : (i = N8(o), i.c(), cs(i, 1), i.m(t.parentNode, t)) : i && (k8(), dc(i, 1, 1, () => {
        i = null;
      }), B8()), /*visible*/
      o[4] ? a ? (a.p(o, s), s & /*visible*/
      16 && cs(a, 1)) : (a = L8(o), a.c(), cs(a, 1), a.m(n.parentNode, n)) : a && (k8(), dc(a, 1, 1, () => {
        a = null;
      }), B8());
    },
    i(o) {
      r || (cs(i), cs(a), r = !0);
    },
    o(o) {
      dc(i), dc(a), r = !1;
    },
    d(o) {
      o && (R8(t), R8(n)), i && i.d(o), a && a.d(o);
    }
  };
}
function cq(e) {
  let t, n;
  return t = new gI({
    props: {
      visible: (
        /*visible*/
        e[4]
      ),
      elem_id: (
        /*elem_id*/
        e[2]
      ),
      elem_classes: (
        /*elem_classes*/
        e[3]
      ),
      scale: (
        /*scale*/
        e[5]
      ),
      min_width: (
        /*min_width*/
        e[6]
      ),
      allow_overflow: !1,
      padding: !0,
      $$slots: { default: [uq] },
      $$scope: { ctx: e }
    }
  }), {
    c() {
      V3(t.$$.fragment);
    },
    m(r, i) {
      U3(t, r, i), n = !0;
    },
    p(r, [i]) {
      const a = {};
      i & /*visible*/
      16 && (a.visible = /*visible*/
      r[4]), i & /*elem_id*/
      4 && (a.elem_id = /*elem_id*/
      r[2]), i & /*elem_classes*/
      8 && (a.elem_classes = /*elem_classes*/
      r[3]), i & /*scale*/
      32 && (a.scale = /*scale*/
      r[5]), i & /*min_width*/
      64 && (a.min_width = /*min_width*/
      r[6]), i & /*$$scope, structures, height, gradio, value, visible, loading_status*/
      4195219 && (a.$$scope = { dirty: i, ctx: r }), t.$set(a);
    },
    i(r) {
      n || (cs(t.$$.fragment, r), n = !0);
    },
    o(r) {
      dc(t.$$.fragment, r), n = !1;
    },
    d(r) {
      z3(t, r);
    }
  };
}
function lq(e, t, n) {
  this && this.__awaiter;
  let { gradio: r } = t, { label: i = "Textbox" } = t, { elem_id: a = "" } = t, { elem_classes: o = [] } = t, { visible: s = !0 } = t, { value: u = "" } = t, { placeholder: c = "" } = t, { show_label: l } = t, { scale: d = null } = t, { min_width: m = void 0 } = t, { loading_status: p = void 0 } = t, { value_is_output: v = !1 } = t, { interactive: f } = t, { rtl: y = !1 } = t, { height: h = void 0 } = t, { structures: g = [] } = t;
  function x() {
    r.dispatch("change"), v || r.dispatch("input");
  }
  const C = () => r.dispatch("clear_status", p);
  function b(_) {
    u = _, n(0, u);
  }
  return e.$$set = (_) => {
    "gradio" in _ && n(1, r = _.gradio), "label" in _ && n(10, i = _.label), "elem_id" in _ && n(2, a = _.elem_id), "elem_classes" in _ && n(3, o = _.elem_classes), "visible" in _ && n(4, s = _.visible), "value" in _ && n(0, u = _.value), "placeholder" in _ && n(11, c = _.placeholder), "show_label" in _ && n(12, l = _.show_label), "scale" in _ && n(5, d = _.scale), "min_width" in _ && n(6, m = _.min_width), "loading_status" in _ && n(7, p = _.loading_status), "value_is_output" in _ && n(13, v = _.value_is_output), "interactive" in _ && n(14, f = _.interactive), "rtl" in _ && n(15, y = _.rtl), "height" in _ && n(8, h = _.height), "structures" in _ && n(9, g = _.structures);
  }, e.$$.update = () => {
    e.$$.dirty & /*value*/
    1 && u === null && n(0, u = ""), e.$$.dirty & /*value*/
    1 && x();
  }, [
    u,
    r,
    a,
    o,
    s,
    d,
    m,
    p,
    h,
    g,
    i,
    c,
    l,
    v,
    f,
    y,
    C,
    b
  ];
}
class dq extends QH {
  constructor(t) {
    super(), aq(this, t, lq, cq, oq, {
      gradio: 1,
      label: 10,
      elem_id: 2,
      elem_classes: 3,
      visible: 4,
      value: 0,
      placeholder: 11,
      show_label: 12,
      scale: 5,
      min_width: 6,
      loading_status: 7,
      value_is_output: 13,
      interactive: 14,
      rtl: 15,
      height: 8,
      structures: 9
    });
  }
  get gradio() {
    return this.$$.ctx[1];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), ri();
  }
  get label() {
    return this.$$.ctx[10];
  }
  set label(t) {
    this.$$set({ label: t }), ri();
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(t) {
    this.$$set({ elem_id: t }), ri();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(t) {
    this.$$set({ elem_classes: t }), ri();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(t) {
    this.$$set({ visible: t }), ri();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(t) {
    this.$$set({ value: t }), ri();
  }
  get placeholder() {
    return this.$$.ctx[11];
  }
  set placeholder(t) {
    this.$$set({ placeholder: t }), ri();
  }
  get show_label() {
    return this.$$.ctx[12];
  }
  set show_label(t) {
    this.$$set({ show_label: t }), ri();
  }
  get scale() {
    return this.$$.ctx[5];
  }
  set scale(t) {
    this.$$set({ scale: t }), ri();
  }
  get min_width() {
    return this.$$.ctx[6];
  }
  set min_width(t) {
    this.$$set({ min_width: t }), ri();
  }
  get loading_status() {
    return this.$$.ctx[7];
  }
  set loading_status(t) {
    this.$$set({ loading_status: t }), ri();
  }
  get value_is_output() {
    return this.$$.ctx[13];
  }
  set value_is_output(t) {
    this.$$set({ value_is_output: t }), ri();
  }
  get interactive() {
    return this.$$.ctx[14];
  }
  set interactive(t) {
    this.$$set({ interactive: t }), ri();
  }
  get rtl() {
    return this.$$.ctx[15];
  }
  set rtl(t) {
    this.$$set({ rtl: t }), ri();
  }
  get height() {
    return this.$$.ctx[8];
  }
  set height(t) {
    this.$$set({ height: t }), ri();
  }
  get structures() {
    return this.$$.ctx[9];
  }
  set structures(t) {
    this.$$set({ structures: t }), ri();
  }
}
export {
  dq as default
};
